Revert "Re-apply with fixes: 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:
Neil Lalonde
2013-12-18 14:47:22 -05:00
parent 58e5d532c5
commit 1f0a59584b
9 changed files with 148 additions and 118 deletions

View File

@@ -19,6 +19,10 @@ module ApplicationHelper
end
end
def html_classes
"#{mobile_view? ? 'mobile-view' : 'desktop-view'} #{mobile_device? ? 'mobile-device' : 'not-mobile-device'}"
end
def escape_unicode(javascript)
if javascript
javascript = javascript.dup.force_encoding("utf-8")
@@ -111,8 +115,18 @@ module ApplicationHelper
"#{Discourse::base_uri}/login"
end
def stylesheet_filenames(target=:desktop)
[asset_path("#{target}.css"), customization_disabled? ? nil : SiteCustomization.custom_stylesheet_path(session[:preview_style], target)].compact
def mobile_view?
return false unless SiteSetting.enable_mobile_theme
if session[:mobile_view]
session[:mobile_view] == '1'
else
mobile_device?
end
end
def mobile_device?
# TODO: this is dumb. user agent matching is a doomed approach. a better solution is coming.
request.user_agent =~ /Mobile|webOS|Nexus 7/ and !(request.user_agent =~ /iPad/)
end
def customization_disabled?