materialize-sass 0.99.0 → 0.100.0

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