From c8e8d46478b40d7eb0fec56997996054779c662d Mon Sep 17 00:00:00 2001 From: "Brendan G. Lim" Date: Fri, 3 Apr 2009 00:20:45 -0400 Subject: [PATCH] fixing up xhtml mobile doctype helper --- lib/mobile_fu_helper.rb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/mobile_fu_helper.rb b/lib/mobile_fu_helper.rb index 9f804c1..6109aa2 100644 --- a/lib/mobile_fu_helper.rb +++ b/lib/mobile_fu_helper.rb @@ -1,9 +1,24 @@ module MobileFuHelper - def mobile_xhtml_doctype - "" + 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 = "\n" + doc_type += "" + 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 \ No newline at end of file +end + +ActionView::Base.send(:include, MobileFuHelper) \ No newline at end of file