mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 04:01:29 -05:00
BUGFIX: Don't depend on localStorage for Discourse to function
This commit is contained in:
parent
0ffa98904f
commit
00469e976d
1 changed files with 15 additions and 6 deletions
|
@ -13,17 +13,26 @@ Discourse.Mobile = {
|
|||
this.isMobileDevice = $html.hasClass('mobile-device');
|
||||
this.mobileView = $html.hasClass('mobile-view');
|
||||
|
||||
if (localStorage && localStorage.mobileView) {
|
||||
var savedValue = (localStorage.mobileView === 'true');
|
||||
if (savedValue !== this.mobileView) {
|
||||
this.reloadPage(savedValue);
|
||||
try{
|
||||
if (localStorage && localStorage.mobileView) {
|
||||
var savedValue = (localStorage.mobileView === 'true');
|
||||
if (savedValue !== this.mobileView) {
|
||||
this.reloadPage(savedValue);
|
||||
}
|
||||
}
|
||||
} catch(err) {
|
||||
// localStorage may be disabled, just skip this
|
||||
// you get security errors if it is disabled
|
||||
}
|
||||
},
|
||||
|
||||
toggleMobileView: function() {
|
||||
if (localStorage) {
|
||||
localStorage.mobileView = !this.mobileView;
|
||||
try{
|
||||
if (localStorage) {
|
||||
localStorage.mobileView = !this.mobileView;
|
||||
}
|
||||
} catch(err) {
|
||||
// localStorage may be disabled, skip
|
||||
}
|
||||
this.reloadPage(!this.mobileView);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue