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,5 +0,0 @@
1
- /*!
2
- * Date picker for pickadate.js v3.5.3
3
- * http://amsul.github.io/pickadate.js/date.htm
4
- */
5
- !function(a){"function"==typeof define&&define.amd?define(["picker","jquery"],a):"object"==typeof exports?module.exports=a(require("./picker.js"),require("jquery")):a(Picker,jQuery)}(function(a,b){function c(a,b){var c=this,d=a.$node[0],e=d.value,f=a.$node.data("value"),g=f||e,h=f?b.formatSubmit:b.format,i=function(){return d.currentStyle?"rtl"==d.currentStyle.direction:"rtl"==getComputedStyle(a.$root[0]).direction};c.settings=b,c.$node=a.$node,c.queue={min:"measure create",max:"measure create",now:"now create",select:"parse create validate",highlight:"parse navigate create validate",view:"parse create validate viewset",disable:"deactivate",enable:"activate"},c.item={},c.item.clear=null,c.item.disable=(b.disable||[]).slice(0),c.item.enable=-function(a){return a[0]===!0?a.shift():-1}(c.item.disable),c.set("min",b.min).set("max",b.max).set("now"),g?c.set("select",g,{format:h}):c.set("select",null).set("highlight",c.item.now),c.key={40:7,38:-7,39:function(){return i()?-1:1},37:function(){return i()?1:-1},go:function(a){var b=c.item.highlight,d=new Date(b.year,b.month,b.date+a);c.set("highlight",[d.getFullYear(),d.getMonth(),d.getDate()],{interval:a}),this.render()}},a.on("render",function(){a.$root.find("."+b.klass.selectMonth).on("change",function(){var c=this.value;c&&(a.set("highlight",[a.get("view").year,c,a.get("highlight").date]),a.$root.find("."+b.klass.selectMonth).trigger("focus"))}),a.$root.find("."+b.klass.selectYear).on("change",function(){var c=this.value;c&&(a.set("highlight",[c,a.get("view").month,a.get("highlight").date]),a.$root.find("."+b.klass.selectYear).trigger("focus"))})},1).on("open",function(){var d="";c.disabled(c.get("now"))&&(d=":not(."+b.klass.buttonToday+")"),a.$root.find("button"+d+", select").attr("disabled",!1)},1).on("close",function(){a.$root.find("button, select").attr("disabled",!0)},1)}var d=7,e=6,f=a._;c.prototype.set=function(a,b,c){var d=this,e=d.item;return null===b?("clear"==a&&(a="select"),e[a]=b,d):(e["enable"==a?"disable":"flip"==a?"enable":a]=d.queue[a].split(" ").map(function(e){return b=d[e](a,b,c)}).pop(),"select"==a?d.set("highlight",e.select,c):"highlight"==a?d.set("view",e.highlight,c):a.match(/^(flip|min|max|disable|enable)$/)&&(e.select&&d.disabled(e.select)&&d.set("select",e.select,c),e.highlight&&d.disabled(e.highlight)&&d.set("highlight",e.highlight,c)),d)},c.prototype.get=function(a){return this.item[a]},c.prototype.create=function(a,c,d){var e,g=this;return c=void 0===c?a:c,c==-1/0||1/0==c?e=c:b.isPlainObject(c)&&f.isInteger(c.pick)?c=c.obj:b.isArray(c)?(c=new Date(c[0],c[1],c[2]),c=f.isDate(c)?c:g.create().obj):c=f.isInteger(c)||f.isDate(c)?g.normalize(new Date(c),d):g.now(a,c,d),{year:e||c.getFullYear(),month:e||c.getMonth(),date:e||c.getDate(),day:e||c.getDay(),obj:e||c,pick:e||c.getTime()}},c.prototype.createRange=function(a,c){var d=this,e=function(a){return a===!0||b.isArray(a)||f.isDate(a)?d.create(a):a};return f.isInteger(a)||(a=e(a)),f.isInteger(c)||(c=e(c)),f.isInteger(a)&&b.isPlainObject(c)?a=[c.year,c.month,c.date+a]:f.isInteger(c)&&b.isPlainObject(a)&&(c=[a.year,a.month,a.date+c]),{from:e(a),to:e(c)}},c.prototype.withinRange=function(a,b){return a=this.createRange(a.from,a.to),b.pick>=a.from.pick&&b.pick<=a.to.pick},c.prototype.overlapRanges=function(a,b){var c=this;return a=c.createRange(a.from,a.to),b=c.createRange(b.from,b.to),c.withinRange(a,b.from)||c.withinRange(a,b.to)||c.withinRange(b,a.from)||c.withinRange(b,a.to)},c.prototype.now=function(a,b,c){return b=new Date,c&&c.rel&&b.setDate(b.getDate()+c.rel),this.normalize(b,c)},c.prototype.navigate=function(a,c,d){var e,f,g,h,i=b.isArray(c),j=b.isPlainObject(c),k=this.item.view;if(i||j){for(j?(f=c.year,g=c.month,h=c.date):(f=+c[0],g=+c[1],h=+c[2]),d&&d.nav&&k&&k.month!==g&&(f=k.year,g=k.month),e=new Date(f,g+(d&&d.nav?d.nav:0),1),f=e.getFullYear(),g=e.getMonth();new Date(f,g,h).getMonth()!==g;)h-=1;c=[f,g,h]}return c},c.prototype.normalize=function(a){return a.setHours(0,0,0,0),a},c.prototype.measure=function(a,b){var c=this;return b?"string"==typeof b?b=c.parse(a,b):f.isInteger(b)&&(b=c.now(a,b,{rel:b})):b="min"==a?-1/0:1/0,b},c.prototype.viewset=function(a,b){return this.create([b.year,b.month,1])},c.prototype.validate=function(a,c,d){var e,g,h,i,j=this,k=c,l=d&&d.interval?d.interval:1,m=-1===j.item.enable,n=j.item.min,o=j.item.max,p=m&&j.item.disable.filter(function(a){if(b.isArray(a)){var d=j.create(a).pick;d<c.pick?e=!0:d>c.pick&&(g=!0)}return f.isInteger(a)}).length;if((!d||!d.nav)&&(!m&&j.disabled(c)||m&&j.disabled(c)&&(p||e||g)||!m&&(c.pick<=n.pick||c.pick>=o.pick)))for(m&&!p&&(!g&&l>0||!e&&0>l)&&(l*=-1);j.disabled(c)&&(Math.abs(l)>1&&(c.month<k.month||c.month>k.month)&&(c=k,l=l>0?1:-1),c.pick<=n.pick?(h=!0,l=1,c=j.create([n.year,n.month,n.date+(c.pick===n.pick?0:-1)])):c.pick>=o.pick&&(i=!0,l=-1,c=j.create([o.year,o.month,o.date+(c.pick===o.pick?0:1)])),!h||!i);)c=j.create([c.year,c.month,c.date+l]);return c},c.prototype.disabled=function(a){var c=this,d=c.item.disable.filter(function(d){return f.isInteger(d)?a.day===(c.settings.firstDay?d:d-1)%7:b.isArray(d)||f.isDate(d)?a.pick===c.create(d).pick:b.isPlainObject(d)?c.withinRange(d,a):void 0});return d=d.length&&!d.filter(function(a){return b.isArray(a)&&"inverted"==a[3]||b.isPlainObject(a)&&a.inverted}).length,-1===c.item.enable?!d:d||a.pick<c.item.min.pick||a.pick>c.item.max.pick},c.prototype.parse=function(a,b,c){var d=this,e={};return b&&"string"==typeof b?(c&&c.format||(c=c||{},c.format=d.settings.format),d.formats.toArray(c.format).map(function(a){var c=d.formats[a],g=c?f.trigger(c,d,[b,e]):a.replace(/^!/,"").length;c&&(e[a]=b.substr(0,g)),b=b.substr(g)}),[e.yyyy||e.yy,+(e.mm||e.m)-1,e.dd||e.d]):b},c.prototype.formats=function(){function a(a,b,c){var d=a.match(/\w+/)[0];return c.mm||c.m||(c.m=b.indexOf(d)+1),d.length}function b(a){return a.match(/\w+/)[0].length}return{d:function(a,b){return a?f.digits(a):b.date},dd:function(a,b){return a?2:f.lead(b.date)},ddd:function(a,c){return a?b(a):this.settings.weekdaysShort[c.day]},dddd:function(a,c){return a?b(a):this.settings.weekdaysFull[c.day]},m:function(a,b){return a?f.digits(a):b.month+1},mm:function(a,b){return a?2:f.lead(b.month+1)},mmm:function(b,c){var d=this.settings.monthsShort;return b?a(b,d,c):d[c.month]},mmmm:function(b,c){var d=this.settings.monthsFull;return b?a(b,d,c):d[c.month]},yy:function(a,b){return a?2:(""+b.year).slice(2)},yyyy:function(a,b){return a?4:b.year},toArray:function(a){return a.split(/(d{1,4}|m{1,4}|y{4}|yy|!.)/g)},toString:function(a,b){var c=this;return c.formats.toArray(a).map(function(a){return f.trigger(c.formats[a],c,[0,b])||a.replace(/^!/,"")}).join("")}}}(),c.prototype.isDateExact=function(a,c){var d=this;return f.isInteger(a)&&f.isInteger(c)||"boolean"==typeof a&&"boolean"==typeof c?a===c:(f.isDate(a)||b.isArray(a))&&(f.isDate(c)||b.isArray(c))?d.create(a).pick===d.create(c).pick:b.isPlainObject(a)&&b.isPlainObject(c)?d.isDateExact(a.from,c.from)&&d.isDateExact(a.to,c.to):!1},c.prototype.isDateOverlap=function(a,c){var d=this,e=d.settings.firstDay?1:0;return f.isInteger(a)&&(f.isDate(c)||b.isArray(c))?(a=a%7+e,a===d.create(c).day+1):f.isInteger(c)&&(f.isDate(a)||b.isArray(a))?(c=c%7+e,c===d.create(a).day+1):b.isPlainObject(a)&&b.isPlainObject(c)?d.overlapRanges(a,c):!1},c.prototype.flipEnable=function(a){var b=this.item;b.enable=a||(-1==b.enable?1:-1)},c.prototype.deactivate=function(a,c){var d=this,e=d.item.disable.slice(0);return"flip"==c?d.flipEnable():c===!1?(d.flipEnable(1),e=[]):c===!0?(d.flipEnable(-1),e=[]):c.map(function(a){for(var c,g=0;g<e.length;g+=1)if(d.isDateExact(a,e[g])){c=!0;break}c||(f.isInteger(a)||f.isDate(a)||b.isArray(a)||b.isPlainObject(a)&&a.from&&a.to)&&e.push(a)}),e},c.prototype.activate=function(a,c){var d=this,e=d.item.disable,g=e.length;return"flip"==c?d.flipEnable():c===!0?(d.flipEnable(1),e=[]):c===!1?(d.flipEnable(-1),e=[]):c.map(function(a){var c,h,i,j;for(i=0;g>i;i+=1){if(h=e[i],d.isDateExact(h,a)){c=e[i]=null,j=!0;break}if(d.isDateOverlap(h,a)){b.isPlainObject(a)?(a.inverted=!0,c=a):b.isArray(a)?(c=a,c[3]||c.push("inverted")):f.isDate(a)&&(c=[a.getFullYear(),a.getMonth(),a.getDate(),"inverted"]);break}}if(c)for(i=0;g>i;i+=1)if(d.isDateExact(e[i],a)){e[i]=null;break}if(j)for(i=0;g>i;i+=1)if(d.isDateOverlap(e[i],a)){e[i]=null;break}c&&e.push(c)}),e.filter(function(a){return null!=a})},c.prototype.nodes=function(a){var b=this,c=b.settings,g=b.item,h=g.now,i=g.select,j=g.highlight,k=g.view,l=g.disable,m=g.min,n=g.max,o=function(a,b){return c.firstDay&&(a.push(a.shift()),b.push(b.shift())),f.node("thead",f.node("tr",f.group({min:0,max:d-1,i:1,node:"th",item:function(d){return[a[d],c.klass.weekdays,'scope=col title="'+b[d]+'"']}})))}((c.showWeekdaysFull?c.weekdaysFull:c.weekdaysShort).slice(0),c.weekdaysFull.slice(0)),p=function(a){return f.node("div"," ",c.klass["nav"+(a?"Next":"Prev")]+(a&&k.year>=n.year&&k.month>=n.month||!a&&k.year<=m.year&&k.month<=m.month?" "+c.klass.navDisabled:""),"data-nav="+(a||-1)+" "+f.ariaAttr({role:"button",controls:b.$node[0].id+"_table"})+' title="'+(a?c.labelMonthNext:c.labelMonthPrev)+'"')},q=function(){var d=c.showMonthsShort?c.monthsShort:c.monthsFull;return c.selectMonths?f.node("select",f.group({min:0,max:11,i:1,node:"option",item:function(a){return[d[a],0,"value="+a+(k.month==a?" selected":"")+(k.year==m.year&&a<m.month||k.year==n.year&&a>n.month?" disabled":"")]}}),c.klass.selectMonth,(a?"":"disabled")+" "+f.ariaAttr({controls:b.$node[0].id+"_table"})+' title="'+c.labelMonthSelect+'"'):f.node("div",d[k.month],c.klass.month)},r=function(){var d=k.year,e=c.selectYears===!0?5:~~(c.selectYears/2);if(e){var g=m.year,h=n.year,i=d-e,j=d+e;if(g>i&&(j+=g-i,i=g),j>h){var l=i-g,o=j-h;i-=l>o?o:l,j=h}return f.node("select",f.group({min:i,max:j,i:1,node:"option",item:function(a){return[a,0,"value="+a+(d==a?" selected":"")]}}),c.klass.selectYear,(a?"":"disabled")+" "+f.ariaAttr({controls:b.$node[0].id+"_table"})+' title="'+c.labelYearSelect+'"')}return f.node("div",d,c.klass.year)};return f.node("div",(c.selectYears?r()+q():q()+r())+p()+p(1),c.klass.header)+f.node("table",o+f.node("tbody",f.group({min:0,max:e-1,i:1,node:"tr",item:function(a){var e=c.firstDay&&0===b.create([k.year,k.month,1]).day?-7:0;return[f.group({min:d*a-k.day+e+1,max:function(){return this.min+d-1},i:1,node:"td",item:function(a){a=b.create([k.year,k.month,a+(c.firstDay?1:0)]);var d=i&&i.pick==a.pick,e=j&&j.pick==a.pick,g=l&&b.disabled(a)||a.pick<m.pick||a.pick>n.pick;return[f.node("div",a.date,function(b){return b.push(k.month==a.month?c.klass.infocus:c.klass.outfocus),h.pick==a.pick&&b.push(c.klass.now),d&&b.push(c.klass.selected),e&&b.push(c.klass.highlighted),g&&b.push(c.klass.disabled),b.join(" ")}([c.klass.day]),"data-pick="+a.pick+" "+f.ariaAttr({role:"gridcell",selected:d&&b.$node.val()===f.trigger(b.formats.toString,b,[c.format,a])?!0:null,activedescendant:e?!0:null,disabled:g?!0:null})),"",f.ariaAttr({role:"presentation"})]}})]}})),c.klass.table,'id="'+b.$node[0].id+'_table" '+f.ariaAttr({role:"grid",controls:b.$node[0].id,readonly:!0}))+f.node("div",f.node("button",c.today,c.klass.buttonToday,"type=button data-pick="+h.pick+(a&&!b.disabled(h)?"":" disabled")+" "+f.ariaAttr({controls:b.$node[0].id}))+f.node("button",c.clear,c.klass.buttonClear,"type=button data-clear=1"+(a?"":" disabled")+" "+f.ariaAttr({controls:b.$node[0].id}))+f.node("button",c.close,c.klass.buttonClose,"type=button data-close=true "+(a?"":" disabled")+" "+f.ariaAttr({controls:b.$node[0].id})),c.klass.footer)},c.defaults=function(a){return{labelMonthNext:"Next month",labelMonthPrev:"Previous month",labelMonthSelect:"Select a month",labelYearSelect:"Select a year",monthsFull:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdaysFull:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],today:"Today",clear:"Clear",close:"Close",format:"d mmmm, yyyy",klass:{table:a+"table",header:a+"header",navPrev:a+"nav--prev",navNext:a+"nav--next",navDisabled:a+"nav--disabled",month:a+"month",year:a+"year",selectMonth:a+"select--month",selectYear:a+"select--year",weekdays:a+"weekday",day:a+"day",disabled:a+"day--disabled",selected:a+"day--selected",highlighted:a+"day--highlighted",now:a+"day--today",infocus:a+"day--infocus",outfocus:a+"day--outfocus",footer:a+"footer",buttonClear:a+"button--clear",buttonToday:a+"button--today",buttonClose:a+"button--close"}}}(a.klasses().picker+"__"),a.extend("pickadate",c)});
@@ -1,1078 +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
-
8
- (function ( factory ) {
9
-
10
- // AMD.
11
- if ( typeof define == 'function' && define.amd )
12
- define( 'picker', ['jquery'], factory )
13
-
14
- // Node.js/browserify.
15
- else if ( typeof exports == 'object' )
16
- module.exports = factory( require('jquery') )
17
-
18
- // Browser globals.
19
- else this.Picker = factory( jQuery )
20
-
21
- }(function( $ ) {
22
-
23
- var $window = $( window )
24
- var $document = $( document )
25
- var $html = $( document.documentElement )
26
-
27
-
28
- /**
29
- * The picker constructor that creates a blank picker.
30
- */
31
- function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {
32
-
33
- // If there’s no element, return the picker constructor.
34
- if ( !ELEMENT ) return PickerConstructor
35
-
36
-
37
- var
38
- IS_DEFAULT_THEME = false,
39
-
40
-
41
- // The state of the picker.
42
- STATE = {
43
- id: ELEMENT.id || 'P' + Math.abs( ~~(Math.random() * new Date()) )
44
- },
45
-
46
-
47
- // Merge the defaults and options passed.
48
- SETTINGS = COMPONENT ? $.extend( true, {}, COMPONENT.defaults, OPTIONS ) : OPTIONS || {},
49
-
50
-
51
- // Merge the default classes with the settings classes.
52
- CLASSES = $.extend( {}, PickerConstructor.klasses(), SETTINGS.klass ),
53
-
54
-
55
- // The element node wrapper into a jQuery object.
56
- $ELEMENT = $( ELEMENT ),
57
-
58
-
59
- // Pseudo picker constructor.
60
- PickerInstance = function() {
61
- return this.start()
62
- },
63
-
64
-
65
- // The picker prototype.
66
- P = PickerInstance.prototype = {
67
-
68
- constructor: PickerInstance,
69
-
70
- $node: $ELEMENT,
71
-
72
-
73
- /**
74
- * Initialize everything
75
- */
76
- start: function() {
77
-
78
- // If it’s already started, do nothing.
79
- if ( STATE && STATE.start ) return P
80
-
81
-
82
- // Update the picker states.
83
- STATE.methods = {}
84
- STATE.start = true
85
- STATE.open = false
86
- STATE.type = ELEMENT.type
87
-
88
-
89
- // Confirm focus state, convert into text input to remove UA stylings,
90
- // and set as readonly to prevent keyboard popup.
91
- ELEMENT.autofocus = ELEMENT == document.activeElement
92
- ELEMENT.readOnly = !SETTINGS.editable
93
- ELEMENT.id = ELEMENT.id || STATE.id
94
- if ( ELEMENT.type != 'text' ) {
95
- ELEMENT.type = 'text'
96
- }
97
-
98
-
99
- // Create a new picker component with the settings.
100
- P.component = new COMPONENT(P, SETTINGS)
101
-
102
-
103
- // Create the picker root with a holder and then prepare it.
104
- P.$root = $( PickerConstructor._.node('div', createWrappedComponent(), CLASSES.picker, 'id="' + ELEMENT.id + '_root"') )
105
- prepareElementRoot()
106
-
107
-
108
- // If there’s a format for the hidden input element, create the element.
109
- if ( SETTINGS.formatSubmit ) {
110
- prepareElementHidden()
111
- }
112
-
113
-
114
- // Prepare the input element.
115
- prepareElement()
116
-
117
-
118
- // Insert the root as specified in the settings.
119
- if ( SETTINGS.container ) $( SETTINGS.container ).append( P.$root )
120
- else $ELEMENT.after( P.$root )
121
-
122
-
123
- // Bind the default component and settings events.
124
- P.on({
125
- start: P.component.onStart,
126
- render: P.component.onRender,
127
- stop: P.component.onStop,
128
- open: P.component.onOpen,
129
- close: P.component.onClose,
130
- set: P.component.onSet
131
- }).on({
132
- start: SETTINGS.onStart,
133
- render: SETTINGS.onRender,
134
- stop: SETTINGS.onStop,
135
- open: SETTINGS.onOpen,
136
- close: SETTINGS.onClose,
137
- set: SETTINGS.onSet
138
- })
139
-
140
-
141
- // Once we’re all set, check the theme in use.
142
- IS_DEFAULT_THEME = isUsingDefaultTheme( P.$root.children()[ 0 ] )
143
-
144
-
145
- // If the element has autofocus, open the picker.
146
- if ( ELEMENT.autofocus ) {
147
- P.open()
148
- }
149
-
150
-
151
- // Trigger queued the “start” and “render” events.
152
- return P.trigger( 'start' ).trigger( 'render' )
153
- }, //start
154
-
155
-
156
- /**
157
- * Render a new picker
158
- */
159
- render: function( entireComponent ) {
160
-
161
- // Insert a new component holder in the root or box.
162
- if ( entireComponent ) P.$root.html( createWrappedComponent() )
163
- else P.$root.find( '.' + CLASSES.box ).html( P.component.nodes( STATE.open ) )
164
-
165
- // Trigger the queued “render” events.
166
- return P.trigger( 'render' )
167
- }, //render
168
-
169
-
170
- /**
171
- * Destroy everything
172
- */
173
- stop: function() {
174
-
175
- // If it’s already stopped, do nothing.
176
- if ( !STATE.start ) return P
177
-
178
- // Then close the picker.
179
- P.close()
180
-
181
- // Remove the hidden field.
182
- if ( P._hidden ) {
183
- P._hidden.parentNode.removeChild( P._hidden )
184
- }
185
-
186
- // Remove the root.
187
- P.$root.remove()
188
-
189
- // Remove the input class, remove the stored data, and unbind
190
- // the events (after a tick for IE - see `P.close`).
191
- $ELEMENT.removeClass( CLASSES.input ).removeData( NAME )
192
- setTimeout( function() {
193
- $ELEMENT.off( '.' + STATE.id )
194
- }, 0)
195
-
196
- // Restore the element state
197
- ELEMENT.type = STATE.type
198
- ELEMENT.readOnly = false
199
-
200
- // Trigger the queued “stop” events.
201
- P.trigger( 'stop' )
202
-
203
- // Reset the picker states.
204
- STATE.methods = {}
205
- STATE.start = false
206
-
207
- return P
208
- }, //stop
209
-
210
-
211
- /**
212
- * Open up the picker
213
- */
214
- open: function( dontGiveFocus ) {
215
-
216
- // If it’s already open, do nothing.
217
- if ( STATE.open ) return P
218
-
219
- // Add the “active” class.
220
- $ELEMENT.addClass( CLASSES.active )
221
- aria( ELEMENT, 'expanded', true )
222
-
223
- // * A Firefox bug, when `html` has `overflow:hidden`, results in
224
- // killing transitions :(. So add the “opened” state on the next tick.
225
- // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
226
- setTimeout( function() {
227
-
228
- // Add the “opened” class to the picker root.
229
- P.$root.addClass( CLASSES.opened )
230
- aria( P.$root[0], 'hidden', false )
231
-
232
- }, 0 )
233
-
234
- // If we have to give focus, bind the element and doc events.
235
- if ( dontGiveFocus !== false ) {
236
-
237
- // Set it as open.
238
- STATE.open = true
239
-
240
- // Prevent the page from scrolling.
241
- if ( IS_DEFAULT_THEME ) {
242
- $html.
243
- css( 'overflow', 'hidden' ).
244
- css( 'padding-right', '+=' + getScrollbarWidth() )
245
- }
246
-
247
- // Pass focus to the element’s jQuery object.
248
- $ELEMENT.trigger( 'focus' )
249
-
250
- // Bind the document events.
251
- $document.on( 'click.' + STATE.id + ' focusin.' + STATE.id, function( event ) {
252
-
253
- var target = event.target
254
-
255
- // If the target of the event is not the element, close the picker picker.
256
- // * Don’t worry about clicks or focusins on the root because those don’t bubble up.
257
- // Also, for Firefox, a click on an `option` element bubbles up directly
258
- // to the doc. So make sure the target wasn't the doc.
259
- // * In Firefox stopPropagation() doesn’t prevent right-click events from bubbling,
260
- // which causes the picker to unexpectedly close when right-clicking it. So make
261
- // sure the event wasn’t a right-click.
262
- if ( target != ELEMENT && target != document && event.which != 3 ) {
263
-
264
- // If the target was the holder that covers the screen,
265
- // keep the element focused to maintain tabindex.
266
- P.close( target === P.$root.children()[0] )
267
- }
268
-
269
- }).on( 'keydown.' + STATE.id, function( event ) {
270
-
271
- var
272
- // Get the keycode.
273
- keycode = event.keyCode,
274
-
275
- // Translate that to a selection change.
276
- keycodeToMove = P.component.key[ keycode ],
277
-
278
- // Grab the target.
279
- target = event.target
280
-
281
-
282
- // On escape, close the picker and give focus.
283
- if ( keycode == 27 ) {
284
- P.close( true )
285
- }
286
-
287
-
288
- // Check if there is a key movement or “enter” keypress on the element.
289
- else if ( target == ELEMENT && ( keycodeToMove || keycode == 13 ) ) {
290
-
291
- // Prevent the default action to stop page movement.
292
- event.preventDefault()
293
-
294
- // Trigger the key movement action.
295
- if ( keycodeToMove ) {
296
- PickerConstructor._.trigger( P.component.key.go, P, [ PickerConstructor._.trigger( keycodeToMove ) ] )
297
- }
298
-
299
- // On “enter”, if the highlighted item isn’t disabled, set the value and close.
300
- else if ( !P.$root.find( '.' + CLASSES.highlighted ).hasClass( CLASSES.disabled ) ) {
301
- P.set( 'select', P.component.item.highlight ).close()
302
- }
303
- }
304
-
305
-
306
- // If the target is within the root and “enter” is pressed,
307
- // prevent the default action and trigger a click on the target instead.
308
- else if ( $.contains( P.$root[0], target ) && keycode == 13 ) {
309
- event.preventDefault()
310
- target.click()
311
- }
312
- })
313
- }
314
-
315
- // Trigger the queued “open” events.
316
- return P.trigger( 'open' )
317
- }, //open
318
-
319
-
320
- /**
321
- * Close the picker
322
- */
323
- close: function( giveFocus ) {
324
-
325
- // If we need to give focus, do it before changing states.
326
- if ( giveFocus ) {
327
- // ....ah yes! It would’ve been incomplete without a crazy workaround for IE :|
328
- // The focus is triggered *after* the close has completed - causing it
329
- // to open again. So unbind and rebind the event at the next tick.
330
- $ELEMENT.off( 'focus.' + STATE.id ).trigger( 'focus' )
331
- setTimeout( function() {
332
- $ELEMENT.on( 'focus.' + STATE.id, focusToOpen )
333
- }, 0 )
334
- }
335
-
336
- // Remove the “active” class.
337
- $ELEMENT.removeClass( CLASSES.active )
338
- aria( ELEMENT, 'expanded', false )
339
-
340
- // * A Firefox bug, when `html` has `overflow:hidden`, results in
341
- // killing transitions :(. So remove the “opened” state on the next tick.
342
- // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
343
- setTimeout( function() {
344
-
345
- // Remove the “opened” and “focused” class from the picker root.
346
- P.$root.removeClass( CLASSES.opened + ' ' + CLASSES.focused )
347
- aria( P.$root[0], 'hidden', true )
348
-
349
- }, 0 )
350
-
351
- // If it’s already closed, do nothing more.
352
- if ( !STATE.open ) return P
353
-
354
- // Set it as closed.
355
- STATE.open = false
356
-
357
- // Allow the page to scroll.
358
- if ( IS_DEFAULT_THEME ) {
359
- $html.
360
- css( 'overflow', '' ).
361
- css( 'padding-right', '-=' + getScrollbarWidth() )
362
- }
363
-
364
- // Unbind the document events.
365
- $document.off( '.' + STATE.id )
366
-
367
- // Trigger the queued “close” events.
368
- return P.trigger( 'close' )
369
- }, //close
370
-
371
-
372
- /**
373
- * Clear the values
374
- */
375
- clear: function( options ) {
376
- return P.set( 'clear', null, options )
377
- }, //clear
378
-
379
-
380
- /**
381
- * Set something
382
- */
383
- set: function( thing, value, options ) {
384
-
385
- var thingItem, thingValue,
386
- thingIsObject = $.isPlainObject( thing ),
387
- thingObject = thingIsObject ? thing : {}
388
-
389
- // Make sure we have usable options.
390
- options = thingIsObject && $.isPlainObject( value ) ? value : options || {}
391
-
392
- if ( thing ) {
393
-
394
- // If the thing isn’t an object, make it one.
395
- if ( !thingIsObject ) {
396
- thingObject[ thing ] = value
397
- }
398
-
399
- // Go through the things of items to set.
400
- for ( thingItem in thingObject ) {
401
-
402
- // Grab the value of the thing.
403
- thingValue = thingObject[ thingItem ]
404
-
405
- // First, if the item exists and there’s a value, set it.
406
- if ( thingItem in P.component.item ) {
407
- if ( thingValue === undefined ) thingValue = null
408
- P.component.set( thingItem, thingValue, options )
409
- }
410
-
411
- // Then, check to update the element value and broadcast a change.
412
- if ( thingItem == 'select' || thingItem == 'clear' ) {
413
- $ELEMENT.
414
- val( thingItem == 'clear' ? '' : P.get( thingItem, SETTINGS.format ) ).
415
- trigger( 'change' )
416
- }
417
- }
418
-
419
- // Render a new picker.
420
- P.render()
421
- }
422
-
423
- // When the method isn’t muted, trigger queued “set” events and pass the `thingObject`.
424
- return options.muted ? P : P.trigger( 'set', thingObject )
425
- }, //set
426
-
427
-
428
- /**
429
- * Get something
430
- */
431
- get: function( thing, format ) {
432
-
433
- // Make sure there’s something to get.
434
- thing = thing || 'value'
435
-
436
- // If a picker state exists, return that.
437
- if ( STATE[ thing ] != null ) {
438
- return STATE[ thing ]
439
- }
440
-
441
- // Return the value, if that.
442
- if ( thing == 'value' ) {
443
- return ELEMENT.value
444
- }
445
-
446
- // Check if a component item exists, return that.
447
- if ( thing in P.component.item ) {
448
- if ( typeof format == 'string' ) {
449
- var thingValue = P.component.get( thing )
450
- return thingValue ?
451
- PickerConstructor._.trigger(
452
- P.component.formats.toString,
453
- P.component,
454
- [ format, thingValue ]
455
- ) : ''
456
- }
457
- return P.component.get( thing )
458
- }
459
- }, //get
460
-
461
-
462
-
463
- /**
464
- * Bind events on the things.
465
- */
466
- on: function( thing, method, internal ) {
467
-
468
- var thingName, thingMethod,
469
- thingIsObject = $.isPlainObject( thing ),
470
- thingObject = thingIsObject ? thing : {}
471
-
472
- if ( thing ) {
473
-
474
- // If the thing isn’t an object, make it one.
475
- if ( !thingIsObject ) {
476
- thingObject[ thing ] = method
477
- }
478
-
479
- // Go through the things to bind to.
480
- for ( thingName in thingObject ) {
481
-
482
- // Grab the method of the thing.
483
- thingMethod = thingObject[ thingName ]
484
-
485
- // If it was an internal binding, prefix it.
486
- if ( internal ) {
487
- thingName = '_' + thingName
488
- }
489
-
490
- // Make sure the thing methods collection exists.
491
- STATE.methods[ thingName ] = STATE.methods[ thingName ] || []
492
-
493
- // Add the method to the relative method collection.
494
- STATE.methods[ thingName ].push( thingMethod )
495
- }
496
- }
497
-
498
- return P
499
- }, //on
500
-
501
-
502
-
503
- /**
504
- * Unbind events on the things.
505
- */
506
- off: function() {
507
- var i, thingName,
508
- names = arguments;
509
- for ( i = 0, namesCount = names.length; i < namesCount; i += 1 ) {
510
- thingName = names[i]
511
- if ( thingName in STATE.methods ) {
512
- delete STATE.methods[thingName]
513
- }
514
- }
515
- return P
516
- },
517
-
518
-
519
- /**
520
- * Fire off method events.
521
- */
522
- trigger: function( name, data ) {
523
- var _trigger = function( name ) {
524
- var methodList = STATE.methods[ name ]
525
- if ( methodList ) {
526
- methodList.map( function( method ) {
527
- PickerConstructor._.trigger( method, P, [ data ] )
528
- })
529
- }
530
- }
531
- _trigger( '_' + name )
532
- _trigger( name )
533
- return P
534
- } //trigger
535
- } //PickerInstance.prototype
536
-
537
-
538
- /**
539
- * Wrap the picker holder components together.
540
- */
541
- function createWrappedComponent() {
542
-
543
- // Create a picker wrapper holder
544
- return PickerConstructor._.node( 'div',
545
-
546
- // Create a picker wrapper node
547
- PickerConstructor._.node( 'div',
548
-
549
- // Create a picker frame
550
- PickerConstructor._.node( 'div',
551
-
552
- // Create a picker box node
553
- PickerConstructor._.node( 'div',
554
-
555
- // Create the components nodes.
556
- P.component.nodes( STATE.open ),
557
-
558
- // The picker box class
559
- CLASSES.box
560
- ),
561
-
562
- // Picker wrap class
563
- CLASSES.wrap
564
- ),
565
-
566
- // Picker frame class
567
- CLASSES.frame
568
- ),
569
-
570
- // Picker holder class
571
- CLASSES.holder
572
- ) //endreturn
573
- } //createWrappedComponent
574
-
575
-
576
-
577
- /**
578
- * Prepare the input element with all bindings.
579
- */
580
- function prepareElement() {
581
-
582
- $ELEMENT.
583
-
584
- // Store the picker data by component name.
585
- data(NAME, P).
586
-
587
- // Add the “input” class name.
588
- addClass(CLASSES.input).
589
-
590
- // If there’s a `data-value`, update the value of the element.
591
- val( $ELEMENT.data('value') ?
592
- P.get('select', SETTINGS.format) :
593
- ELEMENT.value
594
- ).
595
-
596
- // On focus/click, open the picker and adjust the root “focused” state.
597
- on('focus.' + STATE.id + ' click.' + STATE.id, focusToOpen)
598
-
599
-
600
- // Only bind keydown events if the element isn’t editable.
601
- if ( !SETTINGS.editable ) {
602
-
603
- // Handle keyboard event based on the picker being opened or not.
604
- $ELEMENT.on('keydown.' + STATE.id, function(event) {
605
-
606
- var keycode = event.keyCode,
607
-
608
- // Check if one of the delete keys was pressed.
609
- isKeycodeDelete = /^(8|46)$/.test(keycode)
610
-
611
- // For some reason IE clears the input value on “escape”.
612
- if ( keycode == 27 ) {
613
- P.close()
614
- return false
615
- }
616
-
617
- // Check if `space` or `delete` was pressed or the picker is closed with a key movement.
618
- if ( keycode == 32 || isKeycodeDelete || !STATE.open && P.component.key[keycode] ) {
619
-
620
- // Prevent it from moving the page and bubbling to doc.
621
- event.preventDefault()
622
- event.stopPropagation()
623
-
624
- // If `delete` was pressed, clear the values and close the picker.
625
- // Otherwise open the picker.
626
- if ( isKeycodeDelete ) { P.clear().close() }
627
- else { P.open() }
628
- }
629
- })
630
- }
631
-
632
-
633
- // Update the aria attributes.
634
- aria(ELEMENT, {
635
- haspopup: true,
636
- expanded: false,
637
- readonly: false,
638
- owns: ELEMENT.id + '_root' + (P._hidden ? ' ' + P._hidden.id : '')
639
- })
640
- }
641
-
642
-
643
- /**
644
- * Prepare the root picker element with all bindings.
645
- */
646
- function prepareElementRoot() {
647
-
648
- P.$root.
649
-
650
- on({
651
-
652
- // When something within the root is focused, stop from bubbling
653
- // to the doc and remove the “focused” state from the root.
654
- focusin: function( event ) {
655
- P.$root.removeClass( CLASSES.focused )
656
- event.stopPropagation()
657
- },
658
-
659
- // When something within the root holder is clicked, stop it
660
- // from bubbling to the doc.
661
- 'mousedown click': function( event ) {
662
-
663
- var target = event.target
664
-
665
- // Make sure the target isn’t the root holder so it can bubble up.
666
- if ( target != P.$root.children()[ 0 ] ) {
667
-
668
- event.stopPropagation()
669
-
670
- // * For mousedown events, cancel the default action in order to
671
- // prevent cases where focus is shifted onto external elements
672
- // when using things like jQuery mobile or MagnificPopup (ref: #249 & #120).
673
- // Also, for Firefox, don’t prevent action on the `option` element.
674
- if ( event.type == 'mousedown' && !$( target ).is( ':input' ) && target.nodeName != 'OPTION' ) {
675
-
676
- event.preventDefault()
677
-
678
- // Re-focus onto the element so that users can click away
679
- // from elements focused within the picker.
680
- ELEMENT.focus()
681
- }
682
- }
683
- }
684
- }).
685
-
686
- // If there’s a click on an actionable element, carry out the actions.
687
- on( 'click', '[data-pick], [data-nav], [data-clear]', function() {
688
-
689
- var $target = $( this ),
690
- targetData = $target.data(),
691
- targetDisabled = $target.hasClass( CLASSES.navDisabled ) || $target.hasClass( CLASSES.disabled ),
692
-
693
- // * For IE, non-focusable elements can be active elements as well
694
- // (http://stackoverflow.com/a/2684561).
695
- activeElement = document.activeElement
696
- activeElement = activeElement && ( activeElement.type || activeElement.href ) && activeElement
697
-
698
- // If it’s disabled or nothing inside is actively focused, re-focus the element.
699
- if ( targetDisabled || activeElement && !$.contains( P.$root[0], activeElement ) ) {
700
- ELEMENT.focus()
701
- }
702
-
703
- // If something is superficially changed, update the `highlight` based on the `nav`.
704
- if ( targetData.nav && !targetDisabled ) {
705
- P.set( 'highlight', P.component.item.highlight, { nav: targetData.nav } )
706
- }
707
-
708
- // If something is picked, set `select` then close with focus.
709
- else if ( PickerConstructor._.isInteger( targetData.pick ) && !targetDisabled ) {
710
- P.set( 'select', targetData.pick ).close( true )
711
- }
712
-
713
- // If a “clear” button is pressed, empty the values and close with focus.
714
- else if ( targetData.clear ) {
715
- P.clear().close( true )
716
- }
717
- })
718
- .on('click', '[data-close]', function () {
719
- P.close(true);
720
- }) //P.$root
721
-
722
- aria( P.$root[0], 'hidden', true )
723
- }
724
-
725
-
726
- /**
727
- * Prepare the hidden input element along with all bindings.
728
- */
729
- function prepareElementHidden() {
730
-
731
- var name
732
-
733
- if ( SETTINGS.hiddenName === true ) {
734
- name = ELEMENT.name
735
- ELEMENT.name = ''
736
- }
737
- else {
738
- name = [
739
- typeof SETTINGS.hiddenPrefix == 'string' ? SETTINGS.hiddenPrefix : '',
740
- typeof SETTINGS.hiddenSuffix == 'string' ? SETTINGS.hiddenSuffix : '_submit'
741
- ]
742
- name = name[0] + ELEMENT.name + name[1]
743
- }
744
-
745
- P._hidden = $(
746
- '<input ' +
747
- 'type=hidden ' +
748
-
749
- // Create the name using the original input’s with a prefix and suffix.
750
- 'name="' + name + '"' +
751
-
752
- // Create the ID using the original input’s; only if it has one.
753
- (ELEMENT.id ? 'id="' + ELEMENT.id + '_hidden"' : '') +
754
-
755
- // If the element has a value, set the hidden value as well.
756
- (
757
- $ELEMENT.data('value') || ELEMENT.value ?
758
- ' value="' + P.get('select', SETTINGS.formatSubmit) + '"' :
759
- ''
760
- ) +
761
- '>'
762
- )[0]
763
-
764
- $ELEMENT.
765
-
766
- // If the value changes, update the hidden input with the correct format.
767
- on('change.' + STATE.id, function() {
768
- P._hidden.value = ELEMENT.value ?
769
- P.get('select', SETTINGS.formatSubmit) :
770
- ''
771
- }).
772
-
773
- // Insert the hidden input after the element.
774
- after(P._hidden)
775
- }
776
-
777
-
778
- // Separated for IE
779
- function focusToOpen( event ) {
780
-
781
- // Stop the event from propagating to the doc.
782
- event.stopPropagation()
783
-
784
- // If it’s a focus event, add the “focused” class to the root.
785
- if ( event.type == 'focus' ) {
786
- P.$root.addClass( CLASSES.focused )
787
- }
788
-
789
- // And then finally open the picker.
790
- P.open()
791
- }
792
-
793
-
794
- // Return a new picker instance.
795
- return new PickerInstance()
796
- } //PickerConstructor
797
-
798
-
799
-
800
- /**
801
- * The default classes and prefix to use for the HTML classes.
802
- */
803
- PickerConstructor.klasses = function( prefix ) {
804
- prefix = prefix || 'picker'
805
- return {
806
-
807
- picker: prefix,
808
- opened: prefix + '--opened',
809
- focused: prefix + '--focused',
810
-
811
- input: prefix + '__input',
812
- active: prefix + '__input--active',
813
-
814
- holder: prefix + '__holder',
815
-
816
- frame: prefix + '__frame',
817
- wrap: prefix + '__wrap',
818
-
819
- box: prefix + '__box'
820
- }
821
- } //PickerConstructor.klasses
822
-
823
-
824
-
825
- /**
826
- * Check if the default theme is being used.
827
- */
828
- function isUsingDefaultTheme( element ) {
829
-
830
- var theme,
831
- prop = 'position'
832
-
833
- // For IE.
834
- if ( element.currentStyle ) {
835
- theme = element.currentStyle[prop]
836
- }
837
-
838
- // For normal browsers.
839
- else if ( window.getComputedStyle ) {
840
- theme = getComputedStyle( element )[prop]
841
- }
842
-
843
- return theme == 'fixed'
844
- }
845
-
846
-
847
-
848
- /**
849
- * Get the width of the browser’s scrollbar.
850
- * Taken from: https://github.com/VodkaBears/Remodal/blob/master/src/jquery.remodal.js
851
- */
852
- function getScrollbarWidth() {
853
-
854
- if ( $html.height() <= $window.height() ) {
855
- return 0
856
- }
857
-
858
- var $outer = $( '<div style="visibility:hidden;width:100px" />' ).
859
- appendTo( 'body' )
860
-
861
- // Get the width without scrollbars.
862
- var widthWithoutScroll = $outer[0].offsetWidth
863
-
864
- // Force adding scrollbars.
865
- $outer.css( 'overflow', 'scroll' )
866
-
867
- // Add the inner div.
868
- var $inner = $( '<div style="width:100%" />' ).appendTo( $outer )
869
-
870
- // Get the width with scrollbars.
871
- var widthWithScroll = $inner[0].offsetWidth
872
-
873
- // Remove the divs.
874
- $outer.remove()
875
-
876
- // Return the difference between the widths.
877
- return widthWithoutScroll - widthWithScroll
878
- }
879
-
880
-
881
-
882
- /**
883
- * PickerConstructor helper methods.
884
- */
885
- PickerConstructor._ = {
886
-
887
- /**
888
- * Create a group of nodes. Expects:
889
- * `
890
- {
891
- min: {Integer},
892
- max: {Integer},
893
- i: {Integer},
894
- node: {String},
895
- item: {Function}
896
- }
897
- * `
898
- */
899
- group: function( groupObject ) {
900
-
901
- var
902
- // Scope for the looped object
903
- loopObjectScope,
904
-
905
- // Create the nodes list
906
- nodesList = '',
907
-
908
- // The counter starts from the `min`
909
- counter = PickerConstructor._.trigger( groupObject.min, groupObject )
910
-
911
-
912
- // Loop from the `min` to `max`, incrementing by `i`
913
- for ( ; counter <= PickerConstructor._.trigger( groupObject.max, groupObject, [ counter ] ); counter += groupObject.i ) {
914
-
915
- // Trigger the `item` function within scope of the object
916
- loopObjectScope = PickerConstructor._.trigger( groupObject.item, groupObject, [ counter ] )
917
-
918
- // Splice the subgroup and create nodes out of the sub nodes
919
- nodesList += PickerConstructor._.node(
920
- groupObject.node,
921
- loopObjectScope[ 0 ], // the node
922
- loopObjectScope[ 1 ], // the classes
923
- loopObjectScope[ 2 ] // the attributes
924
- )
925
- }
926
-
927
- // Return the list of nodes
928
- return nodesList
929
- }, //group
930
-
931
-
932
- /**
933
- * Create a dom node string
934
- */
935
- node: function( wrapper, item, klass, attribute ) {
936
-
937
- // If the item is false-y, just return an empty string
938
- if ( !item ) return ''
939
-
940
- // If the item is an array, do a join
941
- item = $.isArray( item ) ? item.join( '' ) : item
942
-
943
- // Check for the class
944
- klass = klass ? ' class="' + klass + '"' : ''
945
-
946
- // Check for any attributes
947
- attribute = attribute ? ' ' + attribute : ''
948
-
949
- // Return the wrapped item
950
- return '<' + wrapper + klass + attribute + '>' + item + '</' + wrapper + '>'
951
- }, //node
952
-
953
-
954
- /**
955
- * Lead numbers below 10 with a zero.
956
- */
957
- lead: function( number ) {
958
- return ( number < 10 ? '0': '' ) + number
959
- },
960
-
961
-
962
- /**
963
- * Trigger a function otherwise return the value.
964
- */
965
- trigger: function( callback, scope, args ) {
966
- return typeof callback == 'function' ? callback.apply( scope, args || [] ) : callback
967
- },
968
-
969
-
970
- /**
971
- * If the second character is a digit, length is 2 otherwise 1.
972
- */
973
- digits: function( string ) {
974
- return ( /\d/ ).test( string[ 1 ] ) ? 2 : 1
975
- },
976
-
977
-
978
- /**
979
- * Tell if something is a date object.
980
- */
981
- isDate: function( value ) {
982
- return {}.toString.call( value ).indexOf( 'Date' ) > -1 && this.isInteger( value.getDate() )
983
- },
984
-
985
-
986
- /**
987
- * Tell if something is an integer.
988
- */
989
- isInteger: function( value ) {
990
- return {}.toString.call( value ).indexOf( 'Number' ) > -1 && value % 1 === 0
991
- },
992
-
993
-
994
- /**
995
- * Create ARIA attribute strings.
996
- */
997
- ariaAttr: ariaAttr
998
- } //PickerConstructor._
999
-
1000
-
1001
-
1002
- /**
1003
- * Extend the picker with a component and defaults.
1004
- */
1005
- PickerConstructor.extend = function( name, Component ) {
1006
-
1007
- // Extend jQuery.
1008
- $.fn[ name ] = function( options, action ) {
1009
-
1010
- // Grab the component data.
1011
- var componentData = this.data( name )
1012
-
1013
- // If the picker is requested, return the data object.
1014
- if ( options == 'picker' ) {
1015
- return componentData
1016
- }
1017
-
1018
- // If the component data exists and `options` is a string, carry out the action.
1019
- if ( componentData && typeof options == 'string' ) {
1020
- return PickerConstructor._.trigger( componentData[ options ], componentData, [ action ] )
1021
- }
1022
-
1023
- // Otherwise go through each matched element and if the component
1024
- // doesn’t exist, create a new picker using `this` element
1025
- // and merging the defaults and options with a deep copy.
1026
- return this.each( function() {
1027
- var $this = $( this )
1028
- if ( !$this.data( name ) ) {
1029
- new PickerConstructor( this, name, Component, options )
1030
- }
1031
- })
1032
- }
1033
-
1034
- // Set the defaults.
1035
- $.fn[ name ].defaults = Component.defaults
1036
- } //PickerConstructor.extend
1037
-
1038
-
1039
-
1040
- function aria(element, attribute, value) {
1041
- if ( $.isPlainObject(attribute) ) {
1042
- for ( var key in attribute ) {
1043
- ariaSet(element, key, attribute[key])
1044
- }
1045
- }
1046
- else {
1047
- ariaSet(element, attribute, value)
1048
- }
1049
- }
1050
- function ariaSet(element, attribute, value) {
1051
- element.setAttribute(
1052
- (attribute == 'role' ? '' : 'aria-') + attribute,
1053
- value
1054
- )
1055
- }
1056
- function ariaAttr(attribute, data) {
1057
- if ( !$.isPlainObject(attribute) ) {
1058
- attribute = { attribute: data }
1059
- }
1060
- data = ''
1061
- for ( var key in attribute ) {
1062
- var attr = (key == 'role' ? '' : 'aria-') + key,
1063
- attrVal = attribute[key]
1064
- data += attrVal == null ? '' : attr + '="' + attribute[key] + '"'
1065
- }
1066
- return data
1067
- }
1068
-
1069
-
1070
-
1071
- // Expose the picker constructor.
1072
- return PickerConstructor
1073
-
1074
-
1075
- }));
1076
-
1077
-
1078
-