materialize-sass 0.100.2 → 0.100.2.1

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