zurb-foundation 3.2.5 → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. data/.gitignore +6 -2
  2. data/CHANGELOG.md +1 -26
  3. data/CONTRIBUTING.md +18 -0
  4. data/Gemfile.lock +19 -0
  5. data/Gruntfile.js +27 -0
  6. data/README.md +5 -6
  7. data/{Capfile → docs/Capfile} +0 -1
  8. data/docs/Gemfile +8 -0
  9. data/docs/Gemfile.lock +43 -0
  10. data/docs/Procfile +2 -0
  11. data/docs/README.md +1 -0
  12. data/docs/_sidebar-components.html.erb +109 -0
  13. data/docs/_sidebar.html.erb +109 -0
  14. data/docs/_zurb-jobs.html.erb +5 -0
  15. data/docs/changelog.html.erb +185 -0
  16. data/docs/compile.rb +43 -0
  17. data/docs/components/alert-boxes.html.erb +202 -0
  18. data/docs/components/block-grid.html.erb +118 -0
  19. data/docs/components/breadcrumbs.html.erb +146 -0
  20. data/docs/components/button-groups.html.erb +174 -0
  21. data/docs/components/buttons.html.erb +220 -0
  22. data/docs/components/clearing.html.erb +152 -0
  23. data/docs/components/custom-forms.html.erb +306 -0
  24. data/docs/components/dropdown-buttons.html.erb +233 -0
  25. data/docs/components/dropdown.html.erb +186 -0
  26. data/docs/components/flex-video.html.erb +93 -0
  27. data/docs/components/forms.html.erb +468 -0
  28. data/docs/components/grid.html.erb +355 -0
  29. data/docs/components/inline-lists.html.erb +89 -0
  30. data/docs/components/joyride.html.erb +178 -0
  31. data/docs/components/keystrokes.html.erb +74 -0
  32. data/docs/components/labels.html.erb +98 -0
  33. data/docs/components/magellan.html.erb +84 -0
  34. data/docs/components/orbit.html.erb +262 -0
  35. data/docs/components/pagination.html.erb +181 -0
  36. data/docs/components/panels.html.erb +121 -0
  37. data/docs/components/pricing-tables.html.erb +154 -0
  38. data/docs/components/progress-bars.html.erb +120 -0
  39. data/docs/components/reveal.html.erb +147 -0
  40. data/docs/components/section.html.erb +156 -0
  41. data/docs/components/side-nav.html.erb +122 -0
  42. data/docs/components/split-buttons.html.erb +218 -0
  43. data/docs/components/sub-nav.html.erb +120 -0
  44. data/docs/components/switch.html.erb +288 -0
  45. data/docs/components/tables.html.erb +123 -0
  46. data/docs/components/thumbnails.html.erb +87 -0
  47. data/docs/components/tooltips.html.erb +73 -0
  48. data/docs/components/top-bar.html.erb +219 -0
  49. data/docs/components/type.html.erb +359 -0
  50. data/docs/components/visibility.html.erb +102 -0
  51. data/docs/config.ru +12 -0
  52. data/docs/config/deploy.rb +33 -0
  53. data/docs/controller.rb +43 -0
  54. data/docs/css/_coderay.scss +116 -0
  55. data/docs/css/_settings.scss +1 -0
  56. data/docs/css/docs.scss +174 -0
  57. data/docs/css/normalize.scss +396 -0
  58. data/docs/css/qunit-composite.css +13 -0
  59. data/docs/css/qunit.css +235 -0
  60. data/docs/faq.html.erb +61 -0
  61. data/docs/img/demos/demo1-th.png +0 -0
  62. data/docs/img/demos/demo1.png +0 -0
  63. data/docs/img/demos/demo2-th.png +0 -0
  64. data/docs/img/demos/demo2.png +0 -0
  65. data/docs/img/demos/demo3-th.png +0 -0
  66. data/docs/img/demos/demo3.png +0 -0
  67. data/docs/img/demos/demo4-th.png +0 -0
  68. data/docs/img/demos/demo4.png +0 -0
  69. data/docs/img/demos/demo5-th.png +0 -0
  70. data/docs/img/demos/demo5.png +0 -0
  71. data/docs/index.html.erb +299 -0
  72. data/docs/javascript.html.erb +133 -0
  73. data/docs/js/docs.js +3 -0
  74. data/docs/js/qunit-composite.js +105 -0
  75. data/docs/js/qunit.js +1977 -0
  76. data/docs/js/tests/tabs/simple_tabs.html +57 -0
  77. data/docs/js/tests/tabs/simple_tabs.js +54 -0
  78. data/docs/js/tests/tooltips/tooltips.html +39 -0
  79. data/docs/js/tests/tooltips/tooltips.js +11 -0
  80. data/docs/layout.html.erb +99 -0
  81. data/docs/rails.html.erb +66 -0
  82. data/docs/sass.html.erb +299 -0
  83. data/docs/support.html.erb +134 -0
  84. data/foundation.gemspec +2 -4
  85. data/index.html +3 -23
  86. data/js/foundation/foundation.alerts.js +50 -0
  87. data/js/foundation/foundation.clearing.js +478 -0
  88. data/{vendor/assets/javascripts/foundation/jquery.cookie.js → js/foundation/foundation.cookie.js} +3 -1
  89. data/js/foundation/foundation.dropdown.js +122 -0
  90. data/js/foundation/foundation.forms.js +403 -0
  91. data/js/foundation/foundation.joyride.js +613 -0
  92. data/js/foundation/foundation.js +331 -0
  93. data/js/foundation/foundation.magellan.js +130 -0
  94. data/js/foundation/foundation.orbit.js +355 -0
  95. data/{vendor/assets/javascripts/foundation/jquery.placeholder.js → js/foundation/foundation.placeholder.js} +4 -2
  96. data/js/foundation/foundation.reveal.js +264 -0
  97. data/js/foundation/foundation.section.js +180 -0
  98. data/js/foundation/foundation.tooltips.js +195 -0
  99. data/js/foundation/foundation.topbar.js +187 -0
  100. data/js/foundation/index.js +16 -0
  101. data/{vendor/assets/javascripts/foundation/modernizr.foundation.js → js/vendor/custom.modernizr.js} +0 -0
  102. data/js/vendor/jquery.js +9597 -0
  103. data/js/vendor/zepto.js +1782 -0
  104. data/lib/foundation/engine.rb +8 -1
  105. data/lib/foundation/generators/install_generator.rb +24 -1
  106. data/lib/foundation/generators/templates/application.html.erb +20 -6
  107. data/lib/foundation/generators/templates/application.html.haml +2 -6
  108. data/lib/foundation/generators/templates/application.html.slim +2 -5
  109. data/lib/foundation/version.rb +1 -1
  110. data/lib/zurb-foundation.rb +7 -9
  111. data/package.json +9 -0
  112. data/scss/foundation.scss +42 -15
  113. data/scss/foundation/_foundation-global.scss +226 -0
  114. data/scss/foundation/components/_alert-boxes.scss +106 -0
  115. data/scss/foundation/components/_block-grid.scss +63 -0
  116. data/scss/foundation/components/_breadcrumbs.scss +117 -0
  117. data/scss/foundation/components/_button-groups.scss +59 -0
  118. data/scss/foundation/components/_buttons.scss +217 -0
  119. data/scss/foundation/components/_clearing.scss +209 -0
  120. data/scss/foundation/components/_custom-forms.scss +232 -0
  121. data/scss/foundation/components/_dropdown-buttons.scss +114 -0
  122. data/scss/foundation/components/_dropdown.scss +137 -0
  123. data/scss/foundation/components/_flex-video.scss +45 -0
  124. data/scss/foundation/components/_forms.scss +309 -0
  125. data/scss/foundation/components/_grid.scss +149 -71
  126. data/scss/foundation/components/_inline-lists.scss +47 -0
  127. data/scss/foundation/components/_joyride.scss +193 -0
  128. data/scss/foundation/components/_keystrokes.scss +56 -0
  129. data/scss/foundation/components/_labels.scss +81 -0
  130. data/scss/foundation/components/_magellan.scss +15 -0
  131. data/scss/foundation/components/_orbit.scss +193 -0
  132. data/scss/foundation/components/_pagination.scss +99 -0
  133. data/scss/foundation/components/_panels.scss +76 -0
  134. data/scss/foundation/components/_pricing-tables.scss +130 -0
  135. data/scss/foundation/components/_progress-bars.scss +68 -0
  136. data/scss/foundation/components/_reveal.scss +131 -0
  137. data/scss/foundation/components/_section.scss +194 -0
  138. data/scss/foundation/components/_side-nav.scss +68 -0
  139. data/scss/foundation/components/_split-buttons.scss +159 -0
  140. data/scss/foundation/components/_sub-nav.scss +67 -0
  141. data/scss/foundation/components/_switch.scss +242 -0
  142. data/scss/foundation/components/_tables.scss +80 -0
  143. data/scss/foundation/components/_thumbs.scss +45 -0
  144. data/scss/foundation/components/_tooltips.scss +113 -0
  145. data/scss/foundation/components/_top-bar.scss +443 -0
  146. data/scss/foundation/components/_type.scss +411 -0
  147. data/scss/foundation/components/_visibility.scss +117 -0
  148. data/scss/normalize.scss +396 -0
  149. data/templates/project/config.rb +26 -0
  150. data/templates/project/index.html +28 -43
  151. data/templates/project/manifest.rb +21 -28
  152. data/templates/project/scss/_settings.scss +4 -243
  153. data/templates/project/scss/app.scss +37 -44
  154. data/templates/project/scss/normalize.scss +396 -0
  155. data/test/stylesheets/styles.css +955 -0
  156. metadata +144 -153
  157. data/config/deploy.rb +0 -42
  158. data/lib/foundation/generators/layout_generator.rb +0 -28
  159. data/scss/foundation/_settings.scss +0 -281
  160. data/scss/foundation/common/_base.scss +0 -4
  161. data/scss/foundation/common/_forms.scss +0 -117
  162. data/scss/foundation/common/_globals.scss +0 -35
  163. data/scss/foundation/common/_ratios.scss +0 -19
  164. data/scss/foundation/common/_typography.scss +0 -104
  165. data/scss/foundation/components/modules/_all.scss +0 -10
  166. data/scss/foundation/components/modules/_buttons.scss +0 -178
  167. data/scss/foundation/components/modules/_clearing.scss +0 -61
  168. data/scss/foundation/components/modules/_joyride.scss +0 -33
  169. data/scss/foundation/components/modules/_mqueries.scss +0 -458
  170. data/scss/foundation/components/modules/_navbar.scss +0 -74
  171. data/scss/foundation/components/modules/_offcanvas.scss +0 -55
  172. data/scss/foundation/components/modules/_orbit.scss +0 -90
  173. data/scss/foundation/components/modules/_reveal.scss +0 -34
  174. data/scss/foundation/components/modules/_tabs.scss +0 -67
  175. data/scss/foundation/components/modules/_topbar.scss +0 -167
  176. data/scss/foundation/components/modules/_ui.scss +0 -292
  177. data/scss/foundation/functions/_all.scss +0 -2
  178. data/scss/foundation/functions/_convert-number-to-word.scss +0 -10
  179. data/scss/foundation/functions/_grid-calc.scss +0 -5
  180. data/scss/foundation/functions/modular-scale.scss +0 -3
  181. data/scss/foundation/mixins/_all.scss +0 -5
  182. data/scss/foundation/mixins/_clearfix.scss +0 -13
  183. data/scss/foundation/mixins/_css-triangle.scss +0 -22
  184. data/scss/foundation/mixins/_font-size.scss +0 -13
  185. data/scss/foundation/mixins/_respond-to.scss +0 -11
  186. data/scss/foundation/mixins/_semantic-grid.scss +0 -66
  187. data/test/buttons.html +0 -189
  188. data/test/clearing.html +0 -85
  189. data/test/config.rb +0 -11
  190. data/test/elements.html +0 -490
  191. data/test/forms.html +0 -371
  192. data/test/grid.html +0 -543
  193. data/test/images/orbit-demo/demo1.jpeg +0 -0
  194. data/test/images/orbit-demo/demo2.jpeg +0 -0
  195. data/test/images/orbit-demo/demo3.jpeg +0 -0
  196. data/test/images/orbit-demo/slider-background.jpeg +0 -0
  197. data/test/index.html +0 -83
  198. data/test/joyride.html +0 -127
  199. data/test/magellan.html +0 -112
  200. data/test/navigation.html +0 -269
  201. data/test/orbit.html +0 -112
  202. data/test/reveal.html +0 -91
  203. data/test/scss/_settings.scss +0 -245
  204. data/test/scss/styles.scss +0 -50
  205. data/test/tabs.html +0 -197
  206. data/test/template.html +0 -52
  207. data/test/topbar-login.html +0 -194
  208. data/test/topbar.html +0 -139
  209. data/test/type.html +0 -188
  210. data/vendor/assets/images/foundation/orbit/bullets.jpg +0 -0
  211. data/vendor/assets/images/foundation/orbit/left-arrow-small.png +0 -0
  212. data/vendor/assets/images/foundation/orbit/left-arrow.png +0 -0
  213. data/vendor/assets/images/foundation/orbit/loading.gif +0 -0
  214. data/vendor/assets/images/foundation/orbit/mask-black.png +0 -0
  215. data/vendor/assets/images/foundation/orbit/pause-black.png +0 -0
  216. data/vendor/assets/images/foundation/orbit/right-arrow-small.png +0 -0
  217. data/vendor/assets/images/foundation/orbit/right-arrow.png +0 -0
  218. data/vendor/assets/images/foundation/orbit/rotator-black.png +0 -0
  219. data/vendor/assets/images/foundation/orbit/timer-black.png +0 -0
  220. data/vendor/assets/javascripts/foundation/app.js +0 -41
  221. data/vendor/assets/javascripts/foundation/index.js +0 -19
  222. data/vendor/assets/javascripts/foundation/jquery.event.move.js +0 -580
  223. data/vendor/assets/javascripts/foundation/jquery.event.swipe.js +0 -130
  224. data/vendor/assets/javascripts/foundation/jquery.foundation.accordion.js +0 -47
  225. data/vendor/assets/javascripts/foundation/jquery.foundation.alerts.js +0 -20
  226. data/vendor/assets/javascripts/foundation/jquery.foundation.buttons.js +0 -83
  227. data/vendor/assets/javascripts/foundation/jquery.foundation.clearing.js +0 -413
  228. data/vendor/assets/javascripts/foundation/jquery.foundation.forms.js +0 -502
  229. data/vendor/assets/javascripts/foundation/jquery.foundation.joyride.js +0 -639
  230. data/vendor/assets/javascripts/foundation/jquery.foundation.magellan.js +0 -96
  231. data/vendor/assets/javascripts/foundation/jquery.foundation.mediaQueryToggle.js +0 -27
  232. data/vendor/assets/javascripts/foundation/jquery.foundation.navigation.js +0 -55
  233. data/vendor/assets/javascripts/foundation/jquery.foundation.orbit.js +0 -919
  234. data/vendor/assets/javascripts/foundation/jquery.foundation.reveal.js +0 -794
  235. data/vendor/assets/javascripts/foundation/jquery.foundation.tabs.js +0 -66
  236. data/vendor/assets/javascripts/foundation/jquery.foundation.tooltips.js +0 -211
  237. data/vendor/assets/javascripts/foundation/jquery.foundation.topbar.js +0 -174
  238. data/vendor/assets/javascripts/foundation/jquery.js +0 -9555
  239. data/vendor/assets/javascripts/foundation/jquery.offcanvas.js +0 -50
@@ -1,502 +0,0 @@
1
- /*
2
- * jQuery Custom Forms Plugin 1.0
3
- * www.ZURB.com
4
- * Copyright 2010, ZURB
5
- * Free to use under the MIT license.
6
- * http://www.opensource.org/licenses/mit-license.php
7
- */
8
-
9
- (function( $ ){
10
-
11
- /**
12
- * Helper object used to quickly adjust all hidden parent element's, display and visibility properties.
13
- * This is currently used for the custom drop downs. When the dropdowns are contained within a reveal modal
14
- * we cannot accurately determine the list-item elements width property, since the modal's display property is set
15
- * to 'none'.
16
- *
17
- * This object will help us work around that problem.
18
- *
19
- * NOTE: This could also be plugin.
20
- *
21
- * @function hiddenFix
22
- */
23
- var hiddenFix = function() {
24
-
25
- return {
26
- /**
27
- * Sets all hidden parent elements and self to visibile.
28
- *
29
- * @method adjust
30
- * @param {jQuery Object} $child
31
- */
32
-
33
- // We'll use this to temporarily store style properties.
34
- tmp : [],
35
-
36
- // We'll use this to set hidden parent elements.
37
- hidden : null,
38
-
39
- adjust : function( $child ) {
40
- // Internal reference.
41
- var _self = this;
42
-
43
- // Set all hidden parent elements, including this element.
44
- _self.hidden = $child.parents().andSelf().filter( ":hidden" );
45
-
46
- // Loop through all hidden elements.
47
- _self.hidden.each( function() {
48
-
49
- // Cache the element.
50
- var $elem = $( this );
51
-
52
- // Store the style attribute.
53
- // Undefined if element doesn't have a style attribute.
54
- _self.tmp.push( $elem.attr( 'style' ) );
55
-
56
- // Set the element's display property to block,
57
- // but ensure it's visibility is hidden.
58
- $elem.css( { 'visibility' : 'hidden', 'display' : 'block' } );
59
- });
60
-
61
- }, // end adjust
62
-
63
- /**
64
- * Resets the elements previous state.
65
- *
66
- * @method reset
67
- */
68
- reset : function() {
69
- // Internal reference.
70
- var _self = this;
71
- // Loop through our hidden element collection.
72
- _self.hidden.each( function( i ) {
73
- // Cache this element.
74
- var $elem = $( this ),
75
- _tmp = _self.tmp[ i ]; // Get the stored 'style' value for this element.
76
-
77
- // If the stored value is undefined.
78
- if( _tmp === undefined )
79
- // Remove the style attribute.
80
- $elem.removeAttr( 'style' );
81
- else
82
- // Otherwise, reset the element style attribute.
83
- $elem.attr( 'style', _tmp );
84
-
85
- });
86
- // Reset the tmp array.
87
- _self.tmp = [];
88
- // Reset the hidden elements variable.
89
- _self.hidden = null;
90
-
91
- } // end reset
92
-
93
- }; // end return
94
-
95
- };
96
-
97
- jQuery.foundation = jQuery.foundation || {};
98
- jQuery.foundation.customForms = jQuery.foundation.customForms || {};
99
-
100
- $.foundation.customForms.appendCustomMarkup = function ( options ) {
101
-
102
- var defaults = {
103
- disable_class: "no-custom"
104
- };
105
-
106
- options = $.extend( defaults, options );
107
-
108
- function appendCustomMarkup(idx, sel) {
109
- var $this = $(sel).hide(),
110
- type = $this.attr('type'),
111
- $span = $this.next('span.custom.' + type);
112
-
113
- if ($span.length === 0) {
114
- $span = $('<span class="custom ' + type + '"></span>').insertAfter($this);
115
- }
116
-
117
- $span.toggleClass('checked', $this.is(':checked'));
118
- $span.toggleClass('disabled', $this.is(':disabled'));
119
- }
120
-
121
- function appendCustomSelect(idx, sel) {
122
- var hiddenFixObj = hiddenFix();
123
- //
124
- // jQueryify the <select> element and cache it.
125
- //
126
- var $this = $( sel ),
127
- //
128
- // Find the custom drop down element.
129
- //
130
- $customSelect = $this.next( 'div.custom.dropdown' ),
131
- //
132
- // Find the custom select element within the custom drop down.
133
- //
134
- $customList = $customSelect.find( 'ul' ),
135
- //
136
- // Find the custom a.current element.
137
- //
138
- $selectCurrent = $customSelect.find( ".current" ),
139
- //
140
- // Find the custom a.selector element (the drop-down icon).
141
- //
142
- $selector = $customSelect.find( ".selector" ),
143
- //
144
- // Get the <options> from the <select> element.
145
- //
146
- $options = $this.find( 'option' ),
147
- //
148
- // Filter down the selected options
149
- //
150
- $selectedOption = $options.filter( ':selected' ),
151
- //
152
- // Initial max width.
153
- //
154
- maxWidth = 0,
155
- //
156
- // We'll use this variable to create the <li> elements for our custom select.
157
- //
158
- liHtml = '',
159
- //
160
- // We'll use this to cache the created <li> elements within our custom select.
161
- //
162
- $listItems
163
- ;
164
- var $currentSelect = false;
165
- //
166
- // Should we not create a custom list?
167
- //
168
- if ( $this.hasClass( options.disable_class ) ) return;
169
-
170
- //
171
- // Did we not create a custom select element yet?
172
- //
173
- if ( $customSelect.length === 0 ) {
174
- //
175
- // Let's create our custom select element!
176
- //
177
-
178
- //
179
- // Determine what select size to use.
180
- //
181
- var customSelectSize = $this.hasClass( 'small' ) ? 'small' :
182
- $this.hasClass( 'medium' ) ? 'medium' :
183
- $this.hasClass( 'large' ) ? 'large' :
184
- $this.hasClass( 'expand' ) ? 'expand' : ''
185
- ;
186
- //
187
- // Build our custom list.
188
- //
189
- $customSelect = $('<div class="' + ['custom', 'dropdown', customSelectSize ].join( ' ' ) + '"><a href="#" class="selector"></a><ul /></div>');
190
- //
191
- // Grab the selector element
192
- //
193
- $selector = $customSelect.find( ".selector" );
194
- //
195
- // Grab the unordered list element from the custom list.
196
- //
197
- $customList = $customSelect.find( "ul" );
198
- //
199
- // Build our <li> elements.
200
- //
201
- liHtml = $options.map( function() { return "<li>" + $( this ).html() + "</li>"; } ).get().join( '' );
202
- //
203
- // Append our <li> elements to the custom list (<ul>).
204
- //
205
- $customList.append( liHtml );
206
- //
207
- // Insert the the currently selected list item before all other elements.
208
- // Then, find the element and assign it to $currentSelect.
209
- //
210
-
211
- $currentSelect = $customSelect.prepend( '<a href="#" class="current">' + $selectedOption.html() + '</a>' ).find( ".current" );
212
- //
213
- // Add the custom select element after the <select> element.
214
- //
215
- $this.after( $customSelect )
216
- //
217
- //then hide the <select> element.
218
- //
219
- .hide();
220
-
221
- } else {
222
- //
223
- // Create our list item <li> elements.
224
- //
225
- liHtml = $options.map( function() { return "<li>" + $( this ).html() + "</li>"; } ).get().join( '' );
226
- //
227
- // Refresh the ul with options from the select in case the supplied markup doesn't match.
228
- // Clear what's currently in the <ul> element.
229
- //
230
- $customList.html( '' )
231
- //
232
- // Populate the list item <li> elements.
233
- //
234
- .append( liHtml );
235
-
236
- } // endif $customSelect.length === 0
237
-
238
- //
239
- // Determine whether or not the custom select element should be disabled.
240
- //
241
- $customSelect.toggleClass( 'disabled', $this.is( ':disabled' ) );
242
- //
243
- // Cache our List item elements.
244
- //
245
- $listItems = $customList.find( 'li' );
246
-
247
- //
248
- // Determine which elements to select in our custom list.
249
- //
250
- $options.each( function ( index ) {
251
-
252
- if ( this.selected ) {
253
- //
254
- // Add the selected class to the current li element
255
- //
256
- $listItems.eq( index ).addClass( 'selected' );
257
- //
258
- // Update the current element with the option value.
259
- //
260
- if ($currentSelect) {
261
- $currentSelect.html( $( this ).html() );
262
- }
263
-
264
- }
265
-
266
- });
267
-
268
- //
269
- // Update the custom <ul> list width property.
270
- //
271
- $customList.css( 'width', 'auto' );
272
- //
273
- // Set the custom select width property.
274
- //
275
- $customSelect.css( 'width', 'auto' );
276
-
277
- //
278
- // If we're not specifying a predetermined form size.
279
- //
280
- if ( !$customSelect.is( '.small, .medium, .large, .expand' ) ) {
281
-
282
- // ------------------------------------------------------------------------------------
283
- // This is a work-around for when elements are contained within hidden parents.
284
- // For example, when custom-form elements are inside of a hidden reveal modal.
285
- //
286
- // We need to display the current custom list element as well as hidden parent elements
287
- // in order to properly calculate the list item element's width property.
288
- // -------------------------------------------------------------------------------------
289
-
290
- //
291
- // Show the drop down.
292
- // This should ensure that the list item's width values are properly calculated.
293
- //
294
- $customSelect.addClass( 'open' );
295
- //
296
- // Quickly, display all parent elements.
297
- // This should help us calcualate the width of the list item's within the drop down.
298
- //
299
- hiddenFixObj.adjust( $customList );
300
- //
301
- // Grab the largest list item width.
302
- //
303
- maxWidth = ( $listItems.outerWidth() > maxWidth ) ? $listItems.outerWidth() : maxWidth;
304
- //
305
- // Okay, now reset the parent elements.
306
- // This will hide them again.
307
- //
308
- hiddenFixObj.reset();
309
- //
310
- // Finally, hide the drop down.
311
- //
312
- $customSelect.removeClass( 'open' );
313
- //
314
- // Set the custom list width.
315
- //
316
- $customSelect.width( maxWidth + 18);
317
- //
318
- // Set the custom list element (<ul />) width.
319
- //
320
- $customList.width( maxWidth + 16 );
321
-
322
- } // endif
323
-
324
- }
325
-
326
- $('form.custom input:radio[data-customforms!=disabled]').each(appendCustomMarkup);
327
- $('form.custom input:checkbox[data-customforms!=disabled]').each(appendCustomMarkup);
328
- $('form.custom select[data-customforms!=disabled]').each(appendCustomSelect);
329
- };
330
-
331
- var refreshCustomSelect = function($select) {
332
- var maxWidth = 0,
333
- $customSelect = $select.next();
334
- $options = $select.find('option');
335
- $customSelect.find('ul').html('');
336
-
337
- $options.each(function () {
338
- $li = $('<li>' + $(this).html() + '</li>');
339
- $customSelect.find('ul').append($li);
340
- });
341
-
342
- // re-populate
343
- $options.each(function (index) {
344
- if (this.selected) {
345
- $customSelect.find('li').eq(index).addClass('selected');
346
- $customSelect.find('.current').html($(this).html());
347
- }
348
- });
349
-
350
- // fix width
351
- $customSelect.removeAttr('style')
352
- .find('ul').removeAttr('style');
353
- $customSelect.find('li').each(function () {
354
- $customSelect.addClass('open');
355
- if ($(this).outerWidth() > maxWidth) {
356
- maxWidth = $(this).outerWidth();
357
- }
358
- $customSelect.removeClass('open');
359
- });
360
- $customSelect.css('width', maxWidth + 18 + 'px');
361
- $customSelect.find('ul').css('width', maxWidth + 16 + 'px');
362
-
363
- };
364
-
365
- var toggleCheckbox = function($element) {
366
- var $input = $element.prev(),
367
- input = $input[0];
368
-
369
- if (false === $input.is(':disabled')) {
370
- input.checked = ((input.checked) ? false : true);
371
- $element.toggleClass('checked');
372
-
373
- $input.trigger('change');
374
- }
375
- };
376
-
377
- var toggleRadio = function($element) {
378
- var $input = $element.prev(),
379
- $form = $input.closest('form.custom'),
380
- input = $input[0];
381
-
382
- if (false === $input.is(':disabled')) {
383
- $form.find('input:radio[name="' + $input.attr('name') + '"]').next().not($element).removeClass('checked');
384
- if ( !$element.hasClass('checked') ) {
385
- $element.toggleClass('checked');
386
- }
387
- input.checked = $element.hasClass('checked');
388
-
389
- $input.trigger('change');
390
- }
391
- };
392
-
393
- $(document).on('click', 'form.custom span.custom.checkbox', function (event) {
394
- event.preventDefault();
395
- event.stopPropagation();
396
-
397
- toggleCheckbox($(this));
398
- });
399
-
400
- $(document).on('click', 'form.custom span.custom.radio', function (event) {
401
- event.preventDefault();
402
- event.stopPropagation();
403
-
404
- toggleRadio($(this));
405
- });
406
-
407
- $(document).on('change', 'form.custom select[data-customforms!=disabled]', function (event) {
408
- refreshCustomSelect($(this));
409
- });
410
-
411
- $(document).on('click', 'form.custom label', function (event) {
412
- var $associatedElement = $('#' + $(this).attr('for') + '[data-customforms!=disabled]'),
413
- $customCheckbox,
414
- $customRadio;
415
- if ($associatedElement.length !== 0) {
416
- if ($associatedElement.attr('type') === 'checkbox') {
417
- event.preventDefault();
418
- $customCheckbox = $(this).find('span.custom.checkbox');
419
- //the checkbox might be outside after the label
420
- if ($customCheckbox.length == 0) {
421
- $customCheckbox = $(this).next('span.custom.checkbox');
422
- }
423
- //the checkbox might be outside before the label
424
- if ($customCheckbox.length == 0) {
425
- $customCheckbox = $(this).prev('span.custom.checkbox');
426
- }
427
- toggleCheckbox($customCheckbox);
428
- } else if ($associatedElement.attr('type') === 'radio') {
429
- event.preventDefault();
430
- $customRadio = $(this).find('span.custom.radio');
431
- //the radio might be outside after the label
432
- if ($customRadio.length == 0) {
433
- $customRadio = $(this).next('span.custom.radio');
434
- }
435
- //the radio might be outside before the label
436
- if ($customRadio.length == 0) {
437
- $customRadio = $(this).prev('span.custom.radio');
438
- }
439
- toggleRadio($customRadio);
440
- }
441
- }
442
- });
443
-
444
- $(document).on('click', 'form.custom div.custom.dropdown a.current, form.custom div.custom.dropdown a.selector', function (event) {
445
- var $this = $(this),
446
- $dropdown = $this.closest('div.custom.dropdown'),
447
- $select = $dropdown.prev();
448
-
449
- event.preventDefault();
450
- $('div.dropdown').removeClass('open');
451
-
452
- if (false === $select.is(':disabled')) {
453
- $dropdown.toggleClass('open');
454
-
455
- if ($dropdown.hasClass('open')) {
456
- $(document).bind('click.customdropdown', function (event) {
457
- $dropdown.removeClass('open');
458
- $(document).unbind('.customdropdown');
459
- });
460
- } else {
461
- $(document).unbind('.customdropdown');
462
- }
463
- return false;
464
- }
465
- });
466
-
467
- $(document).on('click', 'form.custom div.custom.dropdown li', function (event) {
468
- var $this = $(this),
469
- $customDropdown = $this.closest('div.custom.dropdown'),
470
- $select = $customDropdown.prev(),
471
- selectedIndex = 0;
472
-
473
- event.preventDefault();
474
- event.stopPropagation();
475
- $('div.dropdown').removeClass('open');
476
-
477
- $this
478
- .closest('ul')
479
- .find('li')
480
- .removeClass('selected');
481
- $this.addClass('selected');
482
-
483
- $customDropdown
484
- .removeClass('open')
485
- .find('a.current')
486
- .html($this.html());
487
-
488
- $this.closest('ul').find('li').each(function (index) {
489
- if ($this[0] == this) {
490
- selectedIndex = index;
491
- }
492
-
493
- });
494
- $select[0].selectedIndex = selectedIndex;
495
-
496
- $select.trigger('change');
497
- });
498
-
499
-
500
- $.fn.foundationCustomForms = $.foundation.customForms.appendCustomMarkup;
501
-
502
- })( jQuery );