PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.6.24
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.6.24
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / assets / js / vendor.js

vendor.js in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.6.24, at assets/js/vendor.js

13,003 lines 454.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* assets/wpuf/vendor/vue/vue.min.js */
2 /*!
3 * Vue.js v2.2.4
4 * (c) 2014-2017 Evan You
5 * Released under the MIT License.
6 */
7 !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Vue=t()}(this,function(){"use strict";function e(e){return null==e?"":"object"==typeof e?JSON.stringify(e,null,2):String(e)}function t(e){var t=parseFloat(e);return isNaN(t)?e:t}function n(e,t){for(var n=Object.create(null),r=e.split(","),i=0;i<r.length;i++)n[r[i]]=!0;return t?function(e){return n[e.toLowerCase()]}:function(e){return n[e]}}function r(e,t){if(e.length){var n=e.indexOf(t);if(n>-1)return e.splice(n,1)}}function i(e,t){return Si.call(e,t)}function o(e){return"string"==typeof e||"number"==typeof e}function a(e){var t=Object.create(null);return function(n){var r=t[n];return r||(t[n]=e(n))}}function s(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n}function c(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function u(e,t){for(var n in t)e[n]=t[n];return e}function l(e){return null!==e&&"object"==typeof e}function f(e){return Li.call(e)===Di}function p(e){for(var t={},n=0;n<e.length;n++)e[n]&&u(t,e[n]);return t}function d(){}function v(e){return e.reduce(function(e,t){return e.concat(t.staticKeys||[])},[]).join(",")}function h(e,t){var n=l(e),r=l(t);if(!n||!r)return!n&&!r&&String(e)===String(t);try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){return e===t}}function m(e,t){for(var n=0;n<e.length;n++)if(h(e[n],t))return n;return-1}function g(e){var t=!1;return function(){t||(t=!0,e())}}function y(e){var t=(e+"").charCodeAt(0);return 36===t||95===t}function _(e,t,n,r){Object.defineProperty(e,t,{value:n,enumerable:!!r,writable:!0,configurable:!0})}function b(e){if(!Hi.test(e)){var t=e.split(".");return function(e){for(var n=0;n<t.length;n++){if(!e)return;e=e[t[n]]}return e}}}function $(e){return/native code/.test(e.toString())}function w(e){no.target&&ro.push(no.target),no.target=e}function x(){no.target=ro.pop()}function C(e,t){e.__proto__=t}function k(e,t,n){for(var r=0,i=n.length;r<i;r++){var o=n[r];_(e,o,t[o])}}function A(e,t){if(l(e)){var n;return i(e,"__ob__")&&e.__ob__ instanceof co?n=e.__ob__:so.shouldConvert&&!Gi()&&(Array.isArray(e)||f(e))&&Object.isExtensible(e)&&!e._isVue&&(n=new co(e)),t&&n&&n.vmCount++,n}}function O(e,t,n,r){var i=new no,o=Object.getOwnPropertyDescriptor(e,t);if(!o||o.configurable!==!1){var a=o&&o.get,s=o&&o.set,c=A(n);Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:function(){var t=a?a.call(e):n;return no.target&&(i.depend(),c&&c.dep.depend(),Array.isArray(t)&&E(t)),t},set:function(t){var r=a?a.call(e):n;t===r||t!==t&&r!==r||(s?s.call(e,t):n=t,c=A(t),i.notify())}})}}function S(e,t,n){if(Array.isArray(e))return e.length=Math.max(e.length,t),e.splice(t,1,n),n;if(i(e,t))return e[t]=n,n;var r=e.__ob__;return e._isVue||r&&r.vmCount?n:r?(O(r.value,t,n),r.dep.notify(),n):(e[t]=n,n)}function T(e,t){if(Array.isArray(e))return void e.splice(t,1);var n=e.__ob__;e._isVue||n&&n.vmCount||i(e,t)&&(delete e[t],n&&n.dep.notify())}function E(e){for(var t=void 0,n=0,r=e.length;n<r;n++)t=e[n],t&&t.__ob__&&t.__ob__.dep.depend(),Array.isArray(t)&&E(t)}function j(e,t){if(!t)return e;for(var n,r,o,a=Object.keys(t),s=0;s<a.length;s++)n=a[s],r=e[n],o=t[n],i(e,n)?f(r)&&f(o)&&j(r,o):S(e,n,o);return e}function N(e,t){return t?e?e.concat(t):Array.isArray(t)?t:[t]:e}function I(e,t){var n=Object.create(e||null);return t?u(n,t):n}function L(e){var t=e.props;if(t){var n,r,i,o={};if(Array.isArray(t))for(n=t.length;n--;)r=t[n],"string"==typeof r&&(i=Ei(r),o[i]={type:null});else if(f(t))for(var a in t)r=t[a],i=Ei(a),o[i]=f(r)?r:{type:r};e.props=o}}function D(e){var t=e.directives;if(t)for(var n in t){var r=t[n];"function"==typeof r&&(t[n]={bind:r,update:r})}}function M(e,t,n){function r(r){var i=uo[r]||lo;l[r]=i(e[r],t[r],n,r)}L(t),D(t);var o=t.extends;if(o&&(e="function"==typeof o?M(e,o.options,n):M(e,o,n)),t.mixins)for(var a=0,s=t.mixins.length;a<s;a++){var c=t.mixins[a];c.prototype instanceof st&&(c=c.options),e=M(e,c,n)}var u,l={};for(u in e)r(u);for(u in t)i(e,u)||r(u);return l}function P(e,t,n,r){if("string"==typeof n){var o=e[t];if(i(o,n))return o[n];var a=Ei(n);if(i(o,a))return o[a];var s=ji(a);if(i(o,s))return o[s];var c=o[n]||o[a]||o[s];return c}}function R(e,t,n,r){var o=t[e],a=!i(n,e),s=n[e];if(U(Boolean,o.type)&&(a&&!i(o,"default")?s=!1:U(String,o.type)||""!==s&&s!==Ii(e)||(s=!0)),void 0===s){s=F(r,o,e);var c=so.shouldConvert;so.shouldConvert=!0,A(s),so.shouldConvert=c}return s}function F(e,t,n){if(i(t,"default")){var r=t.default;return e&&e.$options.propsData&&void 0===e.$options.propsData[n]&&void 0!==e._props[n]?e._props[n]:"function"==typeof r&&"Function"!==H(t.type)?r.call(e):r}}function H(e){var t=e&&e.toString().match(/^\s*function (\w+)/);return t&&t[1]}function U(e,t){if(!Array.isArray(t))return H(t)===H(e);for(var n=0,r=t.length;n<r;n++)if(H(t[n])===H(e))return!0;return!1}function B(e,t,n){if(Ri.errorHandler)Ri.errorHandler.call(null,e,t,n);else{if(!Bi||"undefined"==typeof console)throw e;console.error(e)}}function V(e){return new fo(void 0,void 0,void 0,String(e))}function z(e){var t=new fo(e.tag,e.data,e.children,e.text,e.elm,e.context,e.componentOptions);return t.ns=e.ns,t.isStatic=e.isStatic,t.key=e.key,t.isCloned=!0,t}function J(e){for(var t=e.length,n=new Array(t),r=0;r<t;r++)n[r]=z(e[r]);return n}function K(e){function t(){var e=arguments,n=t.fns;if(!Array.isArray(n))return n.apply(null,arguments);for(var r=0;r<n.length;r++)n[r].apply(null,e)}return t.fns=e,t}function q(e,t,n,r,i){var o,a,s,c;for(o in e)a=e[o],s=t[o],c=mo(o),a&&(s?a!==s&&(s.fns=a,e[o]=s):(a.fns||(a=e[o]=K(a)),n(c.name,a,c.once,c.capture)));for(o in t)e[o]||(c=mo(o),r(c.name,t[o],c.capture))}function W(e,t,n){function i(){n.apply(this,arguments),r(o.fns,i)}var o,a=e[t];a?a.fns&&a.merged?(o=a,o.fns.push(i)):o=K([a,i]):o=K([i]),o.merged=!0,e[t]=o}function Z(e){for(var t=0;t<e.length;t++)if(Array.isArray(e[t]))return Array.prototype.concat.apply([],e);return e}function G(e){return o(e)?[V(e)]:Array.isArray(e)?Y(e):void 0}function Y(e,t){var n,r,i,a=[];for(n=0;n<e.length;n++)r=e[n],null!=r&&"boolean"!=typeof r&&(i=a[a.length-1],Array.isArray(r)?a.push.apply(a,Y(r,(t||"")+"_"+n)):o(r)?i&&i.text?i.text+=String(r):""!==r&&a.push(V(r)):r.text&&i&&i.text?a[a.length-1]=V(i.text+r.text):(r.tag&&null==r.key&&null!=t&&(r.key="__vlist"+t+"_"+n+"__"),a.push(r)));return a}function Q(e){return e&&e.filter(function(e){return e&&e.componentOptions})[0]}function X(e){e._events=Object.create(null),e._hasHookEvent=!1;var t=e.$options._parentListeners;t&&ne(e,t)}function ee(e,t,n){n?vo.$once(e,t):vo.$on(e,t)}function te(e,t){vo.$off(e,t)}function ne(e,t,n){vo=e,q(t,n||{},ee,te,e)}function re(e){var t=/^hook:/;e.prototype.$on=function(e,n){var r=this,i=this;if(Array.isArray(e))for(var o=0,a=e.length;o<a;o++)r.$on(e[o],n);else(i._events[e]||(i._events[e]=[])).push(n),t.test(e)&&(i._hasHookEvent=!0);return i},e.prototype.$once=function(e,t){function n(){r.$off(e,n),t.apply(r,arguments)}var r=this;return n.fn=t,r.$on(e,n),r},e.prototype.$off=function(e,t){var n=this,r=this;if(!arguments.length)return r._events=Object.create(null),r;if(Array.isArray(e)){for(var i=0,o=e.length;i<o;i++)n.$off(e[i],t);return r}var a=r._events[e];if(!a)return r;if(1===arguments.length)return r._events[e]=null,r;for(var s,c=a.length;c--;)if(s=a[c],s===t||s.fn===t){a.splice(c,1);break}return r},e.prototype.$emit=function(e){var t=this,n=t._events[e];if(n){n=n.length>1?c(n):n;for(var r=c(arguments,1),i=0,o=n.length;i<o;i++)n[i].apply(t,r)}return t}}function ie(e,t){var n={};if(!e)return n;for(var r,i,o=[],a=0,s=e.length;a<s;a++)if(i=e[a],(i.context===t||i.functionalContext===t)&&i.data&&(r=i.data.slot)){var c=n[r]||(n[r]=[]);"template"===i.tag?c.push.apply(c,i.children):c.push(i)}else o.push(i);return o.every(oe)||(n.default=o),n}function oe(e){return e.isComment||" "===e.text}function ae(e){for(var t={},n=0;n<e.length;n++)t[e[n][0]]=e[n][1];return t}function se(e){var t=e.$options,n=t.parent;if(n&&!t.abstract){for(;n.$options.abstract&&n.$parent;)n=n.$parent;n.$children.push(e)}e.$parent=n,e.$root=n?n.$root:e,e.$children=[],e.$refs={},e._watcher=null,e._inactive=null,e._directInactive=!1,e._isMounted=!1,e._isDestroyed=!1,e._isBeingDestroyed=!1}function ce(e){e.prototype._update=function(e,t){var n=this;n._isMounted&&ve(n,"beforeUpdate");var r=n.$el,i=n._vnode,o=go;go=n,n._vnode=e,i?n.$el=n.__patch__(i,e):n.$el=n.__patch__(n.$el,e,t,!1,n.$options._parentElm,n.$options._refElm),go=o,r&&(r.__vue__=null),n.$el&&(n.$el.__vue__=n),n.$vnode&&n.$parent&&n.$vnode===n.$parent._vnode&&(n.$parent.$el=n.$el)},e.prototype.$forceUpdate=function(){var e=this;e._watcher&&e._watcher.update()},e.prototype.$destroy=function(){var e=this;if(!e._isBeingDestroyed){ve(e,"beforeDestroy"),e._isBeingDestroyed=!0;var t=e.$parent;!t||t._isBeingDestroyed||e.$options.abstract||r(t.$children,e),e._watcher&&e._watcher.teardown();for(var n=e._watchers.length;n--;)e._watchers[n].teardown();e._data.__ob__&&e._data.__ob__.vmCount--,e._isDestroyed=!0,ve(e,"destroyed"),e.$off(),e.$el&&(e.$el.__vue__=null),e.__patch__(e._vnode,null)}}}function ue(e,t,n){e.$el=t,e.$options.render||(e.$options.render=ho),ve(e,"beforeMount");var r;return r=function(){e._update(e._render(),n)},e._watcher=new Co(e,r,d),n=!1,null==e.$vnode&&(e._isMounted=!0,ve(e,"mounted")),e}function le(e,t,n,r,i){var o=!!(i||e.$options._renderChildren||r.data.scopedSlots||e.$scopedSlots!==Fi);if(e.$options._parentVnode=r,e.$vnode=r,e._vnode&&(e._vnode.parent=r),e.$options._renderChildren=i,t&&e.$options.props){so.shouldConvert=!1;for(var a=e._props,s=e.$options._propKeys||[],c=0;c<s.length;c++){var u=s[c];a[u]=R(u,e.$options.props,t,e)}so.shouldConvert=!0,e.$options.propsData=t}if(n){var l=e.$options._parentListeners;e.$options._parentListeners=n,ne(e,n,l)}o&&(e.$slots=ie(i,r.context),e.$forceUpdate())}function fe(e){for(;e&&(e=e.$parent);)if(e._inactive)return!0;return!1}function pe(e,t){if(t){if(e._directInactive=!1,fe(e))return}else if(e._directInactive)return;if(e._inactive||null==e._inactive){e._inactive=!1;for(var n=0;n<e.$children.length;n++)pe(e.$children[n]);ve(e,"activated")}}function de(e,t){if(!(t&&(e._directInactive=!0,fe(e))||e._inactive)){e._inactive=!0;for(var n=0;n<e.$children.length;n++)de(e.$children[n]);ve(e,"deactivated")}}function ve(e,t){var n=e.$options[t];if(n)for(var r=0,i=n.length;r<i;r++)try{n[r].call(e)}catch(n){B(n,e,t+" hook")}e._hasHookEvent&&e.$emit("hook:"+t)}function he(){yo.length=0,_o={},bo=$o=!1}function me(){$o=!0;var e,t,n;for(yo.sort(function(e,t){return e.id-t.id}),wo=0;wo<yo.length;wo++)e=yo[wo],t=e.id,_o[t]=null,e.run();for(wo=yo.length;wo--;)e=yo[wo],n=e.vm,n._watcher===e&&n._isMounted&&ve(n,"updated");Yi&&Ri.devtools&&Yi.emit("flush"),he()}function ge(e){var t=e.id;if(null==_o[t]){if(_o[t]=!0,$o){for(var n=yo.length-1;n>=0&&yo[n].id>e.id;)n--;yo.splice(Math.max(n,wo)+1,0,e)}else yo.push(e);bo||(bo=!0,Xi(me))}}function ye(e){ko.clear(),_e(e,ko)}function _e(e,t){var n,r,i=Array.isArray(e);if((i||l(e))&&Object.isExtensible(e)){if(e.__ob__){var o=e.__ob__.dep.id;if(t.has(o))return;t.add(o)}if(i)for(n=e.length;n--;)_e(e[n],t);else for(r=Object.keys(e),n=r.length;n--;)_e(e[r[n]],t)}}function be(e,t,n){Ao.get=function(){return this[t][n]},Ao.set=function(e){this[t][n]=e},Object.defineProperty(e,n,Ao)}function $e(e){e._watchers=[];var t=e.$options;t.props&&we(e,t.props),t.methods&&Oe(e,t.methods),t.data?xe(e):A(e._data={},!0),t.computed&&Ce(e,t.computed),t.watch&&Se(e,t.watch)}function we(e,t){var n=e.$options.propsData||{},r=e._props={},i=e.$options._propKeys=[],o=!e.$parent;so.shouldConvert=o;var a=function(o){i.push(o);var a=R(o,t,n,e);O(r,o,a),o in e||be(e,"_props",o)};for(var s in t)a(s);so.shouldConvert=!0}function xe(e){var t=e.$options.data;t=e._data="function"==typeof t?t.call(e):t||{},f(t)||(t={});for(var n=Object.keys(t),r=e.$options.props,o=n.length;o--;)r&&i(r,n[o])||y(n[o])||be(e,"_data",n[o]);A(t,!0)}function Ce(e,t){var n=e._computedWatchers=Object.create(null);for(var r in t){var i=t[r],o="function"==typeof i?i:i.get;n[r]=new Co(e,o,d,Oo),r in e||ke(e,r,i)}}function ke(e,t,n){"function"==typeof n?(Ao.get=Ae(t),Ao.set=d):(Ao.get=n.get?n.cache!==!1?Ae(t):n.get:d,Ao.set=n.set?n.set:d),Object.defineProperty(e,t,Ao)}function Ae(e){return function(){var t=this._computedWatchers&&this._computedWatchers[e];if(t)return t.dirty&&t.evaluate(),no.target&&t.depend(),t.value}}function Oe(e,t){e.$options.props;for(var n in t)e[n]=null==t[n]?d:s(t[n],e)}function Se(e,t){for(var n in t){var r=t[n];if(Array.isArray(r))for(var i=0;i<r.length;i++)Te(e,n,r[i]);else Te(e,n,r)}}function Te(e,t,n){var r;f(n)&&(r=n,n=n.handler),"string"==typeof n&&(n=e[n]),e.$watch(t,n,r)}function Ee(e){var t={};t.get=function(){return this._data};var n={};n.get=function(){return this._props},Object.defineProperty(e.prototype,"$data",t),Object.defineProperty(e.prototype,"$props",n),e.prototype.$set=S,e.prototype.$delete=T,e.prototype.$watch=function(e,t,n){var r=this;n=n||{},n.user=!0;var i=new Co(r,e,t,n);return n.immediate&&t.call(r,i.value),function(){i.teardown()}}}function je(e,t,n,r,i){if(e){var o=n.$options._base;if(l(e)&&(e=o.extend(e)),"function"==typeof e){if(!e.cid)if(e.resolved)e=e.resolved;else if(e=Le(e,o,function(){n.$forceUpdate()}),!e)return;it(e),t=t||{},t.model&&Fe(e.options,t);var a=De(t,e);if(e.options.functional)return Ne(e,a,t,n,r);var s=t.on;t.on=t.nativeOn,e.options.abstract&&(t={}),Pe(t);var c=e.options.name||i,u=new fo("vue-component-"+e.cid+(c?"-"+c:""),t,void 0,void 0,void 0,n,{Ctor:e,propsData:a,listeners:s,tag:i,children:r});return u}}}function Ne(e,t,n,r,i){var o={},a=e.options.props;if(a)for(var s in a)o[s]=R(s,a,t);var c=Object.create(r),u=function(e,t,n,r){return He(c,e,t,n,r,!0)},l=e.options.render.call(null,u,{props:o,data:n,parent:r,children:i,slots:function(){return ie(i,r)}});return l instanceof fo&&(l.functionalContext=r,n.slot&&((l.data||(l.data={})).slot=n.slot)),l}function Ie(e,t,n,r){var i=e.componentOptions,o={_isComponent:!0,parent:t,propsData:i.propsData,_componentTag:i.tag,_parentVnode:e,_parentListeners:i.listeners,_renderChildren:i.children,_parentElm:n||null,_refElm:r||null},a=e.data.inlineTemplate;return a&&(o.render=a.render,o.staticRenderFns=a.staticRenderFns),new i.Ctor(o)}function Le(e,t,n){if(!e.requested){e.requested=!0;var r=e.pendingCallbacks=[n],i=!0,o=function(n){if(l(n)&&(n=t.extend(n)),e.resolved=n,!i)for(var o=0,a=r.length;o<a;o++)r[o](n)},a=function(e){},s=e(o,a);return s&&"function"==typeof s.then&&!e.resolved&&s.then(o,a),i=!1,e.resolved}e.pendingCallbacks.push(n)}function De(e,t){var n=t.options.props;if(n){var r={},i=e.attrs,o=e.props,a=e.domProps;if(i||o||a)for(var s in n){var c=Ii(s);Me(r,o,s,c,!0)||Me(r,i,s,c)||Me(r,a,s,c)}return r}}function Me(e,t,n,r,o){if(t){if(i(t,n))return e[n]=t[n],o||delete t[n],!0;if(i(t,r))return e[n]=t[r],o||delete t[r],!0}return!1}function Pe(e){e.hook||(e.hook={});for(var t=0;t<To.length;t++){var n=To[t],r=e.hook[n],i=So[n];e.hook[n]=r?Re(i,r):i}}function Re(e,t){return function(n,r,i,o){e(n,r,i,o),t(n,r,i,o)}}function Fe(e,t){var n=e.model&&e.model.prop||"value",r=e.model&&e.model.event||"input";(t.props||(t.props={}))[n]=t.model.value;var i=t.on||(t.on={});i[r]?i[r]=[t.model.callback].concat(i[r]):i[r]=t.model.callback}function He(e,t,n,r,i,a){return(Array.isArray(n)||o(n))&&(i=r,r=n,n=void 0),a&&(i=jo),Ue(e,t,n,r,i)}function Ue(e,t,n,r,i){if(n&&n.__ob__)return ho();if(!t)return ho();Array.isArray(r)&&"function"==typeof r[0]&&(n=n||{},n.scopedSlots={default:r[0]},r.length=0),i===jo?r=G(r):i===Eo&&(r=Z(r));var o,a;if("string"==typeof t){var s;a=Ri.getTagNamespace(t),o=Ri.isReservedTag(t)?new fo(Ri.parsePlatformTagName(t),n,r,void 0,void 0,e):(s=P(e.$options,"components",t))?je(s,n,e,r,t):new fo(t,n,r,void 0,void 0,e)}else o=je(t,n,e,r);return o?(a&&Be(o,a),o):ho()}function Be(e,t){if(e.ns=t,"foreignObject"!==e.tag&&e.children)for(var n=0,r=e.children.length;n<r;n++){var i=e.children[n];i.tag&&!i.ns&&Be(i,t)}}function Ve(e,t){var n,r,i,o,a;if(Array.isArray(e)||"string"==typeof e)for(n=new Array(e.length),r=0,i=e.length;r<i;r++)n[r]=t(e[r],r);else if("number"==typeof e)for(n=new Array(e),r=0;r<e;r++)n[r]=t(r+1,r);else if(l(e))for(o=Object.keys(e),n=new Array(o.length),r=0,i=o.length;r<i;r++)a=o[r],n[r]=t(e[a],a,r);return n}function ze(e,t,n,r){var i=this.$scopedSlots[e];if(i)return n=n||{},r&&u(n,r),i(n)||t;var o=this.$slots[e];return o||t}function Je(e){return P(this.$options,"filters",e,!0)||Pi}function Ke(e,t,n){var r=Ri.keyCodes[t]||n;return Array.isArray(r)?r.indexOf(e)===-1:r!==e}function qe(e,t,n,r){if(n)if(l(n)){Array.isArray(n)&&(n=p(n));var i;for(var o in n){if("class"===o||"style"===o)i=e;else{var a=e.attrs&&e.attrs.type;i=r||Ri.mustUseProp(t,a,o)?e.domProps||(e.domProps={}):e.attrs||(e.attrs={})}o in i||(i[o]=n[o])}}else;return e}function We(e,t){var n=this._staticTrees[e];return n&&!t?Array.isArray(n)?J(n):z(n):(n=this._staticTrees[e]=this.$options.staticRenderFns[e].call(this._renderProxy),Ge(n,"__static__"+e,!1),n)}function Ze(e,t,n){return Ge(e,"__once__"+t+(n?"_"+n:""),!0),e}function Ge(e,t,n){if(Array.isArray(e))for(var r=0;r<e.length;r++)e[r]&&"string"!=typeof e[r]&&Ye(e[r],t+"_"+r,n);else Ye(e,t,n)}function Ye(e,t,n){e.isStatic=!0,e.key=t,e.isOnce=n}function Qe(e){e.$vnode=null,e._vnode=null,e._staticTrees=null;var t=e.$options._parentVnode,n=t&&t.context;e.$slots=ie(e.$options._renderChildren,n),e.$scopedSlots=Fi,e._c=function(t,n,r,i){return He(e,t,n,r,i,!1)},e.$createElement=function(t,n,r,i){return He(e,t,n,r,i,!0)}}function Xe(n){n.prototype.$nextTick=function(e){return Xi(e,this)},n.prototype._render=function(){var e=this,t=e.$options,n=t.render,r=t.staticRenderFns,i=t._parentVnode;if(e._isMounted)for(var o in e.$slots)e.$slots[o]=J(e.$slots[o]);e.$scopedSlots=i&&i.data.scopedSlots||Fi,r&&!e._staticTrees&&(e._staticTrees=[]),e.$vnode=i;var a;try{a=n.call(e._renderProxy,e.$createElement)}catch(t){B(t,e,"render function"),a=e._vnode}return a instanceof fo||(a=ho()),a.parent=i,a},n.prototype._o=Ze,n.prototype._n=t,n.prototype._s=e,n.prototype._l=Ve,n.prototype._t=ze,n.prototype._q=h,n.prototype._i=m,n.prototype._m=We,n.prototype._f=Je,n.prototype._k=Ke,n.prototype._b=qe,n.prototype._v=V,n.prototype._e=ho,n.prototype._u=ae}function et(e){var t=e.$options.provide;t&&(e._provided="function"==typeof t?t.call(e):t)}function tt(e){var t=e.$options.inject;if(t)for(var n=Array.isArray(t),r=n?t:Qi?Reflect.ownKeys(t):Object.keys(t),i=0;i<r.length;i++)for(var o=r[i],a=n?o:t[o],s=e;s;){if(s._provided&&a in s._provided){e[o]=s._provided[a];break}s=s.$parent}}function nt(e){e.prototype._init=function(e){var t=this;t._uid=No++,t._isVue=!0,e&&e._isComponent?rt(t,e):t.$options=M(it(t.constructor),e||{},t),t._renderProxy=t,t._self=t,se(t),X(t),Qe(t),ve(t,"beforeCreate"),tt(t),$e(t),et(t),ve(t,"created"),t.$options.el&&t.$mount(t.$options.el)}}function rt(e,t){var n=e.$options=Object.create(e.constructor.options);n.parent=t.parent,n.propsData=t.propsData,n._parentVnode=t._parentVnode,n._parentListeners=t._parentListeners,n._renderChildren=t._renderChildren,n._componentTag=t._componentTag,n._parentElm=t._parentElm,n._refElm=t._refElm,t.render&&(n.render=t.render,n.staticRenderFns=t.staticRenderFns)}function it(e){var t=e.options;if(e.super){var n=it(e.super),r=e.superOptions;if(n!==r){e.superOptions=n;var i=ot(e);i&&u(e.extendOptions,i),t=e.options=M(n,e.extendOptions),t.name&&(t.components[t.name]=e)}}return t}function ot(e){var t,n=e.options,r=e.sealedOptions;for(var i in n)n[i]!==r[i]&&(t||(t={}),t[i]=at(n[i],r[i]));return t}function at(e,t){if(Array.isArray(e)){var n=[];t=Array.isArray(t)?t:[t];for(var r=0;r<e.length;r++)t.indexOf(e[r])<0&&n.push(e[r]);return n}return e}function st(e){this._init(e)}function ct(e){e.use=function(e){if(!e.installed){var t=c(arguments,1);return t.unshift(this),"function"==typeof e.install?e.install.apply(e,t):"function"==typeof e&&e.apply(null,t),e.installed=!0,this}}}function ut(e){e.mixin=function(e){this.options=M(this.options,e)}}function lt(e){e.cid=0;var t=1;e.extend=function(e){e=e||{};var n=this,r=n.cid,i=e._Ctor||(e._Ctor={});if(i[r])return i[r];var o=e.name||n.options.name,a=function(e){this._init(e)};return a.prototype=Object.create(n.prototype),a.prototype.constructor=a,a.cid=t++,a.options=M(n.options,e),a.super=n,a.options.props&&ft(a),a.options.computed&&pt(a),a.extend=n.extend,a.mixin=n.mixin,a.use=n.use,Ri._assetTypes.forEach(function(e){a[e]=n[e]}),o&&(a.options.components[o]=a),a.superOptions=n.options,a.extendOptions=e,a.sealedOptions=u({},a.options),i[r]=a,a}}function ft(e){var t=e.options.props;for(var n in t)be(e.prototype,"_props",n)}function pt(e){var t=e.options.computed;for(var n in t)ke(e.prototype,n,t[n])}function dt(e){Ri._assetTypes.forEach(function(t){e[t]=function(e,n){return n?("component"===t&&f(n)&&(n.name=n.name||e,n=this.options._base.extend(n)),"directive"===t&&"function"==typeof n&&(n={bind:n,update:n}),this.options[t+"s"][e]=n,n):this.options[t+"s"][e]}})}function vt(e){return e&&(e.Ctor.options.name||e.tag)}function ht(e,t){return"string"==typeof e?e.split(",").indexOf(t)>-1:e instanceof RegExp&&e.test(t)}function mt(e,t){for(var n in e){var r=e[n];if(r){var i=vt(r.componentOptions);i&&!t(i)&&(gt(r),e[n]=null)}}}function gt(e){e&&(e.componentInstance._inactive||ve(e.componentInstance,"deactivated"),e.componentInstance.$destroy())}function yt(e){var t={};t.get=function(){return Ri},Object.defineProperty(e,"config",t),e.util={warn:eo,extend:u,mergeOptions:M,defineReactive:O},e.set=S,e.delete=T,e.nextTick=Xi,e.options=Object.create(null),Ri._assetTypes.forEach(function(t){e.options[t+"s"]=Object.create(null)}),e.options._base=e,u(e.options.components,Do),ct(e),ut(e),lt(e),dt(e)}function _t(e){for(var t=e.data,n=e,r=e;r.componentInstance;)r=r.componentInstance._vnode,r.data&&(t=bt(r.data,t));for(;n=n.parent;)n.data&&(t=bt(t,n.data));return $t(t)}function bt(e,t){return{staticClass:wt(e.staticClass,t.staticClass),class:e.class?[e.class,t.class]:t.class}}function $t(e){var t=e.class,n=e.staticClass;return n||t?wt(n,xt(t)):""}function wt(e,t){return e?t?e+" "+t:e:t||""}function xt(e){var t="";if(!e)return t;if("string"==typeof e)return e;if(Array.isArray(e)){for(var n,r=0,i=e.length;r<i;r++)e[r]&&(n=xt(e[r]))&&(t+=n+" ");return t.slice(0,-1)}if(l(e)){for(var o in e)e[o]&&(t+=o+" ");return t.slice(0,-1)}return t}function Ct(e){return ta(e)?"svg":"math"===e?"math":void 0}function kt(e){if(!Bi)return!0;if(ra(e))return!1;if(e=e.toLowerCase(),null!=ia[e])return ia[e];var t=document.createElement(e);return e.indexOf("-")>-1?ia[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:ia[e]=/HTMLUnknownElement/.test(t.toString())}function At(e){if("string"==typeof e){var t=document.querySelector(e);return t?t:document.createElement("div")}return e}function Ot(e,t){var n=document.createElement(e);return"select"!==e?n:(t.data&&t.data.attrs&&void 0!==t.data.attrs.multiple&&n.setAttribute("multiple","multiple"),n)}function St(e,t){return document.createElementNS(Xo[e],t)}function Tt(e){return document.createTextNode(e)}function Et(e){return document.createComment(e)}function jt(e,t,n){e.insertBefore(t,n)}function Nt(e,t){e.removeChild(t)}function It(e,t){e.appendChild(t)}function Lt(e){return e.parentNode}function Dt(e){return e.nextSibling}function Mt(e){return e.tagName}function Pt(e,t){e.textContent=t}function Rt(e,t,n){e.setAttribute(t,n)}function Ft(e,t){var n=e.data.ref;if(n){var i=e.context,o=e.componentInstance||e.elm,a=i.$refs;t?Array.isArray(a[n])?r(a[n],o):a[n]===o&&(a[n]=void 0):e.data.refInFor?Array.isArray(a[n])&&a[n].indexOf(o)<0?a[n].push(o):a[n]=[o]:a[n]=o}}function Ht(e){return null==e}function Ut(e){return null!=e}function Bt(e,t){return e.key===t.key&&e.tag===t.tag&&e.isComment===t.isComment&&!e.data==!t.data}function Vt(e,t,n){var r,i,o={};for(r=t;r<=n;++r)i=e[r].key,Ut(i)&&(o[i]=r);return o}function zt(e){function t(e){return new fo(O.tagName(e).toLowerCase(),{},[],void 0,e)}function r(e,t){function n(){0===--n.listeners&&i(e)}return n.listeners=t,n}function i(e){var t=O.parentNode(e);t&&O.removeChild(t,e)}function a(e,t,n,r,i){if(e.isRootInsert=!i,!s(e,t,n,r)){var o=e.data,a=e.children,c=e.tag;Ut(c)?(e.elm=e.ns?O.createElementNS(e.ns,c):O.createElement(c,e),v(e),f(e,a,t),Ut(o)&&d(e,t),l(n,e.elm,r)):e.isComment?(e.elm=O.createComment(e.text),l(n,e.elm,r)):(e.elm=O.createTextNode(e.text),l(n,e.elm,r))}}function s(e,t,n,r){var i=e.data;if(Ut(i)){var o=Ut(e.componentInstance)&&i.keepAlive;if(Ut(i=i.hook)&&Ut(i=i.init)&&i(e,!1,n,r),Ut(e.componentInstance))return c(e,t),o&&u(e,t,n,r),!0}}function c(e,t){e.data.pendingInsert&&t.push.apply(t,e.data.pendingInsert),e.elm=e.componentInstance.$el,p(e)?(d(e,t),v(e)):(Ft(e),t.push(e))}function u(e,t,n,r){for(var i,o=e;o.componentInstance;)if(o=o.componentInstance._vnode,Ut(i=o.data)&&Ut(i=i.transition)){for(i=0;i<k.activate.length;++i)k.activate[i](sa,o);t.push(o);break}l(n,e.elm,r)}function l(e,t,n){e&&(n?O.insertBefore(e,t,n):O.appendChild(e,t))}function f(e,t,n){if(Array.isArray(t))for(var r=0;r<t.length;++r)a(t[r],n,e.elm,null,!0);else o(e.text)&&O.appendChild(e.elm,O.createTextNode(e.text))}function p(e){for(;e.componentInstance;)e=e.componentInstance._vnode;return Ut(e.tag)}function d(e,t){for(var n=0;n<k.create.length;++n)k.create[n](sa,e);x=e.data.hook,Ut(x)&&(x.create&&x.create(sa,e),x.insert&&t.push(e))}function v(e){for(var t,n=e;n;)Ut(t=n.context)&&Ut(t=t.$options._scopeId)&&O.setAttribute(e.elm,t,""),n=n.parent;Ut(t=go)&&t!==e.context&&Ut(t=t.$options._scopeId)&&O.setAttribute(e.elm,t,"")}function h(e,t,n,r,i,o){for(;r<=i;++r)a(n[r],o,e,t)}function m(e){var t,n,r=e.data;if(Ut(r))for(Ut(t=r.hook)&&Ut(t=t.destroy)&&t(e),t=0;t<k.destroy.length;++t)k.destroy[t](e);if(Ut(t=e.children))for(n=0;n<e.children.length;++n)m(e.children[n])}function g(e,t,n,r){for(;n<=r;++n){var o=t[n];Ut(o)&&(Ut(o.tag)?(y(o),m(o)):i(o.elm))}}function y(e,t){if(t||Ut(e.data)){var n=k.remove.length+1;for(t?t.listeners+=n:t=r(e.elm,n),Ut(x=e.componentInstance)&&Ut(x=x._vnode)&&Ut(x.data)&&y(x,t),x=0;x<k.remove.length;++x)k.remove[x](e,t);Ut(x=e.data.hook)&&Ut(x=x.remove)?x(e,t):t()}else i(e.elm)}function _(e,t,n,r,i){for(var o,s,c,u,l=0,f=0,p=t.length-1,d=t[0],v=t[p],m=n.length-1,y=n[0],_=n[m],$=!i;l<=p&&f<=m;)Ht(d)?d=t[++l]:Ht(v)?v=t[--p]:Bt(d,y)?(b(d,y,r),d=t[++l],y=n[++f]):Bt(v,_)?(b(v,_,r),v=t[--p],_=n[--m]):Bt(d,_)?(b(d,_,r),$&&O.insertBefore(e,d.elm,O.nextSibling(v.elm)),d=t[++l],_=n[--m]):Bt(v,y)?(b(v,y,r),$&&O.insertBefore(e,v.elm,d.elm),v=t[--p],y=n[++f]):(Ht(o)&&(o=Vt(t,l,p)),s=Ut(y.key)?o[y.key]:null,Ht(s)?(a(y,r,e,d.elm),y=n[++f]):(c=t[s],Bt(c,y)?(b(c,y,r),t[s]=void 0,$&&O.insertBefore(e,y.elm,d.elm),y=n[++f]):(a(y,r,e,d.elm),y=n[++f])));l>p?(u=Ht(n[m+1])?null:n[m+1].elm,h(e,u,n,f,m,r)):f>m&&g(e,t,l,p)}function b(e,t,n,r){if(e!==t){if(t.isStatic&&e.isStatic&&t.key===e.key&&(t.isCloned||t.isOnce))return t.elm=e.elm,void(t.componentInstance=e.componentInstance);var i,o=t.data,a=Ut(o);a&&Ut(i=o.hook)&&Ut(i=i.prepatch)&&i(e,t);var s=t.elm=e.elm,c=e.children,u=t.children;if(a&&p(t)){for(i=0;i<k.update.length;++i)k.update[i](e,t);Ut(i=o.hook)&&Ut(i=i.update)&&i(e,t)}Ht(t.text)?Ut(c)&&Ut(u)?c!==u&&_(s,c,u,n,r):Ut(u)?(Ut(e.text)&&O.setTextContent(s,""),h(s,null,u,0,u.length-1,n)):Ut(c)?g(s,c,0,c.length-1):Ut(e.text)&&O.setTextContent(s,""):e.text!==t.text&&O.setTextContent(s,t.text),a&&Ut(i=o.hook)&&Ut(i=i.postpatch)&&i(e,t)}}function $(e,t,n){if(n&&e.parent)e.parent.data.pendingInsert=t;else for(var r=0;r<t.length;++r)t[r].data.hook.insert(t[r])}function w(e,t,n){t.elm=e;var r=t.tag,i=t.data,o=t.children;if(Ut(i)&&(Ut(x=i.hook)&&Ut(x=x.init)&&x(t,!0),Ut(x=t.componentInstance)))return c(t,n),!0;if(Ut(r)){if(Ut(o))if(e.hasChildNodes()){for(var a=!0,s=e.firstChild,u=0;u<o.length;u++){if(!s||!w(s,o[u],n)){a=!1;break}s=s.nextSibling}if(!a||s)return!1}else f(t,o,n);if(Ut(i))for(var l in i)if(!S(l)){d(t,n);break}}else e.data!==t.text&&(e.data=t.text);return!0}var x,C,k={},A=e.modules,O=e.nodeOps;for(x=0;x<ca.length;++x)for(k[ca[x]]=[],C=0;C<A.length;++C)void 0!==A[C][ca[x]]&&k[ca[x]].push(A[C][ca[x]]);var S=n("attrs,style,class,staticClass,staticStyle,key");return function(e,n,r,i,o,s){if(!n)return void(e&&m(e));var c=!1,u=[];if(e){var l=Ut(e.nodeType);if(!l&&Bt(e,n))b(e,n,u,i);else{if(l){if(1===e.nodeType&&e.hasAttribute("server-rendered")&&(e.removeAttribute("server-rendered"),r=!0),r&&w(e,n,u))return $(n,u,!0),e;e=t(e)}var f=e.elm,d=O.parentNode(f);if(a(n,u,f._leaveCb?null:d,O.nextSibling(f)),n.parent){for(var v=n.parent;v;)v.elm=n.elm,v=v.parent;if(p(n))for(var h=0;h<k.create.length;++h)k.create[h](sa,n.parent)}null!==d?g(d,[e],0,0):Ut(e.tag)&&m(e)}}else c=!0,a(n,u,o,s);return $(n,u,c),n.elm}}function Jt(e,t){(e.data.directives||t.data.directives)&&Kt(e,t)}function Kt(e,t){var n,r,i,o=e===sa,a=t===sa,s=qt(e.data.directives,e.context),c=qt(t.data.directives,t.context),u=[],l=[];for(n in c)r=s[n],i=c[n],r?(i.oldValue=r.value,Zt(i,"update",t,e),i.def&&i.def.componentUpdated&&l.push(i)):(Zt(i,"bind",t,e),i.def&&i.def.inserted&&u.push(i));if(u.length){var f=function(){for(var n=0;n<u.length;n++)Zt(u[n],"inserted",t,e)};o?W(t.data.hook||(t.data.hook={}),"insert",f):f()}if(l.length&&W(t.data.hook||(t.data.hook={}),"postpatch",function(){for(var n=0;n<l.length;n++)Zt(l[n],"componentUpdated",t,e)}),!o)for(n in s)c[n]||Zt(s[n],"unbind",e,e,a)}function qt(e,t){var n=Object.create(null);if(!e)return n;var r,i;for(r=0;r<e.length;r++)i=e[r],i.modifiers||(i.modifiers=la),n[Wt(i)]=i,i.def=P(t.$options,"directives",i.name,!0);return n}function Wt(e){return e.rawName||e.name+"."+Object.keys(e.modifiers||{}).join(".")}function Zt(e,t,n,r,i){var o=e.def&&e.def[t];o&&o(n.elm,e,n,r,i)}function Gt(e,t){if(e.data.attrs||t.data.attrs){var n,r,i,o=t.elm,a=e.data.attrs||{},s=t.data.attrs||{};s.__ob__&&(s=t.data.attrs=u({},s));for(n in s)r=s[n],i=a[n],i!==r&&Yt(o,n,r);Ji&&s.value!==a.value&&Yt(o,"value",s.value);for(n in a)null==s[n]&&(Go(n)?o.removeAttributeNS(Zo,Yo(n)):qo(n)||o.removeAttribute(n))}}function Yt(e,t,n){Wo(t)?Qo(n)?e.removeAttribute(t):e.setAttribute(t,t):qo(t)?e.setAttribute(t,Qo(n)||"false"===n?"false":"true"):Go(t)?Qo(n)?e.removeAttributeNS(Zo,Yo(t)):e.setAttributeNS(Zo,t,n):Qo(n)?e.removeAttribute(t):e.setAttribute(t,n)}function Qt(e,t){var n=t.elm,r=t.data,i=e.data;if(r.staticClass||r.class||i&&(i.staticClass||i.class)){var o=_t(t),a=n._transitionClasses;a&&(o=wt(o,xt(a))),o!==n._prevClass&&(n.setAttribute("class",o),n._prevClass=o)}}function Xt(e){function t(){(a||(a=[])).push(e.slice(v,i).trim()),v=i+1}var n,r,i,o,a,s=!1,c=!1,u=!1,l=!1,f=0,p=0,d=0,v=0;for(i=0;i<e.length;i++)if(r=n,n=e.charCodeAt(i),s)39===n&&92!==r&&(s=!1);else if(c)34===n&&92!==r&&(c=!1);else if(u)96===n&&92!==r&&(u=!1);else if(l)47===n&&92!==r&&(l=!1);else if(124!==n||124===e.charCodeAt(i+1)||124===e.charCodeAt(i-1)||f||p||d){switch(n){case 34:c=!0;break;case 39:s=!0;break;case 96:u=!0;break;case 40:d++;break;case 41:d--;break;case 91:p++;break;case 93:p--;break;case 123:f++;break;case 125:f--}if(47===n){for(var h=i-1,m=void 0;h>=0&&(m=e.charAt(h)," "===m);h--);m&&va.test(m)||(l=!0)}}else void 0===o?(v=i+1,o=e.slice(0,i).trim()):t();if(void 0===o?o=e.slice(0,i).trim():0!==v&&t(),a)for(i=0;i<a.length;i++)o=en(o,a[i]);return o}function en(e,t){var n=t.indexOf("(");if(n<0)return'_f("'+t+'")('+e+")";var r=t.slice(0,n),i=t.slice(n+1);return'_f("'+r+'")('+e+","+i}function tn(e){console.error("[Vue compiler]: "+e)}function nn(e,t){return e?e.map(function(e){return e[t]}).filter(function(e){return e}):[]}function rn(e,t,n){(e.props||(e.props=[])).push({name:t,value:n})}function on(e,t,n){(e.attrs||(e.attrs=[])).push({name:t,value:n})}function an(e,t,n,r,i,o){(e.directives||(e.directives=[])).push({name:t,rawName:n,value:r,arg:i,modifiers:o})}function sn(e,t,n,r,i){r&&r.capture&&(delete r.capture,t="!"+t),r&&r.once&&(delete r.once,t="~"+t);var o;r&&r.native?(delete r.native,
8 o=e.nativeEvents||(e.nativeEvents={})):o=e.events||(e.events={});var a={value:n,modifiers:r},s=o[t];Array.isArray(s)?i?s.unshift(a):s.push(a):s?o[t]=i?[a,s]:[s,a]:o[t]=a}function cn(e,t,n){var r=un(e,":"+t)||un(e,"v-bind:"+t);if(null!=r)return Xt(r);if(n!==!1){var i=un(e,t);if(null!=i)return JSON.stringify(i)}}function un(e,t){var n;if(null!=(n=e.attrsMap[t]))for(var r=e.attrsList,i=0,o=r.length;i<o;i++)if(r[i].name===t){r.splice(i,1);break}return n}function ln(e,t,n){var r=n||{},i=r.number,o=r.trim,a="$$v",s=a;o&&(s="(typeof "+a+" === 'string'? "+a+".trim(): "+a+")"),i&&(s="_n("+s+")");var c=fn(t,s);e.model={value:"("+t+")",expression:'"'+t+'"',callback:"function ("+a+") {"+c+"}"}}function fn(e,t){var n=pn(e);return null===n.idx?e+"="+t:"var $$exp = "+n.exp+", $$idx = "+n.idx+";if (!Array.isArray($$exp)){"+e+"="+t+"}else{$$exp.splice($$idx, 1, "+t+")}"}function pn(e){if(Po=e,Mo=Po.length,Fo=Ho=Uo=0,e.indexOf("[")<0||e.lastIndexOf("]")<Mo-1)return{exp:e,idx:null};for(;!vn();)Ro=dn(),hn(Ro)?gn(Ro):91===Ro&&mn(Ro);return{exp:e.substring(0,Ho),idx:e.substring(Ho+1,Uo)}}function dn(){return Po.charCodeAt(++Fo)}function vn(){return Fo>=Mo}function hn(e){return 34===e||39===e}function mn(e){var t=1;for(Ho=Fo;!vn();)if(e=dn(),hn(e))gn(e);else if(91===e&&t++,93===e&&t--,0===t){Uo=Fo;break}}function gn(e){for(var t=e;!vn()&&(e=dn(),e!==t););}function yn(e,t,n){Bo=n;var r=t.value,i=t.modifiers,o=e.tag,a=e.attrsMap.type;if("select"===o)$n(e,r,i);else if("input"===o&&"checkbox"===a)_n(e,r,i);else if("input"===o&&"radio"===a)bn(e,r,i);else if("input"===o||"textarea"===o)wn(e,r,i);else if(!Ri.isReservedTag(o))return ln(e,r,i),!1;return!0}function _n(e,t,n){var r=n&&n.number,i=cn(e,"value")||"null",o=cn(e,"true-value")||"true",a=cn(e,"false-value")||"false";rn(e,"checked","Array.isArray("+t+")?_i("+t+","+i+")>-1"+("true"===o?":("+t+")":":_q("+t+","+o+")")),sn(e,ma,"var $$a="+t+",$$el=$event.target,$$c=$$el.checked?("+o+"):("+a+");if(Array.isArray($$a)){var $$v="+(r?"_n("+i+")":i)+",$$i=_i($$a,$$v);if($$c){$$i<0&&("+t+"=$$a.concat($$v))}else{$$i>-1&&("+t+"=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}}else{"+t+"=$$c}",null,!0)}function bn(e,t,n){var r=n&&n.number,i=cn(e,"value")||"null";i=r?"_n("+i+")":i,rn(e,"checked","_q("+t+","+i+")"),sn(e,ma,fn(t,i),null,!0)}function $n(e,t,n){var r=n&&n.number,i='Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return '+(r?"_n(val)":"val")+"})",o="$event.target.multiple ? $$selectedVal : $$selectedVal[0]",a="var $$selectedVal = "+i+";";a=a+" "+fn(t,o),sn(e,"change",a,null,!0)}function wn(e,t,n){var r=e.attrsMap.type,i=n||{},o=i.lazy,a=i.number,s=i.trim,c=!o&&"range"!==r,u=o?"change":"range"===r?ha:"input",l="$event.target.value";s&&(l="$event.target.value.trim()"),a&&(l="_n("+l+")");var f=fn(t,l);c&&(f="if($event.target.composing)return;"+f),rn(e,"value","("+t+")"),sn(e,u,f,null,!0),(s||a||"number"===r)&&sn(e,"blur","$forceUpdate()")}function xn(e){var t;e[ha]&&(t=zi?"change":"input",e[t]=[].concat(e[ha],e[t]||[]),delete e[ha]),e[ma]&&(t=Zi?"click":"change",e[t]=[].concat(e[ma],e[t]||[]),delete e[ma])}function Cn(e,t,n,r){if(n){var i=t,o=Vo;t=function(n){var a=1===arguments.length?i(n):i.apply(null,arguments);null!==a&&kn(e,t,r,o)}}Vo.addEventListener(e,t,r)}function kn(e,t,n,r){(r||Vo).removeEventListener(e,t,n)}function An(e,t){if(e.data.on||t.data.on){var n=t.data.on||{},r=e.data.on||{};Vo=t.elm,xn(n),q(n,r,Cn,kn,t.context)}}function On(e,t){if(e.data.domProps||t.data.domProps){var n,r,i=t.elm,o=e.data.domProps||{},a=t.data.domProps||{};a.__ob__&&(a=t.data.domProps=u({},a));for(n in o)null==a[n]&&(i[n]="");for(n in a)if(r=a[n],"textContent"!==n&&"innerHTML"!==n||(t.children&&(t.children.length=0),r!==o[n]))if("value"===n){i._value=r;var s=null==r?"":String(r);Sn(i,t,s)&&(i.value=s)}else i[n]=r}}function Sn(e,t,n){return!e.composing&&("option"===t.tag||Tn(e,n)||En(e,n))}function Tn(e,t){return document.activeElement!==e&&e.value!==t}function En(e,n){var r=e.value,i=e._vModifiers;return i&&i.number||"number"===e.type?t(r)!==t(n):i&&i.trim?r.trim()!==n.trim():r!==n}function jn(e){var t=Nn(e.style);return e.staticStyle?u(e.staticStyle,t):t}function Nn(e){return Array.isArray(e)?p(e):"string"==typeof e?_a(e):e}function In(e,t){var n,r={};if(t)for(var i=e;i.componentInstance;)i=i.componentInstance._vnode,i.data&&(n=jn(i.data))&&u(r,n);(n=jn(e.data))&&u(r,n);for(var o=e;o=o.parent;)o.data&&(n=jn(o.data))&&u(r,n);return r}function Ln(e,t){var n=t.data,r=e.data;if(n.staticStyle||n.style||r.staticStyle||r.style){var i,o,a=t.elm,s=e.data.staticStyle,c=e.data.style||{},l=s||c,f=Nn(t.data.style)||{};t.data.style=f.__ob__?u({},f):f;var p=In(t,!0);for(o in l)null==p[o]&&wa(a,o,"");for(o in p)i=p[o],i!==l[o]&&wa(a,o,null==i?"":i)}}function Dn(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(/\s+/).forEach(function(t){return e.classList.add(t)}):e.classList.add(t);else{var n=" "+(e.getAttribute("class")||"")+" ";n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function Mn(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(/\s+/).forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t);else{for(var n=" "+(e.getAttribute("class")||"")+" ",r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");e.setAttribute("class",n.trim())}}function Pn(e){if(e){if("object"==typeof e){var t={};return e.css!==!1&&u(t,Aa(e.name||"v")),u(t,e),t}return"string"==typeof e?Aa(e):void 0}}function Rn(e){La(function(){La(e)})}function Fn(e,t){(e._transitionClasses||(e._transitionClasses=[])).push(t),Dn(e,t)}function Hn(e,t){e._transitionClasses&&r(e._transitionClasses,t),Mn(e,t)}function Un(e,t,n){var r=Bn(e,t),i=r.type,o=r.timeout,a=r.propCount;if(!i)return n();var s=i===Sa?ja:Ia,c=0,u=function(){e.removeEventListener(s,l),n()},l=function(t){t.target===e&&++c>=a&&u()};setTimeout(function(){c<a&&u()},o+1),e.addEventListener(s,l)}function Bn(e,t){var n,r=window.getComputedStyle(e),i=r[Ea+"Delay"].split(", "),o=r[Ea+"Duration"].split(", "),a=Vn(i,o),s=r[Na+"Delay"].split(", "),c=r[Na+"Duration"].split(", "),u=Vn(s,c),l=0,f=0;t===Sa?a>0&&(n=Sa,l=a,f=o.length):t===Ta?u>0&&(n=Ta,l=u,f=c.length):(l=Math.max(a,u),n=l>0?a>u?Sa:Ta:null,f=n?n===Sa?o.length:c.length:0);var p=n===Sa&&Da.test(r[Ea+"Property"]);return{type:n,timeout:l,propCount:f,hasTransform:p}}function Vn(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max.apply(null,t.map(function(t,n){return zn(t)+zn(e[n])}))}function zn(e){return 1e3*Number(e.slice(0,-1))}function Jn(e,n){var r=e.elm;r._leaveCb&&(r._leaveCb.cancelled=!0,r._leaveCb());var i=Pn(e.data.transition);if(i&&!r._enterCb&&1===r.nodeType){for(var o=i.css,a=i.type,s=i.enterClass,c=i.enterToClass,u=i.enterActiveClass,f=i.appearClass,p=i.appearToClass,d=i.appearActiveClass,v=i.beforeEnter,h=i.enter,m=i.afterEnter,y=i.enterCancelled,_=i.beforeAppear,b=i.appear,$=i.afterAppear,w=i.appearCancelled,x=i.duration,C=go,k=go.$vnode;k&&k.parent;)k=k.parent,C=k.context;var A=!C._isMounted||!e.isRootInsert;if(!A||b||""===b){var O=A&&f?f:s,S=A&&d?d:u,T=A&&p?p:c,E=A?_||v:v,j=A&&"function"==typeof b?b:h,N=A?$||m:m,I=A?w||y:y,L=t(l(x)?x.enter:x),D=o!==!1&&!Ji,M=Wn(j),P=r._enterCb=g(function(){D&&(Hn(r,T),Hn(r,S)),P.cancelled?(D&&Hn(r,O),I&&I(r)):N&&N(r),r._enterCb=null});e.data.show||W(e.data.hook||(e.data.hook={}),"insert",function(){var t=r.parentNode,n=t&&t._pending&&t._pending[e.key];n&&n.tag===e.tag&&n.elm._leaveCb&&n.elm._leaveCb(),j&&j(r,P)}),E&&E(r),D&&(Fn(r,O),Fn(r,S),Rn(function(){Fn(r,T),Hn(r,O),P.cancelled||M||(qn(L)?setTimeout(P,L):Un(r,a,P))})),e.data.show&&(n&&n(),j&&j(r,P)),D||M||P()}}}function Kn(e,n){function r(){w.cancelled||(e.data.show||((i.parentNode._pending||(i.parentNode._pending={}))[e.key]=e),p&&p(i),_&&(Fn(i,c),Fn(i,f),Rn(function(){Fn(i,u),Hn(i,c),w.cancelled||b||(qn($)?setTimeout(w,$):Un(i,s,w))})),d&&d(i,w),_||b||w())}var i=e.elm;i._enterCb&&(i._enterCb.cancelled=!0,i._enterCb());var o=Pn(e.data.transition);if(!o)return n();if(!i._leaveCb&&1===i.nodeType){var a=o.css,s=o.type,c=o.leaveClass,u=o.leaveToClass,f=o.leaveActiveClass,p=o.beforeLeave,d=o.leave,v=o.afterLeave,h=o.leaveCancelled,m=o.delayLeave,y=o.duration,_=a!==!1&&!Ji,b=Wn(d),$=t(l(y)?y.leave:y),w=i._leaveCb=g(function(){i.parentNode&&i.parentNode._pending&&(i.parentNode._pending[e.key]=null),_&&(Hn(i,u),Hn(i,f)),w.cancelled?(_&&Hn(i,c),h&&h(i)):(n(),v&&v(i)),i._leaveCb=null});m?m(r):r()}}function qn(e){return"number"==typeof e&&!isNaN(e)}function Wn(e){if(!e)return!1;var t=e.fns;return t?Wn(Array.isArray(t)?t[0]:t):(e._length||e.length)>1}function Zn(e,t){t.data.show||Jn(t)}function Gn(e,t,n){var r=t.value,i=e.multiple;if(!i||Array.isArray(r)){for(var o,a,s=0,c=e.options.length;s<c;s++)if(a=e.options[s],i)o=m(r,Qn(a))>-1,a.selected!==o&&(a.selected=o);else if(h(Qn(a),r))return void(e.selectedIndex!==s&&(e.selectedIndex=s));i||(e.selectedIndex=-1)}}function Yn(e,t){for(var n=0,r=t.length;n<r;n++)if(h(Qn(t[n]),e))return!1;return!0}function Qn(e){return"_value"in e?e._value:e.value}function Xn(e){e.target.composing=!0}function er(e){e.target.composing=!1,tr(e.target,"input")}function tr(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}function nr(e){return!e.componentInstance||e.data&&e.data.transition?e:nr(e.componentInstance._vnode)}function rr(e){var t=e&&e.componentOptions;return t&&t.Ctor.options.abstract?rr(Q(t.children)):e}function ir(e){var t={},n=e.$options;for(var r in n.propsData)t[r]=e[r];var i=n._parentListeners;for(var o in i)t[Ei(o)]=i[o];return t}function or(e,t){return/\d-keep-alive$/.test(t.tag)?e("keep-alive"):null}function ar(e){for(;e=e.parent;)if(e.data.transition)return!0}function sr(e,t){return t.key===e.key&&t.tag===e.tag}function cr(e){e.elm._moveCb&&e.elm._moveCb(),e.elm._enterCb&&e.elm._enterCb()}function ur(e){e.data.newPos=e.elm.getBoundingClientRect()}function lr(e){var t=e.data.pos,n=e.data.newPos,r=t.left-n.left,i=t.top-n.top;if(r||i){e.data.moved=!0;var o=e.elm.style;o.transform=o.WebkitTransform="translate("+r+"px,"+i+"px)",o.transitionDuration="0s"}}function fr(e,t){var n=document.createElement("div");return n.innerHTML='<div a="'+e+'">',n.innerHTML.indexOf(t)>0}function pr(e){return Wa=Wa||document.createElement("div"),Wa.innerHTML=e,Wa.textContent}function dr(e,t){var n=t?Ls:Is;return e.replace(n,function(e){return Ns[e]})}function vr(e,t){function n(t){f+=t,e=e.substring(t)}function r(){var t=e.match(os);if(t){var r={tagName:t[1],attrs:[],start:f};n(t[0].length);for(var i,o;!(i=e.match(as))&&(o=e.match(ns));)n(o[0].length),r.attrs.push(o);if(i)return r.unarySlash=i[1],n(i[0].length),r.end=f,r}}function i(e){var n=e.tagName,r=e.unarySlash;u&&("p"===s&&Qa(n)&&o(s),Ya(n)&&s===n&&o(n));for(var i=l(n)||"html"===n&&"head"===s||!!r,a=e.attrs.length,f=new Array(a),p=0;p<a;p++){var d=e.attrs[p];fs&&d[0].indexOf('""')===-1&&(""===d[3]&&delete d[3],""===d[4]&&delete d[4],""===d[5]&&delete d[5]);var v=d[3]||d[4]||d[5]||"";f[p]={name:d[1],value:dr(v,t.shouldDecodeNewlines)}}i||(c.push({tag:n,lowerCasedTag:n.toLowerCase(),attrs:f}),s=n),t.start&&t.start(n,f,i,e.start,e.end)}function o(e,n,r){var i,o;if(null==n&&(n=f),null==r&&(r=f),e&&(o=e.toLowerCase()),e)for(i=c.length-1;i>=0&&c[i].lowerCasedTag!==o;i--);else i=0;if(i>=0){for(var a=c.length-1;a>=i;a--)t.end&&t.end(c[a].tag,n,r);c.length=i,s=i&&c[i-1].tag}else"br"===o?t.start&&t.start(e,[],!0,n,r):"p"===o&&(t.start&&t.start(e,[],!1,n,r),t.end&&t.end(e,n,r))}for(var a,s,c=[],u=t.expectHTML,l=t.isUnaryTag||Mi,f=0;e;){if(a=e,s&&Es(s)){var p=s.toLowerCase(),d=js[p]||(js[p]=new RegExp("([\\s\\S]*?)(</"+p+"[^>]*>)","i")),v=0,h=e.replace(d,function(e,n,r){return v=r.length,Es(p)||"noscript"===p||(n=n.replace(/<!--([\s\S]*?)-->/g,"$1").replace(/<!\[CDATA\[([\s\S]*?)]]>/g,"$1")),t.chars&&t.chars(n),""});f+=e.length-h.length,e=h,o(p,f-v,f)}else{var m=e.indexOf("<");if(0===m){if(us.test(e)){var g=e.indexOf("-->");if(g>=0){n(g+3);continue}}if(ls.test(e)){var y=e.indexOf("]>");if(y>=0){n(y+2);continue}}var _=e.match(cs);if(_){n(_[0].length);continue}var b=e.match(ss);if(b){var $=f;n(b[0].length),o(b[1],$,f);continue}var w=r();if(w){i(w);continue}}var x=void 0,C=void 0,k=void 0;if(m>=0){for(C=e.slice(m);!(ss.test(C)||os.test(C)||us.test(C)||ls.test(C)||(k=C.indexOf("<",1),k<0));)m+=k,C=e.slice(m);x=e.substring(0,m),n(m)}m<0&&(x=e,e=""),t.chars&&x&&t.chars(x)}if(e===a){t.chars&&t.chars(e);break}}o()}function hr(e,t){var n=t?Ps(t):Ds;if(n.test(e)){for(var r,i,o=[],a=n.lastIndex=0;r=n.exec(e);){i=r.index,i>a&&o.push(JSON.stringify(e.slice(a,i)));var s=Xt(r[1].trim());o.push("_s("+s+")"),a=i+r[0].length}return a<e.length&&o.push(JSON.stringify(e.slice(a))),o.join("+")}}function mr(e,t){function n(e){e.pre&&(s=!1),gs(e.tag)&&(c=!1)}ps=t.warn||tn,_s=t.getTagNamespace||Mi,ys=t.mustUseProp||Mi,gs=t.isPreTag||Mi,hs=nn(t.modules,"preTransformNode"),vs=nn(t.modules,"transformNode"),ms=nn(t.modules,"postTransformNode"),ds=t.delimiters;var r,i,o=[],a=t.preserveWhitespace!==!1,s=!1,c=!1;return vr(e,{warn:ps,expectHTML:t.expectHTML,isUnaryTag:t.isUnaryTag,shouldDecodeNewlines:t.shouldDecodeNewlines,start:function(e,a,u){function l(e){}var f=i&&i.ns||_s(e);zi&&"svg"===f&&(a=Lr(a));var p={type:1,tag:e,attrsList:a,attrsMap:Nr(a),parent:i,children:[]};f&&(p.ns=f),Ir(p)&&!Gi()&&(p.forbidden=!0);for(var d=0;d<hs.length;d++)hs[d](p,t);if(s||(gr(p),p.pre&&(s=!0)),gs(p.tag)&&(c=!0),s)yr(p);else{$r(p),wr(p),Ar(p),_r(p),p.plain=!p.key&&!a.length,br(p),Or(p),Sr(p);for(var v=0;v<vs.length;v++)vs[v](p,t);Tr(p)}if(r?o.length||r.if&&(p.elseif||p.else)&&(l(p),kr(r,{exp:p.elseif,block:p})):(r=p,l(r)),i&&!p.forbidden)if(p.elseif||p.else)xr(p,i);else if(p.slotScope){i.plain=!1;var h=p.slotTarget||'"default"';(i.scopedSlots||(i.scopedSlots={}))[h]=p}else i.children.push(p),p.parent=i;u?n(p):(i=p,o.push(p));for(var m=0;m<ms.length;m++)ms[m](p,t)},end:function(){var e=o[o.length-1],t=e.children[e.children.length-1];t&&3===t.type&&" "===t.text&&!c&&e.children.pop(),o.length-=1,i=o[o.length-1],n(e)},chars:function(e){if(i&&(!zi||"textarea"!==i.tag||i.attrsMap.placeholder!==e)){var t=i.children;if(e=c||e.trim()?Js(e):a&&t.length?" ":""){var n;!s&&" "!==e&&(n=hr(e,ds))?t.push({type:2,expression:n,text:e}):" "===e&&t.length&&" "===t[t.length-1].text||t.push({type:3,text:e})}}}}),r}function gr(e){null!=un(e,"v-pre")&&(e.pre=!0)}function yr(e){var t=e.attrsList.length;if(t)for(var n=e.attrs=new Array(t),r=0;r<t;r++)n[r]={name:e.attrsList[r].name,value:JSON.stringify(e.attrsList[r].value)};else e.pre||(e.plain=!0)}function _r(e){var t=cn(e,"key");t&&(e.key=t)}function br(e){var t=cn(e,"ref");t&&(e.ref=t,e.refInFor=Er(e))}function $r(e){var t;if(t=un(e,"v-for")){var n=t.match(Hs);if(!n)return;e.for=n[2].trim();var r=n[1].trim(),i=r.match(Us);i?(e.alias=i[1].trim(),e.iterator1=i[2].trim(),i[3]&&(e.iterator2=i[3].trim())):e.alias=r}}function wr(e){var t=un(e,"v-if");if(t)e.if=t,kr(e,{exp:t,block:e});else{null!=un(e,"v-else")&&(e.else=!0);var n=un(e,"v-else-if");n&&(e.elseif=n)}}function xr(e,t){var n=Cr(t.children);n&&n.if&&kr(n,{exp:e.elseif,block:e})}function Cr(e){for(var t=e.length;t--;){if(1===e[t].type)return e[t];e.pop()}}function kr(e,t){e.ifConditions||(e.ifConditions=[]),e.ifConditions.push(t)}function Ar(e){var t=un(e,"v-once");null!=t&&(e.once=!0)}function Or(e){if("slot"===e.tag)e.slotName=cn(e,"name");else{var t=cn(e,"slot");t&&(e.slotTarget='""'===t?'"default"':t),"template"===e.tag&&(e.slotScope=un(e,"scope"))}}function Sr(e){var t;(t=cn(e,"is"))&&(e.component=t),null!=un(e,"inline-template")&&(e.inlineTemplate=!0)}function Tr(e){var t,n,r,i,o,a,s,c=e.attrsList;for(t=0,n=c.length;t<n;t++)if(r=i=c[t].name,o=c[t].value,Fs.test(r))if(e.hasBindings=!0,a=jr(r),a&&(r=r.replace(zs,"")),Vs.test(r))r=r.replace(Vs,""),o=Xt(o),s=!1,a&&(a.prop&&(s=!0,r=Ei(r),"innerHtml"===r&&(r="innerHTML")),a.camel&&(r=Ei(r))),s||ys(e.tag,e.attrsMap.type,r)?rn(e,r,o):on(e,r,o);else if(Rs.test(r))r=r.replace(Rs,""),sn(e,r,o,a);else{r=r.replace(Fs,"");var u=r.match(Bs),l=u&&u[1];l&&(r=r.slice(0,-(l.length+1))),an(e,r,i,o,l,a)}else on(e,r,JSON.stringify(o))}function Er(e){for(var t=e;t;){if(void 0!==t.for)return!0;t=t.parent}return!1}function jr(e){var t=e.match(zs);if(t){var n={};return t.forEach(function(e){n[e.slice(1)]=!0}),n}}function Nr(e){for(var t={},n=0,r=e.length;n<r;n++)t[e[n].name]=e[n].value;return t}function Ir(e){return"style"===e.tag||"script"===e.tag&&(!e.attrsMap.type||"text/javascript"===e.attrsMap.type)}function Lr(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];Ks.test(r.name)||(r.name=r.name.replace(qs,""),t.push(r))}return t}function Dr(e,t){e&&(bs=Ws(t.staticKeys||""),$s=t.isReservedTag||Mi,Pr(e),Rr(e,!1))}function Mr(e){return n("type,tag,attrsList,attrsMap,plain,parent,children,attrs"+(e?","+e:""))}function Pr(e){if(e.static=Hr(e),1===e.type){if(!$s(e.tag)&&"slot"!==e.tag&&null==e.attrsMap["inline-template"])return;for(var t=0,n=e.children.length;t<n;t++){var r=e.children[t];Pr(r),r.static||(e.static=!1)}}}function Rr(e,t){if(1===e.type){if((e.static||e.once)&&(e.staticInFor=t),e.static&&e.children.length&&(1!==e.children.length||3!==e.children[0].type))return void(e.staticRoot=!0);if(e.staticRoot=!1,e.children)for(var n=0,r=e.children.length;n<r;n++)Rr(e.children[n],t||!!e.for);e.ifConditions&&Fr(e.ifConditions,t)}}function Fr(e,t){for(var n=1,r=e.length;n<r;n++)Rr(e[n].block,t)}function Hr(e){return 2!==e.type&&(3===e.type||!(!e.pre&&(e.hasBindings||e.if||e.for||Oi(e.tag)||!$s(e.tag)||Ur(e)||!Object.keys(e).every(bs))))}function Ur(e){for(;e.parent;){if(e=e.parent,"template"!==e.tag)return!1;if(e.for)return!0}return!1}function Br(e,t){var n=t?"nativeOn:{":"on:{";for(var r in e)n+='"'+r+'":'+Vr(r,e[r])+",";return n.slice(0,-1)+"}"}function Vr(e,t){if(!t)return"function(){}";if(Array.isArray(t))return"["+t.map(function(t){return Vr(e,t)}).join(",")+"]";var n=Gs.test(t.value),r=Zs.test(t.value);if(t.modifiers){var i="",o="",a=[];for(var s in t.modifiers)Xs[s]?(o+=Xs[s],Ys[s]&&a.push(s)):a.push(s);a.length&&(i+=zr(a)),o&&(i+=o);var c=n?t.value+"($event)":r?"("+t.value+")($event)":t.value;return"function($event){"+i+c+"}"}return n||r?t.value:"function($event){"+t.value+"}"}function zr(e){return"if(!('button' in $event)&&"+e.map(Jr).join("&&")+")return null;"}function Jr(e){var t=parseInt(e,10);if(t)return"$event.keyCode!=="+t;var n=Ys[e];return"_k($event.keyCode,"+JSON.stringify(e)+(n?","+JSON.stringify(n):"")+")"}function Kr(e,t){e.wrapData=function(n){return"_b("+n+",'"+e.tag+"',"+t.value+(t.modifiers&&t.modifiers.prop?",true":"")+")"}}function qr(e,t){var n=Os,r=Os=[],i=Ss;Ss=0,Ts=t,ws=t.warn||tn,xs=nn(t.modules,"transformCode"),Cs=nn(t.modules,"genData"),ks=t.directives||{},As=t.isReservedTag||Mi;var o=e?Wr(e):'_c("div")';return Os=n,Ss=i,{render:"with(this){return "+o+"}",staticRenderFns:r}}function Wr(e){if(e.staticRoot&&!e.staticProcessed)return Zr(e);if(e.once&&!e.onceProcessed)return Gr(e);if(e.for&&!e.forProcessed)return Xr(e);if(e.if&&!e.ifProcessed)return Yr(e);if("template"!==e.tag||e.slotTarget){if("slot"===e.tag)return fi(e);var t;if(e.component)t=pi(e.component,e);else{var n=e.plain?void 0:ei(e),r=e.inlineTemplate?null:oi(e,!0);t="_c('"+e.tag+"'"+(n?","+n:"")+(r?","+r:"")+")"}for(var i=0;i<xs.length;i++)t=xs[i](e,t);return t}return oi(e)||"void 0"}function Zr(e){return e.staticProcessed=!0,Os.push("with(this){return "+Wr(e)+"}"),"_m("+(Os.length-1)+(e.staticInFor?",true":"")+")"}function Gr(e){if(e.onceProcessed=!0,e.if&&!e.ifProcessed)return Yr(e);if(e.staticInFor){for(var t="",n=e.parent;n;){if(n.for){t=n.key;break}n=n.parent}return t?"_o("+Wr(e)+","+Ss++ +(t?","+t:"")+")":Wr(e)}return Zr(e)}function Yr(e){return e.ifProcessed=!0,Qr(e.ifConditions.slice())}function Qr(e){function t(e){return e.once?Gr(e):Wr(e)}if(!e.length)return"_e()";var n=e.shift();return n.exp?"("+n.exp+")?"+t(n.block)+":"+Qr(e):""+t(n.block)}function Xr(e){var t=e.for,n=e.alias,r=e.iterator1?","+e.iterator1:"",i=e.iterator2?","+e.iterator2:"";return e.forProcessed=!0,"_l(("+t+"),function("+n+r+i+"){return "+Wr(e)+"})"}function ei(e){var t="{",n=ti(e);n&&(t+=n+","),e.key&&(t+="key:"+e.key+","),e.ref&&(t+="ref:"+e.ref+","),e.refInFor&&(t+="refInFor:true,"),e.pre&&(t+="pre:true,"),e.component&&(t+='tag:"'+e.tag+'",');for(var r=0;r<Cs.length;r++)t+=Cs[r](e);if(e.attrs&&(t+="attrs:{"+di(e.attrs)+"},"),e.props&&(t+="domProps:{"+di(e.props)+"},"),e.events&&(t+=Br(e.events)+","),e.nativeEvents&&(t+=Br(e.nativeEvents,!0)+","),e.slotTarget&&(t+="slot:"+e.slotTarget+","),e.scopedSlots&&(t+=ri(e.scopedSlots)+","),e.model&&(t+="model:{value:"+e.model.value+",callback:"+e.model.callback+",expression:"+e.model.expression+"},"),e.inlineTemplate){var i=ni(e);i&&(t+=i+",")}return t=t.replace(/,$/,"")+"}",e.wrapData&&(t=e.wrapData(t)),t}function ti(e){var t=e.directives;if(t){var n,r,i,o,a="directives:[",s=!1;for(n=0,r=t.length;n<r;n++){i=t[n],o=!0;var c=ks[i.name]||ec[i.name];c&&(o=!!c(e,i,ws)),o&&(s=!0,a+='{name:"'+i.name+'",rawName:"'+i.rawName+'"'+(i.value?",value:("+i.value+"),expression:"+JSON.stringify(i.value):"")+(i.arg?',arg:"'+i.arg+'"':"")+(i.modifiers?",modifiers:"+JSON.stringify(i.modifiers):"")+"},")}return s?a.slice(0,-1)+"]":void 0}}function ni(e){var t=e.children[0];if(1===t.type){var n=qr(t,Ts);return"inlineTemplate:{render:function(){"+n.render+"},staticRenderFns:["+n.staticRenderFns.map(function(e){return"function(){"+e+"}"}).join(",")+"]}"}}function ri(e){return"scopedSlots:_u(["+Object.keys(e).map(function(t){return ii(t,e[t])}).join(",")+"])"}function ii(e,t){return"["+e+",function("+String(t.attrsMap.scope)+"){return "+("template"===t.tag?oi(t)||"void 0":Wr(t))+"}]"}function oi(e,t){var n=e.children;if(n.length){var r=n[0];if(1===n.length&&r.for&&"template"!==r.tag&&"slot"!==r.tag)return Wr(r);var i=t?ai(n):0;return"["+n.map(ui).join(",")+"]"+(i?","+i:"")}}function ai(e){for(var t=0,n=0;n<e.length;n++){var r=e[n];if(1===r.type){if(si(r)||r.ifConditions&&r.ifConditions.some(function(e){return si(e.block)})){t=2;break}(ci(r)||r.ifConditions&&r.ifConditions.some(function(e){return ci(e.block)}))&&(t=1)}}return t}function si(e){return void 0!==e.for||"template"===e.tag||"slot"===e.tag}function ci(e){return!As(e.tag)}function ui(e){return 1===e.type?Wr(e):li(e)}function li(e){return"_v("+(2===e.type?e.expression:vi(JSON.stringify(e.text)))+")"}function fi(e){var t=e.slotName||'"default"',n=oi(e),r="_t("+t+(n?","+n:""),i=e.attrs&&"{"+e.attrs.map(function(e){return Ei(e.name)+":"+e.value}).join(",")+"}",o=e.attrsMap["v-bind"];return!i&&!o||n||(r+=",null"),i&&(r+=","+i),o&&(r+=(i?"":",null")+","+o),r+")"}function pi(e,t){var n=t.inlineTemplate?null:oi(t,!0);return"_c("+e+","+ei(t)+(n?","+n:"")+")"}function di(e){for(var t="",n=0;n<e.length;n++){var r=e[n];t+='"'+r.name+'":'+vi(r.value)+","}return t.slice(0,-1)}function vi(e){return e.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function hi(e,t){var n=mr(e.trim(),t);Dr(n,t);var r=qr(n,t);return{ast:n,render:r.render,staticRenderFns:r.staticRenderFns}}function mi(e,t){try{return new Function(e)}catch(n){return t.push({err:n,code:e}),d}}function gi(e){function t(t,n){var r=Object.create(e),i=[],o=[];if(r.warn=function(e,t){(t?o:i).push(e)},n){n.modules&&(r.modules=(e.modules||[]).concat(n.modules)),n.directives&&(r.directives=u(Object.create(e.directives),n.directives));for(var a in n)"modules"!==a&&"directives"!==a&&(r[a]=n[a])}var s=hi(t,r);return s.errors=i,s.tips=o,s}function n(e,n,i){n=n||{};var o=n.delimiters?String(n.delimiters)+e:e;if(r[o])return r[o];var a=t(e,n),s={},c=[];s.render=mi(a.render,c);var u=a.staticRenderFns.length;s.staticRenderFns=new Array(u);for(var l=0;l<u;l++)s.staticRenderFns[l]=mi(a.staticRenderFns[l],c);return r[o]=s}var r=Object.create(null);return{compile:t,compileToFunctions:n}}function yi(e,t){var n=(t.warn||tn,un(e,"class"));n&&(e.staticClass=JSON.stringify(n));var r=cn(e,"class",!1);r&&(e.classBinding=r)}function _i(e){var t="";return e.staticClass&&(t+="staticClass:"+e.staticClass+","),e.classBinding&&(t+="class:"+e.classBinding+","),t}function bi(e,t){var n=(t.warn||tn,un(e,"style"));n&&(e.staticStyle=JSON.stringify(_a(n)));var r=cn(e,"style",!1);r&&(e.styleBinding=r)}function $i(e){var t="";return e.staticStyle&&(t+="staticStyle:"+e.staticStyle+","),e.styleBinding&&(t+="style:("+e.styleBinding+"),"),t}function wi(e,t){t.value&&rn(e,"textContent","_s("+t.value+")")}function xi(e,t){t.value&&rn(e,"innerHTML","_s("+t.value+")")}function Ci(e){if(e.outerHTML)return e.outerHTML;var t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML}var ki,Ai,Oi=n("slot,component",!0),Si=Object.prototype.hasOwnProperty,Ti=/-(\w)/g,Ei=a(function(e){return e.replace(Ti,function(e,t){return t?t.toUpperCase():""})}),ji=a(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}),Ni=/([^-])([A-Z])/g,Ii=a(function(e){return e.replace(Ni,"$1-$2").replace(Ni,"$1-$2").toLowerCase()}),Li=Object.prototype.toString,Di="[object Object]",Mi=function(){return!1},Pi=function(e){return e},Ri={optionMergeStrategies:Object.create(null),silent:!1,productionTip:!1,devtools:!1,performance:!1,errorHandler:null,ignoredElements:[],keyCodes:Object.create(null),isReservedTag:Mi,isUnknownElement:Mi,getTagNamespace:d,parsePlatformTagName:Pi,mustUseProp:Mi,_assetTypes:["component","directive","filter"],_lifecycleHooks:["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated"],_maxUpdateCount:100},Fi=Object.freeze({}),Hi=/[^\w.$]/,Ui="__proto__"in{},Bi="undefined"!=typeof window,Vi=Bi&&window.navigator.userAgent.toLowerCase(),zi=Vi&&/msie|trident/.test(Vi),Ji=Vi&&Vi.indexOf("msie 9.0")>0,Ki=Vi&&Vi.indexOf("edge/")>0,qi=Vi&&Vi.indexOf("android")>0,Wi=Vi&&/iphone|ipad|ipod|ios/.test(Vi),Zi=Vi&&/chrome\/\d+/.test(Vi)&&!Ki,Gi=function(){return void 0===ki&&(ki=!Bi&&"undefined"!=typeof global&&"server"===global.process.env.VUE_ENV),ki},Yi=Bi&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__,Qi="undefined"!=typeof Symbol&&$(Symbol)&&"undefined"!=typeof Reflect&&$(Reflect.ownKeys),Xi=function(){function e(){r=!1;var e=n.slice(0);n.length=0;for(var t=0;t<e.length;t++)e[t]()}var t,n=[],r=!1;if("undefined"!=typeof Promise&&$(Promise)){var i=Promise.resolve(),o=function(e){console.error(e)};t=function(){i.then(e).catch(o),Wi&&setTimeout(d)}}else if("undefined"==typeof MutationObserver||!$(MutationObserver)&&"[object MutationObserverConstructor]"!==MutationObserver.toString())t=function(){setTimeout(e,0)};else{var a=1,s=new MutationObserver(e),c=document.createTextNode(String(a));s.observe(c,{characterData:!0}),t=function(){a=(a+1)%2,c.data=String(a)}}return function(e,i){var o;if(n.push(function(){e&&e.call(i),o&&o(i)}),r||(r=!0,t()),!e&&"undefined"!=typeof Promise)return new Promise(function(e){o=e})}}();Ai="undefined"!=typeof Set&&$(Set)?Set:function(){function e(){this.set=Object.create(null)}return e.prototype.has=function(e){return this.set[e]===!0},e.prototype.add=function(e){this.set[e]=!0},e.prototype.clear=function(){this.set=Object.create(null)},e}();var eo=d,to=0,no=function(){this.id=to++,this.subs=[]};no.prototype.addSub=function(e){this.subs.push(e)},no.prototype.removeSub=function(e){r(this.subs,e)},no.prototype.depend=function(){no.target&&no.target.addDep(this)},no.prototype.notify=function(){for(var e=this.subs.slice(),t=0,n=e.length;t<n;t++)e[t].update()},no.target=null;var ro=[],io=Array.prototype,oo=Object.create(io);["push","pop","shift","unshift","splice","sort","reverse"].forEach(function(e){var t=io[e];_(oo,e,function(){for(var n=arguments,r=arguments.length,i=new Array(r);r--;)i[r]=n[r];var o,a=t.apply(this,i),s=this.__ob__;switch(e){case"push":o=i;break;case"unshift":o=i;break;case"splice":o=i.slice(2)}return o&&s.observeArray(o),s.dep.notify(),a})});var ao=Object.getOwnPropertyNames(oo),so={shouldConvert:!0,isSettingProps:!1},co=function(e){if(this.value=e,this.dep=new no,this.vmCount=0,_(e,"__ob__",this),Array.isArray(e)){var t=Ui?C:k;t(e,oo,ao),this.observeArray(e)}else this.walk(e)};co.prototype.walk=function(e){for(var t=Object.keys(e),n=0;n<t.length;n++)O(e,t[n],e[t[n]])},co.prototype.observeArray=function(e){for(var t=0,n=e.length;t<n;t++)A(e[t])};var uo=Ri.optionMergeStrategies;uo.data=function(e,t,n){return n?e||t?function(){var r="function"==typeof t?t.call(n):t,i="function"==typeof e?e.call(n):void 0;return r?j(r,i):i}:void 0:t?"function"!=typeof t?e:e?function(){return j(t.call(this),e.call(this))}:t:e},Ri._lifecycleHooks.forEach(function(e){uo[e]=N}),Ri._assetTypes.forEach(function(e){uo[e+"s"]=I}),uo.watch=function(e,t){if(!t)return Object.create(e||null);if(!e)return t;var n={};u(n,e);for(var r in t){var i=n[r],o=t[r];i&&!Array.isArray(i)&&(i=[i]),n[r]=i?i.concat(o):[o]}return n},uo.props=uo.methods=uo.computed=function(e,t){if(!t)return Object.create(e||null);if(!e)return t;var n=Object.create(null);return u(n,e),u(n,t),n};var lo=function(e,t){return void 0===t?e:t},fo=function(e,t,n,r,i,o,a){this.tag=e,this.data=t,this.children=n,this.text=r,this.elm=i,this.ns=void 0,this.context=o,this.functionalContext=void 0,this.key=t&&t.key,this.componentOptions=a,this.componentInstance=void 0,this.parent=void 0,this.raw=!1,this.isStatic=!1,this.isRootInsert=!0,this.isComment=!1,this.isCloned=!1,this.isOnce=!1},po={child:{}};po.child.get=function(){return this.componentInstance},Object.defineProperties(fo.prototype,po);var vo,ho=function(){var e=new fo;return e.text="",e.isComment=!0,e},mo=a(function(e){var t="~"===e.charAt(0);e=t?e.slice(1):e;var n="!"===e.charAt(0);return e=n?e.slice(1):e,{name:e,once:t,capture:n}}),go=null,yo=[],_o={},bo=!1,$o=!1,wo=0,xo=0,Co=function(e,t,n,r){this.vm=e,e._watchers.push(this),r?(this.deep=!!r.deep,this.user=!!r.user,this.lazy=!!r.lazy,this.sync=!!r.sync):this.deep=this.user=this.lazy=this.sync=!1,this.cb=n,this.id=++xo,this.active=!0,this.dirty=this.lazy,this.deps=[],this.newDeps=[],this.depIds=new Ai,this.newDepIds=new Ai,this.expression="","function"==typeof t?this.getter=t:(this.getter=b(t),this.getter||(this.getter=function(){})),this.value=this.lazy?void 0:this.get()};Co.prototype.get=function(){w(this);var e,t=this.vm;if(this.user)try{e=this.getter.call(t,t)}catch(e){B(e,t,'getter for watcher "'+this.expression+'"')}else e=this.getter.call(t,t);return this.deep&&ye(e),x(),this.cleanupDeps(),e},Co.prototype.addDep=function(e){var t=e.id;this.newDepIds.has(t)||(this.newDepIds.add(t),this.newDeps.push(e),this.depIds.has(t)||e.addSub(this))},Co.prototype.cleanupDeps=function(){for(var e=this,t=this.deps.length;t--;){var n=e.deps[t];e.newDepIds.has(n.id)||n.removeSub(e)}var r=this.depIds;this.depIds=this.newDepIds,this.newDepIds=r,this.newDepIds.clear(),r=this.deps,this.deps=this.newDeps,this.newDeps=r,this.newDeps.length=0},Co.prototype.update=function(){this.lazy?this.dirty=!0:this.sync?this.run():ge(this)},Co.prototype.run=function(){if(this.active){var e=this.get();if(e!==this.value||l(e)||this.deep){var t=this.value;if(this.value=e,this.user)try{this.cb.call(this.vm,e,t)}catch(e){B(e,this.vm,'callback for watcher "'+this.expression+'"')}else this.cb.call(this.vm,e,t)}}},Co.prototype.evaluate=function(){this.value=this.get(),this.dirty=!1},Co.prototype.depend=function(){for(var e=this,t=this.deps.length;t--;)e.deps[t].depend()},Co.prototype.teardown=function(){var e=this;if(this.active){this.vm._isBeingDestroyed||r(this.vm._watchers,this);for(var t=this.deps.length;t--;)e.deps[t].removeSub(e);this.active=!1}};var ko=new Ai,Ao={enumerable:!0,configurable:!0,get:d,set:d},Oo={lazy:!0},So={init:function(e,t,n,r){if(!e.componentInstance||e.componentInstance._isDestroyed){var i=e.componentInstance=Ie(e,go,n,r);i.$mount(t?e.elm:void 0,t)}else if(e.data.keepAlive){var o=e;So.prepatch(o,o)}},prepatch:function(e,t){var n=t.componentOptions,r=t.componentInstance=e.componentInstance;le(r,n.propsData,n.listeners,t,n.children)},insert:function(e){e.componentInstance._isMounted||(e.componentInstance._isMounted=!0,ve(e.componentInstance,"mounted")),
9 e.data.keepAlive&&pe(e.componentInstance,!0)},destroy:function(e){e.componentInstance._isDestroyed||(e.data.keepAlive?de(e.componentInstance,!0):e.componentInstance.$destroy())}},To=Object.keys(So),Eo=1,jo=2,No=0;nt(st),Ee(st),re(st),ce(st),Xe(st);var Io=[String,RegExp],Lo={name:"keep-alive",abstract:!0,props:{include:Io,exclude:Io},created:function(){this.cache=Object.create(null)},destroyed:function(){var e=this;for(var t in e.cache)gt(e.cache[t])},watch:{include:function(e){mt(this.cache,function(t){return ht(e,t)})},exclude:function(e){mt(this.cache,function(t){return!ht(e,t)})}},render:function(){var e=Q(this.$slots.default),t=e&&e.componentOptions;if(t){var n=vt(t);if(n&&(this.include&&!ht(this.include,n)||this.exclude&&ht(this.exclude,n)))return e;var r=null==e.key?t.Ctor.cid+(t.tag?"::"+t.tag:""):e.key;this.cache[r]?e.componentInstance=this.cache[r].componentInstance:this.cache[r]=e,e.data.keepAlive=!0}return e}},Do={KeepAlive:Lo};yt(st),Object.defineProperty(st.prototype,"$isServer",{get:Gi}),st.version="2.2.4";var Mo,Po,Ro,Fo,Ho,Uo,Bo,Vo,zo,Jo=n("input,textarea,option,select"),Ko=function(e,t,n){return"value"===n&&Jo(e)&&"button"!==t||"selected"===n&&"option"===e||"checked"===n&&"input"===e||"muted"===n&&"video"===e},qo=n("contenteditable,draggable,spellcheck"),Wo=n("allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,default,defaultchecked,defaultmuted,defaultselected,defer,disabled,enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,required,reversed,scoped,seamless,selected,sortable,translate,truespeed,typemustmatch,visible"),Zo="http://www.w3.org/1999/xlink",Go=function(e){return":"===e.charAt(5)&&"xlink"===e.slice(0,5)},Yo=function(e){return Go(e)?e.slice(6,e.length):""},Qo=function(e){return null==e||e===!1},Xo={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},ea=n("html,body,base,head,link,meta,style,title,address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,div,dd,dl,dt,figcaption,figure,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,menuitem,summary,content,element,shadow,template"),ta=n("svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view",!0),na=function(e){return"pre"===e},ra=function(e){return ea(e)||ta(e)},ia=Object.create(null),oa=Object.freeze({createElement:Ot,createElementNS:St,createTextNode:Tt,createComment:Et,insertBefore:jt,removeChild:Nt,appendChild:It,parentNode:Lt,nextSibling:Dt,tagName:Mt,setTextContent:Pt,setAttribute:Rt}),aa={create:function(e,t){Ft(t)},update:function(e,t){e.data.ref!==t.data.ref&&(Ft(e,!0),Ft(t))},destroy:function(e){Ft(e,!0)}},sa=new fo("",{},[]),ca=["create","activate","update","remove","destroy"],ua={create:Jt,update:Jt,destroy:function(e){Jt(e,sa)}},la=Object.create(null),fa=[aa,ua],pa={create:Gt,update:Gt},da={create:Qt,update:Qt},va=/[\w).+\-_$\]]/,ha="__r",ma="__c",ga={create:An,update:An},ya={create:On,update:On},_a=a(function(e){var t={},n=/;(?![^(]*\))/g,r=/:(.+)/;return e.split(n).forEach(function(e){if(e){var n=e.split(r);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}),ba=/^--/,$a=/\s*!important$/,wa=function(e,t,n){ba.test(t)?e.style.setProperty(t,n):$a.test(n)?e.style.setProperty(t,n.replace($a,""),"important"):e.style[Ca(t)]=n},xa=["Webkit","Moz","ms"],Ca=a(function(e){if(zo=zo||document.createElement("div"),e=Ei(e),"filter"!==e&&e in zo.style)return e;for(var t=e.charAt(0).toUpperCase()+e.slice(1),n=0;n<xa.length;n++){var r=xa[n]+t;if(r in zo.style)return r}}),ka={create:Ln,update:Ln},Aa=a(function(e){return{enterClass:e+"-enter",enterToClass:e+"-enter-to",enterActiveClass:e+"-enter-active",leaveClass:e+"-leave",leaveToClass:e+"-leave-to",leaveActiveClass:e+"-leave-active"}}),Oa=Bi&&!Ji,Sa="transition",Ta="animation",Ea="transition",ja="transitionend",Na="animation",Ia="animationend";Oa&&(void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(Ea="WebkitTransition",ja="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(Na="WebkitAnimation",Ia="webkitAnimationEnd"));var La=Bi&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout,Da=/\b(transform|all)(,|$)/,Ma=Bi?{create:Zn,activate:Zn,remove:function(e,t){e.data.show?t():Kn(e,t)}}:{},Pa=[pa,da,ga,ya,ka,Ma],Ra=Pa.concat(fa),Fa=zt({nodeOps:oa,modules:Ra});Ji&&document.addEventListener("selectionchange",function(){var e=document.activeElement;e&&e.vmodel&&tr(e,"input")});var Ha={inserted:function(e,t,n){if("select"===n.tag){var r=function(){Gn(e,t,n.context)};r(),(zi||Ki)&&setTimeout(r,0)}else"textarea"!==n.tag&&"text"!==e.type||(e._vModifiers=t.modifiers,t.modifiers.lazy||(qi||(e.addEventListener("compositionstart",Xn),e.addEventListener("compositionend",er)),Ji&&(e.vmodel=!0)))},componentUpdated:function(e,t,n){if("select"===n.tag){Gn(e,t,n.context);var r=e.multiple?t.value.some(function(t){return Yn(t,e.options)}):t.value!==t.oldValue&&Yn(t.value,e.options);r&&tr(e,"change")}}},Ua={bind:function(e,t,n){var r=t.value;n=nr(n);var i=n.data&&n.data.transition,o=e.__vOriginalDisplay="none"===e.style.display?"":e.style.display;r&&i&&!Ji?(n.data.show=!0,Jn(n,function(){e.style.display=o})):e.style.display=r?o:"none"},update:function(e,t,n){var r=t.value,i=t.oldValue;if(r!==i){n=nr(n);var o=n.data&&n.data.transition;o&&!Ji?(n.data.show=!0,r?Jn(n,function(){e.style.display=e.__vOriginalDisplay}):Kn(n,function(){e.style.display="none"})):e.style.display=r?e.__vOriginalDisplay:"none"}},unbind:function(e,t,n,r,i){i||(e.style.display=e.__vOriginalDisplay)}},Ba={model:Ha,show:Ua},Va={name:String,appear:Boolean,css:Boolean,mode:String,type:String,enterClass:String,leaveClass:String,enterToClass:String,leaveToClass:String,enterActiveClass:String,leaveActiveClass:String,appearClass:String,appearActiveClass:String,appearToClass:String,duration:[Number,String,Object]},za={name:"transition",props:Va,abstract:!0,render:function(e){var t=this,n=this.$slots.default;if(n&&(n=n.filter(function(e){return e.tag}),n.length)){var r=this.mode,i=n[0];if(ar(this.$vnode))return i;var a=rr(i);if(!a)return i;if(this._leaving)return or(e,i);var s="__transition-"+this._uid+"-";a.key=null==a.key?s+a.tag:o(a.key)?0===String(a.key).indexOf(s)?a.key:s+a.key:a.key;var c=(a.data||(a.data={})).transition=ir(this),l=this._vnode,f=rr(l);if(a.data.directives&&a.data.directives.some(function(e){return"show"===e.name})&&(a.data.show=!0),f&&f.data&&!sr(a,f)){var p=f&&(f.data.transition=u({},c));if("out-in"===r)return this._leaving=!0,W(p,"afterLeave",function(){t._leaving=!1,t.$forceUpdate()}),or(e,i);if("in-out"===r){var d,v=function(){d()};W(c,"afterEnter",v),W(c,"enterCancelled",v),W(p,"delayLeave",function(e){d=e})}}return i}}},Ja=u({tag:String,moveClass:String},Va);delete Ja.mode;var Ka={props:Ja,render:function(e){for(var t=this.tag||this.$vnode.data.tag||"span",n=Object.create(null),r=this.prevChildren=this.children,i=this.$slots.default||[],o=this.children=[],a=ir(this),s=0;s<i.length;s++){var c=i[s];c.tag&&null!=c.key&&0!==String(c.key).indexOf("__vlist")&&(o.push(c),n[c.key]=c,(c.data||(c.data={})).transition=a)}if(r){for(var u=[],l=[],f=0;f<r.length;f++){var p=r[f];p.data.transition=a,p.data.pos=p.elm.getBoundingClientRect(),n[p.key]?u.push(p):l.push(p)}this.kept=e(t,null,u),this.removed=l}return e(t,null,o)},beforeUpdate:function(){this.__patch__(this._vnode,this.kept,!1,!0),this._vnode=this.kept},updated:function(){var e=this.prevChildren,t=this.moveClass||(this.name||"v")+"-move";if(e.length&&this.hasMove(e[0].elm,t)){e.forEach(cr),e.forEach(ur),e.forEach(lr);var n=document.body;n.offsetHeight;e.forEach(function(e){if(e.data.moved){var n=e.elm,r=n.style;Fn(n,t),r.transform=r.WebkitTransform=r.transitionDuration="",n.addEventListener(ja,n._moveCb=function e(r){r&&!/transform$/.test(r.propertyName)||(n.removeEventListener(ja,e),n._moveCb=null,Hn(n,t))})}})}},methods:{hasMove:function(e,t){if(!Oa)return!1;if(null!=this._hasMove)return this._hasMove;var n=e.cloneNode();e._transitionClasses&&e._transitionClasses.forEach(function(e){Mn(n,e)}),Dn(n,t),n.style.display="none",this.$el.appendChild(n);var r=Bn(n);return this.$el.removeChild(n),this._hasMove=r.hasTransform}}},qa={Transition:za,TransitionGroup:Ka};st.config.mustUseProp=Ko,st.config.isReservedTag=ra,st.config.getTagNamespace=Ct,st.config.isUnknownElement=kt,u(st.options.directives,Ba),u(st.options.components,qa),st.prototype.__patch__=Bi?Fa:d,st.prototype.$mount=function(e,t){return e=e&&Bi?At(e):void 0,ue(this,e,t)},setTimeout(function(){Ri.devtools&&Yi&&Yi.emit("init",st)},0);var Wa,Za=!!Bi&&fr("\n","&#10;"),Ga=n("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),Ya=n("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),Qa=n("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track"),Xa=/([^\s"'<>\/=]+)/,es=/(?:=)/,ts=[/"([^"]*)"+/.source,/'([^']*)'+/.source,/([^\s"'=<>`]+)/.source],ns=new RegExp("^\\s*"+Xa.source+"(?:\\s*("+es.source+")\\s*(?:"+ts.join("|")+"))?"),rs="[a-zA-Z_][\\w\\-\\.]*",is="((?:"+rs+"\\:)?"+rs+")",os=new RegExp("^<"+is),as=/^\s*(\/?)>/,ss=new RegExp("^<\\/"+is+"[^>]*>"),cs=/^<!DOCTYPE [^>]+>/i,us=/^<!--/,ls=/^<!\[/,fs=!1;"x".replace(/x(.)?/g,function(e,t){fs=""===t});var ps,ds,vs,hs,ms,gs,ys,_s,bs,$s,ws,xs,Cs,ks,As,Os,Ss,Ts,Es=n("script,style,textarea",!0),js={},Ns={"&lt;":"<","&gt;":">","&quot;":'"',"&amp;":"&","&#10;":"\n"},Is=/&(?:lt|gt|quot|amp);/g,Ls=/&(?:lt|gt|quot|amp|#10);/g,Ds=/\{\{((?:.|\n)+?)\}\}/g,Ms=/[-.*+?^${}()|[\]\/\\]/g,Ps=a(function(e){var t=e[0].replace(Ms,"\\$&"),n=e[1].replace(Ms,"\\$&");return new RegExp(t+"((?:.|\\n)+?)"+n,"g")}),Rs=/^@|^v-on:/,Fs=/^v-|^@|^:/,Hs=/(.*?)\s+(?:in|of)\s+(.*)/,Us=/\((\{[^}]*\}|[^,]*),([^,]*)(?:,([^,]*))?\)/,Bs=/:(.*)$/,Vs=/^:|^v-bind:/,zs=/\.[^.]+/g,Js=a(pr),Ks=/^xmlns:NS\d+/,qs=/^NS\d+:/,Ws=a(Mr),Zs=/^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/,Gs=/^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/,Ys={esc:27,tab:9,enter:13,space:32,up:38,left:37,right:39,down:40,delete:[8,46]},Qs=function(e){return"if("+e+")return null;"},Xs={stop:"$event.stopPropagation();",prevent:"$event.preventDefault();",self:Qs("$event.target !== $event.currentTarget"),ctrl:Qs("!$event.ctrlKey"),shift:Qs("!$event.shiftKey"),alt:Qs("!$event.altKey"),meta:Qs("!$event.metaKey"),left:Qs("'button' in $event && $event.button !== 0"),middle:Qs("'button' in $event && $event.button !== 1"),right:Qs("'button' in $event && $event.button !== 2")},ec={bind:Kr,cloak:d},tc={staticKeys:["staticClass"],transformNode:yi,genData:_i},nc={staticKeys:["staticStyle"],transformNode:bi,genData:$i},rc=[tc,nc],ic={model:yn,text:wi,html:xi},oc={expectHTML:!0,modules:rc,directives:ic,isPreTag:na,isUnaryTag:Ga,mustUseProp:Ko,isReservedTag:ra,getTagNamespace:Ct,staticKeys:v(rc)},ac=gi(oc),sc=ac.compileToFunctions,cc=a(function(e){var t=At(e);return t&&t.innerHTML}),uc=st.prototype.$mount;return st.prototype.$mount=function(e,t){if(e=e&&At(e),e===document.body||e===document.documentElement)return this;var n=this.$options;if(!n.render){var r=n.template;if(r)if("string"==typeof r)"#"===r.charAt(0)&&(r=cc(r));else{if(!r.nodeType)return this;r=r.innerHTML}else e&&(r=Ci(e));if(r){var i=sc(r,{shouldDecodeNewlines:Za,delimiters:n.delimiters},this),o=i.render,a=i.staticRenderFns;n.render=o,n.staticRenderFns=a}}return uc.call(this,e,t)},st.compile=sc,st});
10 /* assets/wpuf/vendor/vuex/vuex.js */
11 /**
12 * vuex v2.2.1
13 * (c) 2017 Evan You
14 * @license MIT
15 */
16 (function (global, factory) {
17 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
18 typeof define === 'function' && define.amd ? define(factory) :
19 (global.Vuex = factory());
20 }(this, (function () { 'use strict';
21
22 var applyMixin = function (Vue) {
23 var version = Number(Vue.version.split('.')[0]);
24
25 if (version >= 2) {
26 var usesInit = Vue.config._lifecycleHooks.indexOf('init') > -1;
27 Vue.mixin(usesInit ? { init: vuexInit } : { beforeCreate: vuexInit });
28 } else {
29 // override init and inject vuex init procedure
30 // for 1.x backwards compatibility.
31 var _init = Vue.prototype._init;
32 Vue.prototype._init = function (options) {
33 if ( options === void 0 ) options = {};
34
35 options.init = options.init
36 ? [vuexInit].concat(options.init)
37 : vuexInit;
38 _init.call(this, options);
39 };
40 }
41
42 /**
43 * Vuex init hook, injected into each instances init hooks list.
44 */
45
46 function vuexInit () {
47 var options = this.$options;
48 // store injection
49 if (options.store) {
50 this.$store = options.store;
51 } else if (options.parent && options.parent.$store) {
52 this.$store = options.parent.$store;
53 }
54 }
55 };
56
57 var devtoolHook =
58 typeof window !== 'undefined' &&
59 window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
60
61 function devtoolPlugin (store) {
62 if (!devtoolHook) { return }
63
64 store._devtoolHook = devtoolHook;
65
66 devtoolHook.emit('vuex:init', store);
67
68 devtoolHook.on('vuex:travel-to-state', function (targetState) {
69 store.replaceState(targetState);
70 });
71
72 store.subscribe(function (mutation, state) {
73 devtoolHook.emit('vuex:mutation', mutation, state);
74 });
75 }
76
77 /**
78 * Get the first item that pass the test
79 * by second argument function
80 *
81 * @param {Array} list
82 * @param {Function} f
83 * @return {*}
84 */
85 /**
86 * Deep copy the given object considering circular structure.
87 * This function caches all nested objects and its copies.
88 * If it detects circular structure, use cached copy to avoid infinite loop.
89 *
90 * @param {*} obj
91 * @param {Array<Object>} cache
92 * @return {*}
93 */
94
95
96 /**
97 * forEach for object
98 */
99 function forEachValue (obj, fn) {
100 Object.keys(obj).forEach(function (key) { return fn(obj[key], key); });
101 }
102
103 function isObject (obj) {
104 return obj !== null && typeof obj === 'object'
105 }
106
107 function isPromise (val) {
108 return val && typeof val.then === 'function'
109 }
110
111 function assert (condition, msg) {
112 if (!condition) { throw new Error(("[vuex] " + msg)) }
113 }
114
115 var Module = function Module (rawModule, runtime) {
116 this.runtime = runtime;
117 this._children = Object.create(null);
118 this._rawModule = rawModule;
119 };
120
121 var prototypeAccessors$1 = { state: {},namespaced: {} };
122
123 prototypeAccessors$1.state.get = function () {
124 return this._rawModule.state || {}
125 };
126
127 prototypeAccessors$1.namespaced.get = function () {
128 return !!this._rawModule.namespaced
129 };
130
131 Module.prototype.addChild = function addChild (key, module) {
132 this._children[key] = module;
133 };
134
135 Module.prototype.removeChild = function removeChild (key) {
136 delete this._children[key];
137 };
138
139 Module.prototype.getChild = function getChild (key) {
140 return this._children[key]
141 };
142
143 Module.prototype.update = function update (rawModule) {
144 this._rawModule.namespaced = rawModule.namespaced;
145 if (rawModule.actions) {
146 this._rawModule.actions = rawModule.actions;
147 }
148 if (rawModule.mutations) {
149 this._rawModule.mutations = rawModule.mutations;
150 }
151 if (rawModule.getters) {
152 this._rawModule.getters = rawModule.getters;
153 }
154 };
155
156 Module.prototype.forEachChild = function forEachChild (fn) {
157 forEachValue(this._children, fn);
158 };
159
160 Module.prototype.forEachGetter = function forEachGetter (fn) {
161 if (this._rawModule.getters) {
162 forEachValue(this._rawModule.getters, fn);
163 }
164 };
165
166 Module.prototype.forEachAction = function forEachAction (fn) {
167 if (this._rawModule.actions) {
168 forEachValue(this._rawModule.actions, fn);
169 }
170 };
171
172 Module.prototype.forEachMutation = function forEachMutation (fn) {
173 if (this._rawModule.mutations) {
174 forEachValue(this._rawModule.mutations, fn);
175 }
176 };
177
178 Object.defineProperties( Module.prototype, prototypeAccessors$1 );
179
180 var ModuleCollection = function ModuleCollection (rawRootModule) {
181 var this$1 = this;
182
183 // register root module (Vuex.Store options)
184 this.root = new Module(rawRootModule, false);
185
186 // register all nested modules
187 if (rawRootModule.modules) {
188 forEachValue(rawRootModule.modules, function (rawModule, key) {
189 this$1.register([key], rawModule, false);
190 });
191 }
192 };
193
194 ModuleCollection.prototype.get = function get (path) {
195 return path.reduce(function (module, key) {
196 return module.getChild(key)
197 }, this.root)
198 };
199
200 ModuleCollection.prototype.getNamespace = function getNamespace (path) {
201 var module = this.root;
202 return path.reduce(function (namespace, key) {
203 module = module.getChild(key);
204 return namespace + (module.namespaced ? key + '/' : '')
205 }, '')
206 };
207
208 ModuleCollection.prototype.update = function update$1 (rawRootModule) {
209 update(this.root, rawRootModule);
210 };
211
212 ModuleCollection.prototype.register = function register (path, rawModule, runtime) {
213 var this$1 = this;
214 if ( runtime === void 0 ) runtime = true;
215
216 var parent = this.get(path.slice(0, -1));
217 var newModule = new Module(rawModule, runtime);
218 parent.addChild(path[path.length - 1], newModule);
219
220 // register nested modules
221 if (rawModule.modules) {
222 forEachValue(rawModule.modules, function (rawChildModule, key) {
223 this$1.register(path.concat(key), rawChildModule, runtime);
224 });
225 }
226 };
227
228 ModuleCollection.prototype.unregister = function unregister (path) {
229 var parent = this.get(path.slice(0, -1));
230 var key = path[path.length - 1];
231 if (!parent.getChild(key).runtime) { return }
232
233 parent.removeChild(key);
234 };
235
236 function update (targetModule, newModule) {
237 // update target module
238 targetModule.update(newModule);
239
240 // update nested modules
241 if (newModule.modules) {
242 for (var key in newModule.modules) {
243 if (!targetModule.getChild(key)) {
244 console.warn(
245 "[vuex] trying to add a new module '" + key + "' on hot reloading, " +
246 'manual reload is needed'
247 );
248 return
249 }
250 update(targetModule.getChild(key), newModule.modules[key]);
251 }
252 }
253 }
254
255 var Vue; // bind on install
256
257 var Store = function Store (options) {
258 var this$1 = this;
259 if ( options === void 0 ) options = {};
260
261 assert(Vue, "must call Vue.use(Vuex) before creating a store instance.");
262 assert(typeof Promise !== 'undefined', "vuex requires a Promise polyfill in this browser.");
263
264 var state = options.state; if ( state === void 0 ) state = {};
265 var plugins = options.plugins; if ( plugins === void 0 ) plugins = [];
266 var strict = options.strict; if ( strict === void 0 ) strict = false;
267
268 // store internal state
269 this._committing = false;
270 this._actions = Object.create(null);
271 this._mutations = Object.create(null);
272 this._wrappedGetters = Object.create(null);
273 this._modules = new ModuleCollection(options);
274 this._modulesNamespaceMap = Object.create(null);
275 this._subscribers = [];
276 this._watcherVM = new Vue();
277
278 // bind commit and dispatch to self
279 var store = this;
280 var ref = this;
281 var dispatch = ref.dispatch;
282 var commit = ref.commit;
283 this.dispatch = function boundDispatch (type, payload) {
284 return dispatch.call(store, type, payload)
285 };
286 this.commit = function boundCommit (type, payload, options) {
287 return commit.call(store, type, payload, options)
288 };
289
290 // strict mode
291 this.strict = strict;
292
293 // init root module.
294 // this also recursively registers all sub-modules
295 // and collects all module getters inside this._wrappedGetters
296 installModule(this, state, [], this._modules.root);
297
298 // initialize the store vm, which is responsible for the reactivity
299 // (also registers _wrappedGetters as computed properties)
300 resetStoreVM(this, state);
301
302 // apply plugins
303 plugins.concat(devtoolPlugin).forEach(function (plugin) { return plugin(this$1); });
304 };
305
306 var prototypeAccessors = { state: {} };
307
308 prototypeAccessors.state.get = function () {
309 return this._vm._data.$$state
310 };
311
312 prototypeAccessors.state.set = function (v) {
313 assert(false, "Use store.replaceState() to explicit replace store state.");
314 };
315
316 Store.prototype.commit = function commit (_type, _payload, _options) {
317 var this$1 = this;
318
319 // check object-style commit
320 var ref = unifyObjectStyle(_type, _payload, _options);
321 var type = ref.type;
322 var payload = ref.payload;
323 var options = ref.options;
324
325 var mutation = { type: type, payload: payload };
326 var entry = this._mutations[type];
327 if (!entry) {
328 console.error(("[vuex] unknown mutation type: " + type));
329 return
330 }
331 this._withCommit(function () {
332 entry.forEach(function commitIterator (handler) {
333 handler(payload);
334 });
335 });
336 this._subscribers.forEach(function (sub) { return sub(mutation, this$1.state); });
337
338 if (options && options.silent) {
339 console.warn(
340 "[vuex] mutation type: " + type + ". Silent option has been removed. " +
341 'Use the filter functionality in the vue-devtools'
342 );
343 }
344 };
345
346 Store.prototype.dispatch = function dispatch (_type, _payload) {
347 // check object-style dispatch
348 var ref = unifyObjectStyle(_type, _payload);
349 var type = ref.type;
350 var payload = ref.payload;
351
352 var entry = this._actions[type];
353 if (!entry) {
354 console.error(("[vuex] unknown action type: " + type));
355 return
356 }
357 return entry.length > 1
358 ? Promise.all(entry.map(function (handler) { return handler(payload); }))
359 : entry[0](payload)
360 };
361
362 Store.prototype.subscribe = function subscribe (fn) {
363 var subs = this._subscribers;
364 if (subs.indexOf(fn) < 0) {
365 subs.push(fn);
366 }
367 return function () {
368 var i = subs.indexOf(fn);
369 if (i > -1) {
370 subs.splice(i, 1);
371 }
372 }
373 };
374
375 Store.prototype.watch = function watch (getter, cb, options) {
376 var this$1 = this;
377
378 assert(typeof getter === 'function', "store.watch only accepts a function.");
379 return this._watcherVM.$watch(function () { return getter(this$1.state, this$1.getters); }, cb, options)
380 };
381
382 Store.prototype.replaceState = function replaceState (state) {
383 var this$1 = this;
384
385 this._withCommit(function () {
386 this$1._vm._data.$$state = state;
387 });
388 };
389
390 Store.prototype.registerModule = function registerModule (path, rawModule) {
391 if (typeof path === 'string') { path = [path]; }
392 assert(Array.isArray(path), "module path must be a string or an Array.");
393 this._modules.register(path, rawModule);
394 installModule(this, this.state, path, this._modules.get(path));
395 // reset store to update getters...
396 resetStoreVM(this, this.state);
397 };
398
399 Store.prototype.unregisterModule = function unregisterModule (path) {
400 var this$1 = this;
401
402 if (typeof path === 'string') { path = [path]; }
403 assert(Array.isArray(path), "module path must be a string or an Array.");
404 this._modules.unregister(path);
405 this._withCommit(function () {
406 var parentState = getNestedState(this$1.state, path.slice(0, -1));
407 Vue.delete(parentState, path[path.length - 1]);
408 });
409 resetStore(this);
410 };
411
412 Store.prototype.hotUpdate = function hotUpdate (newOptions) {
413 this._modules.update(newOptions);
414 resetStore(this, true);
415 };
416
417 Store.prototype._withCommit = function _withCommit (fn) {
418 var committing = this._committing;
419 this._committing = true;
420 fn();
421 this._committing = committing;
422 };
423
424 Object.defineProperties( Store.prototype, prototypeAccessors );
425
426 function resetStore (store, hot) {
427 store._actions = Object.create(null);
428 store._mutations = Object.create(null);
429 store._wrappedGetters = Object.create(null);
430 store._modulesNamespaceMap = Object.create(null);
431 var state = store.state;
432 // init all modules
433 installModule(store, state, [], store._modules.root, true);
434 // reset vm
435 resetStoreVM(store, state, hot);
436 }
437
438 function resetStoreVM (store, state, hot) {
439 var oldVm = store._vm;
440
441 // bind store public getters
442 store.getters = {};
443 var wrappedGetters = store._wrappedGetters;
444 var computed = {};
445 forEachValue(wrappedGetters, function (fn, key) {
446 // use computed to leverage its lazy-caching mechanism
447 computed[key] = function () { return fn(store); };
448 Object.defineProperty(store.getters, key, {
449 get: function () { return store._vm[key]; },
450 enumerable: true // for local getters
451 });
452 });
453
454 // use a Vue instance to store the state tree
455 // suppress warnings just in case the user has added
456 // some funky global mixins
457 var silent = Vue.config.silent;
458 Vue.config.silent = true;
459 store._vm = new Vue({
460 data: {
461 $$state: state
462 },
463 computed: computed
464 });
465 Vue.config.silent = silent;
466
467 // enable strict mode for new vm
468 if (store.strict) {
469 enableStrictMode(store);
470 }
471
472 if (oldVm) {
473 if (hot) {
474 // dispatch changes in all subscribed watchers
475 // to force getter re-evaluation for hot reloading.
476 store._withCommit(function () {
477 oldVm._data.$$state = null;
478 });
479 }
480 Vue.nextTick(function () { return oldVm.$destroy(); });
481 }
482 }
483
484 function installModule (store, rootState, path, module, hot) {
485 var isRoot = !path.length;
486 var namespace = store._modules.getNamespace(path);
487
488 // register in namespace map
489 if (namespace) {
490 store._modulesNamespaceMap[namespace] = module;
491 }
492
493 // set state
494 if (!isRoot && !hot) {
495 var parentState = getNestedState(rootState, path.slice(0, -1));
496 var moduleName = path[path.length - 1];
497 store._withCommit(function () {
498 Vue.set(parentState, moduleName, module.state);
499 });
500 }
501
502 var local = module.context = makeLocalContext(store, namespace, path);
503
504 module.forEachMutation(function (mutation, key) {
505 var namespacedType = namespace + key;
506 registerMutation(store, namespacedType, mutation, local);
507 });
508
509 module.forEachAction(function (action, key) {
510 var namespacedType = namespace + key;
511 registerAction(store, namespacedType, action, local);
512 });
513
514 module.forEachGetter(function (getter, key) {
515 var namespacedType = namespace + key;
516 registerGetter(store, namespacedType, getter, local);
517 });
518
519 module.forEachChild(function (child, key) {
520 installModule(store, rootState, path.concat(key), child, hot);
521 });
522 }
523
524 /**
525 * make localized dispatch, commit, getters and state
526 * if there is no namespace, just use root ones
527 */
528 function makeLocalContext (store, namespace, path) {
529 var noNamespace = namespace === '';
530
531 var local = {
532 dispatch: noNamespace ? store.dispatch : function (_type, _payload, _options) {
533 var args = unifyObjectStyle(_type, _payload, _options);
534 var payload = args.payload;
535 var options = args.options;
536 var type = args.type;
537
538 if (!options || !options.root) {
539 type = namespace + type;
540 if (!store._actions[type]) {
541 console.error(("[vuex] unknown local action type: " + (args.type) + ", global type: " + type));
542 return
543 }
544 }
545
546 return store.dispatch(type, payload)
547 },
548
549 commit: noNamespace ? store.commit : function (_type, _payload, _options) {
550 var args = unifyObjectStyle(_type, _payload, _options);
551 var payload = args.payload;
552 var options = args.options;
553 var type = args.type;
554
555 if (!options || !options.root) {
556 type = namespace + type;
557 if (!store._mutations[type]) {
558 console.error(("[vuex] unknown local mutation type: " + (args.type) + ", global type: " + type));
559 return
560 }
561 }
562
563 store.commit(type, payload, options);
564 }
565 };
566
567 // getters and state object must be gotten lazily
568 // because they will be changed by vm update
569 Object.defineProperties(local, {
570 getters: {
571 get: noNamespace
572 ? function () { return store.getters; }
573 : function () { return makeLocalGetters(store, namespace); }
574 },
575 state: {
576 get: function () { return getNestedState(store.state, path); }
577 }
578 });
579
580 return local
581 }
582
583 function makeLocalGetters (store, namespace) {
584 var gettersProxy = {};
585
586 var splitPos = namespace.length;
587 Object.keys(store.getters).forEach(function (type) {
588 // skip if the target getter is not match this namespace
589 if (type.slice(0, splitPos) !== namespace) { return }
590
591 // extract local getter type
592 var localType = type.slice(splitPos);
593
594 // Add a port to the getters proxy.
595 // Define as getter property because
596 // we do not want to evaluate the getters in this time.
597 Object.defineProperty(gettersProxy, localType, {
598 get: function () { return store.getters[type]; },
599 enumerable: true
600 });
601 });
602
603 return gettersProxy
604 }
605
606 function registerMutation (store, type, handler, local) {
607 var entry = store._mutations[type] || (store._mutations[type] = []);
608 entry.push(function wrappedMutationHandler (payload) {
609 handler(local.state, payload);
610 });
611 }
612
613 function registerAction (store, type, handler, local) {
614 var entry = store._actions[type] || (store._actions[type] = []);
615 entry.push(function wrappedActionHandler (payload, cb) {
616 var res = handler({
617 dispatch: local.dispatch,
618 commit: local.commit,
619 getters: local.getters,
620 state: local.state,
621 rootGetters: store.getters,
622 rootState: store.state
623 }, payload, cb);
624 if (!isPromise(res)) {
625 res = Promise.resolve(res);
626 }
627 if (store._devtoolHook) {
628 return res.catch(function (err) {
629 store._devtoolHook.emit('vuex:error', err);
630 throw err
631 })
632 } else {
633 return res
634 }
635 });
636 }
637
638 function registerGetter (store, type, rawGetter, local) {
639 if (store._wrappedGetters[type]) {
640 console.error(("[vuex] duplicate getter key: " + type));
641 return
642 }
643 store._wrappedGetters[type] = function wrappedGetter (store) {
644 return rawGetter(
645 local.state, // local state
646 local.getters, // local getters
647 store.state, // root state
648 store.getters // root getters
649 )
650 };
651 }
652
653 function enableStrictMode (store) {
654 store._vm.$watch(function () { return this._data.$$state }, function () {
655 assert(store._committing, "Do not mutate vuex store state outside mutation handlers.");
656 }, { deep: true, sync: true });
657 }
658
659 function getNestedState (state, path) {
660 return path.length
661 ? path.reduce(function (state, key) { return state[key]; }, state)
662 : state
663 }
664
665 function unifyObjectStyle (type, payload, options) {
666 if (isObject(type) && type.type) {
667 options = payload;
668 payload = type;
669 type = type.type;
670 }
671
672 assert(typeof type === 'string', ("Expects string as the type, but found " + (typeof type) + "."));
673
674 return { type: type, payload: payload, options: options }
675 }
676
677 function install (_Vue) {
678 if (Vue) {
679 console.error(
680 '[vuex] already installed. Vue.use(Vuex) should be called only once.'
681 );
682 return
683 }
684 Vue = _Vue;
685 applyMixin(Vue);
686 }
687
688 // auto install in dist mode
689 if (typeof window !== 'undefined' && window.Vue) {
690 install(window.Vue);
691 }
692
693 var mapState = normalizeNamespace(function (namespace, states) {
694 var res = {};
695 normalizeMap(states).forEach(function (ref) {
696 var key = ref.key;
697 var val = ref.val;
698
699 res[key] = function mappedState () {
700 var state = this.$store.state;
701 var getters = this.$store.getters;
702 if (namespace) {
703 var module = getModuleByNamespace(this.$store, 'mapState', namespace);
704 if (!module) {
705 return
706 }
707 state = module.context.state;
708 getters = module.context.getters;
709 }
710 return typeof val === 'function'
711 ? val.call(this, state, getters)
712 : state[val]
713 };
714 // mark vuex getter for devtools
715 res[key].vuex = true;
716 });
717 return res
718 });
719
720 var mapMutations = normalizeNamespace(function (namespace, mutations) {
721 var res = {};
722 normalizeMap(mutations).forEach(function (ref) {
723 var key = ref.key;
724 var val = ref.val;
725
726 val = namespace + val;
727 res[key] = function mappedMutation () {
728 var args = [], len = arguments.length;
729 while ( len-- ) args[ len ] = arguments[ len ];
730
731 if (namespace && !getModuleByNamespace(this.$store, 'mapMutations', namespace)) {
732 return
733 }
734 return this.$store.commit.apply(this.$store, [val].concat(args))
735 };
736 });
737 return res
738 });
739
740 var mapGetters = normalizeNamespace(function (namespace, getters) {
741 var res = {};
742 normalizeMap(getters).forEach(function (ref) {
743 var key = ref.key;
744 var val = ref.val;
745
746 val = namespace + val;
747 res[key] = function mappedGetter () {
748 if (namespace && !getModuleByNamespace(this.$store, 'mapGetters', namespace)) {
749 return
750 }
751 if (!(val in this.$store.getters)) {
752 console.error(("[vuex] unknown getter: " + val));
753 return
754 }
755 return this.$store.getters[val]
756 };
757 // mark vuex getter for devtools
758 res[key].vuex = true;
759 });
760 return res
761 });
762
763 var mapActions = normalizeNamespace(function (namespace, actions) {
764 var res = {};
765 normalizeMap(actions).forEach(function (ref) {
766 var key = ref.key;
767 var val = ref.val;
768
769 val = namespace + val;
770 res[key] = function mappedAction () {
771 var args = [], len = arguments.length;
772 while ( len-- ) args[ len ] = arguments[ len ];
773
774 if (namespace && !getModuleByNamespace(this.$store, 'mapActions', namespace)) {
775 return
776 }
777 return this.$store.dispatch.apply(this.$store, [val].concat(args))
778 };
779 });
780 return res
781 });
782
783 function normalizeMap (map) {
784 return Array.isArray(map)
785 ? map.map(function (key) { return ({ key: key, val: key }); })
786 : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); })
787 }
788
789 function normalizeNamespace (fn) {
790 return function (namespace, map) {
791 if (typeof namespace !== 'string') {
792 map = namespace;
793 namespace = '';
794 } else if (namespace.charAt(namespace.length - 1) !== '/') {
795 namespace += '/';
796 }
797 return fn(namespace, map)
798 }
799 }
800
801 function getModuleByNamespace (store, helper, namespace) {
802 var module = store._modulesNamespaceMap[namespace];
803 if (!module) {
804 console.error(("[vuex] module namespace not found in " + helper + "(): " + namespace));
805 }
806 return module
807 }
808
809 var index = {
810 Store: Store,
811 install: install,
812 version: '2.2.1',
813 mapState: mapState,
814 mapMutations: mapMutations,
815 mapGetters: mapGetters,
816 mapActions: mapActions
817 };
818
819 return index;
820
821 })));
822
823 /* assets/js/vendor/vue-router.js */
824 /**
825 * vue-router v2.3.1
826 * (c) 2017 Evan You
827 * @license MIT
828 */
829 (function (global, factory) {
830 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
831 typeof define === 'function' && define.amd ? define(factory) :
832 (global.VueRouter = factory());
833 }(this, (function () { 'use strict';
834
835 /* */
836
837 function assert (condition, message) {
838 if (!condition) {
839 throw new Error(("[vue-router] " + message))
840 }
841 }
842
843 function warn (condition, message) {
844 if (!condition) {
845 typeof console !== 'undefined' && console.warn(("[vue-router] " + message));
846 }
847 }
848
849 var View = {
850 name: 'router-view',
851 functional: true,
852 props: {
853 name: {
854 type: String,
855 default: 'default'
856 }
857 },
858 render: function render (h, ref) {
859 var props = ref.props;
860 var children = ref.children;
861 var parent = ref.parent;
862 var data = ref.data;
863
864 data.routerView = true;
865
866 var name = props.name;
867 var route = parent.$route;
868 var cache = parent._routerViewCache || (parent._routerViewCache = {});
869
870 // determine current view depth, also check to see if the tree
871 // has been toggled inactive but kept-alive.
872 var depth = 0;
873 var inactive = false;
874 while (parent) {
875 if (parent.$vnode && parent.$vnode.data.routerView) {
876 depth++;
877 }
878 if (parent._inactive) {
879 inactive = true;
880 }
881 parent = parent.$parent;
882 }
883 data.routerViewDepth = depth;
884
885 // render previous view if the tree is inactive and kept-alive
886 if (inactive) {
887 return h(cache[name], data, children)
888 }
889
890 var matched = route.matched[depth];
891 // render empty node if no matched route
892 if (!matched) {
893 cache[name] = null;
894 return h()
895 }
896
897 var component = cache[name] = matched.components[name];
898
899 // inject instance registration hooks
900 var hooks = data.hook || (data.hook = {});
901 hooks.init = function (vnode) {
902 matched.instances[name] = vnode.child;
903 };
904 hooks.prepatch = function (oldVnode, vnode) {
905 matched.instances[name] = vnode.child;
906 };
907 hooks.destroy = function (vnode) {
908 if (matched.instances[name] === vnode.child) {
909 matched.instances[name] = undefined;
910 }
911 };
912
913 // resolve props
914 data.props = resolveProps(route, matched.props && matched.props[name]);
915
916 return h(component, data, children)
917 }
918 };
919
920 function resolveProps (route, config) {
921 switch (typeof config) {
922 case 'undefined':
923 return
924 case 'object':
925 return config
926 case 'function':
927 return config(route)
928 case 'boolean':
929 return config ? route.params : undefined
930 default:
931 warn(false, ("props in \"" + (route.path) + "\" is a " + (typeof config) + ", expecting an object, function or boolean."));
932 }
933 }
934
935 /* */
936
937 var encodeReserveRE = /[!'()*]/g;
938 var encodeReserveReplacer = function (c) { return '%' + c.charCodeAt(0).toString(16); };
939 var commaRE = /%2C/g;
940
941 // fixed encodeURIComponent which is more comformant to RFC3986:
942 // - escapes [!'()*]
943 // - preserve commas
944 var encode = function (str) { return encodeURIComponent(str)
945 .replace(encodeReserveRE, encodeReserveReplacer)
946 .replace(commaRE, ','); };
947
948 var decode = decodeURIComponent;
949
950 function resolveQuery (
951 query,
952 extraQuery
953 ) {
954 if ( extraQuery === void 0 ) extraQuery = {};
955
956 if (query) {
957 var parsedQuery;
958 try {
959 parsedQuery = parseQuery(query);
960 } catch (e) {
961 "development" !== 'production' && warn(false, e.message);
962 parsedQuery = {};
963 }
964 for (var key in extraQuery) {
965 parsedQuery[key] = extraQuery[key];
966 }
967 return parsedQuery
968 } else {
969 return extraQuery
970 }
971 }
972
973 function parseQuery (query) {
974 var res = {};
975
976 query = query.trim().replace(/^(\?|#|&)/, '');
977
978 if (!query) {
979 return res
980 }
981
982 query.split('&').forEach(function (param) {
983 var parts = param.replace(/\+/g, ' ').split('=');
984 var key = decode(parts.shift());
985 var val = parts.length > 0
986 ? decode(parts.join('='))
987 : null;
988
989 if (res[key] === undefined) {
990 res[key] = val;
991 } else if (Array.isArray(res[key])) {
992 res[key].push(val);
993 } else {
994 res[key] = [res[key], val];
995 }
996 });
997
998 return res
999 }
1000
1001 function stringifyQuery (obj) {
1002 var res = obj ? Object.keys(obj).map(function (key) {
1003 var val = obj[key];
1004
1005 if (val === undefined) {
1006 return ''
1007 }
1008
1009 if (val === null) {
1010 return encode(key)
1011 }
1012
1013 if (Array.isArray(val)) {
1014 var result = [];
1015 val.slice().forEach(function (val2) {
1016 if (val2 === undefined) {
1017 return
1018 }
1019 if (val2 === null) {
1020 result.push(encode(key));
1021 } else {
1022 result.push(encode(key) + '=' + encode(val2));
1023 }
1024 });
1025 return result.join('&')
1026 }
1027
1028 return encode(key) + '=' + encode(val)
1029 }).filter(function (x) { return x.length > 0; }).join('&') : null;
1030 return res ? ("?" + res) : ''
1031 }
1032
1033 /* */
1034
1035 var trailingSlashRE = /\/?$/;
1036
1037 function createRoute (
1038 record,
1039 location,
1040 redirectedFrom
1041 ) {
1042 var route = {
1043 name: location.name || (record && record.name),
1044 meta: (record && record.meta) || {},
1045 path: location.path || '/',
1046 hash: location.hash || '',
1047 query: location.query || {},
1048 params: location.params || {},
1049 fullPath: getFullPath(location),
1050 matched: record ? formatMatch(record) : []
1051 };
1052 if (redirectedFrom) {
1053 route.redirectedFrom = getFullPath(redirectedFrom);
1054 }
1055 return Object.freeze(route)
1056 }
1057
1058 // the starting route that represents the initial state
1059 var START = createRoute(null, {
1060 path: '/'
1061 });
1062
1063 function formatMatch (record) {
1064 var res = [];
1065 while (record) {
1066 res.unshift(record);
1067 record = record.parent;
1068 }
1069 return res
1070 }
1071
1072 function getFullPath (ref) {
1073 var path = ref.path;
1074 var query = ref.query; if ( query === void 0 ) query = {};
1075 var hash = ref.hash; if ( hash === void 0 ) hash = '';
1076
1077 return (path || '/') + stringifyQuery(query) + hash
1078 }
1079
1080 function isSameRoute (a, b) {
1081 if (b === START) {
1082 return a === b
1083 } else if (!b) {
1084 return false
1085 } else if (a.path && b.path) {
1086 return (
1087 a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') &&
1088 a.hash === b.hash &&
1089 isObjectEqual(a.query, b.query)
1090 )
1091 } else if (a.name && b.name) {
1092 return (
1093 a.name === b.name &&
1094 a.hash === b.hash &&
1095 isObjectEqual(a.query, b.query) &&
1096 isObjectEqual(a.params, b.params)
1097 )
1098 } else {
1099 return false
1100 }
1101 }
1102
1103 function isObjectEqual (a, b) {
1104 if ( a === void 0 ) a = {};
1105 if ( b === void 0 ) b = {};
1106
1107 var aKeys = Object.keys(a);
1108 var bKeys = Object.keys(b);
1109 if (aKeys.length !== bKeys.length) {
1110 return false
1111 }
1112 return aKeys.every(function (key) { return String(a[key]) === String(b[key]); })
1113 }
1114
1115 function isIncludedRoute (current, target) {
1116 return (
1117 current.path.replace(trailingSlashRE, '/').indexOf(
1118 target.path.replace(trailingSlashRE, '/')
1119 ) === 0 &&
1120 (!target.hash || current.hash === target.hash) &&
1121 queryIncludes(current.query, target.query)
1122 )
1123 }
1124
1125 function queryIncludes (current, target) {
1126 for (var key in target) {
1127 if (!(key in current)) {
1128 return false
1129 }
1130 }
1131 return true
1132 }
1133
1134 /* */
1135
1136 // work around weird flow bug
1137 var toTypes = [String, Object];
1138 var eventTypes = [String, Array];
1139
1140 var Link = {
1141 name: 'router-link',
1142 props: {
1143 to: {
1144 type: toTypes,
1145 required: true
1146 },
1147 tag: {
1148 type: String,
1149 default: 'a'
1150 },
1151 exact: Boolean,
1152 append: Boolean,
1153 replace: Boolean,
1154 activeClass: String,
1155 event: {
1156 type: eventTypes,
1157 default: 'click'
1158 }
1159 },
1160 render: function render (h) {
1161 var this$1 = this;
1162
1163 var router = this.$router;
1164 var current = this.$route;
1165 var ref = router.resolve(this.to, current, this.append);
1166 var location = ref.location;
1167 var route = ref.route;
1168 var href = ref.href;
1169 var classes = {};
1170 var activeClass = this.activeClass || router.options.linkActiveClass || 'router-link-active';
1171 var compareTarget = location.path ? createRoute(null, location) : route;
1172 classes[activeClass] = this.exact
1173 ? isSameRoute(current, compareTarget)
1174 : isIncludedRoute(current, compareTarget);
1175
1176 var handler = function (e) {
1177 if (guardEvent(e)) {
1178 if (this$1.replace) {
1179 router.replace(location);
1180 } else {
1181 router.push(location);
1182 }
1183 }
1184 };
1185
1186 var on = { click: guardEvent };
1187 if (Array.isArray(this.event)) {
1188 this.event.forEach(function (e) { on[e] = handler; });
1189 } else {
1190 on[this.event] = handler;
1191 }
1192
1193 var data = {
1194 class: classes
1195 };
1196
1197 if (this.tag === 'a') {
1198 data.on = on;
1199 data.attrs = { href: href };
1200 } else {
1201 // find the first <a> child and apply listener and href
1202 var a = findAnchor(this.$slots.default);
1203 if (a) {
1204 // in case the <a> is a static node
1205 a.isStatic = false;
1206 var extend = _Vue.util.extend;
1207 var aData = a.data = extend({}, a.data);
1208 aData.on = on;
1209 var aAttrs = a.data.attrs = extend({}, a.data.attrs);
1210 aAttrs.href = href;
1211 } else {
1212 // doesn't have <a> child, apply listener to self
1213 data.on = on;
1214 }
1215 }
1216
1217 return h(this.tag, data, this.$slots.default)
1218 }
1219 };
1220
1221 function guardEvent (e) {
1222 // don't redirect with control keys
1223 if (e.metaKey || e.ctrlKey || e.shiftKey) { return }
1224 // don't redirect when preventDefault called
1225 if (e.defaultPrevented) { return }
1226 // don't redirect on right click
1227 if (e.button !== undefined && e.button !== 0) { return }
1228 // don't redirect if `target="_blank"`
1229 if (e.target && e.target.getAttribute) {
1230 var target = e.target.getAttribute('target');
1231 if (/\b_blank\b/i.test(target)) { return }
1232 }
1233 // this may be a Weex event which doesn't have this method
1234 if (e.preventDefault) {
1235 e.preventDefault();
1236 }
1237 return true
1238 }
1239
1240 function findAnchor (children) {
1241 if (children) {
1242 var child;
1243 for (var i = 0; i < children.length; i++) {
1244 child = children[i];
1245 if (child.tag === 'a') {
1246 return child
1247 }
1248 if (child.children && (child = findAnchor(child.children))) {
1249 return child
1250 }
1251 }
1252 }
1253 }
1254
1255 var _Vue;
1256
1257 function install (Vue) {
1258 if (install.installed) { return }
1259 install.installed = true;
1260
1261 _Vue = Vue;
1262
1263 Object.defineProperty(Vue.prototype, '$router', {
1264 get: function get () { return this.$root._router }
1265 });
1266
1267 Object.defineProperty(Vue.prototype, '$route', {
1268 get: function get () { return this.$root._route }
1269 });
1270
1271 Vue.mixin({
1272 beforeCreate: function beforeCreate () {
1273 if (this.$options.router) {
1274 this._router = this.$options.router;
1275 this._router.init(this);
1276 Vue.util.defineReactive(this, '_route', this._router.history.current);
1277 }
1278 }
1279 });
1280
1281 Vue.component('router-view', View);
1282 Vue.component('router-link', Link);
1283
1284 var strats = Vue.config.optionMergeStrategies;
1285 // use the same hook merging strategy for route hooks
1286 strats.beforeRouteEnter = strats.beforeRouteLeave = strats.created;
1287 }
1288
1289 /* */
1290
1291 var inBrowser = typeof window !== 'undefined';
1292
1293 /* */
1294
1295 function resolvePath (
1296 relative,
1297 base,
1298 append
1299 ) {
1300 if (relative.charAt(0) === '/') {
1301 return relative
1302 }
1303
1304 if (relative.charAt(0) === '?' || relative.charAt(0) === '#') {
1305 return base + relative
1306 }
1307
1308 var stack = base.split('/');
1309
1310 // remove trailing segment if:
1311 // - not appending
1312 // - appending to trailing slash (last segment is empty)
1313 if (!append || !stack[stack.length - 1]) {
1314 stack.pop();
1315 }
1316
1317 // resolve relative path
1318 var segments = relative.replace(/^\//, '').split('/');
1319 for (var i = 0; i < segments.length; i++) {
1320 var segment = segments[i];
1321 if (segment === '.') {
1322 continue
1323 } else if (segment === '..') {
1324 stack.pop();
1325 } else {
1326 stack.push(segment);
1327 }
1328 }
1329
1330 // ensure leading slash
1331 if (stack[0] !== '') {
1332 stack.unshift('');
1333 }
1334
1335 return stack.join('/')
1336 }
1337
1338 function parsePath (path) {
1339 var hash = '';
1340 var query = '';
1341
1342 var hashIndex = path.indexOf('#');
1343 if (hashIndex >= 0) {
1344 hash = path.slice(hashIndex);
1345 path = path.slice(0, hashIndex);
1346 }
1347
1348 var queryIndex = path.indexOf('?');
1349 if (queryIndex >= 0) {
1350 query = path.slice(queryIndex + 1);
1351 path = path.slice(0, queryIndex);
1352 }
1353
1354 return {
1355 path: path,
1356 query: query,
1357 hash: hash
1358 }
1359 }
1360
1361 function cleanPath (path) {
1362 return path.replace(/\/\//g, '/')
1363 }
1364
1365 /* */
1366
1367 function createRouteMap (
1368 routes,
1369 oldPathMap,
1370 oldNameMap
1371 ) {
1372 var pathMap = oldPathMap || Object.create(null);
1373 var nameMap = oldNameMap || Object.create(null);
1374
1375 routes.forEach(function (route) {
1376 addRouteRecord(pathMap, nameMap, route);
1377 });
1378
1379 return {
1380 pathMap: pathMap,
1381 nameMap: nameMap
1382 }
1383 }
1384
1385 function addRouteRecord (
1386 pathMap,
1387 nameMap,
1388 route,
1389 parent,
1390 matchAs
1391 ) {
1392 var path = route.path;
1393 var name = route.name;
1394 {
1395 assert(path != null, "\"path\" is required in a route configuration.");
1396 assert(
1397 typeof route.component !== 'string',
1398 "route config \"component\" for path: " + (String(path || name)) + " cannot be a " +
1399 "string id. Use an actual component instead."
1400 );
1401 }
1402
1403 var record = {
1404 path: normalizePath(path, parent),
1405 components: route.components || { default: route.component },
1406 instances: {},
1407 name: name,
1408 parent: parent,
1409 matchAs: matchAs,
1410 redirect: route.redirect,
1411 beforeEnter: route.beforeEnter,
1412 meta: route.meta || {},
1413 props: route.props == null
1414 ? {}
1415 : route.components
1416 ? route.props
1417 : { default: route.props }
1418 };
1419
1420 if (route.children) {
1421 // Warn if route is named and has a default child route.
1422 // If users navigate to this route by name, the default child will
1423 // not be rendered (GH Issue #629)
1424 {
1425 if (route.name && route.children.some(function (child) { return /^\/?$/.test(child.path); })) {
1426 warn(
1427 false,
1428 "Named Route '" + (route.name) + "' has a default child route. " +
1429 "When navigating to this named route (:to=\"{name: '" + (route.name) + "'\"), " +
1430 "the default child route will not be rendered. Remove the name from " +
1431 "this route and use the name of the default child route for named " +
1432 "links instead."
1433 );
1434 }
1435 }
1436 route.children.forEach(function (child) {
1437 var childMatchAs = matchAs
1438 ? cleanPath((matchAs + "/" + (child.path)))
1439 : undefined;
1440 addRouteRecord(pathMap, nameMap, child, record, childMatchAs);
1441 });
1442 }
1443
1444 if (route.alias !== undefined) {
1445 if (Array.isArray(route.alias)) {
1446 route.alias.forEach(function (alias) {
1447 var aliasRoute = {
1448 path: alias,
1449 children: route.children
1450 };
1451 addRouteRecord(pathMap, nameMap, aliasRoute, parent, record.path);
1452 });
1453 } else {
1454 var aliasRoute = {
1455 path: route.alias,
1456 children: route.children
1457 };
1458 addRouteRecord(pathMap, nameMap, aliasRoute, parent, record.path);
1459 }
1460 }
1461
1462 if (!pathMap[record.path]) {
1463 pathMap[record.path] = record;
1464 }
1465
1466 if (name) {
1467 if (!nameMap[name]) {
1468 nameMap[name] = record;
1469 } else if ("development" !== 'production' && !matchAs) {
1470 warn(
1471 false,
1472 "Duplicate named routes definition: " +
1473 "{ name: \"" + name + "\", path: \"" + (record.path) + "\" }"
1474 );
1475 }
1476 }
1477 }
1478
1479 function normalizePath (path, parent) {
1480 path = path.replace(/\/$/, '');
1481 if (path[0] === '/') { return path }
1482 if (parent == null) { return path }
1483 return cleanPath(((parent.path) + "/" + path))
1484 }
1485
1486 var index$1 = Array.isArray || function (arr) {
1487 return Object.prototype.toString.call(arr) == '[object Array]';
1488 };
1489
1490 var isarray = index$1;
1491
1492 /**
1493 * Expose `pathToRegexp`.
1494 */
1495 var index = pathToRegexp;
1496 var parse_1 = parse;
1497 var compile_1 = compile;
1498 var tokensToFunction_1 = tokensToFunction;
1499 var tokensToRegExp_1 = tokensToRegExp;
1500
1501 /**
1502 * The main path matching regexp utility.
1503 *
1504 * @type {RegExp}
1505 */
1506 var PATH_REGEXP = new RegExp([
1507 // Match escaped characters that would otherwise appear in future matches.
1508 // This allows the user to escape special characters that won't transform.
1509 '(\\\\.)',
1510 // Match Express-style parameters and un-named parameters with a prefix
1511 // and optional suffixes. Matches appear as:
1512 //
1513 // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
1514 // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
1515 // "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
1516 '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
1517 ].join('|'), 'g');
1518
1519 /**
1520 * Parse a string for the raw tokens.
1521 *
1522 * @param {string} str
1523 * @param {Object=} options
1524 * @return {!Array}
1525 */
1526 function parse (str, options) {
1527 var tokens = [];
1528 var key = 0;
1529 var index = 0;
1530 var path = '';
1531 var defaultDelimiter = options && options.delimiter || '/';
1532 var res;
1533
1534 while ((res = PATH_REGEXP.exec(str)) != null) {
1535 var m = res[0];
1536 var escaped = res[1];
1537 var offset = res.index;
1538 path += str.slice(index, offset);
1539 index = offset + m.length;
1540
1541 // Ignore already escaped sequences.
1542 if (escaped) {
1543 path += escaped[1];
1544 continue
1545 }
1546
1547 var next = str[index];
1548 var prefix = res[2];
1549 var name = res[3];
1550 var capture = res[4];
1551 var group = res[5];
1552 var modifier = res[6];
1553 var asterisk = res[7];
1554
1555 // Push the current path onto the tokens.
1556 if (path) {
1557 tokens.push(path);
1558 path = '';
1559 }
1560
1561 var partial = prefix != null && next != null && next !== prefix;
1562 var repeat = modifier === '+' || modifier === '*';
1563 var optional = modifier === '?' || modifier === '*';
1564 var delimiter = res[2] || defaultDelimiter;
1565 var pattern = capture || group;
1566
1567 tokens.push({
1568 name: name || key++,
1569 prefix: prefix || '',
1570 delimiter: delimiter,
1571 optional: optional,
1572 repeat: repeat,
1573 partial: partial,
1574 asterisk: !!asterisk,
1575 pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
1576 });
1577 }
1578
1579 // Match any characters still remaining.
1580 if (index < str.length) {
1581 path += str.substr(index);
1582 }
1583
1584 // If the path exists, push it onto the end.
1585 if (path) {
1586 tokens.push(path);
1587 }
1588
1589 return tokens
1590 }
1591
1592 /**
1593 * Compile a string to a template function for the path.
1594 *
1595 * @param {string} str
1596 * @param {Object=} options
1597 * @return {!function(Object=, Object=)}
1598 */
1599 function compile (str, options) {
1600 return tokensToFunction(parse(str, options))
1601 }
1602
1603 /**
1604 * Prettier encoding of URI path segments.
1605 *
1606 * @param {string}
1607 * @return {string}
1608 */
1609 function encodeURIComponentPretty (str) {
1610 return encodeURI(str).replace(/[\/?#]/g, function (c) {
1611 return '%' + c.charCodeAt(0).toString(16).toUpperCase()
1612 })
1613 }
1614
1615 /**
1616 * Encode the asterisk parameter. Similar to `pretty`, but allows slashes.
1617 *
1618 * @param {string}
1619 * @return {string}
1620 */
1621 function encodeAsterisk (str) {
1622 return encodeURI(str).replace(/[?#]/g, function (c) {
1623 return '%' + c.charCodeAt(0).toString(16).toUpperCase()
1624 })
1625 }
1626
1627 /**
1628 * Expose a method for transforming tokens into the path function.
1629 */
1630 function tokensToFunction (tokens) {
1631 // Compile all the tokens into regexps.
1632 var matches = new Array(tokens.length);
1633
1634 // Compile all the patterns before compilation.
1635 for (var i = 0; i < tokens.length; i++) {
1636 if (typeof tokens[i] === 'object') {
1637 matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$');
1638 }
1639 }
1640
1641 return function (obj, opts) {
1642 var path = '';
1643 var data = obj || {};
1644 var options = opts || {};
1645 var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent;
1646
1647 for (var i = 0; i < tokens.length; i++) {
1648 var token = tokens[i];
1649
1650 if (typeof token === 'string') {
1651 path += token;
1652
1653 continue
1654 }
1655
1656 var value = data[token.name];
1657 var segment;
1658
1659 if (value == null) {
1660 if (token.optional) {
1661 // Prepend partial segment prefixes.
1662 if (token.partial) {
1663 path += token.prefix;
1664 }
1665
1666 continue
1667 } else {
1668 throw new TypeError('Expected "' + token.name + '" to be defined')
1669 }
1670 }
1671
1672 if (isarray(value)) {
1673 if (!token.repeat) {
1674 throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`')
1675 }
1676
1677 if (value.length === 0) {
1678 if (token.optional) {
1679 continue
1680 } else {
1681 throw new TypeError('Expected "' + token.name + '" to not be empty')
1682 }
1683 }
1684
1685 for (var j = 0; j < value.length; j++) {
1686 segment = encode(value[j]);
1687
1688 if (!matches[i].test(segment)) {
1689 throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`')
1690 }
1691
1692 path += (j === 0 ? token.prefix : token.delimiter) + segment;
1693 }
1694
1695 continue
1696 }
1697
1698 segment = token.asterisk ? encodeAsterisk(value) : encode(value);
1699
1700 if (!matches[i].test(segment)) {
1701 throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"')
1702 }
1703
1704 path += token.prefix + segment;
1705 }
1706
1707 return path
1708 }
1709 }
1710
1711 /**
1712 * Escape a regular expression string.
1713 *
1714 * @param {string} str
1715 * @return {string}
1716 */
1717 function escapeString (str) {
1718 return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
1719 }
1720
1721 /**
1722 * Escape the capturing group by escaping special characters and meaning.
1723 *
1724 * @param {string} group
1725 * @return {string}
1726 */
1727 function escapeGroup (group) {
1728 return group.replace(/([=!:$\/()])/g, '\\$1')
1729 }
1730
1731 /**
1732 * Attach the keys as a property of the regexp.
1733 *
1734 * @param {!RegExp} re
1735 * @param {Array} keys
1736 * @return {!RegExp}
1737 */
1738 function attachKeys (re, keys) {
1739 re.keys = keys;
1740 return re
1741 }
1742
1743 /**
1744 * Get the flags for a regexp from the options.
1745 *
1746 * @param {Object} options
1747 * @return {string}
1748 */
1749 function flags (options) {
1750 return options.sensitive ? '' : 'i'
1751 }
1752
1753 /**
1754 * Pull out keys from a regexp.
1755 *
1756 * @param {!RegExp} path
1757 * @param {!Array} keys
1758 * @return {!RegExp}
1759 */
1760 function regexpToRegexp (path, keys) {
1761 // Use a negative lookahead to match only capturing groups.
1762 var groups = path.source.match(/\((?!\?)/g);
1763
1764 if (groups) {
1765 for (var i = 0; i < groups.length; i++) {
1766 keys.push({
1767 name: i,
1768 prefix: null,
1769 delimiter: null,
1770 optional: false,
1771 repeat: false,
1772 partial: false,
1773 asterisk: false,
1774 pattern: null
1775 });
1776 }
1777 }
1778
1779 return attachKeys(path, keys)
1780 }
1781
1782 /**
1783 * Transform an array into a regexp.
1784 *
1785 * @param {!Array} path
1786 * @param {Array} keys
1787 * @param {!Object} options
1788 * @return {!RegExp}
1789 */
1790 function arrayToRegexp (path, keys, options) {
1791 var parts = [];
1792
1793 for (var i = 0; i < path.length; i++) {
1794 parts.push(pathToRegexp(path[i], keys, options).source);
1795 }
1796
1797 var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
1798
1799 return attachKeys(regexp, keys)
1800 }
1801
1802 /**
1803 * Create a path regexp from string input.
1804 *
1805 * @param {string} path
1806 * @param {!Array} keys
1807 * @param {!Object} options
1808 * @return {!RegExp}
1809 */
1810 function stringToRegexp (path, keys, options) {
1811 return tokensToRegExp(parse(path, options), keys, options)
1812 }
1813
1814 /**
1815 * Expose a function for taking tokens and returning a RegExp.
1816 *
1817 * @param {!Array} tokens
1818 * @param {(Array|Object)=} keys
1819 * @param {Object=} options
1820 * @return {!RegExp}
1821 */
1822 function tokensToRegExp (tokens, keys, options) {
1823 if (!isarray(keys)) {
1824 options = /** @type {!Object} */ (keys || options);
1825 keys = [];
1826 }
1827
1828 options = options || {};
1829
1830 var strict = options.strict;
1831 var end = options.end !== false;
1832 var route = '';
1833
1834 // Iterate over the tokens and create our regexp string.
1835 for (var i = 0; i < tokens.length; i++) {
1836 var token = tokens[i];
1837
1838 if (typeof token === 'string') {
1839 route += escapeString(token);
1840 } else {
1841 var prefix = escapeString(token.prefix);
1842 var capture = '(?:' + token.pattern + ')';
1843
1844 keys.push(token);
1845
1846 if (token.repeat) {
1847 capture += '(?:' + prefix + capture + ')*';
1848 }
1849
1850 if (token.optional) {
1851 if (!token.partial) {
1852 capture = '(?:' + prefix + '(' + capture + '))?';
1853 } else {
1854 capture = prefix + '(' + capture + ')?';
1855 }
1856 } else {
1857 capture = prefix + '(' + capture + ')';
1858 }
1859
1860 route += capture;
1861 }
1862 }
1863
1864 var delimiter = escapeString(options.delimiter || '/');
1865 var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
1866
1867 // In non-strict mode we allow a slash at the end of match. If the path to
1868 // match already ends with a slash, we remove it for consistency. The slash
1869 // is valid at the end of a path match, not in the middle. This is important
1870 // in non-ending mode, where "/test/" shouldn't match "/test//route".
1871 if (!strict) {
1872 route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
1873 }
1874
1875 if (end) {
1876 route += '$';
1877 } else {
1878 // In non-ending mode, we need the capturing groups to match as much as
1879 // possible by using a positive lookahead to the end or next path segment.
1880 route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
1881 }
1882
1883 return attachKeys(new RegExp('^' + route, flags(options)), keys)
1884 }
1885
1886 /**
1887 * Normalize the given path string, returning a regular expression.
1888 *
1889 * An empty array can be passed in for the keys, which will hold the
1890 * placeholder key descriptions. For example, using `/user/:id`, `keys` will
1891 * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
1892 *
1893 * @param {(string|RegExp|Array)} path
1894 * @param {(Array|Object)=} keys
1895 * @param {Object=} options
1896 * @return {!RegExp}
1897 */
1898 function pathToRegexp (path, keys, options) {
1899 if (!isarray(keys)) {
1900 options = /** @type {!Object} */ (keys || options);
1901 keys = [];
1902 }
1903
1904 options = options || {};
1905
1906 if (path instanceof RegExp) {
1907 return regexpToRegexp(path, /** @type {!Array} */ (keys))
1908 }
1909
1910 if (isarray(path)) {
1911 return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options)
1912 }
1913
1914 return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)
1915 }
1916
1917 index.parse = parse_1;
1918 index.compile = compile_1;
1919 index.tokensToFunction = tokensToFunction_1;
1920 index.tokensToRegExp = tokensToRegExp_1;
1921
1922 /* */
1923
1924 var regexpCache = Object.create(null);
1925
1926 function getRouteRegex (path) {
1927 var hit = regexpCache[path];
1928 var keys, regexp;
1929
1930 if (hit) {
1931 keys = hit.keys;
1932 regexp = hit.regexp;
1933 } else {
1934 keys = [];
1935 regexp = index(path, keys);
1936 regexpCache[path] = { keys: keys, regexp: regexp };
1937 }
1938
1939 return { keys: keys, regexp: regexp }
1940 }
1941
1942 var regexpCompileCache = Object.create(null);
1943
1944 function fillParams (
1945 path,
1946 params,
1947 routeMsg
1948 ) {
1949 try {
1950 var filler =
1951 regexpCompileCache[path] ||
1952 (regexpCompileCache[path] = index.compile(path));
1953 return filler(params || {}, { pretty: true })
1954 } catch (e) {
1955 {
1956 warn(false, ("missing param for " + routeMsg + ": " + (e.message)));
1957 }
1958 return ''
1959 }
1960 }
1961
1962 /* */
1963
1964 function normalizeLocation (
1965 raw,
1966 current,
1967 append
1968 ) {
1969 var next = typeof raw === 'string' ? { path: raw } : raw;
1970 // named target
1971 if (next.name || next._normalized) {
1972 return next
1973 }
1974
1975 // relative params
1976 if (!next.path && next.params && current) {
1977 next = assign({}, next);
1978 next._normalized = true;
1979 var params = assign(assign({}, current.params), next.params);
1980 if (current.name) {
1981 next.name = current.name;
1982 next.params = params;
1983 } else if (current.matched) {
1984 var rawPath = current.matched[current.matched.length - 1].path;
1985 next.path = fillParams(rawPath, params, ("path " + (current.path)));
1986 } else {
1987 warn(false, "relative params navigation requires a current route.");
1988 }
1989 return next
1990 }
1991
1992 var parsedPath = parsePath(next.path || '');
1993 var basePath = (current && current.path) || '/';
1994 var path = parsedPath.path
1995 ? resolvePath(parsedPath.path, basePath, append || next.append)
1996 : (current && current.path) || '/';
1997 var query = resolveQuery(parsedPath.query, next.query);
1998 var hash = next.hash || parsedPath.hash;
1999 if (hash && hash.charAt(0) !== '#') {
2000 hash = "#" + hash;
2001 }
2002
2003 return {
2004 _normalized: true,
2005 path: path,
2006 query: query,
2007 hash: hash
2008 }
2009 }
2010
2011 function assign (a, b) {
2012 for (var key in b) {
2013 a[key] = b[key];
2014 }
2015 return a
2016 }
2017
2018 /* */
2019
2020 function createMatcher (routes) {
2021 var ref = createRouteMap(routes);
2022 var pathMap = ref.pathMap;
2023 var nameMap = ref.nameMap;
2024
2025 function addRoutes (routes) {
2026 createRouteMap(routes, pathMap, nameMap);
2027 }
2028
2029 function match (
2030 raw,
2031 currentRoute,
2032 redirectedFrom
2033 ) {
2034 var location = normalizeLocation(raw, currentRoute);
2035 var name = location.name;
2036
2037 if (name) {
2038 var record = nameMap[name];
2039 {
2040 warn(record, ("Route with name '" + name + "' does not exist"));
2041 }
2042 var paramNames = getRouteRegex(record.path).keys
2043 .filter(function (key) { return !key.optional; })
2044 .map(function (key) { return key.name; });
2045
2046 if (typeof location.params !== 'object') {
2047 location.params = {};
2048 }
2049
2050 if (currentRoute && typeof currentRoute.params === 'object') {
2051 for (var key in currentRoute.params) {
2052 if (!(key in location.params) && paramNames.indexOf(key) > -1) {
2053 location.params[key] = currentRoute.params[key];
2054 }
2055 }
2056 }
2057
2058 if (record) {
2059 location.path = fillParams(record.path, location.params, ("named route \"" + name + "\""));
2060 return _createRoute(record, location, redirectedFrom)
2061 }
2062 } else if (location.path) {
2063 location.params = {};
2064 for (var path in pathMap) {
2065 if (matchRoute(path, location.params, location.path)) {
2066 return _createRoute(pathMap[path], location, redirectedFrom)
2067 }
2068 }
2069 }
2070 // no match
2071 return _createRoute(null, location)
2072 }
2073
2074 function redirect (
2075 record,
2076 location
2077 ) {
2078 var originalRedirect = record.redirect;
2079 var redirect = typeof originalRedirect === 'function'
2080 ? originalRedirect(createRoute(record, location))
2081 : originalRedirect;
2082
2083 if (typeof redirect === 'string') {
2084 redirect = { path: redirect };
2085 }
2086
2087 if (!redirect || typeof redirect !== 'object') {
2088 "development" !== 'production' && warn(
2089 false, ("invalid redirect option: " + (JSON.stringify(redirect)))
2090 );
2091 return _createRoute(null, location)
2092 }
2093
2094 var re = redirect;
2095 var name = re.name;
2096 var path = re.path;
2097 var query = location.query;
2098 var hash = location.hash;
2099 var params = location.params;
2100 query = re.hasOwnProperty('query') ? re.query : query;
2101 hash = re.hasOwnProperty('hash') ? re.hash : hash;
2102 params = re.hasOwnProperty('params') ? re.params : params;
2103
2104 if (name) {
2105 // resolved named direct
2106 var targetRecord = nameMap[name];
2107 {
2108 assert(targetRecord, ("redirect failed: named route \"" + name + "\" not found."));
2109 }
2110 return match({
2111 _normalized: true,
2112 name: name,
2113 query: query,
2114 hash: hash,
2115 params: params
2116 }, undefined, location)
2117 } else if (path) {
2118 // 1. resolve relative redirect
2119 var rawPath = resolveRecordPath(path, record);
2120 // 2. resolve params
2121 var resolvedPath = fillParams(rawPath, params, ("redirect route with path \"" + rawPath + "\""));
2122 // 3. rematch with existing query and hash
2123 return match({
2124 _normalized: true,
2125 path: resolvedPath,
2126 query: query,
2127 hash: hash
2128 }, undefined, location)
2129 } else {
2130 warn(false, ("invalid redirect option: " + (JSON.stringify(redirect))));
2131 return _createRoute(null, location)
2132 }
2133 }
2134
2135 function alias (
2136 record,
2137 location,
2138 matchAs
2139 ) {
2140 var aliasedPath = fillParams(matchAs, location.params, ("aliased route with path \"" + matchAs + "\""));
2141 var aliasedMatch = match({
2142 _normalized: true,
2143 path: aliasedPath
2144 });
2145 if (aliasedMatch) {
2146 var matched = aliasedMatch.matched;
2147 var aliasedRecord = matched[matched.length - 1];
2148 location.params = aliasedMatch.params;
2149 return _createRoute(aliasedRecord, location)
2150 }
2151 return _createRoute(null, location)
2152 }
2153
2154 function _createRoute (
2155 record,
2156 location,
2157 redirectedFrom
2158 ) {
2159 if (record && record.redirect) {
2160 return redirect(record, redirectedFrom || location)
2161 }
2162 if (record && record.matchAs) {
2163 return alias(record, location, record.matchAs)
2164 }
2165 return createRoute(record, location, redirectedFrom)
2166 }
2167
2168 return {
2169 match: match,
2170 addRoutes: addRoutes
2171 }
2172 }
2173
2174 function matchRoute (
2175 path,
2176 params,
2177 pathname
2178 ) {
2179 var ref = getRouteRegex(path);
2180 var regexp = ref.regexp;
2181 var keys = ref.keys;
2182 var m = pathname.match(regexp);
2183
2184 if (!m) {
2185 return false
2186 } else if (!params) {
2187 return true
2188 }
2189
2190 for (var i = 1, len = m.length; i < len; ++i) {
2191 var key = keys[i - 1];
2192 var val = typeof m[i] === 'string' ? decodeURIComponent(m[i]) : m[i];
2193 if (key) { params[key.name] = val; }
2194 }
2195
2196 return true
2197 }
2198
2199 function resolveRecordPath (path, record) {
2200 return resolvePath(path, record.parent ? record.parent.path : '/', true)
2201 }
2202
2203 /* */
2204
2205
2206 var positionStore = Object.create(null);
2207
2208 function setupScroll () {
2209 window.addEventListener('popstate', function (e) {
2210 saveScrollPosition();
2211 if (e.state && e.state.key) {
2212 setStateKey(e.state.key);
2213 }
2214 });
2215 }
2216
2217 function handleScroll (
2218 router,
2219 to,
2220 from,
2221 isPop
2222 ) {
2223 if (!router.app) {
2224 return
2225 }
2226
2227 var behavior = router.options.scrollBehavior;
2228 if (!behavior) {
2229 return
2230 }
2231
2232 {
2233 assert(typeof behavior === 'function', "scrollBehavior must be a function");
2234 }
2235
2236 // wait until re-render finishes before scrolling
2237 router.app.$nextTick(function () {
2238 var position = getScrollPosition();
2239 var shouldScroll = behavior(to, from, isPop ? position : null);
2240 if (!shouldScroll) {
2241 return
2242 }
2243 var isObject = typeof shouldScroll === 'object';
2244 if (isObject && typeof shouldScroll.selector === 'string') {
2245 var el = document.querySelector(shouldScroll.selector);
2246 if (el) {
2247 position = getElementPosition(el);
2248 } else if (isValidPosition(shouldScroll)) {
2249 position = normalizePosition(shouldScroll);
2250 }
2251 } else if (isObject && isValidPosition(shouldScroll)) {
2252 position = normalizePosition(shouldScroll);
2253 }
2254
2255 if (position) {
2256 window.scrollTo(position.x, position.y);
2257 }
2258 });
2259 }
2260
2261 function saveScrollPosition () {
2262 var key = getStateKey();
2263 if (key) {
2264 positionStore[key] = {
2265 x: window.pageXOffset,
2266 y: window.pageYOffset
2267 };
2268 }
2269 }
2270
2271 function getScrollPosition () {
2272 var key = getStateKey();
2273 if (key) {
2274 return positionStore[key]
2275 }
2276 }
2277
2278 function getElementPosition (el) {
2279 var docEl = document.documentElement;
2280 var docRect = docEl.getBoundingClientRect();
2281 var elRect = el.getBoundingClientRect();
2282 return {
2283 x: elRect.left - docRect.left,
2284 y: elRect.top - docRect.top
2285 }
2286 }
2287
2288 function isValidPosition (obj) {
2289 return isNumber(obj.x) || isNumber(obj.y)
2290 }
2291
2292 function normalizePosition (obj) {
2293 return {
2294 x: isNumber(obj.x) ? obj.x : window.pageXOffset,
2295 y: isNumber(obj.y) ? obj.y : window.pageYOffset
2296 }
2297 }
2298
2299 function isNumber (v) {
2300 return typeof v === 'number'
2301 }
2302
2303 /* */
2304
2305 var supportsPushState = inBrowser && (function () {
2306 var ua = window.navigator.userAgent;
2307
2308 if (
2309 (ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
2310 ua.indexOf('Mobile Safari') !== -1 &&
2311 ua.indexOf('Chrome') === -1 &&
2312 ua.indexOf('Windows Phone') === -1
2313 ) {
2314 return false
2315 }
2316
2317 return window.history && 'pushState' in window.history
2318 })();
2319
2320 // use User Timing api (if present) for more accurate key precision
2321 var Time = inBrowser && window.performance && window.performance.now
2322 ? window.performance
2323 : Date;
2324
2325 var _key = genKey();
2326
2327 function genKey () {
2328 return Time.now().toFixed(3)
2329 }
2330
2331 function getStateKey () {
2332 return _key
2333 }
2334
2335 function setStateKey (key) {
2336 _key = key;
2337 }
2338
2339 function pushState (url, replace) {
2340 saveScrollPosition();
2341 // try...catch the pushState call to get around Safari
2342 // DOM Exception 18 where it limits to 100 pushState calls
2343 var history = window.history;
2344 try {
2345 if (replace) {
2346 history.replaceState({ key: _key }, '', url);
2347 } else {
2348 _key = genKey();
2349 history.pushState({ key: _key }, '', url);
2350 }
2351 } catch (e) {
2352 window.location[replace ? 'replace' : 'assign'](url);
2353 }
2354 }
2355
2356 function replaceState (url) {
2357 pushState(url, true);
2358 }
2359
2360 /* */
2361
2362 function runQueue (queue, fn, cb) {
2363 var step = function (index) {
2364 if (index >= queue.length) {
2365 cb();
2366 } else {
2367 if (queue[index]) {
2368 fn(queue[index], function () {
2369 step(index + 1);
2370 });
2371 } else {
2372 step(index + 1);
2373 }
2374 }
2375 };
2376 step(0);
2377 }
2378
2379 /* */
2380
2381
2382 var History = function History (router, base) {
2383 this.router = router;
2384 this.base = normalizeBase(base);
2385 // start with a route object that stands for "nowhere"
2386 this.current = START;
2387 this.pending = null;
2388 this.ready = false;
2389 this.readyCbs = [];
2390 };
2391
2392 History.prototype.listen = function listen (cb) {
2393 this.cb = cb;
2394 };
2395
2396 History.prototype.onReady = function onReady (cb) {
2397 if (this.ready) {
2398 cb();
2399 } else {
2400 this.readyCbs.push(cb);
2401 }
2402 };
2403
2404 History.prototype.transitionTo = function transitionTo (location, onComplete, onAbort) {
2405 var this$1 = this;
2406
2407 var route = this.router.match(location, this.current);
2408 this.confirmTransition(route, function () {
2409 this$1.updateRoute(route);
2410 onComplete && onComplete(route);
2411 this$1.ensureURL();
2412
2413 // fire ready cbs once
2414 if (!this$1.ready) {
2415 this$1.ready = true;
2416 this$1.readyCbs.forEach(function (cb) {
2417 cb(route);
2418 });
2419 }
2420 }, onAbort);
2421 };
2422
2423 History.prototype.confirmTransition = function confirmTransition (route, onComplete, onAbort) {
2424 var this$1 = this;
2425
2426 var current = this.current;
2427 var abort = function () { onAbort && onAbort(); };
2428 if (
2429 isSameRoute(route, current) &&
2430 // in the case the route map has been dynamically appended to
2431 route.matched.length === current.matched.length
2432 ) {
2433 this.ensureURL();
2434 return abort()
2435 }
2436
2437 var ref = resolveQueue(this.current.matched, route.matched);
2438 var updated = ref.updated;
2439 var deactivated = ref.deactivated;
2440 var activated = ref.activated;
2441
2442 var queue = [].concat(
2443 // in-component leave guards
2444 extractLeaveGuards(deactivated),
2445 // global before hooks
2446 this.router.beforeHooks,
2447 // in-component update hooks
2448 extractUpdateHooks(updated),
2449 // in-config enter guards
2450 activated.map(function (m) { return m.beforeEnter; }),
2451 // async components
2452 resolveAsyncComponents(activated)
2453 );
2454
2455 this.pending = route;
2456 var iterator = function (hook, next) {
2457 if (this$1.pending !== route) {
2458 return abort()
2459 }
2460 hook(route, current, function (to) {
2461 if (to === false) {
2462 // next(false) -> abort navigation, ensure current URL
2463 this$1.ensureURL(true);
2464 abort();
2465 } else if (typeof to === 'string' || typeof to === 'object') {
2466 // next('/') or next({ path: '/' }) -> redirect
2467 (typeof to === 'object' && to.replace) ? this$1.replace(to) : this$1.push(to);
2468 abort();
2469 } else {
2470 // confirm transition and pass on the value
2471 next(to);
2472 }
2473 });
2474 };
2475
2476 runQueue(queue, iterator, function () {
2477 var postEnterCbs = [];
2478 var isValid = function () { return this$1.current === route; };
2479 var enterGuards = extractEnterGuards(activated, postEnterCbs, isValid);
2480 // wait until async components are resolved before
2481 // extracting in-component enter guards
2482 runQueue(enterGuards, iterator, function () {
2483 if (this$1.pending !== route) {
2484 return abort()
2485 }
2486 this$1.pending = null;
2487 onComplete(route);
2488 if (this$1.router.app) {
2489 this$1.router.app.$nextTick(function () {
2490 postEnterCbs.forEach(function (cb) { return cb(); });
2491 });
2492 }
2493 });
2494 });
2495 };
2496
2497 History.prototype.updateRoute = function updateRoute (route) {
2498 var prev = this.current;
2499 this.current = route;
2500 this.cb && this.cb(route);
2501 this.router.afterHooks.forEach(function (hook) {
2502 hook && hook(route, prev);
2503 });
2504 };
2505
2506 function normalizeBase (base) {
2507 if (!base) {
2508 if (inBrowser) {
2509 // respect <base> tag
2510 var baseEl = document.querySelector('base');
2511 base = (baseEl && baseEl.getAttribute('href')) || '/';
2512 } else {
2513 base = '/';
2514 }
2515 }
2516 // make sure there's the starting slash
2517 if (base.charAt(0) !== '/') {
2518 base = '/' + base;
2519 }
2520 // remove trailing slash
2521 return base.replace(/\/$/, '')
2522 }
2523
2524 function resolveQueue (
2525 current,
2526 next
2527 ) {
2528 var i;
2529 var max = Math.max(current.length, next.length);
2530 for (i = 0; i < max; i++) {
2531 if (current[i] !== next[i]) {
2532 break
2533 }
2534 }
2535 return {
2536 updated: next.slice(0, i),
2537 activated: next.slice(i),
2538 deactivated: current.slice(i)
2539 }
2540 }
2541
2542 function extractGuards (
2543 records,
2544 name,
2545 bind,
2546 reverse
2547 ) {
2548 var guards = flatMapComponents(records, function (def, instance, match, key) {
2549 var guard = extractGuard(def, name);
2550 if (guard) {
2551 return Array.isArray(guard)
2552 ? guard.map(function (guard) { return bind(guard, instance, match, key); })
2553 : bind(guard, instance, match, key)
2554 }
2555 });
2556 return flatten(reverse ? guards.reverse() : guards)
2557 }
2558
2559 function extractGuard (
2560 def,
2561 key
2562 ) {
2563 if (typeof def !== 'function') {
2564 // extend now so that global mixins are applied.
2565 def = _Vue.extend(def);
2566 }
2567 return def.options[key]
2568 }
2569
2570 function extractLeaveGuards (deactivated) {
2571 return extractGuards(deactivated, 'beforeRouteLeave', bindGuard, true)
2572 }
2573
2574 function extractUpdateHooks (updated) {
2575 return extractGuards(updated, 'beforeRouteUpdate', bindGuard)
2576 }
2577
2578 function bindGuard (guard, instance) {
2579 return function boundRouteGuard () {
2580 return guard.apply(instance, arguments)
2581 }
2582 }
2583
2584 function extractEnterGuards (
2585 activated,
2586 cbs,
2587 isValid
2588 ) {
2589 return extractGuards(activated, 'beforeRouteEnter', function (guard, _, match, key) {
2590 return bindEnterGuard(guard, match, key, cbs, isValid)
2591 })
2592 }
2593
2594 function bindEnterGuard (
2595 guard,
2596 match,
2597 key,
2598 cbs,
2599 isValid
2600 ) {
2601 return function routeEnterGuard (to, from, next) {
2602 return guard(to, from, function (cb) {
2603 next(cb);
2604 if (typeof cb === 'function') {
2605 cbs.push(function () {
2606 // #750
2607 // if a router-view is wrapped with an out-in transition,
2608 // the instance may not have been registered at this time.
2609 // we will need to poll for registration until current route
2610 // is no longer valid.
2611 poll(cb, match.instances, key, isValid);
2612 });
2613 }
2614 })
2615 }
2616 }
2617
2618 function poll (
2619 cb, // somehow flow cannot infer this is a function
2620 instances,
2621 key,
2622 isValid
2623 ) {
2624 if (instances[key]) {
2625 cb(instances[key]);
2626 } else if (isValid()) {
2627 setTimeout(function () {
2628 poll(cb, instances, key, isValid);
2629 }, 16);
2630 }
2631 }
2632
2633 function resolveAsyncComponents (matched) {
2634 return flatMapComponents(matched, function (def, _, match, key) {
2635 // if it's a function and doesn't have Vue options attached,
2636 // assume it's an async component resolve function.
2637 // we are not using Vue's default async resolving mechanism because
2638 // we want to halt the navigation until the incoming component has been
2639 // resolved.
2640 if (typeof def === 'function' && !def.options) {
2641 return function (to, from, next) {
2642 var resolve = once(function (resolvedDef) {
2643 match.components[key] = resolvedDef;
2644 next();
2645 });
2646
2647 var reject = once(function (reason) {
2648 warn(false, ("Failed to resolve async component " + key + ": " + reason));
2649 next(false);
2650 });
2651
2652 var res = def(resolve, reject);
2653 if (res && typeof res.then === 'function') {
2654 res.then(resolve, reject);
2655 }
2656 }
2657 }
2658 })
2659 }
2660
2661 function flatMapComponents (
2662 matched,
2663 fn
2664 ) {
2665 return flatten(matched.map(function (m) {
2666 return Object.keys(m.components).map(function (key) { return fn(
2667 m.components[key],
2668 m.instances[key],
2669 m, key
2670 ); })
2671 }))
2672 }
2673
2674 function flatten (arr) {
2675 return Array.prototype.concat.apply([], arr)
2676 }
2677
2678 // in Webpack 2, require.ensure now also returns a Promise
2679 // so the resolve/reject functions may get called an extra time
2680 // if the user uses an arrow function shorthand that happens to
2681 // return that Promise.
2682 function once (fn) {
2683 var called = false;
2684 return function () {
2685 if (called) { return }
2686 called = true;
2687 return fn.apply(this, arguments)
2688 }
2689 }
2690
2691 /* */
2692
2693
2694 var HTML5History = (function (History$$1) {
2695 function HTML5History (router, base) {
2696 var this$1 = this;
2697
2698 History$$1.call(this, router, base);
2699
2700 var expectScroll = router.options.scrollBehavior;
2701
2702 if (expectScroll) {
2703 setupScroll();
2704 }
2705
2706 window.addEventListener('popstate', function (e) {
2707 this$1.transitionTo(getLocation(this$1.base), function (route) {
2708 if (expectScroll) {
2709 handleScroll(router, route, this$1.current, true);
2710 }
2711 });
2712 });
2713 }
2714
2715 if ( History$$1 ) HTML5History.__proto__ = History$$1;
2716 HTML5History.prototype = Object.create( History$$1 && History$$1.prototype );
2717 HTML5History.prototype.constructor = HTML5History;
2718
2719 HTML5History.prototype.go = function go (n) {
2720 window.history.go(n);
2721 };
2722
2723 HTML5History.prototype.push = function push (location, onComplete, onAbort) {
2724 var this$1 = this;
2725
2726 var ref = this;
2727 var fromRoute = ref.current;
2728 this.transitionTo(location, function (route) {
2729 pushState(cleanPath(this$1.base + route.fullPath));
2730 handleScroll(this$1.router, route, fromRoute, false);
2731 onComplete && onComplete(route);
2732 }, onAbort);
2733 };
2734
2735 HTML5History.prototype.replace = function replace (location, onComplete, onAbort) {
2736 var this$1 = this;
2737
2738 var ref = this;
2739 var fromRoute = ref.current;
2740 this.transitionTo(location, function (route) {
2741 replaceState(cleanPath(this$1.base + route.fullPath));
2742 handleScroll(this$1.router, route, fromRoute, false);
2743 onComplete && onComplete(route);
2744 }, onAbort);
2745 };
2746
2747 HTML5History.prototype.ensureURL = function ensureURL (push) {
2748 if (getLocation(this.base) !== this.current.fullPath) {
2749 var current = cleanPath(this.base + this.current.fullPath);
2750 push ? pushState(current) : replaceState(current);
2751 }
2752 };
2753
2754 HTML5History.prototype.getCurrentLocation = function getCurrentLocation () {
2755 return getLocation(this.base)
2756 };
2757
2758 return HTML5History;
2759 }(History));
2760
2761 function getLocation (base) {
2762 var path = window.location.pathname;
2763 if (base && path.indexOf(base) === 0) {
2764 path = path.slice(base.length);
2765 }
2766 return (path || '/') + window.location.search + window.location.hash
2767 }
2768
2769 /* */
2770
2771
2772 var HashHistory = (function (History$$1) {
2773 function HashHistory (router, base, fallback) {
2774 History$$1.call(this, router, base);
2775 // check history fallback deeplinking
2776 if (fallback && checkFallback(this.base)) {
2777 return
2778 }
2779 ensureSlash();
2780 }
2781
2782 if ( History$$1 ) HashHistory.__proto__ = History$$1;
2783 HashHistory.prototype = Object.create( History$$1 && History$$1.prototype );
2784 HashHistory.prototype.constructor = HashHistory;
2785
2786 // this is delayed until the app mounts
2787 // to avoid the hashchange listener being fired too early
2788 HashHistory.prototype.setupListeners = function setupListeners () {
2789 var this$1 = this;
2790
2791 window.addEventListener('hashchange', function () {
2792 if (!ensureSlash()) {
2793 return
2794 }
2795 this$1.transitionTo(getHash(), function (route) {
2796 replaceHash(route.fullPath);
2797 });
2798 });
2799 };
2800
2801 HashHistory.prototype.push = function push (location, onComplete, onAbort) {
2802 this.transitionTo(location, function (route) {
2803 pushHash(route.fullPath);
2804 onComplete && onComplete(route);
2805 }, onAbort);
2806 };
2807
2808 HashHistory.prototype.replace = function replace (location, onComplete, onAbort) {
2809 this.transitionTo(location, function (route) {
2810 replaceHash(route.fullPath);
2811 onComplete && onComplete(route);
2812 }, onAbort);
2813 };
2814
2815 HashHistory.prototype.go = function go (n) {
2816 window.history.go(n);
2817 };
2818
2819 HashHistory.prototype.ensureURL = function ensureURL (push) {
2820 var current = this.current.fullPath;
2821 if (getHash() !== current) {
2822 push ? pushHash(current) : replaceHash(current);
2823 }
2824 };
2825
2826 HashHistory.prototype.getCurrentLocation = function getCurrentLocation () {
2827 return getHash()
2828 };
2829
2830 return HashHistory;
2831 }(History));
2832
2833 function checkFallback (base) {
2834 var location = getLocation(base);
2835 if (!/^\/#/.test(location)) {
2836 window.location.replace(
2837 cleanPath(base + '/#' + location)
2838 );
2839 return true
2840 }
2841 }
2842
2843 function ensureSlash () {
2844 var path = getHash();
2845 if (path.charAt(0) === '/') {
2846 return true
2847 }
2848 replaceHash('/' + path);
2849 return false
2850 }
2851
2852 function getHash () {
2853 // We can't use window.location.hash here because it's not
2854 // consistent across browsers - Firefox will pre-decode it!
2855 var href = window.location.href;
2856 var index = href.indexOf('#');
2857 return index === -1 ? '' : href.slice(index + 1)
2858 }
2859
2860 function pushHash (path) {
2861 window.location.hash = path;
2862 }
2863
2864 function replaceHash (path) {
2865 var i = window.location.href.indexOf('#');
2866 window.location.replace(
2867 window.location.href.slice(0, i >= 0 ? i : 0) + '#' + path
2868 );
2869 }
2870
2871 /* */
2872
2873
2874 var AbstractHistory = (function (History$$1) {
2875 function AbstractHistory (router, base) {
2876 History$$1.call(this, router, base);
2877 this.stack = [];
2878 this.index = -1;
2879 }
2880
2881 if ( History$$1 ) AbstractHistory.__proto__ = History$$1;
2882 AbstractHistory.prototype = Object.create( History$$1 && History$$1.prototype );
2883 AbstractHistory.prototype.constructor = AbstractHistory;
2884
2885 AbstractHistory.prototype.push = function push (location, onComplete, onAbort) {
2886 var this$1 = this;
2887
2888 this.transitionTo(location, function (route) {
2889 this$1.stack = this$1.stack.slice(0, this$1.index + 1).concat(route);
2890 this$1.index++;
2891 onComplete && onComplete(route);
2892 }, onAbort);
2893 };
2894
2895 AbstractHistory.prototype.replace = function replace (location, onComplete, onAbort) {
2896 var this$1 = this;
2897
2898 this.transitionTo(location, function (route) {
2899 this$1.stack = this$1.stack.slice(0, this$1.index).concat(route);
2900 onComplete && onComplete(route);
2901 }, onAbort);
2902 };
2903
2904 AbstractHistory.prototype.go = function go (n) {
2905 var this$1 = this;
2906
2907 var targetIndex = this.index + n;
2908 if (targetIndex < 0 || targetIndex >= this.stack.length) {
2909 return
2910 }
2911 var route = this.stack[targetIndex];
2912 this.confirmTransition(route, function () {
2913 this$1.index = targetIndex;
2914 this$1.updateRoute(route);
2915 });
2916 };
2917
2918 AbstractHistory.prototype.getCurrentLocation = function getCurrentLocation () {
2919 var current = this.stack[this.stack.length - 1];
2920 return current ? current.fullPath : '/'
2921 };
2922
2923 AbstractHistory.prototype.ensureURL = function ensureURL () {
2924 // noop
2925 };
2926
2927 return AbstractHistory;
2928 }(History));
2929
2930 /* */
2931
2932 var VueRouter = function VueRouter (options) {
2933 if ( options === void 0 ) options = {};
2934
2935 this.app = null;
2936 this.apps = [];
2937 this.options = options;
2938 this.beforeHooks = [];
2939 this.afterHooks = [];
2940 this.matcher = createMatcher(options.routes || []);
2941
2942 var mode = options.mode || 'hash';
2943 this.fallback = mode === 'history' && !supportsPushState;
2944 if (this.fallback) {
2945 mode = 'hash';
2946 }
2947 if (!inBrowser) {
2948 mode = 'abstract';
2949 }
2950 this.mode = mode;
2951
2952 switch (mode) {
2953 case 'history':
2954 this.history = new HTML5History(this, options.base);
2955 break
2956 case 'hash':
2957 this.history = new HashHistory(this, options.base, this.fallback);
2958 break
2959 case 'abstract':
2960 this.history = new AbstractHistory(this, options.base);
2961 break
2962 default:
2963 {
2964 assert(false, ("invalid mode: " + mode));
2965 }
2966 }
2967 };
2968
2969 var prototypeAccessors = { currentRoute: {} };
2970
2971 VueRouter.prototype.match = function match (
2972 raw,
2973 current,
2974 redirectedFrom
2975 ) {
2976 return this.matcher.match(raw, current, redirectedFrom)
2977 };
2978
2979 prototypeAccessors.currentRoute.get = function () {
2980 return this.history && this.history.current
2981 };
2982
2983 VueRouter.prototype.init = function init (app /* Vue component instance */) {
2984 var this$1 = this;
2985
2986 "development" !== 'production' && assert(
2987 install.installed,
2988 "not installed. Make sure to call `Vue.use(VueRouter)` " +
2989 "before creating root instance."
2990 );
2991
2992 this.apps.push(app);
2993
2994 // main app already initialized.
2995 if (this.app) {
2996 return
2997 }
2998
2999 this.app = app;
3000
3001 var history = this.history;
3002
3003 if (history instanceof HTML5History) {
3004 history.transitionTo(history.getCurrentLocation());
3005 } else if (history instanceof HashHistory) {
3006 var setupHashListener = function () {
3007 history.setupListeners();
3008 };
3009 history.transitionTo(
3010 history.getCurrentLocation(),
3011 setupHashListener,
3012 setupHashListener
3013 );
3014 }
3015
3016 history.listen(function (route) {
3017 this$1.apps.forEach(function (app) {
3018 app._route = route;
3019 });
3020 });
3021 };
3022
3023 VueRouter.prototype.beforeEach = function beforeEach (fn) {
3024 this.beforeHooks.push(fn);
3025 };
3026
3027 VueRouter.prototype.afterEach = function afterEach (fn) {
3028 this.afterHooks.push(fn);
3029 };
3030
3031 VueRouter.prototype.onReady = function onReady (cb) {
3032 this.history.onReady(cb);
3033 };
3034
3035 VueRouter.prototype.push = function push (location, onComplete, onAbort) {
3036 this.history.push(location, onComplete, onAbort);
3037 };
3038
3039 VueRouter.prototype.replace = function replace (location, onComplete, onAbort) {
3040 this.history.replace(location, onComplete, onAbort);
3041 };
3042
3043 VueRouter.prototype.go = function go (n) {
3044 this.history.go(n);
3045 };
3046
3047 VueRouter.prototype.back = function back () {
3048 this.go(-1);
3049 };
3050
3051 VueRouter.prototype.forward = function forward () {
3052 this.go(1);
3053 };
3054
3055 VueRouter.prototype.getMatchedComponents = function getMatchedComponents (to) {
3056 var route = to
3057 ? this.resolve(to).route
3058 : this.currentRoute;
3059 if (!route) {
3060 return []
3061 }
3062 return [].concat.apply([], route.matched.map(function (m) {
3063 return Object.keys(m.components).map(function (key) {
3064 return m.components[key]
3065 })
3066 }))
3067 };
3068
3069 VueRouter.prototype.resolve = function resolve (
3070 to,
3071 current,
3072 append
3073 ) {
3074 var location = normalizeLocation(to, current || this.history.current, append);
3075 var route = this.match(location, current);
3076 var fullPath = route.redirectedFrom || route.fullPath;
3077 var base = this.history.base;
3078 var href = createHref(base, fullPath, this.mode);
3079 return {
3080 location: location,
3081 route: route,
3082 href: href,
3083 // for backwards compat
3084 normalizedTo: location,
3085 resolved: route
3086 }
3087 };
3088
3089 VueRouter.prototype.addRoutes = function addRoutes (routes) {
3090 this.matcher.addRoutes(routes);
3091 if (this.history.current !== START) {
3092 this.history.transitionTo(this.history.getCurrentLocation());
3093 }
3094 };
3095
3096 Object.defineProperties( VueRouter.prototype, prototypeAccessors );
3097
3098 function createHref (base, fullPath, mode) {
3099 var path = mode === 'hash' ? '#' + fullPath : fullPath;
3100 return base ? cleanPath(base + '/' + path) : path
3101 }
3102
3103 VueRouter.install = install;
3104 VueRouter.version = '2.3.1';
3105
3106 if (inBrowser && window.Vue) {
3107 window.Vue.use(VueRouter);
3108 }
3109
3110 return VueRouter;
3111
3112 })));
3113
3114 /* assets/js/vendor/nprogress.js */
3115 /* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress
3116 * @license MIT */
3117
3118 ;(function(root, factory) {
3119
3120 if (typeof define === 'function' && define.amd) {
3121 define(factory);
3122 } else if (typeof exports === 'object') {
3123 module.exports = factory();
3124 } else {
3125 root.NProgress = factory();
3126 }
3127
3128 })(this, function() {
3129 var NProgress = {};
3130
3131 NProgress.version = '0.2.0';
3132
3133 var Settings = NProgress.settings = {
3134 minimum: 0.08,
3135 easing: 'linear',
3136 positionUsing: '',
3137 speed: 200,
3138 trickle: true,
3139 trickleSpeed: 200,
3140 showSpinner: true,
3141 barSelector: '[role="bar"]',
3142 spinnerSelector: '[role="spinner"]',
3143 parent: 'body',
3144 template: '<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'
3145 };
3146
3147 /**
3148 * Updates configuration.
3149 *
3150 * NProgress.configure({
3151 * minimum: 0.1
3152 * });
3153 */
3154 NProgress.configure = function(options) {
3155 var key, value;
3156 for (key in options) {
3157 value = options[key];
3158 if (value !== undefined && options.hasOwnProperty(key)) Settings[key] = value;
3159 }
3160
3161 return this;
3162 };
3163
3164 /**
3165 * Last number.
3166 */
3167
3168 NProgress.status = null;
3169
3170 /**
3171 * Sets the progress bar status, where `n` is a number from `0.0` to `1.0`.
3172 *
3173 * NProgress.set(0.4);
3174 * NProgress.set(1.0);
3175 */
3176
3177 NProgress.set = function(n) {
3178 var started = NProgress.isStarted();
3179
3180 n = clamp(n, Settings.minimum, 1);
3181 NProgress.status = (n === 1 ? null : n);
3182
3183 var progress = NProgress.render(!started),
3184 bar = progress.querySelector(Settings.barSelector),
3185 speed = Settings.speed,
3186 ease = Settings.easing;
3187
3188 progress.offsetWidth; /* Repaint */
3189
3190 queue(function(next) {
3191 // Set positionUsing if it hasn't already been set
3192 if (Settings.positionUsing === '') Settings.positionUsing = NProgress.getPositioningCSS();
3193
3194 // Add transition
3195 css(bar, barPositionCSS(n, speed, ease));
3196
3197 if (n === 1) {
3198 // Fade out
3199 css(progress, {
3200 transition: 'none',
3201 opacity: 1
3202 });
3203 progress.offsetWidth; /* Repaint */
3204
3205 setTimeout(function() {
3206 css(progress, {
3207 transition: 'all ' + speed + 'ms linear',
3208 opacity: 0
3209 });
3210 setTimeout(function() {
3211 NProgress.remove();
3212 next();
3213 }, speed);
3214 }, speed);
3215 } else {
3216 setTimeout(next, speed);
3217 }
3218 });
3219
3220 return this;
3221 };
3222
3223 NProgress.isStarted = function() {
3224 return typeof NProgress.status === 'number';
3225 };
3226
3227 /**
3228 * Shows the progress bar.
3229 * This is the same as setting the status to 0%, except that it doesn't go backwards.
3230 *
3231 * NProgress.start();
3232 *
3233 */
3234 NProgress.start = function() {
3235 if (!NProgress.status) NProgress.set(0);
3236
3237 var work = function() {
3238 setTimeout(function() {
3239 if (!NProgress.status) return;
3240 NProgress.trickle();
3241 work();
3242 }, Settings.trickleSpeed);
3243 };
3244
3245 if (Settings.trickle) work();
3246
3247 return this;
3248 };
3249
3250 /**
3251 * Hides the progress bar.
3252 * This is the *sort of* the same as setting the status to 100%, with the
3253 * difference being `done()` makes some placebo effect of some realistic motion.
3254 *
3255 * NProgress.done();
3256 *
3257 * If `true` is passed, it will show the progress bar even if its hidden.
3258 *
3259 * NProgress.done(true);
3260 */
3261
3262 NProgress.done = function(force) {
3263 if (!force && !NProgress.status) return this;
3264
3265 return NProgress.inc(0.3 + 0.5 * Math.random()).set(1);
3266 };
3267
3268 /**
3269 * Increments by a random amount.
3270 */
3271
3272 NProgress.inc = function(amount) {
3273 var n = NProgress.status;
3274
3275 if (!n) {
3276 return NProgress.start();
3277 } else if(n > 1) {
3278 return;
3279 } else {
3280 if (typeof amount !== 'number') {
3281 if (n >= 0 && n < 0.2) { amount = 0.1; }
3282 else if (n >= 0.2 && n < 0.5) { amount = 0.04; }
3283 else if (n >= 0.5 && n < 0.8) { amount = 0.02; }
3284 else if (n >= 0.8 && n < 0.99) { amount = 0.005; }
3285 else { amount = 0; }
3286 }
3287
3288 n = clamp(n + amount, 0, 0.994);
3289 return NProgress.set(n);
3290 }
3291 };
3292
3293 NProgress.trickle = function() {
3294 return NProgress.inc();
3295 };
3296
3297 /**
3298 * Waits for all supplied jQuery promises and
3299 * increases the progress as the promises resolve.
3300 *
3301 * @param $promise jQUery Promise
3302 */
3303 (function() {
3304 var initial = 0, current = 0;
3305
3306 NProgress.promise = function($promise) {
3307 if (!$promise || $promise.state() === "resolved") {
3308 return this;
3309 }
3310
3311 if (current === 0) {
3312 NProgress.start();
3313 }
3314
3315 initial++;
3316 current++;
3317
3318 $promise.always(function() {
3319 current--;
3320 if (current === 0) {
3321 initial = 0;
3322 NProgress.done();
3323 } else {
3324 NProgress.set((initial - current) / initial);
3325 }
3326 });
3327
3328 return this;
3329 };
3330
3331 })();
3332
3333 /**
3334 * (Internal) renders the progress bar markup based on the `template`
3335 * setting.
3336 */
3337
3338 NProgress.render = function(fromStart) {
3339 if (NProgress.isRendered()) return document.getElementById('nprogress');
3340
3341 addClass(document.documentElement, 'nprogress-busy');
3342
3343 var progress = document.createElement('div');
3344 progress.id = 'nprogress';
3345 progress.innerHTML = Settings.template;
3346
3347 var bar = progress.querySelector(Settings.barSelector),
3348 perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0),
3349 parent = document.querySelector(Settings.parent),
3350 spinner;
3351
3352 css(bar, {
3353 transition: 'all 0 linear',
3354 transform: 'translate3d(' + perc + '%,0,0)'
3355 });
3356
3357 if (!Settings.showSpinner) {
3358 spinner = progress.querySelector(Settings.spinnerSelector);
3359 spinner && removeElement(spinner);
3360 }
3361
3362 if (parent != document.body) {
3363 addClass(parent, 'nprogress-custom-parent');
3364 }
3365
3366 parent.appendChild(progress);
3367 return progress;
3368 };
3369
3370 /**
3371 * Removes the element. Opposite of render().
3372 */
3373
3374 NProgress.remove = function() {
3375 removeClass(document.documentElement, 'nprogress-busy');
3376 removeClass(document.querySelector(Settings.parent), 'nprogress-custom-parent');
3377 var progress = document.getElementById('nprogress');
3378 progress && removeElement(progress);
3379 };
3380
3381 /**
3382 * Checks if the progress bar is rendered.
3383 */
3384
3385 NProgress.isRendered = function() {
3386 return !!document.getElementById('nprogress');
3387 };
3388
3389 /**
3390 * Determine which positioning CSS rule to use.
3391 */
3392
3393 NProgress.getPositioningCSS = function() {
3394 // Sniff on document.body.style
3395 var bodyStyle = document.body.style;
3396
3397 // Sniff prefixes
3398 var vendorPrefix = ('WebkitTransform' in bodyStyle) ? 'Webkit' :
3399 ('MozTransform' in bodyStyle) ? 'Moz' :
3400 ('msTransform' in bodyStyle) ? 'ms' :
3401 ('OTransform' in bodyStyle) ? 'O' : '';
3402
3403 if (vendorPrefix + 'Perspective' in bodyStyle) {
3404 // Modern browsers with 3D support, e.g. Webkit, IE10
3405 return 'translate3d';
3406 } else if (vendorPrefix + 'Transform' in bodyStyle) {
3407 // Browsers without 3D support, e.g. IE9
3408 return 'translate';
3409 } else {
3410 // Browsers without translate() support, e.g. IE7-8
3411 return 'margin';
3412 }
3413 };
3414
3415 /**
3416 * Helpers
3417 */
3418
3419 function clamp(n, min, max) {
3420 if (n < min) return min;
3421 if (n > max) return max;
3422 return n;
3423 }
3424
3425 /**
3426 * (Internal) converts a percentage (`0..1`) to a bar translateX
3427 * percentage (`-100%..0%`).
3428 */
3429
3430 function toBarPerc(n) {
3431 return (-1 + n) * 100;
3432 }
3433
3434
3435 /**
3436 * (Internal) returns the correct CSS for changing the bar's
3437 * position given an n percentage, and speed and ease from Settings
3438 */
3439
3440 function barPositionCSS(n, speed, ease) {
3441 var barCSS;
3442
3443 if (Settings.positionUsing === 'translate3d') {
3444 barCSS = { transform: 'translate3d('+toBarPerc(n)+'%,0,0)' };
3445 } else if (Settings.positionUsing === 'translate') {
3446 barCSS = { transform: 'translate('+toBarPerc(n)+'%,0)' };
3447 } else {
3448 barCSS = { 'margin-left': toBarPerc(n)+'%' };
3449 }
3450
3451 barCSS.transition = 'all '+speed+'ms '+ease;
3452
3453 return barCSS;
3454 }
3455
3456 /**
3457 * (Internal) Queues a function to be executed.
3458 */
3459
3460 var queue = (function() {
3461 var pending = [];
3462
3463 function next() {
3464 var fn = pending.shift();
3465 if (fn) {
3466 fn(next);
3467 }
3468 }
3469
3470 return function(fn) {
3471 pending.push(fn);
3472 if (pending.length == 1) next();
3473 };
3474 })();
3475
3476 /**
3477 * (Internal) Applies css properties to an element, similar to the jQuery
3478 * css method.
3479 *
3480 * While this helper does assist with vendor prefixed property names, it
3481 * does not perform any manipulation of values prior to setting styles.
3482 */
3483
3484 var css = (function() {
3485 var cssPrefixes = [ 'Webkit', 'O', 'Moz', 'ms' ],
3486 cssProps = {};
3487
3488 function camelCase(string) {
3489 return string.replace(/^-ms-/, 'ms-').replace(/-([\da-z])/gi, function(match, letter) {
3490 return letter.toUpperCase();
3491 });
3492 }
3493
3494 function getVendorProp(name) {
3495 var style = document.body.style;
3496 if (name in style) return name;
3497
3498 var i = cssPrefixes.length,
3499 capName = name.charAt(0).toUpperCase() + name.slice(1),
3500 vendorName;
3501 while (i--) {
3502 vendorName = cssPrefixes[i] + capName;
3503 if (vendorName in style) return vendorName;
3504 }
3505
3506 return name;
3507 }
3508
3509 function getStyleProp(name) {
3510 name = camelCase(name);
3511 return cssProps[name] || (cssProps[name] = getVendorProp(name));
3512 }
3513
3514 function applyCss(element, prop, value) {
3515 prop = getStyleProp(prop);
3516 element.style[prop] = value;
3517 }
3518
3519 return function(element, properties) {
3520 var args = arguments,
3521 prop,
3522 value;
3523
3524 if (args.length == 2) {
3525 for (prop in properties) {
3526 value = properties[prop];
3527 if (value !== undefined && properties.hasOwnProperty(prop)) applyCss(element, prop, value);
3528 }
3529 } else {
3530 applyCss(element, args[1], args[2]);
3531 }
3532 }
3533 })();
3534
3535 /**
3536 * (Internal) Determines if an element or space separated list of class names contains a class name.
3537 */
3538
3539 function hasClass(element, name) {
3540 var list = typeof element == 'string' ? element : classList(element);
3541 return list.indexOf(' ' + name + ' ') >= 0;
3542 }
3543
3544 /**
3545 * (Internal) Adds a class to an element.
3546 */
3547
3548 function addClass(element, name) {
3549 var oldList = classList(element),
3550 newList = oldList + name;
3551
3552 if (hasClass(oldList, name)) return;
3553
3554 // Trim the opening space.
3555 element.className = newList.substring(1);
3556 }
3557
3558 /**
3559 * (Internal) Removes a class from an element.
3560 */
3561
3562 function removeClass(element, name) {
3563 var oldList = classList(element),
3564 newList;
3565
3566 if (!hasClass(element, name)) return;
3567
3568 // Replace the class name.
3569 newList = oldList.replace(' ' + name + ' ', ' ');
3570
3571 // Trim the opening and closing spaces.
3572 element.className = newList.substring(1, newList.length - 1);
3573 }
3574
3575 /**
3576 * (Internal) Gets a space separated list of the class names on the element.
3577 * The list is wrapped with a single space on each end to facilitate finding
3578 * matches within the list.
3579 */
3580
3581 function classList(element) {
3582 return (' ' + (element && element.className || '') + ' ').replace(/\s+/gi, ' ');
3583 }
3584
3585 /**
3586 * (Internal) Removes an element from the DOM.
3587 */
3588
3589 function removeElement(element) {
3590 element && element.parentNode && element.parentNode.removeChild(element);
3591 }
3592
3593 return NProgress;
3594 });
3595
3596 /* assets/wpuf/js/jquery-ui-timepicker-addon.js */
3597 /*
3598 * jQuery timepicker addon
3599 * By: Trent Richardson [http://trentrichardson.com]
3600 * Version 1.2
3601 * Last Modified: 02/02/2013
3602 *
3603 * Copyright 2013 Trent Richardson
3604 * You may use this project under MIT or GPL licenses.
3605 * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
3606 * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
3607 */
3608
3609 /*jslint evil: true, white: false, undef: false, nomen: false */
3610
3611 (function($) {
3612
3613 /*
3614 * Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded"
3615 */
3616 $.ui.timepicker = $.ui.timepicker || {};
3617 if ($.ui.timepicker.version) {
3618 return;
3619 }
3620
3621 /*
3622 * Extend jQueryUI, get it started with our version number
3623 */
3624 $.extend($.ui, {
3625 timepicker: {
3626 version: "1.2"
3627 }
3628 });
3629
3630 /*
3631 * Timepicker manager.
3632 * Use the singleton instance of this class, $.timepicker, to interact with the time picker.
3633 * Settings for (groups of) time pickers are maintained in an instance object,
3634 * allowing multiple different settings on the same page.
3635 */
3636 var Timepicker = function() {
3637 this.regional = []; // Available regional settings, indexed by language code
3638 this.regional[''] = { // Default regional settings
3639 currentText: 'Now',
3640 closeText: 'Done',
3641 amNames: ['AM', 'A'],
3642 pmNames: ['PM', 'P'],
3643 timeFormat: 'HH:mm',
3644 timeSuffix: '',
3645 timeOnlyTitle: 'Choose Time',
3646 timeText: 'Time',
3647 hourText: 'Hour',
3648 minuteText: 'Minute',
3649 secondText: 'Second',
3650 millisecText: 'Millisecond',
3651 timezoneText: 'Time Zone',
3652 isRTL: false
3653 };
3654 this._defaults = { // Global defaults for all the datetime picker instances
3655 showButtonPanel: true,
3656 timeOnly: false,
3657 showHour: true,
3658 showMinute: true,
3659 showSecond: false,
3660 showMillisec: false,
3661 showTimezone: false,
3662 showTime: true,
3663 stepHour: 1,
3664 stepMinute: 1,
3665 stepSecond: 1,
3666 stepMillisec: 1,
3667 hour: 0,
3668 minute: 0,
3669 second: 0,
3670 millisec: 0,
3671 timezone: null,
3672 useLocalTimezone: false,
3673 defaultTimezone: "+0000",
3674 hourMin: 0,
3675 minuteMin: 0,
3676 secondMin: 0,
3677 millisecMin: 0,
3678 hourMax: 23,
3679 minuteMax: 59,
3680 secondMax: 59,
3681 millisecMax: 999,
3682 minDateTime: null,
3683 maxDateTime: null,
3684 onSelect: null,
3685 hourGrid: 0,
3686 minuteGrid: 0,
3687 secondGrid: 0,
3688 millisecGrid: 0,
3689 alwaysSetTime: true,
3690 separator: ' ',
3691 altFieldTimeOnly: true,
3692 altTimeFormat: null,
3693 altSeparator: null,
3694 altTimeSuffix: null,
3695 pickerTimeFormat: null,
3696 pickerTimeSuffix: null,
3697 showTimepicker: true,
3698 timezoneIso8601: false,
3699 timezoneList: null,
3700 addSliderAccess: false,
3701 sliderAccessArgs: null,
3702 controlType: 'slider',
3703 defaultValue: null,
3704 parse: 'strict'
3705 };
3706 $.extend(this._defaults, this.regional['']);
3707 };
3708
3709 $.extend(Timepicker.prototype, {
3710 $input: null,
3711 $altInput: null,
3712 $timeObj: null,
3713 inst: null,
3714 hour_slider: null,
3715 minute_slider: null,
3716 second_slider: null,
3717 millisec_slider: null,
3718 timezone_select: null,
3719 hour: 0,
3720 minute: 0,
3721 second: 0,
3722 millisec: 0,
3723 timezone: null,
3724 defaultTimezone: "+0000",
3725 hourMinOriginal: null,
3726 minuteMinOriginal: null,
3727 secondMinOriginal: null,
3728 millisecMinOriginal: null,
3729 hourMaxOriginal: null,
3730 minuteMaxOriginal: null,
3731 secondMaxOriginal: null,
3732 millisecMaxOriginal: null,
3733 ampm: '',
3734 formattedDate: '',
3735 formattedTime: '',
3736 formattedDateTime: '',
3737 timezoneList: null,
3738 units: ['hour','minute','second','millisec'],
3739 control: null,
3740
3741 /*
3742 * Override the default settings for all instances of the time picker.
3743 * @param settings object - the new settings to use as defaults (anonymous object)
3744 * @return the manager object
3745 */
3746 setDefaults: function(settings) {
3747 extendRemove(this._defaults, settings || {});
3748 return this;
3749 },
3750
3751 /*
3752 * Create a new Timepicker instance
3753 */
3754 _newInst: function($input, o) {
3755 var tp_inst = new Timepicker(),
3756 inlineSettings = {},
3757 fns = {},
3758 overrides, i;
3759
3760 for (var attrName in this._defaults) {
3761 if(this._defaults.hasOwnProperty(attrName)){
3762 var attrValue = $input.attr('time:' + attrName);
3763 if (attrValue) {
3764 try {
3765 inlineSettings[attrName] = eval(attrValue);
3766 } catch (err) {
3767 inlineSettings[attrName] = attrValue;
3768 }
3769 }
3770 }
3771 }
3772 overrides = {
3773 beforeShow: function (input, dp_inst) {
3774 if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) {
3775 return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst);
3776 }
3777 },
3778 onChangeMonthYear: function (year, month, dp_inst) {
3779 // Update the time as well : this prevents the time from disappearing from the $input field.
3780 tp_inst._updateDateTime(dp_inst);
3781 if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) {
3782 tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
3783 }
3784 },
3785 onClose: function (dateText, dp_inst) {
3786 if (tp_inst.timeDefined === true && $input.val() !== '') {
3787 tp_inst._updateDateTime(dp_inst);
3788 }
3789 if ($.isFunction(tp_inst._defaults.evnts.onClose)) {
3790 tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst);
3791 }
3792 }
3793 };
3794 for (i in overrides) {
3795 if (overrides.hasOwnProperty(i)) {
3796 fns[i] = o[i] || null;
3797 }
3798 }
3799 tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, overrides, {
3800 evnts:fns,
3801 timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
3802 });
3803 tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) {
3804 return val.toUpperCase();
3805 });
3806 tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) {
3807 return val.toUpperCase();
3808 });
3809
3810 // controlType is string - key to our this._controls
3811 if(typeof(tp_inst._defaults.controlType) === 'string'){
3812 if($.fn[tp_inst._defaults.controlType] === undefined){
3813 tp_inst._defaults.controlType = 'select';
3814 }
3815 tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType];
3816 }
3817 // controlType is an object and must implement create, options, value methods
3818 else{
3819 tp_inst.control = tp_inst._defaults.controlType;
3820 }
3821
3822 if (tp_inst._defaults.timezoneList === null) {
3823 var timezoneList = ['-1200', '-1100', '-1000', '-0930', '-0900', '-0800', '-0700', '-0600', '-0500', '-0430', '-0400', '-0330', '-0300', '-0200', '-0100', '+0000',
3824 '+0100', '+0200', '+0300', '+0330', '+0400', '+0430', '+0500', '+0530', '+0545', '+0600', '+0630', '+0700', '+0800', '+0845', '+0900', '+0930',
3825 '+1000', '+1030', '+1100', '+1130', '+1200', '+1245', '+1300', '+1400'];
3826
3827 if (tp_inst._defaults.timezoneIso8601) {
3828 timezoneList = $.map(timezoneList, function(val) {
3829 return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3));
3830 });
3831 }
3832 tp_inst._defaults.timezoneList = timezoneList;
3833 }
3834
3835 tp_inst.timezone = tp_inst._defaults.timezone;
3836 tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin? tp_inst._defaults.hourMin :
3837 tp_inst._defaults.hour > tp_inst._defaults.hourMax? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
3838 tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin? tp_inst._defaults.minuteMin :
3839 tp_inst._defaults.minute > tp_inst._defaults.minuteMax? tp_inst._defaults.minuteMax : tp_inst._defaults.minute;
3840 tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin? tp_inst._defaults.secondMin :
3841 tp_inst._defaults.second > tp_inst._defaults.secondMax? tp_inst._defaults.secondMax : tp_inst._defaults.second;
3842 tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin? tp_inst._defaults.millisecMin :
3843 tp_inst._defaults.millisec > tp_inst._defaults.millisecMax? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec;
3844 tp_inst.ampm = '';
3845 tp_inst.$input = $input;
3846
3847 if (o.altField) {
3848 tp_inst.$altInput = $(o.altField).css({
3849 cursor: 'pointer'
3850 }).focus(function() {
3851 $input.trigger("focus");
3852 });
3853 }
3854
3855 if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) {
3856 tp_inst._defaults.minDate = new Date();
3857 }
3858 if (tp_inst._defaults.maxDate === 0 || tp_inst._defaults.maxDateTime === 0) {
3859 tp_inst._defaults.maxDate = new Date();
3860 }
3861
3862 // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
3863 if (tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) {
3864 tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
3865 }
3866 if (tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) {
3867 tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
3868 }
3869 if (tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) {
3870 tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
3871 }
3872 if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) {
3873 tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
3874 }
3875 tp_inst.$input.bind('focus', function() {
3876 tp_inst._onFocus();
3877 });
3878
3879 return tp_inst;
3880 },
3881
3882 /*
3883 * add our sliders to the calendar
3884 */
3885 _addTimePicker: function(dp_inst) {
3886 var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val();
3887
3888 this.timeDefined = this._parseTime(currDT);
3889 this._limitMinMaxDateTime(dp_inst, false);
3890 this._injectTimePicker();
3891 },
3892
3893 /*
3894 * parse the time string from input value or _setTime
3895 */
3896 _parseTime: function(timeString, withDate) {
3897 if (!this.inst) {
3898 this.inst = $.datepicker._getInst(this.$input[0]);
3899 }
3900
3901 if (withDate || !this._defaults.timeOnly) {
3902 var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
3903 try {
3904 var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults);
3905 if (!parseRes.timeObj) {
3906 return false;
3907 }
3908 $.extend(this, parseRes.timeObj);
3909 } catch (err) {
3910 $.timepicker.log("Error parsing the date/time string: " + err +
3911 "\ndate/time string = " + timeString +
3912 "\ntimeFormat = " + this._defaults.timeFormat +
3913 "\ndateFormat = " + dp_dateFormat);
3914 return false;
3915 }
3916 return true;
3917 } else {
3918 var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults);
3919 if (!timeObj) {
3920 return false;
3921 }
3922 $.extend(this, timeObj);
3923 return true;
3924 }
3925 },
3926
3927 /*
3928 * generate and inject html for timepicker into ui datepicker
3929 */
3930 _injectTimePicker: function() {
3931 var $dp = this.inst.dpDiv,
3932 o = this.inst.settings,
3933 tp_inst = this,
3934 litem = '',
3935 uitem = '',
3936 max = {},
3937 gridSize = {},
3938 size = null;
3939
3940 // Prevent displaying twice
3941 if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
3942 var noDisplay = ' style="display:none;"',
3943 html = '<div class="ui-timepicker-div'+ (o.isRTL? ' ui-timepicker-rtl' : '') +'"><dl>' + '<dt class="ui_tpicker_time_label"' + ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
3944 '<dd class="ui_tpicker_time"' + ((o.showTime) ? '' : noDisplay) + '></dd>';
3945
3946 // Create the markup
3947 for(var i=0,l=this.units.length; i<l; i++){
3948 litem = this.units[i];
3949 uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
3950 // Added by Peter Medeiros:
3951 // - Figure out what the hour/minute/second max should be based on the step values.
3952 // - Example: if stepMinute is 15, then minMax is 45.
3953 max[litem] = parseInt((o[litem+'Max'] - ((o[litem+'Max'] - o[litem+'Min']) % o['step'+uitem])), 10);
3954 gridSize[litem] = 0;
3955
3956 html += '<dt class="ui_tpicker_'+ litem +'_label"' + ((o['show'+uitem]) ? '' : noDisplay) + '>' + o[litem +'Text'] + '</dt>' +
3957 '<dd class="ui_tpicker_'+ litem +'"><div class="ui_tpicker_'+ litem +'_slider"' + ((o['show'+uitem]) ? '' : noDisplay) + '></div>';
3958
3959 if (o['show'+uitem] && o[litem+'Grid'] > 0) {
3960 html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
3961
3962 if(litem == 'hour'){
3963 for (var h = o[litem+'Min']; h <= max[litem]; h += parseInt(o[litem+'Grid'], 10)) {
3964 gridSize[litem]++;
3965 var tmph = $.datepicker.formatTime(useAmpm(o.pickerTimeFormat || o.timeFormat)? 'hht':'HH', {hour:h}, o);
3966 html += '<td data-for="'+litem+'">' + tmph + '</td>';
3967 }
3968 }
3969 else{
3970 for (var m = o[litem+'Min']; m <= max[litem]; m += parseInt(o[litem+'Grid'], 10)) {
3971 gridSize[litem]++;
3972 html += '<td data-for="'+litem+'">' + ((m < 10) ? '0' : '') + m + '</td>';
3973 }
3974 }
3975
3976 html += '</tr></table></div>';
3977 }
3978 html += '</dd>';
3979 }
3980
3981 // Timezone
3982 html += '<dt class="ui_tpicker_timezone_label"' + ((o.showTimezone) ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
3983 html += '<dd class="ui_tpicker_timezone" ' + ((o.showTimezone) ? '' : noDisplay) + '></dd>';
3984
3985 // Create the elements from string
3986 html += '</dl></div>';
3987 var $tp = $(html);
3988
3989 // if we only want time picker...
3990 if (o.timeOnly === true) {
3991 $tp.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' + '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' + '</div>');
3992 $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
3993 }
3994
3995 // add sliders, adjust grids, add events
3996 for(var i=0,l=tp_inst.units.length; i<l; i++){
3997 litem = tp_inst.units[i];
3998 uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
3999
4000 // add the slider
4001 tp_inst[litem+'_slider'] = tp_inst.control.create(tp_inst, $tp.find('.ui_tpicker_'+litem+'_slider'), litem, tp_inst[litem], o[litem+'Min'], max[litem], o['step'+uitem]);
4002
4003 // adjust the grid and add click event
4004 if (o['show'+uitem] && o[litem+'Grid'] > 0) {
4005 size = 100 * gridSize[litem] * o[litem+'Grid'] / (max[litem] - o[litem+'Min']);
4006 $tp.find('.ui_tpicker_'+litem+' table').css({
4007 width: size + "%",
4008 marginLeft: o.isRTL? '0' : ((size / (-2 * gridSize[litem])) + "%"),
4009 marginRight: o.isRTL? ((size / (-2 * gridSize[litem])) + "%") : '0',
4010 borderCollapse: 'collapse'
4011 }).find("td").click(function(e){
4012 var $t = $(this),
4013 h = $t.html(),
4014 n = parseInt(h.replace(/[^0-9]/g),10),
4015 ap = h.replace(/[^apm]/ig),
4016 f = $t.data('for'); // loses scope, so we use data-for
4017
4018 if(f == 'hour'){
4019 if(ap.indexOf('p') !== -1 && n < 12){
4020 n += 12;
4021 }
4022 else{
4023 if(ap.indexOf('a') !== -1 && n === 12){
4024 n = 0;
4025 }
4026 }
4027 }
4028
4029 tp_inst.control.value(tp_inst, tp_inst[f+'_slider'], litem, n);
4030
4031 tp_inst._onTimeChange();
4032 tp_inst._onSelectHandler();
4033 })
4034 .css({
4035 cursor: 'pointer',
4036 width: (100 / gridSize[litem]) + '%',
4037 textAlign: 'center',
4038 overflow: 'hidden'
4039 });
4040 } // end if grid > 0
4041 } // end for loop
4042
4043 // Add timezone options
4044 this.timezone_select = $tp.find('.ui_tpicker_timezone').append('<select></select>').find("select");
4045 $.fn.append.apply(this.timezone_select,
4046 $.map(o.timezoneList, function(val, idx) {
4047 return $("<option />").val(typeof val == "object" ? val.value : val).text(typeof val == "object" ? val.label : val);
4048 }));
4049 if (typeof(this.timezone) != "undefined" && this.timezone !== null && this.timezone !== "") {
4050 var local_date = new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12);
4051 var local_timezone = $.timepicker.timeZoneOffsetString(local_date);
4052 if (local_timezone == this.timezone) {
4053 selectLocalTimeZone(tp_inst);
4054 } else {
4055 this.timezone_select.val(this.timezone);
4056 }
4057 } else {
4058 if (typeof(this.hour) != "undefined" && this.hour !== null && this.hour !== "") {
4059 this.timezone_select.val(o.defaultTimezone);
4060 } else {
4061 selectLocalTimeZone(tp_inst);
4062 }
4063 }
4064 this.timezone_select.change(function() {
4065 tp_inst._defaults.useLocalTimezone = false;
4066 tp_inst._onTimeChange();
4067 tp_inst._onSelectHandler();
4068 });
4069 // End timezone options
4070
4071 // inject timepicker into datepicker
4072 var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
4073 if ($buttonPanel.length) {
4074 $buttonPanel.before($tp);
4075 } else {
4076 $dp.append($tp);
4077 }
4078
4079 this.$timeObj = $tp.find('.ui_tpicker_time');
4080
4081 if (this.inst !== null) {
4082 var timeDefined = this.timeDefined;
4083 this._onTimeChange();
4084 this.timeDefined = timeDefined;
4085 }
4086
4087 // slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
4088 if (this._defaults.addSliderAccess) {
4089 var sliderAccessArgs = this._defaults.sliderAccessArgs,
4090 rtl = this._defaults.isRTL;
4091 sliderAccessArgs.isRTL = rtl;
4092
4093 setTimeout(function() { // fix for inline mode
4094 if ($tp.find('.ui-slider-access').length === 0) {
4095 $tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
4096
4097 // fix any grids since sliders are shorter
4098 var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
4099 if (sliderAccessWidth) {
4100 $tp.find('table:visible').each(function() {
4101 var $g = $(this),
4102 oldWidth = $g.outerWidth(),
4103 oldMarginLeft = $g.css(rtl? 'marginRight':'marginLeft').toString().replace('%', ''),
4104 newWidth = oldWidth - sliderAccessWidth,
4105 newMarginLeft = ((oldMarginLeft * newWidth) / oldWidth) + '%',
4106 css = { width: newWidth, marginRight: 0, marginLeft: 0 };
4107 css[rtl? 'marginRight':'marginLeft'] = newMarginLeft;
4108 $g.css(css);
4109 });
4110 }
4111 }
4112 }, 10);
4113 }
4114 // end slideAccess integration
4115
4116 }
4117 },
4118
4119 /*
4120 * This function tries to limit the ability to go outside the
4121 * min/max date range
4122 */
4123 _limitMinMaxDateTime: function(dp_inst, adjustSliders) {
4124 var o = this._defaults,
4125 dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
4126
4127 if (!this._defaults.showTimepicker) {
4128 return;
4129 } // No time so nothing to check here
4130
4131 if ($.datepicker._get(dp_inst, 'minDateTime') !== null && $.datepicker._get(dp_inst, 'minDateTime') !== undefined && dp_date) {
4132 var minDateTime = $.datepicker._get(dp_inst, 'minDateTime'),
4133 minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
4134
4135 if (this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null) {
4136 this.hourMinOriginal = o.hourMin;
4137 this.minuteMinOriginal = o.minuteMin;
4138 this.secondMinOriginal = o.secondMin;
4139 this.millisecMinOriginal = o.millisecMin;
4140 }
4141
4142 if (dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
4143 this._defaults.hourMin = minDateTime.getHours();
4144 if (this.hour <= this._defaults.hourMin) {
4145 this.hour = this._defaults.hourMin;
4146 this._defaults.minuteMin = minDateTime.getMinutes();
4147 if (this.minute <= this._defaults.minuteMin) {
4148 this.minute = this._defaults.minuteMin;
4149 this._defaults.secondMin = minDateTime.getSeconds();
4150 if (this.second <= this._defaults.secondMin) {
4151 this.second = this._defaults.secondMin;
4152 this._defaults.millisecMin = minDateTime.getMilliseconds();
4153 } else {
4154 if (this.millisec < this._defaults.millisecMin) {
4155 this.millisec = this._defaults.millisecMin;
4156 }
4157 this._defaults.millisecMin = this.millisecMinOriginal;
4158 }
4159 } else {
4160 this._defaults.secondMin = this.secondMinOriginal;
4161 this._defaults.millisecMin = this.millisecMinOriginal;
4162 }
4163 } else {
4164 this._defaults.minuteMin = this.minuteMinOriginal;
4165 this._defaults.secondMin = this.secondMinOriginal;
4166 this._defaults.millisecMin = this.millisecMinOriginal;
4167 }
4168 } else {
4169 this._defaults.hourMin = this.hourMinOriginal;
4170 this._defaults.minuteMin = this.minuteMinOriginal;
4171 this._defaults.secondMin = this.secondMinOriginal;
4172 this._defaults.millisecMin = this.millisecMinOriginal;
4173 }
4174 }
4175
4176 if ($.datepicker._get(dp_inst, 'maxDateTime') !== null && $.datepicker._get(dp_inst, 'maxDateTime') !== undefined && dp_date) {
4177 var maxDateTime = $.datepicker._get(dp_inst, 'maxDateTime'),
4178 maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
4179
4180 if (this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null) {
4181 this.hourMaxOriginal = o.hourMax;
4182 this.minuteMaxOriginal = o.minuteMax;
4183 this.secondMaxOriginal = o.secondMax;
4184 this.millisecMaxOriginal = o.millisecMax;
4185 }
4186
4187 if (dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()) {
4188 this._defaults.hourMax = maxDateTime.getHours();
4189 if (this.hour >= this._defaults.hourMax) {
4190 this.hour = this._defaults.hourMax;
4191 this._defaults.minuteMax = maxDateTime.getMinutes();
4192 if (this.minute >= this._defaults.minuteMax) {
4193 this.minute = this._defaults.minuteMax;
4194 this._defaults.secondMax = maxDateTime.getSeconds();
4195 if (this.second >= this._defaults.secondMax) {
4196 this.second = this._defaults.secondMax;
4197 this._defaults.millisecMax = maxDateTime.getMilliseconds();
4198 } else {
4199 if (this.millisec > this._defaults.millisecMax) {
4200 this.millisec = this._defaults.millisecMax;
4201 }
4202 this._defaults.millisecMax = this.millisecMaxOriginal;
4203 }
4204 } else {
4205 this._defaults.secondMax = this.secondMaxOriginal;
4206 this._defaults.millisecMax = this.millisecMaxOriginal;
4207 }
4208 } else {
4209 this._defaults.minuteMax = this.minuteMaxOriginal;
4210 this._defaults.secondMax = this.secondMaxOriginal;
4211 this._defaults.millisecMax = this.millisecMaxOriginal;
4212 }
4213 } else {
4214 this._defaults.hourMax = this.hourMaxOriginal;
4215 this._defaults.minuteMax = this.minuteMaxOriginal;
4216 this._defaults.secondMax = this.secondMaxOriginal;
4217 this._defaults.millisecMax = this.millisecMaxOriginal;
4218 }
4219 }
4220
4221 if (adjustSliders !== undefined && adjustSliders === true) {
4222 var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
4223 minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
4224 secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)), 10),
4225 millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10);
4226
4227 if (this.hour_slider) {
4228 this.control.options(this, this.hour_slider, 'hour', { min: this._defaults.hourMin, max: hourMax });
4229 this.control.value(this, this.hour_slider, 'hour', this.hour - (this.hour % this._defaults.stepHour));
4230 }
4231 if (this.minute_slider) {
4232 this.control.options(this, this.minute_slider, 'minute', { min: this._defaults.minuteMin, max: minMax });
4233 this.control.value(this, this.minute_slider, 'minute', this.minute - (this.minute % this._defaults.stepMinute));
4234 }
4235 if (this.second_slider) {
4236 this.control.options(this, this.second_slider, 'second', { min: this._defaults.secondMin, max: secMax });
4237 this.control.value(this, this.second_slider, 'second', this.second - (this.second % this._defaults.stepSecond));
4238 }
4239 if (this.millisec_slider) {
4240 this.control.options(this, this.millisec_slider, 'millisec', { min: this._defaults.millisecMin, max: millisecMax });
4241 this.control.value(this, this.millisec_slider, 'millisec', this.millisec - (this.millisec % this._defaults.stepMillisec));
4242 }
4243 }
4244
4245 },
4246
4247 /*
4248 * when a slider moves, set the internal time...
4249 * on time change is also called when the time is updated in the text field
4250 */
4251 _onTimeChange: function() {
4252 var hour = (this.hour_slider) ? this.control.value(this, this.hour_slider, 'hour') : false,
4253 minute = (this.minute_slider) ? this.control.value(this, this.minute_slider, 'minute') : false,
4254 second = (this.second_slider) ? this.control.value(this, this.second_slider, 'second') : false,
4255 millisec = (this.millisec_slider) ? this.control.value(this, this.millisec_slider, 'millisec') : false,
4256 timezone = (this.timezone_select) ? this.timezone_select.val() : false,
4257 o = this._defaults,
4258 pickerTimeFormat = o.pickerTimeFormat || o.timeFormat,
4259 pickerTimeSuffix = o.pickerTimeSuffix || o.timeSuffix;
4260
4261 if (typeof(hour) == 'object') {
4262 hour = false;
4263 }
4264 if (typeof(minute) == 'object') {
4265 minute = false;
4266 }
4267 if (typeof(second) == 'object') {
4268 second = false;
4269 }
4270 if (typeof(millisec) == 'object') {
4271 millisec = false;
4272 }
4273 if (typeof(timezone) == 'object') {
4274 timezone = false;
4275 }
4276
4277 if (hour !== false) {
4278 hour = parseInt(hour, 10);
4279 }
4280 if (minute !== false) {
4281 minute = parseInt(minute, 10);
4282 }
4283 if (second !== false) {
4284 second = parseInt(second, 10);
4285 }
4286 if (millisec !== false) {
4287 millisec = parseInt(millisec, 10);
4288 }
4289
4290 var ampm = o[hour < 12 ? 'amNames' : 'pmNames'][0];
4291
4292 // If the update was done in the input field, the input field should not be updated.
4293 // If the update was done using the sliders, update the input field.
4294 var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || millisec != this.millisec
4295 || (this.ampm.length > 0 && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
4296 || ((this.timezone === null && timezone != this.defaultTimezone) || (this.timezone !== null && timezone != this.timezone)));
4297
4298 if (hasChanged) {
4299
4300 if (hour !== false) {
4301 this.hour = hour;
4302 }
4303 if (minute !== false) {
4304 this.minute = minute;
4305 }
4306 if (second !== false) {
4307 this.second = second;
4308 }
4309 if (millisec !== false) {
4310 this.millisec = millisec;
4311 }
4312 if (timezone !== false) {
4313 this.timezone = timezone;
4314 }
4315
4316 if (!this.inst) {
4317 this.inst = $.datepicker._getInst(this.$input[0]);
4318 }
4319
4320 this._limitMinMaxDateTime(this.inst, true);
4321 }
4322 if (useAmpm(o.timeFormat)) {
4323 this.ampm = ampm;
4324 }
4325
4326 // Updates the time within the timepicker
4327 this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o);
4328 if (this.$timeObj) {
4329 if(pickerTimeFormat === o.timeFormat){
4330 this.$timeObj.text(this.formattedTime + pickerTimeSuffix);
4331 }
4332 else{
4333 this.$timeObj.text($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix);
4334 }
4335 }
4336
4337 this.timeDefined = true;
4338 if (hasChanged) {
4339 this._updateDateTime();
4340 }
4341 },
4342
4343 /*
4344 * call custom onSelect.
4345 * bind to sliders slidestop, and grid click.
4346 */
4347 _onSelectHandler: function() {
4348 var onSelect = this._defaults.onSelect || this.inst.settings.onSelect;
4349 var inputEl = this.$input ? this.$input[0] : null;
4350 if (onSelect && inputEl) {
4351 onSelect.apply(inputEl, [this.formattedDateTime, this]);
4352 }
4353 },
4354
4355 /*
4356 * update our input with the new date time..
4357 */
4358 _updateDateTime: function(dp_inst) {
4359 dp_inst = this.inst || dp_inst;
4360 var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
4361 dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
4362 formatCfg = $.datepicker._getFormatConfig(dp_inst),
4363 timeAvailable = dt !== null && this.timeDefined;
4364 this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
4365 var formattedDateTime = this.formattedDate;
4366
4367 // if a slider was changed but datepicker doesn't have a value yet, set it
4368 if(dp_inst.lastVal==""){
4369 dp_inst.currentYear=dp_inst.selectedYear;
4370 dp_inst.currentMonth=dp_inst.selectedMonth;
4371 dp_inst.currentDay=dp_inst.selectedDay;
4372 }
4373
4374 /*
4375 * remove following lines to force every changes in date picker to change the input value
4376 * Bug descriptions: when an input field has a default value, and click on the field to pop up the date picker.
4377 * If the user manually empty the value in the input field, the date picker will never change selected value.
4378 */
4379 //if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0)) {
4380 // return;
4381 //}
4382
4383 if (this._defaults.timeOnly === true) {
4384 formattedDateTime = this.formattedTime;
4385 } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
4386 formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
4387 }
4388
4389 this.formattedDateTime = formattedDateTime;
4390
4391 if (!this._defaults.showTimepicker) {
4392 this.$input.val(this.formattedDate);
4393 } else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
4394 this.$altInput.val(this.formattedTime);
4395 this.$input.val(this.formattedDate);
4396 } else if (this.$altInput) {
4397 this.$input.val(formattedDateTime);
4398 var altFormattedDateTime = '',
4399 altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator,
4400 altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
4401
4402 if (this._defaults.altFormat) altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
4403 else altFormattedDateTime = this.formattedDate;
4404 if (altFormattedDateTime) altFormattedDateTime += altSeparator;
4405 if (this._defaults.altTimeFormat) altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
4406 else altFormattedDateTime += this.formattedTime + altTimeSuffix;
4407 this.$altInput.val(altFormattedDateTime);
4408 } else {
4409 this.$input.val(formattedDateTime);
4410 }
4411
4412 this.$input.trigger("change");
4413 },
4414
4415 _onFocus: function() {
4416 if (!this.$input.val() && this._defaults.defaultValue) {
4417 this.$input.val(this._defaults.defaultValue);
4418 var inst = $.datepicker._getInst(this.$input.get(0)),
4419 tp_inst = $.datepicker._get(inst, 'timepicker');
4420 if (tp_inst) {
4421 if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
4422 try {
4423 $.datepicker._updateDatepicker(inst);
4424 } catch (err) {
4425 $.timepicker.log(err);
4426 }
4427 }
4428 }
4429 }
4430 },
4431
4432 /*
4433 * Small abstraction to control types
4434 * We can add more, just be sure to follow the pattern: create, options, value
4435 */
4436 _controls: {
4437 // slider methods
4438 slider: {
4439 create: function(tp_inst, obj, unit, val, min, max, step){
4440 var rtl = tp_inst._defaults.isRTL; // if rtl go -60->0 instead of 0->60
4441 return obj.prop('slide', null).slider({
4442 orientation: "horizontal",
4443 value: rtl? val*-1 : val,
4444 min: rtl? max*-1 : min,
4445 max: rtl? min*-1 : max,
4446 step: step,
4447 slide: function(event, ui) {
4448 tp_inst.control.value(tp_inst, $(this), unit, rtl? ui.value*-1:ui.value);
4449 tp_inst._onTimeChange();
4450 },
4451 stop: function(event, ui) {
4452 tp_inst._onSelectHandler();
4453 }
4454 });
4455 },
4456 options: function(tp_inst, obj, unit, opts, val){
4457 if(tp_inst._defaults.isRTL){
4458 if(typeof(opts) == 'string'){
4459 if(opts == 'min' || opts == 'max'){
4460 if(val !== undefined)
4461 return obj.slider(opts, val*-1);
4462 return Math.abs(obj.slider(opts));
4463 }
4464 return obj.slider(opts);
4465 }
4466 var min = opts.min,
4467 max = opts.max;
4468 opts.min = opts.max = null;
4469 if(min !== undefined)
4470 opts.max = min * -1;
4471 if(max !== undefined)
4472 opts.min = max * -1;
4473 return obj.slider(opts);
4474 }
4475 if(typeof(opts) == 'string' && val !== undefined)
4476 return obj.slider(opts, val);
4477 return obj.slider(opts);
4478 },
4479 value: function(tp_inst, obj, unit, val){
4480 if(tp_inst._defaults.isRTL){
4481 if(val !== undefined)
4482 return obj.slider('value', val*-1);
4483 return Math.abs(obj.slider('value'));
4484 }
4485 if(val !== undefined)
4486 return obj.slider('value', val);
4487 return obj.slider('value');
4488 }
4489 },
4490 // select methods
4491 select: {
4492 create: function(tp_inst, obj, unit, val, min, max, step){
4493 var sel = '<select class="ui-timepicker-select" data-unit="'+ unit +'" data-min="'+ min +'" data-max="'+ max +'" data-step="'+ step +'">',
4494 ul = tp_inst._defaults.timeFormat.indexOf('t') !== -1? 'toLowerCase':'toUpperCase',
4495 m = 0;
4496
4497 for(var i=min; i<=max; i+=step){
4498 sel += '<option value="'+ i +'"'+ (i==val? ' selected':'') +'>';
4499 if(unit == 'hour' && useAmpm(tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat))
4500 sel += $.datepicker.formatTime("hh TT", {hour:i}, tp_inst._defaults);
4501 else if(unit == 'millisec' || i >= 10) sel += i;
4502 else sel += '0'+ i.toString();
4503 sel += '</option>';
4504 }
4505 sel += '</select>';
4506
4507 obj.children('select').remove();
4508
4509 $(sel).appendTo(obj).change(function(e){
4510 tp_inst._onTimeChange();
4511 tp_inst._onSelectHandler();
4512 });
4513
4514 return obj;
4515 },
4516 options: function(tp_inst, obj, unit, opts, val){
4517 var o = {},
4518 $t = obj.children('select');
4519 if(typeof(opts) == 'string'){
4520 if(val === undefined)
4521 return $t.data(opts);
4522 o[opts] = val;
4523 }
4524 else o = opts;
4525 return tp_inst.control.create(tp_inst, obj, $t.data('unit'), $t.val(), o.min || $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step'));
4526 },
4527 value: function(tp_inst, obj, unit, val){
4528 var $t = obj.children('select');
4529 if(val !== undefined)
4530 return $t.val(val);
4531 return $t.val();
4532 }
4533 }
4534 } // end _controls
4535
4536 });
4537
4538 $.fn.extend({
4539 /*
4540 * shorthand just to use timepicker..
4541 */
4542 timepicker: function(o) {
4543 o = o || {};
4544 var tmp_args = Array.prototype.slice.call(arguments);
4545
4546 if (typeof o == 'object') {
4547 tmp_args[0] = $.extend(o, {
4548 timeOnly: true
4549 });
4550 }
4551
4552 return $(this).each(function() {
4553 $.fn.datetimepicker.apply($(this), tmp_args);
4554 });
4555 },
4556
4557 /*
4558 * extend timepicker to datepicker
4559 */
4560 datetimepicker: function(o) {
4561 o = o || {};
4562 var tmp_args = arguments;
4563
4564 if (typeof(o) == 'string') {
4565 if (o == 'getDate') {
4566 return $.fn.datepicker.apply($(this[0]), tmp_args);
4567 } else {
4568 return this.each(function() {
4569 var $t = $(this);
4570 $t.datepicker.apply($t, tmp_args);
4571 });
4572 }
4573 } else {
4574 return this.each(function() {
4575 var $t = $(this);
4576 $t.datepicker($.timepicker._newInst($t, o)._defaults);
4577 });
4578 }
4579 }
4580 });
4581
4582 /*
4583 * Public Utility to parse date and time
4584 */
4585 $.datepicker.parseDateTime = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
4586 var parseRes = parseDateTimeInternal(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings);
4587 if (parseRes.timeObj) {
4588 var t = parseRes.timeObj;
4589 parseRes.date.setHours(t.hour, t.minute, t.second, t.millisec);
4590 }
4591
4592 return parseRes.date;
4593 };
4594
4595 /*
4596 * Public utility to parse time
4597 */
4598 $.datepicker.parseTime = function(timeFormat, timeString, options) {
4599 var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {});
4600
4601 // Strict parse requires the timeString to match the timeFormat exactly
4602 var strictParse = function(f, s, o){
4603
4604 // pattern for standard and localized AM/PM markers
4605 var getPatternAmpm = function(amNames, pmNames) {
4606 var markers = [];
4607 if (amNames) {
4608 $.merge(markers, amNames);
4609 }
4610 if (pmNames) {
4611 $.merge(markers, pmNames);
4612 }
4613 markers = $.map(markers, function(val) {
4614 return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&');
4615 });
4616 return '(' + markers.join('|') + ')?';
4617 };
4618
4619 // figure out position of time elements.. cause js cant do named captures
4620 var getFormatPositions = function(timeFormat) {
4621 var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z|'.*?')/g),
4622 orders = {
4623 h: -1,
4624 m: -1,
4625 s: -1,
4626 l: -1,
4627 t: -1,
4628 z: -1
4629 };
4630
4631 if (finds) {
4632 for (var i = 0; i < finds.length; i++) {
4633 if (orders[finds[i].toString().charAt(0)] == -1) {
4634 orders[finds[i].toString().charAt(0)] = i + 1;
4635 }
4636 }
4637 }
4638 return orders;
4639 };
4640
4641 var regstr = '^' + f.toString()
4642 .replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[lz]|'.*?')/g, function (match) {
4643 var ml = match.length;
4644 switch (match.charAt(0).toLowerCase()) {
4645 case 'h': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
4646 case 'm': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
4647 case 's': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
4648 case 'l': return '(\\d?\\d?\\d)';
4649 case 'z': return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
4650 case 't': return getPatternAmpm(o.amNames, o.pmNames);
4651 default: // literal escaped in quotes
4652 return '(' + match.replace(/\'/g, "").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g, function (m) { return "\\" + m; }) + ')?';
4653 }
4654 })
4655 .replace(/\s/g, '\\s?') +
4656 o.timeSuffix + '$',
4657 order = getFormatPositions(f),
4658 ampm = '',
4659 treg;
4660
4661 treg = s.match(new RegExp(regstr, 'i'));
4662
4663 var resTime = {
4664 hour: 0,
4665 minute: 0,
4666 second: 0,
4667 millisec: 0
4668 };
4669
4670 if (treg) {
4671 if (order.t !== -1) {
4672 if (treg[order.t] === undefined || treg[order.t].length === 0) {
4673 ampm = '';
4674 resTime.ampm = '';
4675 } else {
4676 ampm = $.inArray(treg[order.t].toUpperCase(), o.amNames) !== -1 ? 'AM' : 'PM';
4677 resTime.ampm = o[ampm == 'AM' ? 'amNames' : 'pmNames'][0];
4678 }
4679 }
4680
4681 if (order.h !== -1) {
4682 if (ampm == 'AM' && treg[order.h] == '12') {
4683 resTime.hour = 0; // 12am = 0 hour
4684 } else {
4685 if (ampm == 'PM' && treg[order.h] != '12') {
4686 resTime.hour = parseInt(treg[order.h], 10) + 12; // 12pm = 12 hour, any other pm = hour + 12
4687 } else {
4688 resTime.hour = Number(treg[order.h]);
4689 }
4690 }
4691 }
4692
4693 if (order.m !== -1) {
4694 resTime.minute = Number(treg[order.m]);
4695 }
4696 if (order.s !== -1) {
4697 resTime.second = Number(treg[order.s]);
4698 }
4699 if (order.l !== -1) {
4700 resTime.millisec = Number(treg[order.l]);
4701 }
4702 if (order.z !== -1 && treg[order.z] !== undefined) {
4703 var tz = treg[order.z].toUpperCase();
4704 switch (tz.length) {
4705 case 1:
4706 // Z
4707 tz = o.timezoneIso8601 ? 'Z' : '+0000';
4708 break;
4709 case 5:
4710 // +hhmm
4711 if (o.timezoneIso8601) {
4712 tz = tz.substring(1) == '0000' ? 'Z' : tz.substring(0, 3) + ':' + tz.substring(3);
4713 }
4714 break;
4715 case 6:
4716 // +hh:mm
4717 if (!o.timezoneIso8601) {
4718 tz = tz == 'Z' || tz.substring(1) == '00:00' ? '+0000' : tz.replace(/:/, '');
4719 } else {
4720 if (tz.substring(1) == '00:00') {
4721 tz = 'Z';
4722 }
4723 }
4724 break;
4725 }
4726 resTime.timezone = tz;
4727 }
4728
4729
4730 return resTime;
4731 }
4732 return false;
4733 };// end strictParse
4734
4735 // First try JS Date, if that fails, use strictParse
4736 var looseParse = function(f,s,o){
4737 try{
4738 var d = new Date('2012-01-01 '+ s);
4739 if(isNaN(d.getTime())){
4740 d = new Date('2012-01-01T'+ s);
4741 if(isNaN(d.getTime())){
4742 d = new Date('01/01/2012 '+ s);
4743 if(isNaN(d.getTime())){
4744 throw "Unable to parse time with native Date: "+ s;
4745 }
4746 }
4747 }
4748
4749 return {
4750 hour: d.getHours(),
4751 minute: d.getMinutes(),
4752 second: d.getSeconds(),
4753 millisec: d.getMilliseconds(),
4754 timezone: $.timepicker.timeZoneOffsetString(d)
4755 };
4756 }
4757 catch(err){
4758 try{
4759 return strictParse(f,s,o);
4760 }
4761 catch(err2){
4762 $.timepicker.log("Unable to parse \ntimeString: "+ s +"\ntimeFormat: "+ f);
4763 }
4764 }
4765 return false;
4766 }; // end looseParse
4767
4768 if(typeof o.parse === "function"){
4769 return o.parse(timeFormat, timeString, o)
4770 }
4771 if(o.parse === 'loose'){
4772 return looseParse(timeFormat, timeString, o);
4773 }
4774 return strictParse(timeFormat, timeString, o);
4775 };
4776
4777 /*
4778 * Public utility to format the time
4779 * format = string format of the time
4780 * time = a {}, not a Date() for timezones
4781 * options = essentially the regional[].. amNames, pmNames, ampm
4782 */
4783 $.datepicker.formatTime = function(format, time, options) {
4784 options = options || {};
4785 options = $.extend({}, $.timepicker._defaults, options);
4786 time = $.extend({
4787 hour: 0,
4788 minute: 0,
4789 second: 0,
4790 millisec: 0,
4791 timezone: '+0000'
4792 }, time);
4793
4794 var tmptime = format,
4795 ampmName = options.amNames[0],
4796 hour = parseInt(time.hour, 10);
4797
4798 if (hour > 11) {
4799 ampmName = options.pmNames[0];
4800 }
4801
4802 tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[lz]|('.*?'|".*?"))/g, function(match) {
4803 switch (match) {
4804 case 'HH':
4805 return ('0' + hour).slice(-2);
4806 case 'H':
4807 return hour;
4808 case 'hh':
4809 return ('0' + convert24to12(hour)).slice(-2);
4810 case 'h':
4811 return convert24to12(hour);
4812 case 'mm':
4813 return ('0' + time.minute).slice(-2);
4814 case 'm':
4815 return time.minute;
4816 case 'ss':
4817 return ('0' + time.second).slice(-2);
4818 case 's':
4819 return time.second;
4820 case 'l':
4821 return ('00' + time.millisec).slice(-3);
4822 case 'z':
4823 return time.timezone === null? options.defaultTimezone : time.timezone;
4824 case 'T':
4825 return ampmName.charAt(0).toUpperCase();
4826 case 'TT':
4827 return ampmName.toUpperCase();
4828 case 't':
4829 return ampmName.charAt(0).toLowerCase();
4830 case 'tt':
4831 return ampmName.toLowerCase();
4832 default:
4833 return match.replace(/\'/g, "") || "'";
4834 }
4835 });
4836
4837 tmptime = $.trim(tmptime);
4838 return tmptime;
4839 };
4840
4841 /*
4842 * the bad hack :/ override datepicker so it doesnt close on select
4843 // inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
4844 */
4845 $.datepicker._base_selectDate = $.datepicker._selectDate;
4846 $.datepicker._selectDate = function(id, dateStr) {
4847 var inst = this._getInst($(id)[0]),
4848 tp_inst = this._get(inst, 'timepicker');
4849
4850 if (tp_inst) {
4851 tp_inst._limitMinMaxDateTime(inst, true);
4852 inst.inline = inst.stay_open = true;
4853 //This way the onSelect handler called from calendarpicker get the full dateTime
4854 this._base_selectDate(id, dateStr);
4855 inst.inline = inst.stay_open = false;
4856 this._notifyChange(inst);
4857 this._updateDatepicker(inst);
4858 } else {
4859 this._base_selectDate(id, dateStr);
4860 }
4861 };
4862
4863 /*
4864 * second bad hack :/ override datepicker so it triggers an event when changing the input field
4865 * and does not redraw the datepicker on every selectDate event
4866 */
4867 $.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
4868 $.datepicker._updateDatepicker = function(inst) {
4869
4870 // don't popup the datepicker if there is another instance already opened
4871 var input = inst.input[0];
4872 if ($.datepicker._curInst && $.datepicker._curInst != inst && $.datepicker._datepickerShowing && $.datepicker._lastInput != input) {
4873 return;
4874 }
4875
4876 if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
4877
4878 this._base_updateDatepicker(inst);
4879
4880 // Reload the time control when changing something in the input text field.
4881 var tp_inst = this._get(inst, 'timepicker');
4882 if (tp_inst) {
4883 tp_inst._addTimePicker(inst);
4884
4885 // if (tp_inst._defaults.useLocalTimezone) { //checks daylight saving with the new date.
4886 // var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 12);
4887 // selectLocalTimeZone(tp_inst, date);
4888 // tp_inst._onTimeChange();
4889 // }
4890 }
4891 }
4892 };
4893
4894 /*
4895 * third bad hack :/ override datepicker so it allows spaces and colon in the input field
4896 */
4897 $.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
4898 $.datepicker._doKeyPress = function(event) {
4899 var inst = $.datepicker._getInst(event.target),
4900 tp_inst = $.datepicker._get(inst, 'timepicker');
4901
4902 if (tp_inst) {
4903 if ($.datepicker._get(inst, 'constrainInput')) {
4904 var ampm = useAmpm(tp_inst._defaults.timeFormat),
4905 dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
4906 datetimeChars = tp_inst._defaults.timeFormat.toString()
4907 .replace(/[hms]/g, '')
4908 .replace(/TT/g, ampm ? 'APM' : '')
4909 .replace(/Tt/g, ampm ? 'AaPpMm' : '')
4910 .replace(/tT/g, ampm ? 'AaPpMm' : '')
4911 .replace(/T/g, ampm ? 'AP' : '')
4912 .replace(/tt/g, ampm ? 'apm' : '')
4913 .replace(/t/g, ampm ? 'ap' : '') +
4914 " " + tp_inst._defaults.separator +
4915 tp_inst._defaults.timeSuffix +
4916 (tp_inst._defaults.showTimezone ? tp_inst._defaults.timezoneList.join('') : '') +
4917 (tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) +
4918 dateChars,
4919 chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
4920 return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
4921 }
4922 }
4923
4924 return $.datepicker._base_doKeyPress(event);
4925 };
4926
4927 /*
4928 * Fourth bad hack :/ override _updateAlternate function used in inline mode to init altField
4929 */
4930 $.datepicker._base_updateAlternate = $.datepicker._updateAlternate;
4931 /* Update any alternate field to synchronise with the main field. */
4932 $.datepicker._updateAlternate = function(inst) {
4933 var tp_inst = this._get(inst, 'timepicker');
4934 if(tp_inst){
4935 var altField = tp_inst._defaults.altField;
4936 if (altField) { // update alternate field too
4937 var altFormat = tp_inst._defaults.altFormat || tp_inst._defaults.dateFormat,
4938 date = this._getDate(inst),
4939 formatCfg = $.datepicker._getFormatConfig(inst),
4940 altFormattedDateTime = '',
4941 altSeparator = tp_inst._defaults.altSeparator ? tp_inst._defaults.altSeparator : tp_inst._defaults.separator,
4942 altTimeSuffix = tp_inst._defaults.altTimeSuffix ? tp_inst._defaults.altTimeSuffix : tp_inst._defaults.timeSuffix,
4943 altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;
4944
4945 altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
4946 if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null){
4947 if(tp_inst._defaults.altFormat)
4948 altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
4949 else altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
4950 }
4951 $(altField).val(altFormattedDateTime);
4952 }
4953 }
4954 else{
4955 $.datepicker._base_updateAlternate(inst);
4956 }
4957 };
4958
4959 /*
4960 * Override key up event to sync manual input changes.
4961 */
4962 $.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
4963 $.datepicker._doKeyUp = function(event) {
4964 var inst = $.datepicker._getInst(event.target),
4965 tp_inst = $.datepicker._get(inst, 'timepicker');
4966
4967 if (tp_inst) {
4968 if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
4969 try {
4970 $.datepicker._updateDatepicker(inst);
4971 } catch (err) {
4972 $.timepicker.log(err);
4973 }
4974 }
4975 }
4976
4977 return $.datepicker._base_doKeyUp(event);
4978 };
4979
4980 /*
4981 * override "Today" button to also grab the time.
4982 */
4983 $.datepicker._base_gotoToday = $.datepicker._gotoToday;
4984 $.datepicker._gotoToday = function(id) {
4985 var inst = this._getInst($(id)[0]),
4986 $dp = inst.dpDiv;
4987 this._base_gotoToday(id);
4988 var tp_inst = this._get(inst, 'timepicker');
4989 selectLocalTimeZone(tp_inst);
4990 var now = new Date();
4991 this._setTime(inst, now);
4992 $('.ui-datepicker-today', $dp).click();
4993 };
4994
4995 /*
4996 * Disable & enable the Time in the datetimepicker
4997 */
4998 $.datepicker._disableTimepickerDatepicker = function(target) {
4999 var inst = this._getInst(target);
5000 if (!inst) {
5001 return;
5002 }
5003
5004 var tp_inst = this._get(inst, 'timepicker');
5005 $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
5006 if (tp_inst) {
5007 tp_inst._defaults.showTimepicker = false;
5008 tp_inst._updateDateTime(inst);
5009 }
5010 };
5011
5012 $.datepicker._enableTimepickerDatepicker = function(target) {
5013 var inst = this._getInst(target);
5014 if (!inst) {
5015 return;
5016 }
5017
5018 var tp_inst = this._get(inst, 'timepicker');
5019 $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
5020 if (tp_inst) {
5021 tp_inst._defaults.showTimepicker = true;
5022 tp_inst._addTimePicker(inst); // Could be disabled on page load
5023 tp_inst._updateDateTime(inst);
5024 }
5025 };
5026
5027 /*
5028 * Create our own set time function
5029 */
5030 $.datepicker._setTime = function(inst, date) {
5031 var tp_inst = this._get(inst, 'timepicker');
5032 if (tp_inst) {
5033 var defaults = tp_inst._defaults;
5034
5035 // calling _setTime with no date sets time to defaults
5036 tp_inst.hour = date ? date.getHours() : defaults.hour;
5037 tp_inst.minute = date ? date.getMinutes() : defaults.minute;
5038 tp_inst.second = date ? date.getSeconds() : defaults.second;
5039 tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
5040
5041 //check if within min/max times..
5042 tp_inst._limitMinMaxDateTime(inst, true);
5043
5044 tp_inst._onTimeChange();
5045 tp_inst._updateDateTime(inst);
5046 }
5047 };
5048
5049 /*
5050 * Create new public method to set only time, callable as $().datepicker('setTime', date)
5051 */
5052 $.datepicker._setTimeDatepicker = function(target, date, withDate) {
5053 var inst = this._getInst(target);
5054 if (!inst) {
5055 return;
5056 }
5057
5058 var tp_inst = this._get(inst, 'timepicker');
5059
5060 if (tp_inst) {
5061 this._setDateFromField(inst);
5062 var tp_date;
5063 if (date) {
5064 if (typeof date == "string") {
5065 tp_inst._parseTime(date, withDate);
5066 tp_date = new Date();
5067 tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
5068 } else {
5069 tp_date = new Date(date.getTime());
5070 }
5071 if (tp_date.toString() == 'Invalid Date') {
5072 tp_date = undefined;
5073 }
5074 this._setTime(inst, tp_date);
5075 }
5076 }
5077
5078 };
5079
5080 /*
5081 * override setDate() to allow setting time too within Date object
5082 */
5083 $.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
5084 $.datepicker._setDateDatepicker = function(target, date) {
5085 var inst = this._getInst(target);
5086 if (!inst) {
5087 return;
5088 }
5089
5090 var tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
5091
5092 this._updateDatepicker(inst);
5093 this._base_setDateDatepicker.apply(this, arguments);
5094 this._setTimeDatepicker(target, tp_date, true);
5095 };
5096
5097 /*
5098 * override getDate() to allow getting time too within Date object
5099 */
5100 $.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
5101 $.datepicker._getDateDatepicker = function(target, noDefault) {
5102 var inst = this._getInst(target);
5103 if (!inst) {
5104 return;
5105 }
5106
5107 var tp_inst = this._get(inst, 'timepicker');
5108
5109 if (tp_inst) {
5110 // if it hasn't yet been defined, grab from field
5111 if(inst.lastVal === undefined){
5112 this._setDateFromField(inst, noDefault);
5113 }
5114
5115 var date = this._getDate(inst);
5116 if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) {
5117 date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
5118 }
5119 return date;
5120 }
5121 return this._base_getDateDatepicker(target, noDefault);
5122 };
5123
5124 /*
5125 * override parseDate() because UI 1.8.14 throws an error about "Extra characters"
5126 * An option in datapicker to ignore extra format characters would be nicer.
5127 */
5128 $.datepicker._base_parseDate = $.datepicker.parseDate;
5129 $.datepicker.parseDate = function(format, value, settings) {
5130 var date;
5131 try {
5132 date = this._base_parseDate(format, value, settings);
5133 } catch (err) {
5134 // Hack! The error message ends with a colon, a space, and
5135 // the "extra" characters. We rely on that instead of
5136 // attempting to perfectly reproduce the parsing algorithm.
5137 date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
5138 $.timepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format);
5139 }
5140 return date;
5141 };
5142
5143 /*
5144 * override formatDate to set date with time to the input
5145 */
5146 $.datepicker._base_formatDate = $.datepicker._formatDate;
5147 $.datepicker._formatDate = function(inst, day, month, year) {
5148 var tp_inst = this._get(inst, 'timepicker');
5149 if (tp_inst) {
5150 tp_inst._updateDateTime(inst);
5151 return tp_inst.$input.val();
5152 }
5153 return this._base_formatDate(inst);
5154 };
5155
5156 /*
5157 * override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
5158 */
5159 $.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
5160 $.datepicker._optionDatepicker = function(target, name, value) {
5161 var inst = this._getInst(target),
5162 name_clone;
5163 if (!inst) {
5164 return null;
5165 }
5166
5167 var tp_inst = this._get(inst, 'timepicker');
5168 if (tp_inst) {
5169 var min = null,
5170 max = null,
5171 onselect = null,
5172 overrides = tp_inst._defaults.evnts,
5173 fns = {},
5174 prop;
5175 if (typeof name == 'string') { // if min/max was set with the string
5176 if (name === 'minDate' || name === 'minDateTime') {
5177 min = value;
5178 } else if (name === 'maxDate' || name === 'maxDateTime') {
5179 max = value;
5180 } else if (name === 'onSelect') {
5181 onselect = value;
5182 } else if (overrides.hasOwnProperty(name)) {
5183 if (typeof (value) === 'undefined') {
5184 return overrides[name];
5185 }
5186 fns[name] = value;
5187 name_clone = {}; //empty results in exiting function after overrides updated
5188 }
5189 } else if (typeof name == 'object') { //if min/max was set with the JSON
5190 if (name.minDate) {
5191 min = name.minDate;
5192 } else if (name.minDateTime) {
5193 min = name.minDateTime;
5194 } else if (name.maxDate) {
5195 max = name.maxDate;
5196 } else if (name.maxDateTime) {
5197 max = name.maxDateTime;
5198 }
5199 for (prop in overrides) {
5200 if (overrides.hasOwnProperty(prop) && name[prop]) {
5201 fns[prop] = name[prop];
5202 }
5203 }
5204 }
5205 for (prop in fns) {
5206 if (fns.hasOwnProperty(prop)) {
5207 overrides[prop] = fns[prop];
5208 if (!name_clone) { name_clone = $.extend({}, name);}
5209 delete name_clone[prop];
5210 }
5211 }
5212 if (name_clone && isEmptyObject(name_clone)) { return; }
5213 if (min) { //if min was set
5214 if (min === 0) {
5215 min = new Date();
5216 } else {
5217 min = new Date(min);
5218 }
5219 tp_inst._defaults.minDate = min;
5220 tp_inst._defaults.minDateTime = min;
5221 } else if (max) { //if max was set
5222 if (max === 0) {
5223 max = new Date();
5224 } else {
5225 max = new Date(max);
5226 }
5227 tp_inst._defaults.maxDate = max;
5228 tp_inst._defaults.maxDateTime = max;
5229 } else if (onselect) {
5230 tp_inst._defaults.onSelect = onselect;
5231 }
5232 }
5233 if (value === undefined) {
5234 return this._base_optionDatepicker.call($.datepicker, target, name);
5235 }
5236 return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
5237 };
5238 /*
5239 * jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
5240 * it will return false for all objects
5241 */
5242 var isEmptyObject = function(obj) {
5243 var prop;
5244 for (prop in obj) {
5245 if (obj.hasOwnProperty(obj)) {
5246 return false;
5247 }
5248 }
5249 return true;
5250 };
5251
5252 /*
5253 * jQuery extend now ignores nulls!
5254 */
5255 var extendRemove = function(target, props) {
5256 $.extend(target, props);
5257 for (var name in props) {
5258 if (props[name] === null || props[name] === undefined) {
5259 target[name] = props[name];
5260 }
5261 }
5262 return target;
5263 };
5264
5265 /*
5266 * Determine by the time format if should use ampm
5267 * Returns true if should use ampm, false if not
5268 */
5269 var useAmpm = function(timeFormat){
5270 return (timeFormat.indexOf('t') !== -1 && timeFormat.indexOf('h') !== -1);
5271 };
5272
5273 /*
5274 * Converts 24 hour format into 12 hour
5275 * Returns 12 hour without leading 0
5276 */
5277 var convert24to12 = function(hour) {
5278 if (hour > 12) {
5279 hour = hour - 12;
5280 }
5281
5282 if (hour == 0) {
5283 hour = 12;
5284 }
5285
5286 return String(hour);
5287 };
5288
5289 /*
5290 * Splits datetime string into date ans time substrings.
5291 * Throws exception when date can't be parsed
5292 * Returns [dateString, timeString]
5293 */
5294 var splitDateTime = function(dateFormat, dateTimeString, dateSettings, timeSettings) {
5295 try {
5296 // The idea is to get the number separator occurances in datetime and the time format requested (since time has
5297 // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
5298 var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.timepicker._defaults.separator,
5299 format = timeSettings && timeSettings.timeFormat ? timeSettings.timeFormat : $.timepicker._defaults.timeFormat,
5300 timeParts = format.split(separator), // how many occurances of separator may be in our format?
5301 timePartsLen = timeParts.length,
5302 allParts = dateTimeString.split(separator),
5303 allPartsLen = allParts.length;
5304
5305 if (allPartsLen > 1) {
5306 return [
5307 allParts.splice(0,allPartsLen-timePartsLen).join(separator),
5308 allParts.splice(0,timePartsLen).join(separator)
5309 ];
5310 }
5311
5312 } catch (err) {
5313 $.timepicker.log('Could not split the date from the time. Please check the following datetimepicker options' +
5314 "\nthrown error: " + err +
5315 "\ndateTimeString" + dateTimeString +
5316 "\ndateFormat = " + dateFormat +
5317 "\nseparator = " + timeSettings.separator +
5318 "\ntimeFormat = " + timeSettings.timeFormat);
5319
5320 if (err.indexOf(":") >= 0) {
5321 // Hack! The error message ends with a colon, a space, and
5322 // the "extra" characters. We rely on that instead of
5323 // attempting to perfectly reproduce the parsing algorithm.
5324 var dateStringLength = dateTimeString.length - (err.length - err.indexOf(':') - 2),
5325 timeString = dateTimeString.substring(dateStringLength);
5326
5327 return [$.trim(dateTimeString.substring(0, dateStringLength)), $.trim(dateTimeString.substring(dateStringLength))];
5328
5329 } else {
5330 throw err;
5331 }
5332 }
5333 return [dateTimeString, ''];
5334 };
5335
5336 /*
5337 * Internal function to parse datetime interval
5338 * Returns: {date: Date, timeObj: Object}, where
5339 * date - parsed date without time (type Date)
5340 * timeObj = {hour: , minute: , second: , millisec: } - parsed time. Optional
5341 */
5342 var parseDateTimeInternal = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
5343 var date;
5344 var splitRes = splitDateTime(dateFormat, dateTimeString, dateSettings, timeSettings);
5345 date = $.datepicker._base_parseDate(dateFormat, splitRes[0], dateSettings);
5346 if (splitRes[1] !== '') {
5347 var timeString = splitRes[1],
5348 parsedTime = $.datepicker.parseTime(timeFormat, timeString, timeSettings);
5349
5350 if (parsedTime === null) {
5351 throw 'Wrong time format';
5352 }
5353 return {
5354 date: date,
5355 timeObj: parsedTime
5356 };
5357 } else {
5358 return {
5359 date: date
5360 };
5361 }
5362 };
5363
5364 /*
5365 * Internal function to set timezone_select to the local timezone
5366 */
5367 var selectLocalTimeZone = function(tp_inst, date) {
5368 if (tp_inst && tp_inst.timezone_select) {
5369 tp_inst._defaults.useLocalTimezone = true;
5370 var now = typeof date !== 'undefined' ? date : new Date();
5371 var tzoffset = $.timepicker.timeZoneOffsetString(now);
5372 if (tp_inst._defaults.timezoneIso8601) {
5373 tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
5374 }
5375 tp_inst.timezone_select.val(tzoffset);
5376 }
5377 };
5378
5379 /*
5380 * Create a Singleton Insance
5381 */
5382 $.timepicker = new Timepicker();
5383
5384 /**
5385 * Get the timezone offset as string from a date object (eg '+0530' for UTC+5.5)
5386 * @param date
5387 * @return string
5388 */
5389 $.timepicker.timeZoneOffsetString = function(date) {
5390 var off = date.getTimezoneOffset() * -1,
5391 minutes = off % 60,
5392 hours = (off - minutes) / 60;
5393 return (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).slice(-2) + ('0' + (minutes * 101).toString()).slice(-2);
5394 };
5395
5396 /**
5397 * Calls `timepicker()` on the `startTime` and `endTime` elements, and configures them to
5398 * enforce date range limits.
5399 * n.b. The input value must be correctly formatted (reformatting is not supported)
5400 * @param Element startTime
5401 * @param Element endTime
5402 * @param obj options Options for the timepicker() call
5403 * @return jQuery
5404 */
5405 $.timepicker.timeRange = function(startTime, endTime, options) {
5406 return $.timepicker.handleRange('timepicker', startTime, endTime, options);
5407 };
5408
5409 /**
5410 * Calls `datetimepicker` on the `startTime` and `endTime` elements, and configures them to
5411 * enforce date range limits.
5412 * @param Element startTime
5413 * @param Element endTime
5414 * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
5415 * a boolean value that can be used to reformat the input values to the `dateFormat`.
5416 * @param string method Can be used to specify the type of picker to be added
5417 * @return jQuery
5418 */
5419 $.timepicker.dateTimeRange = function(startTime, endTime, options) {
5420 $.timepicker.dateRange(startTime, endTime, options, 'datetimepicker');
5421 };
5422
5423 /**
5424 * Calls `method` on the `startTime` and `endTime` elements, and configures them to
5425 * enforce date range limits.
5426 * @param Element startTime
5427 * @param Element endTime
5428 * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
5429 * a boolean value that can be used to reformat the input values to the `dateFormat`.
5430 * @param string method Can be used to specify the type of picker to be added
5431 * @return jQuery
5432 */
5433 $.timepicker.dateRange = function(startTime, endTime, options, method) {
5434 method = method || 'datepicker';
5435 $.timepicker.handleRange(method, startTime, endTime, options);
5436 };
5437
5438 /**
5439 * Calls `method` on the `startTime` and `endTime` elements, and configures them to
5440 * enforce date range limits.
5441 * @param string method Can be used to specify the type of picker to be added
5442 * @param Element startTime
5443 * @param Element endTime
5444 * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
5445 * a boolean value that can be used to reformat the input values to the `dateFormat`.
5446 * @return jQuery
5447 */
5448 $.timepicker.handleRange = function(method, startTime, endTime, options) {
5449 $.fn[method].call(startTime, $.extend({
5450 onClose: function(dateText, inst) {
5451 checkDates(this, endTime, dateText);
5452 },
5453 onSelect: function(selectedDateTime) {
5454 selected(this, endTime, 'minDate');
5455 }
5456 }, options, options.start));
5457 $.fn[method].call(endTime, $.extend({
5458 onClose: function(dateText, inst) {
5459 checkDates(this, startTime, dateText);
5460 },
5461 onSelect: function(selectedDateTime) {
5462 selected(this, startTime, 'maxDate');
5463 }
5464 }, options, options.end));
5465 // timepicker doesn't provide access to its 'timeFormat' option,
5466 // nor could I get datepicker.formatTime() to behave with times, so I
5467 // have disabled reformatting for timepicker
5468 if (method != 'timepicker' && options.reformat) {
5469 $([startTime, endTime]).each(function() {
5470 var format = $(this)[method].call($(this), 'option', 'dateFormat'),
5471 date = new Date($(this).val());
5472 if ($(this).val() && date) {
5473 $(this).val($.datepicker.formatDate(format, date));
5474 }
5475 });
5476 }
5477 checkDates(startTime, endTime, startTime.val());
5478
5479 function checkDates(changed, other, dateText) {
5480 if (other.val() && (new Date(startTime.val()) > new Date(endTime.val()))) {
5481 other.val(dateText);
5482 }
5483 }
5484 selected(startTime, endTime, 'minDate');
5485 selected(endTime, startTime, 'maxDate');
5486
5487 function selected(changed, other, option) {
5488 if (!$(changed).val()) {
5489 return;
5490 }
5491 var date = $(changed)[method].call($(changed), 'getDate');
5492 // timepicker doesn't implement 'getDate' and returns a jQuery
5493 if (date.getTime) {
5494 $(other)[method].call($(other), 'option', option, date);
5495 }
5496 }
5497 return $([startTime.get(0), endTime.get(0)]);
5498 };
5499
5500 /**
5501 * Log error or data to the console during error or debugging
5502 * @param Object err pass any type object to log to the console during error or debugging
5503 * @return void
5504 */
5505 $.timepicker.log = function(err){
5506 if(window.console)
5507 console.log(err);
5508 };
5509
5510 /*
5511 * Keep up with the version
5512 */
5513 $.timepicker.version = "1.2";
5514
5515 })(jQuery);
5516
5517 /* assets/wpuf/vendor/sweetalert2/dist/sweetalert2.js */
5518 /*!
5519 * sweetalert2 v6.6.4
5520 * Released under the MIT License.
5521 */
5522 (function (global, factory) {
5523 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
5524 typeof define === 'function' && define.amd ? define(factory) :
5525 (global.Sweetalert2 = factory());
5526 }(this, (function () { 'use strict';
5527
5528 var defaultParams = {
5529 title: '',
5530 titleText: '',
5531 text: '',
5532 html: '',
5533 type: null,
5534 customClass: '',
5535 target: 'body',
5536 animation: true,
5537 allowOutsideClick: true,
5538 allowEscapeKey: true,
5539 allowEnterKey: true,
5540 showConfirmButton: true,
5541 showCancelButton: false,
5542 preConfirm: null,
5543 confirmButtonText: 'OK',
5544 confirmButtonColor: '#3085d6',
5545 confirmButtonClass: null,
5546 cancelButtonText: 'Cancel',
5547 cancelButtonColor: '#aaa',
5548 cancelButtonClass: null,
5549 buttonsStyling: true,
5550 reverseButtons: false,
5551 focusCancel: false,
5552 showCloseButton: false,
5553 showLoaderOnConfirm: false,
5554 imageUrl: null,
5555 imageWidth: null,
5556 imageHeight: null,
5557 imageClass: null,
5558 timer: null,
5559 width: 500,
5560 padding: 20,
5561 background: '#fff',
5562 input: null,
5563 inputPlaceholder: '',
5564 inputValue: '',
5565 inputOptions: {},
5566 inputAutoTrim: true,
5567 inputClass: null,
5568 inputAttributes: {},
5569 inputValidator: null,
5570 progressSteps: [],
5571 currentProgressStep: null,
5572 progressStepsDistance: '40px',
5573 onOpen: null,
5574 onClose: null,
5575 useRejections: true
5576 };
5577
5578 var swalPrefix = 'swal2-';
5579
5580 var prefix = function prefix(items) {
5581 var result = {};
5582 for (var i in items) {
5583 result[items[i]] = swalPrefix + items[i];
5584 }
5585 return result;
5586 };
5587
5588 var swalClasses = prefix(['container', 'shown', 'iosfix', 'modal', 'overlay', 'fade', 'show', 'hide', 'noanimation', 'close', 'title', 'content', 'buttonswrapper', 'confirm', 'cancel', 'icon', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea', 'inputerror', 'validationerror', 'progresssteps', 'activeprogressstep', 'progresscircle', 'progressline', 'loading', 'styled']);
5589
5590 var iconTypes = prefix(['success', 'warning', 'info', 'question', 'error']);
5591
5592 /*
5593 * Set hover, active and focus-states for buttons (source: http://www.sitepoint.com/javascript-generate-lighter-darker-color)
5594 */
5595 var colorLuminance = function colorLuminance(hex, lum) {
5596 // Validate hex string
5597 hex = String(hex).replace(/[^0-9a-f]/gi, '');
5598 if (hex.length < 6) {
5599 hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
5600 }
5601 lum = lum || 0;
5602
5603 // Convert to decimal and change luminosity
5604 var rgb = '#';
5605 for (var i = 0; i < 3; i++) {
5606 var c = parseInt(hex.substr(i * 2, 2), 16);
5607 c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
5608 rgb += ('00' + c).substr(c.length);
5609 }
5610
5611 return rgb;
5612 };
5613
5614 var uniqueArray = function uniqueArray(arr) {
5615 var result = [];
5616 for (var i in arr) {
5617 if (result.indexOf(arr[i]) === -1) {
5618 result.push(arr[i]);
5619 }
5620 }
5621 return result;
5622 };
5623
5624 /* global MouseEvent */
5625
5626 // Remember state in cases where opening and handling a modal will fiddle with it.
5627 var states = {
5628 previousWindowKeyDown: null,
5629 previousActiveElement: null,
5630 previousBodyPadding: null
5631 };
5632
5633 /*
5634 * Add modal + overlay to DOM
5635 */
5636 var init = function init(params) {
5637 if (typeof document === 'undefined') {
5638 console.error('SweetAlert2 requires document to initialize');
5639 return;
5640 }
5641
5642 var container = document.createElement('div');
5643 container.className = swalClasses.container;
5644 container.innerHTML = sweetHTML;
5645
5646 var targetElement = document.querySelector(params.target);
5647 if (!targetElement) {
5648 console.warn('SweetAlert2: Can\'t find the target "' + params.target + '"');
5649 targetElement = document.body;
5650 }
5651 targetElement.appendChild(container);
5652
5653 var modal = getModal();
5654 var input = getChildByClass(modal, swalClasses.input);
5655 var file = getChildByClass(modal, swalClasses.file);
5656 var range = modal.querySelector('.' + swalClasses.range + ' input');
5657 var rangeOutput = modal.querySelector('.' + swalClasses.range + ' output');
5658 var select = getChildByClass(modal, swalClasses.select);
5659 var checkbox = modal.querySelector('.' + swalClasses.checkbox + ' input');
5660 var textarea = getChildByClass(modal, swalClasses.textarea);
5661
5662 input.oninput = function () {
5663 sweetAlert.resetValidationError();
5664 };
5665
5666 input.onkeydown = function (event) {
5667 setTimeout(function () {
5668 if (event.keyCode === 13 && params.allowEnterKey) {
5669 event.stopPropagation();
5670 sweetAlert.clickConfirm();
5671 }
5672 }, 0);
5673 };
5674
5675 file.onchange = function () {
5676 sweetAlert.resetValidationError();
5677 };
5678
5679 range.oninput = function () {
5680 sweetAlert.resetValidationError();
5681 rangeOutput.value = range.value;
5682 };
5683
5684 range.onchange = function () {
5685 sweetAlert.resetValidationError();
5686 range.previousSibling.value = range.value;
5687 };
5688
5689 select.onchange = function () {
5690 sweetAlert.resetValidationError();
5691 };
5692
5693 checkbox.onchange = function () {
5694 sweetAlert.resetValidationError();
5695 };
5696
5697 textarea.oninput = function () {
5698 sweetAlert.resetValidationError();
5699 };
5700
5701 return modal;
5702 };
5703
5704 /*
5705 * Manipulate DOM
5706 */
5707
5708 var sweetHTML = ('\n <div role="dialog" aria-labelledby="' + swalClasses.title + '" aria-describedby="' + swalClasses.content + '" class="' + swalClasses.modal + '" tabindex="-1">\n <ul class="' + swalClasses.progresssteps + '"></ul>\n <div class="' + swalClasses.icon + ' ' + iconTypes.error + '">\n <span class="swal2-x-mark"><span class="swal2-x-mark-line-left"></span><span class="swal2-x-mark-line-right"></span></span>\n </div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.question + '">?</div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.warning + '">!</div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.info + '">i</div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.success + '">\n <div class="swal2-success-circular-line-left"></div>\n <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>\n <div class="swal2-success-ring"></div> <div class="swal2-success-fix"></div>\n <div class="swal2-success-circular-line-right"></div>\n </div>\n <img class="' + swalClasses.image + '">\n <h2 class="' + swalClasses.title + '" id="' + swalClasses.title + '"></h2>\n <div id="' + swalClasses.content + '" class="' + swalClasses.content + '"></div>\n <input class="' + swalClasses.input + '">\n <input type="file" class="' + swalClasses.file + '">\n <div class="' + swalClasses.range + '">\n <output></output>\n <input type="range">\n </div>\n <select class="' + swalClasses.select + '"></select>\n <div class="' + swalClasses.radio + '"></div>\n <label for="' + swalClasses.checkbox + '" class="' + swalClasses.checkbox + '">\n <input type="checkbox">\n </label>\n <textarea class="' + swalClasses.textarea + '"></textarea>\n <div class="' + swalClasses.validationerror + '"></div>\n <div class="' + swalClasses.buttonswrapper + '">\n <button type="button" class="' + swalClasses.confirm + '">OK</button>\n <button type="button" class="' + swalClasses.cancel + '">Cancel</button>\n </div>\n <button type="button" class="' + swalClasses.close + '" aria-label="Close this dialog">&times;</button>\n </div>\n').replace(/(^|\n)\s*/g, '');
5709
5710 var getContainer = function getContainer() {
5711 return document.body.querySelector('.' + swalClasses.container);
5712 };
5713
5714 var getModal = function getModal() {
5715 return getContainer() ? getContainer().querySelector('.' + swalClasses.modal) : null;
5716 };
5717
5718 var getIcons = function getIcons() {
5719 var modal = getModal();
5720 return modal.querySelectorAll('.' + swalClasses.icon);
5721 };
5722
5723 var elementByClass = function elementByClass(className) {
5724 return getContainer() ? getContainer().querySelector('.' + className) : null;
5725 };
5726
5727 var getTitle = function getTitle() {
5728 return elementByClass(swalClasses.title);
5729 };
5730
5731 var getContent = function getContent() {
5732 return elementByClass(swalClasses.content);
5733 };
5734
5735 var getImage = function getImage() {
5736 return elementByClass(swalClasses.image);
5737 };
5738
5739 var getButtonsWrapper = function getButtonsWrapper() {
5740 return elementByClass(swalClasses.buttonswrapper);
5741 };
5742
5743 var getProgressSteps = function getProgressSteps() {
5744 return elementByClass(swalClasses.progresssteps);
5745 };
5746
5747 var getValidationError = function getValidationError() {
5748 return elementByClass(swalClasses.validationerror);
5749 };
5750
5751 var getConfirmButton = function getConfirmButton() {
5752 return elementByClass(swalClasses.confirm);
5753 };
5754
5755 var getCancelButton = function getCancelButton() {
5756 return elementByClass(swalClasses.cancel);
5757 };
5758
5759 var getCloseButton = function getCloseButton() {
5760 return elementByClass(swalClasses.close);
5761 };
5762
5763 var getFocusableElements = function getFocusableElements(focusCancel) {
5764 var buttons = [getConfirmButton(), getCancelButton()];
5765 if (focusCancel) {
5766 buttons.reverse();
5767 }
5768 var focusableElements = buttons.concat(Array.prototype.slice.call(getModal().querySelectorAll('button, input:not([type=hidden]), textarea, select, a, *[tabindex]:not([tabindex="-1"])')));
5769 return uniqueArray(focusableElements);
5770 };
5771
5772 var hasClass = function hasClass(elem, className) {
5773 if (elem.classList) {
5774 return elem.classList.contains(className);
5775 }
5776 return false;
5777 };
5778
5779 var focusInput = function focusInput(input) {
5780 input.focus();
5781
5782 // place cursor at end of text in text input
5783 if (input.type !== 'file') {
5784 // http://stackoverflow.com/a/2345915/1331425
5785 var val = input.value;
5786 input.value = '';
5787 input.value = val;
5788 }
5789 };
5790
5791 var addClass = function addClass(elem, className) {
5792 if (!elem || !className) {
5793 return;
5794 }
5795 var classes = className.split(/\s+/).filter(Boolean);
5796 classes.forEach(function (className) {
5797 elem.classList.add(className);
5798 });
5799 };
5800
5801 var removeClass = function removeClass(elem, className) {
5802 if (!elem || !className) {
5803 return;
5804 }
5805 var classes = className.split(/\s+/).filter(Boolean);
5806 classes.forEach(function (className) {
5807 elem.classList.remove(className);
5808 });
5809 };
5810
5811 var getChildByClass = function getChildByClass(elem, className) {
5812 for (var i = 0; i < elem.childNodes.length; i++) {
5813 if (hasClass(elem.childNodes[i], className)) {
5814 return elem.childNodes[i];
5815 }
5816 }
5817 };
5818
5819 var show = function show(elem, display) {
5820 if (!display) {
5821 display = 'block';
5822 }
5823 elem.style.opacity = '';
5824 elem.style.display = display;
5825 };
5826
5827 var hide = function hide(elem) {
5828 elem.style.opacity = '';
5829 elem.style.display = 'none';
5830 };
5831
5832 var empty = function empty(elem) {
5833 while (elem.firstChild) {
5834 elem.removeChild(elem.firstChild);
5835 }
5836 };
5837
5838 // borrowed from jqeury $(elem).is(':visible') implementation
5839 var isVisible = function isVisible(elem) {
5840 return elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length;
5841 };
5842
5843 var removeStyleProperty = function removeStyleProperty(elem, property) {
5844 if (elem.style.removeProperty) {
5845 elem.style.removeProperty(property);
5846 } else {
5847 elem.style.removeAttribute(property);
5848 }
5849 };
5850
5851 var fireClick = function fireClick(node) {
5852 if (!isVisible(node)) {
5853 return false;
5854 }
5855
5856 // Taken from http://www.nonobtrusive.com/2011/11/29/programatically-fire-crossbrowser-click-event-with-javascript/
5857 // Then fixed for today's Chrome browser.
5858 if (typeof MouseEvent === 'function') {
5859 // Up-to-date approach
5860 var mevt = new MouseEvent('click', {
5861 view: window,
5862 bubbles: false,
5863 cancelable: true
5864 });
5865 node.dispatchEvent(mevt);
5866 } else if (document.createEvent) {
5867 // Fallback
5868 var evt = document.createEvent('MouseEvents');
5869 evt.initEvent('click', false, false);
5870 node.dispatchEvent(evt);
5871 } else if (document.createEventObject) {
5872 node.fireEvent('onclick');
5873 } else if (typeof node.onclick === 'function') {
5874 node.onclick();
5875 }
5876 };
5877
5878 var animationEndEvent = function () {
5879 var testEl = document.createElement('div');
5880 var transEndEventNames = {
5881 'WebkitAnimation': 'webkitAnimationEnd',
5882 'OAnimation': 'oAnimationEnd oanimationend',
5883 'msAnimation': 'MSAnimationEnd',
5884 'animation': 'animationend'
5885 };
5886 for (var i in transEndEventNames) {
5887 if (transEndEventNames.hasOwnProperty(i) && testEl.style[i] !== undefined) {
5888 return transEndEventNames[i];
5889 }
5890 }
5891
5892 return false;
5893 }();
5894
5895 // Reset previous window keydown handler and focued element
5896 var resetPrevState = function resetPrevState() {
5897 window.onkeydown = states.previousWindowKeyDown;
5898 if (states.previousActiveElement && states.previousActiveElement.focus) {
5899 var x = window.scrollX;
5900 var y = window.scrollY;
5901 states.previousActiveElement.focus();
5902 if (x && y) {
5903 // IE has no scrollX/scrollY support
5904 window.scrollTo(x, y);
5905 }
5906 }
5907 };
5908
5909 // Measure width of scrollbar
5910 // https://github.com/twbs/bootstrap/blob/master/js/modal.js#L279-L286
5911 var measureScrollbar = function measureScrollbar() {
5912 var supportsTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints;
5913 if (supportsTouch) {
5914 return 0;
5915 }
5916 var scrollDiv = document.createElement('div');
5917 scrollDiv.style.width = '50px';
5918 scrollDiv.style.height = '50px';
5919 scrollDiv.style.overflow = 'scroll';
5920 document.body.appendChild(scrollDiv);
5921 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
5922 document.body.removeChild(scrollDiv);
5923 return scrollbarWidth;
5924 };
5925
5926 // JavaScript Debounce Function
5927 // Simplivied version of https://davidwalsh.name/javascript-debounce-function
5928 var debounce = function debounce(func, wait) {
5929 var timeout = void 0;
5930 return function () {
5931 var later = function later() {
5932 timeout = null;
5933 func();
5934 };
5935 clearTimeout(timeout);
5936 timeout = setTimeout(later, wait);
5937 };
5938 };
5939
5940 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
5941 return typeof obj;
5942 } : function (obj) {
5943 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
5944 };
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966 var _extends = Object.assign || function (target) {
5967 for (var i = 1; i < arguments.length; i++) {
5968 var source = arguments[i];
5969
5970 for (var key in source) {
5971 if (Object.prototype.hasOwnProperty.call(source, key)) {
5972 target[key] = source[key];
5973 }
5974 }
5975 }
5976
5977 return target;
5978 };
5979
5980 var modalParams = _extends({}, defaultParams);
5981 var queue = [];
5982 var swal2Observer = void 0;
5983
5984 /*
5985 * Set type, text and actions on modal
5986 */
5987 var setParameters = function setParameters(params) {
5988 var modal = getModal() || init(params);
5989
5990 for (var param in params) {
5991 if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
5992 console.warn('SweetAlert2: Unknown parameter "' + param + '"');
5993 }
5994 }
5995
5996 // Set modal width
5997 modal.style.width = typeof params.width === 'number' ? params.width + 'px' : params.width;
5998
5999 modal.style.padding = params.padding + 'px';
6000 modal.style.background = params.background;
6001 var successIconParts = modal.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
6002 for (var i = 0; i < successIconParts.length; i++) {
6003 successIconParts[i].style.background = params.background;
6004 }
6005
6006 var title = getTitle();
6007 var content = getContent();
6008 var buttonsWrapper = getButtonsWrapper();
6009 var confirmButton = getConfirmButton();
6010 var cancelButton = getCancelButton();
6011 var closeButton = getCloseButton();
6012
6013 // Title
6014 if (params.titleText) {
6015 title.innerText = params.titleText;
6016 } else {
6017 title.innerHTML = params.title.split('\n').join('<br>');
6018 }
6019
6020 // Content
6021 if (params.text || params.html) {
6022 if (_typeof(params.html) === 'object') {
6023 content.innerHTML = '';
6024 if (0 in params.html) {
6025 for (var _i = 0; _i in params.html; _i++) {
6026 content.appendChild(params.html[_i].cloneNode(true));
6027 }
6028 } else {
6029 content.appendChild(params.html.cloneNode(true));
6030 }
6031 } else if (params.html) {
6032 content.innerHTML = params.html;
6033 } else if (params.text) {
6034 content.textContent = params.text;
6035 }
6036 show(content);
6037 } else {
6038 hide(content);
6039 }
6040
6041 // Close button
6042 if (params.showCloseButton) {
6043 show(closeButton);
6044 } else {
6045 hide(closeButton);
6046 }
6047
6048 // Custom Class
6049 modal.className = swalClasses.modal;
6050 if (params.customClass) {
6051 addClass(modal, params.customClass);
6052 }
6053
6054 // Progress steps
6055 var progressStepsContainer = getProgressSteps();
6056 var currentProgressStep = parseInt(params.currentProgressStep === null ? sweetAlert.getQueueStep() : params.currentProgressStep, 10);
6057 if (params.progressSteps.length) {
6058 show(progressStepsContainer);
6059 empty(progressStepsContainer);
6060 if (currentProgressStep >= params.progressSteps.length) {
6061 console.warn('SweetAlert2: Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
6062 }
6063 params.progressSteps.forEach(function (step, index) {
6064 var circle = document.createElement('li');
6065 addClass(circle, swalClasses.progresscircle);
6066 circle.innerHTML = step;
6067 if (index === currentProgressStep) {
6068 addClass(circle, swalClasses.activeprogressstep);
6069 }
6070 progressStepsContainer.appendChild(circle);
6071 if (index !== params.progressSteps.length - 1) {
6072 var line = document.createElement('li');
6073 addClass(line, swalClasses.progressline);
6074 line.style.width = params.progressStepsDistance;
6075 progressStepsContainer.appendChild(line);
6076 }
6077 });
6078 } else {
6079 hide(progressStepsContainer);
6080 }
6081
6082 // Icon
6083 var icons = getIcons();
6084 for (var _i2 = 0; _i2 < icons.length; _i2++) {
6085 hide(icons[_i2]);
6086 }
6087 if (params.type) {
6088 var validType = false;
6089 for (var iconType in iconTypes) {
6090 if (params.type === iconType) {
6091 validType = true;
6092 break;
6093 }
6094 }
6095 if (!validType) {
6096 console.error('SweetAlert2: Unknown alert type: ' + params.type);
6097 return false;
6098 }
6099 var icon = modal.querySelector('.' + swalClasses.icon + '.' + iconTypes[params.type]);
6100 show(icon);
6101
6102 // Animate icon
6103 if (params.animation) {
6104 switch (params.type) {
6105 case 'success':
6106 addClass(icon, 'swal2-animate-success-icon');
6107 addClass(icon.querySelector('.swal2-success-line-tip'), 'swal2-animate-success-line-tip');
6108 addClass(icon.querySelector('.swal2-success-line-long'), 'swal2-animate-success-line-long');
6109 break;
6110 case 'error':
6111 addClass(icon, 'swal2-animate-error-icon');
6112 addClass(icon.querySelector('.swal2-x-mark'), 'swal2-animate-x-mark');
6113 break;
6114 default:
6115 break;
6116 }
6117 }
6118 }
6119
6120 // Custom image
6121 var image = getImage();
6122 if (params.imageUrl) {
6123 image.setAttribute('src', params.imageUrl);
6124 show(image);
6125
6126 if (params.imageWidth) {
6127 image.setAttribute('width', params.imageWidth);
6128 } else {
6129 image.removeAttribute('width');
6130 }
6131
6132 if (params.imageHeight) {
6133 image.setAttribute('height', params.imageHeight);
6134 } else {
6135 image.removeAttribute('height');
6136 }
6137
6138 image.className = swalClasses.image;
6139 if (params.imageClass) {
6140 addClass(image, params.imageClass);
6141 }
6142 } else {
6143 hide(image);
6144 }
6145
6146 // Cancel button
6147 if (params.showCancelButton) {
6148 cancelButton.style.display = 'inline-block';
6149 } else {
6150 hide(cancelButton);
6151 }
6152
6153 // Confirm button
6154 if (params.showConfirmButton) {
6155 removeStyleProperty(confirmButton, 'display');
6156 } else {
6157 hide(confirmButton);
6158 }
6159
6160 // Buttons wrapper
6161 if (!params.showConfirmButton && !params.showCancelButton) {
6162 hide(buttonsWrapper);
6163 } else {
6164 show(buttonsWrapper);
6165 }
6166
6167 // Edit text on cancel and confirm buttons
6168 confirmButton.innerHTML = params.confirmButtonText;
6169 cancelButton.innerHTML = params.cancelButtonText;
6170
6171 // Set buttons to selected background colors
6172 if (params.buttonsStyling) {
6173 confirmButton.style.backgroundColor = params.confirmButtonColor;
6174 cancelButton.style.backgroundColor = params.cancelButtonColor;
6175 }
6176
6177 // Add buttons custom classes
6178 confirmButton.className = swalClasses.confirm;
6179 addClass(confirmButton, params.confirmButtonClass);
6180 cancelButton.className = swalClasses.cancel;
6181 addClass(cancelButton, params.cancelButtonClass);
6182
6183 // Buttons styling
6184 if (params.buttonsStyling) {
6185 addClass(confirmButton, swalClasses.styled);
6186 addClass(cancelButton, swalClasses.styled);
6187 } else {
6188 removeClass(confirmButton, swalClasses.styled);
6189 removeClass(cancelButton, swalClasses.styled);
6190
6191 confirmButton.style.backgroundColor = confirmButton.style.borderLeftColor = confirmButton.style.borderRightColor = '';
6192 cancelButton.style.backgroundColor = cancelButton.style.borderLeftColor = cancelButton.style.borderRightColor = '';
6193 }
6194
6195 // CSS animation
6196 if (params.animation === true) {
6197 removeClass(modal, swalClasses.noanimation);
6198 } else {
6199 addClass(modal, swalClasses.noanimation);
6200 }
6201 };
6202
6203 /*
6204 * Animations
6205 */
6206 var openModal = function openModal(animation, onComplete) {
6207 var container = getContainer();
6208 var modal = getModal();
6209
6210 if (animation) {
6211 addClass(modal, swalClasses.show);
6212 addClass(container, swalClasses.fade);
6213 removeClass(modal, swalClasses.hide);
6214 } else {
6215 removeClass(modal, swalClasses.fade);
6216 }
6217 show(modal);
6218
6219 // scrolling is 'hidden' until animation is done, after that 'auto'
6220 container.style.overflowY = 'hidden';
6221 if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
6222 modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
6223 modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
6224 container.style.overflowY = 'auto';
6225 });
6226 } else {
6227 container.style.overflowY = 'auto';
6228 }
6229
6230 addClass(document.documentElement, swalClasses.shown);
6231 addClass(document.body, swalClasses.shown);
6232 addClass(container, swalClasses.shown);
6233 fixScrollbar();
6234 iOSfix();
6235 states.previousActiveElement = document.activeElement;
6236 if (onComplete !== null && typeof onComplete === 'function') {
6237 setTimeout(function () {
6238 onComplete(modal);
6239 });
6240 }
6241 };
6242
6243 var fixScrollbar = function fixScrollbar() {
6244 // for queues, do not do this more than once
6245 if (states.previousBodyPadding !== null) {
6246 return;
6247 }
6248 // if the body has overflow
6249 if (document.body.scrollHeight > window.innerHeight) {
6250 // add padding so the content doesn't shift after removal of scrollbar
6251 states.previousBodyPadding = document.body.style.paddingRight;
6252 document.body.style.paddingRight = measureScrollbar() + 'px';
6253 }
6254 };
6255
6256 var undoScrollbar = function undoScrollbar() {
6257 if (states.previousBodyPadding !== null) {
6258 document.body.style.paddingRight = states.previousBodyPadding;
6259 states.previousBodyPadding = null;
6260 }
6261 };
6262
6263 // Fix iOS scrolling http://stackoverflow.com/q/39626302/1331425
6264 var iOSfix = function iOSfix() {
6265 var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
6266 if (iOS && !hasClass(document.body, swalClasses.iosfix)) {
6267 var offset = document.body.scrollTop;
6268 document.body.style.top = offset * -1 + 'px';
6269 addClass(document.body, swalClasses.iosfix);
6270 }
6271 };
6272
6273 var undoIOSfix = function undoIOSfix() {
6274 if (hasClass(document.body, swalClasses.iosfix)) {
6275 var offset = parseInt(document.body.style.top, 10);
6276 removeClass(document.body, swalClasses.iosfix);
6277 document.body.style.top = '';
6278 document.body.scrollTop = offset * -1;
6279 }
6280 };
6281
6282 // SweetAlert entry point
6283 var sweetAlert = function sweetAlert() {
6284 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
6285 args[_key] = arguments[_key];
6286 }
6287
6288 if (args[0] === undefined) {
6289 console.error('SweetAlert2 expects at least 1 attribute!');
6290 return false;
6291 }
6292
6293 var params = _extends({}, modalParams);
6294
6295 switch (_typeof(args[0])) {
6296 case 'string':
6297 params.title = args[0];
6298 params.html = args[1];
6299 params.type = args[2];
6300
6301 break;
6302
6303 case 'object':
6304 _extends(params, args[0]);
6305 params.extraParams = args[0].extraParams;
6306
6307 if (params.input === 'email' && params.inputValidator === null) {
6308 params.inputValidator = function (email) {
6309 return new Promise(function (resolve, reject) {
6310 var emailRegex = /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
6311 if (emailRegex.test(email)) {
6312 resolve();
6313 } else {
6314 reject('Invalid email address');
6315 }
6316 });
6317 };
6318 }
6319
6320 if (params.input === 'url' && params.inputValidator === null) {
6321 params.inputValidator = function (url) {
6322 return new Promise(function (resolve, reject) {
6323 var urlRegex = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/;
6324 if (urlRegex.test(url)) {
6325 resolve();
6326 } else {
6327 reject('Invalid URL');
6328 }
6329 });
6330 };
6331 }
6332 break;
6333
6334 default:
6335 console.error('SweetAlert2: Unexpected type of argument! Expected "string" or "object", got ' + _typeof(args[0]));
6336 return false;
6337 }
6338
6339 setParameters(params);
6340
6341 var container = getContainer();
6342 var modal = getModal();
6343
6344 return new Promise(function (resolve, reject) {
6345 // Close on timer
6346 if (params.timer) {
6347 modal.timeout = setTimeout(function () {
6348 sweetAlert.closeModal(params.onClose);
6349 if (params.useRejections) {
6350 reject('timer');
6351 } else {
6352 resolve({ dismiss: 'timer' });
6353 }
6354 }, params.timer);
6355 }
6356
6357 // Get input element by specified type or, if type isn't specified, by params.input
6358 var getInput = function getInput(inputType) {
6359 inputType = inputType || params.input;
6360 if (!inputType) {
6361 return null;
6362 }
6363 switch (inputType) {
6364 case 'select':
6365 case 'textarea':
6366 case 'file':
6367 return getChildByClass(modal, swalClasses[inputType]);
6368 case 'checkbox':
6369 return modal.querySelector('.' + swalClasses.checkbox + ' input');
6370 case 'radio':
6371 return modal.querySelector('.' + swalClasses.radio + ' input:checked') || modal.querySelector('.' + swalClasses.radio + ' input:first-child');
6372 case 'range':
6373 return modal.querySelector('.' + swalClasses.range + ' input');
6374 default:
6375 return getChildByClass(modal, swalClasses.input);
6376 }
6377 };
6378
6379 // Get the value of the modal input
6380 var getInputValue = function getInputValue() {
6381 var input = getInput();
6382 if (!input) {
6383 return null;
6384 }
6385 switch (params.input) {
6386 case 'checkbox':
6387 return input.checked ? 1 : 0;
6388 case 'radio':
6389 return input.checked ? input.value : null;
6390 case 'file':
6391 return input.files.length ? input.files[0] : null;
6392 default:
6393 return params.inputAutoTrim ? input.value.trim() : input.value;
6394 }
6395 };
6396
6397 // input autofocus
6398 if (params.input) {
6399 setTimeout(function () {
6400 var input = getInput();
6401 if (input) {
6402 focusInput(input);
6403 }
6404 }, 0);
6405 }
6406
6407 var confirm = function confirm(value) {
6408 if (params.showLoaderOnConfirm) {
6409 sweetAlert.showLoading();
6410 }
6411
6412 if (params.preConfirm) {
6413 params.preConfirm(value, params.extraParams).then(function (preConfirmValue) {
6414 sweetAlert.closeModal(params.onClose);
6415 resolve(preConfirmValue || value);
6416 }, function (error) {
6417 sweetAlert.hideLoading();
6418 if (error) {
6419 sweetAlert.showValidationError(error);
6420 }
6421 });
6422 } else {
6423 sweetAlert.closeModal(params.onClose);
6424 if (params.useRejections) {
6425 resolve(value);
6426 } else {
6427 resolve({ value: value });
6428 }
6429 }
6430 };
6431
6432 // Mouse interactions
6433 var onButtonEvent = function onButtonEvent(event) {
6434 var e = event || window.event;
6435 var target = e.target || e.srcElement;
6436 var confirmButton = getConfirmButton();
6437 var cancelButton = getCancelButton();
6438 var targetedConfirm = confirmButton && (confirmButton === target || confirmButton.contains(target));
6439 var targetedCancel = cancelButton && (cancelButton === target || cancelButton.contains(target));
6440
6441 switch (e.type) {
6442 case 'mouseover':
6443 case 'mouseup':
6444 if (params.buttonsStyling) {
6445 if (targetedConfirm) {
6446 confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.1);
6447 } else if (targetedCancel) {
6448 cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.1);
6449 }
6450 }
6451 break;
6452 case 'mouseout':
6453 if (params.buttonsStyling) {
6454 if (targetedConfirm) {
6455 confirmButton.style.backgroundColor = params.confirmButtonColor;
6456 } else if (targetedCancel) {
6457 cancelButton.style.backgroundColor = params.cancelButtonColor;
6458 }
6459 }
6460 break;
6461 case 'mousedown':
6462 if (params.buttonsStyling) {
6463 if (targetedConfirm) {
6464 confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.2);
6465 } else if (targetedCancel) {
6466 cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.2);
6467 }
6468 }
6469 break;
6470 case 'click':
6471 // Clicked 'confirm'
6472 if (targetedConfirm && sweetAlert.isVisible()) {
6473 sweetAlert.disableButtons();
6474 if (params.input) {
6475 var inputValue = getInputValue();
6476
6477 if (params.inputValidator) {
6478 sweetAlert.disableInput();
6479 params.inputValidator(inputValue, params.extraParams).then(function () {
6480 sweetAlert.enableButtons();
6481 sweetAlert.enableInput();
6482 confirm(inputValue);
6483 }, function (error) {
6484 sweetAlert.enableButtons();
6485 sweetAlert.enableInput();
6486 if (error) {
6487 sweetAlert.showValidationError(error);
6488 }
6489 });
6490 } else {
6491 confirm(inputValue);
6492 }
6493 } else {
6494 confirm(true);
6495 }
6496
6497 // Clicked 'cancel'
6498 } else if (targetedCancel && sweetAlert.isVisible()) {
6499 sweetAlert.disableButtons();
6500 sweetAlert.closeModal(params.onClose);
6501 if (params.useRejections) {
6502 reject('cancel');
6503 } else {
6504 resolve({ dismiss: 'cancel' });
6505 }
6506 }
6507 break;
6508 default:
6509 }
6510 };
6511
6512 var buttons = modal.querySelectorAll('button');
6513 for (var i = 0; i < buttons.length; i++) {
6514 buttons[i].onclick = onButtonEvent;
6515 buttons[i].onmouseover = onButtonEvent;
6516 buttons[i].onmouseout = onButtonEvent;
6517 buttons[i].onmousedown = onButtonEvent;
6518 }
6519
6520 // Closing modal by close button
6521 getCloseButton().onclick = function () {
6522 sweetAlert.closeModal(params.onClose);
6523 if (params.useRejections) {
6524 reject('close');
6525 } else {
6526 resolve({ dismiss: 'close' });
6527 }
6528 };
6529
6530 // Closing modal by overlay click
6531 container.onclick = function (e) {
6532 if (e.target !== container) {
6533 return;
6534 }
6535 if (params.allowOutsideClick) {
6536 sweetAlert.closeModal(params.onClose);
6537 if (params.useRejections) {
6538 reject('overlay');
6539 } else {
6540 resolve({ dismiss: 'overlay' });
6541 }
6542 }
6543 };
6544
6545 var buttonsWrapper = getButtonsWrapper();
6546 var confirmButton = getConfirmButton();
6547 var cancelButton = getCancelButton();
6548
6549 // Reverse buttons (Confirm on the right side)
6550 if (params.reverseButtons) {
6551 confirmButton.parentNode.insertBefore(cancelButton, confirmButton);
6552 } else {
6553 confirmButton.parentNode.insertBefore(confirmButton, cancelButton);
6554 }
6555
6556 // Focus handling
6557 var setFocus = function setFocus(index, increment) {
6558 var focusableElements = getFocusableElements(params.focusCancel);
6559 // search for visible elements and select the next possible match
6560 for (var _i3 = 0; _i3 < focusableElements.length; _i3++) {
6561 index = index + increment;
6562
6563 // rollover to first item
6564 if (index === focusableElements.length) {
6565 index = 0;
6566
6567 // go to last item
6568 } else if (index === -1) {
6569 index = focusableElements.length - 1;
6570 }
6571
6572 // determine if element is visible
6573 var el = focusableElements[index];
6574 if (isVisible(el)) {
6575 return el.focus();
6576 }
6577 }
6578 };
6579
6580 var handleKeyDown = function handleKeyDown(event) {
6581 var e = event || window.event;
6582 var keyCode = e.keyCode || e.which;
6583
6584 if ([9, 13, 32, 27, 37, 38, 39, 40].indexOf(keyCode) === -1) {
6585 // Don't do work on keys we don't care about.
6586 return;
6587 }
6588
6589 var targetElement = e.target || e.srcElement;
6590
6591 var focusableElements = getFocusableElements(params.focusCancel);
6592 var btnIndex = -1; // Find the button - note, this is a nodelist, not an array.
6593 for (var _i4 = 0; _i4 < focusableElements.length; _i4++) {
6594 if (targetElement === focusableElements[_i4]) {
6595 btnIndex = _i4;
6596 break;
6597 }
6598 }
6599
6600 // TAB
6601 if (keyCode === 9) {
6602 if (!e.shiftKey) {
6603 // Cycle to the next button
6604 setFocus(btnIndex, 1);
6605 } else {
6606 // Cycle to the prev button
6607 setFocus(btnIndex, -1);
6608 }
6609 e.stopPropagation();
6610 e.preventDefault();
6611
6612 // ARROWS - switch focus between buttons
6613 } else if (keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
6614 // focus Cancel button if Confirm button is currently focused
6615 if (document.activeElement === confirmButton && isVisible(cancelButton)) {
6616 cancelButton.focus();
6617 // and vice versa
6618 } else if (document.activeElement === cancelButton && isVisible(confirmButton)) {
6619 confirmButton.focus();
6620 }
6621
6622 // ENTER/SPACE
6623 } else if (keyCode === 13 || keyCode === 32) {
6624 if (btnIndex === -1 && params.allowEnterKey) {
6625 // ENTER/SPACE clicked outside of a button.
6626 if (params.focusCancel) {
6627 fireClick(cancelButton, e);
6628 } else {
6629 fireClick(confirmButton, e);
6630 }
6631 e.stopPropagation();
6632 e.preventDefault();
6633 }
6634
6635 // ESC
6636 } else if (keyCode === 27 && params.allowEscapeKey === true) {
6637 sweetAlert.closeModal(params.onClose);
6638 if (params.useRejections) {
6639 reject('esc');
6640 } else {
6641 resolve({ dismiss: 'esc' });
6642 }
6643 }
6644 };
6645
6646 if (!window.onkeydown || window.onkeydown.toString() !== handleKeyDown.toString()) {
6647 states.previousWindowKeyDown = window.onkeydown;
6648 window.onkeydown = handleKeyDown;
6649 }
6650
6651 // Loading state
6652 if (params.buttonsStyling) {
6653 confirmButton.style.borderLeftColor = params.confirmButtonColor;
6654 confirmButton.style.borderRightColor = params.confirmButtonColor;
6655 }
6656
6657 /**
6658 * Show spinner instead of Confirm button and disable Cancel button
6659 */
6660 sweetAlert.hideLoading = sweetAlert.disableLoading = function () {
6661 if (!params.showConfirmButton) {
6662 hide(confirmButton);
6663 if (!params.showCancelButton) {
6664 hide(getButtonsWrapper());
6665 }
6666 }
6667 removeClass(buttonsWrapper, swalClasses.loading);
6668 removeClass(modal, swalClasses.loading);
6669 confirmButton.disabled = false;
6670 cancelButton.disabled = false;
6671 };
6672
6673 sweetAlert.getTitle = function () {
6674 return getTitle();
6675 };
6676 sweetAlert.getContent = function () {
6677 return getContent();
6678 };
6679 sweetAlert.getInput = function () {
6680 return getInput();
6681 };
6682 sweetAlert.getImage = function () {
6683 return getImage();
6684 };
6685 sweetAlert.getButtonsWrapper = function () {
6686 return getButtonsWrapper();
6687 };
6688 sweetAlert.getConfirmButton = function () {
6689 return getConfirmButton();
6690 };
6691 sweetAlert.getCancelButton = function () {
6692 return getCancelButton();
6693 };
6694
6695 sweetAlert.enableButtons = function () {
6696 confirmButton.disabled = false;
6697 cancelButton.disabled = false;
6698 };
6699
6700 sweetAlert.disableButtons = function () {
6701 confirmButton.disabled = true;
6702 cancelButton.disabled = true;
6703 };
6704
6705 sweetAlert.enableConfirmButton = function () {
6706 confirmButton.disabled = false;
6707 };
6708
6709 sweetAlert.disableConfirmButton = function () {
6710 confirmButton.disabled = true;
6711 };
6712
6713 sweetAlert.enableInput = function () {
6714 var input = getInput();
6715 if (!input) {
6716 return false;
6717 }
6718 if (input.type === 'radio') {
6719 var radiosContainer = input.parentNode.parentNode;
6720 var radios = radiosContainer.querySelectorAll('input');
6721 for (var _i5 = 0; _i5 < radios.length; _i5++) {
6722 radios[_i5].disabled = false;
6723 }
6724 } else {
6725 input.disabled = false;
6726 }
6727 };
6728
6729 sweetAlert.disableInput = function () {
6730 var input = getInput();
6731 if (!input) {
6732 return false;
6733 }
6734 if (input && input.type === 'radio') {
6735 var radiosContainer = input.parentNode.parentNode;
6736 var radios = radiosContainer.querySelectorAll('input');
6737 for (var _i6 = 0; _i6 < radios.length; _i6++) {
6738 radios[_i6].disabled = true;
6739 }
6740 } else {
6741 input.disabled = true;
6742 }
6743 };
6744
6745 // Set modal min-height to disable scrolling inside the modal
6746 sweetAlert.recalculateHeight = debounce(function () {
6747 var modal = getModal();
6748 if (!modal) {
6749 return;
6750 }
6751 var prevState = modal.style.display;
6752 modal.style.minHeight = '';
6753 show(modal);
6754 modal.style.minHeight = modal.scrollHeight + 1 + 'px';
6755 modal.style.display = prevState;
6756 }, 50);
6757
6758 // Show block with validation error
6759 sweetAlert.showValidationError = function (error) {
6760 var validationError = getValidationError();
6761 validationError.innerHTML = error;
6762 show(validationError);
6763
6764 var input = getInput();
6765 if (input) {
6766 focusInput(input);
6767 addClass(input, swalClasses.inputerror);
6768 }
6769 };
6770
6771 // Hide block with validation error
6772 sweetAlert.resetValidationError = function () {
6773 var validationError = getValidationError();
6774 hide(validationError);
6775 sweetAlert.recalculateHeight();
6776
6777 var input = getInput();
6778 if (input) {
6779 removeClass(input, swalClasses.inputerror);
6780 }
6781 };
6782
6783 sweetAlert.getProgressSteps = function () {
6784 return params.progressSteps;
6785 };
6786
6787 sweetAlert.setProgressSteps = function (progressSteps) {
6788 params.progressSteps = progressSteps;
6789 setParameters(params);
6790 };
6791
6792 sweetAlert.showProgressSteps = function () {
6793 show(getProgressSteps());
6794 };
6795
6796 sweetAlert.hideProgressSteps = function () {
6797 hide(getProgressSteps());
6798 };
6799
6800 sweetAlert.enableButtons();
6801 sweetAlert.hideLoading();
6802 sweetAlert.resetValidationError();
6803
6804 // inputs
6805 var inputTypes = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
6806 var input = void 0;
6807 for (var _i7 = 0; _i7 < inputTypes.length; _i7++) {
6808 var inputClass = swalClasses[inputTypes[_i7]];
6809 var inputContainer = getChildByClass(modal, inputClass);
6810 input = getInput(inputTypes[_i7]);
6811
6812 // set attributes
6813 if (input) {
6814 for (var j in input.attributes) {
6815 if (input.attributes.hasOwnProperty(j)) {
6816 var attrName = input.attributes[j].name;
6817 if (attrName !== 'type' && attrName !== 'value') {
6818 input.removeAttribute(attrName);
6819 }
6820 }
6821 }
6822 for (var attr in params.inputAttributes) {
6823 input.setAttribute(attr, params.inputAttributes[attr]);
6824 }
6825 }
6826
6827 // set class
6828 inputContainer.className = inputClass;
6829 if (params.inputClass) {
6830 addClass(inputContainer, params.inputClass);
6831 }
6832
6833 hide(inputContainer);
6834 }
6835
6836 var populateInputOptions = void 0;
6837 switch (params.input) {
6838 case 'text':
6839 case 'email':
6840 case 'password':
6841 case 'number':
6842 case 'tel':
6843 case 'url':
6844 input = getChildByClass(modal, swalClasses.input);
6845 input.value = params.inputValue;
6846 input.placeholder = params.inputPlaceholder;
6847 input.type = params.input;
6848 show(input);
6849 break;
6850 case 'file':
6851 input = getChildByClass(modal, swalClasses.file);
6852 input.placeholder = params.inputPlaceholder;
6853 input.type = params.input;
6854 show(input);
6855 break;
6856 case 'range':
6857 var range = getChildByClass(modal, swalClasses.range);
6858 var rangeInput = range.querySelector('input');
6859 var rangeOutput = range.querySelector('output');
6860 rangeInput.value = params.inputValue;
6861 rangeInput.type = params.input;
6862 rangeOutput.value = params.inputValue;
6863 show(range);
6864 break;
6865 case 'select':
6866 var select = getChildByClass(modal, swalClasses.select);
6867 select.innerHTML = '';
6868 if (params.inputPlaceholder) {
6869 var placeholder = document.createElement('option');
6870 placeholder.innerHTML = params.inputPlaceholder;
6871 placeholder.value = '';
6872 placeholder.disabled = true;
6873 placeholder.selected = true;
6874 select.appendChild(placeholder);
6875 }
6876 populateInputOptions = function populateInputOptions(inputOptions) {
6877 for (var optionValue in inputOptions) {
6878 var option = document.createElement('option');
6879 option.value = optionValue;
6880 option.innerHTML = inputOptions[optionValue];
6881 if (params.inputValue === optionValue) {
6882 option.selected = true;
6883 }
6884 select.appendChild(option);
6885 }
6886 show(select);
6887 select.focus();
6888 };
6889 break;
6890 case 'radio':
6891 var radio = getChildByClass(modal, swalClasses.radio);
6892 radio.innerHTML = '';
6893 populateInputOptions = function populateInputOptions(inputOptions) {
6894 for (var radioValue in inputOptions) {
6895 var radioInput = document.createElement('input');
6896 var radioLabel = document.createElement('label');
6897 var radioLabelSpan = document.createElement('span');
6898 radioInput.type = 'radio';
6899 radioInput.name = swalClasses.radio;
6900 radioInput.value = radioValue;
6901 if (params.inputValue === radioValue) {
6902 radioInput.checked = true;
6903 }
6904 radioLabelSpan.innerHTML = inputOptions[radioValue];
6905 radioLabel.appendChild(radioInput);
6906 radioLabel.appendChild(radioLabelSpan);
6907 radioLabel.for = radioInput.id;
6908 radio.appendChild(radioLabel);
6909 }
6910 show(radio);
6911 var radios = radio.querySelectorAll('input');
6912 if (radios.length) {
6913 radios[0].focus();
6914 }
6915 };
6916 break;
6917 case 'checkbox':
6918 var checkbox = getChildByClass(modal, swalClasses.checkbox);
6919 var checkboxInput = getInput('checkbox');
6920 checkboxInput.type = 'checkbox';
6921 checkboxInput.value = 1;
6922 checkboxInput.id = swalClasses.checkbox;
6923 checkboxInput.checked = Boolean(params.inputValue);
6924 var label = checkbox.getElementsByTagName('span');
6925 if (label.length) {
6926 checkbox.removeChild(label[0]);
6927 }
6928 label = document.createElement('span');
6929 label.innerHTML = params.inputPlaceholder;
6930 checkbox.appendChild(label);
6931 show(checkbox);
6932 break;
6933 case 'textarea':
6934 var textarea = getChildByClass(modal, swalClasses.textarea);
6935 textarea.value = params.inputValue;
6936 textarea.placeholder = params.inputPlaceholder;
6937 show(textarea);
6938 break;
6939 case null:
6940 break;
6941 default:
6942 console.error('SweetAlert2: Unexpected type of input! Expected "text", "email", "password", "number", "tel", "select", "radio", "checkbox", "textarea", "file" or "url", got "' + params.input + '"');
6943 break;
6944 }
6945
6946 if (params.input === 'select' || params.input === 'radio') {
6947 if (params.inputOptions instanceof Promise) {
6948 sweetAlert.showLoading();
6949 params.inputOptions.then(function (inputOptions) {
6950 sweetAlert.hideLoading();
6951 populateInputOptions(inputOptions);
6952 });
6953 } else if (_typeof(params.inputOptions) === 'object') {
6954 populateInputOptions(params.inputOptions);
6955 } else {
6956 console.error('SweetAlert2: Unexpected type of inputOptions! Expected object or Promise, got ' + _typeof(params.inputOptions));
6957 }
6958 }
6959
6960 openModal(params.animation, params.onOpen);
6961
6962 // Focus the first element (input or button)
6963 if (params.allowEnterKey) {
6964 setFocus(-1, 1);
6965 } else {
6966 if (document.activeElement) {
6967 document.activeElement.blur();
6968 }
6969 }
6970
6971 // fix scroll
6972 getContainer().scrollTop = 0;
6973
6974 // Observe changes inside the modal and adjust height
6975 if (typeof MutationObserver !== 'undefined' && !swal2Observer) {
6976 swal2Observer = new MutationObserver(sweetAlert.recalculateHeight);
6977 swal2Observer.observe(modal, { childList: true, characterData: true, subtree: true });
6978 }
6979 });
6980 };
6981
6982 /*
6983 * Global function to determine if swal2 modal is shown
6984 */
6985 sweetAlert.isVisible = function () {
6986 return !!getModal();
6987 };
6988
6989 /*
6990 * Global function for chaining sweetAlert modals
6991 */
6992 sweetAlert.queue = function (steps) {
6993 queue = steps;
6994 var resetQueue = function resetQueue() {
6995 queue = [];
6996 document.body.removeAttribute('data-swal2-queue-step');
6997 };
6998 var queueResult = [];
6999 return new Promise(function (resolve, reject) {
7000 (function step(i, callback) {
7001 if (i < queue.length) {
7002 document.body.setAttribute('data-swal2-queue-step', i);
7003
7004 sweetAlert(queue[i]).then(function (result) {
7005 queueResult.push(result);
7006 step(i + 1, callback);
7007 }, function (dismiss) {
7008 resetQueue();
7009 reject(dismiss);
7010 });
7011 } else {
7012 resetQueue();
7013 resolve(queueResult);
7014 }
7015 })(0);
7016 });
7017 };
7018
7019 /*
7020 * Global function for getting the index of current modal in queue
7021 */
7022 sweetAlert.getQueueStep = function () {
7023 return document.body.getAttribute('data-swal2-queue-step');
7024 };
7025
7026 /*
7027 * Global function for inserting a modal to the queue
7028 */
7029 sweetAlert.insertQueueStep = function (step, index) {
7030 if (index && index < queue.length) {
7031 return queue.splice(index, 0, step);
7032 }
7033 return queue.push(step);
7034 };
7035
7036 /*
7037 * Global function for deleting a modal from the queue
7038 */
7039 sweetAlert.deleteQueueStep = function (index) {
7040 if (typeof queue[index] !== 'undefined') {
7041 queue.splice(index, 1);
7042 }
7043 };
7044
7045 /*
7046 * Global function to close sweetAlert
7047 */
7048 sweetAlert.close = sweetAlert.closeModal = function (onComplete) {
7049 var container = getContainer();
7050 var modal = getModal();
7051 if (!modal) {
7052 return;
7053 }
7054 removeClass(modal, swalClasses.show);
7055 addClass(modal, swalClasses.hide);
7056 clearTimeout(modal.timeout);
7057
7058 resetPrevState();
7059
7060 var removeModalAndResetState = function removeModalAndResetState() {
7061 if (container.parentNode) {
7062 container.parentNode.removeChild(container);
7063 }
7064 removeClass(document.documentElement, swalClasses.shown);
7065 removeClass(document.body, swalClasses.shown);
7066 undoScrollbar();
7067 undoIOSfix();
7068 };
7069
7070 // If animation is supported, animate
7071 if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
7072 modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
7073 modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
7074 if (hasClass(modal, swalClasses.hide)) {
7075 removeModalAndResetState();
7076 }
7077 });
7078 } else {
7079 // Otherwise, remove immediately
7080 removeModalAndResetState();
7081 }
7082 if (onComplete !== null && typeof onComplete === 'function') {
7083 setTimeout(function () {
7084 onComplete(modal);
7085 });
7086 }
7087 };
7088
7089 /*
7090 * Global function to click 'Confirm' button
7091 */
7092 sweetAlert.clickConfirm = function () {
7093 return getConfirmButton().click();
7094 };
7095
7096 /*
7097 * Global function to click 'Cancel' button
7098 */
7099 sweetAlert.clickCancel = function () {
7100 return getCancelButton().click();
7101 };
7102
7103 /**
7104 * Show spinner instead of Confirm button and disable Cancel button
7105 */
7106 sweetAlert.showLoading = sweetAlert.enableLoading = function () {
7107 var modal = getModal();
7108 if (!modal) {
7109 sweetAlert('');
7110 }
7111 var buttonsWrapper = getButtonsWrapper();
7112 var confirmButton = getConfirmButton();
7113 var cancelButton = getCancelButton();
7114
7115 show(buttonsWrapper);
7116 show(confirmButton, 'inline-block');
7117 addClass(buttonsWrapper, swalClasses.loading);
7118 addClass(modal, swalClasses.loading);
7119 confirmButton.disabled = true;
7120 cancelButton.disabled = true;
7121 };
7122
7123 /**
7124 * Set default params for each popup
7125 * @param {Object} userParams
7126 */
7127 sweetAlert.setDefaults = function (userParams) {
7128 if (!userParams || (typeof userParams === 'undefined' ? 'undefined' : _typeof(userParams)) !== 'object') {
7129 return console.error('SweetAlert2: the argument for setDefaults() is required and has to be a object');
7130 }
7131
7132 for (var param in userParams) {
7133 if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
7134 console.warn('SweetAlert2: Unknown parameter "' + param + '"');
7135 delete userParams[param];
7136 }
7137 }
7138
7139 _extends(modalParams, userParams);
7140 };
7141
7142 /**
7143 * Reset default params for each popup
7144 */
7145 sweetAlert.resetDefaults = function () {
7146 modalParams = _extends({}, defaultParams);
7147 };
7148
7149 sweetAlert.noop = function () {};
7150
7151 sweetAlert.version = '6.6.4';
7152
7153 sweetAlert.default = sweetAlert;
7154
7155 return sweetAlert;
7156
7157 })));
7158 if (window.Sweetalert2) window.sweetAlert = window.swal = window.Sweetalert2;
7159
7160 /* assets/wpuf/vendor/jquery.scrollTo/jquery.scrollTo.js */
7161 /*!
7162 * jQuery.scrollTo
7163 * Copyright (c) 2007-2015 Ariel Flesler - aflesler ○ gmail • com | http://flesler.blogspot.com
7164 * Licensed under MIT
7165 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
7166 * @projectDescription Lightweight, cross-browser and highly customizable animated scrolling with jQuery
7167 * @author Ariel Flesler
7168 * @version 2.1.2
7169 */
7170 ;(function(factory) {
7171 'use strict';
7172 if (typeof define === 'function' && define.amd) {
7173 // AMD
7174 define(['jquery'], factory);
7175 } else if (typeof module !== 'undefined' && module.exports) {
7176 // CommonJS
7177 module.exports = factory(require('jquery'));
7178 } else {
7179 // Global
7180 factory(jQuery);
7181 }
7182 })(function($) {
7183 'use strict';
7184
7185 var $scrollTo = $.scrollTo = function(target, duration, settings) {
7186 return $(window).scrollTo(target, duration, settings);
7187 };
7188
7189 $scrollTo.defaults = {
7190 axis:'xy',
7191 duration: 0,
7192 limit:true
7193 };
7194
7195 function isWin(elem) {
7196 return !elem.nodeName ||
7197 $.inArray(elem.nodeName.toLowerCase(), ['iframe','#document','html','body']) !== -1;
7198 }
7199
7200 $.fn.scrollTo = function(target, duration, settings) {
7201 if (typeof duration === 'object') {
7202 settings = duration;
7203 duration = 0;
7204 }
7205 if (typeof settings === 'function') {
7206 settings = { onAfter:settings };
7207 }
7208 if (target === 'max') {
7209 target = 9e9;
7210 }
7211
7212 settings = $.extend({}, $scrollTo.defaults, settings);
7213 // Speed is still recognized for backwards compatibility
7214 duration = duration || settings.duration;
7215 // Make sure the settings are given right
7216 var queue = settings.queue && settings.axis.length > 1;
7217 if (queue) {
7218 // Let's keep the overall duration
7219 duration /= 2;
7220 }
7221 settings.offset = both(settings.offset);
7222 settings.over = both(settings.over);
7223
7224 return this.each(function() {
7225 // Null target yields nothing, just like jQuery does
7226 if (target === null) return;
7227
7228 var win = isWin(this),
7229 elem = win ? this.contentWindow || window : this,
7230 $elem = $(elem),
7231 targ = target,
7232 attr = {},
7233 toff;
7234
7235 switch (typeof targ) {
7236 // A number will pass the regex
7237 case 'number':
7238 case 'string':
7239 if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
7240 targ = both(targ);
7241 // We are done
7242 break;
7243 }
7244 // Relative/Absolute selector
7245 targ = win ? $(targ) : $(targ, elem);
7246 /* falls through */
7247 case 'object':
7248 if (targ.length === 0) return;
7249 // DOMElement / jQuery
7250 if (targ.is || targ.style) {
7251 // Get the real position of the target
7252 toff = (targ = $(targ)).offset();
7253 }
7254 }
7255
7256 var offset = $.isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset;
7257
7258 $.each(settings.axis.split(''), function(i, axis) {
7259 var Pos = axis === 'x' ? 'Left' : 'Top',
7260 pos = Pos.toLowerCase(),
7261 key = 'scroll' + Pos,
7262 prev = $elem[key](),
7263 max = $scrollTo.max(elem, axis);
7264
7265 if (toff) {// jQuery / DOMElement
7266 attr[key] = toff[pos] + (win ? 0 : prev - $elem.offset()[pos]);
7267
7268 // If it's a dom element, reduce the margin
7269 if (settings.margin) {
7270 attr[key] -= parseInt(targ.css('margin'+Pos), 10) || 0;
7271 attr[key] -= parseInt(targ.css('border'+Pos+'Width'), 10) || 0;
7272 }
7273
7274 attr[key] += offset[pos] || 0;
7275
7276 if (settings.over[pos]) {
7277 // Scroll to a fraction of its width/height
7278 attr[key] += targ[axis === 'x'?'width':'height']() * settings.over[pos];
7279 }
7280 } else {
7281 var val = targ[pos];
7282 // Handle percentage values
7283 attr[key] = val.slice && val.slice(-1) === '%' ?
7284 parseFloat(val) / 100 * max
7285 : val;
7286 }
7287
7288 // Number or 'number'
7289 if (settings.limit && /^\d+$/.test(attr[key])) {
7290 // Check the limits
7291 attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max);
7292 }
7293
7294 // Don't waste time animating, if there's no need.
7295 if (!i && settings.axis.length > 1) {
7296 if (prev === attr[key]) {
7297 // No animation needed
7298 attr = {};
7299 } else if (queue) {
7300 // Intermediate animation
7301 animate(settings.onAfterFirst);
7302 // Don't animate this axis again in the next iteration.
7303 attr = {};
7304 }
7305 }
7306 });
7307
7308 animate(settings.onAfter);
7309
7310 function animate(callback) {
7311 var opts = $.extend({}, settings, {
7312 // The queue setting conflicts with animate()
7313 // Force it to always be true
7314 queue: true,
7315 duration: duration,
7316 complete: callback && function() {
7317 callback.call(elem, targ, settings);
7318 }
7319 });
7320 $elem.animate(attr, opts);
7321 }
7322 });
7323 };
7324
7325 // Max scrolling position, works on quirks mode
7326 // It only fails (not too badly) on IE, quirks mode.
7327 $scrollTo.max = function(elem, axis) {
7328 var Dim = axis === 'x' ? 'Width' : 'Height',
7329 scroll = 'scroll'+Dim;
7330
7331 if (!isWin(elem))
7332 return elem[scroll] - $(elem)[Dim.toLowerCase()]();
7333
7334 var size = 'client' + Dim,
7335 doc = elem.ownerDocument || elem.document,
7336 html = doc.documentElement,
7337 body = doc.body;
7338
7339 return Math.max(html[scroll], body[scroll]) - Math.min(html[size], body[size]);
7340 };
7341
7342 function both(val) {
7343 return $.isFunction(val) || $.isPlainObject(val) ? val : { top:val, left:val };
7344 }
7345
7346 // Add special hooks so that window scroll properties can be animated
7347 $.Tween.propHooks.scrollLeft =
7348 $.Tween.propHooks.scrollTop = {
7349 get: function(t) {
7350 return $(t.elem)[t.prop]();
7351 },
7352 set: function(t) {
7353 var curr = this.get(t);
7354 // If interrupt is true and user scrolled, stop animating
7355 if (t.options.interrupt && t._last && t._last !== curr) {
7356 return $(t.elem).stop();
7357 }
7358 var next = Math.round(t.now);
7359 // Don't waste CPU
7360 // Browsers don't render floating point scroll
7361 if (curr !== next) {
7362 $(t.elem)[t.prop](next);
7363 t._last = this.get(t);
7364 }
7365 }
7366 };
7367
7368 // AMD requirement
7369 return $scrollTo;
7370 });
7371
7372 /* assets/wpuf/vendor/selectize/js/standalone/selectize.js */
7373 /**
7374 * sifter.js
7375 * Copyright (c) 2013 Brian Reavis & contributors
7376 *
7377 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7378 * file except in compliance with the License. You may obtain a copy of the License at:
7379 * http://www.apache.org/licenses/LICENSE-2.0
7380 *
7381 * Unless required by applicable law or agreed to in writing, software distributed under
7382 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
7383 * ANY KIND, either express or implied. See the License for the specific language
7384 * governing permissions and limitations under the License.
7385 *
7386 * @author Brian Reavis <brian@thirdroute.com>
7387 */
7388
7389 (function(root, factory) {
7390 if (typeof define === 'function' && define.amd) {
7391 define('sifter', factory);
7392 } else if (typeof exports === 'object') {
7393 module.exports = factory();
7394 } else {
7395 root.Sifter = factory();
7396 }
7397 }(this, function() {
7398
7399 /**
7400 * Textually searches arrays and hashes of objects
7401 * by property (or multiple properties). Designed
7402 * specifically for autocomplete.
7403 *
7404 * @constructor
7405 * @param {array|object} items
7406 * @param {object} items
7407 */
7408 var Sifter = function(items, settings) {
7409 this.items = items;
7410 this.settings = settings || {diacritics: true};
7411 };
7412
7413 /**
7414 * Splits a search string into an array of individual
7415 * regexps to be used to match results.
7416 *
7417 * @param {string} query
7418 * @returns {array}
7419 */
7420 Sifter.prototype.tokenize = function(query) {
7421 query = trim(String(query || '').toLowerCase());
7422 if (!query || !query.length) return [];
7423
7424 var i, n, regex, letter;
7425 var tokens = [];
7426 var words = query.split(/ +/);
7427
7428 for (i = 0, n = words.length; i < n; i++) {
7429 regex = escape_regex(words[i]);
7430 if (this.settings.diacritics) {
7431 for (letter in DIACRITICS) {
7432 if (DIACRITICS.hasOwnProperty(letter)) {
7433 regex = regex.replace(new RegExp(letter, 'g'), DIACRITICS[letter]);
7434 }
7435 }
7436 }
7437 tokens.push({
7438 string : words[i],
7439 regex : new RegExp(regex, 'i')
7440 });
7441 }
7442
7443 return tokens;
7444 };
7445
7446 /**
7447 * Iterates over arrays and hashes.
7448 *
7449 * ```
7450 * this.iterator(this.items, function(item, id) {
7451 * // invoked for each item
7452 * });
7453 * ```
7454 *
7455 * @param {array|object} object
7456 */
7457 Sifter.prototype.iterator = function(object, callback) {
7458 var iterator;
7459 if (is_array(object)) {
7460 iterator = Array.prototype.forEach || function(callback) {
7461 for (var i = 0, n = this.length; i < n; i++) {
7462 callback(this[i], i, this);
7463 }
7464 };
7465 } else {
7466 iterator = function(callback) {
7467 for (var key in this) {
7468 if (this.hasOwnProperty(key)) {
7469 callback(this[key], key, this);
7470 }
7471 }
7472 };
7473 }
7474
7475 iterator.apply(object, [callback]);
7476 };
7477
7478 /**
7479 * Returns a function to be used to score individual results.
7480 *
7481 * Good matches will have a higher score than poor matches.
7482 * If an item is not a match, 0 will be returned by the function.
7483 *
7484 * @param {object|string} search
7485 * @param {object} options (optional)
7486 * @returns {function}
7487 */
7488 Sifter.prototype.getScoreFunction = function(search, options) {
7489 var self, fields, tokens, token_count, nesting;
7490
7491 self = this;
7492 search = self.prepareSearch(search, options);
7493 tokens = search.tokens;
7494 fields = search.options.fields;
7495 token_count = tokens.length;
7496 nesting = search.options.nesting;
7497
7498 /**
7499 * Calculates how close of a match the
7500 * given value is against a search token.
7501 *
7502 * @param {mixed} value
7503 * @param {object} token
7504 * @return {number}
7505 */
7506 var scoreValue = function(value, token) {
7507 var score, pos;
7508
7509 if (!value) return 0;
7510 value = String(value || '');
7511 pos = value.search(token.regex);
7512 if (pos === -1) return 0;
7513 score = token.string.length / value.length;
7514 if (pos === 0) score += 0.5;
7515 return score;
7516 };
7517
7518 /**
7519 * Calculates the score of an object
7520 * against the search query.
7521 *
7522 * @param {object} token
7523 * @param {object} data
7524 * @return {number}
7525 */
7526 var scoreObject = (function() {
7527 var field_count = fields.length;
7528 if (!field_count) {
7529 return function() { return 0; };
7530 }
7531 if (field_count === 1) {
7532 return function(token, data) {
7533 return scoreValue(getattr(data, fields[0], nesting), token);
7534 };
7535 }
7536 return function(token, data) {
7537 for (var i = 0, sum = 0; i < field_count; i++) {
7538 sum += scoreValue(getattr(data, fields[i], nesting), token);
7539 }
7540 return sum / field_count;
7541 };
7542 })();
7543
7544 if (!token_count) {
7545 return function() { return 0; };
7546 }
7547 if (token_count === 1) {
7548 return function(data) {
7549 return scoreObject(tokens[0], data);
7550 };
7551 }
7552
7553 if (search.options.conjunction === 'and') {
7554 return function(data) {
7555 var score;
7556 for (var i = 0, sum = 0; i < token_count; i++) {
7557 score = scoreObject(tokens[i], data);
7558 if (score <= 0) return 0;
7559 sum += score;
7560 }
7561 return sum / token_count;
7562 };
7563 } else {
7564 return function(data) {
7565 for (var i = 0, sum = 0; i < token_count; i++) {
7566 sum += scoreObject(tokens[i], data);
7567 }
7568 return sum / token_count;
7569 };
7570 }
7571 };
7572
7573 /**
7574 * Returns a function that can be used to compare two
7575 * results, for sorting purposes. If no sorting should
7576 * be performed, `null` will be returned.
7577 *
7578 * @param {string|object} search
7579 * @param {object} options
7580 * @return function(a,b)
7581 */
7582 Sifter.prototype.getSortFunction = function(search, options) {
7583 var i, n, self, field, fields, fields_count, multiplier, multipliers, get_field, implicit_score, sort;
7584
7585 self = this;
7586 search = self.prepareSearch(search, options);
7587 sort = (!search.query && options.sort_empty) || options.sort;
7588
7589 /**
7590 * Fetches the specified sort field value
7591 * from a search result item.
7592 *
7593 * @param {string} name
7594 * @param {object} result
7595 * @return {mixed}
7596 */
7597 get_field = function(name, result) {
7598 if (name === '$score') return result.score;
7599 return getattr(self.items[result.id], name, options.nesting);
7600 };
7601
7602 // parse options
7603 fields = [];
7604 if (sort) {
7605 for (i = 0, n = sort.length; i < n; i++) {
7606 if (search.query || sort[i].field !== '$score') {
7607 fields.push(sort[i]);
7608 }
7609 }
7610 }
7611
7612 // the "$score" field is implied to be the primary
7613 // sort field, unless it's manually specified
7614 if (search.query) {
7615 implicit_score = true;
7616 for (i = 0, n = fields.length; i < n; i++) {
7617 if (fields[i].field === '$score') {
7618 implicit_score = false;
7619 break;
7620 }
7621 }
7622 if (implicit_score) {
7623 fields.unshift({field: '$score', direction: 'desc'});
7624 }
7625 } else {
7626 for (i = 0, n = fields.length; i < n; i++) {
7627 if (fields[i].field === '$score') {
7628 fields.splice(i, 1);
7629 break;
7630 }
7631 }
7632 }
7633
7634 multipliers = [];
7635 for (i = 0, n = fields.length; i < n; i++) {
7636 multipliers.push(fields[i].direction === 'desc' ? -1 : 1);
7637 }
7638
7639 // build function
7640 fields_count = fields.length;
7641 if (!fields_count) {
7642 return null;
7643 } else if (fields_count === 1) {
7644 field = fields[0].field;
7645 multiplier = multipliers[0];
7646 return function(a, b) {
7647 return multiplier * cmp(
7648 get_field(field, a),
7649 get_field(field, b)
7650 );
7651 };
7652 } else {
7653 return function(a, b) {
7654 var i, result, a_value, b_value, field;
7655 for (i = 0; i < fields_count; i++) {
7656 field = fields[i].field;
7657 result = multipliers[i] * cmp(
7658 get_field(field, a),
7659 get_field(field, b)
7660 );
7661 if (result) return result;
7662 }
7663 return 0;
7664 };
7665 }
7666 };
7667
7668 /**
7669 * Parses a search query and returns an object
7670 * with tokens and fields ready to be populated
7671 * with results.
7672 *
7673 * @param {string} query
7674 * @param {object} options
7675 * @returns {object}
7676 */
7677 Sifter.prototype.prepareSearch = function(query, options) {
7678 if (typeof query === 'object') return query;
7679
7680 options = extend({}, options);
7681
7682 var option_fields = options.fields;
7683 var option_sort = options.sort;
7684 var option_sort_empty = options.sort_empty;
7685
7686 if (option_fields && !is_array(option_fields)) options.fields = [option_fields];
7687 if (option_sort && !is_array(option_sort)) options.sort = [option_sort];
7688 if (option_sort_empty && !is_array(option_sort_empty)) options.sort_empty = [option_sort_empty];
7689
7690 return {
7691 options : options,
7692 query : String(query || '').toLowerCase(),
7693 tokens : this.tokenize(query),
7694 total : 0,
7695 items : []
7696 };
7697 };
7698
7699 /**
7700 * Searches through all items and returns a sorted array of matches.
7701 *
7702 * The `options` parameter can contain:
7703 *
7704 * - fields {string|array}
7705 * - sort {array}
7706 * - score {function}
7707 * - filter {bool}
7708 * - limit {integer}
7709 *
7710 * Returns an object containing:
7711 *
7712 * - options {object}
7713 * - query {string}
7714 * - tokens {array}
7715 * - total {int}
7716 * - items {array}
7717 *
7718 * @param {string} query
7719 * @param {object} options
7720 * @returns {object}
7721 */
7722 Sifter.prototype.search = function(query, options) {
7723 var self = this, value, score, search, calculateScore;
7724 var fn_sort;
7725 var fn_score;
7726
7727 search = this.prepareSearch(query, options);
7728 options = search.options;
7729 query = search.query;
7730
7731 // generate result scoring function
7732 fn_score = options.score || self.getScoreFunction(search);
7733
7734 // perform search and sort
7735 if (query.length) {
7736 self.iterator(self.items, function(item, id) {
7737 score = fn_score(item);
7738 if (options.filter === false || score > 0) {
7739 search.items.push({'score': score, 'id': id});
7740 }
7741 });
7742 } else {
7743 self.iterator(self.items, function(item, id) {
7744 search.items.push({'score': 1, 'id': id});
7745 });
7746 }
7747
7748 fn_sort = self.getSortFunction(search, options);
7749 if (fn_sort) search.items.sort(fn_sort);
7750
7751 // apply limits
7752 search.total = search.items.length;
7753 if (typeof options.limit === 'number') {
7754 search.items = search.items.slice(0, options.limit);
7755 }
7756
7757 return search;
7758 };
7759
7760 // utilities
7761 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7762
7763 var cmp = function(a, b) {
7764 if (typeof a === 'number' && typeof b === 'number') {
7765 return a > b ? 1 : (a < b ? -1 : 0);
7766 }
7767 a = asciifold(String(a || ''));
7768 b = asciifold(String(b || ''));
7769 if (a > b) return 1;
7770 if (b > a) return -1;
7771 return 0;
7772 };
7773
7774 var extend = function(a, b) {
7775 var i, n, k, object;
7776 for (i = 1, n = arguments.length; i < n; i++) {
7777 object = arguments[i];
7778 if (!object) continue;
7779 for (k in object) {
7780 if (object.hasOwnProperty(k)) {
7781 a[k] = object[k];
7782 }
7783 }
7784 }
7785 return a;
7786 };
7787
7788 /**
7789 * A property getter resolving dot-notation
7790 * @param {Object} obj The root object to fetch property on
7791 * @param {String} name The optionally dotted property name to fetch
7792 * @param {Boolean} nesting Handle nesting or not
7793 * @return {Object} The resolved property value
7794 */
7795 var getattr = function(obj, name, nesting) {
7796 if (!obj || !name) return;
7797 if (!nesting) return obj[name];
7798 var names = name.split(".");
7799 while(names.length && (obj = obj[names.shift()]));
7800 return obj;
7801 };
7802
7803 var trim = function(str) {
7804 return (str + '').replace(/^\s+|\s+$|/g, '');
7805 };
7806
7807 var escape_regex = function(str) {
7808 return (str + '').replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
7809 };
7810
7811 var is_array = Array.isArray || (typeof $ !== 'undefined' && $.isArray) || function(object) {
7812 return Object.prototype.toString.call(object) === '[object Array]';
7813 };
7814
7815 var DIACRITICS = {
7816 'a': '[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]',
7817 'b': '[b␢βΒB฿𐌁ᛒ]',
7818 'c': '[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]',
7819 'd': '[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]',
7820 'e': '[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]',
7821 'f': '[fƑƒḞḟ]',
7822 'g': '[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]',
7823 'h': '[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]',
7824 'i': '[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]',
7825 'j': '[jȷĴĵɈɉʝɟʲ]',
7826 'k': '[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]',
7827 'l': '[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]',
7828 'n': '[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]',
7829 'o': '[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]',
7830 'p': '[pṔṕṖṗⱣᵽƤƥᵱ]',
7831 'q': '[qꝖꝗʠɊɋꝘꝙq̃]',
7832 'r': '[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]',
7833 's': '[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]',
7834 't': '[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]',
7835 'u': '[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]',
7836 'v': '[vṼṽṾṿƲʋꝞꝟⱱʋ]',
7837 'w': '[wẂẃẀẁŴŵẄẅẆẇẈẉ]',
7838 'x': '[xẌẍẊẋχ]',
7839 'y': '[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]',
7840 'z': '[zŹźẐẑŽžŻżẒẓẔẕƵƶ]'
7841 };
7842
7843 var asciifold = (function() {
7844 var i, n, k, chunk;
7845 var foreignletters = '';
7846 var lookup = {};
7847 for (k in DIACRITICS) {
7848 if (DIACRITICS.hasOwnProperty(k)) {
7849 chunk = DIACRITICS[k].substring(2, DIACRITICS[k].length - 1);
7850 foreignletters += chunk;
7851 for (i = 0, n = chunk.length; i < n; i++) {
7852 lookup[chunk.charAt(i)] = k;
7853 }
7854 }
7855 }
7856 var regexp = new RegExp('[' + foreignletters + ']', 'g');
7857 return function(str) {
7858 return str.replace(regexp, function(foreignletter) {
7859 return lookup[foreignletter];
7860 }).toLowerCase();
7861 };
7862 })();
7863
7864
7865 // export
7866 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7867
7868 return Sifter;
7869 }));
7870
7871
7872
7873 /**
7874 * microplugin.js
7875 * Copyright (c) 2013 Brian Reavis & contributors
7876 *
7877 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7878 * file except in compliance with the License. You may obtain a copy of the License at:
7879 * http://www.apache.org/licenses/LICENSE-2.0
7880 *
7881 * Unless required by applicable law or agreed to in writing, software distributed under
7882 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
7883 * ANY KIND, either express or implied. See the License for the specific language
7884 * governing permissions and limitations under the License.
7885 *
7886 * @author Brian Reavis <brian@thirdroute.com>
7887 */
7888
7889 (function(root, factory) {
7890 if (typeof define === 'function' && define.amd) {
7891 define('microplugin', factory);
7892 } else if (typeof exports === 'object') {
7893 module.exports = factory();
7894 } else {
7895 root.MicroPlugin = factory();
7896 }
7897 }(this, function() {
7898 var MicroPlugin = {};
7899
7900 MicroPlugin.mixin = function(Interface) {
7901 Interface.plugins = {};
7902
7903 /**
7904 * Initializes the listed plugins (with options).
7905 * Acceptable formats:
7906 *
7907 * List (without options):
7908 * ['a', 'b', 'c']
7909 *
7910 * List (with options):
7911 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
7912 *
7913 * Hash (with options):
7914 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
7915 *
7916 * @param {mixed} plugins
7917 */
7918 Interface.prototype.initializePlugins = function(plugins) {
7919 var i, n, key;
7920 var self = this;
7921 var queue = [];
7922
7923 self.plugins = {
7924 names : [],
7925 settings : {},
7926 requested : {},
7927 loaded : {}
7928 };
7929
7930 if (utils.isArray(plugins)) {
7931 for (i = 0, n = plugins.length; i < n; i++) {
7932 if (typeof plugins[i] === 'string') {
7933 queue.push(plugins[i]);
7934 } else {
7935 self.plugins.settings[plugins[i].name] = plugins[i].options;
7936 queue.push(plugins[i].name);
7937 }
7938 }
7939 } else if (plugins) {
7940 for (key in plugins) {
7941 if (plugins.hasOwnProperty(key)) {
7942 self.plugins.settings[key] = plugins[key];
7943 queue.push(key);
7944 }
7945 }
7946 }
7947
7948 while (queue.length) {
7949 self.require(queue.shift());
7950 }
7951 };
7952
7953 Interface.prototype.loadPlugin = function(name) {
7954 var self = this;
7955 var plugins = self.plugins;
7956 var plugin = Interface.plugins[name];
7957
7958 if (!Interface.plugins.hasOwnProperty(name)) {
7959 throw new Error('Unable to find "' + name + '" plugin');
7960 }
7961
7962 plugins.requested[name] = true;
7963 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
7964 plugins.names.push(name);
7965 };
7966
7967 /**
7968 * Initializes a plugin.
7969 *
7970 * @param {string} name
7971 */
7972 Interface.prototype.require = function(name) {
7973 var self = this;
7974 var plugins = self.plugins;
7975
7976 if (!self.plugins.loaded.hasOwnProperty(name)) {
7977 if (plugins.requested[name]) {
7978 throw new Error('Plugin has circular dependency ("' + name + '")');
7979 }
7980 self.loadPlugin(name);
7981 }
7982
7983 return plugins.loaded[name];
7984 };
7985
7986 /**
7987 * Registers a plugin.
7988 *
7989 * @param {string} name
7990 * @param {function} fn
7991 */
7992 Interface.define = function(name, fn) {
7993 Interface.plugins[name] = {
7994 'name' : name,
7995 'fn' : fn
7996 };
7997 };
7998 };
7999
8000 var utils = {
8001 isArray: Array.isArray || function(vArg) {
8002 return Object.prototype.toString.call(vArg) === '[object Array]';
8003 }
8004 };
8005
8006 return MicroPlugin;
8007 }));
8008
8009 /**
8010 * selectize.js (v0.12.4)
8011 * Copyright (c) 2013–2015 Brian Reavis & contributors
8012 *
8013 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8014 * file except in compliance with the License. You may obtain a copy of the License at:
8015 * http://www.apache.org/licenses/LICENSE-2.0
8016 *
8017 * Unless required by applicable law or agreed to in writing, software distributed under
8018 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8019 * ANY KIND, either express or implied. See the License for the specific language
8020 * governing permissions and limitations under the License.
8021 *
8022 * @author Brian Reavis <brian@thirdroute.com>
8023 */
8024
8025 /*jshint curly:false */
8026 /*jshint browser:true */
8027
8028 (function(root, factory) {
8029 if (typeof define === 'function' && define.amd) {
8030 define('selectize', ['jquery','sifter','microplugin'], factory);
8031 } else if (typeof exports === 'object') {
8032 module.exports = factory(require('jquery'), require('sifter'), require('microplugin'));
8033 } else {
8034 root.Selectize = factory(root.jQuery, root.Sifter, root.MicroPlugin);
8035 }
8036 }(this, function($, Sifter, MicroPlugin) {
8037 'use strict';
8038
8039 var highlight = function($element, pattern) {
8040 if (typeof pattern === 'string' && !pattern.length) return;
8041 var regex = (typeof pattern === 'string') ? new RegExp(pattern, 'i') : pattern;
8042
8043 var highlight = function(node) {
8044 var skip = 0;
8045 if (node.nodeType === 3) {
8046 var pos = node.data.search(regex);
8047 if (pos >= 0 && node.data.length > 0) {
8048 var match = node.data.match(regex);
8049 var spannode = document.createElement('span');
8050 spannode.className = 'highlight';
8051 var middlebit = node.splitText(pos);
8052 var endbit = middlebit.splitText(match[0].length);
8053 var middleclone = middlebit.cloneNode(true);
8054 spannode.appendChild(middleclone);
8055 middlebit.parentNode.replaceChild(spannode, middlebit);
8056 skip = 1;
8057 }
8058 } else if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
8059 for (var i = 0; i < node.childNodes.length; ++i) {
8060 i += highlight(node.childNodes[i]);
8061 }
8062 }
8063 return skip;
8064 };
8065
8066 return $element.each(function() {
8067 highlight(this);
8068 });
8069 };
8070
8071 /**
8072 * removeHighlight fn copied from highlight v5 and
8073 * edited to remove with() and pass js strict mode
8074 */
8075 $.fn.removeHighlight = function() {
8076 return this.find("span.highlight").each(function() {
8077 this.parentNode.firstChild.nodeName;
8078 var parent = this.parentNode;
8079 parent.replaceChild(this.firstChild, this);
8080 parent.normalize();
8081 }).end();
8082 };
8083
8084
8085 var MicroEvent = function() {};
8086 MicroEvent.prototype = {
8087 on: function(event, fct){
8088 this._events = this._events || {};
8089 this._events[event] = this._events[event] || [];
8090 this._events[event].push(fct);
8091 },
8092 off: function(event, fct){
8093 var n = arguments.length;
8094 if (n === 0) return delete this._events;
8095 if (n === 1) return delete this._events[event];
8096
8097 this._events = this._events || {};
8098 if (event in this._events === false) return;
8099 this._events[event].splice(this._events[event].indexOf(fct), 1);
8100 },
8101 trigger: function(event /* , args... */){
8102 this._events = this._events || {};
8103 if (event in this._events === false) return;
8104 for (var i = 0; i < this._events[event].length; i++){
8105 this._events[event][i].apply(this, Array.prototype.slice.call(arguments, 1));
8106 }
8107 }
8108 };
8109
8110 /**
8111 * Mixin will delegate all MicroEvent.js function in the destination object.
8112 *
8113 * - MicroEvent.mixin(Foobar) will make Foobar able to use MicroEvent
8114 *
8115 * @param {object} the object which will support MicroEvent
8116 */
8117 MicroEvent.mixin = function(destObject){
8118 var props = ['on', 'off', 'trigger'];
8119 for (var i = 0; i < props.length; i++){
8120 destObject.prototype[props[i]] = MicroEvent.prototype[props[i]];
8121 }
8122 };
8123
8124 var IS_MAC = /Mac/.test(navigator.userAgent);
8125
8126 var KEY_A = 65;
8127 var KEY_COMMA = 188;
8128 var KEY_RETURN = 13;
8129 var KEY_ESC = 27;
8130 var KEY_LEFT = 37;
8131 var KEY_UP = 38;
8132 var KEY_P = 80;
8133 var KEY_RIGHT = 39;
8134 var KEY_DOWN = 40;
8135 var KEY_N = 78;
8136 var KEY_BACKSPACE = 8;
8137 var KEY_DELETE = 46;
8138 var KEY_SHIFT = 16;
8139 var KEY_CMD = IS_MAC ? 91 : 17;
8140 var KEY_CTRL = IS_MAC ? 18 : 17;
8141 var KEY_TAB = 9;
8142
8143 var TAG_SELECT = 1;
8144 var TAG_INPUT = 2;
8145
8146 // for now, android support in general is too spotty to support validity
8147 var SUPPORTS_VALIDITY_API = !/android/i.test(window.navigator.userAgent) && !!document.createElement('input').validity;
8148
8149
8150 var isset = function(object) {
8151 return typeof object !== 'undefined';
8152 };
8153
8154 /**
8155 * Converts a scalar to its best string representation
8156 * for hash keys and HTML attribute values.
8157 *
8158 * Transformations:
8159 * 'str' -> 'str'
8160 * null -> ''
8161 * undefined -> ''
8162 * true -> '1'
8163 * false -> '0'
8164 * 0 -> '0'
8165 * 1 -> '1'
8166 *
8167 * @param {string} value
8168 * @returns {string|null}
8169 */
8170 var hash_key = function(value) {
8171 if (typeof value === 'undefined' || value === null) return null;
8172 if (typeof value === 'boolean') return value ? '1' : '0';
8173 return value + '';
8174 };
8175
8176 /**
8177 * Escapes a string for use within HTML.
8178 *
8179 * @param {string} str
8180 * @returns {string}
8181 */
8182 var escape_html = function(str) {
8183 return (str + '')
8184 .replace(/&/g, '&amp;')
8185 .replace(/</g, '&lt;')
8186 .replace(/>/g, '&gt;')
8187 .replace(/"/g, '&quot;');
8188 };
8189
8190 /**
8191 * Escapes "$" characters in replacement strings.
8192 *
8193 * @param {string} str
8194 * @returns {string}
8195 */
8196 var escape_replace = function(str) {
8197 return (str + '').replace(/\$/g, '$$$$');
8198 };
8199
8200 var hook = {};
8201
8202 /**
8203 * Wraps `method` on `self` so that `fn`
8204 * is invoked before the original method.
8205 *
8206 * @param {object} self
8207 * @param {string} method
8208 * @param {function} fn
8209 */
8210 hook.before = function(self, method, fn) {
8211 var original = self[method];
8212 self[method] = function() {
8213 fn.apply(self, arguments);
8214 return original.apply(self, arguments);
8215 };
8216 };
8217
8218 /**
8219 * Wraps `method` on `self` so that `fn`
8220 * is invoked after the original method.
8221 *
8222 * @param {object} self
8223 * @param {string} method
8224 * @param {function} fn
8225 */
8226 hook.after = function(self, method, fn) {
8227 var original = self[method];
8228 self[method] = function() {
8229 var result = original.apply(self, arguments);
8230 fn.apply(self, arguments);
8231 return result;
8232 };
8233 };
8234
8235 /**
8236 * Wraps `fn` so that it can only be invoked once.
8237 *
8238 * @param {function} fn
8239 * @returns {function}
8240 */
8241 var once = function(fn) {
8242 var called = false;
8243 return function() {
8244 if (called) return;
8245 called = true;
8246 fn.apply(this, arguments);
8247 };
8248 };
8249
8250 /**
8251 * Wraps `fn` so that it can only be called once
8252 * every `delay` milliseconds (invoked on the falling edge).
8253 *
8254 * @param {function} fn
8255 * @param {int} delay
8256 * @returns {function}
8257 */
8258 var debounce = function(fn, delay) {
8259 var timeout;
8260 return function() {
8261 var self = this;
8262 var args = arguments;
8263 window.clearTimeout(timeout);
8264 timeout = window.setTimeout(function() {
8265 fn.apply(self, args);
8266 }, delay);
8267 };
8268 };
8269
8270 /**
8271 * Debounce all fired events types listed in `types`
8272 * while executing the provided `fn`.
8273 *
8274 * @param {object} self
8275 * @param {array} types
8276 * @param {function} fn
8277 */
8278 var debounce_events = function(self, types, fn) {
8279 var type;
8280 var trigger = self.trigger;
8281 var event_args = {};
8282
8283 // override trigger method
8284 self.trigger = function() {
8285 var type = arguments[0];
8286 if (types.indexOf(type) !== -1) {
8287 event_args[type] = arguments;
8288 } else {
8289 return trigger.apply(self, arguments);
8290 }
8291 };
8292
8293 // invoke provided function
8294 fn.apply(self, []);
8295 self.trigger = trigger;
8296
8297 // trigger queued events
8298 for (type in event_args) {
8299 if (event_args.hasOwnProperty(type)) {
8300 trigger.apply(self, event_args[type]);
8301 }
8302 }
8303 };
8304
8305 /**
8306 * A workaround for http://bugs.jquery.com/ticket/6696
8307 *
8308 * @param {object} $parent - Parent element to listen on.
8309 * @param {string} event - Event name.
8310 * @param {string} selector - Descendant selector to filter by.
8311 * @param {function} fn - Event handler.
8312 */
8313 var watchChildEvent = function($parent, event, selector, fn) {
8314 $parent.on(event, selector, function(e) {
8315 var child = e.target;
8316 while (child && child.parentNode !== $parent[0]) {
8317 child = child.parentNode;
8318 }
8319 e.currentTarget = child;
8320 return fn.apply(this, [e]);
8321 });
8322 };
8323
8324 /**
8325 * Determines the current selection within a text input control.
8326 * Returns an object containing:
8327 * - start
8328 * - length
8329 *
8330 * @param {object} input
8331 * @returns {object}
8332 */
8333 var getSelection = function(input) {
8334 var result = {};
8335 if ('selectionStart' in input) {
8336 result.start = input.selectionStart;
8337 result.length = input.selectionEnd - result.start;
8338 } else if (document.selection) {
8339 input.focus();
8340 var sel = document.selection.createRange();
8341 var selLen = document.selection.createRange().text.length;
8342 sel.moveStart('character', -input.value.length);
8343 result.start = sel.text.length - selLen;
8344 result.length = selLen;
8345 }
8346 return result;
8347 };
8348
8349 /**
8350 * Copies CSS properties from one element to another.
8351 *
8352 * @param {object} $from
8353 * @param {object} $to
8354 * @param {array} properties
8355 */
8356 var transferStyles = function($from, $to, properties) {
8357 var i, n, styles = {};
8358 if (properties) {
8359 for (i = 0, n = properties.length; i < n; i++) {
8360 styles[properties[i]] = $from.css(properties[i]);
8361 }
8362 } else {
8363 styles = $from.css();
8364 }
8365 $to.css(styles);
8366 };
8367
8368 /**
8369 * Measures the width of a string within a
8370 * parent element (in pixels).
8371 *
8372 * @param {string} str
8373 * @param {object} $parent
8374 * @returns {int}
8375 */
8376 var measureString = function(str, $parent) {
8377 if (!str) {
8378 return 0;
8379 }
8380
8381 var $test = $('<test>').css({
8382 position: 'absolute',
8383 top: -99999,
8384 left: -99999,
8385 width: 'auto',
8386 padding: 0,
8387 whiteSpace: 'pre'
8388 }).text(str).appendTo('body');
8389
8390 transferStyles($parent, $test, [
8391 'letterSpacing',
8392 'fontSize',
8393 'fontFamily',
8394 'fontWeight',
8395 'textTransform'
8396 ]);
8397
8398 var width = $test.width();
8399 $test.remove();
8400
8401 return width;
8402 };
8403
8404 /**
8405 * Sets up an input to grow horizontally as the user
8406 * types. If the value is changed manually, you can
8407 * trigger the "update" handler to resize:
8408 *
8409 * $input.trigger('update');
8410 *
8411 * @param {object} $input
8412 */
8413 var autoGrow = function($input) {
8414 var currentWidth = null;
8415
8416 var update = function(e, options) {
8417 var value, keyCode, printable, placeholder, width;
8418 var shift, character, selection;
8419 e = e || window.event || {};
8420 options = options || {};
8421
8422 if (e.metaKey || e.altKey) return;
8423 if (!options.force && $input.data('grow') === false) return;
8424
8425 value = $input.val();
8426 if (e.type && e.type.toLowerCase() === 'keydown') {
8427 keyCode = e.keyCode;
8428 printable = (
8429 (keyCode >= 97 && keyCode <= 122) || // a-z
8430 (keyCode >= 65 && keyCode <= 90) || // A-Z
8431 (keyCode >= 48 && keyCode <= 57) || // 0-9
8432 keyCode === 32 // space
8433 );
8434
8435 if (keyCode === KEY_DELETE || keyCode === KEY_BACKSPACE) {
8436 selection = getSelection($input[0]);
8437 if (selection.length) {
8438 value = value.substring(0, selection.start) + value.substring(selection.start + selection.length);
8439 } else if (keyCode === KEY_BACKSPACE && selection.start) {
8440 value = value.substring(0, selection.start - 1) + value.substring(selection.start + 1);
8441 } else if (keyCode === KEY_DELETE && typeof selection.start !== 'undefined') {
8442 value = value.substring(0, selection.start) + value.substring(selection.start + 1);
8443 }
8444 } else if (printable) {
8445 shift = e.shiftKey;
8446 character = String.fromCharCode(e.keyCode);
8447 if (shift) character = character.toUpperCase();
8448 else character = character.toLowerCase();
8449 value += character;
8450 }
8451 }
8452
8453 placeholder = $input.attr('placeholder');
8454 if (!value && placeholder) {
8455 value = placeholder;
8456 }
8457
8458 width = measureString(value, $input) + 4;
8459 if (width !== currentWidth) {
8460 currentWidth = width;
8461 $input.width(width);
8462 $input.triggerHandler('resize');
8463 }
8464 };
8465
8466 $input.on('keydown keyup update blur', update);
8467 update();
8468 };
8469
8470 var domToString = function(d) {
8471 var tmp = document.createElement('div');
8472
8473 tmp.appendChild(d.cloneNode(true));
8474
8475 return tmp.innerHTML;
8476 };
8477
8478 var logError = function(message, options){
8479 if(!options) options = {};
8480 var component = "Selectize";
8481
8482 console.error(component + ": " + message)
8483
8484 if(options.explanation){
8485 // console.group is undefined in <IE11
8486 if(console.group) console.group();
8487 console.error(options.explanation);
8488 if(console.group) console.groupEnd();
8489 }
8490 }
8491
8492
8493 var Selectize = function($input, settings) {
8494 var key, i, n, dir, input, self = this;
8495 input = $input[0];
8496 input.selectize = self;
8497
8498 // detect rtl environment
8499 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
8500 dir = computedStyle ? computedStyle.getPropertyValue('direction') : input.currentStyle && input.currentStyle.direction;
8501 dir = dir || $input.parents('[dir]:first').attr('dir') || '';
8502
8503 // setup default state
8504 $.extend(self, {
8505 order : 0,
8506 settings : settings,
8507 $input : $input,
8508 tabIndex : $input.attr('tabindex') || '',
8509 tagType : input.tagName.toLowerCase() === 'select' ? TAG_SELECT : TAG_INPUT,
8510 rtl : /rtl/i.test(dir),
8511
8512 eventNS : '.selectize' + (++Selectize.count),
8513 highlightedValue : null,
8514 isOpen : false,
8515 isDisabled : false,
8516 isRequired : $input.is('[required]'),
8517 isInvalid : false,
8518 isLocked : false,
8519 isFocused : false,
8520 isInputHidden : false,
8521 isSetup : false,
8522 isShiftDown : false,
8523 isCmdDown : false,
8524 isCtrlDown : false,
8525 ignoreFocus : false,
8526 ignoreBlur : false,
8527 ignoreHover : false,
8528 hasOptions : false,
8529 currentResults : null,
8530 lastValue : '',
8531 caretPos : 0,
8532 loading : 0,
8533 loadedSearches : {},
8534
8535 $activeOption : null,
8536 $activeItems : [],
8537
8538 optgroups : {},
8539 options : {},
8540 userOptions : {},
8541 items : [],
8542 renderCache : {},
8543 onSearchChange : settings.loadThrottle === null ? self.onSearchChange : debounce(self.onSearchChange, settings.loadThrottle)
8544 });
8545
8546 // search system
8547 self.sifter = new Sifter(this.options, {diacritics: settings.diacritics});
8548
8549 // build options table
8550 if (self.settings.options) {
8551 for (i = 0, n = self.settings.options.length; i < n; i++) {
8552 self.registerOption(self.settings.options[i]);
8553 }
8554 delete self.settings.options;
8555 }
8556
8557 // build optgroup table
8558 if (self.settings.optgroups) {
8559 for (i = 0, n = self.settings.optgroups.length; i < n; i++) {
8560 self.registerOptionGroup(self.settings.optgroups[i]);
8561 }
8562 delete self.settings.optgroups;
8563 }
8564
8565 // option-dependent defaults
8566 self.settings.mode = self.settings.mode || (self.settings.maxItems === 1 ? 'single' : 'multi');
8567 if (typeof self.settings.hideSelected !== 'boolean') {
8568 self.settings.hideSelected = self.settings.mode === 'multi';
8569 }
8570
8571 self.initializePlugins(self.settings.plugins);
8572 self.setupCallbacks();
8573 self.setupTemplates();
8574 self.setup();
8575 };
8576
8577 // mixins
8578 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
8579
8580 MicroEvent.mixin(Selectize);
8581
8582 if(typeof MicroPlugin !== "undefined"){
8583 MicroPlugin.mixin(Selectize);
8584 }else{
8585 logError("Dependency MicroPlugin is missing",
8586 {explanation:
8587 "Make sure you either: (1) are using the \"standalone\" "+
8588 "version of Selectize, or (2) require MicroPlugin before you "+
8589 "load Selectize."}
8590 );
8591 }
8592
8593
8594 // methods
8595 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
8596
8597 $.extend(Selectize.prototype, {
8598
8599 /**
8600 * Creates all elements and sets up event bindings.
8601 */
8602 setup: function() {
8603 var self = this;
8604 var settings = self.settings;
8605 var eventNS = self.eventNS;
8606 var $window = $(window);
8607 var $document = $(document);
8608 var $input = self.$input;
8609
8610 var $wrapper;
8611 var $control;
8612 var $control_input;
8613 var $dropdown;
8614 var $dropdown_content;
8615 var $dropdown_parent;
8616 var inputMode;
8617 var timeout_blur;
8618 var timeout_focus;
8619 var classes;
8620 var classes_plugins;
8621 var inputId;
8622
8623 inputMode = self.settings.mode;
8624 classes = $input.attr('class') || '';
8625
8626 $wrapper = $('<div>').addClass(settings.wrapperClass).addClass(classes).addClass(inputMode);
8627 $control = $('<div>').addClass(settings.inputClass).addClass('items').appendTo($wrapper);
8628 $control_input = $('<input type="text" autocomplete="off" />').appendTo($control).attr('tabindex', $input.is(':disabled') ? '-1' : self.tabIndex);
8629 $dropdown_parent = $(settings.dropdownParent || $wrapper);
8630 $dropdown = $('<div>').addClass(settings.dropdownClass).addClass(inputMode).hide().appendTo($dropdown_parent);
8631 $dropdown_content = $('<div>').addClass(settings.dropdownContentClass).appendTo($dropdown);
8632
8633 if(inputId = $input.attr('id')) {
8634 $control_input.attr('id', inputId + '-selectized');
8635 $("label[for='"+inputId+"']").attr('for', inputId + '-selectized');
8636 }
8637
8638 if(self.settings.copyClassesToDropdown) {
8639 $dropdown.addClass(classes);
8640 }
8641
8642 $wrapper.css({
8643 width: $input[0].style.width
8644 });
8645
8646 if (self.plugins.names.length) {
8647 classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
8648 $wrapper.addClass(classes_plugins);
8649 $dropdown.addClass(classes_plugins);
8650 }
8651
8652 if ((settings.maxItems === null || settings.maxItems > 1) && self.tagType === TAG_SELECT) {
8653 $input.attr('multiple', 'multiple');
8654 }
8655
8656 if (self.settings.placeholder) {
8657 $control_input.attr('placeholder', settings.placeholder);
8658 }
8659
8660 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
8661 if (!self.settings.splitOn && self.settings.delimiter) {
8662 var delimiterEscaped = self.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
8663 self.settings.splitOn = new RegExp('\\s*' + delimiterEscaped + '+\\s*');
8664 }
8665
8666 if ($input.attr('autocorrect')) {
8667 $control_input.attr('autocorrect', $input.attr('autocorrect'));
8668 }
8669
8670 if ($input.attr('autocapitalize')) {
8671 $control_input.attr('autocapitalize', $input.attr('autocapitalize'));
8672 }
8673
8674 self.$wrapper = $wrapper;
8675 self.$control = $control;
8676 self.$control_input = $control_input;
8677 self.$dropdown = $dropdown;
8678 self.$dropdown_content = $dropdown_content;
8679
8680 $dropdown.on('mouseenter', '[data-selectable]', function() { return self.onOptionHover.apply(self, arguments); });
8681 $dropdown.on('mousedown click', '[data-selectable]', function() { return self.onOptionSelect.apply(self, arguments); });
8682 watchChildEvent($control, 'mousedown', '*:not(input)', function() { return self.onItemSelect.apply(self, arguments); });
8683 autoGrow($control_input);
8684
8685 $control.on({
8686 mousedown : function() { return self.onMouseDown.apply(self, arguments); },
8687 click : function() { return self.onClick.apply(self, arguments); }
8688 });
8689
8690 $control_input.on({
8691 mousedown : function(e) { e.stopPropagation(); },
8692 keydown : function() { return self.onKeyDown.apply(self, arguments); },
8693 keyup : function() { return self.onKeyUp.apply(self, arguments); },
8694 keypress : function() { return self.onKeyPress.apply(self, arguments); },
8695 resize : function() { self.positionDropdown.apply(self, []); },
8696 blur : function() { return self.onBlur.apply(self, arguments); },
8697 focus : function() { self.ignoreBlur = false; return self.onFocus.apply(self, arguments); },
8698 paste : function() { return self.onPaste.apply(self, arguments); }
8699 });
8700
8701 $document.on('keydown' + eventNS, function(e) {
8702 self.isCmdDown = e[IS_MAC ? 'metaKey' : 'ctrlKey'];
8703 self.isCtrlDown = e[IS_MAC ? 'altKey' : 'ctrlKey'];
8704 self.isShiftDown = e.shiftKey;
8705 });
8706
8707 $document.on('keyup' + eventNS, function(e) {
8708 if (e.keyCode === KEY_CTRL) self.isCtrlDown = false;
8709 if (e.keyCode === KEY_SHIFT) self.isShiftDown = false;
8710 if (e.keyCode === KEY_CMD) self.isCmdDown = false;
8711 });
8712
8713 $document.on('mousedown' + eventNS, function(e) {
8714 if (self.isFocused) {
8715 // prevent events on the dropdown scrollbar from causing the control to blur
8716 if (e.target === self.$dropdown[0] || e.target.parentNode === self.$dropdown[0]) {
8717 return false;
8718 }
8719 // blur on click outside
8720 if (!self.$control.has(e.target).length && e.target !== self.$control[0]) {
8721 self.blur(e.target);
8722 }
8723 }
8724 });
8725
8726 $window.on(['scroll' + eventNS, 'resize' + eventNS].join(' '), function() {
8727 if (self.isOpen) {
8728 self.positionDropdown.apply(self, arguments);
8729 }
8730 });
8731 $window.on('mousemove' + eventNS, function() {
8732 self.ignoreHover = false;
8733 });
8734
8735 // store original children and tab index so that they can be
8736 // restored when the destroy() method is called.
8737 this.revertSettings = {
8738 $children : $input.children().detach(),
8739 tabindex : $input.attr('tabindex')
8740 };
8741
8742 $input.attr('tabindex', -1).hide().after(self.$wrapper);
8743
8744 if ($.isArray(settings.items)) {
8745 self.setValue(settings.items);
8746 delete settings.items;
8747 }
8748
8749 // feature detect for the validation API
8750 if (SUPPORTS_VALIDITY_API) {
8751 $input.on('invalid' + eventNS, function(e) {
8752 e.preventDefault();
8753 self.isInvalid = true;
8754 self.refreshState();
8755 });
8756 }
8757
8758 self.updateOriginalInput();
8759 self.refreshItems();
8760 self.refreshState();
8761 self.updatePlaceholder();
8762 self.isSetup = true;
8763
8764 if ($input.is(':disabled')) {
8765 self.disable();
8766 }
8767
8768 self.on('change', this.onChange);
8769
8770 $input.data('selectize', self);
8771 $input.addClass('selectized');
8772 self.trigger('initialize');
8773
8774 // preload options
8775 if (settings.preload === true) {
8776 self.onSearchChange('');
8777 }
8778
8779 },
8780
8781 /**
8782 * Sets up default rendering functions.
8783 */
8784 setupTemplates: function() {
8785 var self = this;
8786 var field_label = self.settings.labelField;
8787 var field_optgroup = self.settings.optgroupLabelField;
8788
8789 var templates = {
8790 'optgroup': function(data) {
8791 return '<div class="optgroup">' + data.html + '</div>';
8792 },
8793 'optgroup_header': function(data, escape) {
8794 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
8795 },
8796 'option': function(data, escape) {
8797 return '<div class="option">' + escape(data[field_label]) + '</div>';
8798 },
8799 'item': function(data, escape) {
8800 return '<div class="item">' + escape(data[field_label]) + '</div>';
8801 },
8802 'option_create': function(data, escape) {
8803 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
8804 }
8805 };
8806
8807 self.settings.render = $.extend({}, templates, self.settings.render);
8808 },
8809
8810 /**
8811 * Maps fired events to callbacks provided
8812 * in the settings used when creating the control.
8813 */
8814 setupCallbacks: function() {
8815 var key, fn, callbacks = {
8816 'initialize' : 'onInitialize',
8817 'change' : 'onChange',
8818 'item_add' : 'onItemAdd',
8819 'item_remove' : 'onItemRemove',
8820 'clear' : 'onClear',
8821 'option_add' : 'onOptionAdd',
8822 'option_remove' : 'onOptionRemove',
8823 'option_clear' : 'onOptionClear',
8824 'optgroup_add' : 'onOptionGroupAdd',
8825 'optgroup_remove' : 'onOptionGroupRemove',
8826 'optgroup_clear' : 'onOptionGroupClear',
8827 'dropdown_open' : 'onDropdownOpen',
8828 'dropdown_close' : 'onDropdownClose',
8829 'type' : 'onType',
8830 'load' : 'onLoad',
8831 'focus' : 'onFocus',
8832 'blur' : 'onBlur'
8833 };
8834
8835 for (key in callbacks) {
8836 if (callbacks.hasOwnProperty(key)) {
8837 fn = this.settings[callbacks[key]];
8838 if (fn) this.on(key, fn);
8839 }
8840 }
8841 },
8842
8843 /**
8844 * Triggered when the main control element
8845 * has a click event.
8846 *
8847 * @param {object} e
8848 * @return {boolean}
8849 */
8850 onClick: function(e) {
8851 var self = this;
8852
8853 // necessary for mobile webkit devices (manual focus triggering
8854 // is ignored unless invoked within a click event)
8855 if (!self.isFocused) {
8856 self.focus();
8857 e.preventDefault();
8858 }
8859 },
8860
8861 /**
8862 * Triggered when the main control element
8863 * has a mouse down event.
8864 *
8865 * @param {object} e
8866 * @return {boolean}
8867 */
8868 onMouseDown: function(e) {
8869 var self = this;
8870 var defaultPrevented = e.isDefaultPrevented();
8871 var $target = $(e.target);
8872
8873 if (self.isFocused) {
8874 // retain focus by preventing native handling. if the
8875 // event target is the input it should not be modified.
8876 // otherwise, text selection within the input won't work.
8877 if (e.target !== self.$control_input[0]) {
8878 if (self.settings.mode === 'single') {
8879 // toggle dropdown
8880 self.isOpen ? self.close() : self.open();
8881 } else if (!defaultPrevented) {
8882 self.setActiveItem(null);
8883 }
8884 return false;
8885 }
8886 } else {
8887 // give control focus
8888 if (!defaultPrevented) {
8889 window.setTimeout(function() {
8890 self.focus();
8891 }, 0);
8892 }
8893 }
8894 },
8895
8896 /**
8897 * Triggered when the value of the control has been changed.
8898 * This should propagate the event to the original DOM
8899 * input / select element.
8900 */
8901 onChange: function() {
8902 this.$input.trigger('change');
8903 },
8904
8905 /**
8906 * Triggered on <input> paste.
8907 *
8908 * @param {object} e
8909 * @returns {boolean}
8910 */
8911 onPaste: function(e) {
8912 var self = this;
8913
8914 if (self.isFull() || self.isInputHidden || self.isLocked) {
8915 e.preventDefault();
8916 return;
8917 }
8918
8919 // If a regex or string is included, this will split the pasted
8920 // input and create Items for each separate value
8921 if (self.settings.splitOn) {
8922
8923 // Wait for pasted text to be recognized in value
8924 setTimeout(function() {
8925 var pastedText = self.$control_input.val();
8926 if(!pastedText.match(self.settings.splitOn)){ return }
8927
8928 var splitInput = $.trim(pastedText).split(self.settings.splitOn);
8929 for (var i = 0, n = splitInput.length; i < n; i++) {
8930 self.createItem(splitInput[i]);
8931 }
8932 }, 0);
8933 }
8934 },
8935
8936 /**
8937 * Triggered on <input> keypress.
8938 *
8939 * @param {object} e
8940 * @returns {boolean}
8941 */
8942 onKeyPress: function(e) {
8943 if (this.isLocked) return e && e.preventDefault();
8944 var character = String.fromCharCode(e.keyCode || e.which);
8945 if (this.settings.create && this.settings.mode === 'multi' && character === this.settings.delimiter) {
8946 this.createItem();
8947 e.preventDefault();
8948 return false;
8949 }
8950 },
8951
8952 /**
8953 * Triggered on <input> keydown.
8954 *
8955 * @param {object} e
8956 * @returns {boolean}
8957 */
8958 onKeyDown: function(e) {
8959 var isInput = e.target === this.$control_input[0];
8960 var self = this;
8961
8962 if (self.isLocked) {
8963 if (e.keyCode !== KEY_TAB) {
8964 e.preventDefault();
8965 }
8966 return;
8967 }
8968
8969 switch (e.keyCode) {
8970 case KEY_A:
8971 if (self.isCmdDown) {
8972 self.selectAll();
8973 return;
8974 }
8975 break;
8976 case KEY_ESC:
8977 if (self.isOpen) {
8978 e.preventDefault();
8979 e.stopPropagation();
8980 self.close();
8981 }
8982 return;
8983 case KEY_N:
8984 if (!e.ctrlKey || e.altKey) break;
8985 case KEY_DOWN:
8986 if (!self.isOpen && self.hasOptions) {
8987 self.open();
8988 } else if (self.$activeOption) {
8989 self.ignoreHover = true;
8990 var $next = self.getAdjacentOption(self.$activeOption, 1);
8991 if ($next.length) self.setActiveOption($next, true, true);
8992 }
8993 e.preventDefault();
8994 return;
8995 case KEY_P:
8996 if (!e.ctrlKey || e.altKey) break;
8997 case KEY_UP:
8998 if (self.$activeOption) {
8999 self.ignoreHover = true;
9000 var $prev = self.getAdjacentOption(self.$activeOption, -1);
9001 if ($prev.length) self.setActiveOption($prev, true, true);
9002 }
9003 e.preventDefault();
9004 return;
9005 case KEY_RETURN:
9006 if (self.isOpen && self.$activeOption) {
9007 self.onOptionSelect({currentTarget: self.$activeOption});
9008 e.preventDefault();
9009 }
9010 return;
9011 case KEY_LEFT:
9012 self.advanceSelection(-1, e);
9013 return;
9014 case KEY_RIGHT:
9015 self.advanceSelection(1, e);
9016 return;
9017 case KEY_TAB:
9018 if (self.settings.selectOnTab && self.isOpen && self.$activeOption) {
9019 self.onOptionSelect({currentTarget: self.$activeOption});
9020
9021 // Default behaviour is to jump to the next field, we only want this
9022 // if the current field doesn't accept any more entries
9023 if (!self.isFull()) {
9024 e.preventDefault();
9025 }
9026 }
9027 if (self.settings.create && self.createItem()) {
9028 e.preventDefault();
9029 }
9030 return;
9031 case KEY_BACKSPACE:
9032 case KEY_DELETE:
9033 self.deleteSelection(e);
9034 return;
9035 }
9036
9037 if ((self.isFull() || self.isInputHidden) && !(IS_MAC ? e.metaKey : e.ctrlKey)) {
9038 e.preventDefault();
9039 return;
9040 }
9041 },
9042
9043 /**
9044 * Triggered on <input> keyup.
9045 *
9046 * @param {object} e
9047 * @returns {boolean}
9048 */
9049 onKeyUp: function(e) {
9050 var self = this;
9051
9052 if (self.isLocked) return e && e.preventDefault();
9053 var value = self.$control_input.val() || '';
9054 if (self.lastValue !== value) {
9055 self.lastValue = value;
9056 self.onSearchChange(value);
9057 self.refreshOptions();
9058 self.trigger('type', value);
9059 }
9060 },
9061
9062 /**
9063 * Invokes the user-provide option provider / loader.
9064 *
9065 * Note: this function is debounced in the Selectize
9066 * constructor (by `settings.loadThrottle` milliseconds)
9067 *
9068 * @param {string} value
9069 */
9070 onSearchChange: function(value) {
9071 var self = this;
9072 var fn = self.settings.load;
9073 if (!fn) return;
9074 if (self.loadedSearches.hasOwnProperty(value)) return;
9075 self.loadedSearches[value] = true;
9076 self.load(function(callback) {
9077 fn.apply(self, [value, callback]);
9078 });
9079 },
9080
9081 /**
9082 * Triggered on <input> focus.
9083 *
9084 * @param {object} e (optional)
9085 * @returns {boolean}
9086 */
9087 onFocus: function(e) {
9088 var self = this;
9089 var wasFocused = self.isFocused;
9090
9091 if (self.isDisabled) {
9092 self.blur();
9093 e && e.preventDefault();
9094 return false;
9095 }
9096
9097 if (self.ignoreFocus) return;
9098 self.isFocused = true;
9099 if (self.settings.preload === 'focus') self.onSearchChange('');
9100
9101 if (!wasFocused) self.trigger('focus');
9102
9103 if (!self.$activeItems.length) {
9104 self.showInput();
9105 self.setActiveItem(null);
9106 self.refreshOptions(!!self.settings.openOnFocus);
9107 }
9108
9109 self.refreshState();
9110 },
9111
9112 /**
9113 * Triggered on <input> blur.
9114 *
9115 * @param {object} e
9116 * @param {Element} dest
9117 */
9118 onBlur: function(e, dest) {
9119 var self = this;
9120 if (!self.isFocused) return;
9121 self.isFocused = false;
9122
9123 if (self.ignoreFocus) {
9124 return;
9125 } else if (!self.ignoreBlur && document.activeElement === self.$dropdown_content[0]) {
9126 // necessary to prevent IE closing the dropdown when the scrollbar is clicked
9127 self.ignoreBlur = true;
9128 self.onFocus(e);
9129 return;
9130 }
9131
9132 var deactivate = function() {
9133 self.close();
9134 self.setTextboxValue('');
9135 self.setActiveItem(null);
9136 self.setActiveOption(null);
9137 self.setCaret(self.items.length);
9138 self.refreshState();
9139
9140 // IE11 bug: element still marked as active
9141 dest && dest.focus && dest.focus();
9142
9143 self.ignoreFocus = false;
9144 self.trigger('blur');
9145 };
9146
9147 self.ignoreFocus = true;
9148 if (self.settings.create && self.settings.createOnBlur) {
9149 self.createItem(null, false, deactivate);
9150 } else {
9151 deactivate();
9152 }
9153 },
9154
9155 /**
9156 * Triggered when the user rolls over
9157 * an option in the autocomplete dropdown menu.
9158 *
9159 * @param {object} e
9160 * @returns {boolean}
9161 */
9162 onOptionHover: function(e) {
9163 if (this.ignoreHover) return;
9164 this.setActiveOption(e.currentTarget, false);
9165 },
9166
9167 /**
9168 * Triggered when the user clicks on an option
9169 * in the autocomplete dropdown menu.
9170 *
9171 * @param {object} e
9172 * @returns {boolean}
9173 */
9174 onOptionSelect: function(e) {
9175 var value, $target, $option, self = this;
9176
9177 if (e.preventDefault) {
9178 e.preventDefault();
9179 e.stopPropagation();
9180 }
9181
9182 $target = $(e.currentTarget);
9183 if ($target.hasClass('create')) {
9184 self.createItem(null, function() {
9185 if (self.settings.closeAfterSelect) {
9186 self.close();
9187 }
9188 });
9189 } else {
9190 value = $target.attr('data-value');
9191 if (typeof value !== 'undefined') {
9192 self.lastQuery = null;
9193 self.setTextboxValue('');
9194 self.addItem(value);
9195 if (self.settings.closeAfterSelect) {
9196 self.close();
9197 } else if (!self.settings.hideSelected && e.type && /mouse/.test(e.type)) {
9198 self.setActiveOption(self.getOption(value));
9199 }
9200 }
9201 }
9202 },
9203
9204 /**
9205 * Triggered when the user clicks on an item
9206 * that has been selected.
9207 *
9208 * @param {object} e
9209 * @returns {boolean}
9210 */
9211 onItemSelect: function(e) {
9212 var self = this;
9213
9214 if (self.isLocked) return;
9215 if (self.settings.mode === 'multi') {
9216 e.preventDefault();
9217 self.setActiveItem(e.currentTarget, e);
9218 }
9219 },
9220
9221 /**
9222 * Invokes the provided method that provides
9223 * results to a callback---which are then added
9224 * as options to the control.
9225 *
9226 * @param {function} fn
9227 */
9228 load: function(fn) {
9229 var self = this;
9230 var $wrapper = self.$wrapper.addClass(self.settings.loadingClass);
9231
9232 self.loading++;
9233 fn.apply(self, [function(results) {
9234 self.loading = Math.max(self.loading - 1, 0);
9235 if (results && results.length) {
9236 self.addOption(results);
9237 self.refreshOptions(self.isFocused && !self.isInputHidden);
9238 }
9239 if (!self.loading) {
9240 $wrapper.removeClass(self.settings.loadingClass);
9241 }
9242 self.trigger('load', results);
9243 }]);
9244 },
9245
9246 /**
9247 * Sets the input field of the control to the specified value.
9248 *
9249 * @param {string} value
9250 */
9251 setTextboxValue: function(value) {
9252 var $input = this.$control_input;
9253 var changed = $input.val() !== value;
9254 if (changed) {
9255 $input.val(value).triggerHandler('update');
9256 this.lastValue = value;
9257 }
9258 },
9259
9260 /**
9261 * Returns the value of the control. If multiple items
9262 * can be selected (e.g. <select multiple>), this returns
9263 * an array. If only one item can be selected, this
9264 * returns a string.
9265 *
9266 * @returns {mixed}
9267 */
9268 getValue: function() {
9269 if (this.tagType === TAG_SELECT && this.$input.attr('multiple')) {
9270 return this.items;
9271 } else {
9272 return this.items.join(this.settings.delimiter);
9273 }
9274 },
9275
9276 /**
9277 * Resets the selected items to the given value.
9278 *
9279 * @param {mixed} value
9280 */
9281 setValue: function(value, silent) {
9282 var events = silent ? [] : ['change'];
9283
9284 debounce_events(this, events, function() {
9285 this.clear(silent);
9286 this.addItems(value, silent);
9287 });
9288 },
9289
9290 /**
9291 * Sets the selected item.
9292 *
9293 * @param {object} $item
9294 * @param {object} e (optional)
9295 */
9296 setActiveItem: function($item, e) {
9297 var self = this;
9298 var eventName;
9299 var i, idx, begin, end, item, swap;
9300 var $last;
9301
9302 if (self.settings.mode === 'single') return;
9303 $item = $($item);
9304
9305 // clear the active selection
9306 if (!$item.length) {
9307 $(self.$activeItems).removeClass('active');
9308 self.$activeItems = [];
9309 if (self.isFocused) {
9310 self.showInput();
9311 }
9312 return;
9313 }
9314
9315 // modify selection
9316 eventName = e && e.type.toLowerCase();
9317
9318 if (eventName === 'mousedown' && self.isShiftDown && self.$activeItems.length) {
9319 $last = self.$control.children('.active:last');
9320 begin = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$last[0]]);
9321 end = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$item[0]]);
9322 if (begin > end) {
9323 swap = begin;
9324 begin = end;
9325 end = swap;
9326 }
9327 for (i = begin; i <= end; i++) {
9328 item = self.$control[0].childNodes[i];
9329 if (self.$activeItems.indexOf(item) === -1) {
9330 $(item).addClass('active');
9331 self.$activeItems.push(item);
9332 }
9333 }
9334 e.preventDefault();
9335 } else if ((eventName === 'mousedown' && self.isCtrlDown) || (eventName === 'keydown' && this.isShiftDown)) {
9336 if ($item.hasClass('active')) {
9337 idx = self.$activeItems.indexOf($item[0]);
9338 self.$activeItems.splice(idx, 1);
9339 $item.removeClass('active');
9340 } else {
9341 self.$activeItems.push($item.addClass('active')[0]);
9342 }
9343 } else {
9344 $(self.$activeItems).removeClass('active');
9345 self.$activeItems = [$item.addClass('active')[0]];
9346 }
9347
9348 // ensure control has focus
9349 self.hideInput();
9350 if (!this.isFocused) {
9351 self.focus();
9352 }
9353 },
9354
9355 /**
9356 * Sets the selected item in the dropdown menu
9357 * of available options.
9358 *
9359 * @param {object} $object
9360 * @param {boolean} scroll
9361 * @param {boolean} animate
9362 */
9363 setActiveOption: function($option, scroll, animate) {
9364 var height_menu, height_item, y;
9365 var scroll_top, scroll_bottom;
9366 var self = this;
9367
9368 if (self.$activeOption) self.$activeOption.removeClass('active');
9369 self.$activeOption = null;
9370
9371 $option = $($option);
9372 if (!$option.length) return;
9373
9374 self.$activeOption = $option.addClass('active');
9375
9376 if (scroll || !isset(scroll)) {
9377
9378 height_menu = self.$dropdown_content.height();
9379 height_item = self.$activeOption.outerHeight(true);
9380 scroll = self.$dropdown_content.scrollTop() || 0;
9381 y = self.$activeOption.offset().top - self.$dropdown_content.offset().top + scroll;
9382 scroll_top = y;
9383 scroll_bottom = y - height_menu + height_item;
9384
9385 if (y + height_item > height_menu + scroll) {
9386 self.$dropdown_content.stop().animate({scrollTop: scroll_bottom}, animate ? self.settings.scrollDuration : 0);
9387 } else if (y < scroll) {
9388 self.$dropdown_content.stop().animate({scrollTop: scroll_top}, animate ? self.settings.scrollDuration : 0);
9389 }
9390
9391 }
9392 },
9393
9394 /**
9395 * Selects all items (CTRL + A).
9396 */
9397 selectAll: function() {
9398 var self = this;
9399 if (self.settings.mode === 'single') return;
9400
9401 self.$activeItems = Array.prototype.slice.apply(self.$control.children(':not(input)').addClass('active'));
9402 if (self.$activeItems.length) {
9403 self.hideInput();
9404 self.close();
9405 }
9406 self.focus();
9407 },
9408
9409 /**
9410 * Hides the input element out of view, while
9411 * retaining its focus.
9412 */
9413 hideInput: function() {
9414 var self = this;
9415
9416 self.setTextboxValue('');
9417 self.$control_input.css({opacity: 0, position: 'absolute', left: self.rtl ? 10000 : -10000});
9418 self.isInputHidden = true;
9419 },
9420
9421 /**
9422 * Restores input visibility.
9423 */
9424 showInput: function() {
9425 this.$control_input.css({opacity: 1, position: 'relative', left: 0});
9426 this.isInputHidden = false;
9427 },
9428
9429 /**
9430 * Gives the control focus.
9431 */
9432 focus: function() {
9433 var self = this;
9434 if (self.isDisabled) return;
9435
9436 self.ignoreFocus = true;
9437 self.$control_input[0].focus();
9438 window.setTimeout(function() {
9439 self.ignoreFocus = false;
9440 self.onFocus();
9441 }, 0);
9442 },
9443
9444 /**
9445 * Forces the control out of focus.
9446 *
9447 * @param {Element} dest
9448 */
9449 blur: function(dest) {
9450 this.$control_input[0].blur();
9451 this.onBlur(null, dest);
9452 },
9453
9454 /**
9455 * Returns a function that scores an object
9456 * to show how good of a match it is to the
9457 * provided query.
9458 *
9459 * @param {string} query
9460 * @param {object} options
9461 * @return {function}
9462 */
9463 getScoreFunction: function(query) {
9464 return this.sifter.getScoreFunction(query, this.getSearchOptions());
9465 },
9466
9467 /**
9468 * Returns search options for sifter (the system
9469 * for scoring and sorting results).
9470 *
9471 * @see https://github.com/brianreavis/sifter.js
9472 * @return {object}
9473 */
9474 getSearchOptions: function() {
9475 var settings = this.settings;
9476 var sort = settings.sortField;
9477 if (typeof sort === 'string') {
9478 sort = [{field: sort}];
9479 }
9480
9481 return {
9482 fields : settings.searchField,
9483 conjunction : settings.searchConjunction,
9484 sort : sort
9485 };
9486 },
9487
9488 /**
9489 * Searches through available options and returns
9490 * a sorted array of matches.
9491 *
9492 * Returns an object containing:
9493 *
9494 * - query {string}
9495 * - tokens {array}
9496 * - total {int}
9497 * - items {array}
9498 *
9499 * @param {string} query
9500 * @returns {object}
9501 */
9502 search: function(query) {
9503 var i, value, score, result, calculateScore;
9504 var self = this;
9505 var settings = self.settings;
9506 var options = this.getSearchOptions();
9507
9508 // validate user-provided result scoring function
9509 if (settings.score) {
9510 calculateScore = self.settings.score.apply(this, [query]);
9511 if (typeof calculateScore !== 'function') {
9512 throw new Error('Selectize "score" setting must be a function that returns a function');
9513 }
9514 }
9515
9516 // perform search
9517 if (query !== self.lastQuery) {
9518 self.lastQuery = query;
9519 result = self.sifter.search(query, $.extend(options, {score: calculateScore}));
9520 self.currentResults = result;
9521 } else {
9522 result = $.extend(true, {}, self.currentResults);
9523 }
9524
9525 // filter out selected items
9526 if (settings.hideSelected) {
9527 for (i = result.items.length - 1; i >= 0; i--) {
9528 if (self.items.indexOf(hash_key(result.items[i].id)) !== -1) {
9529 result.items.splice(i, 1);
9530 }
9531 }
9532 }
9533
9534 return result;
9535 },
9536
9537 /**
9538 * Refreshes the list of available options shown
9539 * in the autocomplete dropdown menu.
9540 *
9541 * @param {boolean} triggerDropdown
9542 */
9543 refreshOptions: function(triggerDropdown) {
9544 var i, j, k, n, groups, groups_order, option, option_html, optgroup, optgroups, html, html_children, has_create_option;
9545 var $active, $active_before, $create;
9546
9547 if (typeof triggerDropdown === 'undefined') {
9548 triggerDropdown = true;
9549 }
9550
9551 var self = this;
9552 var query = $.trim(self.$control_input.val());
9553 var results = self.search(query);
9554 var $dropdown_content = self.$dropdown_content;
9555 var active_before = self.$activeOption && hash_key(self.$activeOption.attr('data-value'));
9556
9557 // build markup
9558 n = results.items.length;
9559 if (typeof self.settings.maxOptions === 'number') {
9560 n = Math.min(n, self.settings.maxOptions);
9561 }
9562
9563 // render and group available options individually
9564 groups = {};
9565 groups_order = [];
9566
9567 for (i = 0; i < n; i++) {
9568 option = self.options[results.items[i].id];
9569 option_html = self.render('option', option);
9570 optgroup = option[self.settings.optgroupField] || '';
9571 optgroups = $.isArray(optgroup) ? optgroup : [optgroup];
9572
9573 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
9574 optgroup = optgroups[j];
9575 if (!self.optgroups.hasOwnProperty(optgroup)) {
9576 optgroup = '';
9577 }
9578 if (!groups.hasOwnProperty(optgroup)) {
9579 groups[optgroup] = document.createDocumentFragment();
9580 groups_order.push(optgroup);
9581 }
9582 groups[optgroup].appendChild(option_html);
9583 }
9584 }
9585
9586 // sort optgroups
9587 if (this.settings.lockOptgroupOrder) {
9588 groups_order.sort(function(a, b) {
9589 var a_order = self.optgroups[a].$order || 0;
9590 var b_order = self.optgroups[b].$order || 0;
9591 return a_order - b_order;
9592 });
9593 }
9594
9595 // render optgroup headers & join groups
9596 html = document.createDocumentFragment();
9597 for (i = 0, n = groups_order.length; i < n; i++) {
9598 optgroup = groups_order[i];
9599 if (self.optgroups.hasOwnProperty(optgroup) && groups[optgroup].childNodes.length) {
9600 // render the optgroup header and options within it,
9601 // then pass it to the wrapper template
9602 html_children = document.createDocumentFragment();
9603 html_children.appendChild(self.render('optgroup_header', self.optgroups[optgroup]));
9604 html_children.appendChild(groups[optgroup]);
9605
9606 html.appendChild(self.render('optgroup', $.extend({}, self.optgroups[optgroup], {
9607 html: domToString(html_children),
9608 dom: html_children
9609 })));
9610 } else {
9611 html.appendChild(groups[optgroup]);
9612 }
9613 }
9614
9615 $dropdown_content.html(html);
9616
9617 // highlight matching terms inline
9618 if (self.settings.highlight && results.query.length && results.tokens.length) {
9619 $dropdown_content.removeHighlight();
9620 for (i = 0, n = results.tokens.length; i < n; i++) {
9621 highlight($dropdown_content, results.tokens[i].regex);
9622 }
9623 }
9624
9625 // add "selected" class to selected options
9626 if (!self.settings.hideSelected) {
9627 for (i = 0, n = self.items.length; i < n; i++) {
9628 self.getOption(self.items[i]).addClass('selected');
9629 }
9630 }
9631
9632 // add create option
9633 has_create_option = self.canCreate(query);
9634 if (has_create_option) {
9635 $dropdown_content.prepend(self.render('option_create', {input: query}));
9636 $create = $($dropdown_content[0].childNodes[0]);
9637 }
9638
9639 // activate
9640 self.hasOptions = results.items.length > 0 || has_create_option;
9641 if (self.hasOptions) {
9642 if (results.items.length > 0) {
9643 $active_before = active_before && self.getOption(active_before);
9644 if ($active_before && $active_before.length) {
9645 $active = $active_before;
9646 } else if (self.settings.mode === 'single' && self.items.length) {
9647 $active = self.getOption(self.items[0]);
9648 }
9649 if (!$active || !$active.length) {
9650 if ($create && !self.settings.addPrecedence) {
9651 $active = self.getAdjacentOption($create, 1);
9652 } else {
9653 $active = $dropdown_content.find('[data-selectable]:first');
9654 }
9655 }
9656 } else {
9657 $active = $create;
9658 }
9659 self.setActiveOption($active);
9660 if (triggerDropdown && !self.isOpen) { self.open(); }
9661 } else {
9662 self.setActiveOption(null);
9663 if (triggerDropdown && self.isOpen) { self.close(); }
9664 }
9665 },
9666
9667 /**
9668 * Adds an available option. If it already exists,
9669 * nothing will happen. Note: this does not refresh
9670 * the options list dropdown (use `refreshOptions`
9671 * for that).
9672 *
9673 * Usage:
9674 *
9675 * this.addOption(data)
9676 *
9677 * @param {object|array} data
9678 */
9679 addOption: function(data) {
9680 var i, n, value, self = this;
9681
9682 if ($.isArray(data)) {
9683 for (i = 0, n = data.length; i < n; i++) {
9684 self.addOption(data[i]);
9685 }
9686 return;
9687 }
9688
9689 if (value = self.registerOption(data)) {
9690 self.userOptions[value] = true;
9691 self.lastQuery = null;
9692 self.trigger('option_add', value, data);
9693 }
9694 },
9695
9696 /**
9697 * Registers an option to the pool of options.
9698 *
9699 * @param {object} data
9700 * @return {boolean|string}
9701 */
9702 registerOption: function(data) {
9703 var key = hash_key(data[this.settings.valueField]);
9704 if (typeof key === 'undefined' || key === null || this.options.hasOwnProperty(key)) return false;
9705 data.$order = data.$order || ++this.order;
9706 this.options[key] = data;
9707 return key;
9708 },
9709
9710 /**
9711 * Registers an option group to the pool of option groups.
9712 *
9713 * @param {object} data
9714 * @return {boolean|string}
9715 */
9716 registerOptionGroup: function(data) {
9717 var key = hash_key(data[this.settings.optgroupValueField]);
9718 if (!key) return false;
9719
9720 data.$order = data.$order || ++this.order;
9721 this.optgroups[key] = data;
9722 return key;
9723 },
9724
9725 /**
9726 * Registers a new optgroup for options
9727 * to be bucketed into.
9728 *
9729 * @param {string} id
9730 * @param {object} data
9731 */
9732 addOptionGroup: function(id, data) {
9733 data[this.settings.optgroupValueField] = id;
9734 if (id = this.registerOptionGroup(data)) {
9735 this.trigger('optgroup_add', id, data);
9736 }
9737 },
9738
9739 /**
9740 * Removes an existing option group.
9741 *
9742 * @param {string} id
9743 */
9744 removeOptionGroup: function(id) {
9745 if (this.optgroups.hasOwnProperty(id)) {
9746 delete this.optgroups[id];
9747 this.renderCache = {};
9748 this.trigger('optgroup_remove', id);
9749 }
9750 },
9751
9752 /**
9753 * Clears all existing option groups.
9754 */
9755 clearOptionGroups: function() {
9756 this.optgroups = {};
9757 this.renderCache = {};
9758 this.trigger('optgroup_clear');
9759 },
9760
9761 /**
9762 * Updates an option available for selection. If
9763 * it is visible in the selected items or options
9764 * dropdown, it will be re-rendered automatically.
9765 *
9766 * @param {string} value
9767 * @param {object} data
9768 */
9769 updateOption: function(value, data) {
9770 var self = this;
9771 var $item, $item_new;
9772 var value_new, index_item, cache_items, cache_options, order_old;
9773
9774 value = hash_key(value);
9775 value_new = hash_key(data[self.settings.valueField]);
9776
9777 // sanity checks
9778 if (value === null) return;
9779 if (!self.options.hasOwnProperty(value)) return;
9780 if (typeof value_new !== 'string') throw new Error('Value must be set in option data');
9781
9782 order_old = self.options[value].$order;
9783
9784 // update references
9785 if (value_new !== value) {
9786 delete self.options[value];
9787 index_item = self.items.indexOf(value);
9788 if (index_item !== -1) {
9789 self.items.splice(index_item, 1, value_new);
9790 }
9791 }
9792 data.$order = data.$order || order_old;
9793 self.options[value_new] = data;
9794
9795 // invalidate render cache
9796 cache_items = self.renderCache['item'];
9797 cache_options = self.renderCache['option'];
9798
9799 if (cache_items) {
9800 delete cache_items[value];
9801 delete cache_items[value_new];
9802 }
9803 if (cache_options) {
9804 delete cache_options[value];
9805 delete cache_options[value_new];
9806 }
9807
9808 // update the item if it's selected
9809 if (self.items.indexOf(value_new) !== -1) {
9810 $item = self.getItem(value);
9811 $item_new = $(self.render('item', data));
9812 if ($item.hasClass('active')) $item_new.addClass('active');
9813 $item.replaceWith($item_new);
9814 }
9815
9816 // invalidate last query because we might have updated the sortField
9817 self.lastQuery = null;
9818
9819 // update dropdown contents
9820 if (self.isOpen) {
9821 self.refreshOptions(false);
9822 }
9823 },
9824
9825 /**
9826 * Removes a single option.
9827 *
9828 * @param {string} value
9829 * @param {boolean} silent
9830 */
9831 removeOption: function(value, silent) {
9832 var self = this;
9833 value = hash_key(value);
9834
9835 var cache_items = self.renderCache['item'];
9836 var cache_options = self.renderCache['option'];
9837 if (cache_items) delete cache_items[value];
9838 if (cache_options) delete cache_options[value];
9839
9840 delete self.userOptions[value];
9841 delete self.options[value];
9842 self.lastQuery = null;
9843 self.trigger('option_remove', value);
9844 self.removeItem(value, silent);
9845 },
9846
9847 /**
9848 * Clears all options.
9849 */
9850 clearOptions: function() {
9851 var self = this;
9852
9853 self.loadedSearches = {};
9854 self.userOptions = {};
9855 self.renderCache = {};
9856 self.options = self.sifter.items = {};
9857 self.lastQuery = null;
9858 self.trigger('option_clear');
9859 self.clear();
9860 },
9861
9862 /**
9863 * Returns the jQuery element of the option
9864 * matching the given value.
9865 *
9866 * @param {string} value
9867 * @returns {object}
9868 */
9869 getOption: function(value) {
9870 return this.getElementWithValue(value, this.$dropdown_content.find('[data-selectable]'));
9871 },
9872
9873 /**
9874 * Returns the jQuery element of the next or
9875 * previous selectable option.
9876 *
9877 * @param {object} $option
9878 * @param {int} direction can be 1 for next or -1 for previous
9879 * @return {object}
9880 */
9881 getAdjacentOption: function($option, direction) {
9882 var $options = this.$dropdown.find('[data-selectable]');
9883 var index = $options.index($option) + direction;
9884
9885 return index >= 0 && index < $options.length ? $options.eq(index) : $();
9886 },
9887
9888 /**
9889 * Finds the first element with a "data-value" attribute
9890 * that matches the given value.
9891 *
9892 * @param {mixed} value
9893 * @param {object} $els
9894 * @return {object}
9895 */
9896 getElementWithValue: function(value, $els) {
9897 value = hash_key(value);
9898
9899 if (typeof value !== 'undefined' && value !== null) {
9900 for (var i = 0, n = $els.length; i < n; i++) {
9901 if ($els[i].getAttribute('data-value') === value) {
9902 return $($els[i]);
9903 }
9904 }
9905 }
9906
9907 return $();
9908 },
9909
9910 /**
9911 * Returns the jQuery element of the item
9912 * matching the given value.
9913 *
9914 * @param {string} value
9915 * @returns {object}
9916 */
9917 getItem: function(value) {
9918 return this.getElementWithValue(value, this.$control.children());
9919 },
9920
9921 /**
9922 * "Selects" multiple items at once. Adds them to the list
9923 * at the current caret position.
9924 *
9925 * @param {string} value
9926 * @param {boolean} silent
9927 */
9928 addItems: function(values, silent) {
9929 var items = $.isArray(values) ? values : [values];
9930 for (var i = 0, n = items.length; i < n; i++) {
9931 this.isPending = (i < n - 1);
9932 this.addItem(items[i], silent);
9933 }
9934 },
9935
9936 /**
9937 * "Selects" an item. Adds it to the list
9938 * at the current caret position.
9939 *
9940 * @param {string} value
9941 * @param {boolean} silent
9942 */
9943 addItem: function(value, silent) {
9944 var events = silent ? [] : ['change'];
9945
9946 debounce_events(this, events, function() {
9947 var $item, $option, $options;
9948 var self = this;
9949 var inputMode = self.settings.mode;
9950 var i, active, value_next, wasFull;
9951 value = hash_key(value);
9952
9953 if (self.items.indexOf(value) !== -1) {
9954 if (inputMode === 'single') self.close();
9955 return;
9956 }
9957
9958 if (!self.options.hasOwnProperty(value)) return;
9959 if (inputMode === 'single') self.clear(silent);
9960 if (inputMode === 'multi' && self.isFull()) return;
9961
9962 $item = $(self.render('item', self.options[value]));
9963 wasFull = self.isFull();
9964 self.items.splice(self.caretPos, 0, value);
9965 self.insertAtCaret($item);
9966 if (!self.isPending || (!wasFull && self.isFull())) {
9967 self.refreshState();
9968 }
9969
9970 if (self.isSetup) {
9971 $options = self.$dropdown_content.find('[data-selectable]');
9972
9973 // update menu / remove the option (if this is not one item being added as part of series)
9974 if (!self.isPending) {
9975 $option = self.getOption(value);
9976 value_next = self.getAdjacentOption($option, 1).attr('data-value');
9977 self.refreshOptions(self.isFocused && inputMode !== 'single');
9978 if (value_next) {
9979 self.setActiveOption(self.getOption(value_next));
9980 }
9981 }
9982
9983 // hide the menu if the maximum number of items have been selected or no options are left
9984 if (!$options.length || self.isFull()) {
9985 self.close();
9986 } else {
9987 self.positionDropdown();
9988 }
9989
9990 self.updatePlaceholder();
9991 self.trigger('item_add', value, $item);
9992 self.updateOriginalInput({silent: silent});
9993 }
9994 });
9995 },
9996
9997 /**
9998 * Removes the selected item matching
9999 * the provided value.
10000 *
10001 * @param {string} value
10002 */
10003 removeItem: function(value, silent) {
10004 var self = this;
10005 var $item, i, idx;
10006
10007 $item = (value instanceof $) ? value : self.getItem(value);
10008 value = hash_key($item.attr('data-value'));
10009 i = self.items.indexOf(value);
10010
10011 if (i !== -1) {
10012 $item.remove();
10013 if ($item.hasClass('active')) {
10014 idx = self.$activeItems.indexOf($item[0]);
10015 self.$activeItems.splice(idx, 1);
10016 }
10017
10018 self.items.splice(i, 1);
10019 self.lastQuery = null;
10020 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
10021 self.removeOption(value, silent);
10022 }
10023
10024 if (i < self.caretPos) {
10025 self.setCaret(self.caretPos - 1);
10026 }
10027
10028 self.refreshState();
10029 self.updatePlaceholder();
10030 self.updateOriginalInput({silent: silent});
10031 self.positionDropdown();
10032 self.trigger('item_remove', value, $item);
10033 }
10034 },
10035
10036 /**
10037 * Invokes the `create` method provided in the
10038 * selectize options that should provide the data
10039 * for the new item, given the user input.
10040 *
10041 * Once this completes, it will be added
10042 * to the item list.
10043 *
10044 * @param {string} value
10045 * @param {boolean} [triggerDropdown]
10046 * @param {function} [callback]
10047 * @return {boolean}
10048 */
10049 createItem: function(input, triggerDropdown) {
10050 var self = this;
10051 var caret = self.caretPos;
10052 input = input || $.trim(self.$control_input.val() || '');
10053
10054 var callback = arguments[arguments.length - 1];
10055 if (typeof callback !== 'function') callback = function() {};
10056
10057 if (typeof triggerDropdown !== 'boolean') {
10058 triggerDropdown = true;
10059 }
10060
10061 if (!self.canCreate(input)) {
10062 callback();
10063 return false;
10064 }
10065
10066 self.lock();
10067
10068 var setup = (typeof self.settings.create === 'function') ? this.settings.create : function(input) {
10069 var data = {};
10070 data[self.settings.labelField] = input;
10071 data[self.settings.valueField] = input;
10072 return data;
10073 };
10074
10075 var create = once(function(data) {
10076 self.unlock();
10077
10078 if (!data || typeof data !== 'object') return callback();
10079 var value = hash_key(data[self.settings.valueField]);
10080 if (typeof value !== 'string') return callback();
10081
10082 self.setTextboxValue('');
10083 self.addOption(data);
10084 self.setCaret(caret);
10085 self.addItem(value);
10086 self.refreshOptions(triggerDropdown && self.settings.mode !== 'single');
10087 callback(data);
10088 });
10089
10090 var output = setup.apply(this, [input, create]);
10091 if (typeof output !== 'undefined') {
10092 create(output);
10093 }
10094
10095 return true;
10096 },
10097
10098 /**
10099 * Re-renders the selected item lists.
10100 */
10101 refreshItems: function() {
10102 this.lastQuery = null;
10103
10104 if (this.isSetup) {
10105 this.addItem(this.items);
10106 }
10107
10108 this.refreshState();
10109 this.updateOriginalInput();
10110 },
10111
10112 /**
10113 * Updates all state-dependent attributes
10114 * and CSS classes.
10115 */
10116 refreshState: function() {
10117 this.refreshValidityState();
10118 this.refreshClasses();
10119 },
10120
10121 /**
10122 * Update the `required` attribute of both input and control input.
10123 *
10124 * The `required` property needs to be activated on the control input
10125 * for the error to be displayed at the right place. `required` also
10126 * needs to be temporarily deactivated on the input since the input is
10127 * hidden and can't show errors.
10128 */
10129 refreshValidityState: function() {
10130 if (!this.isRequired) return false;
10131
10132 var invalid = !this.items.length;
10133
10134 this.isInvalid = invalid;
10135 this.$control_input.prop('required', invalid);
10136 this.$input.prop('required', !invalid);
10137 },
10138
10139 /**
10140 * Updates all state-dependent CSS classes.
10141 */
10142 refreshClasses: function() {
10143 var self = this;
10144 var isFull = self.isFull();
10145 var isLocked = self.isLocked;
10146
10147 self.$wrapper
10148 .toggleClass('rtl', self.rtl);
10149
10150 self.$control
10151 .toggleClass('focus', self.isFocused)
10152 .toggleClass('disabled', self.isDisabled)
10153 .toggleClass('required', self.isRequired)
10154 .toggleClass('invalid', self.isInvalid)
10155 .toggleClass('locked', isLocked)
10156 .toggleClass('full', isFull).toggleClass('not-full', !isFull)
10157 .toggleClass('input-active', self.isFocused && !self.isInputHidden)
10158 .toggleClass('dropdown-active', self.isOpen)
10159 .toggleClass('has-options', !$.isEmptyObject(self.options))
10160 .toggleClass('has-items', self.items.length > 0);
10161
10162 self.$control_input.data('grow', !isFull && !isLocked);
10163 },
10164
10165 /**
10166 * Determines whether or not more items can be added
10167 * to the control without exceeding the user-defined maximum.
10168 *
10169 * @returns {boolean}
10170 */
10171 isFull: function() {
10172 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
10173 },
10174
10175 /**
10176 * Refreshes the original <select> or <input>
10177 * element to reflect the current state.
10178 */
10179 updateOriginalInput: function(opts) {
10180 var i, n, options, label, self = this;
10181 opts = opts || {};
10182
10183 if (self.tagType === TAG_SELECT) {
10184 options = [];
10185 for (i = 0, n = self.items.length; i < n; i++) {
10186 label = self.options[self.items[i]][self.settings.labelField] || '';
10187 options.push('<option value="' + escape_html(self.items[i]) + '" selected="selected">' + escape_html(label) + '</option>');
10188 }
10189 if (!options.length && !this.$input.attr('multiple')) {
10190 options.push('<option value="" selected="selected"></option>');
10191 }
10192 self.$input.html(options.join(''));
10193 } else {
10194 self.$input.val(self.getValue());
10195 self.$input.attr('value',self.$input.val());
10196 }
10197
10198 if (self.isSetup) {
10199 if (!opts.silent) {
10200 self.trigger('change', self.$input.val());
10201 }
10202 }
10203 },
10204
10205 /**
10206 * Shows/hide the input placeholder depending
10207 * on if there items in the list already.
10208 */
10209 updatePlaceholder: function() {
10210 if (!this.settings.placeholder) return;
10211 var $input = this.$control_input;
10212
10213 if (this.items.length) {
10214 $input.removeAttr('placeholder');
10215 } else {
10216 $input.attr('placeholder', this.settings.placeholder);
10217 }
10218 $input.triggerHandler('update', {force: true});
10219 },
10220
10221 /**
10222 * Shows the autocomplete dropdown containing
10223 * the available options.
10224 */
10225 open: function() {
10226 var self = this;
10227
10228 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull())) return;
10229 self.focus();
10230 self.isOpen = true;
10231 self.refreshState();
10232 self.$dropdown.css({visibility: 'hidden', display: 'block'});
10233 self.positionDropdown();
10234 self.$dropdown.css({visibility: 'visible'});
10235 self.trigger('dropdown_open', self.$dropdown);
10236 },
10237
10238 /**
10239 * Closes the autocomplete dropdown menu.
10240 */
10241 close: function() {
10242 var self = this;
10243 var trigger = self.isOpen;
10244
10245 if (self.settings.mode === 'single' && self.items.length) {
10246 self.hideInput();
10247 self.$control_input.blur(); // close keyboard on iOS
10248 }
10249
10250 self.isOpen = false;
10251 self.$dropdown.hide();
10252 self.setActiveOption(null);
10253 self.refreshState();
10254
10255 if (trigger) self.trigger('dropdown_close', self.$dropdown);
10256 },
10257
10258 /**
10259 * Calculates and applies the appropriate
10260 * position of the dropdown.
10261 */
10262 positionDropdown: function() {
10263 var $control = this.$control;
10264 var offset = this.settings.dropdownParent === 'body' ? $control.offset() : $control.position();
10265 offset.top += $control.outerHeight(true);
10266
10267 this.$dropdown.css({
10268 width : $control.outerWidth(),
10269 top : offset.top,
10270 left : offset.left
10271 });
10272 },
10273
10274 /**
10275 * Resets / clears all selected items
10276 * from the control.
10277 *
10278 * @param {boolean} silent
10279 */
10280 clear: function(silent) {
10281 var self = this;
10282
10283 if (!self.items.length) return;
10284 self.$control.children(':not(input)').remove();
10285 self.items = [];
10286 self.lastQuery = null;
10287 self.setCaret(0);
10288 self.setActiveItem(null);
10289 self.updatePlaceholder();
10290 self.updateOriginalInput({silent: silent});
10291 self.refreshState();
10292 self.showInput();
10293 self.trigger('clear');
10294 },
10295
10296 /**
10297 * A helper method for inserting an element
10298 * at the current caret position.
10299 *
10300 * @param {object} $el
10301 */
10302 insertAtCaret: function($el) {
10303 var caret = Math.min(this.caretPos, this.items.length);
10304 if (caret === 0) {
10305 this.$control.prepend($el);
10306 } else {
10307 $(this.$control[0].childNodes[caret]).before($el);
10308 }
10309 this.setCaret(caret + 1);
10310 },
10311
10312 /**
10313 * Removes the current selected item(s).
10314 *
10315 * @param {object} e (optional)
10316 * @returns {boolean}
10317 */
10318 deleteSelection: function(e) {
10319 var i, n, direction, selection, values, caret, option_select, $option_select, $tail;
10320 var self = this;
10321
10322 direction = (e && e.keyCode === KEY_BACKSPACE) ? -1 : 1;
10323 selection = getSelection(self.$control_input[0]);
10324
10325 if (self.$activeOption && !self.settings.hideSelected) {
10326 option_select = self.getAdjacentOption(self.$activeOption, -1).attr('data-value');
10327 }
10328
10329 // determine items that will be removed
10330 values = [];
10331
10332 if (self.$activeItems.length) {
10333 $tail = self.$control.children('.active:' + (direction > 0 ? 'last' : 'first'));
10334 caret = self.$control.children(':not(input)').index($tail);
10335 if (direction > 0) { caret++; }
10336
10337 for (i = 0, n = self.$activeItems.length; i < n; i++) {
10338 values.push($(self.$activeItems[i]).attr('data-value'));
10339 }
10340 if (e) {
10341 e.preventDefault();
10342 e.stopPropagation();
10343 }
10344 } else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
10345 if (direction < 0 && selection.start === 0 && selection.length === 0) {
10346 values.push(self.items[self.caretPos - 1]);
10347 } else if (direction > 0 && selection.start === self.$control_input.val().length) {
10348 values.push(self.items[self.caretPos]);
10349 }
10350 }
10351
10352 // allow the callback to abort
10353 if (!values.length || (typeof self.settings.onDelete === 'function' && self.settings.onDelete.apply(self, [values]) === false)) {
10354 return false;
10355 }
10356
10357 // perform removal
10358 if (typeof caret !== 'undefined') {
10359 self.setCaret(caret);
10360 }
10361 while (values.length) {
10362 self.removeItem(values.pop());
10363 }
10364
10365 self.showInput();
10366 self.positionDropdown();
10367 self.refreshOptions(true);
10368
10369 // select previous option
10370 if (option_select) {
10371 $option_select = self.getOption(option_select);
10372 if ($option_select.length) {
10373 self.setActiveOption($option_select);
10374 }
10375 }
10376
10377 return true;
10378 },
10379
10380 /**
10381 * Selects the previous / next item (depending
10382 * on the `direction` argument).
10383 *
10384 * > 0 - right
10385 * < 0 - left
10386 *
10387 * @param {int} direction
10388 * @param {object} e (optional)
10389 */
10390 advanceSelection: function(direction, e) {
10391 var tail, selection, idx, valueLength, cursorAtEdge, $tail;
10392 var self = this;
10393
10394 if (direction === 0) return;
10395 if (self.rtl) direction *= -1;
10396
10397 tail = direction > 0 ? 'last' : 'first';
10398 selection = getSelection(self.$control_input[0]);
10399
10400 if (self.isFocused && !self.isInputHidden) {
10401 valueLength = self.$control_input.val().length;
10402 cursorAtEdge = direction < 0
10403 ? selection.start === 0 && selection.length === 0
10404 : selection.start === valueLength;
10405
10406 if (cursorAtEdge && !valueLength) {
10407 self.advanceCaret(direction, e);
10408 }
10409 } else {
10410 $tail = self.$control.children('.active:' + tail);
10411 if ($tail.length) {
10412 idx = self.$control.children(':not(input)').index($tail);
10413 self.setActiveItem(null);
10414 self.setCaret(direction > 0 ? idx + 1 : idx);
10415 }
10416 }
10417 },
10418
10419 /**
10420 * Moves the caret left / right.
10421 *
10422 * @param {int} direction
10423 * @param {object} e (optional)
10424 */
10425 advanceCaret: function(direction, e) {
10426 var self = this, fn, $adj;
10427
10428 if (direction === 0) return;
10429
10430 fn = direction > 0 ? 'next' : 'prev';
10431 if (self.isShiftDown) {
10432 $adj = self.$control_input[fn]();
10433 if ($adj.length) {
10434 self.hideInput();
10435 self.setActiveItem($adj);
10436 e && e.preventDefault();
10437 }
10438 } else {
10439 self.setCaret(self.caretPos + direction);
10440 }
10441 },
10442
10443 /**
10444 * Moves the caret to the specified index.
10445 *
10446 * @param {int} i
10447 */
10448 setCaret: function(i) {
10449 var self = this;
10450
10451 if (self.settings.mode === 'single') {
10452 i = self.items.length;
10453 } else {
10454 i = Math.max(0, Math.min(self.items.length, i));
10455 }
10456
10457 if(!self.isPending) {
10458 // the input must be moved by leaving it in place and moving the
10459 // siblings, due to the fact that focus cannot be restored once lost
10460 // on mobile webkit devices
10461 var j, n, fn, $children, $child;
10462 $children = self.$control.children(':not(input)');
10463 for (j = 0, n = $children.length; j < n; j++) {
10464 $child = $($children[j]).detach();
10465 if (j < i) {
10466 self.$control_input.before($child);
10467 } else {
10468 self.$control.append($child);
10469 }
10470 }
10471 }
10472
10473 self.caretPos = i;
10474 },
10475
10476 /**
10477 * Disables user input on the control. Used while
10478 * items are being asynchronously created.
10479 */
10480 lock: function() {
10481 this.close();
10482 this.isLocked = true;
10483 this.refreshState();
10484 },
10485
10486 /**
10487 * Re-enables user input on the control.
10488 */
10489 unlock: function() {
10490 this.isLocked = false;
10491 this.refreshState();
10492 },
10493
10494 /**
10495 * Disables user input on the control completely.
10496 * While disabled, it cannot receive focus.
10497 */
10498 disable: function() {
10499 var self = this;
10500 self.$input.prop('disabled', true);
10501 self.$control_input.prop('disabled', true).prop('tabindex', -1);
10502 self.isDisabled = true;
10503 self.lock();
10504 },
10505
10506 /**
10507 * Enables the control so that it can respond
10508 * to focus and user input.
10509 */
10510 enable: function() {
10511 var self = this;
10512 self.$input.prop('disabled', false);
10513 self.$control_input.prop('disabled', false).prop('tabindex', self.tabIndex);
10514 self.isDisabled = false;
10515 self.unlock();
10516 },
10517
10518 /**
10519 * Completely destroys the control and
10520 * unbinds all event listeners so that it can
10521 * be garbage collected.
10522 */
10523 destroy: function() {
10524 var self = this;
10525 var eventNS = self.eventNS;
10526 var revertSettings = self.revertSettings;
10527
10528 self.trigger('destroy');
10529 self.off();
10530 self.$wrapper.remove();
10531 self.$dropdown.remove();
10532
10533 self.$input
10534 .html('')
10535 .append(revertSettings.$children)
10536 .removeAttr('tabindex')
10537 .removeClass('selectized')
10538 .attr({tabindex: revertSettings.tabindex})
10539 .show();
10540
10541 self.$control_input.removeData('grow');
10542 self.$input.removeData('selectize');
10543
10544 $(window).off(eventNS);
10545 $(document).off(eventNS);
10546 $(document.body).off(eventNS);
10547
10548 delete self.$input[0].selectize;
10549 },
10550
10551 /**
10552 * A helper method for rendering "item" and
10553 * "option" templates, given the data.
10554 *
10555 * @param {string} templateName
10556 * @param {object} data
10557 * @returns {string}
10558 */
10559 render: function(templateName, data) {
10560 var value, id, label;
10561 var html = '';
10562 var cache = false;
10563 var self = this;
10564 var regex_tag = /^[\t \r\n]*<([a-z][a-z0-9\-_]*(?:\:[a-z][a-z0-9\-_]*)?)/i;
10565
10566 if (templateName === 'option' || templateName === 'item') {
10567 value = hash_key(data[self.settings.valueField]);
10568 cache = !!value;
10569 }
10570
10571 // pull markup from cache if it exists
10572 if (cache) {
10573 if (!isset(self.renderCache[templateName])) {
10574 self.renderCache[templateName] = {};
10575 }
10576 if (self.renderCache[templateName].hasOwnProperty(value)) {
10577 return self.renderCache[templateName][value];
10578 }
10579 }
10580
10581 // render markup
10582 html = $(self.settings.render[templateName].apply(this, [data, escape_html]));
10583
10584 // add mandatory attributes
10585 if (templateName === 'option' || templateName === 'option_create') {
10586 html.attr('data-selectable', '');
10587 }
10588 else if (templateName === 'optgroup') {
10589 id = data[self.settings.optgroupValueField] || '';
10590 html.attr('data-group', id);
10591 }
10592 if (templateName === 'option' || templateName === 'item') {
10593 html.attr('data-value', value || '');
10594 }
10595
10596 // update cache
10597 if (cache) {
10598 self.renderCache[templateName][value] = html[0];
10599 }
10600
10601 return html[0];
10602 },
10603
10604 /**
10605 * Clears the render cache for a template. If
10606 * no template is given, clears all render
10607 * caches.
10608 *
10609 * @param {string} templateName
10610 */
10611 clearCache: function(templateName) {
10612 var self = this;
10613 if (typeof templateName === 'undefined') {
10614 self.renderCache = {};
10615 } else {
10616 delete self.renderCache[templateName];
10617 }
10618 },
10619
10620 /**
10621 * Determines whether or not to display the
10622 * create item prompt, given a user input.
10623 *
10624 * @param {string} input
10625 * @return {boolean}
10626 */
10627 canCreate: function(input) {
10628 var self = this;
10629 if (!self.settings.create) return false;
10630 var filter = self.settings.createFilter;
10631 return input.length
10632 && (typeof filter !== 'function' || filter.apply(self, [input]))
10633 && (typeof filter !== 'string' || new RegExp(filter).test(input))
10634 && (!(filter instanceof RegExp) || filter.test(input));
10635 }
10636
10637 });
10638
10639
10640 Selectize.count = 0;
10641 Selectize.defaults = {
10642 options: [],
10643 optgroups: [],
10644
10645 plugins: [],
10646 delimiter: ',',
10647 splitOn: null, // regexp or string for splitting up values from a paste command
10648 persist: true,
10649 diacritics: true,
10650 create: false,
10651 createOnBlur: false,
10652 createFilter: null,
10653 highlight: true,
10654 openOnFocus: true,
10655 maxOptions: 1000,
10656 maxItems: null,
10657 hideSelected: null,
10658 addPrecedence: false,
10659 selectOnTab: false,
10660 preload: false,
10661 allowEmptyOption: false,
10662 closeAfterSelect: false,
10663
10664 scrollDuration: 60,
10665 loadThrottle: 300,
10666 loadingClass: 'loading',
10667
10668 dataAttr: 'data-data',
10669 optgroupField: 'optgroup',
10670 valueField: 'value',
10671 labelField: 'text',
10672 optgroupLabelField: 'label',
10673 optgroupValueField: 'value',
10674 lockOptgroupOrder: false,
10675
10676 sortField: '$order',
10677 searchField: ['text'],
10678 searchConjunction: 'and',
10679
10680 mode: null,
10681 wrapperClass: 'selectize-control',
10682 inputClass: 'selectize-input',
10683 dropdownClass: 'selectize-dropdown',
10684 dropdownContentClass: 'selectize-dropdown-content',
10685
10686 dropdownParent: null,
10687
10688 copyClassesToDropdown: true,
10689
10690 /*
10691 load : null, // function(query, callback) { ... }
10692 score : null, // function(search) { ... }
10693 onInitialize : null, // function() { ... }
10694 onChange : null, // function(value) { ... }
10695 onItemAdd : null, // function(value, $item) { ... }
10696 onItemRemove : null, // function(value) { ... }
10697 onClear : null, // function() { ... }
10698 onOptionAdd : null, // function(value, data) { ... }
10699 onOptionRemove : null, // function(value) { ... }
10700 onOptionClear : null, // function() { ... }
10701 onOptionGroupAdd : null, // function(id, data) { ... }
10702 onOptionGroupRemove : null, // function(id) { ... }
10703 onOptionGroupClear : null, // function() { ... }
10704 onDropdownOpen : null, // function($dropdown) { ... }
10705 onDropdownClose : null, // function($dropdown) { ... }
10706 onType : null, // function(str) { ... }
10707 onDelete : null, // function(values) { ... }
10708 */
10709
10710 render: {
10711 /*
10712 item: null,
10713 optgroup: null,
10714 optgroup_header: null,
10715 option: null,
10716 option_create: null
10717 */
10718 }
10719 };
10720
10721
10722 $.fn.selectize = function(settings_user) {
10723 var defaults = $.fn.selectize.defaults;
10724 var settings = $.extend({}, defaults, settings_user);
10725 var attr_data = settings.dataAttr;
10726 var field_label = settings.labelField;
10727 var field_value = settings.valueField;
10728 var field_optgroup = settings.optgroupField;
10729 var field_optgroup_label = settings.optgroupLabelField;
10730 var field_optgroup_value = settings.optgroupValueField;
10731
10732 /**
10733 * Initializes selectize from a <input type="text"> element.
10734 *
10735 * @param {object} $input
10736 * @param {object} settings_element
10737 */
10738 var init_textbox = function($input, settings_element) {
10739 var i, n, values, option;
10740
10741 var data_raw = $input.attr(attr_data);
10742
10743 if (!data_raw) {
10744 var value = $.trim($input.val() || '');
10745 if (!settings.allowEmptyOption && !value.length) return;
10746 values = value.split(settings.delimiter);
10747 for (i = 0, n = values.length; i < n; i++) {
10748 option = {};
10749 option[field_label] = values[i];
10750 option[field_value] = values[i];
10751 settings_element.options.push(option);
10752 }
10753 settings_element.items = values;
10754 } else {
10755 settings_element.options = JSON.parse(data_raw);
10756 for (i = 0, n = settings_element.options.length; i < n; i++) {
10757 settings_element.items.push(settings_element.options[i][field_value]);
10758 }
10759 }
10760 };
10761
10762 /**
10763 * Initializes selectize from a <select> element.
10764 *
10765 * @param {object} $input
10766 * @param {object} settings_element
10767 */
10768 var init_select = function($input, settings_element) {
10769 var i, n, tagName, $children, order = 0;
10770 var options = settings_element.options;
10771 var optionsMap = {};
10772
10773 var readData = function($el) {
10774 var data = attr_data && $el.attr(attr_data);
10775 if (typeof data === 'string' && data.length) {
10776 return JSON.parse(data);
10777 }
10778 return null;
10779 };
10780
10781 var addOption = function($option, group) {
10782 $option = $($option);
10783
10784 var value = hash_key($option.val());
10785 if (!value && !settings.allowEmptyOption) return;
10786
10787 // if the option already exists, it's probably been
10788 // duplicated in another optgroup. in this case, push
10789 // the current group to the "optgroup" property on the
10790 // existing option so that it's rendered in both places.
10791 if (optionsMap.hasOwnProperty(value)) {
10792 if (group) {
10793 var arr = optionsMap[value][field_optgroup];
10794 if (!arr) {
10795 optionsMap[value][field_optgroup] = group;
10796 } else if (!$.isArray(arr)) {
10797 optionsMap[value][field_optgroup] = [arr, group];
10798 } else {
10799 arr.push(group);
10800 }
10801 }
10802 return;
10803 }
10804
10805 var option = readData($option) || {};
10806 option[field_label] = option[field_label] || $option.text();
10807 option[field_value] = option[field_value] || value;
10808 option[field_optgroup] = option[field_optgroup] || group;
10809
10810 optionsMap[value] = option;
10811 options.push(option);
10812
10813 if ($option.is(':selected')) {
10814 settings_element.items.push(value);
10815 }
10816 };
10817
10818 var addGroup = function($optgroup) {
10819 var i, n, id, optgroup, $options;
10820
10821 $optgroup = $($optgroup);
10822 id = $optgroup.attr('label');
10823
10824 if (id) {
10825 optgroup = readData($optgroup) || {};
10826 optgroup[field_optgroup_label] = id;
10827 optgroup[field_optgroup_value] = id;
10828 settings_element.optgroups.push(optgroup);
10829 }
10830
10831 $options = $('option', $optgroup);
10832 for (i = 0, n = $options.length; i < n; i++) {
10833 addOption($options[i], id);
10834 }
10835 };
10836
10837 settings_element.maxItems = $input.attr('multiple') ? null : 1;
10838
10839 $children = $input.children();
10840 for (i = 0, n = $children.length; i < n; i++) {
10841 tagName = $children[i].tagName.toLowerCase();
10842 if (tagName === 'optgroup') {
10843 addGroup($children[i]);
10844 } else if (tagName === 'option') {
10845 addOption($children[i]);
10846 }
10847 }
10848 };
10849
10850 return this.each(function() {
10851 if (this.selectize) return;
10852
10853 var instance;
10854 var $input = $(this);
10855 var tag_name = this.tagName.toLowerCase();
10856 var placeholder = $input.attr('placeholder') || $input.attr('data-placeholder');
10857 if (!placeholder && !settings.allowEmptyOption) {
10858 placeholder = $input.children('option[value=""]').text();
10859 }
10860
10861 var settings_element = {
10862 'placeholder' : placeholder,
10863 'options' : [],
10864 'optgroups' : [],
10865 'items' : []
10866 };
10867
10868 if (tag_name === 'select') {
10869 init_select($input, settings_element);
10870 } else {
10871 init_textbox($input, settings_element);
10872 }
10873
10874 instance = new Selectize($input, $.extend(true, {}, defaults, settings_element, settings_user));
10875 });
10876 };
10877
10878 $.fn.selectize.defaults = Selectize.defaults;
10879 $.fn.selectize.support = {
10880 validity: SUPPORTS_VALIDITY_API
10881 };
10882
10883
10884 Selectize.define('drag_drop', function(options) {
10885 if (!$.fn.sortable) throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');
10886 if (this.settings.mode !== 'multi') return;
10887 var self = this;
10888
10889 self.lock = (function() {
10890 var original = self.lock;
10891 return function() {
10892 var sortable = self.$control.data('sortable');
10893 if (sortable) sortable.disable();
10894 return original.apply(self, arguments);
10895 };
10896 })();
10897
10898 self.unlock = (function() {
10899 var original = self.unlock;
10900 return function() {
10901 var sortable = self.$control.data('sortable');
10902 if (sortable) sortable.enable();
10903 return original.apply(self, arguments);
10904 };
10905 })();
10906
10907 self.setup = (function() {
10908 var original = self.setup;
10909 return function() {
10910 original.apply(this, arguments);
10911
10912 var $control = self.$control.sortable({
10913 items: '[data-value]',
10914 forcePlaceholderSize: true,
10915 disabled: self.isLocked,
10916 start: function(e, ui) {
10917 ui.placeholder.css('width', ui.helper.css('width'));
10918 $control.css({overflow: 'visible'});
10919 },
10920 stop: function() {
10921 $control.css({overflow: 'hidden'});
10922 var active = self.$activeItems ? self.$activeItems.slice() : null;
10923 var values = [];
10924 $control.children('[data-value]').each(function() {
10925 values.push($(this).attr('data-value'));
10926 });
10927 self.setValue(values);
10928 self.setActiveItem(active);
10929 }
10930 });
10931 };
10932 })();
10933
10934 });
10935
10936 Selectize.define('dropdown_header', function(options) {
10937 var self = this;
10938
10939 options = $.extend({
10940 title : 'Untitled',
10941 headerClass : 'selectize-dropdown-header',
10942 titleRowClass : 'selectize-dropdown-header-title',
10943 labelClass : 'selectize-dropdown-header-label',
10944 closeClass : 'selectize-dropdown-header-close',
10945
10946 html: function(data) {
10947 return (
10948 '<div class="' + data.headerClass + '">' +
10949 '<div class="' + data.titleRowClass + '">' +
10950 '<span class="' + data.labelClass + '">' + data.title + '</span>' +
10951 '<a href="javascript:void(0)" class="' + data.closeClass + '">&times;</a>' +
10952 '</div>' +
10953 '</div>'
10954 );
10955 }
10956 }, options);
10957
10958 self.setup = (function() {
10959 var original = self.setup;
10960 return function() {
10961 original.apply(self, arguments);
10962 self.$dropdown_header = $(options.html(options));
10963 self.$dropdown.prepend(self.$dropdown_header);
10964 };
10965 })();
10966
10967 });
10968
10969 Selectize.define('optgroup_columns', function(options) {
10970 var self = this;
10971
10972 options = $.extend({
10973 equalizeWidth : true,
10974 equalizeHeight : true
10975 }, options);
10976
10977 this.getAdjacentOption = function($option, direction) {
10978 var $options = $option.closest('[data-group]').find('[data-selectable]');
10979 var index = $options.index($option) + direction;
10980
10981 return index >= 0 && index < $options.length ? $options.eq(index) : $();
10982 };
10983
10984 this.onKeyDown = (function() {
10985 var original = self.onKeyDown;
10986 return function(e) {
10987 var index, $option, $options, $optgroup;
10988
10989 if (this.isOpen && (e.keyCode === KEY_LEFT || e.keyCode === KEY_RIGHT)) {
10990 self.ignoreHover = true;
10991 $optgroup = this.$activeOption.closest('[data-group]');
10992 index = $optgroup.find('[data-selectable]').index(this.$activeOption);
10993
10994 if(e.keyCode === KEY_LEFT) {
10995 $optgroup = $optgroup.prev('[data-group]');
10996 } else {
10997 $optgroup = $optgroup.next('[data-group]');
10998 }
10999
11000 $options = $optgroup.find('[data-selectable]');
11001 $option = $options.eq(Math.min($options.length - 1, index));
11002 if ($option.length) {
11003 this.setActiveOption($option);
11004 }
11005 return;
11006 }
11007
11008 return original.apply(this, arguments);
11009 };
11010 })();
11011
11012 var getScrollbarWidth = function() {
11013 var div;
11014 var width = getScrollbarWidth.width;
11015 var doc = document;
11016
11017 if (typeof width === 'undefined') {
11018 div = doc.createElement('div');
11019 div.innerHTML = '<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>';
11020 div = div.firstChild;
11021 doc.body.appendChild(div);
11022 width = getScrollbarWidth.width = div.offsetWidth - div.clientWidth;
11023 doc.body.removeChild(div);
11024 }
11025 return width;
11026 };
11027
11028 var equalizeSizes = function() {
11029 var i, n, height_max, width, width_last, width_parent, $optgroups;
11030
11031 $optgroups = $('[data-group]', self.$dropdown_content);
11032 n = $optgroups.length;
11033 if (!n || !self.$dropdown_content.width()) return;
11034
11035 if (options.equalizeHeight) {
11036 height_max = 0;
11037 for (i = 0; i < n; i++) {
11038 height_max = Math.max(height_max, $optgroups.eq(i).height());
11039 }
11040 $optgroups.css({height: height_max});
11041 }
11042
11043 if (options.equalizeWidth) {
11044 width_parent = self.$dropdown_content.innerWidth() - getScrollbarWidth();
11045 width = Math.round(width_parent / n);
11046 $optgroups.css({width: width});
11047 if (n > 1) {
11048 width_last = width_parent - width * (n - 1);
11049 $optgroups.eq(n - 1).css({width: width_last});
11050 }
11051 }
11052 };
11053
11054 if (options.equalizeHeight || options.equalizeWidth) {
11055 hook.after(this, 'positionDropdown', equalizeSizes);
11056 hook.after(this, 'refreshOptions', equalizeSizes);
11057 }
11058
11059
11060 });
11061
11062 Selectize.define('remove_button', function(options) {
11063 options = $.extend({
11064 label : '&times;',
11065 title : 'Remove',
11066 className : 'remove',
11067 append : true
11068 }, options);
11069
11070 var singleClose = function(thisRef, options) {
11071
11072 options.className = 'remove-single';
11073
11074 var self = thisRef;
11075 var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
11076
11077 /**
11078 * Appends an element as a child (with raw HTML).
11079 *
11080 * @param {string} html_container
11081 * @param {string} html_element
11082 * @return {string}
11083 */
11084 var append = function(html_container, html_element) {
11085 return html_container + html_element;
11086 };
11087
11088 thisRef.setup = (function() {
11089 var original = self.setup;
11090 return function() {
11091 // override the item rendering method to add the button to each
11092 if (options.append) {
11093 var id = $(self.$input.context).attr('id');
11094 var selectizer = $('#'+id);
11095
11096 var render_item = self.settings.render.item;
11097 self.settings.render.item = function(data) {
11098 return append(render_item.apply(thisRef, arguments), html);
11099 };
11100 }
11101
11102 original.apply(thisRef, arguments);
11103
11104 // add event listener
11105 thisRef.$control.on('click', '.' + options.className, function(e) {
11106 e.preventDefault();
11107 if (self.isLocked) return;
11108
11109 self.clear();
11110 });
11111
11112 };
11113 })();
11114 };
11115
11116 var multiClose = function(thisRef, options) {
11117
11118 var self = thisRef;
11119 var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
11120
11121 /**
11122 * Appends an element as a child (with raw HTML).
11123 *
11124 * @param {string} html_container
11125 * @param {string} html_element
11126 * @return {string}
11127 */
11128 var append = function(html_container, html_element) {
11129 var pos = html_container.search(/(<\/[^>]+>\s*)$/);
11130 return html_container.substring(0, pos) + html_element + html_container.substring(pos);
11131 };
11132
11133 thisRef.setup = (function() {
11134 var original = self.setup;
11135 return function() {
11136 // override the item rendering method to add the button to each
11137 if (options.append) {
11138 var render_item = self.settings.render.item;
11139 self.settings.render.item = function(data) {
11140 return append(render_item.apply(thisRef, arguments), html);
11141 };
11142 }
11143
11144 original.apply(thisRef, arguments);
11145
11146 // add event listener
11147 thisRef.$control.on('click', '.' + options.className, function(e) {
11148 e.preventDefault();
11149 if (self.isLocked) return;
11150
11151 var $item = $(e.currentTarget).parent();
11152 self.setActiveItem($item);
11153 if (self.deleteSelection()) {
11154 self.setCaret(self.items.length);
11155 }
11156 });
11157
11158 };
11159 })();
11160 };
11161
11162 if (this.settings.mode === 'single') {
11163 singleClose(this, options);
11164 return;
11165 } else {
11166 multiClose(this, options);
11167 }
11168 });
11169
11170
11171 Selectize.define('restore_on_backspace', function(options) {
11172 var self = this;
11173
11174 options.text = options.text || function(option) {
11175 return option[this.settings.labelField];
11176 };
11177
11178 this.onKeyDown = (function() {
11179 var original = self.onKeyDown;
11180 return function(e) {
11181 var index, option;
11182 if (e.keyCode === KEY_BACKSPACE && this.$control_input.val() === '' && !this.$activeItems.length) {
11183 index = this.caretPos - 1;
11184 if (index >= 0 && index < this.items.length) {
11185 option = this.options[this.items[index]];
11186 if (this.deleteSelection(e)) {
11187 this.setTextboxValue(options.text.apply(this, [option]));
11188 this.refreshOptions(true);
11189 }
11190 e.preventDefault();
11191 return;
11192 }
11193 }
11194 return original.apply(this, arguments);
11195 };
11196 })();
11197 });
11198
11199
11200 return Selectize;
11201 }));
11202 /* assets/wpuf/vendor/toastr/toastr.js */
11203 /*
11204 * Toastr
11205 * Copyright 2012-2015
11206 * Authors: John Papa, Hans Fjällemark, and Tim Ferrell.
11207 * All Rights Reserved.
11208 * Use, reproduction, distribution, and modification of this code is subject to the terms and
11209 * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
11210 *
11211 * ARIA Support: Greta Krafsig
11212 *
11213 * Project: https://github.com/CodeSeven/toastr
11214 */
11215 /* global define */
11216 (function (define) {
11217 define(['jquery'], function ($) {
11218 return (function () {
11219 var $container;
11220 var listener;
11221 var toastId = 0;
11222 var toastType = {
11223 error: 'error',
11224 info: 'info',
11225 success: 'success',
11226 warning: 'warning'
11227 };
11228
11229 var toastr = {
11230 clear: clear,
11231 remove: remove,
11232 error: error,
11233 getContainer: getContainer,
11234 info: info,
11235 options: {},
11236 subscribe: subscribe,
11237 success: success,
11238 version: '2.1.3',
11239 warning: warning
11240 };
11241
11242 var previousToast;
11243
11244 return toastr;
11245
11246 ////////////////
11247
11248 function error(message, title, optionsOverride) {
11249 return notify({
11250 type: toastType.error,
11251 iconClass: getOptions().iconClasses.error,
11252 message: message,
11253 optionsOverride: optionsOverride,
11254 title: title
11255 });
11256 }
11257
11258 function getContainer(options, create) {
11259 if (!options) { options = getOptions(); }
11260 $container = $('#' + options.containerId);
11261 if ($container.length) {
11262 return $container;
11263 }
11264 if (create) {
11265 $container = createContainer(options);
11266 }
11267 return $container;
11268 }
11269
11270 function info(message, title, optionsOverride) {
11271 return notify({
11272 type: toastType.info,
11273 iconClass: getOptions().iconClasses.info,
11274 message: message,
11275 optionsOverride: optionsOverride,
11276 title: title
11277 });
11278 }
11279
11280 function subscribe(callback) {
11281 listener = callback;
11282 }
11283
11284 function success(message, title, optionsOverride) {
11285 return notify({
11286 type: toastType.success,
11287 iconClass: getOptions().iconClasses.success,
11288 message: message,
11289 optionsOverride: optionsOverride,
11290 title: title
11291 });
11292 }
11293
11294 function warning(message, title, optionsOverride) {
11295 return notify({
11296 type: toastType.warning,
11297 iconClass: getOptions().iconClasses.warning,
11298 message: message,
11299 optionsOverride: optionsOverride,
11300 title: title
11301 });
11302 }
11303
11304 function clear($toastElement, clearOptions) {
11305 var options = getOptions();
11306 if (!$container) { getContainer(options); }
11307 if (!clearToast($toastElement, options, clearOptions)) {
11308 clearContainer(options);
11309 }
11310 }
11311
11312 function remove($toastElement) {
11313 var options = getOptions();
11314 if (!$container) { getContainer(options); }
11315 if ($toastElement && $(':focus', $toastElement).length === 0) {
11316 removeToast($toastElement);
11317 return;
11318 }
11319 if ($container.children().length) {
11320 $container.remove();
11321 }
11322 }
11323
11324 // internal functions
11325
11326 function clearContainer (options) {
11327 var toastsToClear = $container.children();
11328 for (var i = toastsToClear.length - 1; i >= 0; i--) {
11329 clearToast($(toastsToClear[i]), options);
11330 }
11331 }
11332
11333 function clearToast ($toastElement, options, clearOptions) {
11334 var force = clearOptions && clearOptions.force ? clearOptions.force : false;
11335 if ($toastElement && (force || $(':focus', $toastElement).length === 0)) {
11336 $toastElement[options.hideMethod]({
11337 duration: options.hideDuration,
11338 easing: options.hideEasing,
11339 complete: function () { removeToast($toastElement); }
11340 });
11341 return true;
11342 }
11343 return false;
11344 }
11345
11346 function createContainer(options) {
11347 $container = $('<div/>')
11348 .attr('id', options.containerId)
11349 .addClass(options.positionClass);
11350
11351 $container.appendTo($(options.target));
11352 return $container;
11353 }
11354
11355 function getDefaults() {
11356 return {
11357 tapToDismiss: true,
11358 toastClass: 'toast',
11359 containerId: 'toast-container',
11360 debug: false,
11361
11362 showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
11363 showDuration: 300,
11364 showEasing: 'swing', //swing and linear are built into jQuery
11365 onShown: undefined,
11366 hideMethod: 'fadeOut',
11367 hideDuration: 1000,
11368 hideEasing: 'swing',
11369 onHidden: undefined,
11370 closeMethod: false,
11371 closeDuration: false,
11372 closeEasing: false,
11373 closeOnHover: true,
11374
11375 extendedTimeOut: 1000,
11376 iconClasses: {
11377 error: 'toast-error',
11378 info: 'toast-info',
11379 success: 'toast-success',
11380 warning: 'toast-warning'
11381 },
11382 iconClass: 'toast-info',
11383 positionClass: 'toast-top-right',
11384 timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
11385 titleClass: 'toast-title',
11386 messageClass: 'toast-message',
11387 escapeHtml: false,
11388 target: 'body',
11389 closeHtml: '<button type="button">&times;</button>',
11390 closeClass: 'toast-close-button',
11391 newestOnTop: true,
11392 preventDuplicates: false,
11393 progressBar: false,
11394 progressClass: 'toast-progress',
11395 rtl: false
11396 };
11397 }
11398
11399 function publish(args) {
11400 if (!listener) { return; }
11401 listener(args);
11402 }
11403
11404 function notify(map) {
11405 var options = getOptions();
11406 var iconClass = map.iconClass || options.iconClass;
11407
11408 if (typeof (map.optionsOverride) !== 'undefined') {
11409 options = $.extend(options, map.optionsOverride);
11410 iconClass = map.optionsOverride.iconClass || iconClass;
11411 }
11412
11413 if (shouldExit(options, map)) { return; }
11414
11415 toastId++;
11416
11417 $container = getContainer(options, true);
11418
11419 var intervalId = null;
11420 var $toastElement = $('<div/>');
11421 var $titleElement = $('<div/>');
11422 var $messageElement = $('<div/>');
11423 var $progressElement = $('<div/>');
11424 var $closeElement = $(options.closeHtml);
11425 var progressBar = {
11426 intervalId: null,
11427 hideEta: null,
11428 maxHideTime: null
11429 };
11430 var response = {
11431 toastId: toastId,
11432 state: 'visible',
11433 startTime: new Date(),
11434 options: options,
11435 map: map
11436 };
11437
11438 personalizeToast();
11439
11440 displayToast();
11441
11442 handleEvents();
11443
11444 publish(response);
11445
11446 if (options.debug && console) {
11447 console.log(response);
11448 }
11449
11450 return $toastElement;
11451
11452 function escapeHtml(source) {
11453 if (source == null) {
11454 source = '';
11455 }
11456
11457 return source
11458 .replace(/&/g, '&amp;')
11459 .replace(/"/g, '&quot;')
11460 .replace(/'/g, '&#39;')
11461 .replace(/</g, '&lt;')
11462 .replace(/>/g, '&gt;');
11463 }
11464
11465 function personalizeToast() {
11466 setIcon();
11467 setTitle();
11468 setMessage();
11469 setCloseButton();
11470 setProgressBar();
11471 setRTL();
11472 setSequence();
11473 setAria();
11474 }
11475
11476 function setAria() {
11477 var ariaValue = '';
11478 switch (map.iconClass) {
11479 case 'toast-success':
11480 case 'toast-info':
11481 ariaValue = 'polite';
11482 break;
11483 default:
11484 ariaValue = 'assertive';
11485 }
11486 $toastElement.attr('aria-live', ariaValue);
11487 }
11488
11489 function handleEvents() {
11490 if (options.closeOnHover) {
11491 $toastElement.hover(stickAround, delayedHideToast);
11492 }
11493
11494 if (!options.onclick && options.tapToDismiss) {
11495 $toastElement.click(hideToast);
11496 }
11497
11498 if (options.closeButton && $closeElement) {
11499 $closeElement.click(function (event) {
11500 if (event.stopPropagation) {
11501 event.stopPropagation();
11502 } else if (event.cancelBubble !== undefined && event.cancelBubble !== true) {
11503 event.cancelBubble = true;
11504 }
11505
11506 if (options.onCloseClick) {
11507 options.onCloseClick(event);
11508 }
11509
11510 hideToast(true);
11511 });
11512 }
11513
11514 if (options.onclick) {
11515 $toastElement.click(function (event) {
11516 options.onclick(event);
11517 hideToast();
11518 });
11519 }
11520 }
11521
11522 function displayToast() {
11523 $toastElement.hide();
11524
11525 $toastElement[options.showMethod](
11526 {duration: options.showDuration, easing: options.showEasing, complete: options.onShown}
11527 );
11528
11529 if (options.timeOut > 0) {
11530 intervalId = setTimeout(hideToast, options.timeOut);
11531 progressBar.maxHideTime = parseFloat(options.timeOut);
11532 progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
11533 if (options.progressBar) {
11534 progressBar.intervalId = setInterval(updateProgress, 10);
11535 }
11536 }
11537 }
11538
11539 function setIcon() {
11540 if (map.iconClass) {
11541 $toastElement.addClass(options.toastClass).addClass(iconClass);
11542 }
11543 }
11544
11545 function setSequence() {
11546 if (options.newestOnTop) {
11547 $container.prepend($toastElement);
11548 } else {
11549 $container.append($toastElement);
11550 }
11551 }
11552
11553 function setTitle() {
11554 if (map.title) {
11555 var suffix = map.title;
11556 if (options.escapeHtml) {
11557 suffix = escapeHtml(map.title);
11558 }
11559 $titleElement.append(suffix).addClass(options.titleClass);
11560 $toastElement.append($titleElement);
11561 }
11562 }
11563
11564 function setMessage() {
11565 if (map.message) {
11566 var suffix = map.message;
11567 if (options.escapeHtml) {
11568 suffix = escapeHtml(map.message);
11569 }
11570 $messageElement.append(suffix).addClass(options.messageClass);
11571 $toastElement.append($messageElement);
11572 }
11573 }
11574
11575 function setCloseButton() {
11576 if (options.closeButton) {
11577 $closeElement.addClass(options.closeClass).attr('role', 'button');
11578 $toastElement.prepend($closeElement);
11579 }
11580 }
11581
11582 function setProgressBar() {
11583 if (options.progressBar) {
11584 $progressElement.addClass(options.progressClass);
11585 $toastElement.prepend($progressElement);
11586 }
11587 }
11588
11589 function setRTL() {
11590 if (options.rtl) {
11591 $toastElement.addClass('rtl');
11592 }
11593 }
11594
11595 function shouldExit(options, map) {
11596 if (options.preventDuplicates) {
11597 if (map.message === previousToast) {
11598 return true;
11599 } else {
11600 previousToast = map.message;
11601 }
11602 }
11603 return false;
11604 }
11605
11606 function hideToast(override) {
11607 var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
11608 var duration = override && options.closeDuration !== false ?
11609 options.closeDuration : options.hideDuration;
11610 var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
11611 if ($(':focus', $toastElement).length && !override) {
11612 return;
11613 }
11614 clearTimeout(progressBar.intervalId);
11615 return $toastElement[method]({
11616 duration: duration,
11617 easing: easing,
11618 complete: function () {
11619 removeToast($toastElement);
11620 clearTimeout(intervalId);
11621 if (options.onHidden && response.state !== 'hidden') {
11622 options.onHidden();
11623 }
11624 response.state = 'hidden';
11625 response.endTime = new Date();
11626 publish(response);
11627 }
11628 });
11629 }
11630
11631 function delayedHideToast() {
11632 if (options.timeOut > 0 || options.extendedTimeOut > 0) {
11633 intervalId = setTimeout(hideToast, options.extendedTimeOut);
11634 progressBar.maxHideTime = parseFloat(options.extendedTimeOut);
11635 progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
11636 }
11637 }
11638
11639 function stickAround() {
11640 clearTimeout(intervalId);
11641 progressBar.hideEta = 0;
11642 $toastElement.stop(true, true)[options.showMethod](
11643 {duration: options.showDuration, easing: options.showEasing}
11644 );
11645 }
11646
11647 function updateProgress() {
11648 var percentage = ((progressBar.hideEta - (new Date().getTime())) / progressBar.maxHideTime) * 100;
11649 $progressElement.width(percentage + '%');
11650 }
11651 }
11652
11653 function getOptions() {
11654 return $.extend({}, getDefaults(), toastr.options);
11655 }
11656
11657 function removeToast($toastElement) {
11658 if (!$container) { $container = getContainer(); }
11659 if ($toastElement.is(':visible')) {
11660 return;
11661 }
11662 $toastElement.remove();
11663 $toastElement = null;
11664 if ($container.children().length === 0) {
11665 $container.remove();
11666 previousToast = undefined;
11667 }
11668 }
11669
11670 })();
11671 });
11672 }(typeof define === 'function' && define.amd ? define : function (deps, factory) {
11673 if (typeof module !== 'undefined' && module.exports) { //Node
11674 module.exports = factory(require('jquery'));
11675 } else {
11676 window.toastr = factory(window.jQuery);
11677 }
11678 }));
11679
11680 /* assets/wpuf/vendor/clipboard/clipboard.js */
11681 /*!
11682 * clipboard.js v1.6.0
11683 * https://zenorocha.github.io/clipboard.js
11684 *
11685 * Licensed MIT © Zeno Rocha
11686 */
11687 (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Clipboard = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
11688 var DOCUMENT_NODE_TYPE = 9;
11689
11690 /**
11691 * A polyfill for Element.matches()
11692 */
11693 if (Element && !Element.prototype.matches) {
11694 var proto = Element.prototype;
11695
11696 proto.matches = proto.matchesSelector ||
11697 proto.mozMatchesSelector ||
11698 proto.msMatchesSelector ||
11699 proto.oMatchesSelector ||
11700 proto.webkitMatchesSelector;
11701 }
11702
11703 /**
11704 * Finds the closest parent that matches a selector.
11705 *
11706 * @param {Element} element
11707 * @param {String} selector
11708 * @return {Function}
11709 */
11710 function closest (element, selector) {
11711 while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
11712 if (element.matches(selector)) return element;
11713 element = element.parentNode;
11714 }
11715 }
11716
11717 module.exports = closest;
11718
11719 },{}],2:[function(require,module,exports){
11720 var closest = require('./closest');
11721
11722 /**
11723 * Delegates event to a selector.
11724 *
11725 * @param {Element} element
11726 * @param {String} selector
11727 * @param {String} type
11728 * @param {Function} callback
11729 * @param {Boolean} useCapture
11730 * @return {Object}
11731 */
11732 function delegate(element, selector, type, callback, useCapture) {
11733 var listenerFn = listener.apply(this, arguments);
11734
11735 element.addEventListener(type, listenerFn, useCapture);
11736
11737 return {
11738 destroy: function() {
11739 element.removeEventListener(type, listenerFn, useCapture);
11740 }
11741 }
11742 }
11743
11744 /**
11745 * Finds closest match and invokes callback.
11746 *
11747 * @param {Element} element
11748 * @param {String} selector
11749 * @param {String} type
11750 * @param {Function} callback
11751 * @return {Function}
11752 */
11753 function listener(element, selector, type, callback) {
11754 return function(e) {
11755 e.delegateTarget = closest(e.target, selector);
11756
11757 if (e.delegateTarget) {
11758 callback.call(element, e);
11759 }
11760 }
11761 }
11762
11763 module.exports = delegate;
11764
11765 },{"./closest":1}],3:[function(require,module,exports){
11766 /**
11767 * Check if argument is a HTML element.
11768 *
11769 * @param {Object} value
11770 * @return {Boolean}
11771 */
11772 exports.node = function(value) {
11773 return value !== undefined
11774 && value instanceof HTMLElement
11775 && value.nodeType === 1;
11776 };
11777
11778 /**
11779 * Check if argument is a list of HTML elements.
11780 *
11781 * @param {Object} value
11782 * @return {Boolean}
11783 */
11784 exports.nodeList = function(value) {
11785 var type = Object.prototype.toString.call(value);
11786
11787 return value !== undefined
11788 && (type === '[object NodeList]' || type === '[object HTMLCollection]')
11789 && ('length' in value)
11790 && (value.length === 0 || exports.node(value[0]));
11791 };
11792
11793 /**
11794 * Check if argument is a string.
11795 *
11796 * @param {Object} value
11797 * @return {Boolean}
11798 */
11799 exports.string = function(value) {
11800 return typeof value === 'string'
11801 || value instanceof String;
11802 };
11803
11804 /**
11805 * Check if argument is a function.
11806 *
11807 * @param {Object} value
11808 * @return {Boolean}
11809 */
11810 exports.fn = function(value) {
11811 var type = Object.prototype.toString.call(value);
11812
11813 return type === '[object Function]';
11814 };
11815
11816 },{}],4:[function(require,module,exports){
11817 var is = require('./is');
11818 var delegate = require('delegate');
11819
11820 /**
11821 * Validates all params and calls the right
11822 * listener function based on its target type.
11823 *
11824 * @param {String|HTMLElement|HTMLCollection|NodeList} target
11825 * @param {String} type
11826 * @param {Function} callback
11827 * @return {Object}
11828 */
11829 function listen(target, type, callback) {
11830 if (!target && !type && !callback) {
11831 throw new Error('Missing required arguments');
11832 }
11833
11834 if (!is.string(type)) {
11835 throw new TypeError('Second argument must be a String');
11836 }
11837
11838 if (!is.fn(callback)) {
11839 throw new TypeError('Third argument must be a Function');
11840 }
11841
11842 if (is.node(target)) {
11843 return listenNode(target, type, callback);
11844 }
11845 else if (is.nodeList(target)) {
11846 return listenNodeList(target, type, callback);
11847 }
11848 else if (is.string(target)) {
11849 return listenSelector(target, type, callback);
11850 }
11851 else {
11852 throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
11853 }
11854 }
11855
11856 /**
11857 * Adds an event listener to a HTML element
11858 * and returns a remove listener function.
11859 *
11860 * @param {HTMLElement} node
11861 * @param {String} type
11862 * @param {Function} callback
11863 * @return {Object}
11864 */
11865 function listenNode(node, type, callback) {
11866 node.addEventListener(type, callback);
11867
11868 return {
11869 destroy: function() {
11870 node.removeEventListener(type, callback);
11871 }
11872 }
11873 }
11874
11875 /**
11876 * Add an event listener to a list of HTML elements
11877 * and returns a remove listener function.
11878 *
11879 * @param {NodeList|HTMLCollection} nodeList
11880 * @param {String} type
11881 * @param {Function} callback
11882 * @return {Object}
11883 */
11884 function listenNodeList(nodeList, type, callback) {
11885 Array.prototype.forEach.call(nodeList, function(node) {
11886 node.addEventListener(type, callback);
11887 });
11888
11889 return {
11890 destroy: function() {
11891 Array.prototype.forEach.call(nodeList, function(node) {
11892 node.removeEventListener(type, callback);
11893 });
11894 }
11895 }
11896 }
11897
11898 /**
11899 * Add an event listener to a selector
11900 * and returns a remove listener function.
11901 *
11902 * @param {String} selector
11903 * @param {String} type
11904 * @param {Function} callback
11905 * @return {Object}
11906 */
11907 function listenSelector(selector, type, callback) {
11908 return delegate(document.body, selector, type, callback);
11909 }
11910
11911 module.exports = listen;
11912
11913 },{"./is":3,"delegate":2}],5:[function(require,module,exports){
11914 function select(element) {
11915 var selectedText;
11916
11917 if (element.nodeName === 'SELECT') {
11918 element.focus();
11919
11920 selectedText = element.value;
11921 }
11922 else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
11923 var isReadOnly = element.hasAttribute('readonly');
11924
11925 if (!isReadOnly) {
11926 element.setAttribute('readonly', '');
11927 }
11928
11929 element.select();
11930 element.setSelectionRange(0, element.value.length);
11931
11932 if (!isReadOnly) {
11933 element.removeAttribute('readonly');
11934 }
11935
11936 selectedText = element.value;
11937 }
11938 else {
11939 if (element.hasAttribute('contenteditable')) {
11940 element.focus();
11941 }
11942
11943 var selection = window.getSelection();
11944 var range = document.createRange();
11945
11946 range.selectNodeContents(element);
11947 selection.removeAllRanges();
11948 selection.addRange(range);
11949
11950 selectedText = selection.toString();
11951 }
11952
11953 return selectedText;
11954 }
11955
11956 module.exports = select;
11957
11958 },{}],6:[function(require,module,exports){
11959 function E () {
11960 // Keep this empty so it's easier to inherit from
11961 // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
11962 }
11963
11964 E.prototype = {
11965 on: function (name, callback, ctx) {
11966 var e = this.e || (this.e = {});
11967
11968 (e[name] || (e[name] = [])).push({
11969 fn: callback,
11970 ctx: ctx
11971 });
11972
11973 return this;
11974 },
11975
11976 once: function (name, callback, ctx) {
11977 var self = this;
11978 function listener () {
11979 self.off(name, listener);
11980 callback.apply(ctx, arguments);
11981 };
11982
11983 listener._ = callback
11984 return this.on(name, listener, ctx);
11985 },
11986
11987 emit: function (name) {
11988 var data = [].slice.call(arguments, 1);
11989 var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
11990 var i = 0;
11991 var len = evtArr.length;
11992
11993 for (i; i < len; i++) {
11994 evtArr[i].fn.apply(evtArr[i].ctx, data);
11995 }
11996
11997 return this;
11998 },
11999
12000 off: function (name, callback) {
12001 var e = this.e || (this.e = {});
12002 var evts = e[name];
12003 var liveEvents = [];
12004
12005 if (evts && callback) {
12006 for (var i = 0, len = evts.length; i < len; i++) {
12007 if (evts[i].fn !== callback && evts[i].fn._ !== callback)
12008 liveEvents.push(evts[i]);
12009 }
12010 }
12011
12012 // Remove event from queue to prevent memory leak
12013 // Suggested by https://github.com/lazd
12014 // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
12015
12016 (liveEvents.length)
12017 ? e[name] = liveEvents
12018 : delete e[name];
12019
12020 return this;
12021 }
12022 };
12023
12024 module.exports = E;
12025
12026 },{}],7:[function(require,module,exports){
12027 (function (global, factory) {
12028 if (typeof define === "function" && define.amd) {
12029 define(['module', 'select'], factory);
12030 } else if (typeof exports !== "undefined") {
12031 factory(module, require('select'));
12032 } else {
12033 var mod = {
12034 exports: {}
12035 };
12036 factory(mod, global.select);
12037 global.clipboardAction = mod.exports;
12038 }
12039 })(this, function (module, _select) {
12040 'use strict';
12041
12042 var _select2 = _interopRequireDefault(_select);
12043
12044 function _interopRequireDefault(obj) {
12045 return obj && obj.__esModule ? obj : {
12046 default: obj
12047 };
12048 }
12049
12050 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
12051 return typeof obj;
12052 } : function (obj) {
12053 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
12054 };
12055
12056 function _classCallCheck(instance, Constructor) {
12057 if (!(instance instanceof Constructor)) {
12058 throw new TypeError("Cannot call a class as a function");
12059 }
12060 }
12061
12062 var _createClass = function () {
12063 function defineProperties(target, props) {
12064 for (var i = 0; i < props.length; i++) {
12065 var descriptor = props[i];
12066 descriptor.enumerable = descriptor.enumerable || false;
12067 descriptor.configurable = true;
12068 if ("value" in descriptor) descriptor.writable = true;
12069 Object.defineProperty(target, descriptor.key, descriptor);
12070 }
12071 }
12072
12073 return function (Constructor, protoProps, staticProps) {
12074 if (protoProps) defineProperties(Constructor.prototype, protoProps);
12075 if (staticProps) defineProperties(Constructor, staticProps);
12076 return Constructor;
12077 };
12078 }();
12079
12080 var ClipboardAction = function () {
12081 /**
12082 * @param {Object} options
12083 */
12084 function ClipboardAction(options) {
12085 _classCallCheck(this, ClipboardAction);
12086
12087 this.resolveOptions(options);
12088 this.initSelection();
12089 }
12090
12091 /**
12092 * Defines base properties passed from constructor.
12093 * @param {Object} options
12094 */
12095
12096
12097 _createClass(ClipboardAction, [{
12098 key: 'resolveOptions',
12099 value: function resolveOptions() {
12100 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
12101
12102 this.action = options.action;
12103 this.emitter = options.emitter;
12104 this.target = options.target;
12105 this.text = options.text;
12106 this.trigger = options.trigger;
12107
12108 this.selectedText = '';
12109 }
12110 }, {
12111 key: 'initSelection',
12112 value: function initSelection() {
12113 if (this.text) {
12114 this.selectFake();
12115 } else if (this.target) {
12116 this.selectTarget();
12117 }
12118 }
12119 }, {
12120 key: 'selectFake',
12121 value: function selectFake() {
12122 var _this = this;
12123
12124 var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
12125
12126 this.removeFake();
12127
12128 this.fakeHandlerCallback = function () {
12129 return _this.removeFake();
12130 };
12131 this.fakeHandler = document.body.addEventListener('click', this.fakeHandlerCallback) || true;
12132
12133 this.fakeElem = document.createElement('textarea');
12134 // Prevent zooming on iOS
12135 this.fakeElem.style.fontSize = '12pt';
12136 // Reset box model
12137 this.fakeElem.style.border = '0';
12138 this.fakeElem.style.padding = '0';
12139 this.fakeElem.style.margin = '0';
12140 // Move element out of screen horizontally
12141 this.fakeElem.style.position = 'absolute';
12142 this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
12143 // Move element to the same position vertically
12144 var yPosition = window.pageYOffset || document.documentElement.scrollTop;
12145 this.fakeElem.style.top = yPosition + 'px';
12146
12147 this.fakeElem.setAttribute('readonly', '');
12148 this.fakeElem.value = this.text;
12149
12150 document.body.appendChild(this.fakeElem);
12151
12152 this.selectedText = (0, _select2.default)(this.fakeElem);
12153 this.copyText();
12154 }
12155 }, {
12156 key: 'removeFake',
12157 value: function removeFake() {
12158 if (this.fakeHandler) {
12159 document.body.removeEventListener('click', this.fakeHandlerCallback);
12160 this.fakeHandler = null;
12161 this.fakeHandlerCallback = null;
12162 }
12163
12164 if (this.fakeElem) {
12165 document.body.removeChild(this.fakeElem);
12166 this.fakeElem = null;
12167 }
12168 }
12169 }, {
12170 key: 'selectTarget',
12171 value: function selectTarget() {
12172 this.selectedText = (0, _select2.default)(this.target);
12173 this.copyText();
12174 }
12175 }, {
12176 key: 'copyText',
12177 value: function copyText() {
12178 var succeeded = void 0;
12179
12180 try {
12181 succeeded = document.execCommand(this.action);
12182 } catch (err) {
12183 succeeded = false;
12184 }
12185
12186 this.handleResult(succeeded);
12187 }
12188 }, {
12189 key: 'handleResult',
12190 value: function handleResult(succeeded) {
12191 this.emitter.emit(succeeded ? 'success' : 'error', {
12192 action: this.action,
12193 text: this.selectedText,
12194 trigger: this.trigger,
12195 clearSelection: this.clearSelection.bind(this)
12196 });
12197 }
12198 }, {
12199 key: 'clearSelection',
12200 value: function clearSelection() {
12201 if (this.target) {
12202 this.target.blur();
12203 }
12204
12205 window.getSelection().removeAllRanges();
12206 }
12207 }, {
12208 key: 'destroy',
12209 value: function destroy() {
12210 this.removeFake();
12211 }
12212 }, {
12213 key: 'action',
12214 set: function set() {
12215 var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
12216
12217 this._action = action;
12218
12219 if (this._action !== 'copy' && this._action !== 'cut') {
12220 throw new Error('Invalid "action" value, use either "copy" or "cut"');
12221 }
12222 },
12223 get: function get() {
12224 return this._action;
12225 }
12226 }, {
12227 key: 'target',
12228 set: function set(target) {
12229 if (target !== undefined) {
12230 if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {
12231 if (this.action === 'copy' && target.hasAttribute('disabled')) {
12232 throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
12233 }
12234
12235 if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
12236 throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
12237 }
12238
12239 this._target = target;
12240 } else {
12241 throw new Error('Invalid "target" value, use a valid Element');
12242 }
12243 }
12244 },
12245 get: function get() {
12246 return this._target;
12247 }
12248 }]);
12249
12250 return ClipboardAction;
12251 }();
12252
12253 module.exports = ClipboardAction;
12254 });
12255
12256 },{"select":5}],8:[function(require,module,exports){
12257 (function (global, factory) {
12258 if (typeof define === "function" && define.amd) {
12259 define(['module', './clipboard-action', 'tiny-emitter', 'good-listener'], factory);
12260 } else if (typeof exports !== "undefined") {
12261 factory(module, require('./clipboard-action'), require('tiny-emitter'), require('good-listener'));
12262 } else {
12263 var mod = {
12264 exports: {}
12265 };
12266 factory(mod, global.clipboardAction, global.tinyEmitter, global.goodListener);
12267 global.clipboard = mod.exports;
12268 }
12269 })(this, function (module, _clipboardAction, _tinyEmitter, _goodListener) {
12270 'use strict';
12271
12272 var _clipboardAction2 = _interopRequireDefault(_clipboardAction);
12273
12274 var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter);
12275
12276 var _goodListener2 = _interopRequireDefault(_goodListener);
12277
12278 function _interopRequireDefault(obj) {
12279 return obj && obj.__esModule ? obj : {
12280 default: obj
12281 };
12282 }
12283
12284 function _classCallCheck(instance, Constructor) {
12285 if (!(instance instanceof Constructor)) {
12286 throw new TypeError("Cannot call a class as a function");
12287 }
12288 }
12289
12290 var _createClass = function () {
12291 function defineProperties(target, props) {
12292 for (var i = 0; i < props.length; i++) {
12293 var descriptor = props[i];
12294 descriptor.enumerable = descriptor.enumerable || false;
12295 descriptor.configurable = true;
12296 if ("value" in descriptor) descriptor.writable = true;
12297 Object.defineProperty(target, descriptor.key, descriptor);
12298 }
12299 }
12300
12301 return function (Constructor, protoProps, staticProps) {
12302 if (protoProps) defineProperties(Constructor.prototype, protoProps);
12303 if (staticProps) defineProperties(Constructor, staticProps);
12304 return Constructor;
12305 };
12306 }();
12307
12308 function _possibleConstructorReturn(self, call) {
12309 if (!self) {
12310 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
12311 }
12312
12313 return call && (typeof call === "object" || typeof call === "function") ? call : self;
12314 }
12315
12316 function _inherits(subClass, superClass) {
12317 if (typeof superClass !== "function" && superClass !== null) {
12318 throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
12319 }
12320
12321 subClass.prototype = Object.create(superClass && superClass.prototype, {
12322 constructor: {
12323 value: subClass,
12324 enumerable: false,
12325 writable: true,
12326 configurable: true
12327 }
12328 });
12329 if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
12330 }
12331
12332 var Clipboard = function (_Emitter) {
12333 _inherits(Clipboard, _Emitter);
12334
12335 /**
12336 * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
12337 * @param {Object} options
12338 */
12339 function Clipboard(trigger, options) {
12340 _classCallCheck(this, Clipboard);
12341
12342 var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));
12343
12344 _this.resolveOptions(options);
12345 _this.listenClick(trigger);
12346 return _this;
12347 }
12348
12349 /**
12350 * Defines if attributes would be resolved using internal setter functions
12351 * or custom functions that were passed in the constructor.
12352 * @param {Object} options
12353 */
12354
12355
12356 _createClass(Clipboard, [{
12357 key: 'resolveOptions',
12358 value: function resolveOptions() {
12359 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
12360
12361 this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
12362 this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
12363 this.text = typeof options.text === 'function' ? options.text : this.defaultText;
12364 }
12365 }, {
12366 key: 'listenClick',
12367 value: function listenClick(trigger) {
12368 var _this2 = this;
12369
12370 this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
12371 return _this2.onClick(e);
12372 });
12373 }
12374 }, {
12375 key: 'onClick',
12376 value: function onClick(e) {
12377 var trigger = e.delegateTarget || e.currentTarget;
12378
12379 if (this.clipboardAction) {
12380 this.clipboardAction = null;
12381 }
12382
12383 this.clipboardAction = new _clipboardAction2.default({
12384 action: this.action(trigger),
12385 target: this.target(trigger),
12386 text: this.text(trigger),
12387 trigger: trigger,
12388 emitter: this
12389 });
12390 }
12391 }, {
12392 key: 'defaultAction',
12393 value: function defaultAction(trigger) {
12394 return getAttributeValue('action', trigger);
12395 }
12396 }, {
12397 key: 'defaultTarget',
12398 value: function defaultTarget(trigger) {
12399 var selector = getAttributeValue('target', trigger);
12400
12401 if (selector) {
12402 return document.querySelector(selector);
12403 }
12404 }
12405 }, {
12406 key: 'defaultText',
12407 value: function defaultText(trigger) {
12408 return getAttributeValue('text', trigger);
12409 }
12410 }, {
12411 key: 'destroy',
12412 value: function destroy() {
12413 this.listener.destroy();
12414
12415 if (this.clipboardAction) {
12416 this.clipboardAction.destroy();
12417 this.clipboardAction = null;
12418 }
12419 }
12420 }], [{
12421 key: 'isSupported',
12422 value: function isSupported() {
12423 var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
12424
12425 var actions = typeof action === 'string' ? [action] : action;
12426 var support = !!document.queryCommandSupported;
12427
12428 actions.forEach(function (action) {
12429 support = support && !!document.queryCommandSupported(action);
12430 });
12431
12432 return support;
12433 }
12434 }]);
12435
12436 return Clipboard;
12437 }(_tinyEmitter2.default);
12438
12439 /**
12440 * Helper function to retrieve attribute value.
12441 * @param {String} suffix
12442 * @param {Element} element
12443 */
12444 function getAttributeValue(suffix, element) {
12445 var attribute = 'data-clipboard-' + suffix;
12446
12447 if (!element.hasAttribute(attribute)) {
12448 return;
12449 }
12450
12451 return element.getAttribute(attribute);
12452 }
12453
12454 module.exports = Clipboard;
12455 });
12456
12457 },{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)
12458 });
12459 /* assets/wpuf/vendor/tooltip/tooltip.js */
12460 /* ========================================================================
12461 * Bootstrap: tooltip.js v3.3.7
12462 * http://getbootstrap.com/javascript/#tooltip
12463 * Inspired by the original jQuery.tipsy by Jason Frame
12464 * ========================================================================
12465 * Copyright 2011-2016 Twitter, Inc.
12466 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
12467 * ======================================================================== */
12468
12469 +function ($) {
12470 'use strict';
12471 $.support.transition = false;
12472
12473 // TOOLTIP PUBLIC CLASS DEFINITION
12474 // ===============================
12475
12476 var Tooltip = function (element, options) {
12477 this.type = null
12478 this.options = null
12479 this.enabled = null
12480 this.timeout = null
12481 this.hoverState = null
12482 this.$element = null
12483 this.inState = null
12484
12485 this.init('tooltip', element, options)
12486 }
12487
12488 Tooltip.VERSION = '3.3.7'
12489
12490 Tooltip.TRANSITION_DURATION = 150
12491
12492 Tooltip.DEFAULTS = {
12493 animation: true,
12494 placement: 'top',
12495 selector: false,
12496 template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
12497 trigger: 'hover focus',
12498 title: '',
12499 delay: 0,
12500 html: false,
12501 container: false,
12502 viewport: {
12503 selector: 'body',
12504 padding: 0
12505 }
12506 }
12507
12508 Tooltip.prototype.init = function (type, element, options) {
12509 this.enabled = true
12510 this.type = type
12511 this.$element = $(element)
12512 this.options = this.getOptions(options)
12513 this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
12514 this.inState = { click: false, hover: false, focus: false }
12515
12516 if (this.$element[0] instanceof document.constructor && !this.options.selector) {
12517 throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')
12518 }
12519
12520 var triggers = this.options.trigger.split(' ')
12521
12522 for (var i = triggers.length; i--;) {
12523 var trigger = triggers[i]
12524
12525 if (trigger == 'click') {
12526 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
12527 } else if (trigger != 'manual') {
12528 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
12529 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
12530
12531 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
12532 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
12533 }
12534 }
12535
12536 this.options.selector ?
12537 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
12538 this.fixTitle()
12539 }
12540
12541 Tooltip.prototype.getDefaults = function () {
12542 return Tooltip.DEFAULTS
12543 }
12544
12545 Tooltip.prototype.getOptions = function (options) {
12546 options = $.extend({}, this.getDefaults(), this.$element.data(), options)
12547
12548 if (options.delay && typeof options.delay == 'number') {
12549 options.delay = {
12550 show: options.delay,
12551 hide: options.delay
12552 }
12553 }
12554
12555 return options
12556 }
12557
12558 Tooltip.prototype.getDelegateOptions = function () {
12559 var options = {}
12560 var defaults = this.getDefaults()
12561
12562 this._options && $.each(this._options, function (key, value) {
12563 if (defaults[key] != value) options[key] = value
12564 })
12565
12566 return options
12567 }
12568
12569 Tooltip.prototype.enter = function (obj) {
12570 var self = obj instanceof this.constructor ?
12571 obj : $(obj.currentTarget).data('bs.' + this.type)
12572
12573 if (!self) {
12574 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
12575 $(obj.currentTarget).data('bs.' + this.type, self)
12576 }
12577
12578 if (obj instanceof $.Event) {
12579 self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true
12580 }
12581
12582 if (self.tip().hasClass('in') || self.hoverState == 'in') {
12583 self.hoverState = 'in'
12584 return
12585 }
12586
12587 clearTimeout(self.timeout)
12588
12589 self.hoverState = 'in'
12590
12591 if (!self.options.delay || !self.options.delay.show) return self.show()
12592
12593 self.timeout = setTimeout(function () {
12594 if (self.hoverState == 'in') self.show()
12595 }, self.options.delay.show)
12596 }
12597
12598 Tooltip.prototype.isInStateTrue = function () {
12599 for (var key in this.inState) {
12600 if (this.inState[key]) return true
12601 }
12602
12603 return false
12604 }
12605
12606 Tooltip.prototype.leave = function (obj) {
12607 var self = obj instanceof this.constructor ?
12608 obj : $(obj.currentTarget).data('bs.' + this.type)
12609
12610 if (!self) {
12611 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
12612 $(obj.currentTarget).data('bs.' + this.type, self)
12613 }
12614
12615 if (obj instanceof $.Event) {
12616 self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false
12617 }
12618
12619 if (self.isInStateTrue()) return
12620
12621 clearTimeout(self.timeout)
12622
12623 self.hoverState = 'out'
12624
12625 if (!self.options.delay || !self.options.delay.hide) return self.hide()
12626
12627 self.timeout = setTimeout(function () {
12628 if (self.hoverState == 'out') self.hide()
12629 }, self.options.delay.hide)
12630 }
12631
12632 Tooltip.prototype.show = function () {
12633 var e = $.Event('show.bs.' + this.type)
12634
12635 if (this.hasContent() && this.enabled) {
12636 this.$element.trigger(e)
12637
12638 var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])
12639 if (e.isDefaultPrevented() || !inDom) return
12640 var that = this
12641
12642 var $tip = this.tip()
12643
12644 var tipId = this.getUID(this.type)
12645
12646 this.setContent()
12647 $tip.attr('id', tipId)
12648 this.$element.attr('aria-describedby', tipId)
12649
12650 if (this.options.animation) $tip.addClass('fade')
12651
12652 var placement = typeof this.options.placement == 'function' ?
12653 this.options.placement.call(this, $tip[0], this.$element[0]) :
12654 this.options.placement
12655
12656 var autoToken = /\s?auto?\s?/i
12657 var autoPlace = autoToken.test(placement)
12658 if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
12659
12660 $tip
12661 .detach()
12662 .css({ top: 0, left: 0, display: 'block' })
12663 .addClass(placement)
12664 .data('bs.' + this.type, this)
12665
12666 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
12667 this.$element.trigger('inserted.bs.' + this.type)
12668
12669 var pos = this.getPosition()
12670 var actualWidth = $tip[0].offsetWidth
12671 var actualHeight = $tip[0].offsetHeight
12672
12673 if (autoPlace) {
12674 var orgPlacement = placement
12675 var viewportDim = this.getPosition(this.$viewport)
12676
12677 placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top' :
12678 placement == 'top' && pos.top - actualHeight < viewportDim.top ? 'bottom' :
12679 placement == 'right' && pos.right + actualWidth > viewportDim.width ? 'left' :
12680 placement == 'left' && pos.left - actualWidth < viewportDim.left ? 'right' :
12681 placement
12682
12683 $tip
12684 .removeClass(orgPlacement)
12685 .addClass(placement)
12686 }
12687
12688 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
12689
12690 this.applyPlacement(calculatedOffset, placement)
12691
12692 var complete = function () {
12693 var prevHoverState = that.hoverState
12694 that.$element.trigger('shown.bs.' + that.type)
12695 that.hoverState = null
12696
12697 if (prevHoverState == 'out') that.leave(that)
12698 }
12699
12700 $.support.transition && this.$tip.hasClass('fade') ?
12701 $tip
12702 .one('bsTransitionEnd', complete)
12703 .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
12704 complete()
12705 }
12706 }
12707
12708 Tooltip.prototype.applyPlacement = function (offset, placement) {
12709 var $tip = this.tip()
12710 var width = $tip[0].offsetWidth
12711 var height = $tip[0].offsetHeight
12712
12713 // manually read margins because getBoundingClientRect includes difference
12714 var marginTop = parseInt($tip.css('margin-top'), 10)
12715 var marginLeft = parseInt($tip.css('margin-left'), 10)
12716
12717 // we must check for NaN for ie 8/9
12718 if (isNaN(marginTop)) marginTop = 0
12719 if (isNaN(marginLeft)) marginLeft = 0
12720
12721 offset.top += marginTop
12722 offset.left += marginLeft
12723
12724 // $.fn.offset doesn't round pixel values
12725 // so we use setOffset directly with our own function B-0
12726 $.offset.setOffset($tip[0], $.extend({
12727 using: function (props) {
12728 $tip.css({
12729 top: Math.round(props.top),
12730 left: Math.round(props.left)
12731 })
12732 }
12733 }, offset), 0)
12734
12735 $tip.addClass('in')
12736
12737 // check to see if placing tip in new offset caused the tip to resize itself
12738 var actualWidth = $tip[0].offsetWidth
12739 var actualHeight = $tip[0].offsetHeight
12740
12741 if (placement == 'top' && actualHeight != height) {
12742 offset.top = offset.top + height - actualHeight
12743 }
12744
12745 var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
12746
12747 if (delta.left) offset.left += delta.left
12748 else offset.top += delta.top
12749
12750 var isVertical = /top|bottom/.test(placement)
12751 var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
12752 var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'
12753
12754 $tip.offset(offset)
12755 this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
12756 }
12757
12758 Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) {
12759 this.arrow()
12760 .css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
12761 .css(isVertical ? 'top' : 'left', '')
12762 }
12763
12764 Tooltip.prototype.setContent = function () {
12765 var $tip = this.tip()
12766 var title = this.getTitle()
12767
12768 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
12769 $tip.removeClass('fade in top bottom left right')
12770 }
12771
12772 Tooltip.prototype.hide = function (callback) {
12773 var that = this
12774 var $tip = $(this.$tip)
12775 var e = $.Event('hide.bs.' + this.type)
12776
12777 function complete() {
12778 if (that.hoverState != 'in') $tip.detach()
12779 if (that.$element) { // TODO: Check whether guarding this code with this `if` is really necessary.
12780 that.$element
12781 .removeAttr('aria-describedby')
12782 .trigger('hidden.bs.' + that.type)
12783 }
12784 callback && callback()
12785 }
12786
12787 this.$element.trigger(e)
12788
12789 if (e.isDefaultPrevented()) return
12790
12791 $tip.removeClass('in')
12792
12793 $.support.transition && $tip.hasClass('fade') ?
12794 $tip
12795 .one('bsTransitionEnd', complete)
12796 .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
12797 complete()
12798
12799 this.hoverState = null
12800
12801 return this
12802 }
12803
12804 Tooltip.prototype.fixTitle = function () {
12805 var $e = this.$element
12806 if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') {
12807 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
12808 }
12809 }
12810
12811 Tooltip.prototype.hasContent = function () {
12812 return this.getTitle()
12813 }
12814
12815 Tooltip.prototype.getPosition = function ($element) {
12816 $element = $element || this.$element
12817
12818 var el = $element[0]
12819 var isBody = el.tagName == 'BODY'
12820
12821 var elRect = el.getBoundingClientRect()
12822 if (elRect.width == null) {
12823 // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
12824 elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
12825 }
12826 var isSvg = window.SVGElement && el instanceof window.SVGElement
12827 // Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3.
12828 // See https://github.com/twbs/bootstrap/issues/20280
12829 var elOffset = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset())
12830 var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
12831 var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null
12832
12833 return $.extend({}, elRect, scroll, outerDims, elOffset)
12834 }
12835
12836 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
12837 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
12838 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
12839 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
12840 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
12841
12842 }
12843
12844 Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
12845 var delta = { top: 0, left: 0 }
12846 if (!this.$viewport) return delta
12847
12848 var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
12849 var viewportDimensions = this.getPosition(this.$viewport)
12850
12851 if (/right|left/.test(placement)) {
12852 var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
12853 var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
12854 if (topEdgeOffset < viewportDimensions.top) { // top overflow
12855 delta.top = viewportDimensions.top - topEdgeOffset
12856 } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
12857 delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
12858 }
12859 } else {
12860 var leftEdgeOffset = pos.left - viewportPadding
12861 var rightEdgeOffset = pos.left + viewportPadding + actualWidth
12862 if (leftEdgeOffset < viewportDimensions.left) { // left overflow
12863 delta.left = viewportDimensions.left - leftEdgeOffset
12864 } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow
12865 delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
12866 }
12867 }
12868
12869 return delta
12870 }
12871
12872 Tooltip.prototype.getTitle = function () {
12873 var title
12874 var $e = this.$element
12875 var o = this.options
12876
12877 title = $e.attr('data-original-title')
12878 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
12879
12880 return title
12881 }
12882
12883 Tooltip.prototype.getUID = function (prefix) {
12884 do prefix += ~~(Math.random() * 1000000)
12885 while (document.getElementById(prefix))
12886 return prefix
12887 }
12888
12889 Tooltip.prototype.tip = function () {
12890 if (!this.$tip) {
12891 this.$tip = $(this.options.template)
12892 if (this.$tip.length != 1) {
12893 throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')
12894 }
12895 }
12896 return this.$tip
12897 }
12898
12899 Tooltip.prototype.arrow = function () {
12900 return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
12901 }
12902
12903 Tooltip.prototype.enable = function () {
12904 this.enabled = true
12905 }
12906
12907 Tooltip.prototype.disable = function () {
12908 this.enabled = false
12909 }
12910
12911 Tooltip.prototype.toggleEnabled = function () {
12912 this.enabled = !this.enabled
12913 }
12914
12915 Tooltip.prototype.toggle = function (e) {
12916 var self = this
12917 if (e) {
12918 self = $(e.currentTarget).data('bs.' + this.type)
12919 if (!self) {
12920 self = new this.constructor(e.currentTarget, this.getDelegateOptions())
12921 $(e.currentTarget).data('bs.' + this.type, self)
12922 }
12923 }
12924
12925 if (e) {
12926 self.inState.click = !self.inState.click
12927 if (self.isInStateTrue()) self.enter(self)
12928 else self.leave(self)
12929 } else {
12930 self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
12931 }
12932 }
12933
12934 Tooltip.prototype.destroy = function () {
12935 var that = this
12936 clearTimeout(this.timeout)
12937 this.hide(function () {
12938 that.$element.off('.' + that.type).removeData('bs.' + that.type)
12939 if (that.$tip) {
12940 that.$tip.detach()
12941 }
12942 that.$tip = null
12943 that.$arrow = null
12944 that.$viewport = null
12945 that.$element = null
12946 })
12947 }
12948
12949
12950 // TOOLTIP PLUGIN DEFINITION
12951 // =========================
12952
12953 function Plugin(option) {
12954 return this.each(function () {
12955 var $this = $(this)
12956 var data = $this.data('bs.tooltip')
12957 var options = typeof option == 'object' && option
12958
12959 if (!data && /destroy|hide/.test(option)) return
12960 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
12961 if (typeof option == 'string') data[option]()
12962 })
12963 }
12964
12965 var old = $.fn.tooltip
12966
12967 $.fn.tooltip = Plugin
12968 $.fn.tooltip.Constructor = Tooltip
12969
12970
12971 // TOOLTIP NO CONFLICT
12972 // ===================
12973
12974 $.fn.tooltip.noConflict = function () {
12975 $.fn.tooltip = old
12976 return this
12977 }
12978
12979 }(jQuery);
12980
12981 /* assets/js/utils/jquery-extensions.js */
12982 ;(function($) {
12983 $.fn.extend({
12984 /**
12985 * Custom jQuery serialize wrapper.
12986 *
12987 * When WordPress 5.6 increased the jQuery version to 3.5.1, the serialize function changed. Instead of
12988 * sending spaces as "+", they are sent as "%20". This wrapper is for backwards compatibility.
12989 *
12990 * @todo This function is duplicated in both the frontend and backend. Need to have the code live in
12991 * just one location.
12992 *
12993 * @since 1.6.7
12994 */
12995 weSerialize: function() {
12996 return $( this ).serialize().replaceAll( '%20', '+' );
12997 },
12998 });
12999 })(jQuery);
13000 /* assets/js/vendor/tinymce/plugins/code/plugin.min.js */
13001 tinymce.PluginManager.add("code",function(a){function b(){var b=a.windowManager.open({title:"Source code",body:{type:"textbox",name:"code",multiline:!0,minWidth:a.getParam("code_dialog_width",600),minHeight:a.getParam("code_dialog_height",Math.min(tinymce.DOM.getViewPort().h-200,500)),spellcheck:!1,style:"direction: ltr; text-align: left"},onSubmit:function(b){a.focus(),a.undoManager.transact(function(){a.setContent(b.data.code)}),a.selection.setCursorLocation(),a.nodeChanged()}});b.find("#code").value(a.getContent({source_view:!0}))}a.addCommand("mceCodeEditor",b),a.addButton("code",{icon:"code",tooltip:"Source code",onclick:b}),a.addMenuItem("code",{icon:"code",text:"Source code",context:"tools",onclick:b})});
13002 /* assets/js/vendor/tinymce/plugins/hr/plugin.min.js */
13003 tinymce.PluginManager.add("hr",function(a){a.addCommand("InsertHorizontalRule",function(){a.execCommand("mceInsertContent",!1,"<hr />")}),a.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),a.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})});