Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added wrappers for iPhone service links (email, tel, google maps) as …

…helper methods
  • Loading branch information...
commit 5a160a8761a2338b79c4dd6590c9e121c6a14ff6 1 parent c892908
Roland Oth smtm authored
Showing with 30 additions and 3 deletions.
  1. +18 −1 README
  2. +12 −2 lib/iui_helper.rb
19 README
View
@@ -108,7 +108,24 @@ panel(&block)
dialog(&block)
Wrapper for an iUI div class dialog
-
+
+servicelink_tel(telno)
+ Creates a service link when a correctly formatted telephone number string is given (telno).
+ Triggres the iPhone Phone App so that a call is initiated.
+
+servicelink_email(email)
+ Creates a service link when to the mail application. A mailto type link is created
+ Triggres the iPhone Email App.
+
+servicebutton_map(gadr,caption)
+ Creates a service button to the maps application. The gadr parameter is a correctly
+ formatted google adress string.
+ A good place to implement the gadr method is in your people/adress model. Like so:
+ def gadr
+ "#{street},#{zip} #{city},#{country}"
+ end
+ caption is the text that goes into the button
+
observe_orientation_change(url_options = {})
Place in the layout header file, the url_options is any Rails URL format.
The URL gets a callback when the iPhone's orientation changes. The
14 lib/iui_helper.rb
View
@@ -3,7 +3,7 @@ module IuiHelper
def viewport_tag(options = {})
content = ""
content += "width = device-width, user-scalable=no" if options[:device_width]
- content_tag(:meta, :name => "viewport", :content => content)
+ tag(:meta, :name => "viewport", :content => content)
end
def include_iui_files
@@ -114,6 +114,16 @@ def dialog(&block)
concat(div, block.binding)
end
+ def servicelink_tel(telno)
+ content_tag("a",telno,:class=>"ciuServiceLink",:target => "_self",:href => "tel:#{telno}" ,:onclick => "return(navigator.userAgent.indexOf('iPhone') != -1)")
+ end
+ def servicelink_email(email)
+ content_tag("a",email,:class=>"ciuServiceLink",:target => "_self",:href => "mailto:#{email}" ,:onclick => "return(navigator.userAgent.indexOf('iPhone') != -1)")
+ end
+ def servicebutton_map(gadr,caption)
+ content_tag("a",caption,:class=>"ciuServiceButton",:target => "_self",:href => "http://maps.google.com/maps?q=#{gadr}" ,:onclick => "return(navigator.userAgent.indexOf('iPhone') != -1)")
+ end
+
def observe_orientation_change(url_options = {})
remote = remote_function :url => url_options,
:with => "'position=' + String(window.orientation)"
@@ -127,4 +137,4 @@ def register_orientation_change
end
-ActionView::Base.send(:include, IuiHelper)
+ActionView::Base.send(:include, IuiHelper)
Please sign in to comment.
Something went wrong with that request. Please try again.