squab 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE.md +13 -0
- data/README.md +4 -0
- data/bin/squab +4 -0
- data/defaults.yaml +5 -0
- data/lib/squab.rb +2 -0
- data/lib/squab/db.rb +37 -0
- data/lib/squab/events.rb +301 -0
- data/lib/squab/web.rb +231 -0
- data/public/api.html +66 -0
- data/public/css/anytime.css +777 -0
- data/public/css/bootstrap-responsive.css +1058 -0
- data/public/css/bootstrap-responsive.min.css +9 -0
- data/public/css/bootstrap.css +5774 -0
- data/public/css/bootstrap.min.css +9 -0
- data/public/css/docs.css +1001 -0
- data/public/css/normalize.css +406 -0
- data/public/css/pickadate/default.css +240 -0
- data/public/css/pickadate/default.date.css +332 -0
- data/public/css/prettify.css +30 -0
- data/public/css/squab.css +307 -0
- data/public/events.html +85 -0
- data/public/img/glyphicons-halflings-white.png +0 -0
- data/public/img/glyphicons-halflings.png +0 -0
- data/public/js/collection/events.js +74 -0
- data/public/js/lib/backbone-min.js +4 -0
- data/public/js/lib/datejs/core.js +48 -0
- data/public/js/lib/datejs/date-en-US.js +145 -0
- data/public/js/lib/jquery-latest.js +9440 -0
- data/public/js/lib/lodash.min.js +48 -0
- data/public/js/lib/pickadate/legacy.js +140 -0
- data/public/js/lib/pickadate/picker.date.js +957 -0
- data/public/js/lib/pickadate/picker.js +791 -0
- data/public/js/lib/typeahead.min.js +7 -0
- data/public/js/model/event.js +38 -0
- data/public/js/router.js +38 -0
- data/public/js/squab.js +6 -0
- data/public/js/view/day_view.js +22 -0
- data/public/js/view/event_view.js +14 -0
- data/public/js/view/events_view.js +46 -0
- data/public/js/view/search_view.js +130 -0
- metadata +220 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Lo-Dash 1.3.1 (Custom Build) lodash.com/license
|
4
|
+
* Build: `lodash modern -o ./dist/lodash.js`
|
5
|
+
* Underscore.js 1.4.4 underscorejs.org/LICENSE
|
6
|
+
*/
|
7
|
+
;!function(n){function t(n,t,e){e=(e||0)-1;for(var r=n.length;++e<r;)if(n[e]===t)return e;return-1}function e(n,e){var r=typeof e;if(n=n.k,"boolean"==r||e==h)return n[e];"number"!=r&&"string"!=r&&(r="object");var u="number"==r?e:j+e;return n=n[r]||(n[r]={}),"object"==r?n[u]&&-1<t(n[u],e)?0:-1:n[u]?0:-1}function r(n){var t=this.k,e=typeof n;if("boolean"==e||n==h)t[n]=y;else{"number"!=e&&"string"!=e&&(e="object");var r="number"==e?n:j+n,u=t[e]||(t[e]={});"object"==e?(u[r]||(u[r]=[])).push(n)==this.b.length&&(t[e]=b):u[r]=y
|
8
|
+
}}function u(n){return n.charCodeAt(0)}function a(n,t){var e=n.m,r=t.m;if(n=n.l,t=t.l,n!==t){if(n>t||typeof n=="undefined")return 1;if(n<t||typeof t=="undefined")return-1}return e<r?-1:1}function o(n){var t=-1,e=n.length,u=l();u["false"]=u["null"]=u["true"]=u.undefined=b;var a=l();for(a.b=n,a.k=u,a.push=r;++t<e;)a.push(n[t]);return u.object===false?(p(a),h):a}function i(n){return"\\"+Q[n]}function f(){return m.pop()||[]}function l(){return d.pop()||{b:h,k:h,l:h,"false":b,m:0,leading:b,maxWait:0,"null":b,number:h,object:h,push:h,string:h,trailing:b,"true":b,undefined:b,n:h}
|
9
|
+
}function c(n){n.length=0,m.length<C&&m.push(n)}function p(n){var t=n.k;t&&p(t),n.b=n.k=n.l=n.object=n.number=n.string=n.n=h,d.length<C&&d.push(n)}function s(n,t,e){t||(t=0),typeof e=="undefined"&&(e=n?n.length:0);var r=-1;e=e-t||0;for(var u=Array(0>e?0:e);++r<e;)u[r]=n[t+r];return u}function v(r){function m(n){if(!n||ve.call(n)!=V)return b;var t=n.valueOf,e=typeof t=="function"&&(e=fe(t))&&fe(e);return e?n==e||fe(n)==e:it(n)}function d(n,t,e){if(!n||!L[typeof n])return n;t=t&&typeof e=="undefined"?t:tt.createCallback(t,e);
|
10
|
+
for(var r=-1,u=L[typeof n]&&Se(n),a=u?u.length:0;++r<a&&(e=u[r],!(t(n[e],e,n)===false)););return n}function C(n,t,e){var r;if(!n||!L[typeof n])return n;t=t&&typeof e=="undefined"?t:tt.createCallback(t,e);for(r in n)if(t(n[r],r,n)===false)break;return n}function Q(n,t,e){var r,u=n,a=u;if(!u)return a;for(var o=arguments,i=0,f=typeof e=="number"?2:o.length;++i<f;)if((u=o[i])&&L[typeof u])for(var l=-1,c=L[typeof u]&&Se(u),p=c?c.length:0;++l<p;)r=c[l],"undefined"==typeof a[r]&&(a[r]=u[r]);return a}function X(n,t,e){var r,u=n,a=u;
|
11
|
+
if(!u)return a;var o=arguments,i=0,f=typeof e=="number"?2:o.length;if(3<f&&"function"==typeof o[f-2])var l=tt.createCallback(o[--f-1],o[f--],2);else 2<f&&"function"==typeof o[f-1]&&(l=o[--f]);for(;++i<f;)if((u=o[i])&&L[typeof u])for(var c=-1,p=L[typeof u]&&Se(u),s=p?p.length:0;++c<s;)r=p[c],a[r]=l?l(a[r],u[r]):u[r];return a}function Z(n){var t,e=[];if(!n||!L[typeof n])return e;for(t in n)le.call(n,t)&&e.push(t);return e}function tt(n){return n&&typeof n=="object"&&!Ee(n)&&le.call(n,"__wrapped__")?n:new et(n)
|
12
|
+
}function et(n){this.__wrapped__=n}function rt(n,t,e,r){function u(){var r=arguments,l=o?this:t;return a||(n=t[i]),e.length&&(r=r.length?(r=Ce.call(r),f?r.concat(e):e.concat(r)):e),this instanceof u?(l=gt(n.prototype)?ye(n.prototype):{},r=n.apply(l,r),gt(r)?r:l):n.apply(l,r)}var a=vt(n),o=!e,i=t;if(o){var f=r;e=t}else if(!a){if(!r)throw new Yt;t=n}return u}function ut(n){return Ie[n]}function at(){var n=(n=tt.indexOf)===$t?t:n;return n}function ot(n){return function(t,e,r,u){return typeof e!="boolean"&&e!=h&&(u=r,r=u&&u[e]===t?g:e,e=b),r!=h&&(r=tt.createCallback(r,u)),n(t,e,r,u)
|
13
|
+
}}function it(n){var t,e;return n&&ve.call(n)==V&&(t=n.constructor,!vt(t)||t instanceof t)?(C(n,function(n,t){e=t}),e===g||le.call(n,e)):b}function ft(n){return Ae[n]}function lt(n,t,e,r,u,a){var o=n;if(typeof t!="boolean"&&t!=h&&(r=e,e=t,t=b),typeof e=="function"){if(e=typeof r=="undefined"?e:tt.createCallback(e,r,1),o=e(o),typeof o!="undefined")return o;o=n}if(r=gt(o)){var i=ve.call(o);if(!J[i])return o;var l=Ee(o)}if(!r||!t)return r?l?s(o):X({},o):o;switch(r=xe[i],i){case P:case K:return new r(+o);
|
14
|
+
case U:case H:return new r(o);case G:return r(o.source,A.exec(o))}i=!u,u||(u=f()),a||(a=f());for(var p=u.length;p--;)if(u[p]==n)return a[p];return o=l?r(o.length):{},l&&(le.call(n,"index")&&(o.index=n.index),le.call(n,"input")&&(o.input=n.input)),u.push(n),a.push(o),(l?wt:d)(n,function(n,r){o[r]=lt(n,t,e,g,u,a)}),i&&(c(u),c(a)),o}function ct(n){var t=[];return C(n,function(n,e){vt(n)&&t.push(e)}),t.sort()}function pt(n){for(var t=-1,e=Se(n),r=e.length,u={};++t<r;){var a=e[t];u[n[a]]=a}return u}function st(n,t,e,r,u,a){var o=e===k;
|
15
|
+
if(typeof e=="function"&&!o){e=tt.createCallback(e,r,2);var i=e(n,t);if(typeof i!="undefined")return!!i}if(n===t)return 0!==n||1/n==1/t;var l=typeof n,p=typeof t;if(n===n&&(!n||"function"!=l&&"object"!=l)&&(!t||"function"!=p&&"object"!=p))return b;if(n==h||t==h)return n===t;if(p=ve.call(n),l=ve.call(t),p==z&&(p=V),l==z&&(l=V),p!=l)return b;switch(p){case P:case K:return+n==+t;case U:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case G:case H:return n==Xt(t)}if(l=p==W,!l){if(le.call(n,"__wrapped__")||le.call(t,"__wrapped__"))return st(n.__wrapped__||n,t.__wrapped__||t,e,r,u,a);
|
16
|
+
if(p!=V)return b;var p=n.constructor,s=t.constructor;if(p!=s&&(!vt(p)||!(p instanceof p&&vt(s)&&s instanceof s)))return b}for(s=!u,u||(u=f()),a||(a=f()),p=u.length;p--;)if(u[p]==n)return a[p]==t;var v=0,i=y;if(u.push(n),a.push(t),l){if(p=n.length,v=t.length,i=v==n.length,!i&&!o)return i;for(;v--;)if(l=p,s=t[v],o)for(;l--&&!(i=st(n[l],s,e,r,u,a)););else if(!(i=st(n[v],s,e,r,u,a)))break;return i}return C(t,function(t,o,f){return le.call(f,o)?(v++,i=le.call(n,o)&&st(n[o],t,e,r,u,a)):void 0}),i&&!o&&C(n,function(n,t,e){return le.call(e,t)?i=-1<--v:void 0
|
17
|
+
}),s&&(c(u),c(a)),i}function vt(n){return typeof n=="function"}function gt(n){return!(!n||!L[typeof n])}function yt(n){return typeof n=="number"||ve.call(n)==U}function ht(n){return typeof n=="string"||ve.call(n)==H}function bt(n,t,e){var r=arguments,u=0,a=2;if(!gt(n))return n;if(e===k)var o=r[3],i=r[4],l=r[5];else{var p=y,i=f(),l=f();typeof e!="number"&&(a=r.length),3<a&&"function"==typeof r[a-2]?o=tt.createCallback(r[--a-1],r[a--],2):2<a&&"function"==typeof r[a-1]&&(o=r[--a])}for(;++u<a;)(Ee(r[u])?wt:d)(r[u],function(t,e){var r,u,a=t,f=n[e];
|
18
|
+
if(t&&((u=Ee(t))||m(t))){for(a=i.length;a--;)if(r=i[a]==t){f=l[a];break}if(!r){var c;o&&(a=o(f,t),c=typeof a!="undefined")&&(f=a),c||(f=u?Ee(f)?f:[]:m(f)?f:{}),i.push(t),l.push(f),c||(f=bt(f,t,k,o,i,l))}}else o&&(a=o(f,t),typeof a=="undefined"&&(a=t)),typeof a!="undefined"&&(f=a);n[e]=f});return p&&(c(i),c(l)),n}function mt(n){for(var t=-1,e=Se(n),r=e.length,u=Mt(r);++t<r;)u[t]=n[e[t]];return u}function dt(n,t,e){var r=-1,u=at(),a=n?n.length:0,o=b;return e=(0>e?_e(0,a+e):e)||0,a&&typeof a=="number"?o=-1<(ht(n)?n.indexOf(t,e):u(n,t,e)):d(n,function(n){return++r<e?void 0:!(o=n===t)
|
19
|
+
}),o}function _t(n,t,e){var r=y;t=tt.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e<u&&(r=!!t(n[e],e,n)););else d(n,function(n,e,u){return r=!!t(n,e,u)});return r}function kt(n,t,e){var r=[];t=tt.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e<u;){var a=n[e];t(a,e,n)&&r.push(a)}else d(n,function(n,e,u){t(n,e,u)&&r.push(n)});return r}function jt(n,t,e){t=tt.createCallback(t,e),e=-1;var r=n?n.length:0;if(typeof r!="number"){var u;return d(n,function(n,e,r){return t(n,e,r)?(u=n,b):void 0
|
20
|
+
}),u}for(;++e<r;){var a=n[e];if(t(a,e,n))return a}}function wt(n,t,e){var r=-1,u=n?n.length:0;if(t=t&&typeof e=="undefined"?t:tt.createCallback(t,e),typeof u=="number")for(;++r<u&&t(n[r],r,n)!==false;);else d(n,t);return n}function Ct(n,t,e){var r=-1,u=n?n.length:0;if(t=tt.createCallback(t,e),typeof u=="number")for(var a=Mt(u);++r<u;)a[r]=t(n[r],r,n);else a=[],d(n,function(n,e,u){a[++r]=t(n,e,u)});return a}function xt(n,t,e){var r=-1/0,a=r;if(!t&&Ee(n)){e=-1;for(var o=n.length;++e<o;){var i=n[e];i>a&&(a=i)
|
21
|
+
}}else t=!t&&ht(n)?u:tt.createCallback(t,e),wt(n,function(n,e,u){e=t(n,e,u),e>r&&(r=e,a=n)});return a}function Ot(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Mt(r);++e<r;)u[e]=n[e][t];return u||Ct(n,t)}function Et(n,t,e,r){if(!n)return e;var u=3>arguments.length;t=tt.createCallback(t,r,4);var a=-1,o=n.length;if(typeof o=="number")for(u&&(e=n[++a]);++a<o;)e=t(e,n[a],a,n);else d(n,function(n,r,a){e=u?(u=b,n):t(e,n,r,a)});return e}function St(n,t,e,r){var u=n?n.length:0,a=3>arguments.length;
|
22
|
+
if(typeof u!="number")var o=Se(n),u=o.length;return t=tt.createCallback(t,r,4),wt(n,function(r,i,f){i=o?o[--u]:--u,e=a?(a=b,n[i]):t(e,n[i],i,f)}),e}function It(n,t,e){var r;t=tt.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e<u&&!(r=t(n[e],e,n)););else d(n,function(n,e,u){return!(r=t(n,e,u))});return!!r}function At(n){var r=-1,u=at(),a=n?n.length:0,i=ae.apply(Zt,Ce.call(arguments,1)),f=[],l=a>=w&&u===t;if(l){var c=o(i);c?(u=e,i=c):l=b}for(;++r<a;)c=n[r],0>u(i,c)&&f.push(c);
|
23
|
+
return l&&p(i),f}function Nt(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=h){var a=-1;for(t=tt.createCallback(t,e);++a<u&&t(n[a],a,n);)r++}else if(r=t,r==h||e)return n[0];return s(n,0,ke(_e(0,r),u))}}function $t(n,e,r){if(typeof r=="number"){var u=n?n.length:0;r=0>r?_e(0,u+r):r||0}else if(r)return r=Ft(n,e),n[r]===e?r:-1;return n?t(n,e,r):-1}function Bt(n,t,e){if(typeof t!="number"&&t!=h){var r=0,u=-1,a=n?n.length:0;for(t=tt.createCallback(t,e);++u<a&&t(n[u],u,n);)r++}else r=t==h||e?1:_e(0,t);
|
24
|
+
return s(n,r)}function Ft(n,t,e,r){var u=0,a=n?n.length:u;for(e=e?tt.createCallback(e,r,1):Wt,t=e(t);u<a;)r=u+a>>>1,e(n[r])<t?u=r+1:a=r;return u}function Rt(n){for(var t=-1,e=n?xt(Ot(n,"length")):0,r=Mt(0>e?0:e);++t<e;)r[t]=Ot(n,t);return r}function Tt(n,t){for(var e=-1,r=n?n.length:0,u={};++e<r;){var a=n[e];t?u[a]=t[e]:u[a[0]]=a[1]}return u}function qt(n,t){return Oe.fastBind||ge&&2<arguments.length?ge.call.apply(ge,arguments):rt(n,t,Ce.call(arguments,2))}function Dt(n,t,e){function r(){ue(s),ue(v),l=0,s=v=h
|
25
|
+
}function u(){var t=g&&(!m||1<l);r(),t&&(p!==false&&(c=new Vt),i=n.apply(f,o))}function a(){r(),(g||p!==t)&&(c=new Vt,i=n.apply(f,o))}var o,i,f,l=0,c=0,p=b,s=h,v=h,g=y;if(t=_e(0,t||0),e===y)var m=y,g=b;else gt(e)&&(m=e.leading,p="maxWait"in e&&_e(t,e.maxWait||0),g="trailing"in e?e.trailing:g);return function(){if(o=arguments,f=this,l++,ue(v),p===false)m&&2>l&&(i=n.apply(f,o));else{var e=new Vt;!s&&!m&&(c=e);var r=p-(e-c);0<r?s||(s=se(a,r)):(ue(s),s=h,c=e,i=n.apply(f,o))}return t!==p&&(v=se(u,t)),i}}function zt(n){var t=Ce.call(arguments,1);
|
26
|
+
return se(function(){n.apply(g,t)},1)}function Wt(n){return n}function Pt(n){wt(ct(n),function(t){var e=tt[t]=n[t];tt.prototype[t]=function(){var n=this.__wrapped__,t=[n];return ce.apply(t,arguments),t=e.apply(tt,t),n&&typeof n=="object"&&n===t?this:new et(t)}})}function Kt(){return this.__wrapped__}r=r?nt.defaults(n.Object(),r,nt.pick(n,D)):n;var Mt=r.Array,Ut=r.Boolean,Vt=r.Date,Gt=r.Function,Ht=r.Math,Jt=r.Number,Lt=r.Object,Qt=r.RegExp,Xt=r.String,Yt=r.TypeError,Zt=[],ne=Lt.prototype,te=r._,ee=Qt("^"+Xt(ne.valueOf).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),re=Ht.ceil,ue=r.clearTimeout,ae=Zt.concat,oe=Ht.floor,ie=Gt.prototype.toString,fe=ee.test(fe=Lt.getPrototypeOf)&&fe,le=ne.hasOwnProperty,ce=Zt.push,pe=r.setImmediate,se=r.setTimeout,ve=ne.toString,ge=ee.test(ge=ve.bind)&&ge,ye=ee.test(ye=Lt.create)&&ye,he=ee.test(he=Mt.isArray)&&he,be=r.isFinite,me=r.isNaN,de=ee.test(de=Lt.keys)&&de,_e=Ht.max,ke=Ht.min,je=r.parseInt,we=Ht.random,Ce=Zt.slice,Ht=ee.test(r.attachEvent),Ht=ge&&!/\n|true/.test(ge+Ht),xe={};
|
27
|
+
xe[W]=Mt,xe[P]=Ut,xe[K]=Vt,xe[M]=Gt,xe[V]=Lt,xe[U]=Jt,xe[G]=Qt,xe[H]=Xt,et.prototype=tt.prototype;var Oe=tt.support={};Oe.fastBind=ge&&!Ht,tt.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:tt}};var Ee=he,Se=de?function(n){return gt(n)?de(n):[]}:Z,Ie={"&":"&","<":"<",">":">",'"':""","'":"'"},Ae=pt(Ie),Ut=ot(function $e(n,t,e){for(var r=-1,u=n?n.length:0,a=[];++r<u;){var o=n[r];e&&(o=e(o,r,n)),Ee(o)?ce.apply(a,t?o:$e(o)):a.push(o)
|
28
|
+
}return a}),Ne=ot(function(n,r,u){var a=-1,i=at(),l=n?n.length:0,s=[],v=!r&&l>=w&&i===t,g=u||v?f():s;if(v){var y=o(g);y?(i=e,g=y):(v=b,g=u?g:(c(g),s))}for(;++a<l;){var y=n[a],h=u?u(y,a,n):y;(r?!a||g[g.length-1]!==h:0>i(g,h))&&((u||v)&&g.push(h),s.push(y))}return v?(c(g.b),p(g)):u&&c(g),s});return Ht&&Y&&typeof pe=="function"&&(zt=qt(pe,r)),pe=8==je(B+"08")?je:function(n,t){return je(ht(n)?n.replace(F,""):n,t||0)},tt.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0
|
29
|
+
}},tt.assign=X,tt.at=function(n){for(var t=-1,e=ae.apply(Zt,Ce.call(arguments,1)),r=e.length,u=Mt(r);++t<r;)u[t]=n[e[t]];return u},tt.bind=qt,tt.bindAll=function(n){for(var t=1<arguments.length?ae.apply(Zt,Ce.call(arguments,1)):ct(n),e=-1,r=t.length;++e<r;){var u=t[e];n[u]=qt(n[u],n)}return n},tt.bindKey=function(n,t){return rt(n,t,Ce.call(arguments,2),k)},tt.compact=function(n){for(var t=-1,e=n?n.length:0,r=[];++t<e;){var u=n[t];u&&r.push(u)}return r},tt.compose=function(){var n=arguments;return function(){for(var t=arguments,e=n.length;e--;)t=[n[e].apply(this,t)];
|
30
|
+
return t[0]}},tt.countBy=function(n,t,e){var r={};return t=tt.createCallback(t,e),wt(n,function(n,e,u){e=Xt(t(n,e,u)),le.call(r,e)?r[e]++:r[e]=1}),r},tt.createCallback=function(n,t,e){if(n==h)return Wt;var r=typeof n;if("function"!=r){if("object"!=r)return function(t){return t[n]};var u=Se(n);return function(t){for(var e=u.length,r=b;e--&&(r=st(t[u[e]],n[u[e]],k)););return r}}return typeof t=="undefined"||$&&!$.test(ie.call(n))?n:1===e?function(e){return n.call(t,e)}:2===e?function(e,r){return n.call(t,e,r)
|
31
|
+
}:4===e?function(e,r,u,a){return n.call(t,e,r,u,a)}:function(e,r,u){return n.call(t,e,r,u)}},tt.debounce=Dt,tt.defaults=Q,tt.defer=zt,tt.delay=function(n,t){var e=Ce.call(arguments,2);return se(function(){n.apply(g,e)},t)},tt.difference=At,tt.filter=kt,tt.flatten=Ut,tt.forEach=wt,tt.forIn=C,tt.forOwn=d,tt.functions=ct,tt.groupBy=function(n,t,e){var r={};return t=tt.createCallback(t,e),wt(n,function(n,e,u){e=Xt(t(n,e,u)),(le.call(r,e)?r[e]:r[e]=[]).push(n)}),r},tt.initial=function(n,t,e){if(!n)return[];
|
32
|
+
var r=0,u=n.length;if(typeof t!="number"&&t!=h){var a=u;for(t=tt.createCallback(t,e);a--&&t(n[a],a,n);)r++}else r=t==h||e?1:t||r;return s(n,0,ke(_e(0,u-r),u))},tt.intersection=function(n){for(var r=arguments,u=r.length,a=-1,i=f(),l=-1,s=at(),v=n?n.length:0,g=[],y=f();++a<u;){var h=r[a];i[a]=s===t&&(h?h.length:0)>=w&&o(a?r[a]:y)}n:for(;++l<v;){var b=i[0],h=n[l];if(0>(b?e(b,h):s(y,h))){for(a=u,(b||y).push(h);--a;)if(b=i[a],0>(b?e(b,h):s(r[a],h)))continue n;g.push(h)}}for(;u--;)(b=i[u])&&p(b);return c(i),c(y),g
|
33
|
+
},tt.invert=pt,tt.invoke=function(n,t){var e=Ce.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Mt(typeof a=="number"?a:0);return wt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},tt.keys=Se,tt.map=Ct,tt.max=xt,tt.memoize=function(n,t){function e(){var r=e.cache,u=j+(t?t.apply(this,arguments):arguments[0]);return le.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}return e.cache={},e},tt.merge=bt,tt.min=function(n,t,e){var r=1/0,a=r;if(!t&&Ee(n)){e=-1;for(var o=n.length;++e<o;){var i=n[e];
|
34
|
+
i<a&&(a=i)}}else t=!t&&ht(n)?u:tt.createCallback(t,e),wt(n,function(n,e,u){e=t(n,e,u),e<r&&(r=e,a=n)});return a},tt.omit=function(n,t,e){var r=at(),u=typeof t=="function",a={};if(u)t=tt.createCallback(t,e);else var o=ae.apply(Zt,Ce.call(arguments,1));return C(n,function(n,e,i){(u?!t(n,e,i):0>r(o,e))&&(a[e]=n)}),a},tt.once=function(n){var t,e;return function(){return t?e:(t=y,e=n.apply(this,arguments),n=h,e)}},tt.pairs=function(n){for(var t=-1,e=Se(n),r=e.length,u=Mt(r);++t<r;){var a=e[t];u[t]=[a,n[a]]
|
35
|
+
}return u},tt.partial=function(n){return rt(n,Ce.call(arguments,1))},tt.partialRight=function(n){return rt(n,Ce.call(arguments,1),h,k)},tt.pick=function(n,t,e){var r={};if(typeof t!="function")for(var u=-1,a=ae.apply(Zt,Ce.call(arguments,1)),o=gt(n)?a.length:0;++u<o;){var i=a[u];i in n&&(r[i]=n[i])}else t=tt.createCallback(t,e),C(n,function(n,e,u){t(n,e,u)&&(r[e]=n)});return r},tt.pluck=Ot,tt.range=function(n,t,e){n=+n||0,e=+e||1,t==h&&(t=n,n=0);var r=-1;t=_e(0,re((t-n)/e));for(var u=Mt(t);++r<t;)u[r]=n,n+=e;
|
36
|
+
return u},tt.reject=function(n,t,e){return t=tt.createCallback(t,e),kt(n,function(n,e,r){return!t(n,e,r)})},tt.rest=Bt,tt.shuffle=function(n){var t=-1,e=n?n.length:0,r=Mt(typeof e=="number"?e:0);return wt(n,function(n){var e=oe(we()*(++t+1));r[t]=r[e],r[e]=n}),r},tt.sortBy=function(n,t,e){var r=-1,u=n?n.length:0,o=Mt(typeof u=="number"?u:0);for(t=tt.createCallback(t,e),wt(n,function(n,e,u){var a=o[++r]=l();a.l=t(n,e,u),a.m=r,a.n=n}),u=o.length,o.sort(a);u--;)n=o[u],o[u]=n.n,p(n);return o},tt.tap=function(n,t){return t(n),n
|
37
|
+
},tt.throttle=function(n,t,e){var r=y,u=y;return e===false?r=b:gt(e)&&(r="leading"in e?e.leading:r,u="trailing"in e?e.trailing:u),e=l(),e.leading=r,e.maxWait=t,e.trailing=u,n=Dt(n,t,e),p(e),n},tt.times=function(n,t,e){n=-1<(n=+n)?n:0;var r=-1,u=Mt(n);for(t=tt.createCallback(t,e,1);++r<n;)u[r]=t(r);return u},tt.toArray=function(n){return n&&typeof n.length=="number"?s(n):mt(n)},tt.transform=function(n,t,e,r){var u=Ee(n);return t=tt.createCallback(t,r,4),e==h&&(u?e=[]:(r=n&&n.constructor,e=gt(r&&r.prototype)?ye(r&&r.prototype):{})),(u?wt:d)(n,function(n,r,u){return t(e,n,r,u)
|
38
|
+
}),e},tt.union=function(n){return Ee(n)||(arguments[0]=n?Ce.call(n):Zt),Ne(ae.apply(Zt,arguments))},tt.uniq=Ne,tt.unzip=Rt,tt.values=mt,tt.where=kt,tt.without=function(n){return At(n,Ce.call(arguments,1))},tt.wrap=function(n,t){return function(){var e=[n];return ce.apply(e,arguments),t.apply(this,e)}},tt.zip=function(n){return n?Rt(arguments):[]},tt.zipObject=Tt,tt.collect=Ct,tt.drop=Bt,tt.each=wt,tt.extend=X,tt.methods=ct,tt.object=Tt,tt.select=kt,tt.tail=Bt,tt.unique=Ne,Pt(tt),tt.chain=tt,tt.prototype.chain=function(){return this
|
39
|
+
},tt.clone=lt,tt.cloneDeep=function(n,t,e){return lt(n,y,t,e)},tt.contains=dt,tt.escape=function(n){return n==h?"":Xt(n).replace(T,ut)},tt.every=_t,tt.find=jt,tt.findIndex=function(n,t,e){var r=-1,u=n?n.length:0;for(t=tt.createCallback(t,e);++r<u;)if(t(n[r],r,n))return r;return-1},tt.findKey=function(n,t,e){var r;return t=tt.createCallback(t,e),d(n,function(n,e,u){return t(n,e,u)?(r=e,b):void 0}),r},tt.has=function(n,t){return n?le.call(n,t):b},tt.identity=Wt,tt.indexOf=$t,tt.isArguments=function(n){return ve.call(n)==z
|
40
|
+
},tt.isArray=Ee,tt.isBoolean=function(n){return n===y||n===false||ve.call(n)==P},tt.isDate=function(n){return n?typeof n=="object"&&ve.call(n)==K:b},tt.isElement=function(n){return n?1===n.nodeType:b},tt.isEmpty=function(n){var t=y;if(!n)return t;var e=ve.call(n),r=n.length;return e==W||e==H||e==z||e==V&&typeof r=="number"&&vt(n.splice)?!r:(d(n,function(){return t=b}),t)},tt.isEqual=st,tt.isFinite=function(n){return be(n)&&!me(parseFloat(n))},tt.isFunction=vt,tt.isNaN=function(n){return yt(n)&&n!=+n
|
41
|
+
},tt.isNull=function(n){return n===h},tt.isNumber=yt,tt.isObject=gt,tt.isPlainObject=m,tt.isRegExp=function(n){return n?typeof n=="object"&&ve.call(n)==G:b},tt.isString=ht,tt.isUndefined=function(n){return typeof n=="undefined"},tt.lastIndexOf=function(n,t,e){var r=n?n.length:0;for(typeof e=="number"&&(r=(0>e?_e(0,r+e):ke(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},tt.mixin=Pt,tt.noConflict=function(){return r._=te,this},tt.parseInt=pe,tt.random=function(n,t){n==h&&t==h&&(t=1),n=+n||0,t==h?(t=n,n=0):t=+t||0;
|
42
|
+
var e=we();return n%1||t%1?n+ke(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+oe(e*(t-n+1))},tt.reduce=Et,tt.reduceRight=St,tt.result=function(n,t){var e=n?n[t]:g;return vt(e)?n[t]():e},tt.runInContext=v,tt.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Se(n).length},tt.some=It,tt.sortedIndex=Ft,tt.template=function(n,t,e){var r=tt.templateSettings;n||(n=""),e=Q({},e,r);var u,a=Q({},e.imports,r.imports),r=Se(a),a=mt(a),o=0,f=e.interpolate||R,l="__p+='",f=Qt((e.escape||R).source+"|"+f.source+"|"+(f===N?I:R).source+"|"+(e.evaluate||R).source+"|$","g");
|
43
|
+
n.replace(f,function(t,e,r,a,f,c){return r||(r=a),l+=n.slice(o,c).replace(q,i),e&&(l+="'+__e("+e+")+'"),f&&(u=y,l+="';"+f+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),o=c+t.length,t}),l+="';\n",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(x,""):l).replace(O,"$1").replace(E,"$1;"),l="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var c=Gt(r,"return "+l).apply(g,a)
|
44
|
+
}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},tt.unescape=function(n){return n==h?"":Xt(n).replace(S,ft)},tt.uniqueId=function(n){var t=++_;return Xt(n==h?"":n)+t},tt.all=_t,tt.any=It,tt.detect=jt,tt.findWhere=jt,tt.foldl=Et,tt.foldr=St,tt.include=dt,tt.inject=Et,d(tt,function(n,t){tt.prototype[t]||(tt.prototype[t]=function(){var t=[this.__wrapped__];return ce.apply(t,arguments),n.apply(tt,t)})}),tt.first=Nt,tt.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=h){var a=u;
|
45
|
+
for(t=tt.createCallback(t,e);a--&&t(n[a],a,n);)r++}else if(r=t,r==h||e)return n[u-1];return s(n,_e(0,u-r))}},tt.take=Nt,tt.head=Nt,d(tt,function(n,t){tt.prototype[t]||(tt.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e);return t==h||e&&typeof t!="function"?r:new et(r)})}),tt.VERSION="1.3.1",tt.prototype.toString=function(){return Xt(this.__wrapped__)},tt.prototype.value=Kt,tt.prototype.valueOf=Kt,wt(["join","pop","shift"],function(n){var t=Zt[n];tt.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)
|
46
|
+
}}),wt(["push","reverse","sort","unshift"],function(n){var t=Zt[n];tt.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),wt(["concat","slice","splice"],function(n){var t=Zt[n];tt.prototype[n]=function(){return new et(t.apply(this.__wrapped__,arguments))}}),tt}var g,y=!0,h=null,b=!1,m=[],d=[],_=0,k={},j=+new Date+"",w=75,C=40,x=/\b__p\+='';/g,O=/\b(__p\+=)''\+/g,E=/(__e\(.*?\)|\b__t\))\+'';/g,S=/&(?:amp|lt|gt|quot|#39);/g,I=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,A=/\w*$/,N=/<%=([\s\S]+?)%>/g,$=($=/\bthis\b/)&&$.test(v)&&$,B=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",F=RegExp("^["+B+"]*0+(?=.$)"),R=/($^)/,T=/[&<>"']/g,q=/['\n\r\t\u2028\u2029\\]/g,D="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),z="[object Arguments]",W="[object Array]",P="[object Boolean]",K="[object Date]",M="[object Function]",U="[object Number]",V="[object Object]",G="[object RegExp]",H="[object String]",J={};
|
47
|
+
J[M]=b,J[z]=J[W]=J[P]=J[K]=J[U]=J[V]=J[G]=J[H]=y;var L={"boolean":b,"function":y,object:y,number:b,string:b,undefined:b},Q={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},X=L[typeof exports]&&exports,Y=L[typeof module]&&module&&module.exports==X&&module,Z=L[typeof global]&&global;!Z||Z.global!==Z&&Z.window!==Z||(n=Z);var nt=v();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=nt, define(function(){return nt})):X&&!X.nodeType?Y?(Y.exports=nt)._=nt:X._=nt:n._=nt
|
48
|
+
}(this);
|
@@ -0,0 +1,140 @@
|
|
1
|
+
|
2
|
+
/*jshint
|
3
|
+
asi: true,
|
4
|
+
unused: true,
|
5
|
+
boss: true,
|
6
|
+
loopfunc: true,
|
7
|
+
eqnull: true
|
8
|
+
*/
|
9
|
+
|
10
|
+
|
11
|
+
/*!
|
12
|
+
* Legacy browser support
|
13
|
+
*/
|
14
|
+
|
15
|
+
// isArray support
|
16
|
+
if ( !Array.isArray ) {
|
17
|
+
Array.isArray = function( value ) {
|
18
|
+
return {}.toString.call( value ) == '[object Array]'
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
// Map array support
|
24
|
+
if ( ![].map ) {
|
25
|
+
Array.prototype.map = function ( callback, self ) {
|
26
|
+
var array = this, len = array.length, newArray = new Array( len )
|
27
|
+
for ( var i = 0; i < len; i++ ) {
|
28
|
+
if ( i in array ) {
|
29
|
+
newArray[ i ] = callback.call( self, array[ i ], i, array )
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return newArray
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
// Filter array support
|
38
|
+
if ( ![].filter ) {
|
39
|
+
Array.prototype.filter = function( callback ) {
|
40
|
+
if ( this == null ) throw new TypeError()
|
41
|
+
var t = Object( this ), len = t.length >>> 0
|
42
|
+
if ( typeof callback != 'function' ) throw new TypeError()
|
43
|
+
var newArray = [], thisp = arguments[ 1 ]
|
44
|
+
for ( var i = 0; i < len; i++ ) {
|
45
|
+
if ( i in t ) {
|
46
|
+
var val = t[ i ]
|
47
|
+
if ( callback.call( thisp, val, i, t ) ) newArray.push( val )
|
48
|
+
}
|
49
|
+
}
|
50
|
+
return newArray
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
|
55
|
+
// Index of array support
|
56
|
+
if ( ![].indexOf ) {
|
57
|
+
Array.prototype.indexOf = function( searchElement ) {
|
58
|
+
if ( this == null ) throw new TypeError()
|
59
|
+
var t = Object( this ), len = t.length >>> 0
|
60
|
+
if ( len === 0 ) return -1
|
61
|
+
var n = 0
|
62
|
+
if ( arguments.length > 1 ) {
|
63
|
+
n = Number( arguments[ 1 ] )
|
64
|
+
if ( n != n ) {
|
65
|
+
n = 0
|
66
|
+
}
|
67
|
+
else if ( n !== 0 && n != Infinity && n != -Infinity ) {
|
68
|
+
n = ( n > 0 || -1 ) * Math.floor( Math.abs( n ) )
|
69
|
+
}
|
70
|
+
}
|
71
|
+
if ( n >= len ) return -1
|
72
|
+
var k = n >= 0 ? n : Math.max( len - Math.abs( n ), 0 )
|
73
|
+
for ( ; k < len; k++ ) {
|
74
|
+
if ( k in t && t[ k ] === searchElement ) return k
|
75
|
+
}
|
76
|
+
return -1
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
|
81
|
+
/*!
|
82
|
+
* Cross-Browser Split 1.1.1
|
83
|
+
* Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
|
84
|
+
* Available under the MIT License
|
85
|
+
* http://blog.stevenlevithan.com/archives/cross-browser-split
|
86
|
+
*/
|
87
|
+
var nativeSplit = String.prototype.split, compliantExecNpcg = /()??/.exec('')[1] === undefined
|
88
|
+
String.prototype.split = function(separator, limit) {
|
89
|
+
var str = this
|
90
|
+
if (Object.prototype.toString.call(separator) !== '[object RegExp]') {
|
91
|
+
return nativeSplit.call(str, separator, limit)
|
92
|
+
}
|
93
|
+
var output = [],
|
94
|
+
flags = (separator.ignoreCase ? 'i' : '') +
|
95
|
+
(separator.multiline ? 'm' : '') +
|
96
|
+
(separator.extended ? 'x' : '') +
|
97
|
+
(separator.sticky ? 'y' : ''),
|
98
|
+
lastLastIndex = 0,
|
99
|
+
separator2, match, lastIndex, lastLength
|
100
|
+
separator = new RegExp(separator.source, flags + 'g')
|
101
|
+
str += ''
|
102
|
+
if (!compliantExecNpcg) {
|
103
|
+
separator2 = new RegExp('^' + separator.source + '$(?!\\s)', flags)
|
104
|
+
}
|
105
|
+
limit = limit === undefined ? -1 >>> 0 : limit >>> 0
|
106
|
+
while (match = separator.exec(str)) {
|
107
|
+
lastIndex = match.index + match[0].length
|
108
|
+
if (lastIndex > lastLastIndex) {
|
109
|
+
output.push(str.slice(lastLastIndex, match.index))
|
110
|
+
if (!compliantExecNpcg && match.length > 1) {
|
111
|
+
match[0].replace(separator2, function () {
|
112
|
+
for (var i = 1; i < arguments.length - 2; i++) {
|
113
|
+
if (arguments[i] === undefined) {
|
114
|
+
match[i] = undefined
|
115
|
+
}
|
116
|
+
}
|
117
|
+
})
|
118
|
+
}
|
119
|
+
if (match.length > 1 && match.index < str.length) {
|
120
|
+
Array.prototype.push.apply(output, match.slice(1))
|
121
|
+
}
|
122
|
+
lastLength = match[0].length
|
123
|
+
lastLastIndex = lastIndex
|
124
|
+
if (output.length >= limit) {
|
125
|
+
break
|
126
|
+
}
|
127
|
+
}
|
128
|
+
if (separator.lastIndex === match.index) {
|
129
|
+
separator.lastIndex++
|
130
|
+
}
|
131
|
+
}
|
132
|
+
if (lastLastIndex === str.length) {
|
133
|
+
if (lastLength || !separator.test('')) {
|
134
|
+
output.push('')
|
135
|
+
}
|
136
|
+
} else {
|
137
|
+
output.push(str.slice(lastLastIndex))
|
138
|
+
}
|
139
|
+
return output.length > limit ? output.slice(0, limit) : output
|
140
|
+
}
|
@@ -0,0 +1,957 @@
|
|
1
|
+
|
2
|
+
/*!
|
3
|
+
* Date picker for pickadate.js v3.2.0
|
4
|
+
* http://amsul.github.io/pickadate.js/date.htm
|
5
|
+
*/
|
6
|
+
|
7
|
+
/*jshint
|
8
|
+
debug: true,
|
9
|
+
devel: true,
|
10
|
+
browser: true,
|
11
|
+
asi: true,
|
12
|
+
unused: true,
|
13
|
+
boss: true
|
14
|
+
*/
|
15
|
+
|
16
|
+
|
17
|
+
// Create a new scope.
|
18
|
+
(function() {
|
19
|
+
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Globals and constants
|
23
|
+
*/
|
24
|
+
var DAYS_IN_WEEK = 7,
|
25
|
+
WEEKS_IN_CALENDAR = 6
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
/**
|
30
|
+
* The date picker constructor
|
31
|
+
*/
|
32
|
+
function DatePicker( picker, settings ) {
|
33
|
+
|
34
|
+
var calendar = this,
|
35
|
+
elementValue = picker.$node[ 0 ].value,
|
36
|
+
elementDataValue = picker.$node.data( 'value' ),
|
37
|
+
valueString = elementDataValue || elementValue,
|
38
|
+
formatString = elementDataValue ? settings.formatSubmit : settings.format
|
39
|
+
|
40
|
+
calendar.settings = settings
|
41
|
+
|
42
|
+
// The queue of methods that will be used to build item objects.
|
43
|
+
calendar.queue = {
|
44
|
+
min: 'measure create',
|
45
|
+
max: 'measure create',
|
46
|
+
now: 'now create',
|
47
|
+
select: 'parse create validate',
|
48
|
+
highlight: 'navigate create validate',
|
49
|
+
view: 'create validate viewset',
|
50
|
+
disable: 'flipItem',
|
51
|
+
enable: 'flipItem'
|
52
|
+
}
|
53
|
+
|
54
|
+
// The component's item object.
|
55
|
+
calendar.item = {}
|
56
|
+
|
57
|
+
calendar.item.disable = ( settings.disable || [] ).slice( 0 )
|
58
|
+
calendar.item.enable = -(function( collectionDisabled ) {
|
59
|
+
return collectionDisabled[ 0 ] === true ? collectionDisabled.shift() : -1
|
60
|
+
})( calendar.item.disable )
|
61
|
+
|
62
|
+
calendar.
|
63
|
+
set( 'min', settings.min ).
|
64
|
+
set( 'max', settings.max ).
|
65
|
+
set( 'now' ).
|
66
|
+
|
67
|
+
// Setting the `select` also sets the `highlight` and `view`.
|
68
|
+
set( 'select',
|
69
|
+
|
70
|
+
// Use the value provided or default to selecting “today”.
|
71
|
+
valueString || calendar.item.now,
|
72
|
+
{
|
73
|
+
// Use the appropriate format.
|
74
|
+
format: formatString,
|
75
|
+
|
76
|
+
// Set user-provided month data as true when there is a
|
77
|
+
// “mm” or “m” used in the relative format string.
|
78
|
+
data: (function( formatArray ) {
|
79
|
+
return valueString && ( formatArray.indexOf( 'mm' ) > -1 || formatArray.indexOf( 'm' ) > -1 )
|
80
|
+
})( calendar.formats.toArray( formatString ) )
|
81
|
+
}
|
82
|
+
)
|
83
|
+
|
84
|
+
|
85
|
+
// The keycode to movement mapping.
|
86
|
+
calendar.key = {
|
87
|
+
40: 7, // Down
|
88
|
+
38: -7, // Up
|
89
|
+
39: 1, // Right
|
90
|
+
37: -1, // Left
|
91
|
+
go: function( timeChange ) {
|
92
|
+
calendar.set( 'highlight', [ calendar.item.highlight.year, calendar.item.highlight.month, calendar.item.highlight.date + timeChange ], { interval: timeChange } )
|
93
|
+
this.render()
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
// Bind some picker events.
|
99
|
+
picker.
|
100
|
+
on( 'render', function() {
|
101
|
+
picker.$root.find( '.' + settings.klass.selectMonth ).on( 'change', function() {
|
102
|
+
picker.set( 'highlight', [ picker.get( 'view' ).year, this.value, picker.get( 'highlight' ).date ] )
|
103
|
+
picker.$root.find( '.' + settings.klass.selectMonth ).focus()
|
104
|
+
})
|
105
|
+
picker.$root.find( '.' + settings.klass.selectYear ).on( 'change', function() {
|
106
|
+
picker.set( 'highlight', [ this.value, picker.get( 'view' ).month, picker.get( 'highlight' ).date ] )
|
107
|
+
picker.$root.find( '.' + settings.klass.selectYear ).focus()
|
108
|
+
})
|
109
|
+
}).
|
110
|
+
on( 'open', function() {
|
111
|
+
picker.$root.find( 'button, select' ).attr( 'disabled', false )
|
112
|
+
}).
|
113
|
+
on( 'close', function() {
|
114
|
+
picker.$root.find( 'button, select' ).attr( 'disabled', true )
|
115
|
+
})
|
116
|
+
|
117
|
+
} //DatePicker
|
118
|
+
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Set a datepicker item object.
|
122
|
+
*/
|
123
|
+
DatePicker.prototype.set = function( type, value, options ) {
|
124
|
+
|
125
|
+
var calendar = this
|
126
|
+
|
127
|
+
// Go through the queue of methods, and invoke the function. Update this
|
128
|
+
// as the time unit, and set the final resultant as this item type.
|
129
|
+
// * In the case of `enable`, keep the queue but set `disable` instead.
|
130
|
+
// And in the case of `flip`, keep the queue but set `enable` instead.
|
131
|
+
calendar.item[ ( type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type ) ] = calendar.queue[ type ].split( ' ' ).map( function( method ) {
|
132
|
+
return value = calendar[ method ]( type, value, options )
|
133
|
+
}).pop()
|
134
|
+
|
135
|
+
// Check if we need to cascade through more updates.
|
136
|
+
if ( type == 'select' ) {
|
137
|
+
calendar.set( 'highlight', calendar.item.select, options )
|
138
|
+
}
|
139
|
+
else if ( type == 'highlight' ) {
|
140
|
+
calendar.set( 'view', calendar.item.highlight, options )
|
141
|
+
}
|
142
|
+
else if ( ( type == 'flip' || type == 'min' || type == 'max' || type == 'disable' || type == 'enable' ) && calendar.item.select && calendar.item.highlight ) {
|
143
|
+
calendar.
|
144
|
+
set( 'select', calendar.item.select, options ).
|
145
|
+
set( 'highlight', calendar.item.highlight, options )
|
146
|
+
}
|
147
|
+
|
148
|
+
return calendar
|
149
|
+
} //DatePicker.prototype.set
|
150
|
+
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Get a datepicker item object.
|
154
|
+
*/
|
155
|
+
DatePicker.prototype.get = function( type ) {
|
156
|
+
return this.item[ type ]
|
157
|
+
} //DatePicker.prototype.get
|
158
|
+
|
159
|
+
|
160
|
+
/**
|
161
|
+
* Create a picker date object.
|
162
|
+
*/
|
163
|
+
DatePicker.prototype.create = function( type, value, options ) {
|
164
|
+
|
165
|
+
var isInfiniteValue,
|
166
|
+
calendar = this
|
167
|
+
|
168
|
+
// If there’s no value, use the type as the value.
|
169
|
+
value = value === undefined ? type : value
|
170
|
+
|
171
|
+
|
172
|
+
// If it’s infinity, update the value.
|
173
|
+
if ( value == -Infinity || value == Infinity ) {
|
174
|
+
isInfiniteValue = value
|
175
|
+
}
|
176
|
+
|
177
|
+
// If it’s an object, use the native date object.
|
178
|
+
else if ( Picker._.isObject( value ) && Picker._.isInteger( value.pick ) ) {
|
179
|
+
value = value.obj
|
180
|
+
}
|
181
|
+
|
182
|
+
// If it’s an array, convert it into a date and make sure
|
183
|
+
// that it’s a valid date – otherwise default to today.
|
184
|
+
else if ( Array.isArray( value ) ) {
|
185
|
+
value = new Date( value[ 0 ], value[ 1 ], value[ 2 ] )
|
186
|
+
value = Picker._.isDate( value ) ? value : calendar.create().obj
|
187
|
+
}
|
188
|
+
|
189
|
+
// If it’s a number or date object, make a normalized date.
|
190
|
+
else if ( Picker._.isInteger( value ) || Picker._.isDate( value ) ) {
|
191
|
+
value = calendar.normalize( new Date( value ), options )
|
192
|
+
}
|
193
|
+
|
194
|
+
// If it’s a literal true or any other case, set it to now.
|
195
|
+
else /*if ( value === true )*/ {
|
196
|
+
value = calendar.now( type, value, options )
|
197
|
+
}
|
198
|
+
|
199
|
+
// Return the compiled object.
|
200
|
+
return {
|
201
|
+
year: isInfiniteValue || value.getFullYear(),
|
202
|
+
month: isInfiniteValue || value.getMonth(),
|
203
|
+
date: isInfiniteValue || value.getDate(),
|
204
|
+
day: isInfiniteValue || value.getDay(),
|
205
|
+
obj: isInfiniteValue || value,
|
206
|
+
pick: isInfiniteValue || value.getTime()
|
207
|
+
}
|
208
|
+
} //DatePicker.prototype.create
|
209
|
+
|
210
|
+
|
211
|
+
/**
|
212
|
+
* Get the date today.
|
213
|
+
*/
|
214
|
+
DatePicker.prototype.now = function( type, value, options ) {
|
215
|
+
value = new Date()
|
216
|
+
if ( options && options.rel ) {
|
217
|
+
value.setDate( value.getDate() + options.rel )
|
218
|
+
}
|
219
|
+
return this.normalize( value, options )
|
220
|
+
} //DatePicker.prototype.now
|
221
|
+
|
222
|
+
|
223
|
+
/**
|
224
|
+
* Navigate to next/prev month.
|
225
|
+
*/
|
226
|
+
DatePicker.prototype.navigate = function( type, value, options ) {
|
227
|
+
|
228
|
+
if ( Picker._.isObject( value ) ) {
|
229
|
+
|
230
|
+
var targetDateObject = new Date( value.year, value.month + ( options && options.nav ? options.nav : 0 ), 1 ),
|
231
|
+
year = targetDateObject.getFullYear(),
|
232
|
+
month = targetDateObject.getMonth(),
|
233
|
+
date = value.date
|
234
|
+
|
235
|
+
// Make sure the date is valid and if the month we’re going to doesn’t have enough
|
236
|
+
// days, keep decreasing the date until we reach the month’s last date.
|
237
|
+
while ( Picker._.isDate( targetDateObject ) && new Date( year, month, date ).getMonth() !== month ) {
|
238
|
+
date -= 1
|
239
|
+
}
|
240
|
+
|
241
|
+
value = [ year, month, date ]
|
242
|
+
}
|
243
|
+
|
244
|
+
return value
|
245
|
+
} //DatePicker.prototype.navigate
|
246
|
+
|
247
|
+
|
248
|
+
/**
|
249
|
+
* Normalize a date by setting the hours to midnight.
|
250
|
+
*/
|
251
|
+
DatePicker.prototype.normalize = function( value/*, options*/ ) {
|
252
|
+
value.setHours( 0, 0, 0, 0 )
|
253
|
+
return value
|
254
|
+
}
|
255
|
+
|
256
|
+
|
257
|
+
/**
|
258
|
+
* Measure the range of dates.
|
259
|
+
*/
|
260
|
+
DatePicker.prototype.measure = function( type, value/*, options*/ ) {
|
261
|
+
|
262
|
+
var calendar = this
|
263
|
+
|
264
|
+
// If it's anything false-y, remove the limits.
|
265
|
+
if ( !value ) {
|
266
|
+
value = type == 'min' ? -Infinity : Infinity
|
267
|
+
}
|
268
|
+
|
269
|
+
// If it's an integer, get a date relative to today.
|
270
|
+
else if ( Picker._.isInteger( value ) ) {
|
271
|
+
value = calendar.now( type, value, { rel: value } )
|
272
|
+
}
|
273
|
+
|
274
|
+
return value
|
275
|
+
} ///DatePicker.prototype.measure
|
276
|
+
|
277
|
+
|
278
|
+
/**
|
279
|
+
* Create a viewset object based on navigation.
|
280
|
+
*/
|
281
|
+
DatePicker.prototype.viewset = function( type, dateObject/*, options*/ ) {
|
282
|
+
return this.create([ dateObject.year, dateObject.month, 1 ])
|
283
|
+
}
|
284
|
+
|
285
|
+
|
286
|
+
/**
|
287
|
+
* Validate a date as enabled and shift if needed.
|
288
|
+
*/
|
289
|
+
DatePicker.prototype.validate = function( type, dateObject, options ) {
|
290
|
+
|
291
|
+
var calendar = this,
|
292
|
+
|
293
|
+
// Keep a reference to the original date.
|
294
|
+
originalDateObject = dateObject,
|
295
|
+
|
296
|
+
// Make sure we have an interval.
|
297
|
+
interval = options && options.interval ? options.interval : 1,
|
298
|
+
|
299
|
+
// Check if the calendar enabled dates are inverted.
|
300
|
+
isInverted = calendar.item.enable === -1,
|
301
|
+
|
302
|
+
// Check if we have any enabled dates after/before now.
|
303
|
+
hasEnabledBeforeTarget, hasEnabledAfterTarget,
|
304
|
+
|
305
|
+
// The min & max limits.
|
306
|
+
minLimitObject = calendar.item.min,
|
307
|
+
maxLimitObject = calendar.item.max,
|
308
|
+
|
309
|
+
// Check if we’ve reached the limit during shifting.
|
310
|
+
reachedMin, reachedMax,
|
311
|
+
|
312
|
+
// Check if the calendar is inverted and at least one weekday is enabled.
|
313
|
+
hasEnabledWeekdays = isInverted && calendar.item.disable.filter( function( value ) {
|
314
|
+
|
315
|
+
// If there’s a date, check where it is relative to the target.
|
316
|
+
if ( Array.isArray( value ) ) {
|
317
|
+
var dateTime = calendar.create( value ).pick
|
318
|
+
if ( dateTime < dateObject.pick ) hasEnabledBeforeTarget = true
|
319
|
+
else if ( dateTime > dateObject.pick ) hasEnabledAfterTarget = true
|
320
|
+
}
|
321
|
+
|
322
|
+
// Return only integers for enabled weekdays.
|
323
|
+
return Picker._.isInteger( value )
|
324
|
+
}).length
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
// Cases to validate for:
|
329
|
+
// [1] Not inverted and date disabled.
|
330
|
+
// [2] Inverted and some dates enabled.
|
331
|
+
// [3] Out of range.
|
332
|
+
//
|
333
|
+
// Cases to **not** validate for:
|
334
|
+
// • Navigating months.
|
335
|
+
// • Not inverted and date enabled.
|
336
|
+
// • Inverted and all dates disabled.
|
337
|
+
// • ..and anything else.
|
338
|
+
if ( !options.nav ) if (
|
339
|
+
/* 1 */ ( !isInverted && calendar.disabled( dateObject ) ) ||
|
340
|
+
/* 2 */ ( isInverted && calendar.disabled( dateObject ) && ( hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget ) ) ||
|
341
|
+
/* 3 */ ( dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick )
|
342
|
+
) {
|
343
|
+
|
344
|
+
|
345
|
+
// When inverted, flip the direction if there aren’t any enabled weekdays
|
346
|
+
// and there are no enabled dates in the direction of the interval.
|
347
|
+
if ( isInverted && !hasEnabledWeekdays && ( ( !hasEnabledAfterTarget && interval > 0 ) || ( !hasEnabledBeforeTarget && interval < 0 ) ) ) {
|
348
|
+
interval *= -1
|
349
|
+
}
|
350
|
+
|
351
|
+
|
352
|
+
// Keep looping until we reach an enabled date.
|
353
|
+
while ( calendar.disabled( dateObject ) ) {
|
354
|
+
|
355
|
+
|
356
|
+
// If we’ve looped into the next/prev month, return to the original date and flatten the interval.
|
357
|
+
if ( Math.abs( interval ) > 1 && ( dateObject.month < originalDateObject.month || dateObject.month > originalDateObject.month ) ) {
|
358
|
+
dateObject = originalDateObject
|
359
|
+
interval = Math.abs( interval ) / interval
|
360
|
+
}
|
361
|
+
|
362
|
+
|
363
|
+
// If we’ve reached the min/max limit, reverse the direction and flatten the interval.
|
364
|
+
if ( dateObject.pick <= minLimitObject.pick ) {
|
365
|
+
reachedMin = true
|
366
|
+
interval = 1
|
367
|
+
}
|
368
|
+
else if ( dateObject.pick >= maxLimitObject.pick ) {
|
369
|
+
reachedMax = true
|
370
|
+
interval = -1
|
371
|
+
}
|
372
|
+
|
373
|
+
|
374
|
+
// If we’ve reached both limits, just break out of the loop.
|
375
|
+
if ( reachedMin && reachedMax ) {
|
376
|
+
break
|
377
|
+
}
|
378
|
+
|
379
|
+
|
380
|
+
// Finally, create the shifted date using the interval and keep looping.
|
381
|
+
dateObject = calendar.create([ dateObject.year, dateObject.month, dateObject.date + interval ])
|
382
|
+
}
|
383
|
+
|
384
|
+
} //endif
|
385
|
+
|
386
|
+
|
387
|
+
// Return the date object settled on.
|
388
|
+
return dateObject
|
389
|
+
} //DatePicker.prototype.validate
|
390
|
+
|
391
|
+
|
392
|
+
/**
|
393
|
+
* Check if an object is disabled.
|
394
|
+
*/
|
395
|
+
DatePicker.prototype.disabled = function( dateObject ) {
|
396
|
+
|
397
|
+
var calendar = this,
|
398
|
+
|
399
|
+
// Filter through the disabled dates to check if this is one.
|
400
|
+
isDisabledDate = calendar.item.disable.filter( function( dateToDisable ) {
|
401
|
+
|
402
|
+
// If the date is a number, match the weekday with 0index and `firstDay` check.
|
403
|
+
if ( Picker._.isInteger( dateToDisable ) ) {
|
404
|
+
return dateObject.day === ( calendar.settings.firstDay ? dateToDisable : dateToDisable - 1 ) % 7
|
405
|
+
}
|
406
|
+
|
407
|
+
// If it's an array, create the object and match the exact date.
|
408
|
+
if ( Array.isArray( dateToDisable ) ) {
|
409
|
+
return dateObject.pick === calendar.create( dateToDisable ).pick
|
410
|
+
}
|
411
|
+
}).length
|
412
|
+
|
413
|
+
|
414
|
+
// It’s disabled beyond the min/max limits. If within the limits, check the
|
415
|
+
// calendar “enabled” flag is flipped and respectively flip the condition.
|
416
|
+
return dateObject.pick < calendar.item.min.pick ||
|
417
|
+
dateObject.pick > calendar.item.max.pick ||
|
418
|
+
calendar.item.enable === -1 ? !isDisabledDate : isDisabledDate
|
419
|
+
} //DatePicker.prototype.disabled
|
420
|
+
|
421
|
+
|
422
|
+
/**
|
423
|
+
* Parse a string into a usable type.
|
424
|
+
*/
|
425
|
+
DatePicker.prototype.parse = function( type, value, options ) {
|
426
|
+
|
427
|
+
var calendar = this,
|
428
|
+
parsingObject = {}
|
429
|
+
|
430
|
+
if ( !value || Picker._.isInteger( value ) || Array.isArray( value ) || Picker._.isDate( value ) || Picker._.isObject( value ) && Picker._.isInteger( value.pick ) ) {
|
431
|
+
return value
|
432
|
+
}
|
433
|
+
|
434
|
+
// We need a `.format` to parse the value.
|
435
|
+
if ( !( options && options.format ) ) {
|
436
|
+
// should probably default to the default format.
|
437
|
+
throw "Need a formatting option to parse this.."
|
438
|
+
}
|
439
|
+
|
440
|
+
// Convert the format into an array and then map through it.
|
441
|
+
calendar.formats.toArray( options.format ).map( function( label ) {
|
442
|
+
|
443
|
+
var
|
444
|
+
// Grab the formatting label.
|
445
|
+
formattingLabel = calendar.formats[ label ],
|
446
|
+
|
447
|
+
// The format length is from the formatting label function or the
|
448
|
+
// label length without the escaping exclamation (!) mark.
|
449
|
+
formatLength = formattingLabel ? Picker._.trigger( formattingLabel, calendar, [ value, parsingObject ] ) : label.replace( /^!/, '' ).length
|
450
|
+
|
451
|
+
// If there's a format label, split the value up to the format length.
|
452
|
+
// Then add it to the parsing object with appropriate label.
|
453
|
+
if ( formattingLabel ) {
|
454
|
+
parsingObject[ label ] = value.substr( 0, formatLength )
|
455
|
+
}
|
456
|
+
|
457
|
+
// Update the value as the substring from format length to end.
|
458
|
+
value = value.substr( formatLength )
|
459
|
+
})
|
460
|
+
|
461
|
+
// If it’s parsing a user provided month value, compensate for month 0index.
|
462
|
+
return [ parsingObject.yyyy || parsingObject.yy, +( parsingObject.mm || parsingObject.m ) - ( options.data ? 1 : 0 ), parsingObject.dd || parsingObject.d ]
|
463
|
+
} //DatePicker.prototype.parse
|
464
|
+
|
465
|
+
|
466
|
+
/**
|
467
|
+
* Various formats to display the object in.
|
468
|
+
*/
|
469
|
+
DatePicker.prototype.formats = (function() {
|
470
|
+
|
471
|
+
// Return the length of the first word in a collection.
|
472
|
+
function getWordLengthFromCollection( string, collection, dateObject ) {
|
473
|
+
|
474
|
+
// Grab the first word from the string.
|
475
|
+
var word = string.match( /\w+/ )[ 0 ]
|
476
|
+
|
477
|
+
// If there's no month index, add it to the date object
|
478
|
+
if ( !dateObject.mm && !dateObject.m ) {
|
479
|
+
dateObject.m = collection.indexOf( word )
|
480
|
+
}
|
481
|
+
|
482
|
+
// Return the length of the word.
|
483
|
+
return word.length
|
484
|
+
}
|
485
|
+
|
486
|
+
// Get the length of the first word in a string.
|
487
|
+
function getFirstWordLength( string ) {
|
488
|
+
return string.match( /\w+/ )[ 0 ].length
|
489
|
+
}
|
490
|
+
|
491
|
+
return {
|
492
|
+
|
493
|
+
d: function( string, dateObject ) {
|
494
|
+
|
495
|
+
// If there's string, then get the digits length.
|
496
|
+
// Otherwise return the selected date.
|
497
|
+
return string ? Picker._.digits( string ) : dateObject.date
|
498
|
+
},
|
499
|
+
dd: function( string, dateObject ) {
|
500
|
+
|
501
|
+
// If there's a string, then the length is always 2.
|
502
|
+
// Otherwise return the selected date with a leading zero.
|
503
|
+
return string ? 2 : Picker._.lead( dateObject.date )
|
504
|
+
},
|
505
|
+
ddd: function( string, dateObject ) {
|
506
|
+
|
507
|
+
// If there's a string, then get the length of the first word.
|
508
|
+
// Otherwise return the short selected weekday.
|
509
|
+
return string ? getFirstWordLength( string ) : this.settings.weekdaysShort[ dateObject.day ]
|
510
|
+
},
|
511
|
+
dddd: function( string, dateObject ) {
|
512
|
+
|
513
|
+
// If there's a string, then get the length of the first word.
|
514
|
+
// Otherwise return the full selected weekday.
|
515
|
+
return string ? getFirstWordLength( string ) : this.settings.weekdaysFull[ dateObject.day ]
|
516
|
+
},
|
517
|
+
m: function( string, dateObject ) {
|
518
|
+
|
519
|
+
// If there's a string, then get the length of the digits
|
520
|
+
// Otherwise return the selected month with 0index compensation.
|
521
|
+
return string ? Picker._.digits( string ) : dateObject.month + 1
|
522
|
+
},
|
523
|
+
mm: function( string, dateObject ) {
|
524
|
+
|
525
|
+
// If there's a string, then the length is always 2.
|
526
|
+
// Otherwise return the selected month with 0index and leading zero.
|
527
|
+
return string ? 2 : Picker._.lead( dateObject.month + 1 )
|
528
|
+
},
|
529
|
+
mmm: function( string, dateObject ) {
|
530
|
+
|
531
|
+
var collection = this.settings.monthsShort
|
532
|
+
|
533
|
+
// If there's a string, get length of the relevant month from the short
|
534
|
+
// months collection. Otherwise return the selected month from that collection.
|
535
|
+
return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
|
536
|
+
},
|
537
|
+
mmmm: function( string, dateObject ) {
|
538
|
+
|
539
|
+
var collection = this.settings.monthsFull
|
540
|
+
|
541
|
+
// If there's a string, get length of the relevant month from the full
|
542
|
+
// months collection. Otherwise return the selected month from that collection.
|
543
|
+
return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
|
544
|
+
},
|
545
|
+
yy: function( string, dateObject ) {
|
546
|
+
|
547
|
+
// If there's a string, then the length is always 2.
|
548
|
+
// Otherwise return the selected year by slicing out the first 2 digits.
|
549
|
+
return string ? 2 : ( '' + dateObject.year ).slice( 2 )
|
550
|
+
},
|
551
|
+
yyyy: function( string, dateObject ) {
|
552
|
+
|
553
|
+
// If there's a string, then the length is always 4.
|
554
|
+
// Otherwise return the selected year.
|
555
|
+
return string ? 4 : dateObject.year
|
556
|
+
},
|
557
|
+
|
558
|
+
// Create an array by splitting the formatting string passed.
|
559
|
+
toArray: function( formatString ) { return formatString.split( /(d{1,4}|m{1,4}|y{4}|yy|!.)/g ) },
|
560
|
+
|
561
|
+
// Format an object into a string using the formatting options.
|
562
|
+
toString: function ( formatString, itemObject ) {
|
563
|
+
var calendar = this
|
564
|
+
return calendar.formats.toArray( formatString ).map( function( label ) {
|
565
|
+
return Picker._.trigger( calendar.formats[ label ], calendar, [ 0, itemObject ] ) || label.replace( /^!/, '' )
|
566
|
+
}).join( '' )
|
567
|
+
}
|
568
|
+
}
|
569
|
+
})() //DatePicker.prototype.formats
|
570
|
+
|
571
|
+
|
572
|
+
/**
|
573
|
+
* Flip an item as enabled or disabled.
|
574
|
+
*/
|
575
|
+
DatePicker.prototype.flipItem = function( type, value/*, options*/ ) {
|
576
|
+
|
577
|
+
var calendar = this,
|
578
|
+
collection = calendar.item.disable,
|
579
|
+
isInverted = calendar.item.enable === -1
|
580
|
+
|
581
|
+
// Flip the enabled and disabled dates.
|
582
|
+
if ( value == 'flip' ) {
|
583
|
+
calendar.item.enable = isInverted ? 1 : -1
|
584
|
+
}
|
585
|
+
|
586
|
+
// Check if we have to add/remove from collection.
|
587
|
+
else if ( !isInverted && type == 'enable' || isInverted && type == 'disable' ) {
|
588
|
+
collection = calendar.removeDisabled( collection, value )
|
589
|
+
}
|
590
|
+
else if ( !isInverted && type == 'disable' || isInverted && type == 'enable' ) {
|
591
|
+
collection = calendar.addDisabled( collection, value )
|
592
|
+
}
|
593
|
+
|
594
|
+
return collection
|
595
|
+
} //DatePicker.prototype.flipItem
|
596
|
+
|
597
|
+
|
598
|
+
/**
|
599
|
+
* Add an item to the disabled collection.
|
600
|
+
*/
|
601
|
+
DatePicker.prototype.addDisabled = function( collection, item ) {
|
602
|
+
var calendar = this
|
603
|
+
item.map( function( timeUnit ) {
|
604
|
+
if ( !calendar.filterDisabled( collection, timeUnit ).length ) {
|
605
|
+
collection.push( timeUnit )
|
606
|
+
}
|
607
|
+
})
|
608
|
+
return collection
|
609
|
+
} //DatePicker.prototype.addDisabled
|
610
|
+
|
611
|
+
|
612
|
+
/**
|
613
|
+
* Remove an item from the disabled collection.
|
614
|
+
*/
|
615
|
+
DatePicker.prototype.removeDisabled = function( collection, item ) {
|
616
|
+
var calendar = this
|
617
|
+
item.map( function( timeUnit ) {
|
618
|
+
collection = calendar.filterDisabled( collection, timeUnit, 1 )
|
619
|
+
})
|
620
|
+
return collection
|
621
|
+
} //DatePicker.prototype.removeDisabled
|
622
|
+
|
623
|
+
|
624
|
+
/**
|
625
|
+
* Filter through the disabled collection to find a time unit.
|
626
|
+
*/
|
627
|
+
DatePicker.prototype.filterDisabled = function( collection, timeUnit, isRemoving ) {
|
628
|
+
var timeIsArray = Array.isArray( timeUnit )
|
629
|
+
return collection.filter( function( disabledTimeUnit ) {
|
630
|
+
var isMatch = !timeIsArray && timeUnit === disabledTimeUnit ||
|
631
|
+
timeIsArray && Array.isArray( disabledTimeUnit ) && timeUnit.toString() === disabledTimeUnit.toString()
|
632
|
+
return isRemoving ? !isMatch : isMatch
|
633
|
+
})
|
634
|
+
} //DatePicker.prototype.filterDisabled
|
635
|
+
|
636
|
+
|
637
|
+
/**
|
638
|
+
* Create a string for the nodes in the picker.
|
639
|
+
*/
|
640
|
+
DatePicker.prototype.nodes = function( isOpen ) {
|
641
|
+
|
642
|
+
var
|
643
|
+
calendar = this,
|
644
|
+
settings = calendar.settings,
|
645
|
+
nowObject = calendar.item.now,
|
646
|
+
selectedObject = calendar.item.select,
|
647
|
+
highlightedObject = calendar.item.highlight,
|
648
|
+
viewsetObject = calendar.item.view,
|
649
|
+
disabledCollection = calendar.item.disable,
|
650
|
+
minLimitObject = calendar.item.min,
|
651
|
+
maxLimitObject = calendar.item.max,
|
652
|
+
|
653
|
+
|
654
|
+
// Create the calendar table head using a copy of weekday labels collection.
|
655
|
+
// * We do a copy so we don't mutate the original array.
|
656
|
+
tableHead = (function( collection ) {
|
657
|
+
|
658
|
+
// If the first day should be Monday, move Sunday to the end.
|
659
|
+
if ( settings.firstDay ) {
|
660
|
+
collection.push( collection.shift() )
|
661
|
+
}
|
662
|
+
|
663
|
+
// Create and return the table head group.
|
664
|
+
return Picker._.node(
|
665
|
+
'thead',
|
666
|
+
Picker._.group({
|
667
|
+
min: 0,
|
668
|
+
max: DAYS_IN_WEEK - 1,
|
669
|
+
i: 1,
|
670
|
+
node: 'th',
|
671
|
+
item: function( counter ) {
|
672
|
+
return [
|
673
|
+
collection[ counter ],
|
674
|
+
settings.klass.weekdays
|
675
|
+
]
|
676
|
+
}
|
677
|
+
})
|
678
|
+
) //endreturn
|
679
|
+
})( ( settings.showWeekdaysFull ? settings.weekdaysFull : settings.weekdaysShort ).slice( 0 ) ), //tableHead
|
680
|
+
|
681
|
+
|
682
|
+
// Create the nav for next/prev month.
|
683
|
+
createMonthNav = function( next ) {
|
684
|
+
|
685
|
+
// Otherwise, return the created month tag.
|
686
|
+
return Picker._.node(
|
687
|
+
'div',
|
688
|
+
' ',
|
689
|
+
settings.klass[ 'nav' + ( next ? 'Next' : 'Prev' ) ] + (
|
690
|
+
|
691
|
+
// If the focused month is outside the range, disabled the button.
|
692
|
+
( next && viewsetObject.year >= maxLimitObject.year && viewsetObject.month >= maxLimitObject.month ) ||
|
693
|
+
( !next && viewsetObject.year <= minLimitObject.year && viewsetObject.month <= minLimitObject.month ) ?
|
694
|
+
' ' + settings.klass.navDisabled : ''
|
695
|
+
),
|
696
|
+
'data-nav=' + ( next || -1 )
|
697
|
+
) //endreturn
|
698
|
+
}, //createMonthNav
|
699
|
+
|
700
|
+
|
701
|
+
// Create the month label.
|
702
|
+
createMonthLabel = function( monthsCollection ) {
|
703
|
+
|
704
|
+
// If there are months to select, add a dropdown menu.
|
705
|
+
if ( settings.selectMonths ) {
|
706
|
+
|
707
|
+
return Picker._.node( 'select', Picker._.group({
|
708
|
+
min: 0,
|
709
|
+
max: 11,
|
710
|
+
i: 1,
|
711
|
+
node: 'option',
|
712
|
+
item: function( loopedMonth ) {
|
713
|
+
|
714
|
+
return [
|
715
|
+
|
716
|
+
// The looped month and no classes.
|
717
|
+
monthsCollection[ loopedMonth ], 0,
|
718
|
+
|
719
|
+
// Set the value and selected index.
|
720
|
+
'value=' + loopedMonth +
|
721
|
+
( viewsetObject.month == loopedMonth ? ' selected' : '' ) +
|
722
|
+
(
|
723
|
+
(
|
724
|
+
( viewsetObject.year == minLimitObject.year && loopedMonth < minLimitObject.month ) ||
|
725
|
+
( viewsetObject.year == maxLimitObject.year && loopedMonth > maxLimitObject.month )
|
726
|
+
) ?
|
727
|
+
' disabled' : ''
|
728
|
+
)
|
729
|
+
]
|
730
|
+
}
|
731
|
+
}), settings.klass.selectMonth, isOpen ? '' : 'disabled' )
|
732
|
+
}
|
733
|
+
|
734
|
+
// If there's a need for a month selector
|
735
|
+
return Picker._.node( 'div', monthsCollection[ viewsetObject.month ], settings.klass.month )
|
736
|
+
}, //createMonthLabel
|
737
|
+
|
738
|
+
|
739
|
+
// Create the year label.
|
740
|
+
createYearLabel = function() {
|
741
|
+
|
742
|
+
var focusedYear = viewsetObject.year,
|
743
|
+
|
744
|
+
// If years selector is set to a literal "true", set it to 5. Otherwise
|
745
|
+
// divide in half to get half before and half after focused year.
|
746
|
+
numberYears = settings.selectYears === true ? 5 : ~~( settings.selectYears / 2 )
|
747
|
+
|
748
|
+
// If there are years to select, add a dropdown menu.
|
749
|
+
if ( numberYears ) {
|
750
|
+
|
751
|
+
var
|
752
|
+
minYear = minLimitObject.year,
|
753
|
+
maxYear = maxLimitObject.year,
|
754
|
+
lowestYear = focusedYear - numberYears,
|
755
|
+
highestYear = focusedYear + numberYears
|
756
|
+
|
757
|
+
// If the min year is greater than the lowest year, increase the highest year
|
758
|
+
// by the difference and set the lowest year to the min year.
|
759
|
+
if ( minYear > lowestYear ) {
|
760
|
+
highestYear += minYear - lowestYear
|
761
|
+
lowestYear = minYear
|
762
|
+
}
|
763
|
+
|
764
|
+
// If the max year is less than the highest year, decrease the lowest year
|
765
|
+
// by the lower of the two: available and needed years. Then set the
|
766
|
+
// highest year to the max year.
|
767
|
+
if ( maxYear < highestYear ) {
|
768
|
+
|
769
|
+
var availableYears = lowestYear - minYear,
|
770
|
+
neededYears = highestYear - maxYear
|
771
|
+
|
772
|
+
lowestYear -= availableYears > neededYears ? neededYears : availableYears
|
773
|
+
highestYear = maxYear
|
774
|
+
}
|
775
|
+
|
776
|
+
return Picker._.node( 'select', Picker._.group({
|
777
|
+
min: lowestYear,
|
778
|
+
max: highestYear,
|
779
|
+
i: 1,
|
780
|
+
node: 'option',
|
781
|
+
item: function( loopedYear ) {
|
782
|
+
return [
|
783
|
+
|
784
|
+
// The looped year and no classes.
|
785
|
+
loopedYear, 0,
|
786
|
+
|
787
|
+
// Set the value and selected index.
|
788
|
+
'value=' + loopedYear + ( focusedYear == loopedYear ? ' selected' : '' )
|
789
|
+
]
|
790
|
+
}
|
791
|
+
}), settings.klass.selectYear, isOpen ? '' : 'disabled' )
|
792
|
+
}
|
793
|
+
|
794
|
+
// Otherwise just return the year focused
|
795
|
+
return Picker._.node( 'div', focusedYear, settings.klass.year )
|
796
|
+
} //createYearLabel
|
797
|
+
|
798
|
+
|
799
|
+
// Create and return the entire calendar.
|
800
|
+
return Picker._.node(
|
801
|
+
'div',
|
802
|
+
createMonthNav() + createMonthNav( 1 ) +
|
803
|
+
createMonthLabel( settings.showMonthsShort ? settings.monthsShort : settings.monthsFull ) +
|
804
|
+
createYearLabel(),
|
805
|
+
settings.klass.header
|
806
|
+
) + Picker._.node(
|
807
|
+
'table',
|
808
|
+
tableHead +
|
809
|
+
Picker._.node(
|
810
|
+
'tbody',
|
811
|
+
Picker._.group({
|
812
|
+
min: 0,
|
813
|
+
max: WEEKS_IN_CALENDAR - 1,
|
814
|
+
i: 1,
|
815
|
+
node: 'tr',
|
816
|
+
item: function( rowCounter ) {
|
817
|
+
|
818
|
+
// If Monday is the first day and the month starts on Sunday, shift the date back a week.
|
819
|
+
var shiftDateBy = settings.firstDay && calendar.create([ viewsetObject.year, viewsetObject.month, 1 ]).day === 0 ? -7 : 0
|
820
|
+
|
821
|
+
return [
|
822
|
+
Picker._.group({
|
823
|
+
min: DAYS_IN_WEEK * rowCounter - viewsetObject.day + shiftDateBy + 1, // Add 1 for weekday 0index
|
824
|
+
max: function() {
|
825
|
+
return this.min + DAYS_IN_WEEK - 1
|
826
|
+
},
|
827
|
+
i: 1,
|
828
|
+
node: 'td',
|
829
|
+
item: function( targetDate ) {
|
830
|
+
|
831
|
+
// Convert the time date from a relative date to a target date.
|
832
|
+
targetDate = calendar.create([ viewsetObject.year, viewsetObject.month, targetDate + ( settings.firstDay ? 1 : 0 ) ])
|
833
|
+
|
834
|
+
return [
|
835
|
+
Picker._.node(
|
836
|
+
'div',
|
837
|
+
targetDate.date,
|
838
|
+
(function( klasses ) {
|
839
|
+
|
840
|
+
// Add the `infocus` or `outfocus` classes based on month in view.
|
841
|
+
klasses.push( viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus )
|
842
|
+
|
843
|
+
// Add the `today` class if needed.
|
844
|
+
if ( nowObject.pick == targetDate.pick ) {
|
845
|
+
klasses.push( settings.klass.now )
|
846
|
+
}
|
847
|
+
|
848
|
+
// Add the `selected` class if something's selected and the time matches.
|
849
|
+
if ( selectedObject && selectedObject.pick == targetDate.pick ) {
|
850
|
+
klasses.push( settings.klass.selected )
|
851
|
+
}
|
852
|
+
|
853
|
+
// Add the `highlighted` class if something's highlighted and the time matches.
|
854
|
+
if ( highlightedObject && highlightedObject.pick == targetDate.pick ) {
|
855
|
+
klasses.push( settings.klass.highlighted )
|
856
|
+
}
|
857
|
+
|
858
|
+
// Add the `disabled` class if something's disabled and the object matches.
|
859
|
+
if ( disabledCollection && calendar.disabled( targetDate ) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick ) {
|
860
|
+
klasses.push( settings.klass.disabled )
|
861
|
+
}
|
862
|
+
|
863
|
+
return klasses.join( ' ' )
|
864
|
+
})([ settings.klass.day ]),
|
865
|
+
'data-pick=' + targetDate.pick
|
866
|
+
)
|
867
|
+
] //endreturn
|
868
|
+
}
|
869
|
+
})
|
870
|
+
] //endreturn
|
871
|
+
}
|
872
|
+
})
|
873
|
+
),
|
874
|
+
settings.klass.table
|
875
|
+
) +
|
876
|
+
|
877
|
+
Picker._.node(
|
878
|
+
'div',
|
879
|
+
Picker._.node( 'button', settings.today, settings.klass.buttonToday, 'data-pick=' + nowObject.pick + ( isOpen ? '' : ' disabled' ) ) +
|
880
|
+
Picker._.node( 'button', settings.clear, settings.klass.buttonClear, 'data-clear=1' + ( isOpen ? '' : ' disabled' ) ),
|
881
|
+
settings.klass.footer
|
882
|
+
) //endreturn
|
883
|
+
} //DatePicker.prototype.nodes
|
884
|
+
|
885
|
+
|
886
|
+
|
887
|
+
|
888
|
+
/**
|
889
|
+
* The date picker defaults.
|
890
|
+
*/
|
891
|
+
DatePicker.defaults = (function( prefix ) {
|
892
|
+
|
893
|
+
return {
|
894
|
+
|
895
|
+
// Months and weekdays
|
896
|
+
monthsFull: [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ],
|
897
|
+
monthsShort: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
|
898
|
+
weekdaysFull: [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
|
899
|
+
weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
|
900
|
+
|
901
|
+
// Today and clear
|
902
|
+
today: 'Today',
|
903
|
+
clear: 'Clear',
|
904
|
+
|
905
|
+
// The format to show on the `input` element
|
906
|
+
format: 'd mmmm, yyyy',
|
907
|
+
|
908
|
+
// Classes
|
909
|
+
klass: {
|
910
|
+
|
911
|
+
table: prefix + 'table',
|
912
|
+
|
913
|
+
header: prefix + 'header',
|
914
|
+
|
915
|
+
navPrev: prefix + 'nav--prev',
|
916
|
+
navNext: prefix + 'nav--next',
|
917
|
+
navDisabled: prefix + 'nav--disabled',
|
918
|
+
|
919
|
+
month: prefix + 'month',
|
920
|
+
year: prefix + 'year',
|
921
|
+
|
922
|
+
selectMonth: prefix + 'select--month',
|
923
|
+
selectYear: prefix + 'select--year',
|
924
|
+
|
925
|
+
weekdays: prefix + 'weekday',
|
926
|
+
|
927
|
+
day: prefix + 'day',
|
928
|
+
disabled: prefix + 'day--disabled',
|
929
|
+
selected: prefix + 'day--selected',
|
930
|
+
highlighted: prefix + 'day--highlighted',
|
931
|
+
now: prefix + 'day--today',
|
932
|
+
infocus: prefix + 'day--infocus',
|
933
|
+
outfocus: prefix + 'day--outfocus',
|
934
|
+
|
935
|
+
footer: prefix + 'footer',
|
936
|
+
|
937
|
+
buttonClear: prefix + 'button--clear',
|
938
|
+
buttonToday: prefix + 'button--today'
|
939
|
+
}
|
940
|
+
}
|
941
|
+
})( Picker.klasses().picker + '__' )
|
942
|
+
|
943
|
+
|
944
|
+
|
945
|
+
|
946
|
+
|
947
|
+
/**
|
948
|
+
* Extend the picker to add the date picker.
|
949
|
+
*/
|
950
|
+
Picker.extend( 'pickadate', DatePicker )
|
951
|
+
|
952
|
+
|
953
|
+
// Close the scope.
|
954
|
+
})();
|
955
|
+
|
956
|
+
|
957
|
+
|