Skip to content

Commit

Permalink
Adding in iPad to supported mobile device list
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanlim committed Mar 29, 2010
1 parent 79c5535 commit 8aa797b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/mobile_fu.rb
Expand Up @@ -10,7 +10,7 @@ module MobileFu
'samsung|sanyo|sharp|telit|tsm|mobile|mini|windows ce|smartphone|' +
'240x320|320x320|mobileexplorer|j2me|sgh|portable|sprint|vodafone|' +
'docomo|kddi|softbank|pdxgw|j-phone|astel|minimo|plucker|netfront|' +
'xiino|mot-v|mot-e|portalmmm|sagem|sie-s|sie-m|android|ipod'
'xiino|mot-v|mot-e|portalmmm|sagem|sie-s|sie-m|android|ipod|ipad'

def self.included(base)
base.extend(ClassMethods)
Expand Down
2 changes: 1 addition & 1 deletion lib/mobile_fu_helper.rb
Expand Up @@ -17,7 +17,7 @@ def mobile_xhtml_doctype(type = :mobile, version = '1.0')
end

def js_enabled_mobile_device?
is_device?('iphone') || is_device?('mobileexplorer') || is_device?('android')
is_device?('iphone') || is_device?('ipod') || is_device?('ipad') || is_device?('mobileexplorer') || is_device?('android')
end
end

Expand Down
2 changes: 2 additions & 0 deletions lib/mobilized_styles.rb
Expand Up @@ -37,6 +37,8 @@ def user_agent_device_name
'blackberry'
elsif ua.index('iphone') || ua.index('ipod')
'iphone'
elsif ua.index('ipad')
'ipad'
elsif ua.index('android')
'android'
elsif ua.index('nokia')
Expand Down

3 comments on commit 8aa797b

@kineticac
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have this commit in our code, but iPad is already coming in as mobile. I'd like to exclude it as a mobile device, since the site would probably look fine without the mobile stylesheet. This is the info:
Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10

How do I exclude it as a mobile device?

@brendanlim
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at lib/mobile_fu.rb you just need to remove 'ipad' and any instance of 'ipad' in mobilized_styles.rb and mobile_fu_helper.rb

@tsmango
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kineticac I just wanted to let you know that I removed "ipad" from mobile_fu.rb, mobilized_styles.rb and mobile_fu_helper.rb and the iPad was still being served up mobile views. In addition to those changes, I had to modify is_mobile_device? to the following:

def is_mobile_device?
  !request.user_agent.to_s.downcase.include?('ipad') and (request.user_agent.to_s.downcase =~ Regexp.new(ActionController::MobileFu::MOBILE_USER_AGENTS))
end

I know, this is hacky but it had to be done.

Please sign in to comment.