Skip to content

Commit

Permalink
Merge branch 'develop' into helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Haikal Hussein authored and Haikal Hussein committed Feb 28, 2011
2 parents dd4878b + 1d5ce0d commit ea1b1fe
Show file tree
Hide file tree
Showing 25 changed files with 2,254 additions and 323 deletions.
108 changes: 108 additions & 0 deletions lib/jqmobile_helpers/buttons_helper.rb
Expand Up @@ -29,6 +29,10 @@ def button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -54,6 +58,10 @@ def delete_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -79,6 +87,10 @@ def left_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -104,6 +116,10 @@ def right_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -129,6 +145,10 @@ def up_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -154,6 +174,10 @@ def down_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -179,6 +203,10 @@ def plus_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -204,6 +232,10 @@ def minus_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -229,6 +261,10 @@ def check_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -254,6 +290,10 @@ def gear_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -279,6 +319,10 @@ def refresh_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -304,6 +348,10 @@ def forward_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -329,6 +377,10 @@ def back_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -354,6 +406,10 @@ def grid_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -379,6 +435,10 @@ def star_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -404,6 +464,10 @@ def alert_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -429,6 +493,10 @@ def info_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -454,6 +522,10 @@ def home_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand All @@ -479,6 +551,10 @@ def search_button_link(name, link, options = {})
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']}) default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end end


if html_options.has_key?('data-inline')
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
end

content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


Expand Down Expand Up @@ -506,6 +582,38 @@ def back_split_button(name, link, options ={} )
content_tag(:a, name, {:href => link}.merge(default_options)) content_tag(:a, name, {:href => link}.merge(default_options))
end end


# Grouped Button
#
# ==== Examples
# group_button("
# #{home_button_link('home', buttons_path, 'data-iconpos' => 'right')}
# #{refresh_button_link 'refresh', buttons_path}
# ")
# # => <div data-role="controlgroup">
# <a data-icon="home" data-iconpos="right" data-role="button" href="/buttons">home</a>
# <a data-icon="refresh" data-role="button" href="/buttons">refresh</a>
# </div>
#
# group_button("
# #{home_button_link('home', buttons_path, 'data-iconpos' => 'right')}
# #{refresh_button_link 'refresh', buttons_path}, {'data-type' => 'horizontal'}
# ")
# # => <div data-role="controlgroup" data-type="horizontal" >
# <a data-icon="home" data-iconpos="right" data-role="button" href="/buttons">home</a>
# <a data-icon="refresh" data-role="button" href="/buttons">refresh</a>
# </div>
def group_button(content, options = {})

html_options = options.stringify_keys!
default_options = {'data-role'=> "controlgroup"}

if html_options.has_key?('data-type')
default_options = default_options.merge({'data-type' => html_options['data-type']})
end

content_tag(:div, content, default_options, false)
end

end end
end end


77 changes: 70 additions & 7 deletions lib/jqmobile_helpers/toolbars_helper.rb
Expand Up @@ -2,14 +2,15 @@ module JqmobileHelpers
# = JqmobileHelpers List View Helpers # = JqmobileHelpers List View Helpers
# Provides a set of methods for making toolbars views # Provides a set of methods for making toolbars views
# for jquery-mobile markup # for jquery-mobile markup
module ToolbarsHelper #:nodoc: module ToolbarsHelper




# Header Bar Title # Header Bar Title
# #
# === Examples # === Examples
# #
# <h1>Page Title</h1> # => <%= header_toolbar_title('Put Title Here') %>
# => <h1>Page Title</h1>
# #


def header_toolbar_title(title) def header_toolbar_title(title)
Expand All @@ -20,14 +21,14 @@ def header_toolbar_title(title)
# #
# ---Options --- # ---Options ---
# => '- data-direction = "reverse" ## reverse transition without actually going back in history # => '- data-direction = "reverse" ## reverse transition without actually going back in history
# => - data-icon [delete,check,home,gear] # => - data-icon [delete,check,home,gear]
# => - data-iconpos [text,notext] ## if use notext, link only show icon # => - data-iconpos [text,notext] ## if use notext, link only show icon
# => - class # => - class
# => - data-theme ## default 'a' # => - data-theme ## default 'a'
# #
# === Examples # === Examples
# #
# <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a> # => <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>


def header_toolbar_link(link_name,path,options = {}) def header_toolbar_link(link_name,path,options = {})
html_options = options.stringify_keys! html_options = options.stringify_keys!
Expand All @@ -48,5 +49,67 @@ def header_toolbar_link(link_name,path,options = {})
content_tag(:a, "#{link_name}",default_options) content_tag(:a, "#{link_name}",default_options)
end end


# navigation bar container
#
# A navbar is coded as an unordered list of links wrapped in a container element that has the data-role="navbar" attribute
# To set one of links to the active (selected) state, add class="ui-btn-active" to the anchor
# The navbar maxes out with 5 items, each 1/5 the width of the browser window
# Navbar can be in the header/footer.just add the navbar container inside header/footer container
#
# *** Options ***
# => data-role = 'navbar' (to specify the contanier as navbar)
#
# Example :
# <div data-role="navbar">
# <ul>
# <li><a href="a.html" class="ui-btn-active">One</a></li>
# <li><a href="b.html">Two</a></li>
# </ul>
# </div><!-- /navbar -->
# Usage :
# navbar_link(collection) ** this method is to create the link inside the navbar container
# <%= navbar_bar([navbar_link('saya',root_path,{'data-icon' => 'gear'}),navbar_link('saya',root_path,{'data-icon' => 'gear'}),navbar_link('dia',toolbars_path,{'data-icon' => 'home'}), navbar_link('kami',toolbars_path,{'data-icon' => 'plus'})]) %>


def navbar_bar(collection)
listing = collection.map {|item| content_tag("li",item)}
content_tag("div",content_tag(:ul, listing.join.html_safe), {'data-role' => 'navbar'})
end

# link inside the navbar
# *** Options ***
# => data-icon (to add icon to navbar items)
# => data-iconpos="top" (to stack icon above the navbar items label)
# => data-theme (set theming for navbar)
# Example
# # => <a href="a.html" class="ui-btn-active" 'data-icon'="gear">One</a>
# Usage :
# => navbar_link('saya',root_path,{'data-icon' => 'gear'})


def navbar_link(name,link, options ={})
html_options = options.stringify_keys!
default_options = {}

if html_options.has_key?('data-icon')
default_options = default_options.merge({'data-icon' => html_options['data-icon']})
end

if html_options.has_key?('data-iconpos')
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
end

if html_options.has_key?('data-theme')
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
end

if html_options.has_key?('class')
default_options = default_options.merge({'class' => html_options['class']})
end

content_tag('a',name, {'href' => "#{link}"}.merge(default_options))
end


end end
end end
4 changes: 4 additions & 0 deletions nbproject/private/private.xml
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
</project-private>
16 changes: 10 additions & 6 deletions rdoc/JqmobileHelpers.html
Expand Up @@ -38,18 +38,18 @@ <h3 class="section-header">In Files</h3>
<div class="section-body"> <div class="section-body">
<ul> <ul>


<li><a href="./lib/jqmobile_helpers/buttons_helper_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
class="thickbox" title="lib/jqmobile_helpers/buttons_helper.rb">lib/jqmobile_helpers/buttons_helper.rb</a></li>

<li><a href="./lib/jqmobile_helpers/list_views_helper_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
class="thickbox" title="lib/jqmobile_helpers/list_views_helper.rb">lib/jqmobile_helpers/list_views_helper.rb</a></li>

<li><a href="./lib/jqmobile_helpers/railtie_rb.html?TB_iframe=true&amp;height=550&amp;width=785" <li><a href="./lib/jqmobile_helpers/railtie_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
class="thickbox" title="lib/jqmobile_helpers/railtie.rb">lib/jqmobile_helpers/railtie.rb</a></li> class="thickbox" title="lib/jqmobile_helpers/railtie.rb">lib/jqmobile_helpers/railtie.rb</a></li>


<li><a href="./lib/jqmobile_helpers/toolbars_helper_rb.html?TB_iframe=true&amp;height=550&amp;width=785" <li><a href="./lib/jqmobile_helpers/toolbars_helper_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
class="thickbox" title="lib/jqmobile_helpers/toolbars_helper.rb">lib/jqmobile_helpers/toolbars_helper.rb</a></li> class="thickbox" title="lib/jqmobile_helpers/toolbars_helper.rb">lib/jqmobile_helpers/toolbars_helper.rb</a></li>


<li><a href="./lib/jqmobile_helpers/list_views_helper_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
class="thickbox" title="lib/jqmobile_helpers/list_views_helper.rb">lib/jqmobile_helpers/list_views_helper.rb</a></li>

<li><a href="./lib/jqmobile_helpers/buttons_helper_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
class="thickbox" title="lib/jqmobile_helpers/buttons_helper.rb">lib/jqmobile_helpers/buttons_helper.rb</a></li>

<li><a href="./lib/jqmobile_helpers_rb.html?TB_iframe=true&amp;height=550&amp;width=785" <li><a href="./lib/jqmobile_helpers_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
class="thickbox" title="lib/jqmobile_helpers.rb">lib/jqmobile_helpers.rb</a></li> class="thickbox" title="lib/jqmobile_helpers.rb">lib/jqmobile_helpers.rb</a></li>


Expand Down Expand Up @@ -120,10 +120,14 @@ <h3 class="section-header">Class Index


<li><a href="./JqmobileHelpers.html">JqmobileHelpers</a></li> <li><a href="./JqmobileHelpers.html">JqmobileHelpers</a></li>


<li><a href="./JqmobileHelpers/ButtonsHelper.html">JqmobileHelpers::ButtonsHelper</a></li>

<li><a href="./JqmobileHelpers/ListViewsHelper.html">JqmobileHelpers::ListViewsHelper</a></li> <li><a href="./JqmobileHelpers/ListViewsHelper.html">JqmobileHelpers::ListViewsHelper</a></li>


<li><a href="./JqmobileHelpers/Railtie.html">JqmobileHelpers::Railtie</a></li> <li><a href="./JqmobileHelpers/Railtie.html">JqmobileHelpers::Railtie</a></li>


<li><a href="./JqmobileHelpers/ToolbarsHelper.html">JqmobileHelpers::ToolbarsHelper</a></li>

</ul> </ul>
<div id="no-class-search-results" style="display: none;">No matching classes.</div> <div id="no-class-search-results" style="display: none;">No matching classes.</div>
</div> </div>
Expand Down

0 comments on commit ea1b1fe

Please sign in to comment.