jqmobile_helpers 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +6 -0
- data/Rakefile +29 -0
- data/lib/jqmobile_helpers.rb +1 -0
- data/lib/jqmobile_helpers/action_view_extensions/form_helper.rb +54 -0
- data/lib/jqmobile_helpers/buttons_helper.rb +639 -0
- data/lib/jqmobile_helpers/form_builder.rb +301 -0
- data/lib/jqmobile_helpers/list_views_helper.rb +326 -0
- data/lib/jqmobile_helpers/railtie.rb +23 -0
- data/lib/jqmobile_helpers/toolbars_helper.rb +115 -0
- data/rdoc/JqmobileHelpers.html +185 -0
- data/rdoc/JqmobileHelpers/ActionViewExtensions.html +160 -0
- data/rdoc/JqmobileHelpers/ActionViewExtensions/FormHelper.html +231 -0
- data/rdoc/JqmobileHelpers/ButtonsHelper.html +1502 -0
- data/rdoc/JqmobileHelpers/FormBuilder.html +816 -0
- data/rdoc/JqmobileHelpers/ListViewsHelper.html +952 -0
- data/rdoc/JqmobileHelpers/Railtie.html +177 -0
- data/rdoc/JqmobileHelpers/ToolbarsHelper.html +416 -0
- data/rdoc/README_rdoc.html +109 -0
- data/rdoc/created.rid +9 -0
- data/rdoc/index.html +180 -0
- data/rdoc/js/darkfish.js +116 -0
- data/rdoc/js/jquery.js +32 -0
- data/rdoc/js/quicksearch.js +114 -0
- data/rdoc/js/thickbox-compressed.js +10 -0
- data/rdoc/lib/jqmobile_helpers/action_view_extensions/form_helper_rb.html +52 -0
- data/rdoc/lib/jqmobile_helpers/buttons_helper_rb.html +52 -0
- data/rdoc/lib/jqmobile_helpers/form_builder_rb.html +52 -0
- data/rdoc/lib/jqmobile_helpers/list_views_helper_rb.html +52 -0
- data/rdoc/lib/jqmobile_helpers/railtie_rb.html +62 -0
- data/rdoc/lib/jqmobile_helpers/toolbars_helper_rb.html +52 -0
- data/rdoc/lib/jqmobile_helpers_rb.html +54 -0
- data/rdoc/rdoc.css +706 -0
- data/test/buttons_helper_test.rb +112 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/buttons_controller.rb +9 -0
- data/test/dummy/app/controllers/forms_controller.rb +71 -0
- data/test/dummy/app/controllers/posts_controller.rb +83 -0
- data/test/dummy/app/controllers/toolbars_controller.rb +16 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/posts_helper.rb +2 -0
- data/test/dummy/app/helpers/toolbars_helper.rb +2 -0
- data/test/dummy/app/models/post.rb +2 -0
- data/test/dummy/app/models/toolbar.rb +2 -0
- data/test/dummy/app/views/buttons/index.html.erb +168 -0
- data/test/dummy/app/views/forms/_form.html.erb +20 -0
- data/test/dummy/app/views/forms/edit.html.erb +6 -0
- data/test/dummy/app/views/forms/index.html.erb +7 -0
- data/test/dummy/app/views/forms/new.html.erb +5 -0
- data/test/dummy/app/views/forms/show.html.erb +24 -0
- data/test/dummy/app/views/layouts/application.html.erb +49 -0
- data/test/dummy/app/views/posts/_form.html.erb +29 -0
- data/test/dummy/app/views/posts/edit.html.erb +6 -0
- data/test/dummy/app/views/posts/index.html.erb +128 -0
- data/test/dummy/app/views/posts/new.html.erb +5 -0
- data/test/dummy/app/views/posts/show.html.erb +24 -0
- data/test/dummy/app/views/toolbars/index.html.erb +25 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +45 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +22 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +26 -0
- data/test/dummy/config/environments/production.rb +49 -0
- data/test/dummy/config/environments/test.rb +35 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +69 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20110218095442_create_posts.rb +15 -0
- data/test/dummy/db/migrate/20110223031713_create_toolbars.rb +12 -0
- data/test/dummy/db/schema.rb +29 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +7446 -0
- data/test/dummy/log/production.log +0 -0
- data/test/dummy/log/server.log +0 -0
- data/test/dummy/log/test.log +2278 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/images/ajax-loader.png +0 -0
- data/test/dummy/public/images/form-check-off.png +0 -0
- data/test/dummy/public/images/form-check-on.png +0 -0
- data/test/dummy/public/images/form-radio-off.png +0 -0
- data/test/dummy/public/images/form-radio-on.png +0 -0
- data/test/dummy/public/images/icon-search-black.png +0 -0
- data/test/dummy/public/images/icons-18-black.png +0 -0
- data/test/dummy/public/images/icons-18-white.png +0 -0
- data/test/dummy/public/images/icons-36-black.png +0 -0
- data/test/dummy/public/images/icons-36-white.png +0 -0
- data/test/dummy/public/javascripts/application.js +2 -0
- data/test/dummy/public/javascripts/jquery-1.5.min.js +8176 -0
- data/test/dummy/public/javascripts/jquery-ui-1.8.9.custom.min.js +781 -0
- data/test/dummy/public/javascripts/jquery.mobile-1.0a3.min.js +121 -0
- data/test/dummy/public/javascripts/rails.js +175 -0
- data/test/dummy/public/stylesheets/images/ajax-loader.png +0 -0
- data/test/dummy/public/stylesheets/images/form-check-off.png +0 -0
- data/test/dummy/public/stylesheets/images/form-check-on.png +0 -0
- data/test/dummy/public/stylesheets/images/form-radio-off.png +0 -0
- data/test/dummy/public/stylesheets/images/form-radio-on.png +0 -0
- data/test/dummy/public/stylesheets/images/icon-search-black.png +0 -0
- data/test/dummy/public/stylesheets/images/icons-18-black.png +0 -0
- data/test/dummy/public/stylesheets/images/icons-18-white.png +0 -0
- data/test/dummy/public/stylesheets/images/icons-36-black.png +0 -0
- data/test/dummy/public/stylesheets/images/icons-36-white.png +0 -0
- data/test/dummy/public/stylesheets/jquery-ui-1.8.9.custom.css +573 -0
- data/test/dummy/public/stylesheets/jquery.mobile-1.0a3.min.css +16 -0
- data/test/dummy/public/stylesheets/scaffold.css +56 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/tmp/pids/server.pid +1 -0
- data/test/form_helper_test.rb +13 -0
- data/test/integration/navigation_test.rb +7 -0
- data/test/list_views_helper_test.rb +65 -0
- data/test/support/integration_case.rb +5 -0
- data/test/support/misc_helpers.rb +18 -0
- data/test/support/mock_controller.rb +15 -0
- data/test/support/mock_response.rb +14 -0
- data/test/support/models.rb +135 -0
- data/test/test_helper.rb +92 -0
- data/test/toolbars_helper_test.rb +21 -0
- metadata +182 -0
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "rails", "3.0.3"
|
4
|
+
gem "capybara", ">= 0.4.0"
|
5
|
+
gem "sqlite3-ruby", :require => "sqlite3"
|
6
|
+
|
7
|
+
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
|
8
|
+
# gem 'ruby-debug'
|
9
|
+
# gem 'ruby-debug19'
|
10
|
+
|
11
|
+
group :test do
|
12
|
+
gem "mocha", :require => false
|
13
|
+
end
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 Consoci8 Sdn Bhd
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rake'
|
10
|
+
require 'rake/rdoctask'
|
11
|
+
|
12
|
+
require 'rake/testtask'
|
13
|
+
|
14
|
+
Rake::TestTask.new(:test) do |t|
|
15
|
+
t.libs << 'lib'
|
16
|
+
t.libs << 'test'
|
17
|
+
t.pattern = 'test/**/*_test.rb'
|
18
|
+
t.verbose = false
|
19
|
+
end
|
20
|
+
|
21
|
+
task :default => :test
|
22
|
+
|
23
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
24
|
+
rdoc.rdoc_dir = 'rdoc'
|
25
|
+
rdoc.title = 'JqmobileHelpers'
|
26
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
27
|
+
rdoc.rdoc_files.include('README.rdoc')
|
28
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
29
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'jqmobile_helpers/railtie'
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module JqmobileHelpers
|
2
|
+
module ActionViewExtensions
|
3
|
+
# This module creates simple form wrappers around default form_for and fields_for.
|
4
|
+
#
|
5
|
+
# Example:
|
6
|
+
#
|
7
|
+
# jq_form_for @user do |f|
|
8
|
+
# f.input :name, :required => true, :description => 'Your name please'
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
module FormHelper
|
12
|
+
# based on what is done in formtastic
|
13
|
+
# http://github.com/justinfrench/formtastic/blob/master/lib/formtastic.rb#L1706
|
14
|
+
@@default_field_error_proc = nil
|
15
|
+
|
16
|
+
# Override the default ActiveRecordHelper behaviour of wrapping the input.
|
17
|
+
# This gets taken care of semantically by adding an error class to the wrapper tag
|
18
|
+
# containing the input.
|
19
|
+
#
|
20
|
+
FIELD_ERROR_PROC = proc do |html_tag, instance_tag|
|
21
|
+
html_tag
|
22
|
+
end
|
23
|
+
|
24
|
+
def with_custom_field_error_proc(&block)
|
25
|
+
@@default_field_error_proc = ::ActionView::Base.field_error_proc
|
26
|
+
::ActionView::Base.field_error_proc = FIELD_ERROR_PROC
|
27
|
+
result = yield
|
28
|
+
::ActionView::Base.field_error_proc = @@default_field_error_proc
|
29
|
+
result
|
30
|
+
end
|
31
|
+
|
32
|
+
[:form_for, :fields_for].each do |helper|
|
33
|
+
class_eval <<-METHOD, __FILE__, __LINE__
|
34
|
+
def jq_#{helper}(record_or_name_or_array, *args, &block)
|
35
|
+
options = args.extract_options!
|
36
|
+
options[:builder] ||= JqmobileHelpers::FormBuilder
|
37
|
+
css_class = case record_or_name_or_array
|
38
|
+
when String, Symbol then record_or_name_or_array.to_s
|
39
|
+
when Array then dom_class(record_or_name_or_array.last)
|
40
|
+
else dom_class(record_or_name_or_array)
|
41
|
+
end
|
42
|
+
options[:html] ||= {}
|
43
|
+
options[:html][:class] = "jq_form \#{css_class} \#{options[:html][:class]}".strip
|
44
|
+
|
45
|
+
with_custom_field_error_proc do
|
46
|
+
#{helper}(record_or_name_or_array, *(args << options), &block)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
METHOD
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
ActionView::Base.send :include, JqmobileHelpers::ActionViewExtensions::FormHelper
|
@@ -0,0 +1,639 @@
|
|
1
|
+
module JqmobileHelpers
|
2
|
+
# = JqmobileHelpers Buttons Helper
|
3
|
+
# Provides a set of helper methods for jquery-mobile buttons
|
4
|
+
module ButtonsHelper
|
5
|
+
|
6
|
+
# Button Link
|
7
|
+
#
|
8
|
+
# ==== Examples
|
9
|
+
# button_link 'New Post', new_post_path
|
10
|
+
# # => <a data-role="button" href="http://google.com">New Post</a>
|
11
|
+
#
|
12
|
+
# button_link 'New Post', new_post_path, {'data-theme' => 'c', 'data-icon' => 'plus', 'data-iconpos' => 'right'}
|
13
|
+
# # => <a data-icon="plus" data-iconpos="right" data-role="button" data-theme="c" href="http://google.com">New Post</a>
|
14
|
+
#
|
15
|
+
def button_link(name, link, options = {})
|
16
|
+
|
17
|
+
html_options = options.stringify_keys!
|
18
|
+
default_options = {'data-role' => "button"}
|
19
|
+
|
20
|
+
if html_options.has_key?('data-icon')
|
21
|
+
default_options = default_options.merge({'data-icon' => html_options['data-icon']})
|
22
|
+
end
|
23
|
+
|
24
|
+
if html_options.has_key?('data-theme')
|
25
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
26
|
+
end
|
27
|
+
|
28
|
+
if html_options.has_key?('data-iconpos')
|
29
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
30
|
+
end
|
31
|
+
|
32
|
+
if html_options.has_key?('data-inline')
|
33
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
34
|
+
end
|
35
|
+
|
36
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
37
|
+
end
|
38
|
+
|
39
|
+
# Delete Button Link
|
40
|
+
#
|
41
|
+
# ==== Examples
|
42
|
+
# delete_button_link 'Delete', destroy_path
|
43
|
+
# # => <a data-role="button" data-icon="delete" href="/posts/new">Delete</a>
|
44
|
+
#
|
45
|
+
# delete_button_link 'Delete', destroy_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
46
|
+
# # => <a data-role="button" data-icon="delete" data-iconpos="right" data-theme="c" href="/posts/destroy">Delete</a>
|
47
|
+
#
|
48
|
+
def delete_button_link(name, link, options = {})
|
49
|
+
|
50
|
+
html_options = options.stringify_keys!
|
51
|
+
default_options = {'data-role' => "button", 'data-icon' => "delete"}
|
52
|
+
|
53
|
+
if html_options.has_key?('data-theme')
|
54
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
55
|
+
end
|
56
|
+
|
57
|
+
if html_options.has_key?('data-iconpos')
|
58
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
59
|
+
end
|
60
|
+
|
61
|
+
if html_options.has_key?('data-inline')
|
62
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
63
|
+
end
|
64
|
+
|
65
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
66
|
+
end
|
67
|
+
|
68
|
+
# Left Button Link
|
69
|
+
#
|
70
|
+
# ==== Examples
|
71
|
+
# left_button_link 'Back', new_post_path
|
72
|
+
# # => <a data-role="button" data-icon="arrow-l" href="/posts/new">Back</a>
|
73
|
+
#
|
74
|
+
# left_button_link 'Back', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
75
|
+
# # => <a data-role="button" data-icon="arrow-l" data-iconpos="right" data-theme="c" href="/posts/new">Back</a>
|
76
|
+
#
|
77
|
+
def left_button_link(name, link, options = {})
|
78
|
+
|
79
|
+
html_options = options.stringify_keys!
|
80
|
+
default_options = {'data-role' => "button", 'data-icon' => "arrow-l"}
|
81
|
+
|
82
|
+
if html_options.has_key?('data-theme')
|
83
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
84
|
+
end
|
85
|
+
|
86
|
+
if html_options.has_key?('data-iconpos')
|
87
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
88
|
+
end
|
89
|
+
|
90
|
+
if html_options.has_key?('data-inline')
|
91
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
92
|
+
end
|
93
|
+
|
94
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
95
|
+
end
|
96
|
+
|
97
|
+
# Right Button Link
|
98
|
+
#
|
99
|
+
# ==== Examples
|
100
|
+
# right_button_link 'Proceed', new_post_path
|
101
|
+
# # => <a data-role="button" data-icon="arrow-r" href="/posts/new" data-theme="c">Proceed</a>
|
102
|
+
#
|
103
|
+
# right_button_link 'Proceed', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
104
|
+
# # => <a data-role="button" data-icon="arrow-r" data-iconpos="right" data-theme="c" href="/posts/new">Proceed</a>
|
105
|
+
#
|
106
|
+
def right_button_link(name, link, options = {})
|
107
|
+
|
108
|
+
html_options = options.stringify_keys!
|
109
|
+
default_options = {'data-role' => "button", 'data-icon' => "arrow-r"}
|
110
|
+
|
111
|
+
if html_options.has_key?('data-theme')
|
112
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
113
|
+
end
|
114
|
+
|
115
|
+
if html_options.has_key?('data-iconpos')
|
116
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
117
|
+
end
|
118
|
+
|
119
|
+
if html_options.has_key?('data-inline')
|
120
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
121
|
+
end
|
122
|
+
|
123
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
124
|
+
end
|
125
|
+
|
126
|
+
# Up Button Link
|
127
|
+
#
|
128
|
+
# ==== Examples
|
129
|
+
# up_button_link 'top', new_post_path
|
130
|
+
# # => <a data-role="button" data-icon="arrow-u" href="/posts/new">top</a>
|
131
|
+
#
|
132
|
+
# up_button_link 'top', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'top'}
|
133
|
+
# # => <a data-role="button" data-icon="arrow-u" data-iconpos="top" data-theme="c" href="/posts/new">top</a>
|
134
|
+
#
|
135
|
+
def up_button_link(name, link, options = {})
|
136
|
+
|
137
|
+
html_options = options.stringify_keys!
|
138
|
+
default_options = {'data-role' => "button", 'data-icon' => "arrow-u"}
|
139
|
+
|
140
|
+
if html_options.has_key?('data-theme')
|
141
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
142
|
+
end
|
143
|
+
|
144
|
+
if html_options.has_key?('data-iconpos')
|
145
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
146
|
+
end
|
147
|
+
|
148
|
+
if html_options.has_key?('data-inline')
|
149
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
150
|
+
end
|
151
|
+
|
152
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
153
|
+
end
|
154
|
+
|
155
|
+
# Down Button Link
|
156
|
+
#
|
157
|
+
# ==== Examples
|
158
|
+
# down_button_link 'bottom', new_post_path
|
159
|
+
# # => <a data-role="button" data-icon="arrow-d" href="/posts/new">bottom</a>
|
160
|
+
#
|
161
|
+
# down_button_link 'bottom', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'bottom'}
|
162
|
+
# # => <a data-role="button" data-icon="arrow-d" data-iconpos="bottom" data-theme="c" href="/posts/new">bottom</a>
|
163
|
+
#
|
164
|
+
def down_button_link(name, link, options = {})
|
165
|
+
|
166
|
+
html_options = options.stringify_keys!
|
167
|
+
default_options = {'data-role' => "button", 'data-icon' => "arrow-d"}
|
168
|
+
|
169
|
+
if html_options.has_key?('data-theme')
|
170
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
171
|
+
end
|
172
|
+
|
173
|
+
if html_options.has_key?('data-iconpos')
|
174
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
175
|
+
end
|
176
|
+
|
177
|
+
if html_options.has_key?('data-inline')
|
178
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
179
|
+
end
|
180
|
+
|
181
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
182
|
+
end
|
183
|
+
|
184
|
+
# Plus Button Link
|
185
|
+
#
|
186
|
+
# ==== Examples
|
187
|
+
# plus_button_link 'plus', new_post_path
|
188
|
+
# # => <a data-role="button" data-icon="plus" href="/posts/new">plus</a>
|
189
|
+
#
|
190
|
+
# plus_button_link 'plus', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
191
|
+
# # => <a data-role="button" data-icon="plus" data-iconpos="right" data-theme="c" href="/posts/new">plus</a>
|
192
|
+
#
|
193
|
+
def plus_button_link(name, link, options = {})
|
194
|
+
|
195
|
+
html_options = options.stringify_keys!
|
196
|
+
default_options = {'data-role' => "button", 'data-icon' => "plus"}
|
197
|
+
|
198
|
+
if html_options.has_key?('data-theme')
|
199
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
200
|
+
end
|
201
|
+
|
202
|
+
if html_options.has_key?('data-iconpos')
|
203
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
204
|
+
end
|
205
|
+
|
206
|
+
if html_options.has_key?('data-inline')
|
207
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
208
|
+
end
|
209
|
+
|
210
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
211
|
+
end
|
212
|
+
|
213
|
+
# Minus Button Link
|
214
|
+
#
|
215
|
+
# ==== Examples
|
216
|
+
# minus_button_link 'minus', new_post_path
|
217
|
+
# # => <a data-role="button" data-icon="minus" href="/posts/new">minus</a>
|
218
|
+
#
|
219
|
+
# minus_button_link 'minus', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
220
|
+
# # => <a data-role="button" data-icon="minus" data-iconpos="right" data-theme="c" href="/posts/new">minus</a>
|
221
|
+
#
|
222
|
+
def minus_button_link(name, link, options = {})
|
223
|
+
|
224
|
+
html_options = options.stringify_keys!
|
225
|
+
default_options = {'data-role' => "button", 'data-icon' => "minus"}
|
226
|
+
|
227
|
+
if html_options.has_key?('data-theme')
|
228
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
229
|
+
end
|
230
|
+
|
231
|
+
if html_options.has_key?('data-iconpos')
|
232
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
233
|
+
end
|
234
|
+
|
235
|
+
if html_options.has_key?('data-inline')
|
236
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
237
|
+
end
|
238
|
+
|
239
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
240
|
+
end
|
241
|
+
|
242
|
+
# Check Button Link
|
243
|
+
#
|
244
|
+
# ==== Examples
|
245
|
+
# check_button_link 'check', new_post_path
|
246
|
+
# # => <a data-role="button" data-icon="check" href="/posts/new">check</a>
|
247
|
+
#
|
248
|
+
# check_button_link 'check', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
249
|
+
# # => <a data-role="button" data-icon="check" data-iconpos="right" data-theme="c" href="/posts/new">check</a>
|
250
|
+
#
|
251
|
+
def check_button_link(name, link, options = {})
|
252
|
+
|
253
|
+
html_options = options.stringify_keys!
|
254
|
+
default_options = {'data-role' => "button", 'data-icon' => "check"}
|
255
|
+
|
256
|
+
if html_options.has_key?('data-theme')
|
257
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
258
|
+
end
|
259
|
+
|
260
|
+
if html_options.has_key?('data-iconpos')
|
261
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
262
|
+
end
|
263
|
+
|
264
|
+
if html_options.has_key?('data-inline')
|
265
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
266
|
+
end
|
267
|
+
|
268
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
269
|
+
end
|
270
|
+
|
271
|
+
# Gear Button Link
|
272
|
+
#
|
273
|
+
# ==== Examples
|
274
|
+
# gear_button_link 'gear', new_post_path
|
275
|
+
# # => <a data-role="button" data-icon="gear" href="/posts/new">gear</a>
|
276
|
+
#
|
277
|
+
# gear_button_link 'gear', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
278
|
+
# # => <a data-role="button" data-icon="gear" data-iconpos="right" data-theme="c" href="/posts/new">gear</a>
|
279
|
+
#
|
280
|
+
def gear_button_link(name, link, options = {})
|
281
|
+
|
282
|
+
html_options = options.stringify_keys!
|
283
|
+
default_options = {'data-role' => "button", 'data-icon' => "gear"}
|
284
|
+
|
285
|
+
if html_options.has_key?('data-theme')
|
286
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
287
|
+
end
|
288
|
+
|
289
|
+
if html_options.has_key?('data-iconpos')
|
290
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
291
|
+
end
|
292
|
+
|
293
|
+
if html_options.has_key?('data-inline')
|
294
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
295
|
+
end
|
296
|
+
|
297
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
298
|
+
end
|
299
|
+
|
300
|
+
# Refresh Button Link
|
301
|
+
#
|
302
|
+
# ==== Examples
|
303
|
+
# refresh_button_link 'refresh', new_post_path
|
304
|
+
# # => <a data-role="button" data-icon="refresh" href="/posts/new">refresh</a>
|
305
|
+
#
|
306
|
+
# refresh_button_link 'refresh', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
307
|
+
# # => <a data-role="button" data-icon="refresh" data-iconpos="right" data-theme="c" href="/posts/new">refresh</a>
|
308
|
+
#
|
309
|
+
def refresh_button_link(name, link, options = {})
|
310
|
+
|
311
|
+
html_options = options.stringify_keys!
|
312
|
+
default_options = {'data-role' => "button", 'data-icon' => "refresh"}
|
313
|
+
|
314
|
+
if html_options.has_key?('data-theme')
|
315
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
316
|
+
end
|
317
|
+
|
318
|
+
if html_options.has_key?('data-iconpos')
|
319
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
320
|
+
end
|
321
|
+
|
322
|
+
if html_options.has_key?('data-inline')
|
323
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
324
|
+
end
|
325
|
+
|
326
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
327
|
+
end
|
328
|
+
|
329
|
+
# Forward Button Link
|
330
|
+
#
|
331
|
+
# ==== Examples
|
332
|
+
# forward_button_link 'forward', new_post_path
|
333
|
+
# # => <a data-role="button" data-icon="forward" href="/posts/new">forward</a>
|
334
|
+
#
|
335
|
+
# forward_button_link 'forward', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
336
|
+
# # => <a data-role="button" data-icon="forward" data-iconpos="right" data-theme="c" href="/posts/new">forward</a>
|
337
|
+
#
|
338
|
+
def forward_button_link(name, link, options = {})
|
339
|
+
|
340
|
+
html_options = options.stringify_keys!
|
341
|
+
default_options = {'data-role' => "button", 'data-icon' => "forward"}
|
342
|
+
|
343
|
+
if html_options.has_key?('data-theme')
|
344
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
345
|
+
end
|
346
|
+
|
347
|
+
if html_options.has_key?('data-iconpos')
|
348
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
349
|
+
end
|
350
|
+
|
351
|
+
if html_options.has_key?('data-inline')
|
352
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
353
|
+
end
|
354
|
+
|
355
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
356
|
+
end
|
357
|
+
|
358
|
+
# Back Button Link
|
359
|
+
#
|
360
|
+
# ==== Examples
|
361
|
+
# back_button_link 'back', new_post_path
|
362
|
+
# # => <a data-role="button" data-icon="back" href="/posts/new">back</a>
|
363
|
+
#
|
364
|
+
# back_button_link 'back', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
365
|
+
# # => <a data-role="button" data-icon="back" data-iconpos="right" data-theme="c" href="/posts/new">back</a>
|
366
|
+
#
|
367
|
+
def back_button_link(name, link, options = {})
|
368
|
+
|
369
|
+
html_options = options.stringify_keys!
|
370
|
+
default_options = {'data-role' => "button", 'data-icon' => "back"}
|
371
|
+
|
372
|
+
if html_options.has_key?('data-theme')
|
373
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
374
|
+
end
|
375
|
+
|
376
|
+
if html_options.has_key?('data-iconpos')
|
377
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
378
|
+
end
|
379
|
+
|
380
|
+
if html_options.has_key?('data-inline')
|
381
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
382
|
+
end
|
383
|
+
|
384
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
385
|
+
end
|
386
|
+
|
387
|
+
# Grid Button Link
|
388
|
+
#
|
389
|
+
# ==== Examples
|
390
|
+
# grid_button_link 'grid', new_post_path
|
391
|
+
# # => <a data-role="button" data-icon="grid" href="/posts/new">grid</a>
|
392
|
+
#
|
393
|
+
# grid_button_link 'grid', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
394
|
+
# # => <a data-role="button" data-icon="grid" data-iconpos="right" data-theme="c" href="/posts/new">grid</a>
|
395
|
+
#
|
396
|
+
def grid_button_link(name, link, options = {})
|
397
|
+
|
398
|
+
html_options = options.stringify_keys!
|
399
|
+
default_options = {'data-role' => "button", 'data-icon' => "grid"}
|
400
|
+
|
401
|
+
if html_options.has_key?('data-theme')
|
402
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
403
|
+
end
|
404
|
+
|
405
|
+
if html_options.has_key?('data-iconpos')
|
406
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
407
|
+
end
|
408
|
+
|
409
|
+
if html_options.has_key?('data-inline')
|
410
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
411
|
+
end
|
412
|
+
|
413
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
414
|
+
end
|
415
|
+
|
416
|
+
# Star Button Link
|
417
|
+
#
|
418
|
+
# ==== Examples
|
419
|
+
# star_button_link 'star', new_post_path
|
420
|
+
# # => <a data-role="button" data-icon="star" href="/posts/new">star</a>
|
421
|
+
#
|
422
|
+
# star_button_link 'star', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
423
|
+
# # => <a data-role="button" data-icon="star" data-iconpos="right" data-theme="c" href="/posts/new">star</a>
|
424
|
+
#
|
425
|
+
def star_button_link(name, link, options = {})
|
426
|
+
|
427
|
+
html_options = options.stringify_keys!
|
428
|
+
default_options = {'data-role' => "button", 'data-icon' => "star"}
|
429
|
+
|
430
|
+
if html_options.has_key?('data-theme')
|
431
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
432
|
+
end
|
433
|
+
|
434
|
+
if html_options.has_key?('data-iconpos')
|
435
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
436
|
+
end
|
437
|
+
|
438
|
+
if html_options.has_key?('data-inline')
|
439
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
440
|
+
end
|
441
|
+
|
442
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
443
|
+
end
|
444
|
+
|
445
|
+
# Alert Button Link
|
446
|
+
#
|
447
|
+
# ==== Examples
|
448
|
+
# alert_button_link 'alert', new_post_path
|
449
|
+
# # => <a data-role="button" data-icon="alert" href="/posts/new">alert</a>
|
450
|
+
#
|
451
|
+
# alert_button_link 'alert', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
452
|
+
# # => <a data-role="button" data-icon="alert" data-iconpos="right" data-theme="c" href="/posts/new">alert</a>
|
453
|
+
#
|
454
|
+
def alert_button_link(name, link, options = {})
|
455
|
+
|
456
|
+
html_options = options.stringify_keys!
|
457
|
+
default_options = {'data-role' => "button", 'data-icon' => "alert"}
|
458
|
+
|
459
|
+
if html_options.has_key?('data-theme')
|
460
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
461
|
+
end
|
462
|
+
|
463
|
+
if html_options.has_key?('data-iconpos')
|
464
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
465
|
+
end
|
466
|
+
|
467
|
+
if html_options.has_key?('data-inline')
|
468
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
469
|
+
end
|
470
|
+
|
471
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
472
|
+
end
|
473
|
+
|
474
|
+
# Info Button Link
|
475
|
+
#
|
476
|
+
# ==== Examples
|
477
|
+
# info_button_link 'info', new_post_path
|
478
|
+
# # => <a data-role="button" data-icon="info" href="/posts/new">info</a>
|
479
|
+
#
|
480
|
+
# info_button_link 'info', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
481
|
+
# # => <a data-role="button" data-icon="info" data-iconpos="right" data-theme="c" href="/posts/new">info</a>
|
482
|
+
#
|
483
|
+
def info_button_link(name, link, options = {})
|
484
|
+
|
485
|
+
html_options = options.stringify_keys!
|
486
|
+
default_options = {'data-role' => "button", 'data-icon' => "info"}
|
487
|
+
|
488
|
+
if html_options.has_key?('data-theme')
|
489
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
490
|
+
end
|
491
|
+
|
492
|
+
if html_options.has_key?('data-iconpos')
|
493
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
494
|
+
end
|
495
|
+
|
496
|
+
if html_options.has_key?('data-inline')
|
497
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
498
|
+
end
|
499
|
+
|
500
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
501
|
+
end
|
502
|
+
|
503
|
+
# Home Button Link
|
504
|
+
#
|
505
|
+
# ==== Examples
|
506
|
+
# home_button_link 'home', new_post_path
|
507
|
+
# # => <a data-role="button" data-icon="home" href="/posts/new">home</a>
|
508
|
+
#
|
509
|
+
# home_button_link 'home', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
510
|
+
# # => <a data-role="button" data-icon="home" data-iconpos="right" data-theme="c" href="/posts/new">home</a>
|
511
|
+
#
|
512
|
+
def home_button_link(name, link, options = {})
|
513
|
+
|
514
|
+
html_options = options.stringify_keys!
|
515
|
+
default_options = {'data-role' => "button", 'data-icon' => "home"}
|
516
|
+
|
517
|
+
if html_options.has_key?('data-theme')
|
518
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
519
|
+
end
|
520
|
+
|
521
|
+
if html_options.has_key?('data-iconpos')
|
522
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
523
|
+
end
|
524
|
+
|
525
|
+
if html_options.has_key?('data-inline')
|
526
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
527
|
+
end
|
528
|
+
|
529
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
530
|
+
end
|
531
|
+
|
532
|
+
# Search Button Link
|
533
|
+
#
|
534
|
+
# ==== Examples
|
535
|
+
# search_button_link 'search', new_post_path
|
536
|
+
# # => <a data-role="button" data-icon="search" href="/posts/new">search</a>
|
537
|
+
#
|
538
|
+
# search_button_link 'search', new_post_path, {'data-theme' => 'c', 'data-iconpos' => 'right'}
|
539
|
+
# # => <a data-role="button" data-icon="search" data-iconpos="right" data-theme="c" href="/posts/new">search</a>
|
540
|
+
#
|
541
|
+
def search_button_link(name, link, options = {})
|
542
|
+
|
543
|
+
html_options = options.stringify_keys!
|
544
|
+
default_options = {'data-role' => "button", 'data-icon' => "search"}
|
545
|
+
|
546
|
+
if html_options.has_key?('data-theme')
|
547
|
+
default_options = default_options.merge({'data-theme' => html_options['data-theme']})
|
548
|
+
end
|
549
|
+
|
550
|
+
if html_options.has_key?('data-iconpos')
|
551
|
+
default_options = default_options.merge({'data-iconpos' => html_options['data-iconpos']})
|
552
|
+
end
|
553
|
+
|
554
|
+
if html_options.has_key?('data-inline')
|
555
|
+
default_options = default_options.merge({'data-inline' => html_options['data-inline']})
|
556
|
+
end
|
557
|
+
|
558
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
559
|
+
end
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
# ====================================== BACK-SPLIT-BUTTON ===========================================================
|
564
|
+
# In cases where there is more than one possible action per list item,
|
565
|
+
# a split button can be used to offer two independently clickable items -- the list item and a small arrow icon in the far right
|
566
|
+
# The framework will add a vertical divider line and sets the title attribute of the link to the text the link for accessibility.
|
567
|
+
# It is similar for the Split-Button List.
|
568
|
+
#
|
569
|
+
#
|
570
|
+
# ==== Options
|
571
|
+
# # => 'data-inset' => 'true' (Default data-inset is set to true)
|
572
|
+
# # => 'data-theme' => 'c' (Default data-theme is set to c)
|
573
|
+
#
|
574
|
+
# ==== Examples
|
575
|
+
# <%= back_split_button "Back", posts_path %>
|
576
|
+
# # => <div data-role="content"><a href="index.html" data-role="button" data-rel="back">Back</a></div>
|
577
|
+
#
|
578
|
+
#
|
579
|
+
def back_split_button(name, link, options ={} )
|
580
|
+
html_options = options.stringify_keys!
|
581
|
+
default_options = {'data-role' => "button", 'data-rel' => "back"}
|
582
|
+
content_tag(:a, name, {:href => link}.merge(default_options))
|
583
|
+
end
|
584
|
+
|
585
|
+
# Grouped Button
|
586
|
+
#
|
587
|
+
# ==== Examples
|
588
|
+
# group_button("
|
589
|
+
# #{home_button_link('home', buttons_path, 'data-iconpos' => 'right')}
|
590
|
+
# #{refresh_button_link 'refresh', buttons_path}
|
591
|
+
# ")
|
592
|
+
# # => <div data-role="controlgroup">
|
593
|
+
# <a data-icon="home" data-iconpos="right" data-role="button" href="/buttons">home</a>
|
594
|
+
# <a data-icon="refresh" data-role="button" href="/buttons">refresh</a>
|
595
|
+
# </div>
|
596
|
+
#
|
597
|
+
# group_button("
|
598
|
+
# #{home_button_link('home', buttons_path, 'data-iconpos' => 'right')}
|
599
|
+
# #{refresh_button_link 'refresh', buttons_path}, {'data-type' => 'horizontal'}
|
600
|
+
# ")
|
601
|
+
# # => <div data-role="controlgroup" data-type="horizontal" >
|
602
|
+
# <a data-icon="home" data-iconpos="right" data-role="button" href="/buttons">home</a>
|
603
|
+
# <a data-icon="refresh" data-role="button" href="/buttons">refresh</a>
|
604
|
+
# </div>
|
605
|
+
def group_button(content, options = {})
|
606
|
+
|
607
|
+
html_options = options.stringify_keys!
|
608
|
+
default_options = {'data-role'=> "controlgroup"}
|
609
|
+
|
610
|
+
if html_options.has_key?('data-type')
|
611
|
+
default_options = default_options.merge({'data-type' => html_options['data-type']})
|
612
|
+
end
|
613
|
+
|
614
|
+
content_tag(:div, content, default_options, false)
|
615
|
+
end
|
616
|
+
|
617
|
+
# Inline Buttons
|
618
|
+
#
|
619
|
+
# ==== Examples
|
620
|
+
# inline_button("
|
621
|
+
# #{home_button_link('home', buttons_path, 'data-iconpos' => 'right')}
|
622
|
+
# #{refresh_button_link 'refresh', buttons_path}
|
623
|
+
# ")
|
624
|
+
# # => <div data-inline="true" data-role="controlgroup" data-type="horizontal">
|
625
|
+
# <a data-icon="home" data-iconpos="right" data-role="button" href="/buttons">home</a>
|
626
|
+
# <a data-icon="refresh" data-role="button" href="/buttons">refresh</a>
|
627
|
+
# </div>
|
628
|
+
#
|
629
|
+
|
630
|
+
def inline_button(content)
|
631
|
+
|
632
|
+
default_options = {'data-inline'=> "true", 'data-role'=> "controlgroup", 'data-type' => "horizontal"}
|
633
|
+
|
634
|
+
content_tag(:div, content, default_options, false)
|
635
|
+
end
|
636
|
+
|
637
|
+
end
|
638
|
+
end
|
639
|
+
|