475 lines
47 KiB
JavaScript
475 lines
47 KiB
JavaScript
/*
|
|
The following errors were found when attempting to minify this file:
|
|
- Line 27: Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set the appropriate language_in option.
|
|
- Line 300: Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set the appropriate language_in option.
|
|
- Line 410: Parse error. syntax error
|
|
- Line 415: Parse error. illegal character
|
|
- Line 415: Parse error. missing } in compound statement
|
|
- Line 415: Parse error. missing ; before statement
|
|
- Line 415: Parse error. illegal character
|
|
- Line 416: Parse error. syntax error
|
|
- Line 418: Parse error. missing ) in parenthetical
|
|
- Line 419: Parse error. syntax error
|
|
- Line 424: Parse error. illegal character
|
|
- Line 424: Parse error. missing } in compound statement
|
|
- Line 424: Parse error. missing ; before statement
|
|
- Line 424: Parse error. illegal character
|
|
- Line 426: Parse error. syntax error
|
|
- Line 428: Parse error. invalid return
|
|
- Line 428: Parse error. syntax error
|
|
- Line 433: Parse error. invalid return
|
|
- Line 433: Parse error. illegal character
|
|
- Line 433: Parse error. missing } in compound statement
|
|
- Line 433: Parse error. missing ; before statement
|
|
- Line 433: Parse error. illegal character
|
|
- Line 434: Parse error. syntax error
|
|
- Line 435: Parse error. syntax error
|
|
- Line 437: Parse error. invalid return
|
|
- Line 439: Parse error. syntax error
|
|
- Line 440: Parse error. syntax error
|
|
- Line 441: Parse error. syntax error
|
|
*/
|
|
/*!
|
|
* pickadate.js v3.6.4, 2019/05/25
|
|
* By Amsul, http://amsul.ca
|
|
* Hosted on http://amsul.github.io/pickadate.js
|
|
* Licensed under MIT
|
|
*/
|
|
(function(n){typeof define=="function"&&define.amd?define("picker",["jquery"],n):typeof exports=="object"?module.exports=n(require("jquery")):typeof window=="object"?window.Picker=n(jQuery):this.Picker=n(jQuery)})(function(n){function t(e,s,h,a){function g(){return t._.node("div",t._.node("div",t._.node("div",t._.node("div",v.component.nodes(y.open),w.box),w.wrap),w.frame),w.holder,'tabindex="-1"')}function rt(){b.data(s,v).addClass(w.input).val(b.data("value")?v.get("select",p.format):e.value).on("focus."+y.id+" click."+y.id,function(n){n.preventDefault();v.open()}).on("mousedown",function(){y.handlingOpen=!0;var t=function(){setTimeout(function(){n(document).off("mouseup",t);y.handlingOpen=!1},0)};n(document).on("mouseup",t)});if(!p.editable)b.on("keydown."+y.id,it);i(e,{haspopup:!0,readonly:!1,owns:e.id+"_root"})}function ut(){i(v.$root[0],"hidden",!0)}function nt(){v.$holder.on({keydown:it,"focus.toOpen":tt,blur:function(){b.removeClass(w.target)},focusin:function(n){v.$root.removeClass(w.focused);n.stopPropagation()},"mousedown click":function(t){var i=r(t,e);i!=v.$holder[0]&&(t.stopPropagation(),t.type!="mousedown"||n(i).is("input, select, textarea, button, option")||(t.preventDefault(),v.$holder.eq(0).focus()))}}).on("click","[data-pick], [data-nav], [data-clear], [data-close]",function(){var r=n(this),i=r.data(),u=r.hasClass(w.navDisabled)||r.hasClass(w.disabled),t=o();t=t&&(t.type||t.href?t:null);(u||t&&!n.contains(v.$root[0],t))&&v.$holder.eq(0).focus();!u&&i.nav?v.set("highlight",v.component.item.highlight,{nav:i.nav}):!u&&"pick"in i?(v.set("select",i.pick),p.closeOnSelect&&v.close(!0)):i.clear?(v.clear(),p.closeOnClear&&v.close(!0)):i.close&&v.close(!0)})}function ft(){var t;p.hiddenName===!0?(t=e.name,e.name=""):(t=[typeof p.hiddenPrefix=="string"?p.hiddenPrefix:"",typeof p.hiddenSuffix=="string"?p.hiddenSuffix:"_submit"],t=t[0]+e.name+t[1]);v._hidden=n('<input type=hidden name="'+t+'"'+(b.data("value")||e.value?' value="'+v.get("select",p.formatSubmit)+'"':"")+">")[0];b.on("change."+y.id,function(){v._hidden.value=e.value?v.get("select",p.formatSubmit):""})}function et(){if(k&&c)v.$holder.find("."+w.frame).one("transitionend",function(){v.$holder.eq(0).focus()});else setTimeout(function(){v.$holder.eq(0).focus()},0)}function tt(n){n.stopPropagation();b.addClass(w.target);v.$root.addClass(w.focused);v.open()}function it(n){var t=n.keyCode,i=/^(8|46)$/.test(t);if(t==27)return v.close(!0),!1;(t==32||i||!y.open&&v.component.key[t])&&(n.preventDefault(),n.stopPropagation(),i?v.clear().close():v.open())}if(!e)return t;var k=!1,y={id:e.id||"P"+Math.abs(~~(Math.random()*new Date)),handlingOpen:!1},p=h?n.extend(!0,{},h.defaults,a):a||{},w=n.extend({},t.klasses(),p.klass),b=n(e),d=function(){return this.start()},v=d.prototype={constructor:d,$node:b,start:function(){if(y&&y.start)return v;y.methods={};y.start=!0;y.open=!1;y.type=e.type;e.autofocus=e==o();e.readOnly=!p.editable;p.id=e.id=e.id||y.id;e.type!="text"&&(e.type="text");v.component=new h(v,p);v.$root=n('<div class="'+w.picker+'" id="'+e.id+'_root" />');ut();v.$holder=n(g()).appendTo(v.$root);nt();p.formatSubmit&&ft();rt();p.containerHidden?n(p.containerHidden).append(v._hidden):b.after(v._hidden);p.container?n(p.container).append(v.$root):b.after(v.$root);v.on({start:v.component.onStart,render:v.component.onRender,stop:v.component.onStop,open:v.component.onOpen,close:v.component.onClose,set:v.component.onSet}).on({start:p.onStart,render:p.onRender,stop:p.onStop,open:p.onOpen,close:p.onClose,set:p.onSet});return k=l(v.$holder[0]),e.autofocus&&v.open(),v.trigger("start").trigger("render")},render:function(t){return t?(v.$holder=n(g()),nt(),v.$root.html(v.$holder)):v.$root.find("."+w.box).html(v.component.nodes(y.open)),v.trigger("render")},stop:function(){return y.start?(v.close(),v._hidden&&v._hidden.parentNode.removeChild(v._hidden),v.$root.remove(),b.removeClass(w.input).removeData(s),setTimeout(function(){b.off("."+y.id)},0),e.type=y.type,e.readOnly=!1,v.trigger("stop"),y.methods={},y.start=!1,v):v},open:function(o){if(y.open)return v;if(b.addClass(w.active),setTimeout(function(){v.$root.addClass(w.opened);i(v.$root[0],"hidden",!1)},0),o!==!1){y.open=!0;k&&n("body").css("overflow","hidden").css("padding-right","+="+f());et();u.on("click."+y.id+" focusin."+y.id,function(n){if(!y.handlingOpen){var t=r(n,e);n.isSimulated||t==e||t==document||n.which==3||v.close(t===v.$holder[0])}}).on("keydown."+y.id,function(i){var u=i.keyCode,f=v.component.key[u],o=r(i,e);u==27?v.close(!0):o==v.$holder[0]&&(f||u==13)?(i.preventDefault(),f?t._.trigger(v.component.key.go,v,[t._.trigger(f)]):v.$root.find("."+w.highlighted).hasClass(w.disabled)||(v.set("select",v.component.item.highlight),p.closeOnSelect&&v.close(!0))):n.contains(v.$root[0],o)&&u==13&&(i.preventDefault(),o.click())})}return v.trigger("open")},close:function(t){return(t&&(p.editable?e.focus():(v.$holder.off("focus.toOpen").focus(),setTimeout(function(){v.$holder.on("focus.toOpen",tt)},0))),b.removeClass(w.active),setTimeout(function(){v.$root.removeClass(w.opened+" "+w.focused);i(v.$root[0],"hidden",!0)},0),!y.open)?v:(y.open=!1,k&&n("body").css("overflow","").css("padding-right","-="+f()),u.off("."+y.id),v.trigger("close"))},clear:function(n){return v.set("clear",null,n)},set:function(t,i,r){var u,f,o=n.isPlainObject(t),e=o?t:{};if(r=o&&n.isPlainObject(i)?i:r||{},t){o||(e[t]=i);for(u in e)f=e[u],u in v.component.item&&(f===undefined&&(f=null),v.component.set(u,f,r)),(u=="select"||u=="clear")&&p.updateInput&&b.val(u=="clear"?"":v.get(u,p.format)).trigger("change");v.render()}return r.muted?v:v.trigger("set",e)},get:function(n,i){if(n=n||"value",y[n]!=null)return y[n];if(n=="valueSubmit"){if(v._hidden)return v._hidden.value;n="value"}if(n=="value")return e.value;if(n in v.component.item){if(typeof i=="string"){var r=v.component.get(n);return r?t._.trigger(v.component.formats.toString,v.component,[i,r]):""}return v.component.get(n)}},on:function(t,i,r){var u,e,o=n.isPlainObject(t),f=o?t:{};if(t){o||(f[t]=i);for(u in f)e=f[u],r&&(u="_"+u),y.methods[u]=y.methods[u]||[],y.methods[u].push(e)}return v},off:function(){var n,t,i=arguments;for(n=0,namesCount=i.length;n<namesCount;n+=1)t=i[n],t in y.methods&&delete y.methods[t];return v},trigger:function(n,i){var r=function(n){var r=y.methods[n];r&&r.map(function(n){t._.trigger(n,v,[i])})};return r("_"+n),r(n),v}};return new d}function l(n){var t,i="position";return n.currentStyle?t=n.currentStyle[i]:window.getComputedStyle&&(t=getComputedStyle(n)[i]),t=="fixed"}function f(){var t,i,r,u;return h.height()<=s.height()?0:(t=n('<div style="visibility:hidden;width:100px" />').appendTo("body"),i=t[0].offsetWidth,t.css("overflow","scroll"),r=n('<div style="width:100%" />').appendTo(t),u=r[0].offsetWidth,t.remove(),i-u)}function r(n,t){var i=[];return(n.path&&(i=n.path),n.originalEvent&&n.originalEvent.path&&(i=n.originalEvent.path),i&&i.length>0)?t&&i.indexOf(t)>=0?t:i[0]:n.target}function i(t,i,r){if(n.isPlainObject(i))for(var u in i)e(t,u,i[u]);else e(t,i,r)}function e(n,t,i){n.setAttribute((t=="role"?"":"aria-")+t,i)}function a(t,i){var r,u,f;n.isPlainObject(t)||(t={attribute:i});i="";for(r in t)u=(r=="role"?"":"aria-")+r,f=t[r],i+=f==null?"":u+'="'+t[r]+'"';return i}function o(){try{return document.activeElement}catch(n){}}var s=n(window),u=n(document),h=n(document.documentElement),c=document.documentElement.style.transition!=null;return t.klasses=function(n){return n=n||"picker",{picker:n,opened:n+"--opened",focused:n+"--focused",input:n+"__input",active:n+"__input--active",target:n+"__input--target",holder:n+"__holder",frame:n+"__frame",wrap:n+"__wrap",box:n+"__box"}},t._={group:function(n){for(var i,u="",r=t._.trigger(n.min,n);r<=t._.trigger(n.max,n,[r]);r+=n.i)i=t._.trigger(n.item,n,[r]),u+=t._.node(n.node,i[0],i[1],i[2]);return u},node:function(t,i,r,u){return i?(i=n.isArray(i)?i.join(""):i,r=r?' class="'+r+'"':"",u=u?" "+u:"","<"+t+r+u+">"+i+"<\/"+t+">"):""},lead:function(n){return(n<10?"0":"")+n},trigger:function(n,t,i){return typeof n=="function"?n.apply(t,i||[]):n},digits:function(n){return/\d/.test(n[1])?2:1},isDate:function(n){return{}.toString.call(n).indexOf("Date")>-1&&this.isInteger(n.getDate())},isInteger:function(n){return{}.toString.call(n).indexOf("Number")>-1&&n%1==0},ariaAttr:a},t.extend=function(i,r){n.fn[i]=function(u,f){var e=this.data(i);return u=="picker"?e:e&&typeof u=="string"?t._.trigger(e[u],e,[f]):this.each(function(){var f=n(this);f.data(i)||new t(this,i,r,u)})};n.fn[i].defaults=r.defaults},t});
|
|
/*!
|
|
* Date picker for pickadate.js v3.6.4
|
|
* http://amsul.github.io/pickadate.js/date.htm
|
|
*/
|
|
(function(n){typeof define=="function"&&define.amd?define(["./picker","jquery"],n):typeof exports=="object"?module.exports=n(require("./picker.js"),require("jquery")):n(Picker,jQuery)})(function(n,t){function r(n,t){var i=this,r=n.$node[0],o=r.value,u=n.$node.data("value"),f=u||o,s=u?t.formatSubmit:t.format,e=function(){return r.currentStyle?r.currentStyle.direction=="rtl":getComputedStyle(n.$root[0]).direction=="rtl"};i.settings=t;i.$node=n.$node;i.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"};i.item={};i.item.clear=null;i.item.disable=(t.disable||[]).slice(0);i.item.enable=-function(n){return n[0]===!0?n.shift():-1}(i.item.disable);i.set("min",t.min).set("max",t.max).set("now");f?i.set("select",f,{format:s,defaultValue:!0}):i.set("select",null).set("highlight",i.item.now);i.key={40:7,38:-7,39:function(){return e()?-1:1},37:function(){return e()?1:-1},go:function(n){var t=i.item.highlight,r=new Date(t.year,t.month,t.date+n);i.set("highlight",r,{interval:n});this.render()}};n.on("render",function(){n.$root.find("."+t.klass.selectMonth).on("change",function(){var i=this.value;i&&(n.set("highlight",[n.get("view").year,i,n.get("highlight").date]),n.$root.find("."+t.klass.selectMonth).trigger("focus"))});n.$root.find("."+t.klass.selectYear).on("change",function(){var i=this.value;i&&(n.set("highlight",[i,n.get("view").month,n.get("highlight").date]),n.$root.find("."+t.klass.selectYear).trigger("focus"))})},1).on("open",function(){var r="";i.disabled(i.get("now"))&&(r=":not(."+t.klass.buttonToday+")");n.$root.find("button"+r+", select").attr("disabled",!1)},1).on("close",function(){n.$root.find("button, select").attr("disabled",!0)},1)}var u=7,f=6,i=n._;r.prototype.set=function(n,t,i){var r=this,u=r.item;return t===null?(n=="clear"&&(n="select"),u[n]=t,r):(u[n=="enable"?"disable":n=="flip"?"enable":n]=r.queue[n].split(" ").map(function(u){return t=r[u](n,t,i)}).pop(),n=="select"?r.set("highlight",u.select,i):n=="highlight"?r.set("view",u.highlight,i):n.match(/^(flip|min|max|disable|enable)$/)&&(u.select&&r.disabled(u.select)&&r.set("select",u.select,i),u.highlight&&r.disabled(u.highlight)&&r.set("highlight",u.highlight,i)),r)};r.prototype.get=function(n){return this.item[n]};r.prototype.create=function(n,r,u){var f,e=this;return r=r===undefined?n:r,r==-Infinity||r==Infinity?f=r:t.isPlainObject(r)&&i.isInteger(r.pick)?r=r.obj:t.isArray(r)?(r=new Date(r[0],r[1],r[2]),r=i.isDate(r)?r:e.create().obj):r=i.isInteger(r)||i.isDate(r)?e.normalize(new Date(r),u):e.now(n,r,u),{year:f||r.getFullYear(),month:f||r.getMonth(),date:f||r.getDate(),day:f||r.getDay(),obj:f||r,pick:f||r.getTime()}};r.prototype.createRange=function(n,r){var f=this,u=function(n){return n===!0||t.isArray(n)||i.isDate(n)?f.create(n):n};return i.isInteger(n)||(n=u(n)),i.isInteger(r)||(r=u(r)),i.isInteger(n)&&t.isPlainObject(r)?n=[r.year,r.month,r.date+n]:i.isInteger(r)&&t.isPlainObject(n)&&(r=[n.year,n.month,n.date+r]),{from:u(n),to:u(r)}};r.prototype.withinRange=function(n,t){return n=this.createRange(n.from,n.to),t.pick>=n.from.pick&&t.pick<=n.to.pick};r.prototype.overlapRanges=function(n,t){var i=this;return n=i.createRange(n.from,n.to),t=i.createRange(t.from,t.to),i.withinRange(n,t.from)||i.withinRange(n,t.to)||i.withinRange(t,n.from)||i.withinRange(t,n.to)};r.prototype.now=function(n,t,i){return t=new Date,i&&i.rel&&t.setDate(t.getDate()+i.rel),this.normalize(t,i)};r.prototype.navigate=function(n,i,r){var s,f,u,e,c=t.isArray(i),h=t.isPlainObject(i),o=this.item.view;if(c||h){for(h?(f=i.year,u=i.month,e=i.date):(f=+i[0],u=+i[1],e=+i[2]),r&&r.nav&&o&&o.month!==u&&(f=o.year,u=o.month),s=new Date(f,u+(r&&r.nav?r.nav:0),1),f=s.getFullYear(),u=s.getMonth();new Date(f,u,e).getMonth()!==u;)e-=1;i=[f,u,e]}return i};r.prototype.normalize=function(n){return n.setHours(0,0,0,0),n};r.prototype.measure=function(n,t){var r=this;return i.isInteger(t)?t=r.now(n,t,{rel:t}):t?typeof t=="string"&&(t=r.parse(n,t)):t=n=="min"?-Infinity:Infinity,t};r.prototype.viewset=function(n,t){return this.create([t.year,t.month,1])};r.prototype.validate=function(n,r,u){var f=this,c=r,e=u&&u.interval?u.interval:1,h=f.item.enable===-1,l,a,o=f.item.min,s=f.item.max,v,y,p=h&&f.item.disable.filter(function(n){if(t.isArray(n)){var u=f.create(n).pick;u<r.pick?l=!0:u>r.pick&&(a=!0)}return i.isInteger(n)}).length;if((!u||!u.nav&&!u.defaultValue)&&(!h&&f.disabled(r)||h&&f.disabled(r)&&(p||l||a)||!h&&(r.pick<=o.pick||r.pick>=s.pick)))for(h&&!p&&(!a&&e>0||!l&&e<0)&&(e*=-1);f.disabled(r);){if(Math.abs(e)>1&&(r.month<c.month||r.month>c.month)&&(r=c,e=e>0?1:-1),r.pick<=o.pick?(v=!0,e=1,r=f.create([o.year,o.month,o.date+(r.pick===o.pick?0:-1)])):r.pick>=s.pick&&(y=!0,e=-1,r=f.create([s.year,s.month,s.date+(r.pick===s.pick?0:1)])),v&&y)break;r=f.create([r.year,r.month,r.date+e])}return r};r.prototype.disabled=function(n){var r=this,u=r.item.disable.filter(function(u){return i.isInteger(u)?n.day===(r.settings.firstDay?u:u-1)%7:t.isArray(u)||i.isDate(u)?n.pick===r.create(u).pick:t.isPlainObject(u)?r.withinRange(u,n):void 0});return u=u.length&&!u.filter(function(n){return t.isArray(n)&&n[3]=="inverted"||t.isPlainObject(n)&&n.inverted}).length,r.item.enable===-1?!u:u||n.pick<r.item.min.pick||n.pick>r.item.max.pick};r.prototype.parse=function(n,t,r){var f=this,u={};return!t||typeof t!="string"?t:(r&&r.format||(r=r||{},r.format=f.settings.format),f.formats.toArray(r.format).map(function(n){var r=f.formats[n],e=r?i.trigger(r,f,[t,u]):n.replace(/^!/,"").length;r&&(u[n]=t.substr(0,e));t=t.substr(e)}),[u.yyyy||u.yy,+(u.mm||u.m)-1,u.dd||u.d])};r.prototype.formats=function(){function n(n,t,i){var r=n.match(/[^\x00-\x7F]+|[a-zA-Z0-9_\u0080-\u00FF]+/)[0];return i.mm||i.m||(i.m=t.indexOf(r)+1),r.length}function t(n){return n.match(/[a-zA-Z0-9_\u0080-\u00FF]+/)[0].length}return{d:function(n,t){return n?i.digits(n):t.date},dd:function(n,t){return n?2:i.lead(t.date)},ddd:function(n,i){return n?t(n):this.settings.weekdaysShort[i.day]},dddd:function(n,i){return n?t(n):this.settings.weekdaysFull[i.day]},m:function(n,t){return n?i.digits(n):t.month+1},mm:function(n,t){return n?2:i.lead(t.month+1)},mmm:function(t,i){var r=this.settings.monthsShort;return t?n(t,r,i):r[i.month]},mmmm:function(t,i){var r=this.settings.monthsFull;return t?n(t,r,i):r[i.month]},yy:function(n,t){return n?2:(""+t.year).slice(2)},yyyy:function(n,t){return n?4:t.year},toArray:function(n){return n.split(/(d{1,4}|m{1,4}|y{4}|yy|!.)/g)},toString:function(n,t){var r=this;return r.formats.toArray(n).map(function(n){return i.trigger(r.formats[n],r,[0,t])||n.replace(/^!/,"")}).join("")}}}();r.prototype.isDateExact=function(n,r){var u=this;return i.isInteger(n)&&i.isInteger(r)||typeof n=="boolean"&&typeof r=="boolean"?n===r:(i.isDate(n)||t.isArray(n))&&(i.isDate(r)||t.isArray(r))?u.create(n).pick===u.create(r).pick:t.isPlainObject(n)&&t.isPlainObject(r)?u.isDateExact(n.from,r.from)&&u.isDateExact(n.to,r.to):!1};r.prototype.isDateOverlap=function(n,r){var u=this,f=u.settings.firstDay?1:0;return i.isInteger(n)&&(i.isDate(r)||t.isArray(r))?(n=n%7+f,n===u.create(r).day+1):i.isInteger(r)&&(i.isDate(n)||t.isArray(n))?(r=r%7+f,r===u.create(n).day+1):t.isPlainObject(n)&&t.isPlainObject(r)?u.overlapRanges(n,r):!1};r.prototype.flipEnable=function(n){var t=this.item;t.enable=n||(t.enable==-1?1:-1)};r.prototype.deactivate=function(n,r){var f=this,u=f.item.disable.slice(0);return r=="flip"?f.flipEnable():r===!1?(f.flipEnable(1),u=[]):r===!0?(f.flipEnable(-1),u=[]):r.map(function(n){for(var e,r=0;r<u.length;r+=1)if(f.isDateExact(n,u[r])){e=!0;break}e||(i.isInteger(n)||i.isDate(n)||t.isArray(n)||t.isPlainObject(n)&&n.from&&n.to)&&u.push(n)}),u};r.prototype.activate=function(n,r){var f=this,u=f.item.disable,e=u.length;return r=="flip"?f.flipEnable():r===!0?(f.flipEnable(1),u=[]):r===!1?(f.flipEnable(-1),u=[]):r.map(function(n){for(var o,s,h,r=0;r<e;r+=1)if(s=u[r],f.isDateExact(s,n)){o=u[r]=null;h=!0;break}else if(f.isDateOverlap(s,n)){t.isPlainObject(n)?(n.inverted=!0,o=n):t.isArray(n)?(o=n,o[3]||o.push("inverted")):i.isDate(n)&&(o=[n.getFullYear(),n.getMonth(),n.getDate(),"inverted"]);break}if(o)for(r=0;r<e;r+=1)if(f.isDateExact(u[r],n)){u[r]=null;break}if(h)for(r=0;r<e;r+=1)if(f.isDateOverlap(u[r],n)){u[r]=null;break}o&&u.push(o)}),u.filter(function(n){return n!=null})};r.prototype.nodes=function(n){var r=this,t=r.settings,o=r.item,c=o.now,l=o.select,a=o.highlight,e=o.view,w=o.disable,s=o.min,h=o.max,b=function(n,r){return t.firstDay&&(n.push(n.shift()),r.push(r.shift())),i.node("thead",i.node("tr",i.group({min:0,max:u-1,i:1,node:"th",item:function(i){return[n[i],t.klass.weekdays,'scope=col title="'+r[i]+'"']}})))}((t.showWeekdaysFull?t.weekdaysFull:t.weekdaysShort).slice(0),t.weekdaysFull.slice(0)),v=function(n){return i.node("div"," ",t.klass["nav"+(n?"Next":"Prev")]+(n&&e.year>=h.year&&e.month>=h.month||!n&&e.year<=s.year&&e.month<=s.month?" "+t.klass.navDisabled:""),"data-nav="+(n||-1)+' tabindex="0" '+i.ariaAttr({role:"button",controls:r.$node[0].id+"_table"})+' title="'+(n?t.labelMonthNext:t.labelMonthPrev)+'"')},y=function(){var u=t.showMonthsShort?t.monthsShort:t.monthsFull;return t.selectMonths?i.node("select",i.group({min:0,max:11,i:1,node:"option",item:function(n){return[u[n],0,"value="+n+(e.month==n?" selected":"")+(e.year==s.year&&n<s.month||e.year==h.year&&n>h.month?" disabled":"")]}}),t.klass.selectMonth,(n?"":"disabled")+" "+i.ariaAttr({controls:r.$node[0].id+"_table"})+' title="'+t.labelMonthSelect+'"'):i.node("div",u[e.month],t.klass.month)},p=function(){var o=e.year,l=t.selectYears===!0?5:~~(t.selectYears/2),v,y;if(l){var c=s.year,a=h.year,u=o-l,f=o+l;return c>u&&(f+=c-u,u=c),a<f&&(v=u-c,y=f-a,u-=v>y?y:v,f=a),i.node("select",i.group({min:u,max:f,i:1,node:"option",item:function(n){return[n,0,"value="+n+(o==n?" selected":"")]}}),t.klass.selectYear,(n?"":"disabled")+" "+i.ariaAttr({controls:r.$node[0].id+"_table"})+' title="'+t.labelYearSelect+'"')}return i.node("div",o,t.klass.year)};return i.node("div",(t.selectYears?p()+y():y()+p())+v()+v(1),t.klass.header)+i.node("table",b+i.node("tbody",i.group({min:0,max:f-1,i:1,node:"tr",item:function(n){var f=t.firstDay&&r.create([e.year,e.month,1]).day===0?-7:0;return[i.group({min:u*n-e.day+f+1,max:function(){return this.min+u-1},i:1,node:"td",item:function(n){n=r.create([e.year,e.month,n+(t.firstDay?1:0)]);var u=l&&l.pick==n.pick,f=a&&a.pick==n.pick,o=w&&r.disabled(n)||n.pick<s.pick||n.pick>h.pick,v=i.trigger(r.formats.toString,r,[t.format,n]),y=t.id+"_"+n.pick;return[i.node("div",n.date,function(i){return i.push(e.month==n.month?t.klass.infocus:t.klass.outfocus),c.pick==n.pick&&i.push(t.klass.now),u&&i.push(t.klass.selected),f&&i.push(t.klass.highlighted),o&&i.push(t.klass.disabled),i.join(" ")}([t.klass.day]),"data-pick="+n.pick+" id="+y+' tabindex="0" '+i.ariaAttr({role:"gridcell",label:v,selected:u&&r.$node.val()===v?!0:null,activedescendant:f?n.pick:null,disabled:o?!0:null})),""]}})]}})),t.klass.table,'id="'+r.$node[0].id+'_table" '+i.ariaAttr({role:"grid",controls:r.$node[0].id,readonly:!0}))+i.node("div",i.node("button",t.today,t.klass.buttonToday,"type=button data-pick="+c.pick+(n&&!r.disabled(c)?"":" disabled")+" "+i.ariaAttr({controls:r.$node[0].id}))+i.node("button",t.clear,t.klass.buttonClear,"type=button data-clear=1"+(n?"":" disabled")+" "+i.ariaAttr({controls:r.$node[0].id}))+i.node("button",t.close,t.klass.buttonClose,"type=button data-close=true "+(n?"":" disabled")+" "+i.ariaAttr({controls:r.$node[0].id})),t.klass.footer)};r.defaults=function(n){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",closeOnSelect:!0,closeOnClear:!0,updateInput:!0,format:"d mmmm, yyyy",klass:{table:n+"table",header:n+"header",navPrev:n+"nav--prev",navNext:n+"nav--next",navDisabled:n+"nav--disabled",month:n+"month",year:n+"year",selectMonth:n+"select--month",selectYear:n+"select--year",weekdays:n+"weekday",day:n+"day",disabled:n+"day--disabled",selected:n+"day--selected",highlighted:n+"day--highlighted",now:n+"day--today",infocus:n+"day--infocus",outfocus:n+"day--outfocus",footer:n+"footer",buttonClear:n+"button--clear",buttonToday:n+"button--today",buttonClose:n+"button--close"}}}(n.klasses().picker+"__");n.extend("pickadate",r)});
|
|
/*!
|
|
* Time picker for pickadate.js v3.6.4
|
|
* http://amsul.github.io/pickadate.js/time.htm
|
|
*/
|
|
(function(n){typeof define=="function"&&define.amd?define(["./picker","jquery"],n):typeof exports=="object"?module.exports=n(require("./picker.js"),require("jquery")):n(Picker,jQuery)})(function(n,t){function r(n,t){var i=this,f=n.$node[0].value,r=n.$node.data("value"),u=r||f,e=r?t.formatSubmit:t.format;i.settings=t;i.$node=n.$node;i.queue={interval:"i",min:"measure create",max:"measure create",now:"now create",select:"parse create validate",highlight:"parse create validate",view:"parse create validate",disable:"deactivate",enable:"activate"};i.item={};i.item.clear=null;i.item.interval=t.interval||30;i.item.disable=(t.disable||[]).slice(0);i.item.enable=-function(n){return n[0]===!0?n.shift():-1}(i.item.disable);i.set("min",t.min).set("max",t.max).set("now");u?i.set("select",u,{format:e}):i.set("select",null).set("highlight",i.item.now);i.key={40:1,38:-1,39:1,37:-1,go:function(n){i.set("highlight",i.item.highlight.pick+n*i.item.interval,{interval:n*i.item.interval});this.render()}};n.on("render",function(){var i=n.$root.children(),r=i.find("."+t.klass.viewset),u=function(n){return["webkit","moz","ms","o",""].map(function(t){return(t?"-"+t+"-":"")+n})},f=function(n,t){u("transform").map(function(i){n.css(i,t)});u("transition").map(function(i){n.css(i,t)})};r.length&&(f(i,"none"),i[0].scrollTop=~~r.position().top-r[0].clientHeight*2,f(i,""))},1).on("open",function(){n.$root.find("button").attr("disabled",!1)},1).on("close",function(){n.$root.find("button").attr("disabled",!0)},1)}var e=24,u=60,o=12,f=e*u,i=n._;r.prototype.set=function(n,t,i){var r=this,u=r.item;return t===null?(n=="clear"&&(n="select"),u[n]=t,r):(u[n=="enable"?"disable":n=="flip"?"enable":n]=r.queue[n].split(" ").map(function(u){return t=r[u](n,t,i)}).pop(),n=="select"?r.set("highlight",u.select,i):n=="highlight"?r.set("view",u.highlight,i):n=="interval"?r.set("min",u.min,i).set("max",u.max,i):n.match(/^(flip|min|max|disable|enable)$/)&&(u.select&&r.disabled(u.select)&&r.set("select",t,i),u.highlight&&r.disabled(u.highlight)&&r.set("highlight",t,i),n=="min"&&r.set("max",u.max,i)),r)};r.prototype.get=function(n){return this.item[n]};r.prototype.create=function(n,r,o){var s=this;return r=r===undefined?n:r,i.isDate(r)&&(r=[r.getHours(),r.getMinutes()]),t.isPlainObject(r)&&i.isInteger(r.pick)?r=r.pick:t.isArray(r)?r=+r[0]*u+ +r[1]:i.isInteger(r)||(r=s.now(n,r,o)),n=="max"&&r<s.item.min.pick&&(r+=f),n!="min"&&n!="max"&&(r-s.item.min.pick)%s.item.interval!=0&&(r+=s.item.interval),r=s.normalize(n,r,o),{hour:~~(e+r/u)%e,mins:(u+r%u)%u,time:(f+r)%f,pick:r%f}};r.prototype.createRange=function(n,r){var f=this,u=function(n){return n===!0||t.isArray(n)||i.isDate(n)?f.create(n):n};return i.isInteger(n)||(n=u(n)),i.isInteger(r)||(r=u(r)),i.isInteger(n)&&t.isPlainObject(r)?n=[r.hour,r.mins+n*f.settings.interval]:i.isInteger(r)&&t.isPlainObject(n)&&(r=[n.hour,n.mins+r*f.settings.interval]),{from:u(n),to:u(r)}};r.prototype.withinRange=function(n,t){return n=this.createRange(n.from,n.to),t.pick>=n.from.pick&&t.pick<=n.to.pick};r.prototype.overlapRanges=function(n,t){var i=this;return n=i.createRange(n.from,n.to),t=i.createRange(t.from,t.to),i.withinRange(n,t.from)||i.withinRange(n,t.to)||i.withinRange(t,n.from)||i.withinRange(t,n.to)};r.prototype.now=function(n,t){var f=this.item.interval,o=new Date,r=o.getHours()*u+o.getMinutes(),s=i.isInteger(t),e;return r-=r%f,e=t<0&&f*t+r<=-f,r+=n=="min"&&e?0:f,s&&(r+=f*(e&&n!="max"?t+1:t)),r};r.prototype.normalize=function(n,t){var i=this.item.interval,r=this.item.min&&this.item.min.pick||0;return t-(n=="min"?0:(t-r)%i)};r.prototype.measure=function(n,r,f){var o=this;return r||(r=n=="min"?[0,0]:[e-1,u-1]),typeof r=="string"?r=o.parse(n,r):r===!0||i.isInteger(r)?r=o.now(n,r,f):t.isPlainObject(r)&&i.isInteger(r.pick)&&(r=o.normalize(n,r.pick,f)),r};r.prototype.validate=function(n,t,i){var r=this,u=i&&i.interval?i.interval:r.item.interval;return r.disabled(t)&&(t=r.shift(t,u)),t=r.scope(t),r.disabled(t)&&(t=r.shift(t,u*-1)),t};r.prototype.disabled=function(n){var r=this,u=r.item.disable.filter(function(u){return i.isInteger(u)?n.hour==u:t.isArray(u)||i.isDate(u)?n.pick==r.create(u).pick:t.isPlainObject(u)?r.withinRange(u,n):void 0});return u=u.length&&!u.filter(function(n){return t.isArray(n)&&n[2]=="inverted"||t.isPlainObject(n)&&n.inverted}).length,r.item.enable===-1?!u:u||n.pick<r.item.min.pick||n.pick>r.item.max.pick};r.prototype.shift=function(n,t){var i=this,r=i.item.min.pick,u=i.item.max.pick;for(t=t||i.item.interval;i.disabled(n);)if(n=i.create(n.pick+=t),n.pick<=r||n.pick>=u)break;return n};r.prototype.scope=function(n){var t=this.item.min.pick,i=this.item.max.pick;return this.create(n.pick>i?i:n.pick<t?t:n)};r.prototype.parse=function(n,t,r){var s,c,l,f,o,h=this,e={};if(!t||typeof t!="string")return t;r&&r.format||(r=r||{},r.format=h.settings.format);h.formats.toArray(r.format).map(function(n){var r,u=h.formats[n],f=u?i.trigger(u,h,[t,e]):n.replace(/^!/,"").length;u&&(r=t.substr(0,f),e[n]=r.match(/^\d+$/)?+r:r);t=t.substr(f)});for(f in e)o=e[f],i.isInteger(o)?f.match(/^(h|hh)$/i)?(s=o,(f=="h"||f=="hh")&&(s%=12)):f=="i"&&(c=o):f.match(/^a$/i)&&o.match(/^p/i)&&("h"in e||"hh"in e)&&(l=!0);return(l?s+12:s)*u+c};r.prototype.formats={h:function(n,t){return n?i.digits(n):t.hour%o||o},hh:function(n,t){return n?2:i.lead(t.hour%o||o)},H:function(n,t){return n?i.digits(n):""+t.hour%24},HH:function(n,t){return n?i.digits(n):i.lead(t.hour%24)},i:function(n,t){return n?2:i.lead(t.mins)},a:function(n,t){return n?4:f/2>t.time%f?"a.m.":"p.m."},A:function(n,t){return n?2:f/2>t.time%f?"AM":"PM"},toArray:function(n){return n.split(/(h{1,2}|H{1,2}|i|a|A|!.)/g)},toString:function(n,t){var r=this;return r.formats.toArray(n).map(function(n){return i.trigger(r.formats[n],r,[0,t])||n.replace(/^!/,"")}).join("")}};r.prototype.isTimeExact=function(n,r){var u=this;return i.isInteger(n)&&i.isInteger(r)||typeof n=="boolean"&&typeof r=="boolean"?n===r:(i.isDate(n)||t.isArray(n))&&(i.isDate(r)||t.isArray(r))?u.create(n).pick===u.create(r).pick:t.isPlainObject(n)&&t.isPlainObject(r)?u.isTimeExact(n.from,r.from)&&u.isTimeExact(n.to,r.to):!1};r.prototype.isTimeOverlap=function(n,r){var u=this;return i.isInteger(n)&&(i.isDate(r)||t.isArray(r))?n===u.create(r).hour:i.isInteger(r)&&(i.isDate(n)||t.isArray(n))?r===u.create(n).hour:t.isPlainObject(n)&&t.isPlainObject(r)?u.overlapRanges(n,r):!1};r.prototype.flipEnable=function(n){var t=this.item;t.enable=n||(t.enable==-1?1:-1)};r.prototype.deactivate=function(n,r){var f=this,u=f.item.disable.slice(0);return r=="flip"?f.flipEnable():r===!1?(f.flipEnable(1),u=[]):r===!0?(f.flipEnable(-1),u=[]):r.map(function(n){for(var e,r=0;r<u.length;r+=1)if(f.isTimeExact(n,u[r])){e=!0;break}e||(i.isInteger(n)||i.isDate(n)||t.isArray(n)||t.isPlainObject(n)&&n.from&&n.to)&&u.push(n)}),u};r.prototype.activate=function(n,r){var f=this,u=f.item.disable,e=u.length;return r=="flip"?f.flipEnable():r===!0?(f.flipEnable(1),u=[]):r===!1?(f.flipEnable(-1),u=[]):r.map(function(n){for(var o,s,h,r=0;r<e;r+=1)if(s=u[r],f.isTimeExact(s,n)){o=u[r]=null;h=!0;break}else if(f.isTimeOverlap(s,n)){t.isPlainObject(n)?(n.inverted=!0,o=n):t.isArray(n)?(o=n,o[2]||o.push("inverted")):i.isDate(n)&&(o=[n.getFullYear(),n.getMonth(),n.getDate(),"inverted"]);break}if(o)for(r=0;r<e;r+=1)if(f.isTimeExact(u[r],n)){u[r]=null;break}if(h)for(r=0;r<e;r+=1)if(f.isTimeOverlap(u[r],n)){u[r]=null;break}o&&u.push(o)}),u.filter(function(n){return n!=null})};r.prototype.i=function(n,t){return i.isInteger(t)&&t>0?t:this.item.interval};r.prototype.nodes=function(n){var t=this,r=t.settings,u=t.item.select,f=t.item.highlight,e=t.item.view,o=t.item.disable;return i.node("ul",i.group({min:t.item.min.pick,max:t.item.max.pick,i:t.item.interval,node:"li",item:function(n){n=t.create(n);var s=n.pick,h=u&&u.pick==s,c=f&&f.pick==s,l=o&&t.disabled(n),a=i.trigger(t.formats.toString,t,[r.format,n]);return[i.trigger(t.formats.toString,t,[i.trigger(r.formatLabel,t,[n])||r.format,n]),function(n){return h&&n.push(r.klass.selected),c&&n.push(r.klass.highlighted),e&&e.pick==s&&n.push(r.klass.viewset),l&&n.push(r.klass.disabled),n.join(" ")}([r.klass.listItem]),"data-pick="+n.pick+" "+i.ariaAttr({role:"option",label:a,selected:h&&t.$node.val()===a?!0:null,activedescendant:c?!0:null,disabled:l?!0:null})]}})+i.node("li",i.node("button",r.clear,r.klass.buttonClear,"type=button data-clear=1"+(n?"":" disabled")+" "+i.ariaAttr({controls:t.$node[0].id})),"",i.ariaAttr({role:"presentation"})),r.klass.list,i.ariaAttr({role:"listbox",controls:t.$node[0].id}))};r.defaults=function(n){return{clear:"Clear",format:"h:i A",interval:30,closeOnSelect:!0,closeOnClear:!0,updateInput:!0,klass:{picker:n+" "+n+"--time",holder:n+"__holder",list:n+"__list",listItem:n+"__list-item",disabled:n+"__list-item--disabled",selected:n+"__list-item--selected",highlighted:n+"__list-item--highlighted",viewset:n+"__list-item--viewset",now:n+"__list-item--now",buttonClear:n+"__button--clear"}}}(n.klasses().picker);n.extend("pickatime",r)});
|
|
/**
|
|
cp.datepicker.js provides an JavaScript Date picker control.
|
|
*/
|
|
var cp = cp || {};
|
|
$(document).ready(function() {
|
|
cp.datetimepicker = (function($) {
|
|
// These are the publicly-accessible methods
|
|
if (!$) { return; }
|
|
return {
|
|
createTimePicker: createTimePicker,
|
|
createDatePicker: createDatePicker,
|
|
};
|
|
|
|
|
|
// getOptionsFromHtmlAttributes parses through any attribute in the user-specific HTML date or time picker and
|
|
// overwrites the values in "options" with values corresponding to "data-cp-datetimepicker-{optionName}". The
|
|
// "optionName" portion of the attribute should correspond to a property of the pickadate or pickatime
|
|
// options element.
|
|
function getOptionsFromHtmlAttributes($inputElement, originalOptions) {
|
|
$($inputElement[0].attributes).each(function() {
|
|
if (this.name.match('^data-cp-datetimepicker-')) {
|
|
var optionName = this.name.replace('data-cp-datetimepicker-', '');
|
|
var originalValue = originalOptions[optionName];
|
|
if (!originalValue) {
|
|
// We only want to set the option value if it was not already set in the JavaScript options.
|
|
// That is, the JavaScript options should always win over the HTML5 options.
|
|
|
|
var optionVal = this.value;
|
|
if (parseInt(optionVal)) {
|
|
optionVal = parseInt(optionVal);
|
|
}
|
|
|
|
originalOptions[optionName] = optionVal;
|
|
}
|
|
}
|
|
});
|
|
return originalOptions;
|
|
}
|
|
|
|
// createTimePicker creates a new time picker object out of the DOM object specified by timeTextboxSelector.
|
|
// The timeTextboxSelector object must be an HTML INPUT element.
|
|
function createTimePicker(timeTextboxSelector, options) {
|
|
|
|
// The actualy Input Time component will be a hidden field. The DOM object in the source HTML
|
|
// will be the editable text field for the user.
|
|
|
|
options = options || {};
|
|
|
|
var $inputTextBox = $(timeTextboxSelector);
|
|
|
|
if (!($inputTextBox) || $inputTextBox.length === 0) {
|
|
// We got passed a bad selector
|
|
console.log('ERR: cp.datetimepicker :: Could not find element: ' + timeTextboxSelector);
|
|
return;
|
|
}
|
|
|
|
// Set any options that were specified directly from within the HTML tag.
|
|
options = getOptionsFromHtmlAttributes($inputTextBox, options);
|
|
|
|
//Wrap fieldSetSelector inside div if wrapInsideDiv is true
|
|
var fieldSetSelector = '<fieldset class="fieldset__datetimepicker__wrapper">';
|
|
|
|
if (options.wrapInsideDiv) {
|
|
fieldSetSelector = '<div class="t-widget t-timepicker">' + fieldSetSelector + '</div>';
|
|
}
|
|
|
|
$fieldset = $(fieldSetSelector);
|
|
$inputTextBox.wrap($fieldset);
|
|
|
|
var $hiddenTimeInput = $('<input type="text" class="cp_input_datetime" tabindex="-1"/>');
|
|
$hiddenTimeInput.attr('data-cp-time-textbox-selector', timeTextboxSelector);
|
|
|
|
$hiddenTimeInput.attr('aria-hidden', true);
|
|
|
|
$hiddenTimeInput.insertAfter($inputTextBox);
|
|
|
|
// We need to force "editable" in the options, otherwise things start to break.
|
|
options.editable = true;
|
|
$hiddenTimeInput.pickatime(options);
|
|
|
|
var pickerObject = $hiddenTimeInput.pickatime('picker'); // reference to the pickatime object
|
|
|
|
$inputTextBox.on({
|
|
change: function() {
|
|
var inputTime = this.value;
|
|
pickerObject.set('customSelect', insertColonIfOverFourChars(inputTime), options);
|
|
},
|
|
focus: function() {
|
|
pickerObject.open(false);
|
|
|
|
// We have to set the tab-index of the "clear" button, so tabbing through fields works properly.
|
|
$('.picker__button--clear').attr('tabindex', -1);
|
|
},
|
|
blur: function() {
|
|
pickerObject.close(true);
|
|
}
|
|
});
|
|
|
|
pickerObject.on('set', function(e) {
|
|
var inputVal = $inputTextBox.val();
|
|
|
|
var selectedVal = autoTimeFormat(inputVal);
|
|
|
|
if (typeof e.clear === "object" || (typeof e.select !== "undefined" && !isNaN(e.select)) || (e.customSelect && !selectedVal.match(/^([1-9]|1[012])(:[0-5]\d) [APap][mM]$/))) {
|
|
selectedVal = this.get('value') === '' ? '12:00 AM' : this.get('value');
|
|
}
|
|
|
|
$inputTextBox.val(selectedVal);
|
|
$inputTextBox.attr('value', selectedVal);
|
|
|
|
});
|
|
|
|
// Priming initialization if there was a value specified for the input
|
|
if ($inputTextBox.val() !== '') {
|
|
pickerObject.set('select', $inputTextBox.val(), options);
|
|
}
|
|
|
|
$(pickerObject.$root).find('.picker__list').attr('aria-label', 'Time List');
|
|
|
|
return pickerObject;
|
|
}
|
|
|
|
// createDatePicker creates a new date picker object using the element specified by "dateTextboxSelector".
|
|
// The dateTextboxSelector object must be an HTML INPUT element.
|
|
function createDatePicker(dateTextboxSelector, options) {
|
|
// The actualy Input Date component will be a hidden field. The DOM object in the source HTML
|
|
// will be the editable text field for the user.
|
|
options = options || {};
|
|
|
|
var $inputTextBox = $(dateTextboxSelector);
|
|
|
|
if (!($inputTextBox) || $inputTextBox.length === 0) {
|
|
// We got passed a bad selector
|
|
console.log('ERR: cp.datetimepicker :: Could not find element: ' + dateTextboxSelector);
|
|
return;
|
|
}
|
|
|
|
// Set any options that were specified directly from within the HTML tag.
|
|
options = getOptionsFromHtmlAttributes($inputTextBox, options);
|
|
var dateAsString = $inputTextBox.val();
|
|
if (options.format == 'dd/mm/yyyy' && dateAsString.length > 0) {
|
|
var splitDate = autoCompleteDate(dateAsString, options.format).split('/');
|
|
$inputTextBox.val(splitDate[1] + '/' + splitDate[0] + '/' + splitDate[2]);
|
|
}
|
|
|
|
if (options.useNativeControls) {
|
|
$inputTextBox.prop('type', 'date');
|
|
return;
|
|
}
|
|
|
|
var $hiddenDateInput = $('<input type="text" class="cp_input_datetime" tabindex="-1"/>');
|
|
$hiddenDateInput.attr('data-cp-date-textbox-selector', dateTextboxSelector);
|
|
|
|
$hiddenDateInput.attr('aria-hidden', true);
|
|
var fieldsetSelector = '<fieldset class="fieldset__datetimepicker__wrapper"></fieldset>';
|
|
if (options.wrapInsideDiv)
|
|
fieldsetSelector = '<div class="t-widget t-datepicker">' + fieldsetSelector + '</div>';
|
|
|
|
$fieldset = $(fieldsetSelector);
|
|
$fieldset.attr("data-cp-datetimepicker-selector", dateTextboxSelector);
|
|
$inputTextBox.wrap($fieldset);
|
|
$hiddenDateInput.insertAfter($inputTextBox);
|
|
|
|
// We have to force the editable option, otherwise things start to break.
|
|
options.editable = true;
|
|
|
|
$hiddenDateInput.pickadate(options);
|
|
|
|
var pickerObject = $hiddenDateInput.pickadate('picker'); // reference to the pickadate object
|
|
$inputTextBox.attr("role", "combobox");
|
|
$inputTextBox.attr("aria-haspopup", "dialog");
|
|
$inputTextBox.attr("aria-expanded", "false");
|
|
$inputTextBox.attr("aria-controls", pickerObject.$root.attr("id"));
|
|
|
|
// Add handler to make sure datepicker is visible when shown
|
|
pickerObject && pickerObject.on('open', function() {
|
|
$inputTextBox.attr("aria-expanded", "true");
|
|
// Add a slight delay to ensure that the flyout has been added to the dom and the flyoutHeight is nonzero
|
|
setTimeout(function() {
|
|
// Get the position of the datepicker flyout relative to the top of the document
|
|
var flyoutTop = pickerObject.$holder[0].getBoundingClientRect().top;
|
|
|
|
// Get the height of the datepicker flyout
|
|
var flyoutHeight = pickerObject.$holder[0].offsetHeight;
|
|
|
|
// Get the height of the viewport
|
|
var viewportHeight = window.innerHeight;
|
|
|
|
// Calculate the amount of scrolling needed to make the entire datepicker flyout visible
|
|
var scrollAmount = flyoutTop + flyoutHeight - viewportHeight;
|
|
|
|
// If the datepicker flyout is not fully visible, scroll the viewport down to make it visible
|
|
if (scrollAmount > 0) {
|
|
window.scrollTo(0, scrollAmount + window.scrollY);
|
|
}
|
|
}, 50);
|
|
});
|
|
|
|
function focusInput() {
|
|
$inputTextBox.off("focus", openPicker);
|
|
$inputTextBox.focus();
|
|
$inputTextBox.on("focus", openPicker);
|
|
}
|
|
|
|
pickerObject.on('close', function() {
|
|
//Trigger the change event on the picker object's element.
|
|
window.parent.$(dateTextboxSelector).change();
|
|
$inputTextBox.attr("aria-expanded", "false");
|
|
focusInput();
|
|
});
|
|
|
|
// setDate is a helper function that should only be called from within this module.
|
|
function setDate(dateAsString, placeholder) {
|
|
if (dateAsString === '') {
|
|
pickerObject.set('clear', null, null);
|
|
} else {
|
|
if (pickerObject.component.settings.format == 'dd/mm/yyyy') {
|
|
var splitDate = autoCompleteDate(dateAsString, pickerObject.component.settings.format).split('/');
|
|
var date = splitDate[1] + '/' + splitDate[0] + '/' + splitDate[2];
|
|
var epochDate = Date.parse(date);
|
|
} else {
|
|
var epochDate = Date.parse(autoCompleteDate(dateAsString, pickerObject.component.settings.format));
|
|
}
|
|
if (!epochDate) {
|
|
return;
|
|
} else {
|
|
var parsedDate = new Date(epochDate);
|
|
pickerObject.set('select',
|
|
[parsedDate.getFullYear(), parsedDate.getMonth(), parsedDate.getDate()]);
|
|
}
|
|
}
|
|
}
|
|
|
|
var intervalID;
|
|
|
|
//Moves the date picker further up the DOM so it isn't overlapped https://civicplus.tpondemand.com/entity/22312
|
|
function adjustDTPicker() {
|
|
if (intervalID === 0) {
|
|
return;
|
|
}
|
|
|
|
var elemPicker = $('.picker--opened')[0];
|
|
if (elemPicker) {
|
|
$(elemPicker).appendTo('#cpDatePickerWrapper');
|
|
elemPicker.style.fontSize = 'inherit';
|
|
}
|
|
|
|
clearInterval(intervalID);
|
|
|
|
$('.cpDatePickerElevate').each(function() {
|
|
var $dateInput = $(this);
|
|
if ($dateInput.is(':focus')) {
|
|
adjustFlyoutPosition($dateInput, $('#cpDatePickerWrapper'));
|
|
}
|
|
});
|
|
|
|
intervalID = 0;
|
|
}
|
|
|
|
if ($('#cpDatePickerWrapper').length > 0) {
|
|
$(window).resize(function() {
|
|
$('.cpDatePickerElevate').each(function() {
|
|
var $dateInput = $(this);
|
|
if ($dateInput.is(':focus')) {
|
|
adjustFlyoutPosition($dateInput, $('#cpDatePickerWrapper'));
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
function openPicker() {
|
|
// We have to set the tab-index of the "today", "close", and "clear" buttons, so tabbing through fields works properly.
|
|
$('.picker__button--close').attr('tabindex', -1);
|
|
$('.picker__button--today').attr('tabindex', -1);
|
|
$('.picker__button--clear').attr('tabindex', -1);
|
|
pickerObject.$holder.find('[tabindex="-1"]').attr('tabindex', 0)
|
|
pickerObject.open(false);
|
|
if ($('#cpDatePickerWrapper').length > 0)
|
|
intervalID = setInterval(adjustDTPicker, 50);
|
|
}
|
|
|
|
$inputTextBox.on({
|
|
change: function() {
|
|
setDate(this.value);
|
|
},
|
|
focus: openPicker,
|
|
click: openPicker,
|
|
keydown: function(e) {
|
|
if (e.keyCode === 9) {
|
|
pickerObject.$holder.find('[tabindex="0"]').attr('tabindex', -1);
|
|
}
|
|
if (e.keyCode === 40) {
|
|
e.preventDefault();
|
|
pickerObject.open();
|
|
}
|
|
},
|
|
blur: function(e) {
|
|
pickerObject.close(true);
|
|
$inputTextBox.attr("aria-expanded", "false");
|
|
},
|
|
});
|
|
|
|
pickerObject.on('set', function() {
|
|
$inputTextBox.val(this.get('value'));
|
|
$inputTextBox.attr('value', this.get('value'));
|
|
});
|
|
|
|
// Priming initialization if there was a value specified for the input
|
|
if ($inputTextBox.val() !== '') {
|
|
setDate($inputTextBox.val());
|
|
}
|
|
|
|
|
|
return pickerObject;
|
|
}
|
|
|
|
function insertColonIfOverFourChars(inputString) {
|
|
if (inputString != null && inputString.length > 3 && inputString.indexOf(":") < 0) {
|
|
inputString = inputString.slice(0, 2) + ":" + inputString.slice(2, inputString.length);
|
|
}
|
|
return inputString;
|
|
}
|
|
|
|
function autoCompleteDate(dateAsString, formatString) {
|
|
try {
|
|
var fdts = null;
|
|
var currentDate = new Date();
|
|
|
|
//guard clauses
|
|
if (formatString == null || formatString.length === 0) {
|
|
formatString === "mm/dd/yyyy";
|
|
}
|
|
if ((dateAsString == null || dateAsString.length == 0 || dateAsString.indexOf(".") != -1) && formatString.toLowerCase == "dd/mm/yyyy") {
|
|
return ('0' + currentDate.getDate()).slice(-2) + '/' + ('0' + (currentDate.getMonth() + 1)).slice(-2) + '/' + currentDate.getFullYear();
|
|
} else if (dateAsString == null || dateAsString.length == 0 || dateAsString.indexOf(".") != -1) {
|
|
return ('0' + (currentDate.getMonth() + 1)).slice(-2) + '/' + ('0' + currentDate.getDate()).slice(-2) + '/' + currentDate.getFullYear();
|
|
}
|
|
|
|
fdts = dateAsString.split("/");
|
|
|
|
if (fdts != null) {
|
|
//switch mm/dd/yyyy to be dd/mm/yyyy for logic further down
|
|
if (formatString.toLowerCase() !== "dd/mm/yyyy") {
|
|
var day = fdts[1];
|
|
var month = fdts[0];
|
|
fdts[0] = day;
|
|
fdts[1] = month;
|
|
}
|
|
|
|
if (fdts[0] == null || fdts[0] === '0' || fdts[0].length < 1 || fdts[0].length > 2) {
|
|
fdts[0] = currentDate.getDate();
|
|
}
|
|
if (fdts[1] == null || fdts[1] === '0' || fdts[1].length < 1 || fdts[1].length > 2) {
|
|
fdts[1] = currentDate.getMonth() + 1;
|
|
}
|
|
if (fdts[2] == null || (fdts[2].length !== 2 && fdts[2].length !== 4)) {
|
|
//For last year's date it also adds time at the end of date so extracting year
|
|
fdts[2] = !isNaN(fdts[2].substr(0, 4)) ? fdts[2].substr(0, 4) : currentDate.getFullYear();
|
|
} else if (fdts[2].length === 2) {
|
|
var yr = fdts[2];
|
|
var crDate = new Date();
|
|
var crCtry = crDate.getFullYear();
|
|
var pstCnry = crCtry - 100;
|
|
crCtry = crCtry + ' ';
|
|
pstCnry = pstCnry + ' ';
|
|
crCtry = crCtry.substr(0, 2);
|
|
pstCnry = pstCnry.substr(0, 2);
|
|
if (yr >= 32)
|
|
yr = pstCnry + yr;
|
|
else
|
|
yr = crCtry + yr;
|
|
fdts[2] = yr;
|
|
}
|
|
}
|
|
if (formatString.toLowerCase() === "dd/mm/yyyy") {
|
|
dateAsString = ('0' + fdts[0]).slice(-2) + '/' + ('0' + fdts[1]).slice(-2) + '/' + fdts[2];
|
|
} else {
|
|
dateAsString = ('0' + fdts[1]).slice(-2) + '/' + ('0' + fdts[0]).slice(-2) + '/' + fdts[2];
|
|
}
|
|
return dateAsString;
|
|
} catch (e) {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
function autoTimeFormat(inputString) {
|
|
|
|
const regex1 = /^(0?[1-9]|1[0-2]) ?([ap]m)$/i; //eg: 5AM -> 5:00 AM
|
|
const regex2 = /^(\d{1,2})(\d{2}) ?([ap]m)$/i; //eg: 500AM -> 5:00 AM
|
|
const regex3 = /^(\d{1,2})(?::(\d{2}))?\s*([ap]m)?$/i; //eg: 05:00 am or 5:00 am -> 5:00 AM
|
|
|
|
if (regex1.test(inputString)) {
|
|
return inputString.replace(regex1, (match, hour, period) => {
|
|
const hourNum = parseInt(hour);
|
|
const formattedHour = hourNum === 12 ? 12 : hourNum % 12; // Convert to 12-hour format
|
|
const formattedMinute = "00"; // Add 00 as minutes
|
|
const formattedPeriod = period.toUpperCase(); // Convert period to uppercase
|
|
return `${formattedHour}:${formattedMinute} ${formattedPeriod}`;
|
|
});
|
|
}
|
|
else if (regex2.test(inputString)) {
|
|
return inputString.replace(regex2, (match, hour, minute, period) => {
|
|
const hourNum = parseInt(hour);
|
|
const formattedHour = hourNum === 12 ? 12 : hourNum % 12; // Convert to 12-hour format
|
|
const formattedMinute = minute.padStart(2, "0"); // Pad minute with zero if necessary
|
|
const formattedPeriod = period.toUpperCase(); // Convert period to uppercase
|
|
return `${formattedHour}:${formattedMinute} ${formattedPeriod}`;
|
|
});
|
|
}
|
|
else if (regex3.test(inputString)) {
|
|
return inputString.replace(regex3, (match, hour, minute, period) => {
|
|
const hourNum = parseInt(hour);
|
|
const formattedHour = hourNum === 12 ? 12 : hourNum % 12; // Convert to 12-hour format
|
|
const formattedMinute = minute ? minute : "00"; // Set minute to "00" if not provided
|
|
const formattedPeriod = period ? period.toUpperCase() : ""; // Convert period to uppercase if provided
|
|
return `${formattedHour}:${formattedMinute} ${formattedPeriod}`;
|
|
});
|
|
}
|
|
else {
|
|
return inputString;
|
|
}
|
|
}
|
|
})(window.FeatureToggles.isActive("CMS.JqueryUpgrade.UpgradeTo224") && $('#hdnModuleEligibleForJquery224Upgrade').val() == "true" ? jQuery : typeof jQuery182 === "function" ? jQuery182 : null );
|
|
});
|
|
;
|
|
|