PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.5.2
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.5.2
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.5.2, at assets/js/vendor.js

22,215 lines 602.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* assets/wpuf/vendor/vue/vue.js */
2 /*!
3 * Vue.js v2.2.4
4 * (c) 2014-2017 Evan You
5 * Released under the MIT License.
6 */
7 (function (global, factory) {
8 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
9 typeof define === 'function' && define.amd ? define(factory) :
10 (global.Vue = factory());
11 }(this, (function () { 'use strict';
12
13 /* */
14
15 /**
16 * Convert a value to a string that is actually rendered.
17 */
18 function _toString (val) {
19 return val == null
20 ? ''
21 : typeof val === 'object'
22 ? JSON.stringify(val, null, 2)
23 : String(val)
24 }
25
26 /**
27 * Convert a input value to a number for persistence.
28 * If the conversion fails, return original string.
29 */
30 function toNumber (val) {
31 var n = parseFloat(val);
32 return isNaN(n) ? val : n
33 }
34
35 /**
36 * Make a map and return a function for checking if a key
37 * is in that map.
38 */
39 function makeMap (
40 str,
41 expectsLowerCase
42 ) {
43 var map = Object.create(null);
44 var list = str.split(',');
45 for (var i = 0; i < list.length; i++) {
46 map[list[i]] = true;
47 }
48 return expectsLowerCase
49 ? function (val) { return map[val.toLowerCase()]; }
50 : function (val) { return map[val]; }
51 }
52
53 /**
54 * Check if a tag is a built-in tag.
55 */
56 var isBuiltInTag = makeMap('slot,component', true);
57
58 /**
59 * Remove an item from an array
60 */
61 function remove (arr, item) {
62 if (arr.length) {
63 var index = arr.indexOf(item);
64 if (index > -1) {
65 return arr.splice(index, 1)
66 }
67 }
68 }
69
70 /**
71 * Check whether the object has the property.
72 */
73 var hasOwnProperty = Object.prototype.hasOwnProperty;
74 function hasOwn (obj, key) {
75 return hasOwnProperty.call(obj, key)
76 }
77
78 /**
79 * Check if value is primitive
80 */
81 function isPrimitive (value) {
82 return typeof value === 'string' || typeof value === 'number'
83 }
84
85 /**
86 * Create a cached version of a pure function.
87 */
88 function cached (fn) {
89 var cache = Object.create(null);
90 return (function cachedFn (str) {
91 var hit = cache[str];
92 return hit || (cache[str] = fn(str))
93 })
94 }
95
96 /**
97 * Camelize a hyphen-delimited string.
98 */
99 var camelizeRE = /-(\w)/g;
100 var camelize = cached(function (str) {
101 return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
102 });
103
104 /**
105 * Capitalize a string.
106 */
107 var capitalize = cached(function (str) {
108 return str.charAt(0).toUpperCase() + str.slice(1)
109 });
110
111 /**
112 * Hyphenate a camelCase string.
113 */
114 var hyphenateRE = /([^-])([A-Z])/g;
115 var hyphenate = cached(function (str) {
116 return str
117 .replace(hyphenateRE, '$1-$2')
118 .replace(hyphenateRE, '$1-$2')
119 .toLowerCase()
120 });
121
122 /**
123 * Simple bind, faster than native
124 */
125 function bind (fn, ctx) {
126 function boundFn (a) {
127 var l = arguments.length;
128 return l
129 ? l > 1
130 ? fn.apply(ctx, arguments)
131 : fn.call(ctx, a)
132 : fn.call(ctx)
133 }
134 // record original fn length
135 boundFn._length = fn.length;
136 return boundFn
137 }
138
139 /**
140 * Convert an Array-like object to a real Array.
141 */
142 function toArray (list, start) {
143 start = start || 0;
144 var i = list.length - start;
145 var ret = new Array(i);
146 while (i--) {
147 ret[i] = list[i + start];
148 }
149 return ret
150 }
151
152 /**
153 * Mix properties into target object.
154 */
155 function extend (to, _from) {
156 for (var key in _from) {
157 to[key] = _from[key];
158 }
159 return to
160 }
161
162 /**
163 * Quick object check - this is primarily used to tell
164 * Objects from primitive values when we know the value
165 * is a JSON-compliant type.
166 */
167 function isObject (obj) {
168 return obj !== null && typeof obj === 'object'
169 }
170
171 /**
172 * Strict object type check. Only returns true
173 * for plain JavaScript objects.
174 */
175 var toString = Object.prototype.toString;
176 var OBJECT_STRING = '[object Object]';
177 function isPlainObject (obj) {
178 return toString.call(obj) === OBJECT_STRING
179 }
180
181 /**
182 * Merge an Array of Objects into a single Object.
183 */
184 function toObject (arr) {
185 var res = {};
186 for (var i = 0; i < arr.length; i++) {
187 if (arr[i]) {
188 extend(res, arr[i]);
189 }
190 }
191 return res
192 }
193
194 /**
195 * Perform no operation.
196 */
197 function noop () {}
198
199 /**
200 * Always return false.
201 */
202 var no = function () { return false; };
203
204 /**
205 * Return same value
206 */
207 var identity = function (_) { return _; };
208
209 /**
210 * Generate a static keys string from compiler modules.
211 */
212 function genStaticKeys (modules) {
213 return modules.reduce(function (keys, m) {
214 return keys.concat(m.staticKeys || [])
215 }, []).join(',')
216 }
217
218 /**
219 * Check if two values are loosely equal - that is,
220 * if they are plain objects, do they have the same shape?
221 */
222 function looseEqual (a, b) {
223 var isObjectA = isObject(a);
224 var isObjectB = isObject(b);
225 if (isObjectA && isObjectB) {
226 try {
227 return JSON.stringify(a) === JSON.stringify(b)
228 } catch (e) {
229 // possible circular reference
230 return a === b
231 }
232 } else if (!isObjectA && !isObjectB) {
233 return String(a) === String(b)
234 } else {
235 return false
236 }
237 }
238
239 function looseIndexOf (arr, val) {
240 for (var i = 0; i < arr.length; i++) {
241 if (looseEqual(arr[i], val)) { return i }
242 }
243 return -1
244 }
245
246 /**
247 * Ensure a function is called only once.
248 */
249 function once (fn) {
250 var called = false;
251 return function () {
252 if (!called) {
253 called = true;
254 fn();
255 }
256 }
257 }
258
259 /* */
260
261 var config = {
262 /**
263 * Option merge strategies (used in core/util/options)
264 */
265 optionMergeStrategies: Object.create(null),
266
267 /**
268 * Whether to suppress warnings.
269 */
270 silent: false,
271
272 /**
273 * Show production mode tip message on boot?
274 */
275 productionTip: "development" !== 'production',
276
277 /**
278 * Whether to enable devtools
279 */
280 devtools: "development" !== 'production',
281
282 /**
283 * Whether to record perf
284 */
285 performance: false,
286
287 /**
288 * Error handler for watcher errors
289 */
290 errorHandler: null,
291
292 /**
293 * Ignore certain custom elements
294 */
295 ignoredElements: [],
296
297 /**
298 * Custom user key aliases for v-on
299 */
300 keyCodes: Object.create(null),
301
302 /**
303 * Check if a tag is reserved so that it cannot be registered as a
304 * component. This is platform-dependent and may be overwritten.
305 */
306 isReservedTag: no,
307
308 /**
309 * Check if a tag is an unknown element.
310 * Platform-dependent.
311 */
312 isUnknownElement: no,
313
314 /**
315 * Get the namespace of an element
316 */
317 getTagNamespace: noop,
318
319 /**
320 * Parse the real tag name for the specific platform.
321 */
322 parsePlatformTagName: identity,
323
324 /**
325 * Check if an attribute must be bound using property, e.g. value
326 * Platform-dependent.
327 */
328 mustUseProp: no,
329
330 /**
331 * List of asset types that a component can own.
332 */
333 _assetTypes: [
334 'component',
335 'directive',
336 'filter'
337 ],
338
339 /**
340 * List of lifecycle hooks.
341 */
342 _lifecycleHooks: [
343 'beforeCreate',
344 'created',
345 'beforeMount',
346 'mounted',
347 'beforeUpdate',
348 'updated',
349 'beforeDestroy',
350 'destroyed',
351 'activated',
352 'deactivated'
353 ],
354
355 /**
356 * Max circular updates allowed in a scheduler flush cycle.
357 */
358 _maxUpdateCount: 100
359 };
360
361 /* */
362
363 var emptyObject = Object.freeze({});
364
365 /**
366 * Check if a string starts with $ or _
367 */
368 function isReserved (str) {
369 var c = (str + '').charCodeAt(0);
370 return c === 0x24 || c === 0x5F
371 }
372
373 /**
374 * Define a property.
375 */
376 function def (obj, key, val, enumerable) {
377 Object.defineProperty(obj, key, {
378 value: val,
379 enumerable: !!enumerable,
380 writable: true,
381 configurable: true
382 });
383 }
384
385 /**
386 * Parse simple path.
387 */
388 var bailRE = /[^\w.$]/;
389 function parsePath (path) {
390 if (bailRE.test(path)) {
391 return
392 }
393 var segments = path.split('.');
394 return function (obj) {
395 for (var i = 0; i < segments.length; i++) {
396 if (!obj) { return }
397 obj = obj[segments[i]];
398 }
399 return obj
400 }
401 }
402
403 /* */
404 /* globals MutationObserver */
405
406 // can we use __proto__?
407 var hasProto = '__proto__' in {};
408
409 // Browser environment sniffing
410 var inBrowser = typeof window !== 'undefined';
411 var UA = inBrowser && window.navigator.userAgent.toLowerCase();
412 var isIE = UA && /msie|trident/.test(UA);
413 var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
414 var isEdge = UA && UA.indexOf('edge/') > 0;
415 var isAndroid = UA && UA.indexOf('android') > 0;
416 var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
417 var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
418
419 // this needs to be lazy-evaled because vue may be required before
420 // vue-server-renderer can set VUE_ENV
421 var _isServer;
422 var isServerRendering = function () {
423 if (_isServer === undefined) {
424 /* istanbul ignore if */
425 if (!inBrowser && typeof global !== 'undefined') {
426 // detect presence of vue-server-renderer and avoid
427 // Webpack shimming the process
428 _isServer = global['process'].env.VUE_ENV === 'server';
429 } else {
430 _isServer = false;
431 }
432 }
433 return _isServer
434 };
435
436 // detect devtools
437 var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
438
439 /* istanbul ignore next */
440 function isNative (Ctor) {
441 return /native code/.test(Ctor.toString())
442 }
443
444 var hasSymbol =
445 typeof Symbol !== 'undefined' && isNative(Symbol) &&
446 typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
447
448 /**
449 * Defer a task to execute it asynchronously.
450 */
451 var nextTick = (function () {
452 var callbacks = [];
453 var pending = false;
454 var timerFunc;
455
456 function nextTickHandler () {
457 pending = false;
458 var copies = callbacks.slice(0);
459 callbacks.length = 0;
460 for (var i = 0; i < copies.length; i++) {
461 copies[i]();
462 }
463 }
464
465 // the nextTick behavior leverages the microtask queue, which can be accessed
466 // via either native Promise.then or MutationObserver.
467 // MutationObserver has wider support, however it is seriously bugged in
468 // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
469 // completely stops working after triggering a few times... so, if native
470 // Promise is available, we will use it:
471 /* istanbul ignore if */
472 if (typeof Promise !== 'undefined' && isNative(Promise)) {
473 var p = Promise.resolve();
474 var logError = function (err) { console.error(err); };
475 timerFunc = function () {
476 p.then(nextTickHandler).catch(logError);
477 // in problematic UIWebViews, Promise.then doesn't completely break, but
478 // it can get stuck in a weird state where callbacks are pushed into the
479 // microtask queue but the queue isn't being flushed, until the browser
480 // needs to do some other work, e.g. handle a timer. Therefore we can
481 // "force" the microtask queue to be flushed by adding an empty timer.
482 if (isIOS) { setTimeout(noop); }
483 };
484 } else if (typeof MutationObserver !== 'undefined' && (
485 isNative(MutationObserver) ||
486 // PhantomJS and iOS 7.x
487 MutationObserver.toString() === '[object MutationObserverConstructor]'
488 )) {
489 // use MutationObserver where native Promise is not available,
490 // e.g. PhantomJS IE11, iOS7, Android 4.4
491 var counter = 1;
492 var observer = new MutationObserver(nextTickHandler);
493 var textNode = document.createTextNode(String(counter));
494 observer.observe(textNode, {
495 characterData: true
496 });
497 timerFunc = function () {
498 counter = (counter + 1) % 2;
499 textNode.data = String(counter);
500 };
501 } else {
502 // fallback to setTimeout
503 /* istanbul ignore next */
504 timerFunc = function () {
505 setTimeout(nextTickHandler, 0);
506 };
507 }
508
509 return function queueNextTick (cb, ctx) {
510 var _resolve;
511 callbacks.push(function () {
512 if (cb) { cb.call(ctx); }
513 if (_resolve) { _resolve(ctx); }
514 });
515 if (!pending) {
516 pending = true;
517 timerFunc();
518 }
519 if (!cb && typeof Promise !== 'undefined') {
520 return new Promise(function (resolve) {
521 _resolve = resolve;
522 })
523 }
524 }
525 })();
526
527 var _Set;
528 /* istanbul ignore if */
529 if (typeof Set !== 'undefined' && isNative(Set)) {
530 // use native Set when available.
531 _Set = Set;
532 } else {
533 // a non-standard Set polyfill that only works with primitive keys.
534 _Set = (function () {
535 function Set () {
536 this.set = Object.create(null);
537 }
538 Set.prototype.has = function has (key) {
539 return this.set[key] === true
540 };
541 Set.prototype.add = function add (key) {
542 this.set[key] = true;
543 };
544 Set.prototype.clear = function clear () {
545 this.set = Object.create(null);
546 };
547
548 return Set;
549 }());
550 }
551
552 var warn = noop;
553 var tip = noop;
554 var formatComponentName;
555
556 {
557 var hasConsole = typeof console !== 'undefined';
558 var classifyRE = /(?:^|[-_])(\w)/g;
559 var classify = function (str) { return str
560 .replace(classifyRE, function (c) { return c.toUpperCase(); })
561 .replace(/[-_]/g, ''); };
562
563 warn = function (msg, vm) {
564 if (hasConsole && (!config.silent)) {
565 console.error("[Vue warn]: " + msg + " " + (
566 vm ? formatLocation(formatComponentName(vm)) : ''
567 ));
568 }
569 };
570
571 tip = function (msg, vm) {
572 if (hasConsole && (!config.silent)) {
573 console.warn("[Vue tip]: " + msg + " " + (
574 vm ? formatLocation(formatComponentName(vm)) : ''
575 ));
576 }
577 };
578
579 formatComponentName = function (vm, includeFile) {
580 if (vm.$root === vm) {
581 return '<Root>'
582 }
583 var name = typeof vm === 'function' && vm.options
584 ? vm.options.name
585 : vm._isVue
586 ? vm.$options.name || vm.$options._componentTag
587 : vm.name;
588
589 var file = vm._isVue && vm.$options.__file;
590 if (!name && file) {
591 var match = file.match(/([^/\\]+)\.vue$/);
592 name = match && match[1];
593 }
594
595 return (
596 (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
597 (file && includeFile !== false ? (" at " + file) : '')
598 )
599 };
600
601 var formatLocation = function (str) {
602 if (str === "<Anonymous>") {
603 str += " - use the \"name\" option for better debugging messages.";
604 }
605 return ("\n(found in " + str + ")")
606 };
607 }
608
609 /* */
610
611
612 var uid$1 = 0;
613
614 /**
615 * A dep is an observable that can have multiple
616 * directives subscribing to it.
617 */
618 var Dep = function Dep () {
619 this.id = uid$1++;
620 this.subs = [];
621 };
622
623 Dep.prototype.addSub = function addSub (sub) {
624 this.subs.push(sub);
625 };
626
627 Dep.prototype.removeSub = function removeSub (sub) {
628 remove(this.subs, sub);
629 };
630
631 Dep.prototype.depend = function depend () {
632 if (Dep.target) {
633 Dep.target.addDep(this);
634 }
635 };
636
637 Dep.prototype.notify = function notify () {
638 // stabilize the subscriber list first
639 var subs = this.subs.slice();
640 for (var i = 0, l = subs.length; i < l; i++) {
641 subs[i].update();
642 }
643 };
644
645 // the current target watcher being evaluated.
646 // this is globally unique because there could be only one
647 // watcher being evaluated at any time.
648 Dep.target = null;
649 var targetStack = [];
650
651 function pushTarget (_target) {
652 if (Dep.target) { targetStack.push(Dep.target); }
653 Dep.target = _target;
654 }
655
656 function popTarget () {
657 Dep.target = targetStack.pop();
658 }
659
660 /*
661 * not type checking this file because flow doesn't play well with
662 * dynamically accessing methods on Array prototype
663 */
664
665 var arrayProto = Array.prototype;
666 var arrayMethods = Object.create(arrayProto);[
667 'push',
668 'pop',
669 'shift',
670 'unshift',
671 'splice',
672 'sort',
673 'reverse'
674 ]
675 .forEach(function (method) {
676 // cache original method
677 var original = arrayProto[method];
678 def(arrayMethods, method, function mutator () {
679 var arguments$1 = arguments;
680
681 // avoid leaking arguments:
682 // http://jsperf.com/closure-with-arguments
683 var i = arguments.length;
684 var args = new Array(i);
685 while (i--) {
686 args[i] = arguments$1[i];
687 }
688 var result = original.apply(this, args);
689 var ob = this.__ob__;
690 var inserted;
691 switch (method) {
692 case 'push':
693 inserted = args;
694 break
695 case 'unshift':
696 inserted = args;
697 break
698 case 'splice':
699 inserted = args.slice(2);
700 break
701 }
702 if (inserted) { ob.observeArray(inserted); }
703 // notify change
704 ob.dep.notify();
705 return result
706 });
707 });
708
709 /* */
710
711 var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
712
713 /**
714 * By default, when a reactive property is set, the new value is
715 * also converted to become reactive. However when passing down props,
716 * we don't want to force conversion because the value may be a nested value
717 * under a frozen data structure. Converting it would defeat the optimization.
718 */
719 var observerState = {
720 shouldConvert: true,
721 isSettingProps: false
722 };
723
724 /**
725 * Observer class that are attached to each observed
726 * object. Once attached, the observer converts target
727 * object's property keys into getter/setters that
728 * collect dependencies and dispatches updates.
729 */
730 var Observer = function Observer (value) {
731 this.value = value;
732 this.dep = new Dep();
733 this.vmCount = 0;
734 def(value, '__ob__', this);
735 if (Array.isArray(value)) {
736 var augment = hasProto
737 ? protoAugment
738 : copyAugment;
739 augment(value, arrayMethods, arrayKeys);
740 this.observeArray(value);
741 } else {
742 this.walk(value);
743 }
744 };
745
746 /**
747 * Walk through each property and convert them into
748 * getter/setters. This method should only be called when
749 * value type is Object.
750 */
751 Observer.prototype.walk = function walk (obj) {
752 var keys = Object.keys(obj);
753 for (var i = 0; i < keys.length; i++) {
754 defineReactive$$1(obj, keys[i], obj[keys[i]]);
755 }
756 };
757
758 /**
759 * Observe a list of Array items.
760 */
761 Observer.prototype.observeArray = function observeArray (items) {
762 for (var i = 0, l = items.length; i < l; i++) {
763 observe(items[i]);
764 }
765 };
766
767 // helpers
768
769 /**
770 * Augment an target Object or Array by intercepting
771 * the prototype chain using __proto__
772 */
773 function protoAugment (target, src) {
774 /* eslint-disable no-proto */
775 target.__proto__ = src;
776 /* eslint-enable no-proto */
777 }
778
779 /**
780 * Augment an target Object or Array by defining
781 * hidden properties.
782 */
783 /* istanbul ignore next */
784 function copyAugment (target, src, keys) {
785 for (var i = 0, l = keys.length; i < l; i++) {
786 var key = keys[i];
787 def(target, key, src[key]);
788 }
789 }
790
791 /**
792 * Attempt to create an observer instance for a value,
793 * returns the new observer if successfully observed,
794 * or the existing observer if the value already has one.
795 */
796 function observe (value, asRootData) {
797 if (!isObject(value)) {
798 return
799 }
800 var ob;
801 if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
802 ob = value.__ob__;
803 } else if (
804 observerState.shouldConvert &&
805 !isServerRendering() &&
806 (Array.isArray(value) || isPlainObject(value)) &&
807 Object.isExtensible(value) &&
808 !value._isVue
809 ) {
810 ob = new Observer(value);
811 }
812 if (asRootData && ob) {
813 ob.vmCount++;
814 }
815 return ob
816 }
817
818 /**
819 * Define a reactive property on an Object.
820 */
821 function defineReactive$$1 (
822 obj,
823 key,
824 val,
825 customSetter
826 ) {
827 var dep = new Dep();
828
829 var property = Object.getOwnPropertyDescriptor(obj, key);
830 if (property && property.configurable === false) {
831 return
832 }
833
834 // cater for pre-defined getter/setters
835 var getter = property && property.get;
836 var setter = property && property.set;
837
838 var childOb = observe(val);
839 Object.defineProperty(obj, key, {
840 enumerable: true,
841 configurable: true,
842 get: function reactiveGetter () {
843 var value = getter ? getter.call(obj) : val;
844 if (Dep.target) {
845 dep.depend();
846 if (childOb) {
847 childOb.dep.depend();
848 }
849 if (Array.isArray(value)) {
850 dependArray(value);
851 }
852 }
853 return value
854 },
855 set: function reactiveSetter (newVal) {
856 var value = getter ? getter.call(obj) : val;
857 /* eslint-disable no-self-compare */
858 if (newVal === value || (newVal !== newVal && value !== value)) {
859 return
860 }
861 /* eslint-enable no-self-compare */
862 if ("development" !== 'production' && customSetter) {
863 customSetter();
864 }
865 if (setter) {
866 setter.call(obj, newVal);
867 } else {
868 val = newVal;
869 }
870 childOb = observe(newVal);
871 dep.notify();
872 }
873 });
874 }
875
876 /**
877 * Set a property on an object. Adds the new property and
878 * triggers change notification if the property doesn't
879 * already exist.
880 */
881 function set (target, key, val) {
882 if (Array.isArray(target)) {
883 target.length = Math.max(target.length, key);
884 target.splice(key, 1, val);
885 return val
886 }
887 if (hasOwn(target, key)) {
888 target[key] = val;
889 return val
890 }
891 var ob = target.__ob__;
892 if (target._isVue || (ob && ob.vmCount)) {
893 "development" !== 'production' && warn(
894 'Avoid adding reactive properties to a Vue instance or its root $data ' +
895 'at runtime - declare it upfront in the data option.'
896 );
897 return val
898 }
899 if (!ob) {
900 target[key] = val;
901 return val
902 }
903 defineReactive$$1(ob.value, key, val);
904 ob.dep.notify();
905 return val
906 }
907
908 /**
909 * Delete a property and trigger change if necessary.
910 */
911 function del (target, key) {
912 if (Array.isArray(target)) {
913 target.splice(key, 1);
914 return
915 }
916 var ob = target.__ob__;
917 if (target._isVue || (ob && ob.vmCount)) {
918 "development" !== 'production' && warn(
919 'Avoid deleting properties on a Vue instance or its root $data ' +
920 '- just set it to null.'
921 );
922 return
923 }
924 if (!hasOwn(target, key)) {
925 return
926 }
927 delete target[key];
928 if (!ob) {
929 return
930 }
931 ob.dep.notify();
932 }
933
934 /**
935 * Collect dependencies on array elements when the array is touched, since
936 * we cannot intercept array element access like property getters.
937 */
938 function dependArray (value) {
939 for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
940 e = value[i];
941 e && e.__ob__ && e.__ob__.dep.depend();
942 if (Array.isArray(e)) {
943 dependArray(e);
944 }
945 }
946 }
947
948 /* */
949
950 /**
951 * Option overwriting strategies are functions that handle
952 * how to merge a parent option value and a child option
953 * value into the final value.
954 */
955 var strats = config.optionMergeStrategies;
956
957 /**
958 * Options with restrictions
959 */
960 {
961 strats.el = strats.propsData = function (parent, child, vm, key) {
962 if (!vm) {
963 warn(
964 "option \"" + key + "\" can only be used during instance " +
965 'creation with the `new` keyword.'
966 );
967 }
968 return defaultStrat(parent, child)
969 };
970 }
971
972 /**
973 * Helper that recursively merges two data objects together.
974 */
975 function mergeData (to, from) {
976 if (!from) { return to }
977 var key, toVal, fromVal;
978 var keys = Object.keys(from);
979 for (var i = 0; i < keys.length; i++) {
980 key = keys[i];
981 toVal = to[key];
982 fromVal = from[key];
983 if (!hasOwn(to, key)) {
984 set(to, key, fromVal);
985 } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
986 mergeData(toVal, fromVal);
987 }
988 }
989 return to
990 }
991
992 /**
993 * Data
994 */
995 strats.data = function (
996 parentVal,
997 childVal,
998 vm
999 ) {
1000 if (!vm) {
1001 // in a Vue.extend merge, both should be functions
1002 if (!childVal) {
1003 return parentVal
1004 }
1005 if (typeof childVal !== 'function') {
1006 "development" !== 'production' && warn(
1007 'The "data" option should be a function ' +
1008 'that returns a per-instance value in component ' +
1009 'definitions.',
1010 vm
1011 );
1012 return parentVal
1013 }
1014 if (!parentVal) {
1015 return childVal
1016 }
1017 // when parentVal & childVal are both present,
1018 // we need to return a function that returns the
1019 // merged result of both functions... no need to
1020 // check if parentVal is a function here because
1021 // it has to be a function to pass previous merges.
1022 return function mergedDataFn () {
1023 return mergeData(
1024 childVal.call(this),
1025 parentVal.call(this)
1026 )
1027 }
1028 } else if (parentVal || childVal) {
1029 return function mergedInstanceDataFn () {
1030 // instance merge
1031 var instanceData = typeof childVal === 'function'
1032 ? childVal.call(vm)
1033 : childVal;
1034 var defaultData = typeof parentVal === 'function'
1035 ? parentVal.call(vm)
1036 : undefined;
1037 if (instanceData) {
1038 return mergeData(instanceData, defaultData)
1039 } else {
1040 return defaultData
1041 }
1042 }
1043 }
1044 };
1045
1046 /**
1047 * Hooks and props are merged as arrays.
1048 */
1049 function mergeHook (
1050 parentVal,
1051 childVal
1052 ) {
1053 return childVal
1054 ? parentVal
1055 ? parentVal.concat(childVal)
1056 : Array.isArray(childVal)
1057 ? childVal
1058 : [childVal]
1059 : parentVal
1060 }
1061
1062 config._lifecycleHooks.forEach(function (hook) {
1063 strats[hook] = mergeHook;
1064 });
1065
1066 /**
1067 * Assets
1068 *
1069 * When a vm is present (instance creation), we need to do
1070 * a three-way merge between constructor options, instance
1071 * options and parent options.
1072 */
1073 function mergeAssets (parentVal, childVal) {
1074 var res = Object.create(parentVal || null);
1075 return childVal
1076 ? extend(res, childVal)
1077 : res
1078 }
1079
1080 config._assetTypes.forEach(function (type) {
1081 strats[type + 's'] = mergeAssets;
1082 });
1083
1084 /**
1085 * Watchers.
1086 *
1087 * Watchers hashes should not overwrite one
1088 * another, so we merge them as arrays.
1089 */
1090 strats.watch = function (parentVal, childVal) {
1091 /* istanbul ignore if */
1092 if (!childVal) { return Object.create(parentVal || null) }
1093 if (!parentVal) { return childVal }
1094 var ret = {};
1095 extend(ret, parentVal);
1096 for (var key in childVal) {
1097 var parent = ret[key];
1098 var child = childVal[key];
1099 if (parent && !Array.isArray(parent)) {
1100 parent = [parent];
1101 }
1102 ret[key] = parent
1103 ? parent.concat(child)
1104 : [child];
1105 }
1106 return ret
1107 };
1108
1109 /**
1110 * Other object hashes.
1111 */
1112 strats.props =
1113 strats.methods =
1114 strats.computed = function (parentVal, childVal) {
1115 if (!childVal) { return Object.create(parentVal || null) }
1116 if (!parentVal) { return childVal }
1117 var ret = Object.create(null);
1118 extend(ret, parentVal);
1119 extend(ret, childVal);
1120 return ret
1121 };
1122
1123 /**
1124 * Default strategy.
1125 */
1126 var defaultStrat = function (parentVal, childVal) {
1127 return childVal === undefined
1128 ? parentVal
1129 : childVal
1130 };
1131
1132 /**
1133 * Validate component names
1134 */
1135 function checkComponents (options) {
1136 for (var key in options.components) {
1137 var lower = key.toLowerCase();
1138 if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
1139 warn(
1140 'Do not use built-in or reserved HTML elements as component ' +
1141 'id: ' + key
1142 );
1143 }
1144 }
1145 }
1146
1147 /**
1148 * Ensure all props option syntax are normalized into the
1149 * Object-based format.
1150 */
1151 function normalizeProps (options) {
1152 var props = options.props;
1153 if (!props) { return }
1154 var res = {};
1155 var i, val, name;
1156 if (Array.isArray(props)) {
1157 i = props.length;
1158 while (i--) {
1159 val = props[i];
1160 if (typeof val === 'string') {
1161 name = camelize(val);
1162 res[name] = { type: null };
1163 } else {
1164 warn('props must be strings when using array syntax.');
1165 }
1166 }
1167 } else if (isPlainObject(props)) {
1168 for (var key in props) {
1169 val = props[key];
1170 name = camelize(key);
1171 res[name] = isPlainObject(val)
1172 ? val
1173 : { type: val };
1174 }
1175 }
1176 options.props = res;
1177 }
1178
1179 /**
1180 * Normalize raw function directives into object format.
1181 */
1182 function normalizeDirectives (options) {
1183 var dirs = options.directives;
1184 if (dirs) {
1185 for (var key in dirs) {
1186 var def = dirs[key];
1187 if (typeof def === 'function') {
1188 dirs[key] = { bind: def, update: def };
1189 }
1190 }
1191 }
1192 }
1193
1194 /**
1195 * Merge two option objects into a new one.
1196 * Core utility used in both instantiation and inheritance.
1197 */
1198 function mergeOptions (
1199 parent,
1200 child,
1201 vm
1202 ) {
1203 {
1204 checkComponents(child);
1205 }
1206 normalizeProps(child);
1207 normalizeDirectives(child);
1208 var extendsFrom = child.extends;
1209 if (extendsFrom) {
1210 parent = typeof extendsFrom === 'function'
1211 ? mergeOptions(parent, extendsFrom.options, vm)
1212 : mergeOptions(parent, extendsFrom, vm);
1213 }
1214 if (child.mixins) {
1215 for (var i = 0, l = child.mixins.length; i < l; i++) {
1216 var mixin = child.mixins[i];
1217 if (mixin.prototype instanceof Vue$3) {
1218 mixin = mixin.options;
1219 }
1220 parent = mergeOptions(parent, mixin, vm);
1221 }
1222 }
1223 var options = {};
1224 var key;
1225 for (key in parent) {
1226 mergeField(key);
1227 }
1228 for (key in child) {
1229 if (!hasOwn(parent, key)) {
1230 mergeField(key);
1231 }
1232 }
1233 function mergeField (key) {
1234 var strat = strats[key] || defaultStrat;
1235 options[key] = strat(parent[key], child[key], vm, key);
1236 }
1237 return options
1238 }
1239
1240 /**
1241 * Resolve an asset.
1242 * This function is used because child instances need access
1243 * to assets defined in its ancestor chain.
1244 */
1245 function resolveAsset (
1246 options,
1247 type,
1248 id,
1249 warnMissing
1250 ) {
1251 /* istanbul ignore if */
1252 if (typeof id !== 'string') {
1253 return
1254 }
1255 var assets = options[type];
1256 // check local registration variations first
1257 if (hasOwn(assets, id)) { return assets[id] }
1258 var camelizedId = camelize(id);
1259 if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
1260 var PascalCaseId = capitalize(camelizedId);
1261 if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
1262 // fallback to prototype chain
1263 var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
1264 if ("development" !== 'production' && warnMissing && !res) {
1265 warn(
1266 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
1267 options
1268 );
1269 }
1270 return res
1271 }
1272
1273 /* */
1274
1275 function validateProp (
1276 key,
1277 propOptions,
1278 propsData,
1279 vm
1280 ) {
1281 var prop = propOptions[key];
1282 var absent = !hasOwn(propsData, key);
1283 var value = propsData[key];
1284 // handle boolean props
1285 if (isType(Boolean, prop.type)) {
1286 if (absent && !hasOwn(prop, 'default')) {
1287 value = false;
1288 } else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) {
1289 value = true;
1290 }
1291 }
1292 // check default value
1293 if (value === undefined) {
1294 value = getPropDefaultValue(vm, prop, key);
1295 // since the default value is a fresh copy,
1296 // make sure to observe it.
1297 var prevShouldConvert = observerState.shouldConvert;
1298 observerState.shouldConvert = true;
1299 observe(value);
1300 observerState.shouldConvert = prevShouldConvert;
1301 }
1302 {
1303 assertProp(prop, key, value, vm, absent);
1304 }
1305 return value
1306 }
1307
1308 /**
1309 * Get the default value of a prop.
1310 */
1311 function getPropDefaultValue (vm, prop, key) {
1312 // no default, return undefined
1313 if (!hasOwn(prop, 'default')) {
1314 return undefined
1315 }
1316 var def = prop.default;
1317 // warn against non-factory defaults for Object & Array
1318 if ("development" !== 'production' && isObject(def)) {
1319 warn(
1320 'Invalid default value for prop "' + key + '": ' +
1321 'Props with type Object/Array must use a factory function ' +
1322 'to return the default value.',
1323 vm
1324 );
1325 }
1326 // the raw prop value was also undefined from previous render,
1327 // return previous default value to avoid unnecessary watcher trigger
1328 if (vm && vm.$options.propsData &&
1329 vm.$options.propsData[key] === undefined &&
1330 vm._props[key] !== undefined) {
1331 return vm._props[key]
1332 }
1333 // call factory function for non-Function types
1334 // a value is Function if its prototype is function even across different execution context
1335 return typeof def === 'function' && getType(prop.type) !== 'Function'
1336 ? def.call(vm)
1337 : def
1338 }
1339
1340 /**
1341 * Assert whether a prop is valid.
1342 */
1343 function assertProp (
1344 prop,
1345 name,
1346 value,
1347 vm,
1348 absent
1349 ) {
1350 if (prop.required && absent) {
1351 warn(
1352 'Missing required prop: "' + name + '"',
1353 vm
1354 );
1355 return
1356 }
1357 if (value == null && !prop.required) {
1358 return
1359 }
1360 var type = prop.type;
1361 var valid = !type || type === true;
1362 var expectedTypes = [];
1363 if (type) {
1364 if (!Array.isArray(type)) {
1365 type = [type];
1366 }
1367 for (var i = 0; i < type.length && !valid; i++) {
1368 var assertedType = assertType(value, type[i]);
1369 expectedTypes.push(assertedType.expectedType || '');
1370 valid = assertedType.valid;
1371 }
1372 }
1373 if (!valid) {
1374 warn(
1375 'Invalid prop: type check failed for prop "' + name + '".' +
1376 ' Expected ' + expectedTypes.map(capitalize).join(', ') +
1377 ', got ' + Object.prototype.toString.call(value).slice(8, -1) + '.',
1378 vm
1379 );
1380 return
1381 }
1382 var validator = prop.validator;
1383 if (validator) {
1384 if (!validator(value)) {
1385 warn(
1386 'Invalid prop: custom validator check failed for prop "' + name + '".',
1387 vm
1388 );
1389 }
1390 }
1391 }
1392
1393 /**
1394 * Assert the type of a value
1395 */
1396 function assertType (value, type) {
1397 var valid;
1398 var expectedType = getType(type);
1399 if (expectedType === 'String') {
1400 valid = typeof value === (expectedType = 'string');
1401 } else if (expectedType === 'Number') {
1402 valid = typeof value === (expectedType = 'number');
1403 } else if (expectedType === 'Boolean') {
1404 valid = typeof value === (expectedType = 'boolean');
1405 } else if (expectedType === 'Function') {
1406 valid = typeof value === (expectedType = 'function');
1407 } else if (expectedType === 'Object') {
1408 valid = isPlainObject(value);
1409 } else if (expectedType === 'Array') {
1410 valid = Array.isArray(value);
1411 } else {
1412 valid = value instanceof type;
1413 }
1414 return {
1415 valid: valid,
1416 expectedType: expectedType
1417 }
1418 }
1419
1420 /**
1421 * Use function string name to check built-in types,
1422 * because a simple equality check will fail when running
1423 * across different vms / iframes.
1424 */
1425 function getType (fn) {
1426 var match = fn && fn.toString().match(/^\s*function (\w+)/);
1427 return match && match[1]
1428 }
1429
1430 function isType (type, fn) {
1431 if (!Array.isArray(fn)) {
1432 return getType(fn) === getType(type)
1433 }
1434 for (var i = 0, len = fn.length; i < len; i++) {
1435 if (getType(fn[i]) === getType(type)) {
1436 return true
1437 }
1438 }
1439 /* istanbul ignore next */
1440 return false
1441 }
1442
1443 function handleError (err, vm, info) {
1444 if (config.errorHandler) {
1445 config.errorHandler.call(null, err, vm, info);
1446 } else {
1447 {
1448 warn(("Error in " + info + ":"), vm);
1449 }
1450 /* istanbul ignore else */
1451 if (inBrowser && typeof console !== 'undefined') {
1452 console.error(err);
1453 } else {
1454 throw err
1455 }
1456 }
1457 }
1458
1459 /* not type checking this file because flow doesn't play well with Proxy */
1460
1461 var initProxy;
1462
1463 {
1464 var allowedGlobals = makeMap(
1465 'Infinity,undefined,NaN,isFinite,isNaN,' +
1466 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
1467 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
1468 'require' // for Webpack/Browserify
1469 );
1470
1471 var warnNonPresent = function (target, key) {
1472 warn(
1473 "Property or method \"" + key + "\" is not defined on the instance but " +
1474 "referenced during render. Make sure to declare reactive data " +
1475 "properties in the data option.",
1476 target
1477 );
1478 };
1479
1480 var hasProxy =
1481 typeof Proxy !== 'undefined' &&
1482 Proxy.toString().match(/native code/);
1483
1484 if (hasProxy) {
1485 var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta');
1486 config.keyCodes = new Proxy(config.keyCodes, {
1487 set: function set (target, key, value) {
1488 if (isBuiltInModifier(key)) {
1489 warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
1490 return false
1491 } else {
1492 target[key] = value;
1493 return true
1494 }
1495 }
1496 });
1497 }
1498
1499 var hasHandler = {
1500 has: function has (target, key) {
1501 var has = key in target;
1502 var isAllowed = allowedGlobals(key) || key.charAt(0) === '_';
1503 if (!has && !isAllowed) {
1504 warnNonPresent(target, key);
1505 }
1506 return has || !isAllowed
1507 }
1508 };
1509
1510 var getHandler = {
1511 get: function get (target, key) {
1512 if (typeof key === 'string' && !(key in target)) {
1513 warnNonPresent(target, key);
1514 }
1515 return target[key]
1516 }
1517 };
1518
1519 initProxy = function initProxy (vm) {
1520 if (hasProxy) {
1521 // determine which proxy handler to use
1522 var options = vm.$options;
1523 var handlers = options.render && options.render._withStripped
1524 ? getHandler
1525 : hasHandler;
1526 vm._renderProxy = new Proxy(vm, handlers);
1527 } else {
1528 vm._renderProxy = vm;
1529 }
1530 };
1531 }
1532
1533 var mark;
1534 var measure;
1535
1536 {
1537 var perf = inBrowser && window.performance;
1538 /* istanbul ignore if */
1539 if (
1540 perf &&
1541 perf.mark &&
1542 perf.measure &&
1543 perf.clearMarks &&
1544 perf.clearMeasures
1545 ) {
1546 mark = function (tag) { return perf.mark(tag); };
1547 measure = function (name, startTag, endTag) {
1548 perf.measure(name, startTag, endTag);
1549 perf.clearMarks(startTag);
1550 perf.clearMarks(endTag);
1551 perf.clearMeasures(name);
1552 };
1553 }
1554 }
1555
1556 /* */
1557
1558 var VNode = function VNode (
1559 tag,
1560 data,
1561 children,
1562 text,
1563 elm,
1564 context,
1565 componentOptions
1566 ) {
1567 this.tag = tag;
1568 this.data = data;
1569 this.children = children;
1570 this.text = text;
1571 this.elm = elm;
1572 this.ns = undefined;
1573 this.context = context;
1574 this.functionalContext = undefined;
1575 this.key = data && data.key;
1576 this.componentOptions = componentOptions;
1577 this.componentInstance = undefined;
1578 this.parent = undefined;
1579 this.raw = false;
1580 this.isStatic = false;
1581 this.isRootInsert = true;
1582 this.isComment = false;
1583 this.isCloned = false;
1584 this.isOnce = false;
1585 };
1586
1587 var prototypeAccessors = { child: {} };
1588
1589 // DEPRECATED: alias for componentInstance for backwards compat.
1590 /* istanbul ignore next */
1591 prototypeAccessors.child.get = function () {
1592 return this.componentInstance
1593 };
1594
1595 Object.defineProperties( VNode.prototype, prototypeAccessors );
1596
1597 var createEmptyVNode = function () {
1598 var node = new VNode();
1599 node.text = '';
1600 node.isComment = true;
1601 return node
1602 };
1603
1604 function createTextVNode (val) {
1605 return new VNode(undefined, undefined, undefined, String(val))
1606 }
1607
1608 // optimized shallow clone
1609 // used for static nodes and slot nodes because they may be reused across
1610 // multiple renders, cloning them avoids errors when DOM manipulations rely
1611 // on their elm reference.
1612 function cloneVNode (vnode) {
1613 var cloned = new VNode(
1614 vnode.tag,
1615 vnode.data,
1616 vnode.children,
1617 vnode.text,
1618 vnode.elm,
1619 vnode.context,
1620 vnode.componentOptions
1621 );
1622 cloned.ns = vnode.ns;
1623 cloned.isStatic = vnode.isStatic;
1624 cloned.key = vnode.key;
1625 cloned.isCloned = true;
1626 return cloned
1627 }
1628
1629 function cloneVNodes (vnodes) {
1630 var len = vnodes.length;
1631 var res = new Array(len);
1632 for (var i = 0; i < len; i++) {
1633 res[i] = cloneVNode(vnodes[i]);
1634 }
1635 return res
1636 }
1637
1638 /* */
1639
1640 var normalizeEvent = cached(function (name) {
1641 var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
1642 name = once$$1 ? name.slice(1) : name;
1643 var capture = name.charAt(0) === '!';
1644 name = capture ? name.slice(1) : name;
1645 return {
1646 name: name,
1647 once: once$$1,
1648 capture: capture
1649 }
1650 });
1651
1652 function createFnInvoker (fns) {
1653 function invoker () {
1654 var arguments$1 = arguments;
1655
1656 var fns = invoker.fns;
1657 if (Array.isArray(fns)) {
1658 for (var i = 0; i < fns.length; i++) {
1659 fns[i].apply(null, arguments$1);
1660 }
1661 } else {
1662 // return handler return value for single handlers
1663 return fns.apply(null, arguments)
1664 }
1665 }
1666 invoker.fns = fns;
1667 return invoker
1668 }
1669
1670 function updateListeners (
1671 on,
1672 oldOn,
1673 add,
1674 remove$$1,
1675 vm
1676 ) {
1677 var name, cur, old, event;
1678 for (name in on) {
1679 cur = on[name];
1680 old = oldOn[name];
1681 event = normalizeEvent(name);
1682 if (!cur) {
1683 "development" !== 'production' && warn(
1684 "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
1685 vm
1686 );
1687 } else if (!old) {
1688 if (!cur.fns) {
1689 cur = on[name] = createFnInvoker(cur);
1690 }
1691 add(event.name, cur, event.once, event.capture);
1692 } else if (cur !== old) {
1693 old.fns = cur;
1694 on[name] = old;
1695 }
1696 }
1697 for (name in oldOn) {
1698 if (!on[name]) {
1699 event = normalizeEvent(name);
1700 remove$$1(event.name, oldOn[name], event.capture);
1701 }
1702 }
1703 }
1704
1705 /* */
1706
1707 function mergeVNodeHook (def, hookKey, hook) {
1708 var invoker;
1709 var oldHook = def[hookKey];
1710
1711 function wrappedHook () {
1712 hook.apply(this, arguments);
1713 // important: remove merged hook to ensure it's called only once
1714 // and prevent memory leak
1715 remove(invoker.fns, wrappedHook);
1716 }
1717
1718 if (!oldHook) {
1719 // no existing hook
1720 invoker = createFnInvoker([wrappedHook]);
1721 } else {
1722 /* istanbul ignore if */
1723 if (oldHook.fns && oldHook.merged) {
1724 // already a merged invoker
1725 invoker = oldHook;
1726 invoker.fns.push(wrappedHook);
1727 } else {
1728 // existing plain hook
1729 invoker = createFnInvoker([oldHook, wrappedHook]);
1730 }
1731 }
1732
1733 invoker.merged = true;
1734 def[hookKey] = invoker;
1735 }
1736
1737 /* */
1738
1739 // The template compiler attempts to minimize the need for normalization by
1740 // statically analyzing the template at compile time.
1741 //
1742 // For plain HTML markup, normalization can be completely skipped because the
1743 // generated render function is guaranteed to return Array<VNode>. There are
1744 // two cases where extra normalization is needed:
1745
1746 // 1. When the children contains components - because a functional component
1747 // may return an Array instead of a single root. In this case, just a simple
1748 // normalization is needed - if any child is an Array, we flatten the whole
1749 // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
1750 // because functional components already normalize their own children.
1751 function simpleNormalizeChildren (children) {
1752 for (var i = 0; i < children.length; i++) {
1753 if (Array.isArray(children[i])) {
1754 return Array.prototype.concat.apply([], children)
1755 }
1756 }
1757 return children
1758 }
1759
1760 // 2. When the children contains constructs that always generated nested Arrays,
1761 // e.g. <template>, <slot>, v-for, or when the children is provided by user
1762 // with hand-written render functions / JSX. In such cases a full normalization
1763 // is needed to cater to all possible types of children values.
1764 function normalizeChildren (children) {
1765 return isPrimitive(children)
1766 ? [createTextVNode(children)]
1767 : Array.isArray(children)
1768 ? normalizeArrayChildren(children)
1769 : undefined
1770 }
1771
1772 function normalizeArrayChildren (children, nestedIndex) {
1773 var res = [];
1774 var i, c, last;
1775 for (i = 0; i < children.length; i++) {
1776 c = children[i];
1777 if (c == null || typeof c === 'boolean') { continue }
1778 last = res[res.length - 1];
1779 // nested
1780 if (Array.isArray(c)) {
1781 res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
1782 } else if (isPrimitive(c)) {
1783 if (last && last.text) {
1784 last.text += String(c);
1785 } else if (c !== '') {
1786 // convert primitive to vnode
1787 res.push(createTextVNode(c));
1788 }
1789 } else {
1790 if (c.text && last && last.text) {
1791 res[res.length - 1] = createTextVNode(last.text + c.text);
1792 } else {
1793 // default key for nested array children (likely generated by v-for)
1794 if (c.tag && c.key == null && nestedIndex != null) {
1795 c.key = "__vlist" + nestedIndex + "_" + i + "__";
1796 }
1797 res.push(c);
1798 }
1799 }
1800 }
1801 return res
1802 }
1803
1804 /* */
1805
1806 function getFirstComponentChild (children) {
1807 return children && children.filter(function (c) { return c && c.componentOptions; })[0]
1808 }
1809
1810 /* */
1811
1812 function initEvents (vm) {
1813 vm._events = Object.create(null);
1814 vm._hasHookEvent = false;
1815 // init parent attached events
1816 var listeners = vm.$options._parentListeners;
1817 if (listeners) {
1818 updateComponentListeners(vm, listeners);
1819 }
1820 }
1821
1822 var target;
1823
1824 function add (event, fn, once$$1) {
1825 if (once$$1) {
1826 target.$once(event, fn);
1827 } else {
1828 target.$on(event, fn);
1829 }
1830 }
1831
1832 function remove$1 (event, fn) {
1833 target.$off(event, fn);
1834 }
1835
1836 function updateComponentListeners (
1837 vm,
1838 listeners,
1839 oldListeners
1840 ) {
1841 target = vm;
1842 updateListeners(listeners, oldListeners || {}, add, remove$1, vm);
1843 }
1844
1845 function eventsMixin (Vue) {
1846 var hookRE = /^hook:/;
1847 Vue.prototype.$on = function (event, fn) {
1848 var this$1 = this;
1849
1850 var vm = this;
1851 if (Array.isArray(event)) {
1852 for (var i = 0, l = event.length; i < l; i++) {
1853 this$1.$on(event[i], fn);
1854 }
1855 } else {
1856 (vm._events[event] || (vm._events[event] = [])).push(fn);
1857 // optimize hook:event cost by using a boolean flag marked at registration
1858 // instead of a hash lookup
1859 if (hookRE.test(event)) {
1860 vm._hasHookEvent = true;
1861 }
1862 }
1863 return vm
1864 };
1865
1866 Vue.prototype.$once = function (event, fn) {
1867 var vm = this;
1868 function on () {
1869 vm.$off(event, on);
1870 fn.apply(vm, arguments);
1871 }
1872 on.fn = fn;
1873 vm.$on(event, on);
1874 return vm
1875 };
1876
1877 Vue.prototype.$off = function (event, fn) {
1878 var this$1 = this;
1879
1880 var vm = this;
1881 // all
1882 if (!arguments.length) {
1883 vm._events = Object.create(null);
1884 return vm
1885 }
1886 // array of events
1887 if (Array.isArray(event)) {
1888 for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
1889 this$1.$off(event[i$1], fn);
1890 }
1891 return vm
1892 }
1893 // specific event
1894 var cbs = vm._events[event];
1895 if (!cbs) {
1896 return vm
1897 }
1898 if (arguments.length === 1) {
1899 vm._events[event] = null;
1900 return vm
1901 }
1902 // specific handler
1903 var cb;
1904 var i = cbs.length;
1905 while (i--) {
1906 cb = cbs[i];
1907 if (cb === fn || cb.fn === fn) {
1908 cbs.splice(i, 1);
1909 break
1910 }
1911 }
1912 return vm
1913 };
1914
1915 Vue.prototype.$emit = function (event) {
1916 var vm = this;
1917 var cbs = vm._events[event];
1918 if (cbs) {
1919 cbs = cbs.length > 1 ? toArray(cbs) : cbs;
1920 var args = toArray(arguments, 1);
1921 for (var i = 0, l = cbs.length; i < l; i++) {
1922 cbs[i].apply(vm, args);
1923 }
1924 }
1925 return vm
1926 };
1927 }
1928
1929 /* */
1930
1931 /**
1932 * Runtime helper for resolving raw children VNodes into a slot object.
1933 */
1934 function resolveSlots (
1935 children,
1936 context
1937 ) {
1938 var slots = {};
1939 if (!children) {
1940 return slots
1941 }
1942 var defaultSlot = [];
1943 var name, child;
1944 for (var i = 0, l = children.length; i < l; i++) {
1945 child = children[i];
1946 // named slots should only be respected if the vnode was rendered in the
1947 // same context.
1948 if ((child.context === context || child.functionalContext === context) &&
1949 child.data && (name = child.data.slot)) {
1950 var slot = (slots[name] || (slots[name] = []));
1951 if (child.tag === 'template') {
1952 slot.push.apply(slot, child.children);
1953 } else {
1954 slot.push(child);
1955 }
1956 } else {
1957 defaultSlot.push(child);
1958 }
1959 }
1960 // ignore whitespace
1961 if (!defaultSlot.every(isWhitespace)) {
1962 slots.default = defaultSlot;
1963 }
1964 return slots
1965 }
1966
1967 function isWhitespace (node) {
1968 return node.isComment || node.text === ' '
1969 }
1970
1971 function resolveScopedSlots (
1972 fns
1973 ) {
1974 var res = {};
1975 for (var i = 0; i < fns.length; i++) {
1976 res[fns[i][0]] = fns[i][1];
1977 }
1978 return res
1979 }
1980
1981 /* */
1982
1983 var activeInstance = null;
1984
1985 function initLifecycle (vm) {
1986 var options = vm.$options;
1987
1988 // locate first non-abstract parent
1989 var parent = options.parent;
1990 if (parent && !options.abstract) {
1991 while (parent.$options.abstract && parent.$parent) {
1992 parent = parent.$parent;
1993 }
1994 parent.$children.push(vm);
1995 }
1996
1997 vm.$parent = parent;
1998 vm.$root = parent ? parent.$root : vm;
1999
2000 vm.$children = [];
2001 vm.$refs = {};
2002
2003 vm._watcher = null;
2004 vm._inactive = null;
2005 vm._directInactive = false;
2006 vm._isMounted = false;
2007 vm._isDestroyed = false;
2008 vm._isBeingDestroyed = false;
2009 }
2010
2011 function lifecycleMixin (Vue) {
2012 Vue.prototype._update = function (vnode, hydrating) {
2013 var vm = this;
2014 if (vm._isMounted) {
2015 callHook(vm, 'beforeUpdate');
2016 }
2017 var prevEl = vm.$el;
2018 var prevVnode = vm._vnode;
2019 var prevActiveInstance = activeInstance;
2020 activeInstance = vm;
2021 vm._vnode = vnode;
2022 // Vue.prototype.__patch__ is injected in entry points
2023 // based on the rendering backend used.
2024 if (!prevVnode) {
2025 // initial render
2026 vm.$el = vm.__patch__(
2027 vm.$el, vnode, hydrating, false /* removeOnly */,
2028 vm.$options._parentElm,
2029 vm.$options._refElm
2030 );
2031 } else {
2032 // updates
2033 vm.$el = vm.__patch__(prevVnode, vnode);
2034 }
2035 activeInstance = prevActiveInstance;
2036 // update __vue__ reference
2037 if (prevEl) {
2038 prevEl.__vue__ = null;
2039 }
2040 if (vm.$el) {
2041 vm.$el.__vue__ = vm;
2042 }
2043 // if parent is an HOC, update its $el as well
2044 if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
2045 vm.$parent.$el = vm.$el;
2046 }
2047 // updated hook is called by the scheduler to ensure that children are
2048 // updated in a parent's updated hook.
2049 };
2050
2051 Vue.prototype.$forceUpdate = function () {
2052 var vm = this;
2053 if (vm._watcher) {
2054 vm._watcher.update();
2055 }
2056 };
2057
2058 Vue.prototype.$destroy = function () {
2059 var vm = this;
2060 if (vm._isBeingDestroyed) {
2061 return
2062 }
2063 callHook(vm, 'beforeDestroy');
2064 vm._isBeingDestroyed = true;
2065 // remove self from parent
2066 var parent = vm.$parent;
2067 if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
2068 remove(parent.$children, vm);
2069 }
2070 // teardown watchers
2071 if (vm._watcher) {
2072 vm._watcher.teardown();
2073 }
2074 var i = vm._watchers.length;
2075 while (i--) {
2076 vm._watchers[i].teardown();
2077 }
2078 // remove reference from data ob
2079 // frozen object may not have observer.
2080 if (vm._data.__ob__) {
2081 vm._data.__ob__.vmCount--;
2082 }
2083 // call the last hook...
2084 vm._isDestroyed = true;
2085 callHook(vm, 'destroyed');
2086 // turn off all instance listeners.
2087 vm.$off();
2088 // remove __vue__ reference
2089 if (vm.$el) {
2090 vm.$el.__vue__ = null;
2091 }
2092 // invoke destroy hooks on current rendered tree
2093 vm.__patch__(vm._vnode, null);
2094 };
2095 }
2096
2097 function mountComponent (
2098 vm,
2099 el,
2100 hydrating
2101 ) {
2102 vm.$el = el;
2103 if (!vm.$options.render) {
2104 vm.$options.render = createEmptyVNode;
2105 {
2106 /* istanbul ignore if */
2107 if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
2108 vm.$options.el || el) {
2109 warn(
2110 'You are using the runtime-only build of Vue where the template ' +
2111 'compiler is not available. Either pre-compile the templates into ' +
2112 'render functions, or use the compiler-included build.',
2113 vm
2114 );
2115 } else {
2116 warn(
2117 'Failed to mount component: template or render function not defined.',
2118 vm
2119 );
2120 }
2121 }
2122 }
2123 callHook(vm, 'beforeMount');
2124
2125 var updateComponent;
2126 /* istanbul ignore if */
2127 if ("development" !== 'production' && config.performance && mark) {
2128 updateComponent = function () {
2129 var name = vm._name;
2130 var id = vm._uid;
2131 var startTag = "vue-perf-start:" + id;
2132 var endTag = "vue-perf-end:" + id;
2133
2134 mark(startTag);
2135 var vnode = vm._render();
2136 mark(endTag);
2137 measure((name + " render"), startTag, endTag);
2138
2139 mark(startTag);
2140 vm._update(vnode, hydrating);
2141 mark(endTag);
2142 measure((name + " patch"), startTag, endTag);
2143 };
2144 } else {
2145 updateComponent = function () {
2146 vm._update(vm._render(), hydrating);
2147 };
2148 }
2149
2150 vm._watcher = new Watcher(vm, updateComponent, noop);
2151 hydrating = false;
2152
2153 // manually mounted instance, call mounted on self
2154 // mounted is called for render-created child components in its inserted hook
2155 if (vm.$vnode == null) {
2156 vm._isMounted = true;
2157 callHook(vm, 'mounted');
2158 }
2159 return vm
2160 }
2161
2162 function updateChildComponent (
2163 vm,
2164 propsData,
2165 listeners,
2166 parentVnode,
2167 renderChildren
2168 ) {
2169 // determine whether component has slot children
2170 // we need to do this before overwriting $options._renderChildren
2171 var hasChildren = !!(
2172 renderChildren || // has new static slots
2173 vm.$options._renderChildren || // has old static slots
2174 parentVnode.data.scopedSlots || // has new scoped slots
2175 vm.$scopedSlots !== emptyObject // has old scoped slots
2176 );
2177
2178 vm.$options._parentVnode = parentVnode;
2179 vm.$vnode = parentVnode; // update vm's placeholder node without re-render
2180 if (vm._vnode) { // update child tree's parent
2181 vm._vnode.parent = parentVnode;
2182 }
2183 vm.$options._renderChildren = renderChildren;
2184
2185 // update props
2186 if (propsData && vm.$options.props) {
2187 observerState.shouldConvert = false;
2188 {
2189 observerState.isSettingProps = true;
2190 }
2191 var props = vm._props;
2192 var propKeys = vm.$options._propKeys || [];
2193 for (var i = 0; i < propKeys.length; i++) {
2194 var key = propKeys[i];
2195 props[key] = validateProp(key, vm.$options.props, propsData, vm);
2196 }
2197 observerState.shouldConvert = true;
2198 {
2199 observerState.isSettingProps = false;
2200 }
2201 // keep a copy of raw propsData
2202 vm.$options.propsData = propsData;
2203 }
2204 // update listeners
2205 if (listeners) {
2206 var oldListeners = vm.$options._parentListeners;
2207 vm.$options._parentListeners = listeners;
2208 updateComponentListeners(vm, listeners, oldListeners);
2209 }
2210 // resolve slots + force update if has children
2211 if (hasChildren) {
2212 vm.$slots = resolveSlots(renderChildren, parentVnode.context);
2213 vm.$forceUpdate();
2214 }
2215 }
2216
2217 function isInInactiveTree (vm) {
2218 while (vm && (vm = vm.$parent)) {
2219 if (vm._inactive) { return true }
2220 }
2221 return false
2222 }
2223
2224 function activateChildComponent (vm, direct) {
2225 if (direct) {
2226 vm._directInactive = false;
2227 if (isInInactiveTree(vm)) {
2228 return
2229 }
2230 } else if (vm._directInactive) {
2231 return
2232 }
2233 if (vm._inactive || vm._inactive == null) {
2234 vm._inactive = false;
2235 for (var i = 0; i < vm.$children.length; i++) {
2236 activateChildComponent(vm.$children[i]);
2237 }
2238 callHook(vm, 'activated');
2239 }
2240 }
2241
2242 function deactivateChildComponent (vm, direct) {
2243 if (direct) {
2244 vm._directInactive = true;
2245 if (isInInactiveTree(vm)) {
2246 return
2247 }
2248 }
2249 if (!vm._inactive) {
2250 vm._inactive = true;
2251 for (var i = 0; i < vm.$children.length; i++) {
2252 deactivateChildComponent(vm.$children[i]);
2253 }
2254 callHook(vm, 'deactivated');
2255 }
2256 }
2257
2258 function callHook (vm, hook) {
2259 var handlers = vm.$options[hook];
2260 if (handlers) {
2261 for (var i = 0, j = handlers.length; i < j; i++) {
2262 try {
2263 handlers[i].call(vm);
2264 } catch (e) {
2265 handleError(e, vm, (hook + " hook"));
2266 }
2267 }
2268 }
2269 if (vm._hasHookEvent) {
2270 vm.$emit('hook:' + hook);
2271 }
2272 }
2273
2274 /* */
2275
2276
2277 var queue = [];
2278 var has = {};
2279 var circular = {};
2280 var waiting = false;
2281 var flushing = false;
2282 var index = 0;
2283
2284 /**
2285 * Reset the scheduler's state.
2286 */
2287 function resetSchedulerState () {
2288 queue.length = 0;
2289 has = {};
2290 {
2291 circular = {};
2292 }
2293 waiting = flushing = false;
2294 }
2295
2296 /**
2297 * Flush both queues and run the watchers.
2298 */
2299 function flushSchedulerQueue () {
2300 flushing = true;
2301 var watcher, id, vm;
2302
2303 // Sort queue before flush.
2304 // This ensures that:
2305 // 1. Components are updated from parent to child. (because parent is always
2306 // created before the child)
2307 // 2. A component's user watchers are run before its render watcher (because
2308 // user watchers are created before the render watcher)
2309 // 3. If a component is destroyed during a parent component's watcher run,
2310 // its watchers can be skipped.
2311 queue.sort(function (a, b) { return a.id - b.id; });
2312
2313 // do not cache length because more watchers might be pushed
2314 // as we run existing watchers
2315 for (index = 0; index < queue.length; index++) {
2316 watcher = queue[index];
2317 id = watcher.id;
2318 has[id] = null;
2319 watcher.run();
2320 // in dev build, check and stop circular updates.
2321 if ("development" !== 'production' && has[id] != null) {
2322 circular[id] = (circular[id] || 0) + 1;
2323 if (circular[id] > config._maxUpdateCount) {
2324 warn(
2325 'You may have an infinite update loop ' + (
2326 watcher.user
2327 ? ("in watcher with expression \"" + (watcher.expression) + "\"")
2328 : "in a component render function."
2329 ),
2330 watcher.vm
2331 );
2332 break
2333 }
2334 }
2335 }
2336
2337 // call updated hooks
2338 index = queue.length;
2339 while (index--) {
2340 watcher = queue[index];
2341 vm = watcher.vm;
2342 if (vm._watcher === watcher && vm._isMounted) {
2343 callHook(vm, 'updated');
2344 }
2345 }
2346
2347 // devtool hook
2348 /* istanbul ignore if */
2349 if (devtools && config.devtools) {
2350 devtools.emit('flush');
2351 }
2352
2353 resetSchedulerState();
2354 }
2355
2356 /**
2357 * Push a watcher into the watcher queue.
2358 * Jobs with duplicate IDs will be skipped unless it's
2359 * pushed when the queue is being flushed.
2360 */
2361 function queueWatcher (watcher) {
2362 var id = watcher.id;
2363 if (has[id] == null) {
2364 has[id] = true;
2365 if (!flushing) {
2366 queue.push(watcher);
2367 } else {
2368 // if already flushing, splice the watcher based on its id
2369 // if already past its id, it will be run next immediately.
2370 var i = queue.length - 1;
2371 while (i >= 0 && queue[i].id > watcher.id) {
2372 i--;
2373 }
2374 queue.splice(Math.max(i, index) + 1, 0, watcher);
2375 }
2376 // queue the flush
2377 if (!waiting) {
2378 waiting = true;
2379 nextTick(flushSchedulerQueue);
2380 }
2381 }
2382 }
2383
2384 /* */
2385
2386 var uid$2 = 0;
2387
2388 /**
2389 * A watcher parses an expression, collects dependencies,
2390 * and fires callback when the expression value changes.
2391 * This is used for both the $watch() api and directives.
2392 */
2393 var Watcher = function Watcher (
2394 vm,
2395 expOrFn,
2396 cb,
2397 options
2398 ) {
2399 this.vm = vm;
2400 vm._watchers.push(this);
2401 // options
2402 if (options) {
2403 this.deep = !!options.deep;
2404 this.user = !!options.user;
2405 this.lazy = !!options.lazy;
2406 this.sync = !!options.sync;
2407 } else {
2408 this.deep = this.user = this.lazy = this.sync = false;
2409 }
2410 this.cb = cb;
2411 this.id = ++uid$2; // uid for batching
2412 this.active = true;
2413 this.dirty = this.lazy; // for lazy watchers
2414 this.deps = [];
2415 this.newDeps = [];
2416 this.depIds = new _Set();
2417 this.newDepIds = new _Set();
2418 this.expression = expOrFn.toString();
2419 // parse expression for getter
2420 if (typeof expOrFn === 'function') {
2421 this.getter = expOrFn;
2422 } else {
2423 this.getter = parsePath(expOrFn);
2424 if (!this.getter) {
2425 this.getter = function () {};
2426 "development" !== 'production' && warn(
2427 "Failed watching path: \"" + expOrFn + "\" " +
2428 'Watcher only accepts simple dot-delimited paths. ' +
2429 'For full control, use a function instead.',
2430 vm
2431 );
2432 }
2433 }
2434 this.value = this.lazy
2435 ? undefined
2436 : this.get();
2437 };
2438
2439 /**
2440 * Evaluate the getter, and re-collect dependencies.
2441 */
2442 Watcher.prototype.get = function get () {
2443 pushTarget(this);
2444 var value;
2445 var vm = this.vm;
2446 if (this.user) {
2447 try {
2448 value = this.getter.call(vm, vm);
2449 } catch (e) {
2450 handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
2451 }
2452 } else {
2453 value = this.getter.call(vm, vm);
2454 }
2455 // "touch" every property so they are all tracked as
2456 // dependencies for deep watching
2457 if (this.deep) {
2458 traverse(value);
2459 }
2460 popTarget();
2461 this.cleanupDeps();
2462 return value
2463 };
2464
2465 /**
2466 * Add a dependency to this directive.
2467 */
2468 Watcher.prototype.addDep = function addDep (dep) {
2469 var id = dep.id;
2470 if (!this.newDepIds.has(id)) {
2471 this.newDepIds.add(id);
2472 this.newDeps.push(dep);
2473 if (!this.depIds.has(id)) {
2474 dep.addSub(this);
2475 }
2476 }
2477 };
2478
2479 /**
2480 * Clean up for dependency collection.
2481 */
2482 Watcher.prototype.cleanupDeps = function cleanupDeps () {
2483 var this$1 = this;
2484
2485 var i = this.deps.length;
2486 while (i--) {
2487 var dep = this$1.deps[i];
2488 if (!this$1.newDepIds.has(dep.id)) {
2489 dep.removeSub(this$1);
2490 }
2491 }
2492 var tmp = this.depIds;
2493 this.depIds = this.newDepIds;
2494 this.newDepIds = tmp;
2495 this.newDepIds.clear();
2496 tmp = this.deps;
2497 this.deps = this.newDeps;
2498 this.newDeps = tmp;
2499 this.newDeps.length = 0;
2500 };
2501
2502 /**
2503 * Subscriber interface.
2504 * Will be called when a dependency changes.
2505 */
2506 Watcher.prototype.update = function update () {
2507 /* istanbul ignore else */
2508 if (this.lazy) {
2509 this.dirty = true;
2510 } else if (this.sync) {
2511 this.run();
2512 } else {
2513 queueWatcher(this);
2514 }
2515 };
2516
2517 /**
2518 * Scheduler job interface.
2519 * Will be called by the scheduler.
2520 */
2521 Watcher.prototype.run = function run () {
2522 if (this.active) {
2523 var value = this.get();
2524 if (
2525 value !== this.value ||
2526 // Deep watchers and watchers on Object/Arrays should fire even
2527 // when the value is the same, because the value may
2528 // have mutated.
2529 isObject(value) ||
2530 this.deep
2531 ) {
2532 // set new value
2533 var oldValue = this.value;
2534 this.value = value;
2535 if (this.user) {
2536 try {
2537 this.cb.call(this.vm, value, oldValue);
2538 } catch (e) {
2539 handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
2540 }
2541 } else {
2542 this.cb.call(this.vm, value, oldValue);
2543 }
2544 }
2545 }
2546 };
2547
2548 /**
2549 * Evaluate the value of the watcher.
2550 * This only gets called for lazy watchers.
2551 */
2552 Watcher.prototype.evaluate = function evaluate () {
2553 this.value = this.get();
2554 this.dirty = false;
2555 };
2556
2557 /**
2558 * Depend on all deps collected by this watcher.
2559 */
2560 Watcher.prototype.depend = function depend () {
2561 var this$1 = this;
2562
2563 var i = this.deps.length;
2564 while (i--) {
2565 this$1.deps[i].depend();
2566 }
2567 };
2568
2569 /**
2570 * Remove self from all dependencies' subscriber list.
2571 */
2572 Watcher.prototype.teardown = function teardown () {
2573 var this$1 = this;
2574
2575 if (this.active) {
2576 // remove self from vm's watcher list
2577 // this is a somewhat expensive operation so we skip it
2578 // if the vm is being destroyed.
2579 if (!this.vm._isBeingDestroyed) {
2580 remove(this.vm._watchers, this);
2581 }
2582 var i = this.deps.length;
2583 while (i--) {
2584 this$1.deps[i].removeSub(this$1);
2585 }
2586 this.active = false;
2587 }
2588 };
2589
2590 /**
2591 * Recursively traverse an object to evoke all converted
2592 * getters, so that every nested property inside the object
2593 * is collected as a "deep" dependency.
2594 */
2595 var seenObjects = new _Set();
2596 function traverse (val) {
2597 seenObjects.clear();
2598 _traverse(val, seenObjects);
2599 }
2600
2601 function _traverse (val, seen) {
2602 var i, keys;
2603 var isA = Array.isArray(val);
2604 if ((!isA && !isObject(val)) || !Object.isExtensible(val)) {
2605 return
2606 }
2607 if (val.__ob__) {
2608 var depId = val.__ob__.dep.id;
2609 if (seen.has(depId)) {
2610 return
2611 }
2612 seen.add(depId);
2613 }
2614 if (isA) {
2615 i = val.length;
2616 while (i--) { _traverse(val[i], seen); }
2617 } else {
2618 keys = Object.keys(val);
2619 i = keys.length;
2620 while (i--) { _traverse(val[keys[i]], seen); }
2621 }
2622 }
2623
2624 /* */
2625
2626 var sharedPropertyDefinition = {
2627 enumerable: true,
2628 configurable: true,
2629 get: noop,
2630 set: noop
2631 };
2632
2633 function proxy (target, sourceKey, key) {
2634 sharedPropertyDefinition.get = function proxyGetter () {
2635 return this[sourceKey][key]
2636 };
2637 sharedPropertyDefinition.set = function proxySetter (val) {
2638 this[sourceKey][key] = val;
2639 };
2640 Object.defineProperty(target, key, sharedPropertyDefinition);
2641 }
2642
2643 function initState (vm) {
2644 vm._watchers = [];
2645 var opts = vm.$options;
2646 if (opts.props) { initProps(vm, opts.props); }
2647 if (opts.methods) { initMethods(vm, opts.methods); }
2648 if (opts.data) {
2649 initData(vm);
2650 } else {
2651 observe(vm._data = {}, true /* asRootData */);
2652 }
2653 if (opts.computed) { initComputed(vm, opts.computed); }
2654 if (opts.watch) { initWatch(vm, opts.watch); }
2655 }
2656
2657 var isReservedProp = { key: 1, ref: 1, slot: 1 };
2658
2659 function initProps (vm, propsOptions) {
2660 var propsData = vm.$options.propsData || {};
2661 var props = vm._props = {};
2662 // cache prop keys so that future props updates can iterate using Array
2663 // instead of dynamic object key enumeration.
2664 var keys = vm.$options._propKeys = [];
2665 var isRoot = !vm.$parent;
2666 // root instance props should be converted
2667 observerState.shouldConvert = isRoot;
2668 var loop = function ( key ) {
2669 keys.push(key);
2670 var value = validateProp(key, propsOptions, propsData, vm);
2671 /* istanbul ignore else */
2672 {
2673 if (isReservedProp[key]) {
2674 warn(
2675 ("\"" + key + "\" is a reserved attribute and cannot be used as component prop."),
2676 vm
2677 );
2678 }
2679 defineReactive$$1(props, key, value, function () {
2680 if (vm.$parent && !observerState.isSettingProps) {
2681 warn(
2682 "Avoid mutating a prop directly since the value will be " +
2683 "overwritten whenever the parent component re-renders. " +
2684 "Instead, use a data or computed property based on the prop's " +
2685 "value. Prop being mutated: \"" + key + "\"",
2686 vm
2687 );
2688 }
2689 });
2690 }
2691 // static props are already proxied on the component's prototype
2692 // during Vue.extend(). We only need to proxy props defined at
2693 // instantiation here.
2694 if (!(key in vm)) {
2695 proxy(vm, "_props", key);
2696 }
2697 };
2698
2699 for (var key in propsOptions) loop( key );
2700 observerState.shouldConvert = true;
2701 }
2702
2703 function initData (vm) {
2704 var data = vm.$options.data;
2705 data = vm._data = typeof data === 'function'
2706 ? data.call(vm)
2707 : data || {};
2708 if (!isPlainObject(data)) {
2709 data = {};
2710 "development" !== 'production' && warn(
2711 'data functions should return an object:\n' +
2712 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
2713 vm
2714 );
2715 }
2716 // proxy data on instance
2717 var keys = Object.keys(data);
2718 var props = vm.$options.props;
2719 var i = keys.length;
2720 while (i--) {
2721 if (props && hasOwn(props, keys[i])) {
2722 "development" !== 'production' && warn(
2723 "The data property \"" + (keys[i]) + "\" is already declared as a prop. " +
2724 "Use prop default value instead.",
2725 vm
2726 );
2727 } else if (!isReserved(keys[i])) {
2728 proxy(vm, "_data", keys[i]);
2729 }
2730 }
2731 // observe data
2732 observe(data, true /* asRootData */);
2733 }
2734
2735 var computedWatcherOptions = { lazy: true };
2736
2737 function initComputed (vm, computed) {
2738 var watchers = vm._computedWatchers = Object.create(null);
2739
2740 for (var key in computed) {
2741 var userDef = computed[key];
2742 var getter = typeof userDef === 'function' ? userDef : userDef.get;
2743 // create internal watcher for the computed property.
2744 watchers[key] = new Watcher(vm, getter, noop, computedWatcherOptions);
2745
2746 // component-defined computed properties are already defined on the
2747 // component prototype. We only need to define computed properties defined
2748 // at instantiation here.
2749 if (!(key in vm)) {
2750 defineComputed(vm, key, userDef);
2751 }
2752 }
2753 }
2754
2755 function defineComputed (target, key, userDef) {
2756 if (typeof userDef === 'function') {
2757 sharedPropertyDefinition.get = createComputedGetter(key);
2758 sharedPropertyDefinition.set = noop;
2759 } else {
2760 sharedPropertyDefinition.get = userDef.get
2761 ? userDef.cache !== false
2762 ? createComputedGetter(key)
2763 : userDef.get
2764 : noop;
2765 sharedPropertyDefinition.set = userDef.set
2766 ? userDef.set
2767 : noop;
2768 }
2769 Object.defineProperty(target, key, sharedPropertyDefinition);
2770 }
2771
2772 function createComputedGetter (key) {
2773 return function computedGetter () {
2774 var watcher = this._computedWatchers && this._computedWatchers[key];
2775 if (watcher) {
2776 if (watcher.dirty) {
2777 watcher.evaluate();
2778 }
2779 if (Dep.target) {
2780 watcher.depend();
2781 }
2782 return watcher.value
2783 }
2784 }
2785 }
2786
2787 function initMethods (vm, methods) {
2788 var props = vm.$options.props;
2789 for (var key in methods) {
2790 vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
2791 {
2792 if (methods[key] == null) {
2793 warn(
2794 "method \"" + key + "\" has an undefined value in the component definition. " +
2795 "Did you reference the function correctly?",
2796 vm
2797 );
2798 }
2799 if (props && hasOwn(props, key)) {
2800 warn(
2801 ("method \"" + key + "\" has already been defined as a prop."),
2802 vm
2803 );
2804 }
2805 }
2806 }
2807 }
2808
2809 function initWatch (vm, watch) {
2810 for (var key in watch) {
2811 var handler = watch[key];
2812 if (Array.isArray(handler)) {
2813 for (var i = 0; i < handler.length; i++) {
2814 createWatcher(vm, key, handler[i]);
2815 }
2816 } else {
2817 createWatcher(vm, key, handler);
2818 }
2819 }
2820 }
2821
2822 function createWatcher (vm, key, handler) {
2823 var options;
2824 if (isPlainObject(handler)) {
2825 options = handler;
2826 handler = handler.handler;
2827 }
2828 if (typeof handler === 'string') {
2829 handler = vm[handler];
2830 }
2831 vm.$watch(key, handler, options);
2832 }
2833
2834 function stateMixin (Vue) {
2835 // flow somehow has problems with directly declared definition object
2836 // when using Object.defineProperty, so we have to procedurally build up
2837 // the object here.
2838 var dataDef = {};
2839 dataDef.get = function () { return this._data };
2840 var propsDef = {};
2841 propsDef.get = function () { return this._props };
2842 {
2843 dataDef.set = function (newData) {
2844 warn(
2845 'Avoid replacing instance root $data. ' +
2846 'Use nested data properties instead.',
2847 this
2848 );
2849 };
2850 propsDef.set = function () {
2851 warn("$props is readonly.", this);
2852 };
2853 }
2854 Object.defineProperty(Vue.prototype, '$data', dataDef);
2855 Object.defineProperty(Vue.prototype, '$props', propsDef);
2856
2857 Vue.prototype.$set = set;
2858 Vue.prototype.$delete = del;
2859
2860 Vue.prototype.$watch = function (
2861 expOrFn,
2862 cb,
2863 options
2864 ) {
2865 var vm = this;
2866 options = options || {};
2867 options.user = true;
2868 var watcher = new Watcher(vm, expOrFn, cb, options);
2869 if (options.immediate) {
2870 cb.call(vm, watcher.value);
2871 }
2872 return function unwatchFn () {
2873 watcher.teardown();
2874 }
2875 };
2876 }
2877
2878 /* */
2879
2880 // hooks to be invoked on component VNodes during patch
2881 var componentVNodeHooks = {
2882 init: function init (
2883 vnode,
2884 hydrating,
2885 parentElm,
2886 refElm
2887 ) {
2888 if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) {
2889 var child = vnode.componentInstance = createComponentInstanceForVnode(
2890 vnode,
2891 activeInstance,
2892 parentElm,
2893 refElm
2894 );
2895 child.$mount(hydrating ? vnode.elm : undefined, hydrating);
2896 } else if (vnode.data.keepAlive) {
2897 // kept-alive components, treat as a patch
2898 var mountedNode = vnode; // work around flow
2899 componentVNodeHooks.prepatch(mountedNode, mountedNode);
2900 }
2901 },
2902
2903 prepatch: function prepatch (oldVnode, vnode) {
2904 var options = vnode.componentOptions;
2905 var child = vnode.componentInstance = oldVnode.componentInstance;
2906 updateChildComponent(
2907 child,
2908 options.propsData, // updated props
2909 options.listeners, // updated listeners
2910 vnode, // new parent vnode
2911 options.children // new children
2912 );
2913 },
2914
2915 insert: function insert (vnode) {
2916 if (!vnode.componentInstance._isMounted) {
2917 vnode.componentInstance._isMounted = true;
2918 callHook(vnode.componentInstance, 'mounted');
2919 }
2920 if (vnode.data.keepAlive) {
2921 activateChildComponent(vnode.componentInstance, true /* direct */);
2922 }
2923 },
2924
2925 destroy: function destroy (vnode) {
2926 if (!vnode.componentInstance._isDestroyed) {
2927 if (!vnode.data.keepAlive) {
2928 vnode.componentInstance.$destroy();
2929 } else {
2930 deactivateChildComponent(vnode.componentInstance, true /* direct */);
2931 }
2932 }
2933 }
2934 };
2935
2936 var hooksToMerge = Object.keys(componentVNodeHooks);
2937
2938 function createComponent (
2939 Ctor,
2940 data,
2941 context,
2942 children,
2943 tag
2944 ) {
2945 if (!Ctor) {
2946 return
2947 }
2948
2949 var baseCtor = context.$options._base;
2950 if (isObject(Ctor)) {
2951 Ctor = baseCtor.extend(Ctor);
2952 }
2953
2954 if (typeof Ctor !== 'function') {
2955 {
2956 warn(("Invalid Component definition: " + (String(Ctor))), context);
2957 }
2958 return
2959 }
2960
2961 // async component
2962 if (!Ctor.cid) {
2963 if (Ctor.resolved) {
2964 Ctor = Ctor.resolved;
2965 } else {
2966 Ctor = resolveAsyncComponent(Ctor, baseCtor, function () {
2967 // it's ok to queue this on every render because
2968 // $forceUpdate is buffered by the scheduler.
2969 context.$forceUpdate();
2970 });
2971 if (!Ctor) {
2972 // return nothing if this is indeed an async component
2973 // wait for the callback to trigger parent update.
2974 return
2975 }
2976 }
2977 }
2978
2979 // resolve constructor options in case global mixins are applied after
2980 // component constructor creation
2981 resolveConstructorOptions(Ctor);
2982
2983 data = data || {};
2984
2985 // transform component v-model data into props & events
2986 if (data.model) {
2987 transformModel(Ctor.options, data);
2988 }
2989
2990 // extract props
2991 var propsData = extractProps(data, Ctor);
2992
2993 // functional component
2994 if (Ctor.options.functional) {
2995 return createFunctionalComponent(Ctor, propsData, data, context, children)
2996 }
2997
2998 // extract listeners, since these needs to be treated as
2999 // child component listeners instead of DOM listeners
3000 var listeners = data.on;
3001 // replace with listeners with .native modifier
3002 data.on = data.nativeOn;
3003
3004 if (Ctor.options.abstract) {
3005 // abstract components do not keep anything
3006 // other than props & listeners
3007 data = {};
3008 }
3009
3010 // merge component management hooks onto the placeholder node
3011 mergeHooks(data);
3012
3013 // return a placeholder vnode
3014 var name = Ctor.options.name || tag;
3015 var vnode = new VNode(
3016 ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
3017 data, undefined, undefined, undefined, context,
3018 { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }
3019 );
3020 return vnode
3021 }
3022
3023 function createFunctionalComponent (
3024 Ctor,
3025 propsData,
3026 data,
3027 context,
3028 children
3029 ) {
3030 var props = {};
3031 var propOptions = Ctor.options.props;
3032 if (propOptions) {
3033 for (var key in propOptions) {
3034 props[key] = validateProp(key, propOptions, propsData);
3035 }
3036 }
3037 // ensure the createElement function in functional components
3038 // gets a unique context - this is necessary for correct named slot check
3039 var _context = Object.create(context);
3040 var h = function (a, b, c, d) { return createElement(_context, a, b, c, d, true); };
3041 var vnode = Ctor.options.render.call(null, h, {
3042 props: props,
3043 data: data,
3044 parent: context,
3045 children: children,
3046 slots: function () { return resolveSlots(children, context); }
3047 });
3048 if (vnode instanceof VNode) {
3049 vnode.functionalContext = context;
3050 if (data.slot) {
3051 (vnode.data || (vnode.data = {})).slot = data.slot;
3052 }
3053 }
3054 return vnode
3055 }
3056
3057 function createComponentInstanceForVnode (
3058 vnode, // we know it's MountedComponentVNode but flow doesn't
3059 parent, // activeInstance in lifecycle state
3060 parentElm,
3061 refElm
3062 ) {
3063 var vnodeComponentOptions = vnode.componentOptions;
3064 var options = {
3065 _isComponent: true,
3066 parent: parent,
3067 propsData: vnodeComponentOptions.propsData,
3068 _componentTag: vnodeComponentOptions.tag,
3069 _parentVnode: vnode,
3070 _parentListeners: vnodeComponentOptions.listeners,
3071 _renderChildren: vnodeComponentOptions.children,
3072 _parentElm: parentElm || null,
3073 _refElm: refElm || null
3074 };
3075 // check inline-template render functions
3076 var inlineTemplate = vnode.data.inlineTemplate;
3077 if (inlineTemplate) {
3078 options.render = inlineTemplate.render;
3079 options.staticRenderFns = inlineTemplate.staticRenderFns;
3080 }
3081 return new vnodeComponentOptions.Ctor(options)
3082 }
3083
3084 function resolveAsyncComponent (
3085 factory,
3086 baseCtor,
3087 cb
3088 ) {
3089 if (factory.requested) {
3090 // pool callbacks
3091 factory.pendingCallbacks.push(cb);
3092 } else {
3093 factory.requested = true;
3094 var cbs = factory.pendingCallbacks = [cb];
3095 var sync = true;
3096
3097 var resolve = function (res) {
3098 if (isObject(res)) {
3099 res = baseCtor.extend(res);
3100 }
3101 // cache resolved
3102 factory.resolved = res;
3103 // invoke callbacks only if this is not a synchronous resolve
3104 // (async resolves are shimmed as synchronous during SSR)
3105 if (!sync) {
3106 for (var i = 0, l = cbs.length; i < l; i++) {
3107 cbs[i](res);
3108 }
3109 }
3110 };
3111
3112 var reject = function (reason) {
3113 "development" !== 'production' && warn(
3114 "Failed to resolve async component: " + (String(factory)) +
3115 (reason ? ("\nReason: " + reason) : '')
3116 );
3117 };
3118
3119 var res = factory(resolve, reject);
3120
3121 // handle promise
3122 if (res && typeof res.then === 'function' && !factory.resolved) {
3123 res.then(resolve, reject);
3124 }
3125
3126 sync = false;
3127 // return in case resolved synchronously
3128 return factory.resolved
3129 }
3130 }
3131
3132 function extractProps (data, Ctor) {
3133 // we are only extracting raw values here.
3134 // validation and default values are handled in the child
3135 // component itself.
3136 var propOptions = Ctor.options.props;
3137 if (!propOptions) {
3138 return
3139 }
3140 var res = {};
3141 var attrs = data.attrs;
3142 var props = data.props;
3143 var domProps = data.domProps;
3144 if (attrs || props || domProps) {
3145 for (var key in propOptions) {
3146 var altKey = hyphenate(key);
3147 {
3148 var keyInLowerCase = key.toLowerCase();
3149 if (
3150 key !== keyInLowerCase &&
3151 attrs && attrs.hasOwnProperty(keyInLowerCase)
3152 ) {
3153 warn(
3154 "Prop \"" + keyInLowerCase + "\" is not declared in component " +
3155 (formatComponentName(Ctor)) + ". Note that HTML attributes are " +
3156 "case-insensitive and camelCased props need to use their kebab-case " +
3157 "equivalents when using in-DOM templates. You should probably use " +
3158 "\"" + altKey + "\" instead of \"" + key + "\"."
3159 );
3160 }
3161 }
3162 checkProp(res, props, key, altKey, true) ||
3163 checkProp(res, attrs, key, altKey) ||
3164 checkProp(res, domProps, key, altKey);
3165 }
3166 }
3167 return res
3168 }
3169
3170 function checkProp (
3171 res,
3172 hash,
3173 key,
3174 altKey,
3175 preserve
3176 ) {
3177 if (hash) {
3178 if (hasOwn(hash, key)) {
3179 res[key] = hash[key];
3180 if (!preserve) {
3181 delete hash[key];
3182 }
3183 return true
3184 } else if (hasOwn(hash, altKey)) {
3185 res[key] = hash[altKey];
3186 if (!preserve) {
3187 delete hash[altKey];
3188 }
3189 return true
3190 }
3191 }
3192 return false
3193 }
3194
3195 function mergeHooks (data) {
3196 if (!data.hook) {
3197 data.hook = {};
3198 }
3199 for (var i = 0; i < hooksToMerge.length; i++) {
3200 var key = hooksToMerge[i];
3201 var fromParent = data.hook[key];
3202 var ours = componentVNodeHooks[key];
3203 data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours;
3204 }
3205 }
3206
3207 function mergeHook$1 (one, two) {
3208 return function (a, b, c, d) {
3209 one(a, b, c, d);
3210 two(a, b, c, d);
3211 }
3212 }
3213
3214 // transform component v-model info (value and callback) into
3215 // prop and event handler respectively.
3216 function transformModel (options, data) {
3217 var prop = (options.model && options.model.prop) || 'value';
3218 var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value;
3219 var on = data.on || (data.on = {});
3220 if (on[event]) {
3221 on[event] = [data.model.callback].concat(on[event]);
3222 } else {
3223 on[event] = data.model.callback;
3224 }
3225 }
3226
3227 /* */
3228
3229 var SIMPLE_NORMALIZE = 1;
3230 var ALWAYS_NORMALIZE = 2;
3231
3232 // wrapper function for providing a more flexible interface
3233 // without getting yelled at by flow
3234 function createElement (
3235 context,
3236 tag,
3237 data,
3238 children,
3239 normalizationType,
3240 alwaysNormalize
3241 ) {
3242 if (Array.isArray(data) || isPrimitive(data)) {
3243 normalizationType = children;
3244 children = data;
3245 data = undefined;
3246 }
3247 if (alwaysNormalize) { normalizationType = ALWAYS_NORMALIZE; }
3248 return _createElement(context, tag, data, children, normalizationType)
3249 }
3250
3251 function _createElement (
3252 context,
3253 tag,
3254 data,
3255 children,
3256 normalizationType
3257 ) {
3258 if (data && data.__ob__) {
3259 "development" !== 'production' && warn(
3260 "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
3261 'Always create fresh vnode data objects in each render!',
3262 context
3263 );
3264 return createEmptyVNode()
3265 }
3266 if (!tag) {
3267 // in case of component :is set to falsy value
3268 return createEmptyVNode()
3269 }
3270 // support single function children as default scoped slot
3271 if (Array.isArray(children) &&
3272 typeof children[0] === 'function') {
3273 data = data || {};
3274 data.scopedSlots = { default: children[0] };
3275 children.length = 0;
3276 }
3277 if (normalizationType === ALWAYS_NORMALIZE) {
3278 children = normalizeChildren(children);
3279 } else if (normalizationType === SIMPLE_NORMALIZE) {
3280 children = simpleNormalizeChildren(children);
3281 }
3282 var vnode, ns;
3283 if (typeof tag === 'string') {
3284 var Ctor;
3285 ns = config.getTagNamespace(tag);
3286 if (config.isReservedTag(tag)) {
3287 // platform built-in elements
3288 vnode = new VNode(
3289 config.parsePlatformTagName(tag), data, children,
3290 undefined, undefined, context
3291 );
3292 } else if ((Ctor = resolveAsset(context.$options, 'components', tag))) {
3293 // component
3294 vnode = createComponent(Ctor, data, context, children, tag);
3295 } else {
3296 // unknown or unlisted namespaced elements
3297 // check at runtime because it may get assigned a namespace when its
3298 // parent normalizes children
3299 vnode = new VNode(
3300 tag, data, children,
3301 undefined, undefined, context
3302 );
3303 }
3304 } else {
3305 // direct component options / constructor
3306 vnode = createComponent(tag, data, context, children);
3307 }
3308 if (vnode) {
3309 if (ns) { applyNS(vnode, ns); }
3310 return vnode
3311 } else {
3312 return createEmptyVNode()
3313 }
3314 }
3315
3316 function applyNS (vnode, ns) {
3317 vnode.ns = ns;
3318 if (vnode.tag === 'foreignObject') {
3319 // use default namespace inside foreignObject
3320 return
3321 }
3322 if (vnode.children) {
3323 for (var i = 0, l = vnode.children.length; i < l; i++) {
3324 var child = vnode.children[i];
3325 if (child.tag && !child.ns) {
3326 applyNS(child, ns);
3327 }
3328 }
3329 }
3330 }
3331
3332 /* */
3333
3334 /**
3335 * Runtime helper for rendering v-for lists.
3336 */
3337 function renderList (
3338 val,
3339 render
3340 ) {
3341 var ret, i, l, keys, key;
3342 if (Array.isArray(val) || typeof val === 'string') {
3343 ret = new Array(val.length);
3344 for (i = 0, l = val.length; i < l; i++) {
3345 ret[i] = render(val[i], i);
3346 }
3347 } else if (typeof val === 'number') {
3348 ret = new Array(val);
3349 for (i = 0; i < val; i++) {
3350 ret[i] = render(i + 1, i);
3351 }
3352 } else if (isObject(val)) {
3353 keys = Object.keys(val);
3354 ret = new Array(keys.length);
3355 for (i = 0, l = keys.length; i < l; i++) {
3356 key = keys[i];
3357 ret[i] = render(val[key], key, i);
3358 }
3359 }
3360 return ret
3361 }
3362
3363 /* */
3364
3365 /**
3366 * Runtime helper for rendering <slot>
3367 */
3368 function renderSlot (
3369 name,
3370 fallback,
3371 props,
3372 bindObject
3373 ) {
3374 var scopedSlotFn = this.$scopedSlots[name];
3375 if (scopedSlotFn) { // scoped slot
3376 props = props || {};
3377 if (bindObject) {
3378 extend(props, bindObject);
3379 }
3380 return scopedSlotFn(props) || fallback
3381 } else {
3382 var slotNodes = this.$slots[name];
3383 // warn duplicate slot usage
3384 if (slotNodes && "development" !== 'production') {
3385 slotNodes._rendered && warn(
3386 "Duplicate presence of slot \"" + name + "\" found in the same render tree " +
3387 "- this will likely cause render errors.",
3388 this
3389 );
3390 slotNodes._rendered = true;
3391 }
3392 return slotNodes || fallback
3393 }
3394 }
3395
3396 /* */
3397
3398 /**
3399 * Runtime helper for resolving filters
3400 */
3401 function resolveFilter (id) {
3402 return resolveAsset(this.$options, 'filters', id, true) || identity
3403 }
3404
3405 /* */
3406
3407 /**
3408 * Runtime helper for checking keyCodes from config.
3409 */
3410 function checkKeyCodes (
3411 eventKeyCode,
3412 key,
3413 builtInAlias
3414 ) {
3415 var keyCodes = config.keyCodes[key] || builtInAlias;
3416 if (Array.isArray(keyCodes)) {
3417 return keyCodes.indexOf(eventKeyCode) === -1
3418 } else {
3419 return keyCodes !== eventKeyCode
3420 }
3421 }
3422
3423 /* */
3424
3425 /**
3426 * Runtime helper for merging v-bind="object" into a VNode's data.
3427 */
3428 function bindObjectProps (
3429 data,
3430 tag,
3431 value,
3432 asProp
3433 ) {
3434 if (value) {
3435 if (!isObject(value)) {
3436 "development" !== 'production' && warn(
3437 'v-bind without argument expects an Object or Array value',
3438 this
3439 );
3440 } else {
3441 if (Array.isArray(value)) {
3442 value = toObject(value);
3443 }
3444 var hash;
3445 for (var key in value) {
3446 if (key === 'class' || key === 'style') {
3447 hash = data;
3448 } else {
3449 var type = data.attrs && data.attrs.type;
3450 hash = asProp || config.mustUseProp(tag, type, key)
3451 ? data.domProps || (data.domProps = {})
3452 : data.attrs || (data.attrs = {});
3453 }
3454 if (!(key in hash)) {
3455 hash[key] = value[key];
3456 }
3457 }
3458 }
3459 }
3460 return data
3461 }
3462
3463 /* */
3464
3465 /**
3466 * Runtime helper for rendering static trees.
3467 */
3468 function renderStatic (
3469 index,
3470 isInFor
3471 ) {
3472 var tree = this._staticTrees[index];
3473 // if has already-rendered static tree and not inside v-for,
3474 // we can reuse the same tree by doing a shallow clone.
3475 if (tree && !isInFor) {
3476 return Array.isArray(tree)
3477 ? cloneVNodes(tree)
3478 : cloneVNode(tree)
3479 }
3480 // otherwise, render a fresh tree.
3481 tree = this._staticTrees[index] =
3482 this.$options.staticRenderFns[index].call(this._renderProxy);
3483 markStatic(tree, ("__static__" + index), false);
3484 return tree
3485 }
3486
3487 /**
3488 * Runtime helper for v-once.
3489 * Effectively it means marking the node as static with a unique key.
3490 */
3491 function markOnce (
3492 tree,
3493 index,
3494 key
3495 ) {
3496 markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
3497 return tree
3498 }
3499
3500 function markStatic (
3501 tree,
3502 key,
3503 isOnce
3504 ) {
3505 if (Array.isArray(tree)) {
3506 for (var i = 0; i < tree.length; i++) {
3507 if (tree[i] && typeof tree[i] !== 'string') {
3508 markStaticNode(tree[i], (key + "_" + i), isOnce);
3509 }
3510 }
3511 } else {
3512 markStaticNode(tree, key, isOnce);
3513 }
3514 }
3515
3516 function markStaticNode (node, key, isOnce) {
3517 node.isStatic = true;
3518 node.key = key;
3519 node.isOnce = isOnce;
3520 }
3521
3522 /* */
3523
3524 function initRender (vm) {
3525 vm.$vnode = null; // the placeholder node in parent tree
3526 vm._vnode = null; // the root of the child tree
3527 vm._staticTrees = null;
3528 var parentVnode = vm.$options._parentVnode;
3529 var renderContext = parentVnode && parentVnode.context;
3530 vm.$slots = resolveSlots(vm.$options._renderChildren, renderContext);
3531 vm.$scopedSlots = emptyObject;
3532 // bind the createElement fn to this instance
3533 // so that we get proper render context inside it.
3534 // args order: tag, data, children, normalizationType, alwaysNormalize
3535 // internal version is used by render functions compiled from templates
3536 vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
3537 // normalization is always applied for the public version, used in
3538 // user-written render functions.
3539 vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
3540 }
3541
3542 function renderMixin (Vue) {
3543 Vue.prototype.$nextTick = function (fn) {
3544 return nextTick(fn, this)
3545 };
3546
3547 Vue.prototype._render = function () {
3548 var vm = this;
3549 var ref = vm.$options;
3550 var render = ref.render;
3551 var staticRenderFns = ref.staticRenderFns;
3552 var _parentVnode = ref._parentVnode;
3553
3554 if (vm._isMounted) {
3555 // clone slot nodes on re-renders
3556 for (var key in vm.$slots) {
3557 vm.$slots[key] = cloneVNodes(vm.$slots[key]);
3558 }
3559 }
3560
3561 vm.$scopedSlots = (_parentVnode && _parentVnode.data.scopedSlots) || emptyObject;
3562
3563 if (staticRenderFns && !vm._staticTrees) {
3564 vm._staticTrees = [];
3565 }
3566 // set parent vnode. this allows render functions to have access
3567 // to the data on the placeholder node.
3568 vm.$vnode = _parentVnode;
3569 // render self
3570 var vnode;
3571 try {
3572 vnode = render.call(vm._renderProxy, vm.$createElement);
3573 } catch (e) {
3574 handleError(e, vm, "render function");
3575 // return error render result,
3576 // or previous vnode to prevent render error causing blank component
3577 /* istanbul ignore else */
3578 {
3579 vnode = vm.$options.renderError
3580 ? vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e)
3581 : vm._vnode;
3582 }
3583 }
3584 // return empty vnode in case the render function errored out
3585 if (!(vnode instanceof VNode)) {
3586 if ("development" !== 'production' && Array.isArray(vnode)) {
3587 warn(
3588 'Multiple root nodes returned from render function. Render function ' +
3589 'should return a single root node.',
3590 vm
3591 );
3592 }
3593 vnode = createEmptyVNode();
3594 }
3595 // set parent
3596 vnode.parent = _parentVnode;
3597 return vnode
3598 };
3599
3600 // internal render helpers.
3601 // these are exposed on the instance prototype to reduce generated render
3602 // code size.
3603 Vue.prototype._o = markOnce;
3604 Vue.prototype._n = toNumber;
3605 Vue.prototype._s = _toString;
3606 Vue.prototype._l = renderList;
3607 Vue.prototype._t = renderSlot;
3608 Vue.prototype._q = looseEqual;
3609 Vue.prototype._i = looseIndexOf;
3610 Vue.prototype._m = renderStatic;
3611 Vue.prototype._f = resolveFilter;
3612 Vue.prototype._k = checkKeyCodes;
3613 Vue.prototype._b = bindObjectProps;
3614 Vue.prototype._v = createTextVNode;
3615 Vue.prototype._e = createEmptyVNode;
3616 Vue.prototype._u = resolveScopedSlots;
3617 }
3618
3619 /* */
3620
3621 function initProvide (vm) {
3622 var provide = vm.$options.provide;
3623 if (provide) {
3624 vm._provided = typeof provide === 'function'
3625 ? provide.call(vm)
3626 : provide;
3627 }
3628 }
3629
3630 function initInjections (vm) {
3631 var inject = vm.$options.inject;
3632 if (inject) {
3633 // inject is :any because flow is not smart enough to figure out cached
3634 // isArray here
3635 var isArray = Array.isArray(inject);
3636 var keys = isArray
3637 ? inject
3638 : hasSymbol
3639 ? Reflect.ownKeys(inject)
3640 : Object.keys(inject);
3641
3642 for (var i = 0; i < keys.length; i++) {
3643 var key = keys[i];
3644 var provideKey = isArray ? key : inject[key];
3645 var source = vm;
3646 while (source) {
3647 if (source._provided && provideKey in source._provided) {
3648 vm[key] = source._provided[provideKey];
3649 break
3650 }
3651 source = source.$parent;
3652 }
3653 }
3654 }
3655 }
3656
3657 /* */
3658
3659 var uid = 0;
3660
3661 function initMixin (Vue) {
3662 Vue.prototype._init = function (options) {
3663 /* istanbul ignore if */
3664 if ("development" !== 'production' && config.performance && mark) {
3665 mark('vue-perf-init');
3666 }
3667
3668 var vm = this;
3669 // a uid
3670 vm._uid = uid++;
3671 // a flag to avoid this being observed
3672 vm._isVue = true;
3673 // merge options
3674 if (options && options._isComponent) {
3675 // optimize internal component instantiation
3676 // since dynamic options merging is pretty slow, and none of the
3677 // internal component options needs special treatment.
3678 initInternalComponent(vm, options);
3679 } else {
3680 vm.$options = mergeOptions(
3681 resolveConstructorOptions(vm.constructor),
3682 options || {},
3683 vm
3684 );
3685 }
3686 /* istanbul ignore else */
3687 {
3688 initProxy(vm);
3689 }
3690 // expose real self
3691 vm._self = vm;
3692 initLifecycle(vm);
3693 initEvents(vm);
3694 initRender(vm);
3695 callHook(vm, 'beforeCreate');
3696 initInjections(vm); // resolve injections before data/props
3697 initState(vm);
3698 initProvide(vm); // resolve provide after data/props
3699 callHook(vm, 'created');
3700
3701 /* istanbul ignore if */
3702 if ("development" !== 'production' && config.performance && mark) {
3703 vm._name = formatComponentName(vm, false);
3704 mark('vue-perf-init-end');
3705 measure(((vm._name) + " init"), 'vue-perf-init', 'vue-perf-init-end');
3706 }
3707
3708 if (vm.$options.el) {
3709 vm.$mount(vm.$options.el);
3710 }
3711 };
3712 }
3713
3714 function initInternalComponent (vm, options) {
3715 var opts = vm.$options = Object.create(vm.constructor.options);
3716 // doing this because it's faster than dynamic enumeration.
3717 opts.parent = options.parent;
3718 opts.propsData = options.propsData;
3719 opts._parentVnode = options._parentVnode;
3720 opts._parentListeners = options._parentListeners;
3721 opts._renderChildren = options._renderChildren;
3722 opts._componentTag = options._componentTag;
3723 opts._parentElm = options._parentElm;
3724 opts._refElm = options._refElm;
3725 if (options.render) {
3726 opts.render = options.render;
3727 opts.staticRenderFns = options.staticRenderFns;
3728 }
3729 }
3730
3731 function resolveConstructorOptions (Ctor) {
3732 var options = Ctor.options;
3733 if (Ctor.super) {
3734 var superOptions = resolveConstructorOptions(Ctor.super);
3735 var cachedSuperOptions = Ctor.superOptions;
3736 if (superOptions !== cachedSuperOptions) {
3737 // super option changed,
3738 // need to resolve new options.
3739 Ctor.superOptions = superOptions;
3740 // check if there are any late-modified/attached options (#4976)
3741 var modifiedOptions = resolveModifiedOptions(Ctor);
3742 // update base extend options
3743 if (modifiedOptions) {
3744 extend(Ctor.extendOptions, modifiedOptions);
3745 }
3746 options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
3747 if (options.name) {
3748 options.components[options.name] = Ctor;
3749 }
3750 }
3751 }
3752 return options
3753 }
3754
3755 function resolveModifiedOptions (Ctor) {
3756 var modified;
3757 var latest = Ctor.options;
3758 var sealed = Ctor.sealedOptions;
3759 for (var key in latest) {
3760 if (latest[key] !== sealed[key]) {
3761 if (!modified) { modified = {}; }
3762 modified[key] = dedupe(latest[key], sealed[key]);
3763 }
3764 }
3765 return modified
3766 }
3767
3768 function dedupe (latest, sealed) {
3769 // compare latest and sealed to ensure lifecycle hooks won't be duplicated
3770 // between merges
3771 if (Array.isArray(latest)) {
3772 var res = [];
3773 sealed = Array.isArray(sealed) ? sealed : [sealed];
3774 for (var i = 0; i < latest.length; i++) {
3775 if (sealed.indexOf(latest[i]) < 0) {
3776 res.push(latest[i]);
3777 }
3778 }
3779 return res
3780 } else {
3781 return latest
3782 }
3783 }
3784
3785 function Vue$3 (options) {
3786 if ("development" !== 'production' &&
3787 !(this instanceof Vue$3)) {
3788 warn('Vue is a constructor and should be called with the `new` keyword');
3789 }
3790 this._init(options);
3791 }
3792
3793 initMixin(Vue$3);
3794 stateMixin(Vue$3);
3795 eventsMixin(Vue$3);
3796 lifecycleMixin(Vue$3);
3797 renderMixin(Vue$3);
3798
3799 /* */
3800
3801 function initUse (Vue) {
3802 Vue.use = function (plugin) {
3803 /* istanbul ignore if */
3804 if (plugin.installed) {
3805 return
3806 }
3807 // additional parameters
3808 var args = toArray(arguments, 1);
3809 args.unshift(this);
3810 if (typeof plugin.install === 'function') {
3811 plugin.install.apply(plugin, args);
3812 } else if (typeof plugin === 'function') {
3813 plugin.apply(null, args);
3814 }
3815 plugin.installed = true;
3816 return this
3817 };
3818 }
3819
3820 /* */
3821
3822 function initMixin$1 (Vue) {
3823 Vue.mixin = function (mixin) {
3824 this.options = mergeOptions(this.options, mixin);
3825 };
3826 }
3827
3828 /* */
3829
3830 function initExtend (Vue) {
3831 /**
3832 * Each instance constructor, including Vue, has a unique
3833 * cid. This enables us to create wrapped "child
3834 * constructors" for prototypal inheritance and cache them.
3835 */
3836 Vue.cid = 0;
3837 var cid = 1;
3838
3839 /**
3840 * Class inheritance
3841 */
3842 Vue.extend = function (extendOptions) {
3843 extendOptions = extendOptions || {};
3844 var Super = this;
3845 var SuperId = Super.cid;
3846 var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
3847 if (cachedCtors[SuperId]) {
3848 return cachedCtors[SuperId]
3849 }
3850
3851 var name = extendOptions.name || Super.options.name;
3852 {
3853 if (!/^[a-zA-Z][\w-]*$/.test(name)) {
3854 warn(
3855 'Invalid component name: "' + name + '". Component names ' +
3856 'can only contain alphanumeric characters and the hyphen, ' +
3857 'and must start with a letter.'
3858 );
3859 }
3860 }
3861
3862 var Sub = function VueComponent (options) {
3863 this._init(options);
3864 };
3865 Sub.prototype = Object.create(Super.prototype);
3866 Sub.prototype.constructor = Sub;
3867 Sub.cid = cid++;
3868 Sub.options = mergeOptions(
3869 Super.options,
3870 extendOptions
3871 );
3872 Sub['super'] = Super;
3873
3874 // For props and computed properties, we define the proxy getters on
3875 // the Vue instances at extension time, on the extended prototype. This
3876 // avoids Object.defineProperty calls for each instance created.
3877 if (Sub.options.props) {
3878 initProps$1(Sub);
3879 }
3880 if (Sub.options.computed) {
3881 initComputed$1(Sub);
3882 }
3883
3884 // allow further extension/mixin/plugin usage
3885 Sub.extend = Super.extend;
3886 Sub.mixin = Super.mixin;
3887 Sub.use = Super.use;
3888
3889 // create asset registers, so extended classes
3890 // can have their private assets too.
3891 config._assetTypes.forEach(function (type) {
3892 Sub[type] = Super[type];
3893 });
3894 // enable recursive self-lookup
3895 if (name) {
3896 Sub.options.components[name] = Sub;
3897 }
3898
3899 // keep a reference to the super options at extension time.
3900 // later at instantiation we can check if Super's options have
3901 // been updated.
3902 Sub.superOptions = Super.options;
3903 Sub.extendOptions = extendOptions;
3904 Sub.sealedOptions = extend({}, Sub.options);
3905
3906 // cache constructor
3907 cachedCtors[SuperId] = Sub;
3908 return Sub
3909 };
3910 }
3911
3912 function initProps$1 (Comp) {
3913 var props = Comp.options.props;
3914 for (var key in props) {
3915 proxy(Comp.prototype, "_props", key);
3916 }
3917 }
3918
3919 function initComputed$1 (Comp) {
3920 var computed = Comp.options.computed;
3921 for (var key in computed) {
3922 defineComputed(Comp.prototype, key, computed[key]);
3923 }
3924 }
3925
3926 /* */
3927
3928 function initAssetRegisters (Vue) {
3929 /**
3930 * Create asset registration methods.
3931 */
3932 config._assetTypes.forEach(function (type) {
3933 Vue[type] = function (
3934 id,
3935 definition
3936 ) {
3937 if (!definition) {
3938 return this.options[type + 's'][id]
3939 } else {
3940 /* istanbul ignore if */
3941 {
3942 if (type === 'component' && config.isReservedTag(id)) {
3943 warn(
3944 'Do not use built-in or reserved HTML elements as component ' +
3945 'id: ' + id
3946 );
3947 }
3948 }
3949 if (type === 'component' && isPlainObject(definition)) {
3950 definition.name = definition.name || id;
3951 definition = this.options._base.extend(definition);
3952 }
3953 if (type === 'directive' && typeof definition === 'function') {
3954 definition = { bind: definition, update: definition };
3955 }
3956 this.options[type + 's'][id] = definition;
3957 return definition
3958 }
3959 };
3960 });
3961 }
3962
3963 /* */
3964
3965 var patternTypes = [String, RegExp];
3966
3967 function getComponentName (opts) {
3968 return opts && (opts.Ctor.options.name || opts.tag)
3969 }
3970
3971 function matches (pattern, name) {
3972 if (typeof pattern === 'string') {
3973 return pattern.split(',').indexOf(name) > -1
3974 } else if (pattern instanceof RegExp) {
3975 return pattern.test(name)
3976 }
3977 /* istanbul ignore next */
3978 return false
3979 }
3980
3981 function pruneCache (cache, filter) {
3982 for (var key in cache) {
3983 var cachedNode = cache[key];
3984 if (cachedNode) {
3985 var name = getComponentName(cachedNode.componentOptions);
3986 if (name && !filter(name)) {
3987 pruneCacheEntry(cachedNode);
3988 cache[key] = null;
3989 }
3990 }
3991 }
3992 }
3993
3994 function pruneCacheEntry (vnode) {
3995 if (vnode) {
3996 if (!vnode.componentInstance._inactive) {
3997 callHook(vnode.componentInstance, 'deactivated');
3998 }
3999 vnode.componentInstance.$destroy();
4000 }
4001 }
4002
4003 var KeepAlive = {
4004 name: 'keep-alive',
4005 abstract: true,
4006
4007 props: {
4008 include: patternTypes,
4009 exclude: patternTypes
4010 },
4011
4012 created: function created () {
4013 this.cache = Object.create(null);
4014 },
4015
4016 destroyed: function destroyed () {
4017 var this$1 = this;
4018
4019 for (var key in this$1.cache) {
4020 pruneCacheEntry(this$1.cache[key]);
4021 }
4022 },
4023
4024 watch: {
4025 include: function include (val) {
4026 pruneCache(this.cache, function (name) { return matches(val, name); });
4027 },
4028 exclude: function exclude (val) {
4029 pruneCache(this.cache, function (name) { return !matches(val, name); });
4030 }
4031 },
4032
4033 render: function render () {
4034 var vnode = getFirstComponentChild(this.$slots.default);
4035 var componentOptions = vnode && vnode.componentOptions;
4036 if (componentOptions) {
4037 // check pattern
4038 var name = getComponentName(componentOptions);
4039 if (name && (
4040 (this.include && !matches(this.include, name)) ||
4041 (this.exclude && matches(this.exclude, name))
4042 )) {
4043 return vnode
4044 }
4045 var key = vnode.key == null
4046 // same constructor may get registered as different local components
4047 // so cid alone is not enough (#3269)
4048 ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
4049 : vnode.key;
4050 if (this.cache[key]) {
4051 vnode.componentInstance = this.cache[key].componentInstance;
4052 } else {
4053 this.cache[key] = vnode;
4054 }
4055 vnode.data.keepAlive = true;
4056 }
4057 return vnode
4058 }
4059 };
4060
4061 var builtInComponents = {
4062 KeepAlive: KeepAlive
4063 };
4064
4065 /* */
4066
4067 function initGlobalAPI (Vue) {
4068 // config
4069 var configDef = {};
4070 configDef.get = function () { return config; };
4071 {
4072 configDef.set = function () {
4073 warn(
4074 'Do not replace the Vue.config object, set individual fields instead.'
4075 );
4076 };
4077 }
4078 Object.defineProperty(Vue, 'config', configDef);
4079
4080 // exposed util methods.
4081 // NOTE: these are not considered part of the public API - avoid relying on
4082 // them unless you are aware of the risk.
4083 Vue.util = {
4084 warn: warn,
4085 extend: extend,
4086 mergeOptions: mergeOptions,
4087 defineReactive: defineReactive$$1
4088 };
4089
4090 Vue.set = set;
4091 Vue.delete = del;
4092 Vue.nextTick = nextTick;
4093
4094 Vue.options = Object.create(null);
4095 config._assetTypes.forEach(function (type) {
4096 Vue.options[type + 's'] = Object.create(null);
4097 });
4098
4099 // this is used to identify the "base" constructor to extend all plain-object
4100 // components with in Weex's multi-instance scenarios.
4101 Vue.options._base = Vue;
4102
4103 extend(Vue.options.components, builtInComponents);
4104
4105 initUse(Vue);
4106 initMixin$1(Vue);
4107 initExtend(Vue);
4108 initAssetRegisters(Vue);
4109 }
4110
4111 initGlobalAPI(Vue$3);
4112
4113 Object.defineProperty(Vue$3.prototype, '$isServer', {
4114 get: isServerRendering
4115 });
4116
4117 Vue$3.version = '2.2.4';
4118
4119 /* */
4120
4121 // attributes that should be using props for binding
4122 var acceptValue = makeMap('input,textarea,option,select');
4123 var mustUseProp = function (tag, type, attr) {
4124 return (
4125 (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
4126 (attr === 'selected' && tag === 'option') ||
4127 (attr === 'checked' && tag === 'input') ||
4128 (attr === 'muted' && tag === 'video')
4129 )
4130 };
4131
4132 var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
4133
4134 var isBooleanAttr = makeMap(
4135 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
4136 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
4137 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
4138 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
4139 'required,reversed,scoped,seamless,selected,sortable,translate,' +
4140 'truespeed,typemustmatch,visible'
4141 );
4142
4143 var xlinkNS = 'http://www.w3.org/1999/xlink';
4144
4145 var isXlink = function (name) {
4146 return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
4147 };
4148
4149 var getXlinkProp = function (name) {
4150 return isXlink(name) ? name.slice(6, name.length) : ''
4151 };
4152
4153 var isFalsyAttrValue = function (val) {
4154 return val == null || val === false
4155 };
4156
4157 /* */
4158
4159 function genClassForVnode (vnode) {
4160 var data = vnode.data;
4161 var parentNode = vnode;
4162 var childNode = vnode;
4163 while (childNode.componentInstance) {
4164 childNode = childNode.componentInstance._vnode;
4165 if (childNode.data) {
4166 data = mergeClassData(childNode.data, data);
4167 }
4168 }
4169 while ((parentNode = parentNode.parent)) {
4170 if (parentNode.data) {
4171 data = mergeClassData(data, parentNode.data);
4172 }
4173 }
4174 return genClassFromData(data)
4175 }
4176
4177 function mergeClassData (child, parent) {
4178 return {
4179 staticClass: concat(child.staticClass, parent.staticClass),
4180 class: child.class
4181 ? [child.class, parent.class]
4182 : parent.class
4183 }
4184 }
4185
4186 function genClassFromData (data) {
4187 var dynamicClass = data.class;
4188 var staticClass = data.staticClass;
4189 if (staticClass || dynamicClass) {
4190 return concat(staticClass, stringifyClass(dynamicClass))
4191 }
4192 /* istanbul ignore next */
4193 return ''
4194 }
4195
4196 function concat (a, b) {
4197 return a ? b ? (a + ' ' + b) : a : (b || '')
4198 }
4199
4200 function stringifyClass (value) {
4201 var res = '';
4202 if (!value) {
4203 return res
4204 }
4205 if (typeof value === 'string') {
4206 return value
4207 }
4208 if (Array.isArray(value)) {
4209 var stringified;
4210 for (var i = 0, l = value.length; i < l; i++) {
4211 if (value[i]) {
4212 if ((stringified = stringifyClass(value[i]))) {
4213 res += stringified + ' ';
4214 }
4215 }
4216 }
4217 return res.slice(0, -1)
4218 }
4219 if (isObject(value)) {
4220 for (var key in value) {
4221 if (value[key]) { res += key + ' '; }
4222 }
4223 return res.slice(0, -1)
4224 }
4225 /* istanbul ignore next */
4226 return res
4227 }
4228
4229 /* */
4230
4231 var namespaceMap = {
4232 svg: 'http://www.w3.org/2000/svg',
4233 math: 'http://www.w3.org/1998/Math/MathML'
4234 };
4235
4236 var isHTMLTag = makeMap(
4237 'html,body,base,head,link,meta,style,title,' +
4238 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
4239 'div,dd,dl,dt,figcaption,figure,hr,img,li,main,ol,p,pre,ul,' +
4240 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
4241 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
4242 'embed,object,param,source,canvas,script,noscript,del,ins,' +
4243 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
4244 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
4245 'output,progress,select,textarea,' +
4246 'details,dialog,menu,menuitem,summary,' +
4247 'content,element,shadow,template'
4248 );
4249
4250 // this map is intentionally selective, only covering SVG elements that may
4251 // contain child elements.
4252 var isSVG = makeMap(
4253 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
4254 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
4255 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
4256 true
4257 );
4258
4259 var isPreTag = function (tag) { return tag === 'pre'; };
4260
4261 var isReservedTag = function (tag) {
4262 return isHTMLTag(tag) || isSVG(tag)
4263 };
4264
4265 function getTagNamespace (tag) {
4266 if (isSVG(tag)) {
4267 return 'svg'
4268 }
4269 // basic support for MathML
4270 // note it doesn't support other MathML elements being component roots
4271 if (tag === 'math') {
4272 return 'math'
4273 }
4274 }
4275
4276 var unknownElementCache = Object.create(null);
4277 function isUnknownElement (tag) {
4278 /* istanbul ignore if */
4279 if (!inBrowser) {
4280 return true
4281 }
4282 if (isReservedTag(tag)) {
4283 return false
4284 }
4285 tag = tag.toLowerCase();
4286 /* istanbul ignore if */
4287 if (unknownElementCache[tag] != null) {
4288 return unknownElementCache[tag]
4289 }
4290 var el = document.createElement(tag);
4291 if (tag.indexOf('-') > -1) {
4292 // http://stackoverflow.com/a/28210364/1070244
4293 return (unknownElementCache[tag] = (
4294 el.constructor === window.HTMLUnknownElement ||
4295 el.constructor === window.HTMLElement
4296 ))
4297 } else {
4298 return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
4299 }
4300 }
4301
4302 /* */
4303
4304 /**
4305 * Query an element selector if it's not an element already.
4306 */
4307 function query (el) {
4308 if (typeof el === 'string') {
4309 var selected = document.querySelector(el);
4310 if (!selected) {
4311 "development" !== 'production' && warn(
4312 'Cannot find element: ' + el
4313 );
4314 return document.createElement('div')
4315 }
4316 return selected
4317 } else {
4318 return el
4319 }
4320 }
4321
4322 /* */
4323
4324 function createElement$1 (tagName, vnode) {
4325 var elm = document.createElement(tagName);
4326 if (tagName !== 'select') {
4327 return elm
4328 }
4329 // false or null will remove the attribute but undefined will not
4330 if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
4331 elm.setAttribute('multiple', 'multiple');
4332 }
4333 return elm
4334 }
4335
4336 function createElementNS (namespace, tagName) {
4337 return document.createElementNS(namespaceMap[namespace], tagName)
4338 }
4339
4340 function createTextNode (text) {
4341 return document.createTextNode(text)
4342 }
4343
4344 function createComment (text) {
4345 return document.createComment(text)
4346 }
4347
4348 function insertBefore (parentNode, newNode, referenceNode) {
4349 parentNode.insertBefore(newNode, referenceNode);
4350 }
4351
4352 function removeChild (node, child) {
4353 node.removeChild(child);
4354 }
4355
4356 function appendChild (node, child) {
4357 node.appendChild(child);
4358 }
4359
4360 function parentNode (node) {
4361 return node.parentNode
4362 }
4363
4364 function nextSibling (node) {
4365 return node.nextSibling
4366 }
4367
4368 function tagName (node) {
4369 return node.tagName
4370 }
4371
4372 function setTextContent (node, text) {
4373 node.textContent = text;
4374 }
4375
4376 function setAttribute (node, key, val) {
4377 node.setAttribute(key, val);
4378 }
4379
4380
4381 var nodeOps = Object.freeze({
4382 createElement: createElement$1,
4383 createElementNS: createElementNS,
4384 createTextNode: createTextNode,
4385 createComment: createComment,
4386 insertBefore: insertBefore,
4387 removeChild: removeChild,
4388 appendChild: appendChild,
4389 parentNode: parentNode,
4390 nextSibling: nextSibling,
4391 tagName: tagName,
4392 setTextContent: setTextContent,
4393 setAttribute: setAttribute
4394 });
4395
4396 /* */
4397
4398 var ref = {
4399 create: function create (_, vnode) {
4400 registerRef(vnode);
4401 },
4402 update: function update (oldVnode, vnode) {
4403 if (oldVnode.data.ref !== vnode.data.ref) {
4404 registerRef(oldVnode, true);
4405 registerRef(vnode);
4406 }
4407 },
4408 destroy: function destroy (vnode) {
4409 registerRef(vnode, true);
4410 }
4411 };
4412
4413 function registerRef (vnode, isRemoval) {
4414 var key = vnode.data.ref;
4415 if (!key) { return }
4416
4417 var vm = vnode.context;
4418 var ref = vnode.componentInstance || vnode.elm;
4419 var refs = vm.$refs;
4420 if (isRemoval) {
4421 if (Array.isArray(refs[key])) {
4422 remove(refs[key], ref);
4423 } else if (refs[key] === ref) {
4424 refs[key] = undefined;
4425 }
4426 } else {
4427 if (vnode.data.refInFor) {
4428 if (Array.isArray(refs[key]) && refs[key].indexOf(ref) < 0) {
4429 refs[key].push(ref);
4430 } else {
4431 refs[key] = [ref];
4432 }
4433 } else {
4434 refs[key] = ref;
4435 }
4436 }
4437 }
4438
4439 /**
4440 * Virtual DOM patching algorithm based on Snabbdom by
4441 * Simon Friis Vindum (@paldepind)
4442 * Licensed under the MIT License
4443 * https://github.com/paldepind/snabbdom/blob/master/LICENSE
4444 *
4445 * modified by Evan You (@yyx990803)
4446 *
4447
4448 /*
4449 * Not type-checking this because this file is perf-critical and the cost
4450 * of making flow understand it is not worth it.
4451 */
4452
4453 var emptyNode = new VNode('', {}, []);
4454
4455 var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
4456
4457 function isUndef (s) {
4458 return s == null
4459 }
4460
4461 function isDef (s) {
4462 return s != null
4463 }
4464
4465 function sameVnode (vnode1, vnode2) {
4466 return (
4467 vnode1.key === vnode2.key &&
4468 vnode1.tag === vnode2.tag &&
4469 vnode1.isComment === vnode2.isComment &&
4470 !vnode1.data === !vnode2.data
4471 )
4472 }
4473
4474 function createKeyToOldIdx (children, beginIdx, endIdx) {
4475 var i, key;
4476 var map = {};
4477 for (i = beginIdx; i <= endIdx; ++i) {
4478 key = children[i].key;
4479 if (isDef(key)) { map[key] = i; }
4480 }
4481 return map
4482 }
4483
4484 function createPatchFunction (backend) {
4485 var i, j;
4486 var cbs = {};
4487
4488 var modules = backend.modules;
4489 var nodeOps = backend.nodeOps;
4490
4491 for (i = 0; i < hooks.length; ++i) {
4492 cbs[hooks[i]] = [];
4493 for (j = 0; j < modules.length; ++j) {
4494 if (modules[j][hooks[i]] !== undefined) { cbs[hooks[i]].push(modules[j][hooks[i]]); }
4495 }
4496 }
4497
4498 function emptyNodeAt (elm) {
4499 return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
4500 }
4501
4502 function createRmCb (childElm, listeners) {
4503 function remove$$1 () {
4504 if (--remove$$1.listeners === 0) {
4505 removeNode(childElm);
4506 }
4507 }
4508 remove$$1.listeners = listeners;
4509 return remove$$1
4510 }
4511
4512 function removeNode (el) {
4513 var parent = nodeOps.parentNode(el);
4514 // element may have already been removed due to v-html / v-text
4515 if (parent) {
4516 nodeOps.removeChild(parent, el);
4517 }
4518 }
4519
4520 var inPre = 0;
4521 function createElm (vnode, insertedVnodeQueue, parentElm, refElm, nested) {
4522 vnode.isRootInsert = !nested; // for transition enter check
4523 if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
4524 return
4525 }
4526
4527 var data = vnode.data;
4528 var children = vnode.children;
4529 var tag = vnode.tag;
4530 if (isDef(tag)) {
4531 {
4532 if (data && data.pre) {
4533 inPre++;
4534 }
4535 if (
4536 !inPre &&
4537 !vnode.ns &&
4538 !(config.ignoredElements.length && config.ignoredElements.indexOf(tag) > -1) &&
4539 config.isUnknownElement(tag)
4540 ) {
4541 warn(
4542 'Unknown custom element: <' + tag + '> - did you ' +
4543 'register the component correctly? For recursive components, ' +
4544 'make sure to provide the "name" option.',
4545 vnode.context
4546 );
4547 }
4548 }
4549 vnode.elm = vnode.ns
4550 ? nodeOps.createElementNS(vnode.ns, tag)
4551 : nodeOps.createElement(tag, vnode);
4552 setScope(vnode);
4553
4554 /* istanbul ignore if */
4555 {
4556 createChildren(vnode, children, insertedVnodeQueue);
4557 if (isDef(data)) {
4558 invokeCreateHooks(vnode, insertedVnodeQueue);
4559 }
4560 insert(parentElm, vnode.elm, refElm);
4561 }
4562
4563 if ("development" !== 'production' && data && data.pre) {
4564 inPre--;
4565 }
4566 } else if (vnode.isComment) {
4567 vnode.elm = nodeOps.createComment(vnode.text);
4568 insert(parentElm, vnode.elm, refElm);
4569 } else {
4570 vnode.elm = nodeOps.createTextNode(vnode.text);
4571 insert(parentElm, vnode.elm, refElm);
4572 }
4573 }
4574
4575 function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
4576 var i = vnode.data;
4577 if (isDef(i)) {
4578 var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
4579 if (isDef(i = i.hook) && isDef(i = i.init)) {
4580 i(vnode, false /* hydrating */, parentElm, refElm);
4581 }
4582 // after calling the init hook, if the vnode is a child component
4583 // it should've created a child instance and mounted it. the child
4584 // component also has set the placeholder vnode's elm.
4585 // in that case we can just return the element and be done.
4586 if (isDef(vnode.componentInstance)) {
4587 initComponent(vnode, insertedVnodeQueue);
4588 if (isReactivated) {
4589 reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
4590 }
4591 return true
4592 }
4593 }
4594 }
4595
4596 function initComponent (vnode, insertedVnodeQueue) {
4597 if (vnode.data.pendingInsert) {
4598 insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
4599 }
4600 vnode.elm = vnode.componentInstance.$el;
4601 if (isPatchable(vnode)) {
4602 invokeCreateHooks(vnode, insertedVnodeQueue);
4603 setScope(vnode);
4604 } else {
4605 // empty component root.
4606 // skip all element-related modules except for ref (#3455)
4607 registerRef(vnode);
4608 // make sure to invoke the insert hook
4609 insertedVnodeQueue.push(vnode);
4610 }
4611 }
4612
4613 function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
4614 var i;
4615 // hack for #4339: a reactivated component with inner transition
4616 // does not trigger because the inner node's created hooks are not called
4617 // again. It's not ideal to involve module-specific logic in here but
4618 // there doesn't seem to be a better way to do it.
4619 var innerNode = vnode;
4620 while (innerNode.componentInstance) {
4621 innerNode = innerNode.componentInstance._vnode;
4622 if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
4623 for (i = 0; i < cbs.activate.length; ++i) {
4624 cbs.activate[i](emptyNode, innerNode);
4625 }
4626 insertedVnodeQueue.push(innerNode);
4627 break
4628 }
4629 }
4630 // unlike a newly created component,
4631 // a reactivated keep-alive component doesn't insert itself
4632 insert(parentElm, vnode.elm, refElm);
4633 }
4634
4635 function insert (parent, elm, ref) {
4636 if (parent) {
4637 if (ref) {
4638 nodeOps.insertBefore(parent, elm, ref);
4639 } else {
4640 nodeOps.appendChild(parent, elm);
4641 }
4642 }
4643 }
4644
4645 function createChildren (vnode, children, insertedVnodeQueue) {
4646 if (Array.isArray(children)) {
4647 for (var i = 0; i < children.length; ++i) {
4648 createElm(children[i], insertedVnodeQueue, vnode.elm, null, true);
4649 }
4650 } else if (isPrimitive(vnode.text)) {
4651 nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text));
4652 }
4653 }
4654
4655 function isPatchable (vnode) {
4656 while (vnode.componentInstance) {
4657 vnode = vnode.componentInstance._vnode;
4658 }
4659 return isDef(vnode.tag)
4660 }
4661
4662 function invokeCreateHooks (vnode, insertedVnodeQueue) {
4663 for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
4664 cbs.create[i$1](emptyNode, vnode);
4665 }
4666 i = vnode.data.hook; // Reuse variable
4667 if (isDef(i)) {
4668 if (i.create) { i.create(emptyNode, vnode); }
4669 if (i.insert) { insertedVnodeQueue.push(vnode); }
4670 }
4671 }
4672
4673 // set scope id attribute for scoped CSS.
4674 // this is implemented as a special case to avoid the overhead
4675 // of going through the normal attribute patching process.
4676 function setScope (vnode) {
4677 var i;
4678 var ancestor = vnode;
4679 while (ancestor) {
4680 if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
4681 nodeOps.setAttribute(vnode.elm, i, '');
4682 }
4683 ancestor = ancestor.parent;
4684 }
4685 // for slot content they should also get the scopeId from the host instance.
4686 if (isDef(i = activeInstance) &&
4687 i !== vnode.context &&
4688 isDef(i = i.$options._scopeId)) {
4689 nodeOps.setAttribute(vnode.elm, i, '');
4690 }
4691 }
4692
4693 function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
4694 for (; startIdx <= endIdx; ++startIdx) {
4695 createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm);
4696 }
4697 }
4698
4699 function invokeDestroyHook (vnode) {
4700 var i, j;
4701 var data = vnode.data;
4702 if (isDef(data)) {
4703 if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
4704 for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
4705 }
4706 if (isDef(i = vnode.children)) {
4707 for (j = 0; j < vnode.children.length; ++j) {
4708 invokeDestroyHook(vnode.children[j]);
4709 }
4710 }
4711 }
4712
4713 function removeVnodes (parentElm, vnodes, startIdx, endIdx) {
4714 for (; startIdx <= endIdx; ++startIdx) {
4715 var ch = vnodes[startIdx];
4716 if (isDef(ch)) {
4717 if (isDef(ch.tag)) {
4718 removeAndInvokeRemoveHook(ch);
4719 invokeDestroyHook(ch);
4720 } else { // Text node
4721 removeNode(ch.elm);
4722 }
4723 }
4724 }
4725 }
4726
4727 function removeAndInvokeRemoveHook (vnode, rm) {
4728 if (rm || isDef(vnode.data)) {
4729 var listeners = cbs.remove.length + 1;
4730 if (!rm) {
4731 // directly removing
4732 rm = createRmCb(vnode.elm, listeners);
4733 } else {
4734 // we have a recursively passed down rm callback
4735 // increase the listeners count
4736 rm.listeners += listeners;
4737 }
4738 // recursively invoke hooks on child component root node
4739 if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
4740 removeAndInvokeRemoveHook(i, rm);
4741 }
4742 for (i = 0; i < cbs.remove.length; ++i) {
4743 cbs.remove[i](vnode, rm);
4744 }
4745 if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
4746 i(vnode, rm);
4747 } else {
4748 rm();
4749 }
4750 } else {
4751 removeNode(vnode.elm);
4752 }
4753 }
4754
4755 function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
4756 var oldStartIdx = 0;
4757 var newStartIdx = 0;
4758 var oldEndIdx = oldCh.length - 1;
4759 var oldStartVnode = oldCh[0];
4760 var oldEndVnode = oldCh[oldEndIdx];
4761 var newEndIdx = newCh.length - 1;
4762 var newStartVnode = newCh[0];
4763 var newEndVnode = newCh[newEndIdx];
4764 var oldKeyToIdx, idxInOld, elmToMove, refElm;
4765
4766 // removeOnly is a special flag used only by <transition-group>
4767 // to ensure removed elements stay in correct relative positions
4768 // during leaving transitions
4769 var canMove = !removeOnly;
4770
4771 while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
4772 if (isUndef(oldStartVnode)) {
4773 oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
4774 } else if (isUndef(oldEndVnode)) {
4775 oldEndVnode = oldCh[--oldEndIdx];
4776 } else if (sameVnode(oldStartVnode, newStartVnode)) {
4777 patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue);
4778 oldStartVnode = oldCh[++oldStartIdx];
4779 newStartVnode = newCh[++newStartIdx];
4780 } else if (sameVnode(oldEndVnode, newEndVnode)) {
4781 patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue);
4782 oldEndVnode = oldCh[--oldEndIdx];
4783 newEndVnode = newCh[--newEndIdx];
4784 } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
4785 patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue);
4786 canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
4787 oldStartVnode = oldCh[++oldStartIdx];
4788 newEndVnode = newCh[--newEndIdx];
4789 } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
4790 patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue);
4791 canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
4792 oldEndVnode = oldCh[--oldEndIdx];
4793 newStartVnode = newCh[++newStartIdx];
4794 } else {
4795 if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
4796 idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
4797 if (isUndef(idxInOld)) { // New element
4798 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
4799 newStartVnode = newCh[++newStartIdx];
4800 } else {
4801 elmToMove = oldCh[idxInOld];
4802 /* istanbul ignore if */
4803 if ("development" !== 'production' && !elmToMove) {
4804 warn(
4805 'It seems there are duplicate keys that is causing an update error. ' +
4806 'Make sure each v-for item has a unique key.'
4807 );
4808 }
4809 if (sameVnode(elmToMove, newStartVnode)) {
4810 patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
4811 oldCh[idxInOld] = undefined;
4812 canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm);
4813 newStartVnode = newCh[++newStartIdx];
4814 } else {
4815 // same key but different element. treat as new element
4816 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
4817 newStartVnode = newCh[++newStartIdx];
4818 }
4819 }
4820 }
4821 }
4822 if (oldStartIdx > oldEndIdx) {
4823 refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
4824 addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
4825 } else if (newStartIdx > newEndIdx) {
4826 removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
4827 }
4828 }
4829
4830 function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
4831 if (oldVnode === vnode) {
4832 return
4833 }
4834 // reuse element for static trees.
4835 // note we only do this if the vnode is cloned -
4836 // if the new node is not cloned it means the render functions have been
4837 // reset by the hot-reload-api and we need to do a proper re-render.
4838 if (vnode.isStatic &&
4839 oldVnode.isStatic &&
4840 vnode.key === oldVnode.key &&
4841 (vnode.isCloned || vnode.isOnce)) {
4842 vnode.elm = oldVnode.elm;
4843 vnode.componentInstance = oldVnode.componentInstance;
4844 return
4845 }
4846 var i;
4847 var data = vnode.data;
4848 var hasData = isDef(data);
4849 if (hasData && isDef(i = data.hook) && isDef(i = i.prepatch)) {
4850 i(oldVnode, vnode);
4851 }
4852 var elm = vnode.elm = oldVnode.elm;
4853 var oldCh = oldVnode.children;
4854 var ch = vnode.children;
4855 if (hasData && isPatchable(vnode)) {
4856 for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
4857 if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
4858 }
4859 if (isUndef(vnode.text)) {
4860 if (isDef(oldCh) && isDef(ch)) {
4861 if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
4862 } else if (isDef(ch)) {
4863 if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
4864 addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
4865 } else if (isDef(oldCh)) {
4866 removeVnodes(elm, oldCh, 0, oldCh.length - 1);
4867 } else if (isDef(oldVnode.text)) {
4868 nodeOps.setTextContent(elm, '');
4869 }
4870 } else if (oldVnode.text !== vnode.text) {
4871 nodeOps.setTextContent(elm, vnode.text);
4872 }
4873 if (hasData) {
4874 if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
4875 }
4876 }
4877
4878 function invokeInsertHook (vnode, queue, initial) {
4879 // delay insert hooks for component root nodes, invoke them after the
4880 // element is really inserted
4881 if (initial && vnode.parent) {
4882 vnode.parent.data.pendingInsert = queue;
4883 } else {
4884 for (var i = 0; i < queue.length; ++i) {
4885 queue[i].data.hook.insert(queue[i]);
4886 }
4887 }
4888 }
4889
4890 var bailed = false;
4891 // list of modules that can skip create hook during hydration because they
4892 // are already rendered on the client or has no need for initialization
4893 var isRenderedModule = makeMap('attrs,style,class,staticClass,staticStyle,key');
4894
4895 // Note: this is a browser-only function so we can assume elms are DOM nodes.
4896 function hydrate (elm, vnode, insertedVnodeQueue) {
4897 {
4898 if (!assertNodeMatch(elm, vnode)) {
4899 return false
4900 }
4901 }
4902 vnode.elm = elm;
4903 var tag = vnode.tag;
4904 var data = vnode.data;
4905 var children = vnode.children;
4906 if (isDef(data)) {
4907 if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
4908 if (isDef(i = vnode.componentInstance)) {
4909 // child component. it should have hydrated its own tree.
4910 initComponent(vnode, insertedVnodeQueue);
4911 return true
4912 }
4913 }
4914 if (isDef(tag)) {
4915 if (isDef(children)) {
4916 // empty element, allow client to pick up and populate children
4917 if (!elm.hasChildNodes()) {
4918 createChildren(vnode, children, insertedVnodeQueue);
4919 } else {
4920 var childrenMatch = true;
4921 var childNode = elm.firstChild;
4922 for (var i$1 = 0; i$1 < children.length; i$1++) {
4923 if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
4924 childrenMatch = false;
4925 break
4926 }
4927 childNode = childNode.nextSibling;
4928 }
4929 // if childNode is not null, it means the actual childNodes list is
4930 // longer than the virtual children list.
4931 if (!childrenMatch || childNode) {
4932 if ("development" !== 'production' &&
4933 typeof console !== 'undefined' &&
4934 !bailed) {
4935 bailed = true;
4936 console.warn('Parent: ', elm);
4937 console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
4938 }
4939 return false
4940 }
4941 }
4942 }
4943 if (isDef(data)) {
4944 for (var key in data) {
4945 if (!isRenderedModule(key)) {
4946 invokeCreateHooks(vnode, insertedVnodeQueue);
4947 break
4948 }
4949 }
4950 }
4951 } else if (elm.data !== vnode.text) {
4952 elm.data = vnode.text;
4953 }
4954 return true
4955 }
4956
4957 function assertNodeMatch (node, vnode) {
4958 if (vnode.tag) {
4959 return (
4960 vnode.tag.indexOf('vue-component') === 0 ||
4961 vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
4962 )
4963 } else {
4964 return node.nodeType === (vnode.isComment ? 8 : 3)
4965 }
4966 }
4967
4968 return function patch (oldVnode, vnode, hydrating, removeOnly, parentElm, refElm) {
4969 if (!vnode) {
4970 if (oldVnode) { invokeDestroyHook(oldVnode); }
4971 return
4972 }
4973
4974 var isInitialPatch = false;
4975 var insertedVnodeQueue = [];
4976
4977 if (!oldVnode) {
4978 // empty mount (likely as component), create new root element
4979 isInitialPatch = true;
4980 createElm(vnode, insertedVnodeQueue, parentElm, refElm);
4981 } else {
4982 var isRealElement = isDef(oldVnode.nodeType);
4983 if (!isRealElement && sameVnode(oldVnode, vnode)) {
4984 // patch existing root node
4985 patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly);
4986 } else {
4987 if (isRealElement) {
4988 // mounting to a real element
4989 // check if this is server-rendered content and if we can perform
4990 // a successful hydration.
4991 if (oldVnode.nodeType === 1 && oldVnode.hasAttribute('server-rendered')) {
4992 oldVnode.removeAttribute('server-rendered');
4993 hydrating = true;
4994 }
4995 if (hydrating) {
4996 if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
4997 invokeInsertHook(vnode, insertedVnodeQueue, true);
4998 return oldVnode
4999 } else {
5000 warn(
5001 'The client-side rendered virtual DOM tree is not matching ' +
5002 'server-rendered content. This is likely caused by incorrect ' +
5003 'HTML markup, for example nesting block-level elements inside ' +
5004 '<p>, or missing <tbody>. Bailing hydration and performing ' +
5005 'full client-side render.'
5006 );
5007 }
5008 }
5009 // either not server-rendered, or hydration failed.
5010 // create an empty node and replace it
5011 oldVnode = emptyNodeAt(oldVnode);
5012 }
5013 // replacing existing element
5014 var oldElm = oldVnode.elm;
5015 var parentElm$1 = nodeOps.parentNode(oldElm);
5016 createElm(
5017 vnode,
5018 insertedVnodeQueue,
5019 // extremely rare edge case: do not insert if old element is in a
5020 // leaving transition. Only happens when combining transition +
5021 // keep-alive + HOCs. (#4590)
5022 oldElm._leaveCb ? null : parentElm$1,
5023 nodeOps.nextSibling(oldElm)
5024 );
5025
5026 if (vnode.parent) {
5027 // component root element replaced.
5028 // update parent placeholder node element, recursively
5029 var ancestor = vnode.parent;
5030 while (ancestor) {
5031 ancestor.elm = vnode.elm;
5032 ancestor = ancestor.parent;
5033 }
5034 if (isPatchable(vnode)) {
5035 for (var i = 0; i < cbs.create.length; ++i) {
5036 cbs.create[i](emptyNode, vnode.parent);
5037 }
5038 }
5039 }
5040
5041 if (parentElm$1 !== null) {
5042 removeVnodes(parentElm$1, [oldVnode], 0, 0);
5043 } else if (isDef(oldVnode.tag)) {
5044 invokeDestroyHook(oldVnode);
5045 }
5046 }
5047 }
5048
5049 invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
5050 return vnode.elm
5051 }
5052 }
5053
5054 /* */
5055
5056 var directives = {
5057 create: updateDirectives,
5058 update: updateDirectives,
5059 destroy: function unbindDirectives (vnode) {
5060 updateDirectives(vnode, emptyNode);
5061 }
5062 };
5063
5064 function updateDirectives (oldVnode, vnode) {
5065 if (oldVnode.data.directives || vnode.data.directives) {
5066 _update(oldVnode, vnode);
5067 }
5068 }
5069
5070 function _update (oldVnode, vnode) {
5071 var isCreate = oldVnode === emptyNode;
5072 var isDestroy = vnode === emptyNode;
5073 var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
5074 var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
5075
5076 var dirsWithInsert = [];
5077 var dirsWithPostpatch = [];
5078
5079 var key, oldDir, dir;
5080 for (key in newDirs) {
5081 oldDir = oldDirs[key];
5082 dir = newDirs[key];
5083 if (!oldDir) {
5084 // new directive, bind
5085 callHook$1(dir, 'bind', vnode, oldVnode);
5086 if (dir.def && dir.def.inserted) {
5087 dirsWithInsert.push(dir);
5088 }
5089 } else {
5090 // existing directive, update
5091 dir.oldValue = oldDir.value;
5092 callHook$1(dir, 'update', vnode, oldVnode);
5093 if (dir.def && dir.def.componentUpdated) {
5094 dirsWithPostpatch.push(dir);
5095 }
5096 }
5097 }
5098
5099 if (dirsWithInsert.length) {
5100 var callInsert = function () {
5101 for (var i = 0; i < dirsWithInsert.length; i++) {
5102 callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
5103 }
5104 };
5105 if (isCreate) {
5106 mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert);
5107 } else {
5108 callInsert();
5109 }
5110 }
5111
5112 if (dirsWithPostpatch.length) {
5113 mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', function () {
5114 for (var i = 0; i < dirsWithPostpatch.length; i++) {
5115 callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
5116 }
5117 });
5118 }
5119
5120 if (!isCreate) {
5121 for (key in oldDirs) {
5122 if (!newDirs[key]) {
5123 // no longer present, unbind
5124 callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
5125 }
5126 }
5127 }
5128 }
5129
5130 var emptyModifiers = Object.create(null);
5131
5132 function normalizeDirectives$1 (
5133 dirs,
5134 vm
5135 ) {
5136 var res = Object.create(null);
5137 if (!dirs) {
5138 return res
5139 }
5140 var i, dir;
5141 for (i = 0; i < dirs.length; i++) {
5142 dir = dirs[i];
5143 if (!dir.modifiers) {
5144 dir.modifiers = emptyModifiers;
5145 }
5146 res[getRawDirName(dir)] = dir;
5147 dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
5148 }
5149 return res
5150 }
5151
5152 function getRawDirName (dir) {
5153 return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
5154 }
5155
5156 function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
5157 var fn = dir.def && dir.def[hook];
5158 if (fn) {
5159 fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
5160 }
5161 }
5162
5163 var baseModules = [
5164 ref,
5165 directives
5166 ];
5167
5168 /* */
5169
5170 function updateAttrs (oldVnode, vnode) {
5171 if (!oldVnode.data.attrs && !vnode.data.attrs) {
5172 return
5173 }
5174 var key, cur, old;
5175 var elm = vnode.elm;
5176 var oldAttrs = oldVnode.data.attrs || {};
5177 var attrs = vnode.data.attrs || {};
5178 // clone observed objects, as the user probably wants to mutate it
5179 if (attrs.__ob__) {
5180 attrs = vnode.data.attrs = extend({}, attrs);
5181 }
5182
5183 for (key in attrs) {
5184 cur = attrs[key];
5185 old = oldAttrs[key];
5186 if (old !== cur) {
5187 setAttr(elm, key, cur);
5188 }
5189 }
5190 // #4391: in IE9, setting type can reset value for input[type=radio]
5191 /* istanbul ignore if */
5192 if (isIE9 && attrs.value !== oldAttrs.value) {
5193 setAttr(elm, 'value', attrs.value);
5194 }
5195 for (key in oldAttrs) {
5196 if (attrs[key] == null) {
5197 if (isXlink(key)) {
5198 elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
5199 } else if (!isEnumeratedAttr(key)) {
5200 elm.removeAttribute(key);
5201 }
5202 }
5203 }
5204 }
5205
5206 function setAttr (el, key, value) {
5207 if (isBooleanAttr(key)) {
5208 // set attribute for blank value
5209 // e.g. <option disabled>Select one</option>
5210 if (isFalsyAttrValue(value)) {
5211 el.removeAttribute(key);
5212 } else {
5213 el.setAttribute(key, key);
5214 }
5215 } else if (isEnumeratedAttr(key)) {
5216 el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
5217 } else if (isXlink(key)) {
5218 if (isFalsyAttrValue(value)) {
5219 el.removeAttributeNS(xlinkNS, getXlinkProp(key));
5220 } else {
5221 el.setAttributeNS(xlinkNS, key, value);
5222 }
5223 } else {
5224 if (isFalsyAttrValue(value)) {
5225 el.removeAttribute(key);
5226 } else {
5227 el.setAttribute(key, value);
5228 }
5229 }
5230 }
5231
5232 var attrs = {
5233 create: updateAttrs,
5234 update: updateAttrs
5235 };
5236
5237 /* */
5238
5239 function updateClass (oldVnode, vnode) {
5240 var el = vnode.elm;
5241 var data = vnode.data;
5242 var oldData = oldVnode.data;
5243 if (!data.staticClass && !data.class &&
5244 (!oldData || (!oldData.staticClass && !oldData.class))) {
5245 return
5246 }
5247
5248 var cls = genClassForVnode(vnode);
5249
5250 // handle transition classes
5251 var transitionClass = el._transitionClasses;
5252 if (transitionClass) {
5253 cls = concat(cls, stringifyClass(transitionClass));
5254 }
5255
5256 // set the class
5257 if (cls !== el._prevClass) {
5258 el.setAttribute('class', cls);
5259 el._prevClass = cls;
5260 }
5261 }
5262
5263 var klass = {
5264 create: updateClass,
5265 update: updateClass
5266 };
5267
5268 /* */
5269
5270 var validDivisionCharRE = /[\w).+\-_$\]]/;
5271
5272 function parseFilters (exp) {
5273 var inSingle = false;
5274 var inDouble = false;
5275 var inTemplateString = false;
5276 var inRegex = false;
5277 var curly = 0;
5278 var square = 0;
5279 var paren = 0;
5280 var lastFilterIndex = 0;
5281 var c, prev, i, expression, filters;
5282
5283 for (i = 0; i < exp.length; i++) {
5284 prev = c;
5285 c = exp.charCodeAt(i);
5286 if (inSingle) {
5287 if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
5288 } else if (inDouble) {
5289 if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
5290 } else if (inTemplateString) {
5291 if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
5292 } else if (inRegex) {
5293 if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
5294 } else if (
5295 c === 0x7C && // pipe
5296 exp.charCodeAt(i + 1) !== 0x7C &&
5297 exp.charCodeAt(i - 1) !== 0x7C &&
5298 !curly && !square && !paren
5299 ) {
5300 if (expression === undefined) {
5301 // first filter, end of expression
5302 lastFilterIndex = i + 1;
5303 expression = exp.slice(0, i).trim();
5304 } else {
5305 pushFilter();
5306 }
5307 } else {
5308 switch (c) {
5309 case 0x22: inDouble = true; break // "
5310 case 0x27: inSingle = true; break // '
5311 case 0x60: inTemplateString = true; break // `
5312 case 0x28: paren++; break // (
5313 case 0x29: paren--; break // )
5314 case 0x5B: square++; break // [
5315 case 0x5D: square--; break // ]
5316 case 0x7B: curly++; break // {
5317 case 0x7D: curly--; break // }
5318 }
5319 if (c === 0x2f) { // /
5320 var j = i - 1;
5321 var p = (void 0);
5322 // find first non-whitespace prev char
5323 for (; j >= 0; j--) {
5324 p = exp.charAt(j);
5325 if (p !== ' ') { break }
5326 }
5327 if (!p || !validDivisionCharRE.test(p)) {
5328 inRegex = true;
5329 }
5330 }
5331 }
5332 }
5333
5334 if (expression === undefined) {
5335 expression = exp.slice(0, i).trim();
5336 } else if (lastFilterIndex !== 0) {
5337 pushFilter();
5338 }
5339
5340 function pushFilter () {
5341 (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
5342 lastFilterIndex = i + 1;
5343 }
5344
5345 if (filters) {
5346 for (i = 0; i < filters.length; i++) {
5347 expression = wrapFilter(expression, filters[i]);
5348 }
5349 }
5350
5351 return expression
5352 }
5353
5354 function wrapFilter (exp, filter) {
5355 var i = filter.indexOf('(');
5356 if (i < 0) {
5357 // _f: resolveFilter
5358 return ("_f(\"" + filter + "\")(" + exp + ")")
5359 } else {
5360 var name = filter.slice(0, i);
5361 var args = filter.slice(i + 1);
5362 return ("_f(\"" + name + "\")(" + exp + "," + args)
5363 }
5364 }
5365
5366 /* */
5367
5368 function baseWarn (msg) {
5369 console.error(("[Vue compiler]: " + msg));
5370 }
5371
5372 function pluckModuleFunction (
5373 modules,
5374 key
5375 ) {
5376 return modules
5377 ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
5378 : []
5379 }
5380
5381 function addProp (el, name, value) {
5382 (el.props || (el.props = [])).push({ name: name, value: value });
5383 }
5384
5385 function addAttr (el, name, value) {
5386 (el.attrs || (el.attrs = [])).push({ name: name, value: value });
5387 }
5388
5389 function addDirective (
5390 el,
5391 name,
5392 rawName,
5393 value,
5394 arg,
5395 modifiers
5396 ) {
5397 (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
5398 }
5399
5400 function addHandler (
5401 el,
5402 name,
5403 value,
5404 modifiers,
5405 important
5406 ) {
5407 // check capture modifier
5408 if (modifiers && modifiers.capture) {
5409 delete modifiers.capture;
5410 name = '!' + name; // mark the event as captured
5411 }
5412 if (modifiers && modifiers.once) {
5413 delete modifiers.once;
5414 name = '~' + name; // mark the event as once
5415 }
5416 var events;
5417 if (modifiers && modifiers.native) {
5418 delete modifiers.native;
5419 events = el.nativeEvents || (el.nativeEvents = {});
5420 } else {
5421 events = el.events || (el.events = {});
5422 }
5423 var newHandler = { value: value, modifiers: modifiers };
5424 var handlers = events[name];
5425 /* istanbul ignore if */
5426 if (Array.isArray(handlers)) {
5427 important ? handlers.unshift(newHandler) : handlers.push(newHandler);
5428 } else if (handlers) {
5429 events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
5430 } else {
5431 events[name] = newHandler;
5432 }
5433 }
5434
5435 function getBindingAttr (
5436 el,
5437 name,
5438 getStatic
5439 ) {
5440 var dynamicValue =
5441 getAndRemoveAttr(el, ':' + name) ||
5442 getAndRemoveAttr(el, 'v-bind:' + name);
5443 if (dynamicValue != null) {
5444 return parseFilters(dynamicValue)
5445 } else if (getStatic !== false) {
5446 var staticValue = getAndRemoveAttr(el, name);
5447 if (staticValue != null) {
5448 return JSON.stringify(staticValue)
5449 }
5450 }
5451 }
5452
5453 function getAndRemoveAttr (el, name) {
5454 var val;
5455 if ((val = el.attrsMap[name]) != null) {
5456 var list = el.attrsList;
5457 for (var i = 0, l = list.length; i < l; i++) {
5458 if (list[i].name === name) {
5459 list.splice(i, 1);
5460 break
5461 }
5462 }
5463 }
5464 return val
5465 }
5466
5467 /* */
5468
5469 /**
5470 * Cross-platform code generation for component v-model
5471 */
5472 function genComponentModel (
5473 el,
5474 value,
5475 modifiers
5476 ) {
5477 var ref = modifiers || {};
5478 var number = ref.number;
5479 var trim = ref.trim;
5480
5481 var baseValueExpression = '$$v';
5482 var valueExpression = baseValueExpression;
5483 if (trim) {
5484 valueExpression =
5485 "(typeof " + baseValueExpression + " === 'string'" +
5486 "? " + baseValueExpression + ".trim()" +
5487 ": " + baseValueExpression + ")";
5488 }
5489 if (number) {
5490 valueExpression = "_n(" + valueExpression + ")";
5491 }
5492 var assignment = genAssignmentCode(value, valueExpression);
5493
5494 el.model = {
5495 value: ("(" + value + ")"),
5496 expression: ("\"" + value + "\""),
5497 callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
5498 };
5499 }
5500
5501 /**
5502 * Cross-platform codegen helper for generating v-model value assignment code.
5503 */
5504 function genAssignmentCode (
5505 value,
5506 assignment
5507 ) {
5508 var modelRs = parseModel(value);
5509 if (modelRs.idx === null) {
5510 return (value + "=" + assignment)
5511 } else {
5512 return "var $$exp = " + (modelRs.exp) + ", $$idx = " + (modelRs.idx) + ";" +
5513 "if (!Array.isArray($$exp)){" +
5514 value + "=" + assignment + "}" +
5515 "else{$$exp.splice($$idx, 1, " + assignment + ")}"
5516 }
5517 }
5518
5519 /**
5520 * parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
5521 *
5522 * for loop possible cases:
5523 *
5524 * - test
5525 * - test[idx]
5526 * - test[test1[idx]]
5527 * - test["a"][idx]
5528 * - xxx.test[a[a].test1[idx]]
5529 * - test.xxx.a["asa"][test1[idx]]
5530 *
5531 */
5532
5533 var len;
5534 var str;
5535 var chr;
5536 var index$1;
5537 var expressionPos;
5538 var expressionEndPos;
5539
5540 function parseModel (val) {
5541 str = val;
5542 len = str.length;
5543 index$1 = expressionPos = expressionEndPos = 0;
5544
5545 if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
5546 return {
5547 exp: val,
5548 idx: null
5549 }
5550 }
5551
5552 while (!eof()) {
5553 chr = next();
5554 /* istanbul ignore if */
5555 if (isStringStart(chr)) {
5556 parseString(chr);
5557 } else if (chr === 0x5B) {
5558 parseBracket(chr);
5559 }
5560 }
5561
5562 return {
5563 exp: val.substring(0, expressionPos),
5564 idx: val.substring(expressionPos + 1, expressionEndPos)
5565 }
5566 }
5567
5568 function next () {
5569 return str.charCodeAt(++index$1)
5570 }
5571
5572 function eof () {
5573 return index$1 >= len
5574 }
5575
5576 function isStringStart (chr) {
5577 return chr === 0x22 || chr === 0x27
5578 }
5579
5580 function parseBracket (chr) {
5581 var inBracket = 1;
5582 expressionPos = index$1;
5583 while (!eof()) {
5584 chr = next();
5585 if (isStringStart(chr)) {
5586 parseString(chr);
5587 continue
5588 }
5589 if (chr === 0x5B) { inBracket++; }
5590 if (chr === 0x5D) { inBracket--; }
5591 if (inBracket === 0) {
5592 expressionEndPos = index$1;
5593 break
5594 }
5595 }
5596 }
5597
5598 function parseString (chr) {
5599 var stringQuote = chr;
5600 while (!eof()) {
5601 chr = next();
5602 if (chr === stringQuote) {
5603 break
5604 }
5605 }
5606 }
5607
5608 /* */
5609
5610 var warn$1;
5611
5612 // in some cases, the event used has to be determined at runtime
5613 // so we used some reserved tokens during compile.
5614 var RANGE_TOKEN = '__r';
5615 var CHECKBOX_RADIO_TOKEN = '__c';
5616
5617 function model (
5618 el,
5619 dir,
5620 _warn
5621 ) {
5622 warn$1 = _warn;
5623 var value = dir.value;
5624 var modifiers = dir.modifiers;
5625 var tag = el.tag;
5626 var type = el.attrsMap.type;
5627
5628 {
5629 var dynamicType = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
5630 if (tag === 'input' && dynamicType) {
5631 warn$1(
5632 "<input :type=\"" + dynamicType + "\" v-model=\"" + value + "\">:\n" +
5633 "v-model does not support dynamic input types. Use v-if branches instead."
5634 );
5635 }
5636 // inputs with type="file" are read only and setting the input's
5637 // value will throw an error.
5638 if (tag === 'input' && type === 'file') {
5639 warn$1(
5640 "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
5641 "File inputs are read only. Use a v-on:change listener instead."
5642 );
5643 }
5644 }
5645
5646 if (tag === 'select') {
5647 genSelect(el, value, modifiers);
5648 } else if (tag === 'input' && type === 'checkbox') {
5649 genCheckboxModel(el, value, modifiers);
5650 } else if (tag === 'input' && type === 'radio') {
5651 genRadioModel(el, value, modifiers);
5652 } else if (tag === 'input' || tag === 'textarea') {
5653 genDefaultModel(el, value, modifiers);
5654 } else if (!config.isReservedTag(tag)) {
5655 genComponentModel(el, value, modifiers);
5656 // component v-model doesn't need extra runtime
5657 return false
5658 } else {
5659 warn$1(
5660 "<" + (el.tag) + " v-model=\"" + value + "\">: " +
5661 "v-model is not supported on this element type. " +
5662 'If you are working with contenteditable, it\'s recommended to ' +
5663 'wrap a library dedicated for that purpose inside a custom component.'
5664 );
5665 }
5666
5667 // ensure runtime directive metadata
5668 return true
5669 }
5670
5671 function genCheckboxModel (
5672 el,
5673 value,
5674 modifiers
5675 ) {
5676 var number = modifiers && modifiers.number;
5677 var valueBinding = getBindingAttr(el, 'value') || 'null';
5678 var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
5679 var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
5680 addProp(el, 'checked',
5681 "Array.isArray(" + value + ")" +
5682 "?_i(" + value + "," + valueBinding + ")>-1" + (
5683 trueValueBinding === 'true'
5684 ? (":(" + value + ")")
5685 : (":_q(" + value + "," + trueValueBinding + ")")
5686 )
5687 );
5688 addHandler(el, CHECKBOX_RADIO_TOKEN,
5689 "var $$a=" + value + "," +
5690 '$$el=$event.target,' +
5691 "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
5692 'if(Array.isArray($$a)){' +
5693 "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
5694 '$$i=_i($$a,$$v);' +
5695 "if($$c){$$i<0&&(" + value + "=$$a.concat($$v))}" +
5696 "else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" +
5697 "}else{" + value + "=$$c}",
5698 null, true
5699 );
5700 }
5701
5702 function genRadioModel (
5703 el,
5704 value,
5705 modifiers
5706 ) {
5707 var number = modifiers && modifiers.number;
5708 var valueBinding = getBindingAttr(el, 'value') || 'null';
5709 valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
5710 addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
5711 addHandler(el, CHECKBOX_RADIO_TOKEN, genAssignmentCode(value, valueBinding), null, true);
5712 }
5713
5714 function genSelect (
5715 el,
5716 value,
5717 modifiers
5718 ) {
5719 var number = modifiers && modifiers.number;
5720 var selectedVal = "Array.prototype.filter" +
5721 ".call($event.target.options,function(o){return o.selected})" +
5722 ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
5723 "return " + (number ? '_n(val)' : 'val') + "})";
5724
5725 var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
5726 var code = "var $$selectedVal = " + selectedVal + ";";
5727 code = code + " " + (genAssignmentCode(value, assignment));
5728 addHandler(el, 'change', code, null, true);
5729 }
5730
5731 function genDefaultModel (
5732 el,
5733 value,
5734 modifiers
5735 ) {
5736 var type = el.attrsMap.type;
5737 var ref = modifiers || {};
5738 var lazy = ref.lazy;
5739 var number = ref.number;
5740 var trim = ref.trim;
5741 var needCompositionGuard = !lazy && type !== 'range';
5742 var event = lazy
5743 ? 'change'
5744 : type === 'range'
5745 ? RANGE_TOKEN
5746 : 'input';
5747
5748 var valueExpression = '$event.target.value';
5749 if (trim) {
5750 valueExpression = "$event.target.value.trim()";
5751 }
5752 if (number) {
5753 valueExpression = "_n(" + valueExpression + ")";
5754 }
5755
5756 var code = genAssignmentCode(value, valueExpression);
5757 if (needCompositionGuard) {
5758 code = "if($event.target.composing)return;" + code;
5759 }
5760
5761 addProp(el, 'value', ("(" + value + ")"));
5762 addHandler(el, event, code, null, true);
5763 if (trim || number || type === 'number') {
5764 addHandler(el, 'blur', '$forceUpdate()');
5765 }
5766 }
5767
5768 /* */
5769
5770 // normalize v-model event tokens that can only be determined at runtime.
5771 // it's important to place the event as the first in the array because
5772 // the whole point is ensuring the v-model callback gets called before
5773 // user-attached handlers.
5774 function normalizeEvents (on) {
5775 var event;
5776 /* istanbul ignore if */
5777 if (on[RANGE_TOKEN]) {
5778 // IE input[type=range] only supports `change` event
5779 event = isIE ? 'change' : 'input';
5780 on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
5781 delete on[RANGE_TOKEN];
5782 }
5783 if (on[CHECKBOX_RADIO_TOKEN]) {
5784 // Chrome fires microtasks in between click/change, leads to #4521
5785 event = isChrome ? 'click' : 'change';
5786 on[event] = [].concat(on[CHECKBOX_RADIO_TOKEN], on[event] || []);
5787 delete on[CHECKBOX_RADIO_TOKEN];
5788 }
5789 }
5790
5791 var target$1;
5792
5793 function add$1 (
5794 event,
5795 handler,
5796 once,
5797 capture
5798 ) {
5799 if (once) {
5800 var oldHandler = handler;
5801 var _target = target$1; // save current target element in closure
5802 handler = function (ev) {
5803 var res = arguments.length === 1
5804 ? oldHandler(ev)
5805 : oldHandler.apply(null, arguments);
5806 if (res !== null) {
5807 remove$2(event, handler, capture, _target);
5808 }
5809 };
5810 }
5811 target$1.addEventListener(event, handler, capture);
5812 }
5813
5814 function remove$2 (
5815 event,
5816 handler,
5817 capture,
5818 _target
5819 ) {
5820 (_target || target$1).removeEventListener(event, handler, capture);
5821 }
5822
5823 function updateDOMListeners (oldVnode, vnode) {
5824 if (!oldVnode.data.on && !vnode.data.on) {
5825 return
5826 }
5827 var on = vnode.data.on || {};
5828 var oldOn = oldVnode.data.on || {};
5829 target$1 = vnode.elm;
5830 normalizeEvents(on);
5831 updateListeners(on, oldOn, add$1, remove$2, vnode.context);
5832 }
5833
5834 var events = {
5835 create: updateDOMListeners,
5836 update: updateDOMListeners
5837 };
5838
5839 /* */
5840
5841 function updateDOMProps (oldVnode, vnode) {
5842 if (!oldVnode.data.domProps && !vnode.data.domProps) {
5843 return
5844 }
5845 var key, cur;
5846 var elm = vnode.elm;
5847 var oldProps = oldVnode.data.domProps || {};
5848 var props = vnode.data.domProps || {};
5849 // clone observed objects, as the user probably wants to mutate it
5850 if (props.__ob__) {
5851 props = vnode.data.domProps = extend({}, props);
5852 }
5853
5854 for (key in oldProps) {
5855 if (props[key] == null) {
5856 elm[key] = '';
5857 }
5858 }
5859 for (key in props) {
5860 cur = props[key];
5861 // ignore children if the node has textContent or innerHTML,
5862 // as these will throw away existing DOM nodes and cause removal errors
5863 // on subsequent patches (#3360)
5864 if (key === 'textContent' || key === 'innerHTML') {
5865 if (vnode.children) { vnode.children.length = 0; }
5866 if (cur === oldProps[key]) { continue }
5867 }
5868
5869 if (key === 'value') {
5870 // store value as _value as well since
5871 // non-string values will be stringified
5872 elm._value = cur;
5873 // avoid resetting cursor position when value is the same
5874 var strCur = cur == null ? '' : String(cur);
5875 if (shouldUpdateValue(elm, vnode, strCur)) {
5876 elm.value = strCur;
5877 }
5878 } else {
5879 elm[key] = cur;
5880 }
5881 }
5882 }
5883
5884 // check platforms/web/util/attrs.js acceptValue
5885
5886
5887 function shouldUpdateValue (
5888 elm,
5889 vnode,
5890 checkVal
5891 ) {
5892 return (!elm.composing && (
5893 vnode.tag === 'option' ||
5894 isDirty(elm, checkVal) ||
5895 isInputChanged(elm, checkVal)
5896 ))
5897 }
5898
5899 function isDirty (elm, checkVal) {
5900 // return true when textbox (.number and .trim) loses focus and its value is not equal to the updated value
5901 return document.activeElement !== elm && elm.value !== checkVal
5902 }
5903
5904 function isInputChanged (elm, newVal) {
5905 var value = elm.value;
5906 var modifiers = elm._vModifiers; // injected by v-model runtime
5907 if ((modifiers && modifiers.number) || elm.type === 'number') {
5908 return toNumber(value) !== toNumber(newVal)
5909 }
5910 if (modifiers && modifiers.trim) {
5911 return value.trim() !== newVal.trim()
5912 }
5913 return value !== newVal
5914 }
5915
5916 var domProps = {
5917 create: updateDOMProps,
5918 update: updateDOMProps
5919 };
5920
5921 /* */
5922
5923 var parseStyleText = cached(function (cssText) {
5924 var res = {};
5925 var listDelimiter = /;(?![^(]*\))/g;
5926 var propertyDelimiter = /:(.+)/;
5927 cssText.split(listDelimiter).forEach(function (item) {
5928 if (item) {
5929 var tmp = item.split(propertyDelimiter);
5930 tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
5931 }
5932 });
5933 return res
5934 });
5935
5936 // merge static and dynamic style data on the same vnode
5937 function normalizeStyleData (data) {
5938 var style = normalizeStyleBinding(data.style);
5939 // static style is pre-processed into an object during compilation
5940 // and is always a fresh object, so it's safe to merge into it
5941 return data.staticStyle
5942 ? extend(data.staticStyle, style)
5943 : style
5944 }
5945
5946 // normalize possible array / string values into Object
5947 function normalizeStyleBinding (bindingStyle) {
5948 if (Array.isArray(bindingStyle)) {
5949 return toObject(bindingStyle)
5950 }
5951 if (typeof bindingStyle === 'string') {
5952 return parseStyleText(bindingStyle)
5953 }
5954 return bindingStyle
5955 }
5956
5957 /**
5958 * parent component style should be after child's
5959 * so that parent component's style could override it
5960 */
5961 function getStyle (vnode, checkChild) {
5962 var res = {};
5963 var styleData;
5964
5965 if (checkChild) {
5966 var childNode = vnode;
5967 while (childNode.componentInstance) {
5968 childNode = childNode.componentInstance._vnode;
5969 if (childNode.data && (styleData = normalizeStyleData(childNode.data))) {
5970 extend(res, styleData);
5971 }
5972 }
5973 }
5974
5975 if ((styleData = normalizeStyleData(vnode.data))) {
5976 extend(res, styleData);
5977 }
5978
5979 var parentNode = vnode;
5980 while ((parentNode = parentNode.parent)) {
5981 if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
5982 extend(res, styleData);
5983 }
5984 }
5985 return res
5986 }
5987
5988 /* */
5989
5990 var cssVarRE = /^--/;
5991 var importantRE = /\s*!important$/;
5992 var setProp = function (el, name, val) {
5993 /* istanbul ignore if */
5994 if (cssVarRE.test(name)) {
5995 el.style.setProperty(name, val);
5996 } else if (importantRE.test(val)) {
5997 el.style.setProperty(name, val.replace(importantRE, ''), 'important');
5998 } else {
5999 el.style[normalize(name)] = val;
6000 }
6001 };
6002
6003 var prefixes = ['Webkit', 'Moz', 'ms'];
6004
6005 var testEl;
6006 var normalize = cached(function (prop) {
6007 testEl = testEl || document.createElement('div');
6008 prop = camelize(prop);
6009 if (prop !== 'filter' && (prop in testEl.style)) {
6010 return prop
6011 }
6012 var upper = prop.charAt(0).toUpperCase() + prop.slice(1);
6013 for (var i = 0; i < prefixes.length; i++) {
6014 var prefixed = prefixes[i] + upper;
6015 if (prefixed in testEl.style) {
6016 return prefixed
6017 }
6018 }
6019 });
6020
6021 function updateStyle (oldVnode, vnode) {
6022 var data = vnode.data;
6023 var oldData = oldVnode.data;
6024
6025 if (!data.staticStyle && !data.style &&
6026 !oldData.staticStyle && !oldData.style) {
6027 return
6028 }
6029
6030 var cur, name;
6031 var el = vnode.elm;
6032 var oldStaticStyle = oldVnode.data.staticStyle;
6033 var oldStyleBinding = oldVnode.data.style || {};
6034
6035 // if static style exists, stylebinding already merged into it when doing normalizeStyleData
6036 var oldStyle = oldStaticStyle || oldStyleBinding;
6037
6038 var style = normalizeStyleBinding(vnode.data.style) || {};
6039
6040 vnode.data.style = style.__ob__ ? extend({}, style) : style;
6041
6042 var newStyle = getStyle(vnode, true);
6043
6044 for (name in oldStyle) {
6045 if (newStyle[name] == null) {
6046 setProp(el, name, '');
6047 }
6048 }
6049 for (name in newStyle) {
6050 cur = newStyle[name];
6051 if (cur !== oldStyle[name]) {
6052 // ie9 setting to null has no effect, must use empty string
6053 setProp(el, name, cur == null ? '' : cur);
6054 }
6055 }
6056 }
6057
6058 var style = {
6059 create: updateStyle,
6060 update: updateStyle
6061 };
6062
6063 /* */
6064
6065 /**
6066 * Add class with compatibility for SVG since classList is not supported on
6067 * SVG elements in IE
6068 */
6069 function addClass (el, cls) {
6070 /* istanbul ignore if */
6071 if (!cls || !(cls = cls.trim())) {
6072 return
6073 }
6074
6075 /* istanbul ignore else */
6076 if (el.classList) {
6077 if (cls.indexOf(' ') > -1) {
6078 cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); });
6079 } else {
6080 el.classList.add(cls);
6081 }
6082 } else {
6083 var cur = " " + (el.getAttribute('class') || '') + " ";
6084 if (cur.indexOf(' ' + cls + ' ') < 0) {
6085 el.setAttribute('class', (cur + cls).trim());
6086 }
6087 }
6088 }
6089
6090 /**
6091 * Remove class with compatibility for SVG since classList is not supported on
6092 * SVG elements in IE
6093 */
6094 function removeClass (el, cls) {
6095 /* istanbul ignore if */
6096 if (!cls || !(cls = cls.trim())) {
6097 return
6098 }
6099
6100 /* istanbul ignore else */
6101 if (el.classList) {
6102 if (cls.indexOf(' ') > -1) {
6103 cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); });
6104 } else {
6105 el.classList.remove(cls);
6106 }
6107 } else {
6108 var cur = " " + (el.getAttribute('class') || '') + " ";
6109 var tar = ' ' + cls + ' ';
6110 while (cur.indexOf(tar) >= 0) {
6111 cur = cur.replace(tar, ' ');
6112 }
6113 el.setAttribute('class', cur.trim());
6114 }
6115 }
6116
6117 /* */
6118
6119 function resolveTransition (def$$1) {
6120 if (!def$$1) {
6121 return
6122 }
6123 /* istanbul ignore else */
6124 if (typeof def$$1 === 'object') {
6125 var res = {};
6126 if (def$$1.css !== false) {
6127 extend(res, autoCssTransition(def$$1.name || 'v'));
6128 }
6129 extend(res, def$$1);
6130 return res
6131 } else if (typeof def$$1 === 'string') {
6132 return autoCssTransition(def$$1)
6133 }
6134 }
6135
6136 var autoCssTransition = cached(function (name) {
6137 return {
6138 enterClass: (name + "-enter"),
6139 enterToClass: (name + "-enter-to"),
6140 enterActiveClass: (name + "-enter-active"),
6141 leaveClass: (name + "-leave"),
6142 leaveToClass: (name + "-leave-to"),
6143 leaveActiveClass: (name + "-leave-active")
6144 }
6145 });
6146
6147 var hasTransition = inBrowser && !isIE9;
6148 var TRANSITION = 'transition';
6149 var ANIMATION = 'animation';
6150
6151 // Transition property/event sniffing
6152 var transitionProp = 'transition';
6153 var transitionEndEvent = 'transitionend';
6154 var animationProp = 'animation';
6155 var animationEndEvent = 'animationend';
6156 if (hasTransition) {
6157 /* istanbul ignore if */
6158 if (window.ontransitionend === undefined &&
6159 window.onwebkittransitionend !== undefined) {
6160 transitionProp = 'WebkitTransition';
6161 transitionEndEvent = 'webkitTransitionEnd';
6162 }
6163 if (window.onanimationend === undefined &&
6164 window.onwebkitanimationend !== undefined) {
6165 animationProp = 'WebkitAnimation';
6166 animationEndEvent = 'webkitAnimationEnd';
6167 }
6168 }
6169
6170 // binding to window is necessary to make hot reload work in IE in strict mode
6171 var raf = inBrowser && window.requestAnimationFrame
6172 ? window.requestAnimationFrame.bind(window)
6173 : setTimeout;
6174
6175 function nextFrame (fn) {
6176 raf(function () {
6177 raf(fn);
6178 });
6179 }
6180
6181 function addTransitionClass (el, cls) {
6182 (el._transitionClasses || (el._transitionClasses = [])).push(cls);
6183 addClass(el, cls);
6184 }
6185
6186 function removeTransitionClass (el, cls) {
6187 if (el._transitionClasses) {
6188 remove(el._transitionClasses, cls);
6189 }
6190 removeClass(el, cls);
6191 }
6192
6193 function whenTransitionEnds (
6194 el,
6195 expectedType,
6196 cb
6197 ) {
6198 var ref = getTransitionInfo(el, expectedType);
6199 var type = ref.type;
6200 var timeout = ref.timeout;
6201 var propCount = ref.propCount;
6202 if (!type) { return cb() }
6203 var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
6204 var ended = 0;
6205 var end = function () {
6206 el.removeEventListener(event, onEnd);
6207 cb();
6208 };
6209 var onEnd = function (e) {
6210 if (e.target === el) {
6211 if (++ended >= propCount) {
6212 end();
6213 }
6214 }
6215 };
6216 setTimeout(function () {
6217 if (ended < propCount) {
6218 end();
6219 }
6220 }, timeout + 1);
6221 el.addEventListener(event, onEnd);
6222 }
6223
6224 var transformRE = /\b(transform|all)(,|$)/;
6225
6226 function getTransitionInfo (el, expectedType) {
6227 var styles = window.getComputedStyle(el);
6228 var transitionDelays = styles[transitionProp + 'Delay'].split(', ');
6229 var transitionDurations = styles[transitionProp + 'Duration'].split(', ');
6230 var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
6231 var animationDelays = styles[animationProp + 'Delay'].split(', ');
6232 var animationDurations = styles[animationProp + 'Duration'].split(', ');
6233 var animationTimeout = getTimeout(animationDelays, animationDurations);
6234
6235 var type;
6236 var timeout = 0;
6237 var propCount = 0;
6238 /* istanbul ignore if */
6239 if (expectedType === TRANSITION) {
6240 if (transitionTimeout > 0) {
6241 type = TRANSITION;
6242 timeout = transitionTimeout;
6243 propCount = transitionDurations.length;
6244 }
6245 } else if (expectedType === ANIMATION) {
6246 if (animationTimeout > 0) {
6247 type = ANIMATION;
6248 timeout = animationTimeout;
6249 propCount = animationDurations.length;
6250 }
6251 } else {
6252 timeout = Math.max(transitionTimeout, animationTimeout);
6253 type = timeout > 0
6254 ? transitionTimeout > animationTimeout
6255 ? TRANSITION
6256 : ANIMATION
6257 : null;
6258 propCount = type
6259 ? type === TRANSITION
6260 ? transitionDurations.length
6261 : animationDurations.length
6262 : 0;
6263 }
6264 var hasTransform =
6265 type === TRANSITION &&
6266 transformRE.test(styles[transitionProp + 'Property']);
6267 return {
6268 type: type,
6269 timeout: timeout,
6270 propCount: propCount,
6271 hasTransform: hasTransform
6272 }
6273 }
6274
6275 function getTimeout (delays, durations) {
6276 /* istanbul ignore next */
6277 while (delays.length < durations.length) {
6278 delays = delays.concat(delays);
6279 }
6280
6281 return Math.max.apply(null, durations.map(function (d, i) {
6282 return toMs(d) + toMs(delays[i])
6283 }))
6284 }
6285
6286 function toMs (s) {
6287 return Number(s.slice(0, -1)) * 1000
6288 }
6289
6290 /* */
6291
6292 function enter (vnode, toggleDisplay) {
6293 var el = vnode.elm;
6294
6295 // call leave callback now
6296 if (el._leaveCb) {
6297 el._leaveCb.cancelled = true;
6298 el._leaveCb();
6299 }
6300
6301 var data = resolveTransition(vnode.data.transition);
6302 if (!data) {
6303 return
6304 }
6305
6306 /* istanbul ignore if */
6307 if (el._enterCb || el.nodeType !== 1) {
6308 return
6309 }
6310
6311 var css = data.css;
6312 var type = data.type;
6313 var enterClass = data.enterClass;
6314 var enterToClass = data.enterToClass;
6315 var enterActiveClass = data.enterActiveClass;
6316 var appearClass = data.appearClass;
6317 var appearToClass = data.appearToClass;
6318 var appearActiveClass = data.appearActiveClass;
6319 var beforeEnter = data.beforeEnter;
6320 var enter = data.enter;
6321 var afterEnter = data.afterEnter;
6322 var enterCancelled = data.enterCancelled;
6323 var beforeAppear = data.beforeAppear;
6324 var appear = data.appear;
6325 var afterAppear = data.afterAppear;
6326 var appearCancelled = data.appearCancelled;
6327 var duration = data.duration;
6328
6329 // activeInstance will always be the <transition> component managing this
6330 // transition. One edge case to check is when the <transition> is placed
6331 // as the root node of a child component. In that case we need to check
6332 // <transition>'s parent for appear check.
6333 var context = activeInstance;
6334 var transitionNode = activeInstance.$vnode;
6335 while (transitionNode && transitionNode.parent) {
6336 transitionNode = transitionNode.parent;
6337 context = transitionNode.context;
6338 }
6339
6340 var isAppear = !context._isMounted || !vnode.isRootInsert;
6341
6342 if (isAppear && !appear && appear !== '') {
6343 return
6344 }
6345
6346 var startClass = isAppear && appearClass
6347 ? appearClass
6348 : enterClass;
6349 var activeClass = isAppear && appearActiveClass
6350 ? appearActiveClass
6351 : enterActiveClass;
6352 var toClass = isAppear && appearToClass
6353 ? appearToClass
6354 : enterToClass;
6355
6356 var beforeEnterHook = isAppear
6357 ? (beforeAppear || beforeEnter)
6358 : beforeEnter;
6359 var enterHook = isAppear
6360 ? (typeof appear === 'function' ? appear : enter)
6361 : enter;
6362 var afterEnterHook = isAppear
6363 ? (afterAppear || afterEnter)
6364 : afterEnter;
6365 var enterCancelledHook = isAppear
6366 ? (appearCancelled || enterCancelled)
6367 : enterCancelled;
6368
6369 var explicitEnterDuration = toNumber(
6370 isObject(duration)
6371 ? duration.enter
6372 : duration
6373 );
6374
6375 if ("development" !== 'production' && explicitEnterDuration != null) {
6376 checkDuration(explicitEnterDuration, 'enter', vnode);
6377 }
6378
6379 var expectsCSS = css !== false && !isIE9;
6380 var userWantsControl = getHookArgumentsLength(enterHook);
6381
6382 var cb = el._enterCb = once(function () {
6383 if (expectsCSS) {
6384 removeTransitionClass(el, toClass);
6385 removeTransitionClass(el, activeClass);
6386 }
6387 if (cb.cancelled) {
6388 if (expectsCSS) {
6389 removeTransitionClass(el, startClass);
6390 }
6391 enterCancelledHook && enterCancelledHook(el);
6392 } else {
6393 afterEnterHook && afterEnterHook(el);
6394 }
6395 el._enterCb = null;
6396 });
6397
6398 if (!vnode.data.show) {
6399 // remove pending leave element on enter by injecting an insert hook
6400 mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () {
6401 var parent = el.parentNode;
6402 var pendingNode = parent && parent._pending && parent._pending[vnode.key];
6403 if (pendingNode &&
6404 pendingNode.tag === vnode.tag &&
6405 pendingNode.elm._leaveCb) {
6406 pendingNode.elm._leaveCb();
6407 }
6408 enterHook && enterHook(el, cb);
6409 });
6410 }
6411
6412 // start enter transition
6413 beforeEnterHook && beforeEnterHook(el);
6414 if (expectsCSS) {
6415 addTransitionClass(el, startClass);
6416 addTransitionClass(el, activeClass);
6417 nextFrame(function () {
6418 addTransitionClass(el, toClass);
6419 removeTransitionClass(el, startClass);
6420 if (!cb.cancelled && !userWantsControl) {
6421 if (isValidDuration(explicitEnterDuration)) {
6422 setTimeout(cb, explicitEnterDuration);
6423 } else {
6424 whenTransitionEnds(el, type, cb);
6425 }
6426 }
6427 });
6428 }
6429
6430 if (vnode.data.show) {
6431 toggleDisplay && toggleDisplay();
6432 enterHook && enterHook(el, cb);
6433 }
6434
6435 if (!expectsCSS && !userWantsControl) {
6436 cb();
6437 }
6438 }
6439
6440 function leave (vnode, rm) {
6441 var el = vnode.elm;
6442
6443 // call enter callback now
6444 if (el._enterCb) {
6445 el._enterCb.cancelled = true;
6446 el._enterCb();
6447 }
6448
6449 var data = resolveTransition(vnode.data.transition);
6450 if (!data) {
6451 return rm()
6452 }
6453
6454 /* istanbul ignore if */
6455 if (el._leaveCb || el.nodeType !== 1) {
6456 return
6457 }
6458
6459 var css = data.css;
6460 var type = data.type;
6461 var leaveClass = data.leaveClass;
6462 var leaveToClass = data.leaveToClass;
6463 var leaveActiveClass = data.leaveActiveClass;
6464 var beforeLeave = data.beforeLeave;
6465 var leave = data.leave;
6466 var afterLeave = data.afterLeave;
6467 var leaveCancelled = data.leaveCancelled;
6468 var delayLeave = data.delayLeave;
6469 var duration = data.duration;
6470
6471 var expectsCSS = css !== false && !isIE9;
6472 var userWantsControl = getHookArgumentsLength(leave);
6473
6474 var explicitLeaveDuration = toNumber(
6475 isObject(duration)
6476 ? duration.leave
6477 : duration
6478 );
6479
6480 if ("development" !== 'production' && explicitLeaveDuration != null) {
6481 checkDuration(explicitLeaveDuration, 'leave', vnode);
6482 }
6483
6484 var cb = el._leaveCb = once(function () {
6485 if (el.parentNode && el.parentNode._pending) {
6486 el.parentNode._pending[vnode.key] = null;
6487 }
6488 if (expectsCSS) {
6489 removeTransitionClass(el, leaveToClass);
6490 removeTransitionClass(el, leaveActiveClass);
6491 }
6492 if (cb.cancelled) {
6493 if (expectsCSS) {
6494 removeTransitionClass(el, leaveClass);
6495 }
6496 leaveCancelled && leaveCancelled(el);
6497 } else {
6498 rm();
6499 afterLeave && afterLeave(el);
6500 }
6501 el._leaveCb = null;
6502 });
6503
6504 if (delayLeave) {
6505 delayLeave(performLeave);
6506 } else {
6507 performLeave();
6508 }
6509
6510 function performLeave () {
6511 // the delayed leave may have already been cancelled
6512 if (cb.cancelled) {
6513 return
6514 }
6515 // record leaving element
6516 if (!vnode.data.show) {
6517 (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] = vnode;
6518 }
6519 beforeLeave && beforeLeave(el);
6520 if (expectsCSS) {
6521 addTransitionClass(el, leaveClass);
6522 addTransitionClass(el, leaveActiveClass);
6523 nextFrame(function () {
6524 addTransitionClass(el, leaveToClass);
6525 removeTransitionClass(el, leaveClass);
6526 if (!cb.cancelled && !userWantsControl) {
6527 if (isValidDuration(explicitLeaveDuration)) {
6528 setTimeout(cb, explicitLeaveDuration);
6529 } else {
6530 whenTransitionEnds(el, type, cb);
6531 }
6532 }
6533 });
6534 }
6535 leave && leave(el, cb);
6536 if (!expectsCSS && !userWantsControl) {
6537 cb();
6538 }
6539 }
6540 }
6541
6542 // only used in dev mode
6543 function checkDuration (val, name, vnode) {
6544 if (typeof val !== 'number') {
6545 warn(
6546 "<transition> explicit " + name + " duration is not a valid number - " +
6547 "got " + (JSON.stringify(val)) + ".",
6548 vnode.context
6549 );
6550 } else if (isNaN(val)) {
6551 warn(
6552 "<transition> explicit " + name + " duration is NaN - " +
6553 'the duration expression might be incorrect.',
6554 vnode.context
6555 );
6556 }
6557 }
6558
6559 function isValidDuration (val) {
6560 return typeof val === 'number' && !isNaN(val)
6561 }
6562
6563 /**
6564 * Normalize a transition hook's argument length. The hook may be:
6565 * - a merged hook (invoker) with the original in .fns
6566 * - a wrapped component method (check ._length)
6567 * - a plain function (.length)
6568 */
6569 function getHookArgumentsLength (fn) {
6570 if (!fn) { return false }
6571 var invokerFns = fn.fns;
6572 if (invokerFns) {
6573 // invoker
6574 return getHookArgumentsLength(
6575 Array.isArray(invokerFns)
6576 ? invokerFns[0]
6577 : invokerFns
6578 )
6579 } else {
6580 return (fn._length || fn.length) > 1
6581 }
6582 }
6583
6584 function _enter (_, vnode) {
6585 if (!vnode.data.show) {
6586 enter(vnode);
6587 }
6588 }
6589
6590 var transition = inBrowser ? {
6591 create: _enter,
6592 activate: _enter,
6593 remove: function remove$$1 (vnode, rm) {
6594 /* istanbul ignore else */
6595 if (!vnode.data.show) {
6596 leave(vnode, rm);
6597 } else {
6598 rm();
6599 }
6600 }
6601 } : {};
6602
6603 var platformModules = [
6604 attrs,
6605 klass,
6606 events,
6607 domProps,
6608 style,
6609 transition
6610 ];
6611
6612 /* */
6613
6614 // the directive module should be applied last, after all
6615 // built-in modules have been applied.
6616 var modules = platformModules.concat(baseModules);
6617
6618 var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
6619
6620 /**
6621 * Not type checking this file because flow doesn't like attaching
6622 * properties to Elements.
6623 */
6624
6625 /* istanbul ignore if */
6626 if (isIE9) {
6627 // http://www.matts411.com/post/internet-explorer-9-oninput/
6628 document.addEventListener('selectionchange', function () {
6629 var el = document.activeElement;
6630 if (el && el.vmodel) {
6631 trigger(el, 'input');
6632 }
6633 });
6634 }
6635
6636 var model$1 = {
6637 inserted: function inserted (el, binding, vnode) {
6638 if (vnode.tag === 'select') {
6639 var cb = function () {
6640 setSelected(el, binding, vnode.context);
6641 };
6642 cb();
6643 /* istanbul ignore if */
6644 if (isIE || isEdge) {
6645 setTimeout(cb, 0);
6646 }
6647 } else if (vnode.tag === 'textarea' || el.type === 'text') {
6648 el._vModifiers = binding.modifiers;
6649 if (!binding.modifiers.lazy) {
6650 if (!isAndroid) {
6651 el.addEventListener('compositionstart', onCompositionStart);
6652 el.addEventListener('compositionend', onCompositionEnd);
6653 }
6654 /* istanbul ignore if */
6655 if (isIE9) {
6656 el.vmodel = true;
6657 }
6658 }
6659 }
6660 },
6661 componentUpdated: function componentUpdated (el, binding, vnode) {
6662 if (vnode.tag === 'select') {
6663 setSelected(el, binding, vnode.context);
6664 // in case the options rendered by v-for have changed,
6665 // it's possible that the value is out-of-sync with the rendered options.
6666 // detect such cases and filter out values that no longer has a matching
6667 // option in the DOM.
6668 var needReset = el.multiple
6669 ? binding.value.some(function (v) { return hasNoMatchingOption(v, el.options); })
6670 : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, el.options);
6671 if (needReset) {
6672 trigger(el, 'change');
6673 }
6674 }
6675 }
6676 };
6677
6678 function setSelected (el, binding, vm) {
6679 var value = binding.value;
6680 var isMultiple = el.multiple;
6681 if (isMultiple && !Array.isArray(value)) {
6682 "development" !== 'production' && warn(
6683 "<select multiple v-model=\"" + (binding.expression) + "\"> " +
6684 "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
6685 vm
6686 );
6687 return
6688 }
6689 var selected, option;
6690 for (var i = 0, l = el.options.length; i < l; i++) {
6691 option = el.options[i];
6692 if (isMultiple) {
6693 selected = looseIndexOf(value, getValue(option)) > -1;
6694 if (option.selected !== selected) {
6695 option.selected = selected;
6696 }
6697 } else {
6698 if (looseEqual(getValue(option), value)) {
6699 if (el.selectedIndex !== i) {
6700 el.selectedIndex = i;
6701 }
6702 return
6703 }
6704 }
6705 }
6706 if (!isMultiple) {
6707 el.selectedIndex = -1;
6708 }
6709 }
6710
6711 function hasNoMatchingOption (value, options) {
6712 for (var i = 0, l = options.length; i < l; i++) {
6713 if (looseEqual(getValue(options[i]), value)) {
6714 return false
6715 }
6716 }
6717 return true
6718 }
6719
6720 function getValue (option) {
6721 return '_value' in option
6722 ? option._value
6723 : option.value
6724 }
6725
6726 function onCompositionStart (e) {
6727 e.target.composing = true;
6728 }
6729
6730 function onCompositionEnd (e) {
6731 e.target.composing = false;
6732 trigger(e.target, 'input');
6733 }
6734
6735 function trigger (el, type) {
6736 var e = document.createEvent('HTMLEvents');
6737 e.initEvent(type, true, true);
6738 el.dispatchEvent(e);
6739 }
6740
6741 /* */
6742
6743 // recursively search for possible transition defined inside the component root
6744 function locateNode (vnode) {
6745 return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
6746 ? locateNode(vnode.componentInstance._vnode)
6747 : vnode
6748 }
6749
6750 var show = {
6751 bind: function bind (el, ref, vnode) {
6752 var value = ref.value;
6753
6754 vnode = locateNode(vnode);
6755 var transition = vnode.data && vnode.data.transition;
6756 var originalDisplay = el.__vOriginalDisplay =
6757 el.style.display === 'none' ? '' : el.style.display;
6758 if (value && transition && !isIE9) {
6759 vnode.data.show = true;
6760 enter(vnode, function () {
6761 el.style.display = originalDisplay;
6762 });
6763 } else {
6764 el.style.display = value ? originalDisplay : 'none';
6765 }
6766 },
6767
6768 update: function update (el, ref, vnode) {
6769 var value = ref.value;
6770 var oldValue = ref.oldValue;
6771
6772 /* istanbul ignore if */
6773 if (value === oldValue) { return }
6774 vnode = locateNode(vnode);
6775 var transition = vnode.data && vnode.data.transition;
6776 if (transition && !isIE9) {
6777 vnode.data.show = true;
6778 if (value) {
6779 enter(vnode, function () {
6780 el.style.display = el.__vOriginalDisplay;
6781 });
6782 } else {
6783 leave(vnode, function () {
6784 el.style.display = 'none';
6785 });
6786 }
6787 } else {
6788 el.style.display = value ? el.__vOriginalDisplay : 'none';
6789 }
6790 },
6791
6792 unbind: function unbind (
6793 el,
6794 binding,
6795 vnode,
6796 oldVnode,
6797 isDestroy
6798 ) {
6799 if (!isDestroy) {
6800 el.style.display = el.__vOriginalDisplay;
6801 }
6802 }
6803 };
6804
6805 var platformDirectives = {
6806 model: model$1,
6807 show: show
6808 };
6809
6810 /* */
6811
6812 // Provides transition support for a single element/component.
6813 // supports transition mode (out-in / in-out)
6814
6815 var transitionProps = {
6816 name: String,
6817 appear: Boolean,
6818 css: Boolean,
6819 mode: String,
6820 type: String,
6821 enterClass: String,
6822 leaveClass: String,
6823 enterToClass: String,
6824 leaveToClass: String,
6825 enterActiveClass: String,
6826 leaveActiveClass: String,
6827 appearClass: String,
6828 appearActiveClass: String,
6829 appearToClass: String,
6830 duration: [Number, String, Object]
6831 };
6832
6833 // in case the child is also an abstract component, e.g. <keep-alive>
6834 // we want to recursively retrieve the real component to be rendered
6835 function getRealChild (vnode) {
6836 var compOptions = vnode && vnode.componentOptions;
6837 if (compOptions && compOptions.Ctor.options.abstract) {
6838 return getRealChild(getFirstComponentChild(compOptions.children))
6839 } else {
6840 return vnode
6841 }
6842 }
6843
6844 function extractTransitionData (comp) {
6845 var data = {};
6846 var options = comp.$options;
6847 // props
6848 for (var key in options.propsData) {
6849 data[key] = comp[key];
6850 }
6851 // events.
6852 // extract listeners and pass them directly to the transition methods
6853 var listeners = options._parentListeners;
6854 for (var key$1 in listeners) {
6855 data[camelize(key$1)] = listeners[key$1];
6856 }
6857 return data
6858 }
6859
6860 function placeholder (h, rawChild) {
6861 return /\d-keep-alive$/.test(rawChild.tag)
6862 ? h('keep-alive')
6863 : null
6864 }
6865
6866 function hasParentTransition (vnode) {
6867 while ((vnode = vnode.parent)) {
6868 if (vnode.data.transition) {
6869 return true
6870 }
6871 }
6872 }
6873
6874 function isSameChild (child, oldChild) {
6875 return oldChild.key === child.key && oldChild.tag === child.tag
6876 }
6877
6878 var Transition = {
6879 name: 'transition',
6880 props: transitionProps,
6881 abstract: true,
6882
6883 render: function render (h) {
6884 var this$1 = this;
6885
6886 var children = this.$slots.default;
6887 if (!children) {
6888 return
6889 }
6890
6891 // filter out text nodes (possible whitespaces)
6892 children = children.filter(function (c) { return c.tag; });
6893 /* istanbul ignore if */
6894 if (!children.length) {
6895 return
6896 }
6897
6898 // warn multiple elements
6899 if ("development" !== 'production' && children.length > 1) {
6900 warn(
6901 '<transition> can only be used on a single element. Use ' +
6902 '<transition-group> for lists.',
6903 this.$parent
6904 );
6905 }
6906
6907 var mode = this.mode;
6908
6909 // warn invalid mode
6910 if ("development" !== 'production' &&
6911 mode && mode !== 'in-out' && mode !== 'out-in') {
6912 warn(
6913 'invalid <transition> mode: ' + mode,
6914 this.$parent
6915 );
6916 }
6917
6918 var rawChild = children[0];
6919
6920 // if this is a component root node and the component's
6921 // parent container node also has transition, skip.
6922 if (hasParentTransition(this.$vnode)) {
6923 return rawChild
6924 }
6925
6926 // apply transition data to child
6927 // use getRealChild() to ignore abstract components e.g. keep-alive
6928 var child = getRealChild(rawChild);
6929 /* istanbul ignore if */
6930 if (!child) {
6931 return rawChild
6932 }
6933
6934 if (this._leaving) {
6935 return placeholder(h, rawChild)
6936 }
6937
6938 // ensure a key that is unique to the vnode type and to this transition
6939 // component instance. This key will be used to remove pending leaving nodes
6940 // during entering.
6941 var id = "__transition-" + (this._uid) + "-";
6942 child.key = child.key == null
6943 ? id + child.tag
6944 : isPrimitive(child.key)
6945 ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
6946 : child.key;
6947
6948 var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
6949 var oldRawChild = this._vnode;
6950 var oldChild = getRealChild(oldRawChild);
6951
6952 // mark v-show
6953 // so that the transition module can hand over the control to the directive
6954 if (child.data.directives && child.data.directives.some(function (d) { return d.name === 'show'; })) {
6955 child.data.show = true;
6956 }
6957
6958 if (oldChild && oldChild.data && !isSameChild(child, oldChild)) {
6959 // replace old child transition data with fresh one
6960 // important for dynamic transitions!
6961 var oldData = oldChild && (oldChild.data.transition = extend({}, data));
6962 // handle transition mode
6963 if (mode === 'out-in') {
6964 // return placeholder node and queue update when leave finishes
6965 this._leaving = true;
6966 mergeVNodeHook(oldData, 'afterLeave', function () {
6967 this$1._leaving = false;
6968 this$1.$forceUpdate();
6969 });
6970 return placeholder(h, rawChild)
6971 } else if (mode === 'in-out') {
6972 var delayedLeave;
6973 var performLeave = function () { delayedLeave(); };
6974 mergeVNodeHook(data, 'afterEnter', performLeave);
6975 mergeVNodeHook(data, 'enterCancelled', performLeave);
6976 mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
6977 }
6978 }
6979
6980 return rawChild
6981 }
6982 };
6983
6984 /* */
6985
6986 // Provides transition support for list items.
6987 // supports move transitions using the FLIP technique.
6988
6989 // Because the vdom's children update algorithm is "unstable" - i.e.
6990 // it doesn't guarantee the relative positioning of removed elements,
6991 // we force transition-group to update its children into two passes:
6992 // in the first pass, we remove all nodes that need to be removed,
6993 // triggering their leaving transition; in the second pass, we insert/move
6994 // into the final desired state. This way in the second pass removed
6995 // nodes will remain where they should be.
6996
6997 var props = extend({
6998 tag: String,
6999 moveClass: String
7000 }, transitionProps);
7001
7002 delete props.mode;
7003
7004 var TransitionGroup = {
7005 props: props,
7006
7007 render: function render (h) {
7008 var tag = this.tag || this.$vnode.data.tag || 'span';
7009 var map = Object.create(null);
7010 var prevChildren = this.prevChildren = this.children;
7011 var rawChildren = this.$slots.default || [];
7012 var children = this.children = [];
7013 var transitionData = extractTransitionData(this);
7014
7015 for (var i = 0; i < rawChildren.length; i++) {
7016 var c = rawChildren[i];
7017 if (c.tag) {
7018 if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
7019 children.push(c);
7020 map[c.key] = c
7021 ;(c.data || (c.data = {})).transition = transitionData;
7022 } else {
7023 var opts = c.componentOptions;
7024 var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
7025 warn(("<transition-group> children must be keyed: <" + name + ">"));
7026 }
7027 }
7028 }
7029
7030 if (prevChildren) {
7031 var kept = [];
7032 var removed = [];
7033 for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
7034 var c$1 = prevChildren[i$1];
7035 c$1.data.transition = transitionData;
7036 c$1.data.pos = c$1.elm.getBoundingClientRect();
7037 if (map[c$1.key]) {
7038 kept.push(c$1);
7039 } else {
7040 removed.push(c$1);
7041 }
7042 }
7043 this.kept = h(tag, null, kept);
7044 this.removed = removed;
7045 }
7046
7047 return h(tag, null, children)
7048 },
7049
7050 beforeUpdate: function beforeUpdate () {
7051 // force removing pass
7052 this.__patch__(
7053 this._vnode,
7054 this.kept,
7055 false, // hydrating
7056 true // removeOnly (!important, avoids unnecessary moves)
7057 );
7058 this._vnode = this.kept;
7059 },
7060
7061 updated: function updated () {
7062 var children = this.prevChildren;
7063 var moveClass = this.moveClass || ((this.name || 'v') + '-move');
7064 if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
7065 return
7066 }
7067
7068 // we divide the work into three loops to avoid mixing DOM reads and writes
7069 // in each iteration - which helps prevent layout thrashing.
7070 children.forEach(callPendingCbs);
7071 children.forEach(recordPosition);
7072 children.forEach(applyTranslation);
7073
7074 // force reflow to put everything in position
7075 var body = document.body;
7076 var f = body.offsetHeight; // eslint-disable-line
7077
7078 children.forEach(function (c) {
7079 if (c.data.moved) {
7080 var el = c.elm;
7081 var s = el.style;
7082 addTransitionClass(el, moveClass);
7083 s.transform = s.WebkitTransform = s.transitionDuration = '';
7084 el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
7085 if (!e || /transform$/.test(e.propertyName)) {
7086 el.removeEventListener(transitionEndEvent, cb);
7087 el._moveCb = null;
7088 removeTransitionClass(el, moveClass);
7089 }
7090 });
7091 }
7092 });
7093 },
7094
7095 methods: {
7096 hasMove: function hasMove (el, moveClass) {
7097 /* istanbul ignore if */
7098 if (!hasTransition) {
7099 return false
7100 }
7101 if (this._hasMove != null) {
7102 return this._hasMove
7103 }
7104 // Detect whether an element with the move class applied has
7105 // CSS transitions. Since the element may be inside an entering
7106 // transition at this very moment, we make a clone of it and remove
7107 // all other transition classes applied to ensure only the move class
7108 // is applied.
7109 var clone = el.cloneNode();
7110 if (el._transitionClasses) {
7111 el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
7112 }
7113 addClass(clone, moveClass);
7114 clone.style.display = 'none';
7115 this.$el.appendChild(clone);
7116 var info = getTransitionInfo(clone);
7117 this.$el.removeChild(clone);
7118 return (this._hasMove = info.hasTransform)
7119 }
7120 }
7121 };
7122
7123 function callPendingCbs (c) {
7124 /* istanbul ignore if */
7125 if (c.elm._moveCb) {
7126 c.elm._moveCb();
7127 }
7128 /* istanbul ignore if */
7129 if (c.elm._enterCb) {
7130 c.elm._enterCb();
7131 }
7132 }
7133
7134 function recordPosition (c) {
7135 c.data.newPos = c.elm.getBoundingClientRect();
7136 }
7137
7138 function applyTranslation (c) {
7139 var oldPos = c.data.pos;
7140 var newPos = c.data.newPos;
7141 var dx = oldPos.left - newPos.left;
7142 var dy = oldPos.top - newPos.top;
7143 if (dx || dy) {
7144 c.data.moved = true;
7145 var s = c.elm.style;
7146 s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
7147 s.transitionDuration = '0s';
7148 }
7149 }
7150
7151 var platformComponents = {
7152 Transition: Transition,
7153 TransitionGroup: TransitionGroup
7154 };
7155
7156 /* */
7157
7158 // install platform specific utils
7159 Vue$3.config.mustUseProp = mustUseProp;
7160 Vue$3.config.isReservedTag = isReservedTag;
7161 Vue$3.config.getTagNamespace = getTagNamespace;
7162 Vue$3.config.isUnknownElement = isUnknownElement;
7163
7164 // install platform runtime directives & components
7165 extend(Vue$3.options.directives, platformDirectives);
7166 extend(Vue$3.options.components, platformComponents);
7167
7168 // install platform patch function
7169 Vue$3.prototype.__patch__ = inBrowser ? patch : noop;
7170
7171 // public mount method
7172 Vue$3.prototype.$mount = function (
7173 el,
7174 hydrating
7175 ) {
7176 el = el && inBrowser ? query(el) : undefined;
7177 return mountComponent(this, el, hydrating)
7178 };
7179
7180 // devtools global hook
7181 /* istanbul ignore next */
7182 setTimeout(function () {
7183 if (config.devtools) {
7184 if (devtools) {
7185 devtools.emit('init', Vue$3);
7186 } else if ("development" !== 'production' && isChrome) {
7187 console[console.info ? 'info' : 'log'](
7188 'Download the Vue Devtools extension for a better development experience:\n' +
7189 'https://github.com/vuejs/vue-devtools'
7190 );
7191 }
7192 }
7193 if ("development" !== 'production' &&
7194 config.productionTip !== false &&
7195 inBrowser && typeof console !== 'undefined') {
7196 console[console.info ? 'info' : 'log'](
7197 "You are running Vue in development mode.\n" +
7198 "Make sure to turn on production mode when deploying for production.\n" +
7199 "See more tips at https://vuejs.org/guide/deployment.html"
7200 );
7201 }
7202 }, 0);
7203
7204 /* */
7205
7206 // check whether current browser encodes a char inside attribute values
7207 function shouldDecode (content, encoded) {
7208 var div = document.createElement('div');
7209 div.innerHTML = "<div a=\"" + content + "\">";
7210 return div.innerHTML.indexOf(encoded) > 0
7211 }
7212
7213 // #3663
7214 // IE encodes newlines inside attribute values while other browsers don't
7215 var shouldDecodeNewlines = inBrowser ? shouldDecode('\n', '&#10;') : false;
7216
7217 /* */
7218
7219 var isUnaryTag = makeMap(
7220 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
7221 'link,meta,param,source,track,wbr'
7222 );
7223
7224 // Elements that you can, intentionally, leave open
7225 // (and which close themselves)
7226 var canBeLeftOpenTag = makeMap(
7227 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
7228 );
7229
7230 // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
7231 // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
7232 var isNonPhrasingTag = makeMap(
7233 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
7234 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
7235 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
7236 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
7237 'title,tr,track'
7238 );
7239
7240 /* */
7241
7242 var decoder;
7243
7244 function decode (html) {
7245 decoder = decoder || document.createElement('div');
7246 decoder.innerHTML = html;
7247 return decoder.textContent
7248 }
7249
7250 /**
7251 * Not type-checking this file because it's mostly vendor code.
7252 */
7253
7254 /*!
7255 * HTML Parser By John Resig (ejohn.org)
7256 * Modified by Juriy "kangax" Zaytsev
7257 * Original code by Erik Arvidsson, Mozilla Public License
7258 * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
7259 */
7260
7261 // Regular Expressions for parsing tags and attributes
7262 var singleAttrIdentifier = /([^\s"'<>/=]+)/;
7263 var singleAttrAssign = /(?:=)/;
7264 var singleAttrValues = [
7265 // attr value double quotes
7266 /"([^"]*)"+/.source,
7267 // attr value, single quotes
7268 /'([^']*)'+/.source,
7269 // attr value, no quotes
7270 /([^\s"'=<>`]+)/.source
7271 ];
7272 var attribute = new RegExp(
7273 '^\\s*' + singleAttrIdentifier.source +
7274 '(?:\\s*(' + singleAttrAssign.source + ')' +
7275 '\\s*(?:' + singleAttrValues.join('|') + '))?'
7276 );
7277
7278 // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
7279 // but for Vue templates we can enforce a simple charset
7280 var ncname = '[a-zA-Z_][\\w\\-\\.]*';
7281 var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
7282 var startTagOpen = new RegExp('^<' + qnameCapture);
7283 var startTagClose = /^\s*(\/?)>/;
7284 var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
7285 var doctype = /^<!DOCTYPE [^>]+>/i;
7286 var comment = /^<!--/;
7287 var conditionalComment = /^<!\[/;
7288
7289 var IS_REGEX_CAPTURING_BROKEN = false;
7290 'x'.replace(/x(.)?/g, function (m, g) {
7291 IS_REGEX_CAPTURING_BROKEN = g === '';
7292 });
7293
7294 // Special Elements (can contain anything)
7295 var isPlainTextElement = makeMap('script,style,textarea', true);
7296 var reCache = {};
7297
7298 var decodingMap = {
7299 '&lt;': '<',
7300 '&gt;': '>',
7301 '&quot;': '"',
7302 '&amp;': '&',
7303 '&#10;': '\n'
7304 };
7305 var encodedAttr = /&(?:lt|gt|quot|amp);/g;
7306 var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g;
7307
7308 function decodeAttr (value, shouldDecodeNewlines) {
7309 var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
7310 return value.replace(re, function (match) { return decodingMap[match]; })
7311 }
7312
7313 function parseHTML (html, options) {
7314 var stack = [];
7315 var expectHTML = options.expectHTML;
7316 var isUnaryTag$$1 = options.isUnaryTag || no;
7317 var index = 0;
7318 var last, lastTag;
7319 while (html) {
7320 last = html;
7321 // Make sure we're not in a plaintext content element like script/style
7322 if (!lastTag || !isPlainTextElement(lastTag)) {
7323 var textEnd = html.indexOf('<');
7324 if (textEnd === 0) {
7325 // Comment:
7326 if (comment.test(html)) {
7327 var commentEnd = html.indexOf('-->');
7328
7329 if (commentEnd >= 0) {
7330 advance(commentEnd + 3);
7331 continue
7332 }
7333 }
7334
7335 // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
7336 if (conditionalComment.test(html)) {
7337 var conditionalEnd = html.indexOf(']>');
7338
7339 if (conditionalEnd >= 0) {
7340 advance(conditionalEnd + 2);
7341 continue
7342 }
7343 }
7344
7345 // Doctype:
7346 var doctypeMatch = html.match(doctype);
7347 if (doctypeMatch) {
7348 advance(doctypeMatch[0].length);
7349 continue
7350 }
7351
7352 // End tag:
7353 var endTagMatch = html.match(endTag);
7354 if (endTagMatch) {
7355 var curIndex = index;
7356 advance(endTagMatch[0].length);
7357 parseEndTag(endTagMatch[1], curIndex, index);
7358 continue
7359 }
7360
7361 // Start tag:
7362 var startTagMatch = parseStartTag();
7363 if (startTagMatch) {
7364 handleStartTag(startTagMatch);
7365 continue
7366 }
7367 }
7368
7369 var text = (void 0), rest$1 = (void 0), next = (void 0);
7370 if (textEnd >= 0) {
7371 rest$1 = html.slice(textEnd);
7372 while (
7373 !endTag.test(rest$1) &&
7374 !startTagOpen.test(rest$1) &&
7375 !comment.test(rest$1) &&
7376 !conditionalComment.test(rest$1)
7377 ) {
7378 // < in plain text, be forgiving and treat it as text
7379 next = rest$1.indexOf('<', 1);
7380 if (next < 0) { break }
7381 textEnd += next;
7382 rest$1 = html.slice(textEnd);
7383 }
7384 text = html.substring(0, textEnd);
7385 advance(textEnd);
7386 }
7387
7388 if (textEnd < 0) {
7389 text = html;
7390 html = '';
7391 }
7392
7393 if (options.chars && text) {
7394 options.chars(text);
7395 }
7396 } else {
7397 var stackedTag = lastTag.toLowerCase();
7398 var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
7399 var endTagLength = 0;
7400 var rest = html.replace(reStackedTag, function (all, text, endTag) {
7401 endTagLength = endTag.length;
7402 if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
7403 text = text
7404 .replace(/<!--([\s\S]*?)-->/g, '$1')
7405 .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
7406 }
7407 if (options.chars) {
7408 options.chars(text);
7409 }
7410 return ''
7411 });
7412 index += html.length - rest.length;
7413 html = rest;
7414 parseEndTag(stackedTag, index - endTagLength, index);
7415 }
7416
7417 if (html === last) {
7418 options.chars && options.chars(html);
7419 if ("development" !== 'production' && !stack.length && options.warn) {
7420 options.warn(("Mal-formatted tag at end of template: \"" + html + "\""));
7421 }
7422 break
7423 }
7424 }
7425
7426 // Clean up any remaining tags
7427 parseEndTag();
7428
7429 function advance (n) {
7430 index += n;
7431 html = html.substring(n);
7432 }
7433
7434 function parseStartTag () {
7435 var start = html.match(startTagOpen);
7436 if (start) {
7437 var match = {
7438 tagName: start[1],
7439 attrs: [],
7440 start: index
7441 };
7442 advance(start[0].length);
7443 var end, attr;
7444 while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
7445 advance(attr[0].length);
7446 match.attrs.push(attr);
7447 }
7448 if (end) {
7449 match.unarySlash = end[1];
7450 advance(end[0].length);
7451 match.end = index;
7452 return match
7453 }
7454 }
7455 }
7456
7457 function handleStartTag (match) {
7458 var tagName = match.tagName;
7459 var unarySlash = match.unarySlash;
7460
7461 if (expectHTML) {
7462 if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
7463 parseEndTag(lastTag);
7464 }
7465 if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
7466 parseEndTag(tagName);
7467 }
7468 }
7469
7470 var unary = isUnaryTag$$1(tagName) || tagName === 'html' && lastTag === 'head' || !!unarySlash;
7471
7472 var l = match.attrs.length;
7473 var attrs = new Array(l);
7474 for (var i = 0; i < l; i++) {
7475 var args = match.attrs[i];
7476 // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
7477 if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) {
7478 if (args[3] === '') { delete args[3]; }
7479 if (args[4] === '') { delete args[4]; }
7480 if (args[5] === '') { delete args[5]; }
7481 }
7482 var value = args[3] || args[4] || args[5] || '';
7483 attrs[i] = {
7484 name: args[1],
7485 value: decodeAttr(
7486 value,
7487 options.shouldDecodeNewlines
7488 )
7489 };
7490 }
7491
7492 if (!unary) {
7493 stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs });
7494 lastTag = tagName;
7495 }
7496
7497 if (options.start) {
7498 options.start(tagName, attrs, unary, match.start, match.end);
7499 }
7500 }
7501
7502 function parseEndTag (tagName, start, end) {
7503 var pos, lowerCasedTagName;
7504 if (start == null) { start = index; }
7505 if (end == null) { end = index; }
7506
7507 if (tagName) {
7508 lowerCasedTagName = tagName.toLowerCase();
7509 }
7510
7511 // Find the closest opened tag of the same type
7512 if (tagName) {
7513 for (pos = stack.length - 1; pos >= 0; pos--) {
7514 if (stack[pos].lowerCasedTag === lowerCasedTagName) {
7515 break
7516 }
7517 }
7518 } else {
7519 // If no tag name is provided, clean shop
7520 pos = 0;
7521 }
7522
7523 if (pos >= 0) {
7524 // Close all the open elements, up the stack
7525 for (var i = stack.length - 1; i >= pos; i--) {
7526 if ("development" !== 'production' &&
7527 (i > pos || !tagName) &&
7528 options.warn) {
7529 options.warn(
7530 ("tag <" + (stack[i].tag) + "> has no matching end tag.")
7531 );
7532 }
7533 if (options.end) {
7534 options.end(stack[i].tag, start, end);
7535 }
7536 }
7537
7538 // Remove the open elements from the stack
7539 stack.length = pos;
7540 lastTag = pos && stack[pos - 1].tag;
7541 } else if (lowerCasedTagName === 'br') {
7542 if (options.start) {
7543 options.start(tagName, [], true, start, end);
7544 }
7545 } else if (lowerCasedTagName === 'p') {
7546 if (options.start) {
7547 options.start(tagName, [], false, start, end);
7548 }
7549 if (options.end) {
7550 options.end(tagName, start, end);
7551 }
7552 }
7553 }
7554 }
7555
7556 /* */
7557
7558 var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g;
7559 var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
7560
7561 var buildRegex = cached(function (delimiters) {
7562 var open = delimiters[0].replace(regexEscapeRE, '\\$&');
7563 var close = delimiters[1].replace(regexEscapeRE, '\\$&');
7564 return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
7565 });
7566
7567 function parseText (
7568 text,
7569 delimiters
7570 ) {
7571 var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
7572 if (!tagRE.test(text)) {
7573 return
7574 }
7575 var tokens = [];
7576 var lastIndex = tagRE.lastIndex = 0;
7577 var match, index;
7578 while ((match = tagRE.exec(text))) {
7579 index = match.index;
7580 // push text token
7581 if (index > lastIndex) {
7582 tokens.push(JSON.stringify(text.slice(lastIndex, index)));
7583 }
7584 // tag token
7585 var exp = parseFilters(match[1].trim());
7586 tokens.push(("_s(" + exp + ")"));
7587 lastIndex = index + match[0].length;
7588 }
7589 if (lastIndex < text.length) {
7590 tokens.push(JSON.stringify(text.slice(lastIndex)));
7591 }
7592 return tokens.join('+')
7593 }
7594
7595 /* */
7596
7597 var onRE = /^@|^v-on:/;
7598 var dirRE = /^v-|^@|^:/;
7599 var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/;
7600 var forIteratorRE = /\((\{[^}]*\}|[^,]*),([^,]*)(?:,([^,]*))?\)/;
7601
7602 var argRE = /:(.*)$/;
7603 var bindRE = /^:|^v-bind:/;
7604 var modifierRE = /\.[^.]+/g;
7605
7606 var decodeHTMLCached = cached(decode);
7607
7608 // configurable state
7609 var warn$2;
7610 var delimiters;
7611 var transforms;
7612 var preTransforms;
7613 var postTransforms;
7614 var platformIsPreTag;
7615 var platformMustUseProp;
7616 var platformGetTagNamespace;
7617
7618 /**
7619 * Convert HTML string to AST.
7620 */
7621 function parse (
7622 template,
7623 options
7624 ) {
7625 warn$2 = options.warn || baseWarn;
7626 platformGetTagNamespace = options.getTagNamespace || no;
7627 platformMustUseProp = options.mustUseProp || no;
7628 platformIsPreTag = options.isPreTag || no;
7629 preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
7630 transforms = pluckModuleFunction(options.modules, 'transformNode');
7631 postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
7632 delimiters = options.delimiters;
7633
7634 var stack = [];
7635 var preserveWhitespace = options.preserveWhitespace !== false;
7636 var root;
7637 var currentParent;
7638 var inVPre = false;
7639 var inPre = false;
7640 var warned = false;
7641
7642 function warnOnce (msg) {
7643 if (!warned) {
7644 warned = true;
7645 warn$2(msg);
7646 }
7647 }
7648
7649 function endPre (element) {
7650 // check pre state
7651 if (element.pre) {
7652 inVPre = false;
7653 }
7654 if (platformIsPreTag(element.tag)) {
7655 inPre = false;
7656 }
7657 }
7658
7659 parseHTML(template, {
7660 warn: warn$2,
7661 expectHTML: options.expectHTML,
7662 isUnaryTag: options.isUnaryTag,
7663 shouldDecodeNewlines: options.shouldDecodeNewlines,
7664 start: function start (tag, attrs, unary) {
7665 // check namespace.
7666 // inherit parent ns if there is one
7667 var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
7668
7669 // handle IE svg bug
7670 /* istanbul ignore if */
7671 if (isIE && ns === 'svg') {
7672 attrs = guardIESVGBug(attrs);
7673 }
7674
7675 var element = {
7676 type: 1,
7677 tag: tag,
7678 attrsList: attrs,
7679 attrsMap: makeAttrsMap(attrs),
7680 parent: currentParent,
7681 children: []
7682 };
7683 if (ns) {
7684 element.ns = ns;
7685 }
7686
7687 if (isForbiddenTag(element) && !isServerRendering()) {
7688 element.forbidden = true;
7689 "development" !== 'production' && warn$2(
7690 'Templates should only be responsible for mapping the state to the ' +
7691 'UI. Avoid placing tags with side-effects in your templates, such as ' +
7692 "<" + tag + ">" + ', as they will not be parsed.'
7693 );
7694 }
7695
7696 // apply pre-transforms
7697 for (var i = 0; i < preTransforms.length; i++) {
7698 preTransforms[i](element, options);
7699 }
7700
7701 if (!inVPre) {
7702 processPre(element);
7703 if (element.pre) {
7704 inVPre = true;
7705 }
7706 }
7707 if (platformIsPreTag(element.tag)) {
7708 inPre = true;
7709 }
7710 if (inVPre) {
7711 processRawAttrs(element);
7712 } else {
7713 processFor(element);
7714 processIf(element);
7715 processOnce(element);
7716 processKey(element);
7717
7718 // determine whether this is a plain element after
7719 // removing structural attributes
7720 element.plain = !element.key && !attrs.length;
7721
7722 processRef(element);
7723 processSlot(element);
7724 processComponent(element);
7725 for (var i$1 = 0; i$1 < transforms.length; i$1++) {
7726 transforms[i$1](element, options);
7727 }
7728 processAttrs(element);
7729 }
7730
7731 function checkRootConstraints (el) {
7732 {
7733 if (el.tag === 'slot' || el.tag === 'template') {
7734 warnOnce(
7735 "Cannot use <" + (el.tag) + "> as component root element because it may " +
7736 'contain multiple nodes.'
7737 );
7738 }
7739 if (el.attrsMap.hasOwnProperty('v-for')) {
7740 warnOnce(
7741 'Cannot use v-for on stateful component root element because ' +
7742 'it renders multiple elements.'
7743 );
7744 }
7745 }
7746 }
7747
7748 // tree management
7749 if (!root) {
7750 root = element;
7751 checkRootConstraints(root);
7752 } else if (!stack.length) {
7753 // allow root elements with v-if, v-else-if and v-else
7754 if (root.if && (element.elseif || element.else)) {
7755 checkRootConstraints(element);
7756 addIfCondition(root, {
7757 exp: element.elseif,
7758 block: element
7759 });
7760 } else {
7761 warnOnce(
7762 "Component template should contain exactly one root element. " +
7763 "If you are using v-if on multiple elements, " +
7764 "use v-else-if to chain them instead."
7765 );
7766 }
7767 }
7768 if (currentParent && !element.forbidden) {
7769 if (element.elseif || element.else) {
7770 processIfConditions(element, currentParent);
7771 } else if (element.slotScope) { // scoped slot
7772 currentParent.plain = false;
7773 var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
7774 } else {
7775 currentParent.children.push(element);
7776 element.parent = currentParent;
7777 }
7778 }
7779 if (!unary) {
7780 currentParent = element;
7781 stack.push(element);
7782 } else {
7783 endPre(element);
7784 }
7785 // apply post-transforms
7786 for (var i$2 = 0; i$2 < postTransforms.length; i$2++) {
7787 postTransforms[i$2](element, options);
7788 }
7789 },
7790
7791 end: function end () {
7792 // remove trailing whitespace
7793 var element = stack[stack.length - 1];
7794 var lastNode = element.children[element.children.length - 1];
7795 if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) {
7796 element.children.pop();
7797 }
7798 // pop stack
7799 stack.length -= 1;
7800 currentParent = stack[stack.length - 1];
7801 endPre(element);
7802 },
7803
7804 chars: function chars (text) {
7805 if (!currentParent) {
7806 {
7807 if (text === template) {
7808 warnOnce(
7809 'Component template requires a root element, rather than just text.'
7810 );
7811 } else if ((text = text.trim())) {
7812 warnOnce(
7813 ("text \"" + text + "\" outside root element will be ignored.")
7814 );
7815 }
7816 }
7817 return
7818 }
7819 // IE textarea placeholder bug
7820 /* istanbul ignore if */
7821 if (isIE &&
7822 currentParent.tag === 'textarea' &&
7823 currentParent.attrsMap.placeholder === text) {
7824 return
7825 }
7826 var children = currentParent.children;
7827 text = inPre || text.trim()
7828 ? decodeHTMLCached(text)
7829 // only preserve whitespace if its not right after a starting tag
7830 : preserveWhitespace && children.length ? ' ' : '';
7831 if (text) {
7832 var expression;
7833 if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
7834 children.push({
7835 type: 2,
7836 expression: expression,
7837 text: text
7838 });
7839 } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
7840 children.push({
7841 type: 3,
7842 text: text
7843 });
7844 }
7845 }
7846 }
7847 });
7848 return root
7849 }
7850
7851 function processPre (el) {
7852 if (getAndRemoveAttr(el, 'v-pre') != null) {
7853 el.pre = true;
7854 }
7855 }
7856
7857 function processRawAttrs (el) {
7858 var l = el.attrsList.length;
7859 if (l) {
7860 var attrs = el.attrs = new Array(l);
7861 for (var i = 0; i < l; i++) {
7862 attrs[i] = {
7863 name: el.attrsList[i].name,
7864 value: JSON.stringify(el.attrsList[i].value)
7865 };
7866 }
7867 } else if (!el.pre) {
7868 // non root node in pre blocks with no attributes
7869 el.plain = true;
7870 }
7871 }
7872
7873 function processKey (el) {
7874 var exp = getBindingAttr(el, 'key');
7875 if (exp) {
7876 if ("development" !== 'production' && el.tag === 'template') {
7877 warn$2("<template> cannot be keyed. Place the key on real elements instead.");
7878 }
7879 el.key = exp;
7880 }
7881 }
7882
7883 function processRef (el) {
7884 var ref = getBindingAttr(el, 'ref');
7885 if (ref) {
7886 el.ref = ref;
7887 el.refInFor = checkInFor(el);
7888 }
7889 }
7890
7891 function processFor (el) {
7892 var exp;
7893 if ((exp = getAndRemoveAttr(el, 'v-for'))) {
7894 var inMatch = exp.match(forAliasRE);
7895 if (!inMatch) {
7896 "development" !== 'production' && warn$2(
7897 ("Invalid v-for expression: " + exp)
7898 );
7899 return
7900 }
7901 el.for = inMatch[2].trim();
7902 var alias = inMatch[1].trim();
7903 var iteratorMatch = alias.match(forIteratorRE);
7904 if (iteratorMatch) {
7905 el.alias = iteratorMatch[1].trim();
7906 el.iterator1 = iteratorMatch[2].trim();
7907 if (iteratorMatch[3]) {
7908 el.iterator2 = iteratorMatch[3].trim();
7909 }
7910 } else {
7911 el.alias = alias;
7912 }
7913 }
7914 }
7915
7916 function processIf (el) {
7917 var exp = getAndRemoveAttr(el, 'v-if');
7918 if (exp) {
7919 el.if = exp;
7920 addIfCondition(el, {
7921 exp: exp,
7922 block: el
7923 });
7924 } else {
7925 if (getAndRemoveAttr(el, 'v-else') != null) {
7926 el.else = true;
7927 }
7928 var elseif = getAndRemoveAttr(el, 'v-else-if');
7929 if (elseif) {
7930 el.elseif = elseif;
7931 }
7932 }
7933 }
7934
7935 function processIfConditions (el, parent) {
7936 var prev = findPrevElement(parent.children);
7937 if (prev && prev.if) {
7938 addIfCondition(prev, {
7939 exp: el.elseif,
7940 block: el
7941 });
7942 } else {
7943 warn$2(
7944 "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
7945 "used on element <" + (el.tag) + "> without corresponding v-if."
7946 );
7947 }
7948 }
7949
7950 function findPrevElement (children) {
7951 var i = children.length;
7952 while (i--) {
7953 if (children[i].type === 1) {
7954 return children[i]
7955 } else {
7956 if ("development" !== 'production' && children[i].text !== ' ') {
7957 warn$2(
7958 "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
7959 "will be ignored."
7960 );
7961 }
7962 children.pop();
7963 }
7964 }
7965 }
7966
7967 function addIfCondition (el, condition) {
7968 if (!el.ifConditions) {
7969 el.ifConditions = [];
7970 }
7971 el.ifConditions.push(condition);
7972 }
7973
7974 function processOnce (el) {
7975 var once$$1 = getAndRemoveAttr(el, 'v-once');
7976 if (once$$1 != null) {
7977 el.once = true;
7978 }
7979 }
7980
7981 function processSlot (el) {
7982 if (el.tag === 'slot') {
7983 el.slotName = getBindingAttr(el, 'name');
7984 if ("development" !== 'production' && el.key) {
7985 warn$2(
7986 "`key` does not work on <slot> because slots are abstract outlets " +
7987 "and can possibly expand into multiple elements. " +
7988 "Use the key on a wrapping element instead."
7989 );
7990 }
7991 } else {
7992 var slotTarget = getBindingAttr(el, 'slot');
7993 if (slotTarget) {
7994 el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
7995 }
7996 if (el.tag === 'template') {
7997 el.slotScope = getAndRemoveAttr(el, 'scope');
7998 }
7999 }
8000 }
8001
8002 function processComponent (el) {
8003 var binding;
8004 if ((binding = getBindingAttr(el, 'is'))) {
8005 el.component = binding;
8006 }
8007 if (getAndRemoveAttr(el, 'inline-template') != null) {
8008 el.inlineTemplate = true;
8009 }
8010 }
8011
8012 function processAttrs (el) {
8013 var list = el.attrsList;
8014 var i, l, name, rawName, value, modifiers, isProp;
8015 for (i = 0, l = list.length; i < l; i++) {
8016 name = rawName = list[i].name;
8017 value = list[i].value;
8018 if (dirRE.test(name)) {
8019 // mark element as dynamic
8020 el.hasBindings = true;
8021 // modifiers
8022 modifiers = parseModifiers(name);
8023 if (modifiers) {
8024 name = name.replace(modifierRE, '');
8025 }
8026 if (bindRE.test(name)) { // v-bind
8027 name = name.replace(bindRE, '');
8028 value = parseFilters(value);
8029 isProp = false;
8030 if (modifiers) {
8031 if (modifiers.prop) {
8032 isProp = true;
8033 name = camelize(name);
8034 if (name === 'innerHtml') { name = 'innerHTML'; }
8035 }
8036 if (modifiers.camel) {
8037 name = camelize(name);
8038 }
8039 }
8040 if (isProp || platformMustUseProp(el.tag, el.attrsMap.type, name)) {
8041 addProp(el, name, value);
8042 } else {
8043 addAttr(el, name, value);
8044 }
8045 } else if (onRE.test(name)) { // v-on
8046 name = name.replace(onRE, '');
8047 addHandler(el, name, value, modifiers);
8048 } else { // normal directives
8049 name = name.replace(dirRE, '');
8050 // parse arg
8051 var argMatch = name.match(argRE);
8052 var arg = argMatch && argMatch[1];
8053 if (arg) {
8054 name = name.slice(0, -(arg.length + 1));
8055 }
8056 addDirective(el, name, rawName, value, arg, modifiers);
8057 if ("development" !== 'production' && name === 'model') {
8058 checkForAliasModel(el, value);
8059 }
8060 }
8061 } else {
8062 // literal attribute
8063 {
8064 var expression = parseText(value, delimiters);
8065 if (expression) {
8066 warn$2(
8067 name + "=\"" + value + "\": " +
8068 'Interpolation inside attributes has been removed. ' +
8069 'Use v-bind or the colon shorthand instead. For example, ' +
8070 'instead of <div id="{{ val }}">, use <div :id="val">.'
8071 );
8072 }
8073 }
8074 addAttr(el, name, JSON.stringify(value));
8075 }
8076 }
8077 }
8078
8079 function checkInFor (el) {
8080 var parent = el;
8081 while (parent) {
8082 if (parent.for !== undefined) {
8083 return true
8084 }
8085 parent = parent.parent;
8086 }
8087 return false
8088 }
8089
8090 function parseModifiers (name) {
8091 var match = name.match(modifierRE);
8092 if (match) {
8093 var ret = {};
8094 match.forEach(function (m) { ret[m.slice(1)] = true; });
8095 return ret
8096 }
8097 }
8098
8099 function makeAttrsMap (attrs) {
8100 var map = {};
8101 for (var i = 0, l = attrs.length; i < l; i++) {
8102 if ("development" !== 'production' && map[attrs[i].name] && !isIE) {
8103 warn$2('duplicate attribute: ' + attrs[i].name);
8104 }
8105 map[attrs[i].name] = attrs[i].value;
8106 }
8107 return map
8108 }
8109
8110 function isForbiddenTag (el) {
8111 return (
8112 el.tag === 'style' ||
8113 (el.tag === 'script' && (
8114 !el.attrsMap.type ||
8115 el.attrsMap.type === 'text/javascript'
8116 ))
8117 )
8118 }
8119
8120 var ieNSBug = /^xmlns:NS\d+/;
8121 var ieNSPrefix = /^NS\d+:/;
8122
8123 /* istanbul ignore next */
8124 function guardIESVGBug (attrs) {
8125 var res = [];
8126 for (var i = 0; i < attrs.length; i++) {
8127 var attr = attrs[i];
8128 if (!ieNSBug.test(attr.name)) {
8129 attr.name = attr.name.replace(ieNSPrefix, '');
8130 res.push(attr);
8131 }
8132 }
8133 return res
8134 }
8135
8136 function checkForAliasModel (el, value) {
8137 var _el = el;
8138 while (_el) {
8139 if (_el.for && _el.alias === value) {
8140 warn$2(
8141 "<" + (el.tag) + " v-model=\"" + value + "\">: " +
8142 "You are binding v-model directly to a v-for iteration alias. " +
8143 "This will not be able to modify the v-for source array because " +
8144 "writing to the alias is like modifying a function local variable. " +
8145 "Consider using an array of objects and use v-model on an object property instead."
8146 );
8147 }
8148 _el = _el.parent;
8149 }
8150 }
8151
8152 /* */
8153
8154 var isStaticKey;
8155 var isPlatformReservedTag;
8156
8157 var genStaticKeysCached = cached(genStaticKeys$1);
8158
8159 /**
8160 * Goal of the optimizer: walk the generated template AST tree
8161 * and detect sub-trees that are purely static, i.e. parts of
8162 * the DOM that never needs to change.
8163 *
8164 * Once we detect these sub-trees, we can:
8165 *
8166 * 1. Hoist them into constants, so that we no longer need to
8167 * create fresh nodes for them on each re-render;
8168 * 2. Completely skip them in the patching process.
8169 */
8170 function optimize (root, options) {
8171 if (!root) { return }
8172 isStaticKey = genStaticKeysCached(options.staticKeys || '');
8173 isPlatformReservedTag = options.isReservedTag || no;
8174 // first pass: mark all non-static nodes.
8175 markStatic$1(root);
8176 // second pass: mark static roots.
8177 markStaticRoots(root, false);
8178 }
8179
8180 function genStaticKeys$1 (keys) {
8181 return makeMap(
8182 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
8183 (keys ? ',' + keys : '')
8184 )
8185 }
8186
8187 function markStatic$1 (node) {
8188 node.static = isStatic(node);
8189 if (node.type === 1) {
8190 // do not make component slot content static. this avoids
8191 // 1. components not able to mutate slot nodes
8192 // 2. static slot content fails for hot-reloading
8193 if (
8194 !isPlatformReservedTag(node.tag) &&
8195 node.tag !== 'slot' &&
8196 node.attrsMap['inline-template'] == null
8197 ) {
8198 return
8199 }
8200 for (var i = 0, l = node.children.length; i < l; i++) {
8201 var child = node.children[i];
8202 markStatic$1(child);
8203 if (!child.static) {
8204 node.static = false;
8205 }
8206 }
8207 }
8208 }
8209
8210 function markStaticRoots (node, isInFor) {
8211 if (node.type === 1) {
8212 if (node.static || node.once) {
8213 node.staticInFor = isInFor;
8214 }
8215 // For a node to qualify as a static root, it should have children that
8216 // are not just static text. Otherwise the cost of hoisting out will
8217 // outweigh the benefits and it's better off to just always render it fresh.
8218 if (node.static && node.children.length && !(
8219 node.children.length === 1 &&
8220 node.children[0].type === 3
8221 )) {
8222 node.staticRoot = true;
8223 return
8224 } else {
8225 node.staticRoot = false;
8226 }
8227 if (node.children) {
8228 for (var i = 0, l = node.children.length; i < l; i++) {
8229 markStaticRoots(node.children[i], isInFor || !!node.for);
8230 }
8231 }
8232 if (node.ifConditions) {
8233 walkThroughConditionsBlocks(node.ifConditions, isInFor);
8234 }
8235 }
8236 }
8237
8238 function walkThroughConditionsBlocks (conditionBlocks, isInFor) {
8239 for (var i = 1, len = conditionBlocks.length; i < len; i++) {
8240 markStaticRoots(conditionBlocks[i].block, isInFor);
8241 }
8242 }
8243
8244 function isStatic (node) {
8245 if (node.type === 2) { // expression
8246 return false
8247 }
8248 if (node.type === 3) { // text
8249 return true
8250 }
8251 return !!(node.pre || (
8252 !node.hasBindings && // no dynamic bindings
8253 !node.if && !node.for && // not v-if or v-for or v-else
8254 !isBuiltInTag(node.tag) && // not a built-in
8255 isPlatformReservedTag(node.tag) && // not a component
8256 !isDirectChildOfTemplateFor(node) &&
8257 Object.keys(node).every(isStaticKey)
8258 ))
8259 }
8260
8261 function isDirectChildOfTemplateFor (node) {
8262 while (node.parent) {
8263 node = node.parent;
8264 if (node.tag !== 'template') {
8265 return false
8266 }
8267 if (node.for) {
8268 return true
8269 }
8270 }
8271 return false
8272 }
8273
8274 /* */
8275
8276 var fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
8277 var simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/;
8278
8279 // keyCode aliases
8280 var keyCodes = {
8281 esc: 27,
8282 tab: 9,
8283 enter: 13,
8284 space: 32,
8285 up: 38,
8286 left: 37,
8287 right: 39,
8288 down: 40,
8289 'delete': [8, 46]
8290 };
8291
8292 // #4868: modifiers that prevent the execution of the listener
8293 // need to explicitly return null so that we can determine whether to remove
8294 // the listener for .once
8295 var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
8296
8297 var modifierCode = {
8298 stop: '$event.stopPropagation();',
8299 prevent: '$event.preventDefault();',
8300 self: genGuard("$event.target !== $event.currentTarget"),
8301 ctrl: genGuard("!$event.ctrlKey"),
8302 shift: genGuard("!$event.shiftKey"),
8303 alt: genGuard("!$event.altKey"),
8304 meta: genGuard("!$event.metaKey"),
8305 left: genGuard("'button' in $event && $event.button !== 0"),
8306 middle: genGuard("'button' in $event && $event.button !== 1"),
8307 right: genGuard("'button' in $event && $event.button !== 2")
8308 };
8309
8310 function genHandlers (events, native) {
8311 var res = native ? 'nativeOn:{' : 'on:{';
8312 for (var name in events) {
8313 res += "\"" + name + "\":" + (genHandler(name, events[name])) + ",";
8314 }
8315 return res.slice(0, -1) + '}'
8316 }
8317
8318 function genHandler (
8319 name,
8320 handler
8321 ) {
8322 if (!handler) {
8323 return 'function(){}'
8324 }
8325
8326 if (Array.isArray(handler)) {
8327 return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
8328 }
8329
8330 var isMethodPath = simplePathRE.test(handler.value);
8331 var isFunctionExpression = fnExpRE.test(handler.value);
8332
8333 if (!handler.modifiers) {
8334 return isMethodPath || isFunctionExpression
8335 ? handler.value
8336 : ("function($event){" + (handler.value) + "}") // inline statement
8337 } else {
8338 var code = '';
8339 var genModifierCode = '';
8340 var keys = [];
8341 for (var key in handler.modifiers) {
8342 if (modifierCode[key]) {
8343 genModifierCode += modifierCode[key];
8344 // left/right
8345 if (keyCodes[key]) {
8346 keys.push(key);
8347 }
8348 } else {
8349 keys.push(key);
8350 }
8351 }
8352 if (keys.length) {
8353 code += genKeyFilter(keys);
8354 }
8355 // Make sure modifiers like prevent and stop get executed after key filtering
8356 if (genModifierCode) {
8357 code += genModifierCode;
8358 }
8359 var handlerCode = isMethodPath
8360 ? handler.value + '($event)'
8361 : isFunctionExpression
8362 ? ("(" + (handler.value) + ")($event)")
8363 : handler.value;
8364 return ("function($event){" + code + handlerCode + "}")
8365 }
8366 }
8367
8368 function genKeyFilter (keys) {
8369 return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
8370 }
8371
8372 function genFilterCode (key) {
8373 var keyVal = parseInt(key, 10);
8374 if (keyVal) {
8375 return ("$event.keyCode!==" + keyVal)
8376 }
8377 var alias = keyCodes[key];
8378 return ("_k($event.keyCode," + (JSON.stringify(key)) + (alias ? ',' + JSON.stringify(alias) : '') + ")")
8379 }
8380
8381 /* */
8382
8383 function bind$1 (el, dir) {
8384 el.wrapData = function (code) {
8385 return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ")")
8386 };
8387 }
8388
8389 /* */
8390
8391 var baseDirectives = {
8392 bind: bind$1,
8393 cloak: noop
8394 };
8395
8396 /* */
8397
8398 // configurable state
8399 var warn$3;
8400 var transforms$1;
8401 var dataGenFns;
8402 var platformDirectives$1;
8403 var isPlatformReservedTag$1;
8404 var staticRenderFns;
8405 var onceCount;
8406 var currentOptions;
8407
8408 function generate (
8409 ast,
8410 options
8411 ) {
8412 // save previous staticRenderFns so generate calls can be nested
8413 var prevStaticRenderFns = staticRenderFns;
8414 var currentStaticRenderFns = staticRenderFns = [];
8415 var prevOnceCount = onceCount;
8416 onceCount = 0;
8417 currentOptions = options;
8418 warn$3 = options.warn || baseWarn;
8419 transforms$1 = pluckModuleFunction(options.modules, 'transformCode');
8420 dataGenFns = pluckModuleFunction(options.modules, 'genData');
8421 platformDirectives$1 = options.directives || {};
8422 isPlatformReservedTag$1 = options.isReservedTag || no;
8423 var code = ast ? genElement(ast) : '_c("div")';
8424 staticRenderFns = prevStaticRenderFns;
8425 onceCount = prevOnceCount;
8426 return {
8427 render: ("with(this){return " + code + "}"),
8428 staticRenderFns: currentStaticRenderFns
8429 }
8430 }
8431
8432 function genElement (el) {
8433 if (el.staticRoot && !el.staticProcessed) {
8434 return genStatic(el)
8435 } else if (el.once && !el.onceProcessed) {
8436 return genOnce(el)
8437 } else if (el.for && !el.forProcessed) {
8438 return genFor(el)
8439 } else if (el.if && !el.ifProcessed) {
8440 return genIf(el)
8441 } else if (el.tag === 'template' && !el.slotTarget) {
8442 return genChildren(el) || 'void 0'
8443 } else if (el.tag === 'slot') {
8444 return genSlot(el)
8445 } else {
8446 // component or element
8447 var code;
8448 if (el.component) {
8449 code = genComponent(el.component, el);
8450 } else {
8451 var data = el.plain ? undefined : genData(el);
8452
8453 var children = el.inlineTemplate ? null : genChildren(el, true);
8454 code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
8455 }
8456 // module transforms
8457 for (var i = 0; i < transforms$1.length; i++) {
8458 code = transforms$1[i](el, code);
8459 }
8460 return code
8461 }
8462 }
8463
8464 // hoist static sub-trees out
8465 function genStatic (el) {
8466 el.staticProcessed = true;
8467 staticRenderFns.push(("with(this){return " + (genElement(el)) + "}"));
8468 return ("_m(" + (staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
8469 }
8470
8471 // v-once
8472 function genOnce (el) {
8473 el.onceProcessed = true;
8474 if (el.if && !el.ifProcessed) {
8475 return genIf(el)
8476 } else if (el.staticInFor) {
8477 var key = '';
8478 var parent = el.parent;
8479 while (parent) {
8480 if (parent.for) {
8481 key = parent.key;
8482 break
8483 }
8484 parent = parent.parent;
8485 }
8486 if (!key) {
8487 "development" !== 'production' && warn$3(
8488 "v-once can only be used inside v-for that is keyed. "
8489 );
8490 return genElement(el)
8491 }
8492 return ("_o(" + (genElement(el)) + "," + (onceCount++) + (key ? ("," + key) : "") + ")")
8493 } else {
8494 return genStatic(el)
8495 }
8496 }
8497
8498 function genIf (el) {
8499 el.ifProcessed = true; // avoid recursion
8500 return genIfConditions(el.ifConditions.slice())
8501 }
8502
8503 function genIfConditions (conditions) {
8504 if (!conditions.length) {
8505 return '_e()'
8506 }
8507
8508 var condition = conditions.shift();
8509 if (condition.exp) {
8510 return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions)))
8511 } else {
8512 return ("" + (genTernaryExp(condition.block)))
8513 }
8514
8515 // v-if with v-once should generate code like (a)?_m(0):_m(1)
8516 function genTernaryExp (el) {
8517 return el.once ? genOnce(el) : genElement(el)
8518 }
8519 }
8520
8521 function genFor (el) {
8522 var exp = el.for;
8523 var alias = el.alias;
8524 var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
8525 var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
8526
8527 if (
8528 "development" !== 'production' &&
8529 maybeComponent(el) && el.tag !== 'slot' && el.tag !== 'template' && !el.key
8530 ) {
8531 warn$3(
8532 "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
8533 "v-for should have explicit keys. " +
8534 "See https://vuejs.org/guide/list.html#key for more info.",
8535 true /* tip */
8536 );
8537 }
8538
8539 el.forProcessed = true; // avoid recursion
8540 return "_l((" + exp + ")," +
8541 "function(" + alias + iterator1 + iterator2 + "){" +
8542 "return " + (genElement(el)) +
8543 '})'
8544 }
8545
8546 function genData (el) {
8547 var data = '{';
8548
8549 // directives first.
8550 // directives may mutate the el's other properties before they are generated.
8551 var dirs = genDirectives(el);
8552 if (dirs) { data += dirs + ','; }
8553
8554 // key
8555 if (el.key) {
8556 data += "key:" + (el.key) + ",";
8557 }
8558 // ref
8559 if (el.ref) {
8560 data += "ref:" + (el.ref) + ",";
8561 }
8562 if (el.refInFor) {
8563 data += "refInFor:true,";
8564 }
8565 // pre
8566 if (el.pre) {
8567 data += "pre:true,";
8568 }
8569 // record original tag name for components using "is" attribute
8570 if (el.component) {
8571 data += "tag:\"" + (el.tag) + "\",";
8572 }
8573 // module data generation functions
8574 for (var i = 0; i < dataGenFns.length; i++) {
8575 data += dataGenFns[i](el);
8576 }
8577 // attributes
8578 if (el.attrs) {
8579 data += "attrs:{" + (genProps(el.attrs)) + "},";
8580 }
8581 // DOM props
8582 if (el.props) {
8583 data += "domProps:{" + (genProps(el.props)) + "},";
8584 }
8585 // event handlers
8586 if (el.events) {
8587 data += (genHandlers(el.events)) + ",";
8588 }
8589 if (el.nativeEvents) {
8590 data += (genHandlers(el.nativeEvents, true)) + ",";
8591 }
8592 // slot target
8593 if (el.slotTarget) {
8594 data += "slot:" + (el.slotTarget) + ",";
8595 }
8596 // scoped slots
8597 if (el.scopedSlots) {
8598 data += (genScopedSlots(el.scopedSlots)) + ",";
8599 }
8600 // component v-model
8601 if (el.model) {
8602 data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
8603 }
8604 // inline-template
8605 if (el.inlineTemplate) {
8606 var inlineTemplate = genInlineTemplate(el);
8607 if (inlineTemplate) {
8608 data += inlineTemplate + ",";
8609 }
8610 }
8611 data = data.replace(/,$/, '') + '}';
8612 // v-bind data wrap
8613 if (el.wrapData) {
8614 data = el.wrapData(data);
8615 }
8616 return data
8617 }
8618
8619 function genDirectives (el) {
8620 var dirs = el.directives;
8621 if (!dirs) { return }
8622 var res = 'directives:[';
8623 var hasRuntime = false;
8624 var i, l, dir, needRuntime;
8625 for (i = 0, l = dirs.length; i < l; i++) {
8626 dir = dirs[i];
8627 needRuntime = true;
8628 var gen = platformDirectives$1[dir.name] || baseDirectives[dir.name];
8629 if (gen) {
8630 // compile-time directive that manipulates AST.
8631 // returns true if it also needs a runtime counterpart.
8632 needRuntime = !!gen(el, dir, warn$3);
8633 }
8634 if (needRuntime) {
8635 hasRuntime = true;
8636 res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:\"" + (dir.arg) + "\"") : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
8637 }
8638 }
8639 if (hasRuntime) {
8640 return res.slice(0, -1) + ']'
8641 }
8642 }
8643
8644 function genInlineTemplate (el) {
8645 var ast = el.children[0];
8646 if ("development" !== 'production' && (
8647 el.children.length > 1 || ast.type !== 1
8648 )) {
8649 warn$3('Inline-template components must have exactly one child element.');
8650 }
8651 if (ast.type === 1) {
8652 var inlineRenderFns = generate(ast, currentOptions);
8653 return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
8654 }
8655 }
8656
8657 function genScopedSlots (slots) {
8658 return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) { return genScopedSlot(key, slots[key]); }).join(',')) + "])")
8659 }
8660
8661 function genScopedSlot (key, el) {
8662 return "[" + key + ",function(" + (String(el.attrsMap.scope)) + "){" +
8663 "return " + (el.tag === 'template'
8664 ? genChildren(el) || 'void 0'
8665 : genElement(el)) + "}]"
8666 }
8667
8668 function genChildren (el, checkSkip) {
8669 var children = el.children;
8670 if (children.length) {
8671 var el$1 = children[0];
8672 // optimize single v-for
8673 if (children.length === 1 &&
8674 el$1.for &&
8675 el$1.tag !== 'template' &&
8676 el$1.tag !== 'slot') {
8677 return genElement(el$1)
8678 }
8679 var normalizationType = checkSkip ? getNormalizationType(children) : 0;
8680 return ("[" + (children.map(genNode).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
8681 }
8682 }
8683
8684 // determine the normalization needed for the children array.
8685 // 0: no normalization needed
8686 // 1: simple normalization needed (possible 1-level deep nested array)
8687 // 2: full normalization needed
8688 function getNormalizationType (children) {
8689 var res = 0;
8690 for (var i = 0; i < children.length; i++) {
8691 var el = children[i];
8692 if (el.type !== 1) {
8693 continue
8694 }
8695 if (needsNormalization(el) ||
8696 (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
8697 res = 2;
8698 break
8699 }
8700 if (maybeComponent(el) ||
8701 (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
8702 res = 1;
8703 }
8704 }
8705 return res
8706 }
8707
8708 function needsNormalization (el) {
8709 return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
8710 }
8711
8712 function maybeComponent (el) {
8713 return !isPlatformReservedTag$1(el.tag)
8714 }
8715
8716 function genNode (node) {
8717 if (node.type === 1) {
8718 return genElement(node)
8719 } else {
8720 return genText(node)
8721 }
8722 }
8723
8724 function genText (text) {
8725 return ("_v(" + (text.type === 2
8726 ? text.expression // no need for () because already wrapped in _s()
8727 : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
8728 }
8729
8730 function genSlot (el) {
8731 var slotName = el.slotName || '"default"';
8732 var children = genChildren(el);
8733 var res = "_t(" + slotName + (children ? ("," + children) : '');
8734 var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
8735 var bind$$1 = el.attrsMap['v-bind'];
8736 if ((attrs || bind$$1) && !children) {
8737 res += ",null";
8738 }
8739 if (attrs) {
8740 res += "," + attrs;
8741 }
8742 if (bind$$1) {
8743 res += (attrs ? '' : ',null') + "," + bind$$1;
8744 }
8745 return res + ')'
8746 }
8747
8748 // componentName is el.component, take it as argument to shun flow's pessimistic refinement
8749 function genComponent (componentName, el) {
8750 var children = el.inlineTemplate ? null : genChildren(el, true);
8751 return ("_c(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")")
8752 }
8753
8754 function genProps (props) {
8755 var res = '';
8756 for (var i = 0; i < props.length; i++) {
8757 var prop = props[i];
8758 res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
8759 }
8760 return res.slice(0, -1)
8761 }
8762
8763 // #3895, #4268
8764 function transformSpecialNewlines (text) {
8765 return text
8766 .replace(/\u2028/g, '\\u2028')
8767 .replace(/\u2029/g, '\\u2029')
8768 }
8769
8770 /* */
8771
8772 // these keywords should not appear inside expressions, but operators like
8773 // typeof, instanceof and in are allowed
8774 var prohibitedKeywordRE = new RegExp('\\b' + (
8775 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
8776 'super,throw,while,yield,delete,export,import,return,switch,default,' +
8777 'extends,finally,continue,debugger,function,arguments'
8778 ).split(',').join('\\b|\\b') + '\\b');
8779
8780 // these unary operators should not be used as property/method names
8781 var unaryOperatorsRE = new RegExp('\\b' + (
8782 'delete,typeof,void'
8783 ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
8784
8785 // check valid identifier for v-for
8786 var identRE = /[A-Za-z_$][\w$]*/;
8787
8788 // strip strings in expressions
8789 var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
8790
8791 // detect problematic expressions in a template
8792 function detectErrors (ast) {
8793 var errors = [];
8794 if (ast) {
8795 checkNode(ast, errors);
8796 }
8797 return errors
8798 }
8799
8800 function checkNode (node, errors) {
8801 if (node.type === 1) {
8802 for (var name in node.attrsMap) {
8803 if (dirRE.test(name)) {
8804 var value = node.attrsMap[name];
8805 if (value) {
8806 if (name === 'v-for') {
8807 checkFor(node, ("v-for=\"" + value + "\""), errors);
8808 } else if (onRE.test(name)) {
8809 checkEvent(value, (name + "=\"" + value + "\""), errors);
8810 } else {
8811 checkExpression(value, (name + "=\"" + value + "\""), errors);
8812 }
8813 }
8814 }
8815 }
8816 if (node.children) {
8817 for (var i = 0; i < node.children.length; i++) {
8818 checkNode(node.children[i], errors);
8819 }
8820 }
8821 } else if (node.type === 2) {
8822 checkExpression(node.expression, node.text, errors);
8823 }
8824 }
8825
8826 function checkEvent (exp, text, errors) {
8827 var keywordMatch = exp.replace(stripStringRE, '').match(unaryOperatorsRE);
8828 if (keywordMatch) {
8829 errors.push(
8830 "avoid using JavaScript unary operator as property name: " +
8831 "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
8832 );
8833 }
8834 checkExpression(exp, text, errors);
8835 }
8836
8837 function checkFor (node, text, errors) {
8838 checkExpression(node.for || '', text, errors);
8839 checkIdentifier(node.alias, 'v-for alias', text, errors);
8840 checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
8841 checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
8842 }
8843
8844 function checkIdentifier (ident, type, text, errors) {
8845 if (typeof ident === 'string' && !identRE.test(ident)) {
8846 errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
8847 }
8848 }
8849
8850 function checkExpression (exp, text, errors) {
8851 try {
8852 new Function(("return " + exp));
8853 } catch (e) {
8854 var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
8855 if (keywordMatch) {
8856 errors.push(
8857 "avoid using JavaScript keyword as property name: " +
8858 "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
8859 );
8860 } else {
8861 errors.push(("invalid expression: " + (text.trim())));
8862 }
8863 }
8864 }
8865
8866 /* */
8867
8868 function baseCompile (
8869 template,
8870 options
8871 ) {
8872 var ast = parse(template.trim(), options);
8873 optimize(ast, options);
8874 var code = generate(ast, options);
8875 return {
8876 ast: ast,
8877 render: code.render,
8878 staticRenderFns: code.staticRenderFns
8879 }
8880 }
8881
8882 function makeFunction (code, errors) {
8883 try {
8884 return new Function(code)
8885 } catch (err) {
8886 errors.push({ err: err, code: code });
8887 return noop
8888 }
8889 }
8890
8891 function createCompiler (baseOptions) {
8892 var functionCompileCache = Object.create(null);
8893
8894 function compile (
8895 template,
8896 options
8897 ) {
8898 var finalOptions = Object.create(baseOptions);
8899 var errors = [];
8900 var tips = [];
8901 finalOptions.warn = function (msg, tip$$1) {
8902 (tip$$1 ? tips : errors).push(msg);
8903 };
8904
8905 if (options) {
8906 // merge custom modules
8907 if (options.modules) {
8908 finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
8909 }
8910 // merge custom directives
8911 if (options.directives) {
8912 finalOptions.directives = extend(
8913 Object.create(baseOptions.directives),
8914 options.directives
8915 );
8916 }
8917 // copy other options
8918 for (var key in options) {
8919 if (key !== 'modules' && key !== 'directives') {
8920 finalOptions[key] = options[key];
8921 }
8922 }
8923 }
8924
8925 var compiled = baseCompile(template, finalOptions);
8926 {
8927 errors.push.apply(errors, detectErrors(compiled.ast));
8928 }
8929 compiled.errors = errors;
8930 compiled.tips = tips;
8931 return compiled
8932 }
8933
8934 function compileToFunctions (
8935 template,
8936 options,
8937 vm
8938 ) {
8939 options = options || {};
8940
8941 /* istanbul ignore if */
8942 {
8943 // detect possible CSP restriction
8944 try {
8945 new Function('return 1');
8946 } catch (e) {
8947 if (e.toString().match(/unsafe-eval|CSP/)) {
8948 warn(
8949 'It seems you are using the standalone build of Vue.js in an ' +
8950 'environment with Content Security Policy that prohibits unsafe-eval. ' +
8951 'The template compiler cannot work in this environment. Consider ' +
8952 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
8953 'templates into render functions.'
8954 );
8955 }
8956 }
8957 }
8958
8959 // check cache
8960 var key = options.delimiters
8961 ? String(options.delimiters) + template
8962 : template;
8963 if (functionCompileCache[key]) {
8964 return functionCompileCache[key]
8965 }
8966
8967 // compile
8968 var compiled = compile(template, options);
8969
8970 // check compilation errors/tips
8971 {
8972 if (compiled.errors && compiled.errors.length) {
8973 warn(
8974 "Error compiling template:\n\n" + template + "\n\n" +
8975 compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
8976 vm
8977 );
8978 }
8979 if (compiled.tips && compiled.tips.length) {
8980 compiled.tips.forEach(function (msg) { return tip(msg, vm); });
8981 }
8982 }
8983
8984 // turn code into functions
8985 var res = {};
8986 var fnGenErrors = [];
8987 res.render = makeFunction(compiled.render, fnGenErrors);
8988 var l = compiled.staticRenderFns.length;
8989 res.staticRenderFns = new Array(l);
8990 for (var i = 0; i < l; i++) {
8991 res.staticRenderFns[i] = makeFunction(compiled.staticRenderFns[i], fnGenErrors);
8992 }
8993
8994 // check function generation errors.
8995 // this should only happen if there is a bug in the compiler itself.
8996 // mostly for codegen development use
8997 /* istanbul ignore if */
8998 {
8999 if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
9000 warn(
9001 "Failed to generate render function:\n\n" +
9002 fnGenErrors.map(function (ref) {
9003 var err = ref.err;
9004 var code = ref.code;
9005
9006 return ((err.toString()) + " in\n\n" + code + "\n");
9007 }).join('\n'),
9008 vm
9009 );
9010 }
9011 }
9012
9013 return (functionCompileCache[key] = res)
9014 }
9015
9016 return {
9017 compile: compile,
9018 compileToFunctions: compileToFunctions
9019 }
9020 }
9021
9022 /* */
9023
9024 function transformNode (el, options) {
9025 var warn = options.warn || baseWarn;
9026 var staticClass = getAndRemoveAttr(el, 'class');
9027 if ("development" !== 'production' && staticClass) {
9028 var expression = parseText(staticClass, options.delimiters);
9029 if (expression) {
9030 warn(
9031 "class=\"" + staticClass + "\": " +
9032 'Interpolation inside attributes has been removed. ' +
9033 'Use v-bind or the colon shorthand instead. For example, ' +
9034 'instead of <div class="{{ val }}">, use <div :class="val">.'
9035 );
9036 }
9037 }
9038 if (staticClass) {
9039 el.staticClass = JSON.stringify(staticClass);
9040 }
9041 var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
9042 if (classBinding) {
9043 el.classBinding = classBinding;
9044 }
9045 }
9046
9047 function genData$1 (el) {
9048 var data = '';
9049 if (el.staticClass) {
9050 data += "staticClass:" + (el.staticClass) + ",";
9051 }
9052 if (el.classBinding) {
9053 data += "class:" + (el.classBinding) + ",";
9054 }
9055 return data
9056 }
9057
9058 var klass$1 = {
9059 staticKeys: ['staticClass'],
9060 transformNode: transformNode,
9061 genData: genData$1
9062 };
9063
9064 /* */
9065
9066 function transformNode$1 (el, options) {
9067 var warn = options.warn || baseWarn;
9068 var staticStyle = getAndRemoveAttr(el, 'style');
9069 if (staticStyle) {
9070 /* istanbul ignore if */
9071 {
9072 var expression = parseText(staticStyle, options.delimiters);
9073 if (expression) {
9074 warn(
9075 "style=\"" + staticStyle + "\": " +
9076 'Interpolation inside attributes has been removed. ' +
9077 'Use v-bind or the colon shorthand instead. For example, ' +
9078 'instead of <div style="{{ val }}">, use <div :style="val">.'
9079 );
9080 }
9081 }
9082 el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
9083 }
9084
9085 var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
9086 if (styleBinding) {
9087 el.styleBinding = styleBinding;
9088 }
9089 }
9090
9091 function genData$2 (el) {
9092 var data = '';
9093 if (el.staticStyle) {
9094 data += "staticStyle:" + (el.staticStyle) + ",";
9095 }
9096 if (el.styleBinding) {
9097 data += "style:(" + (el.styleBinding) + "),";
9098 }
9099 return data
9100 }
9101
9102 var style$1 = {
9103 staticKeys: ['staticStyle'],
9104 transformNode: transformNode$1,
9105 genData: genData$2
9106 };
9107
9108 var modules$1 = [
9109 klass$1,
9110 style$1
9111 ];
9112
9113 /* */
9114
9115 function text (el, dir) {
9116 if (dir.value) {
9117 addProp(el, 'textContent', ("_s(" + (dir.value) + ")"));
9118 }
9119 }
9120
9121 /* */
9122
9123 function html (el, dir) {
9124 if (dir.value) {
9125 addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"));
9126 }
9127 }
9128
9129 var directives$1 = {
9130 model: model,
9131 text: text,
9132 html: html
9133 };
9134
9135 /* */
9136
9137 var baseOptions = {
9138 expectHTML: true,
9139 modules: modules$1,
9140 directives: directives$1,
9141 isPreTag: isPreTag,
9142 isUnaryTag: isUnaryTag,
9143 mustUseProp: mustUseProp,
9144 isReservedTag: isReservedTag,
9145 getTagNamespace: getTagNamespace,
9146 staticKeys: genStaticKeys(modules$1)
9147 };
9148
9149 var ref$1 = createCompiler(baseOptions);
9150 var compileToFunctions = ref$1.compileToFunctions;
9151
9152 /* */
9153
9154 var idToTemplate = cached(function (id) {
9155 var el = query(id);
9156 return el && el.innerHTML
9157 });
9158
9159 var mount = Vue$3.prototype.$mount;
9160 Vue$3.prototype.$mount = function (
9161 el,
9162 hydrating
9163 ) {
9164 el = el && query(el);
9165
9166 /* istanbul ignore if */
9167 if (el === document.body || el === document.documentElement) {
9168 "development" !== 'production' && warn(
9169 "Do not mount Vue to <html> or <body> - mount to normal elements instead."
9170 );
9171 return this
9172 }
9173
9174 var options = this.$options;
9175 // resolve template/el and convert to render function
9176 if (!options.render) {
9177 var template = options.template;
9178 if (template) {
9179 if (typeof template === 'string') {
9180 if (template.charAt(0) === '#') {
9181 template = idToTemplate(template);
9182 /* istanbul ignore if */
9183 if ("development" !== 'production' && !template) {
9184 warn(
9185 ("Template element not found or is empty: " + (options.template)),
9186 this
9187 );
9188 }
9189 }
9190 } else if (template.nodeType) {
9191 template = template.innerHTML;
9192 } else {
9193 {
9194 warn('invalid template option:' + template, this);
9195 }
9196 return this
9197 }
9198 } else if (el) {
9199 template = getOuterHTML(el);
9200 }
9201 if (template) {
9202 /* istanbul ignore if */
9203 if ("development" !== 'production' && config.performance && mark) {
9204 mark('compile');
9205 }
9206
9207 var ref = compileToFunctions(template, {
9208 shouldDecodeNewlines: shouldDecodeNewlines,
9209 delimiters: options.delimiters
9210 }, this);
9211 var render = ref.render;
9212 var staticRenderFns = ref.staticRenderFns;
9213 options.render = render;
9214 options.staticRenderFns = staticRenderFns;
9215
9216 /* istanbul ignore if */
9217 if ("development" !== 'production' && config.performance && mark) {
9218 mark('compile end');
9219 measure(((this._name) + " compile"), 'compile', 'compile end');
9220 }
9221 }
9222 }
9223 return mount.call(this, el, hydrating)
9224 };
9225
9226 /**
9227 * Get outerHTML of elements, taking care
9228 * of SVG elements in IE as well.
9229 */
9230 function getOuterHTML (el) {
9231 if (el.outerHTML) {
9232 return el.outerHTML
9233 } else {
9234 var container = document.createElement('div');
9235 container.appendChild(el.cloneNode(true));
9236 return container.innerHTML
9237 }
9238 }
9239
9240 Vue$3.compile = compileToFunctions;
9241
9242 return Vue$3;
9243
9244 })));
9245
9246 /* assets/wpuf/vendor/vuex/vuex.js */
9247 /**
9248 * vuex v2.2.1
9249 * (c) 2017 Evan You
9250 * @license MIT
9251 */
9252 (function (global, factory) {
9253 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
9254 typeof define === 'function' && define.amd ? define(factory) :
9255 (global.Vuex = factory());
9256 }(this, (function () { 'use strict';
9257
9258 var applyMixin = function (Vue) {
9259 var version = Number(Vue.version.split('.')[0]);
9260
9261 if (version >= 2) {
9262 var usesInit = Vue.config._lifecycleHooks.indexOf('init') > -1;
9263 Vue.mixin(usesInit ? { init: vuexInit } : { beforeCreate: vuexInit });
9264 } else {
9265 // override init and inject vuex init procedure
9266 // for 1.x backwards compatibility.
9267 var _init = Vue.prototype._init;
9268 Vue.prototype._init = function (options) {
9269 if ( options === void 0 ) options = {};
9270
9271 options.init = options.init
9272 ? [vuexInit].concat(options.init)
9273 : vuexInit;
9274 _init.call(this, options);
9275 };
9276 }
9277
9278 /**
9279 * Vuex init hook, injected into each instances init hooks list.
9280 */
9281
9282 function vuexInit () {
9283 var options = this.$options;
9284 // store injection
9285 if (options.store) {
9286 this.$store = options.store;
9287 } else if (options.parent && options.parent.$store) {
9288 this.$store = options.parent.$store;
9289 }
9290 }
9291 };
9292
9293 var devtoolHook =
9294 typeof window !== 'undefined' &&
9295 window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
9296
9297 function devtoolPlugin (store) {
9298 if (!devtoolHook) { return }
9299
9300 store._devtoolHook = devtoolHook;
9301
9302 devtoolHook.emit('vuex:init', store);
9303
9304 devtoolHook.on('vuex:travel-to-state', function (targetState) {
9305 store.replaceState(targetState);
9306 });
9307
9308 store.subscribe(function (mutation, state) {
9309 devtoolHook.emit('vuex:mutation', mutation, state);
9310 });
9311 }
9312
9313 /**
9314 * Get the first item that pass the test
9315 * by second argument function
9316 *
9317 * @param {Array} list
9318 * @param {Function} f
9319 * @return {*}
9320 */
9321 /**
9322 * Deep copy the given object considering circular structure.
9323 * This function caches all nested objects and its copies.
9324 * If it detects circular structure, use cached copy to avoid infinite loop.
9325 *
9326 * @param {*} obj
9327 * @param {Array<Object>} cache
9328 * @return {*}
9329 */
9330
9331
9332 /**
9333 * forEach for object
9334 */
9335 function forEachValue (obj, fn) {
9336 Object.keys(obj).forEach(function (key) { return fn(obj[key], key); });
9337 }
9338
9339 function isObject (obj) {
9340 return obj !== null && typeof obj === 'object'
9341 }
9342
9343 function isPromise (val) {
9344 return val && typeof val.then === 'function'
9345 }
9346
9347 function assert (condition, msg) {
9348 if (!condition) { throw new Error(("[vuex] " + msg)) }
9349 }
9350
9351 var Module = function Module (rawModule, runtime) {
9352 this.runtime = runtime;
9353 this._children = Object.create(null);
9354 this._rawModule = rawModule;
9355 };
9356
9357 var prototypeAccessors$1 = { state: {},namespaced: {} };
9358
9359 prototypeAccessors$1.state.get = function () {
9360 return this._rawModule.state || {}
9361 };
9362
9363 prototypeAccessors$1.namespaced.get = function () {
9364 return !!this._rawModule.namespaced
9365 };
9366
9367 Module.prototype.addChild = function addChild (key, module) {
9368 this._children[key] = module;
9369 };
9370
9371 Module.prototype.removeChild = function removeChild (key) {
9372 delete this._children[key];
9373 };
9374
9375 Module.prototype.getChild = function getChild (key) {
9376 return this._children[key]
9377 };
9378
9379 Module.prototype.update = function update (rawModule) {
9380 this._rawModule.namespaced = rawModule.namespaced;
9381 if (rawModule.actions) {
9382 this._rawModule.actions = rawModule.actions;
9383 }
9384 if (rawModule.mutations) {
9385 this._rawModule.mutations = rawModule.mutations;
9386 }
9387 if (rawModule.getters) {
9388 this._rawModule.getters = rawModule.getters;
9389 }
9390 };
9391
9392 Module.prototype.forEachChild = function forEachChild (fn) {
9393 forEachValue(this._children, fn);
9394 };
9395
9396 Module.prototype.forEachGetter = function forEachGetter (fn) {
9397 if (this._rawModule.getters) {
9398 forEachValue(this._rawModule.getters, fn);
9399 }
9400 };
9401
9402 Module.prototype.forEachAction = function forEachAction (fn) {
9403 if (this._rawModule.actions) {
9404 forEachValue(this._rawModule.actions, fn);
9405 }
9406 };
9407
9408 Module.prototype.forEachMutation = function forEachMutation (fn) {
9409 if (this._rawModule.mutations) {
9410 forEachValue(this._rawModule.mutations, fn);
9411 }
9412 };
9413
9414 Object.defineProperties( Module.prototype, prototypeAccessors$1 );
9415
9416 var ModuleCollection = function ModuleCollection (rawRootModule) {
9417 var this$1 = this;
9418
9419 // register root module (Vuex.Store options)
9420 this.root = new Module(rawRootModule, false);
9421
9422 // register all nested modules
9423 if (rawRootModule.modules) {
9424 forEachValue(rawRootModule.modules, function (rawModule, key) {
9425 this$1.register([key], rawModule, false);
9426 });
9427 }
9428 };
9429
9430 ModuleCollection.prototype.get = function get (path) {
9431 return path.reduce(function (module, key) {
9432 return module.getChild(key)
9433 }, this.root)
9434 };
9435
9436 ModuleCollection.prototype.getNamespace = function getNamespace (path) {
9437 var module = this.root;
9438 return path.reduce(function (namespace, key) {
9439 module = module.getChild(key);
9440 return namespace + (module.namespaced ? key + '/' : '')
9441 }, '')
9442 };
9443
9444 ModuleCollection.prototype.update = function update$1 (rawRootModule) {
9445 update(this.root, rawRootModule);
9446 };
9447
9448 ModuleCollection.prototype.register = function register (path, rawModule, runtime) {
9449 var this$1 = this;
9450 if ( runtime === void 0 ) runtime = true;
9451
9452 var parent = this.get(path.slice(0, -1));
9453 var newModule = new Module(rawModule, runtime);
9454 parent.addChild(path[path.length - 1], newModule);
9455
9456 // register nested modules
9457 if (rawModule.modules) {
9458 forEachValue(rawModule.modules, function (rawChildModule, key) {
9459 this$1.register(path.concat(key), rawChildModule, runtime);
9460 });
9461 }
9462 };
9463
9464 ModuleCollection.prototype.unregister = function unregister (path) {
9465 var parent = this.get(path.slice(0, -1));
9466 var key = path[path.length - 1];
9467 if (!parent.getChild(key).runtime) { return }
9468
9469 parent.removeChild(key);
9470 };
9471
9472 function update (targetModule, newModule) {
9473 // update target module
9474 targetModule.update(newModule);
9475
9476 // update nested modules
9477 if (newModule.modules) {
9478 for (var key in newModule.modules) {
9479 if (!targetModule.getChild(key)) {
9480 console.warn(
9481 "[vuex] trying to add a new module '" + key + "' on hot reloading, " +
9482 'manual reload is needed'
9483 );
9484 return
9485 }
9486 update(targetModule.getChild(key), newModule.modules[key]);
9487 }
9488 }
9489 }
9490
9491 var Vue; // bind on install
9492
9493 var Store = function Store (options) {
9494 var this$1 = this;
9495 if ( options === void 0 ) options = {};
9496
9497 assert(Vue, "must call Vue.use(Vuex) before creating a store instance.");
9498 assert(typeof Promise !== 'undefined', "vuex requires a Promise polyfill in this browser.");
9499
9500 var state = options.state; if ( state === void 0 ) state = {};
9501 var plugins = options.plugins; if ( plugins === void 0 ) plugins = [];
9502 var strict = options.strict; if ( strict === void 0 ) strict = false;
9503
9504 // store internal state
9505 this._committing = false;
9506 this._actions = Object.create(null);
9507 this._mutations = Object.create(null);
9508 this._wrappedGetters = Object.create(null);
9509 this._modules = new ModuleCollection(options);
9510 this._modulesNamespaceMap = Object.create(null);
9511 this._subscribers = [];
9512 this._watcherVM = new Vue();
9513
9514 // bind commit and dispatch to self
9515 var store = this;
9516 var ref = this;
9517 var dispatch = ref.dispatch;
9518 var commit = ref.commit;
9519 this.dispatch = function boundDispatch (type, payload) {
9520 return dispatch.call(store, type, payload)
9521 };
9522 this.commit = function boundCommit (type, payload, options) {
9523 return commit.call(store, type, payload, options)
9524 };
9525
9526 // strict mode
9527 this.strict = strict;
9528
9529 // init root module.
9530 // this also recursively registers all sub-modules
9531 // and collects all module getters inside this._wrappedGetters
9532 installModule(this, state, [], this._modules.root);
9533
9534 // initialize the store vm, which is responsible for the reactivity
9535 // (also registers _wrappedGetters as computed properties)
9536 resetStoreVM(this, state);
9537
9538 // apply plugins
9539 plugins.concat(devtoolPlugin).forEach(function (plugin) { return plugin(this$1); });
9540 };
9541
9542 var prototypeAccessors = { state: {} };
9543
9544 prototypeAccessors.state.get = function () {
9545 return this._vm._data.$$state
9546 };
9547
9548 prototypeAccessors.state.set = function (v) {
9549 assert(false, "Use store.replaceState() to explicit replace store state.");
9550 };
9551
9552 Store.prototype.commit = function commit (_type, _payload, _options) {
9553 var this$1 = this;
9554
9555 // check object-style commit
9556 var ref = unifyObjectStyle(_type, _payload, _options);
9557 var type = ref.type;
9558 var payload = ref.payload;
9559 var options = ref.options;
9560
9561 var mutation = { type: type, payload: payload };
9562 var entry = this._mutations[type];
9563 if (!entry) {
9564 console.error(("[vuex] unknown mutation type: " + type));
9565 return
9566 }
9567 this._withCommit(function () {
9568 entry.forEach(function commitIterator (handler) {
9569 handler(payload);
9570 });
9571 });
9572 this._subscribers.forEach(function (sub) { return sub(mutation, this$1.state); });
9573
9574 if (options && options.silent) {
9575 console.warn(
9576 "[vuex] mutation type: " + type + ". Silent option has been removed. " +
9577 'Use the filter functionality in the vue-devtools'
9578 );
9579 }
9580 };
9581
9582 Store.prototype.dispatch = function dispatch (_type, _payload) {
9583 // check object-style dispatch
9584 var ref = unifyObjectStyle(_type, _payload);
9585 var type = ref.type;
9586 var payload = ref.payload;
9587
9588 var entry = this._actions[type];
9589 if (!entry) {
9590 console.error(("[vuex] unknown action type: " + type));
9591 return
9592 }
9593 return entry.length > 1
9594 ? Promise.all(entry.map(function (handler) { return handler(payload); }))
9595 : entry[0](payload)
9596 };
9597
9598 Store.prototype.subscribe = function subscribe (fn) {
9599 var subs = this._subscribers;
9600 if (subs.indexOf(fn) < 0) {
9601 subs.push(fn);
9602 }
9603 return function () {
9604 var i = subs.indexOf(fn);
9605 if (i > -1) {
9606 subs.splice(i, 1);
9607 }
9608 }
9609 };
9610
9611 Store.prototype.watch = function watch (getter, cb, options) {
9612 var this$1 = this;
9613
9614 assert(typeof getter === 'function', "store.watch only accepts a function.");
9615 return this._watcherVM.$watch(function () { return getter(this$1.state, this$1.getters); }, cb, options)
9616 };
9617
9618 Store.prototype.replaceState = function replaceState (state) {
9619 var this$1 = this;
9620
9621 this._withCommit(function () {
9622 this$1._vm._data.$$state = state;
9623 });
9624 };
9625
9626 Store.prototype.registerModule = function registerModule (path, rawModule) {
9627 if (typeof path === 'string') { path = [path]; }
9628 assert(Array.isArray(path), "module path must be a string or an Array.");
9629 this._modules.register(path, rawModule);
9630 installModule(this, this.state, path, this._modules.get(path));
9631 // reset store to update getters...
9632 resetStoreVM(this, this.state);
9633 };
9634
9635 Store.prototype.unregisterModule = function unregisterModule (path) {
9636 var this$1 = this;
9637
9638 if (typeof path === 'string') { path = [path]; }
9639 assert(Array.isArray(path), "module path must be a string or an Array.");
9640 this._modules.unregister(path);
9641 this._withCommit(function () {
9642 var parentState = getNestedState(this$1.state, path.slice(0, -1));
9643 Vue.delete(parentState, path[path.length - 1]);
9644 });
9645 resetStore(this);
9646 };
9647
9648 Store.prototype.hotUpdate = function hotUpdate (newOptions) {
9649 this._modules.update(newOptions);
9650 resetStore(this, true);
9651 };
9652
9653 Store.prototype._withCommit = function _withCommit (fn) {
9654 var committing = this._committing;
9655 this._committing = true;
9656 fn();
9657 this._committing = committing;
9658 };
9659
9660 Object.defineProperties( Store.prototype, prototypeAccessors );
9661
9662 function resetStore (store, hot) {
9663 store._actions = Object.create(null);
9664 store._mutations = Object.create(null);
9665 store._wrappedGetters = Object.create(null);
9666 store._modulesNamespaceMap = Object.create(null);
9667 var state = store.state;
9668 // init all modules
9669 installModule(store, state, [], store._modules.root, true);
9670 // reset vm
9671 resetStoreVM(store, state, hot);
9672 }
9673
9674 function resetStoreVM (store, state, hot) {
9675 var oldVm = store._vm;
9676
9677 // bind store public getters
9678 store.getters = {};
9679 var wrappedGetters = store._wrappedGetters;
9680 var computed = {};
9681 forEachValue(wrappedGetters, function (fn, key) {
9682 // use computed to leverage its lazy-caching mechanism
9683 computed[key] = function () { return fn(store); };
9684 Object.defineProperty(store.getters, key, {
9685 get: function () { return store._vm[key]; },
9686 enumerable: true // for local getters
9687 });
9688 });
9689
9690 // use a Vue instance to store the state tree
9691 // suppress warnings just in case the user has added
9692 // some funky global mixins
9693 var silent = Vue.config.silent;
9694 Vue.config.silent = true;
9695 store._vm = new Vue({
9696 data: {
9697 $$state: state
9698 },
9699 computed: computed
9700 });
9701 Vue.config.silent = silent;
9702
9703 // enable strict mode for new vm
9704 if (store.strict) {
9705 enableStrictMode(store);
9706 }
9707
9708 if (oldVm) {
9709 if (hot) {
9710 // dispatch changes in all subscribed watchers
9711 // to force getter re-evaluation for hot reloading.
9712 store._withCommit(function () {
9713 oldVm._data.$$state = null;
9714 });
9715 }
9716 Vue.nextTick(function () { return oldVm.$destroy(); });
9717 }
9718 }
9719
9720 function installModule (store, rootState, path, module, hot) {
9721 var isRoot = !path.length;
9722 var namespace = store._modules.getNamespace(path);
9723
9724 // register in namespace map
9725 if (namespace) {
9726 store._modulesNamespaceMap[namespace] = module;
9727 }
9728
9729 // set state
9730 if (!isRoot && !hot) {
9731 var parentState = getNestedState(rootState, path.slice(0, -1));
9732 var moduleName = path[path.length - 1];
9733 store._withCommit(function () {
9734 Vue.set(parentState, moduleName, module.state);
9735 });
9736 }
9737
9738 var local = module.context = makeLocalContext(store, namespace, path);
9739
9740 module.forEachMutation(function (mutation, key) {
9741 var namespacedType = namespace + key;
9742 registerMutation(store, namespacedType, mutation, local);
9743 });
9744
9745 module.forEachAction(function (action, key) {
9746 var namespacedType = namespace + key;
9747 registerAction(store, namespacedType, action, local);
9748 });
9749
9750 module.forEachGetter(function (getter, key) {
9751 var namespacedType = namespace + key;
9752 registerGetter(store, namespacedType, getter, local);
9753 });
9754
9755 module.forEachChild(function (child, key) {
9756 installModule(store, rootState, path.concat(key), child, hot);
9757 });
9758 }
9759
9760 /**
9761 * make localized dispatch, commit, getters and state
9762 * if there is no namespace, just use root ones
9763 */
9764 function makeLocalContext (store, namespace, path) {
9765 var noNamespace = namespace === '';
9766
9767 var local = {
9768 dispatch: noNamespace ? store.dispatch : function (_type, _payload, _options) {
9769 var args = unifyObjectStyle(_type, _payload, _options);
9770 var payload = args.payload;
9771 var options = args.options;
9772 var type = args.type;
9773
9774 if (!options || !options.root) {
9775 type = namespace + type;
9776 if (!store._actions[type]) {
9777 console.error(("[vuex] unknown local action type: " + (args.type) + ", global type: " + type));
9778 return
9779 }
9780 }
9781
9782 return store.dispatch(type, payload)
9783 },
9784
9785 commit: noNamespace ? store.commit : function (_type, _payload, _options) {
9786 var args = unifyObjectStyle(_type, _payload, _options);
9787 var payload = args.payload;
9788 var options = args.options;
9789 var type = args.type;
9790
9791 if (!options || !options.root) {
9792 type = namespace + type;
9793 if (!store._mutations[type]) {
9794 console.error(("[vuex] unknown local mutation type: " + (args.type) + ", global type: " + type));
9795 return
9796 }
9797 }
9798
9799 store.commit(type, payload, options);
9800 }
9801 };
9802
9803 // getters and state object must be gotten lazily
9804 // because they will be changed by vm update
9805 Object.defineProperties(local, {
9806 getters: {
9807 get: noNamespace
9808 ? function () { return store.getters; }
9809 : function () { return makeLocalGetters(store, namespace); }
9810 },
9811 state: {
9812 get: function () { return getNestedState(store.state, path); }
9813 }
9814 });
9815
9816 return local
9817 }
9818
9819 function makeLocalGetters (store, namespace) {
9820 var gettersProxy = {};
9821
9822 var splitPos = namespace.length;
9823 Object.keys(store.getters).forEach(function (type) {
9824 // skip if the target getter is not match this namespace
9825 if (type.slice(0, splitPos) !== namespace) { return }
9826
9827 // extract local getter type
9828 var localType = type.slice(splitPos);
9829
9830 // Add a port to the getters proxy.
9831 // Define as getter property because
9832 // we do not want to evaluate the getters in this time.
9833 Object.defineProperty(gettersProxy, localType, {
9834 get: function () { return store.getters[type]; },
9835 enumerable: true
9836 });
9837 });
9838
9839 return gettersProxy
9840 }
9841
9842 function registerMutation (store, type, handler, local) {
9843 var entry = store._mutations[type] || (store._mutations[type] = []);
9844 entry.push(function wrappedMutationHandler (payload) {
9845 handler(local.state, payload);
9846 });
9847 }
9848
9849 function registerAction (store, type, handler, local) {
9850 var entry = store._actions[type] || (store._actions[type] = []);
9851 entry.push(function wrappedActionHandler (payload, cb) {
9852 var res = handler({
9853 dispatch: local.dispatch,
9854 commit: local.commit,
9855 getters: local.getters,
9856 state: local.state,
9857 rootGetters: store.getters,
9858 rootState: store.state
9859 }, payload, cb);
9860 if (!isPromise(res)) {
9861 res = Promise.resolve(res);
9862 }
9863 if (store._devtoolHook) {
9864 return res.catch(function (err) {
9865 store._devtoolHook.emit('vuex:error', err);
9866 throw err
9867 })
9868 } else {
9869 return res
9870 }
9871 });
9872 }
9873
9874 function registerGetter (store, type, rawGetter, local) {
9875 if (store._wrappedGetters[type]) {
9876 console.error(("[vuex] duplicate getter key: " + type));
9877 return
9878 }
9879 store._wrappedGetters[type] = function wrappedGetter (store) {
9880 return rawGetter(
9881 local.state, // local state
9882 local.getters, // local getters
9883 store.state, // root state
9884 store.getters // root getters
9885 )
9886 };
9887 }
9888
9889 function enableStrictMode (store) {
9890 store._vm.$watch(function () { return this._data.$$state }, function () {
9891 assert(store._committing, "Do not mutate vuex store state outside mutation handlers.");
9892 }, { deep: true, sync: true });
9893 }
9894
9895 function getNestedState (state, path) {
9896 return path.length
9897 ? path.reduce(function (state, key) { return state[key]; }, state)
9898 : state
9899 }
9900
9901 function unifyObjectStyle (type, payload, options) {
9902 if (isObject(type) && type.type) {
9903 options = payload;
9904 payload = type;
9905 type = type.type;
9906 }
9907
9908 assert(typeof type === 'string', ("Expects string as the type, but found " + (typeof type) + "."));
9909
9910 return { type: type, payload: payload, options: options }
9911 }
9912
9913 function install (_Vue) {
9914 if (Vue) {
9915 console.error(
9916 '[vuex] already installed. Vue.use(Vuex) should be called only once.'
9917 );
9918 return
9919 }
9920 Vue = _Vue;
9921 applyMixin(Vue);
9922 }
9923
9924 // auto install in dist mode
9925 if (typeof window !== 'undefined' && window.Vue) {
9926 install(window.Vue);
9927 }
9928
9929 var mapState = normalizeNamespace(function (namespace, states) {
9930 var res = {};
9931 normalizeMap(states).forEach(function (ref) {
9932 var key = ref.key;
9933 var val = ref.val;
9934
9935 res[key] = function mappedState () {
9936 var state = this.$store.state;
9937 var getters = this.$store.getters;
9938 if (namespace) {
9939 var module = getModuleByNamespace(this.$store, 'mapState', namespace);
9940 if (!module) {
9941 return
9942 }
9943 state = module.context.state;
9944 getters = module.context.getters;
9945 }
9946 return typeof val === 'function'
9947 ? val.call(this, state, getters)
9948 : state[val]
9949 };
9950 // mark vuex getter for devtools
9951 res[key].vuex = true;
9952 });
9953 return res
9954 });
9955
9956 var mapMutations = normalizeNamespace(function (namespace, mutations) {
9957 var res = {};
9958 normalizeMap(mutations).forEach(function (ref) {
9959 var key = ref.key;
9960 var val = ref.val;
9961
9962 val = namespace + val;
9963 res[key] = function mappedMutation () {
9964 var args = [], len = arguments.length;
9965 while ( len-- ) args[ len ] = arguments[ len ];
9966
9967 if (namespace && !getModuleByNamespace(this.$store, 'mapMutations', namespace)) {
9968 return
9969 }
9970 return this.$store.commit.apply(this.$store, [val].concat(args))
9971 };
9972 });
9973 return res
9974 });
9975
9976 var mapGetters = normalizeNamespace(function (namespace, getters) {
9977 var res = {};
9978 normalizeMap(getters).forEach(function (ref) {
9979 var key = ref.key;
9980 var val = ref.val;
9981
9982 val = namespace + val;
9983 res[key] = function mappedGetter () {
9984 if (namespace && !getModuleByNamespace(this.$store, 'mapGetters', namespace)) {
9985 return
9986 }
9987 if (!(val in this.$store.getters)) {
9988 console.error(("[vuex] unknown getter: " + val));
9989 return
9990 }
9991 return this.$store.getters[val]
9992 };
9993 // mark vuex getter for devtools
9994 res[key].vuex = true;
9995 });
9996 return res
9997 });
9998
9999 var mapActions = normalizeNamespace(function (namespace, actions) {
10000 var res = {};
10001 normalizeMap(actions).forEach(function (ref) {
10002 var key = ref.key;
10003 var val = ref.val;
10004
10005 val = namespace + val;
10006 res[key] = function mappedAction () {
10007 var args = [], len = arguments.length;
10008 while ( len-- ) args[ len ] = arguments[ len ];
10009
10010 if (namespace && !getModuleByNamespace(this.$store, 'mapActions', namespace)) {
10011 return
10012 }
10013 return this.$store.dispatch.apply(this.$store, [val].concat(args))
10014 };
10015 });
10016 return res
10017 });
10018
10019 function normalizeMap (map) {
10020 return Array.isArray(map)
10021 ? map.map(function (key) { return ({ key: key, val: key }); })
10022 : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); })
10023 }
10024
10025 function normalizeNamespace (fn) {
10026 return function (namespace, map) {
10027 if (typeof namespace !== 'string') {
10028 map = namespace;
10029 namespace = '';
10030 } else if (namespace.charAt(namespace.length - 1) !== '/') {
10031 namespace += '/';
10032 }
10033 return fn(namespace, map)
10034 }
10035 }
10036
10037 function getModuleByNamespace (store, helper, namespace) {
10038 var module = store._modulesNamespaceMap[namespace];
10039 if (!module) {
10040 console.error(("[vuex] module namespace not found in " + helper + "(): " + namespace));
10041 }
10042 return module
10043 }
10044
10045 var index = {
10046 Store: Store,
10047 install: install,
10048 version: '2.2.1',
10049 mapState: mapState,
10050 mapMutations: mapMutations,
10051 mapGetters: mapGetters,
10052 mapActions: mapActions
10053 };
10054
10055 return index;
10056
10057 })));
10058
10059 /* assets/js/vendor/vue-router.js */
10060 /**
10061 * vue-router v2.3.1
10062 * (c) 2017 Evan You
10063 * @license MIT
10064 */
10065 (function (global, factory) {
10066 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
10067 typeof define === 'function' && define.amd ? define(factory) :
10068 (global.VueRouter = factory());
10069 }(this, (function () { 'use strict';
10070
10071 /* */
10072
10073 function assert (condition, message) {
10074 if (!condition) {
10075 throw new Error(("[vue-router] " + message))
10076 }
10077 }
10078
10079 function warn (condition, message) {
10080 if (!condition) {
10081 typeof console !== 'undefined' && console.warn(("[vue-router] " + message));
10082 }
10083 }
10084
10085 var View = {
10086 name: 'router-view',
10087 functional: true,
10088 props: {
10089 name: {
10090 type: String,
10091 default: 'default'
10092 }
10093 },
10094 render: function render (h, ref) {
10095 var props = ref.props;
10096 var children = ref.children;
10097 var parent = ref.parent;
10098 var data = ref.data;
10099
10100 data.routerView = true;
10101
10102 var name = props.name;
10103 var route = parent.$route;
10104 var cache = parent._routerViewCache || (parent._routerViewCache = {});
10105
10106 // determine current view depth, also check to see if the tree
10107 // has been toggled inactive but kept-alive.
10108 var depth = 0;
10109 var inactive = false;
10110 while (parent) {
10111 if (parent.$vnode && parent.$vnode.data.routerView) {
10112 depth++;
10113 }
10114 if (parent._inactive) {
10115 inactive = true;
10116 }
10117 parent = parent.$parent;
10118 }
10119 data.routerViewDepth = depth;
10120
10121 // render previous view if the tree is inactive and kept-alive
10122 if (inactive) {
10123 return h(cache[name], data, children)
10124 }
10125
10126 var matched = route.matched[depth];
10127 // render empty node if no matched route
10128 if (!matched) {
10129 cache[name] = null;
10130 return h()
10131 }
10132
10133 var component = cache[name] = matched.components[name];
10134
10135 // inject instance registration hooks
10136 var hooks = data.hook || (data.hook = {});
10137 hooks.init = function (vnode) {
10138 matched.instances[name] = vnode.child;
10139 };
10140 hooks.prepatch = function (oldVnode, vnode) {
10141 matched.instances[name] = vnode.child;
10142 };
10143 hooks.destroy = function (vnode) {
10144 if (matched.instances[name] === vnode.child) {
10145 matched.instances[name] = undefined;
10146 }
10147 };
10148
10149 // resolve props
10150 data.props = resolveProps(route, matched.props && matched.props[name]);
10151
10152 return h(component, data, children)
10153 }
10154 };
10155
10156 function resolveProps (route, config) {
10157 switch (typeof config) {
10158 case 'undefined':
10159 return
10160 case 'object':
10161 return config
10162 case 'function':
10163 return config(route)
10164 case 'boolean':
10165 return config ? route.params : undefined
10166 default:
10167 warn(false, ("props in \"" + (route.path) + "\" is a " + (typeof config) + ", expecting an object, function or boolean."));
10168 }
10169 }
10170
10171 /* */
10172
10173 var encodeReserveRE = /[!'()*]/g;
10174 var encodeReserveReplacer = function (c) { return '%' + c.charCodeAt(0).toString(16); };
10175 var commaRE = /%2C/g;
10176
10177 // fixed encodeURIComponent which is more comformant to RFC3986:
10178 // - escapes [!'()*]
10179 // - preserve commas
10180 var encode = function (str) { return encodeURIComponent(str)
10181 .replace(encodeReserveRE, encodeReserveReplacer)
10182 .replace(commaRE, ','); };
10183
10184 var decode = decodeURIComponent;
10185
10186 function resolveQuery (
10187 query,
10188 extraQuery
10189 ) {
10190 if ( extraQuery === void 0 ) extraQuery = {};
10191
10192 if (query) {
10193 var parsedQuery;
10194 try {
10195 parsedQuery = parseQuery(query);
10196 } catch (e) {
10197 "development" !== 'production' && warn(false, e.message);
10198 parsedQuery = {};
10199 }
10200 for (var key in extraQuery) {
10201 parsedQuery[key] = extraQuery[key];
10202 }
10203 return parsedQuery
10204 } else {
10205 return extraQuery
10206 }
10207 }
10208
10209 function parseQuery (query) {
10210 var res = {};
10211
10212 query = query.trim().replace(/^(\?|#|&)/, '');
10213
10214 if (!query) {
10215 return res
10216 }
10217
10218 query.split('&').forEach(function (param) {
10219 var parts = param.replace(/\+/g, ' ').split('=');
10220 var key = decode(parts.shift());
10221 var val = parts.length > 0
10222 ? decode(parts.join('='))
10223 : null;
10224
10225 if (res[key] === undefined) {
10226 res[key] = val;
10227 } else if (Array.isArray(res[key])) {
10228 res[key].push(val);
10229 } else {
10230 res[key] = [res[key], val];
10231 }
10232 });
10233
10234 return res
10235 }
10236
10237 function stringifyQuery (obj) {
10238 var res = obj ? Object.keys(obj).map(function (key) {
10239 var val = obj[key];
10240
10241 if (val === undefined) {
10242 return ''
10243 }
10244
10245 if (val === null) {
10246 return encode(key)
10247 }
10248
10249 if (Array.isArray(val)) {
10250 var result = [];
10251 val.slice().forEach(function (val2) {
10252 if (val2 === undefined) {
10253 return
10254 }
10255 if (val2 === null) {
10256 result.push(encode(key));
10257 } else {
10258 result.push(encode(key) + '=' + encode(val2));
10259 }
10260 });
10261 return result.join('&')
10262 }
10263
10264 return encode(key) + '=' + encode(val)
10265 }).filter(function (x) { return x.length > 0; }).join('&') : null;
10266 return res ? ("?" + res) : ''
10267 }
10268
10269 /* */
10270
10271 var trailingSlashRE = /\/?$/;
10272
10273 function createRoute (
10274 record,
10275 location,
10276 redirectedFrom
10277 ) {
10278 var route = {
10279 name: location.name || (record && record.name),
10280 meta: (record && record.meta) || {},
10281 path: location.path || '/',
10282 hash: location.hash || '',
10283 query: location.query || {},
10284 params: location.params || {},
10285 fullPath: getFullPath(location),
10286 matched: record ? formatMatch(record) : []
10287 };
10288 if (redirectedFrom) {
10289 route.redirectedFrom = getFullPath(redirectedFrom);
10290 }
10291 return Object.freeze(route)
10292 }
10293
10294 // the starting route that represents the initial state
10295 var START = createRoute(null, {
10296 path: '/'
10297 });
10298
10299 function formatMatch (record) {
10300 var res = [];
10301 while (record) {
10302 res.unshift(record);
10303 record = record.parent;
10304 }
10305 return res
10306 }
10307
10308 function getFullPath (ref) {
10309 var path = ref.path;
10310 var query = ref.query; if ( query === void 0 ) query = {};
10311 var hash = ref.hash; if ( hash === void 0 ) hash = '';
10312
10313 return (path || '/') + stringifyQuery(query) + hash
10314 }
10315
10316 function isSameRoute (a, b) {
10317 if (b === START) {
10318 return a === b
10319 } else if (!b) {
10320 return false
10321 } else if (a.path && b.path) {
10322 return (
10323 a.path.replace(trailingSlashRE, '') === b.path.replace(trailingSlashRE, '') &&
10324 a.hash === b.hash &&
10325 isObjectEqual(a.query, b.query)
10326 )
10327 } else if (a.name && b.name) {
10328 return (
10329 a.name === b.name &&
10330 a.hash === b.hash &&
10331 isObjectEqual(a.query, b.query) &&
10332 isObjectEqual(a.params, b.params)
10333 )
10334 } else {
10335 return false
10336 }
10337 }
10338
10339 function isObjectEqual (a, b) {
10340 if ( a === void 0 ) a = {};
10341 if ( b === void 0 ) b = {};
10342
10343 var aKeys = Object.keys(a);
10344 var bKeys = Object.keys(b);
10345 if (aKeys.length !== bKeys.length) {
10346 return false
10347 }
10348 return aKeys.every(function (key) { return String(a[key]) === String(b[key]); })
10349 }
10350
10351 function isIncludedRoute (current, target) {
10352 return (
10353 current.path.replace(trailingSlashRE, '/').indexOf(
10354 target.path.replace(trailingSlashRE, '/')
10355 ) === 0 &&
10356 (!target.hash || current.hash === target.hash) &&
10357 queryIncludes(current.query, target.query)
10358 )
10359 }
10360
10361 function queryIncludes (current, target) {
10362 for (var key in target) {
10363 if (!(key in current)) {
10364 return false
10365 }
10366 }
10367 return true
10368 }
10369
10370 /* */
10371
10372 // work around weird flow bug
10373 var toTypes = [String, Object];
10374 var eventTypes = [String, Array];
10375
10376 var Link = {
10377 name: 'router-link',
10378 props: {
10379 to: {
10380 type: toTypes,
10381 required: true
10382 },
10383 tag: {
10384 type: String,
10385 default: 'a'
10386 },
10387 exact: Boolean,
10388 append: Boolean,
10389 replace: Boolean,
10390 activeClass: String,
10391 event: {
10392 type: eventTypes,
10393 default: 'click'
10394 }
10395 },
10396 render: function render (h) {
10397 var this$1 = this;
10398
10399 var router = this.$router;
10400 var current = this.$route;
10401 var ref = router.resolve(this.to, current, this.append);
10402 var location = ref.location;
10403 var route = ref.route;
10404 var href = ref.href;
10405 var classes = {};
10406 var activeClass = this.activeClass || router.options.linkActiveClass || 'router-link-active';
10407 var compareTarget = location.path ? createRoute(null, location) : route;
10408 classes[activeClass] = this.exact
10409 ? isSameRoute(current, compareTarget)
10410 : isIncludedRoute(current, compareTarget);
10411
10412 var handler = function (e) {
10413 if (guardEvent(e)) {
10414 if (this$1.replace) {
10415 router.replace(location);
10416 } else {
10417 router.push(location);
10418 }
10419 }
10420 };
10421
10422 var on = { click: guardEvent };
10423 if (Array.isArray(this.event)) {
10424 this.event.forEach(function (e) { on[e] = handler; });
10425 } else {
10426 on[this.event] = handler;
10427 }
10428
10429 var data = {
10430 class: classes
10431 };
10432
10433 if (this.tag === 'a') {
10434 data.on = on;
10435 data.attrs = { href: href };
10436 } else {
10437 // find the first <a> child and apply listener and href
10438 var a = findAnchor(this.$slots.default);
10439 if (a) {
10440 // in case the <a> is a static node
10441 a.isStatic = false;
10442 var extend = _Vue.util.extend;
10443 var aData = a.data = extend({}, a.data);
10444 aData.on = on;
10445 var aAttrs = a.data.attrs = extend({}, a.data.attrs);
10446 aAttrs.href = href;
10447 } else {
10448 // doesn't have <a> child, apply listener to self
10449 data.on = on;
10450 }
10451 }
10452
10453 return h(this.tag, data, this.$slots.default)
10454 }
10455 };
10456
10457 function guardEvent (e) {
10458 // don't redirect with control keys
10459 if (e.metaKey || e.ctrlKey || e.shiftKey) { return }
10460 // don't redirect when preventDefault called
10461 if (e.defaultPrevented) { return }
10462 // don't redirect on right click
10463 if (e.button !== undefined && e.button !== 0) { return }
10464 // don't redirect if `target="_blank"`
10465 if (e.target && e.target.getAttribute) {
10466 var target = e.target.getAttribute('target');
10467 if (/\b_blank\b/i.test(target)) { return }
10468 }
10469 // this may be a Weex event which doesn't have this method
10470 if (e.preventDefault) {
10471 e.preventDefault();
10472 }
10473 return true
10474 }
10475
10476 function findAnchor (children) {
10477 if (children) {
10478 var child;
10479 for (var i = 0; i < children.length; i++) {
10480 child = children[i];
10481 if (child.tag === 'a') {
10482 return child
10483 }
10484 if (child.children && (child = findAnchor(child.children))) {
10485 return child
10486 }
10487 }
10488 }
10489 }
10490
10491 var _Vue;
10492
10493 function install (Vue) {
10494 if (install.installed) { return }
10495 install.installed = true;
10496
10497 _Vue = Vue;
10498
10499 Object.defineProperty(Vue.prototype, '$router', {
10500 get: function get () { return this.$root._router }
10501 });
10502
10503 Object.defineProperty(Vue.prototype, '$route', {
10504 get: function get () { return this.$root._route }
10505 });
10506
10507 Vue.mixin({
10508 beforeCreate: function beforeCreate () {
10509 if (this.$options.router) {
10510 this._router = this.$options.router;
10511 this._router.init(this);
10512 Vue.util.defineReactive(this, '_route', this._router.history.current);
10513 }
10514 }
10515 });
10516
10517 Vue.component('router-view', View);
10518 Vue.component('router-link', Link);
10519
10520 var strats = Vue.config.optionMergeStrategies;
10521 // use the same hook merging strategy for route hooks
10522 strats.beforeRouteEnter = strats.beforeRouteLeave = strats.created;
10523 }
10524
10525 /* */
10526
10527 var inBrowser = typeof window !== 'undefined';
10528
10529 /* */
10530
10531 function resolvePath (
10532 relative,
10533 base,
10534 append
10535 ) {
10536 if (relative.charAt(0) === '/') {
10537 return relative
10538 }
10539
10540 if (relative.charAt(0) === '?' || relative.charAt(0) === '#') {
10541 return base + relative
10542 }
10543
10544 var stack = base.split('/');
10545
10546 // remove trailing segment if:
10547 // - not appending
10548 // - appending to trailing slash (last segment is empty)
10549 if (!append || !stack[stack.length - 1]) {
10550 stack.pop();
10551 }
10552
10553 // resolve relative path
10554 var segments = relative.replace(/^\//, '').split('/');
10555 for (var i = 0; i < segments.length; i++) {
10556 var segment = segments[i];
10557 if (segment === '.') {
10558 continue
10559 } else if (segment === '..') {
10560 stack.pop();
10561 } else {
10562 stack.push(segment);
10563 }
10564 }
10565
10566 // ensure leading slash
10567 if (stack[0] !== '') {
10568 stack.unshift('');
10569 }
10570
10571 return stack.join('/')
10572 }
10573
10574 function parsePath (path) {
10575 var hash = '';
10576 var query = '';
10577
10578 var hashIndex = path.indexOf('#');
10579 if (hashIndex >= 0) {
10580 hash = path.slice(hashIndex);
10581 path = path.slice(0, hashIndex);
10582 }
10583
10584 var queryIndex = path.indexOf('?');
10585 if (queryIndex >= 0) {
10586 query = path.slice(queryIndex + 1);
10587 path = path.slice(0, queryIndex);
10588 }
10589
10590 return {
10591 path: path,
10592 query: query,
10593 hash: hash
10594 }
10595 }
10596
10597 function cleanPath (path) {
10598 return path.replace(/\/\//g, '/')
10599 }
10600
10601 /* */
10602
10603 function createRouteMap (
10604 routes,
10605 oldPathMap,
10606 oldNameMap
10607 ) {
10608 var pathMap = oldPathMap || Object.create(null);
10609 var nameMap = oldNameMap || Object.create(null);
10610
10611 routes.forEach(function (route) {
10612 addRouteRecord(pathMap, nameMap, route);
10613 });
10614
10615 return {
10616 pathMap: pathMap,
10617 nameMap: nameMap
10618 }
10619 }
10620
10621 function addRouteRecord (
10622 pathMap,
10623 nameMap,
10624 route,
10625 parent,
10626 matchAs
10627 ) {
10628 var path = route.path;
10629 var name = route.name;
10630 {
10631 assert(path != null, "\"path\" is required in a route configuration.");
10632 assert(
10633 typeof route.component !== 'string',
10634 "route config \"component\" for path: " + (String(path || name)) + " cannot be a " +
10635 "string id. Use an actual component instead."
10636 );
10637 }
10638
10639 var record = {
10640 path: normalizePath(path, parent),
10641 components: route.components || { default: route.component },
10642 instances: {},
10643 name: name,
10644 parent: parent,
10645 matchAs: matchAs,
10646 redirect: route.redirect,
10647 beforeEnter: route.beforeEnter,
10648 meta: route.meta || {},
10649 props: route.props == null
10650 ? {}
10651 : route.components
10652 ? route.props
10653 : { default: route.props }
10654 };
10655
10656 if (route.children) {
10657 // Warn if route is named and has a default child route.
10658 // If users navigate to this route by name, the default child will
10659 // not be rendered (GH Issue #629)
10660 {
10661 if (route.name && route.children.some(function (child) { return /^\/?$/.test(child.path); })) {
10662 warn(
10663 false,
10664 "Named Route '" + (route.name) + "' has a default child route. " +
10665 "When navigating to this named route (:to=\"{name: '" + (route.name) + "'\"), " +
10666 "the default child route will not be rendered. Remove the name from " +
10667 "this route and use the name of the default child route for named " +
10668 "links instead."
10669 );
10670 }
10671 }
10672 route.children.forEach(function (child) {
10673 var childMatchAs = matchAs
10674 ? cleanPath((matchAs + "/" + (child.path)))
10675 : undefined;
10676 addRouteRecord(pathMap, nameMap, child, record, childMatchAs);
10677 });
10678 }
10679
10680 if (route.alias !== undefined) {
10681 if (Array.isArray(route.alias)) {
10682 route.alias.forEach(function (alias) {
10683 var aliasRoute = {
10684 path: alias,
10685 children: route.children
10686 };
10687 addRouteRecord(pathMap, nameMap, aliasRoute, parent, record.path);
10688 });
10689 } else {
10690 var aliasRoute = {
10691 path: route.alias,
10692 children: route.children
10693 };
10694 addRouteRecord(pathMap, nameMap, aliasRoute, parent, record.path);
10695 }
10696 }
10697
10698 if (!pathMap[record.path]) {
10699 pathMap[record.path] = record;
10700 }
10701
10702 if (name) {
10703 if (!nameMap[name]) {
10704 nameMap[name] = record;
10705 } else if ("development" !== 'production' && !matchAs) {
10706 warn(
10707 false,
10708 "Duplicate named routes definition: " +
10709 "{ name: \"" + name + "\", path: \"" + (record.path) + "\" }"
10710 );
10711 }
10712 }
10713 }
10714
10715 function normalizePath (path, parent) {
10716 path = path.replace(/\/$/, '');
10717 if (path[0] === '/') { return path }
10718 if (parent == null) { return path }
10719 return cleanPath(((parent.path) + "/" + path))
10720 }
10721
10722 var index$1 = Array.isArray || function (arr) {
10723 return Object.prototype.toString.call(arr) == '[object Array]';
10724 };
10725
10726 var isarray = index$1;
10727
10728 /**
10729 * Expose `pathToRegexp`.
10730 */
10731 var index = pathToRegexp;
10732 var parse_1 = parse;
10733 var compile_1 = compile;
10734 var tokensToFunction_1 = tokensToFunction;
10735 var tokensToRegExp_1 = tokensToRegExp;
10736
10737 /**
10738 * The main path matching regexp utility.
10739 *
10740 * @type {RegExp}
10741 */
10742 var PATH_REGEXP = new RegExp([
10743 // Match escaped characters that would otherwise appear in future matches.
10744 // This allows the user to escape special characters that won't transform.
10745 '(\\\\.)',
10746 // Match Express-style parameters and un-named parameters with a prefix
10747 // and optional suffixes. Matches appear as:
10748 //
10749 // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
10750 // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
10751 // "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
10752 '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
10753 ].join('|'), 'g');
10754
10755 /**
10756 * Parse a string for the raw tokens.
10757 *
10758 * @param {string} str
10759 * @param {Object=} options
10760 * @return {!Array}
10761 */
10762 function parse (str, options) {
10763 var tokens = [];
10764 var key = 0;
10765 var index = 0;
10766 var path = '';
10767 var defaultDelimiter = options && options.delimiter || '/';
10768 var res;
10769
10770 while ((res = PATH_REGEXP.exec(str)) != null) {
10771 var m = res[0];
10772 var escaped = res[1];
10773 var offset = res.index;
10774 path += str.slice(index, offset);
10775 index = offset + m.length;
10776
10777 // Ignore already escaped sequences.
10778 if (escaped) {
10779 path += escaped[1];
10780 continue
10781 }
10782
10783 var next = str[index];
10784 var prefix = res[2];
10785 var name = res[3];
10786 var capture = res[4];
10787 var group = res[5];
10788 var modifier = res[6];
10789 var asterisk = res[7];
10790
10791 // Push the current path onto the tokens.
10792 if (path) {
10793 tokens.push(path);
10794 path = '';
10795 }
10796
10797 var partial = prefix != null && next != null && next !== prefix;
10798 var repeat = modifier === '+' || modifier === '*';
10799 var optional = modifier === '?' || modifier === '*';
10800 var delimiter = res[2] || defaultDelimiter;
10801 var pattern = capture || group;
10802
10803 tokens.push({
10804 name: name || key++,
10805 prefix: prefix || '',
10806 delimiter: delimiter,
10807 optional: optional,
10808 repeat: repeat,
10809 partial: partial,
10810 asterisk: !!asterisk,
10811 pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
10812 });
10813 }
10814
10815 // Match any characters still remaining.
10816 if (index < str.length) {
10817 path += str.substr(index);
10818 }
10819
10820 // If the path exists, push it onto the end.
10821 if (path) {
10822 tokens.push(path);
10823 }
10824
10825 return tokens
10826 }
10827
10828 /**
10829 * Compile a string to a template function for the path.
10830 *
10831 * @param {string} str
10832 * @param {Object=} options
10833 * @return {!function(Object=, Object=)}
10834 */
10835 function compile (str, options) {
10836 return tokensToFunction(parse(str, options))
10837 }
10838
10839 /**
10840 * Prettier encoding of URI path segments.
10841 *
10842 * @param {string}
10843 * @return {string}
10844 */
10845 function encodeURIComponentPretty (str) {
10846 return encodeURI(str).replace(/[\/?#]/g, function (c) {
10847 return '%' + c.charCodeAt(0).toString(16).toUpperCase()
10848 })
10849 }
10850
10851 /**
10852 * Encode the asterisk parameter. Similar to `pretty`, but allows slashes.
10853 *
10854 * @param {string}
10855 * @return {string}
10856 */
10857 function encodeAsterisk (str) {
10858 return encodeURI(str).replace(/[?#]/g, function (c) {
10859 return '%' + c.charCodeAt(0).toString(16).toUpperCase()
10860 })
10861 }
10862
10863 /**
10864 * Expose a method for transforming tokens into the path function.
10865 */
10866 function tokensToFunction (tokens) {
10867 // Compile all the tokens into regexps.
10868 var matches = new Array(tokens.length);
10869
10870 // Compile all the patterns before compilation.
10871 for (var i = 0; i < tokens.length; i++) {
10872 if (typeof tokens[i] === 'object') {
10873 matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$');
10874 }
10875 }
10876
10877 return function (obj, opts) {
10878 var path = '';
10879 var data = obj || {};
10880 var options = opts || {};
10881 var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent;
10882
10883 for (var i = 0; i < tokens.length; i++) {
10884 var token = tokens[i];
10885
10886 if (typeof token === 'string') {
10887 path += token;
10888
10889 continue
10890 }
10891
10892 var value = data[token.name];
10893 var segment;
10894
10895 if (value == null) {
10896 if (token.optional) {
10897 // Prepend partial segment prefixes.
10898 if (token.partial) {
10899 path += token.prefix;
10900 }
10901
10902 continue
10903 } else {
10904 throw new TypeError('Expected "' + token.name + '" to be defined')
10905 }
10906 }
10907
10908 if (isarray(value)) {
10909 if (!token.repeat) {
10910 throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`')
10911 }
10912
10913 if (value.length === 0) {
10914 if (token.optional) {
10915 continue
10916 } else {
10917 throw new TypeError('Expected "' + token.name + '" to not be empty')
10918 }
10919 }
10920
10921 for (var j = 0; j < value.length; j++) {
10922 segment = encode(value[j]);
10923
10924 if (!matches[i].test(segment)) {
10925 throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`')
10926 }
10927
10928 path += (j === 0 ? token.prefix : token.delimiter) + segment;
10929 }
10930
10931 continue
10932 }
10933
10934 segment = token.asterisk ? encodeAsterisk(value) : encode(value);
10935
10936 if (!matches[i].test(segment)) {
10937 throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"')
10938 }
10939
10940 path += token.prefix + segment;
10941 }
10942
10943 return path
10944 }
10945 }
10946
10947 /**
10948 * Escape a regular expression string.
10949 *
10950 * @param {string} str
10951 * @return {string}
10952 */
10953 function escapeString (str) {
10954 return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
10955 }
10956
10957 /**
10958 * Escape the capturing group by escaping special characters and meaning.
10959 *
10960 * @param {string} group
10961 * @return {string}
10962 */
10963 function escapeGroup (group) {
10964 return group.replace(/([=!:$\/()])/g, '\\$1')
10965 }
10966
10967 /**
10968 * Attach the keys as a property of the regexp.
10969 *
10970 * @param {!RegExp} re
10971 * @param {Array} keys
10972 * @return {!RegExp}
10973 */
10974 function attachKeys (re, keys) {
10975 re.keys = keys;
10976 return re
10977 }
10978
10979 /**
10980 * Get the flags for a regexp from the options.
10981 *
10982 * @param {Object} options
10983 * @return {string}
10984 */
10985 function flags (options) {
10986 return options.sensitive ? '' : 'i'
10987 }
10988
10989 /**
10990 * Pull out keys from a regexp.
10991 *
10992 * @param {!RegExp} path
10993 * @param {!Array} keys
10994 * @return {!RegExp}
10995 */
10996 function regexpToRegexp (path, keys) {
10997 // Use a negative lookahead to match only capturing groups.
10998 var groups = path.source.match(/\((?!\?)/g);
10999
11000 if (groups) {
11001 for (var i = 0; i < groups.length; i++) {
11002 keys.push({
11003 name: i,
11004 prefix: null,
11005 delimiter: null,
11006 optional: false,
11007 repeat: false,
11008 partial: false,
11009 asterisk: false,
11010 pattern: null
11011 });
11012 }
11013 }
11014
11015 return attachKeys(path, keys)
11016 }
11017
11018 /**
11019 * Transform an array into a regexp.
11020 *
11021 * @param {!Array} path
11022 * @param {Array} keys
11023 * @param {!Object} options
11024 * @return {!RegExp}
11025 */
11026 function arrayToRegexp (path, keys, options) {
11027 var parts = [];
11028
11029 for (var i = 0; i < path.length; i++) {
11030 parts.push(pathToRegexp(path[i], keys, options).source);
11031 }
11032
11033 var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
11034
11035 return attachKeys(regexp, keys)
11036 }
11037
11038 /**
11039 * Create a path regexp from string input.
11040 *
11041 * @param {string} path
11042 * @param {!Array} keys
11043 * @param {!Object} options
11044 * @return {!RegExp}
11045 */
11046 function stringToRegexp (path, keys, options) {
11047 return tokensToRegExp(parse(path, options), keys, options)
11048 }
11049
11050 /**
11051 * Expose a function for taking tokens and returning a RegExp.
11052 *
11053 * @param {!Array} tokens
11054 * @param {(Array|Object)=} keys
11055 * @param {Object=} options
11056 * @return {!RegExp}
11057 */
11058 function tokensToRegExp (tokens, keys, options) {
11059 if (!isarray(keys)) {
11060 options = /** @type {!Object} */ (keys || options);
11061 keys = [];
11062 }
11063
11064 options = options || {};
11065
11066 var strict = options.strict;
11067 var end = options.end !== false;
11068 var route = '';
11069
11070 // Iterate over the tokens and create our regexp string.
11071 for (var i = 0; i < tokens.length; i++) {
11072 var token = tokens[i];
11073
11074 if (typeof token === 'string') {
11075 route += escapeString(token);
11076 } else {
11077 var prefix = escapeString(token.prefix);
11078 var capture = '(?:' + token.pattern + ')';
11079
11080 keys.push(token);
11081
11082 if (token.repeat) {
11083 capture += '(?:' + prefix + capture + ')*';
11084 }
11085
11086 if (token.optional) {
11087 if (!token.partial) {
11088 capture = '(?:' + prefix + '(' + capture + '))?';
11089 } else {
11090 capture = prefix + '(' + capture + ')?';
11091 }
11092 } else {
11093 capture = prefix + '(' + capture + ')';
11094 }
11095
11096 route += capture;
11097 }
11098 }
11099
11100 var delimiter = escapeString(options.delimiter || '/');
11101 var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
11102
11103 // In non-strict mode we allow a slash at the end of match. If the path to
11104 // match already ends with a slash, we remove it for consistency. The slash
11105 // is valid at the end of a path match, not in the middle. This is important
11106 // in non-ending mode, where "/test/" shouldn't match "/test//route".
11107 if (!strict) {
11108 route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
11109 }
11110
11111 if (end) {
11112 route += '$';
11113 } else {
11114 // In non-ending mode, we need the capturing groups to match as much as
11115 // possible by using a positive lookahead to the end or next path segment.
11116 route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
11117 }
11118
11119 return attachKeys(new RegExp('^' + route, flags(options)), keys)
11120 }
11121
11122 /**
11123 * Normalize the given path string, returning a regular expression.
11124 *
11125 * An empty array can be passed in for the keys, which will hold the
11126 * placeholder key descriptions. For example, using `/user/:id`, `keys` will
11127 * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
11128 *
11129 * @param {(string|RegExp|Array)} path
11130 * @param {(Array|Object)=} keys
11131 * @param {Object=} options
11132 * @return {!RegExp}
11133 */
11134 function pathToRegexp (path, keys, options) {
11135 if (!isarray(keys)) {
11136 options = /** @type {!Object} */ (keys || options);
11137 keys = [];
11138 }
11139
11140 options = options || {};
11141
11142 if (path instanceof RegExp) {
11143 return regexpToRegexp(path, /** @type {!Array} */ (keys))
11144 }
11145
11146 if (isarray(path)) {
11147 return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options)
11148 }
11149
11150 return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)
11151 }
11152
11153 index.parse = parse_1;
11154 index.compile = compile_1;
11155 index.tokensToFunction = tokensToFunction_1;
11156 index.tokensToRegExp = tokensToRegExp_1;
11157
11158 /* */
11159
11160 var regexpCache = Object.create(null);
11161
11162 function getRouteRegex (path) {
11163 var hit = regexpCache[path];
11164 var keys, regexp;
11165
11166 if (hit) {
11167 keys = hit.keys;
11168 regexp = hit.regexp;
11169 } else {
11170 keys = [];
11171 regexp = index(path, keys);
11172 regexpCache[path] = { keys: keys, regexp: regexp };
11173 }
11174
11175 return { keys: keys, regexp: regexp }
11176 }
11177
11178 var regexpCompileCache = Object.create(null);
11179
11180 function fillParams (
11181 path,
11182 params,
11183 routeMsg
11184 ) {
11185 try {
11186 var filler =
11187 regexpCompileCache[path] ||
11188 (regexpCompileCache[path] = index.compile(path));
11189 return filler(params || {}, { pretty: true })
11190 } catch (e) {
11191 {
11192 warn(false, ("missing param for " + routeMsg + ": " + (e.message)));
11193 }
11194 return ''
11195 }
11196 }
11197
11198 /* */
11199
11200 function normalizeLocation (
11201 raw,
11202 current,
11203 append
11204 ) {
11205 var next = typeof raw === 'string' ? { path: raw } : raw;
11206 // named target
11207 if (next.name || next._normalized) {
11208 return next
11209 }
11210
11211 // relative params
11212 if (!next.path && next.params && current) {
11213 next = assign({}, next);
11214 next._normalized = true;
11215 var params = assign(assign({}, current.params), next.params);
11216 if (current.name) {
11217 next.name = current.name;
11218 next.params = params;
11219 } else if (current.matched) {
11220 var rawPath = current.matched[current.matched.length - 1].path;
11221 next.path = fillParams(rawPath, params, ("path " + (current.path)));
11222 } else {
11223 warn(false, "relative params navigation requires a current route.");
11224 }
11225 return next
11226 }
11227
11228 var parsedPath = parsePath(next.path || '');
11229 var basePath = (current && current.path) || '/';
11230 var path = parsedPath.path
11231 ? resolvePath(parsedPath.path, basePath, append || next.append)
11232 : (current && current.path) || '/';
11233 var query = resolveQuery(parsedPath.query, next.query);
11234 var hash = next.hash || parsedPath.hash;
11235 if (hash && hash.charAt(0) !== '#') {
11236 hash = "#" + hash;
11237 }
11238
11239 return {
11240 _normalized: true,
11241 path: path,
11242 query: query,
11243 hash: hash
11244 }
11245 }
11246
11247 function assign (a, b) {
11248 for (var key in b) {
11249 a[key] = b[key];
11250 }
11251 return a
11252 }
11253
11254 /* */
11255
11256 function createMatcher (routes) {
11257 var ref = createRouteMap(routes);
11258 var pathMap = ref.pathMap;
11259 var nameMap = ref.nameMap;
11260
11261 function addRoutes (routes) {
11262 createRouteMap(routes, pathMap, nameMap);
11263 }
11264
11265 function match (
11266 raw,
11267 currentRoute,
11268 redirectedFrom
11269 ) {
11270 var location = normalizeLocation(raw, currentRoute);
11271 var name = location.name;
11272
11273 if (name) {
11274 var record = nameMap[name];
11275 {
11276 warn(record, ("Route with name '" + name + "' does not exist"));
11277 }
11278 var paramNames = getRouteRegex(record.path).keys
11279 .filter(function (key) { return !key.optional; })
11280 .map(function (key) { return key.name; });
11281
11282 if (typeof location.params !== 'object') {
11283 location.params = {};
11284 }
11285
11286 if (currentRoute && typeof currentRoute.params === 'object') {
11287 for (var key in currentRoute.params) {
11288 if (!(key in location.params) && paramNames.indexOf(key) > -1) {
11289 location.params[key] = currentRoute.params[key];
11290 }
11291 }
11292 }
11293
11294 if (record) {
11295 location.path = fillParams(record.path, location.params, ("named route \"" + name + "\""));
11296 return _createRoute(record, location, redirectedFrom)
11297 }
11298 } else if (location.path) {
11299 location.params = {};
11300 for (var path in pathMap) {
11301 if (matchRoute(path, location.params, location.path)) {
11302 return _createRoute(pathMap[path], location, redirectedFrom)
11303 }
11304 }
11305 }
11306 // no match
11307 return _createRoute(null, location)
11308 }
11309
11310 function redirect (
11311 record,
11312 location
11313 ) {
11314 var originalRedirect = record.redirect;
11315 var redirect = typeof originalRedirect === 'function'
11316 ? originalRedirect(createRoute(record, location))
11317 : originalRedirect;
11318
11319 if (typeof redirect === 'string') {
11320 redirect = { path: redirect };
11321 }
11322
11323 if (!redirect || typeof redirect !== 'object') {
11324 "development" !== 'production' && warn(
11325 false, ("invalid redirect option: " + (JSON.stringify(redirect)))
11326 );
11327 return _createRoute(null, location)
11328 }
11329
11330 var re = redirect;
11331 var name = re.name;
11332 var path = re.path;
11333 var query = location.query;
11334 var hash = location.hash;
11335 var params = location.params;
11336 query = re.hasOwnProperty('query') ? re.query : query;
11337 hash = re.hasOwnProperty('hash') ? re.hash : hash;
11338 params = re.hasOwnProperty('params') ? re.params : params;
11339
11340 if (name) {
11341 // resolved named direct
11342 var targetRecord = nameMap[name];
11343 {
11344 assert(targetRecord, ("redirect failed: named route \"" + name + "\" not found."));
11345 }
11346 return match({
11347 _normalized: true,
11348 name: name,
11349 query: query,
11350 hash: hash,
11351 params: params
11352 }, undefined, location)
11353 } else if (path) {
11354 // 1. resolve relative redirect
11355 var rawPath = resolveRecordPath(path, record);
11356 // 2. resolve params
11357 var resolvedPath = fillParams(rawPath, params, ("redirect route with path \"" + rawPath + "\""));
11358 // 3. rematch with existing query and hash
11359 return match({
11360 _normalized: true,
11361 path: resolvedPath,
11362 query: query,
11363 hash: hash
11364 }, undefined, location)
11365 } else {
11366 warn(false, ("invalid redirect option: " + (JSON.stringify(redirect))));
11367 return _createRoute(null, location)
11368 }
11369 }
11370
11371 function alias (
11372 record,
11373 location,
11374 matchAs
11375 ) {
11376 var aliasedPath = fillParams(matchAs, location.params, ("aliased route with path \"" + matchAs + "\""));
11377 var aliasedMatch = match({
11378 _normalized: true,
11379 path: aliasedPath
11380 });
11381 if (aliasedMatch) {
11382 var matched = aliasedMatch.matched;
11383 var aliasedRecord = matched[matched.length - 1];
11384 location.params = aliasedMatch.params;
11385 return _createRoute(aliasedRecord, location)
11386 }
11387 return _createRoute(null, location)
11388 }
11389
11390 function _createRoute (
11391 record,
11392 location,
11393 redirectedFrom
11394 ) {
11395 if (record && record.redirect) {
11396 return redirect(record, redirectedFrom || location)
11397 }
11398 if (record && record.matchAs) {
11399 return alias(record, location, record.matchAs)
11400 }
11401 return createRoute(record, location, redirectedFrom)
11402 }
11403
11404 return {
11405 match: match,
11406 addRoutes: addRoutes
11407 }
11408 }
11409
11410 function matchRoute (
11411 path,
11412 params,
11413 pathname
11414 ) {
11415 var ref = getRouteRegex(path);
11416 var regexp = ref.regexp;
11417 var keys = ref.keys;
11418 var m = pathname.match(regexp);
11419
11420 if (!m) {
11421 return false
11422 } else if (!params) {
11423 return true
11424 }
11425
11426 for (var i = 1, len = m.length; i < len; ++i) {
11427 var key = keys[i - 1];
11428 var val = typeof m[i] === 'string' ? decodeURIComponent(m[i]) : m[i];
11429 if (key) { params[key.name] = val; }
11430 }
11431
11432 return true
11433 }
11434
11435 function resolveRecordPath (path, record) {
11436 return resolvePath(path, record.parent ? record.parent.path : '/', true)
11437 }
11438
11439 /* */
11440
11441
11442 var positionStore = Object.create(null);
11443
11444 function setupScroll () {
11445 window.addEventListener('popstate', function (e) {
11446 saveScrollPosition();
11447 if (e.state && e.state.key) {
11448 setStateKey(e.state.key);
11449 }
11450 });
11451 }
11452
11453 function handleScroll (
11454 router,
11455 to,
11456 from,
11457 isPop
11458 ) {
11459 if (!router.app) {
11460 return
11461 }
11462
11463 var behavior = router.options.scrollBehavior;
11464 if (!behavior) {
11465 return
11466 }
11467
11468 {
11469 assert(typeof behavior === 'function', "scrollBehavior must be a function");
11470 }
11471
11472 // wait until re-render finishes before scrolling
11473 router.app.$nextTick(function () {
11474 var position = getScrollPosition();
11475 var shouldScroll = behavior(to, from, isPop ? position : null);
11476 if (!shouldScroll) {
11477 return
11478 }
11479 var isObject = typeof shouldScroll === 'object';
11480 if (isObject && typeof shouldScroll.selector === 'string') {
11481 var el = document.querySelector(shouldScroll.selector);
11482 if (el) {
11483 position = getElementPosition(el);
11484 } else if (isValidPosition(shouldScroll)) {
11485 position = normalizePosition(shouldScroll);
11486 }
11487 } else if (isObject && isValidPosition(shouldScroll)) {
11488 position = normalizePosition(shouldScroll);
11489 }
11490
11491 if (position) {
11492 window.scrollTo(position.x, position.y);
11493 }
11494 });
11495 }
11496
11497 function saveScrollPosition () {
11498 var key = getStateKey();
11499 if (key) {
11500 positionStore[key] = {
11501 x: window.pageXOffset,
11502 y: window.pageYOffset
11503 };
11504 }
11505 }
11506
11507 function getScrollPosition () {
11508 var key = getStateKey();
11509 if (key) {
11510 return positionStore[key]
11511 }
11512 }
11513
11514 function getElementPosition (el) {
11515 var docEl = document.documentElement;
11516 var docRect = docEl.getBoundingClientRect();
11517 var elRect = el.getBoundingClientRect();
11518 return {
11519 x: elRect.left - docRect.left,
11520 y: elRect.top - docRect.top
11521 }
11522 }
11523
11524 function isValidPosition (obj) {
11525 return isNumber(obj.x) || isNumber(obj.y)
11526 }
11527
11528 function normalizePosition (obj) {
11529 return {
11530 x: isNumber(obj.x) ? obj.x : window.pageXOffset,
11531 y: isNumber(obj.y) ? obj.y : window.pageYOffset
11532 }
11533 }
11534
11535 function isNumber (v) {
11536 return typeof v === 'number'
11537 }
11538
11539 /* */
11540
11541 var supportsPushState = inBrowser && (function () {
11542 var ua = window.navigator.userAgent;
11543
11544 if (
11545 (ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
11546 ua.indexOf('Mobile Safari') !== -1 &&
11547 ua.indexOf('Chrome') === -1 &&
11548 ua.indexOf('Windows Phone') === -1
11549 ) {
11550 return false
11551 }
11552
11553 return window.history && 'pushState' in window.history
11554 })();
11555
11556 // use User Timing api (if present) for more accurate key precision
11557 var Time = inBrowser && window.performance && window.performance.now
11558 ? window.performance
11559 : Date;
11560
11561 var _key = genKey();
11562
11563 function genKey () {
11564 return Time.now().toFixed(3)
11565 }
11566
11567 function getStateKey () {
11568 return _key
11569 }
11570
11571 function setStateKey (key) {
11572 _key = key;
11573 }
11574
11575 function pushState (url, replace) {
11576 saveScrollPosition();
11577 // try...catch the pushState call to get around Safari
11578 // DOM Exception 18 where it limits to 100 pushState calls
11579 var history = window.history;
11580 try {
11581 if (replace) {
11582 history.replaceState({ key: _key }, '', url);
11583 } else {
11584 _key = genKey();
11585 history.pushState({ key: _key }, '', url);
11586 }
11587 } catch (e) {
11588 window.location[replace ? 'replace' : 'assign'](url);
11589 }
11590 }
11591
11592 function replaceState (url) {
11593 pushState(url, true);
11594 }
11595
11596 /* */
11597
11598 function runQueue (queue, fn, cb) {
11599 var step = function (index) {
11600 if (index >= queue.length) {
11601 cb();
11602 } else {
11603 if (queue[index]) {
11604 fn(queue[index], function () {
11605 step(index + 1);
11606 });
11607 } else {
11608 step(index + 1);
11609 }
11610 }
11611 };
11612 step(0);
11613 }
11614
11615 /* */
11616
11617
11618 var History = function History (router, base) {
11619 this.router = router;
11620 this.base = normalizeBase(base);
11621 // start with a route object that stands for "nowhere"
11622 this.current = START;
11623 this.pending = null;
11624 this.ready = false;
11625 this.readyCbs = [];
11626 };
11627
11628 History.prototype.listen = function listen (cb) {
11629 this.cb = cb;
11630 };
11631
11632 History.prototype.onReady = function onReady (cb) {
11633 if (this.ready) {
11634 cb();
11635 } else {
11636 this.readyCbs.push(cb);
11637 }
11638 };
11639
11640 History.prototype.transitionTo = function transitionTo (location, onComplete, onAbort) {
11641 var this$1 = this;
11642
11643 var route = this.router.match(location, this.current);
11644 this.confirmTransition(route, function () {
11645 this$1.updateRoute(route);
11646 onComplete && onComplete(route);
11647 this$1.ensureURL();
11648
11649 // fire ready cbs once
11650 if (!this$1.ready) {
11651 this$1.ready = true;
11652 this$1.readyCbs.forEach(function (cb) {
11653 cb(route);
11654 });
11655 }
11656 }, onAbort);
11657 };
11658
11659 History.prototype.confirmTransition = function confirmTransition (route, onComplete, onAbort) {
11660 var this$1 = this;
11661
11662 var current = this.current;
11663 var abort = function () { onAbort && onAbort(); };
11664 if (
11665 isSameRoute(route, current) &&
11666 // in the case the route map has been dynamically appended to
11667 route.matched.length === current.matched.length
11668 ) {
11669 this.ensureURL();
11670 return abort()
11671 }
11672
11673 var ref = resolveQueue(this.current.matched, route.matched);
11674 var updated = ref.updated;
11675 var deactivated = ref.deactivated;
11676 var activated = ref.activated;
11677
11678 var queue = [].concat(
11679 // in-component leave guards
11680 extractLeaveGuards(deactivated),
11681 // global before hooks
11682 this.router.beforeHooks,
11683 // in-component update hooks
11684 extractUpdateHooks(updated),
11685 // in-config enter guards
11686 activated.map(function (m) { return m.beforeEnter; }),
11687 // async components
11688 resolveAsyncComponents(activated)
11689 );
11690
11691 this.pending = route;
11692 var iterator = function (hook, next) {
11693 if (this$1.pending !== route) {
11694 return abort()
11695 }
11696 hook(route, current, function (to) {
11697 if (to === false) {
11698 // next(false) -> abort navigation, ensure current URL
11699 this$1.ensureURL(true);
11700 abort();
11701 } else if (typeof to === 'string' || typeof to === 'object') {
11702 // next('/') or next({ path: '/' }) -> redirect
11703 (typeof to === 'object' && to.replace) ? this$1.replace(to) : this$1.push(to);
11704 abort();
11705 } else {
11706 // confirm transition and pass on the value
11707 next(to);
11708 }
11709 });
11710 };
11711
11712 runQueue(queue, iterator, function () {
11713 var postEnterCbs = [];
11714 var isValid = function () { return this$1.current === route; };
11715 var enterGuards = extractEnterGuards(activated, postEnterCbs, isValid);
11716 // wait until async components are resolved before
11717 // extracting in-component enter guards
11718 runQueue(enterGuards, iterator, function () {
11719 if (this$1.pending !== route) {
11720 return abort()
11721 }
11722 this$1.pending = null;
11723 onComplete(route);
11724 if (this$1.router.app) {
11725 this$1.router.app.$nextTick(function () {
11726 postEnterCbs.forEach(function (cb) { return cb(); });
11727 });
11728 }
11729 });
11730 });
11731 };
11732
11733 History.prototype.updateRoute = function updateRoute (route) {
11734 var prev = this.current;
11735 this.current = route;
11736 this.cb && this.cb(route);
11737 this.router.afterHooks.forEach(function (hook) {
11738 hook && hook(route, prev);
11739 });
11740 };
11741
11742 function normalizeBase (base) {
11743 if (!base) {
11744 if (inBrowser) {
11745 // respect <base> tag
11746 var baseEl = document.querySelector('base');
11747 base = (baseEl && baseEl.getAttribute('href')) || '/';
11748 } else {
11749 base = '/';
11750 }
11751 }
11752 // make sure there's the starting slash
11753 if (base.charAt(0) !== '/') {
11754 base = '/' + base;
11755 }
11756 // remove trailing slash
11757 return base.replace(/\/$/, '')
11758 }
11759
11760 function resolveQueue (
11761 current,
11762 next
11763 ) {
11764 var i;
11765 var max = Math.max(current.length, next.length);
11766 for (i = 0; i < max; i++) {
11767 if (current[i] !== next[i]) {
11768 break
11769 }
11770 }
11771 return {
11772 updated: next.slice(0, i),
11773 activated: next.slice(i),
11774 deactivated: current.slice(i)
11775 }
11776 }
11777
11778 function extractGuards (
11779 records,
11780 name,
11781 bind,
11782 reverse
11783 ) {
11784 var guards = flatMapComponents(records, function (def, instance, match, key) {
11785 var guard = extractGuard(def, name);
11786 if (guard) {
11787 return Array.isArray(guard)
11788 ? guard.map(function (guard) { return bind(guard, instance, match, key); })
11789 : bind(guard, instance, match, key)
11790 }
11791 });
11792 return flatten(reverse ? guards.reverse() : guards)
11793 }
11794
11795 function extractGuard (
11796 def,
11797 key
11798 ) {
11799 if (typeof def !== 'function') {
11800 // extend now so that global mixins are applied.
11801 def = _Vue.extend(def);
11802 }
11803 return def.options[key]
11804 }
11805
11806 function extractLeaveGuards (deactivated) {
11807 return extractGuards(deactivated, 'beforeRouteLeave', bindGuard, true)
11808 }
11809
11810 function extractUpdateHooks (updated) {
11811 return extractGuards(updated, 'beforeRouteUpdate', bindGuard)
11812 }
11813
11814 function bindGuard (guard, instance) {
11815 return function boundRouteGuard () {
11816 return guard.apply(instance, arguments)
11817 }
11818 }
11819
11820 function extractEnterGuards (
11821 activated,
11822 cbs,
11823 isValid
11824 ) {
11825 return extractGuards(activated, 'beforeRouteEnter', function (guard, _, match, key) {
11826 return bindEnterGuard(guard, match, key, cbs, isValid)
11827 })
11828 }
11829
11830 function bindEnterGuard (
11831 guard,
11832 match,
11833 key,
11834 cbs,
11835 isValid
11836 ) {
11837 return function routeEnterGuard (to, from, next) {
11838 return guard(to, from, function (cb) {
11839 next(cb);
11840 if (typeof cb === 'function') {
11841 cbs.push(function () {
11842 // #750
11843 // if a router-view is wrapped with an out-in transition,
11844 // the instance may not have been registered at this time.
11845 // we will need to poll for registration until current route
11846 // is no longer valid.
11847 poll(cb, match.instances, key, isValid);
11848 });
11849 }
11850 })
11851 }
11852 }
11853
11854 function poll (
11855 cb, // somehow flow cannot infer this is a function
11856 instances,
11857 key,
11858 isValid
11859 ) {
11860 if (instances[key]) {
11861 cb(instances[key]);
11862 } else if (isValid()) {
11863 setTimeout(function () {
11864 poll(cb, instances, key, isValid);
11865 }, 16);
11866 }
11867 }
11868
11869 function resolveAsyncComponents (matched) {
11870 return flatMapComponents(matched, function (def, _, match, key) {
11871 // if it's a function and doesn't have Vue options attached,
11872 // assume it's an async component resolve function.
11873 // we are not using Vue's default async resolving mechanism because
11874 // we want to halt the navigation until the incoming component has been
11875 // resolved.
11876 if (typeof def === 'function' && !def.options) {
11877 return function (to, from, next) {
11878 var resolve = once(function (resolvedDef) {
11879 match.components[key] = resolvedDef;
11880 next();
11881 });
11882
11883 var reject = once(function (reason) {
11884 warn(false, ("Failed to resolve async component " + key + ": " + reason));
11885 next(false);
11886 });
11887
11888 var res = def(resolve, reject);
11889 if (res && typeof res.then === 'function') {
11890 res.then(resolve, reject);
11891 }
11892 }
11893 }
11894 })
11895 }
11896
11897 function flatMapComponents (
11898 matched,
11899 fn
11900 ) {
11901 return flatten(matched.map(function (m) {
11902 return Object.keys(m.components).map(function (key) { return fn(
11903 m.components[key],
11904 m.instances[key],
11905 m, key
11906 ); })
11907 }))
11908 }
11909
11910 function flatten (arr) {
11911 return Array.prototype.concat.apply([], arr)
11912 }
11913
11914 // in Webpack 2, require.ensure now also returns a Promise
11915 // so the resolve/reject functions may get called an extra time
11916 // if the user uses an arrow function shorthand that happens to
11917 // return that Promise.
11918 function once (fn) {
11919 var called = false;
11920 return function () {
11921 if (called) { return }
11922 called = true;
11923 return fn.apply(this, arguments)
11924 }
11925 }
11926
11927 /* */
11928
11929
11930 var HTML5History = (function (History$$1) {
11931 function HTML5History (router, base) {
11932 var this$1 = this;
11933
11934 History$$1.call(this, router, base);
11935
11936 var expectScroll = router.options.scrollBehavior;
11937
11938 if (expectScroll) {
11939 setupScroll();
11940 }
11941
11942 window.addEventListener('popstate', function (e) {
11943 this$1.transitionTo(getLocation(this$1.base), function (route) {
11944 if (expectScroll) {
11945 handleScroll(router, route, this$1.current, true);
11946 }
11947 });
11948 });
11949 }
11950
11951 if ( History$$1 ) HTML5History.__proto__ = History$$1;
11952 HTML5History.prototype = Object.create( History$$1 && History$$1.prototype );
11953 HTML5History.prototype.constructor = HTML5History;
11954
11955 HTML5History.prototype.go = function go (n) {
11956 window.history.go(n);
11957 };
11958
11959 HTML5History.prototype.push = function push (location, onComplete, onAbort) {
11960 var this$1 = this;
11961
11962 var ref = this;
11963 var fromRoute = ref.current;
11964 this.transitionTo(location, function (route) {
11965 pushState(cleanPath(this$1.base + route.fullPath));
11966 handleScroll(this$1.router, route, fromRoute, false);
11967 onComplete && onComplete(route);
11968 }, onAbort);
11969 };
11970
11971 HTML5History.prototype.replace = function replace (location, onComplete, onAbort) {
11972 var this$1 = this;
11973
11974 var ref = this;
11975 var fromRoute = ref.current;
11976 this.transitionTo(location, function (route) {
11977 replaceState(cleanPath(this$1.base + route.fullPath));
11978 handleScroll(this$1.router, route, fromRoute, false);
11979 onComplete && onComplete(route);
11980 }, onAbort);
11981 };
11982
11983 HTML5History.prototype.ensureURL = function ensureURL (push) {
11984 if (getLocation(this.base) !== this.current.fullPath) {
11985 var current = cleanPath(this.base + this.current.fullPath);
11986 push ? pushState(current) : replaceState(current);
11987 }
11988 };
11989
11990 HTML5History.prototype.getCurrentLocation = function getCurrentLocation () {
11991 return getLocation(this.base)
11992 };
11993
11994 return HTML5History;
11995 }(History));
11996
11997 function getLocation (base) {
11998 var path = window.location.pathname;
11999 if (base && path.indexOf(base) === 0) {
12000 path = path.slice(base.length);
12001 }
12002 return (path || '/') + window.location.search + window.location.hash
12003 }
12004
12005 /* */
12006
12007
12008 var HashHistory = (function (History$$1) {
12009 function HashHistory (router, base, fallback) {
12010 History$$1.call(this, router, base);
12011 // check history fallback deeplinking
12012 if (fallback && checkFallback(this.base)) {
12013 return
12014 }
12015 ensureSlash();
12016 }
12017
12018 if ( History$$1 ) HashHistory.__proto__ = History$$1;
12019 HashHistory.prototype = Object.create( History$$1 && History$$1.prototype );
12020 HashHistory.prototype.constructor = HashHistory;
12021
12022 // this is delayed until the app mounts
12023 // to avoid the hashchange listener being fired too early
12024 HashHistory.prototype.setupListeners = function setupListeners () {
12025 var this$1 = this;
12026
12027 window.addEventListener('hashchange', function () {
12028 if (!ensureSlash()) {
12029 return
12030 }
12031 this$1.transitionTo(getHash(), function (route) {
12032 replaceHash(route.fullPath);
12033 });
12034 });
12035 };
12036
12037 HashHistory.prototype.push = function push (location, onComplete, onAbort) {
12038 this.transitionTo(location, function (route) {
12039 pushHash(route.fullPath);
12040 onComplete && onComplete(route);
12041 }, onAbort);
12042 };
12043
12044 HashHistory.prototype.replace = function replace (location, onComplete, onAbort) {
12045 this.transitionTo(location, function (route) {
12046 replaceHash(route.fullPath);
12047 onComplete && onComplete(route);
12048 }, onAbort);
12049 };
12050
12051 HashHistory.prototype.go = function go (n) {
12052 window.history.go(n);
12053 };
12054
12055 HashHistory.prototype.ensureURL = function ensureURL (push) {
12056 var current = this.current.fullPath;
12057 if (getHash() !== current) {
12058 push ? pushHash(current) : replaceHash(current);
12059 }
12060 };
12061
12062 HashHistory.prototype.getCurrentLocation = function getCurrentLocation () {
12063 return getHash()
12064 };
12065
12066 return HashHistory;
12067 }(History));
12068
12069 function checkFallback (base) {
12070 var location = getLocation(base);
12071 if (!/^\/#/.test(location)) {
12072 window.location.replace(
12073 cleanPath(base + '/#' + location)
12074 );
12075 return true
12076 }
12077 }
12078
12079 function ensureSlash () {
12080 var path = getHash();
12081 if (path.charAt(0) === '/') {
12082 return true
12083 }
12084 replaceHash('/' + path);
12085 return false
12086 }
12087
12088 function getHash () {
12089 // We can't use window.location.hash here because it's not
12090 // consistent across browsers - Firefox will pre-decode it!
12091 var href = window.location.href;
12092 var index = href.indexOf('#');
12093 return index === -1 ? '' : href.slice(index + 1)
12094 }
12095
12096 function pushHash (path) {
12097 window.location.hash = path;
12098 }
12099
12100 function replaceHash (path) {
12101 var i = window.location.href.indexOf('#');
12102 window.location.replace(
12103 window.location.href.slice(0, i >= 0 ? i : 0) + '#' + path
12104 );
12105 }
12106
12107 /* */
12108
12109
12110 var AbstractHistory = (function (History$$1) {
12111 function AbstractHistory (router, base) {
12112 History$$1.call(this, router, base);
12113 this.stack = [];
12114 this.index = -1;
12115 }
12116
12117 if ( History$$1 ) AbstractHistory.__proto__ = History$$1;
12118 AbstractHistory.prototype = Object.create( History$$1 && History$$1.prototype );
12119 AbstractHistory.prototype.constructor = AbstractHistory;
12120
12121 AbstractHistory.prototype.push = function push (location, onComplete, onAbort) {
12122 var this$1 = this;
12123
12124 this.transitionTo(location, function (route) {
12125 this$1.stack = this$1.stack.slice(0, this$1.index + 1).concat(route);
12126 this$1.index++;
12127 onComplete && onComplete(route);
12128 }, onAbort);
12129 };
12130
12131 AbstractHistory.prototype.replace = function replace (location, onComplete, onAbort) {
12132 var this$1 = this;
12133
12134 this.transitionTo(location, function (route) {
12135 this$1.stack = this$1.stack.slice(0, this$1.index).concat(route);
12136 onComplete && onComplete(route);
12137 }, onAbort);
12138 };
12139
12140 AbstractHistory.prototype.go = function go (n) {
12141 var this$1 = this;
12142
12143 var targetIndex = this.index + n;
12144 if (targetIndex < 0 || targetIndex >= this.stack.length) {
12145 return
12146 }
12147 var route = this.stack[targetIndex];
12148 this.confirmTransition(route, function () {
12149 this$1.index = targetIndex;
12150 this$1.updateRoute(route);
12151 });
12152 };
12153
12154 AbstractHistory.prototype.getCurrentLocation = function getCurrentLocation () {
12155 var current = this.stack[this.stack.length - 1];
12156 return current ? current.fullPath : '/'
12157 };
12158
12159 AbstractHistory.prototype.ensureURL = function ensureURL () {
12160 // noop
12161 };
12162
12163 return AbstractHistory;
12164 }(History));
12165
12166 /* */
12167
12168 var VueRouter = function VueRouter (options) {
12169 if ( options === void 0 ) options = {};
12170
12171 this.app = null;
12172 this.apps = [];
12173 this.options = options;
12174 this.beforeHooks = [];
12175 this.afterHooks = [];
12176 this.matcher = createMatcher(options.routes || []);
12177
12178 var mode = options.mode || 'hash';
12179 this.fallback = mode === 'history' && !supportsPushState;
12180 if (this.fallback) {
12181 mode = 'hash';
12182 }
12183 if (!inBrowser) {
12184 mode = 'abstract';
12185 }
12186 this.mode = mode;
12187
12188 switch (mode) {
12189 case 'history':
12190 this.history = new HTML5History(this, options.base);
12191 break
12192 case 'hash':
12193 this.history = new HashHistory(this, options.base, this.fallback);
12194 break
12195 case 'abstract':
12196 this.history = new AbstractHistory(this, options.base);
12197 break
12198 default:
12199 {
12200 assert(false, ("invalid mode: " + mode));
12201 }
12202 }
12203 };
12204
12205 var prototypeAccessors = { currentRoute: {} };
12206
12207 VueRouter.prototype.match = function match (
12208 raw,
12209 current,
12210 redirectedFrom
12211 ) {
12212 return this.matcher.match(raw, current, redirectedFrom)
12213 };
12214
12215 prototypeAccessors.currentRoute.get = function () {
12216 return this.history && this.history.current
12217 };
12218
12219 VueRouter.prototype.init = function init (app /* Vue component instance */) {
12220 var this$1 = this;
12221
12222 "development" !== 'production' && assert(
12223 install.installed,
12224 "not installed. Make sure to call `Vue.use(VueRouter)` " +
12225 "before creating root instance."
12226 );
12227
12228 this.apps.push(app);
12229
12230 // main app already initialized.
12231 if (this.app) {
12232 return
12233 }
12234
12235 this.app = app;
12236
12237 var history = this.history;
12238
12239 if (history instanceof HTML5History) {
12240 history.transitionTo(history.getCurrentLocation());
12241 } else if (history instanceof HashHistory) {
12242 var setupHashListener = function () {
12243 history.setupListeners();
12244 };
12245 history.transitionTo(
12246 history.getCurrentLocation(),
12247 setupHashListener,
12248 setupHashListener
12249 );
12250 }
12251
12252 history.listen(function (route) {
12253 this$1.apps.forEach(function (app) {
12254 app._route = route;
12255 });
12256 });
12257 };
12258
12259 VueRouter.prototype.beforeEach = function beforeEach (fn) {
12260 this.beforeHooks.push(fn);
12261 };
12262
12263 VueRouter.prototype.afterEach = function afterEach (fn) {
12264 this.afterHooks.push(fn);
12265 };
12266
12267 VueRouter.prototype.onReady = function onReady (cb) {
12268 this.history.onReady(cb);
12269 };
12270
12271 VueRouter.prototype.push = function push (location, onComplete, onAbort) {
12272 this.history.push(location, onComplete, onAbort);
12273 };
12274
12275 VueRouter.prototype.replace = function replace (location, onComplete, onAbort) {
12276 this.history.replace(location, onComplete, onAbort);
12277 };
12278
12279 VueRouter.prototype.go = function go (n) {
12280 this.history.go(n);
12281 };
12282
12283 VueRouter.prototype.back = function back () {
12284 this.go(-1);
12285 };
12286
12287 VueRouter.prototype.forward = function forward () {
12288 this.go(1);
12289 };
12290
12291 VueRouter.prototype.getMatchedComponents = function getMatchedComponents (to) {
12292 var route = to
12293 ? this.resolve(to).route
12294 : this.currentRoute;
12295 if (!route) {
12296 return []
12297 }
12298 return [].concat.apply([], route.matched.map(function (m) {
12299 return Object.keys(m.components).map(function (key) {
12300 return m.components[key]
12301 })
12302 }))
12303 };
12304
12305 VueRouter.prototype.resolve = function resolve (
12306 to,
12307 current,
12308 append
12309 ) {
12310 var location = normalizeLocation(to, current || this.history.current, append);
12311 var route = this.match(location, current);
12312 var fullPath = route.redirectedFrom || route.fullPath;
12313 var base = this.history.base;
12314 var href = createHref(base, fullPath, this.mode);
12315 return {
12316 location: location,
12317 route: route,
12318 href: href,
12319 // for backwards compat
12320 normalizedTo: location,
12321 resolved: route
12322 }
12323 };
12324
12325 VueRouter.prototype.addRoutes = function addRoutes (routes) {
12326 this.matcher.addRoutes(routes);
12327 if (this.history.current !== START) {
12328 this.history.transitionTo(this.history.getCurrentLocation());
12329 }
12330 };
12331
12332 Object.defineProperties( VueRouter.prototype, prototypeAccessors );
12333
12334 function createHref (base, fullPath, mode) {
12335 var path = mode === 'hash' ? '#' + fullPath : fullPath;
12336 return base ? cleanPath(base + '/' + path) : path
12337 }
12338
12339 VueRouter.install = install;
12340 VueRouter.version = '2.3.1';
12341
12342 if (inBrowser && window.Vue) {
12343 window.Vue.use(VueRouter);
12344 }
12345
12346 return VueRouter;
12347
12348 })));
12349
12350 /* assets/js/vendor/nprogress.js */
12351 /* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress
12352 * @license MIT */
12353
12354 ;(function(root, factory) {
12355
12356 if (typeof define === 'function' && define.amd) {
12357 define(factory);
12358 } else if (typeof exports === 'object') {
12359 module.exports = factory();
12360 } else {
12361 root.NProgress = factory();
12362 }
12363
12364 })(this, function() {
12365 var NProgress = {};
12366
12367 NProgress.version = '0.2.0';
12368
12369 var Settings = NProgress.settings = {
12370 minimum: 0.08,
12371 easing: 'linear',
12372 positionUsing: '',
12373 speed: 200,
12374 trickle: true,
12375 trickleSpeed: 200,
12376 showSpinner: true,
12377 barSelector: '[role="bar"]',
12378 spinnerSelector: '[role="spinner"]',
12379 parent: 'body',
12380 template: '<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'
12381 };
12382
12383 /**
12384 * Updates configuration.
12385 *
12386 * NProgress.configure({
12387 * minimum: 0.1
12388 * });
12389 */
12390 NProgress.configure = function(options) {
12391 var key, value;
12392 for (key in options) {
12393 value = options[key];
12394 if (value !== undefined && options.hasOwnProperty(key)) Settings[key] = value;
12395 }
12396
12397 return this;
12398 };
12399
12400 /**
12401 * Last number.
12402 */
12403
12404 NProgress.status = null;
12405
12406 /**
12407 * Sets the progress bar status, where `n` is a number from `0.0` to `1.0`.
12408 *
12409 * NProgress.set(0.4);
12410 * NProgress.set(1.0);
12411 */
12412
12413 NProgress.set = function(n) {
12414 var started = NProgress.isStarted();
12415
12416 n = clamp(n, Settings.minimum, 1);
12417 NProgress.status = (n === 1 ? null : n);
12418
12419 var progress = NProgress.render(!started),
12420 bar = progress.querySelector(Settings.barSelector),
12421 speed = Settings.speed,
12422 ease = Settings.easing;
12423
12424 progress.offsetWidth; /* Repaint */
12425
12426 queue(function(next) {
12427 // Set positionUsing if it hasn't already been set
12428 if (Settings.positionUsing === '') Settings.positionUsing = NProgress.getPositioningCSS();
12429
12430 // Add transition
12431 css(bar, barPositionCSS(n, speed, ease));
12432
12433 if (n === 1) {
12434 // Fade out
12435 css(progress, {
12436 transition: 'none',
12437 opacity: 1
12438 });
12439 progress.offsetWidth; /* Repaint */
12440
12441 setTimeout(function() {
12442 css(progress, {
12443 transition: 'all ' + speed + 'ms linear',
12444 opacity: 0
12445 });
12446 setTimeout(function() {
12447 NProgress.remove();
12448 next();
12449 }, speed);
12450 }, speed);
12451 } else {
12452 setTimeout(next, speed);
12453 }
12454 });
12455
12456 return this;
12457 };
12458
12459 NProgress.isStarted = function() {
12460 return typeof NProgress.status === 'number';
12461 };
12462
12463 /**
12464 * Shows the progress bar.
12465 * This is the same as setting the status to 0%, except that it doesn't go backwards.
12466 *
12467 * NProgress.start();
12468 *
12469 */
12470 NProgress.start = function() {
12471 if (!NProgress.status) NProgress.set(0);
12472
12473 var work = function() {
12474 setTimeout(function() {
12475 if (!NProgress.status) return;
12476 NProgress.trickle();
12477 work();
12478 }, Settings.trickleSpeed);
12479 };
12480
12481 if (Settings.trickle) work();
12482
12483 return this;
12484 };
12485
12486 /**
12487 * Hides the progress bar.
12488 * This is the *sort of* the same as setting the status to 100%, with the
12489 * difference being `done()` makes some placebo effect of some realistic motion.
12490 *
12491 * NProgress.done();
12492 *
12493 * If `true` is passed, it will show the progress bar even if its hidden.
12494 *
12495 * NProgress.done(true);
12496 */
12497
12498 NProgress.done = function(force) {
12499 if (!force && !NProgress.status) return this;
12500
12501 return NProgress.inc(0.3 + 0.5 * Math.random()).set(1);
12502 };
12503
12504 /**
12505 * Increments by a random amount.
12506 */
12507
12508 NProgress.inc = function(amount) {
12509 var n = NProgress.status;
12510
12511 if (!n) {
12512 return NProgress.start();
12513 } else if(n > 1) {
12514 return;
12515 } else {
12516 if (typeof amount !== 'number') {
12517 if (n >= 0 && n < 0.2) { amount = 0.1; }
12518 else if (n >= 0.2 && n < 0.5) { amount = 0.04; }
12519 else if (n >= 0.5 && n < 0.8) { amount = 0.02; }
12520 else if (n >= 0.8 && n < 0.99) { amount = 0.005; }
12521 else { amount = 0; }
12522 }
12523
12524 n = clamp(n + amount, 0, 0.994);
12525 return NProgress.set(n);
12526 }
12527 };
12528
12529 NProgress.trickle = function() {
12530 return NProgress.inc();
12531 };
12532
12533 /**
12534 * Waits for all supplied jQuery promises and
12535 * increases the progress as the promises resolve.
12536 *
12537 * @param $promise jQUery Promise
12538 */
12539 (function() {
12540 var initial = 0, current = 0;
12541
12542 NProgress.promise = function($promise) {
12543 if (!$promise || $promise.state() === "resolved") {
12544 return this;
12545 }
12546
12547 if (current === 0) {
12548 NProgress.start();
12549 }
12550
12551 initial++;
12552 current++;
12553
12554 $promise.always(function() {
12555 current--;
12556 if (current === 0) {
12557 initial = 0;
12558 NProgress.done();
12559 } else {
12560 NProgress.set((initial - current) / initial);
12561 }
12562 });
12563
12564 return this;
12565 };
12566
12567 })();
12568
12569 /**
12570 * (Internal) renders the progress bar markup based on the `template`
12571 * setting.
12572 */
12573
12574 NProgress.render = function(fromStart) {
12575 if (NProgress.isRendered()) return document.getElementById('nprogress');
12576
12577 addClass(document.documentElement, 'nprogress-busy');
12578
12579 var progress = document.createElement('div');
12580 progress.id = 'nprogress';
12581 progress.innerHTML = Settings.template;
12582
12583 var bar = progress.querySelector(Settings.barSelector),
12584 perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0),
12585 parent = document.querySelector(Settings.parent),
12586 spinner;
12587
12588 css(bar, {
12589 transition: 'all 0 linear',
12590 transform: 'translate3d(' + perc + '%,0,0)'
12591 });
12592
12593 if (!Settings.showSpinner) {
12594 spinner = progress.querySelector(Settings.spinnerSelector);
12595 spinner && removeElement(spinner);
12596 }
12597
12598 if (parent != document.body) {
12599 addClass(parent, 'nprogress-custom-parent');
12600 }
12601
12602 parent.appendChild(progress);
12603 return progress;
12604 };
12605
12606 /**
12607 * Removes the element. Opposite of render().
12608 */
12609
12610 NProgress.remove = function() {
12611 removeClass(document.documentElement, 'nprogress-busy');
12612 removeClass(document.querySelector(Settings.parent), 'nprogress-custom-parent');
12613 var progress = document.getElementById('nprogress');
12614 progress && removeElement(progress);
12615 };
12616
12617 /**
12618 * Checks if the progress bar is rendered.
12619 */
12620
12621 NProgress.isRendered = function() {
12622 return !!document.getElementById('nprogress');
12623 };
12624
12625 /**
12626 * Determine which positioning CSS rule to use.
12627 */
12628
12629 NProgress.getPositioningCSS = function() {
12630 // Sniff on document.body.style
12631 var bodyStyle = document.body.style;
12632
12633 // Sniff prefixes
12634 var vendorPrefix = ('WebkitTransform' in bodyStyle) ? 'Webkit' :
12635 ('MozTransform' in bodyStyle) ? 'Moz' :
12636 ('msTransform' in bodyStyle) ? 'ms' :
12637 ('OTransform' in bodyStyle) ? 'O' : '';
12638
12639 if (vendorPrefix + 'Perspective' in bodyStyle) {
12640 // Modern browsers with 3D support, e.g. Webkit, IE10
12641 return 'translate3d';
12642 } else if (vendorPrefix + 'Transform' in bodyStyle) {
12643 // Browsers without 3D support, e.g. IE9
12644 return 'translate';
12645 } else {
12646 // Browsers without translate() support, e.g. IE7-8
12647 return 'margin';
12648 }
12649 };
12650
12651 /**
12652 * Helpers
12653 */
12654
12655 function clamp(n, min, max) {
12656 if (n < min) return min;
12657 if (n > max) return max;
12658 return n;
12659 }
12660
12661 /**
12662 * (Internal) converts a percentage (`0..1`) to a bar translateX
12663 * percentage (`-100%..0%`).
12664 */
12665
12666 function toBarPerc(n) {
12667 return (-1 + n) * 100;
12668 }
12669
12670
12671 /**
12672 * (Internal) returns the correct CSS for changing the bar's
12673 * position given an n percentage, and speed and ease from Settings
12674 */
12675
12676 function barPositionCSS(n, speed, ease) {
12677 var barCSS;
12678
12679 if (Settings.positionUsing === 'translate3d') {
12680 barCSS = { transform: 'translate3d('+toBarPerc(n)+'%,0,0)' };
12681 } else if (Settings.positionUsing === 'translate') {
12682 barCSS = { transform: 'translate('+toBarPerc(n)+'%,0)' };
12683 } else {
12684 barCSS = { 'margin-left': toBarPerc(n)+'%' };
12685 }
12686
12687 barCSS.transition = 'all '+speed+'ms '+ease;
12688
12689 return barCSS;
12690 }
12691
12692 /**
12693 * (Internal) Queues a function to be executed.
12694 */
12695
12696 var queue = (function() {
12697 var pending = [];
12698
12699 function next() {
12700 var fn = pending.shift();
12701 if (fn) {
12702 fn(next);
12703 }
12704 }
12705
12706 return function(fn) {
12707 pending.push(fn);
12708 if (pending.length == 1) next();
12709 };
12710 })();
12711
12712 /**
12713 * (Internal) Applies css properties to an element, similar to the jQuery
12714 * css method.
12715 *
12716 * While this helper does assist with vendor prefixed property names, it
12717 * does not perform any manipulation of values prior to setting styles.
12718 */
12719
12720 var css = (function() {
12721 var cssPrefixes = [ 'Webkit', 'O', 'Moz', 'ms' ],
12722 cssProps = {};
12723
12724 function camelCase(string) {
12725 return string.replace(/^-ms-/, 'ms-').replace(/-([\da-z])/gi, function(match, letter) {
12726 return letter.toUpperCase();
12727 });
12728 }
12729
12730 function getVendorProp(name) {
12731 var style = document.body.style;
12732 if (name in style) return name;
12733
12734 var i = cssPrefixes.length,
12735 capName = name.charAt(0).toUpperCase() + name.slice(1),
12736 vendorName;
12737 while (i--) {
12738 vendorName = cssPrefixes[i] + capName;
12739 if (vendorName in style) return vendorName;
12740 }
12741
12742 return name;
12743 }
12744
12745 function getStyleProp(name) {
12746 name = camelCase(name);
12747 return cssProps[name] || (cssProps[name] = getVendorProp(name));
12748 }
12749
12750 function applyCss(element, prop, value) {
12751 prop = getStyleProp(prop);
12752 element.style[prop] = value;
12753 }
12754
12755 return function(element, properties) {
12756 var args = arguments,
12757 prop,
12758 value;
12759
12760 if (args.length == 2) {
12761 for (prop in properties) {
12762 value = properties[prop];
12763 if (value !== undefined && properties.hasOwnProperty(prop)) applyCss(element, prop, value);
12764 }
12765 } else {
12766 applyCss(element, args[1], args[2]);
12767 }
12768 }
12769 })();
12770
12771 /**
12772 * (Internal) Determines if an element or space separated list of class names contains a class name.
12773 */
12774
12775 function hasClass(element, name) {
12776 var list = typeof element == 'string' ? element : classList(element);
12777 return list.indexOf(' ' + name + ' ') >= 0;
12778 }
12779
12780 /**
12781 * (Internal) Adds a class to an element.
12782 */
12783
12784 function addClass(element, name) {
12785 var oldList = classList(element),
12786 newList = oldList + name;
12787
12788 if (hasClass(oldList, name)) return;
12789
12790 // Trim the opening space.
12791 element.className = newList.substring(1);
12792 }
12793
12794 /**
12795 * (Internal) Removes a class from an element.
12796 */
12797
12798 function removeClass(element, name) {
12799 var oldList = classList(element),
12800 newList;
12801
12802 if (!hasClass(element, name)) return;
12803
12804 // Replace the class name.
12805 newList = oldList.replace(' ' + name + ' ', ' ');
12806
12807 // Trim the opening and closing spaces.
12808 element.className = newList.substring(1, newList.length - 1);
12809 }
12810
12811 /**
12812 * (Internal) Gets a space separated list of the class names on the element.
12813 * The list is wrapped with a single space on each end to facilitate finding
12814 * matches within the list.
12815 */
12816
12817 function classList(element) {
12818 return (' ' + (element && element.className || '') + ' ').replace(/\s+/gi, ' ');
12819 }
12820
12821 /**
12822 * (Internal) Removes an element from the DOM.
12823 */
12824
12825 function removeElement(element) {
12826 element && element.parentNode && element.parentNode.removeChild(element);
12827 }
12828
12829 return NProgress;
12830 });
12831
12832 /* assets/wpuf/js/jquery-ui-timepicker-addon.js */
12833 /*
12834 * jQuery timepicker addon
12835 * By: Trent Richardson [http://trentrichardson.com]
12836 * Version 1.2
12837 * Last Modified: 02/02/2013
12838 *
12839 * Copyright 2013 Trent Richardson
12840 * You may use this project under MIT or GPL licenses.
12841 * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
12842 * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
12843 */
12844
12845 /*jslint evil: true, white: false, undef: false, nomen: false */
12846
12847 (function($) {
12848
12849 /*
12850 * Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded"
12851 */
12852 $.ui.timepicker = $.ui.timepicker || {};
12853 if ($.ui.timepicker.version) {
12854 return;
12855 }
12856
12857 /*
12858 * Extend jQueryUI, get it started with our version number
12859 */
12860 $.extend($.ui, {
12861 timepicker: {
12862 version: "1.2"
12863 }
12864 });
12865
12866 /*
12867 * Timepicker manager.
12868 * Use the singleton instance of this class, $.timepicker, to interact with the time picker.
12869 * Settings for (groups of) time pickers are maintained in an instance object,
12870 * allowing multiple different settings on the same page.
12871 */
12872 var Timepicker = function() {
12873 this.regional = []; // Available regional settings, indexed by language code
12874 this.regional[''] = { // Default regional settings
12875 currentText: 'Now',
12876 closeText: 'Done',
12877 amNames: ['AM', 'A'],
12878 pmNames: ['PM', 'P'],
12879 timeFormat: 'HH:mm',
12880 timeSuffix: '',
12881 timeOnlyTitle: 'Choose Time',
12882 timeText: 'Time',
12883 hourText: 'Hour',
12884 minuteText: 'Minute',
12885 secondText: 'Second',
12886 millisecText: 'Millisecond',
12887 timezoneText: 'Time Zone',
12888 isRTL: false
12889 };
12890 this._defaults = { // Global defaults for all the datetime picker instances
12891 showButtonPanel: true,
12892 timeOnly: false,
12893 showHour: true,
12894 showMinute: true,
12895 showSecond: false,
12896 showMillisec: false,
12897 showTimezone: false,
12898 showTime: true,
12899 stepHour: 1,
12900 stepMinute: 1,
12901 stepSecond: 1,
12902 stepMillisec: 1,
12903 hour: 0,
12904 minute: 0,
12905 second: 0,
12906 millisec: 0,
12907 timezone: null,
12908 useLocalTimezone: false,
12909 defaultTimezone: "+0000",
12910 hourMin: 0,
12911 minuteMin: 0,
12912 secondMin: 0,
12913 millisecMin: 0,
12914 hourMax: 23,
12915 minuteMax: 59,
12916 secondMax: 59,
12917 millisecMax: 999,
12918 minDateTime: null,
12919 maxDateTime: null,
12920 onSelect: null,
12921 hourGrid: 0,
12922 minuteGrid: 0,
12923 secondGrid: 0,
12924 millisecGrid: 0,
12925 alwaysSetTime: true,
12926 separator: ' ',
12927 altFieldTimeOnly: true,
12928 altTimeFormat: null,
12929 altSeparator: null,
12930 altTimeSuffix: null,
12931 pickerTimeFormat: null,
12932 pickerTimeSuffix: null,
12933 showTimepicker: true,
12934 timezoneIso8601: false,
12935 timezoneList: null,
12936 addSliderAccess: false,
12937 sliderAccessArgs: null,
12938 controlType: 'slider',
12939 defaultValue: null,
12940 parse: 'strict'
12941 };
12942 $.extend(this._defaults, this.regional['']);
12943 };
12944
12945 $.extend(Timepicker.prototype, {
12946 $input: null,
12947 $altInput: null,
12948 $timeObj: null,
12949 inst: null,
12950 hour_slider: null,
12951 minute_slider: null,
12952 second_slider: null,
12953 millisec_slider: null,
12954 timezone_select: null,
12955 hour: 0,
12956 minute: 0,
12957 second: 0,
12958 millisec: 0,
12959 timezone: null,
12960 defaultTimezone: "+0000",
12961 hourMinOriginal: null,
12962 minuteMinOriginal: null,
12963 secondMinOriginal: null,
12964 millisecMinOriginal: null,
12965 hourMaxOriginal: null,
12966 minuteMaxOriginal: null,
12967 secondMaxOriginal: null,
12968 millisecMaxOriginal: null,
12969 ampm: '',
12970 formattedDate: '',
12971 formattedTime: '',
12972 formattedDateTime: '',
12973 timezoneList: null,
12974 units: ['hour','minute','second','millisec'],
12975 control: null,
12976
12977 /*
12978 * Override the default settings for all instances of the time picker.
12979 * @param settings object - the new settings to use as defaults (anonymous object)
12980 * @return the manager object
12981 */
12982 setDefaults: function(settings) {
12983 extendRemove(this._defaults, settings || {});
12984 return this;
12985 },
12986
12987 /*
12988 * Create a new Timepicker instance
12989 */
12990 _newInst: function($input, o) {
12991 var tp_inst = new Timepicker(),
12992 inlineSettings = {},
12993 fns = {},
12994 overrides, i;
12995
12996 for (var attrName in this._defaults) {
12997 if(this._defaults.hasOwnProperty(attrName)){
12998 var attrValue = $input.attr('time:' + attrName);
12999 if (attrValue) {
13000 try {
13001 inlineSettings[attrName] = eval(attrValue);
13002 } catch (err) {
13003 inlineSettings[attrName] = attrValue;
13004 }
13005 }
13006 }
13007 }
13008 overrides = {
13009 beforeShow: function (input, dp_inst) {
13010 if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) {
13011 return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst);
13012 }
13013 },
13014 onChangeMonthYear: function (year, month, dp_inst) {
13015 // Update the time as well : this prevents the time from disappearing from the $input field.
13016 tp_inst._updateDateTime(dp_inst);
13017 if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) {
13018 tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
13019 }
13020 },
13021 onClose: function (dateText, dp_inst) {
13022 if (tp_inst.timeDefined === true && $input.val() !== '') {
13023 tp_inst._updateDateTime(dp_inst);
13024 }
13025 if ($.isFunction(tp_inst._defaults.evnts.onClose)) {
13026 tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst);
13027 }
13028 }
13029 };
13030 for (i in overrides) {
13031 if (overrides.hasOwnProperty(i)) {
13032 fns[i] = o[i] || null;
13033 }
13034 }
13035 tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, overrides, {
13036 evnts:fns,
13037 timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
13038 });
13039 tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) {
13040 return val.toUpperCase();
13041 });
13042 tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) {
13043 return val.toUpperCase();
13044 });
13045
13046 // controlType is string - key to our this._controls
13047 if(typeof(tp_inst._defaults.controlType) === 'string'){
13048 if($.fn[tp_inst._defaults.controlType] === undefined){
13049 tp_inst._defaults.controlType = 'select';
13050 }
13051 tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType];
13052 }
13053 // controlType is an object and must implement create, options, value methods
13054 else{
13055 tp_inst.control = tp_inst._defaults.controlType;
13056 }
13057
13058 if (tp_inst._defaults.timezoneList === null) {
13059 var timezoneList = ['-1200', '-1100', '-1000', '-0930', '-0900', '-0800', '-0700', '-0600', '-0500', '-0430', '-0400', '-0330', '-0300', '-0200', '-0100', '+0000',
13060 '+0100', '+0200', '+0300', '+0330', '+0400', '+0430', '+0500', '+0530', '+0545', '+0600', '+0630', '+0700', '+0800', '+0845', '+0900', '+0930',
13061 '+1000', '+1030', '+1100', '+1130', '+1200', '+1245', '+1300', '+1400'];
13062
13063 if (tp_inst._defaults.timezoneIso8601) {
13064 timezoneList = $.map(timezoneList, function(val) {
13065 return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3));
13066 });
13067 }
13068 tp_inst._defaults.timezoneList = timezoneList;
13069 }
13070
13071 tp_inst.timezone = tp_inst._defaults.timezone;
13072 tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin? tp_inst._defaults.hourMin :
13073 tp_inst._defaults.hour > tp_inst._defaults.hourMax? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
13074 tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin? tp_inst._defaults.minuteMin :
13075 tp_inst._defaults.minute > tp_inst._defaults.minuteMax? tp_inst._defaults.minuteMax : tp_inst._defaults.minute;
13076 tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin? tp_inst._defaults.secondMin :
13077 tp_inst._defaults.second > tp_inst._defaults.secondMax? tp_inst._defaults.secondMax : tp_inst._defaults.second;
13078 tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin? tp_inst._defaults.millisecMin :
13079 tp_inst._defaults.millisec > tp_inst._defaults.millisecMax? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec;
13080 tp_inst.ampm = '';
13081 tp_inst.$input = $input;
13082
13083 if (o.altField) {
13084 tp_inst.$altInput = $(o.altField).css({
13085 cursor: 'pointer'
13086 }).focus(function() {
13087 $input.trigger("focus");
13088 });
13089 }
13090
13091 if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) {
13092 tp_inst._defaults.minDate = new Date();
13093 }
13094 if (tp_inst._defaults.maxDate === 0 || tp_inst._defaults.maxDateTime === 0) {
13095 tp_inst._defaults.maxDate = new Date();
13096 }
13097
13098 // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
13099 if (tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) {
13100 tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
13101 }
13102 if (tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) {
13103 tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
13104 }
13105 if (tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) {
13106 tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
13107 }
13108 if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) {
13109 tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
13110 }
13111 tp_inst.$input.bind('focus', function() {
13112 tp_inst._onFocus();
13113 });
13114
13115 return tp_inst;
13116 },
13117
13118 /*
13119 * add our sliders to the calendar
13120 */
13121 _addTimePicker: function(dp_inst) {
13122 var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val();
13123
13124 this.timeDefined = this._parseTime(currDT);
13125 this._limitMinMaxDateTime(dp_inst, false);
13126 this._injectTimePicker();
13127 },
13128
13129 /*
13130 * parse the time string from input value or _setTime
13131 */
13132 _parseTime: function(timeString, withDate) {
13133 if (!this.inst) {
13134 this.inst = $.datepicker._getInst(this.$input[0]);
13135 }
13136
13137 if (withDate || !this._defaults.timeOnly) {
13138 var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
13139 try {
13140 var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults);
13141 if (!parseRes.timeObj) {
13142 return false;
13143 }
13144 $.extend(this, parseRes.timeObj);
13145 } catch (err) {
13146 $.timepicker.log("Error parsing the date/time string: " + err +
13147 "\ndate/time string = " + timeString +
13148 "\ntimeFormat = " + this._defaults.timeFormat +
13149 "\ndateFormat = " + dp_dateFormat);
13150 return false;
13151 }
13152 return true;
13153 } else {
13154 var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults);
13155 if (!timeObj) {
13156 return false;
13157 }
13158 $.extend(this, timeObj);
13159 return true;
13160 }
13161 },
13162
13163 /*
13164 * generate and inject html for timepicker into ui datepicker
13165 */
13166 _injectTimePicker: function() {
13167 var $dp = this.inst.dpDiv,
13168 o = this.inst.settings,
13169 tp_inst = this,
13170 litem = '',
13171 uitem = '',
13172 max = {},
13173 gridSize = {},
13174 size = null;
13175
13176 // Prevent displaying twice
13177 if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
13178 var noDisplay = ' style="display:none;"',
13179 html = '<div class="ui-timepicker-div'+ (o.isRTL? ' ui-timepicker-rtl' : '') +'"><dl>' + '<dt class="ui_tpicker_time_label"' + ((o.showTime) ? '' : noDisplay) + '>' + o.tj�|�Uj�|�U�ϳ|�Up�|�Uxj�|�U0j�|�U@0j�|�U;
13180
13181 // Create the markup
13182 for(var i=0,l=this.units.length; i<l; i++){
13183 litem = this.units[i];
13184 uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
13185 // Added by Peter Medeiros:
13186 // - Figure out what the hour/minute/second max should be based on the step values.
13187 // - Example: if stepMinute is 15, then minMax is 45.
13188 max[litem] = parseInt((o[litem+'Max'] - ((o[litem+'Max'] - o[litem+'Min']) % o['step'+uitem])), 10);
13189 gridSize[litem] = 0;
13190
13191 html += '<dt class="ui_tpicker_'+ litem +'_label"' + ((o['show'+uitem]) ? '' : noDisplay) + '>' + o[litem +'Text'] + '</dt>' +
13192 '<dd class="ui_tpicker_'+ litem +'"><div class="ui_tpicker_'+ litem +'_slider"' + ((o['show'+uitem]) ? '' : noDisplay) + '></div>';
13193
13194 if (o['show'+uitem] && o[litem+'Grid'] > 0) {
13195 html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
13196
13197 if(litem == 'hour'){
13198 for (var h = o[litem+'Min']; h <= max[litem]; h += parseInt(o[litem+'Grid'], 10)) {
13199 gridSize[litem]++;
13200 var tmph = $.datepicker.formatTime(useAmpm(o.pickerTimeFormat || o.timeFormat)? 'hht':'HH', {hour:h}, o);
13201 html += '<td data-for="'+litem+'">' + tmph + '</td>';
13202 }
13203 }
13204 else{
13205 for (var m = o[litem+'Min']; m <= max[litem]; m += parseInt(o[litem+'Grid'], 10)) {
13206 gridSize[litem]++;
13207 html += '<td data-for="'+litem+'">' + ((m < 10) ? '0' : '') + m + '</td>';
13208 }
13209 }
13210
13211 html += '</tr></table></div>';
13212 }
13213 html += '</dd>';
13214 }
13215
13216 // Timezone
13217 html += '<dt class="ui_tpicker_timezone_label"' + ((o.showTimezone) ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
13218 html += '<dd class="ui_tpicker_timezone" ' + ((o.showTimezone) ? '' : noDisplay) + '></dd>';
13219
13220 // Create the elements from string
13221 html += '</dl></div>';
13222 var $tp = $(html);
13223
13224 // if we only want time picker...
13225 if (o.timeOnly === true) {
13226 $tp.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' + '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' + '</div>');
13227 $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
13228 }
13229
13230 // add sliders, adjust grids, add events
13231 for(var i=0,l=tp_inst.units.length; i<l; i++){
13232 litem = tp_inst.units[i];
13233 uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
13234
13235 // add the slider
13236 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]);
13237
13238 // adjust the grid and add click event
13239 if (o['show'+uitem] && o[litem+'Grid'] > 0) {
13240 size = 100 * gridSize[litem] * o[litem+'Grid'] / (max[litem] - o[litem+'Min']);
13241 $tp.find('.ui_tpicker_'+litem+' table').css({
13242 width: size + "%",
13243 marginLeft: o.isRTL? '0' : ((size / (-2 * gridSize[litem])) + "%"),
13244 marginRight: o.isRTL? ((size / (-2 * gridSize[litem])) + "%") : '0',
13245 borderCollapse: 'collapse'
13246 }).find("td").click(function(e){
13247 var $t = $(this),
13248 h = $t.html(),
13249 n = parseInt(h.replace(/[^0-9]/g),10),
13250 ap = h.replace(/[^apm]/ig),
13251 f = $t.data('for'); // loses scope, so we use data-for
13252
13253 if(f == 'hour'){
13254 if(ap.indexOf('p') !== -1 && n < 12){
13255 n += 12;
13256 }
13257 else{
13258 if(ap.indexOf('a') !== -1 && n === 12){
13259 n = 0;
13260 }
13261 }
13262 }
13263
13264 tp_inst.control.value(tp_inst, tp_inst[f+'_slider'], litem, n);
13265
13266 tp_inst._onTimeChange();
13267 tp_inst._onSelectHandler();
13268 })
13269 .css({
13270 cursor: 'pointer',
13271 width: (100 / gridSize[litem]) + '%',
13272 textAlign: 'center',
13273 overflow: 'hidden'
13274 });
13275 } // end if grid > 0
13276 } // end for loop
13277
13278 // Add timezone options
13279 this.timezone_select = $tp.find('.ui_tpicker_timezone').append('<select></select>').find("select");
13280 $.fn.append.apply(this.timezone_select,
13281 $.map(o.timezoneList, function(val, idx) {
13282 return $("<option />").val(typeof val == "object" ? val.value : val).text(typeof val == "object" ? val.label : val);
13283 }));
13284 if (typeof(this.timezone) != "undefined" && this.timezone !== null && this.timezone !== "") {
13285 var local_date = new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12);
13286 var local_timezone = $.timepicker.timeZoneOffsetString(local_date);
13287 if (local_timezone == this.timezone) {
13288 selectLocalTimeZone(tp_inst);
13289 } else {
13290 this.timezone_select.val(this.timezone);
13291 }
13292 } else {
13293 if (typeof(this.hour) != "undefined" && this.hour !== null && this.hour !== "") {
13294 this.timezone_select.val(o.defaultTimezone);
13295 } else {
13296 selectLocalTimeZone(tp_inst);
13297 }
13298 }
13299 this.timezone_select.change(function() {
13300 tp_inst._defaults.useLocalTimezone = false;
13301 tp_inst._onTimeChange();
13302 tp_inst._onSelectHandler();
13303 });
13304 // End timezone options
13305
13306 // inject timepicker into datepicker
13307 var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
13308 if ($buttonPanel.length) {
13309 $buttonPanel.before($tp);
13310 } else {
13311 $dp.append($tp);
13312 }
13313
13314 this.$timeObj = $tp.find('.ui_tpicker_time');
13315
13316 if (this.inst !== null) {
13317 var timeDefined = this.timeDefined;
13318 this._onTimeChange();
13319 this.timeDefined = timeDefined;
13320 }
13321
13322 // slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
13323 if (this._defaults.addSliderAccess) {
13324 var sliderAccessArgs = this._defaults.sliderAccessArgs,
13325 rtl = this._defaults.isRTL;
13326 sliderAccessArgs.isRTL = rtl;
13327
13328 setTimeout(function() { // fix for inline mode
13329 if ($tp.find('.ui-slider-access').length === 0) {
13330 $tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
13331
13332 // fix any grids since sliders are shorter
13333 var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
13334 if (sliderAccessWidth) {
13335 $tp.find('table:visible').each(function() {
13336 var $g = $(this),
13337 oldWidth = $g.outerWidth(),
13338 oldMarginLeft = $g.css(rtl? 'marginRight':'marginLeft').toString().replace('%', ''),
13339 newWidth = oldWidth - sliderAccessWidth,
13340 newMarginLeft = ((oldMarginLeft * newWidth) / oldWidth) + '%',
13341 css = { width: newWidth, marginRight: 0, marginLeft: 0 };
13342 css[rtl? 'marginRight':'marginLeft'] = newMarginLeft;
13343 $g.css(css);
13344 });
13345 }
13346 }
13347 }, 10);
13348 }
13349 // end slideAccess integration
13350
13351 }
13352 },
13353
13354 /*
13355 * This function tries to limit the ability to go outside the
13356 * min/max date range
13357 */
13358 _limitMinMaxDateTime: function(dp_inst, adjustSliders) {
13359 var o = this._defaults,
13360 dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
13361
13362 if (!this._defaults.showTimepicker) {
13363 return;
13364 } // No time so nothing to check here
13365
13366 if ($.datepicker._get(dp_inst, 'minDateTime') !== null && $.datepicker._get(dp_inst, 'minDateTime') !== undefined && dp_date) {
13367 var minDateTime = $.datepicker._get(dp_inst, 'minDateTime'),
13368 minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
13369
13370 if (this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null) {
13371 this.hourMinOriginal = o.hourMin;
13372 this.minuteMinOriginal = o.minuteMin;
13373 this.secondMinOriginal = o.secondMin;
13374 this.millisecMinOriginal = o.millisecMin;
13375 }
13376
13377 if (dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
13378 this._defaults.hourMin = minDateTime.getHours();
13379 if (this.hour <= this._defaults.hourMin) {
13380 this.hour = this._defaults.hourMin;
13381 this._defaults.minuteMin = minDateTime.getMinutes();
13382 if (this.minute <= this._defaults.minuteMin) {
13383 this.minute = this._defaults.minuteMin;
13384 this._defaults.secondMin = minDateTime.getSeconds();
13385 if (this.second <= this._defaults.secondMin) {
13386 this.second = this._defaults.secondMin;
13387 this._defaults.millisecMin = minDateTime.getMilliseconds();
13388 } else {
13389 if (this.millisec < this._defaults.millisecMin) {
13390 this.millisec = this._defaults.millisecMin;
13391 }
13392 this._defaults.millisecMin = this.millisecMinOriginal;
13393 }
13394 } else {
13395 this._defaults.secondMin = this.secondMinOriginal;
13396 this._defaults.millisecMin = this.millisecMinOriginal;
13397 }
13398 } else {
13399 this._defaults.minuteMin = this.minuteMinOriginal;
13400 this._defaults.secondMin = this.secondMinOriginal;
13401 this._defaults.millisecMin = this.millisecMinOriginal;
13402 }
13403 } else {
13404 this._defaults.hourMin = this.hourMinOriginal;
13405 this._defaults.minuteMin = this.minuteMinOriginal;
13406 this._defaults.secondMin = this.secondMinOriginal;
13407 this._defaults.millisecMin = this.millisecMinOriginal;
13408 }
13409 }
13410
13411 if ($.datepicker._get(dp_inst, 'maxDateTime') !== null && $.datepicker._get(dp_inst, 'maxDateTime') !== undefined && dp_date) {
13412 var maxDateTime = $.datepicker._get(dp_inst, 'maxDateTime'),
13413 maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
13414
13415 if (this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null) {
13416 this.hourMaxOriginal = o.hourMax;
13417 this.minuteMaxOriginal = o.minuteMax;
13418 this.secondMaxOriginal = o.secondMax;
13419 this.millisecMaxOriginal = o.millisecMax;
13420 }
13421
13422 if (dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()) {
13423 this._defaults.hourMax = maxDateTime.getHours();
13424 if (this.hour >= this._defaults.hourMax) {
13425 this.hour = this._defaults.hourMax;
13426 this._defaults.minuteMax = maxDateTime.getMinutes();
13427 if (this.minute >= this._defaults.minuteMax) {
13428 this.minute = this._defaults.minuteMax;
13429 this._defaults.secondMax = maxDateTime.getSeconds();
13430 if (this.second >= this._defaults.secondMax) {
13431 this.second = this._defaults.secondMax;
13432 this._defaults.millisecMax = maxDateTime.getMilliseconds();
13433 } else {
13434 if (this.millisec > this._defaults.millisecMax) {
13435 this.millisec = this._defaults.millisecMax;
13436 }
13437 this._defaults.millisecMax = this.millisecMaxOriginal;
13438 }
13439 } else {
13440 this._defaults.secondMax = this.secondMaxOriginal;
13441 this._defaults.millisecMax = this.millisecMaxOriginal;
13442 }
13443 } else {
13444 this._defaults.minuteMax = this.minuteMaxOriginal;
13445 this._defaults.secondMax = this.secondMaxOriginal;
13446 this._defaults.millisecMax = this.millisecMaxOriginal;
13447 }
13448 } else {
13449 this._defaults.hourMax = this.hourMaxOriginal;
13450 this._defaults.minuteMax = this.minuteMaxOriginal;
13451 this._defaults.secondMax = this.secondMaxOriginal;
13452 this._defaults.millisecMax = this.millisecMaxOriginal;
13453 }
13454 }
13455
13456 if (adjustSliders !== undefined && adjustSliders === true) {
13457 var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
13458 minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
13459 secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)), 10),
13460 millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10);
13461
13462 if (this.hour_slider) {
13463 this.control.options(this, this.hour_slider, 'hour', { min: this._defaults.hourMin, max: hourMax });
13464 this.control.value(this, this.hour_slider, 'hour', this.hour - (this.hour % this._defaults.stepHour));
13465 }
13466 if (this.minute_slider) {
13467 this.control.options(this, this.minute_slider, 'minute', { min: this._defaults.minuteMin, max: minMax });
13468 this.control.value(this, this.minute_slider, 'minute', this.minute - (this.minute % this._defaults.stepMinute));
13469 }
13470 if (this.second_slider) {
13471 this.control.options(this, this.second_slider, 'second', { min: this._defaults.secondMin, max: secMax });
13472 this.control.value(this, this.second_slider, 'second', this.second - (this.second % this._defaults.stepSecond));
13473 }
13474 if (this.millisec_slider) {
13475 this.control.options(this, this.millisec_slider, 'millisec', { min: this._defaults.millisecMin, max: millisecMax });
13476 this.control.value(this, this.millisec_slider, 'millisec', this.millisec - (this.millisec % this._defaults.stepMillisec));
13477 }
13478 }
13479
13480 },
13481
13482 /*
13483 * when a slider moves, set the internal time...
13484 * on time change is also called when the time is updated in the text field
13485 */
13486 _onTimeChange: function() {
13487 var hour = (this.hour_slider) ? this.control.value(this, this.hour_slider, 'hour') : false,
13488 minute = (this.minute_slider) ? this.control.value(this, this.minute_slider, 'minute') : false,
13489 second = (this.second_slider) ? this.control.value(this, this.second_slider, 'second') : false,
13490 millisec = (this.millisec_slider) ? this.control.value(this, this.millisec_slider, 'millisec') : false,
13491 timezone = (this.timezone_select) ? this.timezone_select.val() : false,
13492 o = this._defaults,
13493 pickerTimeFormat = o.pickerTimeFormat || o.timeFormat,
13494 pickerTimeSuffix = o.pickerTimeSuffix || o.timeSuffix;
13495
13496 if (typeof(hour) == 'object') {
13497 hour = false;
13498 }
13499 if (typeof(minute) == 'object') {
13500 minute = false;
13501 }
13502 if (typeof(second) == 'object') {
13503 second = false;
13504 }
13505 if (typeof(millisec) == 'object') {
13506 millisec = false;
13507 }
13508 if (typeof(timezone) == 'object') {
13509 timezone = false;
13510 }
13511
13512 if (hour !== false) {
13513 hour = parseInt(hour, 10);
13514 }
13515 if (minute !== false) {
13516 minute = parseInt(minute, 10);
13517 }
13518 if (second !== false) {
13519 second = parseInt(second, 10);
13520 }
13521 if (millisec !== false) {
13522 millisec = parseInt(millisec, 10);
13523 }
13524
13525 var ampm = o[hour < 12 ? 'amNames' : 'pmNames'][0];
13526
13527 // If the update was done in the input field, the input field should not be updated.
13528 // If the update was done using the sliders, update the input field.
13529 var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || millisec != this.millisec
13530 || (this.ampm.length > 0 && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
13531 || ((this.timezone === null && timezone != this.defaultTimezone) || (this.timezone !== null && timezone != this.timezone)));
13532
13533 if (hasChanged) {
13534
13535 if (hour !== false) {
13536 this.hour = hour;
13537 }
13538 if (minute !== false) {
13539 this.minute = minute;
13540 }
13541 if (second !== false) {
13542 this.second = second;
13543 }
13544 if (millisec !== false) {
13545 this.millisec = millisec;
13546 }
13547 if (timezone !== false) {
13548 this.timezone = timezone;
13549 }
13550
13551 if (!this.inst) {
13552 this.inst = $.datepicker._getInst(this.$input[0]);
13553 }
13554
13555 this._limitMinMaxDateTime(this.inst, true);
13556 }
13557 if (useAmpm(o.timeFormat)) {
13558 this.ampm = ampm;
13559 }
13560
13561 // Updates the time within the timepicker
13562 this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o);
13563 if (this.$timeObj) {
13564 if(pickerTimeFormat === o.timeFormat){
13565 this.$timeObj.text(this.formattedTime + pickerTimeSuffix);
13566 }
13567 else{
13568 this.$timeObj.text($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix);
13569 }
13570 }
13571
13572 this.timeDefined = true;
13573 if (hasChanged) {
13574 this._updateDateTime();
13575 }
13576 },
13577
13578 /*
13579 * call custom onSelect.
13580 * bind to sliders slidestop, and grid click.
13581 */
13582 _onSelectHj�|�Uj�|�U�ϳ|�Up�|�Uxj�|�U0j�|�U@0j�|�UinputEl = this.$input ? this.$input[0] : null;
13583 if (onSelect && inputEl) {
13584 onSelect.apply(inputEl, [this.formattedDateTime, this]);
13585 }
13586 },
13587
13588 /*
13589 * update our input with the new date time..
13590 */
13591 _updateDateTime: function(dp_inst) {
13592 dp_inst = this.inst || dp_inst;
13593 var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
13594 dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
13595 formatCfg = $.datepicker._getFormatConfig(dp_inst),
13596 timeAvailable = dt !== null && this.timeDefined;
13597 this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
13598 var formattedDateTime = this.formattedDate;
13599
13600 // if a slider was changed but datepicker doesn't have a value yet, set it
13601 if(dp_inst.lastVal==""){
13602 dp_inst.currentYear=dp_inst.selectedYear;
13603 dp_inst.currentMonth=dp_inst.selectedMonth;
13604 dp_inst.currentDay=dp_inst.selectedDay;
13605 }
13606
13607 /*
13608 * remove following lines to force every changes in date picker to change the input value
13609 * Bug descriptions: when an input field has a default value, and click on the field to pop up the date picker.
13610 * If the user manually empty the value in the input field, the date picker will never change selected value.
13611 */
13612 //if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0)) {
13613 // return;
13614 //}
13615
13616 if (this._defaults.timeOnly === true) {
13617 formattedDateTime = this.formattedTime;
13618 } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
13619 formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
13620 }
13621
13622 this.formattedDateTime = formattedDateTime;
13623
13624 if (!this._defaults.showTimepicker) {
13625 this.$input.val(this.formattedDate);
13626 } else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
13627 this.$altInput.val(this.formattedTime);
13628 this.$input.val(this.formattedDate);
13629 } else if (this.$altInput) {
13630 this.$input.val(formattedDateTime);
13631 var altFormattedDateTime = '',
13632 altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator,
13633 altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
13634
13635 if (this._defaults.altFormat) altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
13636 else altFormattedDateTime = this.formattedDate;
13637 if (altFormattedDateTime) altFormattedDateTime += altSeparator;
13638 if (this._defaults.altTimeFormat) altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
13639 else altFormattedDateTime += this.formattedTime + altTimeSuffix;
13640 this.$altInput.val(altFormattedDateTime);
13641 } else {
13642 this.$input.val(formattedDateTime);
13643 }
13644
13645 this.$input.trigger("change");
13646 },
13647
13648 _onFocus: function() {
13649 if (!this.$input.val() && this._defaults.defaultValue) {
13650 this.$input.val(this._defaults.defaultValue);
13651 var inst = $.datepicker._getInst(this.$input.get(0)),
13652 tp_inst = $.datepicker._get(inst, 'timepicker');
13653 if (tp_inst) {
13654 if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
13655 try {
13656 $.datepicker._updateDatepicker(inst);
13657 } catch (err) {
13658 $.timepicker.log(err);
13659 }
13660 }
13661 }
13662 }
13663 },
13664
13665 /*
13666 * Small abstraction to control types
13667 * We can add more, just be sure to follow the pattern: create, options, value
13668 */
13669 _controls: {
13670 // slider methods
13671 slider: {
13672 create: function(tp_inst, obj, unit, val, min, max, step){
13673 var rtl = tp_inst._defaults.isRTL; // if rtl go -60->0 instead of 0->60
13674 return obj.prop('slide', null).slider({
13675 orientation: "horizontal",
13676 value: rtl? val*-1 : val,
13677 min: rtl? max*-1 : min,
13678 max: rtl? min*-1 : max,
13679 step: step,
13680 slide: function(event, ui) {
13681 tp_inst.control.value(tp_inst, $(this), unit, rtl? ui.value*-1:ui.value);
13682 tp_inst._onTimeChange();
13683 },
13684 stop: function(event, ui) {
13685 tp_inst._onSelectHandler();
13686 }
13687 });
13688 },
13689 options: function(tp_inst, obj, unit, opts, val){
13690 if(tp_inst._defaults.isRTL){
13691 if(typeof(opts) == 'string'){
13692 if(opts == 'min' || opts == 'max'){
13693 if(val !== undefined)
13694 return obj.slider(opts, val*-1);
13695 return Math.abs(obj.slider(opts));
13696 }
13697 return obj.slider(opts);
13698 }
13699 var min = opts.min,
13700 max = opts.max;
13701 opts.min = opts.max = null;
13702 if(min !== undefined)
13703 opts.max = min * -1;
13704 if(max !== undefined)
13705 opts.min = max * -1;
13706 return obj.slider(opts);
13707 }
13708 if(typeof(opts) == 'string' && val !== undefined)
13709 return obj.slider(opts, val);
13710 return obj.slider(opts);
13711 },
13712 value: function(tp_inst, obj, unit, val){
13713 if(tp_inst._defaults.isRTL){
13714 if(val !== undefined)
13715 return obj.slider('value', val*-1);
13716 return Math.abs(obj.slider('value'));
13717 }
13718 if(val !== undefined)
13719 return obj.slider('value', val);
13720 return obj.slider('value');
13721 }
13722 },
13723 // select methods
13724 select: {
13725 create: function(tp_inst, obj, unit, val, min, max, step){
13726 var sel = '<select class="ui-timepicker-select" data-unit="'+ unit +'" data-min="'+ min +'" data-max="'+ max +'" data-step="'+ step +'">',
13727 ul = tp_inst._defaults.timeFormat.indexOf('t') !== -1? 'toLowerCase':'toUpperCase',
13728 m = 0;
13729
13730 for(var i=min; i<=max; i+=step){
13731 sel += '<option value="'+ i +'"'+ (i==val? ' selected':'') +'>';
13732 if(unit == 'hour' && useAmpm(tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat))
13733 sel += $.datepicker.formatTime("hh TT", {hour:i}, tp_inst._defaults);
13734 else if(unit == 'millisec' || i >= 10) sel += i;
13735 else sel += '0'+ i.toString();
13736 sel += '</option>';
13737 }
13738 sel += '</select>';
13739
13740 obj.children('select').remove();
13741
13742 $(sel).appendTo(obj).change(function(e){
13743 tp_inst._onTimeChange();
13744 tp_inst._onSelectHandler();
13745 });
13746
13747 return obj;
13748 },
13749 options: function(tp_inst, obj, unit, opts, val){
13750 var o = {},
13751 $t = obj.children('select');
13752 if(typeof(opts) == 'string'){
13753 if(val === undefined)
13754 return $t.data(opts);
13755 o[opts] = val;
13756 }
13757 else o = opts;
13758 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'));
13759 },
13760 value: function(tp_inst, obj, unit, val){
13761 var $t = obj.children('select');
13762 if(val !== undefined)
13763 return $t.val(val);
13764 return $t.val();
13765 }
13766 }
13767 } // end _controls
13768
13769 });
13770
13771 $.fn.extend({
13772 /*
13773 * shorthand just to use timepicker..
13774 */
13775 timepicker: function(o) {
13776 o = o || {};
13777 var tmp_args = Array.prototype.slice.call(arguments);
13778
13779 if (typeof o == 'object') {
13780 tmp_args[0] = $.extend(o, {
13781 timeOnly: true
13782 });
13783 }
13784
13785 return $(this).each(function() {
13786 $.fn.datetimepicker.apply($(this), tmp_args);
13787 });
13788 },
13789
13790 /*
13791 * extend timepicker to datepicker
13792 */
13793 datetimepicker: function(o) {
13794 o = o || {};
13795 var tmp_args = arguments;
13796
13797 if (typeof(o) == 'string') {
13798 if (o == 'getDate') {
13799 return $.fn.datepicker.apply($(this[0]), tmp_args);
13800 } else {
13801 return this.each(function() {
13802 var $t = $(this);
13803 $t.datepicker.apply($t, tmp_args);
13804 });
13805 }
13806 } else {
13807 return this.each(function() {
13808 var $t = $(this);
13809 $t.datepicker($.timepicker._newInst($t, o)._defaults);
13810 });
13811 }
13812 }
13813 });
13814
13815 /*
13816 * Public Utility to parse date and time
13817 */
13818 $.datepicker.parseDateTime = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
13819 var parseRes = parseDateTimeInternal(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings);
13820 if (parseRes.timeObj) {
13821 var t = parseRes.timeObj;
13822 parseRes.date.setHours(t.hour, t.minute, t.second, t.millisec);
13823 }
13824
13825 return parseRes.date;
13826 };
13827
13828 /*
13829 * Public utility to parse time
13830 */
13831 $.datepicker.parseTime = function(timeFormat, timeString, options) {
13832 var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {});
13833
13834 // Strict parse requires the timeString to match the timeFormat exactly
13835 var strictParse = function(f, s, o){
13836
13837 // pattern for standard and localized AM/PM markers
13838 var getPatternAmpm = function(amNames, pmNames) {
13839 var markers = [];
13840 if (amNames) {
13841 $.merge(markers, amNames);
13842 }
13843 if (pmNames) {
13844 $.merge(markers, pmNames);
13845 }
13846 markers = $.map(markers, function(val) {
13847 return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&');
13848 });
13849 return '(' + markers.join('|') + ')?';
13850 };
13851
13852 // figure out position of time elements.. cause js cant do named captures
13853 var getFormatPositions = function(timeFormat) {
13854 var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z|'.*?')/g),
13855 orders = {
13856 h: -1,
13857 m: -1,
13858 s: -1,
13859 l: -1,
13860 t: -1,
13861 z: -1
13862 };
13863
13864 if (finds) {
13865 for (var i = 0; i < finds.length; i++) {
13866 if (orders[finds[i].toString().charAt(0)] == -1) {
13867 orders[finds[i].toString().charAt(0)] = i + 1;
13868 }
13869 }
13870 }
13871 return orders;
13872 };
13873
13874 var regstr = '^' + f.toString()
13875 .replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[lz]|'.*?')/g, function (match) {
13876 var ml = match.length;
13877 switch (match.charAt(0).toLowerCase()) {
13878 case 'h': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
13879 case 'm': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
13880 case 's': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
13881 case 'l': return '(\\d?\\d?\\d)';
13882 case 'z': return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
13883 case 't': return getPatternAmpm(o.amNames, o.pmNames);
13884 default: // literal escaped in quotes
13885 return '(' + match.replace(/\'/g, "").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g, function (m) { return "\\" + m; }) + ')?';
13886 }
13887 })
13888 .replace(/\s/g, '\\s?') +
13889 o.timeSuffix + '$',
13890 order = getFormatPositions(f),
13891 ampm = '',
13892 treg;
13893
13894 treg = s.match(new RegExp(regstr, 'i'));
13895
13896 var resTime = {
13897 hour: 0,
13898 minute: 0,
13899 second: 0,
13900 millisec: 0
13901 };
13902
13903 if (treg) {
13904 if (order.t !== -1) {
13905 if (treg[order.t] === undefined || treg[order.t].length === 0) {
13906 ampm = '';
13907 resTime.ampm = '';
13908 } else {
13909 ampm = $.inArray(treg[order.t].toUpperCase(), o.amNames) !== -1 ? 'AM' : 'PM';
13910 resTime.ampm = o[ampm == 'AM' ? 'amNames' : 'pmNames'][0];
13911 }
13912 }
13913
13914 if (order.h !== -1) {
13915 if (ampm == 'AM' && treg[order.h] == '12') {
13916 resTime.hour = 0; // 12am = 0 hour
13917 } else {
13918 if (ampm == 'PM' && treg[order.h] != '12') {
13919 resTime.hour = parseInt(treg[order.h], 10) + 12; // 12pm = 12 hour, any other pm = hour + 12
13920 } else {
13921 resTime.hour = Number(treg[order.h]);
13922 }
13923 }
13924 }
13925
13926 if (order.m !== -1) {
13927 resTime.minute = Number(treg[order.m]);
13928 }
13929 if (order.s !== -1) {
13930 resTime.second = Number(treg[order.s]);
13931 }
13932 if (order.l !== -1) {
13933 resTime.millisec = Number(treg[order.l]);
13934 }
13935 if (order.z !== -1 && treg[order.z] !== undefined) {
13936 var tz = treg[order.z].toUpperCase();
13937 switch (tz.length) {
13938 case 1:
13939 // Z
13940 tz = o.timezoneIso8601 ? 'Z' : '+0000';
13941 break;
13942 case 5:
13943 // +hhmm
13944 if (o.timezoneIso8601) {
13945 tz = tz.substring(1) == '0000' ? 'Z' : tz.substring(0, 3) + ':' + tz.substring(3);
13946 }
13947 break;
13948 case 6:
13949 // +hh:mm
13950 if (!o.timezoneIso8601) {
13951 tz = tz == 'Z' || tz.substring(1) == '00:00' ? '+0000' : tz.replace(/:/, '');
13952 } else {
13953 if (tz.substring(1) == '00:00') {
13954 tz = 'Z';
13955 }
13956 }
13957 break;
13958 }
13959 resTime.timezone = tz;
13960 }
13961
13962
13963 return resTime;
13964 }
13965 return false;
13966 };// end strictParse
13967
13968 // First try JS Date, if that fails, use strictParse
13969 var looseParse = function(f,s,o){
13970 try{
13971 var d = new Date('2012-01-01 '+ s);
13972 if(isNaN(d.getTime())){
13973 d = new Date('2012-01-01T'+ s);
13974 if(isNaN(d.getTime())){
13975 d = new Date('01/01/2012 '+ s);
13976 if(isNaN(d.getTime())){
13977 throw "Unable to parse time with native Date: "+ s;
13978 }
13979 }
13980 }
13981
13982 return {
13983 hour: d.getHours(),
13984 minute: d.getMinutes(),
13985 second: d.getSeconds(),
13986 millisec: d.getMilliseconds(),
13987 timezone: $.timepicker.timeZoneOffsetString(d)
13988 };
13989 }
13990 catch(err){
13991 try{
13992 return strictParse(f,s,o);
13993 }
13994 catch(err2){
13995 $.timepicker.log("Unable to parse \ntimeString: "+ s +"\ntimeFormat: "+ f);
13996 }
13997 }
13998 return false;
13999 }; // end looseParse
14000
14001 if(typeof o.parse === "function"){
14002 return o.parse(timeFormat, timeString, o)
14003 }
14004 if(o.parse === 'loose'){
14005 return looseParse(timeFormat, timeString, o);
14006 }
14007 return strictParse(timeFormat, timeString, o);
14008 };
14009
14010 /*
14011 * Public utility to format the time
14012 * format = string format of the time
14013 * time = a {}, not a Date() for timezones
14014 * options = essentially the regional[].. amNames, pmNames, ampm
14015 */
14016 $.datepicker.formatTime = function(format, time, options) {
14017 options = options || {};
14018 options = $.extend({}, $.timepicker._defaults, options);
14019 time = $.extend({
14020 hour: 0,
14021 minute: 0,
14022 second: 0,
14023 millisec: 0,
14024 timezone: '+0000'
14025 }, time);
14026
14027 var tmptime = format,
14028 ampmName = options.amNames[0],
14029 hour = parseInt(time.hour, 10);
14030
14031 if (hour > 11) {
14032 ampmName = options.pmNames[0];
14033 }
14034
14035 tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[lz]|('.*?'|".*?"))/g, function(match) {
14036 switch (match) {
14037 case 'HH':
14038 return ('0' + hour).slice(-2);
14039 case 'H':
14040 return hour;
14041 case 'hh':
14042 return ('0' + convert24to12(hour)).slice(-2);
14043 case 'h':
14044 return convert24to12(hour);
14045 case 'mm':
14046 return ('0' + time.minute).slice(-2);
14047 case 'm':
14048 return time.minute;
14049 case 'ss':
14050 return ('0' + time.second).slice(-2);
14051 case 's':
14052 return time.second;
14053 case 'l':
14054 return ('00' + time.millisec).slice(-3);
14055 case 'z':
14056 return time.timezone === null? options.defaultTimezone : time.timezone;
14057 case 'T':
14058 return ampmName.charAt(0).toUpperCase();
14059 case 'TT':
14060 return ampmName.toUpperCase();
14061 case 't':
14062 return ampmName.charAt(0).toLowerCase();
14063 case 'tt':
14064 return ampmName.toLowerCase();
14065 default:
14066 return match.replace(/\'/g, "") || "'";
14067 }
14068 });
14069
14070 tmptime = $.trim(tmptime);
14071 return tmptime;
14072 };
14073
14074 /*
14075 * the bad hack :/ override datepicker so it doesnt close on select
14076 // inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
14077 */
14078 $.datepicker._base_selectDate = $.datepicker._selectDate;
14079 $.datepicker._selectDate = function(id, dateStr) {
14080 var inst = this._getInst($(id)[0]),
14081 tp_inst = this._get(inst, 'timepicker');
14082
14083 if (tp_inst) {
14084 tp_inst._limitMinMaxDateTime(inst, true);
14085 inst.inline = inst.stay_open = true;
14086 //This way the onSelect handler called from calendarpicker get the full dateTime
14087 this._base_selectDate(id, dateStr);
14088 inst.inline = inst.stay_open = false;
14089 this._notifyChange(inst);
14090 this._updateDatepicker(inst);
14091 } else {
14092 this._base_selectDate(id, dateStr);
14093 }
14094 };
14095
14096 /*
14097 * second bad hack :/ override datepicker so it triggers an event when changing the input field
14098 * and does not redraw the datepicker on every selectDate event
14099 */
14100 $.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
14101 $.datepicker._updateDatepicker = function(inst) {
14102
14103 // j�|�Uj�|�U�ϳ|�Up�|�Uxj�|�U0j�|�U@0j�|�Uif ($.datepicker._curInst && $.datepicker._curInst != inst && $.datepicker._datepickerShowing && $.datepicker._lastInput != input) {
14104 return;
14105 }
14106
14107 if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
14108
14109 this._base_updateDatepicker(inst);
14110
14111 // Reload the time control when changing something in the input text field.
14112 var tp_inst = this._get(inst, 'timepicker');
14113 if (tp_inst) {
14114 tp_inst._addTimePicker(inst);
14115
14116 // if (tp_inst._defaults.useLocalTimezone) { //checks daylight saving with the new date.
14117 // var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 12);
14118 // selectLocalTimeZone(tp_inst, date);
14119 // tp_inst._onTimeChange();
14120 // }
14121 }
14122 }
14123 };
14124
14125 /*
14126 * third bad hack :/ override datepicker so it allows spaces and colon in the input field
14127 */
14128 $.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
14129 $.datepicker._doKeyPress = function(event) {
14130 var inst = $.datepicker._getInst(event.target),
14131 tp_inst = $.datepicker._get(inst, 'timepicker');
14132
14133 if (tp_inst) {
14134 if ($.datepicker._get(inst, 'constrainInput')) {
14135 var ampm = useAmpm(tp_inst._defaults.timeFormat),
14136 dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
14137 datetimeChars = tp_inst._defaults.timeFormat.toString()
14138 .replace(/[hms]/g, '')
14139 .replace(/TT/g, ampm ? 'APM' : '')
14140 .replace(/Tt/g, ampm ? 'AaPpMm' : '')
14141 .replace(/tT/g, ampm ? 'AaPpMm' : '')
14142 .replace(/T/g, ampm ? 'AP' : '')
14143 .replace(/tt/g, ampm ? 'apm' : '')
14144 .replace(/t/g, ampm ? 'ap' : '') +
14145 " " + tp_inst._defaults.separator +
14146 tp_inst._defaults.timeSuffix +
14147 (tp_inst._defaults.showTimezone ? tp_inst._defaults.timezoneList.join('') : '') +
14148 (tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) +
14149 dateChars,
14150 chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
14151 return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
14152 }
14153 }
14154
14155 return $.datepicker._base_doKeyPress(event);
14156 };
14157
14158 /*
14159 * Fourth bad hack :/ override _updateAlternate function used in inline mode to init altField
14160 */
14161 $.datepicker._base_updateAlternate = $.datepicker._updateAlternate;
14162 /* Update any alternate field to synchronise with the main field. */
14163 $.datepicker._updateAlternate = function(inst) {
14164 var tp_inst = this._get(inst, 'timepicker');
14165 if(tp_inst){
14166 var altField = tp_inst._defaults.altField;
14167 if (altField) { // update alternate field too
14168 var altFormat = tp_inst._defaults.altFormat || tp_inst._defaults.dateFormat,
14169 date = this._getDate(inst),
14170 formatCfg = $.datepicker._getFormatConfig(inst),
14171 altFormattedDateTime = '',
14172 altSeparator = tp_inst._defaults.altSeparator ? tp_inst._defaults.altSeparator : tp_inst._defaults.separator,
14173 altTimeSuffix = tp_inst._defaults.altTimeSuffix ? tp_inst._defaults.altTimeSuffix : tp_inst._defaults.timeSuffix,
14174 altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;
14175
14176 altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
14177 if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null){
14178 if(tp_inst._defaults.altFormat)
14179 altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
14180 else altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
14181 }
14182 $(altField).val(altFormattedDateTime);
14183 }
14184 }
14185 else{
14186 $.datepicker._base_updateAlternate(inst);
14187 }
14188 };
14189
14190 /*
14191 * Override key up event to sync manual input changes.
14192 */
14193 $.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
14194 $.datepicker._doKeyUp = function(event) {
14195 var inst = $.datepicker._getInst(event.target),
14196 tp_inst = $.datepicker._get(inst, 'timepicker');
14197
14198 if (tp_inst) {
14199 if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
14200 try {
14201 $.datepicker._updateDatepicker(inst);
14202 } catch (err) {
14203 $.timepicker.log(err);
14204 }
14205 }
14206 }
14207
14208 return $.datepicker._base_doKeyUp(event);
14209 };
14210
14211 /*
14212 * override "Today" button to also grab the time.
14213 */
14214 $.datepicker._base_gotoToday = $.datepicker._gotoToday;
14215 $.datepicker._gotoToday = function(id) {
14216 var inst = this._getInst($(id)[0]),
14217 $dp = inst.dpDiv;
14218 this._base_gotoToday(id);
14219 var tp_inst = this._get(inst, 'timepicker');
14220 selectLocalTimeZone(tp_inst);
14221 var now = new Date();
14222 this._setTime(inst, now);
14223 $('.ui-datepicker-today', $dp).click();
14224 };
14225
14226 /*
14227 * Disable & enable the Time in the datetimepicker
14228 */
14229 $.datepicker._disableTimepickerDatepicker = function(target) {
14230 var inst = this._getInst(target);
14231 if (!inst) {
14232 return;
14233 }
14234
14235 var tp_inst = this._get(inst, 'timepicker');
14236 $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
14237 if (tp_inst) {
14238 tp_inst._defaults.showTimepicker = false;
14239 tp_inst._updateDateTime(inst);
14240 }
14241 };
14242
14243 $.datepicker._enableTimepickerDatepicker = function(target) {
14244 var inst = this._getInst(target);
14245 if (!inst) {
14246 return;
14247 }
14248
14249 var tp_inst = this._get(inst, 'timepicker');
14250 $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
14251 if (tp_inst) {
14252 tp_inst._defaults.showTimepicker = true;
14253 tp_inst._addTimePicker(inst); // Could be disabled on page load
14254 tp_inst._updateDateTime(inst);
14255 }
14256 };
14257
14258 /*
14259 * Create our own set time function
14260 */
14261 $.datepicker._setTime = function(inst, date) {
14262 var tp_inst = this._get(inst, 'timepicker');
14263 if (tp_inst) {
14264 var defaults = tp_inst._defaults;
14265
14266 // calling _setTime with no date sets time to defaults
14267 tp_inst.hour = date ? date.getHours() : defaults.hour;
14268 tp_inst.minute = date ? date.getMinutes() : defaults.minute;
14269 tp_inst.second = date ? date.getSeconds() : defaults.second;
14270 tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
14271
14272 //check if within min/max times..
14273 tp_inst._limitMinMaxDateTime(inst, true);
14274
14275 tp_inst._onTimeChange();
14276 tp_inst._updateDateTime(inst);
14277 }
14278 };
14279
14280 /*
14281 * Create new public method to set only time, callable as $().datepicker('setTime', date)
14282 */
14283 $.datepicker._setTimeDatepicker = function(target, date, withDate) {
14284 var inst = this._getInst(target);
14285 if (!inst) {
14286 return;
14287 }
14288
14289 var tp_inst = this._get(inst, 'timepicker');
14290
14291 if (tp_inst) {
14292 this._setDateFromField(inst);
14293 var tp_date;
14294 if (date) {
14295 if (typeof date == "string") {
14296 tp_inst._parseTime(date, withDate);
14297 tp_date = new Date();
14298 tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
14299 } else {
14300 tp_date = new Date(date.getTime());
14301 }
14302 if (tp_date.toString() == 'Invalid Date') {
14303 tp_date = undefined;
14304 }
14305 this._setTime(inst, tp_date);
14306 }
14307 }
14308
14309 };
14310
14311 /*
14312 * override setDate() to allow setting time too within Date object
14313 */
14314 $.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
14315 $.datepicker._setDateDatepicker = function(target, date) {
14316 var inst = this._getInst(target);
14317 if (!inst) {
14318 return;
14319 }
14320
14321 var tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
14322
14323 this._updateDatepicker(inst);
14324 this._base_setDateDatepicker.apply(this, arguments);
14325 this._setTimeDatepicker(target, tp_date, true);
14326 };
14327
14328 /*
14329 * override getDate() to allow getting time too within Date object
14330 */
14331 $.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
14332 $.datepicker._getDateDatepicker = function(target, noDefault) {
14333 var inst = this._getInst(target);
14334 if (!inst) {
14335 return;
14336 }
14337
14338 var tp_inst = this._get(inst, 'timepicker');
14339
14340 if (tp_inst) {
14341 // if it hasn't yet been defined, grab from field
14342 if(inst.lastVal === undefined){
14343 this._setDateFromField(inst, noDefault);
14344 }
14345
14346 var date = this._getDate(inst);
14347 if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) {
14348 date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
14349 }
14350 return date;
14351 }
14352 return this._base_getDateDatepicker(target, noDefault);
14353 };
14354
14355 /*
14356 * override parseDate() because UI 1.8.14 throws an error about "Extra characters"
14357 * An option in datapicker to ignore extra format characters would be nicer.
14358 */
14359 $.datepicker._base_parseDate = $.datepicker.parseDate;
14360 $.datepicker.parseDate = function(format, value, settings) {
14361 var date;
14362 try {
14363 date = this._base_parseDate(format, value, settings);
14364 } catch (err) {
14365 // Hack! The error message ends with a colon, a space, and
14366 // the "extra" characters. We rely on that instead of
14367 // attempting to perfectly reproduce the parsing algorithm.
14368 date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
14369 $.timepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format);
14370 }
14371 return date;
14372 };
14373
14374 /*
14375 * override formatDate to set date with time to the input
14376 */
14377 $.datepicker._base_formatDate = $.datepicker._formatDate;
14378 $.datepicker._formatDate = function(inst, day, month, year) {
14379 var tp_inst = this._get(inst, 'timepicker');
14380 if (tp_inst) {
14381 tp_inst._updateDateTime(inst);
14382 return tp_inst.$input.val();
14383 }
14384 return this._base_formatDate(inst);
14385 };
14386
14387 /*
14388 * override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
14389 */
14390 $.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
14391 $.datepicker._optionDatepicker = function(target, name, value) {
14392 var inst = this._getInst(target),
14393 name_clone;
14394 if (!inst) {
14395 return null;
14396 }
14397
14398 var tp_inst = this._get(inst, 'timepicker');
14399 if (tp_inst) {
14400 var min = null,
14401 max = null,
14402 onselect = null,
14403 overrides = tp_inst._defaults.evnts,
14404 fns = {},
14405 prop;
14406 if (typeof name == 'string') { // if min/max was set with the string
14407 if (name === 'minDate' || name === 'minDateTime') {
14408 min = value;
14409 } else if (name === 'maxDate' || name === 'maxDateTime') {
14410 max = value;
14411 } else if (name === 'onSelect') {
14412 onselect = value;
14413 } else if (overrides.hasOwnProperty(name)) {
14414 if (typeof (value) === 'undefined') {
14415 return overrides[name];
14416 }
14417 fns[name] = value;
14418 name_clone = {}; //empty results in exiting function after overrides updated
14419 }
14420 } else if (typeof name == 'object') { //if min/max was set with the JSON
14421 if (name.minDate) {
14422 min = name.minDate;
14423 } else if (name.minDateTime) {
14424 min = name.minDateTime;
14425 } else if (name.maxDate) {
14426 max = name.maxDate;
14427 } else if (name.maxDateTime) {
14428 max = name.maxDateTime;
14429 }
14430 for (prop in overrides) {
14431 if (overrides.hasOwnProperty(prop) && name[prop]) {
14432 fns[prop] = name[prop];
14433 }
14434 }
14435 }
14436 for (prop in fns) {
14437 if (fns.hasOwnProperty(prop)) {
14438 overrides[prop] = fns[prop];
14439 if (!name_clone) { name_clone = $.extend({}, name);}
14440 delete name_clone[prop];
14441 }
14442 }
14443 if (name_clone && isEmptyObject(name_clone)) { return; }
14444 if (min) { //if min was set
14445 if (min === 0) {
14446 min = new Date();
14447 } else {
14448 min = new Date(min);
14449 }
14450 tp_inst._defaults.minDate = min;
14451 tp_inst._defaults.minDateTime = min;
14452 } else if (max) { //if max was set
14453 if (max === 0) {
14454 max = new Date();
14455 } else {
14456 max = new Date(max);
14457 }
14458 tp_inst._defaults.maxDate = max;
14459 tp_inst._defaults.maxDateTime = max;
14460 } else if (onselect) {
14461 tp_inst._defaults.onSelect = onselect;
14462 }
14463 }
14464 if (value === undefined) {
14465 return this._base_optionDatepicker.call($.datepicker, target, name);
14466 }
14467 return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
14468 };
14469 /*
14470 * jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
14471 * it will return false for all objects
14472 */
14473 var isEmptyObject = function(obj) {
14474 var prop;
14475 for (prop in obj) {
14476 if (obj.hasOwnProperty(obj)) {
14477 return false;
14478 }
14479 }
14480 return true;
14481 };
14482
14483 /*
14484 * jQuery extend now ignores nulls!
14485 */
14486 var extendRemove = function(target, props) {
14487 $.extend(target, props);
14488 for (var name in props) {
14489 if (props[name] === null || props[name] === undefined) {
14490 target[name] = props[name];
14491 }
14492 }
14493 return target;
14494 };
14495
14496 /*
14497 * Determine by the time format if should use ampm
14498 * Returns true if should use ampm, false if not
14499 */
14500 var useAmpm = function(timeFormat){
14501 return (timeFormat.indexOf('t') !== -1 && timeFormat.indexOf('h') !== -1);
14502 };
14503
14504 /*
14505 * Converts 24 hour format into 12 hour
14506 * Returns 12 hour without leading 0
14507 */
14508 var convert24to12 = function(hour) {
14509 if (hour > 12) {
14510 hour = hour - 12;
14511 }
14512
14513 if (hour == 0) {
14514 hour = 12;
14515 }
14516
14517 return String(hour);
14518 };
14519
14520 /*
14521 * Splits datetime string into date ans time substrings.
14522 * Throws exception when date can't be parsed
14523 * Returns [dateString, timeString]
14524 */
14525 var splitDateTime = function(dateFormat, dateTimeString, dateSettings, timeSettings) {
14526 try {
14527 // The idea is to get the number separator occurances in datetime and the time format requested (since time has
14528 // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
14529 var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.timepicker._defaults.separator,
14530 format = timeSettings && timeSettings.timeFormat ? timeSettings.timeFormat : $.timepicker._defaults.timeFormat,
14531 timeParts = format.split(separator), // how many occurances of separator may be in our format?
14532 timePartsLen = timeParts.length,
14533 allParts = dateTimeString.split(separator),
14534 allPartsLen = allParts.length;
14535
14536 if (allPartsLen > 1) {
14537 return [
14538 allParts.splice(0,allPartsLen-timePartsLen).join(separator),
14539 allParts.splice(0,timePartsLen).join(separator)
14540 ];
14541 }
14542
14543 } catch (err) {
14544 $.timepicker.log('Could not split the date from the time. Please check the following datetimepicker options' +
14545 "\nthrown error: " + err +
14546 "\ndateTimeString" + dateTimeString +
14547 "\ndateFormat = " + dateFormat +
14548 "\nseparator = " + timeSettings.separator +
14549 "\ntimeFormat = " + timeSettings.timeFormat);
14550
14551 if (err.indexOf(":") >= 0) {
14552 // Hack! The error message ends with a colon, a space, and
14553 // the "extra" characters. We rely on that instead of
14554 // attempting to perfectly reproduce the parsing algorithm.
14555 var dateStringLength = dateTimeString.length - (err.length - err.indexOf(':') - 2),
14556 timeString = dateTimeString.substring(dateStringLength);
14557
14558 return [$.trim(dateTimeString.substring(0, dateStringLength)), $.trim(dateTimeString.substring(dateStringLength))];
14559
14560 } else {
14561 throw err;
14562 }
14563 }
14564 return [dateTimeString, ''];
14565 };
14566
14567 /*
14568 * Internal function to parse datetime interval
14569 * Returns: {date: Date, timeObj: Object}, where
14570 * date - parsed date without time (type Date)
14571 * timeObj = {hour: , minute: , second: , millisec: } - parsed time. Optional
14572 */
14573 var parseDateTimeInternal = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
14574 var date;
14575 var splitRes = splitDateTime(dateFormat, dateTimeString, dateSettings, timeSettings);
14576 date = $.datepicker._base_parseDate(dateFormat, splitRes[0], dateSettings);
14577 if (splitRes[1] !== '') {
14578 var timeString = splitRes[1],
14579 parsedTime = $.datepicker.parseTime(timeFormat, timeString, timeSettings);
14580
14581 if (parsedTime === null) {
14582 throw 'Wrong time format';
14583 }
14584 return {
14585 date: date,
14586 timeObj: parsedTime
14587 };
14588 } else {
14589 return {
14590 date: date
14591 };
14592 }
14593 };
14594
14595 /*
14596 * Internal function to set timezone_select to the local timezone
14597 */
14598 var selectLocalTimeZone = function(tp_inst, date) {
14599 if (tp_inst && tp_inst.timezone_select) {
14600 tp_inst._defaults.useLocalTimezone = true;
14601 var now = typeof date !== 'undefined' ? date : new Date();
14602 var tzoffset = $.timepicker.timeZoneOffsetString(now);
14603 if (tp_inst._defaults.timezoneIso8601) {
14604 tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
14605 }
14606 tp_inst.timezone_select.val(tzoffset);
14607 }
14608 };
14609
14610 /*
14611 * Create a Singleton Insance
14612 */
14613 $.timepicker = new Timepicker();
14614
14615 /**
14616 * Get the timezone offset as string from a date object (eg '+0530' for UTC+5.5)
14617 * @param date
14618 * @return string
14619 */
14620 $.timepicker.timeZoneOffsetString = function(date) {
14621 var off = date.getTimezoneOffset() * -1,
14622 minutes = off % 60,
14623 hours = (off - minutes) / 60;
14624 return (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).slice(-2) + ('0' + (minutes * 101).toString()).slice(-2);
14625 };
14626
14627 /**
14628 * Calls `timepicker()` on the `startTime` and `endTime` elements, and configures them to
14629 * enforce date range limits.
14630 * n.b. The input value must be correctly formatted (reformatting is not supported)
14631 * @param Element startTime
14632 * @param Element endTime
14633 * @param obj options Options for the timepicker() call
14634 * @return jQuery
14635 */
14636 $.timepicker.timeRange = function(startTime, endTime, options) {
14637 return $.timepicker.handleRange('timepicker', startTime, endTime, options);
14638 };
14639
14640 /**
14641 * Calls `datetimepicker` on the `startTime` and `endTime` elements, and configures them to
14642 * enforce date range limits.
14643 * @param Element startTime
14644 * @param Element endTime
14645 * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
14646 * a boolean value that can be used to reformat the input values to the `dateFormat`.
14647 * @param string method Can be used to specify the type of picker to be added
14648 * @return jQuery
14649 */
14650 $.timepicker.dateTimeRange = function(startTime, endTime, options) {
14651 $.timepicker.dateRange(startTime, endTime, options, 'datetimepicker');
14652 };
14653
14654 /**
14655 * Calls `method` on the `startTime` and `endTime` elements, and configures them to
14656 * enforce date range limits.
14657 * @param Element startTime
14658 * @param Element endTime
14659 * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
14660 * a boolean value that can be used to reformat the input values to the `dateFormat`.
14661 * @param string method Can be used to specify the type of picker to be added
14662 * @return jQuery
14663 */
14664 $.timepicker.dateRange = function(startTime, endTime, options, method) {
14665 method = method || 'datepicker';
14666 $.timepicker.handleRange(method, startTime, endTime, options);
14667 };
14668
14669 /**
14670 * Calls `method` on the `startTime` and `endTime` elements, and configures them to
14671 * enforce date range limits.
14672 * @param string method Can be used to specify the type of picker to be added
14673 * @param Element startTime
14674 * @param Element endTime
14675 * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
14676 * a boolean value that can be used to reformat the input values to the `dateFormat`.
14677 * @return jQuery
14678 */
14679 $.timepicker.handleRange = function(method, startTime, endTime, options) {
14680 $.fn[method].call(startTime, $.extend({
14681 onClose: function(dateText, inst) {
14682 checkDates(this, endTime, dateText);
14683 },
14684 onSelect: function(selectedDateTime) {
14685 selected(this, endTime, 'minDate');
14686 }
14687 }, options, options.start));
14688 $.fn[method].call(endTime, $.extend({
14689 onClose: function(dateText, inst) {
14690 checkDates(this, startTime, dateText);
14691 },
14692 onSelect: function(selectedDateTime) {
14693 selected(this, startTime, 'maxDate');
14694 }
14695 }, options, options.end));
14696 // timepicker doesn't provide access to its 'timeFormat' option,
14697 // nor could I get datepicker.formatTime() to behave with times, so I
14698 // have disabled reformatting for timepicker
14699 if (method != 'timepicker' && options.reformat) {
14700 $([startTime, endTime]).each(function() {
14701 var format = $(this)[method].call($(this), 'option', 'dateFormat'),
14702 date = new Date($(this).val());
14703 if ($(this).val() && date) {
14704 $(this).val($.datepicker.formatDate(format, date));
14705 }
14706 });
14707 }
14708 checkDates(startTime, endTime, startTime.val());
14709
14710 function checkDates(changed, other, dateText) {
14711 if (other.val() && (new Date(startTime.val()) > new Date(endTime.val()))) {
14712 other.val(dateText);
14713 }
14714 }
14715 selected(startTime, endTime, 'minDate');
14716 selected(endTime, startTime, 'maxDate');
14717
14718 function selected(changed, other, option) {
14719 if (!$(changed).val()) {
14720 return;
14721 }
14722 var date = $(changed)[method].call($(changed), 'getDate');
14723 // timepicker doesn't implement 'getDate' and returns a jQuery
14724 if (date.getTime) {
14725 $(other)[method].call($(other), 'option', option, date);
14726 }
14727 }
14728 return $([startTime.get(0), endTime.get(0)]);
14729 };
14730
14731 /**
14732 * Log error or data to the console during error or debugging
14733 * @param Object err pass any type object to log to the console during error or debugging
14734 * @return void
14735 */
14736 $.timepicker.log = function(err){
14737 if(window.console)
14738 console.log(err);
14739 };
14740
14741 /*
14742 * Keep up with the version
14743 */
14744 $.timepicker.version = "1.2";
14745
14746 })(jQuery);
14747
14748 /* assets/wpuf/vendor/sweetalert2/dist/sweetalert2.js */
14749 /*!
14750 * sweetalert2 v6.6.4
14751 * Released under the MIT License.
14752 */
14753 (function (global, factory) {
14754 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
14755 typeof define === 'function' && define.amd ? define(factory) :
14756 (global.Sweetalert2 = factory());
14757 }(this, (function () { 'use strict';
14758
14759 var defaultParams = {
14760 title: '',
14761 titleText: '',
14762 text: '',
14763 html: '',
14764 type: null,
14765 customClass: '',
14766 target: 'body',
14767 animation: true,
14768 allowOutsideClick: true,
14769 allowEscapeKey: true,
14770 allowEnterKey: true,
14771 showConfirmButton: true,
14772 showCancelButton: false,
14773 preConfirm: null,
14774 confirmButtonText: 'OK',
14775 confirmButtonColor: '#3085d6',
14776 confirmButtonClass: null,
14777 cancelButtonText: 'Cancel',
14778 cancelButtonColor: '#aaa',
14779 cancelButtonClass: null,
14780 buttonsStyling: true,
14781 reverseButtons: false,
14782 focusCancel: false,
14783 showCloseButton: false,
14784 showLoaderOnConfirm: false,
14785 imageUrl: null,
14786 imageWidth: null,
14787 imageHeight: null,
14788 imageClass: null,
14789 timer: null,
14790 width: 500,
14791 padding: 20,
14792 background: '#fff',
14793 input: null,
14794 inputPlaceholder: '',
14795 inputValue: '',
14796 inputOptions: {},
14797 inputAutoTrim: true,
14798 inputClass: null,
14799 inputAttributes: {},
14800 inputValidator: null,
14801 progressSteps: [],
14802 currentProgressStep: null,
14803 progressStepsDistance: '40px',
14804 onOpen: null,
14805 onClose: null,
14806 useRejections: true
14807 };
14808
14809 var swalPrefix = 'swal2-';
14810
14811 var prefix = function prefix(items) {
14812 var result = {};
14813 for (var i in items) {
14814 result[items[i]] = swalPrefix + items[i];
14815 }
14816 return result;
14817 };
14818
14819 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']);
14820
14821 var iconTypes = prefix(['success', 'warning', 'info', 'question', 'error']);
14822
14823 /*
14824 * Set hover, active and focus-states for buttons (source: http://www.sitepoint.com/javascript-generate-lighter-darker-color)
14825 */
14826 var colorLuminance = function colorLuminance(hex, lum) {
14827 // Validate hex string
14828 hex = String(hex).replace(/[^0-9a-f]/gi, '');
14829 if (hex.length < 6) {
14830 hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
14831 }
14832 lum = lum || 0;
14833
14834 // Convert to decimal and change luminosity
14835 var rgb = '#';
14836 for (var i = 0; i < 3; i++) {
14837 var c = parseInt(hex.substr(i * 2, 2), 16);
14838 c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
14839 rgb += ('00' + c).substr(c.length);
14840 }
14841
14842 return rgb;
14843 };
14844
14845 var uniqueArray = function uniqueArray(arr) {
14846 var result = [];
14847 for (var i in arr) {
14848 if (result.indexOf(arr[i]) === -1) {
14849 result.push(arr[i]);
14850 }
14851 }
14852 return result;
14853 };
14854
14855 /* global MouseEvent */
14856
14857 // Remember state in cases where opening and handling a modal will fiddle with it.
14858 var states = {
14859 previousWindowKeyDown: null,
14860 previousActiveElement: null,
14861 previousBodyPadding: null
14862 };
14863
14864 /*
14865 * Add modal + overlay to DOM
14866 */
14867 var init = function init(params) {
14868 if (typeof document === 'undefined') {
14869 console.error('SweetAlert2 requires document to initialize');
14870 return;
14871 }
14872
14873 var container = document.createElement('div');
14874 container.className = swalClasses.container;
14875 container.innerHTML = sweetHTML;
14876
14877 var targetElement = document.querySelector(params.target);
14878 if (!targetElement) {
14879 console.warn('SweetAlert2: Can\'t find the target "' + params.target + '"');
14880 targetElement = document.body;
14881 }
14882 targetElement.appendChild(container);
14883
14884 var modal = getModal();
14885 var input = getChildByClass(modal, swalClasses.input);
14886 var file = getChildByClass(modal, swalClasses.file);
14887 var range = modal.querySelector('.' + swalClasses.range + ' input');
14888 var rangeOutput = modal.querySelector('.' + swalClasses.range + ' output');
14889 var select = getChildByClass(modal, swalClasses.select);
14890 var checkbox = modal.querySelector('.' + swalClasses.checkbox + ' input');
14891 var textarea = getChildByClass(modal, swalClasses.textarea);
14892
14893 input.oninput = function () {
14894 sweetAlert.resetValidationError();
14895 };
14896
14897 input.onkeydown = function (event) {
14898 setTimeout(function () {
14899 if (event.keyCode === 13 && params.allowEnterKey) {
14900 event.stopPropagation();
14901 sweetAlert.clickConfirm();
14902 }
14903 }, 0);
14904 };
14905
14906 file.onchange = function () {
14907 sweetAlert.resetValidationError();
14908 };
14909
14910 range.oninput = function () {
14911 sweetAlert.resetValidationError();
14912 rangeOutput.value = range.value;
14913 };
14914
14915 range.onchange = function () {
14916 sweetAlert.resetValidationError();
14917 range.previousSibling.value = range.value;
14918 };
14919
14920 select.onchange = function () {
14921 sweetAlert.resetValidationError();
14922 };
14923
14924 checkbox.onchange = function () {
14925 sweetAlert.resetValidationError();
14926 };
14927
14928 textarea.oninput = function () {
14929 sweetAlert.resetValidationError();
14930 };
14931
14932 return modal;
14933 };
14934
14935 /*
14936 * Manipulate DOM
14937 */
14938
14939 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, '');
14940
14941 var getContainer = function getContainer() {
14942 return document.body.querySelector('.' + swalClasses.container);
14943 };
14944
14945 var getModal = function getModal() {
14946 return getContainer() ? getContainer().querySelector('.' + swalClasses.modal) : null;
14947 };
14948
14949 var getIcons = function getIcons() {
14950 var modal = getModal();
14951 return modal.querySelectorAll('.' + swalClasses.icon);
14952 };
14953
14954 var elementByClass = function elementByClass(className) {
14955 return getContainer() ? getContainer().querySelector('.' + className) : null;
14956 };
14957
14958 var getTitle = function getTitle() {
14959 return elementByClass(swalClasses.title);
14960 };
14961
14962 var getContent = function getContent() {
14963 return elementByClass(swalClasses.content);
14964 };
14965
14966 var getImage = function getImage() {
14967 return elementByClass(swalClasses.image);
14968 };
14969
14970 var getButtonsWrapper = function getButtonsWrapper() {
14971 return elementByClass(swalClasses.buttonswrapper);
14972 };
14973
14974 var getProgressSteps = function getProgressSteps() {
14975 return elementByClass(swalClasses.progresssteps);
14976 };
14977
14978 var getValidationError = function getValidationError() {
14979 return elementByClass(swalClasses.validationerror);
14980 };
14981
14982 var getConfirmButton = function getConfirmButton() {
14983 return elementByClass(swalClasses.confirm);
14984 };
14985
14986 var getCancelButton = function getCancelButton() {
14987 return elementByClass(swalClasses.cancel);
14988 };
14989
14990 var getCloseButton = function getCloseButton() {
14991 return elementByClass(swalClasses.close);
14992 };
14993
14994 var getFocusableElements = function getFocusableElements(focusCancel) {
14995 var buttons = [getConfirmButton(), getCancelButton()];
14996 if (focusCancel) {
14997 buttons.reverse();
14998 }
14999 var focusableElements = buttons.concat(Array.prototype.slice.call(getModal().querySelectorAll('button, input:not([type=hidden]), textarea, select, a, *[tabindex]:not([tabindex="-1"])')));
15000 return uniqueArray(focusableElements);
15001 };
15002
15003 var hasClass = function hasClass(elem, className) {
15004 if (elem.classList) {
15005 return elem.classList.contains(className);
15006 }
15007 return false;
15008 };
15009
15010 var focusInput = function focusInput(input) {
15011 input.focus();
15012
15013 // place cursor at end of text in text input
15014 if (input.type !== 'file') {
15015 // http://stackoverflow.com/a/2345915/1331425
15016 var val = input.value;
15017 input.value = '';
15018 input.value = val;
15019 }
15020 };
15021
15022 var addClass = function addClass(elem, className) {
15023 if (!elem || !className) {
15024 return;
15025 }
15026 var classes = className.split(/\s+/).filter(Boolean);
15027 classes.forEach(function (className) {
15028 elem.classList.add(className);
15029 });
15030 };
15031
15032 var removeClass = function removeClass(elem, className) {
15033 if (!elem || !className) {
15034 return;
15035 }
15036 var classes = className.split(/\s+/).filter(Boolean);
15037 classes.forEach(function (className) {
15038 elem.classList.remove(className);
15039 });
15040 };
15041
15042 var getChildByClass = function getChildByClass(elem, className) {
15043 for (var i = 0; i < elem.childNodes.length; i++) {
15044 if (hasClass(elem.childNodes[i], className)) {
15045 return elem.childNodes[i];
15046 }
15047 }
15048 };
15049
15050 var show = function show(elem, display) {
15051 if (!display) {
15052 display = 'block';
15053 }
15054 elem.style.opacity = '';
15055 elem.style.display = display;
15056 };
15057
15058 var hide = function hide(elem) {
15059 elem.style.opacity = '';
15060 elem.style.display = 'none';
15061 };
15062
15063 var empty = function empty(elem) {
15064 while (elem.firstChild) {
15065 elem.removeChild(elem.firstChild);
15066 }
15067 };
15068
15069 // borrowed from jqeury $(elem).is(':visible') implementation
15070 var isVisible = function isVisible(elem) {
15071 return elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length;
15072 };
15073
15074 var removeStyleProperty = function removeStyleProperty(elem, property) {
15075 if (elem.style.removeProperty) {
15076 elem.style.removeProperty(property);
15077 } else {
15078 elem.style.removeAttribute(property);
15079 }
15080 };
15081
15082 var fireClick = function fireClick(node) {
15083 if (!isVisible(node)) {
15084 return false;
15085 }
15086
15087 // Taken from http://www.nonobtrusive.com/2011/11/29/programatically-fire-crossbrowser-click-event-with-javascript/
15088 // Then fixed for today's Chrome browser.
15089 if (typeof MouseEvent === 'function') {
15090 // Up-to-date approach
15091 var mevt = new MouseEvent('click', {
15092 view: window,
15093 bubbles: false,
15094 cancelable: true
15095 });
15096 node.dispatchEvent(mevt);
15097 } else if (document.createEvent) {
15098 // Fallback
15099 var evt = document.createEvent('MouseEvents');
15100 evt.initEvent('click', false, false);
15101 node.dispatchEvent(evt);
15102 } else if (document.createEventObject) {
15103 node.fireEvent('onclick');
15104 } else if (typeof node.onclick === 'function') {
15105 node.onclick();
15106 }
15107 };
15108
15109 var animationEndEvent = function () {
15110 var testEl = document.createElement('div');
15111 var transEndEventNames = {
15112 'WebkitAnimation': 'webkitAnimationEnd',
15113 'OAnimation': 'oAnimationEnd oanimationend',
15114 'msAnimation': 'MSAnimationEnd',
15115 'animation': 'animationend'
15116 };
15117 for (var i in transEndEventNames) {
15118 if (transEndEventNames.hasOwnProperty(i) && testEl.style[i] !== undefined) {
15119 return transEndEventNames[i];
15120 }
15121 }
15122
15123 return false;
15124 }();
15125
15126 // Reset previous window keydown handler and focued element
15127 var resetPrevState = function resetPrevState() {
15128 window.onkeydown = states.previousWindowKeyDown;
15129 if (states.previousActiveElement && states.previousActiveElement.focus) {
15130 var x = window.scrollX;
15131 var y = window.scrollY;
15132 states.previousActiveElement.focus();
15133 if (x && y) {
15134 // IE has no scrollX/scrollY support
15135 window.scrollTo(x, y);
15136 }
15137 }
15138 };
15139
15140 // Measure width of scrollbar
15141 // https://github.com/twbs/bootstrap/blob/master/js/modal.js#L279-L286
15142 var measureScrollbar = function measureScrollbar() {
15143 var supportsTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints;
15144 if (supportsTouch) {
15145 return 0;
15146 }
15147 var scrollDiv = document.createElement('div');
15148 scrollDiv.style.width = '50px';
15149 scrollDiv.style.height = '50px';
15150 scrollDiv.style.overflow = 'scroll';
15151 document.body.appendChild(scrollDiv);
15152 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
15153 document.body.removeChild(scrollDiv);
15154 return scrollbarWidth;
15155 };
15156
15157 // JavaScript Debounce Function
15158 // Simplivied version of https://davidwalsh.name/javascript-debounce-function
15159 var debounce = function debounce(func, wait) {
15160 var timeout = void 0;
15161 return function () {
15162 var later = function later() {
15163 timeout = null;
15164 func();
15165 };
15166 clearTimeout(timeout);
15167 timeout = setTimeout(later, wait);
15168 };
15169 };
15170
15171 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
15172 return typeof obj;
15173 } : function (obj) {
15174 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
15175 };
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197 var _extends = Object.assign || function (target) {
15198 for (var i = 1; i < arguments.length; i++) {
15199 var source = arguments[i];
15200
15201 for (var key in source) {
15202 if (Object.prototype.hasOwnProperty.call(source, key)) {
15203 target[key] = source[key];
15204 }
15205 }
15206 }
15207
15208 return target;
15209 };
15210
15211 var modalParams = _extends({}, defaultParams);
15212 var queue = [];
15213 var swal2Observer = void 0;
15214
15215 /*
15216 * Set type, text and actions on modal
15217 */
15218 var setParameters = function setParameters(params) {
15219 var modal = getModal() || init(params);
15220
15221 for (var param in params) {
15222 if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
15223 console.warn('SweetAlert2: Unknown parameter "' + param + '"');
15224 }
15225 }
15226
15227 // Set modal width
15228 modal.style.width = typeof params.width === 'number' ? params.width + 'px' : params.width;
15229
15230 modal.style.padding = params.padding + 'px';
15231 modal.style.background = params.background;
15232 var successIconParts = modal.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
15233 for (var i = 0; i < successIconParts.length; i++) {
15234 successIconParts[i].style.background = params.background;
15235 }
15236
15237 var title = getTitle();
15238 var content = getContent();
15239 var buttonsWrapper = getButtonsWrapper();
15240 var confirmButton = getConfirmButton();
15241 var cancelButton = getCancelButton();
15242 var closeButton = getCloseButton();
15243
15244 // Title
15245 if (params.titleText) {
15246 title.innerText = params.titleText;
15247 } else {
15248 title.innerHTML = params.title.split('\n').join('<br>');
15249 }
15250
15251 // Content
15252 if (params.text || params.html) {
15253 if (_typeof(params.html) === 'object') {
15254 content.innerHTML = '';
15255 if (0 in params.html) {
15256 for (var _i = 0; _i in params.html; _i++) {
15257 content.appendChild(params.html[_i].cloneNode(true));
15258 }
15259 } else {
15260 content.appendChild(params.html.cloneNode(true));
15261 }
15262 } else if (params.html) {
15263 content.innerHTML = params.html;
15264 } else if (params.text) {
15265 content.textContent = params.text;
15266 }
15267 show(content);
15268 } else {
15269 hide(content);
15270 }
15271
15272 // Close button
15273 if (params.showCloseButton) {
15274 show(closeButton);
15275 } else {
15276 hide(closeButton);
15277 }
15278
15279 // Custom Class
15280 modal.className = swalClasses.modal;
15281 if (params.customClass) {
15282 addClass(modal, params.customClass);
15283 }
15284
15285 // Progress steps
15286 var progressStepsContainer = getProgressSteps();
15287 var currentProgressStep = parseInt(params.currentProgressStep === null ? sweetAlert.getQueueStep() : params.currentProgressStep, 10);
15288 if (params.progressSteps.length) {
15289 show(progressStepsContainer);
15290 empty(progressStepsContainer);
15291 if (currentProgressStep >= params.progressSteps.length) {
15292 console.warn('SweetAlert2: Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
15293 }
15294 params.progressSteps.forEach(function (step, index) {
15295 var circle = document.createElement('li');
15296 addClass(circle, swalClasses.progresscircle);
15297 circle.innerHTML = step;
15298 if (index === currentProgressStep) {
15299 addClass(circle, swalClasses.activeprogressstep);
15300 }
15301 progressStepsContainer.appendChild(circle);
15302 if (index !== params.progressSteps.length - 1) {
15303 var line = document.createElement('li');
15304 addClass(line, swalClasses.progressline);
15305 line.style.width = params.progressStepsDistance;
15306 progressStepsContainer.appendChild(line);
15307 }
15308 });
15309 } else {
15310 hide(progressStepsContainer);
15311 }
15312
15313 // Icon
15314 var icons = getIcons();
15315 for (var _i2 = 0; _i2 < icons.length; _i2++) {
15316 hide(icons[_i2]);
15317 }
15318 if (params.type) {
15319 var validType = false;
15320 for (var iconType in iconTypes) {
15321 if (params.type === iconType) {
15322 validType = true;
15323 break;
15324 }
15325 }
15326 if (!validType) {
15327 console.error('SweetAlert2: Unknown alert type: ' + params.type);
15328 return false;
15329 }
15330 var icon = modal.querySelector('.' + swalClasses.icon + '.' + iconTypes[params.type]);
15331 show(icon);
15332
15333 // Animate icon
15334 if (params.animation) {
15335 switch (params.type) {
15336 case 'success':
15337 addClass(icon, 'swal2-animate-success-icon');
15338 addClass(icon.querySelector('.swal2-success-line-tip'), 'swal2-animate-success-line-tip');
15339 addClass(icon.querySelector('.swal2-success-line-long'), 'swal2-animate-success-line-long');
15340 break;
15341 case 'error':
15342 addClass(icon, 'swal2-animate-error-icon');
15343 addClass(icon.querySelector('.swal2-x-mark'), 'swal2-animate-x-mark');
15344 break;
15345 default:
15346 break;
15347 }
15348 }
15349 }
15350
15351 // Custom image
15352 var image = getImage();
15353 if (params.imageUrl) {
15354 image.setAttribute('src', params.imageUrl);
15355 show(image);
15356
15357 if (params.imageWidth) {
15358 image.setAttribute('width', params.imageWidth);
15359 } else {
15360 image.removeAttribute('width');
15361 }
15362
15363 if (params.imageHeight) {
15364 image.setAttribute('height', params.imageHeight);
15365 } else {
15366 image.removeAttribute('height');
15367 }
15368
15369 image.className = swalClasses.image;
15370 if (params.imageClass) {
15371 addClass(image, params.imageClass);
15372 }
15373 } else {
15374 hide(image);
15375 }
15376
15377 // Cancel button
15378 if (params.showCancelButton) {
15379 cancelButton.style.display = 'inline-block';
15380 } else {
15381 hide(cancelButton);
15382 }
15383
15384 // Confirm button
15385 if (params.showConfirmButton) {
15386 removeStyleProperty(confirmButton, 'display');
15387 } else {
15388 hide(confirmButton);
15389 }
15390
15391 // Buttons wrapper
15392 if (!params.showConfirmButton && !params.showCancelButton) {
15393 hide(buttonsWrapper);
15394 } else {
15395 show(buttonsWrapper);
15396 }
15397
15398 // Edit text on cancel and confirm buttons
15399 confirmButton.innerHTML = params.confirmButtonText;
15400 cancelButton.innerHTML = params.cancelButtonText;
15401
15402 // Set buttons to selected background colors
15403 if (params.buttonsStyling) {
15404 confirmButton.style.backgroundColor = params.confirmButtonColor;
15405 cancelButton.style.backgroundColor = params.cancelButtonColor;
15406 }
15407
15408 // Add buttons custom classes
15409 confirmButton.className = swalClasses.confirm;
15410 addClass(confirmButton, params.confirmButtonClass);
15411 cancelButton.className = swalClasses.cancel;
15412 addClass(cancelButton, params.cancelButtonClass);
15413
15414 // Buttons styling
15415 if (params.buttonsStyling) {
15416 addClass(confirmButton, swalClasses.styled);
15417 addClass(cancelButton, swalClasses.styled);
15418 } else {
15419 removeClass(confirmButton, swalClasses.styled);
15420 removeClass(cancelButton, swalClasses.styled);
15421
15422 confirmButton.style.backgroundColor = confirmButton.style.borderLeftColor = confirmButton.style.borderRightColor = '';
15423 cancelButton.style.backgroundColor = cancelButton.style.borderLeftColor = cancelButton.style.borderRightColor = '';
15424 }
15425
15426 // CSS animation
15427 if (params.animation === true) {
15428 removeClass(modal, swalClasses.noanimation);
15429 } else {
15430 addClass(modal, swalClasses.noanimation);
15431 }
15432 };
15433
15434 /*
15435 * Animations
15436 */
15437 var openModal = function openModal(animation, onComplete) {
15438 var container = getContainer();
15439 var modal = getModal();
15440
15441 if (animation) {
15442 addClass(modal, swalClasses.show);
15443 addClass(container, swalClasses.fade);
15444 removeClass(modal, swalClasses.hide);
15445 } else {
15446 removeClass(modal, swalClasses.fade);
15447 }
15448 show(modal);
15449
15450 // scrolling is 'hidden' until animation is done, after that 'auto'
15451 container.style.overflowY = 'hidden';
15452 if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
15453 modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
15454 modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
15455 container.style.overflowY = 'auto';
15456 });
15457 } else {
15458 container.style.overflowY = 'auto';
15459 }
15460
15461 addClass(document.documentElement, swalClasses.shown);
15462 addClass(document.body, swalClasses.shown);
15463 addClass(container, swalClasses.shown);
15464 fixScrollbar();
15465 iOSfix();
15466 states.previousActiveElement = document.activeElement;
15467 if (onComplete !== null && typeof onComplete === 'function') {
15468 setTimeout(function () {
15469 onComplete(modal);
15470 });
15471 }
15472 };
15473
15474 var fixScrollbar = function fixScrollbar() {
15475 // for queues, do not do this more than once
15476 if (states.previousBodyPadding !== null) {
15477 return;
15478 }
15479 // if the body has overflow
15480 if (document.body.scrollHeight > window.innerHeight) {
15481 // add padding so the content doesn't shift after removal of scrollbar
15482 states.previousBodyPadding = document.body.style.paddingRight;
15483 document.body.style.paddingRight = measureScrollbar() + 'px';
15484 }
15485 };
15486
15487 var undoScrollbar = function undoScrollbar() {
15488 if (states.previousBodyPadding !== null) {
15489 document.body.style.paddingRight = states.previousBodyPadding;
15490 states.previousBodyPadding = null;
15491 }
15492 };
15493
15494 // Fix iOS scrolling http://stackoverflow.com/q/39626302/1331425
15495 var iOSfix = function iOSfix() {
15496 var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
15497 if (iOS && !hasClass(document.body, swalClasses.iosfix)) {
15498 var offset = document.body.scrollTop;
15499 document.body.style.top = offset * -1 + 'px';
15500 addClass(document.body, swalClasses.iosfix);
15501 }
15502 };
15503
15504 var undoIOSfix = function undoIOSfix() {
15505 if (hasClass(document.body, swalClasses.iosfix)) {
15506 var offset = parseInt(document.body.style.top, 10);
15507 removeClass(document.body, swalClasses.iosfix);
15508 document.body.style.top = '';
15509 document.body.scrollTop = offset * -1;
15510 }
15511 };
15512
15513 // SweetAlert entry point
15514 var sweetAlert = function sweetAlert() {
15515 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
15516 args[_key] = arguments[_key];
15517 }
15518
15519 if (args[0] === undefined) {
15520 console.error('SweetAlert2 expects at least 1 attribute!');
15521 return false;
15522 }
15523
15524 var params = _extends({}, modalParams);
15525
15526 switch (_typeof(args[0])) {
15527 case 'string':
15528 params.title = args[0];
15529 params.html = args[1];
15530 params.type = args[2];
15531
15532 break;
15533
15534 case 'object':
15535 _extends(params, args[0]);
15536 params.extraParams = args[0].extraParams;
15537
15538 if (params.input === 'email' && params.inputValidator === null) {
15539 params.inputValidator = function (email) {
15540 return new Promise(function (resolve, reject) {
15541 var emailRegex = /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
15542 if (emailRegex.test(email)) {
15543 resolve();
15544 } else {
15545 reject('Invalid email address');
15546 }
15547 });
15548 };
15549 }
15550
15551 if (params.input === 'url' && params.inputValidator === null) {
15552 params.inputValidator = function (url) {
15553 return new Promise(function (resolve, reject) {
15554 var urlRegex = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/;
15555 if (urlRegex.test(url)) {
15556 resolve();
15557 } else {
15558 reject('Invalid URL');
15559 }
15560 });
15561 };
15562 }
15563 break;
15564
15565 default:
15566 console.error('SweetAlert2: Unexpected type of argument! Expected "string" or "object", got ' + _typeof(args[0]));
15567 return false;
15568 }
15569
15570 setParameters(params);
15571
15572 var container = getContainer();
15573 var modal = getModal();
15574
15575 return new Promise(function (resolve, reject) {
15576 // Close on timer
15577 if (params.timer) {
15578 modal.timeout = setTimeout(function () {
15579 sweetAlert.closeModal(params.onClose);
15580 if (params.useRejections) {
15581 reject('timer');
15582 } else {
15583 resolve({ dismiss: 'timer' });
15584 }
15585 }, params.timer);
15586 }
15587
15588 // Get input element by specified type or, if type isn't specified, by params.input
15589 var getInput = function getInput(inputType) {
15590 inputType = inputType || params.input;
15591 if (!inputType) {
15592 return null;
15593 }
15594 switch (inputType) {
15595 case 'select':
15596 case 'textarea':
15597 case 'file':
15598 return getChildByClass(modal, swalClasses[inputType]);
15599 case 'checkbox':
15600 return modal.querySelector('.' + swalClasses.checkbox + ' input');
15601 case 'radio':
15602 return modal.querySelector('.' + swalClasses.radio + ' input:checked') || modal.querySelector('.' + swalClasses.radio + ' input:first-child');
15603 case 'range':
15604 return modal.querySelector('.' + swalClasses.range + ' input');
15605 default:
15606 return getChildByClass(modal, swalClasses.input);
15607 }
15608 };
15609
15610 // Get the value of the modal input
15611 var getInputValue = function getInputValue() {
15612 var input = getInput();
15613 if (!input) {
15614 return null;
15615 }
15616 switch (params.input) {
15617 case 'checkbox':
15618 return input.checked ? 1 : 0;
15619 case 'radio':
15620 return input.checked ? input.value : null;
15621 case 'file':
15622 return input.files.length ? input.files[0] : null;
15623 default:
15624 return params.inputAutoTrim ? input.value.trim() : input.value;
15625 }
15626 };
15627
15628 // input autofocus
15629 if (params.input) {
15630 setTimeout(function () {
15631 var input = getInput();
15632 if (input) {
15633 focusInput(input);
15634 }
15635 }, 0);
15636 }
15637
15638 var confirm = function confirm(value) {
15639 if (params.showLoaderOnConfirm) {
15640 sweetAlert.showLoading();
15641 }
15642
15643 if (params.preConfirm) {
15644 params.preConfirm(value, params.extraParams).then(function (preConfirmValue) {
15645 sweetAlert.closeModal(params.onClose);
15646 resolve(preConfirmValue || value);
15647 }, function (error) {
15648 sweetAlert.hideLoading();
15649 if (error) {
15650 sweetAlert.showValidationError(error);
15651 }
15652 });
15653 } else {
15654 sweetAlert.closeModal(params.onClose);
15655 if (params.useRejections) {
15656 resolve(value);
15657 } else {
15658 resolve({ value: value });
15659 }
15660 }
15661 };
15662
15663 // Mouse interactions
15664 var onButtonEvent = function onButtonEvent(event) {
15665 var e = event || window.event;
15666 var target = e.target || e.srcElement;
15667 var confirmButton = getConfirmButton();
15668 var cancelButton = getCancelButton();
15669 var targetedConfirm = confirmButton && (confirmButton === target || confirmButton.contains(target));
15670 var targetedCancel = cancelButton && (cancelButton === target || cancelButton.contains(target));
15671
15672 switch (e.type) {
15673 case 'mouseover':
15674 case 'mouseup':
15675 if (params.buttonsStyling) {
15676 if (targetedConfirm) {
15677 confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.1);
15678 } else if (targetedCancel) {
15679 cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.1);
15680 }
15681 }
15682 break;
15683 case 'mouseout':
15684 if (params.buttonsStyling) {
15685 if (targetedConfirm) {
15686 confirmButton.style.backgroundColor = params.confirmButtonColor;
15687 } else if (targetedCancel) {
15688 cancelButton.style.backgroundColor = params.cancelButtonColor;
15689 }
15690 }
15691 break;
15692 case 'mousedown':
15693 if (params.buttonsStyling) {
15694 if (targetedConfirm) {
15695 confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.2);
15696 } else if (targetedCancel) {
15697 cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.2);
15698 }
15699 }
15700 break;
15701 case 'click':
15702 // Clicked 'confirm'
15703 if (targetedConfirm && sweetAlert.isVisible()) {
15704 sweetAlert.disableButtons();
15705 if (params.input) {
15706 var inputValue = getInputValue();
15707
15708 if (params.inputValidator) {
15709 sweetAlert.disableInput();
15710 params.inputValidator(inputValue, params.extraParams).then(function () {
15711 sweetAlert.enableButtons();
15712 sweetAlert.enableInput();
15713 confirm(inputValue);
15714 }, function (error) {
15715 sweetAlert.enableButtons();
15716 sweetAlert.enableInput();
15717 if (error) {
15718 sweetAlert.showValidationError(error);
15719 }
15720 });
15721 } else {
15722 confirm(inputValue);
15723 }
15724 } else {
15725 confirm(true);
15726 }
15727
15728 // Clicked 'cancel'
15729 } else if (targetedCancel && sweetAlert.isVisible()) {
15730 sweetAlert.disableButtons();
15731 sweetAlert.closeModal(params.onClose);
15732 if (params.useRejections) {
15733 reject('cancel');
15734 } else {
15735 resolve({ dismiss: 'cancel' });
15736 }
15737 }
15738 break;
15739 default:
15740 }
15741 };
15742
15743 var buttons = modal.querySelectorAll('button');
15744 for (var i = 0; i < buttons.length; i++) {
15745 buttons[i].onclick = onButtonEvent;
15746 buttons[i].onmouseover = onButtonEvent;
15747 buttons[i].onmouseout = onButtonEvent;
15748 buttons[i].onmousedown = onButtonEvent;
15749 }
15750
15751 // Closing modal by close button
15752 getCloseButton().onclick = function () {
15753 sweetAlert.closeModal(params.onClose);
15754 if (params.useRejections) {
15755 reject('close');
15756 } else {
15757 resolve({ dismiss: 'close' });
15758 }
15759 };
15760
15761 // Closing modal by overlay click
15762 container.onclick = function (e) {
15763 if (e.target !== container) {
15764 return;
15765 }
15766 if (params.allowOutsideClick) {
15767 sweetAlert.closeModal(params.onClose);
15768 if (params.useRejections) {
15769 reject('overlay');
15770 } else {
15771 resolve({ dismiss: 'overlay' });
15772 }
15773 }
15774 };
15775
15776 var buttonsWrapper = getButtonsWrapper();
15777 var confirmButton = getConfirmButton();
15778 var cancelButton = getCancelButton();
15779
15780 // Reverse buttons (Confirm on the right side)
15781 if (params.reverseButtons) {
15782 confirmButton.parentNode.insertBefore(cancelButton, confirmButton);
15783 } else {
15784 confirmButton.parentNode.insertBefore(confirmButton, cancelButton);
15785 }
15786
15787 // Focus handling
15788 var setFocus = function setFocus(index, increment) {
15789 var focusableElements = getFocusableElements(params.focusCancel);
15790 // search for visible elements and select the next possible match
15791 for (var _i3 = 0; _i3 < focusableElements.length; _i3++) {
15792 index = index + increment;
15793
15794 // rollover to first item
15795 if (index === focusableElements.length) {
15796 index = 0;
15797
15798 // go to last item
15799 } else if (index === -1) {
15800 index = focusableElements.length - 1;
15801 }
15802
15803 // determine if element is visible
15804 var el = focusableElements[index];
15805 if (isVisible(el)) {
15806 return el.focus();
15807 }
15808 }
15809 };
15810
15811 var handleKeyDown = function handleKeyDown(event) {
15812 var e = event || window.event;
15813 var keyCode = e.keyCode || e.which;
15814
15815 if ([9, 13, 32, 27, 37, 38, 39, 40].indexOf(keyCode) === -1) {
15816 // Don't do work on keys we don't care about.
15817 return;
15818 }
15819
15820 var targetElement = e.target || e.srcElement;
15821
15822 var focusableElements = getFocusableElements(params.focusCancel);
15823 var btnIndex = -1; // Find the button - note, this is a nodelist, not an array.
15824 for (var _i4 = 0; _i4 < focusableElements.length; _i4++) {
15825 if (targetElement === focusableElements[_i4]) {
15826 btnIndex = _i4;
15827 break;
15828 }
15829 }
15830
15831 // TAB
15832 if (keyCode === 9) {
15833 if (!e.shiftKey) {
15834 // Cycle to the next button
15835 setFocus(btnIndex, 1);
15836 } else {
15837 // Cycle to the prev button
15838 setFocus(btnIndex, -1);
15839 }
15840 e.stopPropagation();
15841 e.preventDefault();
15842
15843 // ARROWS - switch focus between buttons
15844 } else if (keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
15845 // focus Cancel button if Confirm button is currently focused
15846 if (document.activeElement === confirmButton && isVisible(cancelButton)) {
15847 cancelButton.focus();
15848 // and vice versa
15849 } else if (document.activeElement === cancelButton && isVisible(confirmButton)) {
15850 confirmButton.focus();
15851 }
15852
15853 // ENTER/SPACE
15854 } else if (keyCode === 13 || keyCode === 32) {
15855 if (btnIndex === -1 && params.allowEnterKey) {
15856 // ENTER/SPACE clicked outside of a button.
15857 if (params.focusCancel) {
15858 fireClick(cancelButton, e);
15859 } else {
15860 fireClick(confirmButton, e);
15861 }
15862 e.stopPropagation();
15863 e.preventDefault();
15864 }
15865
15866 // ESC
15867 } else if (keyCode === 27 && params.allowEscapeKey === true) {
15868 sweetAlert.closeModal(params.onClose);
15869 if (params.useRejections) {
15870 reject('esc');
15871 } else {
15872 resolve({ dismiss: 'esc' });
15873 }
15874 }
15875 };
15876
15877 if (!window.onkeydown || window.onkeydown.toString() !== handleKeyDown.toString()) {
15878 states.previousWindowKeyDown = window.onkeydown;
15879 window.onkeydown = handleKeyDown;
15880 }
15881
15882 // Loading state
15883 if (params.buttonsStyling) {
15884 confirmButton.style.borderLeftColor = params.confirmButtonColor;
15885 confirmButton.style.borderRightColor = params.confirmButtonColor;
15886 }
15887
15888 /**
15889 * Show spinner instead of Confirm button and disable Cancel button
15890 */
15891 sweetAlert.hideLoading = sweetAlert.disableLoading = function () {
15892 if (!params.showConfirmButton) {
15893 hide(confirmButton);
15894 if (!params.showCancelButton) {
15895 hide(getButtonsWrapper());
15896 }
15897 }
15898 removeClass(buttonsWrapper, swalClasses.loading);
15899 removeClass(modal, swalClasses.loading);
15900 confirmButton.disabled = false;
15901 cancelButton.disabled = false;
15902 };
15903
15904 sweetAlert.getTitle = function () {
15905 return getTitle();
15906 };
15907 sweetAlert.getContent = function () {
15908 return getContent();
15909 };
15910 sweetAlert.getInput = function () {
15911 return getInput();
15912 };
15913 sweetAlert.getImage = function () {
15914 return getImage();
15915 };
15916 sweetAlert.getButtonsWrapper = function () {
15917 return getButtonsWrapper();
15918 };
15919 sweetAlert.getConfirmButton = function () {
15920 return getConfirmButton();
15921 };
15922 sweetAlert.getCancelButton = function () {
15923 return getCancelButton();
15924 };
15925
15926 sweetAlert.enableButtons = function () {
15927 confirmButton.disabled = false;
15928 cancelButton.disabled = false;
15929 };
15930
15931 sweetAlert.disableButtons = function () {
15932 confirmButton.disabled = true;
15933 cancelButton.disabled = true;
15934 };
15935
15936 sweetAlert.enableConfirmButton = function () {
15937 confirmButton.disabled = false;
15938 };
15939
15940 sweetAlert.disableConfirmButton = function () {
15941 confirmButton.disabled = true;
15942 };
15943
15944 sweetAlert.enableInput = function () {
15945 var input = getInput();
15946 if (!input) {
15947 return false;
15948 }
15949 if (input.type === 'radio') {
15950 var radiosContainer = input.parentNode.parentNode;
15951 var radios = radiosContainer.querySelectorAll('input');
15952 for (var _i5 = 0; _i5 < radios.length; _i5++) {
15953 radios[_i5].disabled = false;
15954 }
15955 } else {
15956 input.disabled = false;
15957 }
15958 };
15959
15960 sweetAlert.disableInput = function () {
15961 var input = getInput();
15962 if (!input) {
15963 return false;
15964 }
15965 if (input && input.type === 'radio') {
15966 var radiosContainer = input.parentNode.parentNode;
15967 var radios = radiosContainer.querySelectorAll('input');
15968 for (var _i6 = 0; _i6 < radios.length; _i6++) {
15969 radios[_i6].disabled = true;
15970 }
15971 } else {
15972 input.disabled = true;
15973 }
15974 };
15975
15976 // Set modal min-height to disable scrolling inside the modal
15977 sweetAlert.recalculateHeight = debounce(function () {
15978 var modal = getModal();
15979 if (!modal) {
15980 return;
15981 }
15982 var prevState = modal.style.display;
15983 modal.style.minHeight = '';
15984 show(modal);
15985 modal.style.minHeight = modal.scrollHeight + 1 + 'px';
15986 modal.style.display = prevState;
15987 }, 50);
15988
15989 // Show block with validation error
15990 sweetAlert.showValidationError = function (error) {
15991 var validationError = getValidationError();
15992 validationError.innerHTML = error;
15993 show(validationError);
15994
15995 var input = getInput();
15996 if (input) {
15997 focusInput(input);
15998 addClass(input, swalClasses.inputerror);
15999 }
16000 };
16001
16002 // Hide block with validation error
16003 sweetAlert.resetValidationError = function () {
16004 var validationError = getValidationError();
16005 hide(validationError);
16006 sweetAlert.recalculateHeight();
16007
16008 var input = getInput();
16009 if (input) {
16010 removeClass(input, swalClasses.inputerror);
16011 }
16012 };
16013
16014 sweetAlert.getProgressSteps = function () {
16015 return params.progressSteps;
16016 };
16017
16018 sweetAlert.setProgressSteps = function (progressSteps) {
16019 params.progressSteps = progressSteps;
16020 setParameters(params);
16021 };
16022
16023 sweetAlert.showProgressSteps = function () {
16024 show(getProgressSteps());
16025 };
16026
16027 sweetAlert.hideProgressSteps = function () {
16028 hide(getProgressSteps());
16029 };
16030
16031 sweetAlert.enableButtons();
16032 sweetAlert.hideLoading();
16033 sweetAlert.resetValidationError();
16034
16035 // inputs
16036 var inputTypes = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
16037 var input = void 0;
16038 for (var _i7 = 0; _i7 < inputTypes.length; _i7++) {
16039 var inputClass = swalClasses[inputTypes[_i7]];
16040 var inputContainer = getChildByClass(modal, inputClass);
16041 input = getInput(inputTypes[_i7]);
16042
16043 // set attributes
16044 if (input) {
16045 for (var j in input.attributes) {
16046 if (input.attributes.hasOwnProperty(j)) {
16047 var attrName = input.attributes[j].name;
16048 if (attrName !== 'type' && attrName !== 'value') {
16049 input.removeAttribute(attrName);
16050 }
16051 }
16052 }
16053 for (var attr in params.inputAttributes) {
16054 input.setAttribute(attr, params.inputAttributes[attr]);
16055 }
16056 }
16057
16058 // set class
16059 inputContainer.className = inputClass;
16060 if (params.inputClass) {
16061 addClass(inputContainer, params.inputClass);
16062 }
16063
16064 hide(inputContainer);
16065 }
16066
16067 var populateInputOptions = void 0;
16068 switch (params.input) {
16069 case 'text':
16070 case 'email':
16071 case 'password':
16072 case 'number':
16073 case 'tel':
16074 case 'url':
16075 input = getChildByClass(modal, swalClasses.input);
16076 input.value = params.inputValue;
16077 input.placeholder = params.inputPlaceholder;
16078 input.type = params.input;
16079 show(input);
16080 break;
16081 case 'file':
16082 input = getChildByClass(modal, swalClasses.file);
16083 input.placeholder = params.inputPlaceholder;
16084 input.type = params.input;
16085 show(input);
16086 break;
16087 case 'range':
16088 var range = getChildByClass(modal, swalClasses.range);
16089 var rangeInput = range.querySelector('input');
16090 var rangeOutput = range.querySelector('output');
16091 rangeInput.value = params.inputValue;
16092 rangeInput.type = params.input;
16093 rangeOutput.value = params.inputValue;
16094 show(range);
16095 break;
16096 case 'select':
16097 var select = getChildByClass(modal, swalClasses.select);
16098 select.innerHTML = '';
16099 if (params.inputPlaceholder) {
16100 var placeholder = document.createElement('option');
16101 placeholder.innerHTML = params.inputPlaceholder;
16102 placeholder.value = '';
16103 placeholder.disabled = true;
16104 placeholder.selected = true;
16105 select.appendChild(placeholder);
16106 }
16107 populateInputOptions = function populateInputOptions(inputOptions) {
16108 for (var optionValue in inputOptions) {
16109 var option = document.createElement('option');
16110 option.value = optionValue;
16111 option.innerHTML = inputOptions[optionValue];
16112 if (params.inputValue === optionValue) {
16113 option.selected = true;
16114 }
16115 select.appendChild(option);
16116 }
16117 show(select);
16118 select.focus();
16119 };
16120 break;
16121 case 'radio':
16122 var radio = getChildByClass(modal, swalClasses.radio);
16123 radio.innerHTML = '';
16124 populateInputOptions = function populateInputOptions(inputOptions) {
16125 for (var radioValue in inputOptions) {
16126 var radioInput = document.createElement('input');
16127 var radioLabel = document.createElement('label');
16128 var radioLabelSpan = document.createElement('span');
16129 radioInput.type = 'radio';
16130 radioInput.name = swalClasses.radio;
16131 radioInput.value = radioValue;
16132 if (params.inputValue === radioValue) {
16133 radioInput.checked = true;
16134 }
16135 radioLabelSpan.innerHTML = inputOptions[radioValue];
16136 radioLabel.appendChild(radioInput);
16137 radioLabel.appendChild(radioLabelSpan);
16138 radioLabel.for = radioInput.id;
16139 radio.appendChild(radioLabel);
16140 }
16141 show(radio);
16142 var radios = radio.querySelectorAll('input');
16143 if (radios.length) {
16144 radios[0].focus();
16145 }
16146 };
16147 break;
16148 case 'checkbox':
16149 var checkbox = getChildByClass(modal, swalClasses.checkbox);
16150 var checkboxInput = getInput('checkbox');
16151 checkboxInput.type = 'checkbox';
16152 checkboxInput.value = 1;
16153 checkboxInput.id = swalClasses.checkbox;
16154 checkboxInput.checked = Boolean(params.inputValue);
16155 var label = checkbox.getElementsByTagName('span');
16156 if (label.length) {
16157 checkbox.removeChild(label[0]);
16158 }
16159 label = document.createElement('span');
16160 label.innerHTML = params.inputPlaceholder;
16161 checkbox.appendChild(label);
16162 show(checkbox);
16163 break;
16164 case 'textarea':
16165 var textarea = getChildByClass(modal, swalClasses.textarea);
16166 textarea.value = params.inputValue;
16167 textarea.placeholder = params.inputPlaceholder;
16168 show(textarea);
16169 break;
16170 case null:
16171 break;
16172 default:
16173 console.error('SweetAlert2: Unexpected type of input! Expected "text", "email", "password", "number", "tel", "select", "radio", "checkbox", "textarea", "file" or "url", got "' + params.input + '"');
16174 break;
16175 }
16176
16177 if (params.input === 'select' || params.input === 'radio') {
16178 if (params.inputOptions instanceof Promise) {
16179 sweetAlert.showLoading();
16180 params.inputOptions.then(function (inputOptions) {
16181 sweetAlert.hideLoading();
16182 populateInputOptions(inputOptions);
16183 });
16184 } else if (_typeof(params.inputOptions) === 'object') {
16185 populateInputOptions(params.inputOptions);
16186 } else {
16187 console.error('SweetAlert2: Unexpected type of inputOptions! Expected object or Promise, got ' + _typeof(params.inputOptions));
16188 }
16189 }
16190
16191 openModal(params.animation, params.onOpen);
16192
16193 // Focus the first element (input or button)
16194 if (params.allowEnterKey) {
16195 setFocus(-1, 1);
16196 } else {
16197 if (document.activeElement) {
16198 document.activeElement.blur();
16199 }
16200 }
16201
16202 // fix scroll
16203 getContainer().scrollTop = 0;
16204
16205 // Observe changes inside the modal and adjust height
16206 if (typeof MutationObserver !== 'undefined' && !swal2Observer) {
16207 swal2Observer = new MutationObserver(sweetAlert.recalculateHeight);
16208 swal2Observer.observe(modal, { childList: true, characterData: true, subtree: true });
16209 }
16210 });
16211 };
16212
16213 /*
16214 * Global function to determine if swal2 modal is shown
16215 */
16216 sweetAlert.isVisible = function () {
16217 return !!getModal();
16218 };
16219
16220 /*
16221 * Global function for chaining sweetAlert modals
16222 */
16223 sweetAlert.queue = function (steps) {
16224 queue = steps;
16225 var resetQueue = function resetQueue() {
16226 queue = [];
16227 document.body.removeAttribute('data-swal2-queue-step');
16228 };
16229 var queueResult = [];
16230 return new Promise(function (resolve, reject) {
16231 (function step(i, callback) {
16232 if (i < queue.length) {
16233 document.body.setAttribute('data-swal2-queue-step', i);
16234
16235 sweetAlert(queue[i]).then(function (result) {
16236 queueResult.push(result);
16237 step(i + 1, callback);
16238 }, function (dismiss) {
16239 resetQueue();
16240 reject(dismiss);
16241 });
16242 } else {
16243 resetQueue();
16244 resolve(queueResult);
16245 }
16246 })(0);
16247 });
16248 };
16249
16250 /*
16251 * Global function for getting the index of current modal in queue
16252 */
16253 sweetAlert.getQueueStep = function () {
16254 return document.body.getAttribute('data-swal2-queue-step');
16255 };
16256
16257 /*
16258 * Global function for inserting a modal to the queue
16259 */
16260 sweetAlert.insertQueueStep = function (step, index) {
16261 if (index && index < queue.length) {
16262 return queue.splice(index, 0, step);
16263 }
16264 return queue.push(step);
16265 };
16266
16267 /*
16268 * Global function for deleting a modal from the queue
16269 */
16270 sweetAlert.deleteQueueStep = function (index) {
16271 if (typeof queue[index] !== 'undefined') {
16272 queue.splice(index, 1);
16273 }
16274 };
16275
16276 /*
16277 * Global function to close sweetAlert
16278 */
16279 sweetAlert.close = sweetAlert.closeModal = function (onComplete) {
16280 var container = getContainer();
16281 var modal = getModal();
16282 if (!modal) {
16283 return;
16284 }
16285 removeClass(modal, swalClasses.show);
16286 addClass(modal, swalClasses.hide);
16287 clearTimeout(modal.timeout);
16288
16289 resetPrevState();
16290
16291 var removeModalAndResetState = function removeModalAndResetState() {
16292 if (container.parentNode) {
16293 container.parentNode.removeChild(container);
16294 }
16295 removeClass(document.documentElement, swalClasses.shown);
16296 removeClass(document.body, swalClasses.shown);
16297 undoScrollbar();
16298 undoIOSfix();
16299 };
16300
16301 // If animation is supported, animate
16302 if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
16303 modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
16304 modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
16305 if (hasClass(modal, swalClasses.hide)) {
16306 removeModalAndResetState();
16307 }
16308 });
16309 } else {
16310 // Otherwise, remove immediately
16311 removeModalAndResetState();
16312 }
16313 if (onComplete !== null && typeof onComplete === 'function') {
16314 setTimeout(function () {
16315 onComplete(modal);
16316 });
16317 }
16318 };
16319
16320 /*
16321 * Global function to click 'Confirm' button
16322 */
16323 sweetAlert.clickConfirm = function () {
16324 return getConfirmButton().click();
16325 };
16326
16327 /*
16328 * Global function to click 'Cancel' button
16329 */
16330 sweetAlert.clickCancel = function () {
16331 return getCancelButton().click();
16332 };
16333
16334 /**
16335 * Show spinner instead of Confirm button and disable Cancel button
16336 */
16337 sweetAlert.showLoading = sweetAlert.enableLoading = function () {
16338 var modal = getModal();
16339 if (!modal) {
16340 sweetAlert('');
16341 }
16342 var buttonsWrapper = getButtonsWrapper();
16343 var confirmButton = getConfirmButton();
16344 var cancelButton = getCancelButton();
16345
16346 show(buttonsWrapper);
16347 show(confirmButton, 'inline-block');
16348 addClass(buttonsWrapper, swalClasses.loading);
16349 addClass(modal, swalClasses.loading);
16350 confirmButton.disabled = true;
16351 cancelButton.disabled = true;
16352 };
16353
16354 /**
16355 * Set default params for each popup
16356 * @param {Object} userParams
16357 */
16358 sweetAlert.setDefaults = function (userParams) {
16359 if (!userParams || (typeof userParams === 'undefined' ? 'undefined' : _typeof(userParams)) !== 'object') {
16360 return console.error('SweetAlert2: the argument for setDefaults() is required and has to be a object');
16361 }
16362
16363 for (var param in userParams) {
16364 if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
16365 console.warn('SweetAlert2: Unknown parameter "' + param + '"');
16366 delete userParams[param];
16367 }
16368 }
16369
16370 _extends(modalParams, userParams);
16371 };
16372
16373 /**
16374 * Reset default params for each popup
16375 */
16376 sweetAlert.resetDefaults = function () {
16377 modalParams = _extends({}, defaultParams);
16378 };
16379
16380 sweetAlert.noop = function () {};
16381
16382 sweetAlert.version = '6.6.4';
16383
16384 sweetAlert.default = sweetAlert;
16385
16386 return sweetAlert;
16387
16388 })));
16389 if (window.Sweetalert2) window.sweetAlert = window.swal = window.Sweetalert2;
16390
16391 /* assets/wpuf/vendor/jquery.scrollTo/jquery.scrollTo.js */
16392 /*!
16393 * jQuery.scrollTo
16394 * Copyright (c) 2007-2015 Ariel Flesler - aflesler ○ gmail • com | http://flesler.blogspot.com
16395 * Licensed under MIT
16396 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
16397 * @projectDescription Lightweight, cross-browser and highly customizable animated scrolling with jQuery
16398 * @author Ariel Flesler
16399 * @version 2.1.2
16400 */
16401 ;(function(factory) {
16402 'use strict';
16403 if (typeof define === 'function' && define.amd) {
16404 // AMD
16405 define(['jquery'], factory);
16406 } else if (typeof module !== 'undefined' && module.exports) {
16407 // CommonJS
16408 module.exports = factory(require('jquery'));
16409 } else {
16410 // Global
16411 factory(jQuery);
16412 }
16413 })(function($) {
16414 'use strict';
16415
16416 var $scrollTo = $.scrollTo = function(target, duration, settings) {
16417 return $(window).scrollTo(target, duration, settings);
16418 };
16419
16420 $scrollTo.defaults = {
16421 axis:'xy',
16422 duration: 0,
16423 limit:true
16424 };
16425
16426 function isWin(elem) {
16427 return !elem.nodeName ||
16428 $.inArray(elem.nodeName.toLowerCase(), ['iframe','#document','html','body']) !== -1;
16429 }
16430
16431 $.fn.scrollTo = function(target, duration, settings) {
16432 if (typeof duration === 'object') {
16433 settings = duration;
16434 duration = 0;
16435 }
16436 if (typeof settings === 'function') {
16437 settings = { onAfter:settings };
16438 }
16439 if (target === 'max') {
16440 target = 9e9;
16441 }
16442
16443 settings = $.extend({}, $scrollTo.defaults, settings);
16444 // Speed is still recognized for backwards compatibility
16445 duration = duration || settings.duration;
16446 // Make sure the settings are given right
16447 var queue = settings.queue && settings.axis.length > 1;
16448 if (queue) {
16449 // Let's keep the overall duration
16450 duration /= 2;
16451 }
16452 settings.offset = both(settings.offset);
16453 settings.over = both(settings.over);
16454
16455 return this.each(function() {
16456 // Null target yields nothing, just like jQuery does
16457 if (target === null) return;
16458
16459 var win = isWin(this),
16460 elem = win ? this.contentWindow || window : this,
16461 $elem = $(elem),
16462 targ = target,
16463 attr = {},
16464 toff;
16465
16466 switch (typeof targ) {
16467 // A number will pass the regex
16468 case 'number':
16469 case 'string':
16470 if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
16471 targ = both(targ);
16472 // We are done
16473 break;
16474 }
16475 // Relative/Absolute selector
16476 targ = win ? $(targ) : $(targ, elem);
16477 /* falls through */
16478 case 'object':
16479 if (targ.length === 0) return;
16480 // DOMElement / jQuery
16481 if (targ.is || targ.style) {
16482 // Get the real position of the target
16483 toff = (targ = $(targ)).offset();
16484 }
16485 }
16486
16487 var offset = $.isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset;
16488
16489 $.each(settings.axis.split(''), function(i, axis) {
16490 var Pos = axis === 'x' ? 'Left' : 'Top',
16491 pos = Pos.toLowerCase(),
16492 key = 'scroll' + Pos,
16493 prev = $elem[key](),
16494 max = $scrollTo.max(elem, axis);
16495
16496 if (toff) {// jQuery / DOMElement
16497 attr[key] = toff[pos] + (win ? 0 : prev - $elem.offset()[pos]);
16498
16499 // If it's a dom element, reduce the margin
16500 if (settings.margin) {
16501 attr[key] -= parseInt(targ.css('margin'+Pos), 10) || 0;
16502 attr[key] -= parseInt(targ.css('border'+Pos+'Width'), 10) || 0;
16503 }
16504
16505 attr[key] += offset[pos] || 0;
16506
16507 if (settings.over[pos]) {
16508 // Scroll to a fraction of its width/height
16509 attr[key] += targ[axis === 'x'?'width':'height']() * settings.over[pos];
16510 }
16511 } else {
16512 var val = targ[pos];
16513 // Handle percentage values
16514 attr[key] = val.slice && val.slice(-1) === '%' ?
16515 parseFloat(val) / 100 * max
16516 : val;
16517 }
16518
16519 // Number or 'number'
16520 if (settings.limit && /^\d+$/.test(attr[key])) {
16521 // Check the limits
16522 attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max);
16523 }
16524
16525 // Don't waste time animating, if there's no need.
16526 if (!i && settings.axis.length > 1) {
16527 if (prev === attr[key]) {
16528 // No animation needed
16529 attr = {};
16530 } else if (queue) {
16531 // Intermediate animation
16532 animate(settings.onAfterFirst);
16533 // Don't animate this axis again in the next iteration.
16534 attr = {};
16535 }
16536 }
16537 });
16538
16539 animate(settings.onAfter);
16540
16541 function animate(callback) {
16542 var opts = $.extend({}, settings, {
16543 // The queue setting conflicts with animate()
16544 // Force it to always be true
16545 queue: true,
16546 duration: duration,
16547 complete: callback && function() {
16548 callback.call(elem, targ, settings);
16549 }
16550 });
16551 $elem.animate(attr, opts);
16552 }
16553 });
16554 };
16555
16556 // Max scrolling position, works on quirks mode
16557 // It only fails (not too badly) on IE, quirks mode.
16558 $scrollTo.max = function(elem, axis) {
16559 var Dim = axis === 'x' ? 'Width' : 'Height',
16560 scroll = 'scroll'+Dim;
16561
16562 if (!isWin(elem))
16563 return elem[scroll] - $(elem)[Dim.toLowerCase()]();
16564
16565 var size = 'client' + Dim,
16566 doc = elem.ownerDocument || elem.document,
16567 html = doc.documentElement,
16568 body = doc.body;
16569
16570 return Math.max(html[scroll], body[scroll]) - Math.min(html[size], body[size]);
16571 };
16572
16573 function both(val) {
16574 return $.isFunction(val) || $.isPlainObject(val) ? val : { top:val, left:val };
16575 }
16576
16577 // Add special hooks so that window scroll properties can be animated
16578 $.Tween.propHooks.scrollLeft =
16579 $.Tween.propHooks.scrollTop = {
16580 get: function(t) {
16581 return $(t.elem)[t.prop]();
16582 },
16583 set: function(t) {
16584 var curr = this.get(t);
16585 // If interrupt is true and user scrolled, stop animating
16586 if (t.options.interrupt && t._last && t._last !== curr) {
16587 return $(t.elem).stop();
16588 }
16589 var next = Math.round(t.now);
16590 // Don't waste CPU
16591 // Browsers don't render floating point scroll
16592 if (curr !== next) {
16593 $(t.elem)[t.prop](next);
16594 t._last = this.get(t);
16595 }
16596 }
16597 };
16598
16599 // AMD requirement
16600 return $scrollTo;
16601 });
16602
16603 /* assets/wpuf/vendor/selectize/js/standalone/selectize.js */
16604 /**
16605 * sifter.js
16606 * Copyright (c) 2013 Brian Reavis & contributors
16607 *
16608 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
16609 * file except in compliance with the License. You may obtain a copy of the License at:
16610 * http://www.apache.org/licenses/LICENSE-2.0
16611 *
16612 * Unless required by applicable law or agreed to in writing, software distributed under
16613 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
16614 * ANY KIND, either express or implied. See the License for the specific language
16615 * governing permissions and limitations under the License.
16616 *
16617 * @author Brian Reavis <brian@thirdroute.com>
16618 */
16619
16620 (function(root, factory) {
16621 if (typeof define === 'function' && define.amd) {
16622 define('sifter', factory);
16623 } else if (typeof exports === 'object') {
16624 module.exports = factory();
16625 } else {
16626 root.Sifter = factory();
16627 }
16628 }(this, function() {
16629
16630 /**
16631 * Textually searches arrays and hashes of objects
16632 * by property (or multiple properties). Designed
16633 * specifically for autocomplete.
16634 *
16635 * @constructor
16636 * @param {array|object} items
16637 * @param {object} items
16638 */
16639 var Sifter = function(items, settings) {
16640 this.items = items;
16641 this.settings = settings || {diacritics: true};
16642 };
16643
16644 /**
16645 * Splits a search string into an array of individual
16646 * regexps to be used to match results.
16647 *
16648 * @param {string} query
16649 * @returns {array}
16650 */
16651 Sifter.prototype.tokenize = function(query) {
16652 query = trim(String(query || '').toLowerCase());
16653 if (!query || !query.length) return [];
16654
16655 var i, n, regex, letter;
16656 var tokens = [];
16657 var words = query.split(/ +/);
16658
16659 for (i = 0, n = words.length; i < n; i++) {
16660 regex = escape_regex(words[i]);
16661 if (this.settings.diacritics) {
16662 for (letter in DIACRITICS) {
16663 if (DIACRITICS.hasOwnProperty(letter)) {
16664 regex = regex.replace(new RegExp(letter, 'g'), DIACRITICS[letter]);
16665 }
16666 }
16667 }
16668 tokens.push({
16669 string : words[i],
16670 regex : new RegExp(regex, 'i')
16671 });
16672 }
16673
16674 return tokens;
16675 };
16676
16677 /**
16678 * Iterates over arrays and hashes.
16679 *
16680 * ```
16681 * this.iterator(this.items, function(item, id) {
16682 * // invoked for each item
16683 * });
16684 * ```
16685 *
16686 * @param {array|object} object
16687 */
16688 Sifter.prototype.iterator = function(object, callback) {
16689 var iterator;
16690 if (is_array(object)) {
16691 iterator = Array.prototype.forEach || function(callback) {
16692 for (var i = 0, n = this.length; i < n; i++) {
16693 callback(this[i], i, this);
16694 }
16695 };
16696 } else {
16697 iterator = function(callback) {
16698 for (var key in this) {
16699 if (this.hasOwnProperty(key)) {
16700 callback(this[key], key, this);
16701 }
16702 }
16703 };
16704 }
16705
16706 iterator.apply(object, [callback]);
16707 };
16708
16709 /**
16710 * Returns a function to be used to score individual results.
16711 *
16712 * Good matches will have a higher score than poor matches.
16713 * If an item is not a match, 0 will be returned by the function.
16714 *
16715 * @param {object|string} search
16716 * @param {object} options (optional)
16717 * @returns {function}
16718 */
16719 Sifter.prototype.getScoreFunction = function(search, options) {
16720 var self, fields, tokens, token_count, nesting;
16721
16722 self = this;
16723 search = self.prepareSearch(search, options);
16724 tokens = search.tokens;
16725 fields = search.options.fields;
16726 token_count = tokens.length;
16727 nesting = search.options.nesting;
16728
16729 /**
16730 * Calculates how close of a match the
16731 * given value is against a search token.
16732 *
16733 * @param {mixed} value
16734 * @param {object} token
16735 * @return {number}
16736 */
16737 var scoreValue = function(value, token) {
16738 var score, pos;
16739
16740 if (!value) return 0;
16741 value = String(value || '');
16742 pos = value.search(token.regex);
16743 if (pos === -1) return 0;
16744 score = token.string.length / value.length;
16745 if (pos === 0) score += 0.5;
16746 return score;
16747 };
16748
16749 /**
16750 * Calculates the score of an object
16751 * against the search query.
16752 *
16753 * @param {object} token
16754 * @param {object} data
16755 * @return {number}
16756 */
16757 var scoreObject = (function() {
16758 var field_count = fields.length;
16759 if (!field_count) {
16760 return function() { return 0; };
16761 }
16762 if (field_count === 1) {
16763 return function(token, data) {
16764 return scoreValue(getattr(data, fields[0], nesting), token);
16765 };
16766 }
16767 return function(token, data) {
16768 for (var i = 0, sum = 0; i < field_count; i++) {
16769 sum += scoreValue(getattr(data, fields[i], nesting), token);
16770 }
16771 return sum / field_count;
16772 };
16773 })();
16774
16775 if (!token_count) {
16776 return function() { return 0; };
16777 }
16778 if (token_count === 1) {
16779 return function(data) {
16780 return scoreObject(tokens[0], data);
16781 };
16782 }
16783
16784 if (search.options.conjunction === 'and') {
16785 return function(data) {
16786 var score;
16787 for (var i = 0, sum = 0; i < token_count; i++) {
16788 score = scoreObject(tokens[i], data);
16789 if (score <= 0) return 0;
16790 sum += score;
16791 }
16792 return sum / token_count;
16793 };
16794 } else {
16795 return function(data) {
16796 for (var i = 0, sum = 0; i < token_count; i++) {
16797 sum += scoreObject(tokens[i], data);
16798 }
16799 return sum / token_count;
16800 };
16801 }
16802 };
16803
16804 /**
16805 * Returns a function that can be used to compare two
16806 * results, for sorting purposes. If no sorting should
16807 * be performed, `null` will be returned.
16808 *
16809 * @param {string|object} search
16810 * @param {object} options
16811 * @return function(a,b)
16812 */
16813 Sifter.prototype.getSortFunction = function(search, options) {
16814 var i, n, self, field, fields, fields_count, multiplier, multipliers, get_field, implicit_score, sort;
16815
16816 self = this;
16817 search = self.prepareSearch(search, options);
16818 sort = (!search.query && options.sort_empty) || options.sort;
16819
16820 /**
16821 * Fetches the specified sort field value
16822 * from a search result item.
16823 *
16824 * @param {string} name
16825 * @param {object} result
16826 * @return {mixed}
16827 */
16828 get_field = function(name, result) {
16829 if (name === '$score') return result.score;
16830 return getattr(self.items[result.id], name, options.nesting);
16831 };
16832
16833 // parse options
16834 fields = [];
16835 if (sort) {
16836 for (i = 0, n = sort.length; i < n; i++) {
16837 if (search.query || sort[i].field !== '$score') {
16838 fields.push(sort[i]);
16839 }
16840 }
16841 }
16842
16843 // the "$score" field is implied to be the primary
16844 // sort field, unless it's manually specified
16845 if (search.query) {
16846 implicit_score = true;
16847 for (i = 0, n = fields.length; i < n; i++) {
16848 if (fields[i].field === '$score') {
16849 implicit_score = false;
16850 break;
16851 }
16852 }
16853 if (implicit_score) {
16854 fields.unshift({field: '$score', direction: 'desc'});
16855 }
16856 } else {
16857 for (i = 0, n = fields.length; i < n; i++) {
16858 if (fields[i].field === '$score') {
16859 fields.splice(i, 1);
16860 break;
16861 }
16862 }
16863 }
16864
16865 multipliers = [];
16866 for (i = 0, n = fields.length; i < n; i++) {
16867 multipliers.push(fields[i].direction === 'desc' ? -1 : 1);
16868 }
16869
16870 // build function
16871 fields_count = fields.length;
16872 if (!fields_count) {
16873 return null;
16874 } else if (fields_count === 1) {
16875 field = fields[0].field;
16876 multiplier = multipliers[0];
16877 return function(a, b) {
16878 return multiplier * cmp(
16879 get_field(field, a),
16880 get_field(field, b)
16881 );
16882 };
16883 } else {
16884 return function(a, b) {
16885 var i, result, a_value, b_value, field;
16886 for (i = 0; i < fields_count; i++) {
16887 field = fields[i].field;
16888 result = multipliers[i] * cmp(
16889 get_field(field, a),
16890 get_field(field, b)
16891 );
16892 if (result) return result;
16893 }
16894 return 0;
16895 };
16896 }
16897 };
16898
16899 /**
16900 * Parses a search query and returns an object
16901 * with tokens and fields ready to be populated
16902 * with results.
16903 *
16904 * @param {string} query
16905 * @param {object} options
16906 * @returns {object}
16907 */
16908 Sifter.prototype.prepareSearch = function(query, options) {
16909 if (typeof query === 'object') return query;
16910
16911 options = extend({}, options);
16912
16913 var option_fields = options.fields;
16914 var option_sort = options.sort;
16915 var option_sort_empty = options.sort_empty;
16916
16917 if (option_fields && !is_array(option_fields)) options.fields = [option_fields];
16918 if (option_sort && !is_array(option_sort)) options.sort = [option_sort];
16919 if (option_sort_empty && !is_array(option_sort_empty)) options.sort_empty = [option_sort_empty];
16920
16921 return {
16922 options : options,
16923 query : String(query || '').toLowerCase(),
16924 tokens : this.tokenize(query),
16925 total : 0,
16926 items : []
16927 };
16928 };
16929
16930 /**
16931 * Searches through all items and returns a sorted array of matches.
16932 *
16933 * The `options` parameter can contain:
16934 *
16935 * - fields {string|array}
16936 * - sort {array}
16937 * - score {function}
16938 * - filter {bool}
16939 * - limit {integer}
16940 *
16941 * Returns an object containing:
16942 *
16943 * - options {object}
16944 * - query {string}
16945 * - tokens {array}
16946 * - total {int}
16947 * - items {array}
16948 *
16949 * @param {string} query
16950 * @param {object} options
16951 * @returns {object}
16952 */
16953 Sifter.prototype.search = function(query, options) {
16954 var self = this, value, score, search, calculateScore;
16955 var fn_sort;
16956 var fn_score;
16957
16958 search = this.prepareSearch(query, options);
16959 options = search.options;
16960 query = search.query;
16961
16962 // generate result scoring function
16963 fn_score = options.score || self.getScoreFunction(search);
16964
16965 // perform search and sort
16966 if (query.length) {
16967 self.iterator(self.items, function(item, id) {
16968 score = fn_score(item);
16969 if (options.filter === false || score > 0) {
16970 search.items.push({'score': score, 'id': id});
16971 }
16972 });
16973 } else {
16974 self.iterator(self.items, function(item, id) {
16975 search.items.push({'score': 1, 'id': id});
16976 });
16977 }
16978
16979 fn_sort = self.getSortFunction(search, options);
16980 if (fn_sort) search.items.sort(fn_sort);
16981
16982 // apply limits
16983 search.total = search.items.length;
16984 if (typeof options.limit === 'number') {
16985 search.items = search.items.slice(0, options.limit);
16986 }
16987
16988 return search;
16989 };
16990
16991 // utilities
16992 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
16993
16994 var cmp = function(a, b) {
16995 if (typeof a === 'number' && typeof b === 'number') {
16996 return a > b ? 1 : (a < b ? -1 : 0);
16997 }
16998 a = asciifold(String(a || ''));
16999 b = asciifold(String(b || ''));
17000 if (a > b) return 1;
17001 if (b > a) return -1;
17002 return 0;
17003 };
17004
17005 var extend = function(a, b) {
17006 var i, n, k, object;
17007 for (i = 1, n = arguments.length; i < n; i++) {
17008 object = arguments[i];
17009 if (!object) continue;
17010 for (k in object) {
17011 if (object.hasOwnProperty(k)) {
17012 a[k] = object[k];
17013 }
17014 }
17015 }
17016 return a;
17017 };
17018
17019 /**
17020 * A property getter resolving dot-notation
17021 * @param {Object} obj The root object to fetch property on
17022 * @param {String} name The optionally dotted property name to fetch
17023 * @param {Boolean} nesting Handle nesting or not
17024 * @return {Object} The resolved property value
17025 */
17026 var getattr = function(obj, name, nesting) {
17027 if (!obj || !name) return;
17028 if (!nesting) return obj[name];
17029 var names = name.split(".");
17030 while(names.length && (obj = obj[names.shift()]));
17031 return obj;
17032 };
17033
17034 var trim = function(str) {
17035 return (str + '').replace(/^\s+|\s+$|/g, '');
17036 };
17037
17038 var escape_regex = function(str) {
17039 return (str + '').replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
17040 };
17041
17042 var is_array = Array.isArray || (typeof $ !== 'undefined' && $.isArray) || function(object) {
17043 return Object.prototype.toString.call(object) === '[object Array]';
17044 };
17045
17046 var DIACRITICS = {
17047 'a': '[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]',
17048 'b': '[b␢βΒB฿𐌁ᛒ]',
17049 'c': '[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]',
17050 'd': '[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]',
17051 'e': '[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]',
17052 'f': '[fƑƒḞḟ]',
17053 'g': '[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]',
17054 'h': '[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]',
17055 'i': '[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]',
17056 'j': '[jȷĴĵɈɉʝɟʲ]',
17057 'k': '[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]',
17058 'l': '[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]',
17059 'n': '[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]',
17060 'o': '[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]',
17061 'p': '[pṔṕṖṗⱣᵽƤƥᵱ]',
17062 'q': '[qꝖꝗʠɊɋꝘꝙq̃]',
17063 'r': '[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]',
17064 's': '[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]',
17065 't': '[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]',
17066 'u': '[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]',
17067 'v': '[vṼṽṾṿƲʋꝞꝟⱱʋ]',
17068 'w': '[wẂẃẀẁŴŵẄẅẆẇẈẉ]',
17069 'x': '[xẌẍẊẋχ]',
17070 'y': '[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]',
17071 'z': '[zŹźẐẑŽžŻżẒẓẔẕƵƶ]'
17072 };
17073
17074 var asciifold = (function() {
17075 var i, n, k, chunk;
17076 var foreignletters = '';
17077 var lookup = {};
17078 for (k in DIACRITICS) {
17079 if (DIACRITICS.hasOwnProperty(k)) {
17080 chunk = DIACRITICS[k].substring(2, DIACRITICS[k].length - 1);
17081 foreignletters += chunk;
17082 for (i = 0, n = chunk.length; i < n; i++) {
17083 lookup[chunk.charAt(i)] = k;
17084 }
17085 }
17086 }
17087 var regexp = new RegExp('[' + foreignletters + ']', 'g');
17088 return function(str) {
17089 return str.replace(regexp, function(foreignletter) {
17090 return lookup[foreignletter];
17091 }).toLowerCase();
17092 };
17093 })();
17094
17095
17096 // export
17097 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
17098
17099 return Sifter;
17100 }));
17101
17102
17103
17104 /**
17105 * microplugin.js
17106 * Copyright (c) 2013 Brian Reavis & contributors
17107 *
17108 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
17109 * file except in compliance with the License. You may obtain a copy of the License at:
17110 * http://www.apache.org/licenses/LICENSE-2.0
17111 *
17112 * Unless required by applicable law or agreed to in writing, software distributed under
17113 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
17114 * ANY KIND, either express or implied. See the License for the specific language
17115 * governing permissions and limitations under the License.
17116 *
17117 * @author Brian Reavis <brian@thirdroute.com>
17118 */
17119
17120 (function(root, factory) {
17121 if (typeof define === 'function' && define.amd) {
17122 define('microplugin', factory);
17123 } else if (typeof exports === 'object') {
17124 module.exports = factory();
17125 } else {
17126 root.MicroPlugin = factory();
17127 }
17128 }(this, function() {
17129 var MicroPlugin = {};
17130
17131 MicroPlugin.mixin = function(Interface) {
17132 Interface.plugins = {};
17133
17134 /**
17135 * Initializes the listed plugins (with options).
17136 * Acceptable formats:
17137 *
17138 * List (without options):
17139 * ['a', 'b', 'c']
17140 *
17141 * List (with options):
17142 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
17143 *
17144 * Hash (with options):
17145 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
17146 *
17147 * @param {mixed} plugins
17148 */
17149 Interface.prototype.initializePlugins = function(plugins) {
17150 var i, n, key;
17151 var self = this;
17152 var queue = [];
17153
17154 self.plugins = {
17155 names : [],
17156 settings : {},
17157 requested : {},
17158 loaded : {}
17159 };
17160
17161 if (utils.isArray(plugins)) {
17162 for (i = 0, n = plugins.length; i < n; i++) {
17163 if (typeof plugins[i] === 'string') {
17164 queue.push(plugins[i]);
17165 } else {
17166 self.plugins.settings[plugins[i].name] = plugins[i].options;
17167 queue.push(plugins[i].name);
17168 }
17169 }
17170 } else if (plugins) {
17171 for (key in plugins) {
17172 if (plugins.hasOwnProperty(key)) {
17173 self.plugins.settings[key] = plugins[key];
17174 queue.push(key);
17175 }
17176 }
17177 }
17178
17179 while (queue.length) {
17180 self.require(queue.shift());
17181 }
17182 };
17183
17184 Interface.prototype.loadPlugin = function(name) {
17185 var self = this;
17186 var plugins = self.plugins;
17187 var plugin = Interface.plugins[name];
17188
17189 if (!Interface.plugins.hasOwnProperty(name)) {
17190 throw new Error('Unable to find "' + name + '" plugin');
17191 }
17192
17193 plugins.requested[name] = true;
17194 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
17195 plugins.names.push(name);
17196 };
17197
17198 /**
17199 * Initializes a plugin.
17200 *
17201 * @param {string} name
17202 */
17203 Interface.prototype.require = function(name) {
17204 var self = this;
17205 var plugins = self.plugins;
17206
17207 if (!self.plugins.loaded.hasOwnProperty(name)) {
17208 if (plugins.requested[name]) {
17209 throw new Error('Plugin has circular dependency ("' + name + '")');
17210 }
17211 self.loadPlugin(name);
17212 }
17213
17214 return plugins.loaded[name];
17215 };
17216
17217 /**
17218 * Registers a plugin.
17219 *
17220 * @param {string} name
17221 * @param {function} fn
17222 */
17223 Interface.define = function(name, fn) {
17224 Interface.plugins[name] = {
17225 'name' : name,
17226 'fn' : fn
17227 };
17228 };
17229 };
17230
17231 var utils = {
17232 isArray: Array.isArray || function(vArg) {
17233 return Object.prototype.toString.call(vArg) === '[object Array]';
17234 }
17235 };
17236
17237 return MicroPlugin;
17238 }));
17239
17240 /**
17241 * selectize.js (v0.12.4)
17242 * Copyright (c) 2013–2015 Brian Reavis & contributors
17243 *
17244 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
17245 * file except in compliance with the License. You may obtain a copy of the License at:
17246 * http://www.apache.org/licenses/LICENSE-2.0
17247 *
17248 * Unless required by applicable law or agreed to in writing, software distributed under
17249 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
17250 * ANY KIND, either express or implied. See the License for the specific language
17251 * governing permissions and limitations under the License.
17252 *
17253 * @author Brian Reavis <brian@thirdroute.com>
17254 */
17255
17256 /*jshint curly:false */
17257 /*jshint browser:true */
17258
17259 (function(root, factory) {
17260 if (typeof define === 'function' && define.amd) {
17261 define('selectize', ['jquery','sifter','microplugin'], factory);
17262 } else if (typeof exports === 'object') {
17263 module.exports = factory(require('jquery'), require('sifter'), require('microplugin'));
17264 } else {
17265 root.Selectize = factory(root.jQuery, root.Sifter, root.MicroPlugin);
17266 }
17267 }(this, function($, Sifter, MicroPlugin) {
17268 'use strict';
17269
17270 var highlight = function($element, pattern) {
17271 if (typeof pattern === 'string' && !pattern.length) return;
17272 var regex = (typeof pattern === 'string') ? new RegExp(pattern, 'i') : pattern;
17273
17274 var highlight = function(node) {
17275 var skip = 0;
17276 if (node.nodeType === 3) {
17277 var pos = node.data.search(regex);
17278 if (pos >= 0 && node.data.length > 0) {
17279 var match = node.data.match(regex);
17280 var spannode = document.createElement('span');
17281 spannode.className = 'highlight';
17282 var middlebit = node.splitText(pos);
17283 var endbit = middlebit.splitText(match[0].length);
17284 var middleclone = middlebit.cloneNode(true);
17285 spannode.appendChild(middleclone);
17286 middlebit.parentNode.replaceChild(spannode, middlebit);
17287 skip = 1;
17288 }
17289 } else if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
17290 for (var i = 0; i < node.childNodes.length; ++i) {
17291 i += highlight(node.childNodes[i]);
17292 }
17293 }
17294 return skip;
17295 };
17296
17297 return $element.each(function() {
17298 highlight(this);
17299 });
17300 };
17301
17302 /**
17303 * removeHighlight fn copied from highlight v5 and
17304 * edited to remove with() and pass js strict mode
17305 */
17306 $.fn.removeHighlight = function() {
17307 return this.find("span.highlight").each(function() {
17308 this.parentNode.firstChild.nodeName;
17309 var parent = this.parentNode;
17310 parent.replaceChild(this.firstChild, this);
17311 parent.normalize();
17312 }).end();
17313 };
17314
17315
17316 var MicroEvent = function() {};
17317 MicroEvent.prototype = {
17318 on: function(event, fct){
17319 this._events = this._events || {};
17320 this._events[event] = this._events[event] || [];
17321 this._events[event].push(fct);
17322 },
17323 off: function(event, fct){
17324 var n = arguments.length;
17325 if (n === 0) return delete this._events;
17326 if (n === 1) return delete this._events[event];
17327
17328 this._events = this._events || {};
17329 if (event in this._events === false) return;
17330 this._events[event].splice(this._events[event].indexOf(fct), 1);
17331 },
17332 trigger: function(event /* , args... */){
17333 this._events = this._events || {};
17334 if (event in this._events === false) return;
17335 for (var i = 0; i < this._events[event].length; i++){
17336 this._events[event][i].apply(this, Array.prototype.slice.call(arguments, 1));
17337 }
17338 }
17339 };
17340
17341 /**
17342 * Mixin will delegate all MicroEvent.js function in the destination object.
17343 *
17344 * - MicroEvent.mixin(Foobar) will make Foobar able to use MicroEvent
17345 *
17346 * @param {object} the object which will support MicroEvent
17347 */
17348 MicroEvent.mixin = function(destObject){
17349 var props = ['on', 'off', 'trigger'];
17350 for (var i = 0; i < props.length; i++){
17351 destObject.prototype[props[i]] = MicroEvent.prototype[props[i]];
17352 }
17353 };
17354
17355 var IS_MAC = /Mac/.test(navigator.userAgent);
17356
17357 var KEY_A = 65;
17358 var KEY_COMMA = 188;
17359 var KEY_RETURN = 13;
17360 var KEY_ESC = 27;
17361 var KEY_LEFT = 37;
17362 var KEY_UP = 38;
17363 var KEY_P = 80;
17364 var KEY_RIGHT = 39;
17365 var KEY_DOWN = 40;
17366 var KEY_N = 78;
17367 var KEY_BACKSPACE = 8;
17368 var KEY_DELETE = 46;
17369 var KEY_SHIFT = 16;
17370 var KEY_CMD = IS_MAC ? 91 : 17;
17371 var KEY_CTRL = IS_MAC ? 18 : 17;
17372 var KEY_TAB = 9;
17373
17374 var TAG_SELECT = 1;
17375 var TAG_INPUT = 2;
17376
17377 // for now, android support in general is too spotty to support validity
17378 var SUPPORTS_VALIDITY_API = !/android/i.test(window.navigator.userAgent) && !!document.createElement('input').validity;
17379
17380
17381 var isset = function(object) {
17382 return typeof object !== 'undefined';
17383 };
17384
17385 /**
17386 * Converts a scalar to its best string representation
17387 * for hash keys and HTML attribute values.
17388 *
17389 * Transformations:
17390 * 'str' -> 'str'
17391 * null -> ''
17392 * undefined -> ''
17393 * true -> '1'
17394 * false -> '0'
17395 * 0 -> '0'
17396 * 1 -> '1'
17397 *
17398 * @param {string} value
17399 * @returns {string|null}
17400 */
17401 var hash_key = function(value) {
17402 if (typeof value === 'undefined' || value === null) return null;
17403 if (typeof value === 'boolean') return value ? '1' : '0';
17404 return value + '';
17405 };
17406
17407 /**
17408 * Escapes a string for use within HTML.
17409 *
17410 * @param {string} str
17411 * @returns {string}
17412 */
17413 var escape_html = function(str) {
17414 return (str + '')
17415 .replace(/&/g, '&amp;')
17416 .replace(/</g, '&lt;')
17417 .replace(/>/g, '&gt;')
17418 .replace(/"/g, '&quot;');
17419 };
17420
17421 /**
17422 * Escapes "$" characters in replacement strings.
17423 *
17424 * @param {string} str
17425 * @returns {string}
17426 */
17427 var escape_replace = function(str) {
17428 return (str + '').replace(/\$/g, '$$$$');
17429 };
17430
17431 var hook = {};
17432
17433 /**
17434 * Wraps `method` on `self` so that `fn`
17435 * is invoked before the original method.
17436 *
17437 * @param {object} self
17438 * @param {string} method
17439 * @param {function} fn
17440 */
17441 hook.before = function(self, method, fn) {
17442 var original = self[method];
17443 self[method] = function() {
17444 fn.apply(self, arguments);
17445 return original.apply(self, arguments);
17446 };
17447 };
17448
17449 /**
17450 * Wraps `method` on `self` so that `fn`
17451 * is invoked after the original method.
17452 *
17453 * @param {object} self
17454 * @param {string} method
17455 * @param {function} fn
17456 */
17457 hook.after = function(self, method, fn) {
17458 var original = self[method];
17459 self[method] = function() {
17460 var result = original.apply(self, arguments);
17461 fn.apply(self, arguments);
17462 return result;
17463 };
17464 };
17465
17466 /**
17467 * Wraps `fn` so that it can only be invoked once.
17468 *
17469 * @param {function} fn
17470 * @returns {function}
17471 */
17472 var once = function(fn) {
17473 var called = false;
17474 return function() {
17475 if (called) return;
17476 called = true;
17477 fn.apply(this, arguments);
17478 };
17479 };
17480
17481 /**
17482 * Wraps `fn` so that it can only be called once
17483 * every `delay` milliseconds (invoked on the falling edge).
17484 *
17485 * @param {function} fn
17486 * @param {int} delay
17487 * @returns {function}
17488 */
17489 var debounce = function(fn, delay) {
17490 var timeout;
17491 return function() {
17492 var self = this;
17493 var args = arguments;
17494 window.clearTimeout(timeout);
17495 timeout = window.setTimeout(function() {
17496 fn.apply(self, args);
17497 }, delay);
17498 };
17499 };
17500
17501 /**
17502 * Debounce all fired events types listed in `types`
17503 * while executing the provided `fn`.
17504 *
17505 * @param {object} self
17506 * @param {array} types
17507 * @param {function} fn
17508 */
17509 var debounce_events = function(self, types, fn) {
17510 var type;
17511 var trigger = self.trigger;
17512 var event_args = {};
17513
17514 // override trigger method
17515 self.trigger = function() {
17516 var type = arguments[0];
17517 if (types.indexOf(type) !== -1) {
17518 event_args[type] = arguments;
17519 } else {
17520 return trigger.apply(self, arguments);
17521 }
17522 };
17523
17524 // invoke provided function
17525 fn.apply(self, []);
17526 self.trigger = trigger;
17527
17528 // trigger queued events
17529 for (type in event_args) {
17530 if (event_args.hasOwnProperty(type)) {
17531 trigger.apply(self, event_args[type]);
17532 }
17533 }
17534 };
17535
17536 /**
17537 * A workaround for http://bugs.jquery.com/ticket/6696
17538 *
17539 * @param {object} $parent - Parent element to listen on.
17540 * @param {string} event - Event name.
17541 * @param {string} selector - Descendant selector to filter by.
17542 * @param {function} fn - Event handler.
17543 */
17544 var watchChildEvent = function($parent, event, selector, fn) {
17545 $parent.on(event, selector, function(e) {
17546 var child = e.target;
17547 while (child && child.parentNode !== $parent[0]) {
17548 child = child.parentNode;
17549 }
17550 e.currentTarget = child;
17551 return fn.apply(this, [e]);
17552 });
17553 };
17554
17555 /**
17556 * Determines the current selection within a text input control.
17557 * Returns an object containing:
17558 * - start
17559 * - length
17560 *
17561 * @param {object} input
17562 * @returns {object}
17563 */
17564 var getSelection = function(input) {
17565 var result = {};
17566 if ('selectionStart' in input) {
17567 result.start = input.selectionStart;
17568 result.length = input.selectionEnd - result.start;
17569 } else if (document.selection) {
17570 input.focus();
17571 var sel = document.selection.createRange();
17572 var selLen = document.selection.createRange().text.length;
17573 sel.moveStart('character', -input.value.length);
17574 result.start = sel.text.length - selLen;
17575 result.length = selLen;
17576 }
17577 return result;
17578 };
17579
17580 /**
17581 * Copies CSS properties from one element to another.
17582 *
17583 * @param {object} $from
17584 * @param {object} $to
17585 * @param {array} properties
17586 */
17587 var transferStyles = function($from, $to, properties) {
17588 var i, n, styles = {};
17589 if (properties) {
17590 for (i = 0, n = properties.length; i < n; i++) {
17591 styles[properties[i]] = $from.css(properties[i]);
17592 }
17593 } else {
17594 styles = $from.css();
17595 }
17596 $to.css(styles);
17597 };
17598
17599 /**
17600 * Measures the width of a string within a
17601 * parent element (in pixels).
17602 *
17603 * @param {string} str
17604 * @param {object} $parent
17605 * @returns {int}
17606 */
17607 var measureString = function(str, $parent) {
17608 if (!str) {
17609 return 0;
17610 }
17611
17612 var $test = $('<test>').css({
17613 position: 'absolute',
17614 top: -99999,
17615 left: -99999,
17616 width: 'auto',
17617 padding: 0,
17618 whiteSpace: 'pre'
17619 }).text(str).appendTo('body');
17620
17621 transferStyles($parent, $test, [
17622 'letterSpacing',
17623 'fontSize',
17624 'fontFamily',
17625 'fontWeight',
17626 'textTransform'
17627 ]);
17628
17629 var width = $test.width();
17630 $test.remove();
17631
17632 return width;
17633 };
17634
17635 /**
17636 * Sets up an input to grow horizontally as the user
17637 * types. If the value is changed manually, you can
17638 * trigger the "update" handler to resize:
17639 *
17640 * $input.trigger('update');
17641 *
17642 * @param {object} $input
17643 */
17644 var autoGrow = function($input) {
17645 var currentWidth = null;
17646
17647 var update = function(e, options) {
17648 var value, keyCode, printable, placeholder, width;
17649 var shift, character, selection;
17650 e = e || window.event || {};
17651 options = options || {};
17652
17653 if (e.metaKey || e.altKey) return;
17654 if (!options.force && $input.data('grow') === false) return;
17655
17656 value = $input.val();
17657 if (e.type && e.type.toLowerCase() === 'keydown') {
17658 keyCode = e.keyCode;
17659 printable = (
17660 (keyCode >= 97 && keyCode <= 122) || // a-z
17661 (keyCode >= 65 && keyCode <= 90) || // A-Z
17662 (keyCode >= 48 && keyCode <= 57) || // 0-9
17663 keyCode === 32 // space
17664 );
17665
17666 if (keyCode === KEY_DELETE || keyCode === KEY_BACKSPACE) {
17667 selection = getSelection($input[0]);
17668 if (selection.length) {
17669 value = value.substring(0, selection.start) + value.substring(selection.start + selection.length);
17670 } else if (keyCode === KEY_BACKSPACE && selection.start) {
17671 value = value.substring(0, selection.start - 1) + value.substring(selection.start + 1);
17672 } else if (keyCode === KEY_DELETE && typeof selection.start !== 'undefined') {
17673 value = value.substring(0, selection.start) + value.substring(selection.start + 1);
17674 }
17675 } else if (printable) {
17676 shift = e.shiftKey;
17677 character = String.fromCharCode(e.keyCode);
17678 if (shift) character = character.toUpperCase();
17679 else character = character.toLowerCase();
17680 value += character;
17681 }
17682 }
17683
17684 placeholder = $input.attr('placeholder');
17685 if (!value && placeholder) {
17686 value = placeholder;
17687 }
17688
17689 width = measureString(value, $input) + 4;
17690 if (width !== currentWidth) {
17691 currentWidth = width;
17692 $input.width(width);
17693 $input.triggerHandler('resize');
17694 }
17695 };
17696
17697 $input.on('keydown keyup update blur', update);
17698 update();
17699 };
17700
17701 var domToString = function(d) {
17702 var tmp = document.createElement('div');
17703
17704 tmp.appendChild(d.cloneNode(true));
17705
17706 return tmp.innerHTML;
17707 };
17708
17709 var logError = function(message, options){
17710 if(!options) options = {};
17711 var component = "Selectize";
17712
17713 console.error(component + ": " + message)
17714
17715 if(options.explanation){
17716 // console.group is undefined in <IE11
17717 if(console.group) console.group();
17718 console.error(options.explanation);
17719 if(console.group) console.groupEnd();
17720 }
17721 }
17722
17723
17724 var Selectize = function($input, settings) {
17725 var key, i, n, dir, input, self = this;
17726 input = $input[0];
17727 input.selectize = self;
17728
17729 // detect rtl environment
17730 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
17731 dir = computedStyle ? computedStyle.getPropertyValue('direction') : input.currentStyle && input.currentStyle.direction;
17732 dir = dir || $input.parents('[dir]:first').attr('dir') || '';
17733
17734 // setup default state
17735 $.extend(self, {
17736 order : 0,
17737 settings : settings,
17738 $input : $input,
17739 tabIndex : $input.attr('tabindex') || '',
17740 tagType : input.tagName.toLowerCase() === 'select' ? TAG_SELECT : TAG_INPUT,
17741 rtl : /rtl/i.test(dir),
17742
17743 eventNS : '.selectize' + (++Selectize.count),
17744 highlightedValue : null,
17745 isOpen : false,
17746 isDisabled : false,
17747 isRequired : $input.is('[required]'),
17748 isInvalid : false,
17749 isLocked : false,
17750 isFocused : false,
17751 isInputHidden : false,
17752 isSetup : false,
17753 isShiftDown : false,
17754 isCmdDown : false,
17755 isCtrlDown : false,
17756 ignoreFocus : false,
17757 ignoreBlur : false,
17758 ignoreHover : false,
17759 hasOptions : false,
17760 currentResults : null,
17761 lastValue : '',
17762 caretPos : 0,
17763 loading : 0,
17764 loadedSearches : {},
17765
17766 $activeOption : null,
17767 $activeItems : [],
17768
17769 optgroups : {},
17770 options : {},
17771 userOptions : {},
17772 items : [],
17773 renderCache : {},
17774 onSearchChange : settings.loadThrottle === null ? self.onSearchChange : debounce(self.onSearchChange, settings.loadThrottle)
17775 });
17776
17777 // search system
17778 self.sifter = new Sifter(this.options, {diacritics: settings.diacritics});
17779
17780 // build options table
17781 if (self.settings.options) {
17782 for (i = 0, n = self.settings.options.length; i < n; i++) {
17783 self.registerOption(self.settings.options[i]);
17784 }
17785 delete self.settings.options;
17786 }
17787
17788 // build optgroup table
17789 if (self.settings.optgroups) {
17790 for (i = 0, n = self.settings.optgroups.length; i < n; i++) {
17791 self.registerOptionGroup(self.settings.optgroups[i]);
17792 }
17793 delete self.settings.optgroups;
17794 }
17795
17796 // option-dependent defaults
17797 self.settings.mode = self.settings.mode || (self.settings.maxItems === 1 ? 'single' : 'multi');
17798 if (typeof self.settings.hideSelected !== 'boolean') {
17799 self.settings.hideSelected = self.settings.mode === 'multi';
17800 }
17801
17802 self.initializePlugins(self.settings.plugins);
17803 self.setupCallbacks();
17804 self.setupTemplates();
17805 self.setup();
17806 };
17807
17808 // mixins
17809 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
17810
17811 MicroEvent.mixin(Selectize);
17812
17813 if(typeof MicroPlugin !== "undefined"){
17814 MicroPlugin.mixin(Selectize);
17815 }else{
17816 logError("Dependency MicroPlugin is missing",
17817 {explanation:
17818 "Make sure you either: (1) are using the \"standalone\" "+
17819 "version of Selectize, or (2) require MicroPlugin before you "+
17820 "load Selectize."}
17821 );
17822 }
17823
17824
17825 // methods
17826 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
17827
17828 $.extend(Selectize.prototype, {
17829
17830 /**
17831 * Creates all elements and sets up event bindings.
17832 */
17833 setup: function() {
17834 var self = this;
17835 var settings = self.settings;
17836 var eventNS = self.eventNS;
17837 var $window = $(window);
17838 var $document = $(document);
17839 var $input = self.$input;
17840
17841 var $wrapper;
17842 var $control;
17843 var $control_input;
17844 var $dropdown;
17845 var $dropdown_content;
17846 var $dropdown_parent;
17847 var inputMode;
17848 var timeout_blur;
17849 var timeout_focus;
17850 var classes;
17851 var classes_plugins;
17852 var inputId;
17853
17854 inputMode = self.settings.mode;
17855 classes = $input.attr('class') || '';
17856
17857 $wrapper = $('<div>').addClass(settings.wrapperClass).addClass(classes).addClass(inputMode);
17858 $control = $('<div>').addClass(settings.inputClass).addClass('items').appendTo($wrapper);
17859 $control_input = $('<input type="text" autocomplete="off" />').appendTo($control).attr('tabindex', $input.is(':disabled') ? '-1' : self.tabIndex);
17860 $dropdown_parent = $(settings.dropdownParent || $wrapper);
17861 $dropdown = $('<div>').addClass(settings.dropdownClass).addClass(inputMode).hide().appendTo($dropdown_parent);
17862 $dropdown_content = $('<div>').addClass(settings.dropdownContentClass).appendTo($dropdown);
17863
17864 if(inputId = $input.attr('id')) {
17865 $control_input.attr('id', inputId + '-selectized');
17866 $("label[for='"+inputId+"']").attr('for', inputId + '-selectized');
17867 }
17868
17869 if(self.settings.copyClassesToDropdown) {
17870 $dropdown.addClass(classes);
17871 }
17872
17873 $wrapper.css({
17874 width: $input[0].style.width
17875 });
17876
17877 if (self.plugins.names.length) {
17878 classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
17879 $wrapper.addClass(classes_plugins);
17880 $dropdown.addClass(classes_plugins);
17881 }
17882
17883 if ((settings.maxItems === null || settings.maxItems > 1) && self.tagType === TAG_SELECT) {
17884 $input.attr('multiple', 'multiple');
17885 }
17886
17887 if (self.settings.placeholder) {
17888 $control_input.attr('placeholder', settings.placeholder);
17889 }
17890
17891 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
17892 if (!self.settings.splitOn && self.settings.delimiter) {
17893 var delimiterEscaped = self.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
17894 self.settings.splitOn = new RegExp('\\s*' + delimiterEscaped + '+\\s*');
17895 }
17896
17897 if ($input.attr('autocorrect')) {
17898 $control_input.attr('autocorrect', $input.attr('autocorrect'));
17899 }
17900
17901 if ($input.attr('autocapitalize')) {
17902 $control_input.attr('autocapitalize', $input.attr('autocapitalize'));
17903 }
17904
17905 self.$wrapper = $wrapper;
17906 self.$control = $control;
17907 self.$control_input = $control_input;
17908 self.$dropdown = $dropdown;
17909 self.$dropdown_content = $dropdown_content;
17910
17911 $dropdown.on('mouseenter', '[data-selectable]', function() { return self.onOptionHover.apply(self, arguments); });
17912 $dropdown.on('mousedown click', '[data-selectable]', function() { return self.onOptionSelect.apply(self, arguments); });
17913 watchChildEvent($control, 'mousedown', '*:not(input)', function() { return self.onItemSelect.apply(self, arguments); });
17914 autoGrow($control_input);
17915
17916 $control.on({
17917 mousedown : function() { return self.onMouseDown.apply(self, arguments); },
17918 click : function() { return self.onClick.apply(self, arguments); }
17919 });
17920
17921 $control_input.on({
17922 mousedown : function(e) { e.stopPropagation(); },
17923 keydown : function() { return self.onKeyDown.apply(self, arguments); },
17924 keyup : function() { return self.onKeyUp.apply(self, arguments); },
17925 keypress : function() { return self.onKeyPress.apply(self, arguments); },
17926 resize : function() { self.positionDropdown.apply(self, []); },
17927 blur : function() { return self.onBlur.apply(self, arguments); },
17928 focus : function() { self.ignoreBlur = false; return self.onFocus.apply(self, arguments); },
17929 paste : function() { return self.onPaste.apply(self, arguments); }
17930 });
17931
17932 $document.on('keydown' + eventNS, function(e) {
17933 self.isCmdDown = e[IS_MAC ? 'metaKey' : 'ctrlKey'];
17934 self.isCtrlDown = e[IS_MAC ? 'altKey' : 'ctrlKey'];
17935 self.isShiftDown = e.shiftKey;
17936 });
17937
17938 $document.on('keyup' + eventNS, function(e) {
17939 if (e.keyCode === KEY_CTRL) self.isCtrlDown = false;
17940 if (e.keyCode === KEY_SHIFT) self.isShiftDown = false;
17941 if (e.keyCode === KEY_CMD) self.isCmdDown = false;
17942 });
17943
17944 $document.on('mousedown' + eventNS, function(e) {
17945 if (self.isFocused) {
17946 // prevent events on the dropdown scrollbar from causing the control to blur
17947 if (e.target === self.$dropdown[0] || e.target.parentNode === self.$dropdown[0]) {
17948 return false;
17949 }
17950 // blur on click outside
17951 if (!self.$control.has(e.target).length && e.target !== self.$control[0]) {
17952 self.blur(e.target);
17953 }
17954 }
17955 });
17956
17957 $window.on(['scroll' + eventNS, 'resize' + eventNS].join(' '), function() {
17958 if (self.isOpen) {
17959 self.positionDropdown.apply(self, arguments);
17960 }
17961 });
17962 $window.on('mousemove' + eventNS, function() {
17963 self.ignoreHover = false;
17964 });
17965
17966 // store original children and tab index so that they can be
17967 // restored when the destroy() method is called.
17968 this.revertSettings = {
17969 $children : $input.children().detach(),
17970 tabindex : $input.attr('tabindex')
17971 };
17972
17973 $input.attr('tabindex', -1).hide().after(self.$wrapper);
17974
17975 if ($.isArray(settings.items)) {
17976 self.setValue(settings.items);
17977 delete settings.items;
17978 }
17979
17980 // feature detect for the validation API
17981 if (SUPPORTS_VALIDITY_API) {
17982 $input.on('invalid' + eventNS, function(e) {
17983 e.preventDefault();
17984 self.isInvalid = true;
17985 self.refreshState();
17986 });
17987 }
17988
17989 self.updateOriginalInput();
17990 self.refreshItems();
17991 self.refreshState();
17992 self.updatePlaceholder();
17993 self.isSetup = true;
17994
17995 if ($input.is(':disabled')) {
17996 self.disable();
17997 }
17998
17999 self.on('change', this.onChange);
18000
18001 $input.data('selectize', self);
18002 $input.addClass('selectized');
18003 self.trigger('initialize');
18004
18005 // preload options
18006 if (settings.preload === true) {
18007 self.onSearchChange('');
18008 }
18009
18010 },
18011
18012 /**
18013 * Sets up default rendering functions.
18014 */
18015 setupTemplates: function() {
18016 var self = this;
18017 var field_label = self.settings.labelField;
18018 var field_optgroup = self.settings.optgroupLabelField;
18019
18020 var templates = {
18021 'optgroup': function(data) {
18022 return '<div class="optgroup">' + data.html + '</div>';
18023 },
18024 'optgroup_header': function(data, escape) {
18025 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
18026 },
18027 'option': function(data, escape) {
18028 return '<div class="option">' + escape(data[field_label]) + '</div>';
18029 },
18030 'item': function(data, escape) {
18031 return '<div class="item">' + escape(data[field_label]) + '</div>';
18032 },
18033 'option_create': function(data, escape) {
18034 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
18035 }
18036 };
18037
18038 self.settings.render = $.extend({}, templates, self.settings.render);
18039 },
18040
18041 /**
18042 * Maps fired events to callbacks provided
18043 * in the settings used when creating the control.
18044 */
18045 setupCallbacks: function() {
18046 var key, fn, callbacks = {
18047 'initialize' : 'onInitialize',
18048 'change' : 'onChange',
18049 'item_add' : 'onItemAdd',
18050 'item_remove' : 'onItemRemove',
18051 'clear' : 'onClear',
18052 'option_add' : 'onOptionAdd',
18053 'option_remove' : 'onOptionRemove',
18054 'option_clear' : 'onOptionClear',
18055 'optgroup_add' : 'onOptionGroupAdd',
18056 'optgroup_remove' : 'onOptionGroupRemove',
18057 'optgroup_clear' : 'onOptionGroupClear',
18058 'dropdown_open' : 'onDropdownOpen',
18059 'dropdown_close' : 'onDropdownClose',
18060 'type' : 'onType',
18061 'load' : 'onLoad',
18062 'focus' : 'onFocus',
18063 'blur' : 'onBlur'
18064 };
18065
18066 for (key in callbacks) {
18067 if (callbacks.hasOwnProperty(key)) {
18068 fn = this.settings[callbacks[key]];
18069 if (fn) this.on(key, fn);
18070 }
18071 }
18072 },
18073
18074 /**
18075 * Triggered when the main control element
18076 * has a click event.
18077 *
18078 * @param {object} e
18079 * @return {boolean}
18080 */
18081 onClick: function(e) {
18082 var self = this;
18083
18084 // necessary for mobile webkit devices (manual focus triggering
18085 // is ignored unless invoked within a click event)
18086 if (!self.isFocused) {
18087 self.focus();
18088 e.preventDefault();
18089 }
18090 },
18091
18092 /**
18093 * Triggered when the main control element
18094 * has a mouse down event.
18095 *
18096 * @param {object} e
18097 * @return {boolean}
18098 */
18099 onMouseDown: function(e) {
18100 var self = this;
18101 var defaultPrevented = e.isDefaultPrevented();
18102 var $target = $(e.target);
18103
18104 if (self.isFocused) {
18105 // retain focus by preventing native handling. if the
18106 // event target is the input it should not be modified.
18107 // otherwise, text selection within the input won't work.
18108 if (e.target !== self.$control_input[0]) {
18109 if (self.settings.mode === 'single') {
18110 // toggle dropdown
18111 self.isOpen ? self.close() : self.open();
18112 } else if (!defaultPrevented) {
18113 self.setActiveItem(null);
18114 }
18115 return false;
18116 }
18117 } else {
18118 // give control focus
18119 if (!defaultPrevented) {
18120 window.setTimeout(function() {
18121 self.focus();
18122 }, 0);
18123 }
18124 }
18125 },
18126
18127 /**
18128 * Triggered when the value of the control has been changed.
18129 * This should propagate the event to the original DOM
18130 * input / select element.
18131 */
18132 onChange: function() {
18133 this.$input.trigger('change');
18134 },
18135
18136 /**
18137 * Triggered on <input> paste.
18138 *
18139 * @param {object} e
18140 * @returns {boolean}
18141 */
18142 onPaste: function(e) {
18143 var self = this;
18144
18145 if (self.isFull() || self.isInputHidden || self.isLocked) {
18146 e.preventDefault();
18147 return;
18148 }
18149
18150 // If a regex or string is included, this will split the pasted
18151 // input and create Items for each separate value
18152 if (self.settings.splitOn) {
18153
18154 // Wait for pasted text to be recognized in value
18155 setTimeout(function() {
18156 var pastedText = self.$control_input.val();
18157 if(!pastedText.match(self.settings.splitOn)){ return }
18158
18159 var splitInput = $.trim(pastedText).split(self.settings.splitOn);
18160 for (var i = 0, n = splitInput.length; i < n; i++) {
18161 self.createItem(splitInput[i]);
18162 }
18163 }, 0);
18164 }
18165 },
18166
18167 /**
18168 * Triggered on <input> keypress.
18169 *
18170 * @param {object} e
18171 * @returns {boolean}
18172 */
18173 onKeyPress: function(e) {
18174 if (this.isLocked) return e && e.preventDefault();
18175 var character = String.fromCharCode(e.keyCode || e.which);
18176 if (this.settings.create && this.settings.mode === 'multi' && character === this.settings.delimiter) {
18177 this.createItem();
18178 e.preventDefault();
18179 return false;
18180 }
18181 },
18182
18183 /**
18184 * Triggered on <input> keydown.
18185 *
18186 * @param {object} e
18187 * @returns {boolean}
18188 */
18189 onKeyDown: function(e) {
18190 var isInput = e.target === this.$control_input[0];
18191 var self = this;
18192
18193 if (self.isLocked) {
18194 if (e.keyCode !== KEY_TAB) {
18195 e.preventDefault();
18196 }
18197 return;
18198 }
18199
18200 switch (e.keyCode) {
18201 case KEY_A:
18202 if (self.isCmdDown) {
18203 self.selectAll();
18204 return;
18205 }
18206 break;
18207 case KEY_ESC:
18208 if (self.isOpen) {
18209 e.preventDefault();
18210 e.stopPropagation();
18211 self.close();
18212 }
18213 return;
18214 case KEY_N:
18215 if (!e.ctrlKey || e.altKey) break;
18216 case KEY_DOWN:
18217 if (!self.isOpen && self.hasOptions) {
18218 self.open();
18219 } else if (self.$activeOption) {
18220 self.ignoreHover = true;
18221 var $next = self.getAdjacentOption(self.$activeOption, 1);
18222 if ($next.length) self.setActiveOption($next, true, true);
18223 }
18224 e.preventDefault();
18225 return;
18226 case KEY_P:
18227 if (!e.ctrlKey || e.altKey) break;
18228 case KEY_UP:
18229 if (self.$activeOption) {
18230 self.ignoreHover = true;
18231 var $prev = self.getAdjacentOption(self.$activeOption, -1);
18232 if ($prev.length) self.setActiveOption($prev, true, true);
18233 }
18234 e.preventDefault();
18235 return;
18236 case KEY_RETURN:
18237 if (self.isOpen && self.$activeOption) {
18238 self.onOptionSelect({currentTarget: self.$activeOption});
18239 e.preventDefault();
18240 }
18241 return;
18242 case KEY_LEFT:
18243 self.advanceSelection(-1, e);
18244 return;
18245 case KEY_RIGHT:
18246 self.advanceSelection(1, e);
18247 return;
18248 case KEY_TAB:
18249 if (self.settings.selectOnTab && self.isOpen && self.$activeOption) {
18250 self.onOptionSelect({currentTarget: self.$activeOption});
18251
18252 // Default behaviour is to jump to the next field, we only want this
18253 // if the current field doesn't accept any more entries
18254 if (!self.isFull()) {
18255 e.preventDefault();
18256 }
18257 }
18258 if (self.settings.create && self.createItem()) {
18259 e.preventDefault();
18260 }
18261 return;
18262 case KEY_BACKSPACE:
18263 case KEY_DELETE:
18264 self.deleteSelection(e);
18265 return;
18266 }
18267
18268 if ((self.isFull() || self.isInputHidden) && !(IS_MAC ? e.metaKey : e.ctrlKey)) {
18269 e.preventDefault();
18270 return;
18271 }
18272 },
18273
18274 /**
18275 * Triggered on <input> keyup.
18276 *
18277 * @param {object} e
18278 * @returns {boolean}
18279 */
18280 onKeyUp: function(e) {
18281 var self = this;
18282
18283 if (self.isLocked) return e && e.preventDefault();
18284 var value = self.$control_input.val() || '';
18285 if (self.lastValue !== value) {
18286 self.lastValue = value;
18287 self.onSearchChange(value);
18288 self.refreshOptions();
18289 self.trigger('type', value);
18290 }
18291 },
18292
18293 /**
18294 * Invokes the user-provide option provider / loader.
18295 *
18296 * Note: this function is debounced in the Selectize
18297 * constructor (by `settings.loadThrottle` milliseconds)
18298 *
18299 * @param {string} value
18300 */
18301 onSearchChange: function(value) {
18302 var self = this;
18303 var fn = self.settings.load;
18304 if (!fn) return;
18305 if (self.loadedSearches.hasOwnProperty(value)) return;
18306 self.loadedSearches[value] = true;
18307 self.load(function(callback) {
18308 fn.apply(self, [value, callback]);
18309 });
18310 },
18311
18312 /**
18313 * Triggered on <input> focus.
18314 *
18315 * @param {object} e (optional)
18316 * @returns {boolean}
18317 */
18318 onFocus: function(e) {
18319 var self = this;
18320 var wasFocused = self.isFocused;
18321
18322 if (self.isDisabled) {
18323 self.blur();
18324 e && e.preventDefault();
18325 return false;
18326 }
18327
18328 if (self.ignoreFocus) return;
18329 self.isFocused = true;
18330 if (self.settings.preload === 'focus') self.onSearchChange('');
18331
18332 if (!wasFocused) self.trigger('focus');
18333
18334 if (!self.$activeItems.length) {
18335 self.showInput();
18336 self.setActiveItem(null);
18337 self.refreshOptions(!!self.settings.openOnFocus);
18338 }
18339
18340 self.refreshState();
18341 },
18342
18343 /**
18344 * Triggered on <input> blur.
18345 *
18346 * @param {object} e
18347 * @param {Element} dest
18348 */
18349 onBlur: function(e, dest) {
18350 var self = this;
18351 if (!self.isFocused) return;
18352 self.isFocused = false;
18353
18354 if (self.ignoreFocus) {
18355 return;
18356 } else if (!self.ignoreBlur && document.activeElement === self.$dropdown_content[0]) {
18357 // necessary to prevent IE closing the dropdown when the scrollbar is clicked
18358 self.ignoreBlur = true;
18359 self.onFocus(e);
18360 return;
18361 }
18362
18363 var deactivate = function() {
18364 self.close();
18365 self.setTextboxValue('');
18366 self.setActiveItem(null);
18367 self.setActiveOption(null);
18368 self.setCaret(self.items.length);
18369 self.refreshState();
18370
18371 // IE11 bug: element still marked as active
18372 dest && dest.focus && dest.focus();
18373
18374 self.ignoreFocus = false;
18375 self.trigger('blur');
18376 };
18377
18378 self.ignoreFocus = true;
18379 if (self.settings.create && self.settings.createOnBlur) {
18380 self.createItem(null, false, deactivate);
18381 } else {
18382 deactivate();
18383 }
18384 },
18385
18386 /**
18387 * Triggered when the user rolls over
18388 * an option in the autocomplete dropdown menu.
18389 *
18390 * @param {object} e
18391 * @returns {boolean}
18392 */
18393 onOptionHover: function(e) {
18394 if (this.ignoreHover) return;
18395 this.setActiveOption(e.currentTarget, false);
18396 },
18397
18398 /**
18399 * Triggered when the user clicks on an option
18400 * in the autocomplete dropdown menu.
18401 *
18402 * @param {object} e
18403 * @returns {boolean}
18404 */
18405 onOptionSelect: function(e) {
18406 var value, $target, $option, self = this;
18407
18408 if (e.preventDefault) {
18409 e.preventDefault();
18410 e.stopPropagation();
18411 }
18412
18413 $target = $(e.currentTarget);
18414 if ($target.hasClass('create')) {
18415 self.createItem(null, function() {
18416 if (self.settings.closeAfterSelect) {
18417 self.close();
18418 }
18419 });
18420 } else {
18421 value = $target.attr('data-value');
18422 if (typeof value !== 'undefined') {
18423 self.lastQuery = null;
18424 self.setTextboxValue('');
18425 self.addItem(value);
18426 if (self.settings.closeAfterSelect) {
18427 self.close();
18428 } else if (!self.settings.hideSelected && e.type && /mouse/.test(e.type)) {
18429 self.setActiveOption(self.getOption(value));
18430 }
18431 }
18432 }
18433 },
18434
18435 /**
18436 * Triggered when the user clicks on an item
18437 * that has been selected.
18438 *
18439 * @param {object} e
18440 * @returns {boolean}
18441 */
18442 onItemSelect: function(e) {
18443 var self = this;
18444
18445 if (self.isLocked) return;
18446 if (self.settings.mode === 'multi') {
18447 e.preventDefault();
18448 self.setActiveItem(e.currentTarget, e);
18449 }
18450 },
18451
18452 /**
18453 * Invokes the provided method that provides
18454 * results to a callback---which are then added
18455 * as options to the control.
18456 *
18457 * @param {function} fn
18458 */
18459 load: function(fn) {
18460 var self = this;
18461 var $wrapper = self.$wrapper.addClass(self.settings.loadingClass);
18462
18463 self.loading++;
18464 fn.apply(self, [function(results) {
18465 self.loading = Math.max(self.loading - 1, 0);
18466 if (results && results.length) {
18467 self.addOption(results);
18468 self.refreshOptions(self.isFocused && !self.isInputHidden);
18469 }
18470 if (!self.loading) {
18471 $wrapper.removeClass(self.settings.loadingClass);
18472 }
18473 self.trigger('load', results);
18474 }]);
18475 },
18476
18477 /**
18478 * Sets the input field of the control to the specified value.
18479 *
18480 * @param {string} value
18481 */
18482 setTextboxValue: function(value) {
18483 var $input = this.$control_input;
18484 var changed = $input.val() !== value;
18485 if (changed) {
18486 $input.val(value).triggerHandler('update');
18487 this.lastValue = value;
18488 }
18489 },
18490
18491 /**
18492 * Returns the value of the control. If multiple items
18493 * can be selected (e.g. <select multiple>), this returns
18494 * an array. If only one item can be selected, this
18495 * returns a string.
18496 *
18497 * @returns {mixed}
18498 */
18499 getValue: function() {
18500 if (this.tagType === TAG_SELECT && this.$input.attr('multiple')) {
18501 return this.items;
18502 } else {
18503 return this.items.join(this.settings.delimiter);
18504 }
18505 },
18506
18507 /**
18508 * Resets the selected items to the given value.
18509 *
18510 * @param {mixed} value
18511 */
18512 setValue: function(value, silent) {
18513 var events = silent ? [] : ['change'];
18514
18515 debounce_events(this, events, function() {
18516 this.clear(silent);
18517 this.addItems(value, silent);
18518 });
18519 },
18520
18521 /**
18522 * Sets the selected item.
18523 *
18524 * @param {object} $item
18525 * @param {object} e (optional)
18526 */
18527 setActiveItem: function($item, e) {
18528 var self = this;
18529 var eventName;
18530 var i, idx, begin, end, item, swap;
18531 var $last;
18532
18533 if (self.settings.mode === 'single') return;
18534 $item = $($item);
18535
18536 // clear the active selection
18537 if (!$item.length) {
18538 $(self.$activeItems).removeClass('active');
18539 self.$activeItems = [];
18540 if (self.isFocused) {
18541 self.showInput();
18542 }
18543 return;
18544 }
18545
18546 // modify selection
18547 eventName = e && e.type.toLowerCase();
18548
18549 if (eventName === 'mousedown' && self.isShiftDown && self.$activeItems.length) {
18550 $last = self.$control.children('.active:last');
18551 begin = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$last[0]]);
18552 end = Array.prototype.indexOf.apply(self.$control[0].childNodes, [$item[0]]);
18553 if (begin > end) {
18554 swap = begin;
18555 begin = end;
18556 end = swap;
18557 }
18558 for (i = begin; i <= end; i++) {
18559 item = self.$control[0].childNodes[i];
18560 if (self.$activeItems.indexOf(item) === -1) {
18561 $(item).addClass('active');
18562 self.$activeItems.push(item);
18563 }
18564 }
18565 e.preventDefault();
18566 } else if ((eventName === 'mousedown' && self.isCtrlDown) || (eventName === 'keydown' && this.isShiftDown)) {
18567 if ($item.hasClass('active')) {
18568 idx = self.$activeItems.indexOf($item[0]);
18569 self.$activeItems.splice(idx, 1);
18570 $item.removeClass('active');
18571 } else {
18572 self.$activeItems.push($item.addClass('active')[0]);
18573 }
18574 } else {
18575 $(self.$activeItems).removeClass('active');
18576 self.$activeItems = [$item.addClass('active')[0]];
18577 }
18578
18579 // ensure control has focus
18580 self.hideInput();
18581 if (!this.isFocused) {
18582 self.focus();
18583 }
18584 },
18585
18586 /**
18587 * Sets the selected item in the dropdown menu
18588 * of available options.
18589 *
18590 * @param {object} $object
18591 * @param {boolean} scroll
18592 * @param {boolean} animate
18593 */
18594 setActiveOption: function($option, scroll, animate) {
18595 var height_menu, height_item, y;
18596 var scroll_top, scroll_bottom;
18597 var self = this;
18598
18599 if (self.$activeOption) self.$activeOption.removeClass('active');
18600 self.$activeOption = null;
18601
18602 $option = $($option);
18603 if (!$option.length) return;
18604
18605 self.$activeOption = $option.addClass('active');
18606
18607 if (scroll || !isset(scroll)) {
18608
18609 height_menu = self.$dropdown_content.height();
18610 height_item = self.$activeOption.outerHeight(true);
18611 scroll = self.$dropdown_content.scrollTop() || 0;
18612 y = self.$activeOption.offset().top - self.$dropdown_content.offset().top + scroll;
18613 scroll_top = y;
18614 scroll_bottom = y - height_menu + height_item;
18615
18616 if (y + height_item > height_menu + scroll) {
18617 self.$dropdown_content.stop().animate({scrollTop: scroll_bottom}, animate ? self.settings.scrollDuration : 0);
18618 } else if (y < scroll) {
18619 self.$dropdown_content.stop().animate({scrollTop: scroll_top}, animate ? self.settings.scrollDuration : 0);
18620 }
18621
18622 }
18623 },
18624
18625 /**
18626 * Selects all items (CTRL + A).
18627 */
18628 selectAll: function() {
18629 var self = this;
18630 if (self.settings.mode === 'single') return;
18631
18632 self.$activeItems = Array.prototype.slice.apply(self.$control.children(':not(input)').addClass('active'));
18633 if (self.$activeItems.length) {
18634 self.hideInput();
18635 self.close();
18636 }
18637 self.focus();
18638 },
18639
18640 /**
18641 * Hides the input element out of view, while
18642 * retaining its focus.
18643 */
18644 hideInput: function() {
18645 var self = this;
18646
18647 self.setTextboxValue('');
18648 self.$control_input.css({opacity: 0, position: 'absolute', left: self.rtl ? 10000 : -10000});
18649 self.isInputHidden = true;
18650 },
18651
18652 /**
18653 * Restores input visibility.
18654 */
18655 showInput: function() {
18656 this.$control_input.css({opacity: 1, position: 'relative', left: 0});
18657 this.isInputHidden = false;
18658 },
18659
18660 /**
18661 * Gives the control focus.
18662 */
18663 focus: function() {
18664 var self = this;
18665 if (self.isDisabled) return;
18666
18667 self.ignoreFocus = true;
18668 self.$control_input[0].focus();
18669 window.setTimeout(function() {
18670 self.ignoreFocus = false;
18671 self.onFocus();
18672 }, 0);
18673 },
18674
18675 /**
18676 * Forces the control out of focus.
18677 *
18678 * @param {Element} dest
18679 */
18680 blur: function(dest) {
18681 this.$control_input[0].blur();
18682 this.onBlur(null, dest);
18683 },
18684
18685 /**
18686 * Returns a function that scores an object
18687 * to show how good of a match it is to the
18688 * provided query.
18689 *
18690 * @param {string} query
18691 * @param {object} options
18692 * @return {function}
18693 */
18694 getScoreFunction: function(query) {
18695 return this.sifter.getScoreFunction(query, this.getSearchOptions());
18696 },
18697
18698 /**
18699 * Returns search options for sifter (the system
18700 * for scoring and sorting results).
18701 *
18702 * @see https://github.com/brianreavis/sifter.js
18703 * @return {object}
18704 */
18705 getSearchOptions: function() {
18706 var settings = this.settings;
18707 var sort = settings.sortField;
18708 if (typeof sort === 'string') {
18709 sort = [{field: sort}];
18710 }
18711
18712 return {
18713 fields : settings.searchField,
18714 conjunction : settings.searchConjunction,
18715 sort : sort
18716 };
18717 },
18718
18719 /**
18720 * Searches through available options and returns
18721 * a sorted array of matches.
18722 *
18723 * Returns an object containing:
18724 *
18725 * - query {string}
18726 * - tokens {array}
18727 * - total {int}
18728 * - items {array}
18729 *
18730 * @param {string} query
18731 * @returns {object}
18732 */
18733 search: function(query) {
18734 var i, value, score, result, calculateScore;
18735 var self = this;
18736 var settings = self.settings;
18737 var options = this.getSearchOptions();
18738
18739 // validate user-provided result scoring function
18740 if (settings.score) {
18741 calculateScore = self.settings.score.apply(this, [query]);
18742 if (typeof calculateScore !== 'function') {
18743 throw new Error('Selectize "score" setting must be a function that returns a function');
18744 }
18745 }
18746
18747 // perform search
18748 if (query !== self.lastQuery) {
18749 self.lastQuery = query;
18750 result = self.sifter.search(query, $.extend(options, {score: calculateScore}));
18751 self.currentResults = result;
18752 } else {
18753 result = $.extend(true, {}, self.currentResults);
18754 }
18755
18756 // filter out selected items
18757 if (settings.hideSelected) {
18758 for (i = result.items.length - 1; i >= 0; i--) {
18759 if (self.items.indexOf(hash_key(result.items[i].id)) !== -1) {
18760 result.items.splice(i, 1);
18761 }
18762 }
18763 }
18764
18765 return result;
18766 },
18767
18768 /**
18769 * Refreshes the list of available options shown
18770 * in the autocomplete dropdown menu.
18771 *
18772 * @param {boolean} triggerDropdown
18773 */
18774 refreshOptions: function(triggerDropdown) {
18775 var i, j, k, n, groups, groups_order, option, option_html, optgroup, optgroups, html, html_children, has_create_option;
18776 var $active, $active_before, $create;
18777
18778 if (typeof triggerDropdown === 'undefined') {
18779 triggerDropdown = true;
18780 }
18781
18782 var self = this;
18783 var query = $.trim(self.$control_input.val());
18784 var results = self.search(query);
18785 var $dropdown_content = self.$dropdown_content;
18786 var active_before = self.$activeOption && hash_key(self.$activeOption.attr('data-value'));
18787
18788 // build markup
18789 n = results.items.length;
18790 if (typeof self.settings.maxOptions === 'number') {
18791 n = Math.min(n, self.settings.maxOptions);
18792 }
18793
18794 // render and group available options individually
18795 groups = {};
18796 groups_order = [];
18797
18798 for (i = 0; i < n; i++) {
18799 option = self.options[results.items[i].id];
18800 option_html = self.render('option', option);
18801 optgroup = option[self.settings.optgroupField] || '';
18802 optgroups = $.isArray(optgroup) ? optgroup : [optgroup];
18803
18804 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
18805 optgroup = optgroups[j];
18806 if (!self.optgroups.hasOwnProperty(optgroup)) {
18807 optgroup = '';
18808 }
18809 if (!groups.hasOwnProperty(optgroup)) {
18810 groups[optgroup] = document.createDocumentFragment();
18811 groups_order.push(optgroup);
18812 }
18813 groups[optgroup].appendChild(option_html);
18814 }
18815 }
18816
18817 // sort optgroups
18818 if (this.settings.lockOptgroupOrder) {
18819 groups_order.sort(function(a, b) {
18820 var a_order = self.optgroups[a].$order || 0;
18821 var b_order = self.optgroups[b].$order || 0;
18822 return a_order - b_order;
18823 });
18824 }
18825
18826 // render optgroup headers & join groups
18827 html = document.createDocumentFragment();
18828 for (i = 0, n = groups_order.length; i < n; i++) {
18829 optgroup = groups_order[i];
18830 if (self.optgroups.hasOwnProperty(optgroup) && groups[optgroup].childNodes.length) {
18831 // render the optgroup header and options within it,
18832 // then pass it to the wrapper template
18833 html_children = document.createDocumentFragment();
18834 html_children.appendChild(self.render('optgroup_header', self.optgroups[optgroup]));
18835 html_children.appendChild(groups[optgroup]);
18836
18837 html.appendChild(self.render('optgroup', $.extend({}, self.optgroups[optgroup], {
18838 html: domToString(html_children),
18839 dom: html_children
18840 })));
18841 } else {
18842 html.appendChild(groups[optgroup]);
18843 }
18844 }
18845
18846 $dropdown_content.html(html);
18847
18848 // highlight matching terms inline
18849 if (self.settings.highlight && results.query.length && results.tokens.length) {
18850 $dropdown_content.removeHighlight();
18851 for (i = 0, n = results.tokens.length; i < n; i++) {
18852 highlight($dropdown_content, results.tokens[i].regex);
18853 }
18854 }
18855
18856 // add "selected" class to selected options
18857 if (!self.settings.hideSelected) {
18858 for (i = 0, n = self.items.length; i < n; i++) {
18859 self.getOption(self.items[i]).addClass('selected');
18860 }
18861 }
18862
18863 // add create option
18864 has_create_option = self.canCreate(query);
18865 if (has_create_option) {
18866 $dropdown_content.prepend(self.render('option_create', {input: query}));
18867 $create = $($dropdown_content[0].childNodes[0]);
18868 }
18869
18870 // activate
18871 self.hasOptions = results.items.length > 0 || has_create_option;
18872 if (self.hasOptions) {
18873 if (results.items.length > 0) {
18874 $active_before = active_before && self.getOption(active_before);
18875 if ($active_before && $active_before.length) {
18876 $active = $active_before;
18877 } else if (self.settings.mode === 'single' && self.items.length) {
18878 $active = self.getOption(self.items[0]);
18879 }
18880 if (!$active || !$active.length) {
18881 if ($create && !self.settings.addPrecedence) {
18882 $active = self.getAdjacentOption($create, 1);
18883 } else {
18884 $active = $dropdown_content.find('[data-selectable]:first');
18885 }
18886 }
18887 } else {
18888 $active = $create;
18889 }
18890 self.setActiveOption($active);
18891 if (triggerDropdown && !self.isOpen) { self.open(); }
18892 } else {
18893 self.setActiveOption(null);
18894 if (triggerDropdown && self.isOpen) { self.close(); }
18895 }
18896 },
18897
18898 /**
18899 * Adds an available option. If it already exists,
18900 * nothing will happen. Note: this does not refresh
18901 * the options list dropdown (use `refreshOptions`
18902 * for that).
18903 *
18904 * Usage:
18905 *
18906 * this.addOption(data)
18907 *
18908 * @param {object|array} data
18909 */
18910 addOption: function(data) {
18911 var i, n, value, self = this;
18912
18913 if ($.isArray(data)) {
18914 for (i = 0, n = data.length; i < n; i++) {
18915 self.addOption(data[i]);
18916 }
18917 return;
18918 }
18919
18920 if (value = self.registerOption(data)) {
18921 self.userOptions[value] = true;
18922 self.lastQuery = null;
18923 self.trigger('option_add', value, data);
18924 }
18925 },
18926
18927 /**
18928 * Registers an option to the pool of options.
18929 *
18930 * @param {object} data
18931 * @return {boolean|string}
18932 */
18933 registerOption: function(data) {
18934 var key = hash_key(data[this.settings.valueField]);
18935 if (typeof key === 'undefined' || key === null || this.options.hasOwnProperty(key)) return false;
18936 data.$order = data.$order || ++this.order;
18937 this.options[key] = data;
18938 return key;
18939 },
18940
18941 /**
18942 * Registers an option group to the pool of option groups.
18943 *
18944 * @param {object} data
18945 * @return {boolean|string}
18946 */
18947 registerOptionGroup: function(data) {
18948 var key = hash_key(data[this.settings.optgroupValueField]);
18949 if (!key) return false;
18950
18951 data.$order = data.$order || ++this.order;
18952 this.optgroups[key] = data;
18953 return key;
18954 },
18955
18956 /**
18957 * Registers a new optgroup for options
18958 * to be bucketed into.
18959 *
18960 * @param {string} id
18961 * @param {object} data
18962 */
18963 addOptionGroup: function(id, data) {
18964 data[this.settings.optgroupValueField] = id;
18965 if (id = this.registerOptionGroup(data)) {
18966 this.trigger('optgroup_add', id, data);
18967 }
18968 },
18969
18970 /**
18971 * Removes an existing option group.
18972 *
18973 * @param {string} id
18974 */
18975 removeOptionGroup: function(id) {
18976 if (this.optgroups.hasOwnProperty(id)) {
18977 delete this.optgroups[id];
18978 this.renderCache = {};
18979 this.trigger('optgroup_remove', id);
18980 }
18981 },
18982
18983 /**
18984 * Clears all existing option groups.
18985 */
18986 clearOptionGroups: function() {
18987 this.optgroups = {};
18988 this.renderCache = {};
18989 this.trigger('optgroup_clear');
18990 },
18991
18992 /**
18993 * Updates an option available for selection. If
18994 * it is visible in the selected items or options
18995 * dropdown, it will be re-rendered automatically.
18996 *
18997 * @param {string} value
18998 * @param {object} data
18999 */
19000 updateOption: function(value, data) {
19001 var self = this;
19002 var $item, $item_new;
19003 var value_new, index_item, cache_items, cache_options, order_old;
19004
19005 value = hash_key(value);
19006 value_new = hash_key(data[self.settings.valueField]);
19007
19008 // sanity checks
19009 if (value === null) return;
19010 if (!self.options.hasOwnProperty(value)) return;
19011 if (typeof value_new !== 'string') throw new Error('Value must be set in option data');
19012
19013 order_old = self.options[value].$order;
19014
19015 // update references
19016 if (value_new !== value) {
19017 delete self.options[value];
19018 index_item = self.items.indexOf(value);
19019 if (index_item !== -1) {
19020 self.items.splice(index_item, 1, value_new);
19021 }
19022 }
19023 data.$order = data.$order || order_old;
19024 self.options[value_new] = data;
19025
19026 // invalidate render cache
19027 cache_items = self.renderCache['item'];
19028 cache_options = self.renderCache['option'];
19029
19030 if (cache_items) {
19031 delete cache_items[value];
19032 delete cache_items[value_new];
19033 }
19034 if (cache_options) {
19035 delete cache_options[value];
19036 delete cache_options[value_new];
19037 }
19038
19039 // update the item if it's selected
19040 if (self.items.indexOf(value_new) !== -1) {
19041 $item = self.getItem(value);
19042 $item_new = $(self.render('item', data));
19043 if ($item.hasClass('active')) $item_new.addClass('active');
19044 $item.replaceWith($item_new);
19045 }
19046
19047 // invalidate last query because we might have updated the sortField
19048 self.lastQuery = null;
19049
19050 // update dropdown contents
19051 if (self.isOpen) {
19052 self.refreshOptions(false);
19053 }
19054 },
19055
19056 /**
19057 * Removes a single option.
19058 *
19059 * @param {string} value
19060 * @param {boolean} silent
19061 */
19062 removeOption: function(value, silent) {
19063 var self = this;
19064 value = hash_key(value);
19065
19066 var cache_items = self.renderCache['item'];
19067 var cache_options = self.renderCache['option'];
19068 if (cache_items) delete cache_items[value];
19069 if (cache_options) delete cache_options[value];
19070
19071 delete self.userOptions[value];
19072 delete self.options[value];
19073 self.lastQuery = null;
19074 self.trigger('option_remove', value);
19075 self.removeItem(value, silent);
19076 },
19077
19078 /**
19079 * Clears all options.
19080 */
19081 clearOptions: function() {
19082 var self = this;
19083
19084 self.loadedSearches = {};
19085 self.userOptions = {};
19086 self.renderCache = {};
19087 self.options = self.sifter.items = {};
19088 self.lastQuery = null;
19089 self.trigger('option_clear');
19090 self.clear();
19091 },
19092
19093 /**
19094 * Returns the jQuery element of the option
19095 * matching the given value.
19096 *
19097 * @param {string} value
19098 * @returns {object}
19099 */
19100 getOption: function(value) {
19101 return this.getElementWithValue(value, this.$dropdown_content.find('[data-selectable]'));
19102 },
19103
19104 /**
19105 * Returns the jQuery element of the next or
19106 * previous selectable option.
19107 *
19108 * @param {object} $option
19109 * @param {int} direction can be 1 for next or -1 for previous
19110 * @return {object}
19111 */
19112 getAdjacentOption: function($option, direction) {
19113 var $options = this.$dropdown.find('[data-selectable]');
19114 var index = $options.index($option) + direction;
19115
19116 return index >= 0 && index < $options.length ? $options.eq(index) : $();
19117 },
19118
19119 /**
19120 * Finds the first element with a "data-value" attribute
19121 * that matches the given value.
19122 *
19123 * @param {mixed} value
19124 * @param {object} $els
19125 * @return {object}
19126 */
19127 getElementWithValue: function(value, $els) {
19128 value = hash_key(value);
19129
19130 if (typeof value !== 'undefined' && value !== null) {
19131 for (var i = 0, n = $els.length; i < n; i++) {
19132 if ($els[i].getAttribute('data-value') === value) {
19133 return $($els[i]);
19134 }
19135 }
19136 }
19137
19138 return $();
19139 },
19140
19141 /**
19142 * Returns the jQuery element of the item
19143 * matching the given value.
19144 *
19145 * @param {string} value
19146 * @returns {object}
19147 */
19148 getItem: function(value) {
19149 return this.getElementWithValue(value, this.$control.children());
19150 },
19151
19152 /**
19153 * "Selects" multiple items at once. Adds them to the list
19154 * at the current caret position.
19155 *
19156 * @param {string} value
19157 * @param {boolean} silent
19158 */
19159 addItems: function(values, silent) {
19160 var items = $.isArray(values) ? values : [values];
19161 for (var i = 0, n = items.length; i < n; i++) {
19162 this.isPending = (i < n - 1);
19163 this.addItem(items[i], silent);
19164 }
19165 },
19166
19167 /**
19168 * "Selects" an item. Adds it to the list
19169 * at the current caret position.
19170 *
19171 * @param {string} value
19172 * @param {boolean} silent
19173 */
19174 addItem: function(value, silent) {
19175 var events = silent ? [] : ['change'];
19176
19177 debounce_events(this, events, function() {
19178 var $item, $option, $options;
19179 var self = this;
19180 var inputMode = self.settings.mode;
19181 var i, active, value_next, wasFull;
19182 value = hash_key(value);
19183
19184 if (self.items.indexOf(value) !== -1) {
19185 if (inputMode === 'single') self.close();
19186 return;
19187 }
19188
19189 if (!self.options.hasOwnProperty(value)) return;
19190 if (inputMode === 'single') self.clear(silent);
19191 if (inputMode === 'multi' && self.isFull()) return;
19192
19193 $item = $(self.render('item', self.options[value]));
19194 wasFull = self.isFull();
19195 self.items.splice(self.caretPos, 0, value);
19196 self.insertAtCaret($item);
19197 if (!self.isPending || (!wasFull && self.isFull())) {
19198 self.refreshState();
19199 }
19200
19201 if (self.isSetup) {
19202 $options = self.$dropdown_content.find('[data-selectable]');
19203
19204 // update menu / remove the option (if this is not one item being added as part of series)
19205 if (!self.isPending) {
19206 $option = self.getOption(value);
19207 value_next = self.getAdjacentOption($option, 1).attr('data-value');
19208 self.refreshOptions(self.isFocused && inputMode !== 'single');
19209 if (value_next) {
19210 self.setActiveOption(self.getOption(value_next));
19211 }
19212 }
19213
19214 // hide the menu if the maximum number of items have been selected or no options are left
19215 if (!$options.length || self.isFull()) {
19216 self.close();
19217 } else {
19218 self.positionDropdown();
19219 }
19220
19221 self.updatePlaceholder();
19222 self.trigger('item_add', value, $item);
19223 self.updateOriginalInput({silent: silent});
19224 }
19225 });
19226 },
19227
19228 /**
19229 * Removes the selected item matching
19230 * the provided value.
19231 *
19232 * @param {string} value
19233 */
19234 removeItem: function(value, silent) {
19235 var self = this;
19236 var $item, i, idx;
19237
19238 $item = (value instanceof $) ? value : self.getItem(value);
19239 value = hash_key($item.attr('data-value'));
19240 i = self.items.indexOf(value);
19241
19242 if (i !== -1) {
19243 $item.remove();
19244 if ($item.hasClass('active')) {
19245 idx = self.$activeItems.indexOf($item[0]);
19246 self.$activeItems.splice(idx, 1);
19247 }
19248
19249 self.items.splice(i, 1);
19250 self.lastQuery = null;
19251 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
19252 self.removeOption(value, silent);
19253 }
19254
19255 if (i < self.caretPos) {
19256 self.setCaret(self.caretPos - 1);
19257 }
19258
19259 self.refreshState();
19260 self.updatePlaceholder();
19261 self.updateOriginalInput({silent: silent});
19262 self.positionDropdown();
19263 self.trigger('item_remove', value, $item);
19264 }
19265 },
19266
19267 /**
19268 * Invokes the `create` method provided in the
19269 * selectize options that should provide the data
19270 * for the new item, given the user input.
19271 *
19272 * Once this completes, it will be added
19273 * to the item list.
19274 *
19275 * @param {string} value
19276 * @param {boolean} [triggerDropdown]
19277 * @param {function} [callback]
19278 * @return {boolean}
19279 */
19280 createItem: function(input, triggerDropdown) {
19281 var self = this;
19282 var caret = self.caretPos;
19283 input = input || $.trim(self.$control_input.val() || '');
19284
19285 var callback = arguments[arguments.length - 1];
19286 if (typeof callback !== 'function') callback = function() {};
19287
19288 if (typeof triggerDropdown !== 'boolean') {
19289 triggerDropdown = true;
19290 }
19291
19292 if (!self.canCreate(input)) {
19293 callback();
19294 return false;
19295 }
19296
19297 self.lock();
19298
19299 var setup = (typeof self.settings.create === 'function') ? this.settings.create : function(input) {
19300 var data = {};
19301 data[self.settings.labelField] = input;
19302 data[self.settings.valueField] = input;
19303 return data;
19304 };
19305
19306 var create = once(function(data) {
19307 self.unlock();
19308
19309 if (!data || typeof data !== 'object') return callback();
19310 var value = hash_key(data[self.settings.valueField]);
19311 if (typeof value !== 'string') return callback();
19312
19313 self.setTextboxValue('');
19314 self.addOption(data);
19315 self.setCaret(caret);
19316 self.addItem(value);
19317 self.refreshOptions(triggerDropdown && self.settings.mode !== 'single');
19318 callback(data);
19319 });
19320
19321 var output = setup.apply(this, [input, create]);
19322 if (typeof output !== 'undefined') {
19323 create(output);
19324 }
19325
19326 return true;
19327 },
19328
19329 /**
19330 * Re-renders the selected item lists.
19331 */
19332 refreshItems: function() {
19333 this.lastQuery = null;
19334
19335 if (this.isSetup) {
19336 this.addItem(this.items);
19337 }
19338
19339 this.refreshState();
19340 this.updateOriginalInput();
19341 },
19342
19343 /**
19344 * Updates all state-dependent attributes
19345 * and CSS classes.
19346 */
19347 refreshState: function() {
19348 this.refreshValidityState();
19349 this.refreshClasses();
19350 },
19351
19352 /**
19353 * Update the `required` attribute of both input and control input.
19354 *
19355 * The `required` property needs to be activated on the control input
19356 * for the error to be displayed at the right place. `required` also
19357 * needs to be temporarily deactivated on the input since the input is
19358 * hidden and can't show errors.
19359 */
19360 refreshValidityState: function() {
19361 if (!this.isRequired) return false;
19362
19363 var invalid = !this.items.length;
19364
19365 this.isInvalid = invalid;
19366 this.$control_input.prop('required', invalid);
19367 this.$input.prop('required', !invalid);
19368 },
19369
19370 /**
19371 * Updates all state-dependent CSS classes.
19372 */
19373 refreshClasses: function() {
19374 var self = this;
19375 var isFull = self.isFull();
19376 var isLocked = self.isLocked;
19377
19378 self.$wrapper
19379 .toggleClass('rtl', self.rtl);
19380
19381 self.$control
19382 .toggleClass('focus', self.isFocused)
19383 .toggleClass('disabled', self.isDisabled)
19384 .toggleClass('required', self.isRequired)
19385 .toggleClass('invalid', self.isInvalid)
19386 .toggleClass('locked', isLocked)
19387 .toggleClass('full', isFull).toggleClass('not-full', !isFull)
19388 .toggleClass('input-active', self.isFocused && !self.isInputHidden)
19389 .toggleClass('dropdown-active', self.isOpen)
19390 .toggleClass('has-options', !$.isEmptyObject(self.options))
19391 .toggleClass('has-items', self.items.length > 0);
19392
19393 self.$control_input.data('grow', !isFull && !isLocked);
19394 },
19395
19396 /**
19397 * Determines whether or not more items can be added
19398 * to the control without exceeding the user-defined maximum.
19399 *
19400 * @returns {boolean}
19401 */
19402 isFull: function() {
19403 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
19404 },
19405
19406 /**
19407 * Refreshes the original <select> or <input>
19408 * element to reflect the current state.
19409 */
19410 updateOriginalInput: function(opts) {
19411 var i, n, options, label, self = this;
19412 opts = opts || {};
19413
19414 if (self.tagType === TAG_SELECT) {
19415 options = [];
19416 for (i = 0, n = self.items.length; i < n; i++) {
19417 label = self.options[self.items[i]][self.settings.labelField] || '';
19418 options.push('<option value="' + escape_html(self.items[i]) + '" selected="selected">' + escape_html(label) + '</option>');
19419 }
19420 if (!options.length && !this.$input.attr('multiple')) {
19421 options.push('<option value="" selected="selected"></option>');
19422 }
19423 self.$input.html(options.join(''));
19424 } else {
19425 self.$input.val(self.getValue());
19426 self.$input.attr('value',self.$input.val());
19427 }
19428
19429 if (self.isSetup) {
19430 if (!opts.silent) {
19431 self.trigger('change', self.$input.val());
19432 }
19433 }
19434 },
19435
19436 /**
19437 * Shows/hide the input placeholder depending
19438 * on if there items in the list already.
19439 */
19440 updatePlaceholder: function() {
19441 if (!this.settings.placeholder) return;
19442 var $input = this.$control_input;
19443
19444 if (this.items.length) {
19445 $input.removeAttr('placeholder');
19446 } else {
19447 $input.attr('placeholder', this.settings.placeholder);
19448 }
19449 $input.triggerHandler('update', {force: true});
19450 },
19451
19452 /**
19453 * Shows the autocomplete dropdown containing
19454 * the available options.
19455 */
19456 open: function() {
19457 var self = this;
19458
19459 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull())) return;
19460 self.focus();
19461 self.isOpen = true;
19462 self.refreshState();
19463 self.$dropdown.css({visibility: 'hidden', display: 'block'});
19464 self.positionDropdown();
19465 self.$dropdown.css({visibility: 'visible'});
19466 self.trigger('dropdown_open', self.$dropdown);
19467 },
19468
19469 /**
19470 * Closes the autocomplete dropdown menu.
19471 */
19472 close: function() {
19473 var self = this;
19474 var trigger = self.isOpen;
19475
19476 if (self.settings.mode === 'single' && self.items.length) {
19477 self.hideInput();
19478 self.$control_input.blur(); // close keyboard on iOS
19479 }
19480
19481 self.isOpen = false;
19482 self.$dropdown.hide();
19483 self.setActiveOption(null);
19484 self.refreshState();
19485
19486 if (trigger) self.trigger('dropdown_close', self.$dropdown);
19487 },
19488
19489 /**
19490 * Calculates and applies the appropriate
19491 * position of the dropdown.
19492 */
19493 positionDropdown: function() {
19494 var $control = this.$control;
19495 var offset = this.settings.dropdownParent === 'body' ? $control.offset() : $control.position();
19496 offset.top += $control.outerHeight(true);
19497
19498 this.$dropdown.css({
19499 width : $control.outerWidth(),
19500 top : offset.top,
19501 left : offset.left
19502 });
19503 },
19504
19505 /**
19506 * Resets / clears all selected items
19507 * from the control.
19508 *
19509 * @param {boolean} silent
19510 */
19511 clear: function(silent) {
19512 var self = this;
19513
19514 if (!self.items.length) return;
19515 self.$control.children(':not(input)').remove();
19516 self.items = [];
19517 self.lastQuery = null;
19518 self.setCaret(0);
19519 self.setActiveItem(null);
19520 self.updatePlaceholder();
19521 self.updateOriginalInput({silent: silent});
19522 self.refreshState();
19523 self.showInput();
19524 self.trigger('clear');
19525 },
19526
19527 /**
19528 * A helper method for inserting an element
19529 * at the current caret position.
19530 *
19531 * @param {object} $el
19532 */
19533 insertAtCaret: function($el) {
19534 var caret = Math.min(this.caretPos, this.items.length);
19535 if (caret === 0) {
19536 this.$control.prepend($el);
19537 } else {
19538 $(this.$control[0].childNodes[caret]).before($el);
19539 }
19540 this.setCaret(caret + 1);
19541 },
19542
19543 /**
19544 * Removes the current selected item(s).
19545 *
19546 * @param {object} e (optional)
19547 * @returns {boolean}
19548 */
19549 deleteSelection: function(e) {
19550 var i, n, direction, selection, values, caret, option_select, $option_select, $tail;
19551 var self = this;
19552
19553 direction = (e && e.keyCode === KEY_BACKSPACE) ? -1 : 1;
19554 selection = getSelection(self.$control_input[0]);
19555
19556 if (self.$activeOption && !self.settings.hideSelected) {
19557 option_select = self.getAdjacentOption(self.$activeOption, -1).attr('data-value');
19558 }
19559
19560 // determine items that will be removed
19561 values = [];
19562
19563 if (self.$activeItems.length) {
19564 $tail = self.$control.children('.active:' + (direction > 0 ? 'last' : 'first'));
19565 caret = self.$control.children(':not(input)').index($tail);
19566 if (direction > 0) { caret++; }
19567
19568 for (i = 0, n = self.$activeItems.length; i < n; i++) {
19569 values.push($(self.$activeItems[i]).attr('data-value'));
19570 }
19571 if (e) {
19572 e.preventDefault();
19573 e.stopPropagation();
19574 }
19575 } else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
19576 if (direction < 0 && selection.start === 0 && selection.length === 0) {
19577 values.push(self.items[self.caretPos - 1]);
19578 } else if (direction > 0 && selection.start === self.$control_input.val().length) {
19579 values.push(self.items[self.caretPos]);
19580 }
19581 }
19582
19583 // allow the callback to abort
19584 if (!values.length || (typeof self.settings.onDelete === 'function' && self.settings.onDelete.apply(self, [values]) === false)) {
19585 return false;
19586 }
19587
19588 // perform removal
19589 if (typeof caret !== 'undefined') {
19590 self.setCaret(caret);
19591 }
19592 while (values.length) {
19593 self.removeItem(values.pop());
19594 }
19595
19596 self.showInput();
19597 self.positionDropdown();
19598 self.refreshOptions(true);
19599
19600 // select previous option
19601 if (option_select) {
19602 $option_select = self.getOption(option_select);
19603 if ($option_select.length) {
19604 self.setActiveOption($option_select);
19605 }
19606 }
19607
19608 return true;
19609 },
19610
19611 /**
19612 * Selects the previous / next item (depending
19613 * on the `direction` argument).
19614 *
19615 * > 0 - right
19616 * < 0 - left
19617 *
19618 * @param {int} direction
19619 * @param {object} e (optional)
19620 */
19621 advanceSelection: function(direction, e) {
19622 var tail, selection, idx, valueLength, cursorAtEdge, $tail;
19623 var self = this;
19624
19625 if (direction === 0) return;
19626 if (self.rtl) direction *= -1;
19627
19628 tail = direction > 0 ? 'last' : 'first';
19629 selection = getSelection(self.$control_input[0]);
19630
19631 if (self.isFocused && !self.isInputHidden) {
19632 valueLength = self.$control_input.val().length;
19633 cursorAtEdge = direction < 0
19634 ? selection.start === 0 && selection.length === 0
19635 : selection.start === valueLength;
19636
19637 if (cursorAtEdge && !valueLength) {
19638 self.advanceCaret(direction, e);
19639 }
19640 } else {
19641 $tail = self.$control.children('.active:' + tail);
19642 if ($tail.length) {
19643 idx = self.$control.children(':not(input)').index($tail);
19644 self.setActiveItem(null);
19645 self.setCaret(direction > 0 ? idx + 1 : idx);
19646 }
19647 }
19648 },
19649
19650 /**
19651 * Moves the caret left / right.
19652 *
19653 * @param {int} direction
19654 * @param {object} e (optional)
19655 */
19656 advanceCaret: function(direction, e) {
19657 var self = this, fn, $adj;
19658
19659 if (direction === 0) return;
19660
19661 fn = direction > 0 ? 'next' : 'prev';
19662 if (self.isShiftDown) {
19663 $adj = self.$control_input[fn]();
19664 if ($adj.length) {
19665 self.hideInput();
19666 self.setActiveItem($adj);
19667 e && e.preventDefault();
19668 }
19669 } else {
19670 self.setCaret(self.caretPos + direction);
19671 }
19672 },
19673
19674 /**
19675 * Moves the caret to the specified index.
19676 *
19677 * @param {int} i
19678 */
19679 setCaret: function(i) {
19680 var self = this;
19681
19682 if (self.settings.mode === 'single') {
19683 i = self.items.length;
19684 } else {
19685 i = Math.max(0, Math.min(self.items.length, i));
19686 }
19687
19688 if(!self.isPending) {
19689 // the input must be moved by leaving it in place and moving the
19690 // siblings, due to the fact that focus cannot be restored once lost
19691 // on mobile webkit devices
19692 var j, n, fn, $children, $child;
19693 $children = self.$control.children(':not(input)');
19694 for (j = 0, n = $children.length; j < n; j++) {
19695 $child = $($children[j]).detach();
19696 if (j < i) {
19697 self.$control_input.before($child);
19698 } else {
19699 self.$control.append($child);
19700 }
19701 }
19702 }
19703
19704 self.caretPos = i;
19705 },
19706
19707 /**
19708 * Disables user input on the control. Used while
19709 * items are being asynchronously created.
19710 */
19711 lock: function() {
19712 this.close();
19713 this.isLocked = true;
19714 this.refreshState();
19715 },
19716
19717 /**
19718 * Re-enables user input on the control.
19719 */
19720 unlock: function() {
19721 this.isLocked = false;
19722 this.refreshState();
19723 },
19724
19725 /**
19726 * Disables user input on the control completely.
19727 * While disabled, it cannot receive focus.
19728 */
19729 disable: function() {
19730 var self = this;
19731 self.$input.prop('disabled', true);
19732 self.$control_input.prop('disabled', true).prop('tabindex', -1);
19733 self.isDisabled = true;
19734 self.lock();
19735 },
19736
19737 /**
19738 * Enables the control so that it can respond
19739 * to focus and user input.
19740 */
19741 enable: function() {
19742 var self = this;
19743 self.$input.prop('disabled', false);
19744 self.$control_input.prop('disabled', false).prop('tabindex', self.tabIndex);
19745 self.isDisabled = false;
19746 self.unlock();
19747 },
19748
19749 /**
19750 * Completely destroys the control and
19751 * unbinds all event listeners so that it can
19752 * be garbage collected.
19753 */
19754 destroy: function() {
19755 var self = this;
19756 var eventNS = self.eventNS;
19757 var revertSettings = self.revertSettings;
19758
19759 self.trigger('destroy');
19760 self.off();
19761 self.$wrapper.remove();
19762 self.$dropdown.remove();
19763
19764 self.$input
19765 .html('')
19766 .append(revertSettings.$children)
19767 .removeAttr('tabindex')
19768 .removeClass('selectized')
19769 .attr({tabindex: revertSettings.tabindex})
19770 .show();
19771
19772 self.$control_input.removeData('grow');
19773 self.$input.removeData('selectize');
19774
19775 $(window).off(eventNS);
19776 $(document).off(eventNS);
19777 $(document.body).off(eventNS);
19778
19779 delete self.$input[0].selectize;
19780 },
19781
19782 /**
19783 * A helper method for rendering "item" and
19784 * "option" templates, given the data.
19785 *
19786 * @param {string} templateName
19787 * @param {object} data
19788 * @returns {string}
19789 */
19790 render: function(templateName, data) {
19791 var value, id, label;
19792 var html = '';
19793 var cache = false;
19794 var self = this;
19795 var regex_tag = /^[\t \r\n]*<([a-z][a-z0-9\-_]*(?:\:[a-z][a-z0-9\-_]*)?)/i;
19796
19797 if (templateName === 'option' || templateName === 'item') {
19798 value = hash_key(data[self.settings.valueField]);
19799 cache = !!value;
19800 }
19801
19802 // pull markup from cache if it exists
19803 if (cache) {
19804 if (!isset(self.renderCache[templateName])) {
19805 self.renderCache[templateName] = {};
19806 }
19807 if (self.renderCache[templateName].hasOwnProperty(value)) {
19808 return self.renderCache[templateName][value];
19809 }
19810 }
19811
19812 // render markup
19813 html = $(self.settings.render[templateName].apply(this, [data, escape_html]));
19814
19815 // add mandatory attributes
19816 if (templateName === 'option' || templateName === 'option_create') {
19817 html.attr('data-selectable', '');
19818 }
19819 else if (templateName === 'optgroup') {
19820 id = data[self.settings.optgroupValueField] || '';
19821 html.attr('data-group', id);
19822 }
19823 if (templateName === 'option' || templateName === 'item') {
19824 html.attr('data-value', value || '');
19825 }
19826
19827 // update cache
19828 if (cache) {
19829 self.renderCache[templateName][value] = html[0];
19830 }
19831
19832 return html[0];
19833 },
19834
19835 /**
19836 * Clears the render cache for a template. If
19837 * no template is given, clears all render
19838 * caches.
19839 *
19840 * @param {string} templateName
19841 */
19842 clearCache: function(templateName) {
19843 var self = this;
19844 if (typeof templateName === 'undefined') {
19845 self.renderCache = {};
19846 } else {
19847 delete self.renderCache[templateName];
19848 }
19849 },
19850
19851 /**
19852 * Determines whether or not to display the
19853 * create item prompt, given a user input.
19854 *
19855 * @param {string} input
19856 * @return {boolean}
19857 */
19858 canCreate: function(input) {
19859 var self = this;
19860 if (!self.settings.create) return false;
19861 var filter = self.settings.createFilter;
19862 return input.length
19863 && (typeof filter !== 'function' || filter.apply(self, [input]))
19864 && (typeof filter !== 'string' || new RegExp(filter).test(input))
19865 && (!(filter instanceof RegExp) || filter.test(input));
19866 }
19867
19868 });
19869
19870
19871 Selectize.count = 0;
19872 Selectize.defaults = {
19873 options: [],
19874 optgroups: [],
19875
19876 plugins: [],
19877 delimiter: ',',
19878 splitOn: null, // regexp or string for splitting up values from a paste command
19879 persist: true,
19880 diacritics: true,
19881 create: false,
19882 createOnBlur: false,
19883 createFilter: null,
19884 highlight: true,
19885 openOnFocus: true,
19886 maxOptions: 1000,
19887 maxItems: null,
19888 hideSelected: null,
19889 addPrecedence: false,
19890 selectOnTab: false,
19891 preload: false,
19892 allowEmptyOption: false,
19893 closeAfterSelect: false,
19894
19895 scrollDuration: 60,
19896 loadThrottle: 300,
19897 loadingClass: 'loading',
19898
19899 dataAttr: 'data-data',
19900 optgroupField: 'optgroup',
19901 valueField: 'value',
19902 labelField: 'text',
19903 optgroupLabelField: 'label',
19904 optgroupValueField: 'value',
19905 lockOptgroupOrder: false,
19906
19907 sortField: '$order',
19908 searchField: ['text'],
19909 searchConjunction: 'and',
19910
19911 mode: null,
19912 wrapperClass: 'selectize-control',
19913 inputClass: 'selectize-input',
19914 dropdownClass: 'selectize-dropdown',
19915 dropdownContentClass: 'selectize-dropdown-content',
19916
19917 dropdownParent: null,
19918
19919 copyClassesToDropdown: true,
19920
19921 /*
19922 load : null, // function(query, callback) { ... }
19923 score : null, // function(search) { ... }
19924 onInitialize : null, // function() { ... }
19925 onChange : null, // function(value) { ... }
19926 onItemAdd : null, // function(value, $item) { ... }
19927 onItemRemove : null, // function(value) { ... }
19928 onClear : null, // function() { ... }
19929 onOptionAdd : null, // function(value, data) { ... }
19930 onOptionRemove : null, // function(value) { ... }
19931 onOptionClear : null, // function() { ... }
19932 onOptionGroupAdd : null, // function(id, data) { ... }
19933 onOptionGroupRemove : null, // function(id) { ... }
19934 onOptionGroupClear : null, // function() { ... }
19935 onDropdownOpen : null, // function($dropdown) { ... }
19936 onDropdownClose : null, // function($dropdown) { ... }
19937 onType : null, // function(str) { ... }
19938 onDelete : null, // function(values) { ... }
19939 */
19940
19941 render: {
19942 /*
19943 item: null,
19944 optgroup: null,
19945 optgroup_header: null,
19946 option: null,
19947 option_create: null
19948 */
19949 }
19950 };
19951
19952
19953 $.fn.selectize = function(settings_user) {
19954 var defaults = $.fn.selectize.defaults;
19955 var settings = $.extend({}, defaults, settings_user);
19956 var attr_data = settings.dataAttr;
19957 var field_label = settings.labelField;
19958 var field_value = settings.valueField;
19959 var field_optgroup = settings.optgroupField;
19960 var field_optgroup_label = settings.optgroupLabelField;
19961 var field_optgroup_value = settings.optgroupValueField;
19962
19963 /**
19964 * Initializes selectize from a <input type="text"> element.
19965 *
19966 * @param {object} $input
19967 * @param {object} settings_element
19968 */
19969 var init_textbox = function($input, settings_element) {
19970 var i, n, values, option;
19971
19972 var data_raw = $input.attr(attr_data);
19973
19974 if (!data_raw) {
19975 var value = $.trim($input.val() || '');
19976 if (!settings.allowEmptyOption && !value.length) return;
19977 values = value.split(settings.delimiter);
19978 for (i = 0, n = values.length; i < n; i++) {
19979 option = {};
19980 option[field_label] = values[i];
19981 option[field_value] = values[i];
19982 settings_element.options.push(option);
19983 }
19984 settings_element.items = values;
19985 } else {
19986 settings_element.options = JSON.parse(data_raw);
19987 for (i = 0, n = settings_element.options.length; i < n; i++) {
19988 settings_element.items.push(settings_element.options[i][field_value]);
19989 }
19990 }
19991 };
19992
19993 /**
19994 * Initializes selectize from a <select> element.
19995 *
19996 * @param {object} $input
19997 * @param {object} settings_element
19998 */
19999 var init_select = function($input, settings_element) {
20000 var i, n, tagName, $children, order = 0;
20001 var options = settings_element.options;
20002 var optionsMap = {};
20003
20004 var readData = function($el) {
20005 var data = attr_data && $el.attr(attr_data);
20006 if (typeof data === 'string' && data.length) {
20007 return JSON.parse(data);
20008 }
20009 return null;
20010 };
20011
20012 var addOption = function($option, group) {
20013 $option = $($option);
20014
20015 var value = hash_key($option.val());
20016 if (!value && !settings.allowEmptyOption) return;
20017
20018 // if the option already exists, it's probably been
20019 // duplicated in another optgroup. in this case, push
20020 // the current group to the "optgroup" property on the
20021 // existing option so that it's rendered in both places.
20022 if (optionsMap.hasOwnProperty(value)) {
20023 if (group) {
20024 var arr = optionsMap[value][field_optgroup];
20025 if (!arr) {
20026 optionsMap[value][field_optgroup] = group;
20027 } else if (!$.isArray(arr)) {
20028 optionsMap[value][field_optgroup] = [arr, group];
20029 } else {
20030 arr.push(group);
20031 }
20032 }
20033 return;
20034 }
20035
20036 var option = readData($option) || {};
20037 option[field_label] = option[field_label] || $option.text();
20038 option[field_value] = option[field_value] || value;
20039 option[field_optgroup] = option[field_optgroup] || group;
20040
20041 optionsMap[value] = option;
20042 options.push(option);
20043
20044 if ($option.is(':selected')) {
20045 settings_element.items.push(value);
20046 }
20047 };
20048
20049 var addGroup = function($optgroup) {
20050 var i, n, id, optgroup, $options;
20051
20052 $optgroup = $($optgroup);
20053 id = $optgroup.attr('label');
20054
20055 if (id) {
20056 optgroup = readData($optgroup) || {};
20057 optgroup[field_optgroup_label] = id;
20058 optgroup[field_optgroup_value] = id;
20059 settings_element.optgroups.push(optgroup);
20060 }
20061
20062 $options = $('option', $optgroup);
20063 for (i = 0, n = $options.length; i < n; i++) {
20064 addOption($options[i], id);
20065 }
20066 };
20067
20068 settings_element.maxItems = $input.attr('multiple') ? null : 1;
20069
20070 $children = $input.children();
20071 for (i = 0, n = $children.length; i < n; i++) {
20072 tagName = $children[i].tagName.toLowerCase();
20073 if (tagName === 'optgroup') {
20074 addGroup($children[i]);
20075 } else if (tagName === 'option') {
20076 addOption($children[i]);
20077 }
20078 }
20079 };
20080
20081 return this.each(function() {
20082 if (this.selectize) return;
20083
20084 var instance;
20085 var $input = $(this);
20086 var tag_name = this.tagName.toLowerCase();
20087 var placeholder = $input.attr('placeholder') || $input.attr('data-placeholder');
20088 if (!placeholder && !settings.allowEmptyOption) {
20089 placeholder = $input.children('option[value=""]').text();
20090 }
20091
20092 var settings_element = {
20093 'placeholder' : placeholder,
20094 'options' : [],
20095 'optgroups' : [],
20096 'items' : []
20097 };
20098
20099 if (tag_name === 'select') {
20100 init_select($input, settings_element);
20101 } else {
20102 init_textbox($input, settings_element);
20103 }
20104
20105 instance = new Selectize($input, $.extend(true, {}, defaults, settings_element, settings_user));
20106 });
20107 };
20108
20109 $.fn.selectize.defaults = Selectize.defaults;
20110 $.fn.selectize.support = {
20111 validity: SUPPORTS_VALIDITY_API
20112 };
20113
20114
20115 Selectize.define('drag_drop', function(options) {
20116 if (!$.fn.sortable) throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');
20117 if (this.settings.mode !== 'multi') return;
20118 var self = this;
20119
20120 self.lock = (function() {
20121 var original = self.lock;
20122 return function() {
20123 var sortable = self.$control.data('sortable');
20124 if (sortable) sortable.disable();
20125 return original.apply(self, arguments);
20126 };
20127 })();
20128
20129 self.unlock = (function() {
20130 var original = self.unlock;
20131 return function() {
20132 var sortable = self.$control.data('sortable');
20133 if (sortable) sortable.enable();
20134 return original.apply(self, arguments);
20135 };
20136 })();
20137
20138 self.setup = (function() {
20139 var original = self.setup;
20140 return function() {
20141 original.apply(this, arguments);
20142
20143 var $control = self.$control.sortable({
20144 items: '[data-value]',
20145 forcePlaceholderSize: true,
20146 disabled: self.isLocked,
20147 start: function(e, ui) {
20148 ui.placeholder.css('width', ui.helper.css('width'));
20149 $control.css({overflow: 'visible'});
20150 },
20151 stop: function() {
20152 $control.css({overflow: 'hidden'});
20153 var active = self.$activeItems ? self.$activeItems.slice() : null;
20154 var values = [];
20155 $control.children('[data-value]').each(function() {
20156 values.push($(this).attr('data-value'));
20157 });
20158 self.setValue(values);
20159 self.setActiveItem(active);
20160 }
20161 });
20162 };
20163 })();
20164
20165 });
20166
20167 Selectize.define('dropdown_header', function(options) {
20168 var self = this;
20169
20170 options = $.extend({
20171 title : 'Untitled',
20172 headerClass : 'selectize-dropdown-header',
20173 titleRowClass : 'selectize-dropdown-header-title',
20174 labelClass : 'selectize-dropdown-header-label',
20175 closeClass : 'selectize-dropdown-header-close',
20176
20177 html: function(data) {
20178 return (
20179 '<div class="' + data.headerClass + '">' +
20180 '<div class="' + data.titleRowClass + '">' +
20181 '<span class="' + data.labelClass + '">' + data.title + '</span>' +
20182 '<a href="javascript:void(0)" class="' + data.closeClass + '">&times;</a>' +
20183 '</div>' +
20184 '</div>'
20185 );
20186 }
20187 }, options);
20188
20189 self.setup = (function() {
20190 var original = self.setup;
20191 return function() {
20192 original.apply(self, arguments);
20193 self.$dropdown_header = $(options.html(options));
20194 self.$dropdown.prepend(self.$dropdown_header);
20195 };
20196 })();
20197
20198 });
20199
20200 Selectize.define('optgroup_columns', function(options) {
20201 var self = this;
20202
20203 options = $.extend({
20204 equalizeWidth : true,
20205 equalizeHeight : true
20206 }, options);
20207
20208 this.getAdjacentOption = function($option, direction) {
20209 var $options = $option.closest('[data-group]').find('[data-selectable]');
20210 var index = $options.index($option) + direction;
20211
20212 return index >= 0 && index < $options.length ? $options.eq(index) : $();
20213 };
20214
20215 this.onKeyDown = (function() {
20216 var original = self.onKeyDown;
20217 return function(e) {
20218 var index, $option, $options, $optgroup;
20219
20220 if (this.isOpen && (e.keyCode === KEY_LEFT || e.keyCode === KEY_RIGHT)) {
20221 self.ignoreHover = true;
20222 $optgroup = this.$activeOption.closest('[data-group]');
20223 index = $optgroup.find('[data-selectable]').index(this.$activeOption);
20224
20225 if(e.keyCode === KEY_LEFT) {
20226 $optgroup = $optgroup.prev('[data-group]');
20227 } else {
20228 $optgroup = $optgroup.next('[data-group]');
20229 }
20230
20231 $options = $optgroup.find('[data-selectable]');
20232 $option = $options.eq(Math.min($options.length - 1, index));
20233 if ($option.length) {
20234 this.setActiveOption($option);
20235 }
20236 return;
20237 }
20238
20239 return original.apply(this, arguments);
20240 };
20241 })();
20242
20243 var getScrollbarWidth = function() {
20244 var div;
20245 var width = getScrollbarWidth.width;
20246 var doc = document;
20247
20248 if (typeof width === 'undefined') {
20249 div = doc.createElement('div');
20250 div.innerHTML = '<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>';
20251 div = div.firstChild;
20252 doc.body.appendChild(div);
20253 width = getScrollbarWidth.width = div.offsetWidth - div.clientWidth;
20254 doc.body.removeChild(div);
20255 }
20256 return width;
20257 };
20258
20259 var equalizeSizes = function() {
20260 var i, n, height_max, width, width_last, width_parent, $optgroups;
20261
20262 $optgroups = $('[data-group]', self.$dropdown_content);
20263 n = $optgroups.length;
20264 if (!n || !self.$dropdown_content.width()) return;
20265
20266 if (options.equalizeHeight) {
20267 height_max = 0;
20268 for (i = 0; i < n; i++) {
20269 height_max = Math.max(height_max, $optgroups.eq(i).height());
20270 }
20271 $optgroups.css({height: height_max});
20272 }
20273
20274 if (options.equalizeWidth) {
20275 width_parent = self.$dropdown_content.innerWidth() - getScrollbarWidth();
20276 width = Math.round(width_parent / n);
20277 $optgroups.css({width: width});
20278 if (n > 1) {
20279 width_last = width_parent - width * (n - 1);
20280 $optgroups.eq(n - 1).css({width: width_last});
20281 }
20282 }
20283 };
20284
20285 if (options.equalizeHeight || options.equalizeWidth) {
20286 hook.after(this, 'positionDropdown', equalizeSizes);
20287 hook.after(this, 'refreshOptions', equalizeSizes);
20288 }
20289
20290
20291 });
20292
20293 Selectize.define('remove_button', function(options) {
20294 options = $.extend({
20295 label : '&times;',
20296 title : 'Remove',
20297 className : 'remove',
20298 append : true
20299 }, options);
20300
20301 var singleClose = function(thisRef, options) {
20302
20303 options.className = 'remove-single';
20304
20305 var self = thisRef;
20306 var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
20307
20308 /**
20309 * Appends an element as a child (with raw HTML).
20310 *
20311 * @param {string} html_container
20312 * @param {string} html_element
20313 * @return {string}
20314 */
20315 var append = function(html_container, html_element) {
20316 return html_container + html_element;
20317 };
20318
20319 thisRef.setup = (function() {
20320 var original = self.setup;
20321 return function() {
20322 // override the item rendering method to add the button to each
20323 if (options.append) {
20324 var id = $(self.$input.context).attr('id');
20325 var selectizer = $('#'+id);
20326
20327 var render_item = self.settings.render.item;
20328 self.settings.render.item = function(data) {
20329 return append(render_item.apply(thisRef, arguments), html);
20330 };
20331 }
20332
20333 original.apply(thisRef, arguments);
20334
20335 // add event listener
20336 thisRef.$control.on('click', '.' + options.className, function(e) {
20337 e.preventDefault();
20338 if (self.isLocked) return;
20339
20340 self.clear();
20341 });
20342
20343 };
20344 })();
20345 };
20346
20347 var multiClose = function(thisRef, options) {
20348
20349 var self = thisRef;
20350 var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
20351
20352 /**
20353 * Appends an element as a child (with raw HTML).
20354 *
20355 * @param {string} html_container
20356 * @param {string} html_element
20357 * @return {string}
20358 */
20359 var append = function(html_container, html_element) {
20360 var pos = html_container.search(/(<\/[^>]+>\s*)$/);
20361 return html_container.substring(0, pos) + html_element + html_container.substring(pos);
20362 };
20363
20364 thisRef.setup = (function() {
20365 var original = self.setup;
20366 return function() {
20367 // override the item rendering method to add the button to each
20368 if (options.append) {
20369 var render_item = self.settings.render.item;
20370 self.settings.render.item = function(data) {
20371 return append(render_item.apply(thisRef, arguments), html);
20372 };
20373 }
20374
20375 original.apply(thisRef, arguments);
20376
20377 // add event listener
20378 thisRef.$control.on('click', '.' + options.className, function(e) {
20379 e.preventDefault();
20380 if (self.isLocked) return;
20381
20382 var $item = $(e.currentTarget).parent();
20383 self.setActiveItem($item);
20384 if (self.deleteSelection()) {
20385 self.setCaret(self.items.length);
20386 }
20387 });
20388
20389 };
20390 })();
20391 };
20392
20393 if (this.settings.mode === 'single') {
20394 singleClose(this, options);
20395 return;
20396 } else {
20397 multiClose(this, options);
20398 }
20399 });
20400
20401
20402 Selectize.define('restore_on_backspace', function(options) {
20403 var self = this;
20404
20405 options.text = options.text || function(option) {
20406 return option[this.settings.labelField];
20407 };
20408
20409 this.onKeyDown = (function() {
20410 var original = self.onKeyDown;
20411 return function(e) {
20412 var index, option;
20413 if (e.keyCode === KEY_BACKSPACE && this.$control_input.val() === '' && !this.$activeItems.length) {
20414 index = this.caretPos - 1;
20415 if (index >= 0 && index < this.items.length) {
20416 option = this.options[this.items[index]];
20417 if (this.deleteSelection(e)) {
20418 this.setTextboxValue(options.text.apply(this, [option]));
20419 this.refreshOptions(true);
20420 }
20421 e.preventDefault();
20422 return;
20423 }
20424 }
20425 return original.apply(this, arguments);
20426 };
20427 })();
20428 });
20429
20430
20431 return Selectize;
20432 }));
20433 /* assets/wpuf/vendor/toastr/toastr.js */
20434 /*
20435 * Toastr
20436 * Copyright 2012-2015
20437 * Authors: John Papa, Hans Fjällemark, and Tim Ferrell.
20438 * All Rights Reserved.
20439 * Use, reproduction, distribution, and modification of this code is subject to the terms and
20440 * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
20441 *
20442 * ARIA Support: Greta Krafsig
20443 *
20444 * Project: https://github.com/CodeSeven/toastr
20445 */
20446 /* global define */
20447 (function (define) {
20448 define(['jquery'], function ($) {
20449 return (function () {
20450 var $container;
20451 var listener;
20452 var toastId = 0;
20453 var toastType = {
20454 error: 'error',
20455 info: 'info',
20456 success: 'success',
20457 warning: 'warning'
20458 };
20459
20460 var toastr = {
20461 clear: clear,
20462 remove: remove,
20463 error: error,
20464 getContainer: getContainer,
20465 info: info,
20466 options: {},
20467 subscribe: subscribe,
20468 success: success,
20469 version: '2.1.3',
20470 warning: warning
20471 };
20472
20473 var previousToast;
20474
20475 return toastr;
20476
20477 ////////////////
20478
20479 function error(message, title, optionsOverride) {
20480 return notify({
20481 type: toastType.error,
20482 iconClass: getOptions().iconClasses.error,
20483 message: message,
20484 optionsOverride: optionsOverride,
20485 title: title
20486 });
20487 }
20488
20489 function getContainer(options, create) {
20490 if (!options) { options = getOptions(); }
20491 $container = $('#' + options.containerId);
20492 if ($container.length) {
20493 return $container;
20494 }
20495 if (create) {
20496 $container = createContainer(options);
20497 }
20498 return $container;
20499 }
20500
20501 function info(message, title, optionsOverride) {
20502 return notify({
20503 type: toastType.info,
20504 iconClass: getOptions().iconClasses.info,
20505 message: message,
20506 optionsOverride: optionsOverride,
20507 title: title
20508 });
20509 }
20510
20511 function subscribe(callback) {
20512 listener = callback;
20513 }
20514
20515 function success(message, title, optionsOverride) {
20516 return notify({
20517 type: toastType.success,
20518 iconClass: getOptions().iconClasses.success,
20519 message: message,
20520 optionsOverride: optionsOverride,
20521 title: title
20522 });
20523 }
20524
20525 function warning(message, title, optionsOverride) {
20526 return notify({
20527 type: toastType.warning,
20528 iconClass: getOptions().iconClasses.warning,
20529 message: message,
20530 optionsOverride: optionsOverride,
20531 title: title
20532 });
20533 }
20534
20535 function clear($toastElement, clearOptions) {
20536 var options = getOptions();
20537 if (!$container) { getContainer(options); }
20538 if (!clearToast($toastElement, options, clearOptions)) {
20539 clearContainer(options);
20540 }
20541 }
20542
20543 function remove($toastElement) {
20544 var options = getOptions();
20545 if (!$container) { getContainer(options); }
20546 if ($toastElement && $(':focus', $toastElement).length === 0) {
20547 removeToast($toastElement);
20548 return;
20549 }
20550 if ($container.children().length) {
20551 $container.remove();
20552 }
20553 }
20554
20555 // internal functions
20556
20557 function clearContainer (options) {
20558 var toastsToClear = $container.children();
20559 for (var i = toastsToClear.length - 1; i >= 0; i--) {
20560 clearToast($(toastsToClear[i]), options);
20561 }
20562 }
20563
20564 function clearToast ($toastElement, options, clearOptions) {
20565 var force = clearOptions && clearOptions.force ? clearOptions.force : false;
20566 if ($toastElement && (force || $(':focus', $toastElement).length === 0)) {
20567 $toastElement[options.hideMethod]({
20568 duration: options.hideDuration,
20569 easing: options.hideEasing,
20570 complete: function () { removeToast($toastElement); }
20571 });
20572 return true;
20573 }
20574 return false;
20575 }
20576
20577 function createContainer(options) {
20578 $container = $('<div/>')
20579 .attr('id', options.containerId)
20580 .addClass(options.positionClass);
20581
20582 $container.appendTo($(options.target));
20583 return $container;
20584 }
20585
20586 function getDefaults() {
20587 return {
20588 tapToDismiss: true,
20589 toastClass: 'toast',
20590 containerId: 'toast-container',
20591 debug: false,
20592
20593 showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
20594 showDuration: 300,
20595 showEasing: 'swing', //swing and linear are built into jQuery
20596 onShown: undefined,
20597 hideMethod: 'fadeOut',
20598 hideDuration: 1000,
20599 hideEasing: 'swing',
20600 onHidden: undefined,
20601 closeMethod: false,
20602 closeDuration: false,
20603 closeEasing: false,
20604 closeOnHover: true,
20605
20606 extendedTimeOut: 1000,
20607 iconClasses: {
20608 error: 'toast-error',
20609 info: 'toast-info',
20610 success: 'toast-success',
20611 warning: 'toast-warning'
20612 },
20613 iconClass: 'toast-info',
20614 positionClass: 'toast-top-right',
20615 timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
20616 titleClass: 'toast-title',
20617 messageClass: 'toast-message',
20618 escapeHtml: false,
20619 target: 'body',
20620 closeHtml: '<button type="button">&times;</button>',
20621 closeClass: 'toast-close-button',
20622 newestOnTop: true,
20623 preventDuplicates: false,
20624 progressBar: false,
20625 progressClass: 'toast-progress',
20626 rtl: false
20627 };
20628 }
20629
20630 function publish(args) {
20631 if (!listener) { return; }
20632 listener(args);
20633 }
20634
20635 function notify(map) {
20636 var options = getOptions();
20637 var iconClass = map.iconClass || options.iconClass;
20638
20639 if (typeof (map.optionsOverride) !== 'undefined') {
20640 options = $.extend(options, map.optionsOverride);
20641 iconClass = map.optionsOverride.iconClass || iconClass;
20642 }
20643
20644 if (shouldExit(options, map)) { return; }
20645
20646 toastId++;
20647
20648 $container = getContainer(options, true);
20649
20650 var intervalId = null;
20651 var $toastElement = $('<div/>');
20652 var $titleElement = $('<div/>');
20653 var $messageElement = $('<div/>');
20654 var $progressElement = $('<div/>');
20655 var $closeElement = $(options.closeHtml);
20656 var progressBar = {
20657 intervalId: null,
20658 hideEta: null,
20659 maxHideTime: null
20660 };
20661 var response = {
20662 toastId: toastId,
20663 state: 'visible',
20664 startTime: new Date(),
20665 options: options,
20666 map: map
20667 };
20668
20669 personalizeToast();
20670
20671 displayToast();
20672
20673 handleEvents();
20674
20675 publish(response);
20676
20677 if (options.debug && console) {
20678 console.log(response);
20679 }
20680
20681 return $toastElement;
20682
20683 function escapeHtml(source) {
20684 if (source == null) {
20685 source = '';
20686 }
20687
20688 return source
20689 .replace(/&/g, '&amp;')
20690 .replace(/"/g, '&quot;')
20691 .replace(/'/g, '&#39;')
20692 .replace(/</g, '&lt;')
20693 .replace(/>/g, '&gt;');
20694 }
20695
20696 function personalizeToast() {
20697 setIcon();
20698 setTitle();
20699 setMessage();
20700 setCloseButton();
20701 setProgressBar();
20702 setRTL();
20703 setSequence();
20704 setAria();
20705 }
20706
20707 function setAria() {
20708 var ariaValue = '';
20709 switch (map.iconClass) {
20710 case 'toast-success':
20711 case 'toast-info':
20712 ariaValue = 'polite';
20713 break;
20714 default:
20715 ariaValue = 'assertive';
20716 }
20717 $toastElement.attr('aria-live', ariaValue);
20718 }
20719
20720 function handleEvents() {
20721 if (options.closeOnHover) {
20722 $toastElement.hover(stickAround, delayedHideToast);
20723 }
20724
20725 if (!options.onclick && options.tapToDismiss) {
20726 $toastElement.click(hideToast);
20727 }
20728
20729 if (options.closeButton && $closeElement) {
20730 $closeElement.click(function (event) {
20731 if (event.stopPropagation) {
20732 event.stopPropagation();
20733 } else if (event.cancelBubble !== undefined && event.cancelBubble !== true) {
20734 event.cancelBubble = true;
20735 }
20736
20737 if (options.onCloseClick) {
20738 options.onCloseClick(event);
20739 }
20740
20741 hideToast(true);
20742 });
20743 }
20744
20745 if (options.onclick) {
20746 $toastElement.click(function (event) {
20747 options.onclick(event);
20748 hideToast();
20749 });
20750 }
20751 }
20752
20753 function displayToast() {
20754 $toastElement.hide();
20755
20756 $toastElement[options.showMethod](
20757 {duration: options.showDuration, easing: options.showEasing, complete: options.onShown}
20758 );
20759
20760 if (options.timeOut > 0) {
20761 intervalId = setTimeout(hideToast, options.timeOut);
20762 progressBar.maxHideTime = parseFloat(options.timeOut);
20763 progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
20764 if (options.progressBar) {
20765 progressBar.intervalId = setInterval(updateProgress, 10);
20766 }
20767 }
20768 }
20769
20770 function setIcon() {
20771 if (map.iconClass) {
20772 $toastElement.addClass(options.toastClass).addClass(iconClass);
20773 }
20774 }
20775
20776 function setSequence() {
20777 if (options.newestOnTop) {
20778 $container.prepend($toastElement);
20779 } else {
20780 $container.append($toastElement);
20781 }
20782 }
20783
20784 function setTitle() {
20785 if (map.title) {
20786 var suffix = map.title;
20787 if (options.escapeHtml) {
20788 suffix = escapeHtml(map.title);
20789 }
20790 $titleElement.append(suffix).addClass(options.titleClass);
20791 $toastElement.append($titleElement);
20792 }
20793 }
20794
20795 function setMessage() {
20796 if (map.message) {
20797 var suffix = map.message;
20798 if (options.escapeHtml) {
20799 suffix = escapeHtml(map.message);
20800 }
20801 $messageElement.append(suffix).addClass(options.messageClass);
20802 $toastElement.append($messageElement);
20803 }
20804 }
20805
20806 function setCloseButton() {
20807 if (options.closeButton) {
20808 $closeElement.addClass(options.closeClass).attr('role', 'button');
20809 $toastElement.prepend($closeElement);
20810 }
20811 }
20812
20813 function setProgressBar() {
20814 if (options.progressBar) {
20815 $progressElement.addClass(options.progressClass);
20816 $toastElement.prepend($progressElement);
20817 }
20818 }
20819
20820 function setRTL() {
20821 if (options.rtl) {
20822 $toastElement.addClass('rtl');
20823 }
20824 }
20825
20826 function shouldExit(options, map) {
20827 if (options.preventDuplicates) {
20828 if (map.message === previousToast) {
20829 return true;
20830 } else {
20831 previousToast = map.message;
20832 }
20833 }
20834 return false;
20835 }
20836
20837 function hideToast(override) {
20838 var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
20839 var duration = override && options.closeDuration !== false ?
20840 options.closeDuration : options.hideDuration;
20841 var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
20842 if ($(':focus', $toastElement).length && !override) {
20843 return;
20844 }
20845 clearTimeout(progressBar.intervalId);
20846 return $toastElement[method]({
20847 duration: duration,
20848 easing: easing,
20849 complete: function () {
20850 removeToast($toastElement);
20851 clearTimeout(intervalId);
20852 if (options.onHidden && response.state !== 'hidden') {
20853 options.onHidden();
20854 }
20855 response.state = 'hidden';
20856 response.endTime = new Date();
20857 publish(response);
20858 }
20859 });
20860 }
20861
20862 function delayedHideToast() {
20863 if (options.timeOut > 0 || options.extendedTimeOut > 0) {
20864 intervalId = setTimeout(hideToast, options.extendedTimeOut);
20865 progressBar.maxHideTime = parseFloat(options.extendedTimeOut);
20866 progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
20867 }
20868 }
20869
20870 function stickAround() {
20871 clearTimeout(intervalId);
20872 progressBar.hideEta = 0;
20873 $toastElement.stop(true, true)[options.showMethod](
20874 {duration: options.showDuration, easing: options.showEasing}
20875 );
20876 }
20877
20878 function updateProgress() {
20879 var percentage = ((progressBar.hideEta - (new Date().getTime())) / progressBar.maxHideTime) * 100;
20880 $progressElement.width(percentage + '%');
20881 }
20882 }
20883
20884 function getOptions() {
20885 return $.extend({}, getDefaults(), toastr.options);
20886 }
20887
20888 function removeToast($toastElement) {
20889 if (!$container) { $container = getContainer(); }
20890 if ($toastElement.is(':visible')) {
20891 return;
20892 }
20893 $toastElement.remove();
20894 $toastElement = null;
20895 if ($container.children().length === 0) {
20896 $container.remove();
20897 previousToast = undefined;
20898 }
20899 }
20900
20901 })();
20902 });
20903 }(typeof define === 'function' && define.amd ? define : function (deps, factory) {
20904 if (typeof module !== 'undefined' && module.exports) { //Node
20905 module.exports = factory(require('jquery'));
20906 } else {
20907 window.toastr = factory(window.jQuery);
20908 }
20909 }));
20910
20911 /* assets/wpuf/vendor/clipboard/clipboard.js */
20912 /*!
20913 * clipboard.js v1.6.0
20914 * https://zenorocha.github.io/clipboard.js
20915 *
20916 * Licensed MIT © Zeno Rocha
20917 */
20918 (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){
20919 var DOCUMENT_NODE_TYPE = 9;
20920
20921 /**
20922 * A polyfill for Element.matches()
20923 */
20924 if (Element && !Element.prototype.matches) {
20925 var proto = Element.prototype;
20926
20927 proto.matches = proto.matchesSelector ||
20928 proto.mozMatchesSelector ||
20929 proto.msMatchesSelector ||
20930 proto.oMatchesSelector ||
20931 proto.webkitMatchesSelector;
20932 }
20933
20934 /**
20935 * Finds the closest parent that matches a selector.
20936 *
20937 * @param {Element} element
20938 * @param {String} selector
20939 * @return {Function}
20940 */
20941 function closest (element, selector) {
20942 while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
20943 if (element.matches(selector)) return element;
20944 element = element.parentNode;
20945 }
20946 }
20947
20948 module.exports = closest;
20949
20950 },{}],2:[function(require,module,exports){
20951 var closest = require('./closest');
20952
20953 /**
20954 * Delegates event to a selector.
20955 *
20956 * @param {Element} element
20957 * @param {String} selector
20958 * @param {String} type
20959 * @param {Function} callback
20960 * @param {Boolean} useCapture
20961 * @return {Object}
20962 */
20963 function delegate(element, selector, type, callback, useCapture) {
20964 var listenerFn = listener.apply(this, arguments);
20965
20966 element.addEventListener(type, listenerFn, useCapture);
20967
20968 return {
20969 destroy: function() {
20970 element.removeEventListener(type, listenerFn, useCapture);
20971 }
20972 }
20973 }
20974
20975 /**
20976 * Finds closest match and invokes callback.
20977 *
20978 * @param {Element} element
20979 * @param {String} selector
20980 * @param {String} type
20981 * @param {Function} callback
20982 * @return {Function}
20983 */
20984 function listener(element, selector, type, callback) {
20985 return function(e) {
20986 e.delegateTarget = closest(e.target, selector);
20987
20988 if (e.delegateTarget) {
20989 callback.call(element, e);
20990 }
20991 }
20992 }
20993
20994 module.exports = delegate;
20995
20996 },{"./closest":1}],3:[function(require,module,exports){
20997 /**
20998 * Check if argument is a HTML element.
20999 *
21000 * @param {Object} value
21001 * @return {Boolean}
21002 */
21003 exports.node = function(value) {
21004 return value !== undefined
21005 && value instanceof HTMLElement
21006 && value.nodeType === 1;
21007 };
21008
21009 /**
21010 * Check if argument is a list of HTML elements.
21011 *
21012 * @param {Object} value
21013 * @return {Boolean}
21014 */
21015 exports.nodeList = function(value) {
21016 var type = Object.prototype.toString.call(value);
21017
21018 return value !== undefined
21019 && (type === '[object NodeList]' || type === '[object HTMLCollection]')
21020 && ('length' in value)
21021 && (value.length === 0 || exports.node(value[0]));
21022 };
21023
21024 /**
21025 * Check if argument is a string.
21026 *
21027 * @param {Object} value
21028 * @return {Boolean}
21029 */
21030 exports.string = function(value) {
21031 return typeof value === 'string'
21032 || value instanceof String;
21033 };
21034
21035 /**
21036 * Check if argument is a function.
21037 *
21038 * @param {Object} value
21039 * @return {Boolean}
21040 */
21041 exports.fn = function(value) {
21042 var type = Object.prototype.toString.call(value);
21043
21044 return type === '[object Function]';
21045 };
21046
21047 },{}],4:[function(require,module,exports){
21048 var is = require('./is');
21049 var delegate = require('delegate');
21050
21051 /**
21052 * Validates all params and calls the right
21053 * listener function based on its target type.
21054 *
21055 * @param {String|HTMLElement|HTMLCollection|NodeList} target
21056 * @param {String} type
21057 * @param {Function} callback
21058 * @return {Object}
21059 */
21060 function listen(target, type, callback) {
21061 if (!target && !type && !callback) {
21062 throw new Error('Missing required arguments');
21063 }
21064
21065 if (!is.string(type)) {
21066 throw new TypeError('Second argument must be a String');
21067 }
21068
21069 if (!is.fn(callback)) {
21070 throw new TypeError('Third argument must be a Function');
21071 }
21072
21073 if (is.node(target)) {
21074 return listenNode(target, type, callback);
21075 }
21076 else if (is.nodeList(target)) {
21077 return listenNodeList(target, type, callback);
21078 }
21079 else if (is.string(target)) {
21080 return listenSelector(target, type, callback);
21081 }
21082 else {
21083 throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
21084 }
21085 }
21086
21087 /**
21088 * Adds an event listener to a HTML element
21089 * and returns a remove listener function.
21090 *
21091 * @param {HTMLElement} node
21092 * @param {String} type
21093 * @param {Function} callback
21094 * @return {Object}
21095 */
21096 function listenNode(node, type, callback) {
21097 node.addEventListener(type, callback);
21098
21099 return {
21100 destroy: function() {
21101 node.removeEventListener(type, callback);
21102 }
21103 }
21104 }
21105
21106 /**
21107 * Add an event listener to a list of HTML elements
21108 * and returns a remove listener function.
21109 *
21110 * @param {NodeList|HTMLCollection} nodeList
21111 * @param {String} type
21112 * @param {Function} callback
21113 * @return {Object}
21114 */
21115 function listenNodeList(nodeList, type, callback) {
21116 Array.prototype.forEach.call(nodeList, function(node) {
21117 node.addEventListener(type, callback);
21118 });
21119
21120 return {
21121 destroy: function() {
21122 Array.prototype.forEach.call(nodeList, function(node) {
21123 node.removeEventListener(type, callback);
21124 });
21125 }
21126 }
21127 }
21128
21129 /**
21130 * Add an event listener to a selector
21131 * and returns a remove listener function.
21132 *
21133 * @param {String} selector
21134 * @param {String} type
21135 * @param {Function} callback
21136 * @return {Object}
21137 */
21138 function listenSelector(selector, type, callback) {
21139 return delegate(document.body, selector, type, callback);
21140 }
21141
21142 module.exports = listen;
21143
21144 },{"./is":3,"delegate":2}],5:[function(require,module,exports){
21145 function select(element) {
21146 var selectedText;
21147
21148 if (element.nodeName === 'SELECT') {
21149 element.focus();
21150
21151 selectedText = element.value;
21152 }
21153 else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
21154 var isReadOnly = element.hasAttribute('readonly');
21155
21156 if (!isReadOnly) {
21157 element.setAttribute('readonly', '');
21158 }
21159
21160 element.select();
21161 element.setSelectionRange(0, element.value.length);
21162
21163 if (!isReadOnly) {
21164 element.removeAttribute('readonly');
21165 }
21166
21167 selectedText = element.value;
21168 }
21169 else {
21170 if (element.hasAttribute('contenteditable')) {
21171 element.focus();
21172 }
21173
21174 var selection = window.getSelection();
21175 var range = document.createRange();
21176
21177 range.selectNodeContents(element);
21178 selection.removeAllRanges();
21179 selection.addRange(range);
21180
21181 selectedText = selection.toString();
21182 }
21183
21184 return selectedText;
21185 }
21186
21187 module.exports = select;
21188
21189 },{}],6:[function(require,module,exports){
21190 function E () {
21191 // Keep this empty so it's easier to inherit from
21192 // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
21193 }
21194
21195 E.prototype = {
21196 on: function (name, callback, ctx) {
21197 var e = this.e || (this.e = {});
21198
21199 (e[name] || (e[name] = [])).push({
21200 fn: callback,
21201 ctx: ctx
21202 });
21203
21204 return this;
21205 },
21206
21207 once: function (name, callback, ctx) {
21208 var self = this;
21209 function listener () {
21210 self.off(name, listener);
21211 callback.apply(ctx, arguments);
21212 };
21213
21214 listener._ = callback
21215 return this.on(name, listener, ctx);
21216 },
21217
21218 emit: function (name) {
21219 var data = [].slice.call(arguments, 1);
21220 var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
21221 var i = 0;
21222 var len = evtArr.length;
21223
21224 for (i; i < len; i++) {
21225 evtArr[i].fn.apply(evtArr[i].ctx, data);
21226 }
21227
21228 return this;
21229 },
21230
21231 off: function (name, callback) {
21232 var e = this.e || (this.e = {});
21233 var evts = e[name];
21234 var liveEvents = [];
21235
21236 if (evts && callback) {
21237 for (var i = 0, len = evts.length; i < len; i++) {
21238 if (evts[i].fn !== callback && evts[i].fn._ !== callback)
21239 liveEvents.push(evts[i]);
21240 }
21241 }
21242
21243 // Remove event from queue to prevent memory leak
21244 // Suggested by https://github.com/lazd
21245 // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
21246
21247 (liveEvents.length)
21248 ? e[name] = liveEvents
21249 : delete e[name];
21250
21251 return this;
21252 }
21253 };
21254
21255 module.exports = E;
21256
21257 },{}],7:[function(require,module,exports){
21258 (function (global, factory) {
21259 if (typeof define === "function" && define.amd) {
21260 define(['module', 'select'], factory);
21261 } else if (typeof exports !== "undefined") {
21262 factory(module, require('select'));
21263 } else {
21264 var mod = {
21265 exports: {}
21266 };
21267 factory(mod, global.select);
21268 global.clipboardAction = mod.exports;
21269 }
21270 })(this, function (module, _select) {
21271 'use strict';
21272
21273 var _select2 = _interopRequireDefault(_select);
21274
21275 function _interopRequireDefault(obj) {
21276 return obj && obj.__esModule ? obj : {
21277 default: obj
21278 };
21279 }
21280
21281 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
21282 return typeof obj;
21283 } : function (obj) {
21284 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
21285 };
21286
21287 function _classCallCheck(instance, Constructor) {
21288 if (!(instance instanceof Constructor)) {
21289 throw new TypeError("Cannot call a class as a function");
21290 }
21291 }
21292
21293 var _createClass = function () {
21294 function defineProperties(target, props) {
21295 for (var i = 0; i < props.length; i++) {
21296 var descriptor = props[i];
21297 descriptor.enumerable = descriptor.enumerable || false;
21298 descriptor.configurable = true;
21299 if ("value" in descriptor) descriptor.writable = true;
21300 Object.defineProperty(target, descriptor.key, descriptor);
21301 }
21302 }
21303
21304 return function (Constructor, protoProps, staticProps) {
21305 if (protoProps) defineProperties(Constructor.prototype, protoProps);
21306 if (staticProps) defineProperties(Constructor, staticProps);
21307 return Constructor;
21308 };
21309 }();
21310
21311 var ClipboardAction = function () {
21312 /**
21313 * @param {Object} options
21314 */
21315 function ClipboardAction(options) {
21316 _classCallCheck(this, ClipboardAction);
21317
21318 this.resolveOptions(options);
21319 this.initSelection();
21320 }
21321
21322 /**
21323 * Defines base properties passed from constructor.
21324 * @param {Object} options
21325 */
21326
21327
21328 _createClass(ClipboardAction, [{
21329 key: 'resolveOptions',
21330 value: function resolveOptions() {
21331 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
21332
21333 this.action = options.action;
21334 this.emitter = options.emitter;
21335 this.target = options.target;
21336 this.text = options.text;
21337 this.trigger = options.trigger;
21338
21339 this.selectedText = '';
21340 }
21341 }, {
21342 key: 'initSelection',
21343 value: function initSelection() {
21344 if (this.text) {
21345 this.selectFake();
21346 } else if (this.target) {
21347 this.selectTarget();
21348 }
21349 }
21350 }, {
21351 key: 'selectFake',
21352 value: function selectFake() {
21353 var _this = this;
21354
21355 var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
21356
21357 this.removeFake();
21358
21359 this.fakeHandlerCallback = function () {
21360 return _this.removeFake();
21361 };
21362 this.fakeHandler = document.body.addEventListener('click', this.fakeHandlerCallback) || true;
21363
21364 this.fakeElem = document.createElement('textarea');
21365 // Prevent zooming on iOS
21366 this.fakeElem.style.fontSize = '12pt';
21367 // Reset box model
21368 this.fakeElem.style.border = '0';
21369 this.fakeElem.style.padding = '0';
21370 this.fakeElem.style.margin = '0';
21371 // Move element out of screen horizontally
21372 this.fakeElem.style.position = 'absolute';
21373 this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
21374 // Move element to the same position vertically
21375 var yPosition = window.pageYOffset || document.documentElement.scrollTop;
21376 this.fakeElem.style.top = yPosition + 'px';
21377
21378 this.fakeElem.setAttribute('readonly', '');
21379 this.fakeElem.value = this.text;
21380
21381 document.body.appendChild(this.fakeElem);
21382
21383 this.selectedText = (0, _select2.default)(this.fakeElem);
21384 this.copyText();
21385 }
21386 }, {
21387 key: 'removeFake',
21388 value: function removeFake() {
21389 if (this.fakeHandler) {
21390 document.body.removeEventListener('click', this.fakeHandlerCallback);
21391 this.fakeHandler = null;
21392 this.fakeHandlerCallback = null;
21393 }
21394
21395 if (this.fakeElem) {
21396 document.body.removeChild(this.fakeElem);
21397 this.fakeElem = null;
21398 }
21399 }
21400 }, {
21401 key: 'selectTarget',
21402 value: function selectTarget() {
21403 this.selectedText = (0, _select2.default)(this.target);
21404 this.copyText();
21405 }
21406 }, {
21407 key: 'copyText',
21408 value: function copyText() {
21409 var succeeded = void 0;
21410
21411 try {
21412 succeeded = document.execCommand(this.action);
21413 } catch (err) {
21414 succeeded = false;
21415 }
21416
21417 this.handleResult(succeeded);
21418 }
21419 }, {
21420 key: 'handleResult',
21421 value: function handleResult(succeeded) {
21422 this.emitter.emit(succeeded ? 'success' : 'error', {
21423 action: this.action,
21424 text: this.selectedText,
21425 trigger: this.trigger,
21426 clearSelection: this.clearSelection.bind(this)
21427 });
21428 }
21429 }, {
21430 key: 'clearSelection',
21431 value: function clearSelection() {
21432 if (this.target) {
21433 this.target.blur();
21434 }
21435
21436 window.getSelection().removeAllRanges();
21437 }
21438 }, {
21439 key: 'destroy',
21440 value: function destroy() {
21441 this.removeFake();
21442 }
21443 }, {
21444 key: 'action',
21445 set: function set() {
21446 var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
21447
21448 this._action = action;
21449
21450 if (this._action !== 'copy' && this._action !== 'cut') {
21451 throw new Error('Invalid "action" value, use either "copy" or "cut"');
21452 }
21453 },
21454 get: function get() {
21455 return this._action;
21456 }
21457 }, {
21458 key: 'target',
21459 set: function set(target) {
21460 if (target !== undefined) {
21461 if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {
21462 if (this.action === 'copy' && target.hasAttribute('disabled')) {
21463 throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
21464 }
21465
21466 if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
21467 throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
21468 }
21469
21470 this._target = target;
21471 } else {
21472 throw new Error('Invalid "target" value, use a valid Element');
21473 }
21474 }
21475 },
21476 get: function get() {
21477 return this._target;
21478 }
21479 }]);
21480
21481 return ClipboardAction;
21482 }();
21483
21484 module.exports = ClipboardAction;
21485 });
21486
21487 },{"select":5}],8:[function(require,module,exports){
21488 (function (global, factory) {
21489 if (typeof define === "function" && define.amd) {
21490 define(['module', './clipboard-action', 'tiny-emitter', 'good-listener'], factory);
21491 } else if (typeof exports !== "undefined") {
21492 factory(module, require('./clipboard-action'), require('tiny-emitter'), require('good-listener'));
21493 } else {
21494 var mod = {
21495 exports: {}
21496 };
21497 factory(mod, global.clipboardAction, global.tinyEmitter, global.goodListener);
21498 global.clipboard = mod.exports;
21499 }
21500 })(this, function (module, _clipboardAction, _tinyEmitter, _goodListener) {
21501 'use strict';
21502
21503 var _clipboardAction2 = _interopRequireDefault(_clipboardAction);
21504
21505 var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter);
21506
21507 var _goodListener2 = _interopRequireDefault(_goodListener);
21508
21509 function _interopRequireDefault(obj) {
21510 return obj && obj.__esModule ? obj : {
21511 default: obj
21512 };
21513 }
21514
21515 function _classCallCheck(instance, Constructor) {
21516 if (!(instance instanceof Constructor)) {
21517 throw new TypeError("Cannot call a class as a function");
21518 }
21519 }
21520
21521 var _createClass = function () {
21522 function defineProperties(target, props) {
21523 for (var i = 0; i < props.length; i++) {
21524 var descriptor = props[i];
21525 descriptor.enumerable = descriptor.enumerable || false;
21526 descriptor.configurable = true;
21527 if ("value" in descriptor) descriptor.writable = true;
21528 Object.defineProperty(target, descriptor.key, descriptor);
21529 }
21530 }
21531
21532 return function (Constructor, protoProps, staticProps) {
21533 if (protoProps) defineProperties(Constructor.prototype, protoProps);
21534 if (staticProps) defineProperties(Constructor, staticProps);
21535 return Constructor;
21536 };
21537 }();
21538
21539 function _possibleConstructorReturn(self, call) {
21540 if (!self) {
21541 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
21542 }
21543
21544 return call && (typeof call === "object" || typeof call === "function") ? call : self;
21545 }
21546
21547 function _inherits(subClass, superClass) {
21548 if (typeof superClass !== "function" && superClass !== null) {
21549 throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
21550 }
21551
21552 subClass.prototype = Object.create(superClass && superClass.prototype, {
21553 constructor: {
21554 value: subClass,
21555 enumerable: false,
21556 writable: true,
21557 configurable: true
21558 }
21559 });
21560 if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
21561 }
21562
21563 var Clipboard = function (_Emitter) {
21564 _inherits(Clipboard, _Emitter);
21565
21566 /**
21567 * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
21568 * @param {Object} options
21569 */
21570 function Clipboard(trigger, options) {
21571 _classCallCheck(this, Clipboard);
21572
21573 var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));
21574
21575 _this.resolveOptions(options);
21576 _this.listenClick(trigger);
21577 return _this;
21578 }
21579
21580 /**
21581 * Defines if attributes would be resolved using internal setter functions
21582 * or custom functions that were passed in the constructor.
21583 * @param {Object} options
21584 */
21585
21586
21587 _createClass(Clipboard, [{
21588 key: 'resolveOptions',
21589 value: function resolveOptions() {
21590 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
21591
21592 this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
21593 this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
21594 this.text = typeof options.text === 'function' ? options.text : this.defaultText;
21595 }
21596 }, {
21597 key: 'listenClick',
21598 value: function listenClick(trigger) {
21599 var _this2 = this;
21600
21601 this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
21602 return _this2.onClick(e);
21603 });
21604 }
21605 }, {
21606 key: 'onClick',
21607 value: function onClick(e) {
21608 var trigger = e.delegateTarget || e.currentTarget;
21609
21610 if (this.clipboardAction) {
21611 this.clipboardAction = null;
21612 }
21613
21614 this.clipboardAction = new _clipboardAction2.default({
21615 action: this.action(trigger),
21616 target: this.target(trigger),
21617 text: this.text(trigger),
21618 trigger: trigger,
21619 emitter: this
21620 });
21621 }
21622 }, {
21623 key: 'defaultAction',
21624 value: function defaultAction(trigger) {
21625 return getAttributeValue('action', trigger);
21626 }
21627 }, {
21628 key: 'defaultTarget',
21629 value: function defaultTarget(trigger) {
21630 var selector = getAttributeValue('target', trigger);
21631
21632 if (selector) {
21633 return document.querySelector(selector);
21634 }
21635 }
21636 }, {
21637 key: 'defaultText',
21638 value: function defaultText(trigger) {
21639 return getAttributeValue('text', trigger);
21640 }
21641 }, {
21642 key: 'destroy',
21643 value: function destroy() {
21644 this.listener.destroy();
21645
21646 if (this.clipboardAction) {
21647 this.clipboardAction.destroy();
21648 this.clipboardAction = null;
21649 }
21650 }
21651 }], [{
21652 key: 'isSupported',
21653 value: function isSupported() {
21654 var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
21655
21656 var actions = typeof action === 'string' ? [action] : action;
21657 var support = !!document.queryCommandSupported;
21658
21659 actions.forEach(function (action) {
21660 support = support && !!document.queryCommandSupported(action);
21661 });
21662
21663 return support;
21664 }
21665 }]);
21666
21667 return Clipboard;
21668 }(_tinyEmitter2.default);
21669
21670 /**
21671 * Helper function to retrieve attribute value.
21672 * @param {String} suffix
21673 * @param {Element} element
21674 */
21675 function getAttributeValue(suffix, element) {
21676 var attribute = 'data-clipboard-' + suffix;
21677
21678 if (!element.hasAttribute(attribute)) {
21679 return;
21680 }
21681
21682 return element.getAttribute(attribute);
21683 }
21684
21685 module.exports = Clipboard;
21686 });
21687
21688 },{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)
21689 });
21690 /* assets/wpuf/vendor/tooltip/tooltip.js */
21691 /* ========================================================================
21692 * Bootstrap: tooltip.js v3.3.7
21693 * http://getbootstrap.com/javascript/#tooltip
21694 * Inspired by the original jQuery.tipsy by Jason Frame
21695 * ========================================================================
21696 * Copyright 2011-2016 Twitter, Inc.
21697 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
21698 * ======================================================================== */
21699
21700 +function ($) {
21701 'use strict';
21702 $.support.transition = false;
21703
21704 // TOOLTIP PUBLIC CLASS DEFINITION
21705 // ===============================
21706
21707 var Tooltip = function (element, options) {
21708 this.type = null
21709 this.options = null
21710 this.enabled = null
21711 this.timeout = null
21712 this.hoverState = null
21713 this.$element = null
21714 this.inState = null
21715
21716 this.init('tooltip', element, options)
21717 }
21718
21719 Tooltip.VERSION = '3.3.7'
21720
21721 Tooltip.TRANSITION_DURATION = 150
21722
21723 Tooltip.DEFAULTS = {
21724 animation: true,
21725 placement: 'top',
21726 selector: false,
21727 template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
21728 trigger: 'hover focus',
21729 title: '',
21730 delay: 0,
21731 html: false,
21732 container: false,
21733 viewport: {
21734 selector: 'body',
21735 padding: 0
21736 }
21737 }
21738
21739 Tooltip.prototype.init = function (type, element, options) {
21740 this.enabled = true
21741 this.type = type
21742 this.$element = $(element)
21743 this.options = this.getOptions(options)
21744 this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
21745 this.inState = { click: false, hover: false, focus: false }
21746
21747 if (this.$element[0] instanceof document.constructor && !this.options.selector) {
21748 throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')
21749 }
21750
21751 var triggers = this.options.trigger.split(' ')
21752
21753 for (var i = triggers.length; i--;) {
21754 var trigger = triggers[i]
21755
21756 if (trigger == 'click') {
21757 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
21758 } else if (trigger != 'manual') {
21759 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
21760 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
21761
21762 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
21763 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
21764 }
21765 }
21766
21767 this.options.selector ?
21768 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
21769 this.fixTitle()
21770 }
21771
21772 Tooltip.prototype.getDefaults = function () {
21773 return Tooltip.DEFAULTS
21774 }
21775
21776 Tooltip.prototype.getOptions = function (options) {
21777 options = $.extend({}, this.getDefaults(), this.$element.data(), options)
21778
21779 if (options.delay && typeof options.delay == 'number') {
21780 options.delay = {
21781 show: options.delay,
21782 hide: options.delay
21783 }
21784 }
21785
21786 return options
21787 }
21788
21789 Tooltip.prototype.getDelegateOptions = function () {
21790 var options = {}
21791 var defaults = this.getDefaults()
21792
21793 this._options && $.each(this._options, function (key, value) {
21794 if (defaults[key] != value) options[key] = value
21795 })
21796
21797 return options
21798 }
21799
21800 Tooltip.prototype.enter = function (obj) {
21801 var self = obj instanceof this.constructor ?
21802 obj : $(obj.currentTarget).data('bs.' + this.type)
21803
21804 if (!self) {
21805 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
21806 $(obj.currentTarget).data('bs.' + this.type, self)
21807 }
21808
21809 if (obj instanceof $.Event) {
21810 self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true
21811 }
21812
21813 if (self.tip().hasClass('in') || self.hoverState == 'in') {
21814 self.hoverState = 'in'
21815 return
21816 }
21817
21818 clearTimeout(self.timeout)
21819
21820 self.hoverState = 'in'
21821
21822 if (!self.options.delay || !self.options.delay.show) return self.show()
21823
21824 self.timeout = setTimeout(function () {
21825 if (self.hoverState == 'in') self.show()
21826 }, self.options.delay.show)
21827 }
21828
21829 Tooltip.prototype.isInStateTrue = function () {
21830 for (var key in this.inState) {
21831 if (this.inState[key]) return true
21832 }
21833
21834 return false
21835 }
21836
21837 Tooltip.prototype.leave = function (obj) {
21838 var self = obj instanceof this.constructor ?
21839 obj : $(obj.currentTarget).data('bs.' + this.type)
21840
21841 if (!self) {
21842 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
21843 $(obj.currentTarget).data('bs.' + this.type, self)
21844 }
21845
21846 if (obj instanceof $.Event) {
21847 self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false
21848 }
21849
21850 if (self.isInStateTrue()) return
21851
21852 clearTimeout(self.timeout)
21853
21854 self.hoverState = 'out'
21855
21856 if (!self.options.delay || !self.options.delay.hide) return self.hide()
21857
21858 self.timeout = setTimeout(function () {
21859 if (self.hoverState == 'out') self.hide()
21860 }, self.options.delay.hide)
21861 }
21862
21863 Tooltip.prototype.show = function () {
21864 var e = $.Event('show.bs.' + this.type)
21865
21866 if (this.hasContent() && this.enabled) {
21867 this.$element.trigger(e)
21868
21869 var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])
21870 if (e.isDefaultPrevented() || !inDom) return
21871 var that = this
21872
21873 var $tip = this.tip()
21874
21875 var tipId = this.getUID(this.type)
21876
21877 this.setContent()
21878 $tip.attr('id', tipId)
21879 this.$element.attr('aria-describedby', tipId)
21880
21881 if (this.options.animation) $tip.addClass('fade')
21882
21883 var placement = typeof this.options.placement == 'function' ?
21884 this.options.placement.call(this, $tip[0], this.$element[0]) :
21885 this.options.placement
21886
21887 var autoToken = /\s?auto?\s?/i
21888 var autoPlace = autoToken.test(placement)
21889 if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
21890
21891 $tip
21892 .detach()
21893 .css({ top: 0, left: 0, display: 'block' })
21894 .addClass(placement)
21895 .data('bs.' + this.type, this)
21896
21897 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
21898 this.$element.trigger('inserted.bs.' + this.type)
21899
21900 var pos = this.getPosition()
21901 var actualWidth = $tip[0].offsetWidth
21902 var actualHeight = $tip[0].offsetHeight
21903
21904 if (autoPlace) {
21905 var orgPlacement = placement
21906 var viewportDim = this.getPosition(this.$viewport)
21907
21908 placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top' :
21909 placement == 'top' && pos.top - actualHeight < viewportDim.top ? 'bottom' :
21910 placement == 'right' && pos.right + actualWidth > viewportDim.width ? 'left' :
21911 placement == 'left' && pos.left - actualWidth < viewportDim.left ? 'right' :
21912 placement
21913
21914 $tip
21915 .removeClass(orgPlacement)
21916 .addClass(placement)
21917 }
21918
21919 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
21920
21921 this.applyPlacement(calculatedOffset, placement)
21922
21923 var complete = function () {
21924 var prevHoverState = that.hoverState
21925 that.$element.trigger('shown.bs.' + that.type)
21926 that.hoverState = null
21927
21928 if (prevHoverState == 'out') that.leave(that)
21929 }
21930
21931 $.support.transition && this.$tip.hasClass('fade') ?
21932 $tip
21933 .one('bsTransitionEnd', complete)
21934 .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
21935 complete()
21936 }
21937 }
21938
21939 Tooltip.prototype.applyPlacement = function (offset, placement) {
21940 var $tip = this.tip()
21941 var width = $tip[0].offsetWidth
21942 var height = $tip[0].offsetHeight
21943
21944 // manually read margins because getBoundingClientRect includes difference
21945 var marginTop = parseInt($tip.css('margin-top'), 10)
21946 var marginLeft = parseInt($tip.css('margin-left'), 10)
21947
21948 // we must check for NaN for ie 8/9
21949 if (isNaN(marginTop)) marginTop = 0
21950 if (isNaN(marginLeft)) marginLeft = 0
21951
21952 offset.top += marginTop
21953 offset.left += marginLeft
21954
21955 // $.fn.offset doesn't round pixel values
21956 // so we use setOffset directly with our own function B-0
21957 $.offset.setOffset($tip[0], $.extend({
21958 using: function (props) {
21959 $tip.css({
21960 top: Math.round(props.top),
21961 left: Math.round(props.left)
21962 })
21963 }
21964 }, offset), 0)
21965
21966 $tip.addClass('in')
21967
21968 // check to see if placing tip in new offset caused the tip to resize itself
21969 var actualWidth = $tip[0].offsetWidth
21970 var actualHeight = $tip[0].offsetHeight
21971
21972 if (placement == 'top' && actualHeight != height) {
21973 offset.top = offset.top + height - actualHeight
21974 }
21975
21976 var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
21977
21978 if (delta.left) offset.left += delta.left
21979 else offset.top += delta.top
21980
21981 var isVertical = /top|bottom/.test(placement)
21982 var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
21983 var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'
21984
21985 $tip.offset(offset)
21986 this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
21987 }
21988
21989 Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) {
21990 this.arrow()
21991 .css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
21992 .css(isVertical ? 'top' : 'left', '')
21993 }
21994
21995 Tooltip.prototype.setContent = function () {
21996 var $tip = this.tip()
21997 var title = this.getTitle()
21998
21999 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
22000 $tip.removeClass('fade in top bottom left right')
22001 }
22002
22003 Tooltip.prototype.hide = function (callback) {
22004 var that = this
22005 var $tip = $(this.$tip)
22006 var e = $.Event('hide.bs.' + this.type)
22007
22008 function complete() {
22009 if (that.hoverState != 'in') $tip.detach()
22010 if (that.$element) { // TODO: Check whether guarding this code with this `if` is really necessary.
22011 that.$element
22012 .removeAttr('aria-describedby')
22013 .trigger('hidden.bs.' + that.type)
22014 }
22015 callback && callback()
22016 }
22017
22018 this.$element.trigger(e)
22019
22020 if (e.isDefaultPrevented()) return
22021
22022 $tip.removeClass('in')
22023
22024 $.support.transition && $tip.hasClass('fade') ?
22025 $tip
22026 .one('bsTransitionEnd', complete)
22027 .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
22028 complete()
22029
22030 this.hoverState = null
22031
22032 return this
22033 }
22034
22035 Tooltip.prototype.fixTitle = function () {
22036 var $e = this.$element
22037 if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') {
22038 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
22039 }
22040 }
22041
22042 Tooltip.prototype.hasContent = function () {
22043 return this.getTitle()
22044 }
22045
22046 Tooltip.prototype.getPosition = function ($element) {
22047 $element = $element || this.$element
22048
22049 var el = $element[0]
22050 var isBody = el.tagName == 'BODY'
22051
22052 var elRect = el.getBoundingClientRect()
22053 if (elRect.width == null) {
22054 // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
22055 elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
22056 }
22057 var isSvg = window.SVGElement && el instanceof window.SVGElement
22058 // Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3.
22059 // See https://github.com/twbs/bootstrap/issues/20280
22060 var elOffset = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset())
22061 var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
22062 var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null
22063
22064 return $.extend({}, elRect, scroll, outerDims, elOffset)
22065 }
22066
22067 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
22068 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
22069 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
22070 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
22071 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
22072
22073 }
22074
22075 Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
22076 var delta = { top: 0, left: 0 }
22077 if (!this.$viewport) return delta
22078
22079 var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
22080 var viewportDimensions = this.getPosition(this.$viewport)
22081
22082 if (/right|left/.test(placement)) {
22083 var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
22084 var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
22085 if (topEdgeOffset < viewportDimensions.top) { // top overflow
22086 delta.top = viewportDimensions.top - topEdgeOffset
22087 } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
22088 delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
22089 }
22090 } else {
22091 var leftEdgeOffset = pos.left - viewportPadding
22092 var rightEdgeOffset = pos.left + viewportPadding + actualWidth
22093 if (leftEdgeOffset < viewportDimensions.left) { // left overflow
22094 delta.left = viewportDimensions.left - leftEdgeOffset
22095 } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow
22096 delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
22097 }
22098 }
22099
22100 return delta
22101 }
22102
22103 Tooltip.prototype.getTitle = function () {
22104 var title
22105 var $e = this.$element
22106 var o = this.options
22107
22108 title = $e.attr('data-original-title')
22109 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
22110
22111 return title
22112 }
22113
22114 Tooltip.prototype.getUID = function (prefix) {
22115 do prefix += ~~(Math.random() * 1000000)
22116 while (document.getElementById(prefix))
22117 return prefix
22118 }
22119
22120 Tooltip.prototype.tip = function () {
22121 if (!this.$tip) {
22122 this.$tip = $(this.options.template)
22123 if (this.$tip.length != 1) {
22124 throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')
22125 }
22126 }
22127 return this.$tip
22128 }
22129
22130 Tooltip.prototype.arrow = function () {
22131 return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
22132 }
22133
22134 Tooltip.prototype.enable = function () {
22135 this.enabled = true
22136 }
22137
22138 Tooltip.prototype.disable = function () {
22139 this.enabled = false
22140 }
22141
22142 Tooltip.prototype.toggleEnabled = function () {
22143 this.enabled = !this.enabled
22144 }
22145
22146 Tooltip.prototype.toggle = function (e) {
22147 var self = this
22148 if (e) {
22149 self = $(e.currentTarget).data('bs.' + this.type)
22150 if (!self) {
22151 self = new this.constructor(e.currentTarget, this.getDelegateOptions())
22152 $(e.currentTarget).data('bs.' + this.type, self)
22153 }
22154 }
22155
22156 if (e) {
22157 self.inState.click = !self.inState.click
22158 if (self.isInStateTrue()) self.enter(self)
22159 else self.leave(self)
22160 } else {
22161 self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
22162 }
22163 }
22164
22165 Tooltip.prototype.destroy = function () {
22166 var that = this
22167 clearTimeout(this.timeout)
22168 this.hide(function () {
22169 that.$element.off('.' + that.type).removeData('bs.' + that.type)
22170 if (that.$tip) {
22171 that.$tip.detach()
22172 }
22173 that.$tip = null
22174 that.$arrow = null
22175 that.$viewport = null
22176 that.$element = null
22177 })
22178 }
22179
22180
22181 // TOOLTIP PLUGIN DEFINITION
22182 // =========================
22183
22184 function Plugin(option) {
22185 return this.each(function () {
22186 var $this = $(this)
22187 var data = $this.data('bs.tooltip')
22188 var options = typeof option == 'object' && option
22189
22190 if (!data && /destroy|hide/.test(option)) return
22191 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
22192 if (typeof option == 'string') data[option]()
22193 })
22194 }
22195
22196 var old = $.fn.tooltip
22197
22198 $.fn.tooltip = Plugin
22199 $.fn.tooltip.Constructor = Tooltip
22200
22201
22202 // TOOLTIP NO CONFLICT
22203 // ===================
22204
22205 $.fn.tooltip.noConflict = function () {
22206 $.fn.tooltip = old
22207 return this
22208 }
22209
22210 }(jQuery);
22211
22212 /* assets/js/vendor/tinymce/plugins/code/plugin.min.js */
22213 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})});
22214 /* assets/js/vendor/tinymce/plugins/hr/plugin.min.js */
22215 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"})});