Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing up xhtml mobile doctype helper
- Loading branch information
Brendan G. Lim
committed
Apr 3, 2009
1 parent
086ffa4
commit c8e8d46
Showing
1 changed file
with
18 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
module MobileFuHelper | ||
def mobile_xhtml_doctype | ||
"<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">" | ||
ACCEPTABLE_TYPES = [:mobile, :basic] | ||
|
||
def mobile_xhtml_doctype(type = :mobile, version = '1.0') | ||
raise Exception.new("MobileFu: XHTML DOCTYPE type must either be ':mobile' or ':basic'") unless ACCEPTABLE_TYPES.include?(type) | ||
raise Exception.new("MobileFu: XHTML DOCTYPE version must be in the format of '1.0' or '1.1', etc.") unless version.include?('.') | ||
|
||
doc_type = "<?xml version=\"1.0\" charset=\"UTF-8\" ?>\n" | ||
doc_type += "<!DOCTYPE html PUBLIC " | ||
doc_type += case type | ||
when :mobile | ||
"\"-//WAPFORUM//DTD XHTML Mobile #{version}//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile#{version.gsub('.','')}.dtd\">" | ||
when :basic | ||
"\"-//W3C//DTD XHTML Basic #{version}//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic#{version.gsub('.','')}.dtd\">" | ||
end | ||
doc_type | ||
end | ||
|
||
def js_enabled_mobile_device? | ||
is_device?('iphone') || is_device?('mobileexplorer') || is_device?('android') | ||
end | ||
end | ||
end | ||
|
||
ActionView::Base.send(:include, MobileFuHelper) |