bitsnote-assets 0.0.1 → 0.0.2

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