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,1014 @@
1
+
2
+ /*!
3
+ * Time picker for pickadate.js v3.5.3
4
+ * http://amsul.github.io/pickadate.js/time.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 HOURS_IN_DAY = 24,
27
+ MINUTES_IN_HOUR = 60,
28
+ HOURS_TO_NOON = 12,
29
+ MINUTES_IN_DAY = HOURS_IN_DAY * MINUTES_IN_HOUR,
30
+ _ = Picker._
31
+
32
+
33
+
34
+ /**
35
+ * The time picker constructor
36
+ */
37
+ function TimePicker( picker, settings ) {
38
+
39
+ var clock = this,
40
+ elementValue = picker.$node[ 0 ].value,
41
+ elementDataValue = picker.$node.data( 'value' ),
42
+ valueString = elementDataValue || elementValue,
43
+ formatString = elementDataValue ? settings.formatSubmit : settings.format
44
+
45
+ clock.settings = settings
46
+ clock.$node = picker.$node
47
+
48
+ // The queue of methods that will be used to build item objects.
49
+ clock.queue = {
50
+ interval: 'i',
51
+ min: 'measure create',
52
+ max: 'measure create',
53
+ now: 'now create',
54
+ select: 'parse create validate',
55
+ highlight: 'parse create validate',
56
+ view: 'parse create validate',
57
+ disable: 'deactivate',
58
+ enable: 'activate'
59
+ }
60
+
61
+ // The component's item object.
62
+ clock.item = {}
63
+
64
+ clock.item.clear = null
65
+ clock.item.interval = settings.interval || 30
66
+ clock.item.disable = ( settings.disable || [] ).slice( 0 )
67
+ clock.item.enable = -(function( collectionDisabled ) {
68
+ return collectionDisabled[ 0 ] === true ? collectionDisabled.shift() : -1
69
+ })( clock.item.disable )
70
+
71
+ clock.
72
+ set( 'min', settings.min ).
73
+ set( 'max', settings.max ).
74
+ set( 'now' )
75
+
76
+ // When there’s a value, set the `select`, which in turn
77
+ // also sets the `highlight` and `view`.
78
+ if ( valueString ) {
79
+ clock.set( 'select', valueString, {
80
+ format: formatString,
81
+ fromValue: !!elementValue
82
+ })
83
+ }
84
+
85
+ // If there’s no value, default to highlighting “today”.
86
+ else {
87
+ clock.
88
+ set( 'select', null ).
89
+ set( 'highlight', clock.item.now )
90
+ }
91
+
92
+ // The keycode to movement mapping.
93
+ clock.key = {
94
+ 40: 1, // Down
95
+ 38: -1, // Up
96
+ 39: 1, // Right
97
+ 37: -1, // Left
98
+ go: function( timeChange ) {
99
+ clock.set(
100
+ 'highlight',
101
+ clock.item.highlight.pick + timeChange * clock.item.interval,
102
+ { interval: timeChange * clock.item.interval }
103
+ )
104
+ this.render()
105
+ }
106
+ }
107
+
108
+
109
+ // Bind some picker events.
110
+ picker.
111
+ on( 'render', function() {
112
+ var $pickerHolder = picker.$root.children(),
113
+ $viewset = $pickerHolder.find( '.' + settings.klass.viewset ),
114
+ vendors = function( prop ) {
115
+ return ['webkit', 'moz', 'ms', 'o', ''].map(function( vendor ) {
116
+ return ( vendor ? '-' + vendor + '-' : '' ) + prop
117
+ })
118
+ },
119
+ animations = function( $el, state ) {
120
+ vendors( 'transform' ).map(function( prop ) {
121
+ $el.css( prop, state )
122
+ })
123
+ vendors( 'transition' ).map(function( prop ) {
124
+ $el.css( prop, state )
125
+ })
126
+ }
127
+ if ( $viewset.length ) {
128
+ animations( $pickerHolder, 'none' )
129
+ $pickerHolder[ 0 ].scrollTop = ~~$viewset.position().top - ( $viewset[ 0 ].clientHeight * 2 )
130
+ animations( $pickerHolder, '' )
131
+ }
132
+ }, 1 ).
133
+ on( 'open', function() {
134
+ picker.$root.find( 'button' ).attr( 'disabled', false )
135
+ }, 1 ).
136
+ on( 'close', function() {
137
+ picker.$root.find( 'button' ).attr( 'disabled', true )
138
+ }, 1 )
139
+
140
+ } //TimePicker
141
+
142
+
143
+ /**
144
+ * Set a timepicker item object.
145
+ */
146
+ TimePicker.prototype.set = function( type, value, options ) {
147
+
148
+ var clock = this,
149
+ clockItem = clock.item
150
+
151
+ // If the value is `null` just set it immediately.
152
+ if ( value === null ) {
153
+ if ( type == 'clear' ) type = 'select'
154
+ clockItem[ type ] = value
155
+ return clock
156
+ }
157
+
158
+ // Otherwise go through the queue of methods, and invoke the functions.
159
+ // Update this as the time unit, and set the final value as this item.
160
+ // * In the case of `enable`, keep the queue but set `disable` instead.
161
+ // And in the case of `flip`, keep the queue but set `enable` instead.
162
+ clockItem[ ( type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type ) ] = clock.queue[ type ].split( ' ' ).map( function( method ) {
163
+ value = clock[ method ]( type, value, options )
164
+ return value
165
+ }).pop()
166
+
167
+ // Check if we need to cascade through more updates.
168
+ if ( type == 'select' ) {
169
+ clock.set( 'highlight', clockItem.select, options )
170
+ }
171
+ else if ( type == 'highlight' ) {
172
+ clock.set( 'view', clockItem.highlight, options )
173
+ }
174
+ else if ( type == 'interval' ) {
175
+ clock.
176
+ set( 'min', clockItem.min, options ).
177
+ set( 'max', clockItem.max, options )
178
+ }
179
+ else if ( type.match( /^(flip|min|max|disable|enable)$/ ) ) {
180
+ if ( type == 'min' ) {
181
+ clock.set( 'max', clockItem.max, options )
182
+ }
183
+ if ( clockItem.select && clock.disabled( clockItem.select ) ) {
184
+ clock.set( 'select', clockItem.select, options )
185
+ }
186
+ if ( clockItem.highlight && clock.disabled( clockItem.highlight ) ) {
187
+ clock.set( 'highlight', clockItem.highlight, options )
188
+ }
189
+ }
190
+
191
+ return clock
192
+ } //TimePicker.prototype.set
193
+
194
+
195
+ /**
196
+ * Get a timepicker item object.
197
+ */
198
+ TimePicker.prototype.get = function( type ) {
199
+ return this.item[ type ]
200
+ } //TimePicker.prototype.get
201
+
202
+
203
+ /**
204
+ * Create a picker time object.
205
+ */
206
+ TimePicker.prototype.create = function( type, value, options ) {
207
+
208
+ var clock = this
209
+
210
+ // If there’s no value, use the type as the value.
211
+ value = value === undefined ? type : value
212
+
213
+ // If it’s a date object, convert it into an array.
214
+ if ( _.isDate( value ) ) {
215
+ value = [ value.getHours(), value.getMinutes() ]
216
+ }
217
+
218
+ // If it’s an object, use the “pick” value.
219
+ if ( $.isPlainObject( value ) && _.isInteger( value.pick ) ) {
220
+ value = value.pick
221
+ }
222
+
223
+ // If it’s an array, convert it into minutes.
224
+ else if ( $.isArray( value ) ) {
225
+ value = +value[ 0 ] * MINUTES_IN_HOUR + (+value[ 1 ])
226
+ }
227
+
228
+ // If no valid value is passed, set it to “now”.
229
+ else if ( !_.isInteger( value ) ) {
230
+ value = clock.now( type, value, options )
231
+ }
232
+
233
+ // If we’re setting the max, make sure it’s greater than the min.
234
+ if ( type == 'max' && value < clock.item.min.pick ) {
235
+ value += MINUTES_IN_DAY
236
+ }
237
+
238
+ // If the value doesn’t fall directly on the interval,
239
+ // add one interval to indicate it as “passed”.
240
+ if ( type != 'min' && type != 'max' && (value - clock.item.min.pick) % clock.item.interval !== 0 ) {
241
+ value += clock.item.interval
242
+ }
243
+
244
+ // Normalize it into a “reachable” interval.
245
+ value = clock.normalize( type, value, options )
246
+
247
+ // Return the compiled object.
248
+ return {
249
+
250
+ // Divide to get hours from minutes.
251
+ hour: ~~( HOURS_IN_DAY + value / MINUTES_IN_HOUR ) % HOURS_IN_DAY,
252
+
253
+ // The remainder is the minutes.
254
+ mins: ( MINUTES_IN_HOUR + value % MINUTES_IN_HOUR ) % MINUTES_IN_HOUR,
255
+
256
+ // The time in total minutes.
257
+ time: ( MINUTES_IN_DAY + value ) % MINUTES_IN_DAY,
258
+
259
+ // Reference to the “relative” value to pick.
260
+ pick: value
261
+ }
262
+ } //TimePicker.prototype.create
263
+
264
+
265
+ /**
266
+ * Create a range limit object using an array, date object,
267
+ * literal “true”, or integer relative to another time.
268
+ */
269
+ TimePicker.prototype.createRange = function( from, to ) {
270
+
271
+ var clock = this,
272
+ createTime = function( time ) {
273
+ if ( time === true || $.isArray( time ) || _.isDate( time ) ) {
274
+ return clock.create( time )
275
+ }
276
+ return time
277
+ }
278
+
279
+ // Create objects if possible.
280
+ if ( !_.isInteger( from ) ) {
281
+ from = createTime( from )
282
+ }
283
+ if ( !_.isInteger( to ) ) {
284
+ to = createTime( to )
285
+ }
286
+
287
+ // Create relative times.
288
+ if ( _.isInteger( from ) && $.isPlainObject( to ) ) {
289
+ from = [ to.hour, to.mins + ( from * clock.settings.interval ) ];
290
+ }
291
+ else if ( _.isInteger( to ) && $.isPlainObject( from ) ) {
292
+ to = [ from.hour, from.mins + ( to * clock.settings.interval ) ];
293
+ }
294
+
295
+ return {
296
+ from: createTime( from ),
297
+ to: createTime( to )
298
+ }
299
+ } //TimePicker.prototype.createRange
300
+
301
+
302
+ /**
303
+ * Check if a time unit falls within a time range object.
304
+ */
305
+ TimePicker.prototype.withinRange = function( range, timeUnit ) {
306
+ range = this.createRange(range.from, range.to)
307
+ return timeUnit.pick >= range.from.pick && timeUnit.pick <= range.to.pick
308
+ }
309
+
310
+
311
+ /**
312
+ * Check if two time range objects overlap.
313
+ */
314
+ TimePicker.prototype.overlapRanges = function( one, two ) {
315
+
316
+ var clock = this
317
+
318
+ // Convert the ranges into comparable times.
319
+ one = clock.createRange( one.from, one.to )
320
+ two = clock.createRange( two.from, two.to )
321
+
322
+ return clock.withinRange( one, two.from ) || clock.withinRange( one, two.to ) ||
323
+ clock.withinRange( two, one.from ) || clock.withinRange( two, one.to )
324
+ }
325
+
326
+
327
+ /**
328
+ * Get the time relative to now.
329
+ */
330
+ TimePicker.prototype.now = function( type, value/*, options*/ ) {
331
+
332
+ var interval = this.item.interval,
333
+ date = new Date(),
334
+ nowMinutes = date.getHours() * MINUTES_IN_HOUR + date.getMinutes(),
335
+ isValueInteger = _.isInteger( value ),
336
+ isBelowInterval
337
+
338
+ // Make sure “now” falls within the interval range.
339
+ nowMinutes -= nowMinutes % interval
340
+
341
+ // Check if the difference is less than the interval itself.
342
+ isBelowInterval = value < 0 && interval * value + nowMinutes <= -interval
343
+
344
+ // Add an interval because the time has “passed”.
345
+ nowMinutes += type == 'min' && isBelowInterval ? 0 : interval
346
+
347
+ // If the value is a number, adjust by that many intervals.
348
+ if ( isValueInteger ) {
349
+ nowMinutes += interval * (
350
+ isBelowInterval && type != 'max' ?
351
+ value + 1 :
352
+ value
353
+ )
354
+ }
355
+
356
+ // Return the final calculation.
357
+ return nowMinutes
358
+ } //TimePicker.prototype.now
359
+
360
+
361
+ /**
362
+ * Normalize minutes to be “reachable” based on the min and interval.
363
+ */
364
+ TimePicker.prototype.normalize = function( type, value/*, options*/ ) {
365
+
366
+ var interval = this.item.interval,
367
+ minTime = this.item.min && this.item.min.pick || 0
368
+
369
+ // If setting min time, don’t shift anything.
370
+ // Otherwise get the value and min difference and then
371
+ // normalize the difference with the interval.
372
+ value -= type == 'min' ? 0 : ( value - minTime ) % interval
373
+
374
+ // Return the adjusted value.
375
+ return value
376
+ } //TimePicker.prototype.normalize
377
+
378
+
379
+ /**
380
+ * Measure the range of minutes.
381
+ */
382
+ TimePicker.prototype.measure = function( type, value, options ) {
383
+
384
+ var clock = this
385
+
386
+ // If it’s anything false-y, set it to the default.
387
+ if ( !value ) {
388
+ value = type == 'min' ? [ 0, 0 ] : [ HOURS_IN_DAY - 1, MINUTES_IN_HOUR - 1 ]
389
+ }
390
+
391
+ // If it’s a string, parse it.
392
+ if ( typeof value == 'string' ) {
393
+ value = clock.parse( type, value )
394
+ }
395
+
396
+ // If it’s a literal true, or an integer, make it relative to now.
397
+ else if ( value === true || _.isInteger( value ) ) {
398
+ value = clock.now( type, value, options )
399
+ }
400
+
401
+ // If it’s an object already, just normalize it.
402
+ else if ( $.isPlainObject( value ) && _.isInteger( value.pick ) ) {
403
+ value = clock.normalize( type, value.pick, options )
404
+ }
405
+
406
+ return value
407
+ } ///TimePicker.prototype.measure
408
+
409
+
410
+ /**
411
+ * Validate an object as enabled.
412
+ */
413
+ TimePicker.prototype.validate = function( type, timeObject, options ) {
414
+
415
+ var clock = this,
416
+ interval = options && options.interval ? options.interval : clock.item.interval
417
+
418
+ // Check if the object is disabled.
419
+ if ( clock.disabled( timeObject ) ) {
420
+
421
+ // Shift with the interval until we reach an enabled time.
422
+ timeObject = clock.shift( timeObject, interval )
423
+ }
424
+
425
+ // Scope the object into range.
426
+ timeObject = clock.scope( timeObject )
427
+
428
+ // Do a second check to see if we landed on a disabled min/max.
429
+ // In that case, shift using the opposite interval as before.
430
+ if ( clock.disabled( timeObject ) ) {
431
+ timeObject = clock.shift( timeObject, interval * -1 )
432
+ }
433
+
434
+ // Return the final object.
435
+ return timeObject
436
+ } //TimePicker.prototype.validate
437
+
438
+
439
+ /**
440
+ * Check if an object is disabled.
441
+ */
442
+ TimePicker.prototype.disabled = function( timeToVerify ) {
443
+
444
+ var clock = this,
445
+
446
+ // Filter through the disabled times to check if this is one.
447
+ isDisabledMatch = clock.item.disable.filter( function( timeToDisable ) {
448
+
449
+ // If the time is a number, match the hours.
450
+ if ( _.isInteger( timeToDisable ) ) {
451
+ return timeToVerify.hour == timeToDisable
452
+ }
453
+
454
+ // If it’s an array, create the object and match the times.
455
+ if ( $.isArray( timeToDisable ) || _.isDate( timeToDisable ) ) {
456
+ return timeToVerify.pick == clock.create( timeToDisable ).pick
457
+ }
458
+
459
+ // If it’s an object, match a time within the “from” and “to” range.
460
+ if ( $.isPlainObject( timeToDisable ) ) {
461
+ return clock.withinRange( timeToDisable, timeToVerify )
462
+ }
463
+ })
464
+
465
+ // If this time matches a disabled time, confirm it’s not inverted.
466
+ isDisabledMatch = isDisabledMatch.length && !isDisabledMatch.filter(function( timeToDisable ) {
467
+ return $.isArray( timeToDisable ) && timeToDisable[2] == 'inverted' ||
468
+ $.isPlainObject( timeToDisable ) && timeToDisable.inverted
469
+ }).length
470
+
471
+ // If the clock is "enabled" flag is flipped, flip the condition.
472
+ return clock.item.enable === -1 ? !isDisabledMatch : isDisabledMatch ||
473
+ timeToVerify.pick < clock.item.min.pick ||
474
+ timeToVerify.pick > clock.item.max.pick
475
+ } //TimePicker.prototype.disabled
476
+
477
+
478
+ /**
479
+ * Shift an object by an interval until we reach an enabled object.
480
+ */
481
+ TimePicker.prototype.shift = function( timeObject, interval ) {
482
+
483
+ var clock = this,
484
+ minLimit = clock.item.min.pick,
485
+ maxLimit = clock.item.max.pick/*,
486
+ safety = 1000*/
487
+
488
+ interval = interval || clock.item.interval
489
+
490
+ // Keep looping as long as the time is disabled.
491
+ while ( /*safety &&*/ clock.disabled( timeObject ) ) {
492
+
493
+ /*safety -= 1
494
+ if ( !safety ) {
495
+ throw 'Fell into an infinite loop while shifting to ' + timeObject.hour + ':' + timeObject.mins + '.'
496
+ }*/
497
+
498
+ // Increase/decrease the time by the interval and keep looping.
499
+ timeObject = clock.create( timeObject.pick += interval )
500
+
501
+ // If we've looped beyond the limits, break out of the loop.
502
+ if ( timeObject.pick <= minLimit || timeObject.pick >= maxLimit ) {
503
+ break
504
+ }
505
+ }
506
+
507
+ // Return the final object.
508
+ return timeObject
509
+ } //TimePicker.prototype.shift
510
+
511
+
512
+ /**
513
+ * Scope an object to be within range of min and max.
514
+ */
515
+ TimePicker.prototype.scope = function( timeObject ) {
516
+ var minLimit = this.item.min.pick,
517
+ maxLimit = this.item.max.pick
518
+ return this.create( timeObject.pick > maxLimit ? maxLimit : timeObject.pick < minLimit ? minLimit : timeObject )
519
+ } //TimePicker.prototype.scope
520
+
521
+
522
+ /**
523
+ * Parse a string into a usable type.
524
+ */
525
+ TimePicker.prototype.parse = function( type, value, options ) {
526
+
527
+ var hour, minutes, isPM, item, parseValue,
528
+ clock = this,
529
+ parsingObject = {}
530
+
531
+ // If it’s already parsed, we’re good.
532
+ if ( !value || typeof value != 'string' ) {
533
+ return value
534
+ }
535
+
536
+ // We need a `.format` to parse the value with.
537
+ if ( !( options && options.format ) ) {
538
+ options = options || {}
539
+ options.format = clock.settings.format
540
+ }
541
+
542
+ // Convert the format into an array and then map through it.
543
+ clock.formats.toArray( options.format ).map( function( label ) {
544
+
545
+ var
546
+ substring,
547
+
548
+ // Grab the formatting label.
549
+ formattingLabel = clock.formats[ label ],
550
+
551
+ // The format length is from the formatting label function or the
552
+ // label length without the escaping exclamation (!) mark.
553
+ formatLength = formattingLabel ?
554
+ _.trigger( formattingLabel, clock, [ value, parsingObject ] ) :
555
+ label.replace( /^!/, '' ).length
556
+
557
+ // If there's a format label, split the value up to the format length.
558
+ // Then add it to the parsing object with appropriate label.
559
+ if ( formattingLabel ) {
560
+ substring = value.substr( 0, formatLength )
561
+ parsingObject[ label ] = substring.match(/^\d+$/) ? +substring : substring
562
+ }
563
+
564
+ // Update the time value as the substring from format length to end.
565
+ value = value.substr( formatLength )
566
+ })
567
+
568
+ // Grab the hour and minutes from the parsing object.
569
+ for ( item in parsingObject ) {
570
+ parseValue = parsingObject[item]
571
+ if ( _.isInteger(parseValue) ) {
572
+ if ( item.match(/^(h|hh)$/i) ) {
573
+ hour = parseValue
574
+ if ( item == 'h' || item == 'hh' ) {
575
+ hour %= 12
576
+ }
577
+ }
578
+ else if ( item == 'i' ) {
579
+ minutes = parseValue
580
+ }
581
+ }
582
+ else if ( item.match(/^a$/i) && parseValue.match(/^p/i) && ('h' in parsingObject || 'hh' in parsingObject) ) {
583
+ isPM = true
584
+ }
585
+ }
586
+
587
+ // Calculate it in minutes and return.
588
+ return (isPM ? hour + 12 : hour) * MINUTES_IN_HOUR + minutes
589
+ } //TimePicker.prototype.parse
590
+
591
+
592
+ /**
593
+ * Various formats to display the object in.
594
+ */
595
+ TimePicker.prototype.formats = {
596
+
597
+ h: function( string, timeObject ) {
598
+
599
+ // If there's string, then get the digits length.
600
+ // Otherwise return the selected hour in "standard" format.
601
+ return string ? _.digits( string ) : timeObject.hour % HOURS_TO_NOON || HOURS_TO_NOON
602
+ },
603
+ hh: function( string, timeObject ) {
604
+
605
+ // If there's a string, then the length is always 2.
606
+ // Otherwise return the selected hour in "standard" format with a leading zero.
607
+ return string ? 2 : _.lead( timeObject.hour % HOURS_TO_NOON || HOURS_TO_NOON )
608
+ },
609
+ H: function( string, timeObject ) {
610
+
611
+ // If there's string, then get the digits length.
612
+ // Otherwise return the selected hour in "military" format as a string.
613
+ return string ? _.digits( string ) : '' + ( timeObject.hour % 24 )
614
+ },
615
+ HH: function( string, timeObject ) {
616
+
617
+ // If there's string, then get the digits length.
618
+ // Otherwise return the selected hour in "military" format with a leading zero.
619
+ return string ? _.digits( string ) : _.lead( timeObject.hour % 24 )
620
+ },
621
+ i: function( string, timeObject ) {
622
+
623
+ // If there's a string, then the length is always 2.
624
+ // Otherwise return the selected minutes.
625
+ return string ? 2 : _.lead( timeObject.mins )
626
+ },
627
+ a: function( string, timeObject ) {
628
+
629
+ // If there's a string, then the length is always 4.
630
+ // Otherwise check if it's more than "noon" and return either am/pm.
631
+ return string ? 4 : MINUTES_IN_DAY / 2 > timeObject.time % MINUTES_IN_DAY ? 'a.m.' : 'p.m.'
632
+ },
633
+ A: function( string, timeObject ) {
634
+
635
+ // If there's a string, then the length is always 2.
636
+ // Otherwise check if it's more than "noon" and return either am/pm.
637
+ return string ? 2 : MINUTES_IN_DAY / 2 > timeObject.time % MINUTES_IN_DAY ? 'AM' : 'PM'
638
+ },
639
+
640
+ // Create an array by splitting the formatting string passed.
641
+ toArray: function( formatString ) { return formatString.split( /(h{1,2}|H{1,2}|i|a|A|!.)/g ) },
642
+
643
+ // Format an object into a string using the formatting options.
644
+ toString: function ( formatString, itemObject ) {
645
+ var clock = this
646
+ return clock.formats.toArray( formatString ).map( function( label ) {
647
+ return _.trigger( clock.formats[ label ], clock, [ 0, itemObject ] ) || label.replace( /^!/, '' )
648
+ }).join( '' )
649
+ }
650
+ } //TimePicker.prototype.formats
651
+
652
+
653
+
654
+
655
+ /**
656
+ * Check if two time units are the exact.
657
+ */
658
+ TimePicker.prototype.isTimeExact = function( one, two ) {
659
+
660
+ var clock = this
661
+
662
+ // When we’re working with minutes, do a direct comparison.
663
+ if (
664
+ ( _.isInteger( one ) && _.isInteger( two ) ) ||
665
+ ( typeof one == 'boolean' && typeof two == 'boolean' )
666
+ ) {
667
+ return one === two
668
+ }
669
+
670
+ // When we’re working with time representations, compare the “pick” value.
671
+ if (
672
+ ( _.isDate( one ) || $.isArray( one ) ) &&
673
+ ( _.isDate( two ) || $.isArray( two ) )
674
+ ) {
675
+ return clock.create( one ).pick === clock.create( two ).pick
676
+ }
677
+
678
+ // When we’re working with range objects, compare the “from” and “to”.
679
+ if ( $.isPlainObject( one ) && $.isPlainObject( two ) ) {
680
+ return clock.isTimeExact( one.from, two.from ) && clock.isTimeExact( one.to, two.to )
681
+ }
682
+
683
+ return false
684
+ }
685
+
686
+
687
+ /**
688
+ * Check if two time units overlap.
689
+ */
690
+ TimePicker.prototype.isTimeOverlap = function( one, two ) {
691
+
692
+ var clock = this
693
+
694
+ // When we’re working with an integer, compare the hours.
695
+ if ( _.isInteger( one ) && ( _.isDate( two ) || $.isArray( two ) ) ) {
696
+ return one === clock.create( two ).hour
697
+ }
698
+ if ( _.isInteger( two ) && ( _.isDate( one ) || $.isArray( one ) ) ) {
699
+ return two === clock.create( one ).hour
700
+ }
701
+
702
+ // When we’re working with range objects, check if the ranges overlap.
703
+ if ( $.isPlainObject( one ) && $.isPlainObject( two ) ) {
704
+ return clock.overlapRanges( one, two )
705
+ }
706
+
707
+ return false
708
+ }
709
+
710
+
711
+ /**
712
+ * Flip the “enabled” state.
713
+ */
714
+ TimePicker.prototype.flipEnable = function(val) {
715
+ var itemObject = this.item
716
+ itemObject.enable = val || (itemObject.enable == -1 ? 1 : -1)
717
+ }
718
+
719
+
720
+ /**
721
+ * Mark a collection of times as “disabled”.
722
+ */
723
+ TimePicker.prototype.deactivate = function( type, timesToDisable ) {
724
+
725
+ var clock = this,
726
+ disabledItems = clock.item.disable.slice(0)
727
+
728
+
729
+ // If we’re flipping, that’s all we need to do.
730
+ if ( timesToDisable == 'flip' ) {
731
+ clock.flipEnable()
732
+ }
733
+
734
+ else if ( timesToDisable === false ) {
735
+ clock.flipEnable(1)
736
+ disabledItems = []
737
+ }
738
+
739
+ else if ( timesToDisable === true ) {
740
+ clock.flipEnable(-1)
741
+ disabledItems = []
742
+ }
743
+
744
+ // Otherwise go through the times to disable.
745
+ else {
746
+
747
+ timesToDisable.map(function( unitToDisable ) {
748
+
749
+ var matchFound
750
+
751
+ // When we have disabled items, check for matches.
752
+ // If something is matched, immediately break out.
753
+ for ( var index = 0; index < disabledItems.length; index += 1 ) {
754
+ if ( clock.isTimeExact( unitToDisable, disabledItems[index] ) ) {
755
+ matchFound = true
756
+ break
757
+ }
758
+ }
759
+
760
+ // If nothing was found, add the validated unit to the collection.
761
+ if ( !matchFound ) {
762
+ if (
763
+ _.isInteger( unitToDisable ) ||
764
+ _.isDate( unitToDisable ) ||
765
+ $.isArray( unitToDisable ) ||
766
+ ( $.isPlainObject( unitToDisable ) && unitToDisable.from && unitToDisable.to )
767
+ ) {
768
+ disabledItems.push( unitToDisable )
769
+ }
770
+ }
771
+ })
772
+ }
773
+
774
+ // Return the updated collection.
775
+ return disabledItems
776
+ } //TimePicker.prototype.deactivate
777
+
778
+
779
+ /**
780
+ * Mark a collection of times as “enabled”.
781
+ */
782
+ TimePicker.prototype.activate = function( type, timesToEnable ) {
783
+
784
+ var clock = this,
785
+ disabledItems = clock.item.disable,
786
+ disabledItemsCount = disabledItems.length
787
+
788
+ // If we’re flipping, that’s all we need to do.
789
+ if ( timesToEnable == 'flip' ) {
790
+ clock.flipEnable()
791
+ }
792
+
793
+ else if ( timesToEnable === true ) {
794
+ clock.flipEnable(1)
795
+ disabledItems = []
796
+ }
797
+
798
+ else if ( timesToEnable === false ) {
799
+ clock.flipEnable(-1)
800
+ disabledItems = []
801
+ }
802
+
803
+ // Otherwise go through the disabled times.
804
+ else {
805
+
806
+ timesToEnable.map(function( unitToEnable ) {
807
+
808
+ var matchFound,
809
+ disabledUnit,
810
+ index,
811
+ isRangeMatched
812
+
813
+ // Go through the disabled items and try to find a match.
814
+ for ( index = 0; index < disabledItemsCount; index += 1 ) {
815
+
816
+ disabledUnit = disabledItems[index]
817
+
818
+ // When an exact match is found, remove it from the collection.
819
+ if ( clock.isTimeExact( disabledUnit, unitToEnable ) ) {
820
+ matchFound = disabledItems[index] = null
821
+ isRangeMatched = true
822
+ break
823
+ }
824
+
825
+ // When an overlapped match is found, add the “inverted” state to it.
826
+ else if ( clock.isTimeOverlap( disabledUnit, unitToEnable ) ) {
827
+ if ( $.isPlainObject( unitToEnable ) ) {
828
+ unitToEnable.inverted = true
829
+ matchFound = unitToEnable
830
+ }
831
+ else if ( $.isArray( unitToEnable ) ) {
832
+ matchFound = unitToEnable
833
+ if ( !matchFound[2] ) matchFound.push( 'inverted' )
834
+ }
835
+ else if ( _.isDate( unitToEnable ) ) {
836
+ matchFound = [ unitToEnable.getFullYear(), unitToEnable.getMonth(), unitToEnable.getDate(), 'inverted' ]
837
+ }
838
+ break
839
+ }
840
+ }
841
+
842
+ // If a match was found, remove a previous duplicate entry.
843
+ if ( matchFound ) for ( index = 0; index < disabledItemsCount; index += 1 ) {
844
+ if ( clock.isTimeExact( disabledItems[index], unitToEnable ) ) {
845
+ disabledItems[index] = null
846
+ break
847
+ }
848
+ }
849
+
850
+ // In the event that we’re dealing with an overlap of range times,
851
+ // make sure there are no “inverted” times because of it.
852
+ if ( isRangeMatched ) for ( index = 0; index < disabledItemsCount; index += 1 ) {
853
+ if ( clock.isTimeOverlap( disabledItems[index], unitToEnable ) ) {
854
+ disabledItems[index] = null
855
+ break
856
+ }
857
+ }
858
+
859
+ // If something is still matched, add it into the collection.
860
+ if ( matchFound ) {
861
+ disabledItems.push( matchFound )
862
+ }
863
+ })
864
+ }
865
+
866
+ // Return the updated collection.
867
+ return disabledItems.filter(function( val ) { return val != null })
868
+ } //TimePicker.prototype.activate
869
+
870
+
871
+ /**
872
+ * The division to use for the range intervals.
873
+ */
874
+ TimePicker.prototype.i = function( type, value/*, options*/ ) {
875
+ return _.isInteger( value ) && value > 0 ? value : this.item.interval
876
+ }
877
+
878
+
879
+ /**
880
+ * Create a string for the nodes in the picker.
881
+ */
882
+ TimePicker.prototype.nodes = function( isOpen ) {
883
+
884
+ var
885
+ clock = this,
886
+ settings = clock.settings,
887
+ selectedObject = clock.item.select,
888
+ highlightedObject = clock.item.highlight,
889
+ viewsetObject = clock.item.view,
890
+ disabledCollection = clock.item.disable
891
+
892
+ return _.node(
893
+ 'ul',
894
+ _.group({
895
+ min: clock.item.min.pick,
896
+ max: clock.item.max.pick,
897
+ i: clock.item.interval,
898
+ node: 'li',
899
+ item: function( loopedTime ) {
900
+ loopedTime = clock.create( loopedTime )
901
+ var timeMinutes = loopedTime.pick,
902
+ isSelected = selectedObject && selectedObject.pick == timeMinutes,
903
+ isHighlighted = highlightedObject && highlightedObject.pick == timeMinutes,
904
+ isDisabled = disabledCollection && clock.disabled( loopedTime )
905
+ return [
906
+ _.trigger( clock.formats.toString, clock, [ _.trigger( settings.formatLabel, clock, [ loopedTime ] ) || settings.format, loopedTime ] ),
907
+ (function( klasses ) {
908
+
909
+ if ( isSelected ) {
910
+ klasses.push( settings.klass.selected )
911
+ }
912
+
913
+ if ( isHighlighted ) {
914
+ klasses.push( settings.klass.highlighted )
915
+ }
916
+
917
+ if ( viewsetObject && viewsetObject.pick == timeMinutes ) {
918
+ klasses.push( settings.klass.viewset )
919
+ }
920
+
921
+ if ( isDisabled ) {
922
+ klasses.push( settings.klass.disabled )
923
+ }
924
+
925
+ return klasses.join( ' ' )
926
+ })( [ settings.klass.listItem ] ),
927
+ 'data-pick=' + loopedTime.pick + ' ' + _.ariaAttr({
928
+ role: 'option',
929
+ selected: isSelected && clock.$node.val() === _.trigger(
930
+ clock.formats.toString,
931
+ clock,
932
+ [ settings.format, loopedTime ]
933
+ ) ? true : null,
934
+ activedescendant: isHighlighted ? true : null,
935
+ disabled: isDisabled ? true : null
936
+ })
937
+ ]
938
+ }
939
+ }) +
940
+
941
+ // * For Firefox forms to submit, make sure to set the button’s `type` attribute as “button”.
942
+ _.node(
943
+ 'li',
944
+ _.node(
945
+ 'button',
946
+ settings.clear,
947
+ settings.klass.buttonClear,
948
+ 'type=button data-clear=1' + ( isOpen ? '' : ' disabled' ) + ' ' +
949
+ _.ariaAttr({ controls: clock.$node[0].id })
950
+ ),
951
+ '', _.ariaAttr({ role: 'presentation' })
952
+ ),
953
+ settings.klass.list,
954
+ _.ariaAttr({ role: 'listbox', controls: clock.$node[0].id })
955
+ )
956
+ } //TimePicker.prototype.nodes
957
+
958
+
959
+
960
+
961
+
962
+
963
+
964
+ /* ==========================================================================
965
+ Extend the picker to add the component with the defaults.
966
+ ========================================================================== */
967
+
968
+ TimePicker.defaults = (function( prefix ) {
969
+
970
+ return {
971
+
972
+ // Clear
973
+ clear: 'Clear',
974
+
975
+ // The format to show on the `input` element
976
+ format: 'h:i A',
977
+
978
+ // The interval between each time
979
+ interval: 30,
980
+
981
+ // Classes
982
+ klass: {
983
+
984
+ picker: prefix + ' ' + prefix + '--time',
985
+ holder: prefix + '__holder',
986
+
987
+ list: prefix + '__list',
988
+ listItem: prefix + '__list-item',
989
+
990
+ disabled: prefix + '__list-item--disabled',
991
+ selected: prefix + '__list-item--selected',
992
+ highlighted: prefix + '__list-item--highlighted',
993
+ viewset: prefix + '__list-item--viewset',
994
+ now: prefix + '__list-item--now',
995
+
996
+ buttonClear: prefix + '__button--clear'
997
+ }
998
+ }
999
+ })( Picker.klasses().picker )
1000
+
1001
+
1002
+
1003
+
1004
+
1005
+ /**
1006
+ * Extend the picker to add the time picker.
1007
+ */
1008
+ Picker.extend( 'pickatime', TimePicker )
1009
+
1010
+
1011
+ }));
1012
+
1013
+
1014
+