forked from discourse/discourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable mobile view. Use local storage to remember whether you chose m…
…obile or desktop view. Mobile device detection needs to be replaced with a better solution.
- Loading branch information
Showing
6 changed files
with
63 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
A class that is responsible for logic related to mobile devices. | ||
@class Mobile | ||
@namespace Discourse | ||
@module Discourse | ||
**/ | ||
Discourse.Mobile = { | ||
|
||
isMobileDevice: false, | ||
mobileView: false, | ||
|
||
init: function() { | ||
var $html = $('html'); | ||
this.isMobileDevice = $html.hasClass('mobile-device'); | ||
this.mobileView = $html.hasClass('mobile-view'); | ||
|
||
if (localStorage && localStorage.mobileView) { | ||
var savedValue = (localStorage.mobileView === 'true' ? true : false); | ||
if (savedValue !== this.mobileView) { | ||
this.reloadPage(savedValue); | ||
} | ||
} | ||
}, | ||
|
||
toggleMobileView: function() { | ||
if (localStorage) { | ||
localStorage.mobileView = !this.mobileView; | ||
} | ||
this.reloadPage(!this.mobileView); | ||
}, | ||
|
||
reloadPage: function(mobile) { | ||
window.location.assign(window.location.pathname + '?mobile_view=' + (mobile ? '1' : '0')); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters