mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Revert "Stop using user agent to detect mobile devices. Use a media query and yepnope to load the appropriate css and customizations."
This commit is contained in:
@@ -1,42 +1,15 @@
|
||||
<%- unless SiteCustomization.override_default_style(session[:preview_style]) %>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var h = document.getElementsByTagName('html')[0],
|
||||
isMobileView = (localStorage && localStorage.mobileView) ? (localStorage.mobileView === 'true') :
|
||||
Modernizr.mq("only screen and (max-width: 480px), only screen and (max-device-width: 480px)");
|
||||
|
||||
h.className += (isMobileView ? ' mobile-view' : ' desktop-view');
|
||||
Modernizr.load({
|
||||
test: isMobileView,
|
||||
yep: <%= stylesheet_filenames(:mobile).inspect.html_safe %>,
|
||||
nope: <%= stylesheet_filenames(:desktop).inspect.html_safe %>,
|
||||
complete: function() {
|
||||
// CSS file(s) have loaded.
|
||||
$(function() {
|
||||
setTimeout(function() {
|
||||
// Use setTimeout to make this happen in the next event loop.
|
||||
// Trying to avoid a FOUC (flash of unstyled content).
|
||||
if (isMobileView) {
|
||||
$('#custom-mobile-header').show();
|
||||
} else {
|
||||
$('#custom-desktop-header').show();
|
||||
}
|
||||
$('#js-app').attr('style', ''); // Show everything.
|
||||
$(window).trigger('scroll.discourse-dock'); // Calc header div positions now that they're visible.
|
||||
}, 1);
|
||||
});
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
<% if mobile_view? %>
|
||||
<%= stylesheet_link_tag "mobile" %>
|
||||
<% else %>
|
||||
<%= stylesheet_link_tag "desktop" %>
|
||||
<% end %>
|
||||
<%- end %>
|
||||
|
||||
<noscript>
|
||||
<%= stylesheet_link_tag "desktop" %>
|
||||
</noscript>
|
||||
|
||||
<%- if staff? %>
|
||||
<%= stylesheet_link_tag "admin"%>
|
||||
<%-end%>
|
||||
|
||||
<%- unless customization_disabled? %>
|
||||
<%= SiteCustomization.custom_stylesheet(session[:preview_style], mobile_view? ? :mobile : :desktop) %>
|
||||
<%- end %>
|
||||
|
||||
Reference in New Issue
Block a user