diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..9524ba0 Binary files /dev/null and b/.DS_Store differ diff --git a/lib/.DS_Store b/lib/.DS_Store new file mode 100644 index 0000000..275fe50 Binary files /dev/null and b/lib/.DS_Store differ diff --git a/lib/mobile-fu.rb b/lib/mobile-fu.rb index 0849c57..6d25917 100644 --- a/lib/mobile-fu.rb +++ b/lib/mobile-fu.rb @@ -31,6 +31,15 @@ class Railtie < Rails::Railtie module ActionController module MobileFu + # These are various strings that can be found in mobile devices. Please feel free + # to add on to this list. + MOBILE_USER_AGENTS = 'palm|blackberry|nokia|phone|midp|mobi|symbian|chtml|ericsson|minimo|' + + 'audiovox|motorola|samsung|telit|upg1|windows ce|ucweb|astel|plucker|' + + 'x320|x240|j2me|sgh|portable|sprint|docomo|kddi|softbank|android|mmp|' + + 'pdxgw|netfront|xiino|vodafone|portalmmm|sagem|mot-|sie-|ipod|up\\.b|' + + 'webos|amoi|novarra|cdm|alcatel|pocket|ipad|iphone|mobileexplorer|' + + 'mobile' + # These are various strings that can be found in tablet devices. Please feel free # to add on to this list. TABLET_USER_AGENTS = 'ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle' @@ -107,20 +116,14 @@ def force_tablet_format end # Determines the request format based on whether the device is mobile or if - # the user has opted to use either the 'Standard' view or 'Mobile' view. + # the user has opted to use either the 'Standard' view or 'Mobile' view or + # 'Tablet' view. def set_mobile_format if !mobile_exempt? && is_mobile_device? && !request.xhr? request.format = session[:mobile_view] == false ? :html : :mobile session[:mobile_view] = true if session[:mobile_view].nil? - end - end - - # Determines the request format based on whether the device is tablet or if - # the user has opted to use either the 'Standard' view or 'Tablet' view. - - def set_tablet_format - if !mobile_exempt? && is_tablet_device? && !request.xhr? + elsif !mobile_exempt? && is_tablet_device? && !request.xhr? request.format = session[:tablet_view] == false ? :html : :tablet session[:tablet_view] = true if session[:tablet_view].nil? end diff --git a/lib/mobile-fu/.DS_Store b/lib/mobile-fu/.DS_Store new file mode 100644 index 0000000..99e4211 Binary files /dev/null and b/lib/mobile-fu/.DS_Store differ