materialize-sass 0.97.0 → 1.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +5 -5
  2. data/.gitattributes +1 -0
  3. data/.gitignore +3 -0
  4. data/README.md +48 -10
  5. data/Rakefile +129 -1
  6. data/assets/javascripts/materialize/anime.min.js +417 -0
  7. data/assets/javascripts/materialize/autocomplete.js +504 -0
  8. data/assets/javascripts/materialize/buttons.js +409 -0
  9. data/assets/javascripts/materialize/cards.js +34 -0
  10. data/assets/javascripts/materialize/carousel.js +797 -0
  11. data/assets/javascripts/materialize/cash.js +990 -0
  12. data/assets/javascripts/materialize/characterCounter.js +180 -0
  13. data/assets/javascripts/materialize/chips.js +564 -0
  14. data/assets/javascripts/materialize/collapsible.js +337 -0
  15. data/assets/javascripts/materialize/component.js +57 -0
  16. data/assets/javascripts/materialize/datepicker.js +935 -0
  17. data/assets/javascripts/materialize/dropdown.js +659 -0
  18. data/assets/javascripts/materialize/extras/nouislider.js +2147 -0
  19. data/assets/javascripts/materialize/extras/nouislider.min.js +1 -0
  20. data/assets/javascripts/materialize/forms.js +244 -0
  21. data/assets/javascripts/materialize/global.js +408 -0
  22. data/assets/javascripts/materialize/materialbox.js +513 -0
  23. data/assets/javascripts/materialize/modal.js +449 -0
  24. data/assets/javascripts/materialize/parallax.js +173 -0
  25. data/assets/javascripts/materialize/pushpin.js +179 -0
  26. data/assets/javascripts/materialize/range.js +310 -0
  27. data/assets/javascripts/materialize/scrollspy.js +328 -0
  28. data/assets/javascripts/materialize/select.js +497 -0
  29. data/assets/javascripts/materialize/sidenav.js +655 -0
  30. data/assets/javascripts/materialize/slider.js +424 -0
  31. data/assets/javascripts/materialize/tabs.js +476 -0
  32. data/assets/javascripts/materialize/tapTarget.js +364 -0
  33. data/assets/javascripts/materialize/timepicker.js +647 -0
  34. data/assets/javascripts/materialize/toasts.js +355 -0
  35. data/assets/javascripts/materialize/tooltip.js +351 -0
  36. data/{app/assets → assets}/javascripts/materialize/waves.js +42 -47
  37. data/assets/javascripts/materialize-sprockets.js +29 -0
  38. data/assets/javascripts/materialize.js +12374 -0
  39. data/assets/stylesheets/materialize/components/_badges.scss +55 -0
  40. data/assets/stylesheets/materialize/components/_buttons.scss +322 -0
  41. data/{app/assets → assets}/stylesheets/materialize/components/_cards.scss +72 -29
  42. data/assets/stylesheets/materialize/components/_carousel.scss +90 -0
  43. data/assets/stylesheets/materialize/components/_chips.scss +90 -0
  44. data/{app/assets → assets}/stylesheets/materialize/components/_collapsible.scss +23 -17
  45. data/assets/stylesheets/materialize/components/_color-classes.scss +32 -0
  46. data/{app/assets/stylesheets/materialize/components/_color.scss → assets/stylesheets/materialize/components/_color-variables.scss} +22 -64
  47. data/assets/stylesheets/materialize/components/_datepicker.scss +191 -0
  48. data/assets/stylesheets/materialize/components/_dropdown.scss +85 -0
  49. data/{app/assets → assets}/stylesheets/materialize/components/_global.scss +197 -144
  50. data/{app/assets → assets}/stylesheets/materialize/components/_grid.scss +57 -18
  51. data/assets/stylesheets/materialize/components/_icons-material-design.scss +5 -0
  52. data/{app/assets → assets}/stylesheets/materialize/components/_materialbox.scss +15 -13
  53. data/{app/assets → assets}/stylesheets/materialize/components/_modal.scss +18 -14
  54. data/{app/assets → assets}/stylesheets/materialize/components/_navbar.scss +89 -25
  55. data/assets/stylesheets/materialize/components/_normalize.scss +447 -0
  56. data/{app/assets → assets}/stylesheets/materialize/components/_preloader.scss +5 -3
  57. data/assets/stylesheets/materialize/components/_pulse.scss +34 -0
  58. data/assets/stylesheets/materialize/components/_sidenav.scss +208 -0
  59. data/{app/assets → assets}/stylesheets/materialize/components/_slider.scss +2 -2
  60. data/{app/assets → assets}/stylesheets/materialize/components/_table_of_contents.scss +5 -5
  61. data/assets/stylesheets/materialize/components/_tabs.scss +99 -0
  62. data/assets/stylesheets/materialize/components/_tapTarget.scss +103 -0
  63. data/assets/stylesheets/materialize/components/_timepicker.scss +183 -0
  64. data/{app/assets → assets}/stylesheets/materialize/components/_toast.scss +17 -22
  65. data/assets/stylesheets/materialize/components/_tooltip.scss +32 -0
  66. data/assets/stylesheets/materialize/components/_transitions.scss +13 -0
  67. data/{app/assets → assets}/stylesheets/materialize/components/_typography.scss +11 -9
  68. data/assets/stylesheets/materialize/components/_variables.scss +349 -0
  69. data/assets/stylesheets/materialize/components/_waves.scss +114 -0
  70. data/assets/stylesheets/materialize/components/forms/_checkboxes.scss +200 -0
  71. data/assets/stylesheets/materialize/components/forms/_file-input.scss +44 -0
  72. data/assets/stylesheets/materialize/components/forms/_forms.scss +22 -0
  73. data/assets/stylesheets/materialize/components/forms/_input-fields.scss +354 -0
  74. data/assets/stylesheets/materialize/components/forms/_radio-buttons.scss +115 -0
  75. data/assets/stylesheets/materialize/components/forms/_range.scss +161 -0
  76. data/assets/stylesheets/materialize/components/forms/_select.scss +190 -0
  77. data/assets/stylesheets/materialize/components/forms/_switches.scss +89 -0
  78. data/assets/stylesheets/materialize/extras/nouislider.css +406 -0
  79. data/{app/assets → assets}/stylesheets/materialize.scss +13 -10
  80. data/lib/materialize-sass/engine.rb +11 -6
  81. data/lib/materialize-sass/helpers.rb +38 -0
  82. data/lib/materialize-sass/version.rb +1 -1
  83. data/lib/materialize-sass.rb +13 -28
  84. data/materialize-sass.gemspec +5 -5
  85. metadata +97 -105
  86. data/app/assets/fonts/material-design-icons/LICENSE.txt +0 -428
  87. data/app/assets/fonts/material-design-icons/Material-Design-Icons.eot +0 -0
  88. data/app/assets/fonts/material-design-icons/Material-Design-Icons.svg +0 -769
  89. data/app/assets/fonts/material-design-icons/Material-Design-Icons.ttf +0 -0
  90. data/app/assets/fonts/material-design-icons/Material-Design-Icons.woff +0 -0
  91. data/app/assets/fonts/material-design-icons/Material-Design-Icons.woff2 +0 -0
  92. data/app/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
  93. data/app/assets/fonts/roboto/Roboto-Bold.woff +0 -0
  94. data/app/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
  95. data/app/assets/fonts/roboto/Roboto-Light.ttf +0 -0
  96. data/app/assets/fonts/roboto/Roboto-Light.woff +0 -0
  97. data/app/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
  98. data/app/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
  99. data/app/assets/fonts/roboto/Roboto-Medium.woff +0 -0
  100. data/app/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
  101. data/app/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
  102. data/app/assets/fonts/roboto/Roboto-Regular.woff +0 -0
  103. data/app/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
  104. data/app/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
  105. data/app/assets/fonts/roboto/Roboto-Thin.woff +0 -0
  106. data/app/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
  107. data/app/assets/javascripts/materialize/animation.js +0 -9
  108. data/app/assets/javascripts/materialize/buttons.js +0 -61
  109. data/app/assets/javascripts/materialize/cards.js +0 -27
  110. data/app/assets/javascripts/materialize/character_counter.js +0 -59
  111. data/app/assets/javascripts/materialize/collapsible.js +0 -139
  112. data/app/assets/javascripts/materialize/date_picker/picker.date.js +0 -1430
  113. data/app/assets/javascripts/materialize/date_picker/picker.js +0 -1123
  114. data/app/assets/javascripts/materialize/dropdown.js +0 -178
  115. data/app/assets/javascripts/materialize/forms.js +0 -456
  116. data/app/assets/javascripts/materialize/global.js +0 -36
  117. data/app/assets/javascripts/materialize/hammer.min.js +0 -1
  118. data/app/assets/javascripts/materialize/init.js +0 -136
  119. data/app/assets/javascripts/materialize/jquery.easing.1.3.js +0 -205
  120. data/app/assets/javascripts/materialize/jquery.hammer.js +0 -33
  121. data/app/assets/javascripts/materialize/jquery.timeago.min.js +0 -1
  122. data/app/assets/javascripts/materialize/leanModal.js +0 -178
  123. data/app/assets/javascripts/materialize/materialbox.js +0 -249
  124. data/app/assets/javascripts/materialize/parallax.js +0 -58
  125. data/app/assets/javascripts/materialize/prism.js +0 -8
  126. data/app/assets/javascripts/materialize/pushpin.js +0 -62
  127. data/app/assets/javascripts/materialize/scrollFire.js +0 -44
  128. data/app/assets/javascripts/materialize/scrollspy.js +0 -284
  129. data/app/assets/javascripts/materialize/sideNav.js +0 -312
  130. data/app/assets/javascripts/materialize/slider.js +0 -301
  131. data/app/assets/javascripts/materialize/tabs.js +0 -136
  132. data/app/assets/javascripts/materialize/toasts.js +0 -125
  133. data/app/assets/javascripts/materialize/tooltip.js +0 -166
  134. data/app/assets/javascripts/materialize/transitions.js +0 -154
  135. data/app/assets/javascripts/materialize/velocity.min.js +0 -4
  136. data/app/assets/javascripts/materialize-sprockets.js +0 -27
  137. data/app/assets/javascripts/materialize.js +0 -6159
  138. data/app/assets/stylesheets/materialize/components/_buttons.scss +0 -157
  139. data/app/assets/stylesheets/materialize/components/_dropdown.scss +0 -40
  140. data/app/assets/stylesheets/materialize/components/_form.scss +0 -886
  141. data/app/assets/stylesheets/materialize/components/_icons-material-design.scss +0 -3257
  142. data/app/assets/stylesheets/materialize/components/_mixins.scss +0 -5
  143. data/app/assets/stylesheets/materialize/components/_normalize.scss +0 -427
  144. data/app/assets/stylesheets/materialize/components/_prefixer.scss +0 -376
  145. data/app/assets/stylesheets/materialize/components/_roboto.scss +0 -38
  146. data/app/assets/stylesheets/materialize/components/_sideNav.scss +0 -111
  147. data/app/assets/stylesheets/materialize/components/_tabs.scss +0 -47
  148. data/app/assets/stylesheets/materialize/components/_tooltip.scss +0 -34
  149. data/app/assets/stylesheets/materialize/components/_variables.scss +0 -152
  150. data/app/assets/stylesheets/materialize/components/_waves.scss +0 -167
  151. data/app/assets/stylesheets/materialize/components/date_picker/_default.date.scss +0 -435
  152. data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +0 -201
  153. data/app/assets/stylesheets/materialize/components/date_picker/_default.time.scss +0 -125
@@ -1,1123 +0,0 @@
1
- /*!
2
- * pickadate.js v3.5.0, 2014/04/13
3
- * By Amsul, http://amsul.ca
4
- * Hosted on http://amsul.github.io/pickadate.js
5
- * Licensed under MIT
6
- */
7
-
8
- (function ( factory ) {
9
-
10
- // AMD.
11
- if ( typeof define == 'function' && define.amd )
12
- define( 'picker', ['jquery'], factory )
13
-
14
- // Node.js/browserify.
15
- else if ( typeof exports == 'object' )
16
- module.exports = factory( require('jquery') )
17
-
18
- // Browser globals.
19
- else this.Picker = factory( jQuery )
20
-
21
- }(function( $ ) {
22
-
23
- var $window = $( window )
24
- var $document = $( document )
25
- var $html = $( document.documentElement )
26
-
27
-
28
- /**
29
- * The picker constructor that creates a blank picker.
30
- */
31
- function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {
32
-
33
- // If there’s no element, return the picker constructor.
34
- if ( !ELEMENT ) return PickerConstructor
35
-
36
-
37
- var
38
- IS_DEFAULT_THEME = false,
39
-
40
-
41
- // The state of the picker.
42
- STATE = {
43
- id: ELEMENT.id || 'P' + Math.abs( ~~(Math.random() * new Date()) )
44
- },
45
-
46
-
47
- // Merge the defaults and options passed.
48
- SETTINGS = COMPONENT ? $.extend( true, {}, COMPONENT.defaults, OPTIONS ) : OPTIONS || {},
49
-
50
-
51
- // Merge the default classes with the settings classes.
52
- CLASSES = $.extend( {}, PickerConstructor.klasses(), SETTINGS.klass ),
53
-
54
-
55
- // The element node wrapper into a jQuery object.
56
- $ELEMENT = $( ELEMENT ),
57
-
58
-
59
- // Pseudo picker constructor.
60
- PickerInstance = function() {
61
- return this.start()
62
- },
63
-
64
-
65
- // The picker prototype.
66
- P = PickerInstance.prototype = {
67
-
68
- constructor: PickerInstance,
69
-
70
- $node: $ELEMENT,
71
-
72
-
73
- /**
74
- * Initialize everything
75
- */
76
- start: function() {
77
-
78
- // If it’s already started, do nothing.
79
- if ( STATE && STATE.start ) return P
80
-
81
-
82
- // Update the picker states.
83
- STATE.methods = {}
84
- STATE.start = true
85
- STATE.open = false
86
- STATE.type = ELEMENT.type
87
-
88
-
89
- // Confirm focus state, convert into text input to remove UA stylings,
90
- // and set as readonly to prevent keyboard popup.
91
- ELEMENT.autofocus = ELEMENT == getActiveElement()
92
- ELEMENT.readOnly = !SETTINGS.editable
93
- ELEMENT.id = ELEMENT.id || STATE.id
94
- if ( ELEMENT.type != 'text' ) {
95
- ELEMENT.type = 'text'
96
- }
97
-
98
-
99
- // Create a new picker component with the settings.
100
- P.component = new COMPONENT(P, SETTINGS)
101
-
102
-
103
- // Create the picker root with a holder and then prepare it.
104
- P.$root = $( PickerConstructor._.node('div', createWrappedComponent(), CLASSES.picker, 'id="' + ELEMENT.id + '_root" tabindex="0"') )
105
- prepareElementRoot()
106
-
107
-
108
- // If there’s a format for the hidden input element, create the element.
109
- if ( SETTINGS.formatSubmit ) {
110
- prepareElementHidden()
111
- }
112
-
113
-
114
- // Prepare the input element.
115
- prepareElement()
116
-
117
-
118
- // Insert the root as specified in the settings.
119
- if ( SETTINGS.container ) $( SETTINGS.container ).append( P.$root )
120
- else $ELEMENT.after( P.$root )
121
-
122
-
123
- // Bind the default component and settings events.
124
- P.on({
125
- start: P.component.onStart,
126
- render: P.component.onRender,
127
- stop: P.component.onStop,
128
- open: P.component.onOpen,
129
- close: P.component.onClose,
130
- set: P.component.onSet
131
- }).on({
132
- start: SETTINGS.onStart,
133
- render: SETTINGS.onRender,
134
- stop: SETTINGS.onStop,
135
- open: SETTINGS.onOpen,
136
- close: SETTINGS.onClose,
137
- set: SETTINGS.onSet
138
- })
139
-
140
-
141
- // Once we’re all set, check the theme in use.
142
- IS_DEFAULT_THEME = isUsingDefaultTheme( P.$root.children()[ 0 ] )
143
-
144
-
145
- // If the element has autofocus, open the picker.
146
- if ( ELEMENT.autofocus ) {
147
- P.open()
148
- }
149
-
150
-
151
- // Trigger queued the “start” and “render” events.
152
- return P.trigger( 'start' ).trigger( 'render' )
153
- }, //start
154
-
155
-
156
- /**
157
- * Render a new picker
158
- */
159
- render: function( entireComponent ) {
160
-
161
- // Insert a new component holder in the root or box.
162
- if ( entireComponent ) P.$root.html( createWrappedComponent() )
163
- else P.$root.find( '.' + CLASSES.box ).html( P.component.nodes( STATE.open ) )
164
-
165
- // Trigger the queued “render” events.
166
- return P.trigger( 'render' )
167
- }, //render
168
-
169
-
170
- /**
171
- * Destroy everything
172
- */
173
- stop: function() {
174
-
175
- // If it’s already stopped, do nothing.
176
- if ( !STATE.start ) return P
177
-
178
- // Then close the picker.
179
- P.close()
180
-
181
- // Remove the hidden field.
182
- if ( P._hidden ) {
183
- P._hidden.parentNode.removeChild( P._hidden )
184
- }
185
-
186
- // Remove the root.
187
- P.$root.remove()
188
-
189
- // Remove the input class, remove the stored data, and unbind
190
- // the events (after a tick for IE - see `P.close`).
191
- $ELEMENT.removeClass( CLASSES.input ).removeData( NAME )
192
- setTimeout( function() {
193
- $ELEMENT.off( '.' + STATE.id )
194
- }, 0)
195
-
196
- // Restore the element state
197
- ELEMENT.type = STATE.type
198
- ELEMENT.readOnly = false
199
-
200
- // Trigger the queued “stop” events.
201
- P.trigger( 'stop' )
202
-
203
- // Reset the picker states.
204
- STATE.methods = {}
205
- STATE.start = false
206
-
207
- return P
208
- }, //stop
209
-
210
-
211
- /**
212
- * Open up the picker
213
- */
214
- open: function( dontGiveFocus ) {
215
-
216
- // If it’s already open, do nothing.
217
- if ( STATE.open ) return P
218
-
219
- // Add the “active” class.
220
- $ELEMENT.addClass( CLASSES.active )
221
- aria( ELEMENT, 'expanded', true )
222
-
223
- // * A Firefox bug, when `html` has `overflow:hidden`, results in
224
- // killing transitions :(. So add the “opened” state on the next tick.
225
- // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
226
- setTimeout( function() {
227
-
228
- // Add the “opened” class to the picker root.
229
- P.$root.addClass( CLASSES.opened )
230
- aria( P.$root[0], 'hidden', false )
231
-
232
- }, 0 )
233
-
234
- // If we have to give focus, bind the element and doc events.
235
- if ( dontGiveFocus !== false ) {
236
-
237
- // Set it as open.
238
- STATE.open = true
239
-
240
- // Prevent the page from scrolling.
241
- if ( IS_DEFAULT_THEME ) {
242
- $html.
243
- css( 'overflow', 'hidden' ).
244
- css( 'padding-right', '+=' + getScrollbarWidth() )
245
- }
246
-
247
- // Pass focus to the root element’s jQuery object.
248
- // * Workaround for iOS8 to bring the picker’s root into view.
249
- P.$root[0].focus()
250
-
251
- // Bind the document events.
252
- $document.on( 'click.' + STATE.id + ' focusin.' + STATE.id, function( event ) {
253
-
254
- var target = event.target
255
-
256
- // If the target of the event is not the element, close the picker picker.
257
- // * Don’t worry about clicks or focusins on the root because those don’t bubble up.
258
- // Also, for Firefox, a click on an `option` element bubbles up directly
259
- // to the doc. So make sure the target wasn't the doc.
260
- // * In Firefox stopPropagation() doesn’t prevent right-click events from bubbling,
261
- // which causes the picker to unexpectedly close when right-clicking it. So make
262
- // sure the event wasn’t a right-click.
263
- if ( target != ELEMENT && target != document && event.which != 3 ) {
264
-
265
- // If the target was the holder that covers the screen,
266
- // keep the element focused to maintain tabindex.
267
- P.close( target === P.$root.children()[0] )
268
- }
269
-
270
- }).on( 'keydown.' + STATE.id, function( event ) {
271
-
272
- var
273
- // Get the keycode.
274
- keycode = event.keyCode,
275
-
276
- // Translate that to a selection change.
277
- keycodeToMove = P.component.key[ keycode ],
278
-
279
- // Grab the target.
280
- target = event.target
281
-
282
-
283
- // On escape, close the picker and give focus.
284
- if ( keycode == 27 ) {
285
- P.close( true )
286
- }
287
-
288
-
289
- // Check if there is a key movement or “enter” keypress on the element.
290
- else if ( target == P.$root[0] && ( keycodeToMove || keycode == 13 ) ) {
291
-
292
- // Prevent the default action to stop page movement.
293
- event.preventDefault()
294
-
295
- // Trigger the key movement action.
296
- if ( keycodeToMove ) {
297
- PickerConstructor._.trigger( P.component.key.go, P, [ PickerConstructor._.trigger( keycodeToMove ) ] )
298
- }
299
-
300
- // On “enter”, if the highlighted item isn’t disabled, set the value and close.
301
- else if ( !P.$root.find( '.' + CLASSES.highlighted ).hasClass( CLASSES.disabled ) ) {
302
- P.set( 'select', P.component.item.highlight ).close()
303
- }
304
- }
305
-
306
-
307
- // If the target is within the root and “enter” is pressed,
308
- // prevent the default action and trigger a click on the target instead.
309
- else if ( $.contains( P.$root[0], target ) && keycode == 13 ) {
310
- event.preventDefault()
311
- target.click()
312
- }
313
- })
314
- }
315
-
316
- // Trigger the queued “open” events.
317
- return P.trigger( 'open' )
318
- }, //open
319
-
320
-
321
- /**
322
- * Close the picker
323
- */
324
- close: function( giveFocus ) {
325
-
326
- // If we need to give focus, do it before changing states.
327
- if ( giveFocus ) {
328
- // ....ah yes! It would’ve been incomplete without a crazy workaround for IE :|
329
- // The focus is triggered *after* the close has completed - causing it
330
- // to open again. So unbind and rebind the event at the next tick.
331
- P.$root.off( 'focus.toOpen' )[0].focus()
332
- setTimeout( function() {
333
- P.$root.on( 'focus.toOpen', handleFocusToOpenEvent )
334
- }, 0 )
335
- }
336
-
337
- // Remove the “active” class.
338
- $ELEMENT.removeClass( CLASSES.active )
339
- aria( ELEMENT, 'expanded', false )
340
-
341
- // * A Firefox bug, when `html` has `overflow:hidden`, results in
342
- // killing transitions :(. So remove the “opened” state on the next tick.
343
- // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
344
- setTimeout( function() {
345
-
346
- // Remove the “opened” and “focused” class from the picker root.
347
- P.$root.removeClass( CLASSES.opened + ' ' + CLASSES.focused )
348
- aria( P.$root[0], 'hidden', true )
349
-
350
- }, 0 )
351
-
352
- // If it’s already closed, do nothing more.
353
- if ( !STATE.open ) return P
354
-
355
- // Set it as closed.
356
- STATE.open = false
357
-
358
- // Allow the page to scroll.
359
- if ( IS_DEFAULT_THEME ) {
360
- $html.
361
- css( 'overflow', '' ).
362
- css( 'padding-right', '-=' + getScrollbarWidth() )
363
- }
364
-
365
- // Unbind the document events.
366
- $document.off( '.' + STATE.id )
367
-
368
- // Trigger the queued “close” events.
369
- return P.trigger( 'close' )
370
- }, //close
371
-
372
-
373
- /**
374
- * Clear the values
375
- */
376
- clear: function( options ) {
377
- return P.set( 'clear', null, options )
378
- }, //clear
379
-
380
-
381
- /**
382
- * Set something
383
- */
384
- set: function( thing, value, options ) {
385
-
386
- var thingItem, thingValue,
387
- thingIsObject = $.isPlainObject( thing ),
388
- thingObject = thingIsObject ? thing : {}
389
-
390
- // Make sure we have usable options.
391
- options = thingIsObject && $.isPlainObject( value ) ? value : options || {}
392
-
393
- if ( thing ) {
394
-
395
- // If the thing isn’t an object, make it one.
396
- if ( !thingIsObject ) {
397
- thingObject[ thing ] = value
398
- }
399
-
400
- // Go through the things of items to set.
401
- for ( thingItem in thingObject ) {
402
-
403
- // Grab the value of the thing.
404
- thingValue = thingObject[ thingItem ]
405
-
406
- // First, if the item exists and there’s a value, set it.
407
- if ( thingItem in P.component.item ) {
408
- if ( thingValue === undefined ) thingValue = null
409
- P.component.set( thingItem, thingValue, options )
410
- }
411
-
412
- // Then, check to update the element value and broadcast a change.
413
- if ( thingItem == 'select' || thingItem == 'clear' ) {
414
- $ELEMENT.
415
- val( thingItem == 'clear' ? '' : P.get( thingItem, SETTINGS.format ) ).
416
- trigger( 'change' )
417
- }
418
- }
419
-
420
- // Render a new picker.
421
- P.render()
422
- }
423
-
424
- // When the method isn’t muted, trigger queued “set” events and pass the `thingObject`.
425
- return options.muted ? P : P.trigger( 'set', thingObject )
426
- }, //set
427
-
428
-
429
- /**
430
- * Get something
431
- */
432
- get: function( thing, format ) {
433
-
434
- // Make sure there’s something to get.
435
- thing = thing || 'value'
436
-
437
- // If a picker state exists, return that.
438
- if ( STATE[ thing ] != null ) {
439
- return STATE[ thing ]
440
- }
441
-
442
- // Return the submission value, if that.
443
- if ( thing == 'valueSubmit' ) {
444
- if ( P._hidden ) {
445
- return P._hidden.value
446
- }
447
- thing = 'value'
448
- }
449
-
450
- // Return the value, if that.
451
- if ( thing == 'value' ) {
452
- return ELEMENT.value
453
- }
454
-
455
- // Check if a component item exists, return that.
456
- if ( thing in P.component.item ) {
457
- if ( typeof format == 'string' ) {
458
- var thingValue = P.component.get( thing )
459
- return thingValue ?
460
- PickerConstructor._.trigger(
461
- P.component.formats.toString,
462
- P.component,
463
- [ format, thingValue ]
464
- ) : ''
465
- }
466
- return P.component.get( thing )
467
- }
468
- }, //get
469
-
470
-
471
-
472
- /**
473
- * Bind events on the things.
474
- */
475
- on: function( thing, method, internal ) {
476
-
477
- var thingName, thingMethod,
478
- thingIsObject = $.isPlainObject( thing ),
479
- thingObject = thingIsObject ? thing : {}
480
-
481
- if ( thing ) {
482
-
483
- // If the thing isn’t an object, make it one.
484
- if ( !thingIsObject ) {
485
- thingObject[ thing ] = method
486
- }
487
-
488
- // Go through the things to bind to.
489
- for ( thingName in thingObject ) {
490
-
491
- // Grab the method of the thing.
492
- thingMethod = thingObject[ thingName ]
493
-
494
- // If it was an internal binding, prefix it.
495
- if ( internal ) {
496
- thingName = '_' + thingName
497
- }
498
-
499
- // Make sure the thing methods collection exists.
500
- STATE.methods[ thingName ] = STATE.methods[ thingName ] || []
501
-
502
- // Add the method to the relative method collection.
503
- STATE.methods[ thingName ].push( thingMethod )
504
- }
505
- }
506
-
507
- return P
508
- }, //on
509
-
510
-
511
-
512
- /**
513
- * Unbind events on the things.
514
- */
515
- off: function() {
516
- var i, thingName,
517
- names = arguments;
518
- for ( i = 0, namesCount = names.length; i < namesCount; i += 1 ) {
519
- thingName = names[i]
520
- if ( thingName in STATE.methods ) {
521
- delete STATE.methods[thingName]
522
- }
523
- }
524
- return P
525
- },
526
-
527
-
528
- /**
529
- * Fire off method events.
530
- */
531
- trigger: function( name, data ) {
532
- var _trigger = function( name ) {
533
- var methodList = STATE.methods[ name ]
534
- if ( methodList ) {
535
- methodList.map( function( method ) {
536
- PickerConstructor._.trigger( method, P, [ data ] )
537
- })
538
- }
539
- }
540
- _trigger( '_' + name )
541
- _trigger( name )
542
- return P
543
- } //trigger
544
- } //PickerInstance.prototype
545
-
546
-
547
- /**
548
- * Wrap the picker holder components together.
549
- */
550
- function createWrappedComponent() {
551
-
552
- // Create a picker wrapper holder
553
- return PickerConstructor._.node( 'div',
554
-
555
- // Create a picker wrapper node
556
- PickerConstructor._.node( 'div',
557
-
558
- // Create a picker frame
559
- PickerConstructor._.node( 'div',
560
-
561
- // Create a picker box node
562
- PickerConstructor._.node( 'div',
563
-
564
- // Create the components nodes.
565
- P.component.nodes( STATE.open ),
566
-
567
- // The picker box class
568
- CLASSES.box
569
- ),
570
-
571
- // Picker wrap class
572
- CLASSES.wrap
573
- ),
574
-
575
- // Picker frame class
576
- CLASSES.frame
577
- ),
578
-
579
- // Picker holder class
580
- CLASSES.holder
581
- ) //endreturn
582
- } //createWrappedComponent
583
-
584
-
585
-
586
- /**
587
- * Prepare the input element with all bindings.
588
- */
589
- function prepareElement() {
590
-
591
- $ELEMENT.
592
-
593
- // Store the picker data by component name.
594
- data(NAME, P).
595
-
596
- // Add the “input” class name.
597
- addClass(CLASSES.input).
598
-
599
- // Remove the tabindex.
600
- attr('tabindex', -1).
601
-
602
- // If there’s a `data-value`, update the value of the element.
603
- val( $ELEMENT.data('value') ?
604
- P.get('select', SETTINGS.format) :
605
- ELEMENT.value
606
- )
607
-
608
-
609
- // Only bind keydown events if the element isn’t editable.
610
- if ( !SETTINGS.editable ) {
611
-
612
- $ELEMENT.
613
-
614
- // On focus/click, focus onto the root to open it up.
615
- on( 'focus.' + STATE.id + ' click.' + STATE.id, function( event ) {
616
- event.preventDefault()
617
- P.$root[0].focus()
618
- }).
619
-
620
- // Handle keyboard event based on the picker being opened or not.
621
- on( 'keydown.' + STATE.id, handleKeydownEvent )
622
- }
623
-
624
-
625
- // Update the aria attributes.
626
- aria(ELEMENT, {
627
- haspopup: true,
628
- expanded: false,
629
- readonly: false,
630
- owns: ELEMENT.id + '_root'
631
- })
632
- }
633
-
634
-
635
- /**
636
- * Prepare the root picker element with all bindings.
637
- */
638
- function prepareElementRoot() {
639
-
640
- P.$root.
641
-
642
- on({
643
-
644
- // For iOS8.
645
- keydown: handleKeydownEvent,
646
-
647
- // When something within the root is focused, stop from bubbling
648
- // to the doc and remove the “focused” state from the root.
649
- focusin: function( event ) {
650
- P.$root.removeClass( CLASSES.focused )
651
- event.stopPropagation()
652
- },
653
-
654
- // When something within the root holder is clicked, stop it
655
- // from bubbling to the doc.
656
- 'mousedown click': function( event ) {
657
-
658
- var target = event.target
659
-
660
- // Make sure the target isn’t the root holder so it can bubble up.
661
- if ( target != P.$root.children()[ 0 ] ) {
662
-
663
- event.stopPropagation()
664
-
665
- // * For mousedown events, cancel the default action in order to
666
- // prevent cases where focus is shifted onto external elements
667
- // when using things like jQuery mobile or MagnificPopup (ref: #249 & #120).
668
- // Also, for Firefox, don’t prevent action on the `option` element.
669
- if ( event.type == 'mousedown' && !$( target ).is( 'input, select, textarea, button, option' )) {
670
-
671
- event.preventDefault()
672
-
673
- // Re-focus onto the root so that users can click away
674
- // from elements focused within the picker.
675
- P.$root[0].focus()
676
- }
677
- }
678
- }
679
- }).
680
-
681
- // Add/remove the “target” class on focus and blur.
682
- on({
683
- focus: function() {
684
- $ELEMENT.addClass( CLASSES.target )
685
- },
686
- blur: function() {
687
- $ELEMENT.removeClass( CLASSES.target )
688
- }
689
- }).
690
-
691
- // Open the picker and adjust the root “focused” state
692
- on( 'focus.toOpen', handleFocusToOpenEvent ).
693
-
694
- // If there’s a click on an actionable element, carry out the actions.
695
- on( 'click', '[data-pick], [data-nav], [data-clear], [data-close]', function() {
696
-
697
- var $target = $( this ),
698
- targetData = $target.data(),
699
- targetDisabled = $target.hasClass( CLASSES.navDisabled ) || $target.hasClass( CLASSES.disabled ),
700
-
701
- // * For IE, non-focusable elements can be active elements as well
702
- // (http://stackoverflow.com/a/2684561).
703
- activeElement = getActiveElement()
704
- activeElement = activeElement && ( activeElement.type || activeElement.href )
705
-
706
- // If it’s disabled or nothing inside is actively focused, re-focus the element.
707
- if ( targetDisabled || activeElement && !$.contains( P.$root[0], activeElement ) ) {
708
- P.$root[0].focus()
709
- }
710
-
711
- // If something is superficially changed, update the `highlight` based on the `nav`.
712
- if ( !targetDisabled && targetData.nav ) {
713
- P.set( 'highlight', P.component.item.highlight, { nav: targetData.nav } )
714
- }
715
-
716
- // If something is picked, set `select` then close with focus.
717
- else if ( !targetDisabled && 'pick' in targetData ) {
718
- P.set( 'select', targetData.pick )
719
- }
720
-
721
- // If a “clear” button is pressed, empty the values and close with focus.
722
- else if ( targetData.clear ) {
723
- P.clear().close( true )
724
- }
725
-
726
- else if ( targetData.close ) {
727
- P.close( true )
728
- }
729
-
730
- }) //P.$root
731
-
732
- aria( P.$root[0], 'hidden', true )
733
- }
734
-
735
-
736
- /**
737
- * Prepare the hidden input element along with all bindings.
738
- */
739
- function prepareElementHidden() {
740
-
741
- var name
742
-
743
- if ( SETTINGS.hiddenName === true ) {
744
- name = ELEMENT.name
745
- ELEMENT.name = ''
746
- }
747
- else {
748
- name = [
749
- typeof SETTINGS.hiddenPrefix == 'string' ? SETTINGS.hiddenPrefix : '',
750
- typeof SETTINGS.hiddenSuffix == 'string' ? SETTINGS.hiddenSuffix : '_submit'
751
- ]
752
- name = name[0] + ELEMENT.name + name[1]
753
- }
754
-
755
- P._hidden = $(
756
- '<input ' +
757
- 'type=hidden ' +
758
-
759
- // Create the name using the original input’s with a prefix and suffix.
760
- 'name="' + name + '"' +
761
-
762
- // If the element has a value, set the hidden value as well.
763
- (
764
- $ELEMENT.data('value') || ELEMENT.value ?
765
- ' value="' + P.get('select', SETTINGS.formatSubmit) + '"' :
766
- ''
767
- ) +
768
- '>'
769
- )[0]
770
-
771
- $ELEMENT.
772
-
773
- // If the value changes, update the hidden input with the correct format.
774
- on('change.' + STATE.id, function() {
775
- P._hidden.value = ELEMENT.value ?
776
- P.get('select', SETTINGS.formatSubmit) :
777
- ''
778
- })
779
-
780
-
781
- // Insert the hidden input as specified in the settings.
782
- if ( SETTINGS.container ) $( SETTINGS.container ).append( P._hidden )
783
- else $ELEMENT.after( P._hidden )
784
- }
785
-
786
-
787
- // For iOS8.
788
- function handleKeydownEvent( event ) {
789
-
790
- var keycode = event.keyCode,
791
-
792
- // Check if one of the delete keys was pressed.
793
- isKeycodeDelete = /^(8|46)$/.test(keycode)
794
-
795
- // For some reason IE clears the input value on “escape”.
796
- if ( keycode == 27 ) {
797
- P.close()
798
- return false
799
- }
800
-
801
- // Check if `space` or `delete` was pressed or the picker is closed with a key movement.
802
- if ( keycode == 32 || isKeycodeDelete || !STATE.open && P.component.key[keycode] ) {
803
-
804
- // Prevent it from moving the page and bubbling to doc.
805
- event.preventDefault()
806
- event.stopPropagation()
807
-
808
- // If `delete` was pressed, clear the values and close the picker.
809
- // Otherwise open the picker.
810
- if ( isKeycodeDelete ) { P.clear().close() }
811
- else { P.open() }
812
- }
813
- }
814
-
815
-
816
- // Separated for IE
817
- function handleFocusToOpenEvent( event ) {
818
-
819
- // Stop the event from propagating to the doc.
820
- event.stopPropagation()
821
-
822
- // If it’s a focus event, add the “focused” class to the root.
823
- if ( event.type == 'focus' ) {
824
- P.$root.addClass( CLASSES.focused )
825
- }
826
-
827
- // And then finally open the picker.
828
- P.open()
829
- }
830
-
831
-
832
- // Return a new picker instance.
833
- return new PickerInstance()
834
- } //PickerConstructor
835
-
836
-
837
-
838
- /**
839
- * The default classes and prefix to use for the HTML classes.
840
- */
841
- PickerConstructor.klasses = function( prefix ) {
842
- prefix = prefix || 'picker'
843
- return {
844
-
845
- picker: prefix,
846
- opened: prefix + '--opened',
847
- focused: prefix + '--focused',
848
-
849
- input: prefix + '__input',
850
- active: prefix + '__input--active',
851
- target: prefix + '__input--target',
852
-
853
- holder: prefix + '__holder',
854
-
855
- frame: prefix + '__frame',
856
- wrap: prefix + '__wrap',
857
-
858
- box: prefix + '__box'
859
- }
860
- } //PickerConstructor.klasses
861
-
862
-
863
-
864
- /**
865
- * Check if the default theme is being used.
866
- */
867
- function isUsingDefaultTheme( element ) {
868
-
869
- var theme,
870
- prop = 'position'
871
-
872
- // For IE.
873
- if ( element.currentStyle ) {
874
- theme = element.currentStyle[prop]
875
- }
876
-
877
- // For normal browsers.
878
- else if ( window.getComputedStyle ) {
879
- theme = getComputedStyle( element )[prop]
880
- }
881
-
882
- return theme == 'fixed'
883
- }
884
-
885
-
886
-
887
- /**
888
- * Get the width of the browser’s scrollbar.
889
- * Taken from: https://github.com/VodkaBears/Remodal/blob/master/src/jquery.remodal.js
890
- */
891
- function getScrollbarWidth() {
892
-
893
- if ( $html.height() <= $window.height() ) {
894
- return 0
895
- }
896
-
897
- var $outer = $( '<div style="visibility:hidden;width:100px" />' ).
898
- appendTo( 'body' )
899
-
900
- // Get the width without scrollbars.
901
- var widthWithoutScroll = $outer[0].offsetWidth
902
-
903
- // Force adding scrollbars.
904
- $outer.css( 'overflow', 'scroll' )
905
-
906
- // Add the inner div.
907
- var $inner = $( '<div style="width:100%" />' ).appendTo( $outer )
908
-
909
- // Get the width with scrollbars.
910
- var widthWithScroll = $inner[0].offsetWidth
911
-
912
- // Remove the divs.
913
- $outer.remove()
914
-
915
- // Return the difference between the widths.
916
- return widthWithoutScroll - widthWithScroll
917
- }
918
-
919
-
920
-
921
- /**
922
- * PickerConstructor helper methods.
923
- */
924
- PickerConstructor._ = {
925
-
926
- /**
927
- * Create a group of nodes. Expects:
928
- * `
929
- {
930
- min: {Integer},
931
- max: {Integer},
932
- i: {Integer},
933
- node: {String},
934
- item: {Function}
935
- }
936
- * `
937
- */
938
- group: function( groupObject ) {
939
-
940
- var
941
- // Scope for the looped object
942
- loopObjectScope,
943
-
944
- // Create the nodes list
945
- nodesList = '',
946
-
947
- // The counter starts from the `min`
948
- counter = PickerConstructor._.trigger( groupObject.min, groupObject )
949
-
950
-
951
- // Loop from the `min` to `max`, incrementing by `i`
952
- for ( ; counter <= PickerConstructor._.trigger( groupObject.max, groupObject, [ counter ] ); counter += groupObject.i ) {
953
-
954
- // Trigger the `item` function within scope of the object
955
- loopObjectScope = PickerConstructor._.trigger( groupObject.item, groupObject, [ counter ] )
956
-
957
- // Splice the subgroup and create nodes out of the sub nodes
958
- nodesList += PickerConstructor._.node(
959
- groupObject.node,
960
- loopObjectScope[ 0 ], // the node
961
- loopObjectScope[ 1 ], // the classes
962
- loopObjectScope[ 2 ] // the attributes
963
- )
964
- }
965
-
966
- // Return the list of nodes
967
- return nodesList
968
- }, //group
969
-
970
-
971
- /**
972
- * Create a dom node string
973
- */
974
- node: function( wrapper, item, klass, attribute ) {
975
-
976
- // If the item is false-y, just return an empty string
977
- if ( !item ) return ''
978
-
979
- // If the item is an array, do a join
980
- item = $.isArray( item ) ? item.join( '' ) : item
981
-
982
- // Check for the class
983
- klass = klass ? ' class="' + klass + '"' : ''
984
-
985
- // Check for any attributes
986
- attribute = attribute ? ' ' + attribute : ''
987
-
988
- // Return the wrapped item
989
- return '<' + wrapper + klass + attribute + '>' + item + '</' + wrapper + '>'
990
- }, //node
991
-
992
-
993
- /**
994
- * Lead numbers below 10 with a zero.
995
- */
996
- lead: function( number ) {
997
- return ( number < 10 ? '0': '' ) + number
998
- },
999
-
1000
-
1001
- /**
1002
- * Trigger a function otherwise return the value.
1003
- */
1004
- trigger: function( callback, scope, args ) {
1005
- return typeof callback == 'function' ? callback.apply( scope, args || [] ) : callback
1006
- },
1007
-
1008
-
1009
- /**
1010
- * If the second character is a digit, length is 2 otherwise 1.
1011
- */
1012
- digits: function( string ) {
1013
- return ( /\d/ ).test( string[ 1 ] ) ? 2 : 1
1014
- },
1015
-
1016
-
1017
- /**
1018
- * Tell if something is a date object.
1019
- */
1020
- isDate: function( value ) {
1021
- return {}.toString.call( value ).indexOf( 'Date' ) > -1 && this.isInteger( value.getDate() )
1022
- },
1023
-
1024
-
1025
- /**
1026
- * Tell if something is an integer.
1027
- */
1028
- isInteger: function( value ) {
1029
- return {}.toString.call( value ).indexOf( 'Number' ) > -1 && value % 1 === 0
1030
- },
1031
-
1032
-
1033
- /**
1034
- * Create ARIA attribute strings.
1035
- */
1036
- ariaAttr: ariaAttr
1037
- } //PickerConstructor._
1038
-
1039
-
1040
-
1041
- /**
1042
- * Extend the picker with a component and defaults.
1043
- */
1044
- PickerConstructor.extend = function( name, Component ) {
1045
-
1046
- // Extend jQuery.
1047
- $.fn[ name ] = function( options, action ) {
1048
-
1049
- // Grab the component data.
1050
- var componentData = this.data( name )
1051
-
1052
- // If the picker is requested, return the data object.
1053
- if ( options == 'picker' ) {
1054
- return componentData
1055
- }
1056
-
1057
- // If the component data exists and `options` is a string, carry out the action.
1058
- if ( componentData && typeof options == 'string' ) {
1059
- return PickerConstructor._.trigger( componentData[ options ], componentData, [ action ] )
1060
- }
1061
-
1062
- // Otherwise go through each matched element and if the component
1063
- // doesn’t exist, create a new picker using `this` element
1064
- // and merging the defaults and options with a deep copy.
1065
- return this.each( function() {
1066
- var $this = $( this )
1067
- if ( !$this.data( name ) ) {
1068
- new PickerConstructor( this, name, Component, options )
1069
- }
1070
- })
1071
- }
1072
-
1073
- // Set the defaults.
1074
- $.fn[ name ].defaults = Component.defaults
1075
- } //PickerConstructor.extend
1076
-
1077
-
1078
-
1079
- function aria(element, attribute, value) {
1080
- if ( $.isPlainObject(attribute) ) {
1081
- for ( var key in attribute ) {
1082
- ariaSet(element, key, attribute[key])
1083
- }
1084
- }
1085
- else {
1086
- ariaSet(element, attribute, value)
1087
- }
1088
- }
1089
- function ariaSet(element, attribute, value) {
1090
- element.setAttribute(
1091
- (attribute == 'role' ? '' : 'aria-') + attribute,
1092
- value
1093
- )
1094
- }
1095
- function ariaAttr(attribute, data) {
1096
- if ( !$.isPlainObject(attribute) ) {
1097
- attribute = { attribute: data }
1098
- }
1099
- data = ''
1100
- for ( var key in attribute ) {
1101
- var attr = (key == 'role' ? '' : 'aria-') + key,
1102
- attrVal = attribute[key]
1103
- data += attrVal == null ? '' : attr + '="' + attribute[key] + '"'
1104
- }
1105
- return data
1106
- }
1107
-
1108
- // IE8 bug throws an error for activeElements within iframes.
1109
- function getActiveElement() {
1110
- try {
1111
- return document.activeElement
1112
- } catch ( err ) { }
1113
- }
1114
-
1115
-
1116
-
1117
- // Expose the picker constructor.
1118
- return PickerConstructor
1119
-
1120
-
1121
- }));
1122
-
1123
-