assets/javascripts/material.js in material-sass-4.0.0.beta2 vs assets/javascripts/material.js in material-sass-4.0.0.beta3

- old
+ new

@@ -1,1038 +1,3491 @@ /*! - * Material v4.0.0-beta (http://daemonite.github.io/material/) - * Copyright 2017 Daemon Pty Ltd + * Daemonite Material v4.0.0-beta (http://daemonite.github.io/material/) + * Copyright 2011-2018 Daemon Pty Ltd * Licensed under MIT (https://github.com/Daemonite/material/blob/master/LICENSE) */ -if (typeof jQuery === 'undefined') { - throw new Error('Material\'s JavaScript requires jQuery') +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jquery')) : + typeof define === 'function' && define.amd ? define(['exports', 'jquery'], factory) : + (factory((global.material = {}),global.jQuery)); +}(this, (function (exports,$) { 'use strict'; + +$ = $ && $.hasOwnProperty('default') ? $['default'] : $; + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; } -+function ($) { - var version = $.fn.jquery.split(' ')[0].split('.') - if (version[0] < 3 || version[0] >= 4) { - throw new Error('Material\'s JavaScript requires at least jQuery v3.0.0 but less than v4.0.0') - } -}(jQuery); +var picker = createCommonjsModule(function (module, exports) { +/*! + * pickadate.js v3.5.6, 2015/04/20 + * By Amsul, http://amsul.ca + * Hosted on http://amsul.github.io/pickadate.js + * Licensed under MIT + */ -!function(a){this.Picker=a(jQuery)}(function(a){function b(f,g,i,m){function n(){return b._.node("div",b._.node("div",b._.node("div",b._.node("div",B.component.nodes(w.open),y.box),y.wrap),y.frame),y.holder,'tabindex="-1"')}function o(){z.data(g,B).addClass(y.input).val(z.data("value")?B.get("select",x.format):f.value),x.editable||z.on("focus."+w.id+" click."+w.id,function(a){a.preventDefault(),B.open()}).on("keydown."+w.id,u),e(f,{haspopup:!0,expanded:!1,readonly:!1,owns:f.id+"_root"})}function p(){e(B.$root[0],"hidden",!0)}function q(){B.$holder.on({keydown:u,"focus.toOpen":t,blur:function(){z.removeClass(y.target)},focusin:function(a){B.$root.removeClass(y.focused),a.stopPropagation()},"mousedown click":function(b){var c=b.target;c!=B.$holder[0]&&(b.stopPropagation(),"mousedown"!=b.type||a(c).is("input, select, textarea, button, option")||(b.preventDefault(),B.$holder[0].focus()))}}).on("click","[data-pick], [data-nav], [data-clear], [data-close]",function(){var b=a(this),c=b.data(),d=b.hasClass(y.navDisabled)||b.hasClass(y.disabled),e=h();e=e&&(e.type||e.href),(d||e&&!a.contains(B.$root[0],e))&&B.$holder[0].focus(),!d&&c.nav?B.set("highlight",B.component.item.highlight,{nav:c.nav}):!d&&"pick"in c?(B.set("select",c.pick),x.closeOnSelect&&B.close(!0)):c.clear?(B.clear(),x.closeOnClear&&B.close(!0)):c.close&&B.close(!0)})}function r(){var b;x.hiddenName===!0?(b=f.name,f.name=""):(b=["string"==typeof x.hiddenPrefix?x.hiddenPrefix:"","string"==typeof x.hiddenSuffix?x.hiddenSuffix:"_submit"],b=b[0]+f.name+b[1]),B._hidden=a('<input type=hidden name="'+b+'"'+(z.data("value")||f.value?' value="'+B.get("select",x.formatSubmit)+'"':"")+">")[0],z.on("change."+w.id,function(){B._hidden.value=f.value?B.get("select",x.formatSubmit):""})}function s(){v&&l?B.$holder.find("."+y.frame).one("transitionend",function(){B.$holder[0].focus()}):B.$holder[0].focus()}function t(a){a.stopPropagation(),z.addClass(y.target),B.$root.addClass(y.focused),B.open()}function u(a){var b=a.keyCode,c=/^(8|46)$/.test(b);return 27==b?(B.close(!0),!1):void((32==b||c||!w.open&&B.component.key[b])&&(a.preventDefault(),a.stopPropagation(),c?B.clear().close():B.open()))}if(!f)return b;var v=!1,w={id:f.id||"P"+Math.abs(~~(Math.random()*new Date))},x=i?a.extend(!0,{},i.defaults,m):m||{},y=a.extend({},b.klasses(),x.klass),z=a(f),A=function(){return this.start()},B=A.prototype={constructor:A,$node:z,start:function(){return w&&w.start?B:(w.methods={},w.start=!0,w.open=!1,w.type=f.type,f.autofocus=f==h(),f.readOnly=!x.editable,f.id=f.id||w.id,"text"!=f.type&&(f.type="text"),B.component=new i(B,x),B.$root=a('<div class="'+y.picker+'" id="'+f.id+'_root" />'),p(),B.$holder=a(n()).appendTo(B.$root),q(),x.formatSubmit&&r(),o(),x.containerHidden?a(x.containerHidden).append(B._hidden):z.after(B._hidden),x.container?a(x.container).append(B.$root):z.after(B.$root),B.on({start:B.component.onStart,render:B.component.onRender,stop:B.component.onStop,open:B.component.onOpen,close:B.component.onClose,set:B.component.onSet}).on({start:x.onStart,render:x.onRender,stop:x.onStop,open:x.onOpen,close:x.onClose,set:x.onSet}),v=c(B.$holder[0]),f.autofocus&&B.open(),B.trigger("start").trigger("render"))},render:function(b){return b?(B.$holder=a(n()),q(),B.$root.html(B.$holder)):B.$root.find("."+y.box).html(B.component.nodes(w.open)),B.trigger("render")},stop:function(){return w.start?(B.close(),B._hidden&&B._hidden.parentNode.removeChild(B._hidden),B.$root.remove(),z.removeClass(y.input).removeData(g),setTimeout(function(){z.off("."+w.id)},0),f.type=w.type,f.readOnly=!1,B.trigger("stop"),w.methods={},w.start=!1,B):B},open:function(c){return w.open?B:(z.addClass(y.active),e(f,"expanded",!0),setTimeout(function(){B.$root.addClass(y.opened),e(B.$root[0],"hidden",!1)},0),c!==!1&&(w.open=!0,v&&k.css("overflow","hidden").css("padding-right","+="+d()),s(),j.on("click."+w.id+" focusin."+w.id,function(a){var b=a.target;b!=f&&b!=document&&3!=a.which&&B.close(b===B.$holder[0])}).on("keydown."+w.id,function(c){var d=c.keyCode,e=B.component.key[d],f=c.target;27==d?B.close(!0):f!=B.$holder[0]||!e&&13!=d?a.contains(B.$root[0],f)&&13==d&&(c.preventDefault(),f.click()):(c.preventDefault(),e?b._.trigger(B.component.key.go,B,[b._.trigger(e)]):B.$root.find("."+y.highlighted).hasClass(y.disabled)||(B.set("select",B.component.item.highlight),x.closeOnSelect&&B.close(!0)))})),B.trigger("open"))},close:function(a){return a&&(x.editable?f.focus():(B.$holder.off("focus.toOpen").focus(),setTimeout(function(){B.$holder.on("focus.toOpen",t)},0))),z.removeClass(y.active),e(f,"expanded",!1),setTimeout(function(){B.$root.removeClass(y.opened+" "+y.focused),e(B.$root[0],"hidden",!0)},0),w.open?(w.open=!1,v&&k.css("overflow","").css("padding-right","-="+d()),j.off("."+w.id),B.trigger("close")):B},clear:function(a){return B.set("clear",null,a)},set:function(b,c,d){var e,f,g=a.isPlainObject(b),h=g?b:{};if(d=g&&a.isPlainObject(c)?c:d||{},b){g||(h[b]=c);for(e in h)f=h[e],e in B.component.item&&(void 0===f&&(f=null),B.component.set(e,f,d)),("select"==e||"clear"==e)&&z.val("clear"==e?"":B.get(e,x.format)).trigger("change");B.render()}return d.muted?B:B.trigger("set",h)},get:function(a,c){if(a=a||"value",null!=w[a])return w[a];if("valueSubmit"==a){if(B._hidden)return B._hidden.value;a="value"}if("value"==a)return f.value;if(a in B.component.item){if("string"==typeof c){var d=B.component.get(a);return d?b._.trigger(B.component.formats.toString,B.component,[c,d]):""}return B.component.get(a)}},on:function(b,c,d){var e,f,g=a.isPlainObject(b),h=g?b:{};if(b){g||(h[b]=c);for(e in h)f=h[e],d&&(e="_"+e),w.methods[e]=w.methods[e]||[],w.methods[e].push(f)}return B},off:function(){var a,b,c=arguments;for(a=0,namesCount=c.length;a<namesCount;a+=1)b=c[a],b in w.methods&&delete w.methods[b];return B},trigger:function(a,c){var d=function(a){var d=w.methods[a];d&&d.map(function(a){b._.trigger(a,B,[c])})};return d("_"+a),d(a),B}};return new A}function c(a){var b,c="position";return a.currentStyle?b=a.currentStyle[c]:window.getComputedStyle&&(b=getComputedStyle(a)[c]),"fixed"==b}function d(){if(k.height()<=i.height())return 0;var b=a('<div style="visibility:hidden;width:100px" />').appendTo("body"),c=b[0].offsetWidth;b.css("overflow","scroll");var d=a('<div style="width:100%" />').appendTo(b),e=d[0].offsetWidth;return b.remove(),c-e}function e(b,c,d){if(a.isPlainObject(c))for(var e in c)f(b,e,c[e]);else f(b,c,d)}function f(a,b,c){a.setAttribute(("role"==b?"":"aria-")+b,c)}function g(b,c){a.isPlainObject(b)||(b={attribute:c}),c="";for(var d in b){var e=("role"==d?"":"aria-")+d,f=b[d];c+=null==f?"":e+'="'+b[d]+'"'}return c}function h(){try{return document.activeElement}catch(a){}}var i=a(window),j=a(document),k=a(document.documentElement),l=null!=document.documentElement.style.transition;return b.klasses=function(a){return a=a||"picker",{picker:a,opened:a+"--opened",focused:a+"--focused",input:a+"__input",active:a+"__input--active",target:a+"__input--target",holder:a+"__holder",frame:a+"__frame",wrap:a+"__wrap",box:a+"__box"}},b._={group:function(a){for(var c,d="",e=b._.trigger(a.min,a);e<=b._.trigger(a.max,a,[e]);e+=a.i)c=b._.trigger(a.item,a,[e]),d+=b._.node(a.node,c[0],c[1],c[2]);return d},node:function(b,c,d,e){return c?(c=a.isArray(c)?c.join(""):c,d=d?' class="'+d+'"':"",e=e?" "+e:"","<"+b+d+e+">"+c+"</"+b+">"):""},lead:function(a){return(10>a?"0":"")+a},trigger:function(a,b,c){return"function"==typeof a?a.apply(b,c||[]):a},digits:function(a){return/\d/.test(a[1])?2:1},isDate:function(a){return{}.toString.call(a).indexOf("Date")>-1&&this.isInteger(a.getDate())},isInteger:function(a){return{}.toString.call(a).indexOf("Number")>-1&&a%1===0},ariaAttr:g},b.extend=function(c,d){a.fn[c]=function(e,f){var g=this.data(c);return"picker"==e?g:g&&"string"==typeof e?b._.trigger(g[e],g,[f]):this.each(function(){var f=a(this);f.data(c)||new b(this,c,d,e)})},a.fn[c].defaults=d.defaults},b}); -!function(a){a(Picker,jQuery)}(function(a,b){function c(a,b){var c=this,d=a.$node[0],e=d.value,f=a.$node.data("value"),g=f||e,h=f?b.formatSubmit:b.format,i=function(){return d.currentStyle?"rtl"==d.currentStyle.direction:"rtl"==getComputedStyle(a.$root[0]).direction};c.settings=b,c.$node=a.$node,c.queue={min:"measure create",max:"measure create",now:"now create",select:"parse create validate",highlight:"parse navigate create validate",view:"parse create validate viewset",disable:"deactivate",enable:"activate"},c.item={},c.item.clear=null,c.item.disable=(b.disable||[]).slice(0),c.item.enable=-function(a){return a[0]===!0?a.shift():-1}(c.item.disable),c.set("min",b.min).set("max",b.max).set("now"),g?c.set("select",g,{format:h,defaultValue:!0}):c.set("select",null).set("highlight",c.item.now),c.key={40:7,38:-7,39:function(){return i()?-1:1},37:function(){return i()?1:-1},go:function(a){var b=c.item.highlight,d=new Date(b.year,b.month,b.date+a);c.set("highlight",d,{interval:a}),this.render()}},a.on("render",function(){a.$root.find("."+b.klass.selectMonth).on("change",function(){var c=this.value;c&&(a.set("highlight",[a.get("view").year,c,a.get("highlight").date]),a.$root.find("."+b.klass.selectMonth).trigger("focus"))}),a.$root.find("."+b.klass.selectYear).on("change",function(){var c=this.value;c&&(a.set("highlight",[c,a.get("view").month,a.get("highlight").date]),a.$root.find("."+b.klass.selectYear).trigger("focus"))})},1).on("open",function(){var d="";c.disabled(c.get("now"))&&(d=":not(."+b.klass.buttonToday+")"),a.$root.find("button"+d+", select").attr("disabled",!1)},1).on("close",function(){a.$root.find("button, select").attr("disabled",!0)},1)}var d=7,e=6,f=a._;c.prototype.set=function(a,b,c){var d=this,e=d.item;return null===b?("clear"==a&&(a="select"),e[a]=b,d):(e["enable"==a?"disable":"flip"==a?"enable":a]=d.queue[a].split(" ").map(function(e){return b=d[e](a,b,c)}).pop(),"select"==a?d.set("highlight",e.select,c):"highlight"==a?d.set("view",e.highlight,c):a.match(/^(flip|min|max|disable|enable)$/)&&(e.select&&d.disabled(e.select)&&d.set("select",e.select,c),e.highlight&&d.disabled(e.highlight)&&d.set("highlight",e.highlight,c)),d)},c.prototype.get=function(a){return this.item[a]},c.prototype.create=function(a,c,d){var e,g=this;return c=void 0===c?a:c,c==-(1/0)||c==1/0?e=c:b.isPlainObject(c)&&f.isInteger(c.pick)?c=c.obj:b.isArray(c)?(c=new Date(c[0],c[1],c[2]),c=f.isDate(c)?c:g.create().obj):c=f.isInteger(c)||f.isDate(c)?g.normalize(new Date(c),d):g.now(a,c,d),{year:e||c.getFullYear(),month:e||c.getMonth(),date:e||c.getDate(),day:e||c.getDay(),obj:e||c,pick:e||c.getTime()}},c.prototype.createRange=function(a,c){var d=this,e=function(a){return a===!0||b.isArray(a)||f.isDate(a)?d.create(a):a};return f.isInteger(a)||(a=e(a)),f.isInteger(c)||(c=e(c)),f.isInteger(a)&&b.isPlainObject(c)?a=[c.year,c.month,c.date+a]:f.isInteger(c)&&b.isPlainObject(a)&&(c=[a.year,a.month,a.date+c]),{from:e(a),to:e(c)}},c.prototype.withinRange=function(a,b){return a=this.createRange(a.from,a.to),b.pick>=a.from.pick&&b.pick<=a.to.pick},c.prototype.overlapRanges=function(a,b){var c=this;return a=c.createRange(a.from,a.to),b=c.createRange(b.from,b.to),c.withinRange(a,b.from)||c.withinRange(a,b.to)||c.withinRange(b,a.from)||c.withinRange(b,a.to)},c.prototype.now=function(a,b,c){return b=new Date,c&&c.rel&&b.setDate(b.getDate()+c.rel),this.normalize(b,c)},c.prototype.navigate=function(a,c,d){var e,f,g,h,i=b.isArray(c),j=b.isPlainObject(c),k=this.item.view;if(i||j){for(j?(f=c.year,g=c.month,h=c.date):(f=+c[0],g=+c[1],h=+c[2]),d&&d.nav&&k&&k.month!==g&&(f=k.year,g=k.month),e=new Date(f,g+(d&&d.nav?d.nav:0),1),f=e.getFullYear(),g=e.getMonth();new Date(f,g,h).getMonth()!==g;)h-=1;c=[f,g,h]}return c},c.prototype.normalize=function(a){return a.setHours(0,0,0,0),a},c.prototype.measure=function(a,b){var c=this;return b?"string"==typeof b?b=c.parse(a,b):f.isInteger(b)&&(b=c.now(a,b,{rel:b})):b="min"==a?-(1/0):1/0,b},c.prototype.viewset=function(a,b){return this.create([b.year,b.month,1])},c.prototype.validate=function(a,c,d){var e,g,h,i,j=this,k=c,l=d&&d.interval?d.interval:1,m=-1===j.item.enable,n=j.item.min,o=j.item.max,p=m&&j.item.disable.filter(function(a){if(b.isArray(a)){var d=j.create(a).pick;d<c.pick?e=!0:d>c.pick&&(g=!0)}return f.isInteger(a)}).length;if((!d||!d.nav&&!d.defaultValue)&&(!m&&j.disabled(c)||m&&j.disabled(c)&&(p||e||g)||!m&&(c.pick<=n.pick||c.pick>=o.pick)))for(m&&!p&&(!g&&l>0||!e&&0>l)&&(l*=-1);j.disabled(c)&&(Math.abs(l)>1&&(c.month<k.month||c.month>k.month)&&(c=k,l=l>0?1:-1),c.pick<=n.pick?(h=!0,l=1,c=j.create([n.year,n.month,n.date+(c.pick===n.pick?0:-1)])):c.pick>=o.pick&&(i=!0,l=-1,c=j.create([o.year,o.month,o.date+(c.pick===o.pick?0:1)])),!h||!i);)c=j.create([c.year,c.month,c.date+l]);return c},c.prototype.disabled=function(a){var c=this,d=c.item.disable.filter(function(d){return f.isInteger(d)?a.day===(c.settings.firstDay?d:d-1)%7:b.isArray(d)||f.isDate(d)?a.pick===c.create(d).pick:b.isPlainObject(d)?c.withinRange(d,a):void 0});return d=d.length&&!d.filter(function(a){return b.isArray(a)&&"inverted"==a[3]||b.isPlainObject(a)&&a.inverted}).length,-1===c.item.enable?!d:d||a.pick<c.item.min.pick||a.pick>c.item.max.pick},c.prototype.parse=function(a,b,c){var d=this,e={};return b&&"string"==typeof b?(c&&c.format||(c=c||{},c.format=d.settings.format),d.formats.toArray(c.format).map(function(a){var c=d.formats[a],g=c?f.trigger(c,d,[b,e]):a.replace(/^!/,"").length;c&&(e[a]=b.substr(0,g)),b=b.substr(g)}),[e.yyyy||e.yy,+(e.mm||e.m)-1,e.dd||e.d]):b},c.prototype.formats=function(){function a(a,b,c){var d=a.match(/[^\x00-\x7F]+|\w+/)[0];return c.mm||c.m||(c.m=b.indexOf(d)+1),d.length}function b(a){return a.match(/\w+/)[0].length}return{d:function(a,b){return a?f.digits(a):b.date},dd:function(a,b){return a?2:f.lead(b.date)},ddd:function(a,c){return a?b(a):this.settings.weekdaysShort[c.day]},dddd:function(a,c){return a?b(a):this.settings.weekdaysFull[c.day]},m:function(a,b){return a?f.digits(a):b.month+1},mm:function(a,b){return a?2:f.lead(b.month+1)},mmm:function(b,c){var d=this.settings.monthsShort;return b?a(b,d,c):d[c.month]},mmmm:function(b,c){var d=this.settings.monthsFull;return b?a(b,d,c):d[c.month]},yy:function(a,b){return a?2:(""+b.year).slice(2)},yyyy:function(a,b){return a?4:b.year},toArray:function(a){return a.split(/(d{1,4}|m{1,4}|y{4}|yy|!.)/g)},toString:function(a,b){var c=this;return c.formats.toArray(a).map(function(a){return f.trigger(c.formats[a],c,[0,b])||a.replace(/^!/,"")}).join("")}}}(),c.prototype.isDateExact=function(a,c){var d=this;return f.isInteger(a)&&f.isInteger(c)||"boolean"==typeof a&&"boolean"==typeof c?a===c:(f.isDate(a)||b.isArray(a))&&(f.isDate(c)||b.isArray(c))?d.create(a).pick===d.create(c).pick:b.isPlainObject(a)&&b.isPlainObject(c)?d.isDateExact(a.from,c.from)&&d.isDateExact(a.to,c.to):!1},c.prototype.isDateOverlap=function(a,c){var d=this,e=d.settings.firstDay?1:0;return f.isInteger(a)&&(f.isDate(c)||b.isArray(c))?(a=a%7+e,a===d.create(c).day+1):f.isInteger(c)&&(f.isDate(a)||b.isArray(a))?(c=c%7+e,c===d.create(a).day+1):b.isPlainObject(a)&&b.isPlainObject(c)?d.overlapRanges(a,c):!1},c.prototype.flipEnable=function(a){var b=this.item;b.enable=a||(-1==b.enable?1:-1)},c.prototype.deactivate=function(a,c){var d=this,e=d.item.disable.slice(0);return"flip"==c?d.flipEnable():c===!1?(d.flipEnable(1),e=[]):c===!0?(d.flipEnable(-1),e=[]):c.map(function(a){for(var c,g=0;g<e.length;g+=1)if(d.isDateExact(a,e[g])){c=!0;break}c||(f.isInteger(a)||f.isDate(a)||b.isArray(a)||b.isPlainObject(a)&&a.from&&a.to)&&e.push(a)}),e},c.prototype.activate=function(a,c){var d=this,e=d.item.disable,g=e.length;return"flip"==c?d.flipEnable():c===!0?(d.flipEnable(1),e=[]):c===!1?(d.flipEnable(-1),e=[]):c.map(function(a){var c,h,i,j;for(i=0;g>i;i+=1){if(h=e[i],d.isDateExact(h,a)){c=e[i]=null,j=!0;break}if(d.isDateOverlap(h,a)){b.isPlainObject(a)?(a.inverted=!0,c=a):b.isArray(a)?(c=a,c[3]||c.push("inverted")):f.isDate(a)&&(c=[a.getFullYear(),a.getMonth(),a.getDate(),"inverted"]);break}}if(c)for(i=0;g>i;i+=1)if(d.isDateExact(e[i],a)){e[i]=null;break}if(j)for(i=0;g>i;i+=1)if(d.isDateOverlap(e[i],a)){e[i]=null;break}c&&e.push(c)}),e.filter(function(a){return null!=a})},c.prototype.nodes=function(a){var b=this,c=b.settings,g=b.item,h=g.now,i=g.select,j=g.highlight,k=g.view,l=g.disable,m=g.min,n=g.max,o=function(a,b){return c.firstDay&&(a.push(a.shift()),b.push(b.shift())),f.node("thead",f.node("tr",f.group({min:0,max:d-1,i:1,node:"th",item:function(d){return[a[d],c.klass.weekdays,'scope=col title="'+b[d]+'"']}})))}((c.showWeekdaysFull?c.weekdaysFull:c.weekdaysShort).slice(0),c.weekdaysFull.slice(0)),p=function(a){return f.node("div"," ",c.klass["nav"+(a?"Next":"Prev")]+(a&&k.year>=n.year&&k.month>=n.month||!a&&k.year<=m.year&&k.month<=m.month?" "+c.klass.navDisabled:""),"data-nav="+(a||-1)+" "+f.ariaAttr({role:"button",controls:b.$node[0].id+"_table"})+' title="'+(a?c.labelMonthNext:c.labelMonthPrev)+'"')},q=function(){var d=c.showMonthsShort?c.monthsShort:c.monthsFull;return c.selectMonths?f.node("select",f.group({min:0,max:11,i:1,node:"option",item:function(a){return[d[a],0,"value="+a+(k.month==a?" selected":"")+(k.year==m.year&&a<m.month||k.year==n.year&&a>n.month?" disabled":"")]}}),c.klass.selectMonth,(a?"":"disabled")+" "+f.ariaAttr({controls:b.$node[0].id+"_table"})+' title="'+c.labelMonthSelect+'"'):f.node("div",d[k.month],c.klass.month)},r=function(){var d=k.year,e=c.selectYears===!0?5:~~(c.selectYears/2);if(e){var g=m.year,h=n.year,i=d-e,j=d+e;if(g>i&&(j+=g-i,i=g),j>h){var l=i-g,o=j-h;i-=l>o?o:l,j=h}return f.node("select",f.group({min:i,max:j,i:1,node:"option",item:function(a){return[a,0,"value="+a+(d==a?" selected":"")]}}),c.klass.selectYear,(a?"":"disabled")+" "+f.ariaAttr({controls:b.$node[0].id+"_table"})+' title="'+c.labelYearSelect+'"')}return f.node("div",d,c.klass.year)};return f.node("div",(c.selectYears?r()+q():q()+r())+p()+p(1),c.klass.header)+f.node("table",o+f.node("tbody",f.group({min:0,max:e-1,i:1,node:"tr",item:function(a){var e=c.firstDay&&0===b.create([k.year,k.month,1]).day?-7:0;return[f.group({min:d*a-k.day+e+1,max:function(){return this.min+d-1},i:1,node:"td",item:function(a){a=b.create([k.year,k.month,a+(c.firstDay?1:0)]);var d=i&&i.pick==a.pick,e=j&&j.pick==a.pick,g=l&&b.disabled(a)||a.pick<m.pick||a.pick>n.pick,o=f.trigger(b.formats.toString,b,[c.format,a]);return[f.node("div",a.date,function(b){return b.push(k.month==a.month?c.klass.infocus:c.klass.outfocus),h.pick==a.pick&&b.push(c.klass.now),d&&b.push(c.klass.selected),e&&b.push(c.klass.highlighted),g&&b.push(c.klass.disabled),b.join(" ")}([c.klass.day]),"data-pick="+a.pick+" "+f.ariaAttr({role:"gridcell",label:o,selected:d&&b.$node.val()===o?!0:null,activedescendant:e?!0:null,disabled:g?!0:null})),"",f.ariaAttr({role:"presentation"})]}})]}})),c.klass.table,'id="'+b.$node[0].id+'_table" '+f.ariaAttr({role:"grid",controls:b.$node[0].id,readonly:!0}))+f.node("div",f.node("button",c.today,c.klass.buttonToday,"type=button data-pick="+h.pick+(a&&!b.disabled(h)?"":" disabled")+" "+f.ariaAttr({controls:b.$node[0].id}))+f.node("button",c.clear,c.klass.buttonClear,"type=button data-clear=1"+(a?"":" disabled")+" "+f.ariaAttr({controls:b.$node[0].id}))+f.node("button",c.close,c.klass.buttonClose,"type=button data-close=true "+(a?"":" disabled")+" "+f.ariaAttr({controls:b.$node[0].id})),c.klass.footer)},c.defaults=function(a){return{labelMonthNext:"Next month",labelMonthPrev:"Previous month",labelMonthSelect:"Select a month",labelYearSelect:"Select a year",monthsFull:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdaysFull:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],today:"Today",clear:"Clear",close:"Close",closeOnSelect:!0,closeOnClear:!0,format:"d mmmm, yyyy",klass:{table:a+"table",header:a+"header",navPrev:a+"nav--prev",navNext:a+"nav--next",navDisabled:a+"nav--disabled",month:a+"month",year:a+"year",selectMonth:a+"select--month",selectYear:a+"select--year",weekdays:a+"weekday",day:a+"day",disabled:a+"day--disabled",selected:a+"day--selected",highlighted:a+"day--highlighted",now:a+"day--today",infocus:a+"day--infocus",outfocus:a+"day--outfocus",footer:a+"footer",buttonClear:a+"button--clear",buttonToday:a+"button--today",buttonClose:a+"button--close"}}}(a.klasses().picker+"__"),a.extend("pickadate",c)}); -!function(a,b,c,d){function h(b,c){this.element=b,this.$element=a(b),this.init()}var e="textareaAutoSize",f="plugin_"+e,g=function(a){return a.replace(/\s/g,"").length>0};h.prototype={init:function(){var c=parseInt(this.$element.css("paddingBottom"))+parseInt(this.$element.css("paddingTop"))+parseInt(this.$element.css("borderTopWidth"))+parseInt(this.$element.css("borderBottomWidth"))||0;g(this.element.value)&&this.$element.height(this.element.scrollHeight-c),this.$element.on("input keyup",function(d){var e=a(b),f=e.scrollTop();a(this).height(0).height(this.scrollHeight-c),e.scrollTop(f)})}},a.fn[e]=function(b){return this.each(function(){a.data(this,f)||a.data(this,f,new h(this,b))}),this}}(jQuery,window,document); +(function ( factory ) { -!function(a,b){"use strict";"function"==typeof define&&define.amd?define([],function(){return b.apply(a)}):"object"==typeof exports?module.exports=b.call(a):a.Waves=b.call(a)}("object"==typeof global?global:this,function(){"use strict";function e(a){return null!==a&&a===a.window}function f(a){return e(a)?a:9===a.nodeType&&a.defaultView}function g(a){var b=typeof a;return"function"===b||"object"===b&&!!a}function h(a){return g(a)&&a.nodeType>0}function i(a){var d=c.call(a);return"[object String]"===d?b(a):g(a)&&/^\[object (HTMLCollection|NodeList|Object)\]$/.test(d)&&a.hasOwnProperty("length")?a:h(a)?[a]:[]}function j(a){var b,c,d={top:0,left:0},e=a&&a.ownerDocument;return b=e.documentElement,"undefined"!=typeof a.getBoundingClientRect&&(d=a.getBoundingClientRect()),c=f(e),{top:d.top+c.pageYOffset-b.clientTop,left:d.left+c.pageXOffset-b.clientLeft}}function k(a){var b="";for(var c in a)a.hasOwnProperty(c)&&(b+=c+":"+a[c]+";");return b}function n(a,b,c,d){if(c){d.classList.remove("waves-wrapping"),c.classList.remove("waves-rippling");var e=c.getAttribute("data-x"),f=c.getAttribute("data-y"),g=c.getAttribute("data-scale"),h=c.getAttribute("data-translate"),i=Date.now()-Number(c.getAttribute("data-hold")),j=350-i;0>j&&(j=0),"mousemove"===a.type&&(j=150);var m="mousemove"===a.type?2500:l.duration;setTimeout(function(){var a={top:f+"px",left:e+"px",opacity:"0","-webkit-transition-duration":m+"ms","-moz-transition-duration":m+"ms","-o-transition-duration":m+"ms","transition-duration":m+"ms","-webkit-transform":g+" "+h,"-moz-transform":g+" "+h,"-ms-transform":g+" "+h,"-o-transform":g+" "+h,transform:g+" "+h};c.setAttribute("style",k(a)),setTimeout(function(){try{d.removeChild(c),b.removeChild(d)}catch(a){return!1}},m)},j)}}function p(a){if(o.allowEvent(a)===!1)return null;for(var b=null,c=a.target||a.srcElement;null!==c.parentElement;){if(c.classList.contains("waves-effect")&&!(c instanceof SVGElement)){b=c;break}c=c.parentElement}return b}function q(a){var b=p(a);if(null!==b){if(b.disabled||b.getAttribute("disabled")||b.classList.contains("disabled"))return;if(o.registerEvent(a),"touchstart"===a.type&&l.delay){var c=!1,e=setTimeout(function(){e=null,l.show(a,b)},l.delay),f=function(d){e&&(clearTimeout(e),e=null,l.show(a,b)),c||(c=!0,l.hide(d,b))},g=function(a){e&&(clearTimeout(e),e=null),f(a)};b.addEventListener("touchmove",g,!1),b.addEventListener("touchend",f,!1),b.addEventListener("touchcancel",f,!1)}else l.show(a,b),d&&(b.addEventListener("touchend",l.hide,!1),b.addEventListener("touchcancel",l.hide,!1)),b.addEventListener("mouseup",l.hide,!1),b.addEventListener("mouseleave",l.hide,!1)}}var a=a||{},b=document.querySelectorAll.bind(document),c=Object.prototype.toString,d="ontouchstart"in window,l={duration:750,delay:200,show:function(a,b,c){if(2===a.button)return!1;b=b||this;var d=document.createElement("div");d.className="waves-wrap waves-wrapping",b.appendChild(d);var e=document.createElement("div");e.className="waves-ripple waves-rippling",d.appendChild(e);var f=j(b),g=0,h=0;"touches"in a&&a.touches.length?(g=a.touches[0].pageY-f.top,h=a.touches[0].pageX-f.left):(g=a.pageY-f.top,h=a.pageX-f.left),h=h>=0?h:0,g=g>=0?g:0;var i="scale("+b.clientWidth/100*3+")",m="translate(0,0)";c&&(m="translate("+c.x+"px, "+c.y+"px)"),e.setAttribute("data-hold",Date.now()),e.setAttribute("data-x",h),e.setAttribute("data-y",g),e.setAttribute("data-scale",i),e.setAttribute("data-translate",m);var n={top:g+"px",left:h+"px"};e.classList.add("waves-notransition"),e.setAttribute("style",k(n)),e.classList.remove("waves-notransition"),n["-webkit-transform"]=i+" "+m,n["-moz-transform"]=i+" "+m,n["-ms-transform"]=i+" "+m,n["-o-transform"]=i+" "+m,n.transform=i+" "+m,n.opacity="1";var o="mousemove"===a.type?2500:l.duration;n["-webkit-transition-duration"]=o+"ms",n["-moz-transition-duration"]=o+"ms",n["-o-transition-duration"]=o+"ms",n["transition-duration"]=o+"ms",e.setAttribute("style",k(n))},hide:function(a,b){b=b||this;for(var c=b.getElementsByClassName("waves-wrapping"),d=b.getElementsByClassName("waves-rippling"),e=0,f=d.length;f>e;e++)n(a,b,d[e],c[e])}},m={input:function(a){var b=a.parentNode;if("i"!==b.tagName.toLowerCase()||!b.classList.contains("waves-effect")){var c=document.createElement("i");c.className=a.className+" waves-input-wrapper",a.className="waves-button-input",b.replaceChild(c,a),c.appendChild(a);var d=window.getComputedStyle(a,null),e=d.color,f=d.backgroundColor;c.setAttribute("style","color:"+e+";background:"+f),a.setAttribute("style","background-color:rgba(0,0,0,0);")}},img:function(a){var b=a.parentNode;if("i"!==b.tagName.toLowerCase()||!b.classList.contains("waves-effect")){var c=document.createElement("i");b.replaceChild(c,a),c.appendChild(a)}}},o={touches:0,allowEvent:function(a){var b=!0;return/^(mousedown|mousemove)$/.test(a.type)&&o.touches&&(b=!1),b},registerEvent:function(a){var b=a.type;"touchstart"===b?o.touches+=1:/^(touchend|touchcancel)$/.test(b)&&setTimeout(function(){o.touches&&(o.touches-=1)},500)}};return a.init=function(a){var b=document.body;a=a||{},"duration"in a&&(l.duration=a.duration),"delay"in a&&(l.delay=a.delay),d&&(b.addEventListener("touchstart",q,!1),b.addEventListener("touchcancel",o.registerEvent,!1),b.addEventListener("touchend",o.registerEvent,!1)),b.addEventListener("mousedown",q,!1)},a.attach=function(a,b){a=i(a),"[object Array]"===c.call(b)&&(b=b.join(" ")),b=b?" "+b:"";for(var d,e,f=0,g=a.length;g>f;f++)d=a[f],e=d.tagName.toLowerCase(),-1!==["input","img"].indexOf(e)&&(m[e](d),d=d.parentElement),-1===d.className.indexOf("waves-effect")&&(d.className+=" waves-effect"+b)},a.ripple=function(a,b){a=i(a);var c=a.length;if(b=b||{},b.wait=b.wait||0,b.position=b.position||null,c)for(var d,e,f,g={},h=0,k={type:"mousedown",button:1},m=function(a,b){return function(){l.hide(a,b)}};c>h;h++)if(d=a[h],e=b.position||{x:d.clientWidth/2,y:d.clientHeight/2},f=j(d),g.x=f.left+e.x,g.y=f.top+e.y,k.pageX=g.x,k.pageY=g.y,l.show(k,d),b.wait>=0&&null!==b.wait){var n={type:"mouseup",button:1};setTimeout(m(n,d),b.wait)}},a.calm=function(a){a=i(a);for(var b={type:"mouseup",button:1},c=0,d=a.length;d>c;c++)l.hide(b,a[c])},a.displayEffect=function(b){console.error("Waves.displayEffect() has been deprecated and will be removed in future version. Please use Waves.init() to initialize Waves effect"),a.init(b)},a}); + // AMD. + if ( typeof undefined == 'function' && undefined.amd ) + undefined( 'picker', ['jquery'], factory ); -+function ($) { + // Node.js/browserify. + else module.exports = factory( $ ); - 'use strict' +}(function( $$$1 ) { - var Datepicker = function (element, options) { - this._element = element - this._options = options - } +var $window = $$$1( window ); +var $document = $$$1( document ); +var $html = $$$1( document.documentElement ); +var supportsTransitions = document.documentElement.style.transition != null; - if (typeof $.fn.pickadate === 'undefined') { - throw new Error('Material\'s JavaScript requires pickadate.js') - } - Datepicker.DEFAULTS = { - cancel : 'Cancel', - closeOnCancel : true, - closeOnSelect : false, - container : 'body', - disable : [], - firstDay : 0, - format : 'd/m/yyyy', - formatSubmit : '', - klass : { - // button - buttonClear : 'btn btn-outline-primary picker-button-clear', - buttonClose : 'btn btn-outline-primary picker-button-close', - buttonToday : 'btn btn-outline-primary picker-button-today', +/** + * The picker constructor that creates a blank picker. + */ +function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { - // day - day : 'picker-day', - disabled : 'picker-day-disabled', - highlighted : 'picker-day-highlighted', - infocus : 'picker-day-infocus', - now : 'picker-day-today', - outfocus : 'picker-day-outfocus', - selected : 'picker-day-selected', - weekdays : 'picker-weekday', + // If there’s no element, return the picker constructor. + if ( !ELEMENT ) return PickerConstructor - // element - box : 'picker-box', - footer : 'picker-footer', - frame : 'picker-frame', - header : 'picker-header', - holder : 'picker-holder', - table : 'picker-table', - wrap : 'picker-wrap', - // input element - active : 'picker-input-active', - input : 'picker-input', + var + IS_DEFAULT_THEME = false, - // month and year nav - month : 'picker-month', - navDisabled : 'picker-nav-disabled', - navNext : 'material-icons picker-nav-next', - navPrev : 'material-icons picker-nav-prev', - selectMonth : 'picker-select-month', - selectYear : 'picker-select-year', - year : 'picker-year', - // root picker - focused : 'picker-focused', - opened : 'picker-opened', - picker : 'picker' - }, - max : false, - min : false, - 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'], - ok : 'OK', - onClose : false, - onOpen : false, - onRender : false, - onSet : false, - onStart : false, - onStop : false, - selectMonths : false, - selectYears : false, - today : '', - weekdaysFull : ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], - weekdaysShort : ['S', 'M', 'T', 'W', 'T', 'F', 'S'] - } + // The state of the picker. + STATE = { + id: ELEMENT.id || 'P' + Math.abs( ~~(Math.random() * new Date()) ) + }, - Datepicker.prototype.display = function (datepickerApi, datepickerRoot, datepickerValue) { - $('.picker-date-display', datepickerRoot).remove() - $('.picker-wrap', datepickerRoot).prepend('<div class="picker-date-display">' + - '<div class="picker-date-display-top">' + - '<span class="picker-year-display">' + datepickerApi.get(datepickerValue, 'yyyy') + '</span>' + - '</div>' + - '<div class="picker-date-display-bottom">' + - '<span class="picker-weekday-display">' + datepickerApi.get(datepickerValue, 'dddd') + '</span>' + - '<span class="picker-day-display">' + datepickerApi.get(datepickerValue, 'd') + '</span>' + - '<span class="picker-month-display">' + datepickerApi.get(datepickerValue, 'mmm') + '</span>' + - '</div>' + - '</div>') - } + // Merge the defaults and options passed. + SETTINGS = COMPONENT ? $$$1.extend( true, {}, COMPONENT.defaults, OPTIONS ) : OPTIONS || {}, - Datepicker.prototype.show = function () { - var that = this - $(this._element).pickadate({ - clear : that._options.cancel, - close : that._options.ok, - closeOnClear : that._options.closeOnCancel, - closeOnSelect : that._options.closeOnSelect, - container : that._options.container, - disable : that._options.disable, - firstDay : that._options.firstDay, - format : that._options.format, - formatSubmit : that._options.formatSubmit, - klass : that._options.klass, - max : that._options.max, - min : that._options.min, - monthsFull : that._options.monthsFull, - monthsShort : that._options.monthsShort, - onClose : that._options.onClose, - onOpen : that._options.onOpen, - onRender : that._options.onRender, - onSet : that._options.onSet, - onStart : that._options.onStart, - onStop : that._options.onStop, - selectMonths : that._options.selectMonths, - selectYears : that._options.selectYears, - today : that._options.today, - weekdaysFull : that._options.weekdaysFull, - weekdaysShort : that._options.weekdaysShort - }) + // Merge the default classes with the settings classes. + CLASSES = $$$1.extend( {}, PickerConstructor.klasses(), SETTINGS.klass ), - var datepickerApi = $(this._element).pickadate('picker'), - datepickerNode = datepickerApi.$node, - datepickerRoot = datepickerApi.$root - datepickerApi.on({ - close: function () { - $(document.activeElement).blur() - }, - open: function () { - if (!$('.picker__date-display', datepickerRoot).length) { - that.display(datepickerApi, datepickerRoot, 'highlight') + // The element node wrapper into a jQuery object. + $ELEMENT = $$$1( ELEMENT ), + + + // Pseudo picker constructor. + PickerInstance = function() { + return this.start() + }, + + + // The picker prototype. + P = PickerInstance.prototype = { + + constructor: PickerInstance, + + $node: $ELEMENT, + + + /** + * Initialize everything + */ + start: function() { + + // If it’s already started, do nothing. + if ( STATE && STATE.start ) return P + + + // Update the picker states. + STATE.methods = {}; + STATE.start = true; + STATE.open = false; + STATE.type = ELEMENT.type; + + + // Confirm focus state, convert into text input to remove UA stylings, + // and set as readonly to prevent keyboard popup. + ELEMENT.autofocus = ELEMENT == getActiveElement(); + ELEMENT.readOnly = !SETTINGS.editable; + ELEMENT.id = ELEMENT.id || STATE.id; + if ( ELEMENT.type != 'text' ) { + ELEMENT.type = 'text'; + } + + + // Create a new picker component with the settings. + P.component = new COMPONENT(P, SETTINGS); + + + // Create the picker root and then prepare it. + P.$root = $$$1( '<div class="' + CLASSES.picker + '" id="' + ELEMENT.id + '_root" />' ); + prepareElementRoot(); + + + // Create the picker holder and then prepare it. + P.$holder = $$$1( createWrappedComponent() ).appendTo( P.$root ); + prepareElementHolder(); + + + // If there’s a format for the hidden input element, create the element. + if ( SETTINGS.formatSubmit ) { + prepareElementHidden(); + } + + + // Prepare the input element. + prepareElement(); + + + // Insert the hidden input as specified in the settings. + if ( SETTINGS.containerHidden ) $$$1( SETTINGS.containerHidden ).append( P._hidden ); + else $ELEMENT.after( P._hidden ); + + + // Insert the root as specified in the settings. + if ( SETTINGS.container ) $$$1( SETTINGS.container ).append( P.$root ); + else $ELEMENT.after( P.$root ); + + + // Bind the default component and settings events. + P.on({ + start: P.component.onStart, + render: P.component.onRender, + stop: P.component.onStop, + open: P.component.onOpen, + close: P.component.onClose, + set: P.component.onSet + }).on({ + start: SETTINGS.onStart, + render: SETTINGS.onRender, + stop: SETTINGS.onStop, + open: SETTINGS.onOpen, + close: SETTINGS.onClose, + set: SETTINGS.onSet + }); + + + // Once we’re all set, check the theme in use. + IS_DEFAULT_THEME = isUsingDefaultTheme( P.$holder[0] ); + + + // If the element has autofocus, open the picker. + if ( ELEMENT.autofocus ) { + P.open(); + } + + + // Trigger queued the “start” and “render” events. + return P.trigger( 'start' ).trigger( 'render' ) + }, //start + + + /** + * Render a new picker + */ + render: function( entireComponent ) { + + // Insert a new component holder in the root or box. + if ( entireComponent ) { + P.$holder = $$$1( createWrappedComponent() ); + prepareElementHolder(); + P.$root.html( P.$holder ); + } + else P.$root.find( '.' + CLASSES.box ).html( P.component.nodes( STATE.open ) ); + + // Trigger the queued “render” events. + return P.trigger( 'render' ) + }, //render + + + /** + * Destroy everything + */ + stop: function() { + + // If it’s already stopped, do nothing. + if ( !STATE.start ) return P + + // Then close the picker. + P.close(); + + // Remove the hidden field. + if ( P._hidden ) { + P._hidden.parentNode.removeChild( P._hidden ); + } + + // Remove the root. + P.$root.remove(); + + // Remove the input class, remove the stored data, and unbind + // the events (after a tick for IE - see `P.close`). + $ELEMENT.removeClass( CLASSES.input ).removeData( NAME ); + setTimeout( function() { + $ELEMENT.off( '.' + STATE.id ); + }, 0); + + // Restore the element state + ELEMENT.type = STATE.type; + ELEMENT.readOnly = false; + + // Trigger the queued “stop” events. + P.trigger( 'stop' ); + + // Reset the picker states. + STATE.methods = {}; + STATE.start = false; + + return P + }, //stop + + + /** + * Open up the picker + */ + open: function( dontGiveFocus ) { + + // If it’s already open, do nothing. + if ( STATE.open ) return P + + // Add the “active” class. + $ELEMENT.addClass( CLASSES.active ); + aria( ELEMENT, 'expanded', true ); + + // * A Firefox bug, when `html` has `overflow:hidden`, results in + // killing transitions :(. So add the “opened” state on the next tick. + // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289 + setTimeout( function() { + + // Add the “opened” class to the picker root. + P.$root.addClass( CLASSES.opened ); + aria( P.$root[0], 'hidden', false ); + + }, 0 ); + + // If we have to give focus, bind the element and doc events. + if ( dontGiveFocus !== false ) { + + // Set it as open. + STATE.open = true; + + // Prevent the page from scrolling. + if ( IS_DEFAULT_THEME ) { + $html. + css( 'overflow', 'hidden' ). + css( 'padding-right', '+=' + getScrollbarWidth() ); + } + + // Pass focus to the root element’s jQuery object. + focusPickerOnceOpened(); + + // Bind the document events. + $document.on( 'click.' + STATE.id + ' focusin.' + STATE.id, function( event ) { + + var target = event.target; + + // If the target of the event is not the element, close the picker picker. + // * Don’t worry about clicks or focusins on the root because those don’t bubble up. + // Also, for Firefox, a click on an `option` element bubbles up directly + // to the doc. So make sure the target wasn't the doc. + // * In Firefox stopPropagation() doesn’t prevent right-click events from bubbling, + // which causes the picker to unexpectedly close when right-clicking it. So make + // sure the event wasn’t a right-click. + if ( target != ELEMENT && target != document && event.which != 3 ) { + + // If the target was the holder that covers the screen, + // keep the element focused to maintain tabindex. + P.close( target === P.$holder[0] ); + } + + }).on( 'keydown.' + STATE.id, function( event ) { + + var + // Get the keycode. + keycode = event.keyCode, + + // Translate that to a selection change. + keycodeToMove = P.component.key[ keycode ], + + // Grab the target. + target = event.target; + + + // On escape, close the picker and give focus. + if ( keycode == 27 ) { + P.close( true ); + } + + + // Check if there is a key movement or “enter” keypress on the element. + else if ( target == P.$holder[0] && ( keycodeToMove || keycode == 13 ) ) { + + // Prevent the default action to stop page movement. + event.preventDefault(); + + // Trigger the key movement action. + if ( keycodeToMove ) { + PickerConstructor._.trigger( P.component.key.go, P, [ PickerConstructor._.trigger( keycodeToMove ) ] ); + } + + // On “enter”, if the highlighted item isn’t disabled, set the value and close. + else if ( !P.$root.find( '.' + CLASSES.highlighted ).hasClass( CLASSES.disabled ) ) { + P.set( 'select', P.component.item.highlight ); + if ( SETTINGS.closeOnSelect ) { + P.close( true ); + } + } + } + + + // If the target is within the root and “enter” is pressed, + // prevent the default action and trigger a click on the target instead. + else if ( $$$1.contains( P.$root[0], target ) && keycode == 13 ) { + event.preventDefault(); + target.click(); + } + }); + } + + // Trigger the queued “open” events. + return P.trigger( 'open' ) + }, //open + + + /** + * Close the picker + */ + close: function( giveFocus ) { + + // If we need to give focus, do it before changing states. + if ( giveFocus ) { + if ( SETTINGS.editable ) { + ELEMENT.focus(); + } + else { + // ....ah yes! It would’ve been incomplete without a crazy workaround for IE :| + // The focus is triggered *after* the close has completed - causing it + // to open again. So unbind and rebind the event at the next tick. + P.$holder.off( 'focus.toOpen' ).focus(); + setTimeout( function() { + P.$holder.on( 'focus.toOpen', handleFocusToOpenEvent ); + }, 0 ); + } + } + + // Remove the “active” class. + $ELEMENT.removeClass( CLASSES.active ); + aria( ELEMENT, 'expanded', false ); + + // * A Firefox bug, when `html` has `overflow:hidden`, results in + // killing transitions :(. So remove the “opened” state on the next tick. + // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289 + setTimeout( function() { + + // Remove the “opened” and “focused” class from the picker root. + P.$root.removeClass( CLASSES.opened + ' ' + CLASSES.focused ); + aria( P.$root[0], 'hidden', true ); + + }, 0 ); + + // If it’s already closed, do nothing more. + if ( !STATE.open ) return P + + // Set it as closed. + STATE.open = false; + + // Allow the page to scroll. + if ( IS_DEFAULT_THEME ) { + $html. + css( 'overflow', '' ). + css( 'padding-right', '-=' + getScrollbarWidth() ); + } + + // Unbind the document events. + $document.off( '.' + STATE.id ); + + // Trigger the queued “close” events. + return P.trigger( 'close' ) + }, //close + + + /** + * Clear the values + */ + clear: function( options ) { + return P.set( 'clear', null, options ) + }, //clear + + + /** + * Set something + */ + set: function( thing, value, options ) { + + var thingItem, thingValue, + thingIsObject = $$$1.isPlainObject( thing ), + thingObject = thingIsObject ? thing : {}; + + // Make sure we have usable options. + options = thingIsObject && $$$1.isPlainObject( value ) ? value : options || {}; + + if ( thing ) { + + // If the thing isn’t an object, make it one. + if ( !thingIsObject ) { + thingObject[ thing ] = value; + } + + // Go through the things of items to set. + for ( thingItem in thingObject ) { + + // Grab the value of the thing. + thingValue = thingObject[ thingItem ]; + + // First, if the item exists and there’s a value, set it. + if ( thingItem in P.component.item ) { + if ( thingValue === undefined ) thingValue = null; + P.component.set( thingItem, thingValue, options ); + } + + // Then, check to update the element value and broadcast a change. + if ( thingItem == 'select' || thingItem == 'clear' ) { + $ELEMENT. + val( thingItem == 'clear' ? '' : P.get( thingItem, SETTINGS.format ) ). + trigger( 'change' ); + } + } + + // Render a new picker. + P.render(); + } + + // When the method isn’t muted, trigger queued “set” events and pass the `thingObject`. + return options.muted ? P : P.trigger( 'set', thingObject ) + }, //set + + + /** + * Get something + */ + get: function( thing, format ) { + + // Make sure there’s something to get. + thing = thing || 'value'; + + // If a picker state exists, return that. + if ( STATE[ thing ] != null ) { + return STATE[ thing ] + } + + // Return the submission value, if that. + if ( thing == 'valueSubmit' ) { + if ( P._hidden ) { + return P._hidden.value + } + thing = 'value'; + } + + // Return the value, if that. + if ( thing == 'value' ) { + return ELEMENT.value + } + + // Check if a component item exists, return that. + if ( thing in P.component.item ) { + if ( typeof format == 'string' ) { + var thingValue = P.component.get( thing ); + return thingValue ? + PickerConstructor._.trigger( + P.component.formats.toString, + P.component, + [ format, thingValue ] + ) : '' + } + return P.component.get( thing ) + } + }, //get + + + + /** + * Bind events on the things. + */ + on: function( thing, method, internal ) { + + var thingName, thingMethod, + thingIsObject = $$$1.isPlainObject( thing ), + thingObject = thingIsObject ? thing : {}; + + if ( thing ) { + + // If the thing isn’t an object, make it one. + if ( !thingIsObject ) { + thingObject[ thing ] = method; + } + + // Go through the things to bind to. + for ( thingName in thingObject ) { + + // Grab the method of the thing. + thingMethod = thingObject[ thingName ]; + + // If it was an internal binding, prefix it. + if ( internal ) { + thingName = '_' + thingName; + } + + // Make sure the thing methods collection exists. + STATE.methods[ thingName ] = STATE.methods[ thingName ] || []; + + // Add the method to the relative method collection. + STATE.methods[ thingName ].push( thingMethod ); + } + } + + return P + }, //on + + + + /** + * Unbind events on the things. + */ + off: function() { + var i, thingName, + names = arguments; + for ( i = 0, namesCount = names.length; i < namesCount; i += 1 ) { + thingName = names[i]; + if ( thingName in STATE.methods ) { + delete STATE.methods[thingName]; + } + } + return P + }, + + + /** + * Fire off method events. + */ + trigger: function( name, data ) { + var _trigger = function( name ) { + var methodList = STATE.methods[ name ]; + if ( methodList ) { + methodList.map( function( method ) { + PickerConstructor._.trigger( method, P, [ data ] ); + }); + } + }; + _trigger( '_' + name ); + _trigger( name ); + return P + } //trigger + }; //PickerInstance.prototype + + + /** + * Wrap the picker holder components together. + */ + function createWrappedComponent() { + + // Create a picker wrapper holder + return PickerConstructor._.node( 'div', + + // Create a picker wrapper node + PickerConstructor._.node( 'div', + + // Create a picker frame + PickerConstructor._.node( 'div', + + // Create a picker box node + PickerConstructor._.node( 'div', + + // Create the components nodes. + P.component.nodes( STATE.open ), + + // The picker box class + CLASSES.box + ), + + // Picker wrap class + CLASSES.wrap + ), + + // Picker frame class + CLASSES.frame + ), + + // Picker holder class + CLASSES.holder, + + 'tabindex="-1"' + ) //endreturn + } //createWrappedComponent + + + + /** + * Prepare the input element with all bindings. + */ + function prepareElement() { + + $ELEMENT. + + // Store the picker data by component name. + data(NAME, P). + + // Add the “input” class name. + addClass(CLASSES.input). + + // If there’s a `data-value`, update the value of the element. + val( $ELEMENT.data('value') ? + P.get('select', SETTINGS.format) : + ELEMENT.value + ); + + + // Only bind keydown events if the element isn’t editable. + if ( !SETTINGS.editable ) { + + $ELEMENT. + + // On focus/click, open the picker. + on( 'focus.' + STATE.id + ' click.' + STATE.id, function(event) { + event.preventDefault(); + P.open(); + }). + + // Handle keyboard event based on the picker being opened or not. + on( 'keydown.' + STATE.id, handleKeydownEvent ); } - }, - set: function () { - if (datepickerApi.get('select') !== null) { - that.display(datepickerApi, datepickerRoot, 'select') + + + // Update the aria attributes. + aria(ELEMENT, { + haspopup: true, + expanded: false, + readonly: false, + owns: ELEMENT.id + '_root' + }); + } + + + /** + * Prepare the root picker element with all bindings. + */ + function prepareElementRoot() { + aria( P.$root[0], 'hidden', true ); + } + + + /** + * Prepare the holder picker element with all bindings. + */ + function prepareElementHolder() { + + P.$holder. + + on({ + + // For iOS8. + keydown: handleKeydownEvent, + + 'focus.toOpen': handleFocusToOpenEvent, + + blur: function() { + // Remove the “target” class. + $ELEMENT.removeClass( CLASSES.target ); + }, + + // When something within the holder is focused, stop from bubbling + // to the doc and remove the “focused” state from the root. + focusin: function( event ) { + P.$root.removeClass( CLASSES.focused ); + event.stopPropagation(); + }, + + // When something within the holder is clicked, stop it + // from bubbling to the doc. + 'mousedown click': function( event ) { + + var target = event.target; + + // Make sure the target isn’t the root holder so it can bubble up. + if ( target != P.$holder[0] ) { + + event.stopPropagation(); + + // * For mousedown events, cancel the default action in order to + // prevent cases where focus is shifted onto external elements + // when using things like jQuery mobile or MagnificPopup (ref: #249 & #120). + // Also, for Firefox, don’t prevent action on the `option` element. + if ( event.type == 'mousedown' && !$$$1( target ).is( 'input, select, textarea, button, option' )) { + + event.preventDefault(); + + // Re-focus onto the holder so that users can click away + // from elements focused within the picker. + P.$holder[0].focus(); + } + } + } + + }). + + // If there’s a click on an actionable element, carry out the actions. + on( 'click', '[data-pick], [data-nav], [data-clear], [data-close]', function() { + + var $target = $$$1( this ), + targetData = $target.data(), + targetDisabled = $target.hasClass( CLASSES.navDisabled ) || $target.hasClass( CLASSES.disabled ), + + // * For IE, non-focusable elements can be active elements as well + // (http://stackoverflow.com/a/2684561). + activeElement = getActiveElement(); + activeElement = activeElement && ( activeElement.type || activeElement.href ); + + // If it’s disabled or nothing inside is actively focused, re-focus the element. + if ( targetDisabled || activeElement && !$$$1.contains( P.$root[0], activeElement ) ) { + P.$holder[0].focus(); + } + + // If something is superficially changed, update the `highlight` based on the `nav`. + if ( !targetDisabled && targetData.nav ) { + P.set( 'highlight', P.component.item.highlight, { nav: targetData.nav } ); + } + + // If something is picked, set `select` then close with focus. + else if ( !targetDisabled && 'pick' in targetData ) { + P.set( 'select', targetData.pick ); + if ( SETTINGS.closeOnSelect ) { + P.close( true ); + } + } + + // If a “clear” button is pressed, empty the values and close with focus. + else if ( targetData.clear ) { + P.clear(); + if ( SETTINGS.closeOnClear ) { + P.close( true ); + } + } + + else if ( targetData.close ) { + P.close( true ); + } + + }); //P.$holder + + } + + + /** + * Prepare the hidden input element along with all bindings. + */ + function prepareElementHidden() { + + var name; + + if ( SETTINGS.hiddenName === true ) { + name = ELEMENT.name; + ELEMENT.name = ''; } - } - }) - } + else { + name = [ + typeof SETTINGS.hiddenPrefix == 'string' ? SETTINGS.hiddenPrefix : '', + typeof SETTINGS.hiddenSuffix == 'string' ? SETTINGS.hiddenSuffix : '_submit' + ]; + name = name[0] + ELEMENT.name + name[1]; + } - function Plugin (option) { - return this.each(function () { - var data = $(this).data('bs.pickdate') - var options = $.extend({}, Datepicker.DEFAULTS, $(this).data(), typeof option == 'object' && option) + P._hidden = $$$1( + '<input ' + + 'type=hidden ' + - if (!data) { - $(this).data('bs.pickdate', (data = new Datepicker(this, options))) - } + // Create the name using the original input’s with a prefix and suffix. + 'name="' + name + '"' + - data.show() - }) - } + // If the element has a value, set the hidden value as well. + ( + $ELEMENT.data('value') || ELEMENT.value ? + ' value="' + P.get('select', SETTINGS.formatSubmit) + '"' : + '' + ) + + '>' + )[0]; - var old = $.fn.pickdate + $ELEMENT. - $.fn.pickdate = Plugin - $.fn.pickdate.Constructor = Datepicker + // If the value changes, update the hidden input with the correct format. + on('change.' + STATE.id, function() { + P._hidden.value = ELEMENT.value ? + P.get('select', SETTINGS.formatSubmit) : + ''; + }); + } - $.fn.pickdate.noConflict = function () { - $.fn.pickdate = old - return this - } -}(jQuery) + // Wait for transitions to end before focusing the holder. Otherwise, while + // using the `container` option, the view jumps to the container. + function focusPickerOnceOpened() { -$(function () { - if ($('.textarea-autosize').length && (typeof $.fn.textareaAutoSize !== 'undefined')) { - $('.textarea-autosize').textareaAutoSize() - } -}) + if (IS_DEFAULT_THEME && supportsTransitions) { + P.$holder.find('.' + CLASSES.frame).one('transitionend', function() { + P.$holder[0].focus(); + }); + } + else { + P.$holder[0].focus(); + } + } -$(function () { - if ($('.waves-attach').length && (typeof Waves !== 'undefined')) { - Waves.attach('.waves-attach') - Waves.init({ - duration: 300 - }) - } -}) -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + function handleFocusToOpenEvent(event) { -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + // Stop the event from propagating to the doc. + event.stopPropagation(); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + // Add the “target” class. + $ELEMENT.addClass( CLASSES.target ); -+function () { - /* - * expansion panel - * upon selecting the collapsed panel, - * it expands to display in full - */ + // Add the “focused” class to the root. + P.$root.addClass( CLASSES.focused ); - var ExpansionPanel = function ($) { + // And then finally open the picker. + P.open(); + } - // constants >>> - var DATA_KEY = 'bs.collapse'; - var EVENT_KEY = '.' + DATA_KEY; - var ClassName = { - SHOW: 'show', - SHOW_PREDECESSOR: 'show-predecessor' - }; + // For iOS8. + function handleKeydownEvent( event ) { - var Event = { - HIDE: 'hide' + EVENT_KEY, - SHOW: 'show' + EVENT_KEY - }; + var keycode = event.keyCode, - var Selector = { - PANEL: '.expansion-panel', - PANEL_BODY: '.expansion-panel .collapse' - }; - // <<< constants + // Check if one of the delete keys was pressed. + isKeycodeDelete = /^(8|46)$/.test(keycode); - $(document).on('' + Event.HIDE, Selector.PANEL_BODY, function (event) { - var target = $(event.target).closest(Selector.PANEL); + // For some reason IE clears the input value on “escape”. + if ( keycode == 27 ) { + P.close( true ); + return false + } - target.removeClass(ClassName.SHOW); + // Check if `space` or `delete` was pressed or the picker is closed with a key movement. + if ( keycode == 32 || isKeycodeDelete || !STATE.open && P.component.key[keycode] ) { - var predecessor = target.prev(Selector.PANEL); + // Prevent it from moving the page and bubbling to doc. + event.preventDefault(); + event.stopPropagation(); - if (predecessor.length) { - predecessor.removeClass(ClassName.SHOW_PREDECESSOR); - } - }).on('' + Event.SHOW, Selector.PANEL_BODY, function (event) { - var target = $(event.target).closest(Selector.PANEL); + // If `delete` was pressed, clear the values and close the picker. + // Otherwise open the picker. + if ( isKeycodeDelete ) { P.clear().close(); } + else { P.open(); } + } + } - target.addClass(ClassName.SHOW); - var predecessor = target.prev(Selector.PANEL); + // Return a new picker instance. + return new PickerInstance() +} //PickerConstructor - if (predecessor.length) { - predecessor.addClass(ClassName.SHOW_PREDECESSOR); - } - }); - }(jQuery); - /* - * floating label - * when a user engages with the text input field, - * the floating inline labels move to float above the field - */ - var FloatingLabel = function ($) { +/** + * The default classes and prefix to use for the HTML classes. + */ +PickerConstructor.klasses = function( prefix ) { + prefix = prefix || 'picker'; + return { - // constants >>> - var DATA_KEY = 'md.floatinglabel'; - var EVENT_KEY = '.' + DATA_KEY; - var NAME = 'floatinglabel'; - var NO_CONFLICT = $.fn[NAME]; + picker: prefix, + opened: prefix + '--opened', + focused: prefix + '--focused', - var ClassName = { - IS_FOCUSED: 'is-focused', - HAS_VALUE: 'has-value' - }; + input: prefix + '__input', + active: prefix + '__input--active', + target: prefix + '__input--target', - var Event = { - CHANGE: 'change' + EVENT_KEY, - FOCUSIN: 'focusin' + EVENT_KEY, - FOCUSOUT: 'focusout' + EVENT_KEY - }; + holder: prefix + '__holder', - var Selector = { - DATA_PARENT: '.floating-label', - DATA_TOGGLE: '.floating-label .form-control' - }; - // <<< constants + frame: prefix + '__frame', + wrap: prefix + '__wrap', - var FloatingLabel = function () { - function FloatingLabel(element) { - _classCallCheck(this, FloatingLabel); + box: prefix + '__box' + } +}; //PickerConstructor.klasses - this._element = element; - } - FloatingLabel.prototype.change = function change(relatedTarget) { - if ($(this._element).val() || $(this._element).is('select') && $('option:first-child', $(this._element)).html().replace(' ', '') !== '') { - $(relatedTarget).addClass(ClassName.HAS_VALUE); - } else { - $(relatedTarget).removeClass(ClassName.HAS_VALUE); + +/** + * Check if the default theme is being used. + */ +function isUsingDefaultTheme( element ) { + + var theme, + prop = 'position'; + + // For IE. + if ( element.currentStyle ) { + theme = element.currentStyle[prop]; + } + + // For normal browsers. + else if ( window.getComputedStyle ) { + theme = getComputedStyle( element )[prop]; + } + + return theme == 'fixed' +} + + + +/** + * Get the width of the browser’s scrollbar. + * Taken from: https://github.com/VodkaBears/Remodal/blob/master/src/jquery.remodal.js + */ +function getScrollbarWidth() { + + if ( $html.height() <= $window.height() ) { + return 0 + } + + var $outer = $$$1( '<div style="visibility:hidden;width:100px" />' ). + appendTo( 'body' ); + + // Get the width without scrollbars. + var widthWithoutScroll = $outer[0].offsetWidth; + + // Force adding scrollbars. + $outer.css( 'overflow', 'scroll' ); + + // Add the inner div. + var $inner = $$$1( '<div style="width:100%" />' ).appendTo( $outer ); + + // Get the width with scrollbars. + var widthWithScroll = $inner[0].offsetWidth; + + // Remove the divs. + $outer.remove(); + + // Return the difference between the widths. + return widthWithoutScroll - widthWithScroll +} + + + +/** + * PickerConstructor helper methods. + */ +PickerConstructor._ = { + + /** + * Create a group of nodes. Expects: + * ` + { + min: {Integer}, + max: {Integer}, + i: {Integer}, + node: {String}, + item: {Function} } - }; + * ` + */ + group: function( groupObject ) { - FloatingLabel.prototype.focusin = function focusin(relatedTarget) { - $(relatedTarget).addClass(ClassName.IS_FOCUSED); - }; + var + // Scope for the looped object + loopObjectScope, - FloatingLabel.prototype.focusout = function focusout(relatedTarget) { - $(relatedTarget).removeClass(ClassName.IS_FOCUSED); - }; + // Create the nodes list + nodesList = '', - FloatingLabel._jQueryInterface = function _jQueryInterface(event) { - return this.each(function () { - var _event = event ? event : 'change'; - var data = $(this).data(DATA_KEY); + // The counter starts from the `min` + counter = PickerConstructor._.trigger( groupObject.min, groupObject ); - if (!data) { - data = new FloatingLabel(this); - $(this).data(DATA_KEY, data); - } - if (typeof _event === 'string') { - if (data[_event] === undefined) { - throw new Error('No method named "' + _event + '"'); - } + // Loop from the `min` to `max`, incrementing by `i` + for ( ; counter <= PickerConstructor._.trigger( groupObject.max, groupObject, [ counter ] ); counter += groupObject.i ) { - data[_event]($(this).closest(Selector.DATA_PARENT)); - } - }); - }; + // Trigger the `item` function within scope of the object + loopObjectScope = PickerConstructor._.trigger( groupObject.item, groupObject, [ counter ] ); - return FloatingLabel; - }(); + // Splice the subgroup and create nodes out of the sub nodes + nodesList += PickerConstructor._.node( + groupObject.node, + loopObjectScope[ 0 ], // the node + loopObjectScope[ 1 ], // the classes + loopObjectScope[ 2 ] // the attributes + ); + } - $(document).on(Event.CHANGE + ' ' + Event.FOCUSIN + ' ' + Event.FOCUSOUT, Selector.DATA_TOGGLE, function (event) { - FloatingLabel._jQueryInterface.call($(this), event.type); - }); + // Return the list of nodes + return nodesList + }, //group - $.fn[NAME] = FloatingLabel._jQueryInterface; - $.fn[NAME].Constructor = FloatingLabel; - $.fn[NAME].noConflict = function () { - $.fn[NAME] = NO_CONFLICT; - return FloatingLabel._jQueryInterface; - }; - return FloatingLabel; - }(jQuery); + /** + * Create a dom node string + */ + node: function( wrapper, item, klass, attribute ) { - /* - * navigation drawer - * based on bootstrap's (v4.0.0-beta) modal.js - */ + // If the item is false-y, just return an empty string + if ( !item ) return '' - var NavDrawer = function ($) { + // If the item is an array, do a join + item = $$$1.isArray( item ) ? item.join( '' ) : item; - // constants >>> - var DATA_API_KEY = '.data-api'; - var DATA_KEY = 'md.navdrawer'; - var ESCAPE_KEYCODE = 27; - var EVENT_KEY = '.' + DATA_KEY; - var NAME = 'navdrawer'; - var NO_CONFLICT = $.fn[NAME]; - var TRANSITION_DURATION = 292.5; - var TRANSITION_DURATION_BACKDROP = 487.5; + // Check for the class + klass = klass ? ' class="' + klass + '"' : ''; - var ClassName = { - BACKDROP: 'navdrawer-backdrop', - OPEN: 'navdrawer-open', - SHOW: 'show' - }; + // Check for any attributes + attribute = attribute ? ' ' + attribute : ''; - var Default = { - breakpoint: 1280, - keyboard: true, - show: true, - type: 'default' - }; + // Return the wrapped item + return '<' + wrapper + klass + attribute + '>' + item + '</' + wrapper + '>' + }, //node - var DefaultType = { - keyboard: 'boolean', - show: 'boolean', - type: 'string' - }; - var Event = { - CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY, - CLICK_DISMISS: 'click.dismiss' + EVENT_KEY, - FOCUSIN: 'focusin' + EVENT_KEY, - HIDDEN: 'hidden' + EVENT_KEY, - HIDE: 'hide' + EVENT_KEY, - KEYDOWN_DISMISS: 'keydown.dismiss' + EVENT_KEY, - MOUSEDOWN_DISMISS: 'mousedown.dismiss' + EVENT_KEY, - MOUSEUP_DISMISS: 'mouseup.dismiss' + EVENT_KEY, - SHOW: 'show' + EVENT_KEY, - SHOWN: 'shown' + EVENT_KEY - }; + /** + * Lead numbers below 10 with a zero. + */ + lead: function( number ) { + return ( number < 10 ? '0': '' ) + number + }, - var Selector = { - CONTENT: '.navdrawer-content', - DATA_DISMISS: '[data-dismiss="navdrawer"]', - DATA_TOGGLE: '[data-toggle="navdrawer"]' - }; - // <<< constants - var NavDrawer = function () { - function NavDrawer(element, config) { - _classCallCheck(this, NavDrawer); + /** + * Trigger a function otherwise return the value. + */ + trigger: function( callback, scope, args ) { + return typeof callback == 'function' ? callback.apply( scope, args || [] ) : callback + }, - this._backdrop = null; - this._config = this._getConfig(config); - this._content = $(element).find(Selector.CONTENT)[0]; - this._element = element; - this._ignoreBackdropClick = false; - this._isShown = false; - } - NavDrawer.prototype.hide = function hide(event) { - if (event) { - event.preventDefault(); + /** + * If the second character is a digit, length is 2 otherwise 1. + */ + digits: function( string ) { + return ( /\d/ ).test( string[ 1 ] ) ? 2 : 1 + }, + + + /** + * Tell if something is a date object. + */ + isDate: function( value ) { + return {}.toString.call( value ).indexOf( 'Date' ) > -1 && this.isInteger( value.getDate() ) + }, + + + /** + * Tell if something is an integer. + */ + isInteger: function( value ) { + return {}.toString.call( value ).indexOf( 'Number' ) > -1 && value % 1 === 0 + }, + + + /** + * Create ARIA attribute strings. + */ + ariaAttr: ariaAttr +}; //PickerConstructor._ + + + +/** + * Extend the picker with a component and defaults. + */ +PickerConstructor.extend = function( name, Component ) { + + // Extend jQuery. + $$$1.fn[ name ] = function( options, action ) { + + // Grab the component data. + var componentData = this.data( name ); + + // If the picker is requested, return the data object. + if ( options == 'picker' ) { + return componentData } - var hideClassName = ClassName.OPEN + '-' + this._config.type; - var hideEvent = $.Event(Event.HIDE); + // If the component data exists and `options` is a string, carry out the action. + if ( componentData && typeof options == 'string' ) { + return PickerConstructor._.trigger( componentData[ options ], componentData, [ action ] ) + } - $(this._element).trigger(hideEvent); + // Otherwise go through each matched element and if the component + // doesn’t exist, create a new picker using `this` element + // and merging the defaults and options with a deep copy. + return this.each( function() { + var $this = $$$1( this ); + if ( !$this.data( name ) ) { + new PickerConstructor( this, name, Component, options ); + } + }) + }; - if (!this._isShown || hideEvent.isDefaultPrevented()) { - return; + // Set the defaults. + $$$1.fn[ name ].defaults = Component.defaults; +}; //PickerConstructor.extend + + + +function aria(element, attribute, value) { + if ( $$$1.isPlainObject(attribute) ) { + for ( var key in attribute ) { + ariaSet(element, key, attribute[key]); } + } + else { + ariaSet(element, attribute, value); + } +} +function ariaSet(element, attribute, value) { + element.setAttribute( + (attribute == 'role' ? '' : 'aria-') + attribute, + value + ); +} +function ariaAttr(attribute, data) { + if ( !$$$1.isPlainObject(attribute) ) { + attribute = { attribute: data }; + } + data = ''; + for ( var key in attribute ) { + var attr = (key == 'role' ? '' : 'aria-') + key, + attrVal = attribute[key]; + data += attrVal == null ? '' : attr + '="' + attribute[key] + '"'; + } + return data +} - this._isShown = false; - this._setEscapeEvent(); - $(document).off(Event.FOCUSIN); - $(this._content).off(Event.MOUSEDOWN_DISMISS); +// IE8 bug throws an error for activeElements within iframes. +function getActiveElement() { + try { + return document.activeElement + } catch ( err ) { } +} - $(this._element).off(Event.CLICK_DISMISS).removeClass(ClassName.SHOW); - this._hideNavdrawer(hideClassName); - }; - NavDrawer.prototype.show = function show(relatedTarget) { - var _this = this; +// Expose the picker constructor. +return PickerConstructor - var showEvent = $.Event(Event.SHOW, { - relatedTarget: relatedTarget + +})); +}); + +var picker_date = createCommonjsModule(function (module, exports) { +/*! + * Date picker for pickadate.js v3.5.6 + * http://amsul.github.io/pickadate.js/date.htm + */ + +(function ( factory ) { + + // AMD. + if ( typeof undefined == 'function' && undefined.amd ) + undefined( ['picker', 'jquery'], factory ); + + // Node.js/browserify. + else module.exports = factory( picker, $ ); + +}(function( Picker, $$$1 ) { + + +/** + * Globals and constants + */ +var DAYS_IN_WEEK = 7, + WEEKS_IN_CALENDAR = 6, + _ = Picker._; + + + +/** + * The date picker constructor + */ +function DatePicker( picker$$1, settings ) { + + var calendar = this, + element = picker$$1.$node[ 0 ], + elementValue = element.value, + elementDataValue = picker$$1.$node.data( 'value' ), + valueString = elementDataValue || elementValue, + formatString = elementDataValue ? settings.formatSubmit : settings.format, + isRTL = function() { + + return element.currentStyle ? + + // For IE. + element.currentStyle.direction == 'rtl' : + + // For normal browsers. + getComputedStyle( picker$$1.$root[0] ).direction == 'rtl' + }; + + calendar.settings = settings; + calendar.$node = picker$$1.$node; + + // The queue of methods that will be used to build item objects. + calendar.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' + }; + + // The component's item object. + calendar.item = {}; + + calendar.item.clear = null; + calendar.item.disable = ( settings.disable || [] ).slice( 0 ); + calendar.item.enable = -(function( collectionDisabled ) { + return collectionDisabled[ 0 ] === true ? collectionDisabled.shift() : -1 + })( calendar.item.disable ); + + calendar. + set( 'min', settings.min ). + set( 'max', settings.max ). + set( 'now' ); + + // When there’s a value, set the `select`, which in turn + // also sets the `highlight` and `view`. + if ( valueString ) { + calendar.set( 'select', valueString, { + format: formatString, + defaultValue: true }); + } - $(this._element).trigger(showEvent); + // If there’s no value, default to highlighting “today”. + else { + calendar. + set( 'select', null ). + set( 'highlight', calendar.item.now ); + } - if (this._isShown || showEvent.isDefaultPrevented()) { - return; + + // The keycode to movement mapping. + calendar.key = { + 40: 7, // Down + 38: -7, // Up + 39: function() { return isRTL() ? -1 : 1 }, // Right + 37: function() { return isRTL() ? 1 : -1 }, // Left + go: function( timeChange ) { + var highlightedObject = calendar.item.highlight, + targetDate = new Date( highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange ); + calendar.set( + 'highlight', + targetDate, + { interval: timeChange } + ); + this.render(); } + }; - this._isShown = true; - $(document.body).addClass(ClassName.OPEN + '-' + this._config.type); - this._setEscapeEvent(); - $(this._element).addClass(NAME + '-' + this._config.type); - $(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, $.proxy(this.hide, this)); - $(this._content).on(Event.MOUSEDOWN_DISMISS, function () { - $(_this._element).one(Event.MOUSEUP_DISMISS, function (event) { - if ($(event.target).is(_this._element)) { - _this._ignoreBackdropClick = true; + // Bind some picker events. + picker$$1. + on( 'render', function() { + picker$$1.$root.find( '.' + settings.klass.selectMonth ).on( 'change', function() { + var value = this.value; + if ( value ) { + picker$$1.set( 'highlight', [ picker$$1.get( 'view' ).year, value, picker$$1.get( 'highlight' ).date ] ); + picker$$1.$root.find( '.' + settings.klass.selectMonth ).trigger( 'focus' ); + } + }); + picker$$1.$root.find( '.' + settings.klass.selectYear ).on( 'change', function() { + var value = this.value; + if ( value ) { + picker$$1.set( 'highlight', [ value, picker$$1.get( 'view' ).month, picker$$1.get( 'highlight' ).date ] ); + picker$$1.$root.find( '.' + settings.klass.selectYear ).trigger( 'focus' ); + } + }); + }, 1 ). + on( 'open', function() { + var includeToday = ''; + if ( calendar.disabled( calendar.get('now') ) ) { + includeToday = ':not(.' + settings.klass.buttonToday + ')'; } - }); - }); + picker$$1.$root.find( 'button' + includeToday + ', select' ).attr( 'disabled', false ); + }, 1 ). + on( 'close', function() { + picker$$1.$root.find( 'button, select' ).attr( 'disabled', true ); + }, 1 ); - this._showBackdrop(); - this._showElement(relatedTarget); - }; +} //DatePicker - NavDrawer.prototype.toggle = function toggle(relatedTarget) { - return this._isShown ? this.hide() : this.show(relatedTarget); - }; - NavDrawer.prototype._enforceFocus = function _enforceFocus() { - var _this2 = this; +/** + * Set a datepicker item object. + */ +DatePicker.prototype.set = function( type, value, options ) { - $(document).off(Event.FOCUSIN).on(Event.FOCUSIN, function (event) { - if (_this2._config.type === 'default' || $(window).width() <= _this2._config.breakpoint) { - if (_this2._element !== event.target && !$(_this2._element).has(event.target).length) { - _this2._element.focus(); + var calendar = this, + calendarItem = calendar.item; + + // If the value is `null` just set it immediately. + if ( value === null ) { + if ( type == 'clear' ) type = 'select'; + calendarItem[ type ] = value; + return calendar + } + + // Otherwise go through the queue of methods, and invoke the functions. + // Update this as the time unit, and set the final value as this item. + // * In the case of `enable`, keep the queue but set `disable` instead. + // And in the case of `flip`, keep the queue but set `enable` instead. + calendarItem[ ( type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type ) ] = calendar.queue[ type ].split( ' ' ).map( function( method ) { + value = calendar[ method ]( type, value, options ); + return value + }).pop(); + + // Check if we need to cascade through more updates. + if ( type == 'select' ) { + calendar.set( 'highlight', calendarItem.select, options ); + } + else if ( type == 'highlight' ) { + calendar.set( 'view', calendarItem.highlight, options ); + } + else if ( type.match( /^(flip|min|max|disable|enable)$/ ) ) { + if ( calendarItem.select && calendar.disabled( calendarItem.select ) ) { + calendar.set( 'select', calendarItem.select, options ); + } + if ( calendarItem.highlight && calendar.disabled( calendarItem.highlight ) ) { + calendar.set( 'highlight', calendarItem.highlight, options ); + } + } + + return calendar +}; //DatePicker.prototype.set + + +/** + * Get a datepicker item object. + */ +DatePicker.prototype.get = function( type ) { + return this.item[ type ] +}; //DatePicker.prototype.get + + +/** + * Create a picker date object. + */ +DatePicker.prototype.create = function( type, value, options ) { + + var isInfiniteValue, + calendar = this; + + // If there’s no value, use the type as the value. + value = value === undefined ? type : value; + + + // If it’s infinity, update the value. + if ( value == -Infinity || value == Infinity ) { + isInfiniteValue = value; + } + + // If it’s an object, use the native date object. + else if ( $$$1.isPlainObject( value ) && _.isInteger( value.pick ) ) { + value = value.obj; + } + + // If it’s an array, convert it into a date and make sure + // that it’s a valid date – otherwise default to today. + else if ( $$$1.isArray( value ) ) { + value = new Date( value[ 0 ], value[ 1 ], value[ 2 ] ); + value = _.isDate( value ) ? value : calendar.create().obj; + } + + // If it’s a number or date object, make a normalized date. + else if ( _.isInteger( value ) || _.isDate( value ) ) { + value = calendar.normalize( new Date( value ), options ); + } + + // If it’s a literal true or any other case, set it to now. + else /*if ( value === true )*/ { + value = calendar.now( type, value, options ); + } + + // Return the compiled object. + return { + year: isInfiniteValue || value.getFullYear(), + month: isInfiniteValue || value.getMonth(), + date: isInfiniteValue || value.getDate(), + day: isInfiniteValue || value.getDay(), + obj: isInfiniteValue || value, + pick: isInfiniteValue || value.getTime() + } +}; //DatePicker.prototype.create + + +/** + * Create a range limit object using an array, date object, + * literal “true”, or integer relative to another time. + */ +DatePicker.prototype.createRange = function( from, to ) { + + var calendar = this, + createDate = function( date ) { + if ( date === true || $$$1.isArray( date ) || _.isDate( date ) ) { + return calendar.create( date ) } - } - }); - }; + return date + }; - NavDrawer.prototype._getConfig = function _getConfig(config) { - config = $.extend({}, Default, config); - Util.typeCheckConfig(NAME, config, DefaultType); - return config; - }; + // Create objects if possible. + if ( !_.isInteger( from ) ) { + from = createDate( from ); + } + if ( !_.isInteger( to ) ) { + to = createDate( to ); + } - NavDrawer.prototype._hideNavdrawer = function _hideNavdrawer(className) { - var _this3 = this; + // Create relative dates. + if ( _.isInteger( from ) && $$$1.isPlainObject( to ) ) { + from = [ to.year, to.month, to.date + from ]; + } + else if ( _.isInteger( to ) && $$$1.isPlainObject( from ) ) { + to = [ from.year, from.month, from.date + to ]; + } - this._showBackdrop(function () { - $(document.body).removeClass(className); + return { + from: createDate( from ), + to: createDate( to ) + } +}; //DatePicker.prototype.createRange - _this3._element.setAttribute('aria-hidden', 'true'); - _this3._element.style.display = 'none'; - $(_this3._element).trigger(Event.HIDDEN); - }); - }; +/** + * Check if a date unit falls within a date range object. + */ +DatePicker.prototype.withinRange = function( range, dateUnit ) { + range = this.createRange(range.from, range.to); + return dateUnit.pick >= range.from.pick && dateUnit.pick <= range.to.pick +}; - NavDrawer.prototype._removeBackdrop = function _removeBackdrop() { - if (this._backdrop) { - $(this._backdrop).remove(); - this._backdrop = null; + +/** + * Check if two date range objects overlap. + */ +DatePicker.prototype.overlapRanges = function( one, two ) { + + var calendar = this; + + // Convert the ranges into comparable dates. + one = calendar.createRange( one.from, one.to ); + two = calendar.createRange( two.from, two.to ); + + return calendar.withinRange( one, two.from ) || calendar.withinRange( one, two.to ) || + calendar.withinRange( two, one.from ) || calendar.withinRange( two, one.to ) +}; + + +/** + * Get the date today. + */ +DatePicker.prototype.now = function( type, value, options ) { + value = new Date(); + if ( options && options.rel ) { + value.setDate( value.getDate() + options.rel ); + } + return this.normalize( value, options ) +}; + + +/** + * Navigate to next/prev month. + */ +DatePicker.prototype.navigate = function( type, value, options ) { + + var targetDateObject, + targetYear, + targetMonth, + targetDate, + isTargetArray = $$$1.isArray( value ), + isTargetObject = $$$1.isPlainObject( value ), + viewsetObject = this.item.view;/*, + safety = 100*/ + + + if ( isTargetArray || isTargetObject ) { + + if ( isTargetObject ) { + targetYear = value.year; + targetMonth = value.month; + targetDate = value.date; } - }; + else { + targetYear = +value[0]; + targetMonth = +value[1]; + targetDate = +value[2]; + } - NavDrawer.prototype._setEscapeEvent = function _setEscapeEvent() { - var _this4 = this; + // If we’re navigating months but the view is in a different + // month, navigate to the view’s year and month. + if ( options && options.nav && viewsetObject && viewsetObject.month !== targetMonth ) { + targetYear = viewsetObject.year; + targetMonth = viewsetObject.month; + } - if (this._isShown && this._config.keyboard) { - $(this._element).on(Event.KEYDOWN_DISMISS, function (event) { - if (event.which === ESCAPE_KEYCODE) { - _this4.hide(); + // Figure out the expected target year and month. + targetDateObject = new Date( targetYear, targetMonth + ( options && options.nav ? options.nav : 0 ), 1 ); + targetYear = targetDateObject.getFullYear(); + targetMonth = targetDateObject.getMonth(); + + // If the month we’re going to doesn’t have enough days, + // keep decreasing the date until we reach the month’s last date. + while ( /*safety &&*/ new Date( targetYear, targetMonth, targetDate ).getMonth() !== targetMonth ) { + targetDate -= 1; + /*safety -= 1 + if ( !safety ) { + throw 'Fell into an infinite loop while navigating to ' + new Date( targetYear, targetMonth, targetDate ) + '.' + }*/ + } + + value = [ targetYear, targetMonth, targetDate ]; + } + + return value +}; //DatePicker.prototype.navigate + + +/** + * Normalize a date by setting the hours to midnight. + */ +DatePicker.prototype.normalize = function( value/*, options*/ ) { + value.setHours( 0, 0, 0, 0 ); + return value +}; + + +/** + * Measure the range of dates. + */ +DatePicker.prototype.measure = function( type, value/*, options*/ ) { + + var calendar = this; + + // If it’s anything false-y, remove the limits. + if ( !value ) { + value = type == 'min' ? -Infinity : Infinity; + } + + // If it’s a string, parse it. + else if ( typeof value == 'string' ) { + value = calendar.parse( type, value ); + } + + // If it's an integer, get a date relative to today. + else if ( _.isInteger( value ) ) { + value = calendar.now( type, value, { rel: value } ); + } + + return value +}; ///DatePicker.prototype.measure + + +/** + * Create a viewset object based on navigation. + */ +DatePicker.prototype.viewset = function( type, dateObject/*, options*/ ) { + return this.create([ dateObject.year, dateObject.month, 1 ]) +}; + + +/** + * Validate a date as enabled and shift if needed. + */ +DatePicker.prototype.validate = function( type, dateObject, options ) { + + var calendar = this, + + // Keep a reference to the original date. + originalDateObject = dateObject, + + // Make sure we have an interval. + interval = options && options.interval ? options.interval : 1, + + // Check if the calendar enabled dates are inverted. + isFlippedBase = calendar.item.enable === -1, + + // Check if we have any enabled dates after/before now. + hasEnabledBeforeTarget, hasEnabledAfterTarget, + + // The min & max limits. + minLimitObject = calendar.item.min, + maxLimitObject = calendar.item.max, + + // Check if we’ve reached the limit during shifting. + reachedMin, reachedMax, + + // Check if the calendar is inverted and at least one weekday is enabled. + hasEnabledWeekdays = isFlippedBase && calendar.item.disable.filter( function( value ) { + + // If there’s a date, check where it is relative to the target. + if ( $$$1.isArray( value ) ) { + var dateTime = calendar.create( value ).pick; + if ( dateTime < dateObject.pick ) hasEnabledBeforeTarget = true; + else if ( dateTime > dateObject.pick ) hasEnabledAfterTarget = true; } - }); - } else if (!this._isShown) { - $(this._element).off(Event.KEYDOWN_DISMISS); + + // Return only integers for enabled weekdays. + return _.isInteger( value ) + }).length;/*, + + safety = 100*/ + + + + // Cases to validate for: + // [1] Not inverted and date disabled. + // [2] Inverted and some dates enabled. + // [3] Not inverted and out of range. + // + // Cases to **not** validate for: + // • Navigating months. + // • Not inverted and date enabled. + // • Inverted and all dates disabled. + // • ..and anything else. + if ( !options || (!options.nav && !options.defaultValue) ) if ( + /* 1 */ ( !isFlippedBase && calendar.disabled( dateObject ) ) || + /* 2 */ ( isFlippedBase && calendar.disabled( dateObject ) && ( hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget ) ) || + /* 3 */ ( !isFlippedBase && (dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick) ) + ) { + + + // When inverted, flip the direction if there aren’t any enabled weekdays + // and there are no enabled dates in the direction of the interval. + if ( isFlippedBase && !hasEnabledWeekdays && ( ( !hasEnabledAfterTarget && interval > 0 ) || ( !hasEnabledBeforeTarget && interval < 0 ) ) ) { + interval *= -1; } - }; - NavDrawer.prototype._showBackdrop = function _showBackdrop(callback) { - var _this5 = this; - var supportsTransition = Util.supportsTransitionEnd(); + // Keep looping until we reach an enabled date. + while ( /*safety &&*/ calendar.disabled( dateObject ) ) { - if (this._isShown) { - this._backdrop = document.createElement('div'); + /*safety -= 1 + if ( !safety ) { + throw 'Fell into an infinite loop while validating ' + dateObject.obj + '.' + }*/ - $(this._backdrop).addClass(ClassName.BACKDROP).addClass(ClassName.BACKDROP + '-' + this._config.type).appendTo(document.body); - $(this._element).on(Event.CLICK_DISMISS, function (event) { - if (_this5._ignoreBackdropClick) { - _this5._ignoreBackdropClick = false; - return; + // If we’ve looped into the next/prev month with a large interval, return to the original date and flatten the interval. + if ( Math.abs( interval ) > 1 && ( dateObject.month < originalDateObject.month || dateObject.month > originalDateObject.month ) ) { + dateObject = originalDateObject; + interval = interval > 0 ? 1 : -1; } - if (event.target !== event.currentTarget) { - return; + + // If we’ve reached the min/max limit, reverse the direction, flatten the interval and set it to the limit. + if ( dateObject.pick <= minLimitObject.pick ) { + reachedMin = true; + interval = 1; + dateObject = calendar.create([ + minLimitObject.year, + minLimitObject.month, + minLimitObject.date + (dateObject.pick === minLimitObject.pick ? 0 : -1) + ]); } + else if ( dateObject.pick >= maxLimitObject.pick ) { + reachedMax = true; + interval = -1; + dateObject = calendar.create([ + maxLimitObject.year, + maxLimitObject.month, + maxLimitObject.date + (dateObject.pick === maxLimitObject.pick ? 0 : 1) + ]); + } - _this5.hide(); - }); - if (supportsTransition) { - Util.reflow(this._backdrop); - } + // If we’ve reached both limits, just break out of the loop. + if ( reachedMin && reachedMax ) { + break + } - $(this._backdrop).addClass(ClassName.SHOW); - if (!callback) { - return; - } + // Finally, create the shifted date using the interval and keep looping. + dateObject = calendar.create([ dateObject.year, dateObject.month, dateObject.date + interval ]); + } - if (!supportsTransition) { - callback(); - return; - } + } //endif - $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(TRANSITION_DURATION_BACKDROP); - } else if (this._backdrop && !this._isShown) { - $(this._backdrop).removeClass(ClassName.SHOW); - var callbackRemove = function callbackRemove() { - _this5._removeBackdrop(); + // Return the date object settled on. + return dateObject +}; //DatePicker.prototype.validate - if (callback) { - callback(); + +/** + * Check if a date is disabled. + */ +DatePicker.prototype.disabled = function( dateToVerify ) { + + var + calendar = this, + + // Filter through the disabled dates to check if this is one. + isDisabledMatch = calendar.item.disable.filter( function( dateToDisable ) { + + // If the date is a number, match the weekday with 0index and `firstDay` check. + if ( _.isInteger( dateToDisable ) ) { + return dateToVerify.day === ( calendar.settings.firstDay ? dateToDisable : dateToDisable - 1 ) % 7 } - }; - if (supportsTransition) { - $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(TRANSITION_DURATION_BACKDROP); - } else { - callbackRemove(); - } - } else if (callback) { - callback(); + // If it’s an array or a native JS date, create and match the exact date. + if ( $$$1.isArray( dateToDisable ) || _.isDate( dateToDisable ) ) { + return dateToVerify.pick === calendar.create( dateToDisable ).pick + } + + // If it’s an object, match a date within the “from” and “to” range. + if ( $$$1.isPlainObject( dateToDisable ) ) { + return calendar.withinRange( dateToDisable, dateToVerify ) + } + }); + + // If this date matches a disabled date, confirm it’s not inverted. + isDisabledMatch = isDisabledMatch.length && !isDisabledMatch.filter(function( dateToDisable ) { + return $$$1.isArray( dateToDisable ) && dateToDisable[3] == 'inverted' || + $$$1.isPlainObject( dateToDisable ) && dateToDisable.inverted + }).length; + + // Check the calendar “enabled” flag and respectively flip the + // disabled state. Then also check if it’s beyond the min/max limits. + return calendar.item.enable === -1 ? !isDisabledMatch : isDisabledMatch || + dateToVerify.pick < calendar.item.min.pick || + dateToVerify.pick > calendar.item.max.pick + +}; //DatePicker.prototype.disabled + + +/** + * Parse a string into a usable type. + */ +DatePicker.prototype.parse = function( type, value, options ) { + + var calendar = this, + parsingObject = {}; + + // If it’s already parsed, we’re good. + if ( !value || typeof value != 'string' ) { + return value + } + + // We need a `.format` to parse the value with. + if ( !( options && options.format ) ) { + options = options || {}; + options.format = calendar.settings.format; + } + + // Convert the format into an array and then map through it. + calendar.formats.toArray( options.format ).map( function( label ) { + + var + // Grab the formatting label. + formattingLabel = calendar.formats[ label ], + + // The format length is from the formatting label function or the + // label length without the escaping exclamation (!) mark. + formatLength = formattingLabel ? _.trigger( formattingLabel, calendar, [ value, parsingObject ] ) : label.replace( /^!/, '' ).length; + + // If there's a format label, split the value up to the format length. + // Then add it to the parsing object with appropriate label. + if ( formattingLabel ) { + parsingObject[ label ] = value.substr( 0, formatLength ); } - }; - NavDrawer.prototype._showElement = function _showElement(relatedTarget) { - var _this6 = this; + // Update the value as the substring from format length to end. + value = value.substr( formatLength ); + }); - var supportsTransition = Util.supportsTransitionEnd(); + // Compensate for month 0index. + return [ + parsingObject.yyyy || parsingObject.yy, + +( parsingObject.mm || parsingObject.m ) - 1, + parsingObject.dd || parsingObject.d + ] +}; //DatePicker.prototype.parse - if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { - document.body.appendChild(this._element); + +/** + * Various formats to display the object in. + */ +DatePicker.prototype.formats = (function() { + + // Return the length of the first word in a collection. + function getWordLengthFromCollection( string, collection, dateObject ) { + + // Grab the first word from the string. + // Regex pattern from http://stackoverflow.com/q/150033 + var word = string.match( /[^\x00-\x7F]+|\w+/ )[ 0 ]; + + // If there's no month index, add it to the date object + if ( !dateObject.mm && !dateObject.m ) { + dateObject.m = collection.indexOf( word ) + 1; } - this._element.removeAttribute('aria-hidden'); - this._element.style.display = 'block'; + // Return the length of the word. + return word.length + } - if (supportsTransition) { - Util.reflow(this._element); + // Get the length of the first word in a string. + function getFirstWordLength( string ) { + return string.match( /\w+/ )[ 0 ].length + } + + return { + + d: function( string, dateObject ) { + + // If there's string, then get the digits length. + // Otherwise return the selected date. + return string ? _.digits( string ) : dateObject.date + }, + dd: function( string, dateObject ) { + + // If there's a string, then the length is always 2. + // Otherwise return the selected date with a leading zero. + return string ? 2 : _.lead( dateObject.date ) + }, + ddd: function( string, dateObject ) { + + // If there's a string, then get the length of the first word. + // Otherwise return the short selected weekday. + return string ? getFirstWordLength( string ) : this.settings.weekdaysShort[ dateObject.day ] + }, + dddd: function( string, dateObject ) { + + // If there's a string, then get the length of the first word. + // Otherwise return the full selected weekday. + return string ? getFirstWordLength( string ) : this.settings.weekdaysFull[ dateObject.day ] + }, + m: function( string, dateObject ) { + + // If there's a string, then get the length of the digits + // Otherwise return the selected month with 0index compensation. + return string ? _.digits( string ) : dateObject.month + 1 + }, + mm: function( string, dateObject ) { + + // If there's a string, then the length is always 2. + // Otherwise return the selected month with 0index and leading zero. + return string ? 2 : _.lead( dateObject.month + 1 ) + }, + mmm: function( string, dateObject ) { + + var collection = this.settings.monthsShort; + + // If there's a string, get length of the relevant month from the short + // months collection. Otherwise return the selected month from that collection. + return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ] + }, + mmmm: function( string, dateObject ) { + + var collection = this.settings.monthsFull; + + // If there's a string, get length of the relevant month from the full + // months collection. Otherwise return the selected month from that collection. + return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ] + }, + yy: function( string, dateObject ) { + + // If there's a string, then the length is always 2. + // Otherwise return the selected year by slicing out the first 2 digits. + return string ? 2 : ( '' + dateObject.year ).slice( 2 ) + }, + yyyy: function( string, dateObject ) { + + // If there's a string, then the length is always 4. + // Otherwise return the selected year. + return string ? 4 : dateObject.year + }, + + // Create an array by splitting the formatting string passed. + toArray: function( formatString ) { return formatString.split( /(d{1,4}|m{1,4}|y{4}|yy|!.)/g ) }, + + // Format an object into a string using the formatting options. + toString: function ( formatString, itemObject ) { + var calendar = this; + return calendar.formats.toArray( formatString ).map( function( label ) { + return _.trigger( calendar.formats[ label ], calendar, [ 0, itemObject ] ) || label.replace( /^!/, '' ) + }).join( '' ) } + } +})(); //DatePicker.prototype.formats - $(this._element).addClass(ClassName.SHOW); - this._enforceFocus(); - var shownEvent = $.Event(Event.SHOWN, { - relatedTarget: relatedTarget + + +/** + * Check if two date units are the exact. + */ +DatePicker.prototype.isDateExact = function( one, two ) { + + var calendar = this; + + // When we’re working with weekdays, do a direct comparison. + if ( + ( _.isInteger( one ) && _.isInteger( two ) ) || + ( typeof one == 'boolean' && typeof two == 'boolean' ) + ) { + return one === two + } + + // When we’re working with date representations, compare the “pick” value. + if ( + ( _.isDate( one ) || $$$1.isArray( one ) ) && + ( _.isDate( two ) || $$$1.isArray( two ) ) + ) { + return calendar.create( one ).pick === calendar.create( two ).pick + } + + // When we’re working with range objects, compare the “from” and “to”. + if ( $$$1.isPlainObject( one ) && $$$1.isPlainObject( two ) ) { + return calendar.isDateExact( one.from, two.from ) && calendar.isDateExact( one.to, two.to ) + } + + return false +}; + + +/** + * Check if two date units overlap. + */ +DatePicker.prototype.isDateOverlap = function( one, two ) { + + var calendar = this, + firstDay = calendar.settings.firstDay ? 1 : 0; + + // When we’re working with a weekday index, compare the days. + if ( _.isInteger( one ) && ( _.isDate( two ) || $$$1.isArray( two ) ) ) { + one = one % 7 + firstDay; + return one === calendar.create( two ).day + 1 + } + if ( _.isInteger( two ) && ( _.isDate( one ) || $$$1.isArray( one ) ) ) { + two = two % 7 + firstDay; + return two === calendar.create( one ).day + 1 + } + + // When we’re working with range objects, check if the ranges overlap. + if ( $$$1.isPlainObject( one ) && $$$1.isPlainObject( two ) ) { + return calendar.overlapRanges( one, two ) + } + + return false +}; + + +/** + * Flip the “enabled” state. + */ +DatePicker.prototype.flipEnable = function(val) { + var itemObject = this.item; + itemObject.enable = val || (itemObject.enable == -1 ? 1 : -1); +}; + + +/** + * Mark a collection of dates as “disabled”. + */ +DatePicker.prototype.deactivate = function( type, datesToDisable ) { + + var calendar = this, + disabledItems = calendar.item.disable.slice(0); + + + // If we’re flipping, that’s all we need to do. + if ( datesToDisable == 'flip' ) { + calendar.flipEnable(); + } + + else if ( datesToDisable === false ) { + calendar.flipEnable(1); + disabledItems = []; + } + + else if ( datesToDisable === true ) { + calendar.flipEnable(-1); + disabledItems = []; + } + + // Otherwise go through the dates to disable. + else { + + datesToDisable.map(function( unitToDisable ) { + + var matchFound; + + // When we have disabled items, check for matches. + // If something is matched, immediately break out. + for ( var index = 0; index < disabledItems.length; index += 1 ) { + if ( calendar.isDateExact( unitToDisable, disabledItems[index] ) ) { + matchFound = true; + break + } + } + + // If nothing was found, add the validated unit to the collection. + if ( !matchFound ) { + if ( + _.isInteger( unitToDisable ) || + _.isDate( unitToDisable ) || + $$$1.isArray( unitToDisable ) || + ( $$$1.isPlainObject( unitToDisable ) && unitToDisable.from && unitToDisable.to ) + ) { + disabledItems.push( unitToDisable ); + } + } }); + } - var transitionComplete = function transitionComplete() { - _this6._element.focus(); - $(_this6._element).trigger(shownEvent); - }; + // Return the updated collection. + return disabledItems +}; //DatePicker.prototype.deactivate - if (supportsTransition) { - $(this._content).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(TRANSITION_DURATION); - } else { - transitionComplete(); - } - }; - NavDrawer._jQueryInterface = function _jQueryInterface(config, relatedTarget) { - return this.each(function () { - var _config = $.extend({}, NavDrawer.Default, $(this).data(), (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config); +/** + * Mark a collection of dates as “enabled”. + */ +DatePicker.prototype.activate = function( type, datesToEnable ) { - var data = $(this).data(DATA_KEY); + var calendar = this, + disabledItems = calendar.item.disable, + disabledItemsCount = disabledItems.length; - if (!data) { - data = new NavDrawer(this, _config); - $(this).data(DATA_KEY, data); - } + // If we’re flipping, that’s all we need to do. + if ( datesToEnable == 'flip' ) { + calendar.flipEnable(); + } - if (typeof config === 'string') { - if (data[config] === undefined) { - throw new Error('No method named "' + config + '"'); + else if ( datesToEnable === true ) { + calendar.flipEnable(1); + disabledItems = []; + } + + else if ( datesToEnable === false ) { + calendar.flipEnable(-1); + disabledItems = []; + } + + // Otherwise go through the disabled dates. + else { + + datesToEnable.map(function( unitToEnable ) { + + var matchFound, + disabledUnit, + index, + isExactRange; + + // Go through the disabled items and try to find a match. + for ( index = 0; index < disabledItemsCount; index += 1 ) { + + disabledUnit = disabledItems[index]; + + // When an exact match is found, remove it from the collection. + if ( calendar.isDateExact( disabledUnit, unitToEnable ) ) { + matchFound = disabledItems[index] = null; + isExactRange = true; + break + } + + // When an overlapped match is found, add the “inverted” state to it. + else if ( calendar.isDateOverlap( disabledUnit, unitToEnable ) ) { + if ( $$$1.isPlainObject( unitToEnable ) ) { + unitToEnable.inverted = true; + matchFound = unitToEnable; + } + else if ( $$$1.isArray( unitToEnable ) ) { + matchFound = unitToEnable; + if ( !matchFound[3] ) matchFound.push( 'inverted' ); + } + else if ( _.isDate( unitToEnable ) ) { + matchFound = [ unitToEnable.getFullYear(), unitToEnable.getMonth(), unitToEnable.getDate(), 'inverted' ]; + } + break + } } - data[config](relatedTarget); - } else if (_config.show) { - data.show(relatedTarget); - } + // If a match was found, remove a previous duplicate entry. + if ( matchFound ) for ( index = 0; index < disabledItemsCount; index += 1 ) { + if ( calendar.isDateExact( disabledItems[index], unitToEnable ) ) { + disabledItems[index] = null; + break + } + } + + // In the event that we’re dealing with an exact range of dates, + // make sure there are no “inverted” dates because of it. + if ( isExactRange ) for ( index = 0; index < disabledItemsCount; index += 1 ) { + if ( calendar.isDateOverlap( disabledItems[index], unitToEnable ) ) { + disabledItems[index] = null; + break + } + } + + // If something is still matched, add it into the collection. + if ( matchFound ) { + disabledItems.push( matchFound ); + } }); - }; + } - _createClass(NavDrawer, null, [{ - key: 'Default', - get: function get() { - return Default; + // Return the updated collection. + return disabledItems.filter(function( val ) { return val != null }) +}; //DatePicker.prototype.activate + + +/** + * Create a string for the nodes in the picker. + */ +DatePicker.prototype.nodes = function( isOpen ) { + + var + calendar = this, + settings = calendar.settings, + calendarItem = calendar.item, + nowObject = calendarItem.now, + selectedObject = calendarItem.select, + highlightedObject = calendarItem.highlight, + viewsetObject = calendarItem.view, + disabledCollection = calendarItem.disable, + minLimitObject = calendarItem.min, + maxLimitObject = calendarItem.max, + + + // Create the calendar table head using a copy of weekday labels collection. + // * We do a copy so we don't mutate the original array. + tableHead = (function( collection, fullCollection ) { + + // If the first day should be Monday, move Sunday to the end. + if ( settings.firstDay ) { + collection.push( collection.shift() ); + fullCollection.push( fullCollection.shift() ); + } + + // Create and return the table head group. + return _.node( + 'thead', + _.node( + 'tr', + _.group({ + min: 0, + max: DAYS_IN_WEEK - 1, + i: 1, + node: 'th', + item: function( counter ) { + return [ + collection[ counter ], + settings.klass.weekdays, + 'scope=col title="' + fullCollection[ counter ] + '"' + ] + } + }) + ) + ) //endreturn + })( ( settings.showWeekdaysFull ? settings.weekdaysFull : settings.weekdaysShort ).slice( 0 ), settings.weekdaysFull.slice( 0 ) ), //tableHead + + + // Create the nav for next/prev month. + createMonthNav = function( next ) { + + // Otherwise, return the created month tag. + return _.node( + 'div', + ' ', + settings.klass[ 'nav' + ( next ? 'Next' : 'Prev' ) ] + ( + + // If the focused month is outside the range, disabled the button. + ( next && viewsetObject.year >= maxLimitObject.year && viewsetObject.month >= maxLimitObject.month ) || + ( !next && viewsetObject.year <= minLimitObject.year && viewsetObject.month <= minLimitObject.month ) ? + ' ' + settings.klass.navDisabled : '' + ), + 'data-nav=' + ( next || -1 ) + ' ' + + _.ariaAttr({ + role: 'button', + controls: calendar.$node[0].id + '_table' + }) + ' ' + + 'title="' + (next ? settings.labelMonthNext : settings.labelMonthPrev ) + '"' + ) //endreturn + }, //createMonthNav + + + // Create the month label. + createMonthLabel = function() { + + var monthsCollection = settings.showMonthsShort ? settings.monthsShort : settings.monthsFull; + + // If there are months to select, add a dropdown menu. + if ( settings.selectMonths ) { + + return _.node( 'select', + _.group({ + min: 0, + max: 11, + i: 1, + node: 'option', + item: function( loopedMonth ) { + + return [ + + // The looped month and no classes. + monthsCollection[ loopedMonth ], 0, + + // Set the value and selected index. + 'value=' + loopedMonth + + ( viewsetObject.month == loopedMonth ? ' selected' : '' ) + + ( + ( + ( viewsetObject.year == minLimitObject.year && loopedMonth < minLimitObject.month ) || + ( viewsetObject.year == maxLimitObject.year && loopedMonth > maxLimitObject.month ) + ) ? + ' disabled' : '' + ) + ] + } + }), + settings.klass.selectMonth, + ( isOpen ? '' : 'disabled' ) + ' ' + + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' + + 'title="' + settings.labelMonthSelect + '"' + ) + } + + // If there's a need for a month selector + return _.node( 'div', monthsCollection[ viewsetObject.month ], settings.klass.month ) + }, //createMonthLabel + + + // Create the year label. + createYearLabel = function() { + + var focusedYear = viewsetObject.year, + + // If years selector is set to a literal "true", set it to 5. Otherwise + // divide in half to get half before and half after focused year. + numberYears = settings.selectYears === true ? 5 : ~~( settings.selectYears / 2 ); + + // If there are years to select, add a dropdown menu. + if ( numberYears ) { + + var + minYear = minLimitObject.year, + maxYear = maxLimitObject.year, + lowestYear = focusedYear - numberYears, + highestYear = focusedYear + numberYears; + + // If the min year is greater than the lowest year, increase the highest year + // by the difference and set the lowest year to the min year. + if ( minYear > lowestYear ) { + highestYear += minYear - lowestYear; + lowestYear = minYear; + } + + // If the max year is less than the highest year, decrease the lowest year + // by the lower of the two: available and needed years. Then set the + // highest year to the max year. + if ( maxYear < highestYear ) { + + var availableYears = lowestYear - minYear, + neededYears = highestYear - maxYear; + + lowestYear -= availableYears > neededYears ? neededYears : availableYears; + highestYear = maxYear; + } + + return _.node( 'select', + _.group({ + min: lowestYear, + max: highestYear, + i: 1, + node: 'option', + item: function( loopedYear ) { + return [ + + // The looped year and no classes. + loopedYear, 0, + + // Set the value and selected index. + 'value=' + loopedYear + ( focusedYear == loopedYear ? ' selected' : '' ) + ] + } + }), + settings.klass.selectYear, + ( isOpen ? '' : 'disabled' ) + ' ' + _.ariaAttr({ controls: calendar.$node[0].id + '_table' }) + ' ' + + 'title="' + settings.labelYearSelect + '"' + ) + } + + // Otherwise just return the year focused + return _.node( 'div', focusedYear, settings.klass.year ) + }; //createYearLabel + + + // Create and return the entire calendar. + return _.node( + 'div', + ( settings.selectYears ? createYearLabel() + createMonthLabel() : createMonthLabel() + createYearLabel() ) + + createMonthNav() + createMonthNav( 1 ), + settings.klass.header + ) + _.node( + 'table', + tableHead + + _.node( + 'tbody', + _.group({ + min: 0, + max: WEEKS_IN_CALENDAR - 1, + i: 1, + node: 'tr', + item: function( rowCounter ) { + + // If Monday is the first day and the month starts on Sunday, shift the date back a week. + var shiftDateBy = settings.firstDay && calendar.create([ viewsetObject.year, viewsetObject.month, 1 ]).day === 0 ? -7 : 0; + + return [ + _.group({ + min: DAYS_IN_WEEK * rowCounter - viewsetObject.day + shiftDateBy + 1, // Add 1 for weekday 0index + max: function() { + return this.min + DAYS_IN_WEEK - 1 + }, + i: 1, + node: 'td', + item: function( targetDate ) { + + // Convert the time date from a relative date to a target date. + targetDate = calendar.create([ viewsetObject.year, viewsetObject.month, targetDate + ( settings.firstDay ? 1 : 0 ) ]); + + var isSelected = selectedObject && selectedObject.pick == targetDate.pick, + isHighlighted = highlightedObject && highlightedObject.pick == targetDate.pick, + isDisabled = disabledCollection && calendar.disabled( targetDate ) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick, + formattedDate = _.trigger( calendar.formats.toString, calendar, [ settings.format, targetDate ] ); + + return [ + _.node( + 'div', + targetDate.date, + (function( klasses ) { + + // Add the `infocus` or `outfocus` classes based on month in view. + klasses.push( viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus ); + + // Add the `today` class if needed. + if ( nowObject.pick == targetDate.pick ) { + klasses.push( settings.klass.now ); + } + + // Add the `selected` class if something's selected and the time matches. + if ( isSelected ) { + klasses.push( settings.klass.selected ); + } + + // Add the `highlighted` class if something's highlighted and the time matches. + if ( isHighlighted ) { + klasses.push( settings.klass.highlighted ); + } + + // Add the `disabled` class if something's disabled and the object matches. + if ( isDisabled ) { + klasses.push( settings.klass.disabled ); + } + + return klasses.join( ' ' ) + })([ settings.klass.day ]), + 'data-pick=' + targetDate.pick + ' ' + _.ariaAttr({ + role: 'gridcell', + label: formattedDate, + selected: isSelected && calendar.$node.val() === formattedDate ? true : null, + activedescendant: isHighlighted ? true : null, + disabled: isDisabled ? true : null + }) + ), + '', + _.ariaAttr({ role: 'presentation' }) + ] //endreturn + } + }) + ] //endreturn + } + }) + ), + settings.klass.table, + 'id="' + calendar.$node[0].id + '_table' + '" ' + _.ariaAttr({ + role: 'grid', + controls: calendar.$node[0].id, + readonly: true + }) + ) + + + // * For Firefox forms to submit, make sure to set the buttons’ `type` attributes as “button”. + _.node( + 'div', + _.node( 'button', settings.today, settings.klass.buttonToday, + 'type=button data-pick=' + nowObject.pick + + ( isOpen && !calendar.disabled(nowObject) ? '' : ' disabled' ) + ' ' + + _.ariaAttr({ controls: calendar.$node[0].id }) ) + + _.node( 'button', settings.clear, settings.klass.buttonClear, + 'type=button data-clear=1' + + ( isOpen ? '' : ' disabled' ) + ' ' + + _.ariaAttr({ controls: calendar.$node[0].id }) ) + + _.node('button', settings.close, settings.klass.buttonClose, + 'type=button data-close=true ' + + ( isOpen ? '' : ' disabled' ) + ' ' + + _.ariaAttr({ controls: calendar.$node[0].id }) ), + settings.klass.footer + ) //endreturn +}; //DatePicker.prototype.nodes + + + + +/** + * The date picker defaults. + */ +DatePicker.defaults = (function( prefix ) { + + return { + + // The title label to use for the month nav buttons + labelMonthNext: 'Next month', + labelMonthPrev: 'Previous month', + + // The title label to use for the dropdown selectors + labelMonthSelect: 'Select a month', + labelYearSelect: 'Select a year', + + // Months and weekdays + 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 and clear + today: 'Today', + clear: 'Clear', + close: 'Close', + + // Picker close behavior + closeOnSelect: true, + closeOnClear: true, + + // The format to show on the `input` element + format: 'd mmmm, yyyy', + + // Classes + klass: { + + table: prefix + 'table', + + header: prefix + 'header', + + navPrev: prefix + 'nav--prev', + navNext: prefix + 'nav--next', + navDisabled: prefix + 'nav--disabled', + + month: prefix + 'month', + year: prefix + 'year', + + selectMonth: prefix + 'select--month', + selectYear: prefix + 'select--year', + + weekdays: prefix + 'weekday', + + day: prefix + 'day', + disabled: prefix + 'day--disabled', + selected: prefix + 'day--selected', + highlighted: prefix + 'day--highlighted', + now: prefix + 'day--today', + infocus: prefix + 'day--infocus', + outfocus: prefix + 'day--outfocus', + + footer: prefix + 'footer', + + buttonClear: prefix + 'button--clear', + buttonToday: prefix + 'button--today', + buttonClose: prefix + 'button--close' } - }]); + } +})( Picker.klasses().picker + '__' ); - return NavDrawer; - }(); - $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { - var _this7 = this; - var selector = Util.getSelectorFromElement(this); - var target = void 0; - if (selector) { - target = $(selector)[0]; - } - var config = $(target).data(DATA_KEY) ? 'toggle' : $.extend({}, $(target).data(), $(this).data()); +/** + * Extend the picker to add the date picker. + */ +Picker.extend( 'pickadate', DatePicker ); - if (this.tagName === 'A') { - event.preventDefault(); - } - var $target = $(target).one(Event.SHOW, function (showEvent) { - if (showEvent.isDefaultPrevented()) { - return; +})); +}); + +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +/* + * Customise pickadate JavaScript for Material + */ +(function ($$$1) { + var Datepicker = function Datepicker(element, options) { + this._element = element; + this._options = options; + }; + + Datepicker.DEFAULTS = { + cancel: 'Cancel', + closeOnCancel: true, + closeOnSelect: false, + container: 'body', + disable: [], + firstDay: 0, + format: 'd/m/yyyy', + formatSubmit: '', + klass: { + // button + buttonClear: 'btn btn-outline-primary picker-button-clear', + buttonClose: 'btn btn-outline-primary picker-button-close', + buttonToday: 'btn btn-outline-primary picker-button-today', + // day + day: 'picker-day', + disabled: 'picker-day-disabled', + highlighted: 'picker-day-highlighted', + infocus: 'picker-day-infocus', + now: 'picker-day-today', + outfocus: 'picker-day-outfocus', + selected: 'picker-day-selected', + weekdays: 'picker-weekday', + // element + box: 'picker-box', + footer: 'picker-footer', + frame: 'picker-frame', + header: 'picker-header', + holder: 'picker-holder', + table: 'picker-table', + wrap: 'picker-wrap', + // input element + active: 'picker-input-active', + input: 'picker-input', + // month and year nav + month: 'picker-month', + navDisabled: 'picker-nav-disabled', + navNext: 'material-icons picker-nav-next', + navPrev: 'material-icons picker-nav-prev', + selectMonth: 'picker-select-month', + selectYear: 'picker-select-year', + year: 'picker-year', + // root picker + focused: 'picker-focused', + opened: 'picker-opened', + picker: 'picker' + }, + max: false, + min: false, + 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'], + ok: 'OK', + onClose: false, + onOpen: false, + onRender: false, + onSet: false, + onStart: false, + onStop: false, + selectMonths: false, + selectYears: false, + today: '', + weekdaysFull: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + weekdaysShort: ['S', 'M', 'T', 'W', 'T', 'F', 'S'] + }; + + Datepicker.prototype.display = function (datepickerApi, datepickerRoot, datepickerValue) { + $$$1('.picker-date-display', datepickerRoot).remove(); + $$$1('.picker-wrap', datepickerRoot).prepend('<div class="picker-date-display">' + '<div class="picker-date-display-top">' + '<span class="picker-year-display">' + datepickerApi.get(datepickerValue, 'yyyy') + '</span>' + '</div>' + '<div class="picker-date-display-bottom">' + '<span class="picker-weekday-display">' + datepickerApi.get(datepickerValue, 'dddd') + '</span>' + '<span class="picker-day-display">' + datepickerApi.get(datepickerValue, 'd') + '</span>' + '<span class="picker-month-display">' + datepickerApi.get(datepickerValue, 'mmm') + '</span>' + '</div>' + '</div>'); + }; + + Datepicker.prototype.show = function () { + var that = this; + $$$1(this._element).pickadate({ + clear: that._options.cancel, + close: that._options.ok, + closeOnClear: that._options.closeOnCancel, + closeOnSelect: that._options.closeOnSelect, + container: that._options.container, + disable: that._options.disable, + firstDay: that._options.firstDay, + format: that._options.format, + formatSubmit: that._options.formatSubmit, + klass: that._options.klass, + max: that._options.max, + min: that._options.min, + monthsFull: that._options.monthsFull, + monthsShort: that._options.monthsShort, + onClose: that._options.onClose, + onOpen: that._options.onOpen, + onRender: that._options.onRender, + onSet: that._options.onSet, + onStart: that._options.onStart, + onStop: that._options.onStop, + selectMonths: that._options.selectMonths, + selectYears: that._options.selectYears, + today: that._options.today, + weekdaysFull: that._options.weekdaysFull, + weekdaysShort: that._options.weekdaysShort + }); + var datepickerApi = $$$1(this._element).pickadate('picker'), + datepickerNode = datepickerApi.$node, + datepickerRoot = datepickerApi.$root; + datepickerApi.on({ + close: function close() { + $$$1(document.activeElement).blur(); + }, + open: function open() { + if (!$$$1('.picker__date-display', datepickerRoot).length) { + that.display(datepickerApi, datepickerRoot, 'highlight'); } + }, + set: function set() { + if (datepickerApi.get('select') !== null) { + that.display(datepickerApi, datepickerRoot, 'select'); + } + } + }); + }; - $target.one(Event.HIDDEN, function () { - if ($(_this7).is(':visible')) { - _this7.focus(); - } - }); - }); + function Plugin(option) { + return this.each(function () { + var data = $$$1(this).data('bs.pickdate'); + var options = $$$1.extend({}, Datepicker.DEFAULTS, $$$1(this).data(), typeof option == 'object' && option); - NavDrawer._jQueryInterface.call($(target), config, this); + if (!data) { + $$$1(this).data('bs.pickdate', data = new Datepicker(this, options)); + } + + data.show(); }); + } - $.fn[NAME] = NavDrawer._jQueryInterface; - $.fn[NAME].Constructor = NavDrawer; - $.fn[NAME].noConflict = function () { - $.fn[NAME] = NO_CONFLICT; - return NavDrawer._jQueryInterface; - }; + var old = $$$1.fn.pickdate; + $$$1.fn.pickdate = Plugin; + $$$1.fn.pickdate.Constructor = Datepicker; - return NavDrawer; - }(jQuery); + $$$1.fn.pickdate.noConflict = function () { + $$$1.fn.pickdate = old; + return this; + }; +})(jQuery); - /* - * selection control focus - * chrome persists the focus style on checkboxes/radio buttons after clicking - */ +/* + * expansion panel + * upon selecting the collapsed panel, + * it expands to display in full + */ - var ControlFocus = function ($) { +var ExpansionPanel = function ($$$1) { + // constants >>> + var DATA_KEY = 'bs.collapse'; + var EVENT_KEY = "." + DATA_KEY; + var ClassName = { + SHOW: 'show', + SHOW_PREDECESSOR: 'show-predecessor' + }; + var Event = { + HIDE: "hide" + EVENT_KEY, + SHOW: "show" + EVENT_KEY + }; + var Selector = { + PANEL: '.expansion-panel', + PANEL_BODY: '.expansion-panel .collapse' // <<< constants - // constants >>> - var DATA_KEY = 'md.controlfocus'; - var EVENT_KEY = '.' + DATA_KEY; + }; + $$$1(document).on("" + Event.HIDE, Selector.PANEL_BODY, function (event) { + var target = $$$1(event.target).closest(Selector.PANEL); + target.removeClass(ClassName.SHOW); + var predecessor = target.prev(Selector.PANEL); - var ClassName = { - FOCUS: 'focus' + if (predecessor.length) { + predecessor.removeClass(ClassName.SHOW_PREDECESSOR); + } + }).on("" + Event.SHOW, Selector.PANEL_BODY, function (event) { + var target = $$$1(event.target).closest(Selector.PANEL); + target.addClass(ClassName.SHOW); + var predecessor = target.prev(Selector.PANEL); + + if (predecessor.length) { + predecessor.addClass(ClassName.SHOW_PREDECESSOR); + } + }); +}($); + +/* + * floating label + * when a user engages with the text input field, + * the floating inline labels move to float above the field + */ + +var FloatingLabel = function ($$$1) { + // constants >>> + var DATA_KEY = 'md.floatinglabel'; + var EVENT_KEY = "." + DATA_KEY; + var NAME = 'floatinglabel'; + var NO_CONFLICT = $$$1.fn[NAME]; + var ClassName = { + IS_FOCUSED: 'is-focused', + HAS_VALUE: 'has-value' + }; + var Event = { + CHANGE: "change" + EVENT_KEY, + FOCUSIN: "focusin" + EVENT_KEY, + FOCUSOUT: "focusout" + EVENT_KEY + }; + var Selector = { + DATA_PARENT: '.floating-label', + DATA_TOGGLE: '.floating-label .form-control' // <<< constants + + }; + + var FloatingLabel = + /*#__PURE__*/ + function () { + function FloatingLabel(element) { + this._element = element; + } + + var _proto = FloatingLabel.prototype; + + _proto.change = function change(relatedTarget) { + if ($$$1(this._element).val() || $$$1(this._element).is('select') && $$$1('option:first-child', $$$1(this._element)).html().replace(' ', '') !== '') { + $$$1(relatedTarget).addClass(ClassName.HAS_VALUE); + } else { + $$$1(relatedTarget).removeClass(ClassName.HAS_VALUE); + } }; - var LastInteraction = { - IS_MOUSEDOWN: false + _proto.focusin = function focusin(relatedTarget) { + $$$1(relatedTarget).addClass(ClassName.IS_FOCUSED); }; - var Event = { - BLUR: 'blur' + EVENT_KEY, - FOCUS: 'focus' + EVENT_KEY, - MOUSEDOWN: 'mousedown' + EVENT_KEY, - MOUSEUP: 'mouseup' + EVENT_KEY + _proto.focusout = function focusout(relatedTarget) { + $$$1(relatedTarget).removeClass(ClassName.IS_FOCUSED); }; - var Selector = { - CONTROL: '.custom-control', - INPUT: '.custom-control-input' + FloatingLabel._jQueryInterface = function _jQueryInterface(event) { + return this.each(function () { + var _event = event ? event : 'change'; + + var data = $$$1(this).data(DATA_KEY); + + if (!data) { + data = new FloatingLabel(this); + $$$1(this).data(DATA_KEY, data); + } + + if (typeof _event === 'string') { + if (data[_event] === 'undefined') { + throw new Error("No method named \"" + _event + "\""); + } + + data[_event]($$$1(this).closest(Selector.DATA_PARENT)); + } + }); }; - // <<< constants - $(document).on('' + Event.BLUR, Selector.INPUT, function (event) { - $(event.target).removeClass(ClassName.FOCUS); - }).on('' + Event.FOCUS, Selector.INPUT, function (event) { - if (LastInteraction.IS_MOUSEDOWN === false) { - $(event.target).addClass(ClassName.FOCUS); + return FloatingLabel; + }(); + + $$$1(document).on(Event.CHANGE + " " + Event.FOCUSIN + " " + Event.FOCUSOUT, Selector.DATA_TOGGLE, function (event) { + FloatingLabel._jQueryInterface.call($$$1(this), event.type); + }); + $$$1.fn[NAME] = FloatingLabel._jQueryInterface; + $$$1.fn[NAME].Constructor = FloatingLabel; + + $$$1.fn[NAME].noConflict = function () { + $$$1.fn[NAME] = NO_CONFLICT; + return FloatingLabel._jQueryInterface; + }; + + return FloatingLabel; +}($); + +/* + * global util js + * based on bootstrap's (v4.0.0-beta) util.js + */ + +var Util = function ($$$1) { + var MAX_UID = 1000000; + var transition = false; + + function escapeId(selector) { + selector = typeof $$$1.escapeSelector === 'function' ? $$$1.escapeSelector(selector).substr(1) : selector.replace(/(:|\.|\[|\]|,|=|@)/g, '\\$1'); + return selector; + } + + function getSpecialTransitionEndEvent() { + return { + bindType: transition.end, + delegateType: transition.end, + handle: function handle(event) { + if ($$$1(event.target).is(this)) { + return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params + } + + return undefined; // eslint-disable-line no-undefined } - }).on('' + Event.MOUSEDOWN, Selector.CONTROL, function () { - LastInteraction.IS_MOUSEDOWN = true; - }).on('' + Event.MOUSEUP, Selector.CONTROL, function () { - setTimeout(function () { - LastInteraction.IS_MOUSEDOWN = false; - }, 1); + }; + } + + function setTransitionEndSupport() { + transition = transitionEndTest(); + $$$1.fn.emulateTransitionEnd = transitionEndEmulator; + + if (Util.supportsTransitionEnd()) { + $$$1.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent(); + } + } + + function toType(obj) { + return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase(); + } + + function transitionEndEmulator(duration) { + var _this = this; + + var called = false; + $$$1(this).one(Util.TRANSITION_END, function () { + called = true; }); - }(jQuery); + setTimeout(function () { + if (!called) { + Util.triggerTransitionEnd(_this); + } + }, duration); + return this; + } - /* - * tab indicator animation - * requires bootstrap's (v4.0.0-beta) tab.js - */ + function transitionEndTest() { + if (window.QUnit) { + return false; + } - var TabSwitch = function ($) { + return { + end: 'transitionend' + }; + } - // constants >>> - var DATA_KEY = 'md.tabswitch'; - var NAME = 'tabswitch'; - var NO_CONFLICT = $.fn[NAME]; - var TRANSITION_DURATION = 390; + var Util = { + TRANSITION_END: 'mdTransitionEnd', + getSelectorFromElement: function getSelectorFromElement(element) { + var selector = element.getAttribute('data-target'); - var ClassName = { - ANIMATE: 'animate', - DROPDOWN_ITEM: 'dropdown-item', - INDICATOR: 'nav-tabs-indicator', - MATERIAL: 'nav-tabs-material', - SCROLLABLE: 'nav-tabs-scrollable', - SHOW: 'show' + if (!selector || selector === '#') { + selector = element.getAttribute('href') || ''; + } + + if (selector.charAt(0) === '#') { + selector = escapeId(selector); + } + + try { + var $selector = $$$1(document).find(selector); + return $selector.length > 0 ? selector : null; + } catch (err) { + return null; + } + }, + getUID: function getUID(prefix) { + do { + // eslint-disable-next-line no-bitwise + prefix += ~~(Math.random() * MAX_UID); + } while (document.getElementById(prefix)); + + return prefix; + }, + isElement: function isElement(obj) { + return (obj[0] || obj).nodeType; + }, + reflow: function reflow(element) { + return element.offsetHeight; + }, + supportsTransitionEnd: function supportsTransitionEnd() { + return Boolean(transition); + }, + triggerTransitionEnd: function triggerTransitionEnd(element) { + $$$1(element).trigger(transition.end); + }, + typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) { + for (var property in configTypes) { + if (Object.prototype.hasOwnProperty.call(configTypes, property)) { + var expectedTypes = configTypes[property]; + var value = config[property]; + var valueType = value && Util.isElement(value) ? 'element' : toType(value); + + if (!new RegExp(expectedTypes).test(valueType)) { + throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\".")); + } + } + } + } + }; + setTransitionEndSupport(); + return Util; +}($); + +/* + * navigation drawer + * based on bootstrap's (v4.0.0-beta) modal.js + */ + +var NavDrawer = function ($$$1) { + // constants >>> + var DATA_API_KEY = '.data-api'; + var DATA_KEY = 'md.navdrawer'; + var ESCAPE_KEYCODE = 27; + var EVENT_KEY = "." + DATA_KEY; + var NAME = 'navdrawer'; + var NO_CONFLICT = $$$1.fn[NAME]; + var TRANSITION_DURATION = 292.5; + var TRANSITION_DURATION_BACKDROP = 487.5; + var ClassName = { + BACKDROP: 'navdrawer-backdrop', + OPEN: 'navdrawer-open', + SHOW: 'show' + }; + var Default = { + breakpoint: 1280, + keyboard: true, + show: true, + type: 'default' + }; + var DefaultType = { + keyboard: 'boolean', + show: 'boolean', + type: 'string' + }; + var Event = { + CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY, + CLICK_DISMISS: "click.dismiss" + EVENT_KEY, + FOCUSIN: "focusin" + EVENT_KEY, + HIDDEN: "hidden" + EVENT_KEY, + HIDE: "hide" + EVENT_KEY, + KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY, + MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY, + MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY, + SHOW: "show" + EVENT_KEY, + SHOWN: "shown" + EVENT_KEY + }; + var Selector = { + CONTENT: '.navdrawer-content', + DATA_DISMISS: '[data-dismiss="navdrawer"]', + DATA_TOGGLE: '[data-toggle="navdrawer"]' // <<< constants + + }; + + var NavDrawer = + /*#__PURE__*/ + function () { + function NavDrawer(element, config) { + this._backdrop = null; + this._config = this._getConfig(config); + this._content = $$$1(element).find(Selector.CONTENT)[0]; + this._element = element; + this._ignoreBackdropClick = false; + this._isShown = false; + } + + var _proto = NavDrawer.prototype; + + _proto.hide = function hide(event) { + if (event) { + event.preventDefault(); + } + + var hideClassName = ClassName.OPEN + "-" + this._config.type; + var hideEvent = $$$1.Event(Event.HIDE); + $$$1(this._element).trigger(hideEvent); + + if (!this._isShown || hideEvent.isDefaultPrevented()) { + return; + } + + this._isShown = false; + + this._setEscapeEvent(); + + $$$1(document).off(Event.FOCUSIN); + $$$1(this._content).off(Event.MOUSEDOWN_DISMISS); + $$$1(this._element).off(Event.CLICK_DISMISS).removeClass(ClassName.SHOW); + + this._hideNavdrawer(hideClassName); }; - var Event = { - SHOW_BS_TAB: 'show.bs.tab' + _proto.show = function show(relatedTarget) { + var _this = this; + + var showEvent = $$$1.Event(Event.SHOW, { + relatedTarget: relatedTarget + }); + $$$1(this._element).trigger(showEvent); + + if (this._isShown || showEvent.isDefaultPrevented()) { + return; + } + + this._isShown = true; + $$$1(document.body).addClass(ClassName.OPEN + "-" + this._config.type); + + this._setEscapeEvent(); + + $$$1(this._element).addClass(NAME + "-" + this._config.type); + $$$1(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, $$$1.proxy(this.hide, this)); + $$$1(this._content).on(Event.MOUSEDOWN_DISMISS, function () { + $$$1(_this._element).one(Event.MOUSEUP_DISMISS, function (event) { + if ($$$1(event.target).is(_this._element)) { + _this._ignoreBackdropClick = true; + } + }); + }); + + this._showBackdrop(); + + this._showElement(relatedTarget); }; - var Selector = { - DATA_TOGGLE: '.nav-tabs [data-toggle="tab"]', - DROPDOWN: '.dropdown', - NAV: '.nav-tabs' + _proto.toggle = function toggle(relatedTarget) { + return this._isShown ? this.hide() : this.show(relatedTarget); }; - // <<< constants - var TabSwitch = function () { - function TabSwitch(nav) { - _classCallCheck(this, TabSwitch); + _proto._enforceFocus = function _enforceFocus() { + var _this2 = this; - if (typeof $.fn.tab === 'undefined') { - throw new Error('Material\'s JavaScript requires Bootstrap\'s tab.js'); + $$$1(document).off(Event.FOCUSIN).on(Event.FOCUSIN, function (event) { + if (_this2._config.type === 'default' || $$$1(window).width() <= _this2._config.breakpoint) { + if (_this2._element !== event.target && !$$$1(_this2._element).has(event.target).length) { + _this2._element.focus(); + } } + }); + }; - this._nav = nav; - this._navindicator = null; + _proto._getConfig = function _getConfig(config) { + config = $$$1.extend({}, Default, config); + Util.typeCheckConfig(NAME, config, DefaultType); + return config; + }; + + _proto._hideNavdrawer = function _hideNavdrawer(className) { + var _this3 = this; + + this._showBackdrop(function () { + $$$1(document.body).removeClass(className); + + _this3._element.setAttribute('aria-hidden', 'true'); + + _this3._element.style.display = 'none'; + $$$1(_this3._element).trigger(Event.HIDDEN); + }); + }; + + _proto._removeBackdrop = function _removeBackdrop() { + if (this._backdrop) { + $$$1(this._backdrop).remove(); + this._backdrop = null; } + }; - TabSwitch.prototype.switch = function _switch(element, relatedTarget) { - var _this8 = this; + _proto._setEscapeEvent = function _setEscapeEvent() { + var _this4 = this; - var navLeft = $(this._nav).offset().left; - var navScrollLeft = $(this._nav).scrollLeft(); - var navWidth = $(this._nav).outerWidth(); - var supportsTransition = Util.supportsTransitionEnd(); + if (this._isShown && this._config.keyboard) { + $$$1(this._element).on(Event.KEYDOWN_DISMISS, function (event) { + if (event.which === ESCAPE_KEYCODE) { + _this4.hide(); + } + }); + } else if (!this._isShown) { + $$$1(this._element).off(Event.KEYDOWN_DISMISS); + } + }; - if (!this._navindicator) { - this._createIndicator(navLeft, navScrollLeft, navWidth, relatedTarget); - } + _proto._showBackdrop = function _showBackdrop(callback) { + var _this5 = this; - if ($(element).hasClass(ClassName.DROPDOWN_ITEM)) { - element = $(element).closest(Selector.DROPDOWN); - } + var supportsTransition = Util.supportsTransitionEnd(); - var elLeft = $(element).offset().left; - var elWidth = $(element).outerWidth(); + if (this._isShown) { + this._backdrop = document.createElement('div'); + $$$1(this._backdrop).addClass(ClassName.BACKDROP).addClass(ClassName.BACKDROP + "-" + this._config.type).appendTo(document.body); + $$$1(this._element).on(Event.CLICK_DISMISS, function (event) { + if (_this5._ignoreBackdropClick) { + _this5._ignoreBackdropClick = false; + return; + } - $(this._navindicator).addClass(ClassName.SHOW); - Util.reflow(this._navindicator); + if (event.target !== event.currentTarget) { + return; + } + _this5.hide(); + }); + if (supportsTransition) { - $(this._nav).addClass(ClassName.ANIMATE); + Util.reflow(this._backdrop); } - $(this._navindicator).css({ - left: elLeft + navScrollLeft - navLeft, - right: navWidth - (elLeft + navScrollLeft - navLeft + elWidth) - }); + $$$1(this._backdrop).addClass(ClassName.SHOW); - var complete = function complete() { - $(_this8._nav).removeClass(ClassName.ANIMATE); - $(_this8._navindicator).removeClass(ClassName.SHOW); - }; + if (!callback) { + return; + } if (!supportsTransition) { - complete(); + callback(); return; } - $(this._navindicator).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); - }; + $$$1(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(TRANSITION_DURATION_BACKDROP); + } else if (this._backdrop && !this._isShown) { + $$$1(this._backdrop).removeClass(ClassName.SHOW); - TabSwitch.prototype._createIndicator = function _createIndicator(navLeft, navScrollLeft, navWidth, relatedTarget) { - this._navindicator = document.createElement('div'); + var callbackRemove = function callbackRemove() { + _this5._removeBackdrop(); - $(this._navindicator).addClass(ClassName.INDICATOR).appendTo(this._nav); - - if (relatedTarget !== undefined) { - if ($(relatedTarget).hasClass(ClassName.DROPDOWN_ITEM)) { - relatedTarget = $(relatedTarget).closest(Selector.DROPDOWN); + if (callback) { + callback(); } + }; - var relatedLeft = $(relatedTarget).offset().left; - var relatedWidth = $(relatedTarget).outerWidth(); - - $(this._navindicator).css({ - left: relatedLeft + navScrollLeft - navLeft, - right: navWidth - (relatedLeft + navScrollLeft - navLeft + relatedWidth) - }); + if (supportsTransition) { + $$$1(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(TRANSITION_DURATION_BACKDROP); + } else { + callbackRemove(); } + } else if (callback) { + callback(); + } + }; - $(this._nav).addClass(ClassName.MATERIAL); - }; + _proto._showElement = function _showElement(relatedTarget) { + var _this6 = this; - TabSwitch._jQueryInterface = function _jQueryInterface(relatedTarget) { - return this.each(function () { - var nav = $(this).closest(Selector.NAV)[0]; + var supportsTransition = Util.supportsTransitionEnd(); - if (!nav) { - return; - } + if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { + document.body.appendChild(this._element); + } - var data = $(nav).data(DATA_KEY); + this._element.removeAttribute('aria-hidden'); - if (!data) { - data = new TabSwitch(nav); - $(nav).data(DATA_KEY, data); - } + this._element.style.display = 'block'; - data.switch(this, relatedTarget); - }); - }; + if (supportsTransition) { + Util.reflow(this._element); + } - return TabSwitch; - }(); + $$$1(this._element).addClass(ClassName.SHOW); - $(document).on(Event.SHOW_BS_TAB, Selector.DATA_TOGGLE, function (event) { - TabSwitch._jQueryInterface.call($(event.target), event.relatedTarget); - }); + this._enforceFocus(); - $.fn[NAME] = TabSwitch._jQueryInterface; - $.fn[NAME].Constructor = TabSwitch; - $.fn[NAME].noConflict = function () { - $.fn[NAME] = NO_CONFLICT; - return TabSwitch._jQueryInterface; - }; + var shownEvent = $$$1.Event(Event.SHOWN, { + relatedTarget: relatedTarget + }); - return TabSwitch; - }(jQuery); + var transitionComplete = function transitionComplete() { + _this6._element.focus(); - /* - * global util js - * based on bootstrap's (v4.0.0-beta) util.js - */ + $$$1(_this6._element).trigger(shownEvent); + }; - var Util = function ($) { + if (supportsTransition) { + $$$1(this._content).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(TRANSITION_DURATION); + } else { + transitionComplete(); + } + }; - var MAX_UID = 1000000; - var transition = false; + NavDrawer._jQueryInterface = function _jQueryInterface(config, relatedTarget) { + return this.each(function () { + var _config = $$$1.extend({}, NavDrawer.Default, $$$1(this).data(), typeof config === 'object' && config); - var TransitionEndEvent = { - WebkitTransition: 'webkitTransitionEnd', - MozTransition: 'transitionend', - OTransition: 'oTransitionEnd otransitionend', - transition: 'transitionend' - }; + var data = $$$1(this).data(DATA_KEY); - function getSpecialTransitionEndEvent() { - return { - bindType: transition.end, - delegateType: transition.end, - handle: function handle(event) { - if ($(event.target).is(this)) { - // eslint-disable-next-line prefer-rest-params - return event.handleObj.handler.apply(this, arguments); + if (!data) { + data = new NavDrawer(this, _config); + $$$1(this).data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (data[config] === 'undefined') { + throw new Error("No method named \"" + config + "\""); } - return undefined; + + data[config](relatedTarget); + } else if (_config.show) { + data.show(relatedTarget); } - }; - } + }); + }; - function isElement(obj) { - return (obj[0] || obj).nodeType; + _createClass(NavDrawer, null, [{ + key: "Default", + get: function get() { + return Default; + } + }]); + return NavDrawer; + }(); + + $$$1(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { + var _this7 = this; + + var selector = Util.getSelectorFromElement(this); + var target; + + if (selector) { + target = $$$1(selector)[0]; } - function setTransitionEndSupport() { - transition = transitionEndTest(); + var config = $$$1(target).data(DATA_KEY) ? 'toggle' : $$$1.extend({}, $$$1(target).data(), $$$1(this).data()); - $.fn.emulateTransitionEnd = transitionEndEmulator; + if (this.tagName === 'A') { + event.preventDefault(); + } - if (Util.supportsTransitionEnd()) { - $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent(); + var $target = $$$1(target).one(Event.SHOW, function (showEvent) { + if (showEvent.isDefaultPrevented()) { + return; } - } - function toType(obj) { - return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase(); + $target.one(Event.HIDDEN, function () { + if ($$$1(_this7).is(':visible')) { + _this7.focus(); + } + }); + }); + + NavDrawer._jQueryInterface.call($$$1(target), config, this); + }); + $$$1.fn[NAME] = NavDrawer._jQueryInterface; + $$$1.fn[NAME].Constructor = NavDrawer; + + $$$1.fn[NAME].noConflict = function () { + $$$1.fn[NAME] = NO_CONFLICT; + return NavDrawer._jQueryInterface; + }; + + return NavDrawer; +}($); + +/* + * selection control focus + * chrome persists the focus style on checkboxes/radio buttons after clicking + */ + +var SelectionControlFocus = function ($$$1) { + // constants >>> + var DATA_KEY = 'md.selectioncontrolfocus'; + var EVENT_KEY = "." + DATA_KEY; + var ClassName = { + FOCUS: 'focus' + }; + var LastInteraction = { + IS_MOUSEDOWN: false + }; + var Event = { + BLUR: "blur" + EVENT_KEY, + FOCUS: "focus" + EVENT_KEY, + MOUSEDOWN: "mousedown" + EVENT_KEY, + MOUSEUP: "mouseup" + EVENT_KEY + }; + var Selector = { + CONTROL: '.custom-control', + INPUT: '.custom-control-input' // <<< constants + + }; + $$$1(document).on("" + Event.BLUR, Selector.INPUT, function (event) { + $$$1(event.target).removeClass(ClassName.FOCUS); + }).on("" + Event.FOCUS, Selector.INPUT, function (event) { + if (LastInteraction.IS_MOUSEDOWN === false) { + $$$1(event.target).addClass(ClassName.FOCUS); } + }).on("" + Event.MOUSEDOWN, Selector.CONTROL, function () { + LastInteraction.IS_MOUSEDOWN = true; + }).on("" + Event.MOUSEUP, Selector.CONTROL, function () { + setTimeout(function () { + LastInteraction.IS_MOUSEDOWN = false; + }, 1); + }); +}($); - function transitionEndEmulator(duration) { - var _this9 = this; +/* + * tab indicator animation + * requires bootstrap's (v4.0.0-beta) tab.js + */ - var called = false; +var TabSwitch = function ($$$1) { + // constants >>> + var DATA_KEY = 'md.tabswitch'; + var NAME = 'tabswitch'; + var NO_CONFLICT = $$$1.fn[NAME]; + var TRANSITION_DURATION = 390; + var ClassName = { + ANIMATE: 'animate', + DROPDOWN_ITEM: 'dropdown-item', + INDICATOR: 'nav-tabs-indicator', + MATERIAL: 'nav-tabs-material', + SCROLLABLE: 'nav-tabs-scrollable', + SHOW: 'show' + }; + var Event = { + SHOW_BS_TAB: 'show.bs.tab' + }; + var Selector = { + DATA_TOGGLE: '.nav-tabs [data-toggle="tab"]', + DROPDOWN: '.dropdown', + NAV: '.nav-tabs' // <<< constants - $(this).one(Util.TRANSITION_END, function () { - called = true; - }); + }; - setTimeout(function () { - if (!called) { - Util.triggerTransitionEnd(_this9); - } - }, duration); + var TabSwitch = + /*#__PURE__*/ + function () { + function TabSwitch(nav) { + if (typeof $$$1.fn.tab === 'undefined') { + throw new Error('Material\'s JavaScript requires Bootstrap\'s tab.js'); + } - return this; + this._nav = nav; + this._navindicator = null; } - function transitionEndTest() { - if (window.QUnit) { - return false; + var _proto = TabSwitch.prototype; + + _proto.switch = function _switch(element, relatedTarget) { + var _this = this; + + var navLeft = $$$1(this._nav).offset().left; + var navScrollLeft = $$$1(this._nav).scrollLeft(); + var navWidth = $$$1(this._nav).outerWidth(); + var supportsTransition = Util.supportsTransitionEnd(); + + if (!this._navindicator) { + this._createIndicator(navLeft, navScrollLeft, navWidth, relatedTarget); } - var el = document.createElement('material'); + if ($$$1(element).hasClass(ClassName.DROPDOWN_ITEM)) { + element = $$$1(element).closest(Selector.DROPDOWN); + } - for (var name in TransitionEndEvent) { - if (el.style[name] !== undefined) { - return { - end: TransitionEndEvent[name] - }; - } + var elLeft = $$$1(element).offset().left; + var elWidth = $$$1(element).outerWidth(); + $$$1(this._navindicator).addClass(ClassName.SHOW); + Util.reflow(this._navindicator); + + if (supportsTransition) { + $$$1(this._nav).addClass(ClassName.ANIMATE); } - return false; - } + $$$1(this._navindicator).css({ + left: elLeft + navScrollLeft - navLeft, + right: navWidth - (elLeft + navScrollLeft - navLeft + elWidth) + }); - var Util = { - TRANSITION_END: 'mdTransitionEnd', + var complete = function complete() { + $$$1(_this._nav).removeClass(ClassName.ANIMATE); + $$$1(_this._navindicator).removeClass(ClassName.SHOW); + }; - getSelectorFromElement: function getSelectorFromElement(element) { - var selector = element.getAttribute('data-target'); + if (!supportsTransition) { + complete(); + return; + } - if (!selector) { - selector = element.getAttribute('href') || ''; - selector = /^#[a-z]/i.test(selector) ? selector : null; - } + $$$1(this._navindicator).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); + }; - return selector; - }, - getUID: function getUID(prefix) { - do { - // eslint-disable-next-line no-bitwise - prefix += ~~(Math.random() * MAX_UID); - } while (document.getElementById(prefix)); - return prefix; - }, - reflow: function reflow(element) { - new Function('md', 'return md')(element.offsetHeight); - }, - supportsTransitionEnd: function supportsTransitionEnd() { - return Boolean(transition); - }, - triggerTransitionEnd: function triggerTransitionEnd(element) { - $(element).trigger(transition.end); - }, - typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) { - for (var property in configTypes) { - if (configTypes.hasOwnProperty(property)) { - var expectedTypes = configTypes[property]; - var value = config[property]; - var valueType = value && isElement(value) ? 'element' : toType(value); + _proto._createIndicator = function _createIndicator(navLeft, navScrollLeft, navWidth, relatedTarget) { + this._navindicator = document.createElement('div'); + $$$1(this._navindicator).addClass(ClassName.INDICATOR).appendTo(this._nav); - if (!new RegExp(expectedTypes).test(valueType)) { - throw new Error(componentName.toUpperCase() + ': ' + ('Option "' + property + '" provided type "' + valueType + '" ') + ('but expected type "' + expectedTypes + '".')); - } - } + if (relatedTarget !== 'undefined') { + if ($$$1(relatedTarget).hasClass(ClassName.DROPDOWN_ITEM)) { + relatedTarget = $$$1(relatedTarget).closest(Selector.DROPDOWN); } + + var relatedLeft = $$$1(relatedTarget).offset().left; + var relatedWidth = $$$1(relatedTarget).outerWidth(); + $$$1(this._navindicator).css({ + left: relatedLeft + navScrollLeft - navLeft, + right: navWidth - (relatedLeft + navScrollLeft - navLeft + relatedWidth) + }); } + + $$$1(this._nav).addClass(ClassName.MATERIAL); }; - setTransitionEndSupport(); + TabSwitch._jQueryInterface = function _jQueryInterface(relatedTarget) { + return this.each(function () { + var nav = $$$1(this).closest(Selector.NAV)[0]; - return Util; - }(jQuery); -}(); + if (!nav) { + return; + } + + var data = $$$1(nav).data(DATA_KEY); + + if (!data) { + data = new TabSwitch(nav); + $$$1(nav).data(DATA_KEY, data); + } + + data.switch(this, relatedTarget); + }); + }; + + return TabSwitch; + }(); + + $$$1(document).on(Event.SHOW_BS_TAB, Selector.DATA_TOGGLE, function (event) { + TabSwitch._jQueryInterface.call($$$1(event.target), event.relatedTarget); + }); + $$$1.fn[NAME] = TabSwitch._jQueryInterface; + $$$1.fn[NAME].Constructor = TabSwitch; + + $$$1.fn[NAME].noConflict = function () { + $$$1.fn[NAME] = NO_CONFLICT; + return TabSwitch._jQueryInterface; + }; + + return TabSwitch; +}($); + +// Extend third party JavaScript + +exports.Util = Util; +exports.ExpansionPanel = ExpansionPanel; +exports.FloatingLabel = FloatingLabel; +exports.NavDrawer = NavDrawer; +exports.SelectionControlFocus = SelectionControlFocus; +exports.TabSwitch = TabSwitch; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); +//# sourceMappingURL=material.js.map