Revert "Got rid of buggy yepnope spaghetti, however mobile detection really should be driven from the server."
This commit is contained in:
parent
c0e1ef75f6
commit
58e5d532c5
|
@ -115,12 +115,6 @@ module ApplicationHelper
|
||||||
[asset_path("#{target}.css"), customization_disabled? ? nil : SiteCustomization.custom_stylesheet_path(session[:preview_style], target)].compact
|
[asset_path("#{target}.css"), customization_disabled? ? nil : SiteCustomization.custom_stylesheet_path(session[:preview_style], target)].compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def stylesheet_links(target=:desktop)
|
|
||||||
stylesheet_filenames(target).map do |f|
|
|
||||||
"<link rel=\"stylesheet\" href=\"#{f}\" type=\"text/css\" media=\"screen\">"
|
|
||||||
end.join("\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
def customization_disabled?
|
def customization_disabled?
|
||||||
controller.class.name.split("::").first == "Admin" || session[:disable_customization]
|
controller.class.name.split("::").first == "Admin" || session[:disable_customization]
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,16 +2,32 @@
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
(function() {
|
(function() {
|
||||||
var h = document.getElementsByTagName('html')[0];
|
var h = document.getElementsByTagName('html')[0],
|
||||||
window.isMobileView = (localStorage && localStorage.mobileView) ? (localStorage.mobileView === 'true') :
|
isMobileView = (localStorage && localStorage.mobileView) ? (localStorage.mobileView === 'true') :
|
||||||
Modernizr.mq("only screen and (max-width: 480px), only screen and (max-device-width: 480px)");
|
Modernizr.mq("only screen and (max-width: 480px), only screen and (max-device-width: 480px)");
|
||||||
|
|
||||||
h.className += (isMobileView ? ' mobile-view' : ' desktop-view');
|
h.className += (isMobileView ? ' mobile-view' : ' desktop-view');
|
||||||
if(isMobileView) {
|
Modernizr.load({
|
||||||
document.write(<%= stylesheet_links(:mobile).inspect.html_safe %>);
|
test: isMobileView,
|
||||||
} else {
|
yep: <%= stylesheet_filenames(:mobile).inspect.html_safe %>,
|
||||||
document.write(<%= stylesheet_links(:desktop).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>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -31,19 +31,14 @@
|
||||||
<body class="css-loading">
|
<body class="css-loading">
|
||||||
<!--[if IE 9]><script type="text/javascript">ie = "new";</script><![endif]-->
|
<!--[if IE 9]><script type="text/javascript">ie = "new";</script><![endif]-->
|
||||||
|
|
||||||
<div id="js-app">
|
<div id="js-app" style="display: none;">
|
||||||
<%- unless customization_disabled? %>
|
<%- unless customization_disabled? %>
|
||||||
<script>
|
<div id='custom-desktop-header' style='display: none;'>
|
||||||
if(window.isMobile){
|
<%= SiteCustomization.custom_header(session[:preview_style], :desktop) %>
|
||||||
document.write("<div id='custom-mobile-header'>");
|
</div>
|
||||||
document.write(<%= SiteCustomization.custom_header(session[:preview_style], :mobile).inspect.gsub("<", '\x3c').html_safe %>);
|
<div id='custom-mobile-header' style='display: none;'>
|
||||||
document.write("</div>");
|
<%= SiteCustomization.custom_header(session[:preview_style], :mobile) %>
|
||||||
} else {
|
</div>
|
||||||
document.write("<div id='custom-desktop-header'>");
|
|
||||||
document.write(<%= SiteCustomization.custom_header(session[:preview_style], :desktop).inspect.gsub("<", '\x3c').html_safe %>);
|
|
||||||
document.write("</div>");
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<%- end %>
|
<%- end %>
|
||||||
|
|
||||||
<section id='main'>
|
<section id='main'>
|
||||||
|
|
Loading…
Reference in New Issue