facades 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. data/.gitignore +1 -0
  2. data/.rbenv-gemsets +1 -0
  3. data/.rvmrc +1 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +12 -0
  6. data/Guardfile +19 -0
  7. data/README.md +115 -101
  8. data/Rakefile +8 -0
  9. data/app/assets/javascripts/facades/debug/grid.js +0 -0
  10. data/app/helpers/facades_helper.rb +1 -0
  11. data/config.ru +7 -0
  12. data/facades.gemspec +9 -2
  13. data/lib/facades/helpers/layout.rb +36 -73
  14. data/lib/facades/helpers/navigation.rb +182 -110
  15. data/lib/facades/helpers/{elements.rb → notifications.rb} +9 -36
  16. data/lib/facades/helpers.rb +6 -17
  17. data/lib/facades/patterns/tabs.rb +75 -0
  18. data/lib/facades/patterns.rb +7 -0
  19. data/lib/facades/{sass_ext → sass_extensions}/color.rb +5 -13
  20. data/lib/facades/sass_extensions/conversions.rb +27 -0
  21. data/lib/facades/sass_extensions/functions.rb +84 -0
  22. data/lib/facades/sass_extensions/icons.rb +66 -0
  23. data/lib/facades/sass_extensions.rb +21 -0
  24. data/lib/facades/support/compass/project/MIT-LICENSE.txt +20 -0
  25. data/lib/facades/support/compass/project/humans.txt +8 -0
  26. data/lib/facades/support/compass/project/index.html +45 -0
  27. data/lib/facades/support/compass/project/manifest.rb +18 -0
  28. data/lib/facades/support/compass/project/robots.txt +4 -0
  29. data/lib/facades/support/compass.rb +9 -0
  30. data/lib/facades/support/rails.rb +12 -15
  31. data/lib/facades/support/simple_form.rb +32 -0
  32. data/lib/facades/version.rb +1 -1
  33. data/lib/facades.rb +21 -44
  34. data/spec/internal/app/helpers/application_helper.rb +3 -0
  35. data/spec/internal/app/views/navigation/_multi_list.html.erb +11 -0
  36. data/spec/internal/app/views/navigation/_multi_option_list.html.erb +14 -0
  37. data/spec/internal/app/views/navigation/_single_list.html.erb +9 -0
  38. data/spec/internal/config/database.yml +3 -0
  39. data/spec/internal/config/routes.rb +3 -0
  40. data/spec/internal/db/schema.rb +3 -0
  41. data/spec/internal/log/.gitignore +1 -0
  42. data/spec/internal/public/favicon.ico +0 -0
  43. data/spec/spec_helper.rb +16 -6
  44. data/spec/unit/helpers/layout_spec.rb +4 -0
  45. data/spec/unit/helpers/navigation_spec.rb +384 -0
  46. data/spec/unit/helpers/notifications_spec.rb +4 -0
  47. data/spec/unit/patterns/tabs_spec.rb +58 -0
  48. data/src/icons/facades.yml +105 -0
  49. data/src/icons/font-awesome.yml +210 -0
  50. data/src/scss/facades/_buttons.scss +10 -0
  51. data/src/scss/facades/_config.scss +99 -0
  52. data/src/scss/facades/_debug.scss +8 -0
  53. data/src/scss/facades/_forms.scss +228 -0
  54. data/src/scss/facades/_global.scss +104 -0
  55. data/src/scss/facades/_icons.scss +61 -0
  56. data/src/scss/facades/_mixins.scss +115 -0
  57. data/src/scss/facades/_mobile.scss +3 -0
  58. data/src/scss/facades/_setup.scss +191 -0
  59. data/src/scss/facades/_typography.scss +220 -0
  60. data/src/scss/facades/buttons/_glossy.scss +29 -0
  61. data/src/scss/facades/buttons/_gradient.scss +36 -0
  62. data/src/scss/facades/buttons/_shared.scss +33 -0
  63. data/src/scss/facades/buttons/_simple.scss +28 -0
  64. data/src/scss/facades/icons/_classes.scss +37 -0
  65. data/src/scss/facades/icons/_legacy.scss +27 -0
  66. data/src/scss/facades/layout/_lists.scss +43 -0
  67. data/src/scss/facades/mixins/_gradients.scss +30 -0
  68. data/src/scss/facades/mixins/_rhythm.scss +37 -0
  69. data/src/scss/facades/mobile/_buttons.scss +97 -0
  70. data/src/scss/facades/mobile/_config.scss +30 -0
  71. data/src/scss/facades/mobile/_global.scss +81 -0
  72. data/src/scss/facades/mobile/_mixins.scss +49 -0
  73. data/src/scss/facades/mobile/_setup.scss +50 -0
  74. data/src/scss/facades/mobile/patterns/_navbar.scss +21 -0
  75. data/src/scss/facades/mobile/patterns/_panel.scss +37 -0
  76. data/src/scss/facades/mobile/patterns/_stage.scss +20 -0
  77. data/src/scss/facades/mobile/patterns/_toolbar.scss +25 -0
  78. data/src/scss/facades/mobile/themes/_apple.scss +17 -0
  79. data/src/scss/facades/patterns/_labels.scss +50 -0
  80. data/src/scss/facades/patterns/_navbar.scss +4 -0
  81. data/src/scss/facades/patterns/_notifications.scss +82 -0
  82. data/src/scss/facades/patterns/_pagination.scss +4 -0
  83. data/src/scss/facades/patterns/_pills.scss +50 -0
  84. data/src/scss/facades/patterns/_tabs.scss +83 -0
  85. data/src/scss/facades/patterns/_twipsy.scss +84 -0
  86. data/src/scss/facades/typography/_tables.scss +95 -0
  87. metadata +201 -58
  88. data/app/views/facades/_pagination.html.erb +0 -20
  89. data/lib/facades/builders/form/base.rb +0 -212
  90. data/lib/facades/builders/form/elements.rb +0 -112
  91. data/lib/facades/builders/form/helper.rb +0 -29
  92. data/lib/facades/builders/form.rb +0 -22
  93. data/lib/facades/builders/sprite.rb +0 -50
  94. data/lib/facades/builders/table.rb +0 -76
  95. data/lib/facades/debug/html.rb +0 -6
  96. data/lib/facades/helpers/builders.rb +0 -24
  97. data/lib/facades/helpers/mobile.rb +0 -57
  98. data/lib/facades/helpers/pagination.rb +0 -83
  99. data/lib/facades/helpers/utility.rb +0 -31
  100. data/lib/facades/sass_ext/form_elements.rb +0 -52
  101. data/lib/facades/sass_ext/funcs.rb +0 -33
  102. data/lib/facades/sass_ext.rb +0 -14
  103. data/lib/facades/stylesheets/facades/_common.scss +0 -7
  104. data/lib/facades/stylesheets/facades/_css3.scss +0 -93
  105. data/lib/facades/stylesheets/facades/_layout.scss +0 -5
  106. data/lib/facades/stylesheets/facades/_normalize.scss +0 -5
  107. data/lib/facades/stylesheets/facades/_setup.scss +0 -104
  108. data/lib/facades/stylesheets/facades/_typography.scss +0 -2
  109. data/lib/facades/stylesheets/facades/_ui.scss +0 -3
  110. data/lib/facades/stylesheets/facades/_utilities.scss +0 -32
  111. data/lib/facades/stylesheets/facades/layout/_dropdown-list.scss +0 -7
  112. data/lib/facades/stylesheets/facades/layout/_forms.scss +0 -53
  113. data/lib/facades/stylesheets/facades/layout/_grid.scss +0 -49
  114. data/lib/facades/stylesheets/facades/layout/_responsive_grid.scss +0 -164
  115. data/lib/facades/stylesheets/facades/setup/_forms.scss +0 -284
  116. data/lib/facades/stylesheets/facades/setup/_ie.scss +0 -12
  117. data/lib/facades/stylesheets/facades/setup/_reset.scss +0 -255
  118. data/lib/facades/stylesheets/facades/typography/_baseline.scss +0 -91
  119. data/lib/facades/stylesheets/facades/typography/_lists.scss +0 -34
  120. data/lib/facades/stylesheets/facades/typography/_shadow.scss +0 -8
  121. data/lib/facades/stylesheets/facades/ui/_buttons.scss +0 -34
  122. data/lib/facades/stylesheets/facades/ui/_flash-messages.scss +0 -29
  123. data/lib/facades/stylesheets/facades/ui/_tabbed.scss +0 -5
  124. data/lib/facades/stylesheets/facades/ui/_tool-tip.scss +0 -44
  125. data/lib/facades/stylesheets/facades/utilities/_clearfix.scss +0 -20
  126. data/lib/facades/stylesheets/facades/utilities/_color.scss +0 -7
  127. data/lib/facades/stylesheets/facades/utilities/_cursors.scss +0 -4
  128. data/lib/facades/support/serve.rb +0 -17
  129. data/lib/facades/support/tipsy.rb +0 -17
  130. data/spec/facades/helpers/elements_spec.rb +0 -86
  131. data/spec/facades/helpers/layout_helpers_spec.rb +0 -5
  132. data/spec/facades/helpers/navigation_spec.rb +0 -107
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facades
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-05 00:00:00.000000000 Z
12
+ date: 2012-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sass
16
- requirement: &70228226739680 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,9 +21,110 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70228226739680
25
- description: Facades is a front-end development framework which supplies a few helpers,
26
- stylesheets and sass extensions for easier front-end development.
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: compass
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.11.7
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.11.7
46
+ - !ruby/object:Gem::Dependency
47
+ name: combustion
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.3.1
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.1
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 2.7.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 2.7.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: sass-rails
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '3.1'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '3.1'
94
+ - !ruby/object:Gem::Dependency
95
+ name: webrat
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '0.7'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '0.7'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec-rails
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: 2.11.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: 2.11.0
126
+ description: Facades is a collection of front-end patterns and libraries designed
127
+ to speed up development of web sites and applications.
27
128
  email:
28
129
  - brent@kurbmedia.com
29
130
  executables: []
@@ -31,66 +132,92 @@ extensions: []
31
132
  extra_rdoc_files: []
32
133
  files:
33
134
  - .gitignore
135
+ - .rbenv-gemsets
136
+ - .rvmrc
137
+ - .travis.yml
34
138
  - Gemfile
139
+ - Guardfile
35
140
  - README.md
36
141
  - Rakefile
142
+ - app/assets/javascripts/facades/debug/grid.js
37
143
  - app/helpers/facades_helper.rb
38
- - app/views/facades/_pagination.html.erb
144
+ - config.ru
39
145
  - facades.gemspec
40
146
  - lib/facades.rb
41
- - lib/facades/builders/form.rb
42
- - lib/facades/builders/form/base.rb
43
- - lib/facades/builders/form/elements.rb
44
- - lib/facades/builders/form/helper.rb
45
- - lib/facades/builders/sprite.rb
46
- - lib/facades/builders/table.rb
47
- - lib/facades/debug/html.rb
48
147
  - lib/facades/helpers.rb
49
- - lib/facades/helpers/builders.rb
50
- - lib/facades/helpers/elements.rb
51
148
  - lib/facades/helpers/layout.rb
52
- - lib/facades/helpers/mobile.rb
53
149
  - lib/facades/helpers/navigation.rb
54
- - lib/facades/helpers/pagination.rb
55
- - lib/facades/helpers/utility.rb
56
- - lib/facades/sass_ext.rb
57
- - lib/facades/sass_ext/color.rb
58
- - lib/facades/sass_ext/form_elements.rb
59
- - lib/facades/sass_ext/funcs.rb
60
- - lib/facades/stylesheets/facades/_common.scss
61
- - lib/facades/stylesheets/facades/_css3.scss
62
- - lib/facades/stylesheets/facades/_layout.scss
63
- - lib/facades/stylesheets/facades/_normalize.scss
64
- - lib/facades/stylesheets/facades/_setup.scss
65
- - lib/facades/stylesheets/facades/_typography.scss
66
- - lib/facades/stylesheets/facades/_ui.scss
67
- - lib/facades/stylesheets/facades/_utilities.scss
68
- - lib/facades/stylesheets/facades/layout/_dropdown-list.scss
69
- - lib/facades/stylesheets/facades/layout/_forms.scss
70
- - lib/facades/stylesheets/facades/layout/_grid.scss
71
- - lib/facades/stylesheets/facades/layout/_responsive_grid.scss
72
- - lib/facades/stylesheets/facades/setup/_forms.scss
73
- - lib/facades/stylesheets/facades/setup/_ie.scss
74
- - lib/facades/stylesheets/facades/setup/_reset.scss
75
- - lib/facades/stylesheets/facades/typography/_baseline.scss
76
- - lib/facades/stylesheets/facades/typography/_lists.scss
77
- - lib/facades/stylesheets/facades/typography/_shadow.scss
78
- - lib/facades/stylesheets/facades/ui/_buttons.scss
79
- - lib/facades/stylesheets/facades/ui/_flash-messages.scss
80
- - lib/facades/stylesheets/facades/ui/_tabbed.scss
81
- - lib/facades/stylesheets/facades/ui/_tool-tip.scss
82
- - lib/facades/stylesheets/facades/utilities/_clearfix.scss
83
- - lib/facades/stylesheets/facades/utilities/_color.scss
84
- - lib/facades/stylesheets/facades/utilities/_cursors.scss
150
+ - lib/facades/helpers/notifications.rb
151
+ - lib/facades/patterns.rb
152
+ - lib/facades/patterns/tabs.rb
153
+ - lib/facades/sass_extensions.rb
154
+ - lib/facades/sass_extensions/color.rb
155
+ - lib/facades/sass_extensions/conversions.rb
156
+ - lib/facades/sass_extensions/functions.rb
157
+ - lib/facades/sass_extensions/icons.rb
158
+ - lib/facades/support/compass.rb
159
+ - lib/facades/support/compass/project/MIT-LICENSE.txt
160
+ - lib/facades/support/compass/project/humans.txt
161
+ - lib/facades/support/compass/project/index.html
162
+ - lib/facades/support/compass/project/manifest.rb
163
+ - lib/facades/support/compass/project/robots.txt
85
164
  - lib/facades/support/rails.rb
86
- - lib/facades/support/serve.rb
87
- - lib/facades/support/tipsy.rb
165
+ - lib/facades/support/simple_form.rb
88
166
  - lib/facades/version.rb
89
- - spec/facades/helpers/elements_spec.rb
90
- - spec/facades/helpers/layout_helpers_spec.rb
91
- - spec/facades/helpers/navigation_spec.rb
167
+ - spec/internal/app/helpers/application_helper.rb
168
+ - spec/internal/app/views/navigation/_multi_list.html.erb
169
+ - spec/internal/app/views/navigation/_multi_option_list.html.erb
170
+ - spec/internal/app/views/navigation/_single_list.html.erb
171
+ - spec/internal/config/database.yml
172
+ - spec/internal/config/routes.rb
173
+ - spec/internal/db/schema.rb
174
+ - spec/internal/log/.gitignore
92
175
  - spec/internal/log/test.log
176
+ - spec/internal/public/favicon.ico
93
177
  - spec/spec_helper.rb
178
+ - spec/unit/helpers/layout_spec.rb
179
+ - spec/unit/helpers/navigation_spec.rb
180
+ - spec/unit/helpers/notifications_spec.rb
181
+ - spec/unit/patterns/tabs_spec.rb
182
+ - src/icons/facades.yml
183
+ - src/icons/font-awesome.yml
184
+ - src/scss/facades/_buttons.scss
185
+ - src/scss/facades/_config.scss
186
+ - src/scss/facades/_debug.scss
187
+ - src/scss/facades/_forms.scss
188
+ - src/scss/facades/_global.scss
189
+ - src/scss/facades/_icons.scss
190
+ - src/scss/facades/_mixins.scss
191
+ - src/scss/facades/_mobile.scss
192
+ - src/scss/facades/_setup.scss
193
+ - src/scss/facades/_typography.scss
194
+ - src/scss/facades/buttons/_glossy.scss
195
+ - src/scss/facades/buttons/_gradient.scss
196
+ - src/scss/facades/buttons/_shared.scss
197
+ - src/scss/facades/buttons/_simple.scss
198
+ - src/scss/facades/icons/_classes.scss
199
+ - src/scss/facades/icons/_legacy.scss
200
+ - src/scss/facades/layout/_lists.scss
201
+ - src/scss/facades/mixins/_gradients.scss
202
+ - src/scss/facades/mixins/_rhythm.scss
203
+ - src/scss/facades/mobile/_buttons.scss
204
+ - src/scss/facades/mobile/_config.scss
205
+ - src/scss/facades/mobile/_global.scss
206
+ - src/scss/facades/mobile/_mixins.scss
207
+ - src/scss/facades/mobile/_setup.scss
208
+ - src/scss/facades/mobile/patterns/_navbar.scss
209
+ - src/scss/facades/mobile/patterns/_panel.scss
210
+ - src/scss/facades/mobile/patterns/_stage.scss
211
+ - src/scss/facades/mobile/patterns/_toolbar.scss
212
+ - src/scss/facades/mobile/themes/_apple.scss
213
+ - src/scss/facades/patterns/_labels.scss
214
+ - src/scss/facades/patterns/_navbar.scss
215
+ - src/scss/facades/patterns/_notifications.scss
216
+ - src/scss/facades/patterns/_pagination.scss
217
+ - src/scss/facades/patterns/_pills.scss
218
+ - src/scss/facades/patterns/_tabs.scss
219
+ - src/scss/facades/patterns/_twipsy.scss
220
+ - src/scss/facades/typography/_tables.scss
94
221
  homepage: https://github.com/kurbmedia/facades
95
222
  licenses: []
96
223
  post_install_message:
@@ -103,21 +230,37 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
230
  - - ! '>='
104
231
  - !ruby/object:Gem::Version
105
232
  version: '0'
233
+ segments:
234
+ - 0
235
+ hash: 2737179968248594604
106
236
  required_rubygems_version: !ruby/object:Gem::Requirement
107
237
  none: false
108
238
  requirements:
109
239
  - - ! '>='
110
240
  - !ruby/object:Gem::Version
111
241
  version: '0'
242
+ segments:
243
+ - 0
244
+ hash: 2737179968248594604
112
245
  requirements: []
113
246
  rubyforge_project: facades
114
- rubygems_version: 1.8.16
247
+ rubygems_version: 1.8.23
115
248
  signing_key:
116
249
  specification_version: 3
117
- summary: Front-end development awesome-ness
250
+ summary: Front-end development awesome-ness with Compass and Sass.
118
251
  test_files:
119
- - spec/facades/helpers/elements_spec.rb
120
- - spec/facades/helpers/layout_helpers_spec.rb
121
- - spec/facades/helpers/navigation_spec.rb
252
+ - spec/internal/app/helpers/application_helper.rb
253
+ - spec/internal/app/views/navigation/_multi_list.html.erb
254
+ - spec/internal/app/views/navigation/_multi_option_list.html.erb
255
+ - spec/internal/app/views/navigation/_single_list.html.erb
256
+ - spec/internal/config/database.yml
257
+ - spec/internal/config/routes.rb
258
+ - spec/internal/db/schema.rb
259
+ - spec/internal/log/.gitignore
122
260
  - spec/internal/log/test.log
261
+ - spec/internal/public/favicon.ico
123
262
  - spec/spec_helper.rb
263
+ - spec/unit/helpers/layout_spec.rb
264
+ - spec/unit/helpers/navigation_spec.rb
265
+ - spec/unit/helpers/notifications_spec.rb
266
+ - spec/unit/patterns/tabs_spec.rb
@@ -1,20 +0,0 @@
1
- <p class='pagination-detail'>Viewing Page <%= paginator.current_page %> of <%= paginator.total_pages %></p>
2
- <ol class='pagination-links'>
3
- <li class='first'>
4
- <%= paginator.first? ? "&larr;".html_safe : paginator.link(1, {}, "&larr;") %>
5
- </li>
6
- <li class='prev'>
7
- <%= paginator.first? ? "&laquo; Previous".html_safe : paginator.link(paginator.previous, {}, "&laquo; Previous".html_safe) %>
8
- </li>
9
- <% paginator.links.each do |link| %>
10
- <li<%= link.current? ? " class='current'" : "" %>>
11
- <%= link.current? ? link.number : paginator.link(link.number) %>
12
- </li>
13
- <% end %>
14
- <li class='next'>
15
- <%= paginator.last? ? "Next &raquo;".html_safe : paginator.link(paginator.next, {}, "Next &raquo;".html_safe) %>
16
- </li>
17
- <li class='last'>
18
- <%= paginator.last? ? "&rarr;".html_safe : paginator.link(paginator.total_pages, {}, "&rarr;") %>
19
- </li>
20
- </ol>
@@ -1,212 +0,0 @@
1
- module Facades::Builders
2
- module FormBuilder
3
- module Base
4
- # Access the template object
5
- attr_accessor :template
6
- # Tracks the order in which fields are used in the form, this allows the easy rebuilding of the submitted form
7
- # data when submitted since normally the hash isn't ordered.
8
- attr_accessor :field_order
9
- # Tracks the field currently being "processed"
10
- attr_accessor :current_field_type
11
-
12
-
13
- # Overrides fields_for to make sure the form builder is set properly
14
- #
15
- def fields_for(record_or_name_or_array, *args, &block) #:nodoc:
16
- opts = args.extract_options!
17
- opts[:builder] ||= ActionView::Base.default_form_builder
18
- args.push(opts)
19
- with_custom_error_proc do
20
- super(record_or_name_or_array, *args, &block)
21
- end
22
- end
23
-
24
- protected
25
-
26
- ##
27
- #
28
- # Checks to see if a particular attribute is required, if so, a "required" attribute is added to the field.
29
- #
30
- # @param [Symbol] attribute The attribute to check against validators
31
- # @return [Boolean]
32
- #
33
- def attribute_required?(attribute)
34
- validates_presence?(attribute) || validates_inclusion?(attribute)
35
- end
36
-
37
- # Convenience method to use the +content_tag+ method from our template
38
- #
39
- def content_tag(tag, content, options = {}, escape = true, &block) #:nodoc:
40
- @template.content_tag(tag, content, options, escape, &block)
41
- end
42
-
43
- ##
44
- # Checks to see if there are errors for the particular method or attribute
45
- #
46
- # @param [Symbol] method The method/attribute to check
47
- #
48
- # @return [Boolean]
49
- #
50
- def errors_on_attribute?(method)
51
- return false if @object.nil?
52
- !(@object.errors.empty? || !@object.errors[method.to_sym].present? || [@object.errors[method.to_sym]].flatten.empty?)
53
- end
54
-
55
- ##
56
- #
57
- # Checks a passed validator to see if it is required
58
- # 'borrowed' from Formtastic by Justin French (see https://github.com/justinfrench/formtastic)
59
- #
60
- # @param [Hash] options Validator options
61
- #
62
- def options_require_validation?(options)
63
-
64
- allow_blank = options[:allow_blank]
65
- return !allow_blank unless allow_blank.nil?
66
- if_condition = !options[:if].nil?
67
- condition = if_condition ? options[:if] : options[:unless]
68
-
69
- condition = if condition.respond_to?(:call)
70
- condition.call(@object)
71
- elsif condition.is_a?(::Symbol) && @object.respond_to?(condition)
72
- @object.send(condition)
73
- else
74
- condition
75
- end
76
- if_condition ? !!condition : !condition
77
- end
78
-
79
- ##
80
- #
81
- # Checks an options hash to determine if a required method/attribute was overridden manually
82
- # @param [Hash] options The options hash to check
83
- #
84
- #
85
- def required_by_option?(options)
86
- req = (options.is_a?(Hash) ? options.stringify_keys[:required] : options)
87
- !(req.to_s === 'false' || req.nil?)
88
- end
89
-
90
- ##
91
- #
92
- # Wrapper method used by all form fields to customize the output
93
- #
94
- # @param [Symbol] helper_method Original Rails helper method name
95
- # @param [Symbol] method Object method / symbol used for the element
96
- # @param [Array] args Array of original arguments passed to the helper
97
- #
98
- # @return [String] Rendered HTML tag for the element
99
- #
100
- def render_field_as_custom(helper_method, method, *args)
101
-
102
- @current_field_type = helper_method
103
-
104
- options = args.extract_options!
105
- (@field_order ||= []) << method
106
-
107
- # Add an error class to the field if it has errors
108
- #
109
- if errors_on_attribute?(method)
110
- klasses = (options.delete(:class) || "").split(" ")
111
- klasses << 'field-with-error'
112
- options[:class] = klasses.join(" ")
113
- end
114
-
115
- # Add a required attribute to the field if it is required
116
- # Skip if false was passed as the required option
117
- #
118
- options[:required] = "required" if attribute_required?(method) && options.delete(:required).to_s != 'false'
119
- options['data-validates-uniqueness'] = "true" if validates_uniqueness?(method)
120
-
121
- result = send(:"_super_#{helper_method}", method, *(args << options))
122
- messages = @object.nil? ? [] : @object.errors[method]
123
- render_field_with_errors(method, result, messages)
124
-
125
- end
126
-
127
- ##
128
- #
129
- # Renders the passed +html_tag+ with the custom error_template
130
- #
131
- # @param [Symbol] method The method/attribute to check for errors
132
- # @param [Object, String] html_tag Instance of an input tag or a string
133
- # @param [Array] messages An array of all error messages to be added to the template
134
- #
135
- def render_field_with_errors(method, html_tag, messages)
136
- return html_tag unless errors_on_attribute?(method)
137
- error_template = %{
138
- <span class="field-with-errors">
139
- <%= html_tag %>
140
- <span class="errors-for-field"><%= [messages].flatten.join(",") %></span>
141
- </span>}
142
-
143
- render_binding = binding
144
- renderer = ERB.new(error_template)
145
- renderer.result(render_binding).to_s.html_safe
146
- end
147
-
148
- ##
149
- #
150
- # Compiles an array of all validators for a particular attribute
151
- # @param [Symbol] attribtue The attribute to check
152
- #
153
- def validators_for(attribute)
154
-
155
- return [] if @object.nil?
156
- return [] unless @object.class.respond_to?(:validators_on)
157
-
158
- attribute = attribute.to_s.sub(/_id$/, '').to_sym
159
- @object.class.validators_on(attribute).uniq
160
-
161
- end
162
-
163
- ##
164
- #
165
- # Convenience method to see if a particular attribute has validators
166
- # @param [Symbol] attribute The attribute to check
167
- #
168
- def validators_for?(attribute)
169
- !validators_for(attribute).empty?
170
- end
171
-
172
- ##
173
- #
174
- # Checks for a presence validation on a particular attribute
175
- # @param [Symbol] attribute The attribute to check
176
- #
177
- def validates_presence?(attribute)
178
- validator_of_type_exists?(validators_for(attribute), :presence)
179
- end
180
-
181
- ##
182
- #
183
- # Checks for a uniqueness validation on a particular attribute
184
- # @param [Symbol] attribute The attribute to check
185
- #
186
- def validates_uniqueness?(attribute)
187
- validator_of_type_exists?(validators_for(attribute), :uniqueness, false)
188
- end
189
-
190
- ##
191
- #
192
- # Checks for inclusion validation on a particular attribute
193
- # @param [Symbol] attribute The attribute to check
194
- #
195
- def validates_inclusion?(attribute)
196
- validator_of_type_exists?(validators_for(attribute), :inclusion)
197
- end
198
-
199
- private
200
-
201
- def validator_of_type_exists?(validators, kind, check_options = true) #:nodoc: @private
202
- validators.detect do |validator|
203
- exists = (validator.kind.to_s == kind.to_s)
204
- next exists unless (check_options && exists) && validator.options.present?
205
- options_require_validation?(validator.options)
206
- end
207
- end
208
-
209
-
210
- end
211
- end
212
- end
@@ -1,112 +0,0 @@
1
- module Facades::Builders
2
- module FormBuilder
3
- module Elements
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- # create overrides for custom rendering
8
- [:email_field, :password_field, :text_field, :text_area, :url_field, :select].each do |method|
9
- class_eval <<-FUNC, __FILE__, __LINE__ + 1
10
-
11
- alias :_super_#{method} :#{method}
12
-
13
- def #{method}(method_name, *args)
14
- render_field_as_custom(:#{method}, method_name, *args)
15
- end
16
- FUNC
17
- end
18
- end
19
-
20
- ##
21
- # Modified label tag to support adding a 'required' asterisk to the end of the label.
22
- # Same params as the original implementation
23
- #
24
- def label(method, text = nil, options = {}, &block) #:nodoc:
25
-
26
- options, text = text, nil if text.is_a?(Hash)
27
- text ||= method.to_s.humanize
28
-
29
- options.stringify_keys!
30
- klasses = (options.delete(['class']) || "").split(" ")
31
- klasses << 'field-with-error' if errors_on_attribute?(method)
32
- options['class'] = klasses.join(" ") unless klasses.compact.empty?
33
-
34
- text = "#{text} <abbr title='Required'>*</abbr>".html_safe if attribute_required?(method) || required_by_option?(options.delete('required'))
35
- super(method, text, options, &block)
36
-
37
- end
38
-
39
- ##
40
- #
41
- # Creates a button tag to be used in a form instead of the default input[type=submit]
42
- # to help make CSS styling easier
43
- #
44
- # @param [String] value The text for the button
45
- # @param [Hash] options HTML options to be passed to the button
46
- # @option [String] icon If included, adds an image to the button to be used as an icon
47
- #
48
- def button(value = nil, options = {})
49
-
50
- value, options = nil, value if value.is_a?(Hash)
51
- value ||= submit_default_value
52
-
53
- value = [image_tag(icon, :class => 'icon'), value].join(' ') if icon = options.delete(:icon)
54
- klasses = (options.delete(:class) || "").split(" ")
55
- klasses << "button"
56
- options['class'] = klasses.join(" ")
57
- content_tag(:button, value.to_s.html_safe, options.reverse_merge!({ "type" => "submit", "name" => "commit" }))
58
-
59
- end
60
-
61
- ##
62
- #
63
- # Generate a select tag with the 50 US states as options
64
- #
65
- # @param [Symbol] method The object method/attribute to be used
66
- # @param [Hash] options Same as Rails' select options hash
67
- # @option options [Symbol] :international Include an international option
68
- # @option options [Symbol] :abbreviate Use an abbreviated version of the state name for the value
69
- # @param [Hash] html_options Same as Rails' html_options hash
70
- #
71
- # @return [String] HTML select tag
72
- #
73
- def state_select(method, options = {}, html_options = {})
74
- abbr = options.delete(:abbreviate)
75
- abbr = !(abbr.nil? || abbr === false)
76
- select(method, @template.options_for_select(options_for_state_select(abbr, options.delete(:international)), @object.try(:state)), options, html_options)
77
- end
78
-
79
- protected
80
-
81
- ##
82
- #
83
- # Returns a list of US states as an array
84
- #
85
- # @param [Boolean] abbreviate Abbreviate the value
86
- # @param [Boolean, String] incl_international Include an additional state for "International"
87
- #
88
- # @return [Array] An array of states
89
- #
90
- def options_for_state_select(abbreviate = false, incl_international = false)
91
- incl_international ||= false
92
- state_list = [
93
- ['Alabama', "AL"],['Alaska', "AK"],['Arizona', "AZ"],['Arkansas', "AR"],['California', "CA"],['Colorado', "CO"],
94
- ['Connecticut', "CT"],['District of Columbia', "DC"],['Delaware', "DE"],['Florida', "FL"],['Georgia', "GA"],
95
- ['Hawaii', "HI"],['Idaho', "ID"],['Illinois', "IL"],['Indiana', "IN"],['Iowa', "IA"],['Kansas', "KS"],['Kentucky', "KY"],
96
- ['Louisiana', "LA"],['Maine', "ME"],['Maryland', "MD"],['Massachusetts', "MA"],['Michigan', "MI"],['Minnesota', "MN"],
97
- ['Mississippi', "MS"],['Missouri', "MO"],['Montana', "MT"],['Nebraska', "NE"],['Nevada', "NV"],['New Hampshire', "NH"],
98
- ['New Jersey', "NJ"],['New Mexico', "NM"],['New York', "NY"],['North Carolina', "NC"],['North Dakota', "ND"],
99
- ['Ohio', "OH"],['Oklahoma', "OK"],['Oregon', "OR"],['Pennsylvania', "PA"],['Rhode Island', "RI"],['South Carolina', "SC"],
100
- ['South Dakota', "SD"],['Tennessee', "TN"],['Texas', "TX"],['Utah', "UT"],['Vermont', "VT"],['Virginia', "VA"],['Washington', "WA"],
101
- ['West Virginia', "WV"],['Wisconsin', "WI"],['Wyoming', "WY"]
102
-
103
- ].map do |state|
104
- (abbreviate ? state : [state.first, state.first])
105
- end
106
- state_list << ['International', incl_international] unless incl_international === false
107
- state_list
108
- end
109
-
110
- end
111
- end
112
- end