1 | function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
2 |
|
3 | function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
4 |
|
5 | function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
6 |
|
7 | function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
8 |
|
9 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
10 |
|
11 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
12 |
|
13 | function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
14 |
|
15 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
16 |
|
17 | (function (require, global) {
|
18 | require = function (cache, modules, cx) {
|
19 | var loader = function loader(r) {
|
20 | if (!modules[r]) throw new Error(r + ' is not a module');
|
21 | return cache[r] ? cache[r].exports : (cache[r] = {
|
22 | exports: {}
|
23 | }, cache[r].exports = modules[r].call(cx, require, cache[r], cache[r].exports));
|
24 | };
|
25 |
|
26 | loader.modules = modules;
|
27 | return loader;
|
28 | }({}, {
|
29 | 0: function _(require, module, exports) {
|
30 | var _QuickDom;
|
31 |
|
32 | var CSS = require(1);
|
33 |
|
34 | var extend = require(2);
|
35 |
|
36 | var allowedOptions, allowedTemplateOptions;
|
37 | allowedTemplateOptions = ['id', 'name', 'type', 'href', 'selected', 'checked', 'className'];
|
38 |
|
39 | allowedOptions = ['id', 'ref', 'type', 'name', 'text', 'style', 'class', 'className', 'url', 'href', 'selected', 'checked', 'props', 'attrs', 'passStateToChildren', 'stateTriggers'];
|
40 |
|
41 |
|
42 | ;
|
43 | var helpers, styleCache;
|
44 | helpers = {};
|
45 |
|
46 | helpers.includes = function (target, item) {
|
47 | return target && target.indexOf(item) !== -1;
|
48 | };
|
49 |
|
50 | helpers.removeItem = function (target, item) {
|
51 | var itemIndex;
|
52 | itemIndex = target.indexOf(item);
|
53 |
|
54 | if (itemIndex !== -1) {
|
55 | target.splice(itemIndex, 1);
|
56 | }
|
57 |
|
58 | return target;
|
59 | };
|
60 |
|
61 | helpers.normalizeGivenEl = function (targetEl) {
|
62 | switch (false) {
|
63 | case !IS.string(targetEl):
|
64 | return _QuickDom.text(targetEl);
|
65 |
|
66 | case !IS.domNode(targetEl):
|
67 | return _QuickDom(targetEl);
|
68 |
|
69 | case !IS.template(targetEl):
|
70 | return targetEl.spawn();
|
71 |
|
72 | default:
|
73 | return targetEl;
|
74 | }
|
75 | };
|
76 |
|
77 | helpers.isStateStyle = function (string) {
|
78 | return string[0] === '$' || string[0] === '@';
|
79 | };
|
80 |
|
81 | helpers.registerStyle = function (rule, level, important) {
|
82 | var cached, i, len, output, prop, props;
|
83 | level || (level = 0);
|
84 | cached = styleCache.get(rule, level);
|
85 |
|
86 | if (cached) {
|
87 | return cached;
|
88 | }
|
89 |
|
90 | output = {
|
91 | className: [CSS.register(rule, level, important)],
|
92 | fns: [],
|
93 | rule: rule
|
94 | };
|
95 | props = Object.keys(rule);
|
96 |
|
97 | for (i = 0, len = props.length; i < len; i++) {
|
98 | prop = props[i];
|
99 |
|
100 | if (typeof rule[prop] === 'function') {
|
101 | output.fns.push([prop, rule[prop]]);
|
102 | }
|
103 | }
|
104 |
|
105 | return styleCache.set(rule, output, level);
|
106 | };
|
107 |
|
108 | styleCache = new (
|
109 |
|
110 | function () {
|
111 | function _class() {
|
112 | _classCallCheck(this, _class);
|
113 |
|
114 | this.keys = Object.create(null);
|
115 | this.values = Object.create(null);
|
116 | }
|
117 |
|
118 | _createClass(_class, [{
|
119 | key: "get",
|
120 | value: function get(key, level) {
|
121 | var index;
|
122 |
|
123 | if (this.keys[level]) {
|
124 | index = this.keys[level].indexOf(key);
|
125 |
|
126 | if (index !== -1) {
|
127 | return this.values[level][index];
|
128 | }
|
129 | }
|
130 | }
|
131 | }, {
|
132 | key: "set",
|
133 | value: function set(key, value, level) {
|
134 | if (!this.keys[level]) {
|
135 | this.keys[level] = [];
|
136 | this.values[level] = [];
|
137 | }
|
138 |
|
139 | this.keys[level].push(key);
|
140 | this.values[level].push(value);
|
141 | return value;
|
142 | }
|
143 | }]);
|
144 |
|
145 | return _class;
|
146 | }())();
|
147 | ;
|
148 | var IS;
|
149 | IS = require(18);
|
150 | IS = IS.create('natives', 'dom');
|
151 | IS.load({
|
152 | quickDomEl: function quickDomEl(subject) {
|
153 | return subject && subject.constructor.name === QuickElement.name;
|
154 | },
|
155 | template: function template(subject) {
|
156 | return subject && subject.constructor.name === QuickTemplate.name;
|
157 | }
|
158 | });
|
159 | ;
|
160 | var QuickElement, svgNamespace;
|
161 | svgNamespace = 'http://www.w3.org/2000/svg';
|
162 |
|
163 | QuickElement = function () {
|
164 | var QuickElement =
|
165 |
|
166 | function () {
|
167 | function QuickElement(type, options) {
|
168 | _classCallCheck(this, QuickElement);
|
169 |
|
170 | this.type = type;
|
171 | this.options = options;
|
172 | QuickElement.count++;
|
173 |
|
174 | if (this.type[0] === '*') {
|
175 | this.svg = true;
|
176 | }
|
177 |
|
178 | this.el = this.options.existing || (this.type === 'text' ? document.createTextNode(typeof this.options.text === 'string' ? this.options.text : '') : this.svg ? document.createElementNS(svgNamespace, this.type.slice(1)) : document.createElement(this.type));
|
179 |
|
180 | if (this.type === 'text') {
|
181 | this.append = this.prepend = this.attr = function () {};
|
182 | }
|
183 |
|
184 | this._parent = null;
|
185 | this._styles = {};
|
186 | this._state = [];
|
187 | this._children = [];
|
188 |
|
189 | this._normalizeOptions();
|
190 |
|
191 | this._applyOptions();
|
192 |
|
193 | this._attachStateEvents();
|
194 |
|
195 | this._proxyParent();
|
196 |
|
197 | if (this.options.existing) {
|
198 | this._refreshParent();
|
199 | }
|
200 |
|
201 | this.el._quickElement = this;
|
202 | }
|
203 |
|
204 | _createClass(QuickElement, [{
|
205 | key: "toJSON",
|
206 | value: function toJSON() {
|
207 | var child, children, i, len, output;
|
208 | output = [this.type, extend.clone.keys(allowedOptions)(this.options)];
|
209 | children = this.children;
|
210 |
|
211 | for (i = 0, len = children.length; i < len; i++) {
|
212 | child = children[i];
|
213 | output.push(child.toJSON());
|
214 | }
|
215 |
|
216 | return output;
|
217 | }
|
218 | }]);
|
219 |
|
220 | return QuickElement;
|
221 | }();
|
222 |
|
223 | ;
|
224 | QuickElement.count = 0;
|
225 | return QuickElement;
|
226 | }.call(this);
|
227 |
|
228 | if (QuickElement.name == null) {
|
229 | QuickElement.name = 'QuickElement';
|
230 | }
|
231 |
|
232 | Object.defineProperties(QuickElement.prototype, {
|
233 | 'raw': {
|
234 | get: function get() {
|
235 | return this.el;
|
236 | }
|
237 | },
|
238 | '0': {
|
239 | get: function get() {
|
240 | return this.el;
|
241 | }
|
242 | },
|
243 | 'css': {
|
244 | get: function get() {
|
245 | return this.style;
|
246 | }
|
247 | },
|
248 | 'replaceWith': {
|
249 | get: function get() {
|
250 | return this.replace;
|
251 | }
|
252 | },
|
253 | 'removeListener': {
|
254 | get: function get() {
|
255 | return this.off;
|
256 | }
|
257 | }
|
258 | });
|
259 | ;
|
260 |
|
261 | var _filterElements, _getChildRefs2, _getIndexByProp, _getParents;
|
262 |
|
263 | QuickElement.prototype.parentsUntil = function (filter) {
|
264 | return _getParents(this, filter);
|
265 | };
|
266 |
|
267 | QuickElement.prototype.parentMatching = function (filter) {
|
268 | var isRef, nextParent;
|
269 |
|
270 | if (IS.function(filter) || (isRef = IS.string(filter))) {
|
271 | nextParent = this.parent;
|
272 |
|
273 | while (nextParent) {
|
274 | if (isRef) {
|
275 | if (nextParent.ref === filter) {
|
276 | return nextParent;
|
277 | }
|
278 | } else {
|
279 | if (filter(nextParent)) {
|
280 | return nextParent;
|
281 | }
|
282 | }
|
283 |
|
284 | nextParent = nextParent.parent;
|
285 | }
|
286 | }
|
287 | };
|
288 |
|
289 | QuickElement.prototype.query = function (selector) {
|
290 | return _QuickDom(this.raw.querySelector(selector));
|
291 | };
|
292 |
|
293 | QuickElement.prototype.queryAll = function (selector) {
|
294 | var i, item, len, output, result;
|
295 | result = this.raw.querySelectorAll(selector);
|
296 | output = [];
|
297 |
|
298 | for (i = 0, len = result.length; i < len; i++) {
|
299 | item = result[i];
|
300 | output.push(item);
|
301 | }
|
302 |
|
303 | return new QuickBatch(output);
|
304 | };
|
305 |
|
306 | Object.defineProperties(QuickElement.prototype, {
|
307 | 'children': {
|
308 | get: function get() {
|
309 | var child, i, len, ref1;
|
310 |
|
311 | if (this.el.childNodes.length !== this._children.length) {
|
312 |
|
313 | this._children.length = 0;
|
314 |
|
315 | ref1 = this.el.childNodes;
|
316 |
|
317 | for (i = 0, len = ref1.length; i < len; i++) {
|
318 | child = ref1[i];
|
319 |
|
320 | if (child.nodeType < 4) {
|
321 | this._children.push(_QuickDom(child));
|
322 | }
|
323 | }
|
324 | }
|
325 |
|
326 | return this._children;
|
327 | }
|
328 | },
|
329 | 'elementChildren': {
|
330 | get: function get() {
|
331 | return _filterElements(this.children);
|
332 | }
|
333 | },
|
334 | 'parent': {
|
335 | get: function get() {
|
336 | if ((!this._parent || this._parent.el !== this.el.parentNode) && !IS.domDoc(this.el.parentNode)) {
|
337 | this._parent = _QuickDom(this.el.parentNode);
|
338 | }
|
339 |
|
340 | return this._parent;
|
341 | }
|
342 | },
|
343 | 'parents': {
|
344 | get: function get() {
|
345 | return _getParents(this);
|
346 | }
|
347 | },
|
348 | 'next': {
|
349 | get: function get() {
|
350 | return _QuickDom(this.el.nextSibling);
|
351 | }
|
352 | },
|
353 | 'nextEl': {
|
354 | get: function get() {
|
355 | return _QuickDom(this.el.nextElementSibling);
|
356 | }
|
357 | },
|
358 | 'nextElAll': {
|
359 | get: function get() {
|
360 | return _filterElements(this.nextAll);
|
361 | }
|
362 | },
|
363 | 'nextAll': {
|
364 | get: function get() {
|
365 | var nextSibling, siblings;
|
366 | siblings = [];
|
367 | nextSibling = _QuickDom(this.el.nextSibling);
|
368 |
|
369 | while (nextSibling) {
|
370 | siblings.push(nextSibling);
|
371 | nextSibling = nextSibling.next;
|
372 | }
|
373 |
|
374 | return siblings;
|
375 | }
|
376 | },
|
377 | 'prev': {
|
378 | get: function get() {
|
379 | return _QuickDom(this.el.previousSibling);
|
380 | }
|
381 | },
|
382 | 'prevEl': {
|
383 | get: function get() {
|
384 | return _QuickDom(this.el.previousElementSibling);
|
385 | }
|
386 | },
|
387 | 'prevElAll': {
|
388 | get: function get() {
|
389 | return _filterElements(this.prevAll);
|
390 | }
|
391 | },
|
392 | 'prevAll': {
|
393 | get: function get() {
|
394 | var prevSibling, siblings;
|
395 | siblings = [];
|
396 | prevSibling = _QuickDom(this.el.previousSibling);
|
397 |
|
398 | while (prevSibling) {
|
399 | siblings.push(prevSibling);
|
400 | prevSibling = prevSibling.prev;
|
401 | }
|
402 |
|
403 | return siblings;
|
404 | }
|
405 | },
|
406 | 'siblings': {
|
407 | get: function get() {
|
408 | return this.prevAll.reverse().concat(this.nextAll);
|
409 | }
|
410 | },
|
411 | 'elementSiblings': {
|
412 | get: function get() {
|
413 | return _filterElements(this.siblings);
|
414 | }
|
415 | },
|
416 | 'child': {
|
417 | get: function get() {
|
418 | return this._childRefs || _getChildRefs2(this);
|
419 | }
|
420 | },
|
421 | 'childf': {
|
422 | get: function get() {
|
423 | return _getChildRefs2(this, true);
|
424 | }
|
425 | },
|
426 | 'firstChild': {
|
427 | get: function get() {
|
428 | return this.children[0];
|
429 | }
|
430 | },
|
431 | 'lastChild': {
|
432 | get: function get() {
|
433 | var children;
|
434 | children = this.children;
|
435 | return children[children.length - 1];
|
436 | }
|
437 | },
|
438 | 'index': {
|
439 | get: function get() {
|
440 | var parent;
|
441 |
|
442 | if (!(parent = this.parent)) {
|
443 | return null;
|
444 | } else {
|
445 | return parent.children.indexOf(this);
|
446 | }
|
447 | }
|
448 | },
|
449 | 'indexType': {
|
450 | get: function get() {
|
451 | return _getIndexByProp(this, 'type');
|
452 | }
|
453 | },
|
454 | 'indexRef': {
|
455 | get: function get() {
|
456 | return _getIndexByProp(this, 'ref');
|
457 | }
|
458 | }
|
459 | });
|
460 |
|
461 | _getParents = function _getParents(targetEl, filter) {
|
462 | var isRef, nextParent, parents;
|
463 |
|
464 | if (!IS.function(filter) && !(isRef = IS.string(filter))) {
|
465 | filter = void 0;
|
466 | }
|
467 |
|
468 | parents = [];
|
469 | nextParent = targetEl.parent;
|
470 |
|
471 | while (nextParent) {
|
472 | parents.push(nextParent);
|
473 | nextParent = nextParent.parent;
|
474 |
|
475 | if (isRef) {
|
476 | if (nextParent && nextParent.ref === filter) {
|
477 | nextParent = null;
|
478 | }
|
479 | } else if (filter) {
|
480 | if (filter(nextParent)) {
|
481 | nextParent = null;
|
482 | }
|
483 | }
|
484 | }
|
485 |
|
486 | return parents;
|
487 | };
|
488 |
|
489 | _getChildRefs2 = function _getChildRefs(target, freshCopy) {
|
490 | var child, childRefs, children, el, i, len, ref, refs;
|
491 |
|
492 | if (freshCopy || !target._childRefs) {
|
493 | target._childRefs = {};
|
494 | }
|
495 |
|
496 | refs = target._childRefs;
|
497 |
|
498 | if (target.ref) {
|
499 | refs[target.ref] = target;
|
500 | }
|
501 |
|
502 | children = target.children;
|
503 |
|
504 | if (children.length) {
|
505 | for (i = 0, len = children.length; i < len; i++) {
|
506 | child = children[i];
|
507 | childRefs = _getChildRefs2(child, freshCopy);
|
508 |
|
509 | for (ref in childRefs) {
|
510 | el = childRefs[ref];
|
511 | refs[ref] || (refs[ref] = el);
|
512 | }
|
513 | }
|
514 | }
|
515 |
|
516 | return refs;
|
517 | };
|
518 |
|
519 | _getIndexByProp = function _getIndexByProp(main, prop) {
|
520 | var parent;
|
521 |
|
522 | if (!(parent = main.parent)) {
|
523 | return null;
|
524 | } else {
|
525 | return parent.children.filter(function (child) {
|
526 | return child[prop] === main[prop];
|
527 | }).indexOf(main);
|
528 | }
|
529 | };
|
530 |
|
531 | _filterElements = function _filterElements(array) {
|
532 | var i, item, len, output;
|
533 |
|
534 | if (!array.length) {
|
535 | return array;
|
536 | } else {
|
537 | output = [];
|
538 |
|
539 | for (i = 0, len = array.length; i < len; i++) {
|
540 | item = array[i];
|
541 |
|
542 | if (item.type !== 'text') {
|
543 | output.push(item);
|
544 | }
|
545 | }
|
546 |
|
547 | return output;
|
548 | }
|
549 | };
|
550 |
|
551 | ;
|
552 | var CACHED_FN_INSERTED, baseStateTriggers;
|
553 | baseStateTriggers = {
|
554 | 'hover': {
|
555 | on: 'mouseenter',
|
556 | off: 'mouseleave',
|
557 | bubbles: true
|
558 | },
|
559 | 'focus': {
|
560 | on: 'focus',
|
561 | off: 'blur',
|
562 | bubbles: true
|
563 | }
|
564 | };
|
565 |
|
566 | QuickElement.prototype._normalizeOptions = function () {
|
567 | var base1, base2, base3, base4, base5;
|
568 |
|
569 | if (this.options.relatedInstance) {
|
570 | (base1 = this.options).related || (base1.related = this.options.relatedInstance);
|
571 | this.options.relatedInstance = null;
|
572 | }
|
573 |
|
574 | this.related = (base2 = this.options).related != null ? base2.related : base2.related = this;
|
575 |
|
576 | if (this.options.class) {
|
577 | this.options.className = this.options.class;
|
578 | }
|
579 |
|
580 | if (this.options.url) {
|
581 | this.options.href = this.options.url;
|
582 | }
|
583 |
|
584 | if ((base3 = this.options).unpassableStates == null) {
|
585 | base3.unpassableStates = [];
|
586 | }
|
587 |
|
588 | if ((base4 = this.options).passStateToChildren == null) {
|
589 | base4.passStateToChildren = true;
|
590 | }
|
591 |
|
592 | if ((base5 = this.options).passDataToChildren == null) {
|
593 | base5.passDataToChildren = true;
|
594 | }
|
595 |
|
596 | this.options.stateTriggers = this.options.stateTriggers ? extend.clone.deep(baseStateTriggers, this.options.stateTriggers) : baseStateTriggers;
|
597 |
|
598 | if (this.type === 'text') {
|
599 | extend(this, this._parseTexts(this.options.text, this._texts));
|
600 | } else {
|
601 | extend(this, this._parseStyles(this.options.style, this._styles));
|
602 | }
|
603 | };
|
604 |
|
605 | QuickElement.prototype._parseStyles = function (styles, store) {
|
606 | var _mediaStates, _providedStates, _providedStatesShared, _stateShared, _styles, base, _flattenNestedStates, forceStyle, i, keys, len, specialStates, state, stateStyles, state_, states;
|
607 |
|
608 | if (!IS.objectPlain(styles)) {
|
609 | return;
|
610 | }
|
611 |
|
612 | keys = Object.keys(styles);
|
613 | states = keys.filter(function (key) {
|
614 | return helpers.isStateStyle(key);
|
615 | });
|
616 | specialStates = helpers.removeItem(states.slice(), '$base');
|
617 | _mediaStates = states.filter(function (key) {
|
618 | return key[0] === '@';
|
619 | }).map(function (state) {
|
620 | return state.slice(1);
|
621 | });
|
622 | _providedStates = states.map(function (state) {
|
623 | return state.slice(1);
|
624 | });
|
625 | _styles = store || {};
|
626 | _stateShared = _providedStatesShared = void 0;
|
627 | base = !helpers.includes(states, '$base') ? styles : styles.$base;
|
628 | _styles.base = helpers.registerStyle(base, 0, forceStyle = this.options.forceStyle);
|
629 |
|
630 | if (specialStates.length) {
|
631 | _flattenNestedStates = function flattenNestedStates(styleObject, chain, level) {
|
632 | var hasNonStateProps, i, len, output, state, stateChain, state_, styleKeys;
|
633 | styleKeys = Object.keys(styleObject);
|
634 | output = {};
|
635 | hasNonStateProps = false;
|
636 |
|
637 | for (i = 0, len = styleKeys.length; i < len; i++) {
|
638 | state = styleKeys[i];
|
639 |
|
640 | if (!helpers.isStateStyle(state)) {
|
641 | hasNonStateProps = true;
|
642 | output[state] = styleObject[state];
|
643 | } else {
|
644 | chain.push(state_ = state.slice(1));
|
645 | stateChain = new (require(33))(chain);
|
646 |
|
647 | if (_stateShared == null) {
|
648 | _stateShared = [];
|
649 | }
|
650 |
|
651 | if (_providedStatesShared == null) {
|
652 | _providedStatesShared = [];
|
653 | }
|
654 |
|
655 | _providedStatesShared.push(stateChain);
|
656 |
|
657 | if (state[0] === '@') {
|
658 | _mediaStates.push(state_);
|
659 | }
|
660 |
|
661 | _styles[stateChain.string] = helpers.registerStyle(_flattenNestedStates(styleObject[state], chain, level + 1), level + 1, forceStyle);
|
662 | }
|
663 | }
|
664 |
|
665 | if (hasNonStateProps) {
|
666 | return output;
|
667 | }
|
668 | };
|
669 |
|
670 | for (i = 0, len = specialStates.length; i < len; i++) {
|
671 | state = specialStates[i];
|
672 | state_ = state.slice(1);
|
673 | stateStyles = _flattenNestedStates(styles[state], [state_], 1);
|
674 |
|
675 | if (stateStyles) {
|
676 | _styles[state_] = helpers.registerStyle(stateStyles, 1);
|
677 | }
|
678 | }
|
679 | }
|
680 |
|
681 | return {
|
682 | _styles: _styles,
|
683 | _mediaStates: _mediaStates,
|
684 | _stateShared: _stateShared,
|
685 | _providedStates: _providedStates,
|
686 | _providedStatesShared: _providedStatesShared
|
687 | };
|
688 | };
|
689 |
|
690 | QuickElement.prototype._parseTexts = function (texts, store) {
|
691 | var _providedStates, _texts, i, len, state, states;
|
692 |
|
693 | if (!IS.objectPlain(texts)) {
|
694 | return;
|
695 | }
|
696 |
|
697 | states = Object.keys(texts).map(function (state) {
|
698 | return state.slice(1);
|
699 | });
|
700 | _providedStates = states.filter(function (state) {
|
701 | return state !== 'base';
|
702 | });
|
703 | _texts = store || {};
|
704 | _texts = {
|
705 | base: ''
|
706 | };
|
707 |
|
708 | for (i = 0, len = states.length; i < len; i++) {
|
709 | state = states[i];
|
710 | _texts[state] = texts['$' + state];
|
711 | }
|
712 |
|
713 | return {
|
714 | _texts: _texts,
|
715 | _providedStates: _providedStates
|
716 | };
|
717 | };
|
718 |
|
719 | QuickElement.prototype._applyOptions = function () {
|
720 | var _this = this;
|
721 |
|
722 | var event, handler, method, ref, ref1, ref2, value;
|
723 |
|
724 | if (ref = this.options.id || this.options.ref) {
|
725 | this.attr('data-ref', this.ref = ref);
|
726 | }
|
727 |
|
728 | if (this.options.id) {
|
729 | this.el.id = this.options.id;
|
730 | }
|
731 |
|
732 | if (this.options.className) {
|
733 | this.el.className = this.options.className;
|
734 | }
|
735 |
|
736 | if (this.options.src) {
|
737 | this.el.src = this.options.src;
|
738 | }
|
739 |
|
740 | if (this.options.href) {
|
741 | this.el.href = this.options.href;
|
742 | }
|
743 |
|
744 | if (this.options.type) {
|
745 | this.el.type = this.options.type;
|
746 | }
|
747 |
|
748 | if (this.options.name) {
|
749 | this.el.name = this.options.name;
|
750 | }
|
751 |
|
752 | if (this.options.value) {
|
753 | this.el.value = this.options.value;
|
754 | }
|
755 |
|
756 | if (this.options.selected) {
|
757 | this.el.selected = this.options.selected;
|
758 | }
|
759 |
|
760 | if (this.options.checked) {
|
761 | this.el.checked = this.options.checked;
|
762 | }
|
763 |
|
764 | if (this.options.props) {
|
765 | this.prop(this.options.props);
|
766 | }
|
767 |
|
768 | if (this.options.attrs) {
|
769 | this.attr(this.options.attrs);
|
770 | }
|
771 |
|
772 | this._applyRegisteredStyle(this._styles.base, null, null, this.options.styleAfterInsert);
|
773 |
|
774 | if (this._texts) {
|
775 | this.text = this._texts.base;
|
776 | }
|
777 |
|
778 | this.on('inserted', CACHED_FN_INSERTED, false, true);
|
779 |
|
780 | if (this.options.invokeComputersOnce) {
|
781 | this._invokedComputers = {};
|
782 | }
|
783 |
|
784 | if (this.options.recalcOnResize) {
|
785 | window.addEventListener('resize', function () {
|
786 | return _this.recalcStyle();
|
787 | });
|
788 | }
|
789 |
|
790 | if (this.options.events) {
|
791 | ref1 = this.options.events;
|
792 |
|
793 | for (event in ref1) {
|
794 | handler = ref1[event];
|
795 | this.on(event, handler);
|
796 | }
|
797 | }
|
798 |
|
799 | if (this.options.methods) {
|
800 | ref2 = this.options.methods;
|
801 |
|
802 | for (method in ref2) {
|
803 | value = ref2[method];
|
804 |
|
805 | if (!this[method]) {
|
806 | if (IS.function(value)) {
|
807 | this[method] = value;
|
808 | } else if (IS.object(value)) {
|
809 | Object.defineProperty(this, method, {
|
810 | configurable: true,
|
811 | get: value.get,
|
812 | set: value.set
|
813 | });
|
814 | }
|
815 | }
|
816 | }
|
817 | }
|
818 |
|
819 | if (this.type !== 'text' && IS.object(this.options.text)) {
|
820 | this.append(_QuickDom('text', {
|
821 | text: this.options.text
|
822 | }));
|
823 | }
|
824 | };
|
825 |
|
826 | QuickElement.prototype._postCreation = function (data) {
|
827 | if (this.options.computers) {
|
828 | if (data && this.options.data) {
|
829 | data = extend.clone(this.options.data, data);
|
830 | }
|
831 |
|
832 | data || (data = this.options.data);
|
833 | this.applyData(data, false);
|
834 |
|
835 | if (this.options.computers._init) {
|
836 | this._runComputer('_init', data);
|
837 | }
|
838 | }
|
839 |
|
840 | if (this.options.state) {
|
841 | this.state(this.options.state);
|
842 | }
|
843 | };
|
844 |
|
845 | QuickElement.prototype._attachStateEvents = function (force) {
|
846 | var _this2 = this;
|
847 |
|
848 | var states;
|
849 | states = Object.keys(this.options.stateTriggers);
|
850 | states.forEach(function (state) {
|
851 | var disabler, enabler, trigger;
|
852 | trigger = _this2.options.stateTriggers[state];
|
853 |
|
854 | if (!helpers.includes(_this2._providedStates, state) && !force && !trigger.force) {
|
855 | return;
|
856 | }
|
857 |
|
858 | enabler = IS.string(trigger) ? trigger : trigger.on;
|
859 |
|
860 | if (IS.object(trigger)) {
|
861 | disabler = trigger.off;
|
862 | }
|
863 |
|
864 | _this2._listenTo(enabler, function () {
|
865 | return _this2.state(state, true, trigger.bubbles);
|
866 | });
|
867 |
|
868 | if (disabler) {
|
869 | return _this2._listenTo(disabler, function () {
|
870 | return _this2.state(state, false, trigger.bubbles);
|
871 | });
|
872 | }
|
873 | });
|
874 | };
|
875 |
|
876 | QuickElement.prototype._proxyParent = function () {
|
877 | var parent;
|
878 | parent = void 0;
|
879 | return Object.defineProperty(this, '_parent', {
|
880 | get: function get() {
|
881 | return parent;
|
882 | },
|
883 | set: function set(newParent) {
|
884 | var _this3 = this;
|
885 |
|
886 | var lastParent;
|
887 |
|
888 | if (parent = newParent) {
|
889 | lastParent = this.parents.slice(-1)[0];
|
890 |
|
891 | if (lastParent.raw === document.documentElement) {
|
892 | this._unproxyParent(newParent);
|
893 | } else {
|
894 | parent.on('inserted', function () {
|
895 | if (parent === newParent) {
|
896 | return _this3._unproxyParent(newParent);
|
897 | }
|
898 | });
|
899 | }
|
900 | }
|
901 | }
|
902 | });
|
903 | };
|
904 |
|
905 | QuickElement.prototype._unproxyParent = function (newParent) {
|
906 | delete this._parent;
|
907 | this._parent = newParent;
|
908 | this.emitPrivate('inserted', newParent);
|
909 | };
|
910 |
|
911 | CACHED_FN_INSERTED = function CACHED_FN_INSERTED() {
|
912 | var i, len, mediaStates, queryString, results;
|
913 | this._inserted = this;
|
914 |
|
915 | if (this.options.styleAfterInsert) {
|
916 | this.recalcStyle();
|
917 | }
|
918 |
|
919 | if ((mediaStates = this._mediaStates) && this._mediaStates.length) {
|
920 | this._mediaStates = Object.create(null);
|
921 | results = [];
|
922 |
|
923 | for (i = 0, len = mediaStates.length; i < len; i++) {
|
924 | queryString = mediaStates[i];
|
925 | results.push(this._mediaStates[queryString] = MediaQuery.register(this, queryString));
|
926 | }
|
927 |
|
928 | return results;
|
929 | }
|
930 | };
|
931 |
|
932 | ;
|
933 | var regexWhitespace;
|
934 | regexWhitespace = /\s+/;
|
935 |
|
936 | QuickElement.prototype.on = function (eventNames, callback, useCapture, isPrivate) {
|
937 | var _this4 = this;
|
938 |
|
939 | var callbackRef, split;
|
940 |
|
941 | if (this._eventCallbacks == null) {
|
942 | this._eventCallbacks = {
|
943 | __refs: {}
|
944 | };
|
945 | }
|
946 |
|
947 | if (IS.string(eventNames) && IS.function(callback)) {
|
948 | split = eventNames.split('.');
|
949 | callbackRef = split[1];
|
950 | eventNames = split[0];
|
951 |
|
952 | if (eventNames === 'inserted' && this._inserted) {
|
953 | callback.call(this, this._parent);
|
954 | return this;
|
955 | }
|
956 |
|
957 | eventNames.split(regexWhitespace).forEach(function (eventName) {
|
958 | if (!_this4._eventCallbacks[eventName]) {
|
959 | _this4._eventCallbacks[eventName] = [];
|
960 |
|
961 | if (!isPrivate) {
|
962 | _this4._listenTo(eventName, function (event) {
|
963 | return _this4._invokeHandlers(eventName, event);
|
964 | }, useCapture);
|
965 | }
|
966 | }
|
967 |
|
968 | if (callbackRef) {
|
969 | _this4._eventCallbacks.__refs[callbackRef] = callback;
|
970 | }
|
971 |
|
972 | return _this4._eventCallbacks[eventName].push(callback);
|
973 | });
|
974 | }
|
975 |
|
976 | return this;
|
977 | };
|
978 |
|
979 | QuickElement.prototype.once = function (eventNames, callback) {
|
980 | var _this5 = this;
|
981 |
|
982 | var _onceCallback;
|
983 |
|
984 | if (IS.string(eventNames) && IS.function(callback)) {
|
985 | this.on(eventNames, _onceCallback = function onceCallback(event) {
|
986 | _this5.off(eventNames, _onceCallback);
|
987 |
|
988 | return callback.call(_this5, event);
|
989 | });
|
990 | }
|
991 |
|
992 | return this;
|
993 | };
|
994 |
|
995 | QuickElement.prototype.off = function (eventNames, callback) {
|
996 | var _this6 = this;
|
997 |
|
998 | var callbackRef, eventName, split;
|
999 |
|
1000 | if (this._eventCallbacks == null) {
|
1001 | this._eventCallbacks = {
|
1002 | __refs: {}
|
1003 | };
|
1004 | }
|
1005 |
|
1006 | if (!IS.string(eventNames)) {
|
1007 | for (eventName in this._eventCallbacks) {
|
1008 | this.off(eventName);
|
1009 | }
|
1010 | } else {
|
1011 | split = eventNames.split('.');
|
1012 | callbackRef = split[1];
|
1013 | eventNames = split[0];
|
1014 | eventNames.split(regexWhitespace).forEach(function (eventName) {
|
1015 | if (_this6._eventCallbacks[eventName]) {
|
1016 | if (callback == null) {
|
1017 | callback = _this6._eventCallbacks.__refs[callbackRef];
|
1018 | }
|
1019 |
|
1020 | if (IS.function(callback)) {
|
1021 | return helpers.removeItem(_this6._eventCallbacks[eventName], callback);
|
1022 | } else if (!callbackRef) {
|
1023 | return _this6._eventCallbacks[eventName].length = 0;
|
1024 | }
|
1025 | }
|
1026 | });
|
1027 | }
|
1028 |
|
1029 | return this;
|
1030 | };
|
1031 |
|
1032 | QuickElement.prototype.emit = function (eventName) {
|
1033 | var bubbles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
1034 | var cancelable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
1035 | var data = arguments.length > 3 ? arguments[3] : undefined;
|
1036 | var event;
|
1037 |
|
1038 | if (eventName && IS.string(eventName)) {
|
1039 | event = document.createEvent('Event');
|
1040 | event.initEvent(eventName, bubbles, cancelable);
|
1041 |
|
1042 | if (data && _typeof(data) === 'object') {
|
1043 | extend(event, data);
|
1044 | }
|
1045 |
|
1046 | this.el.dispatchEvent(event);
|
1047 | }
|
1048 |
|
1049 | return this;
|
1050 | };
|
1051 |
|
1052 | QuickElement.prototype.emitPrivate = function (eventName, arg) {
|
1053 | var ref;
|
1054 |
|
1055 | if (eventName && IS.string(eventName) && ((ref = this._eventCallbacks) != null ? ref[eventName] : void 0)) {
|
1056 | this._invokeHandlers(eventName, arg);
|
1057 | }
|
1058 |
|
1059 | return this;
|
1060 | };
|
1061 |
|
1062 | QuickElement.prototype._invokeHandlers = function (eventName, arg) {
|
1063 | var callbacks, cb, i, len;
|
1064 | callbacks = this._eventCallbacks[eventName].slice();
|
1065 |
|
1066 | for (i = 0, len = callbacks.length; i < len; i++) {
|
1067 | cb = callbacks[i];
|
1068 | cb.call(this, arg);
|
1069 | }
|
1070 | };
|
1071 |
|
1072 |
|
1073 |
|
1074 | QuickElement.prototype._listenTo = function (eventName, callback, useCapture) {
|
1075 | var eventNameToListenFor, listenMethod;
|
1076 | listenMethod = this.el.addEventListener ? 'addEventListener' : 'attachEvent';
|
1077 | eventNameToListenFor = this.el.addEventListener ? eventName : "on".concat(eventName);
|
1078 | this.el[listenMethod](eventNameToListenFor, callback, useCapture);
|
1079 | return this;
|
1080 | };
|
1081 |
|
1082 | ;
|
1083 | var DUMMY_ARRAY;
|
1084 | DUMMY_ARRAY = [];
|
1085 |
|
1086 | QuickElement.prototype.state = function (targetState, value, bubbles, source) {
|
1087 | var activeStates, child, desiredValue, i, j, key, keys, len, prop, ref, toggle;
|
1088 |
|
1089 | if (arguments.length === 0) {
|
1090 | return this._state.slice();
|
1091 | }
|
1092 |
|
1093 | if (arguments.length === 1) {
|
1094 | if (IS.string(targetState)) {
|
1095 | return helpers.includes(this._state, targetState);
|
1096 | } else if (IS.object(targetState)) {
|
1097 | keys = Object.keys(targetState);
|
1098 | i = -1;
|
1099 |
|
1100 | while (key = keys[++i]) {
|
1101 | this.state(key, targetState[key]);
|
1102 | }
|
1103 |
|
1104 | return this;
|
1105 | }
|
1106 | } else if (this._statePipeTarget && source !== this) {
|
1107 | this._statePipeTarget.state(targetState, value, bubbles, this);
|
1108 |
|
1109 | return this;
|
1110 | } else if (IS.string(targetState)) {
|
1111 | if (targetState[0] === '$') {
|
1112 | targetState = targetState.slice(1);
|
1113 | }
|
1114 |
|
1115 | if (targetState === 'base') {
|
1116 | return this;
|
1117 | }
|
1118 |
|
1119 | desiredValue = !!value;
|
1120 |
|
1121 | activeStates = this._getActiveStates(targetState, false);
|
1122 |
|
1123 | if (this.state(targetState) !== desiredValue) {
|
1124 | prop = this.type === 'text' ? 'Text' : 'Style';
|
1125 |
|
1126 | if (desiredValue) {
|
1127 |
|
1128 | this._state.push(targetState);
|
1129 |
|
1130 | toggle = 'ON';
|
1131 | } else {
|
1132 | helpers.removeItem(this._state, targetState);
|
1133 | toggle = 'OFF';
|
1134 | }
|
1135 |
|
1136 | this['_turn' + prop + toggle](targetState, activeStates);
|
1137 | this.emitPrivate("stateChange:".concat(targetState), desiredValue);
|
1138 | }
|
1139 |
|
1140 |
|
1141 | if (!helpers.includes(this.options.unpassableStates, targetState)) {
|
1142 | if (bubbles) {
|
1143 | if (this.parent) {
|
1144 | this._parent.state(targetState, value, true, source || this);
|
1145 | }
|
1146 | } else if (this.options.passStateToChildren) {
|
1147 | ref = this._children;
|
1148 |
|
1149 | for (j = 0, len = ref.length; j < len; j++) {
|
1150 | child = ref[j];
|
1151 | child.state(targetState, value, false, source || this);
|
1152 | }
|
1153 | }
|
1154 | }
|
1155 |
|
1156 | return this;
|
1157 | }
|
1158 | };
|
1159 |
|
1160 | QuickElement.prototype.toggleState = function (targetState) {
|
1161 | return this.state(targetState, !this.state(targetState));
|
1162 | };
|
1163 |
|
1164 | QuickElement.prototype.resetState = function () {
|
1165 | var activeState, j, len, ref;
|
1166 | ref = this._state.slice();
|
1167 |
|
1168 | for (j = 0, len = ref.length; j < len; j++) {
|
1169 | activeState = ref[j];
|
1170 | this.state(activeState, false);
|
1171 | }
|
1172 |
|
1173 | return this;
|
1174 | };
|
1175 |
|
1176 | QuickElement.prototype.pipeState = function (targetEl) {
|
1177 | var activeState, j, len, ref;
|
1178 |
|
1179 | if (targetEl) {
|
1180 | targetEl = helpers.normalizeGivenEl(targetEl);
|
1181 |
|
1182 | if (IS.quickDomEl(targetEl) && targetEl !== this) {
|
1183 | this._statePipeTarget = targetEl;
|
1184 | ref = this._state;
|
1185 |
|
1186 | for (j = 0, len = ref.length; j < len; j++) {
|
1187 | activeState = ref[j];
|
1188 | targetEl.state(activeState, true);
|
1189 | }
|
1190 | }
|
1191 | } else if (targetEl === false) {
|
1192 | delete this._statePipeTarget;
|
1193 | }
|
1194 |
|
1195 | return this;
|
1196 | };
|
1197 |
|
1198 | QuickElement.prototype._applyRegisteredStyle = function (targetStyle, superiorStates, includeBase, skipFns) {
|
1199 | var className, entry, j, k, len, len1, ref, ref1, superiorStyles;
|
1200 |
|
1201 | if (targetStyle) {
|
1202 | ref = targetStyle.className;
|
1203 |
|
1204 | for (j = 0, len = ref.length; j < len; j++) {
|
1205 | className = ref[j];
|
1206 | this.addClass(className);
|
1207 | }
|
1208 |
|
1209 | if (targetStyle.fns.length && !skipFns) {
|
1210 | if (superiorStates) {
|
1211 | superiorStyles = this._resolveFnStyles(superiorStates, includeBase);
|
1212 | }
|
1213 |
|
1214 | ref1 = targetStyle.fns;
|
1215 |
|
1216 | for (k = 0, len1 = ref1.length; k < len1; k++) {
|
1217 | entry = ref1[k];
|
1218 |
|
1219 | if (!(superiorStyles && superiorStyles[entry[0]])) {
|
1220 | this.style(entry[0], entry[1]);
|
1221 | }
|
1222 | }
|
1223 | }
|
1224 | }
|
1225 | };
|
1226 |
|
1227 | QuickElement.prototype._removeRegisteredStyle = function (targetStyle, superiorStates, includeBase) {
|
1228 | var className, entry, j, k, len, len1, ref, ref1, resetValue, superiorStyles;
|
1229 | ref = targetStyle.className;
|
1230 |
|
1231 | for (j = 0, len = ref.length; j < len; j++) {
|
1232 | className = ref[j];
|
1233 | this.removeClass(className);
|
1234 | }
|
1235 |
|
1236 | if (targetStyle.fns.length) {
|
1237 | if (superiorStates) {
|
1238 | superiorStyles = this._resolveFnStyles(superiorStates, includeBase);
|
1239 | }
|
1240 |
|
1241 | ref1 = targetStyle.fns;
|
1242 |
|
1243 | for (k = 0, len1 = ref1.length; k < len1; k++) {
|
1244 | entry = ref1[k];
|
1245 | resetValue = superiorStyles && superiorStyles[entry[0]] || null;
|
1246 | this.style(entry[0], resetValue);
|
1247 | }
|
1248 | }
|
1249 | };
|
1250 |
|
1251 | QuickElement.prototype._turnStyleON = function (targetState, activeStates) {
|
1252 | var j, len, sharedStates, skipFns, stateChain;
|
1253 | skipFns = this.options.styleAfterInsert && !this._inserted;
|
1254 |
|
1255 | if (this._styles[targetState]) {
|
1256 | this._applyRegisteredStyle(this._styles[targetState], this._getSuperiorStates(targetState, activeStates), false, skipFns);
|
1257 | }
|
1258 |
|
1259 | if (this._providedStatesShared) {
|
1260 | sharedStates = this._getSharedStates(targetState);
|
1261 |
|
1262 | for (j = 0, len = sharedStates.length; j < len; j++) {
|
1263 | stateChain = sharedStates[j];
|
1264 |
|
1265 | if (!helpers.includes(this._stateShared, stateChain.string)) {
|
1266 | this._stateShared.push(stateChain.string);
|
1267 | }
|
1268 |
|
1269 | this._applyRegisteredStyle(this._styles[stateChain.string], null, null, skipFns);
|
1270 | }
|
1271 | }
|
1272 | };
|
1273 |
|
1274 | QuickElement.prototype._turnStyleOFF = function (targetState, activeStates) {
|
1275 | var activeSharedStates, j, len, sharedStates, stateChain, targetStyle;
|
1276 |
|
1277 | if (this._styles[targetState]) {
|
1278 | this._removeRegisteredStyle(this._styles[targetState], activeStates, true);
|
1279 | }
|
1280 |
|
1281 | if (this._providedStatesShared) {
|
1282 | sharedStates = this._getSharedStates(targetState);
|
1283 |
|
1284 | if (sharedStates.length === 0) {
|
1285 | return;
|
1286 | }
|
1287 |
|
1288 | for (j = 0, len = sharedStates.length; j < len; j++) {
|
1289 | stateChain = sharedStates[j];
|
1290 | helpers.removeItem(this._stateShared, stateChain.string);
|
1291 | targetStyle = this._styles[stateChain.string];
|
1292 |
|
1293 | if (targetStyle.fns.length && this._stateShared.length && !activeSharedStates) {
|
1294 | activeSharedStates = this._stateShared.filter(function (state) {
|
1295 | return !helpers.includes(state, targetState);
|
1296 | });
|
1297 | activeStates = activeStates.concat(activeSharedStates);
|
1298 | }
|
1299 |
|
1300 | this._removeRegisteredStyle(targetStyle, activeStates, true);
|
1301 | }
|
1302 | }
|
1303 | };
|
1304 |
|
1305 | QuickElement.prototype._turnTextON = function (targetState, activeStates) {
|
1306 | var superiorStates, targetText;
|
1307 |
|
1308 | if (this._texts && IS.string(targetText = this._texts[targetState])) {
|
1309 | superiorStates = this._getSuperiorStates(targetState, activeStates);
|
1310 |
|
1311 | if (!superiorStates.length) {
|
1312 | this.text = targetText;
|
1313 | }
|
1314 | }
|
1315 | };
|
1316 |
|
1317 | QuickElement.prototype._turnTextOFF = function (targetState, activeStates) {
|
1318 | var targetText;
|
1319 |
|
1320 | if (this._texts && IS.string(targetText = this._texts[targetState])) {
|
1321 | activeStates = activeStates.filter(function (state) {
|
1322 | return state !== targetState;
|
1323 | });
|
1324 | targetText = this._texts[activeStates[activeStates.length - 1]];
|
1325 |
|
1326 | if (targetText == null) {
|
1327 | targetText = this._texts.base;
|
1328 | }
|
1329 |
|
1330 | this.text = targetText;
|
1331 | }
|
1332 | };
|
1333 |
|
1334 | QuickElement.prototype._getActiveStates = function (stateToExclude) {
|
1335 | var includeSharedStates = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
1336 | var activeStates, j, len, plainStates, state;
|
1337 |
|
1338 | if (!this._providedStates) {
|
1339 | return DUMMY_ARRAY;
|
1340 | }
|
1341 |
|
1342 | activeStates = plainStates = this._state;
|
1343 |
|
1344 | if (stateToExclude) {
|
1345 | plainStates = [];
|
1346 |
|
1347 | for (j = 0, len = activeStates.length; j < len; j++) {
|
1348 | state = activeStates[j];
|
1349 |
|
1350 | if (state !== stateToExclude) {
|
1351 | plainStates.push(state);
|
1352 | }
|
1353 | }
|
1354 | }
|
1355 |
|
1356 | if (!includeSharedStates || !this._providedStatesShared) {
|
1357 | return plainStates;
|
1358 | } else {
|
1359 | return plainStates.concat(this._stateShared);
|
1360 | }
|
1361 | };
|
1362 |
|
1363 | QuickElement.prototype._getSuperiorStates = function (targetState, activeStates) {
|
1364 | var candidate, j, len, superior, targetStateIndex;
|
1365 | targetStateIndex = this._providedStates.indexOf(targetState);
|
1366 |
|
1367 | if (targetStateIndex === this._providedStates.length - 1) {
|
1368 | return DUMMY_ARRAY;
|
1369 | }
|
1370 |
|
1371 | superior = [];
|
1372 |
|
1373 | for (j = 0, len = activeStates.length; j < len; j++) {
|
1374 | candidate = activeStates[j];
|
1375 |
|
1376 | if (this._providedStates.indexOf(candidate) > targetStateIndex) {
|
1377 | superior.push(candidate);
|
1378 | }
|
1379 | }
|
1380 |
|
1381 | return superior;
|
1382 | };
|
1383 |
|
1384 | QuickElement.prototype._getSharedStates = function (targetState) {
|
1385 | var activeStates, j, len, ref, sharedStates, stateChain;
|
1386 | activeStates = this._state;
|
1387 | sharedStates = [];
|
1388 | ref = this._providedStatesShared;
|
1389 |
|
1390 | for (j = 0, len = ref.length; j < len; j++) {
|
1391 | stateChain = ref[j];
|
1392 |
|
1393 | if (stateChain.includes(targetState) && stateChain.isApplicable(targetState, activeStates)) {
|
1394 | sharedStates.push(stateChain);
|
1395 | }
|
1396 | }
|
1397 |
|
1398 | return sharedStates;
|
1399 | };
|
1400 |
|
1401 | QuickElement.prototype._resolveFnStyles = function (states, includeBase) {
|
1402 | var entry, j, k, len, len1, output, ref, state;
|
1403 |
|
1404 | if (includeBase) {
|
1405 | states = ['base'].concat(states);
|
1406 | }
|
1407 |
|
1408 | output = {};
|
1409 |
|
1410 | for (j = 0, len = states.length; j < len; j++) {
|
1411 | state = states[j];
|
1412 |
|
1413 | if (this._styles[state] && this._styles[state].fns.length) {
|
1414 | ref = this._styles[state].fns;
|
1415 |
|
1416 | for (k = 0, len1 = ref.length; k < len1; k++) {
|
1417 | entry = ref[k];
|
1418 | output[entry[0]] = entry[1];
|
1419 | }
|
1420 | }
|
1421 | }
|
1422 |
|
1423 | return output;
|
1424 | };
|
1425 |
|
1426 | ;
|
1427 | |
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 |
|
1435 |
|
1436 |
|
1437 | var aspectRatioGetter, orientationGetter;
|
1438 |
|
1439 | QuickElement.prototype.style = function (property) {
|
1440 | var args, i, key, keys, result, value;
|
1441 |
|
1442 | if (this.type === 'text') {
|
1443 | return;
|
1444 | }
|
1445 |
|
1446 | args = arguments;
|
1447 |
|
1448 | if (IS.string(property)) {
|
1449 | value = typeof args[1] === 'function' ? args[1].call(this, this.related) : args[1];
|
1450 |
|
1451 | if (args[1] === null && IS.defined(this.currentStateStyle(property)) && !IS.function(this.currentStateStyle(property))) {
|
1452 | value = CSS.UNSET;
|
1453 | }
|
1454 |
|
1455 | result = CSS(this.el, property, value, this.options.forceStyle);
|
1456 |
|
1457 | if (args.length === 1) {
|
1458 |
|
1459 | if (this._inserted) {
|
1460 | return result;
|
1461 | } else if (!result) {
|
1462 | return result;
|
1463 | } else {
|
1464 | return '';
|
1465 | }
|
1466 | }
|
1467 | } else if (IS.object(property)) {
|
1468 | keys = Object.keys(property);
|
1469 | i = -1;
|
1470 |
|
1471 | while (key = keys[++i]) {
|
1472 | this.style(key, property[key]);
|
1473 | }
|
1474 | }
|
1475 |
|
1476 | return this;
|
1477 | };
|
1478 | |
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 | QuickElement.prototype.styleSafe = function (property, skipComputed) {
|
1488 | var computed, result, sample;
|
1489 |
|
1490 | if (this.type === 'text') {
|
1491 | return;
|
1492 | }
|
1493 |
|
1494 | sample = this.el.style[property];
|
1495 |
|
1496 | if (IS.string(sample) || IS.number(sample)) {
|
1497 | computed = skipComputed ? 0 : this.style(property);
|
1498 | result = computed || this.el.style[property] || this.currentStateStyle(property) || '';
|
1499 |
|
1500 | if (typeof result === 'function') {
|
1501 | return result.call(this, this.related);
|
1502 | } else {
|
1503 | return result;
|
1504 | }
|
1505 | }
|
1506 |
|
1507 | return this;
|
1508 | };
|
1509 |
|
1510 | QuickElement.prototype.styleParsed = function (property, skipComputed) {
|
1511 | return parseFloat(this.styleSafe(property, skipComputed));
|
1512 | };
|
1513 |
|
1514 | QuickElement.prototype.recalcStyle = function (recalcChildren) {
|
1515 | var child, j, len, ref, targetStyles;
|
1516 | targetStyles = this._resolveFnStyles(this._getActiveStates(), true);
|
1517 | this.style(targetStyles);
|
1518 |
|
1519 | if (recalcChildren) {
|
1520 | ref = this._children;
|
1521 |
|
1522 | for (j = 0, len = ref.length; j < len; j++) {
|
1523 | child = ref[j];
|
1524 | child.recalcStyle();
|
1525 | }
|
1526 | }
|
1527 |
|
1528 | return this;
|
1529 | };
|
1530 |
|
1531 | QuickElement.prototype.currentStateStyle = function (property) {
|
1532 | var i, state, states;
|
1533 |
|
1534 | if (property) {
|
1535 | if (this._state.length) {
|
1536 | states = this._state.slice();
|
1537 |
|
1538 | if (this._stateShared && this._stateShared.length) {
|
1539 | var _states;
|
1540 |
|
1541 | (_states = states).push.apply(_states, _toConsumableArray(this._stateShared));
|
1542 | }
|
1543 |
|
1544 | i = states.length;
|
1545 |
|
1546 | while (state = states[--i]) {
|
1547 | if (this._styles[state] && IS.defined(this._styles[state].rule[property])) {
|
1548 | return this._styles[state].rule[property];
|
1549 | }
|
1550 | }
|
1551 | }
|
1552 |
|
1553 | if (this._styles.base) {
|
1554 | return this._styles.base.rule[property];
|
1555 | }
|
1556 | }
|
1557 | };
|
1558 |
|
1559 | QuickElement.prototype.hide = function () {
|
1560 | return this.style('display', 'none');
|
1561 | };
|
1562 |
|
1563 | QuickElement.prototype.show = function (display) {
|
1564 | var ref;
|
1565 |
|
1566 | if (!display) {
|
1567 | display = this.currentStateStyle('display');
|
1568 |
|
1569 | if (display === 'none' || !display) {
|
1570 | display = 'block';
|
1571 | }
|
1572 | }
|
1573 |
|
1574 | if (display == null) {
|
1575 | display = ((ref = this._styles.base) != null ? ref.display : void 0) || 'block';
|
1576 | }
|
1577 |
|
1578 | return this.style('display', display);
|
1579 | };
|
1580 |
|
1581 | Object.defineProperties(QuickElement.prototype, {
|
1582 | 'orientation': orientationGetter = {
|
1583 | get: function get() {
|
1584 | if (this.width > this.height) {
|
1585 | return 'landscape';
|
1586 | } else {
|
1587 | return 'portrait';
|
1588 | }
|
1589 | }
|
1590 | },
|
1591 | 'aspectRatio': aspectRatioGetter = {
|
1592 | get: function get() {
|
1593 | return this.width / this.height;
|
1594 | }
|
1595 | },
|
1596 | 'rect': {
|
1597 | get: function get() {
|
1598 | return this.el.getBoundingClientRect();
|
1599 | }
|
1600 | },
|
1601 | 'width': {
|
1602 | get: function get() {
|
1603 | return parseFloat(this.style('width'));
|
1604 | },
|
1605 | set: function set(value) {
|
1606 | return this.style('width', value);
|
1607 | }
|
1608 | },
|
1609 | 'height': {
|
1610 | get: function get() {
|
1611 | return parseFloat(this.style('height'));
|
1612 | },
|
1613 | set: function set(value) {
|
1614 | return this.style('height', value);
|
1615 | }
|
1616 | }
|
1617 | });
|
1618 | ;
|
1619 |
|
1620 | QuickElement.prototype.attr = function (target, newValue) {
|
1621 | var i, key, keys;
|
1622 |
|
1623 | if (arguments.length === 1) {
|
1624 | if (typeof target === 'string') {
|
1625 | return this.el.getAttribute(target);
|
1626 | }
|
1627 |
|
1628 | if (IS.object(target)) {
|
1629 | keys = Object.keys(target);
|
1630 | i = -1;
|
1631 |
|
1632 | while (key = keys[++i]) {
|
1633 | this.attr(key, target[key]);
|
1634 | }
|
1635 | }
|
1636 | } else if (newValue === null) {
|
1637 | return this.el.removeAttribute(target);
|
1638 | } else {
|
1639 | this.el.setAttribute(target, newValue);
|
1640 | }
|
1641 |
|
1642 | return this;
|
1643 | };
|
1644 |
|
1645 | QuickElement.prototype.prop = function (target, newValue) {
|
1646 | var i, key, keys;
|
1647 |
|
1648 | if (arguments.length === 1) {
|
1649 | if (typeof target === 'string') {
|
1650 | return this.el[target];
|
1651 | }
|
1652 |
|
1653 | if (IS.object(target)) {
|
1654 | keys = Object.keys(target);
|
1655 | i = -1;
|
1656 |
|
1657 | while (key = keys[++i]) {
|
1658 | this.prop(key, target[key]);
|
1659 | }
|
1660 | }
|
1661 | } else {
|
1662 | this.el[target] = newValue;
|
1663 | }
|
1664 |
|
1665 | return this;
|
1666 | };
|
1667 |
|
1668 | ;
|
1669 |
|
1670 | QuickElement.prototype.toTemplate = function () {
|
1671 | return _QuickDom.template(this);
|
1672 | };
|
1673 |
|
1674 | QuickElement.prototype.clone = function () {
|
1675 | var activeState, callback, callbacks, child, elClone, eventName, i, j, k, len, len1, len2, newEl, options, ref, ref1, ref2;
|
1676 | elClone = this.el.cloneNode(false);
|
1677 | options = extend.clone(this.options, {
|
1678 | existing: elClone
|
1679 | });
|
1680 | newEl = new QuickElement(this.type, options);
|
1681 | ref = this._state;
|
1682 |
|
1683 | for (i = 0, len = ref.length; i < len; i++) {
|
1684 | activeState = ref[i];
|
1685 | newEl.state(activeState, true);
|
1686 | }
|
1687 |
|
1688 | ref1 = this.children;
|
1689 |
|
1690 | for (j = 0, len1 = ref1.length; j < len1; j++) {
|
1691 | child = ref1[j];
|
1692 | newEl.append(child.clone());
|
1693 | }
|
1694 |
|
1695 | ref2 = this._eventCallbacks;
|
1696 |
|
1697 | for (eventName in ref2) {
|
1698 | callbacks = ref2[eventName];
|
1699 |
|
1700 | for (k = 0, len2 = callbacks.length; k < len2; k++) {
|
1701 | callback = callbacks[k];
|
1702 | newEl.on(eventName, callback);
|
1703 | }
|
1704 | }
|
1705 |
|
1706 | return newEl;
|
1707 | };
|
1708 |
|
1709 | QuickElement.prototype.append = function (targetEl) {
|
1710 | var prevParent;
|
1711 |
|
1712 | if (targetEl) {
|
1713 | targetEl = helpers.normalizeGivenEl(targetEl);
|
1714 |
|
1715 | if (IS.quickDomEl(targetEl)) {
|
1716 | prevParent = targetEl.parent;
|
1717 |
|
1718 | if (prevParent) {
|
1719 | prevParent._removeChild(targetEl);
|
1720 | }
|
1721 |
|
1722 | this._children.push(targetEl);
|
1723 |
|
1724 | this.el.appendChild(targetEl.el);
|
1725 |
|
1726 | targetEl._refreshParent();
|
1727 |
|
1728 | }
|
1729 | }
|
1730 |
|
1731 | return this;
|
1732 | };
|
1733 |
|
1734 | QuickElement.prototype.appendTo = function (targetEl) {
|
1735 | if (targetEl) {
|
1736 | targetEl = helpers.normalizeGivenEl(targetEl);
|
1737 |
|
1738 | if (IS.quickDomEl(targetEl)) {
|
1739 | targetEl.append(this);
|
1740 | }
|
1741 | }
|
1742 |
|
1743 | return this;
|
1744 | };
|
1745 |
|
1746 | QuickElement.prototype.prepend = function (targetEl) {
|
1747 | var prevParent;
|
1748 |
|
1749 | if (targetEl) {
|
1750 | targetEl = helpers.normalizeGivenEl(targetEl);
|
1751 |
|
1752 | if (IS.quickDomEl(targetEl)) {
|
1753 | prevParent = targetEl.parent;
|
1754 |
|
1755 | if (prevParent) {
|
1756 | prevParent._removeChild(targetEl);
|
1757 | }
|
1758 |
|
1759 | this._children.unshift(targetEl);
|
1760 |
|
1761 | this.el.insertBefore(targetEl.el, this.el.firstChild);
|
1762 |
|
1763 | targetEl._refreshParent();
|
1764 |
|
1765 | }
|
1766 | }
|
1767 |
|
1768 | return this;
|
1769 | };
|
1770 |
|
1771 | QuickElement.prototype.prependTo = function (targetEl) {
|
1772 | if (targetEl) {
|
1773 | targetEl = helpers.normalizeGivenEl(targetEl);
|
1774 |
|
1775 | if (IS.quickDomEl(targetEl)) {
|
1776 | targetEl.prepend(this);
|
1777 | }
|
1778 | }
|
1779 |
|
1780 | return this;
|
1781 | };
|
1782 |
|
1783 | QuickElement.prototype.after = function (targetEl) {
|
1784 | var myIndex;
|
1785 |
|
1786 | if (targetEl && this.parent) {
|
1787 | targetEl = helpers.normalizeGivenEl(targetEl);
|
1788 |
|
1789 | if (IS.quickDomEl(targetEl)) {
|
1790 | myIndex = this.parent._children.indexOf(this);
|
1791 |
|
1792 | this.parent._children.splice(myIndex + 1, 0, targetEl);
|
1793 |
|
1794 | this.el.parentNode.insertBefore(targetEl.el, this.el.nextSibling);
|
1795 |
|
1796 | targetEl._refreshParent();
|
1797 |
|
1798 | }
|
1799 | }
|
1800 |
|
1801 | return this;
|
1802 | };
|
1803 |
|
1804 | QuickElement.prototype.insertAfter = function (targetEl) {
|
1805 | if (targetEl) {
|
1806 | targetEl = helpers.normalizeGivenEl(targetEl);
|
1807 |
|
1808 | if (IS.quickDomEl(targetEl)) {
|
1809 | targetEl.after(this);
|
1810 | }
|
1811 | }
|
1812 |
|
1813 | return this;
|
1814 | };
|
1815 |
|
1816 | QuickElement.prototype.before = function (targetEl) {
|
1817 | var myIndex;
|
1818 |
|
1819 | if (targetEl && this.parent) {
|
1820 | targetEl = helpers.normalizeGivenEl(targetEl);
|
1821 |
|
1822 | if (IS.quickDomEl(targetEl)) {
|
1823 | myIndex = this.parent._children.indexOf(this);
|
1824 |
|
1825 | this.parent._children.splice(myIndex, 0, targetEl);
|
1826 |
|
1827 | this.el.parentNode.insertBefore(targetEl.el, this.el);
|
1828 |
|
1829 | targetEl._refreshParent();
|
1830 |
|
1831 | }
|
1832 | }
|
1833 |
|
1834 | return this;
|
1835 | };
|
1836 |
|
1837 | QuickElement.prototype.insertBefore = function (targetEl) {
|
1838 | if (targetEl) {
|
1839 | targetEl = helpers.normalizeGivenEl(targetEl);
|
1840 |
|
1841 | if (IS.quickDomEl(targetEl)) {
|
1842 | targetEl.before(this);
|
1843 | }
|
1844 | }
|
1845 |
|
1846 | return this;
|
1847 | };
|
1848 |
|
1849 | QuickElement.prototype.detach = function () {
|
1850 | var ref;
|
1851 |
|
1852 | if ((ref = this.parent) != null) {
|
1853 | ref._removeChild(this);
|
1854 | }
|
1855 |
|
1856 | return this;
|
1857 | };
|
1858 |
|
1859 | QuickElement.prototype.remove = function () {
|
1860 | var eventName;
|
1861 | this.detach();
|
1862 | this.resetState();
|
1863 |
|
1864 | if (this._eventCallbacks) {
|
1865 | for (eventName in this._eventCallbacks) {
|
1866 | this._eventCallbacks[eventName].length = 0;
|
1867 | }
|
1868 | }
|
1869 |
|
1870 | return this;
|
1871 | };
|
1872 |
|
1873 | QuickElement.prototype.empty = function () {
|
1874 | var child, i, len, ref;
|
1875 | ref = this.children.slice();
|
1876 |
|
1877 | for (i = 0, len = ref.length; i < len; i++) {
|
1878 | child = ref[i];
|
1879 |
|
1880 | this._removeChild(child);
|
1881 | }
|
1882 |
|
1883 | return this;
|
1884 | };
|
1885 |
|
1886 | QuickElement.prototype.wrap = function (targetEl) {
|
1887 | var currentParent;
|
1888 |
|
1889 | if (targetEl) {
|
1890 | targetEl = helpers.normalizeGivenEl(targetEl);
|
1891 | currentParent = this.parent;
|
1892 |
|
1893 | if (IS.quickDomEl(targetEl) && targetEl !== this && targetEl !== this.parent) {
|
1894 | if (currentParent) {
|
1895 | currentParent._removeChild(this, !targetEl.parent ? targetEl : void 0);
|
1896 | }
|
1897 |
|
1898 | targetEl.append(this);
|
1899 | }
|
1900 | }
|
1901 |
|
1902 | return this;
|
1903 | };
|
1904 |
|
1905 | QuickElement.prototype.unwrap = function () {
|
1906 | var grandParent, parent, parentChildren, parentSibling;
|
1907 | parent = this.parent;
|
1908 |
|
1909 | if (parent) {
|
1910 | parentChildren = _QuickDom.batch(parent.children);
|
1911 | parentSibling = parent.next;
|
1912 | grandParent = parent.parent;
|
1913 |
|
1914 | if (grandParent) {
|
1915 | parent.detach();
|
1916 |
|
1917 | if (parentSibling) {
|
1918 | parentChildren.insertBefore(parentSibling);
|
1919 | } else {
|
1920 | parentChildren.appendTo(grandParent);
|
1921 | }
|
1922 | }
|
1923 | }
|
1924 |
|
1925 | return this;
|
1926 | };
|
1927 |
|
1928 | QuickElement.prototype.replace = function (targetEl) {
|
1929 | var ref;
|
1930 |
|
1931 | if (targetEl) {
|
1932 | targetEl = helpers.normalizeGivenEl(targetEl);
|
1933 |
|
1934 | if (IS.quickDomEl(targetEl) && targetEl !== this) {
|
1935 | targetEl.detach();
|
1936 |
|
1937 | if ((ref = this.parent) != null) {
|
1938 | ref._removeChild(this, targetEl);
|
1939 | }
|
1940 |
|
1941 | targetEl._refreshParent();
|
1942 |
|
1943 | }
|
1944 | }
|
1945 |
|
1946 | return this;
|
1947 | };
|
1948 |
|
1949 | QuickElement.prototype.hasClass = function (target) {
|
1950 | return helpers.includes(this.classList, target);
|
1951 | };
|
1952 |
|
1953 | QuickElement.prototype.addClass = function (target) {
|
1954 | var classList, targetIndex;
|
1955 | classList = this.classList;
|
1956 | targetIndex = classList.indexOf(target);
|
1957 |
|
1958 | if (targetIndex === -1) {
|
1959 | classList.push(target);
|
1960 | this.className = classList.length > 1 ? classList.join(' ') : classList[0];
|
1961 | }
|
1962 |
|
1963 | return this;
|
1964 | };
|
1965 |
|
1966 | QuickElement.prototype.removeClass = function (target) {
|
1967 | var classList, targetIndex;
|
1968 | classList = this.classList;
|
1969 | targetIndex = classList.indexOf(target);
|
1970 |
|
1971 | if (targetIndex !== -1) {
|
1972 | classList.splice(targetIndex, 1);
|
1973 | this.className = classList.length ? classList.join(' ') : '';
|
1974 | }
|
1975 |
|
1976 | return this;
|
1977 | };
|
1978 |
|
1979 | QuickElement.prototype.toggleClass = function (target) {
|
1980 | if (this.hasClass(target)) {
|
1981 | this.removeClass(target);
|
1982 | } else {
|
1983 | this.addClass(target);
|
1984 | }
|
1985 |
|
1986 | return this;
|
1987 | };
|
1988 |
|
1989 | QuickElement.prototype.setRef = function (target) {
|
1990 | this.ref = this.options.ref = target;
|
1991 | this.attr('data-ref', target);
|
1992 | return this;
|
1993 | };
|
1994 |
|
1995 | QuickElement.prototype._refreshParent = function () {
|
1996 | return this.parent;
|
1997 | };
|
1998 |
|
1999 | QuickElement.prototype._removeChild = function (targetChild, replacementChild) {
|
2000 | var indexOfChild;
|
2001 | indexOfChild = this.children.indexOf(targetChild);
|
2002 |
|
2003 | if (indexOfChild !== -1) {
|
2004 | if (replacementChild) {
|
2005 | this.el.replaceChild(replacementChild.el, targetChild.el);
|
2006 |
|
2007 | this._children.splice(indexOfChild, 1, replacementChild);
|
2008 | } else {
|
2009 | this.el.removeChild(targetChild.el);
|
2010 |
|
2011 | this._children.splice(indexOfChild, 1);
|
2012 | }
|
2013 | }
|
2014 |
|
2015 | return this;
|
2016 | };
|
2017 |
|
2018 | Object.defineProperties(QuickElement.prototype, {
|
2019 | 'html': {
|
2020 | get: function get() {
|
2021 | return this.el.innerHTML;
|
2022 | },
|
2023 | set: function set(newValue) {
|
2024 | return this.el.innerHTML = newValue;
|
2025 | }
|
2026 | },
|
2027 | 'text': {
|
2028 | get: function get() {
|
2029 | return this.el.textContent;
|
2030 | },
|
2031 | set: function set(newValue) {
|
2032 | return this.el.textContent = newValue;
|
2033 | }
|
2034 | },
|
2035 | 'className': {
|
2036 | get: function get() {
|
2037 | if (this.svg) {
|
2038 | return this.attr('class') || '';
|
2039 | } else {
|
2040 | return this.raw.className;
|
2041 | }
|
2042 | },
|
2043 | set: function set(newValue) {
|
2044 | if (this.svg) {
|
2045 | return this.attr('class', newValue);
|
2046 | } else {
|
2047 | return this.raw.className = newValue;
|
2048 | }
|
2049 | }
|
2050 | },
|
2051 | 'classList': {
|
2052 | get: function get() {
|
2053 | var list;
|
2054 | list = this.className.split(/\s+/);
|
2055 |
|
2056 | if (list[list.length - 1] === '') {
|
2057 | list.pop();
|
2058 | }
|
2059 |
|
2060 | if (list[0] === '') {
|
2061 | list.shift();
|
2062 | }
|
2063 |
|
2064 | return list;
|
2065 | }
|
2066 | }
|
2067 | });
|
2068 | ;
|
2069 |
|
2070 | QuickElement.prototype.updateOptions = function (options) {
|
2071 | if (IS.object(options)) {
|
2072 | this.options = options;
|
2073 |
|
2074 | this._normalizeOptions();
|
2075 |
|
2076 | this._applyOptions(this.options);
|
2077 | }
|
2078 |
|
2079 | return this;
|
2080 | };
|
2081 |
|
2082 | QuickElement.prototype.updateStateStyles = function (styles) {
|
2083 | var i, len, parsed, state, updatedStates;
|
2084 |
|
2085 | if (IS.objectPlain(styles)) {
|
2086 | extend.deep.concat(this, parsed = this._parseStyles(styles));
|
2087 |
|
2088 | if (parsed._styles) {
|
2089 | updatedStates = Object.keys(parsed._styles);
|
2090 |
|
2091 | for (i = 0, len = updatedStates.length; i < len; i++) {
|
2092 | state = updatedStates[i];
|
2093 |
|
2094 | if (this.state(state) || state === 'base') {
|
2095 | this._applyRegisteredStyle(this._styles[state], this._getActiveStates(state), false);
|
2096 | }
|
2097 | }
|
2098 | }
|
2099 | }
|
2100 |
|
2101 | return this;
|
2102 | };
|
2103 |
|
2104 | QuickElement.prototype.updateStateTexts = function (texts) {
|
2105 | var parsed;
|
2106 |
|
2107 | if (IS.objectPlain(texts)) {
|
2108 | extend.deep.concat(this, parsed = this._parseTexts(texts));
|
2109 | }
|
2110 |
|
2111 | return this;
|
2112 | };
|
2113 |
|
2114 | QuickElement.prototype.applyData = function (data, passThrough) {
|
2115 | var child, computers, defaults, i, j, key, keys, len, len1, ref;
|
2116 |
|
2117 | if (this.options.passDataToChildren && this._children.length && (passThrough != null ? passThrough : passThrough = true)) {
|
2118 | ref = this._children;
|
2119 |
|
2120 | for (i = 0, len = ref.length; i < len; i++) {
|
2121 | child = ref[i];
|
2122 | child.applyData(data);
|
2123 | }
|
2124 | }
|
2125 |
|
2126 | if (computers = this.options.computers) {
|
2127 | defaults = this.options.defaults;
|
2128 | keys = Object.keys(computers);
|
2129 |
|
2130 | for (j = 0, len1 = keys.length; j < len1; j++) {
|
2131 | key = keys[j];
|
2132 |
|
2133 | if (this.options.invokeComputersOnce) {
|
2134 | if (this._invokedComputers[key]) {
|
2135 | continue;
|
2136 | }
|
2137 |
|
2138 | this._invokedComputers[key] = 1;
|
2139 | }
|
2140 |
|
2141 | if (data && data.hasOwnProperty(key)) {
|
2142 | this._runComputer(key, data[key], data);
|
2143 | } else if (defaults && defaults.hasOwnProperty(key)) {
|
2144 | this._runComputer(key, defaults[key], data);
|
2145 | }
|
2146 | }
|
2147 | }
|
2148 |
|
2149 | return this;
|
2150 | };
|
2151 |
|
2152 | QuickElement.prototype._runComputer = function (computer, arg, data) {
|
2153 | return this.options.computers[computer].call(this, arg, data);
|
2154 | };
|
2155 |
|
2156 | ;
|
2157 | ;
|
2158 | var QuickWindow;
|
2159 | QuickWindow = {
|
2160 | type: 'window',
|
2161 | el: window,
|
2162 | raw: window,
|
2163 | _eventCallbacks: {
|
2164 | __refs: {}
|
2165 | }
|
2166 | };
|
2167 | QuickWindow.on = QuickElement.prototype.on;
|
2168 | QuickWindow.off = QuickElement.prototype.off;
|
2169 | QuickWindow.emit = QuickElement.prototype.emit;
|
2170 | QuickWindow.emitPrivate = QuickElement.prototype.emitPrivate;
|
2171 | QuickWindow._listenTo = QuickElement.prototype._listenTo;
|
2172 | QuickWindow._invokeHandlers = QuickElement.prototype._invokeHandlers;
|
2173 | Object.defineProperties(QuickWindow, {
|
2174 | 'width': {
|
2175 | get: function get() {
|
2176 | return window.innerWidth;
|
2177 | }
|
2178 | },
|
2179 | 'height': {
|
2180 | get: function get() {
|
2181 | return window.innerHeight;
|
2182 | }
|
2183 | },
|
2184 | 'orientation': orientationGetter,
|
2185 | 'aspectRatio': aspectRatioGetter
|
2186 | });
|
2187 | ;
|
2188 | var MediaQuery, ruleDelimiter;
|
2189 | MediaQuery = new function () {
|
2190 | var callbacks, testRule;
|
2191 | callbacks = [];
|
2192 | window.addEventListener('resize', function () {
|
2193 | var callback, i, len;
|
2194 |
|
2195 | for (i = 0, len = callbacks.length; i < len; i++) {
|
2196 | callback = callbacks[i];
|
2197 | callback();
|
2198 | }
|
2199 | });
|
2200 |
|
2201 | this.parseQuery = function (target, queryString) {
|
2202 | var querySplit, rules, source;
|
2203 | querySplit = queryString.split('(');
|
2204 | source = querySplit[0];
|
2205 |
|
2206 | source = function () {
|
2207 | switch (source) {
|
2208 | case 'window':
|
2209 | return QuickWindow;
|
2210 |
|
2211 | case 'parent':
|
2212 | return target.parent;
|
2213 |
|
2214 | case 'self':
|
2215 | return target;
|
2216 |
|
2217 | default:
|
2218 | return target.parentMatching(function (parent) {
|
2219 | return parent.ref === source.slice(1);
|
2220 | });
|
2221 | }
|
2222 | }();
|
2223 |
|
2224 | rules = querySplit[1].slice(0, -1).split(ruleDelimiter).map(function (rule) {
|
2225 | var getter, key, keyPrefix, max, min, split, value;
|
2226 | split = rule.split(':');
|
2227 | value = parseFloat(split[1]);
|
2228 |
|
2229 | if (isNaN(value)) {
|
2230 | value = split[1];
|
2231 | }
|
2232 |
|
2233 | key = split[0];
|
2234 | keyPrefix = key.slice(0, 4);
|
2235 | max = keyPrefix === 'max-';
|
2236 | min = !max && keyPrefix === 'min-';
|
2237 |
|
2238 | if (max || min) {
|
2239 | key = key.slice(4);
|
2240 | }
|
2241 |
|
2242 | getter = function () {
|
2243 | switch (key) {
|
2244 | case 'orientation':
|
2245 | return function () {
|
2246 | return source.orientation;
|
2247 | };
|
2248 |
|
2249 | case 'aspect-ratio':
|
2250 | return function () {
|
2251 | return source.aspectRatio;
|
2252 | };
|
2253 |
|
2254 | case 'width':
|
2255 | case 'height':
|
2256 | return function () {
|
2257 | return source[key];
|
2258 | };
|
2259 |
|
2260 | default:
|
2261 | return function () {
|
2262 | var parsedValue, stringValue;
|
2263 | stringValue = source.style(key);
|
2264 | parsedValue = parseFloat(stringValue);
|
2265 |
|
2266 | if (isNaN(parsedValue)) {
|
2267 | return stringValue;
|
2268 | } else {
|
2269 | return parsedValue;
|
2270 | }
|
2271 | };
|
2272 | }
|
2273 | }();
|
2274 |
|
2275 | return {
|
2276 | key: key,
|
2277 | value: value,
|
2278 | min: min,
|
2279 | max: max,
|
2280 | getter: getter
|
2281 | };
|
2282 | });
|
2283 | return {
|
2284 | source: source,
|
2285 | rules: rules
|
2286 | };
|
2287 | };
|
2288 |
|
2289 | this.register = function (target, queryString) {
|
2290 | var callback, query;
|
2291 | query = this.parseQuery(target, queryString);
|
2292 |
|
2293 | if (query.source) {
|
2294 | callbacks.push(callback = function callback() {
|
2295 | return testRule(target, query, queryString);
|
2296 | });
|
2297 | callback();
|
2298 | }
|
2299 |
|
2300 | return query;
|
2301 | };
|
2302 |
|
2303 | testRule = function testRule(target, query, queryString) {
|
2304 | var currentValue, i, len, passed, ref, rule;
|
2305 | passed = true;
|
2306 | ref = query.rules;
|
2307 |
|
2308 | for (i = 0, len = ref.length; i < len; i++) {
|
2309 | rule = ref[i];
|
2310 | currentValue = rule.getter();
|
2311 |
|
2312 | passed = function () {
|
2313 | switch (false) {
|
2314 | case !rule.min:
|
2315 | return currentValue >= rule.value;
|
2316 |
|
2317 | case !rule.max:
|
2318 | return currentValue <= rule.value;
|
2319 |
|
2320 | default:
|
2321 | return currentValue === rule.value;
|
2322 | }
|
2323 | }();
|
2324 |
|
2325 | if (!passed) {
|
2326 | break;
|
2327 | }
|
2328 | }
|
2329 |
|
2330 | return target.state(queryString, passed);
|
2331 | };
|
2332 |
|
2333 | return this;
|
2334 | }();
|
2335 | ruleDelimiter = /,\s*/;
|
2336 | ;
|
2337 |
|
2338 | _QuickDom = function QuickDom() {
|
2339 | var arg, args, element, i, j, len, prevCount;
|
2340 | args = new Array(arguments.length);
|
2341 |
|
2342 | for (i = j = 0, len = arguments.length; j < len; i = ++j) {
|
2343 | arg = arguments[i];
|
2344 | args[i] = arg;
|
2345 | }
|
2346 |
|
2347 | prevCount = QuickElement.count;
|
2348 | element = _QuickDom.create(args);
|
2349 |
|
2350 | if (element && element._postCreation && QuickElement.count !== prevCount) {
|
2351 | element._postCreation();
|
2352 | }
|
2353 |
|
2354 | return element;
|
2355 | };
|
2356 |
|
2357 | _QuickDom.create = function (args) {
|
2358 | var argsLength, child, children, element, i, j, len, options, type;
|
2359 |
|
2360 | switch (false) {
|
2361 | case !IS.array(args[0]):
|
2362 | return _QuickDom.apply(void 0, _toConsumableArray(args[0]));
|
2363 |
|
2364 | case !IS.template(args[0]):
|
2365 | return args[0].spawn();
|
2366 |
|
2367 | case !IS.quickDomEl(args[0]):
|
2368 | if (args[1]) {
|
2369 | return args[0].updateOptions(args[1]);
|
2370 | } else {
|
2371 | return args[0];
|
2372 | }
|
2373 |
|
2374 | case !(IS.domNode(args[0]) || IS.domDoc(args[0])):
|
2375 | if (args[0]._quickElement) {
|
2376 | return args[0]._quickElement;
|
2377 | }
|
2378 |
|
2379 | type = args[0].nodeName.toLowerCase().replace('#', '');
|
2380 | options = args[1] || {};
|
2381 | options.existing = args[0];
|
2382 | return new QuickElement(type, options);
|
2383 |
|
2384 | case args[0] !== window:
|
2385 | return QuickWindow;
|
2386 |
|
2387 | case !IS.string(args[0]):
|
2388 | type = args[0].toLowerCase();
|
2389 |
|
2390 | if (type === 'text') {
|
2391 | options = IS.object(args[1]) ? args[1] : {
|
2392 | text: args[1] || ''
|
2393 | };
|
2394 | } else {
|
2395 | options = IS.object(args[1]) ? args[1] : {};
|
2396 | }
|
2397 |
|
2398 | element = new QuickElement(type, options);
|
2399 |
|
2400 | if (args.length > 2) {
|
2401 | children = new Array(argsLength = args.length);
|
2402 | i = 1;
|
2403 |
|
2404 | while (++i < argsLength) {
|
2405 | children[i + 1] = args[i];
|
2406 | }
|
2407 |
|
2408 | for (j = 0, len = children.length; j < len; j++) {
|
2409 | child = children[j];
|
2410 |
|
2411 | if (IS.string(child)) {
|
2412 | child = _QuickDom.text(child);
|
2413 | }
|
2414 |
|
2415 | if (IS.array(child)) {
|
2416 | child = _QuickDom.apply(void 0, _toConsumableArray(child));
|
2417 | }
|
2418 |
|
2419 | if (IS.quickDomEl(child)) {
|
2420 | element.append(child);
|
2421 | }
|
2422 | }
|
2423 | }
|
2424 |
|
2425 | return element;
|
2426 |
|
2427 | case !(args[0] && (IS.domNode(args[0][0]) || IS.domDoc(args[0][0]))):
|
2428 | return _QuickDom(args[0][0]);
|
2429 | }
|
2430 | };
|
2431 |
|
2432 | _QuickDom.template = function (tree) {
|
2433 | return new QuickTemplate(tree, true);
|
2434 | };
|
2435 |
|
2436 | _QuickDom.html = function (innerHTML) {
|
2437 | var children, container;
|
2438 | container = document.createElement('div');
|
2439 | container.innerHTML = innerHTML;
|
2440 | children = Array.prototype.slice.call(container.childNodes);
|
2441 | return _QuickDom.batch(children);
|
2442 | };
|
2443 |
|
2444 | _QuickDom.query = function (target) {
|
2445 | return _QuickDom(document).query(target);
|
2446 | };
|
2447 |
|
2448 | _QuickDom.queryAll = function (target) {
|
2449 | return _QuickDom(document).queryAll(target);
|
2450 | };
|
2451 |
|
2452 | _QuickDom.isTemplate = function (target) {
|
2453 | return IS.template(target);
|
2454 | };
|
2455 |
|
2456 | _QuickDom.isQuickEl = function (target) {
|
2457 | return IS.quickDomEl(target);
|
2458 | };
|
2459 |
|
2460 | _QuickDom.isEl = function (target) {
|
2461 | return IS.domEl(target);
|
2462 | };
|
2463 |
|
2464 | var QuickBatch;
|
2465 |
|
2466 | QuickBatch =
|
2467 |
|
2468 | function () {
|
2469 | function QuickBatch(elements, returnResults1) {
|
2470 | _classCallCheck(this, QuickBatch);
|
2471 |
|
2472 | this.returnResults = returnResults1;
|
2473 | this.elements = elements.map(function (el) {
|
2474 | return _QuickDom(el);
|
2475 | });
|
2476 | }
|
2477 |
|
2478 | _createClass(QuickBatch, [{
|
2479 | key: "reverse",
|
2480 | value: function reverse() {
|
2481 | this.elements = this.elements.reverse();
|
2482 | return this;
|
2483 | }
|
2484 | }, {
|
2485 | key: "return",
|
2486 | value: function _return(returnNext) {
|
2487 | if (returnNext) {
|
2488 | this.returnResults = true;
|
2489 | return this;
|
2490 | } else {
|
2491 | return this.lastResults;
|
2492 | }
|
2493 | }
|
2494 | }]);
|
2495 |
|
2496 | return QuickBatch;
|
2497 | }();
|
2498 |
|
2499 |
|
2500 |
|
2501 | if (QuickBatch.name == null) {
|
2502 | QuickBatch.name = 'QuickBatch';
|
2503 | }
|
2504 |
|
2505 | Object.keys(QuickElement.prototype).concat('css', 'replaceWith', 'html', 'text').forEach(function (method) {
|
2506 | return QuickBatch.prototype[method] = function (newValue) {
|
2507 | var element, results;
|
2508 |
|
2509 | results = this.lastResults = function () {
|
2510 | var i, len, ref, results1;
|
2511 | ref = this.elements;
|
2512 | results1 = [];
|
2513 |
|
2514 | for (i = 0, len = ref.length; i < len; i++) {
|
2515 | element = ref[i];
|
2516 |
|
2517 | if (method === 'html' || method === 'text') {
|
2518 | if (newValue) {
|
2519 | results1.push(element[method] = newValue);
|
2520 | } else {
|
2521 | results1.push(element[method]);
|
2522 | }
|
2523 | } else {
|
2524 | var _element;
|
2525 |
|
2526 | results1.push((_element = element)[method].apply(_element, arguments));
|
2527 | }
|
2528 | }
|
2529 |
|
2530 | return results1;
|
2531 | }.apply(this, arguments);
|
2532 |
|
2533 | if (this.returnResults) {
|
2534 | return results;
|
2535 | } else {
|
2536 | return this;
|
2537 | }
|
2538 | };
|
2539 | });
|
2540 |
|
2541 | _QuickDom.batch = function (elements, returnResults) {
|
2542 | if (!IS.iterable(elements)) {
|
2543 | throw new Error("Batch: expected an iterable, got ".concat(String(elements)));
|
2544 | } else if (!elements.length) {
|
2545 | throw new Error("Batch: expected a non-empty element collection");
|
2546 | }
|
2547 |
|
2548 | return new QuickBatch(elements, returnResults);
|
2549 | };
|
2550 |
|
2551 | ;
|
2552 | var QuickTemplate;
|
2553 |
|
2554 | var _extendByRef, extendTemplate, notDeepKeys, notKeys;
|
2555 |
|
2556 | notDeepKeys = ['relatedInstance', 'related', 'data'];
|
2557 | notKeys = ['children', '_childRefs'];
|
2558 |
|
2559 | extendTemplate = function extendTemplate(currentOpts, newOpts, globalOpts) {
|
2560 | var currentChild, currentChildren, globalOptsTransform, index, maxLength, needsTemplateWrap, newChild, newChildProcessed, newChildren, noChanges, output, ref, remainingNewChildren;
|
2561 |
|
2562 | if (globalOpts) {
|
2563 | globalOptsTransform = {
|
2564 | options: function options(opts) {
|
2565 | return extend(opts, globalOpts);
|
2566 | }
|
2567 | };
|
2568 | }
|
2569 |
|
2570 | if (IS.array(newOpts)) {
|
2571 | newOpts = parseTree(newOpts, false);
|
2572 | } else if (newOpts && !matchesSchema(newOpts)) {
|
2573 | newOpts = {
|
2574 | options: newOpts
|
2575 | };
|
2576 | }
|
2577 |
|
2578 | output = extend.deep.nullDeletes.notKeys(notKeys).notDeep(notDeepKeys).transform(globalOptsTransform).clone(currentOpts, newOpts);
|
2579 | currentChildren = currentOpts.children;
|
2580 | newChildren = (newOpts != null ? newOpts.children : void 0) || [];
|
2581 | output.children = [];
|
2582 |
|
2583 |
|
2584 | if (IS.array(newChildren)) {
|
2585 | maxLength = Math.max(currentChildren.length, newChildren.length);
|
2586 | index = -1;
|
2587 |
|
2588 | while (++index !== maxLength) {
|
2589 | needsTemplateWrap = noChanges = false;
|
2590 | currentChild = currentChildren[index];
|
2591 | newChild = newChildren[index];
|
2592 |
|
2593 | newChildProcessed = function () {
|
2594 | switch (false) {
|
2595 | case !IS.template(newChild):
|
2596 | return newChild;
|
2597 |
|
2598 | case !IS.array(newChild):
|
2599 | return needsTemplateWrap = parseTree(newChild);
|
2600 |
|
2601 | case !IS.string(newChild):
|
2602 | return needsTemplateWrap = {
|
2603 | type: 'text',
|
2604 | options: {
|
2605 | text: newChild
|
2606 | }
|
2607 | };
|
2608 |
|
2609 | case !(!newChild && !globalOpts):
|
2610 | return noChanges = true;
|
2611 |
|
2612 | default:
|
2613 | return needsTemplateWrap = newChild || true;
|
2614 | }
|
2615 | }();
|
2616 |
|
2617 | if (noChanges) {
|
2618 | newChildProcessed = currentChild;
|
2619 | } else if (needsTemplateWrap) {
|
2620 | newChildProcessed = currentChild ? currentChild.extend(newChildProcessed, globalOpts) : new QuickTemplate(extend.clone(schema, newChildProcessed));
|
2621 | }
|
2622 |
|
2623 | output.children.push(newChildProcessed);
|
2624 | }
|
2625 | } else if (IS.object(newChildren)) {
|
2626 | newChildren = extend.allowNull.clone(newChildren);
|
2627 | output.children = _extendByRef(newChildren, currentChildren, globalOpts);
|
2628 | remainingNewChildren = newChildren;
|
2629 |
|
2630 | for (ref in remainingNewChildren) {
|
2631 | newChild = remainingNewChildren[ref];
|
2632 | newChildProcessed = IS.objectPlain(newChild) && !IS.template(newChild) ? newChild : parseTree(newChild);
|
2633 | output.children.push(new QuickTemplate(newChildProcessed));
|
2634 | delete remainingNewChildren[ref];
|
2635 | }
|
2636 | }
|
2637 |
|
2638 | return output;
|
2639 | };
|
2640 |
|
2641 | _extendByRef = function extendByRef(newChildrenRefs, currentChildren, globalOpts) {
|
2642 | var currentChild, i, len, newChild, newChildProcessed, output;
|
2643 |
|
2644 | if (!currentChildren.length) {
|
2645 | return currentChildren;
|
2646 | } else {
|
2647 | output = [];
|
2648 |
|
2649 | for (i = 0, len = currentChildren.length; i < len; i++) {
|
2650 | currentChild = currentChildren[i];
|
2651 | newChild = newChildrenRefs[currentChild.ref];
|
2652 |
|
2653 | if (newChild) {
|
2654 | newChildProcessed = currentChild.extend(newChild, globalOpts);
|
2655 | delete newChildrenRefs[currentChild.ref];
|
2656 | } else if (newChild === null) {
|
2657 | delete newChildrenRefs[currentChild.ref];
|
2658 | continue;
|
2659 | } else {
|
2660 | newChildProcessed = function () {
|
2661 | switch (false) {
|
2662 | case !globalOpts:
|
2663 | return currentChild.extend(null, globalOpts);
|
2664 |
|
2665 | case !Object.keys(newChildrenRefs).length:
|
2666 | return currentChild.extend();
|
2667 |
|
2668 | default:
|
2669 | return currentChild;
|
2670 | }
|
2671 | }();
|
2672 | }
|
2673 |
|
2674 | newChildProcessed.children = _extendByRef(newChildrenRefs, newChildProcessed.children);
|
2675 | output.push(newChildProcessed);
|
2676 | }
|
2677 |
|
2678 | return output;
|
2679 | }
|
2680 | };
|
2681 |
|
2682 | ;
|
2683 | var parseErrorPrefix, parseTree;
|
2684 |
|
2685 | parseTree = function parseTree(tree, parseChildren) {
|
2686 | var output;
|
2687 |
|
2688 | switch (false) {
|
2689 | case !IS.array(tree):
|
2690 | output = {};
|
2691 |
|
2692 | if (!IS.string(tree[0])) {
|
2693 | throw new Error("".concat(parseErrorPrefix, " string for 'type', got '").concat(String(tree[0]), "'"));
|
2694 | } else {
|
2695 | output.type = tree[0];
|
2696 | }
|
2697 |
|
2698 | if (tree.length > 1 && !IS.object(tree[1]) && tree[1] !== null) {
|
2699 | throw new Error("".concat(parseErrorPrefix, " object for 'options', got '").concat(String(tree[1]), "'"));
|
2700 | } else {
|
2701 | output.options = tree[1] ? extend.deep.clone(tree[1]) : schema.options;
|
2702 |
|
2703 | if (tree[1]) {
|
2704 | output.ref = tree[1].id || tree[1].ref;
|
2705 | }
|
2706 | }
|
2707 |
|
2708 | output.children = tree.slice(2);
|
2709 |
|
2710 | if (parseChildren === false) {
|
2711 | if (tree.length === 3 && IS.objectPlain(tree[2]) && !IS.template(tree[2])) {
|
2712 | output.children = tree[2];
|
2713 | }
|
2714 | } else {
|
2715 | output.children = output.children.map(_QuickDom.template);
|
2716 | }
|
2717 |
|
2718 | return output;
|
2719 |
|
2720 | case !(IS.string(tree) || IS.domText(tree)):
|
2721 | return {
|
2722 | type: 'text',
|
2723 | options: {
|
2724 | text: tree.textContent || tree
|
2725 | },
|
2726 | children: schema.children
|
2727 | };
|
2728 |
|
2729 | case !IS.domEl(tree):
|
2730 | return {
|
2731 | type: tree.nodeName.toLowerCase(),
|
2732 | ref: tree.id,
|
2733 | options: extend.clone.keys(allowedTemplateOptions)(tree),
|
2734 | children: schema.children.map.call(tree.childNodes, _QuickDom.template)
|
2735 | };
|
2736 |
|
2737 | case !IS.quickDomEl(tree):
|
2738 | return {
|
2739 | type: tree.type,
|
2740 | ref: tree.ref,
|
2741 | options: extend.clone.deep.notKeys(['relatedInstance', 'related'])(tree.options),
|
2742 | children: tree.children.map(_QuickDom.template)
|
2743 | };
|
2744 |
|
2745 | case !IS.template(tree):
|
2746 | return tree;
|
2747 |
|
2748 | default:
|
2749 | throw new Error("".concat(parseErrorPrefix, " (array || string || domEl || quickDomEl || template), got ").concat(String(tree)));
|
2750 | }
|
2751 | };
|
2752 |
|
2753 | parseErrorPrefix = 'Template Parse Error: expected';
|
2754 | ;
|
2755 | var matchesSchema, schema;
|
2756 | schema = {
|
2757 | type: 'div',
|
2758 | ref: void 0,
|
2759 | options: {},
|
2760 | children: []
|
2761 | };
|
2762 |
|
2763 | matchesSchema = function matchesSchema(object) {
|
2764 | return typeof object.type !== 'undefined' || typeof object.ref !== 'undefined' || typeof object.options !== 'undefined' || typeof object.children !== 'undefined';
|
2765 | };
|
2766 |
|
2767 | ;
|
2768 |
|
2769 | QuickTemplate =
|
2770 |
|
2771 | function () {
|
2772 | function QuickTemplate(config, isTree) {
|
2773 | _classCallCheck(this, QuickTemplate);
|
2774 |
|
2775 | if (IS.template(config)) {
|
2776 | return config;
|
2777 | }
|
2778 |
|
2779 | config = isTree ? parseTree(config) : config;
|
2780 | extend(this, config);
|
2781 | }
|
2782 |
|
2783 | _createClass(QuickTemplate, [{
|
2784 | key: "extend",
|
2785 | value: function extend(newValues, globalOpts) {
|
2786 | return new QuickTemplate(extendTemplate(this, newValues, globalOpts));
|
2787 | }
|
2788 | }, {
|
2789 | key: "spawn",
|
2790 | value: function spawn(newValues, globalOpts, data) {
|
2791 | var child, childData, children, element, i, len, options, type;
|
2792 |
|
2793 | if (newValues && newValues.data) {
|
2794 | data = newValues.data;
|
2795 |
|
2796 | if (Object.keys(newValues).length === 1) {
|
2797 | newValues = null;
|
2798 | }
|
2799 | }
|
2800 |
|
2801 | if (newValues || globalOpts) {
|
2802 | var _extendTemplate = extendTemplate(this, newValues, globalOpts);
|
2803 |
|
2804 | options = _extendTemplate.options;
|
2805 | children = _extendTemplate.children;
|
2806 | type = _extendTemplate.type;
|
2807 | } else {
|
2808 | options = this.options;
|
2809 | children = this.children;
|
2810 | type = this.type;
|
2811 | options = extend.clone(options);
|
2812 | }
|
2813 |
|
2814 | element = _QuickDom.create([type, options]);
|
2815 |
|
2816 | if (children) {
|
2817 | childData = options.passDataToChildren ? data || options.data : void 0;
|
2818 |
|
2819 | for (i = 0, len = children.length; i < len; i++) {
|
2820 | child = children[i];
|
2821 | element.append(child.spawn(null, null, childData));
|
2822 | }
|
2823 | }
|
2824 |
|
2825 | element._postCreation(data);
|
2826 |
|
2827 | return element;
|
2828 | }
|
2829 | }]);
|
2830 |
|
2831 | return QuickTemplate;
|
2832 | }();
|
2833 |
|
2834 | if (QuickTemplate.name == null) {
|
2835 | QuickTemplate.name = 'QuickTemplate';
|
2836 | }
|
2837 |
|
2838 | Object.defineProperty(QuickTemplate.prototype, 'child', {
|
2839 | get: function get() {
|
2840 | return this._childRefs || _getChildRefs2(this);
|
2841 | }
|
2842 | });
|
2843 | ;
|
2844 | var i, len, shortcut, shortcuts;
|
2845 | shortcuts = ['link:a', 'anchor:a', 'a', 'text', 'div', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'footer', 'section', 'button', 'br', 'ul', 'ol', 'li', 'fieldset', 'input', 'textarea', 'select', 'option', 'form', 'frame', 'hr', 'iframe', 'img', 'picture', 'main', 'nav', 'meta', 'object', 'pre', 'style', 'table', 'tbody', 'th', 'tr', 'td', 'tfoot',
|
2846 | 'video'];
|
2847 |
|
2848 | for (i = 0, len = shortcuts.length; i < len; i++) {
|
2849 | shortcut = shortcuts[i];
|
2850 |
|
2851 | (function (shortcut) {
|
2852 | var prop, split, type;
|
2853 | prop = type = shortcut;
|
2854 |
|
2855 | if (helpers.includes(shortcut, ':')) {
|
2856 | split = shortcut.split(':');
|
2857 | prop = split[0];
|
2858 | type = split[1];
|
2859 | }
|
2860 |
|
2861 | return _QuickDom[prop] = function () {
|
2862 | return _QuickDom.apply(void 0, [type].concat(Array.prototype.slice.call(arguments)));
|
2863 | };
|
2864 | })(shortcut);
|
2865 | }
|
2866 |
|
2867 | ;
|
2868 | _QuickDom.version = "1.0.89";
|
2869 | _QuickDom.CSS = CSS;
|
2870 | module.exports = _QuickDom;
|
2871 | return module.exports;
|
2872 | },
|
2873 | 1: function _(require, module, exports) {
|
2874 | var _QuickCSS, constants, helpers;
|
2875 |
|
2876 | constants = require(13);
|
2877 | helpers = require(14);
|
2878 |
|
2879 | _QuickCSS = function QuickCSS(targetEl, property, value, important) {
|
2880 | var computedStyle, i, len, subEl, subProperty, subValue;
|
2881 |
|
2882 | if (helpers.isIterable(targetEl)) {
|
2883 | for (i = 0, len = targetEl.length; i < len; i++) {
|
2884 | subEl = targetEl[i];
|
2885 |
|
2886 | _QuickCSS(subEl, property, value);
|
2887 | }
|
2888 | } else if (_typeof(property) === 'object') {
|
2889 | for (subProperty in property) {
|
2890 | subValue = property[subProperty];
|
2891 |
|
2892 | _QuickCSS(targetEl, subProperty, subValue);
|
2893 | }
|
2894 | } else {
|
2895 | property = helpers.normalizeProperty(property);
|
2896 |
|
2897 | if (typeof value === 'undefined') {
|
2898 | computedStyle = targetEl._computedStyle || (targetEl._computedStyle = getComputedStyle(targetEl));
|
2899 | return computedStyle[property];
|
2900 | } else if (property) {
|
2901 | targetEl.style.setProperty(property, helpers.normalizeValue(property, value), important ? constants.IMPORTANT : void 0);
|
2902 | }
|
2903 | }
|
2904 | };
|
2905 |
|
2906 | _QuickCSS.animation = function (name, frames) {
|
2907 | var frame, generated, prefix, rules;
|
2908 |
|
2909 | if (name && typeof name === 'string' && frames && _typeof(frames) === 'object') {
|
2910 | prefix = helpers.getPrefix('animation');
|
2911 | generated = '';
|
2912 |
|
2913 | for (frame in frames) {
|
2914 | rules = frames[frame];
|
2915 | generated += "".concat(frame, " {").concat(helpers.ruleToString(rules), "}");
|
2916 | }
|
2917 |
|
2918 | generated = "@".concat(prefix, "keyframes ").concat(name, " {").concat(generated, "}");
|
2919 | return helpers.inlineStyle(generated, true, 0);
|
2920 | }
|
2921 | };
|
2922 |
|
2923 | _QuickCSS.register = function (rule, level, important) {
|
2924 | var className, ref, style;
|
2925 |
|
2926 | if (rule && _typeof(rule) === 'object') {
|
2927 | level || (level = 0);
|
2928 | rule = helpers.ruleToString(rule, important);
|
2929 |
|
2930 | if (!(className = (ref = helpers.inlineStyleConfig[level]) != null ? ref[rule] : void 0)) {
|
2931 | className = helpers.hash(rule);
|
2932 | style = ".".concat(className, " {").concat(rule, "}");
|
2933 | helpers.inlineStyle(style, className, level);
|
2934 | }
|
2935 |
|
2936 | return className;
|
2937 | }
|
2938 | };
|
2939 |
|
2940 | _QuickCSS.clearRegistered = function (level) {
|
2941 | return helpers.clearInlineStyle(level || 0);
|
2942 | };
|
2943 |
|
2944 | _QuickCSS.UNSET = function () {
|
2945 | switch (false) {
|
2946 | case !helpers.isValueSupported('display', 'unset'):
|
2947 | return 'unset';
|
2948 |
|
2949 | case !helpers.isValueSupported('display', 'initial'):
|
2950 | return 'initial';
|
2951 |
|
2952 | case !helpers.isValueSupported('display', 'inherit'):
|
2953 | return 'inherit';
|
2954 | }
|
2955 | }();
|
2956 |
|
2957 | _QuickCSS.supports = helpers.isValueSupported;
|
2958 | _QuickCSS.supportsProperty = helpers.isPropSupported;
|
2959 | _QuickCSS.normalizeProperty = helpers.normalizeProperty;
|
2960 | _QuickCSS.normalizeValue = helpers.normalizeValue;
|
2961 | _QuickCSS.version = "1.3.4";
|
2962 | module.exports = _QuickCSS;
|
2963 | return module.exports;
|
2964 | },
|
2965 | 2: function _(require, module, exports) {
|
2966 | var exports, extend, modifiers, newBuilder, normalizeKeys;
|
2967 | extend = require(16);
|
2968 |
|
2969 | normalizeKeys = function normalizeKeys(keys) {
|
2970 | var i, key, len, output;
|
2971 |
|
2972 | if (keys) {
|
2973 | output = {};
|
2974 |
|
2975 | if (_typeof(keys) !== 'object') {
|
2976 | output[keys] = true;
|
2977 | } else {
|
2978 | if (!Array.isArray(keys)) {
|
2979 | keys = Object.keys(keys);
|
2980 | }
|
2981 |
|
2982 | for (i = 0, len = keys.length; i < len; i++) {
|
2983 | key = keys[i];
|
2984 | output[key] = true;
|
2985 | }
|
2986 | }
|
2987 |
|
2988 | return output;
|
2989 | }
|
2990 | };
|
2991 |
|
2992 | newBuilder = function newBuilder(isBase) {
|
2993 | var _builder;
|
2994 |
|
2995 | _builder = function builder(target) {
|
2996 | var theTarget;
|
2997 | var $_len = arguments.length,
|
2998 | $_i = -1,
|
2999 | sources = new Array($_len);
|
3000 |
|
3001 | while (++$_i < $_len) {
|
3002 | sources[$_i] = arguments[$_i];
|
3003 | }
|
3004 |
|
3005 | if (_builder.options.target) {
|
3006 | theTarget = _builder.options.target;
|
3007 | } else {
|
3008 | theTarget = target;
|
3009 | sources.shift();
|
3010 | }
|
3011 |
|
3012 | return extend(_builder.options, theTarget, sources);
|
3013 | };
|
3014 |
|
3015 | if (isBase) {
|
3016 | _builder.isBase = true;
|
3017 | }
|
3018 |
|
3019 | _builder.options = {};
|
3020 | Object.defineProperties(_builder, modifiers);
|
3021 | return _builder;
|
3022 | };
|
3023 |
|
3024 | modifiers = {
|
3025 | 'deep': {
|
3026 | get: function get() {
|
3027 | var _;
|
3028 |
|
3029 | _ = this.isBase ? newBuilder() : this;
|
3030 | _.options.deep = true;
|
3031 | return _;
|
3032 | }
|
3033 | },
|
3034 | 'own': {
|
3035 | get: function get() {
|
3036 | var _;
|
3037 |
|
3038 | _ = this.isBase ? newBuilder() : this;
|
3039 | _.options.own = true;
|
3040 | return _;
|
3041 | }
|
3042 | },
|
3043 | 'allowNull': {
|
3044 | get: function get() {
|
3045 | var _;
|
3046 |
|
3047 | _ = this.isBase ? newBuilder() : this;
|
3048 | _.options.allowNull = true;
|
3049 | return _;
|
3050 | }
|
3051 | },
|
3052 | 'nullDeletes': {
|
3053 | get: function get() {
|
3054 | var _;
|
3055 |
|
3056 | _ = this.isBase ? newBuilder() : this;
|
3057 | _.options.nullDeletes = true;
|
3058 | return _;
|
3059 | }
|
3060 | },
|
3061 | 'concat': {
|
3062 | get: function get() {
|
3063 | var _;
|
3064 |
|
3065 | _ = this.isBase ? newBuilder() : this;
|
3066 | _.options.concat = true;
|
3067 | return _;
|
3068 | }
|
3069 | },
|
3070 | 'clone': {
|
3071 | get: function get() {
|
3072 | var _;
|
3073 |
|
3074 | _ = this.isBase ? newBuilder() : this;
|
3075 | _.options.target = {};
|
3076 | return _;
|
3077 | }
|
3078 | },
|
3079 | 'notDeep': {
|
3080 | get: function get() {
|
3081 | var _;
|
3082 |
|
3083 | _ = this.isBase ? newBuilder() : this;
|
3084 | return function (keys) {
|
3085 | _.options.notDeep = normalizeKeys(keys);
|
3086 | return _;
|
3087 | };
|
3088 | }
|
3089 | },
|
3090 | 'deepOnly': {
|
3091 | get: function get() {
|
3092 | var _;
|
3093 |
|
3094 | _ = this.isBase ? newBuilder() : this;
|
3095 | return function (keys) {
|
3096 | _.options.deepOnly = normalizeKeys(keys);
|
3097 | return _;
|
3098 | };
|
3099 | }
|
3100 | },
|
3101 | 'keys': {
|
3102 | get: function get() {
|
3103 | var _;
|
3104 |
|
3105 | _ = this.isBase ? newBuilder() : this;
|
3106 | return function (keys) {
|
3107 | _.options.keys = normalizeKeys(keys);
|
3108 | return _;
|
3109 | };
|
3110 | }
|
3111 | },
|
3112 | 'notKeys': {
|
3113 | get: function get() {
|
3114 | var _;
|
3115 |
|
3116 | _ = this.isBase ? newBuilder() : this;
|
3117 | return function (keys) {
|
3118 | _.options.notKeys = normalizeKeys(keys);
|
3119 | return _;
|
3120 | };
|
3121 | }
|
3122 | },
|
3123 | 'transform': {
|
3124 | get: function get() {
|
3125 | var _;
|
3126 |
|
3127 | _ = this.isBase ? newBuilder() : this;
|
3128 | return function (transform) {
|
3129 | if (typeof transform === 'function') {
|
3130 | _.options.globalTransform = transform;
|
3131 | } else if (transform && _typeof(transform) === 'object') {
|
3132 | _.options.transforms = transform;
|
3133 | }
|
3134 |
|
3135 | return _;
|
3136 | };
|
3137 | }
|
3138 | },
|
3139 | 'filter': {
|
3140 | get: function get() {
|
3141 | var _;
|
3142 |
|
3143 | _ = this.isBase ? newBuilder() : this;
|
3144 | return function (filter) {
|
3145 | if (typeof filter === 'function') {
|
3146 | _.options.globalFilter = filter;
|
3147 | } else if (filter && _typeof(filter) === 'object') {
|
3148 | _.options.filters = filter;
|
3149 | }
|
3150 |
|
3151 | return _;
|
3152 | };
|
3153 | }
|
3154 | }
|
3155 | };
|
3156 | module.exports = exports = newBuilder(true);
|
3157 | exports.version = "1.7.3";
|
3158 | return module.exports;
|
3159 | },
|
3160 | 13: function _(require, module, exports) {
|
3161 | exports.REGEX_LEN_VAL = /^\d+(?:[a-z]|\%)+$/i;
|
3162 | exports.REGEX_DIGITS = /\d+$/;
|
3163 | exports.REGEX_SPACE = /\s/;
|
3164 | exports.REGEX_KEBAB = /([A-Z])+/g;
|
3165 | exports.IMPORTANT = 'important';
|
3166 | exports.POSSIBLE_PREFIXES = ['webkit', 'moz', 'ms', 'o'];
|
3167 | exports.REQUIRES_UNIT_VALUE = ['background-position-x', 'background-position-y', 'block-size', 'border-width', 'columnRule-width', 'cx', 'cy', 'font-size', 'grid-column-gap', 'grid-row-gap', 'height', 'inline-size', 'line-height', 'minBlock-size', 'min-height', 'min-inline-size', 'min-width', 'max-height', 'max-width', 'outline-offset', 'outline-width', 'perspective', 'shape-margin', 'stroke-dashoffset', 'stroke-width', 'text-indent', 'width', 'word-spacing', 'top', 'bottom', 'left', 'right', 'x', 'y'];
|
3168 | exports.QUAD_SHORTHANDS = ['margin', 'padding', 'border', 'border-radius'];
|
3169 | exports.DIRECTIONS = ['top', 'bottom', 'left', 'right'];
|
3170 | exports.QUAD_SHORTHANDS.forEach(function (property) {
|
3171 | var direction, i, len, ref;
|
3172 | exports.REQUIRES_UNIT_VALUE.push(property);
|
3173 | ref = exports.DIRECTIONS;
|
3174 |
|
3175 | for (i = 0, len = ref.length; i < len; i++) {
|
3176 | direction = ref[i];
|
3177 | exports.REQUIRES_UNIT_VALUE.push(property + '-' + direction);
|
3178 | }
|
3179 | });
|
3180 | return module.exports;
|
3181 | },
|
3182 | 14: function _(require, module, exports) {
|
3183 | var constants, helpers, sampleStyle, styleConfig;
|
3184 | constants = require(13);
|
3185 | sampleStyle = document.createElement('div').style;
|
3186 | helpers = exports;
|
3187 |
|
3188 | helpers.includes = function (target, item) {
|
3189 | return target && target.indexOf(item) !== -1;
|
3190 | };
|
3191 |
|
3192 | helpers.isIterable = function (target) {
|
3193 | return target && _typeof(target) === 'object' && typeof target.length === 'number' && !target.nodeType;
|
3194 | };
|
3195 |
|
3196 | helpers.toKebabCase = function (string) {
|
3197 | return string.replace(constants.REGEX_KEBAB, function (e, letter) {
|
3198 | return "-".concat(letter.toLowerCase());
|
3199 | });
|
3200 | };
|
3201 |
|
3202 | helpers.isPropSupported = function (property) {
|
3203 | return typeof sampleStyle[property] !== 'undefined';
|
3204 | };
|
3205 |
|
3206 | helpers.isValueSupported = function (property, value) {
|
3207 | if (window.CSS && window.CSS.supports) {
|
3208 | return window.CSS.supports(property, value);
|
3209 | } else {
|
3210 | sampleStyle[property] = value;
|
3211 | return sampleStyle[property] === '' + value;
|
3212 | }
|
3213 | };
|
3214 |
|
3215 | helpers.getPrefix = function (property, skipInitialCheck) {
|
3216 | var j, len1, prefix, ref;
|
3217 |
|
3218 | if (skipInitialCheck || !helpers.isPropSupported(property)) {
|
3219 | ref = constants.POSSIBLE_PREFIXES;
|
3220 |
|
3221 | for (j = 0, len1 = ref.length; j < len1; j++) {
|
3222 | prefix = ref[j];
|
3223 |
|
3224 | if (helpers.isPropSupported("-".concat(prefix, "-").concat(property))) {
|
3225 | return "-".concat(prefix, "-");
|
3226 | }
|
3227 | }
|
3228 | }
|
3229 |
|
3230 | return '';
|
3231 | };
|
3232 |
|
3233 | helpers.normalizeProperty = function (property) {
|
3234 | property = helpers.toKebabCase(property);
|
3235 |
|
3236 | if (helpers.isPropSupported(property)) {
|
3237 | return property;
|
3238 | } else {
|
3239 | return "".concat(helpers.getPrefix(property, true)).concat(property);
|
3240 | }
|
3241 | };
|
3242 |
|
3243 | helpers.normalizeValue = function (property, value) {
|
3244 | if (helpers.includes(constants.REQUIRES_UNIT_VALUE, property) && value !== null) {
|
3245 | value = '' + value;
|
3246 |
|
3247 | if (constants.REGEX_DIGITS.test(value) && !constants.REGEX_LEN_VAL.test(value) && !constants.REGEX_SPACE.test(value)) {
|
3248 | value += property === 'line-height' ? 'em' : 'px';
|
3249 | }
|
3250 | }
|
3251 |
|
3252 | return value;
|
3253 | };
|
3254 |
|
3255 | helpers.sort = function (array) {
|
3256 | var great, i, len, less, pivot;
|
3257 |
|
3258 | if (array.length < 2) {
|
3259 | return array;
|
3260 | } else {
|
3261 | pivot = array[0];
|
3262 | less = [];
|
3263 | great = [];
|
3264 | len = array.length;
|
3265 | i = 0;
|
3266 |
|
3267 | while (++i !== len) {
|
3268 | if (array[i] <= pivot) {
|
3269 | less.push(array[i]);
|
3270 | } else {
|
3271 | great.push(array[i]);
|
3272 | }
|
3273 | }
|
3274 |
|
3275 | return helpers.sort(less).concat(pivot, helpers.sort(great));
|
3276 | }
|
3277 | };
|
3278 |
|
3279 | helpers.hash = function (string) {
|
3280 | var hash, i, length;
|
3281 | hash = 5381;
|
3282 | i = -1;
|
3283 | length = string.length;
|
3284 |
|
3285 | while (++i !== string.length) {
|
3286 | hash = (hash << 5) - hash + string.charCodeAt(i);
|
3287 | hash |= 0;
|
3288 | }
|
3289 |
|
3290 | return '_' + (hash < 0 ? hash * -2 : hash);
|
3291 | };
|
3292 |
|
3293 | helpers.ruleToString = function (rule, important) {
|
3294 | var j, len1, output, prop, property, props, value;
|
3295 | output = '';
|
3296 | props = helpers.sort(Object.keys(rule));
|
3297 |
|
3298 | for (j = 0, len1 = props.length; j < len1; j++) {
|
3299 | prop = props[j];
|
3300 |
|
3301 | if (typeof rule[prop] === 'string' || typeof rule[prop] === 'number') {
|
3302 | property = helpers.normalizeProperty(prop);
|
3303 | value = helpers.normalizeValue(property, rule[prop]);
|
3304 |
|
3305 | if (important) {
|
3306 | value += " !important";
|
3307 | }
|
3308 |
|
3309 | output += "".concat(property, ":").concat(value, ";");
|
3310 | }
|
3311 | }
|
3312 |
|
3313 | return output;
|
3314 | };
|
3315 |
|
3316 | helpers.inlineStyleConfig = styleConfig = Object.create(null);
|
3317 |
|
3318 | helpers.inlineStyle = function (rule, valueToStore, level) {
|
3319 | var config, styleEl;
|
3320 |
|
3321 | if (!(config = styleConfig[level])) {
|
3322 | styleEl = document.createElement('style');
|
3323 | styleEl.id = "quickcss".concat(level || '');
|
3324 | document.head.appendChild(styleEl);
|
3325 | styleConfig[level] = config = {
|
3326 | el: styleEl,
|
3327 | content: '',
|
3328 | cache: Object.create(null)
|
3329 | };
|
3330 | }
|
3331 |
|
3332 | if (!config.cache[rule]) {
|
3333 | config.cache[rule] = valueToStore || true;
|
3334 | config.el.textContent = config.content += rule;
|
3335 | }
|
3336 | };
|
3337 |
|
3338 | helpers.clearInlineStyle = function (level) {
|
3339 | var config, j, key, keys, len1;
|
3340 |
|
3341 | if (config = styleConfig[level]) {
|
3342 | if (!config.content) {
|
3343 | return;
|
3344 | }
|
3345 |
|
3346 | config.el.textContent = config.content = '';
|
3347 | keys = Object.keys(config.cache);
|
3348 |
|
3349 | for (j = 0, len1 = keys.length; j < len1; j++) {
|
3350 | key = keys[j];
|
3351 | config.cache[key] = null;
|
3352 | }
|
3353 | }
|
3354 | };
|
3355 |
|
3356 | return module.exports;
|
3357 | },
|
3358 | 16: function _(require, module, exports) {
|
3359 | var _extend, isArray, isObject, _shouldDeepExtend;
|
3360 |
|
3361 | isArray = function isArray(target) {
|
3362 | return Array.isArray(target);
|
3363 | };
|
3364 |
|
3365 | isObject = function isObject(target) {
|
3366 | return target && Object.prototype.toString.call(target) === '[object Object]' || isArray(target);
|
3367 | };
|
3368 |
|
3369 | _shouldDeepExtend = function shouldDeepExtend(options, target, parentKey) {
|
3370 | if (options.deep) {
|
3371 | if (options.notDeep) {
|
3372 | return !options.notDeep[target];
|
3373 | } else {
|
3374 | return true;
|
3375 | }
|
3376 | } else if (options.deepOnly) {
|
3377 | return options.deepOnly[target] || parentKey && _shouldDeepExtend(options, parentKey);
|
3378 | }
|
3379 | };
|
3380 |
|
3381 | module.exports = _extend = function extend(options, target, sources, parentKey) {
|
3382 | var i, key, len, source, sourceValue, subTarget, targetValue;
|
3383 |
|
3384 | if (!target || _typeof(target) !== 'object' && typeof target !== 'function') {
|
3385 | target = {};
|
3386 | }
|
3387 |
|
3388 | for (i = 0, len = sources.length; i < len; i++) {
|
3389 | source = sources[i];
|
3390 |
|
3391 | if (source != null) {
|
3392 | for (key in source) {
|
3393 | sourceValue = source[key];
|
3394 | targetValue = target[key];
|
3395 |
|
3396 | if (sourceValue === target || sourceValue === void 0 || sourceValue === null && !options.allowNull && !options.nullDeletes || options.keys && !options.keys[key] || options.notKeys && options.notKeys[key] || options.own && !source.hasOwnProperty(key) || options.globalFilter && !options.globalFilter(sourceValue, key, source) || options.filters && options.filters[key] && !options.filters[key](sourceValue, key, source)) {
|
3397 | continue;
|
3398 | }
|
3399 |
|
3400 | if (sourceValue === null && options.nullDeletes) {
|
3401 | delete target[key];
|
3402 | continue;
|
3403 | }
|
3404 |
|
3405 | if (options.globalTransform) {
|
3406 | sourceValue = options.globalTransform(sourceValue, key, source);
|
3407 | }
|
3408 |
|
3409 | if (options.transforms && options.transforms[key]) {
|
3410 | sourceValue = options.transforms[key](sourceValue, key, source);
|
3411 | }
|
3412 |
|
3413 | switch (false) {
|
3414 | case !(options.concat && isArray(sourceValue) && isArray(targetValue)):
|
3415 | target[key] = targetValue.concat(sourceValue);
|
3416 | break;
|
3417 |
|
3418 | case !(_shouldDeepExtend(options, key, parentKey) && isObject(sourceValue)):
|
3419 | subTarget = isObject(targetValue) ? targetValue : isArray(sourceValue) ? [] : {};
|
3420 | target[key] = _extend(options, subTarget, [sourceValue], key);
|
3421 | break;
|
3422 |
|
3423 | default:
|
3424 | target[key] = sourceValue;
|
3425 | }
|
3426 | }
|
3427 | }
|
3428 | }
|
3429 |
|
3430 | return target;
|
3431 | };
|
3432 |
|
3433 | return module.exports;
|
3434 | },
|
3435 | 18: function _(require, module, exports) {
|
3436 | var Checks, availSets;
|
3437 | availSets = {
|
3438 | natives: require(31),
|
3439 | dom: require(32)
|
3440 | };
|
3441 |
|
3442 | Checks =
|
3443 |
|
3444 | function () {
|
3445 | _createClass(Checks, [{
|
3446 | key: "create",
|
3447 | value: function create() {
|
3448 | var args;
|
3449 |
|
3450 | if (arguments.length) {
|
3451 | args = Array.prototype.slice.call(arguments);
|
3452 | }
|
3453 |
|
3454 | return new Checks(args);
|
3455 | }
|
3456 | }]);
|
3457 |
|
3458 | function Checks(sets) {
|
3459 | _classCallCheck(this, Checks);
|
3460 |
|
3461 | var i, len, set;
|
3462 |
|
3463 | if (sets == null) {
|
3464 | sets = ['natives'];
|
3465 | }
|
3466 |
|
3467 | for (i = 0, len = sets.length; i < len; i++) {
|
3468 | set = sets[i];
|
3469 |
|
3470 | if (availSets[set]) {
|
3471 | this.load(availSets[set]);
|
3472 | }
|
3473 | }
|
3474 | }
|
3475 |
|
3476 | _createClass(Checks, [{
|
3477 | key: "load",
|
3478 | value: function load(set) {
|
3479 | var key, value;
|
3480 |
|
3481 | if (availSets.natives.string(set)) {
|
3482 | set = availSets[set];
|
3483 | }
|
3484 |
|
3485 | if (!availSets.natives.objectPlain(set)) {
|
3486 | return;
|
3487 | }
|
3488 |
|
3489 | for (key in set) {
|
3490 | value = set[key];
|
3491 | this[key] = value;
|
3492 | }
|
3493 | }
|
3494 | }]);
|
3495 |
|
3496 | return Checks;
|
3497 | }();
|
3498 |
|
3499 | module.exports = Checks.prototype.create();
|
3500 | return module.exports;
|
3501 | },
|
3502 | 31: function _(require, module, exports) {
|
3503 | var exports;
|
3504 | module.exports = exports = {
|
3505 | defined: function defined(subject) {
|
3506 | return subject !== void 0;
|
3507 | },
|
3508 | array: function array(subject) {
|
3509 | return subject instanceof Array;
|
3510 | },
|
3511 | object: function object(subject) {
|
3512 | return _typeof(subject) === 'object' && subject;
|
3513 | },
|
3514 | objectPlain: function objectPlain(subject) {
|
3515 | return exports.object(subject) && Object.prototype.toString.call(subject) === '[object Object]' && subject.constructor === Object;
|
3516 | },
|
3517 | string: function string(subject) {
|
3518 | return typeof subject === 'string';
|
3519 | },
|
3520 | number: function number(subject) {
|
3521 | return typeof subject === 'number' && !isNaN(subject);
|
3522 | },
|
3523 | numberLoose: function numberLoose(subject) {
|
3524 | return exports.number(subject) || exports.string(subject) && exports.number(Number(subject));
|
3525 | },
|
3526 | function: function _function(subject) {
|
3527 | return typeof subject === 'function';
|
3528 | },
|
3529 | iterable: function iterable(subject) {
|
3530 | return exports.object(subject) && exports.number(subject.length);
|
3531 | }
|
3532 | };
|
3533 | return module.exports;
|
3534 | },
|
3535 | 32: function _(require, module, exports) {
|
3536 | var exports;
|
3537 | module.exports = exports = {
|
3538 | domDoc: function domDoc(subject) {
|
3539 | return subject && subject.nodeType === 9;
|
3540 | },
|
3541 | domEl: function domEl(subject) {
|
3542 | return subject && subject.nodeType === 1;
|
3543 | },
|
3544 | domText: function domText(subject) {
|
3545 | return subject && subject.nodeType === 3;
|
3546 | },
|
3547 | domNode: function domNode(subject) {
|
3548 | return exports.domEl(subject) || exports.domText(subject);
|
3549 | },
|
3550 | domTextarea: function domTextarea(subject) {
|
3551 | return subject && subject.nodeName === 'TEXTAREA';
|
3552 | },
|
3553 | domInput: function domInput(subject) {
|
3554 | return subject && subject.nodeName === 'INPUT';
|
3555 | },
|
3556 | domSelect: function domSelect(subject) {
|
3557 | return subject && subject.nodeName === 'SELECT';
|
3558 | },
|
3559 | domField: function domField(subject) {
|
3560 | return exports.domInput(subject) || exports.domTextarea(subject) || exports.domSelect(subject);
|
3561 | }
|
3562 | };
|
3563 | return module.exports;
|
3564 | },
|
3565 | 33: function _(require, module, exports) {
|
3566 | var StateChain;
|
3567 |
|
3568 | module.exports = StateChain =
|
3569 |
|
3570 | function () {
|
3571 | function StateChain(states) {
|
3572 | _classCallCheck(this, StateChain);
|
3573 |
|
3574 | this.string = states.join('+');
|
3575 | this.array = states.slice();
|
3576 | this.length = states.length;
|
3577 | }
|
3578 |
|
3579 | _createClass(StateChain, [{
|
3580 | key: "includes",
|
3581 | value: function includes(target) {
|
3582 | var i, len, ref, state;
|
3583 | ref = this.array;
|
3584 |
|
3585 | for (i = 0, len = ref.length; i < len; i++) {
|
3586 | state = ref[i];
|
3587 |
|
3588 | if (state === target) {
|
3589 | return true;
|
3590 | }
|
3591 | }
|
3592 |
|
3593 | return false;
|
3594 | }
|
3595 | }, {
|
3596 | key: "without",
|
3597 | value: function without(target) {
|
3598 | return this.array.filter(function (state) {
|
3599 | return state !== target;
|
3600 | }).join('+');
|
3601 | }
|
3602 | }, {
|
3603 | key: "isApplicable",
|
3604 | value: function isApplicable(target, otherActive) {
|
3605 | var active;
|
3606 | active = this.array.filter(function (state) {
|
3607 | return state === target || otherActive.indexOf(state) !== -1;
|
3608 | });
|
3609 | return active.length === this.array.length;
|
3610 | }
|
3611 | }]);
|
3612 |
|
3613 | return StateChain;
|
3614 | }();
|
3615 |
|
3616 | return module.exports;
|
3617 | }
|
3618 | }, this);
|
3619 |
|
3620 | if (typeof define === 'function' && define.umd) {
|
3621 | define(function () {
|
3622 | return require(0);
|
3623 | });
|
3624 | } else if ((typeof module === "undefined" ? "undefined" : _typeof(module)) === 'object' && module.exports) {
|
3625 | module.exports = require(0);
|
3626 | } else {
|
3627 | return this['quickdom'] = require(0);
|
3628 | }
|
3629 | }).call(this, null, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : this);
|