materialize-sass 0.100.2.1 → 1.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +18 -42
  3. data/Rakefile +17 -17
  4. data/{app/assets → assets}/javascripts/materialize-sprockets.js +8 -12
  5. data/assets/javascripts/materialize.js +11877 -0
  6. data/assets/javascripts/materialize/autocomplete.js +420 -0
  7. data/assets/javascripts/materialize/buttons.js +388 -0
  8. data/assets/javascripts/materialize/cards.js +28 -0
  9. data/assets/javascripts/materialize/carousel.js +791 -0
  10. data/assets/javascripts/materialize/cash.js +992 -0
  11. data/assets/javascripts/materialize/characterCounter.js +180 -0
  12. data/assets/javascripts/materialize/chips.js +555 -0
  13. data/assets/javascripts/materialize/collapsible.js +275 -0
  14. data/assets/javascripts/materialize/datepicker.js +898 -0
  15. data/assets/javascripts/materialize/dropdown.js +530 -0
  16. data/{app/assets → assets}/javascripts/materialize/extras/nouislider.js +1 -1
  17. data/{app/assets → assets}/javascripts/materialize/extras/nouislider.min.js +1 -1
  18. data/assets/javascripts/materialize/forms.js +223 -0
  19. data/assets/javascripts/materialize/global.js +353 -0
  20. data/assets/javascripts/materialize/materialbox.js +432 -0
  21. data/{app/assets → assets}/javascripts/materialize/modal.js +82 -113
  22. data/assets/javascripts/materialize/parallax.js +135 -0
  23. data/assets/javascripts/materialize/pushpin.js +158 -0
  24. data/assets/javascripts/materialize/range.js +305 -0
  25. data/assets/javascripts/materialize/scrollspy.js +322 -0
  26. data/assets/javascripts/materialize/select.js +426 -0
  27. data/assets/javascripts/materialize/sidenav.js +584 -0
  28. data/assets/javascripts/materialize/slider.js +383 -0
  29. data/assets/javascripts/materialize/tabs.js +460 -0
  30. data/assets/javascripts/materialize/tapTarget.js +347 -0
  31. data/assets/javascripts/materialize/timepicker.js +616 -0
  32. data/{app/assets → assets}/javascripts/materialize/toasts.js +42 -46
  33. data/assets/javascripts/materialize/tooltip.js +325 -0
  34. data/assets/javascripts/materialize/velocity.min.js +782 -0
  35. data/{app/assets → assets}/javascripts/materialize/waves.js +0 -0
  36. data/{app/assets → assets}/stylesheets/materialize.scss +5 -6
  37. data/{app/assets → assets}/stylesheets/materialize/components/_badges.scss +1 -1
  38. data/{app/assets → assets}/stylesheets/materialize/components/_buttons.scss +34 -2
  39. data/{app/assets → assets}/stylesheets/materialize/components/_cards.scss +0 -0
  40. data/{app/assets → assets}/stylesheets/materialize/components/_carousel.scss +1 -1
  41. data/{app/assets → assets}/stylesheets/materialize/components/_chips.scss +6 -5
  42. data/{app/assets → assets}/stylesheets/materialize/components/_collapsible.scss +3 -3
  43. data/{app/assets → assets}/stylesheets/materialize/components/_color.scss +0 -0
  44. data/assets/stylesheets/materialize/components/_datepicker.scss +180 -0
  45. data/{app/assets → assets}/stylesheets/materialize/components/_dropdown.scss +16 -15
  46. data/{app/assets → assets}/stylesheets/materialize/components/_global.scss +49 -14
  47. data/{app/assets → assets}/stylesheets/materialize/components/_grid.scss +1 -1
  48. data/{app/assets → assets}/stylesheets/materialize/components/_icons-material-design.scss +0 -0
  49. data/{app/assets → assets}/stylesheets/materialize/components/_materialbox.scss +0 -0
  50. data/assets/stylesheets/materialize/components/_mixins.scss +5 -0
  51. data/{app/assets → assets}/stylesheets/materialize/components/_modal.scss +1 -1
  52. data/{app/assets → assets}/stylesheets/materialize/components/_navbar.scss +0 -0
  53. data/assets/stylesheets/materialize/components/_normalize.scss +447 -0
  54. data/{app/assets → assets}/stylesheets/materialize/components/_preloader.scss +0 -0
  55. data/{app/assets → assets}/stylesheets/materialize/components/_pulse.scss +0 -0
  56. data/{app/assets/stylesheets/materialize/components/_sideNav.scss → assets/stylesheets/materialize/components/_sidenav.scss} +23 -21
  57. data/{app/assets → assets}/stylesheets/materialize/components/_slider.scss +0 -0
  58. data/{app/assets → assets}/stylesheets/materialize/components/_table_of_contents.scss +3 -3
  59. data/{app/assets → assets}/stylesheets/materialize/components/_tabs.scss +2 -2
  60. data/{app/assets → assets}/stylesheets/materialize/components/_tapTarget.scss +0 -0
  61. data/assets/stylesheets/materialize/components/_timepicker.scss +182 -0
  62. data/{app/assets → assets}/stylesheets/materialize/components/_toast.scss +0 -0
  63. data/{app/assets → assets}/stylesheets/materialize/components/_tooltip.scss +1 -0
  64. data/{app/assets → assets}/stylesheets/materialize/components/_transitions.scss +0 -0
  65. data/{app/assets → assets}/stylesheets/materialize/components/_typography.scss +8 -8
  66. data/{app/assets → assets}/stylesheets/materialize/components/_variables.scss +42 -44
  67. data/{app/assets → assets}/stylesheets/materialize/components/_waves.scss +0 -0
  68. data/{app/assets → assets}/stylesheets/materialize/components/forms/_checkboxes.scss +24 -24
  69. data/{app/assets → assets}/stylesheets/materialize/components/forms/_file-input.scss +0 -0
  70. data/{app/assets → assets}/stylesheets/materialize/components/forms/_forms.scss +0 -0
  71. data/{app/assets → assets}/stylesheets/materialize/components/forms/_input-fields.scss +49 -35
  72. data/{app/assets → assets}/stylesheets/materialize/components/forms/_radio-buttons.scss +29 -29
  73. data/{app/assets → assets}/stylesheets/materialize/components/forms/_range.scss +32 -31
  74. data/{app/assets → assets}/stylesheets/materialize/components/forms/_select.scss +20 -11
  75. data/{app/assets → assets}/stylesheets/materialize/components/forms/_switches.scss +0 -0
  76. data/{app/assets → assets}/stylesheets/materialize/extras/nouislider.css +1 -1
  77. data/lib/materialize-sass.rb +13 -23
  78. data/lib/materialize-sass/engine.rb +6 -9
  79. data/lib/materialize-sass/version.rb +1 -1
  80. data/materialize-sass.gemspec +2 -1
  81. metadata +97 -97
  82. data/app/assets/fonts/roboto/Roboto-Bold.woff +0 -0
  83. data/app/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
  84. data/app/assets/fonts/roboto/Roboto-Light.woff +0 -0
  85. data/app/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
  86. data/app/assets/fonts/roboto/Roboto-Medium.woff +0 -0
  87. data/app/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
  88. data/app/assets/fonts/roboto/Roboto-Regular.woff +0 -0
  89. data/app/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
  90. data/app/assets/fonts/roboto/Roboto-Thin.woff +0 -0
  91. data/app/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
  92. data/app/assets/javascripts/materialize.js +0 -10021
  93. data/app/assets/javascripts/materialize/animation.js +0 -7
  94. data/app/assets/javascripts/materialize/buttons.js +0 -253
  95. data/app/assets/javascripts/materialize/cards.js +0 -28
  96. data/app/assets/javascripts/materialize/carousel.js +0 -543
  97. data/app/assets/javascripts/materialize/character_counter.js +0 -64
  98. data/app/assets/javascripts/materialize/chips.js +0 -315
  99. data/app/assets/javascripts/materialize/collapsible.js +0 -178
  100. data/app/assets/javascripts/materialize/date_picker/picker.date.js +0 -1399
  101. data/app/assets/javascripts/materialize/date_picker/picker.js +0 -1196
  102. data/app/assets/javascripts/materialize/date_picker/picker.time.js +0 -646
  103. data/app/assets/javascripts/materialize/dropdown.js +0 -257
  104. data/app/assets/javascripts/materialize/forms.js +0 -806
  105. data/app/assets/javascripts/materialize/global.js +0 -170
  106. data/app/assets/javascripts/materialize/hammer.min.js +0 -424
  107. data/app/assets/javascripts/materialize/initial.js +0 -10
  108. data/app/assets/javascripts/materialize/jquery.easing.1.4.js +0 -144
  109. data/app/assets/javascripts/materialize/jquery.hammer.js +0 -33
  110. data/app/assets/javascripts/materialize/materialbox.js +0 -263
  111. data/app/assets/javascripts/materialize/parallax.js +0 -54
  112. data/app/assets/javascripts/materialize/pushpin.js +0 -68
  113. data/app/assets/javascripts/materialize/scrollFire.js +0 -49
  114. data/app/assets/javascripts/materialize/scrollspy.js +0 -230
  115. data/app/assets/javascripts/materialize/sideNav.js +0 -395
  116. data/app/assets/javascripts/materialize/slider.js +0 -295
  117. data/app/assets/javascripts/materialize/tabs.js +0 -244
  118. data/app/assets/javascripts/materialize/tapTarget.js +0 -184
  119. data/app/assets/javascripts/materialize/tooltip.js +0 -227
  120. data/app/assets/javascripts/materialize/transitions.js +0 -163
  121. data/app/assets/javascripts/materialize/velocity.min.js +0 -626
  122. data/app/assets/stylesheets/materialize/components/_normalize.scss +0 -424
  123. data/app/assets/stylesheets/materialize/components/_roboto.scss +0 -39
  124. data/app/assets/stylesheets/materialize/components/date_picker/_default.date.scss +0 -469
  125. data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +0 -216
  126. data/app/assets/stylesheets/materialize/components/date_picker/_default.time.scss +0 -267
@@ -1,1399 +0,0 @@
1
- /*!
2
- * Date picker for pickadate.js v3.6.1
3
- * http://amsul.github.io/pickadate.js/date.htm
4
- */
5
-
6
- (function ( factory ) {
7
- factory(Materialize.Picker, jQuery);
8
- })(function( Picker, $ ) {
9
-
10
-
11
- /**
12
- * Globals and constants
13
- */
14
- var DAYS_IN_WEEK = 7,
15
- WEEKS_IN_CALENDAR = 6,
16
- _ = Picker._
17
-
18
-
19
-
20
- /**
21
- * The date picker constructor
22
- */
23
- function DatePicker( picker, settings ) {
24
-
25
- var calendar = this,
26
- element = picker.$node[ 0 ],
27
- elementValue = element.value,
28
- elementDataValue = picker.$node.data( 'value' ),
29
- valueString = elementDataValue || elementValue,
30
- formatString = elementDataValue ? settings.formatSubmit : settings.format,
31
- isRTL = function() {
32
-
33
- return element.currentStyle ?
34
-
35
- // For IE.
36
- element.currentStyle.direction == 'rtl' :
37
-
38
- // For normal browsers.
39
- getComputedStyle( picker.$root[0] ).direction == 'rtl'
40
- }
41
-
42
- calendar.settings = settings
43
- calendar.$node = picker.$node
44
-
45
- // The queue of methods that will be used to build item objects.
46
- calendar.queue = {
47
- min: 'measure create',
48
- max: 'measure create',
49
- now: 'now create',
50
- select: 'parse create validate',
51
- highlight: 'parse navigate create validate',
52
- view: 'parse create validate viewset',
53
- disable: 'deactivate',
54
- enable: 'activate'
55
- }
56
-
57
- // The component's item object.
58
- calendar.item = {}
59
-
60
- calendar.item.clear = null
61
- calendar.item.disable = ( settings.disable || [] ).slice( 0 )
62
- calendar.item.enable = -(function( collectionDisabled ) {
63
- return collectionDisabled[ 0 ] === true ? collectionDisabled.shift() : -1
64
- })( calendar.item.disable )
65
-
66
- calendar.
67
- set( 'min', settings.min ).
68
- set( 'max', settings.max ).
69
- set( 'now' )
70
-
71
- // When there’s a value, set the `select`, which in turn
72
- // also sets the `highlight` and `view`.
73
- if ( valueString ) {
74
- calendar.set( 'select', valueString, {
75
- format: formatString,
76
- defaultValue: true
77
- })
78
- }
79
-
80
- // If there’s no value, default to highlighting “today”.
81
- else {
82
- calendar.
83
- set( 'select', null ).
84
- set( 'highlight', calendar.item.now )
85
- }
86
-
87
-
88
- // The keycode to movement mapping.
89
- calendar.key = {
90
- 40: 7, // Down
91
- 38: -7, // Up
92
- 39: function() { return isRTL() ? -1 : 1 }, // Right
93
- 37: function() { return isRTL() ? 1 : -1 }, // Left
94
- go: function( timeChange ) {
95
- var highlightedObject = calendar.item.highlight,
96
- targetDate = new Date( highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange )
97
- calendar.set(
98
- 'highlight',
99
- targetDate,
100
- { interval: timeChange }
101
- )
102
- this.render()
103
- }
104
- }
105
-
106
-
107
- // Bind some picker events.
108
- picker.
109
- on( 'render', function() {
110
- picker.$root.find( '.' + settings.klass.selectMonth ).on( 'change', function() {
111
- var value = this.value
112
- if ( value ) {
113
- picker.set( 'highlight', [ picker.get( 'view' ).year, value, picker.get( 'highlight' ).date ] )
114
- picker.$root.find( '.' + settings.klass.selectMonth ).trigger( 'focus' )
115
- }
116
- })
117
- picker.$root.find( '.' + settings.klass.selectYear ).on( 'change', function() {
118
- var value = this.value
119
- if ( value ) {
120
- picker.set( 'highlight', [ value, picker.get( 'view' ).month, picker.get( 'highlight' ).date ] )
121
- picker.$root.find( '.' + settings.klass.selectYear ).trigger( 'focus' )
122
- }
123
- })
124
- }, 1 ).
125
- on( 'open', function() {
126
- var includeToday = ''
127
- if ( calendar.disabled( calendar.get('now') ) ) {
128
- includeToday = ':not(.' + settings.klass.buttonToday + ')'
129
- }
130
- picker.$root.find( 'button' + includeToday + ', select' ).attr( 'disabled', false )
131
- }, 1 ).
132
- on( 'close', function() {
133
- picker.$root.find( 'button, select' ).attr( 'disabled', true )
134
- }, 1 )
135
-
136
- } //DatePicker
137
-
138
-
139
- /**
140
- * Set a datepicker item object.
141
- */
142
- DatePicker.prototype.set = function( type, value, options ) {
143
-
144
- var calendar = this,
145
- calendarItem = calendar.item
146
-
147
- // If the value is `null` just set it immediately.
148
- if ( value === null ) {
149
- if ( type == 'clear' ) type = 'select'
150
- calendarItem[ type ] = value
151
- return calendar
152
- }
153
-
154
- // Otherwise go through the queue of methods, and invoke the functions.
155
- // Update this as the time unit, and set the final value as this item.
156
- // * In the case of `enable`, keep the queue but set `disable` instead.
157
- // And in the case of `flip`, keep the queue but set `enable` instead.
158
- calendarItem[ ( type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type ) ] = calendar.queue[ type ].split( ' ' ).map( function( method ) {
159
- value = calendar[ method ]( type, value, options )
160
- return value
161
- }).pop()
162
-
163
- // Check if we need to cascade through more updates.
164
- if ( type == 'select' ) {
165
- calendar.set( 'highlight', calendarItem.select, options )
166
- }
167
- else if ( type == 'highlight' ) {
168
- calendar.set( 'view', calendarItem.highlight, options )
169
- }
170
- else if ( type.match( /^(flip|min|max|disable|enable)$/ ) ) {
171
- if ( calendarItem.select && calendar.disabled( calendarItem.select ) ) {
172
- calendar.set( 'select', calendarItem.select, options )
173
- }
174
- if ( calendarItem.highlight && calendar.disabled( calendarItem.highlight ) ) {
175
- calendar.set( 'highlight', calendarItem.highlight, options )
176
- }
177
- }
178
-
179
- return calendar
180
- } //DatePicker.prototype.set
181
-
182
-
183
- /**
184
- * Get a datepicker item object.
185
- */
186
- DatePicker.prototype.get = function( type ) {
187
- return this.item[ type ]
188
- } //DatePicker.prototype.get
189
-
190
-
191
- /**
192
- * Create a picker date object.
193
- */
194
- DatePicker.prototype.create = function( type, value, options ) {
195
-
196
- var isInfiniteValue,
197
- calendar = this
198
-
199
- // If there’s no value, use the type as the value.
200
- value = value === undefined ? type : value
201
-
202
-
203
- // If it’s infinity, update the value.
204
- if ( value == -Infinity || value == Infinity ) {
205
- isInfiniteValue = value
206
- }
207
-
208
- // If it’s an object, use the native date object.
209
- else if ( $.isPlainObject( value ) && _.isInteger( value.pick ) ) {
210
- value = value.obj
211
- }
212
-
213
- // If it’s an array, convert it into a date and make sure
214
- // that it’s a valid date – otherwise default to today.
215
- else if ( $.isArray( value ) ) {
216
- value = new Date( value[ 0 ], value[ 1 ], value[ 2 ] )
217
- value = _.isDate( value ) ? value : calendar.create().obj
218
- }
219
-
220
- // If it’s a number or date object, make a normalized date.
221
- else if ( _.isInteger( value ) || _.isDate( value ) ) {
222
- value = calendar.normalize( new Date( value ), options )
223
- }
224
-
225
- // If it’s a literal true or any other case, set it to now.
226
- else /*if ( value === true )*/ {
227
- value = calendar.now( type, value, options )
228
- }
229
-
230
- // Return the compiled object.
231
- return {
232
- year: isInfiniteValue || value.getFullYear(),
233
- month: isInfiniteValue || value.getMonth(),
234
- date: isInfiniteValue || value.getDate(),
235
- day: isInfiniteValue || value.getDay(),
236
- obj: isInfiniteValue || value,
237
- pick: isInfiniteValue || value.getTime()
238
- }
239
- } //DatePicker.prototype.create
240
-
241
-
242
- /**
243
- * Create a range limit object using an array, date object,
244
- * literal “true”, or integer relative to another time.
245
- */
246
- DatePicker.prototype.createRange = function( from, to ) {
247
-
248
- var calendar = this,
249
- createDate = function( date ) {
250
- if ( date === true || $.isArray( date ) || _.isDate( date ) ) {
251
- return calendar.create( date )
252
- }
253
- return date
254
- }
255
-
256
- // Create objects if possible.
257
- if ( !_.isInteger( from ) ) {
258
- from = createDate( from )
259
- }
260
- if ( !_.isInteger( to ) ) {
261
- to = createDate( to )
262
- }
263
-
264
- // Create relative dates.
265
- if ( _.isInteger( from ) && $.isPlainObject( to ) ) {
266
- from = [ to.year, to.month, to.date + from ];
267
- }
268
- else if ( _.isInteger( to ) && $.isPlainObject( from ) ) {
269
- to = [ from.year, from.month, from.date + to ];
270
- }
271
-
272
- return {
273
- from: createDate( from ),
274
- to: createDate( to )
275
- }
276
- } //DatePicker.prototype.createRange
277
-
278
-
279
- /**
280
- * Check if a date unit falls within a date range object.
281
- */
282
- DatePicker.prototype.withinRange = function( range, dateUnit ) {
283
- range = this.createRange(range.from, range.to)
284
- return dateUnit.pick >= range.from.pick && dateUnit.pick <= range.to.pick
285
- }
286
-
287
-
288
- /**
289
- * Check if two date range objects overlap.
290
- */
291
- DatePicker.prototype.overlapRanges = function( one, two ) {
292
-
293
- var calendar = this
294
-
295
- // Convert the ranges into comparable dates.
296
- one = calendar.createRange( one.from, one.to )
297
- two = calendar.createRange( two.from, two.to )
298
-
299
- return calendar.withinRange( one, two.from ) || calendar.withinRange( one, two.to ) ||
300
- calendar.withinRange( two, one.from ) || calendar.withinRange( two, one.to )
301
- }
302
-
303
-
304
- /**
305
- * Get the date today.
306
- */
307
- DatePicker.prototype.now = function( type, value, options ) {
308
- value = new Date()
309
- if ( options && options.rel ) {
310
- value.setDate( value.getDate() + options.rel )
311
- }
312
- return this.normalize( value, options )
313
- }
314
-
315
-
316
- /**
317
- * Navigate to next/prev month.
318
- */
319
- DatePicker.prototype.navigate = function( type, value, options ) {
320
-
321
- var targetDateObject,
322
- targetYear,
323
- targetMonth,
324
- targetDate,
325
- isTargetArray = $.isArray( value ),
326
- isTargetObject = $.isPlainObject( value ),
327
- viewsetObject = this.item.view/*,
328
- safety = 100*/
329
-
330
-
331
- if ( isTargetArray || isTargetObject ) {
332
-
333
- if ( isTargetObject ) {
334
- targetYear = value.year
335
- targetMonth = value.month
336
- targetDate = value.date
337
- }
338
- else {
339
- targetYear = +value[0]
340
- targetMonth = +value[1]
341
- targetDate = +value[2]
342
- }
343
-
344
- // If we’re navigating months but the view is in a different
345
- // month, navigate to the view’s year and month.
346
- if ( options && options.nav && viewsetObject && viewsetObject.month !== targetMonth ) {
347
- targetYear = viewsetObject.year
348
- targetMonth = viewsetObject.month
349
- }
350
-
351
- // Figure out the expected target year and month.
352
- targetDateObject = new Date( targetYear, targetMonth + ( options && options.nav ? options.nav : 0 ), 1 )
353
- targetYear = targetDateObject.getFullYear()
354
- targetMonth = targetDateObject.getMonth()
355
-
356
- // If the month we’re going to doesn’t have enough days,
357
- // keep decreasing the date until we reach the month’s last date.
358
- while ( /*safety &&*/ new Date( targetYear, targetMonth, targetDate ).getMonth() !== targetMonth ) {
359
- targetDate -= 1
360
- /*safety -= 1
361
- if ( !safety ) {
362
- throw 'Fell into an infinite loop while navigating to ' + new Date( targetYear, targetMonth, targetDate ) + '.'
363
- }*/
364
- }
365
-
366
- value = [ targetYear, targetMonth, targetDate ]
367
- }
368
-
369
- return value
370
- } //DatePicker.prototype.navigate
371
-
372
-
373
- /**
374
- * Normalize a date by setting the hours to midnight.
375
- */
376
- DatePicker.prototype.normalize = function( value/*, options*/ ) {
377
- value.setHours( 0, 0, 0, 0 )
378
- return value
379
- }
380
-
381
-
382
- /**
383
- * Measure the range of dates.
384
- */
385
- DatePicker.prototype.measure = function( type, value/*, options*/ ) {
386
-
387
- var calendar = this
388
-
389
- // If it's an integer, get a date relative to today.
390
- if ( _.isInteger( value ) ) {
391
- value = calendar.now( type, value, { rel: value } )
392
- }
393
-
394
- // If it’s anything false-y, remove the limits.
395
- else if ( !value ) {
396
- value = type == 'min' ? -Infinity : Infinity
397
- }
398
-
399
- // If it’s a string, parse it.
400
- else if ( typeof value == 'string' ) {
401
- value = calendar.parse( type, value )
402
- }
403
-
404
- return value
405
- } ///DatePicker.prototype.measure
406
-
407
-
408
- /**
409
- * Create a viewset object based on navigation.
410
- */
411
- DatePicker.prototype.viewset = function( type, dateObject/*, options*/ ) {
412
- return this.create([ dateObject.year, dateObject.month, 1 ])
413
- }
414
-
415
-
416
- /**
417
- * Validate a date as enabled and shift if needed.
418
- */
419
- DatePicker.prototype.validate = function( type, dateObject, options ) {
420
-
421
- var calendar = this,
422
-
423
- // Keep a reference to the original date.
424
- originalDateObject = dateObject,
425
-
426
- // Make sure we have an interval.
427
- interval = options && options.interval ? options.interval : 1,
428
-
429
- // Check if the calendar enabled dates are inverted.
430
- isFlippedBase = calendar.item.enable === -1,
431
-
432
- // Check if we have any enabled dates after/before now.
433
- hasEnabledBeforeTarget, hasEnabledAfterTarget,
434
-
435
- // The min & max limits.
436
- minLimitObject = calendar.item.min,
437
- maxLimitObject = calendar.item.max,
438
-
439
- // Check if we’ve reached the limit during shifting.
440
- reachedMin, reachedMax,
441
-
442
- // Check if the calendar is inverted and at least one weekday is enabled.
443
- hasEnabledWeekdays = isFlippedBase && calendar.item.disable.filter( function( value ) {
444
-
445
- // If there’s a date, check where it is relative to the target.
446
- if ( $.isArray( value ) ) {
447
- var dateTime = calendar.create( value ).pick
448
- if ( dateTime < dateObject.pick ) hasEnabledBeforeTarget = true
449
- else if ( dateTime > dateObject.pick ) hasEnabledAfterTarget = true
450
- }
451
-
452
- // Return only integers for enabled weekdays.
453
- return _.isInteger( value )
454
- }).length/*,
455
-
456
- safety = 100*/
457
-
458
-
459
-
460
- // Cases to validate for:
461
- // [1] Not inverted and date disabled.
462
- // [2] Inverted and some dates enabled.
463
- // [3] Not inverted and out of range.
464
- //
465
- // Cases to **not** validate for:
466
- // • Navigating months.
467
- // • Not inverted and date enabled.
468
- // • Inverted and all dates disabled.
469
- // • ..and anything else.
470
- if ( !options || (!options.nav && !options.defaultValue) ) if (
471
- /* 1 */ ( !isFlippedBase && calendar.disabled( dateObject ) ) ||
472
- /* 2 */ ( isFlippedBase && calendar.disabled( dateObject ) && ( hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget ) ) ||
473
- /* 3 */ ( !isFlippedBase && (dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick) )
474
- ) {
475
-
476
-
477
- // When inverted, flip the direction if there aren’t any enabled weekdays
478
- // and there are no enabled dates in the direction of the interval.
479
- if ( isFlippedBase && !hasEnabledWeekdays && ( ( !hasEnabledAfterTarget && interval > 0 ) || ( !hasEnabledBeforeTarget && interval < 0 ) ) ) {
480
- interval *= -1
481
- }
482
-
483
-
484
- // Keep looping until we reach an enabled date.
485
- while ( /*safety &&*/ calendar.disabled( dateObject ) ) {
486
-
487
- /*safety -= 1
488
- if ( !safety ) {
489
- throw 'Fell into an infinite loop while validating ' + dateObject.obj + '.'
490
- }*/
491
-
492
-
493
- // If we’ve looped into the next/prev month with a large interval, return to the original date and flatten the interval.
494
- if ( Math.abs( interval ) > 1 && ( dateObject.month < originalDateObject.month || dateObject.month > originalDateObject.month ) ) {
495
- dateObject = originalDateObject
496
- interval = interval > 0 ? 1 : -1
497
- }
498
-
499
-
500
- // If we’ve reached the min/max limit, reverse the direction, flatten the interval and set it to the limit.
501
- if ( dateObject.pick <= minLimitObject.pick ) {
502
- reachedMin = true
503
- interval = 1
504
- dateObject = calendar.create([
505
- minLimitObject.year,
506
- minLimitObject.month,
507
- minLimitObject.date + (dateObject.pick === minLimitObject.pick ? 0 : -1)
508
- ])
509
- }
510
- else if ( dateObject.pick >= maxLimitObject.pick ) {
511
- reachedMax = true
512
- interval = -1
513
- dateObject = calendar.create([
514
- maxLimitObject.year,
515
- maxLimitObject.month,
516
- maxLimitObject.date + (dateObject.pick === maxLimitObject.pick ? 0 : 1)
517
- ])
518
- }
519
-
520
-
521
- // If we’ve reached both limits, just break out of the loop.
522
- if ( reachedMin && reachedMax ) {
523
- break
524
- }
525
-
526
-
527
- // Finally, create the shifted date using the interval and keep looping.
528
- dateObject = calendar.create([ dateObject.year, dateObject.month, dateObject.date + interval ])
529
- }
530
-
531
- } //endif
532
-
533
-
534
- // Return the date object settled on.
535
- return dateObject
536
- } //DatePicker.prototype.validate
537
-
538
-
539
- /**
540
- * Check if a date is disabled.
541
- */
542
- DatePicker.prototype.disabled = function( dateToVerify ) {
543
-
544
- var
545
- calendar = this,
546
-
547
- // Filter through the disabled dates to check if this is one.
548
- isDisabledMatch = calendar.item.disable.filter( function( dateToDisable ) {
549
-
550
- // If the date is a number, match the weekday with 0index and `firstDay` check.
551
- if ( _.isInteger( dateToDisable ) ) {
552
- return dateToVerify.day === ( calendar.settings.firstDay ? dateToDisable : dateToDisable - 1 ) % 7
553
- }
554
-
555
- // If it’s an array or a native JS date, create and match the exact date.
556
- if ( $.isArray( dateToDisable ) || _.isDate( dateToDisable ) ) {
557
- return dateToVerify.pick === calendar.create( dateToDisable ).pick
558
- }
559
-
560
- // If it’s an object, match a date within the “from” and “to” range.
561
- if ( $.isPlainObject( dateToDisable ) ) {
562
- return calendar.withinRange( dateToDisable, dateToVerify )
563
- }
564
- })
565
-
566
- // If this date matches a disabled date, confirm it’s not inverted.
567
- isDisabledMatch = isDisabledMatch.length && !isDisabledMatch.filter(function( dateToDisable ) {
568
- return $.isArray( dateToDisable ) && dateToDisable[3] == 'inverted' ||
569
- $.isPlainObject( dateToDisable ) && dateToDisable.inverted
570
- }).length
571
-
572
- // Check the calendar “enabled” flag and respectively flip the
573
- // disabled state. Then also check if it’s beyond the min/max limits.
574
- return calendar.item.enable === -1 ? !isDisabledMatch : isDisabledMatch ||
575
- dateToVerify.pick < calendar.item.min.pick ||
576
- dateToVerify.pick > calendar.item.max.pick
577
-
578
- } //DatePicker.prototype.disabled
579
-
580
-
581
- /**
582
- * Parse a string into a usable type.
583
- */
584
- DatePicker.prototype.parse = function( type, value, options ) {
585
-
586
- var calendar = this,
587
- parsingObject = {}
588
-
589
- // If it’s already parsed, we’re good.
590
- if ( !value || typeof value != 'string' ) {
591
- return value
592
- }
593
-
594
- // We need a `.format` to parse the value with.
595
- if ( !( options && options.format ) ) {
596
- options = options || {}
597
- options.format = calendar.settings.format
598
- }
599
-
600
- // Convert the format into an array and then map through it.
601
- calendar.formats.toArray( options.format ).map( function( label ) {
602
-
603
- var
604
- // Grab the formatting label.
605
- formattingLabel = calendar.formats[ label ],
606
-
607
- // The format length is from the formatting label function or the
608
- // label length without the escaping exclamation (!) mark.
609
- formatLength = formattingLabel ? _.trigger( formattingLabel, calendar, [ value, parsingObject ] ) : label.replace( /^!/, '' ).length
610
-
611
- // If there's a format label, split the value up to the format length.
612
- // Then add it to the parsing object with appropriate label.
613
- if ( formattingLabel ) {
614
- parsingObject[ label ] = value.substr( 0, formatLength )
615
- }
616
-
617
- // Update the value as the substring from format length to end.
618
- value = value.substr( formatLength )
619
- })
620
-
621
- // Compensate for month 0index.
622
- return [
623
- parsingObject.yyyy || parsingObject.yy,
624
- +( parsingObject.mm || parsingObject.m ) - 1,
625
- parsingObject.dd || parsingObject.d
626
- ]
627
- } //DatePicker.prototype.parse
628
-
629
-
630
- /**
631
- * Various formats to display the object in.
632
- */
633
- DatePicker.prototype.formats = (function() {
634
-
635
- // Return the length of the first word in a collection.
636
- function getWordLengthFromCollection( string, collection, dateObject ) {
637
-
638
- // Grab the first word from the string.
639
- // Regex pattern from http://stackoverflow.com/q/150033
640
- var word = string.match( /[^\x00-\x7F]+|\w+/ )[ 0 ]
641
-
642
- // If there's no month index, add it to the date object
643
- if ( !dateObject.mm && !dateObject.m ) {
644
- dateObject.m = collection.indexOf( word ) + 1
645
- }
646
-
647
- // Return the length of the word.
648
- return word.length
649
- }
650
-
651
- // Get the length of the first word in a string.
652
- function getFirstWordLength( string ) {
653
- return string.match( /\w+/ )[ 0 ].length
654
- }
655
-
656
- return {
657
-
658
- d: function( string, dateObject ) {
659
-
660
- // If there's string, then get the digits length.
661
- // Otherwise return the selected date.
662
- return string ? _.digits( string ) : dateObject.date
663
- },
664
- dd: function( string, dateObject ) {
665
-
666
- // If there's a string, then the length is always 2.
667
- // Otherwise return the selected date with a leading zero.
668
- return string ? 2 : _.lead( dateObject.date )
669
- },
670
- ddd: function( string, dateObject ) {
671
-
672
- // If there's a string, then get the length of the first word.
673
- // Otherwise return the short selected weekday.
674
- return string ? getFirstWordLength( string ) : this.settings.weekdaysShort[ dateObject.day ]
675
- },
676
- dddd: function( string, dateObject ) {
677
-
678
- // If there's a string, then get the length of the first word.
679
- // Otherwise return the full selected weekday.
680
- return string ? getFirstWordLength( string ) : this.settings.weekdaysFull[ dateObject.day ]
681
- },
682
- m: function( string, dateObject ) {
683
-
684
- // If there's a string, then get the length of the digits
685
- // Otherwise return the selected month with 0index compensation.
686
- return string ? _.digits( string ) : dateObject.month + 1
687
- },
688
- mm: function( string, dateObject ) {
689
-
690
- // If there's a string, then the length is always 2.
691
- // Otherwise return the selected month with 0index and leading zero.
692
- return string ? 2 : _.lead( dateObject.month + 1 )
693
- },
694
- mmm: function( string, dateObject ) {
695
-
696
- var collection = this.settings.monthsShort
697
-
698
- // If there's a string, get length of the relevant month from the short
699
- // months collection. Otherwise return the selected month from that collection.
700
- return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
701
- },
702
- mmmm: function( string, dateObject ) {
703
-
704
- var collection = this.settings.monthsFull
705
-
706
- // If there's a string, get length of the relevant month from the full
707
- // months collection. Otherwise return the selected month from that collection.
708
- return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
709
- },
710
- yy: function( string, dateObject ) {
711
-
712
- // If there's a string, then the length is always 2.
713
- // Otherwise return the selected year by slicing out the first 2 digits.
714
- return string ? 2 : ( '' + dateObject.year ).slice( 2 )
715
- },
716
- yyyy: function( string, dateObject ) {
717
-
718
- // If there's a string, then the length is always 4.
719
- // Otherwise return the selected year.
720
- return string ? 4 : dateObject.year
721
- },
722
-
723
- // Create an array by splitting the formatting string passed.
724
- toArray: function( formatString ) { return formatString.split( /(d{1,4}|m{1,4}|y{4}|yy|!.)/g ) },
725
-
726
- // Format an object into a string using the formatting options.
727
- toString: function ( formatString, itemObject ) {
728
- var calendar = this
729
- return calendar.formats.toArray( formatString ).map( function( label ) {
730
- return _.trigger( calendar.formats[ label ], calendar, [ 0, itemObject ] ) || label.replace( /^!/, '' )
731
- }).join( '' )
732
- }
733
- }
734
- })() //DatePicker.prototype.formats
735
-
736
-
737
-
738
-
739
- /**
740
- * Check if two date units are the exact.
741
- */
742
- DatePicker.prototype.isDateExact = function( one, two ) {
743
-
744
- var calendar = this
745
-
746
- // When we’re working with weekdays, do a direct comparison.
747
- if (
748
- ( _.isInteger( one ) && _.isInteger( two ) ) ||
749
- ( typeof one == 'boolean' && typeof two == 'boolean' )
750
- ) {
751
- return one === two
752
- }
753
-
754
- // When we’re working with date representations, compare the “pick” value.
755
- if (
756
- ( _.isDate( one ) || $.isArray( one ) ) &&
757
- ( _.isDate( two ) || $.isArray( two ) )
758
- ) {
759
- return calendar.create( one ).pick === calendar.create( two ).pick
760
- }
761
-
762
- // When we’re working with range objects, compare the “from” and “to”.
763
- if ( $.isPlainObject( one ) && $.isPlainObject( two ) ) {
764
- return calendar.isDateExact( one.from, two.from ) && calendar.isDateExact( one.to, two.to )
765
- }
766
-
767
- return false
768
- }
769
-
770
-
771
- /**
772
- * Check if two date units overlap.
773
- */
774
- DatePicker.prototype.isDateOverlap = function( one, two ) {
775
-
776
- var calendar = this,
777
- firstDay = calendar.settings.firstDay ? 1 : 0
778
-
779
- // When we’re working with a weekday index, compare the days.
780
- if ( _.isInteger( one ) && ( _.isDate( two ) || $.isArray( two ) ) ) {
781
- one = one % 7 + firstDay
782
- return one === calendar.create( two ).day + 1
783
- }
784
- if ( _.isInteger( two ) && ( _.isDate( one ) || $.isArray( one ) ) ) {
785
- two = two % 7 + firstDay
786
- return two === calendar.create( one ).day + 1
787
- }
788
-
789
- // When we’re working with range objects, check if the ranges overlap.
790
- if ( $.isPlainObject( one ) && $.isPlainObject( two ) ) {
791
- return calendar.overlapRanges( one, two )
792
- }
793
-
794
- return false
795
- }
796
-
797
-
798
- /**
799
- * Flip the “enabled” state.
800
- */
801
- DatePicker.prototype.flipEnable = function(val) {
802
- var itemObject = this.item
803
- itemObject.enable = val || (itemObject.enable == -1 ? 1 : -1)
804
- }
805
-
806
-
807
- /**
808
- * Mark a collection of dates as “disabled”.
809
- */
810
- DatePicker.prototype.deactivate = function( type, datesToDisable ) {
811
-
812
- var calendar = this,
813
- disabledItems = calendar.item.disable.slice(0)
814
-
815
-
816
- // If we’re flipping, that’s all we need to do.
817
- if ( datesToDisable == 'flip' ) {
818
- calendar.flipEnable()
819
- }
820
-
821
- else if ( datesToDisable === false ) {
822
- calendar.flipEnable(1)
823
- disabledItems = []
824
- }
825
-
826
- else if ( datesToDisable === true ) {
827
- calendar.flipEnable(-1)
828
- disabledItems = []
829
- }
830
-
831
- // Otherwise go through the dates to disable.
832
- else {
833
-
834
- datesToDisable.map(function( unitToDisable ) {
835
-
836
- var matchFound
837
-
838
- // When we have disabled items, check for matches.
839
- // If something is matched, immediately break out.
840
- for ( var index = 0; index < disabledItems.length; index += 1 ) {
841
- if ( calendar.isDateExact( unitToDisable, disabledItems[index] ) ) {
842
- matchFound = true
843
- break
844
- }
845
- }
846
-
847
- // If nothing was found, add the validated unit to the collection.
848
- if ( !matchFound ) {
849
- if (
850
- _.isInteger( unitToDisable ) ||
851
- _.isDate( unitToDisable ) ||
852
- $.isArray( unitToDisable ) ||
853
- ( $.isPlainObject( unitToDisable ) && unitToDisable.from && unitToDisable.to )
854
- ) {
855
- disabledItems.push( unitToDisable )
856
- }
857
- }
858
- })
859
- }
860
-
861
- // Return the updated collection.
862
- return disabledItems
863
- } //DatePicker.prototype.deactivate
864
-
865
-
866
- /**
867
- * Mark a collection of dates as “enabled”.
868
- */
869
- DatePicker.prototype.activate = function( type, datesToEnable ) {
870
-
871
- var calendar = this,
872
- disabledItems = calendar.item.disable,
873
- disabledItemsCount = disabledItems.length
874
-
875
- // If we’re flipping, that’s all we need to do.
876
- if ( datesToEnable == 'flip' ) {
877
- calendar.flipEnable()
878
- }
879
-
880
- else if ( datesToEnable === true ) {
881
- calendar.flipEnable(1)
882
- disabledItems = []
883
- }
884
-
885
- else if ( datesToEnable === false ) {
886
- calendar.flipEnable(-1)
887
- disabledItems = []
888
- }
889
-
890
- // Otherwise go through the disabled dates.
891
- else {
892
-
893
- datesToEnable.map(function( unitToEnable ) {
894
-
895
- var matchFound,
896
- disabledUnit,
897
- index,
898
- isExactRange
899
-
900
- // Go through the disabled items and try to find a match.
901
- for ( index = 0; index < disabledItemsCount; index += 1 ) {
902
-
903
- disabledUnit = disabledItems[index]
904
-
905
- // When an exact match is found, remove it from the collection.
906
- if ( calendar.isDateExact( disabledUnit, unitToEnable ) ) {
907
- matchFound = disabledItems[index] = null
908
- isExactRange = true
909
- break
910
- }
911
-
912
- // When an overlapped match is found, add the “inverted” state to it.
913
- else if ( calendar.isDateOverlap( disabledUnit, unitToEnable ) ) {
914
- if ( $.isPlainObject( unitToEnable ) ) {
915
- unitToEnable.inverted = true
916
- matchFound = unitToEnable
917
- }
918
- else if ( $.isArray( unitToEnable ) ) {
919
- matchFound = unitToEnable
920
- if ( !matchFound[3] ) matchFound.push( 'inverted' )
921
- }
922
- else if ( _.isDate( unitToEnable ) ) {
923
- matchFound = [ unitToEnable.getFullYear(), unitToEnable.getMonth(), unitToEnable.getDate(), 'inverted' ]
924
- }
925
- break
926
- }
927
- }
928
-
929
- // If a match was found, remove a previous duplicate entry.
930
- if ( matchFound ) for ( index = 0; index < disabledItemsCount; index += 1 ) {
931
- if ( calendar.isDateExact( disabledItems[index], unitToEnable ) ) {
932
- disabledItems[index] = null
933
- break
934
- }
935
- }
936
-
937
- // In the event that we’re dealing with an exact range of dates,
938
- // make sure there are no “inverted” dates because of it.
939
- if ( isExactRange ) for ( index = 0; index < disabledItemsCount; index += 1 ) {
940
- if ( calendar.isDateOverlap( disabledItems[index], unitToEnable ) ) {
941
- disabledItems[index] = null
942
- break
943
- }
944
- }
945
-
946
- // If something is still matched, add it into the collection.
947
- if ( matchFound ) {
948
- disabledItems.push( matchFound )
949
- }
950
- })
951
- }
952
-
953
- // Return the updated collection.
954
- return disabledItems.filter(function( val ) { return val != null })
955
- } //DatePicker.prototype.activate
956
-
957
-
958
- /**
959
- * Create a string for the nodes in the picker.
960
- */
961
- DatePicker.prototype.nodes = function( isOpen ) {
962
-
963
- var
964
- calendar = this,
965
- settings = calendar.settings,
966
- calendarItem = calendar.item,
967
- nowObject = calendarItem.now,
968
- selectedObject = calendarItem.select,
969
- highlightedObject = calendarItem.highlight,
970
- viewsetObject = calendarItem.view,
971
- disabledCollection = calendarItem.disable,
972
- minLimitObject = calendarItem.min,
973
- maxLimitObject = calendarItem.max,
974
-
975
-
976
- // Create the calendar table head using a copy of weekday labels collection.
977
- // * We do a copy so we don't mutate the original array.
978
- tableHead = (function( collection, fullCollection ) {
979
-
980
- // If the first day should be Monday, move Sunday to the end.
981
- if ( settings.firstDay ) {
982
- collection.push( collection.shift() )
983
- fullCollection.push( fullCollection.shift() )
984
- }
985
-
986
- // Create and return the table head group.
987
- return _.node(
988
- 'thead',
989
- _.node(
990
- 'tr',
991
- _.group({
992
- min: 0,
993
- max: DAYS_IN_WEEK - 1,
994
- i: 1,
995
- node: 'th',
996
- item: function( counter ) {
997
- return [
998
- collection[ counter ],
999
- settings.klass.weekdays,
1000
- 'scope=col title="' + fullCollection[ counter ] + '"'
1001
- ]
1002
- }
1003
- })
1004
- )
1005
- ) //endreturn
1006
- // Materialize modified
1007
- })( ( settings.showWeekdaysFull ? settings.weekdaysFull : settings.weekdaysLetter ).slice( 0 ), settings.weekdaysFull.slice( 0 ) ), //tableHead
1008
-
1009
-
1010
- // Create the nav for next/prev month.
1011
- createMonthNav = function( next ) {
1012
-
1013
- // Otherwise, return the created month tag.
1014
- return _.node(
1015
- 'div',
1016
- ' ',
1017
- settings.klass[ 'nav' + ( next ? 'Next' : 'Prev' ) ] + (
1018
-
1019
- // If the focused month is outside the range, disabled the button.
1020
- ( next && viewsetObject.year >= maxLimitObject.year && viewsetObject.month >= maxLimitObject.month ) ||
1021
- ( !next && viewsetObject.year <= minLimitObject.year && viewsetObject.month <= minLimitObject.month ) ?
1022
- ' ' + settings.klass.navDisabled : ''
1023
- ),
1024
- 'data-nav=' + ( next || -1 ) + ' ' +
1025
- _.ariaAttr({
1026
- role: 'button',
1027
- controls: calendar.$node[0].id + '_table'
1028
- }) + ' ' +
1029
- 'title="' + (next ? settings.labelMonthNext : settings.labelMonthPrev ) + '"'
1030
- ) //endreturn
1031
- }, //createMonthNav
1032
-
1033
-
1034
- // Create the month label.
1035
- //Materialize modified
1036
- createMonthLabel = function(override) {
1037
-
1038
- var monthsCollection = settings.showMonthsShort ? settings.monthsShort : settings.monthsFull
1039
-
1040
- // Materialize modified
1041
- if (override == "short_months") {
1042
- monthsCollection = settings.monthsShort;
1043
- }
1044
-
1045
- // If there are months to select, add a dropdown menu.
1046
- if ( settings.selectMonths && override == undefined ) {
1047
-
1048
- return _.node( 'select',
1049
- _.group({
1050
- min: 0,
1051
- max: 11,
1052
- i: 1,
1053
- node: 'option',
1054
- item: function( loopedMonth ) {
1055
-
1056
- return [
1057
-
1058
- // The looped month and no classes.
1059
- monthsCollection[ loopedMonth ], 0,
1060
-
1061
- // Set the value and selected index.
1062
- 'value=' + loopedMonth +
1063
- ( viewsetObject.month == loopedMonth ? ' selected' : '' ) +
1064
- (
1065
- (
1066
- ( viewsetObject.year == minLimitObject.year && loopedMonth < minLimitObject.month ) ||
1067
- ( viewsetObject.year == maxLimitObject.year && loopedMonth > maxLimitObject.month )
1068
- ) ?
1069
- ' disabled' : ''
1070
- )
1071
- ]
1072
- }
1073
- }),
1074
- settings.klass.selectMonth + ' browser-default',
1075
- ( isOpen ? '' : 'disabled' ) + ' ' +
1076
- _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' +
1077
- 'title="' + settings.labelMonthSelect + '"'
1078
- )
1079
- }
1080
- // Materialize modified
1081
- if (override == "short_months") if (selectedObject != null) return monthsCollection[selectedObject.month];else return monthsCollection[viewsetObject.month];
1082
-
1083
- // If there's a need for a month selector
1084
- return _.node( 'div', monthsCollection[ viewsetObject.month ], settings.klass.month )
1085
- }, //createMonthLabel
1086
-
1087
-
1088
- // Create the year label.
1089
- // Materialize modified
1090
- createYearLabel = function (override) {
1091
-
1092
- var focusedYear = viewsetObject.year,
1093
-
1094
- // If years selector is set to a literal "true", set it to 5. Otherwise
1095
- // divide in half to get half before and half after focused year.
1096
- numberYears = settings.selectYears === true ? 5 : ~~( settings.selectYears / 2 )
1097
-
1098
- // If there are years to select, add a dropdown menu.
1099
- if ( numberYears ) {
1100
-
1101
- var
1102
- minYear = minLimitObject.year,
1103
- maxYear = maxLimitObject.year,
1104
- lowestYear = focusedYear - numberYears,
1105
- highestYear = focusedYear + numberYears
1106
-
1107
- // If the min year is greater than the lowest year, increase the highest year
1108
- // by the difference and set the lowest year to the min year.
1109
- if ( minYear > lowestYear ) {
1110
- highestYear += minYear - lowestYear
1111
- lowestYear = minYear
1112
- }
1113
-
1114
- // If the max year is less than the highest year, decrease the lowest year
1115
- // by the lower of the two: available and needed years. Then set the
1116
- // highest year to the max year.
1117
- if ( maxYear < highestYear ) {
1118
-
1119
- var availableYears = lowestYear - minYear,
1120
- neededYears = highestYear - maxYear
1121
-
1122
- lowestYear -= availableYears > neededYears ? neededYears : availableYears
1123
- highestYear = maxYear
1124
- }
1125
-
1126
- if (settings.selectYears && override == undefined) {
1127
- return _.node('select', _.group({
1128
- min: lowestYear,
1129
- max: highestYear,
1130
- i: 1,
1131
- node: 'option',
1132
- item: function (loopedYear) {
1133
- return [
1134
-
1135
- // The looped year and no classes.
1136
- loopedYear, 0,
1137
-
1138
- // Set the value and selected index.
1139
- 'value=' + loopedYear + (focusedYear == loopedYear ? ' selected' : '')
1140
- ]
1141
- }
1142
- }),
1143
- settings.klass.selectYear + ' browser-default',
1144
- (isOpen ? '' : 'disabled') + ' ' + _.ariaAttr({controls: calendar.$node[0].id + '_table'}) + ' ' +
1145
- 'title="' + settings.labelYearSelect + '"'
1146
- )
1147
- }
1148
- }
1149
-
1150
- // Materialize modified
1151
- if (override === 'raw' && selectedObject != null) {
1152
- return _.node('div', selectedObject.year);
1153
- }
1154
-
1155
- // Otherwise just return the year focused
1156
- return _.node( 'div', focusedYear, settings.klass.year )
1157
- } //createYearLabel
1158
-
1159
- // Materialize modified
1160
- createDayLabel = function () {
1161
- if (selectedObject != null) return selectedObject.date;else return nowObject.date;
1162
- }
1163
- createWeekdayLabel = function () {
1164
- var display_day;
1165
-
1166
- if (selectedObject != null) display_day = selectedObject.day;else display_day = nowObject.day;
1167
- var weekday = settings.weekdaysShort[display_day];
1168
- return weekday;
1169
- }
1170
-
1171
- // Create and return the entire calendar.
1172
- return _.node(
1173
- // Date presentation View
1174
- 'div',
1175
- // Div for Year
1176
- _.node('div', createYearLabel("raw"), settings.klass.year_display) +
1177
- _.node('span', createWeekdayLabel() + ', ', "picker__weekday-display") +
1178
- // Div for short Month
1179
- _.node('span', createMonthLabel("short_months") + ' ', settings.klass.month_display) +
1180
- // Div for Day
1181
- _.node('span', createDayLabel(), settings.klass.day_display),
1182
- settings.klass.date_display
1183
- ) +
1184
- // Calendar container
1185
- _.node('div',
1186
- _.node('div',
1187
- _.node('div',
1188
- (settings.selectYears ? createYearLabel() + createMonthLabel() : createMonthLabel() + createYearLabel()) +
1189
- createMonthNav() + createMonthNav(1),
1190
- settings.klass.header
1191
- ) +
1192
- _.node('table',
1193
- tableHead +
1194
- _.node('tbody',
1195
- _.group({
1196
- min: 0,
1197
- max: WEEKS_IN_CALENDAR - 1,
1198
- i: 1,
1199
- node: 'tr',
1200
- item: function( rowCounter ) {
1201
-
1202
- // If Monday is the first day and the month starts on Sunday, shift the date back a week.
1203
- var shiftDateBy = settings.firstDay && calendar.create([ viewsetObject.year, viewsetObject.month, 1 ]).day === 0 ? -7 : 0
1204
-
1205
- return [
1206
- _.group({
1207
- min: DAYS_IN_WEEK * rowCounter - viewsetObject.day + shiftDateBy + 1, // Add 1 for weekday 0index
1208
- max: function() {
1209
- return this.min + DAYS_IN_WEEK - 1
1210
- },
1211
- i: 1,
1212
- node: 'td',
1213
- item: function( targetDate ) {
1214
-
1215
- // Convert the time date from a relative date to a target date.
1216
- targetDate = calendar.create([ viewsetObject.year, viewsetObject.month, targetDate + ( settings.firstDay ? 1 : 0 ) ])
1217
-
1218
- var isSelected = selectedObject && selectedObject.pick == targetDate.pick,
1219
- isHighlighted = highlightedObject && highlightedObject.pick == targetDate.pick,
1220
- isDisabled = disabledCollection && calendar.disabled( targetDate ) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick,
1221
- formattedDate = _.trigger( calendar.formats.toString, calendar, [ settings.format, targetDate ] )
1222
-
1223
- return [
1224
- _.node(
1225
- 'div',
1226
- targetDate.date,
1227
- (function( klasses ) {
1228
-
1229
- // Add the `infocus` or `outfocus` classes based on month in view.
1230
- klasses.push( viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus )
1231
-
1232
- // Add the `today` class if needed.
1233
- if ( nowObject.pick == targetDate.pick ) {
1234
- klasses.push( settings.klass.now )
1235
- }
1236
-
1237
- // Add the `selected` class if something's selected and the time matches.
1238
- if ( isSelected ) {
1239
- klasses.push( settings.klass.selected )
1240
- }
1241
-
1242
- // Add the `highlighted` class if something's highlighted and the time matches.
1243
- if ( isHighlighted ) {
1244
- klasses.push( settings.klass.highlighted )
1245
- }
1246
-
1247
- // Add the `disabled` class if something's disabled and the object matches.
1248
- if ( isDisabled ) {
1249
- klasses.push( settings.klass.disabled )
1250
- }
1251
-
1252
- return klasses.join( ' ' )
1253
- })([ settings.klass.day ]),
1254
- 'data-pick=' + targetDate.pick + ' ' + _.ariaAttr({
1255
- role: 'gridcell',
1256
- label: formattedDate,
1257
- selected: isSelected && calendar.$node.val() === formattedDate ? true : null,
1258
- activedescendant: isHighlighted ? true : null,
1259
- disabled: isDisabled ? true : null
1260
- })
1261
- ),
1262
- '',
1263
- _.ariaAttr({ role: 'presentation' })
1264
- ] //endreturn
1265
- }
1266
- })
1267
- ] //endreturn
1268
- }
1269
- })
1270
- ),
1271
- settings.klass.table,
1272
- 'id="' + calendar.$node[0].id + '_table' + '" ' + _.ariaAttr({
1273
- role: 'grid',
1274
- controls: calendar.$node[0].id,
1275
- readonly: true
1276
- })
1277
- ),
1278
- settings.klass.calendar_container
1279
- ) // end calendar
1280
- +
1281
-
1282
- // * For Firefox forms to submit, make sure to set the buttons’ `type` attributes as “button”.
1283
- _.node(
1284
- 'div',
1285
- _.node( 'button', settings.today, "btn-flat picker__today waves-effect",
1286
- 'type=button data-pick=' + nowObject.pick +
1287
- ( isOpen && !calendar.disabled(nowObject) ? '' : ' disabled' ) + ' ' +
1288
- _.ariaAttr({ controls: calendar.$node[0].id }) ) +
1289
- _.node( 'button', settings.clear, "btn-flat picker__clear waves-effect",
1290
- 'type=button data-clear=1' +
1291
- ( isOpen ? '' : ' disabled' ) + ' ' +
1292
- _.ariaAttr({ controls: calendar.$node[0].id }) ) +
1293
- _.node('button', settings.close, "btn-flat picker__close waves-effect",
1294
- 'type=button data-close=true ' +
1295
- ( isOpen ? '' : ' disabled' ) + ' ' +
1296
- _.ariaAttr({ controls: calendar.$node[0].id }) ),
1297
- settings.klass.footer
1298
- ),
1299
- 'picker__container__wrapper'
1300
- ) //endreturn
1301
- } //DatePicker.prototype.nodes
1302
-
1303
-
1304
-
1305
-
1306
- /**
1307
- * The date picker defaults.
1308
- */
1309
- DatePicker.defaults = (function( prefix ) {
1310
-
1311
- return {
1312
-
1313
- // The title label to use for the month nav buttons
1314
- labelMonthNext: 'Next month',
1315
- labelMonthPrev: 'Previous month',
1316
-
1317
- // The title label to use for the dropdown selectors
1318
- labelMonthSelect: 'Select a month',
1319
- labelYearSelect: 'Select a year',
1320
-
1321
- // Months and weekdays
1322
- monthsFull: [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ],
1323
- monthsShort: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
1324
- weekdaysFull: [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
1325
- weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
1326
-
1327
- // Materialize modified
1328
- weekdaysLetter: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1329
-
1330
- // Today and clear
1331
- today: 'Today',
1332
- clear: 'Clear',
1333
- close: 'Close',
1334
-
1335
- // Picker close behavior
1336
- closeOnSelect: true,
1337
- closeOnClear: true,
1338
-
1339
- // Update input value on select/clear
1340
- updateInput: true,
1341
-
1342
- // The format to show on the `input` element
1343
- format: 'd mmmm, yyyy',
1344
-
1345
- // Classes
1346
- klass: {
1347
-
1348
- table: prefix + 'table',
1349
-
1350
- header: prefix + 'header',
1351
-
1352
- // Materialize Added klasses
1353
- date_display: prefix + 'date-display',
1354
- day_display: prefix + 'day-display',
1355
- month_display: prefix + 'month-display',
1356
- year_display: prefix + 'year-display',
1357
- calendar_container: prefix + 'calendar-container',
1358
- // end
1359
-
1360
- navPrev: prefix + 'nav--prev',
1361
- navNext: prefix + 'nav--next',
1362
- navDisabled: prefix + 'nav--disabled',
1363
-
1364
- month: prefix + 'month',
1365
- year: prefix + 'year',
1366
-
1367
- selectMonth: prefix + 'select--month',
1368
- selectYear: prefix + 'select--year',
1369
-
1370
- weekdays: prefix + 'weekday',
1371
-
1372
- day: prefix + 'day',
1373
- disabled: prefix + 'day--disabled',
1374
- selected: prefix + 'day--selected',
1375
- highlighted: prefix + 'day--highlighted',
1376
- now: prefix + 'day--today',
1377
- infocus: prefix + 'day--infocus',
1378
- outfocus: prefix + 'day--outfocus',
1379
-
1380
- footer: prefix + 'footer',
1381
-
1382
- buttonClear: prefix + 'button--clear',
1383
- buttonToday: prefix + 'button--today',
1384
- buttonClose: prefix + 'button--close'
1385
- }
1386
- }
1387
- })( Picker.klasses().picker + '__' )
1388
-
1389
-
1390
-
1391
-
1392
-
1393
- /**
1394
- * Extend the picker to add the date picker.
1395
- */
1396
- Picker.extend( 'pickadate', DatePicker )
1397
-
1398
-
1399
- });