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-11 11:17:55 -05:00
parent ed3d3ae1e1
commit 5171a23a9c
9 changed files with 118 additions and 148 deletions

View File

@ -19,10 +19,6 @@ 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")
@ -115,18 +111,8 @@ module ApplicationHelper
"#{Discourse::base_uri}/login"
end
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/)
def stylesheet_filenames(target=:desktop)
[asset_path("#{target}.css"), customization_disabled? ? nil : SiteCustomization.custom_stylesheet_path(session[:preview_style], target)].compact
end
def customization_disabled?