bitsnote-assets 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/daterangepicker/daterangepicker.js +1113 -0
  3. data/app/assets/stylesheets/daterangepicker/daterangepicker.css +284 -0
  4. data/lib/bitsnote-assets.rb +1 -24
  5. data/lib/bitsnote-assets/version.rb +1 -1
  6. metadata +4 -22
  7. data/app/assets/javascripts/pickadate/picker.date.js +0 -1349
  8. data/app/assets/javascripts/pickadate/picker.date.min.js +0 -5
  9. data/app/assets/javascripts/pickadate/picker.js +0 -1078
  10. data/app/assets/javascripts/pickadate/picker.min.js +0 -7
  11. data/app/assets/javascripts/pickadate/picker.time.js +0 -1014
  12. data/app/assets/javascripts/pickadate/picker.time.min.js +0 -5
  13. data/app/assets/stylesheets/pickadate/classic.css +0 -109
  14. data/app/assets/stylesheets/pickadate/classic.date.css +0 -301
  15. data/app/assets/stylesheets/pickadate/classic.date.min.css +0 -1
  16. data/app/assets/stylesheets/pickadate/classic.min.css +0 -4
  17. data/app/assets/stylesheets/pickadate/classic.time.css +0 -131
  18. data/app/assets/stylesheets/pickadate/classic.time.min.css +0 -1
  19. data/app/assets/stylesheets/pickadate/default.css +0 -175
  20. data/app/assets/stylesheets/pickadate/default.date.css +0 -301
  21. data/app/assets/stylesheets/pickadate/default.date.min.css +0 -1
  22. data/app/assets/stylesheets/pickadate/default.min.css +0 -4
  23. data/app/assets/stylesheets/pickadate/default.time.css +0 -125
  24. data/app/assets/stylesheets/pickadate/default.time.min.css +0 -1
  25. data/app/assets/stylesheets/pickadate/rtl.css +0 -29
  26. data/app/assets/stylesheets/pickadate/rtl.min.css +0 -3
@@ -1,7 +0,0 @@
1
- /*!
2
- * pickadate.js v3.5.3, 2014/07/12
3
- * By Amsul, http://amsul.ca
4
- * Hosted on http://amsul.github.io/pickadate.js
5
- * Licensed under MIT
6
- */
7
- !function(a){"function"==typeof define&&define.amd?define("picker",["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):this.Picker=a(jQuery)}(function(a){function b(f,g,h,k){function l(){return b._.node("div",b._.node("div",b._.node("div",b._.node("div",w.component.nodes(r.open),t.box),t.wrap),t.frame),t.holder)}function m(){u.data(g,w).addClass(t.input).val(u.data("value")?w.get("select",s.format):f.value).on("focus."+r.id+" click."+r.id,p),s.editable||u.on("keydown."+r.id,function(a){var b=a.keyCode,c=/^(8|46)$/.test(b);return 27==b?(w.close(),!1):void((32==b||c||!r.open&&w.component.key[b])&&(a.preventDefault(),a.stopPropagation(),c?w.clear().close():w.open()))}),e(f,{haspopup:!0,expanded:!1,readonly:!1,owns:f.id+"_root"+(w._hidden?" "+w._hidden.id:"")})}function n(){w.$root.on({focusin:function(a){w.$root.removeClass(t.focused),a.stopPropagation()},"mousedown click":function(b){var c=b.target;c!=w.$root.children()[0]&&(b.stopPropagation(),"mousedown"!=b.type||a(c).is(":input")||"OPTION"==c.nodeName||(b.preventDefault(),f.focus()))}}).on("click","[data-pick], [data-nav], [data-clear]",function(){var c=a(this),d=c.data(),e=c.hasClass(t.navDisabled)||c.hasClass(t.disabled),g=document.activeElement;g=g&&(g.type||g.href)&&g,(e||g&&!a.contains(w.$root[0],g))&&f.focus(),d.nav&&!e?w.set("highlight",w.component.item.highlight,{nav:d.nav}):b._.isInteger(d.pick)&&!e?w.set("select",d.pick).close(!0):d.clear&&w.clear().close(!0)}).on("click","[data-close]",function(){w.close(!0)}),e(w.$root[0],"hidden",!0)}function o(){var b;s.hiddenName===!0?(b=f.name,f.name=""):(b=["string"==typeof s.hiddenPrefix?s.hiddenPrefix:"","string"==typeof s.hiddenSuffix?s.hiddenSuffix:"_submit"],b=b[0]+f.name+b[1]),w._hidden=a('<input type=hidden name="'+b+'"'+(f.id?'id="'+f.id+'_hidden"':"")+(u.data("value")||f.value?' value="'+w.get("select",s.formatSubmit)+'"':"")+">")[0],u.on("change."+r.id,function(){w._hidden.value=f.value?w.get("select",s.formatSubmit):""}).after(w._hidden)}function p(a){a.stopPropagation(),"focus"==a.type&&w.$root.addClass(t.focused),w.open()}if(!f)return b;var q=!1,r={id:f.id||"P"+Math.abs(~~(Math.random()*new Date))},s=h?a.extend(!0,{},h.defaults,k):k||{},t=a.extend({},b.klasses(),s.klass),u=a(f),v=function(){return this.start()},w=v.prototype={constructor:v,$node:u,start:function(){return r&&r.start?w:(r.methods={},r.start=!0,r.open=!1,r.type=f.type,f.autofocus=f==document.activeElement,f.readOnly=!s.editable,f.id=f.id||r.id,"text"!=f.type&&(f.type="text"),w.component=new h(w,s),w.$root=a(b._.node("div",l(),t.picker,'id="'+f.id+'_root"')),n(),s.formatSubmit&&o(),m(),s.container?a(s.container).append(w.$root):u.after(w.$root),w.on({start:w.component.onStart,render:w.component.onRender,stop:w.component.onStop,open:w.component.onOpen,close:w.component.onClose,set:w.component.onSet}).on({start:s.onStart,render:s.onRender,stop:s.onStop,open:s.onOpen,close:s.onClose,set:s.onSet}),q=c(w.$root.children()[0]),f.autofocus&&w.open(),w.trigger("start").trigger("render"))},render:function(a){return a?w.$root.html(l()):w.$root.find("."+t.box).html(w.component.nodes(r.open)),w.trigger("render")},stop:function(){return r.start?(w.close(),w._hidden&&w._hidden.parentNode.removeChild(w._hidden),w.$root.remove(),u.removeClass(t.input).removeData(g),setTimeout(function(){u.off("."+r.id)},0),f.type=r.type,f.readOnly=!1,w.trigger("stop"),r.methods={},r.start=!1,w):w},open:function(c){return r.open?w:(u.addClass(t.active),e(f,"expanded",!0),setTimeout(function(){w.$root.addClass(t.opened),e(w.$root[0],"hidden",!1)},0),c!==!1&&(r.open=!0,q&&j.css("overflow","hidden").css("padding-right","+="+d()),u.trigger("focus"),i.on("click."+r.id+" focusin."+r.id,function(a){var b=a.target;b!=f&&b!=document&&3!=a.which&&w.close(b===w.$root.children()[0])}).on("keydown."+r.id,function(c){var d=c.keyCode,e=w.component.key[d],g=c.target;27==d?w.close(!0):g!=f||!e&&13!=d?a.contains(w.$root[0],g)&&13==d&&(c.preventDefault(),g.click()):(c.preventDefault(),e?b._.trigger(w.component.key.go,w,[b._.trigger(e)]):w.$root.find("."+t.highlighted).hasClass(t.disabled)||w.set("select",w.component.item.highlight).close())})),w.trigger("open"))},close:function(a){return a&&(u.off("focus."+r.id).trigger("focus"),setTimeout(function(){u.on("focus."+r.id,p)},0)),u.removeClass(t.active),e(f,"expanded",!1),setTimeout(function(){w.$root.removeClass(t.opened+" "+t.focused),e(w.$root[0],"hidden",!0)},0),r.open?(r.open=!1,q&&j.css("overflow","").css("padding-right","-="+d()),i.off("."+r.id),w.trigger("close")):w},clear:function(a){return w.set("clear",null,a)},set:function(b,c,d){var e,f,g=a.isPlainObject(b),h=g?b:{};if(d=g&&a.isPlainObject(c)?c:d||{},b){g||(h[b]=c);for(e in h)f=h[e],e in w.component.item&&(void 0===f&&(f=null),w.component.set(e,f,d)),("select"==e||"clear"==e)&&u.val("clear"==e?"":w.get(e,s.format)).trigger("change");w.render()}return d.muted?w:w.trigger("set",h)},get:function(a,c){if(a=a||"value",null!=r[a])return r[a];if("value"==a)return f.value;if(a in w.component.item){if("string"==typeof c){var d=w.component.get(a);return d?b._.trigger(w.component.formats.toString,w.component,[c,d]):""}return w.component.get(a)}},on:function(b,c,d){var e,f,g=a.isPlainObject(b),h=g?b:{};if(b){g||(h[b]=c);for(e in h)f=h[e],d&&(e="_"+e),r.methods[e]=r.methods[e]||[],r.methods[e].push(f)}return w},off:function(){var a,b,c=arguments;for(a=0,namesCount=c.length;namesCount>a;a+=1)b=c[a],b in r.methods&&delete r.methods[b];return w},trigger:function(a,c){var d=function(a){var d=r.methods[a];d&&d.map(function(a){b._.trigger(a,w,[c])})};return d("_"+a),d(a),w}};return new v}function c(a){var b,c="position";return a.currentStyle?b=a.currentStyle[c]:window.getComputedStyle&&(b=getComputedStyle(a)[c]),"fixed"==b}function d(){if(j.height()<=h.height())return 0;var b=a('<div style="visibility:hidden;width:100px" />').appendTo("body"),c=b[0].offsetWidth;b.css("overflow","scroll");var d=a('<div style="width:100%" />').appendTo(b),e=d[0].offsetWidth;return b.remove(),c-e}function e(b,c,d){if(a.isPlainObject(c))for(var e in c)f(b,e,c[e]);else f(b,c,d)}function f(a,b,c){a.setAttribute(("role"==b?"":"aria-")+b,c)}function g(b,c){a.isPlainObject(b)||(b={attribute:c}),c="";for(var d in b){var e=("role"==d?"":"aria-")+d,f=b[d];c+=null==f?"":e+'="'+b[d]+'"'}return c}var h=a(window),i=a(document),j=a(document.documentElement);return b.klasses=function(a){return a=a||"picker",{picker:a,opened:a+"--opened",focused:a+"--focused",input:a+"__input",active:a+"__input--active",holder:a+"__holder",frame:a+"__frame",wrap:a+"__wrap",box:a+"__box"}},b._={group:function(a){for(var c,d="",e=b._.trigger(a.min,a);e<=b._.trigger(a.max,a,[e]);e+=a.i)c=b._.trigger(a.item,a,[e]),d+=b._.node(a.node,c[0],c[1],c[2]);return d},node:function(b,c,d,e){return c?(c=a.isArray(c)?c.join(""):c,d=d?' class="'+d+'"':"",e=e?" "+e:"","<"+b+d+e+">"+c+"</"+b+">"):""},lead:function(a){return(10>a?"0":"")+a},trigger:function(a,b,c){return"function"==typeof a?a.apply(b,c||[]):a},digits:function(a){return/\d/.test(a[1])?2:1},isDate:function(a){return{}.toString.call(a).indexOf("Date")>-1&&this.isInteger(a.getDate())},isInteger:function(a){return{}.toString.call(a).indexOf("Number")>-1&&a%1===0},ariaAttr:g},b.extend=function(c,d){a.fn[c]=function(e,f){var g=this.data(c);return"picker"==e?g:g&&"string"==typeof e?b._.trigger(g[e],g,[f]):this.each(function(){var f=a(this);f.data(c)||new b(this,c,d,e)})},a.fn[c].defaults=d.defaults},b});
@@ -1,1014 +0,0 @@
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
-