From d62184d16ebdbc1ba98de2d50ba811526248a5ea Mon Sep 17 00:00:00 2001 From: Guntars Simanskis Date: Mon, 22 May 2017 15:32:41 +0100 Subject: [PATCH] Release v1.0.16 --- bower.json | 2 +- dist/bower.json | 2 +- dist/docs/Constructor.html | 13 +++++++++++-- dist/es5/dev/widget/Constructor.js | 13 +++++++++++-- dist/es5/dev/widget/Constructor.js.map | 2 +- dist/es5/prod/widget/App.js | 4 ++-- dist/es6/dev/widget/Constructor.js | 13 +++++++++++-- dist/es6/prod/widget/App.js | 2 +- dist/package.json | 2 +- package.json | 2 +- 10 files changed, 41 insertions(+), 14 deletions(-) diff --git a/bower.json b/bower.json index 85450e1..2c5e448 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "stonewall", - "version": "1.0.15", + "version": "1.0.16", "repository": { "type": "git", "url": "https://github.com/gunins/stonewall" diff --git a/dist/bower.json b/dist/bower.json index 85450e1..2c5e448 100644 --- a/dist/bower.json +++ b/dist/bower.json @@ -1,6 +1,6 @@ { "name": "stonewall", - "version": "1.0.15", + "version": "1.0.16", "repository": { "type": "git", "url": "https://github.com/gunins/stonewall" diff --git a/dist/docs/Constructor.html b/dist/docs/Constructor.html index d13e3aa..707a10c 100644 --- a/dist/docs/Constructor.html +++ b/dist/docs/Constructor.html @@ -332,11 +332,20 @@

widget/Constructor Class

this.rendered(...this._arguments); this._rendered = true; } else { - this.root = new dom.Element('<div></div>', { + let HTMLelement = document.createElement('div'); + this.root = new dom.Element(HTMLelement, { name: 'root', data: {} }); - this.el = this.root.el; + if (this.el) { + let parent = this.el.parentNode; + if (parent) { + parent.replaceChild(HTMLelement, this.el); + } + } + this.el = HTMLelement; + this.children = {}; + addChildren(this, this.root); this.rendered(...this._arguments); this._rendered = true; diff --git a/dist/es5/dev/widget/Constructor.js b/dist/es5/dev/widget/Constructor.js index 4b052b3..1f4a203 100644 --- a/dist/es5/dev/widget/Constructor.js +++ b/dist/es5/dev/widget/Constructor.js @@ -1306,11 +1306,20 @@ define('widget/Constructor', ['require', 'templating/Decoder', 'templating/dom', this.rendered.apply(this, _toConsumableArray(this._arguments)); this._rendered = true; } else { - this.root = new dom.Element('
', { + var HTMLelement = document.createElement('div'); + this.root = new dom.Element(HTMLelement, { name: 'root', data: {} }); - this.el = this.root.el; + if (this.el) { + var _parent = this.el.parentNode; + if (_parent) { + _parent.replaceChild(HTMLelement, this.el); + } + } + this.el = HTMLelement; + this.children = {}; + addChildren(this, this.root); this.rendered.apply(this, _toConsumableArray(this._arguments)); this._rendered = true; diff --git a/dist/es5/dev/widget/Constructor.js.map b/dist/es5/dev/widget/Constructor.js.map index d0d12a1..b3a11f9 100644 --- a/dist/es5/dev/widget/Constructor.js.map +++ b/dist/es5/dev/widget/Constructor.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../es6/dev/widget/Constructor.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,CAAC,UAAU,OAAV,EAAmB;AAChB,QAAI,QAAO,yDAAP,KAAmB,QAAnB,EAA6B;;;;AAI7B,eAAO,OAAP,GAAiB,SAAjB,CAJ6B;KAAjC,MAKO,IAAI,OAAO,MAAP,KAAkB,UAAlB,IAAgC,OAAO,GAAP,EAAY;;AAEnD,eAAO,OAAP,EAAe,OAAf,EAFmD;KAAhD,MAGA;;AAEH,eAAO,OAAP,GAAiB,SAAjB,CAFG;AAGH,eAAO,KAAP,GAAe,OAAO,OAAP,CAAe,KAAf,CAHZ;AAIH,eAAO,OAAP,GAAiB,OAAO,OAAP,CAAe,OAAf,CAJd;AAKH,eAAO,YAAP,GAAsB,OAAO,OAAP,CAAe,YAAf,CALnB;KAHA;CANV,EAgBC,YAAY;;AAEV,QAAI,UAAU;AACN,gBAAQ,KAAR;KADJ;QAGA,iBAAiB,EAAjB,CALM;;AAOV,QAAI,aAAa,SAAb,UAAa,CAAU,eAAV,EAA2B;AACxC,YAAI,UAAU,EAAV,CADoC;AAExC,eAAO,mBAAmB,QAAQ,QAA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,EApWqB;;AAwZrB,WAAO,WAAP,CAxZqB;CAVtB,CAZH","file":"Constructor.js","sourcesContent":["/**\n * DEVELOPED BY\n * GIL LOPES BUENO\n * gilbueno.mail@gmail.com\n *\n * WORKS WITH:\n * IE 9+, FF 4+, SF 5+, WebKit, CH 7+, OP 12+, BESEN, Rhino 1.7+\n *\n * FORK:\n * https://github.com/melanke/Watch.JS\n */\n\n\n(function (factory) {\n if (typeof exports === 'object') {\n // Node. Does not work with strict CommonJS, but\n // only CommonJS-like enviroments that support module.exports,\n // like Node.\n module.exports = factory();\n } else if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define('watch',factory);\n } else {\n // Browser globals\n window.WatchJS = factory();\n window.watch = window.WatchJS.watch;\n window.unwatch = window.WatchJS.unwatch;\n window.callWatchers = window.WatchJS.callWatchers;\n }\n}(function () {\n\n var WatchJS = {\n noMore: false\n },\n lengthsubjects = [];\n\n var isFunction = function (functionToCheck) {\n var getType = {};\n return functionToCheck && getType.toString.call(functionToCheck) == '[object Function]';\n };\n\n var isInt = function (x) {\n return x % 1 === 0;\n };\n\n var isArray = function (obj) {\n return Object.prototype.toString.call(obj) === '[object Array]';\n };\n\n var getObjDiff = function (a, b) {\n var aplus = [],\n bplus = [];\n\n if (!(typeof a == \"string\") && !(typeof b == \"string\")) {\n\n if (isArray(a)) {\n for (var i = 0; i < a.length; i++) {\n if (b[i] === undefined) aplus.push(i);\n }\n } else {\n for (var i in a) {\n if (a.hasOwnProperty(i)) {\n if (b[i] === undefined) {\n aplus.push(i);\n }\n }\n }\n }\n\n if (isArray(b)) {\n for (var j = 0; j < b.length; j++) {\n if (a[j] === undefined) bplus.push(j);\n }\n } else {\n for (var j in b) {\n if (b.hasOwnProperty(j)) {\n if (a[j] === undefined) {\n bplus.push(j);\n }\n }\n }\n }\n }\n\n return {\n added: aplus,\n removed: bplus\n }\n };\n\n var clone = function (obj) {\n\n if (null == obj || \"object\" != typeof obj) {\n return obj;\n }\n\n var copy = obj.constructor();\n\n for (var attr in obj) {\n copy[attr] = obj[attr];\n }\n\n return copy;\n\n }\n\n var defineGetAndSet = function (obj, propName, getter, setter) {\n /* try {\n\n Object.observe(obj, function (changes) {\n changes.forEach(function (change) {\n if (change.name === propName) {\n setter(change.object[change.name]);\n }\n });\n });\n\n } catch (e) {*/\n\n try {\n Object.defineProperty(obj, propName, {\n get: getter,\n set: setter,\n enumerable: true,\n configurable: true\n });\n } catch (e2) {\n try {\n Object.prototype.__defineGetter__.call(obj, propName, getter);\n Object.prototype.__defineSetter__.call(obj, propName, setter);\n } catch (e3) {\n throw new Error(\"watchJS error: browser not supported :/\")\n }\n }\n\n // }\n };\n\n var defineProp = function (obj, propName, value) {\n try {\n Object.defineProperty(obj, propName, {\n enumerable: false,\n configurable: true,\n writable: false,\n value: value\n });\n } catch (error) {\n obj[propName] = value;\n }\n };\n\n var watch = function () {\n\n if (isFunction(arguments[1])) {\n watchAll.apply(this, arguments);\n } else if (isArray(arguments[1])) {\n watchMany.apply(this, arguments);\n } else {\n watchOne.apply(this, arguments);\n }\n\n };\n\n var watchAll = function (obj, watcher, level, addNRemove) {\n\n if ((typeof obj == \"string\") || (!(obj instanceof Object) && !isArray(obj))) { //accepts only objects and array (not string)\n return;\n }\n\n var props = [];\n\n if (isArray(obj)) {\n for (var prop = 0; prop < obj.length; prop++) { //for each item if obj is an array\n props.push(prop); //put in the props\n }\n } else {\n for (var prop2 in obj) { //for each attribute if obj is an object\n if (prop2 == \"$val\") {\n continue;\n }\n\n if (Object.prototype.hasOwnProperty.call(obj, prop2)) {\n props.push(prop2); //put in the props\n }\n }\n }\n\n watchMany(obj, props, watcher, level, addNRemove); //watch all items of the props\n\n if (addNRemove) {\n pushToLengthSubjects(obj, \"$$watchlengthsubjectroot\", watcher, level);\n }\n };\n\n var watchMany = function (obj, props, watcher, level, addNRemove) {\n\n if ((typeof obj == \"string\") || (!(obj instanceof Object) && !isArray(obj))) { //accepts only objects and array (not string)\n return;\n }\n\n for (var i = 0; i < props.length; i++) { //watch each property\n var prop = props[i];\n watchOne(obj, prop, watcher, level, addNRemove);\n }\n\n };\n\n var watchOne = function (obj, prop, watcher, level, addNRemove) {\n if ((typeof obj == \"string\") || (!(obj instanceof Object) && !isArray(obj))) { //accepts only objects and array (not string)\n return;\n }\n\n if (isFunction(obj[prop])) { //dont watch if it is a function\n return;\n }\n if (obj[prop] != null && (level === undefined || level > 0)) {\n watchAll(obj[prop], watcher, level !== undefined ? level - 1 : level); //recursively watch all attributes of this\n }\n\n defineWatcher(obj, prop, watcher, level);\n\n if (addNRemove && (level === undefined || level > 0)) {\n pushToLengthSubjects(obj, prop, watcher, level);\n }\n\n };\n\n var unwatch = function () {\n\n if (isFunction(arguments[1])) {\n unwatchAll.apply(this, arguments);\n } else if (isArray(arguments[1])) {\n unwatchMany.apply(this, arguments);\n } else {\n unwatchOne.apply(this, arguments);\n }\n\n };\n\n var unwatchAll = function (obj, watcher) {\n\n if (obj instanceof String || (!(obj instanceof Object) && !isArray(obj))) { //accepts only objects and array (not string)\n return;\n }\n\n if (isArray(obj)) {\n var props = [];\n for (var prop = 0; prop < obj.length; prop++) { //for each item if obj is an array\n props.push(prop); //put in the props\n }\n unwatchMany(obj, props, watcher); //watch all itens of the props\n } else {\n var unwatchPropsInObject = function (obj2) {\n var props = [];\n for (var prop2 in obj2) { //for each attribute if obj is an object\n if (obj2.hasOwnProperty(prop2)) {\n if (obj2[prop2] instanceof Object) {\n unwatchPropsInObject(obj2[prop2]); //recurs into object props\n } else {\n props.push(prop2); //put in the props\n }\n }\n }\n unwatchMany(obj2, props, watcher); //unwatch all of the props\n };\n unwatchPropsInObject(obj);\n }\n };\n\n var unwatchMany = function (obj, props, watcher) {\n\n for (var prop2 in props) { //watch each attribute of \"props\" if is an object\n if (props.hasOwnProperty(prop2)) {\n unwatchOne(obj, props[prop2], watcher);\n }\n }\n };\n\n var defineWatcher = function (obj, prop, watcher, level) {\n\n var val = obj[prop];\n\n watchFunctions(obj, prop);\n\n if (!obj.watchers) {\n defineProp(obj, \"watchers\", {});\n }\n\n var newWatcher = false;\n if (!obj.watchers[prop]) {\n obj.watchers[prop] = [];\n newWatcher = true;\n }\n\n for (var i = 0; i < obj.watchers[prop].length; i++) {\n if (obj.watchers[prop][i] === watcher) {\n return;\n }\n }\n\n obj.watchers[prop].push(watcher); //add the new watcher in the watchers array\n\n if (newWatcher) {\n var getter = function () {\n return val;\n };\n\n var setter = function (newval) {\n var oldval = val;\n val = newval;\n\n if (level !== 0 && obj[prop]) {\n // watch sub properties\n watchAll(obj[prop], watcher, (level === undefined) ? level : level - 1);\n }\n\n watchFunctions(obj, prop);\n\n if (!WatchJS.noMore) {\n //if (JSON.stringify(oldval) !== JSON.stringify(newval)) {\n if (oldval !== newval) {\n callWatchers(obj, prop, \"set\", newval, oldval);\n WatchJS.noMore = false;\n }\n }\n };\n\n defineGetAndSet(obj, prop, getter, setter);\n }\n\n };\n\n var callWatchers = function (obj, prop, action, newval, oldval) {\n if (prop !== undefined) {\n for (var wr = 0; wr < obj.watchers[prop].length; wr++) {\n obj.watchers[prop][wr].call(obj, prop, action, newval, oldval);\n }\n } else {\n for (var prop in obj) {//call all\n if (obj.hasOwnProperty(prop)) {\n callWatchers(obj, prop, action, newval, oldval);\n }\n }\n }\n };\n\n // @todo code related to \"watchFunctions\" is certainly buggy\n var methodNames = ['pop', 'push', 'reverse', 'shift', 'sort', 'slice', 'unshift', 'splice'];\n var defineArrayMethodWatcher = function (obj, prop, original, methodName) {\n defineProp(obj[prop], methodName, function () {\n var response = original.apply(obj[prop], arguments);\n watchOne(obj, obj[prop]);\n if (methodName !== 'slice') {\n callWatchers(obj, prop, methodName, arguments);\n }\n return response;\n });\n };\n\n var watchFunctions = function (obj, prop) {\n\n if ((!obj[prop]) || (obj[prop] instanceof String) || (!isArray(obj[prop]))) {\n return;\n }\n\n for (var i = methodNames.length, methodName; i--;) {\n methodName = methodNames[i];\n defineArrayMethodWatcher(obj, prop, obj[prop][methodName], methodName);\n }\n\n };\n\n var unwatchOne = function (obj, prop, watcher) {\n\n for (var i = 0; i < obj.watchers[prop].length; i++) {\n var w = obj.watchers[prop][i];\n if (w == watcher) {\n obj.watchers[prop].splice(i, 1);\n }\n }\n\n removeFromLengthSubjects(obj, prop, watcher);\n };\n\n var loop = function () {\n\n for (var i = 0; i < lengthsubjects.length; i++) {\n\n var subj = lengthsubjects[i];\n\n if (subj.prop === \"$$watchlengthsubjectroot\") {\n\n var difference = getObjDiff(subj.obj, subj.actual);\n\n if (difference.added.length || difference.removed.length) {\n if (difference.added.length) {\n watchMany(subj.obj, difference.added, subj.watcher, subj.level - 1, true);\n }\n\n subj.watcher.call(subj.obj, \"root\", \"differentattr\", difference, subj.actual);\n }\n subj.actual = clone(subj.obj);\n\n } else {\n\n var difference = getObjDiff(subj.obj[subj.prop], subj.actual);\n\n if (difference.added.length || difference.removed.length) {\n if (difference.added.length) {\n for (var j = 0; j < subj.obj.watchers[subj.prop].length; j++) {\n watchMany(subj.obj[subj.prop], difference.added, subj.obj.watchers[subj.prop][j], subj.level -\n 1, true);\n }\n }\n\n callWatchers(subj.obj, subj.prop, \"differentattr\", difference, subj.actual);\n }\n\n subj.actual = clone(subj.obj[subj.prop]);\n\n }\n\n }\n\n };\n\n var pushToLengthSubjects = function (obj, prop, watcher, level) {\n\n var actual;\n\n if (prop === \"$$watchlengthsubjectroot\") {\n actual = clone(obj);\n } else {\n actual = clone(obj[prop]);\n }\n\n lengthsubjects.push({\n obj: obj,\n prop: prop,\n actual: actual,\n watcher: watcher,\n level: level\n });\n };\n\n var removeFromLengthSubjects = function (obj, prop, watcher) {\n\n for (var i = 0; i < lengthsubjects.length; i++) {\n var subj = lengthsubjects[i];\n\n if (subj.obj == obj && subj.prop == prop && subj.watcher == watcher) {\n lengthsubjects.splice(i, 1);\n }\n }\n\n };\n\n setInterval(loop, 50);\n\n WatchJS.watch = watch;\n WatchJS.unwatch = unwatch;\n WatchJS.callWatchers = callWatchers;\n\n return WatchJS;\n\n}));\n/**\n * Created by guntars on 15/03/2016.\n */\ndefine('widget/parsers/addChildren',[], function() {\n 'use strict';\n function addChildren(parent, child, data) {\n if (child && child.name && parent) {\n applyEvents(parent, child, data);\n elReady(parent, child, data);\n let handler = elOnChange(parent, child);\n if (handler) {\n handler(data);\n }\n parent.children[child.name] = child;\n return child;\n }\n };\n\n function elOnChange(context, child) {\n if (context.elOnChange[child.name] !== undefined) {\n return (data)=> context.elOnChange[child.name].call(context, child, data);\n }\n return false;\n };\n\n function elReady(context, child, data) {\n if (context.elReady[child.name] !== undefined) {\n context.elReady[child.name].call(context, child, data);\n }\n };\n\n //Aplying Events to elements\n //\n // @private applyEvents\n // @param {dom.Element} element\n // @param {Array} events\n // @param {Object} data\n function applyEvents(context, child, data) {\n var events = context.events[child.name];\n if (events !== undefined && child.el !== undefined && child.data.type !== 'cp') {\n events.forEach((event)=> {\n context._events.push(child.on(event.name, event.action, context, data));\n });\n }\n };\n\n\n Object.assign(addChildren, {elOnChange, elReady, applyEvents});\n\n return addChildren;\n});\n/**\n * Created by guntars on 11/11/14.\n */\ndefine('widget/parsers/applyAttribute',[\n 'watch',\n './addChildren'\n], function(WatchJS, addChildren) {\n var watch = WatchJS.watch;\n\n function applyAttribute(context, childBinder, data) {\n var bind = childBinder.data.tplSet.bind,\n update = childBinder.data.tplSet.update;\n if (bind) {\n Object.keys(bind).forEach((bindItem)=> {\n let key = bind[bindItem],\n dataItem = data[key];\n switch (bindItem) {\n case 'class':\n let addClass = (className)=> {\n if (className !== undefined && className !== '') {\n childBinder.addClass(className);\n return className;\n } else {\n return false;\n }\n },\n currClass = addClass(dataItem);\n\n if (update === true) {\n watch(data, key, ()=> {\n if (currClass) {\n childBinder.removeClass(currClass);\n }\n currClass = addClass(data[key]);\n });\n }\n\n break;\n case 'checked':\n if (dataItem !== undefined) {\n childBinder.el.checked = dataItem;\n }\n if (update === true) {\n watch(data, key, ()=> childBinder.el.checked = data[key]);\n }\n break;\n case 'value':\n if (dataItem !== undefined) {\n childBinder.el.value = dataItem;\n }\n if (update === true) {\n watch(data, key, ()=> childBinder.el.value = data[key]);\n }\n break;\n case 'required':\n if (dataItem !== undefined) {\n childBinder.el.required = dataItem;\n }\n if (update === true) {\n watch(data, key, ()=> childBinder.el.required = data[key]);\n }\n break;\n case 'text':\n if (dataItem !== undefined) {\n childBinder.text(dataItem);\n }\n if (update === true) {\n watch(data, key, ()=> childBinder.text(data[key]));\n }\n break;\n default:\n if (dataItem !== undefined) {\n childBinder.setAttribute(bindItem, dataItem);\n }\n if (update === true) {\n watch(data, key, ()=> childBinder.setAttribute(bindItem, data[key]));\n }\n }\n\n if (data.text !== undefined && bindItem !== 'text') {\n childBinder.text(data.text);\n if (update === true) {\n if (bindItem !== 'text') {\n watch(data, 'text', ()=> childBinder.text(data.text));\n }\n }\n }\n if (update === true) {\n let handler = addChildren.elOnChange(context, childBinder);\n if (handler) {\n watch(data, key, ()=> handler(data));\n }\n }\n\n });\n }\n\n }\n\n return applyAttribute;\n});\n/**\n * Created by guntars on 11/11/14.\n */\ndefine('widget/parsers/applyParent',[\n 'templating/dom',\n './addChildren'\n], function(dom, addChildren) {\n\n\n function setChildren(context, parentChildren = {}, data = {}) {\n if (context) {\n let elements = context.children;\n\n if (elements) {\n Object.keys(elements).forEach((name)=> {\n let add = true,\n child = elements[name],\n parentChild = parentChildren[name];\n if (parentChild !== undefined) {\n if (context.nodes[name] !== undefined) {\n context.nodes[name].call(context, child, parentChild, data);\n } else if (child !== undefined) {\n if (typeof parentChild === 'string') {\n dom.text(child, parentChild);\n }\n else {\n child = parentChild.run(child.el);\n }\n }\n\n } else if (context.nodes[name] !== undefined &&\n child.data.tplSet.noattach) {\n context.nodes[name].call(context, child, data);\n add = false;\n }\n if (add && child.elGroup.size > 0) {\n addChildren(context, child, data);\n }\n\n });\n }\n }\n }\n\n return setChildren;\n});\n/**\n * Created by guntars on 10/10/2014.\n */\ndefine('widget/utils',[],function () {\n function extend(obj) {\n var type = typeof obj;\n if (!(type === 'function' || type === 'object' && !!obj)) {\n return obj;\n }\n var source, prop;\n for (var i = 1, length = arguments.length; i < length; i++) {\n source = arguments[i];\n for (prop in source) {\n obj[prop] = source[prop];\n }\n }\n return obj;\n };\n\n function fnExtend(protoProps, staticProps) {\n var parent = this;\n var child;\n if (protoProps && protoProps != null &&\n hasOwnProperty.call(protoProps, 'constructor')) {\n child = protoProps.constructor;\n } else {\n child = function () {\n return parent.apply(this, arguments);\n };\n }\n\n extend(child, parent, staticProps);\n\n var Surrogate = function () {\n this.constructor = child;\n };\n Surrogate.prototype = parent.prototype;\n child.prototype = new Surrogate;\n if (protoProps) {\n extend(child.prototype, protoProps);\n }\n\n child.__super__ = parent.prototype;\n return child;\n };\n\n function isString(obj) {\n return toString.call(obj) === '[object String]';\n\n }\n\n function isObject(obj) {\n return obj === Object(obj);\n }\n\n function isArray(obj) {\n return (Array.isArray) ? Array.isArray(obj) : toString.call(obj) === '[object Array]';\n }\n\n\n return {\n fnExtend: fnExtend,\n // Extend a given object with all the properties in passed-in object(s).\n extend: extend,\n // Check if it's String\n isString: isString,\n // Check if I't Object\n isObject: isObject,\n // Check if it's Array\n isArray: isArray\n };\n});\n/**\n * Created by guntars on 11/11/14.\n */\ndefine('widget/parsers/setBinders',[],function () {\n\n function setBinders(children, ignoreCP) {\n let bindings = {};\n Object.defineProperty(bindings, '__cp__', {\n enumerable: false,\n value: []\n });\n Object.keys(children).forEach((key) => {\n let el = children[key];\n if (el && el.data && el.data.bind !== undefined && el.data.type !== 'cp') {\n bindings[el.data.bind] = bindings[el.data.bind] || []\n bindings[el.data.bind].push(el);\n } else if (!ignoreCP && el.data.type === 'cp') {\n bindings['__cp__'].push(el);\n }\n });\n return bindings;\n }\n\n return setBinders;\n});\n/**\n * Created by guntars on 11/11/14.\n */\ndefine('widget/parsers/applyBinders',[\n 'templating/dom',\n '../utils',\n 'watch',\n './setBinders',\n './addChildren',\n './applyAttribute'\n], function(dom, utils, WatchJS, setBinders, addChildren, applyAttribute) {\n var watch = WatchJS.watch,\n unwatch = WatchJS.unwatch;\n\n function parseBinder(context, objKey, obj, binder) {\n if (binder !== undefined) {\n var data = obj[objKey];\n\n if (context.nodes[objKey]) {\n context.nodes[objKey].call(context, binder, data);\n } else {\n if (!utils.isArray(data) && !utils.isObject(data)) {\n let element = binder.run(true);\n element.text(data);\n addChildren.applyEvents(context, element, data);\n addChildren.elReady(context, element, data);\n let handler = addChildren.elOnChange(context, element);\n if (handler) {\n handler(data);\n }\n\n\n if (element.data.tplSet.update) {\n watch(obj, objKey, () => {\n element.text(obj[objKey]);\n let handler = addChildren.elOnChange(context, element);\n if (handler) {\n handler(obj[objKey]);\n }\n });\n }\n } else if (utils.isArray(data)) {\n\n let bindedData = [],\n addItem = (item, index)=> {\n let isString = false;\n if (!utils.isArray(item) && !utils.isObject(item)) {\n isString = true;\n }\n let element = binder.run(true, index);\n if (isString) {\n element.text(item);\n }\n\n bindedData.push({\n binder: element,\n data: item\n });\n\n applyAttribute(context, element, item);\n addChildren.applyEvents(context, element, item);\n addChildren.elReady(context, element, item);\n\n let handler = addChildren.elOnChange(context, element);\n if (handler) {\n handler(item);\n }\n\n if (element.children) {\n element.bindings = setBinders(element.children);\n applyBinders(context, item, element);\n }\n\n\n };\n\n data.forEach(addItem);\n\n let update = binder.data.tplSet.update;\n if (update) {\n let removeMethodNames = ['pop', 'shift', 'splice'],\n insertMethodNames = ['push', 'unshift'],\n sortingMethodNames = ['reverse', 'sort'];\n watch(obj, objKey, (prop, action, newValue, oldValue)=> {\n let clonedData = bindedData.slice(0);\n if (oldValue === undefined && insertMethodNames.indexOf(action) !== -1) {\n let filter = clonedData.filter((item)=> item.data === newValue[0]);\n\n if (filter.length === 0) {\n addItem(newValue[0], (action === 'unshift') ? 0 : clonedData.length);\n }\n } else if (removeMethodNames.indexOf(action) !== -1) {\n clonedData.forEach((binder)=> {\n if (obj[objKey].indexOf(binder.data) === -1) {\n binder.binder.remove();\n bindedData.splice(bindedData.indexOf(binder), 1);\n }\n });\n\n if (action === 'splice') {\n let vals = Array.prototype.slice.call(newValue, 2);\n if (vals && vals.length > 0) {\n vals.forEach((val)=> {\n let index = obj[objKey].indexOf(val);\n if (index !== -1) {\n addItem(val, index);\n }\n });\n }\n }\n } else if (sortingMethodNames.indexOf(action) !== -1) {\n data.forEach((value, index)=> {\n let element = clonedData.filter(item=>item.data === value)[0];\n bindedData.splice(index, 0, bindedData.splice(bindedData.indexOf(element), 1)[0]);\n element.binder.changePosition(index);\n\n });\n }\n\n });\n }\n\n\n } else if (utils.isObject(data)) {\n let element = binder.run(data);\n if (element.data.type !== 'cp') {\n applyAttribute(context, element, data);\n addChildren.applyEvents(context, element, data);\n addChildren.elReady(context, element, data);\n let handler = addChildren.elOnChange(context, element);\n if (handler) {\n handler(data);\n }\n if (element.children) {\n element.bindings = setBinders(element.children);\n applyBinders(context, data, element);\n }\n }\n\n\n }\n }\n }\n\n };\n\n function applyBinders(child, obj, instance) {\n let binders = instance.bindings;\n if (binders) {\n if (binders['__cp__'].length > 0) {\n binders['__cp__'].forEach(binder=> {\n let component = binder.run(obj);\n component.setContext(child.context);\n addChildren.elReady(child, component, obj);\n let handler = addChildren.elOnChange(child, component);\n if (handler) {\n handler(obj);\n }\n\n });\n }\n let keys = Object.keys(binders);\n if (obj && keys.length > 0) {\n keys.forEach((binderKey) => {\n if (obj[binderKey] !== undefined) {\n binders[binderKey].forEach(binder=>parseBinder(child, binderKey, obj, binder));\n } else {\n let fn = (prop, action, newValue, oldValue) => {\n if (newValue !== undefined && oldValue === undefined) {\n binders[binderKey].forEach(binder=>parseBinder(child, binderKey, obj, binder));\n unwatch(obj, binderKey, fn);\n }\n }\n watch(obj, binderKey, fn, 0);\n }\n });\n }\n }\n }\n\n return applyBinders;\n});\n/**\n * Created by guntars on 11/11/14.\n */\ndefine('widget/parsers/setRoutes',[\n 'templating/dom'\n], function(dom) {\n\n const STRIP_COMMENTS = /((\\/\\/.*$)|(\\/\\*[\\s\\S]*?\\*\\/))/mg,\n ARGUMENT_NAMES = /(?:^|,)\\s*([^\\s,=]+)/g;\n\n function getArgs(func) {\n let fnStr = func.toString().replace(STRIP_COMMENTS, ''),\n argsList = fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')),\n result = argsList.match(ARGUMENT_NAMES);\n return (result === null) ? [] : result.map(item => item.replace(/[\\s,]/g, ''));\n }\n\n function destroyComponent(cp) {\n if (cp.remove !== undefined) {\n cp.remove();\n }\n\n }\n\n function applyToChildren(children, cb) {\n if (children !== undefined) {\n Object.keys(children).forEach((name) => {\n let instance = children[name];\n if (!applyToGroup(instance, cb)) {\n cb(instance);\n }\n });\n }\n }\n\n function applyToGroup(child, cb) {\n if (child.elGroup && child.elGroup.size > 0) {\n child.elGroup.forEach((childInstance) => {\n cb(childInstance);\n });\n return true;\n }\n return false;\n }\n\n\n function matchRoute(child, context) {\n if (child.setContext) {\n child.setContext(context);\n } else {\n let route = (child.data !== undefined) ? child.data.route : undefined;\n if (route !== undefined && child.data.type === 'rt') {\n let id,\n match = context.match,\n active = context.active,\n matches = match(route);\n\n matches.to((...args) => {\n let params = args.pop();\n id = (args.length > 0) ? params.getLocation() + '_' + args.join('_') : undefined;\n\n if (!applyToGroup(child, instance => dom.attach(instance))) {\n let childInstance = child.run(true);\n applyToChildren(childInstance.children, instance => {\n if (instance) {\n //TODO: maybe not need Object.assign\n match(route, match => matchRoute(instance, Object.assign({}, context, {\n match,\n active\n })));\n }\n });\n }\n applyToGroup(child, (childInstance) => {\n applyToChildren(childInstance.children, instance => {\n if (instance && instance.to) {\n instance.to(...args.concat(params));\n }\n });\n });\n });\n\n matches.leave(done => {\n let items = 0,\n stopped = false;\n applyToGroup(child, (childInstance) => {\n let finish = () => {\n if (!id) {\n dom.detach(childInstance);\n } else {\n destroyComponent(childInstance);\n }\n },\n close = (close = true) => {\n if (close) {\n items--;\n } else {\n stopped = true;\n done(false);\n }\n\n if (items === 0 && !stopped) {\n active.set(childInstance, finish);\n done(true);\n }\n\n };\n\n applyToChildren(childInstance.children, instance => {\n if (instance && instance.leave !== undefined) {\n let args = getArgs(instance.leave);\n if (args.length > 0) {\n items++\n }\n instance.leave(close);\n }\n });\n\n if (items === 0) {\n active.set(childInstance, finish);\n done(true);\n }\n });\n });\n\n matches.query((params) => {\n applyToGroup(child, (childInstance) => {\n applyToChildren(childInstance.children, (instance) => {\n if (instance && instance.query !== undefined) {\n instance.query(params);\n }\n });\n });\n });\n applyToGroup(child, instance => instance._activeRoute = matches);\n\n } else if (child.children !== undefined && ['cp'].indexOf(child.data.type) === -1) {\n applyToChildren(child.children, instance => matchRoute(instance, context));\n }\n }\n }\n\n function setRoutes(children, context) {\n applyToChildren(children, child => matchRoute(child, context));\n\n };\n\n return setRoutes;\n})\n;\n/**\n * Created by guntars on 15/03/2016.\n */\ndefine('widget/parsers/applyElement',[\n 'templating/dom'\n], function (dom) {\n //Applying dom.Element to template elements.\n //\n // @private applyElement\n // @param {Object} elements\n function applyElement(elements = {}, params) {\n let instances = {};\n Object.keys(elements).forEach((key)=> {\n let instance = elements[key];\n if (typeof instance !== 'string') {\n let element = instance.elGroup.first;\n if (element) {\n instances[key] = element;\n if (element instanceof dom.Element === true &&\n (['pl'].indexOf(element.data.type) !== -1)) {\n let bind = element.data.tplSet.bind;\n if (bind) {\n Object.keys(bind).forEach((attr)=> {\n if (params[bind[attr]] !== undefined) {\n if (attr !== 'class') {\n element.setAttribute(attr, params[bind[attr]]);\n } else {\n element.addClass(params[bind[attr]]);\n }\n }\n });\n }\n\n }\n } else {\n instances[key] = instance;\n }\n }\n });\n\n return instances;\n }\n\n return applyElement;\n});\n/**\n * Created by guntars on 10/10/2014.\n */\n/*globals define*/\n//## widget/Constructor Class\n// This is App Presenter class parse data, and apply to template. Also binding events to Element.\n// Basic Usage example\n//\n// define([\n// 'templating/parser!widget.html',\n// 'widget/Constructor'\n// ], function (template, Constructor) {\n// var Widget = Constructor.extend({\n// template: template\n// });\n// return Widget;\n// });\ndefine('widget/Constructor',[\n 'require',\n 'templating/Decoder',\n 'templating/dom',\n './Mediator',\n './parsers/applyAttribute',\n './parsers/applyParent',\n './parsers/applyBinders',\n './parsers/setBinders',\n './parsers/setRoutes',\n './parsers/applyElement',\n './parsers/addChildren'\n], function(require,\n Decoder,\n dom,\n Mediator,\n applyAttribute,\n applyParent,\n applyBinders,\n setBinders,\n setRoutes,\n applyElement,\n addChildren) {\n 'use strict';\n\n\n function destroy(instance) {\n let keys = Object.keys(instance);\n if (keys.length > 0) {\n keys.forEach((key) => {\n if (key !== 'root') {\n let children = instance[key];\n if (children.elGroup !== undefined && children.elGroup.size > 0) {\n children.elGroup.forEach(child => {\n if (child !== undefined && child.remove !== undefined) {\n child.remove(true);\n }\n })\n }\n }\n });\n }\n }\n\n // Constructor Class\n //\n // @Constructor\n // @param {Object} data\n // @param {Object} children\n // @param {Object} dataSet\n class Constructor {\n static extend(options = {}) {\n class Surrogate extends Constructor {\n }\n Object.assign(Surrogate.prototype, options);\n return Surrogate;\n };\n\n constructor(options = {}, parentChildren, dataSet = {}, node) {\n //TODO: for Backwards compatability later need to remove\n this.instance = this;\n this._events = [];\n this._globalEvents = [];\n this._parentChildren = parentChildren;\n this._options = options;\n this._rendered = false;\n this._arguments = Array.from(arguments);\n this._dataSet = dataSet;\n\n this.eventBus = new Mediator(this);\n\n if (node !== undefined && node.name !== undefined) {\n this.name = node.name;\n }\n this.beforeInit(...this._arguments);\n };\n\n ready(el) {\n this.el = el;\n }\n\n setContext(context) {\n if (!this.context) {\n this.context = context;\n if (!this.async) {\n this.render();\n }\n this.init(...this._arguments);\n }\n };\n\n set context(context) {\n if (!this.data) {\n let keys = (this._dataSet) ? Object.keys(this._dataSet) : [],\n contextData = (keys.length > 0) ? this._dataSet : context.data;\n if (contextData) {\n this.data = contextData[this._options.bind] || contextData;\n }\n }\n context.match((match) => {\n if (this.match) {\n this.match(match);\n }\n\n this._context = Object.assign({\n match: match\n }, context);\n });\n }\n\n get context() {\n return this._context;\n };\n\n // method render called manually if flag async is true;\n //\n // @method render\n render(data) {\n if (!this._rendered) {\n if (this.template) {\n if (data) {\n this.data = data;\n }\n let options = this._options,\n parentChildren = this._parentChildren,\n decoder = new Decoder(this.template),\n template = decoder.render(this.data);\n if (this.el) {\n let parent = this.el.parentNode;\n if (parent) {\n parent.replaceChild(template.fragment, this.el);\n }\n if (this.elGroup && this.elGroup.get(this.el)) {\n this.elGroup.delete(this.el);\n this.el = template.fragment;\n this.elGroup.set(template.fragment, this);\n }\n } else {\n this.el = template.fragment;\n }\n\n\n this.root = new dom.Element(template.fragment, {\n name: 'root',\n data: {}\n });\n\n this.children = applyElement(template.children, options);\n applyParent(this, parentChildren, this.data);\n this.bindings = setBinders(this.children, true);\n\n if (this.data) {\n this.applyBinders(this.data, this);\n }\n\n setRoutes(this.children, this.context);\n addChildren(this, this.root);\n this.rendered(...this._arguments);\n this._rendered = true;\n } else {\n this.root = new dom.Element('
', {\n name: 'root',\n data: {}\n });\n this.el = this.root.el;\n\n this.rendered(...this._arguments);\n this._rendered = true;\n }\n }\n };\n\n // Running before Constructor is initialised\n //\n // @method beforeInit\n // @param {Object} data (comes from template data attributes)\n // @param {Object} children (comes placeholder content\n // from template)\n // @param {Object} datatSet (data passing if component is\n // in template binders)\n beforeInit(data, children, dataSet) {\n };\n\n // Running when Constructor is initialised\n //\n // @method beforeInit\n // @param {Object} data (comes from template data attributes)\n // @param {Object} children (comes placeholder content\n // from template)\n // @param {Object} datatSet (data passing if component is\n // in template binders)\n init(data, children, dataSet) {\n };\n\n // Running when widget is rendered\n //\n // @method rendered\n // @param {Object} data (comes from template data attributes)\n // @param {Object} children (comes placeholder content\n // from template)\n // @param {Object} datatSet (data passing if component is\n // in template binders)\n rendered(data, children, dataSet) {\n };\n\n\n // Load external css style for third party modules.\n //\n // @method loadCss\n // @param {string} url\n loadCss(url) {\n if (this.context._cssReady.indexOf(url) === -1) {\n this.context._cssReady.push(url);\n let linkRef = document.createElement(\"link\");\n linkRef.setAttribute(\"rel\", \"stylesheet\")\n linkRef.setAttribute(\"type\", \"text/css\")\n linkRef.setAttribute(\"href\", url)\n if (typeof linkRef != \"undefined\") {\n document.getElementsByTagName(\"head\")[0].appendChild(linkRef);\n }\n }\n\n };\n\n // Remove from parentNode\n //\n // @method detach\n detach() {\n if (!this._placeholder) {\n this._placeholder = document.createElement(this.el.tagName);\n }\n if (!this._parent) {\n this._parent = this.el.parentNode;\n }\n\n if (this.el && this._parent) {\n this._parent.replaceChild(this._placeholder, this.el)\n }\n\n };\n\n // Add to parentNode\n //\n // @method attach\n attach() {\n if (this._placeholder && this._parent) {\n this._parent.replaceChild(this.el, this._placeholder)\n }\n };\n\n // Executes when Component is destroyed\n //\n // @method applyBinders\n onDestroy() {\n\n };\n\n //Removing widget from Dom\n //\n // @method destroy\n destroy() {\n this.onDestroy();\n this.eventBus.clear();\n while (this._events.length > 0) {\n this._events.shift().remove();\n }\n\n while (this._globalEvents.length > 0) {\n this._globalEvents.shift().remove();\n }\n\n destroy(this.children);\n\n if (this.elGroup !== undefined && this.el !== undefined) {\n this.elGroup.delete(this.el);\n }\n if (this.root && this.root.remove) {\n this.root.remove();\n }\n\n delete this.el;\n\n };\n\n remove(...args) {\n this.destroy(...args);\n }\n\n // Adding Childrens manually after initialization.\n // @method setChildren\n // @param {Element} el\n // @param {Object} data\n //TODO: need to write tests for async operations.\n setChildren(el, data) {\n let name = el.data.name,\n instance = this.children[name];\n\n if (instance !== undefined && instance.el !== undefined) {\n instance.remove();\n }\n\n let newInstance = el.run(data || true);\n if (newInstance.setContext) {\n newInstance.setContext(this.context);\n }\n addChildren(this, newInstance, data);\n return newInstance;\n\n };\n\n // Adding Dynamic components\n // @method addComponent\n // @param {String} name\n // @param {Constructor} Component\n // @param {Element} container\n // @param {Object} data (data attributes)\n // @param {Object} children\n // @param {Object} dataSet (Model for bindings)\n addComponent(Component, options) {\n let name = options.name,\n container = options.container;\n\n if (name === undefined) {\n throw ('you have to define data.name for component.')\n } else if (container === undefined) {\n throw ('You have to define container for component.')\n } else if (this.children[name] !== undefined) {\n throw ('Component using name:' + name + '! already defined.')\n }\n let component = this.setComponent(Component, options),\n instance = component.run(options.container);\n instance.setContext(this.context);\n this.children[name] = instance;\n return instance;\n };\n\n setComponent(Component, options) {\n let instance = {\n name: options.name,\n data: {\n tag: 'div',\n type: 'cp'\n },\n run: (container) => {\n options.appContext = this.context;\n let cp = new Component(options, options.children, options.data),\n el = document.createElement('div');\n el.setAttribute('style', 'display:none;');\n cp.ready(el);\n\n if (container instanceof HTMLElement === true) {\n container.parentNode.replaceChild(cp.el, container);\n } else if (container.el !== undefined && options.pos !== undefined) {\n dom.insertBefore(container, cp, options.pos);\n } else if (container.el !== undefined) {\n dom.append(container, cp);\n }\n return cp;\n }\n }\n return instance;\n }\n\n // Running when Constructor is initialised\n //\n // @method applyBinders\n // @param {Object} data (comes from template data attributes)\n // @param {Object} children (comes placeholder content\n // from template)\n // @param {Object} datatSet (data passing if component is\n // in template binders)\n // Applying Binders manually, if use nodes function\n //\n // @method applyBinders\n applyBinders(...args) {\n return applyBinders(this, ...args);\n }\n }\n Object.assign(Constructor.prototype, {\n // `nodes` Object override default methods to Elements.\n // Usage Example\n //\n // nodes: {\n // listItem: function (el, parent, data) {\n // el.add(parent);\n // el.text(data);\n // }\n // }\n nodes: {},\n\n // `events` Object applying events to elements\n // You can apply more than one event on element\n // Usage Example\n //\n // events: {\n // delete: [\n // {\n // name: 'click',\n // action: function () {\n // this.data.remove = true\n // this.destroy();\n // }\n // }\n // ]\n events: {},\n // Applying extra methods to Element\n // Usage Example\n //\n // elReady: {\n // links: function (el, data) {\n // if(data.class==='active'){\n // el.addClass('active');\n // }\n // }\n // },\n elReady: {},\n // Applying methods to element every time when data is changed for Element\n // Usage Example\n //\n // elOnChange: {\n // links: function (el, data) {\n // if(data.class==='active'){\n // el.addClass('active');\n // }\n // }\n // },\n elOnChange: {}\n });\n\n\n return Constructor;\n});\n"]} \ No newline at end of file +{"version":3,"sources":["../../../es6/dev/widget/Constructor.js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 1.7+\n *\n * FORK:\n * https://github.com/melanke/Watch.JS\n */\n\n\n(function (factory) {\n if (typeof exports === 'object') {\n // Node. Does not work with strict CommonJS, but\n // only CommonJS-like enviroments that support module.exports,\n // like Node.\n module.exports = factory();\n } else if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define('watch',factory);\n } else {\n // Browser globals\n window.WatchJS = factory();\n window.watch = window.WatchJS.watch;\n window.unwatch = window.WatchJS.unwatch;\n window.callWatchers = window.WatchJS.callWatchers;\n }\n}(function () {\n\n var WatchJS = {\n noMore: false\n },\n lengthsubjects = [];\n\n var isFunction = function (functionToCheck) {\n var getType = {};\n return functionToCheck && getType.toString.call(functionToCheck) == '[object Function]';\n };\n\n var isInt = function (x) {\n return x % 1 === 0;\n };\n\n var isArray = function (obj) {\n return Object.prototype.toString.call(obj) === '[object Array]';\n };\n\n var getObjDiff = function (a, b) {\n var aplus = [],\n bplus = [];\n\n if (!(typeof a == \"string\") && !(typeof b == \"string\")) {\n\n if (isArray(a)) {\n for (var i = 0; i < a.length; i++) {\n if (b[i] === undefined) aplus.push(i);\n }\n } else {\n for (var i in a) {\n if (a.hasOwnProperty(i)) {\n if (b[i] === undefined) {\n aplus.push(i);\n }\n }\n }\n }\n\n if (isArray(b)) {\n for (var j = 0; j < b.length; j++) {\n if (a[j] === undefined) bplus.push(j);\n }\n } else {\n for (var j in b) {\n if (b.hasOwnProperty(j)) {\n if (a[j] === undefined) {\n bplus.push(j);\n }\n }\n }\n }\n }\n\n return {\n added: aplus,\n removed: bplus\n }\n };\n\n var clone = function (obj) {\n\n if (null == obj || \"object\" != typeof obj) {\n return obj;\n }\n\n var copy = obj.constructor();\n\n for (var attr in obj) {\n copy[attr] = obj[attr];\n }\n\n return copy;\n\n }\n\n var defineGetAndSet = function (obj, propName, getter, setter) {\n /* try {\n\n Object.observe(obj, function (changes) {\n changes.forEach(function (change) {\n if (change.name === propName) {\n setter(change.object[change.name]);\n }\n });\n });\n\n } catch (e) {*/\n\n try {\n Object.defineProperty(obj, propName, {\n get: getter,\n set: setter,\n enumerable: true,\n configurable: true\n });\n } catch (e2) {\n try {\n Object.prototype.__defineGetter__.call(obj, propName, getter);\n Object.prototype.__defineSetter__.call(obj, propName, setter);\n } catch (e3) {\n throw new Error(\"watchJS error: browser not supported :/\")\n }\n }\n\n // }\n };\n\n var defineProp = function (obj, propName, value) {\n try {\n Object.defineProperty(obj, propName, {\n enumerable: false,\n configurable: true,\n writable: false,\n value: value\n });\n } catch (error) {\n obj[propName] = value;\n }\n };\n\n var watch = function () {\n\n if (isFunction(arguments[1])) {\n watchAll.apply(this, arguments);\n } else if (isArray(arguments[1])) {\n watchMany.apply(this, arguments);\n } else {\n watchOne.apply(this, arguments);\n }\n\n };\n\n var watchAll = function (obj, watcher, level, addNRemove) {\n\n if ((typeof obj == \"string\") || (!(obj instanceof Object) && !isArray(obj))) { //accepts only objects and array (not string)\n return;\n }\n\n var props = [];\n\n if (isArray(obj)) {\n for (var prop = 0; prop < obj.length; prop++) { //for each item if obj is an array\n props.push(prop); //put in the props\n }\n } else {\n for (var prop2 in obj) { //for each attribute if obj is an object\n if (prop2 == \"$val\") {\n continue;\n }\n\n if (Object.prototype.hasOwnProperty.call(obj, prop2)) {\n props.push(prop2); //put in the props\n }\n }\n }\n\n watchMany(obj, props, watcher, level, addNRemove); //watch all items of the props\n\n if (addNRemove) {\n pushToLengthSubjects(obj, \"$$watchlengthsubjectroot\", watcher, level);\n }\n };\n\n var watchMany = function (obj, props, watcher, level, addNRemove) {\n\n if ((typeof obj == \"string\") || (!(obj instanceof Object) && !isArray(obj))) { //accepts only objects and array (not string)\n return;\n }\n\n for (var i = 0; i < props.length; i++) { //watch each property\n var prop = props[i];\n watchOne(obj, prop, watcher, level, addNRemove);\n }\n\n };\n\n var watchOne = function (obj, prop, watcher, level, addNRemove) {\n if ((typeof obj == \"string\") || (!(obj instanceof Object) && !isArray(obj))) { //accepts only objects and array (not string)\n return;\n }\n\n if (isFunction(obj[prop])) { //dont watch if it is a function\n return;\n }\n if (obj[prop] != null && (level === undefined || level > 0)) {\n watchAll(obj[prop], watcher, level !== undefined ? level - 1 : level); //recursively watch all attributes of this\n }\n\n defineWatcher(obj, prop, watcher, level);\n\n if (addNRemove && (level === undefined || level > 0)) {\n pushToLengthSubjects(obj, prop, watcher, level);\n }\n\n };\n\n var unwatch = function () {\n\n if (isFunction(arguments[1])) {\n unwatchAll.apply(this, arguments);\n } else if (isArray(arguments[1])) {\n unwatchMany.apply(this, arguments);\n } else {\n unwatchOne.apply(this, arguments);\n }\n\n };\n\n var unwatchAll = function (obj, watcher) {\n\n if (obj instanceof String || (!(obj instanceof Object) && !isArray(obj))) { //accepts only objects and array (not string)\n return;\n }\n\n if (isArray(obj)) {\n var props = [];\n for (var prop = 0; prop < obj.length; prop++) { //for each item if obj is an array\n props.push(prop); //put in the props\n }\n unwatchMany(obj, props, watcher); //watch all itens of the props\n } else {\n var unwatchPropsInObject = function (obj2) {\n var props = [];\n for (var prop2 in obj2) { //for each attribute if obj is an object\n if (obj2.hasOwnProperty(prop2)) {\n if (obj2[prop2] instanceof Object) {\n unwatchPropsInObject(obj2[prop2]); //recurs into object props\n } else {\n props.push(prop2); //put in the props\n }\n }\n }\n unwatchMany(obj2, props, watcher); //unwatch all of the props\n };\n unwatchPropsInObject(obj);\n }\n };\n\n var unwatchMany = function (obj, props, watcher) {\n\n for (var prop2 in props) { //watch each attribute of \"props\" if is an object\n if (props.hasOwnProperty(prop2)) {\n unwatchOne(obj, props[prop2], watcher);\n }\n }\n };\n\n var defineWatcher = function (obj, prop, watcher, level) {\n\n var val = obj[prop];\n\n watchFunctions(obj, prop);\n\n if (!obj.watchers) {\n defineProp(obj, \"watchers\", {});\n }\n\n var newWatcher = false;\n if (!obj.watchers[prop]) {\n obj.watchers[prop] = [];\n newWatcher = true;\n }\n\n for (var i = 0; i < obj.watchers[prop].length; i++) {\n if (obj.watchers[prop][i] === watcher) {\n return;\n }\n }\n\n obj.watchers[prop].push(watcher); //add the new watcher in the watchers array\n\n if (newWatcher) {\n var getter = function () {\n return val;\n };\n\n var setter = function (newval) {\n var oldval = val;\n val = newval;\n\n if (level !== 0 && obj[prop]) {\n // watch sub properties\n watchAll(obj[prop], watcher, (level === undefined) ? level : level - 1);\n }\n\n watchFunctions(obj, prop);\n\n if (!WatchJS.noMore) {\n //if (JSON.stringify(oldval) !== JSON.stringify(newval)) {\n if (oldval !== newval) {\n callWatchers(obj, prop, \"set\", newval, oldval);\n WatchJS.noMore = false;\n }\n }\n };\n\n defineGetAndSet(obj, prop, getter, setter);\n }\n\n };\n\n var callWatchers = function (obj, prop, action, newval, oldval) {\n if (prop !== undefined) {\n for (var wr = 0; wr < obj.watchers[prop].length; wr++) {\n obj.watchers[prop][wr].call(obj, prop, action, newval, oldval);\n }\n } else {\n for (var prop in obj) {//call all\n if (obj.hasOwnProperty(prop)) {\n callWatchers(obj, prop, action, newval, oldval);\n }\n }\n }\n };\n\n // @todo code related to \"watchFunctions\" is certainly buggy\n var methodNames = ['pop', 'push', 'reverse', 'shift', 'sort', 'slice', 'unshift', 'splice'];\n var defineArrayMethodWatcher = function (obj, prop, original, methodName) {\n defineProp(obj[prop], methodName, function () {\n var response = original.apply(obj[prop], arguments);\n watchOne(obj, obj[prop]);\n if (methodName !== 'slice') {\n callWatchers(obj, prop, methodName, arguments);\n }\n return response;\n });\n };\n\n var watchFunctions = function (obj, prop) {\n\n if ((!obj[prop]) || (obj[prop] instanceof String) || (!isArray(obj[prop]))) {\n return;\n }\n\n for (var i = methodNames.length, methodName; i--;) {\n methodName = methodNames[i];\n defineArrayMethodWatcher(obj, prop, obj[prop][methodName], methodName);\n }\n\n };\n\n var unwatchOne = function (obj, prop, watcher) {\n\n for (var i = 0; i < obj.watchers[prop].length; i++) {\n var w = obj.watchers[prop][i];\n if (w == watcher) {\n obj.watchers[prop].splice(i, 1);\n }\n }\n\n removeFromLengthSubjects(obj, prop, watcher);\n };\n\n var loop = function () {\n\n for (var i = 0; i < lengthsubjects.length; i++) {\n\n var subj = lengthsubjects[i];\n\n if (subj.prop === \"$$watchlengthsubjectroot\") {\n\n var difference = getObjDiff(subj.obj, subj.actual);\n\n if (difference.added.length || difference.removed.length) {\n if (difference.added.length) {\n watchMany(subj.obj, difference.added, subj.watcher, subj.level - 1, true);\n }\n\n subj.watcher.call(subj.obj, \"root\", \"differentattr\", difference, subj.actual);\n }\n subj.actual = clone(subj.obj);\n\n } else {\n\n var difference = getObjDiff(subj.obj[subj.prop], subj.actual);\n\n if (difference.added.length || difference.removed.length) {\n if (difference.added.length) {\n for (var j = 0; j < subj.obj.watchers[subj.prop].length; j++) {\n watchMany(subj.obj[subj.prop], difference.added, subj.obj.watchers[subj.prop][j], subj.level -\n 1, true);\n }\n }\n\n callWatchers(subj.obj, subj.prop, \"differentattr\", difference, subj.actual);\n }\n\n subj.actual = clone(subj.obj[subj.prop]);\n\n }\n\n }\n\n };\n\n var pushToLengthSubjects = function (obj, prop, watcher, level) {\n\n var actual;\n\n if (prop === \"$$watchlengthsubjectroot\") {\n actual = clone(obj);\n } else {\n actual = clone(obj[prop]);\n }\n\n lengthsubjects.push({\n obj: obj,\n prop: prop,\n actual: actual,\n watcher: watcher,\n level: level\n });\n };\n\n var removeFromLengthSubjects = function (obj, prop, watcher) {\n\n for (var i = 0; i < lengthsubjects.length; i++) {\n var subj = lengthsubjects[i];\n\n if (subj.obj == obj && subj.prop == prop && subj.watcher == watcher) {\n lengthsubjects.splice(i, 1);\n }\n }\n\n };\n\n setInterval(loop, 50);\n\n WatchJS.watch = watch;\n WatchJS.unwatch = unwatch;\n WatchJS.callWatchers = callWatchers;\n\n return WatchJS;\n\n}));\n/**\n * Created by guntars on 15/03/2016.\n */\ndefine('widget/parsers/addChildren',[], function() {\n 'use strict';\n function addChildren(parent, child, data) {\n if (child && child.name && parent) {\n applyEvents(parent, child, data);\n elReady(parent, child, data);\n let handler = elOnChange(parent, child);\n if (handler) {\n handler(data);\n }\n parent.children[child.name] = child;\n return child;\n }\n };\n\n function elOnChange(context, child) {\n if (context.elOnChange[child.name] !== undefined) {\n return (data)=> context.elOnChange[child.name].call(context, child, data);\n }\n return false;\n };\n\n function elReady(context, child, data) {\n if (context.elReady[child.name] !== undefined) {\n context.elReady[child.name].call(context, child, data);\n }\n };\n\n //Aplying Events to elements\n //\n // @private applyEvents\n // @param {dom.Element} element\n // @param {Array} events\n // @param {Object} data\n function applyEvents(context, child, data) {\n var events = context.events[child.name];\n if (events !== undefined && child.el !== undefined && child.data.type !== 'cp') {\n events.forEach((event)=> {\n context._events.push(child.on(event.name, event.action, context, data));\n });\n }\n };\n\n\n Object.assign(addChildren, {elOnChange, elReady, applyEvents});\n\n return addChildren;\n});\n/**\n * Created by guntars on 11/11/14.\n */\ndefine('widget/parsers/applyAttribute',[\n 'watch',\n './addChildren'\n], function(WatchJS, addChildren) {\n var watch = WatchJS.watch;\n\n function applyAttribute(context, childBinder, data) {\n var bind = childBinder.data.tplSet.bind,\n update = childBinder.data.tplSet.update;\n if (bind) {\n Object.keys(bind).forEach((bindItem)=> {\n let key = bind[bindItem],\n dataItem = data[key];\n switch (bindItem) {\n case 'class':\n let addClass = (className)=> {\n if (className !== undefined && className !== '') {\n childBinder.addClass(className);\n return className;\n } else {\n return false;\n }\n },\n currClass = addClass(dataItem);\n\n if (update === true) {\n watch(data, key, ()=> {\n if (currClass) {\n childBinder.removeClass(currClass);\n }\n currClass = addClass(data[key]);\n });\n }\n\n break;\n case 'checked':\n if (dataItem !== undefined) {\n childBinder.el.checked = dataItem;\n }\n if (update === true) {\n watch(data, key, ()=> childBinder.el.checked = data[key]);\n }\n break;\n case 'value':\n if (dataItem !== undefined) {\n childBinder.el.value = dataItem;\n }\n if (update === true) {\n watch(data, key, ()=> childBinder.el.value = data[key]);\n }\n break;\n case 'required':\n if (dataItem !== undefined) {\n childBinder.el.required = dataItem;\n }\n if (update === true) {\n watch(data, key, ()=> childBinder.el.required = data[key]);\n }\n break;\n case 'text':\n if (dataItem !== undefined) {\n childBinder.text(dataItem);\n }\n if (update === true) {\n watch(data, key, ()=> childBinder.text(data[key]));\n }\n break;\n default:\n if (dataItem !== undefined) {\n childBinder.setAttribute(bindItem, dataItem);\n }\n if (update === true) {\n watch(data, key, ()=> childBinder.setAttribute(bindItem, data[key]));\n }\n }\n\n if (data.text !== undefined && bindItem !== 'text') {\n childBinder.text(data.text);\n if (update === true) {\n if (bindItem !== 'text') {\n watch(data, 'text', ()=> childBinder.text(data.text));\n }\n }\n }\n if (update === true) {\n let handler = addChildren.elOnChange(context, childBinder);\n if (handler) {\n watch(data, key, ()=> handler(data));\n }\n }\n\n });\n }\n\n }\n\n return applyAttribute;\n});\n/**\n * Created by guntars on 11/11/14.\n */\ndefine('widget/parsers/applyParent',[\n 'templating/dom',\n './addChildren'\n], function(dom, addChildren) {\n\n\n function setChildren(context, parentChildren = {}, data = {}) {\n if (context) {\n let elements = context.children;\n\n if (elements) {\n Object.keys(elements).forEach((name)=> {\n let add = true,\n child = elements[name],\n parentChild = parentChildren[name];\n if (parentChild !== undefined) {\n if (context.nodes[name] !== undefined) {\n context.nodes[name].call(context, child, parentChild, data);\n } else if (child !== undefined) {\n if (typeof parentChild === 'string') {\n dom.text(child, parentChild);\n }\n else {\n child = parentChild.run(child.el);\n }\n }\n\n } else if (context.nodes[name] !== undefined &&\n child.data.tplSet.noattach) {\n context.nodes[name].call(context, child, data);\n add = false;\n }\n if (add && child.elGroup.size > 0) {\n addChildren(context, child, data);\n }\n\n });\n }\n }\n }\n\n return setChildren;\n});\n/**\n * Created by guntars on 10/10/2014.\n */\ndefine('widget/utils',[],function () {\n function extend(obj) {\n var type = typeof obj;\n if (!(type === 'function' || type === 'object' && !!obj)) {\n return obj;\n }\n var source, prop;\n for (var i = 1, length = arguments.length; i < length; i++) {\n source = arguments[i];\n for (prop in source) {\n obj[prop] = source[prop];\n }\n }\n return obj;\n };\n\n function fnExtend(protoProps, staticProps) {\n var parent = this;\n var child;\n if (protoProps && protoProps != null &&\n hasOwnProperty.call(protoProps, 'constructor')) {\n child = protoProps.constructor;\n } else {\n child = function () {\n return parent.apply(this, arguments);\n };\n }\n\n extend(child, parent, staticProps);\n\n var Surrogate = function () {\n this.constructor = child;\n };\n Surrogate.prototype = parent.prototype;\n child.prototype = new Surrogate;\n if (protoProps) {\n extend(child.prototype, protoProps);\n }\n\n child.__super__ = parent.prototype;\n return child;\n };\n\n function isString(obj) {\n return toString.call(obj) === '[object String]';\n\n }\n\n function isObject(obj) {\n return obj === Object(obj);\n }\n\n function isArray(obj) {\n return (Array.isArray) ? Array.isArray(obj) : toString.call(obj) === '[object Array]';\n }\n\n\n return {\n fnExtend: fnExtend,\n // Extend a given object with all the properties in passed-in object(s).\n extend: extend,\n // Check if it's String\n isString: isString,\n // Check if I't Object\n isObject: isObject,\n // Check if it's Array\n isArray: isArray\n };\n});\n/**\n * Created by guntars on 11/11/14.\n */\ndefine('widget/parsers/setBinders',[],function () {\n\n function setBinders(children, ignoreCP) {\n let bindings = {};\n Object.defineProperty(bindings, '__cp__', {\n enumerable: false,\n value: []\n });\n Object.keys(children).forEach((key) => {\n let el = children[key];\n if (el && el.data && el.data.bind !== undefined && el.data.type !== 'cp') {\n bindings[el.data.bind] = bindings[el.data.bind] || []\n bindings[el.data.bind].push(el);\n } else if (!ignoreCP && el.data.type === 'cp') {\n bindings['__cp__'].push(el);\n }\n });\n return bindings;\n }\n\n return setBinders;\n});\n/**\n * Created by guntars on 11/11/14.\n */\ndefine('widget/parsers/applyBinders',[\n 'templating/dom',\n '../utils',\n 'watch',\n './setBinders',\n './addChildren',\n './applyAttribute'\n], function(dom, utils, WatchJS, setBinders, addChildren, applyAttribute) {\n var watch = WatchJS.watch,\n unwatch = WatchJS.unwatch;\n\n function parseBinder(context, objKey, obj, binder) {\n if (binder !== undefined) {\n var data = obj[objKey];\n\n if (context.nodes[objKey]) {\n context.nodes[objKey].call(context, binder, data);\n } else {\n if (!utils.isArray(data) && !utils.isObject(data)) {\n let element = binder.run(true);\n element.text(data);\n addChildren.applyEvents(context, element, data);\n addChildren.elReady(context, element, data);\n let handler = addChildren.elOnChange(context, element);\n if (handler) {\n handler(data);\n }\n\n\n if (element.data.tplSet.update) {\n watch(obj, objKey, () => {\n element.text(obj[objKey]);\n let handler = addChildren.elOnChange(context, element);\n if (handler) {\n handler(obj[objKey]);\n }\n });\n }\n } else if (utils.isArray(data)) {\n\n let bindedData = [],\n addItem = (item, index)=> {\n let isString = false;\n if (!utils.isArray(item) && !utils.isObject(item)) {\n isString = true;\n }\n let element = binder.run(true, index);\n if (isString) {\n element.text(item);\n }\n\n bindedData.push({\n binder: element,\n data: item\n });\n\n applyAttribute(context, element, item);\n addChildren.applyEvents(context, element, item);\n addChildren.elReady(context, element, item);\n\n let handler = addChildren.elOnChange(context, element);\n if (handler) {\n handler(item);\n }\n\n if (element.children) {\n element.bindings = setBinders(element.children);\n applyBinders(context, item, element);\n }\n\n\n };\n\n data.forEach(addItem);\n\n let update = binder.data.tplSet.update;\n if (update) {\n let removeMethodNames = ['pop', 'shift', 'splice'],\n insertMethodNames = ['push', 'unshift'],\n sortingMethodNames = ['reverse', 'sort'];\n watch(obj, objKey, (prop, action, newValue, oldValue)=> {\n let clonedData = bindedData.slice(0);\n if (oldValue === undefined && insertMethodNames.indexOf(action) !== -1) {\n let filter = clonedData.filter((item)=> item.data === newValue[0]);\n\n if (filter.length === 0) {\n addItem(newValue[0], (action === 'unshift') ? 0 : clonedData.length);\n }\n } else if (removeMethodNames.indexOf(action) !== -1) {\n clonedData.forEach((binder)=> {\n if (obj[objKey].indexOf(binder.data) === -1) {\n binder.binder.remove();\n bindedData.splice(bindedData.indexOf(binder), 1);\n }\n });\n\n if (action === 'splice') {\n let vals = Array.prototype.slice.call(newValue, 2);\n if (vals && vals.length > 0) {\n vals.forEach((val)=> {\n let index = obj[objKey].indexOf(val);\n if (index !== -1) {\n addItem(val, index);\n }\n });\n }\n }\n } else if (sortingMethodNames.indexOf(action) !== -1) {\n data.forEach((value, index)=> {\n let element = clonedData.filter(item=>item.data === value)[0];\n bindedData.splice(index, 0, bindedData.splice(bindedData.indexOf(element), 1)[0]);\n element.binder.changePosition(index);\n\n });\n }\n\n });\n }\n\n\n } else if (utils.isObject(data)) {\n let element = binder.run(data);\n if (element.data.type !== 'cp') {\n applyAttribute(context, element, data);\n addChildren.applyEvents(context, element, data);\n addChildren.elReady(context, element, data);\n let handler = addChildren.elOnChange(context, element);\n if (handler) {\n handler(data);\n }\n if (element.children) {\n element.bindings = setBinders(element.children);\n applyBinders(context, data, element);\n }\n }\n\n\n }\n }\n }\n\n };\n\n function applyBinders(child, obj, instance) {\n let binders = instance.bindings;\n if (binders) {\n if (binders['__cp__'].length > 0) {\n binders['__cp__'].forEach(binder=> {\n let component = binder.run(obj);\n component.setContext(child.context);\n addChildren.elReady(child, component, obj);\n let handler = addChildren.elOnChange(child, component);\n if (handler) {\n handler(obj);\n }\n\n });\n }\n let keys = Object.keys(binders);\n if (obj && keys.length > 0) {\n keys.forEach((binderKey) => {\n if (obj[binderKey] !== undefined) {\n binders[binderKey].forEach(binder=>parseBinder(child, binderKey, obj, binder));\n } else {\n let fn = (prop, action, newValue, oldValue) => {\n if (newValue !== undefined && oldValue === undefined) {\n binders[binderKey].forEach(binder=>parseBinder(child, binderKey, obj, binder));\n unwatch(obj, binderKey, fn);\n }\n }\n watch(obj, binderKey, fn, 0);\n }\n });\n }\n }\n }\n\n return applyBinders;\n});\n/**\n * Created by guntars on 11/11/14.\n */\ndefine('widget/parsers/setRoutes',[\n 'templating/dom'\n], function(dom) {\n\n const STRIP_COMMENTS = /((\\/\\/.*$)|(\\/\\*[\\s\\S]*?\\*\\/))/mg,\n ARGUMENT_NAMES = /(?:^|,)\\s*([^\\s,=]+)/g;\n\n function getArgs(func) {\n let fnStr = func.toString().replace(STRIP_COMMENTS, ''),\n argsList = fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')),\n result = argsList.match(ARGUMENT_NAMES);\n return (result === null) ? [] : result.map(item => item.replace(/[\\s,]/g, ''));\n }\n\n function destroyComponent(cp) {\n if (cp.remove !== undefined) {\n cp.remove();\n }\n\n }\n\n function applyToChildren(children, cb) {\n if (children !== undefined) {\n Object.keys(children).forEach((name) => {\n let instance = children[name];\n if (!applyToGroup(instance, cb)) {\n cb(instance);\n }\n });\n }\n }\n\n function applyToGroup(child, cb) {\n if (child.elGroup && child.elGroup.size > 0) {\n child.elGroup.forEach((childInstance) => {\n cb(childInstance);\n });\n return true;\n }\n return false;\n }\n\n\n function matchRoute(child, context) {\n if (child.setContext) {\n child.setContext(context);\n } else {\n let route = (child.data !== undefined) ? child.data.route : undefined;\n if (route !== undefined && child.data.type === 'rt') {\n let id,\n match = context.match,\n active = context.active,\n matches = match(route);\n\n matches.to((...args) => {\n let params = args.pop();\n id = (args.length > 0) ? params.getLocation() + '_' + args.join('_') : undefined;\n\n if (!applyToGroup(child, instance => dom.attach(instance))) {\n let childInstance = child.run(true);\n applyToChildren(childInstance.children, instance => {\n if (instance) {\n //TODO: maybe not need Object.assign\n match(route, match => matchRoute(instance, Object.assign({}, context, {\n match,\n active\n })));\n }\n });\n }\n applyToGroup(child, (childInstance) => {\n applyToChildren(childInstance.children, instance => {\n if (instance && instance.to) {\n instance.to(...args.concat(params));\n }\n });\n });\n });\n\n matches.leave(done => {\n let items = 0,\n stopped = false;\n applyToGroup(child, (childInstance) => {\n let finish = () => {\n if (!id) {\n dom.detach(childInstance);\n } else {\n destroyComponent(childInstance);\n }\n },\n close = (close = true) => {\n if (close) {\n items--;\n } else {\n stopped = true;\n done(false);\n }\n\n if (items === 0 && !stopped) {\n active.set(childInstance, finish);\n done(true);\n }\n\n };\n\n applyToChildren(childInstance.children, instance => {\n if (instance && instance.leave !== undefined) {\n let args = getArgs(instance.leave);\n if (args.length > 0) {\n items++\n }\n instance.leave(close);\n }\n });\n\n if (items === 0) {\n active.set(childInstance, finish);\n done(true);\n }\n });\n });\n\n matches.query((params) => {\n applyToGroup(child, (childInstance) => {\n applyToChildren(childInstance.children, (instance) => {\n if (instance && instance.query !== undefined) {\n instance.query(params);\n }\n });\n });\n });\n applyToGroup(child, instance => instance._activeRoute = matches);\n\n } else if (child.children !== undefined && ['cp'].indexOf(child.data.type) === -1) {\n applyToChildren(child.children, instance => matchRoute(instance, context));\n }\n }\n }\n\n function setRoutes(children, context) {\n applyToChildren(children, child => matchRoute(child, context));\n\n };\n\n return setRoutes;\n})\n;\n/**\n * Created by guntars on 15/03/2016.\n */\ndefine('widget/parsers/applyElement',[\n 'templating/dom'\n], function (dom) {\n //Applying dom.Element to template elements.\n //\n // @private applyElement\n // @param {Object} elements\n function applyElement(elements = {}, params) {\n let instances = {};\n Object.keys(elements).forEach((key)=> {\n let instance = elements[key];\n if (typeof instance !== 'string') {\n let element = instance.elGroup.first;\n if (element) {\n instances[key] = element;\n if (element instanceof dom.Element === true &&\n (['pl'].indexOf(element.data.type) !== -1)) {\n let bind = element.data.tplSet.bind;\n if (bind) {\n Object.keys(bind).forEach((attr)=> {\n if (params[bind[attr]] !== undefined) {\n if (attr !== 'class') {\n element.setAttribute(attr, params[bind[attr]]);\n } else {\n element.addClass(params[bind[attr]]);\n }\n }\n });\n }\n\n }\n } else {\n instances[key] = instance;\n }\n }\n });\n\n return instances;\n }\n\n return applyElement;\n});\n/**\n * Created by guntars on 10/10/2014.\n */\n/*globals define*/\n//## widget/Constructor Class\n// This is App Presenter class parse data, and apply to template. Also binding events to Element.\n// Basic Usage example\n//\n// define([\n// 'templating/parser!widget.html',\n// 'widget/Constructor'\n// ], function (template, Constructor) {\n// var Widget = Constructor.extend({\n// template: template\n// });\n// return Widget;\n// });\ndefine('widget/Constructor',[\n 'require',\n 'templating/Decoder',\n 'templating/dom',\n './Mediator',\n './parsers/applyAttribute',\n './parsers/applyParent',\n './parsers/applyBinders',\n './parsers/setBinders',\n './parsers/setRoutes',\n './parsers/applyElement',\n './parsers/addChildren'\n], function(require,\n Decoder,\n dom,\n Mediator,\n applyAttribute,\n applyParent,\n applyBinders,\n setBinders,\n setRoutes,\n applyElement,\n addChildren) {\n 'use strict';\n\n\n function destroy(instance) {\n let keys = Object.keys(instance);\n if (keys.length > 0) {\n keys.forEach((key) => {\n if (key !== 'root') {\n let children = instance[key];\n if (children.elGroup !== undefined && children.elGroup.size > 0) {\n children.elGroup.forEach(child => {\n if (child !== undefined && child.remove !== undefined) {\n child.remove(true);\n }\n })\n }\n }\n });\n }\n }\n\n // Constructor Class\n //\n // @Constructor\n // @param {Object} data\n // @param {Object} children\n // @param {Object} dataSet\n class Constructor {\n static extend(options = {}) {\n class Surrogate extends Constructor {\n }\n Object.assign(Surrogate.prototype, options);\n return Surrogate;\n };\n\n constructor(options = {}, parentChildren, dataSet = {}, node) {\n //TODO: for Backwards compatability later need to remove\n this.instance = this;\n this._events = [];\n this._globalEvents = [];\n this._parentChildren = parentChildren;\n this._options = options;\n this._rendered = false;\n this._arguments = Array.from(arguments);\n this._dataSet = dataSet;\n\n this.eventBus = new Mediator(this);\n\n if (node !== undefined && node.name !== undefined) {\n this.name = node.name;\n }\n this.beforeInit(...this._arguments);\n };\n\n ready(el) {\n this.el = el;\n }\n\n setContext(context) {\n if (!this.context) {\n this.context = context;\n if (!this.async) {\n this.render();\n }\n this.init(...this._arguments);\n }\n };\n\n set context(context) {\n if (!this.data) {\n let keys = (this._dataSet) ? Object.keys(this._dataSet) : [],\n contextData = (keys.length > 0) ? this._dataSet : context.data;\n if (contextData) {\n this.data = contextData[this._options.bind] || contextData;\n }\n }\n context.match((match) => {\n if (this.match) {\n this.match(match);\n }\n\n this._context = Object.assign({\n match: match\n }, context);\n });\n }\n\n get context() {\n return this._context;\n };\n\n // method render called manually if flag async is true;\n //\n // @method render\n render(data) {\n if (!this._rendered) {\n if (this.template) {\n if (data) {\n this.data = data;\n }\n let options = this._options,\n parentChildren = this._parentChildren,\n decoder = new Decoder(this.template),\n template = decoder.render(this.data);\n if (this.el) {\n let parent = this.el.parentNode;\n if (parent) {\n parent.replaceChild(template.fragment, this.el);\n }\n if (this.elGroup && this.elGroup.get(this.el)) {\n this.elGroup.delete(this.el);\n this.el = template.fragment;\n this.elGroup.set(template.fragment, this);\n }\n } else {\n this.el = template.fragment;\n }\n\n\n this.root = new dom.Element(template.fragment, {\n name: 'root',\n data: {}\n });\n\n this.children = applyElement(template.children, options);\n applyParent(this, parentChildren, this.data);\n this.bindings = setBinders(this.children, true);\n\n if (this.data) {\n this.applyBinders(this.data, this);\n }\n\n setRoutes(this.children, this.context);\n addChildren(this, this.root);\n this.rendered(...this._arguments);\n this._rendered = true;\n } else {\n let HTMLelement = document.createElement('div');\n this.root = new dom.Element(HTMLelement, {\n name: 'root',\n data: {}\n });\n if (this.el) {\n let parent = this.el.parentNode;\n if (parent) {\n parent.replaceChild(HTMLelement, this.el);\n }\n }\n this.el = HTMLelement;\n this.children = {};\n addChildren(this, this.root);\n\n this.rendered(...this._arguments);\n this._rendered = true;\n }\n }\n };\n\n // Running before Constructor is initialised\n //\n // @method beforeInit\n // @param {Object} data (comes from template data attributes)\n // @param {Object} children (comes placeholder content\n // from template)\n // @param {Object} datatSet (data passing if component is\n // in template binders)\n beforeInit(data, children, dataSet) {\n };\n\n // Running when Constructor is initialised\n //\n // @method beforeInit\n // @param {Object} data (comes from template data attributes)\n // @param {Object} children (comes placeholder content\n // from template)\n // @param {Object} datatSet (data passing if component is\n // in template binders)\n init(data, children, dataSet) {\n };\n\n // Running when widget is rendered\n //\n // @method rendered\n // @param {Object} data (comes from template data attributes)\n // @param {Object} children (comes placeholder content\n // from template)\n // @param {Object} datatSet (data passing if component is\n // in template binders)\n rendered(data, children, dataSet) {\n };\n\n\n // Load external css style for third party modules.\n //\n // @method loadCss\n // @param {string} url\n loadCss(url) {\n if (this.context._cssReady.indexOf(url) === -1) {\n this.context._cssReady.push(url);\n let linkRef = document.createElement(\"link\");\n linkRef.setAttribute(\"rel\", \"stylesheet\")\n linkRef.setAttribute(\"type\", \"text/css\")\n linkRef.setAttribute(\"href\", url)\n if (typeof linkRef != \"undefined\") {\n document.getElementsByTagName(\"head\")[0].appendChild(linkRef);\n }\n }\n\n };\n\n // Remove from parentNode\n //\n // @method detach\n detach() {\n if (!this._placeholder) {\n this._placeholder = document.createElement(this.el.tagName);\n }\n if (!this._parent) {\n this._parent = this.el.parentNode;\n }\n\n if (this.el && this._parent) {\n this._parent.replaceChild(this._placeholder, this.el)\n }\n\n };\n\n // Add to parentNode\n //\n // @method attach\n attach() {\n if (this._placeholder && this._parent) {\n this._parent.replaceChild(this.el, this._placeholder)\n }\n };\n\n // Executes when Component is destroyed\n //\n // @method applyBinders\n onDestroy() {\n\n };\n\n //Removing widget from Dom\n //\n // @method destroy\n destroy() {\n this.onDestroy();\n this.eventBus.clear();\n while (this._events.length > 0) {\n this._events.shift().remove();\n }\n\n while (this._globalEvents.length > 0) {\n this._globalEvents.shift().remove();\n }\n\n destroy(this.children);\n\n if (this.elGroup !== undefined && this.el !== undefined) {\n this.elGroup.delete(this.el);\n }\n if (this.root && this.root.remove) {\n this.root.remove();\n }\n\n delete this.el;\n\n };\n\n remove(...args) {\n this.destroy(...args);\n }\n\n // Adding Childrens manually after initialization.\n // @method setChildren\n // @param {Element} el\n // @param {Object} data\n //TODO: need to write tests for async operations.\n setChildren(el, data) {\n let name = el.data.name,\n instance = this.children[name];\n\n if (instance !== undefined && instance.el !== undefined) {\n instance.remove();\n }\n\n let newInstance = el.run(data || true);\n if (newInstance.setContext) {\n newInstance.setContext(this.context);\n }\n addChildren(this, newInstance, data);\n return newInstance;\n\n };\n\n // Adding Dynamic components\n // @method addComponent\n // @param {String} name\n // @param {Constructor} Component\n // @param {Element} container\n // @param {Object} data (data attributes)\n // @param {Object} children\n // @param {Object} dataSet (Model for bindings)\n addComponent(Component, options) {\n let name = options.name,\n container = options.container;\n\n if (name === undefined) {\n throw ('you have to define data.name for component.')\n } else if (container === undefined) {\n throw ('You have to define container for component.')\n } else if (this.children[name] !== undefined) {\n throw ('Component using name:' + name + '! already defined.')\n }\n let component = this.setComponent(Component, options),\n instance = component.run(options.container);\n instance.setContext(this.context);\n this.children[name] = instance;\n return instance;\n };\n\n setComponent(Component, options) {\n let instance = {\n name: options.name,\n data: {\n tag: 'div',\n type: 'cp'\n },\n run: (container) => {\n options.appContext = this.context;\n let cp = new Component(options, options.children, options.data),\n el = document.createElement('div');\n el.setAttribute('style', 'display:none;');\n cp.ready(el);\n\n if (container instanceof HTMLElement === true) {\n container.parentNode.replaceChild(cp.el, container);\n } else if (container.el !== undefined && options.pos !== undefined) {\n dom.insertBefore(container, cp, options.pos);\n } else if (container.el !== undefined) {\n dom.append(container, cp);\n }\n return cp;\n }\n }\n return instance;\n }\n\n // Running when Constructor is initialised\n //\n // @method applyBinders\n // @param {Object} data (comes from template data attributes)\n // @param {Object} children (comes placeholder content\n // from template)\n // @param {Object} datatSet (data passing if component is\n // in template binders)\n // Applying Binders manually, if use nodes function\n //\n // @method applyBinders\n applyBinders(...args) {\n return applyBinders(this, ...args);\n }\n }\n Object.assign(Constructor.prototype, {\n // `nodes` Object override default methods to Elements.\n // Usage Example\n //\n // nodes: {\n // listItem: function (el, parent, data) {\n // el.add(parent);\n // el.text(data);\n // }\n // }\n nodes: {},\n\n // `events` Object applying events to elements\n // You can apply more than one event on element\n // Usage Example\n //\n // events: {\n // delete: [\n // {\n // name: 'click',\n // action: function () {\n // this.data.remove = true\n // this.destroy();\n // }\n // }\n // ]\n events: {},\n // Applying extra methods to Element\n // Usage Example\n //\n // elReady: {\n // links: function (el, data) {\n // if(data.class==='active'){\n // el.addClass('active');\n // }\n // }\n // },\n elReady: {},\n // Applying methods to element every time when data is changed for Element\n // Usage Example\n //\n // elOnChange: {\n // links: function (el, data) {\n // if(data.class==='active'){\n // el.addClass('active');\n // }\n // }\n // },\n elOnChange: {}\n });\n\n\n return Constructor;\n});\n"]} \ No newline at end of file diff --git a/dist/es5/prod/widget/App.js b/dist/es5/prod/widget/App.js index 2c8cacf..3c41a9a 100644 --- a/dist/es5/prod/widget/App.js +++ b/dist/es5/prod/widget/App.js @@ -1,4 +1,4 @@ /*! stonewalljs 2017-05-22 */ "use strict";function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i2?_len-2:0),_key=2;_len>_key;_key++)args[_key-2]=arguments[_key];return fn.apply(null,[value,index].concat(args))})}},{key:"getIndex",value:function(key){return this._indexes.indexOf(key)}},{key:"changeIndex",value:function(key,index){if(key){var indexes=this._indexes,indexOf=indexes.indexOf(key);-1!==indexOf&&index!==indexOf&&this._indexes.splice(index,0,this._indexes.splice(indexOf,1)[0])}}},{key:"getValueByIndex",value:function(index){return this._map.get(this._indexes[index])}},{key:"getKeyByIndex",value:function(index){return this._indexes[index]}},{key:"set",value:function(key,value,index){this._map.set(key,value),void 0!==index?this._indexes.splice(index,0,key):this._indexes.push(key)}},{key:"has",value:function(key){return this._map.has(key)}},{key:"clear",value:function(){this._map.clear(),this._indexes.splice(0,this._indexes.length)}},{key:"onDelete",value:function(cb){var chunk=function(){return cb.apply(void 0,arguments)};return this._onDelete.push(chunk),{remove:function(){this._onDelete.splice(this._onDelete.indexOf(chunk,1))}}}},{key:"delete",value:function(key){var _this2=this;if(this.has(key)){var item=this._map.get(key);this._map["delete"](key),this._indexes.splice(this._indexes.indexOf(key),1),this._onDelete.forEach(function(chunk){return chunk(key,_this2.size,item)})}}},{key:"deleteByIndex",value:function(index){this["delete"](this._indexes[index])}},{key:"first",get:function(){return this.getValueByIndex(0)}},{key:"last",get:function(){return this.getValueByIndex(this._indexes.length-1)}},{key:"size",get:function(){return this._map.size}}]),List}();return List}),define("templating/dom",[],function(){function isObject(obj){var type="undefined"==typeof obj?"undefined":_typeof(obj);return"function"===type||"object"===type&&!!obj}function createPlaceholder(tag){var placeholder=document.createElement(tag||"div");return placeholder.setAttribute("style","display:none;"),placeholder}function destroy(instance){var keys=Object.keys(instance);keys.length>0&&keys.forEach(function(key){if("root"!==key){var children=instance[key];void 0!==children.elGroup&&children.elGroup.size>0&&children.elGroup.forEach(function(child){void 0!==child&&void 0!==child.remove&&child.remove(!0)})}})}var Element=function(){function Element(el,node){_classCallCheck(this,Element),this.el=el,this._events=[],this.name=node.name||node.data.name;var data=this.data=node.data;data&&data.bind&&(this.bind=data.bind)}return _createClass(Element,[{key:"clone",value:function(){return this.run.apply(this,arguments)}},{key:"text",value:function(_text){dom.text(this,_text)}},{key:"detach",value:function(){dom.detach(this)}},{key:"attach",value:function(){dom.attach(this)}},{key:"changePosition",value:function(index){dom.changePosition(this,index)}},{key:"setAttribute",value:function(prop,value){dom.setAttribute(this,prop,value)}},{key:"getAttribute",value:function(prop){return dom.getAttribute(this,prop)}},{key:"removeAttribute",value:function(prop){dom.removeAttribute(this,prop)}},{key:"setStyle",value:function(prop,value){dom.setStyle(this,prop,value)}},{key:"getStyle",value:function(prop){return dom.getStyle(this,prop)}},{key:"removeStyle",value:function(prop){dom.removeStyle(this,prop)}},{key:"addClass",value:function(className){dom.addClass(this,className)}},{key:"hasClass",value:function(className){return dom.hasClass(this,className)}},{key:"removeClass",value:function(className){dom.removeClass(this,className)}},{key:"val",value:function(_val){return dom.val(this,_val)}},{key:"on",value:function(event,cb,context){var args=Array.prototype.slice.call(arguments,0);return dom.on.apply(!1,[this].concat(args))}},{key:"onDOMAttached",value:function(){return dom.onDOMAttached(this)}},{key:"remove",value:function(force){dom.remove(this,force)}}]),Element}(),dom={detach:function(node){node.placeholder instanceof HTMLElement==!1&&(node.placeholder=createPlaceholder(node.data.tag||node.el.tagName)),node&&node.el&&node.el.parentNode&&node.el.parentNode.replaceChild(node.placeholder,node.el)},attach:function(node){node&&node.el&&node.placeholder&&node.placeholder.parentNode&&node.placeholder.parentNode.replaceChild(node.el,node.placeholder)},append:function(parent,child){void 0!==parent.el&&void 0!==child.el&&parent.el.appendChild(child.el)},prepend:function(parent,child){dom.insertBefore(parent,child,0)},insertBefore:function(parent,child,index){var parentEl=parent.el,childEl=child.el;void 0!==parentEl&&void 0!==childEl&&(void 0!==parentEl.childNodes[index]?parentEl.insertBefore(childEl,parentEl.childNodes[index]):parentEl.appendChild(childEl))},changePosition:function(el,index){var HTMLElement=el.el;if(HTMLElement&&HTMLElement.parentNode){var parentNode=HTMLElement.parentNode,elGroup=el.elGroup,size=elGroup.size,target=elGroup.getKeyByIndex(index)||elGroup.getLast();target!==HTMLElement&&(size-1>=index?parentNode.insertBefore(HTMLElement,target):null!==target.nextSibling?parentNode.insertBefore(HTMLElement,target.nextSibling):parentNode.appendChild(HTMLElement),el.elGroup.changeIndex(HTMLElement,index))}},text:function(node,_text2){node&&node.el&&(node.el.innerHTML=_text2)},setAttribute:function(node,prop,value){node&&node.el&&(isObject(prop)?Object.keys(prop).forEach(function(key){node.el.setAttribute(key,prop[key])}):node.el.setAttribute(prop,value))},getAttribute:function(node,prop){return node&&node.el?node.el.getAttribute(prop):void 0},removeAttribute:function(node,prop){node&&node.el&&node.el.removeAttribute(prop)},setStyle:function(node,prop,value){node&&node.el&&(isObject(prop)?Object.keys(prop).forEach(function(key){node.el.style[key]=prop[key]}):node.el.style[prop]=value)},getStyle:function(node,prop){return node&&node.el&&void 0!==node.el&&void 0!==node.el.style?node.el.style[prop]:void 0},removeStyle:function(node,prop){node&&node.el&&(node.el.style[prop]="")},addClass:function(node,className){node&&node.el&&node.el.classList.add(className)},hasClass:function(node,className){return node&&node.el?node.el.classList.contains(className):!1},removeClass:function(node,className){node&&node.el&&node.el.classList.remove(className)},val:function(node,_val2){if(node&&node.el){var el=node.el;if(void 0===_val2)return el.value;el.value=_val2}},on:function(element,ev,cb,context){for(var _len2=arguments.length,args=Array(_len2>4?_len2-4:0),_key2=4;_len2>_key2;_key2++)args[_key2-4]=arguments[_key2];var _this3=this,el=element.el,events=ev.split(" "),fn=function(e){cb.apply(context||_this3,[e,element].concat(args))};events.forEach(function(event){el.addEventListener(event,fn)});var evt={remove:function(){events.forEach(function(event){return el.removeEventListener(event,fn)});var evts=element._events;evts.splice(evts.indexOf(evt),1)}};return element._events.push(evt),evt},remove:function(el){for(;el._events.length>0;)el._events.shift().remove();el.children&&destroy(el.children),void 0!==el.elGroup&&el.elGroup["delete"](el.el),void 0!==el.el&&(el.el.remove?el.el.remove():el.el.parentNode&&el.el.parentNode.removeChild(el.el),delete el.el)},onDOMAttached:function(el){var _this4=this,handlers=[],attached=!1,_step=void 0;return void 0!==el.el&&(_step=function(){if(attached)for(;handlers.length>0;)handlers.shift()();else window.requestAnimationFrame(_step),document.body.contains(el.el)&&(attached=!0)}),{then:function(cb,context){handlers.push(cb.bind(context||_this4)),window.requestAnimationFrame(_step)}}},Element:Element};return dom}),function(root,factory){"function"==typeof define&&define.amd?define("templating/DomFragment",factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&(module.exports=factory())}(void 0,function(){function createPlaceholder(tag){var placeholder=document.createElement(tag||"div");return placeholder.setAttribute("style","display:none;"),placeholder}var DomFragment=function(){function DomFragment(_node,placeholder,childNodes,elGroup,index,obj){return _classCallCheck(this,DomFragment),Object.assign(this,{_node:_node,placeholder:placeholder,childNodes:childNodes,elGroup:elGroup,index:index,obj:obj}),this.render()}return _createClass(DomFragment,[{key:"applyAttributes",value:function(el){var attributes=this._node.data.attribs;Object.keys(attributes).forEach(function(key){el.setAttribute(key,attributes[key])})}},{key:"applyFragment",value:function(el){var node=this._node,plFragment=node.template();if(plFragment)for(;plFragment.childNodes.length>0;)el.appendChild(plFragment.childNodes[0])}},{key:"appendToBody",value:function(el){var elGroup=this.elGroup,placeholder=this.placeholder,size=elGroup.size;if(size>0){var index=void 0===this.index||this.index>size-1?size-1:this.index-1,target=elGroup.keys()[-1!==index?index:0],parentNode=target.parentNode;-1===index?parentNode.insertBefore(el,target):null!==target.nextSibling?parentNode.insertBefore(el,target.nextSibling):parentNode.appendChild(el)}else{var _parentNode=placeholder.parentNode;_parentNode&&_parentNode.replaceChild(el,placeholder)}}},{key:"render",value:function(){var placeholder=this.placeholder,node=this._node,keep=!placeholder.id&&0===this.elGroup.size,instance=node.tmpEl(keep?placeholder:!1,this.obj,this.childNodes,node),el=instance.el||createPlaceholder(node.data.tag);return keep||node.replace?node.replace||(el.innerHTML=""):this.applyAttributes(el),node.replace||this.applyFragment(el),this.appendToBody(el),instance.ready&&instance.ready(el),instance}}]),DomFragment}();return DomFragment}),function(root,factory){"function"==typeof define&&define.amd?define("templating/Decoder",["./utils/List","./dom","./DomFragment"],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&(module.exports=factory(require("./utils/List"),require("./dom"),require("./DomFragment")))}(void 0,function(List,dom,DomFragment){function isObject(obj){return obj===Object(obj)}function isArray(obj){return Array.isArray?Array.isArray(obj):"[object Array]"===toString.call(obj)}var _decoders={},Decoder=function(){function Decoder(root){_classCallCheck(this,Decoder),this._root="string"==typeof root?JSON.parse(root):root,root.children&&root.children.length>0&&(this.children=this._parseElements(root.children))}return _createClass(Decoder,null,[{key:"addDecoder",value:function(decoder){void 0===_decoders[decoder.tagName]&&(_decoders[decoder.tagName]=decoder)}}]),_createClass(Decoder,[{key:"renderFragment",value:function(template,tag){var el=document.createElement("template");return void 0===el.content&&("td"===tag?el=document.createElement("tr"):"tr"===tag&&(el=document.createElement("tbody"))),el.innerHTML=template,void 0!==el.content?el.content.firstChild:el.firstChild}},{key:"_parseElements",value:function(nodeList){var _this5=this,context={};return nodeList.forEach(function(node){var name=node.data.name,tagName=node.tagName;if(tagName){var decodedData=_decoders[tagName].decode(node);if(decodedData){var nodeParams={name:decodedData.name,data:decodedData.data,tmpEl:decodedData.tmpEl,parse:decodedData.parse,replace:decodedData.replace,id:node.id,template:function(){return _this5.renderFragment(node.template,node.data.tag)},noAttach:_decoders[tagName].noAttach||node.data.tplSet.noattach};node.children&&node.children.length>0&&(nodeParams.children=_this5._parseElements(node.children)),context[name]=nodeParams}}else name&&(context[name]={id:node.id,data:node.data,name:name})}),context}},{key:"renderTemplate",value:function(){var childNodes=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},_this6=this,obj=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},fragment=arguments[2],resp={},_runAll=[];Object.keys(childNodes).forEach(function(name){var childFragment=fragment,child=childNodes[name],children=child.children,elGroup=new List,placeholder=document.createElement(child.data.tplSet.tag||"div");if(placeholder.setAttribute("style","display:none;"),placeholder.id=child.id,elGroup.onDelete(function(key,size){0===size&&key.parentNode&&(key.parentNode.replaceChild(placeholder,key),childFragment=function(){return placeholder})}),child.template){var run=function run(force,index){var template=childFragment();force instanceof HTMLElement==!0&&(template=force);var childNodes=void 0,data=template!==force&&(isObject(force)||isArray(force))?force:obj;if(!child.noAttach||force){var _placeholder=template.querySelector("#"+child.id)||template;children&&(childNodes=_this6.renderTemplate(children,data,function(){return template}));var element=new DomFragment(child,_placeholder,childNodes,elGroup,index,data);return template=element.el,childNodes&&childNodes.runAll&&child.parse&&childNodes.runAll(),childNodes&&!element.children&&(element.children=childNodes),element.elGroup=elGroup,element.run=run,elGroup.set(element.el,element,index),element}};_runAll.push(run),resp[name]={data:child.data,run:run,elGroup:elGroup}}else{var element=new dom.Element(childFragment().querySelector("#"+child.id),child);element.removeAttribute("id"),element.elGroup=elGroup,elGroup.set(element.el,element),resp[name]=element}});var setProp=function(obj,name,fn){Object.defineProperty(obj,name,{enumerable:!1,value:fn})},runAll=function(el){return _runAll.forEach(function(run){return run(el)}),resp};return setProp(resp,"runAll",runAll),resp}},{key:"render",value:function(obj){var fragment=this.renderFragment(this._root.template);return{fragment:fragment,children:this.renderTemplate(this.children,obj,function(){return fragment}).runAll(),templateId:this._root.templateId}}}]),Decoder}();return Decoder}),function(root,factory){"function"==typeof define&&define.amd?define("coders/component/cpDecoder",["templating/Decoder"],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&(module.exports=factory(require("./Decoder")))}(void 0,function(Decoder){var componentDecoder={tagName:"cp",decode:function(node){var data=node.data,response={name:data.name,replace:!0,tmpEl:function(placeholder,obj,children,node){var instance=new data.src(data.dataset,children,obj,node);return instance},data:data||{}};return void 0!==data.dataset.bind&&(response.bind=data.dataset.bind),response}};return Decoder&&Decoder.addDecoder(componentDecoder),componentDecoder}),function(root,factory){"function"==typeof define&&define.amd?define("coders/placeholders/plDecoder",["templating/Decoder","templating/dom"],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&(module.exports=factory(require("./Decoder"),require("./dom")))}(void 0,function(Decoder,dom){var componentDecoder={tagName:"pl",decode:function(node){var data=node.data;return{name:data.name,tmpEl:function(el,obj,children,node){return new dom.Element(el||document.createElement(data.tag),node)},parse:!0,data:data}}};return Decoder&&Decoder.addDecoder(componentDecoder),componentDecoder}),function(root,factory){"function"==typeof define&&define.amd?define("coders/databind/bdDecoder",["templating/Decoder","templating/dom"],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&(module.exports=factory(require("./Decoder"),require("./dom")))}(void 0,function(Decoder,dom){var bindingsDecoder={tagName:"bd",noAttach:!0,decode:function(node){var data=this.data=node.data,response={name:data.name,tmpEl:function(el,obj,children,node){return new dom.Element(el||document.createElement(data.tag),node)},data:data};return response}};return Decoder&&Decoder.addDecoder(bindingsDecoder),bindingsDecoder}),function(root,factory){"function"==typeof define&&define.amd?define("coders/router/routerDecoder",["templating/Decoder","templating/dom"],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&(module.exports=factory(require("./Decoder"),require("./dom")))}(void 0,function(Decoder,dom){var componentDecoder={tagName:"rt",noAttach:!0,decode:function(node){var data=node.data,response={name:data.name,tmpEl:function(el,obj,children,node){return new dom.Element(el||document.createElement(data.tag),node)},parse:!0,data:data||{}};return response}};return Decoder&&Decoder.addDecoder(componentDecoder),componentDecoder}),function(root,factory){"function"==typeof define&&define.amd?define("coders/style/styleDecoder",["templating/Decoder"],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&(module.exports=factory(require("./Decoder")))}(void 0,function(Decoder){var styleDecoder={tagName:"style",decode:function(node){if(void 0===node.data.styleAttached){node.data.styleAttached=!0;var style=node.data.style,addStyle=function(style){var tag=document.createElement("style");tag.innerHTML=style,document.head.appendChild(tag)};"string"==typeof style?addStyle(style):style.then(addStyle)}}};return Decoder&&Decoder.addDecoder(styleDecoder),styleDecoder}),function(factory){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))?module.exports=factory():"function"==typeof define&&define.amd?define("watch",factory):(window.WatchJS=factory(),window.watch=window.WatchJS.watch,window.unwatch=window.WatchJS.unwatch,window.callWatchers=window.WatchJS.callWatchers)}(function(){var WatchJS={noMore:!1},lengthsubjects=[],isFunction=function(functionToCheck){var getType={};return functionToCheck&&"[object Function]"==getType.toString.call(functionToCheck)},isArray=function(obj){return"[object Array]"===Object.prototype.toString.call(obj)},getObjDiff=function(a,b){var aplus=[],bplus=[];if("string"!=typeof a&&"string"!=typeof b){if(isArray(a))for(var i=0;i0)&&watchAll(obj[prop],watcher,void 0!==level?level-1:level),defineWatcher(obj,prop,watcher,level),addNRemove&&(void 0===level||level>0)&&pushToLengthSubjects(obj,prop,watcher,level)))},unwatch=function(){isFunction(arguments[1])?unwatchAll.apply(this,arguments):isArray(arguments[1])?unwatchMany.apply(this,arguments):unwatchOne.apply(this,arguments)},unwatchAll=function(obj,watcher){if(!(obj instanceof String)&&(obj instanceof Object||isArray(obj)))if(isArray(obj)){for(var props=[],prop=0;prop1&&void 0!==arguments[1]?arguments[1]:{},data=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(context){var elements=context.children;elements&&Object.keys(elements).forEach(function(name){var add=!0,child=elements[name],parentChild=parentChildren[name];void 0!==parentChild?void 0!==context.nodes[name]?context.nodes[name].call(context,child,parentChild,data):void 0!==child&&("string"==typeof parentChild?dom.text(child,parentChild):child=parentChild.run(child.el)):void 0!==context.nodes[name]&&child.data.tplSet.noattach&&(context.nodes[name].call(context,child,data),add=!1),add&&child.elGroup.size>0&&addChildren(context,child,data)})}}return setChildren}),define("widget/utils",[],function(){function extend(obj){var type="undefined"==typeof obj?"undefined":_typeof(obj);if(!("function"===type||"object"===type&&obj))return obj;for(var source,prop,i=1,length=arguments.length;length>i;i++){source=arguments[i];for(prop in source)obj[prop]=source[prop]}return obj}function fnExtend(protoProps,staticProps){var child,parent=this;child=protoProps&&null!=protoProps&&hasOwnProperty.call(protoProps,"constructor")?protoProps.constructor:function(){return parent.apply(this,arguments)},extend(child,parent,staticProps);var Surrogate=function(){this.constructor=child};return Surrogate.prototype=parent.prototype,child.prototype=new Surrogate,protoProps&&extend(child.prototype,protoProps),child.__super__=parent.prototype,child}function isString(obj){return"[object String]"===toString.call(obj)}function isObject(obj){return obj===Object(obj)}function isArray(obj){return Array.isArray?Array.isArray(obj):"[object Array]"===toString.call(obj)}return{fnExtend:fnExtend,extend:extend,isString:isString,isObject:isObject,isArray:isArray}}),define("widget/parsers/setBinders",[],function(){function setBinders(children,ignoreCP){var bindings={};return Object.defineProperty(bindings,"__cp__",{enumerable:!1,value:[]}),Object.keys(children).forEach(function(key){var el=children[key];el&&el.data&&void 0!==el.data.bind&&"cp"!==el.data.type?(bindings[el.data.bind]=bindings[el.data.bind]||[],bindings[el.data.bind].push(el)):ignoreCP||"cp"!==el.data.type||bindings.__cp__.push(el)}),bindings}return setBinders}),define("widget/parsers/applyBinders",["templating/dom","../utils","watch","./setBinders","./addChildren","./applyAttribute"],function(dom,utils,WatchJS,setBinders,addChildren,applyAttribute){function parseBinder(context,objKey,obj,binder){if(void 0!==binder){var data=obj[objKey];if(context.nodes[objKey])context.nodes[objKey].call(context,binder,data);else if(utils.isArray(data)||utils.isObject(data)){if(utils.isArray(data)){var bindedData=[],addItem=function(item,index){var isString=!1;utils.isArray(item)||utils.isObject(item)||(isString=!0);var element=binder.run(!0,index);isString&&element.text(item),bindedData.push({binder:element,data:item}),applyAttribute(context,element,item),addChildren.applyEvents(context,element,item),addChildren.elReady(context,element,item);var handler=addChildren.elOnChange(context,element);handler&&handler(item),element.children&&(element.bindings=setBinders(element.children),applyBinders(context,item,element))};data.forEach(addItem);var update=binder.data.tplSet.update;if(update){var removeMethodNames=["pop","shift","splice"],insertMethodNames=["push","unshift"],sortingMethodNames=["reverse","sort"]; -watch(obj,objKey,function(prop,action,newValue,oldValue){var clonedData=bindedData.slice(0);if(void 0===oldValue&&-1!==insertMethodNames.indexOf(action)){var filter=clonedData.filter(function(item){return item.data===newValue[0]});0===filter.length&&addItem(newValue[0],"unshift"===action?0:clonedData.length)}else if(-1!==removeMethodNames.indexOf(action)){if(clonedData.forEach(function(binder){-1===obj[objKey].indexOf(binder.data)&&(binder.binder.remove(),bindedData.splice(bindedData.indexOf(binder),1))}),"splice"===action){var vals=Array.prototype.slice.call(newValue,2);vals&&vals.length>0&&vals.forEach(function(val){var index=obj[objKey].indexOf(val);-1!==index&&addItem(val,index)})}}else-1!==sortingMethodNames.indexOf(action)&&data.forEach(function(value,index){var element=clonedData.filter(function(item){return item.data===value})[0];bindedData.splice(index,0,bindedData.splice(bindedData.indexOf(element),1)[0]),element.binder.changePosition(index)})})}}else if(utils.isObject(data)){var _element=binder.run(data);if("cp"!==_element.data.type){applyAttribute(context,_element,data),addChildren.applyEvents(context,_element,data),addChildren.elReady(context,_element,data);var _handler=addChildren.elOnChange(context,_element);_handler&&_handler(data),_element.children&&(_element.bindings=setBinders(_element.children),applyBinders(context,data,_element))}}}else{var element=binder.run(!0);element.text(data),addChildren.applyEvents(context,element,data),addChildren.elReady(context,element,data);var handler=addChildren.elOnChange(context,element);handler&&handler(data),element.data.tplSet.update&&watch(obj,objKey,function(){element.text(obj[objKey]);var handler=addChildren.elOnChange(context,element);handler&&handler(obj[objKey])})}}}function applyBinders(child,obj,instance){var binders=instance.bindings;if(binders){binders.__cp__.length>0&&binders.__cp__.forEach(function(binder){var component=binder.run(obj);component.setContext(child.context),addChildren.elReady(child,component,obj);var handler=addChildren.elOnChange(child,component);handler&&handler(obj)});var keys=Object.keys(binders);obj&&keys.length>0&&keys.forEach(function(binderKey){if(void 0!==obj[binderKey])binders[binderKey].forEach(function(binder){return parseBinder(child,binderKey,obj,binder)});else{var fn=function fn(prop,action,newValue,oldValue){void 0!==newValue&&void 0===oldValue&&(binders[binderKey].forEach(function(binder){return parseBinder(child,binderKey,obj,binder)}),unwatch(obj,binderKey,fn))};watch(obj,binderKey,fn,0)}})}}var watch=WatchJS.watch,unwatch=WatchJS.unwatch;return applyBinders}),define("widget/parsers/setRoutes",["templating/dom"],function(dom){function getArgs(func){var fnStr=func.toString().replace(STRIP_COMMENTS,""),argsList=fnStr.slice(fnStr.indexOf("(")+1,fnStr.indexOf(")")),result=argsList.match(ARGUMENT_NAMES);return null===result?[]:result.map(function(item){return item.replace(/[\s,]/g,"")})}function destroyComponent(cp){void 0!==cp.remove&&cp.remove()}function applyToChildren(children,cb){void 0!==children&&Object.keys(children).forEach(function(name){var instance=children[name];applyToGroup(instance,cb)||cb(instance)})}function applyToGroup(child,cb){return child.elGroup&&child.elGroup.size>0?(child.elGroup.forEach(function(childInstance){cb(childInstance)}),!0):!1}function matchRoute(child,context){if(child.setContext)child.setContext(context);else{var route=void 0!==child.data?child.data.route:void 0;if(void 0!==route&&"rt"===child.data.type){var id=void 0,match=context.match,active=context.active,matches=match(route);matches.to(function(){for(var _len3=arguments.length,args=Array(_len3),_key3=0;_len3>_key3;_key3++)args[_key3]=arguments[_key3];var params=args.pop();if(id=args.length>0?params.getLocation()+"_"+args.join("_"):void 0,!applyToGroup(child,function(instance){return dom.attach(instance)})){var childInstance=child.run(!0);applyToChildren(childInstance.children,function(instance){instance&&match(route,function(match){return matchRoute(instance,Object.assign({},context,{match:match,active:active}))})})}applyToGroup(child,function(childInstance){applyToChildren(childInstance.children,function(instance){instance&&instance.to&&instance.to.apply(instance,_toConsumableArray(args.concat(params)))})})}),matches.leave(function(done){var items=0,stopped=!1;applyToGroup(child,function(childInstance){var finish=function(){id?destroyComponent(childInstance):dom.detach(childInstance)},close=function close(){var close=arguments.length>0&&void 0!==arguments[0]?arguments[0]:!0;close?items--:(stopped=!0,done(!1)),0!==items||stopped||(active.set(childInstance,finish),done(!0))};applyToChildren(childInstance.children,function(instance){if(instance&&void 0!==instance.leave){var args=getArgs(instance.leave);args.length>0&&items++,instance.leave(close)}}),0===items&&(active.set(childInstance,finish),done(!0))})}),matches.query(function(params){applyToGroup(child,function(childInstance){applyToChildren(childInstance.children,function(instance){instance&&void 0!==instance.query&&instance.query(params)})})}),applyToGroup(child,function(instance){return instance._activeRoute=matches})}else void 0!==child.children&&-1===["cp"].indexOf(child.data.type)&&applyToChildren(child.children,function(instance){return matchRoute(instance,context)})}}function setRoutes(children,context){applyToChildren(children,function(child){return matchRoute(child,context)})}var STRIP_COMMENTS=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,ARGUMENT_NAMES=/(?:^|,)\s*([^\s,=]+)/g;return setRoutes}),define("widget/parsers/applyElement",["templating/dom"],function(dom){function applyElement(){var elements=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},params=arguments[1],instances={};return Object.keys(elements).forEach(function(key){var instance=elements[key];if("string"!=typeof instance){var element=instance.elGroup.first;if(element){if(instances[key]=element,element instanceof dom.Element==!0&&-1!==["pl"].indexOf(element.data.type)){var bind=element.data.tplSet.bind;bind&&Object.keys(bind).forEach(function(attr){void 0!==params[bind[attr]]&&("class"!==attr?element.setAttribute(attr,params[bind[attr]]):element.addClass(params[bind[attr]]))})}}else instances[key]=instance}}),instances}return applyElement}),define("widget/Constructor",["require","templating/Decoder","templating/dom","./Mediator","./parsers/applyAttribute","./parsers/applyParent","./parsers/applyBinders","./parsers/setBinders","./parsers/setRoutes","./parsers/applyElement","./parsers/addChildren"],function(require,Decoder,dom,Mediator,applyAttribute,applyParent,_applyBinders,setBinders,setRoutes,applyElement,addChildren){function _destroy(instance){var keys=Object.keys(instance);keys.length>0&&keys.forEach(function(key){if("root"!==key){var children=instance[key];void 0!==children.elGroup&&children.elGroup.size>0&&children.elGroup.forEach(function(child){void 0!==child&&void 0!==child.remove&&child.remove(!0)})}})}var Constructor=function(){function Constructor(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},parentChildren=arguments[1],dataSet=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},node=arguments[3];_classCallCheck(this,Constructor),this.instance=this,this._events=[],this._globalEvents=[],this._parentChildren=parentChildren,this._options=options,this._rendered=!1,this._arguments=Array.from(arguments),this._dataSet=dataSet,this.eventBus=new Mediator(this),void 0!==node&&void 0!==node.name&&(this.name=node.name),this.beforeInit.apply(this,_toConsumableArray(this._arguments))}return _createClass(Constructor,null,[{key:"extend",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Surrogate=function(_Constructor){function Surrogate(){return _classCallCheck(this,Surrogate),_possibleConstructorReturn(this,(Surrogate.__proto__||Object.getPrototypeOf(Surrogate)).apply(this,arguments))}return _inherits(Surrogate,_Constructor),Surrogate}(Constructor);return Object.assign(Surrogate.prototype,options),Surrogate}}]),_createClass(Constructor,[{key:"ready",value:function(el){this.el=el}},{key:"setContext",value:function(context){this.context||(this.context=context,this.async||this.render(),this.init.apply(this,_toConsumableArray(this._arguments)))}},{key:"render",value:function(data){if(!this._rendered)if(this.template){data&&(this.data=data);var options=this._options,parentChildren=this._parentChildren,decoder=new Decoder(this.template),template=decoder.render(this.data);if(this.el){var parent=this.el.parentNode;parent&&parent.replaceChild(template.fragment,this.el),this.elGroup&&this.elGroup.get(this.el)&&(this.elGroup["delete"](this.el),this.el=template.fragment,this.elGroup.set(template.fragment,this))}else this.el=template.fragment;this.root=new dom.Element(template.fragment,{name:"root",data:{}}),this.children=applyElement(template.children,options),applyParent(this,parentChildren,this.data),this.bindings=setBinders(this.children,!0),this.data&&this.applyBinders(this.data,this),setRoutes(this.children,this.context),addChildren(this,this.root),this.rendered.apply(this,_toConsumableArray(this._arguments)),this._rendered=!0}else this.root=new dom.Element("
",{name:"root",data:{}}),this.el=this.root.el,this.rendered.apply(this,_toConsumableArray(this._arguments)),this._rendered=!0}},{key:"beforeInit",value:function(data,children,dataSet){}},{key:"init",value:function(data,children,dataSet){}},{key:"rendered",value:function(data,children,dataSet){}},{key:"loadCss",value:function(url){if(-1===this.context._cssReady.indexOf(url)){this.context._cssReady.push(url);var linkRef=document.createElement("link");linkRef.setAttribute("rel","stylesheet"),linkRef.setAttribute("type","text/css"),linkRef.setAttribute("href",url),"undefined"!=typeof linkRef&&document.getElementsByTagName("head")[0].appendChild(linkRef)}}},{key:"detach",value:function(){this._placeholder||(this._placeholder=document.createElement(this.el.tagName)),this._parent||(this._parent=this.el.parentNode),this.el&&this._parent&&this._parent.replaceChild(this._placeholder,this.el)}},{key:"attach",value:function(){this._placeholder&&this._parent&&this._parent.replaceChild(this.el,this._placeholder)}},{key:"onDestroy",value:function(){}},{key:"destroy",value:function(){for(this.onDestroy(),this.eventBus.clear();this._events.length>0;)this._events.shift().remove();for(;this._globalEvents.length>0;)this._globalEvents.shift().remove();_destroy(this.children),void 0!==this.elGroup&&void 0!==this.el&&this.elGroup["delete"](this.el),this.root&&this.root.remove&&this.root.remove(),delete this.el}},{key:"remove",value:function(){this.destroy.apply(this,arguments)}},{key:"setChildren",value:function(el,data){var name=el.data.name,instance=this.children[name];void 0!==instance&&void 0!==instance.el&&instance.remove();var newInstance=el.run(data||!0);return newInstance.setContext&&newInstance.setContext(this.context),addChildren(this,newInstance,data),newInstance}},{key:"addComponent",value:function(Component,options){var name=options.name,container=options.container;if(void 0===name)throw"you have to define data.name for component.";if(void 0===container)throw"You have to define container for component.";if(void 0!==this.children[name])throw"Component using name:"+name+"! already defined.";var component=this.setComponent(Component,options),instance=component.run(options.container);return instance.setContext(this.context),this.children[name]=instance,instance}},{key:"setComponent",value:function(Component,options){var _this8=this,instance={name:options.name,data:{tag:"div",type:"cp"},run:function(container){options.appContext=_this8.context;var cp=new Component(options,options.children,options.data),el=document.createElement("div");return el.setAttribute("style","display:none;"),cp.ready(el),container instanceof HTMLElement==!0?container.parentNode.replaceChild(cp.el,container):void 0!==container.el&&void 0!==options.pos?dom.insertBefore(container,cp,options.pos):void 0!==container.el&&dom.append(container,cp),cp}};return instance}},{key:"applyBinders",value:function(){for(var _len4=arguments.length,args=Array(_len4),_key4=0;_len4>_key4;_key4++)args[_key4]=arguments[_key4];return _applyBinders.apply(void 0,[this].concat(args))}},{key:"context",set:function(context){var _this9=this;if(!this.data){var keys=this._dataSet?Object.keys(this._dataSet):[],contextData=keys.length>0?this._dataSet:context.data;contextData&&(this.data=contextData[this._options.bind]||contextData)}context.match(function(match){_this9.match&&_this9.match(match),_this9._context=Object.assign({match:match},context)})},get:function(){return this._context}}]),Constructor}();return Object.assign(Constructor.prototype,{nodes:{},events:{},elReady:{},elOnChange:{}}),Constructor}),function(global,factory){"function"==typeof define&&define.amd?define("widget/Mediator",[],function(){return factory()}):"undefined"!=typeof exports?exports.Mediator=factory():global.Mediator=factory()}(void 0,function(){var Subscriber=function(){function Subscriber(fn,options){var context=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},channel=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;_classCallCheck(this,Subscriber),this.fn=fn,this.channel=channel,this.context=context,this.options=options}return _createClass(Subscriber,[{key:"update",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,options),this.channel&&this.setPriority(this.priority)}},{key:"setHook",value:function(context){var channel=this.channel;channel&&channel.hook(this,context)}},{key:"_reduceCalls",value:function(){void 0!==this.calls&&(this.calls--,this.calls<1&&this.remove())}},{key:"remove",value:function(){var channel=this.channel;channel&&channel.removeSubscriber(this)}},{key:"setPriority",value:function(priority){var channel=this.channel;channel&&channel.setPriority(this,priority)}},{key:"run",value:function(data){this.channel.stopped||"function"==typeof this.predicate&&!this.predicate.apply(this.context,data)||(this._reduceCalls(),this.fn.apply(this.context,data))}},{key:"options",set:function(options){this.update(options)}},{key:"context",set:function(context){this.setHook(context),this._context=context},get:function(){return this._context}}]),Subscriber}(),Channel=function(){function Channel(namespace,parent,context,hook){_classCallCheck(this,Channel),this.namespace=namespace||"",this._subscribers=[],this._channels=new Map,this._parent=parent,this.stopped=!1,this.context=context,this.hook=hook}return _createClass(Channel,[{key:"addSubscriber",value:function(fn,options){var context=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.context;return new Subscriber(fn,options,context,this)}},{key:"stopPropagation",value:function(){this.stopped=!0}},{key:"setPriority",value:function(subscriber,priority){var subscribers=this._subscribers,index=subscribers.indexOf(subscriber);-1!==index&&subscribers.splice(subscribers.indexOf(subscriber),1),void 0!==priority&&priority0){var channel=channels.shift(),returnChannel=this.setChannel(channel,readOnly);return returnChannel&&channels.length>0?returnChannel.returnChannel(channels,readOnly):returnChannel}}},{key:"removeSubscriber",value:function(subscriber){var subscribers=this._subscribers,index=subscribers.indexOf(subscriber);subscriber?-1!==index&&subscribers.splice(index,1):subscribers.splice(0,subscribers.length),0===this._subscribers.length&&this._parent&&this._parent.removeChannel(this)}},{key:"removeChannel",value:function(channel){channel===this.getChannel(channel.namespace)&&this._channels["delete"](channel.namespace)}},{key:"clear",value:function(){this._channels.forEach(function(channel){return channel.clear()}),this.removeSubscriber()}},{key:"publish",value:function(data){this._subscribers.slice().forEach(function(subscriber){return subscriber.run(data)}),this._parent&&this._parent.publish(data),this.stopped=!1}}]),Channel}(),Mediator=function(){function Mediator(){var context=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},hook=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};return _classCallCheck(this,Mediator),this instanceof Mediator?void(this.channel=new Channel("",!1,context,hook)):new Mediator(context,hook)}return _createClass(Mediator,[{key:"getChannel",value:function(namespace,readOnly){var namespaceHierarchy=namespace.split(":");return namespaceHierarchy.length>0?this.channel.returnChannel(namespaceHierarchy,readOnly):void 0}},{key:"subscribe",value:function(channelName,fn){var options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},context=arguments[3];if(channelName&&""!==channelName){var channel=this.getChannel(channelName,!1);return channel.addSubscriber(fn,options,context)}throw Error("Namespace should be provided!")}},{key:"once",value:function(channelName,fn){var options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},context=arguments[3];return options.calls=1,this.subscribe(channelName,fn,options,context)}},{key:"publish",value:function(channelName){if(channelName&&""!==channelName){var channel=this.getChannel(channelName,!0);if(channel&&channel.namespace===channelName){for(var _len5=arguments.length,args=Array(_len5>1?_len5-1:0),_key5=1;_len5>_key5;_key5++)args[_key5-1]=arguments[_key5];args.push(channel),channel.publish(args)}}}},{key:"clear",value:function(){this.channel.clear()}}]),Mediator}();return Mediator.prototype.on=Mediator.prototype.subscribe,Mediator.prototype.trigger=Mediator.prototype.publish,Mediator.version="0.9.9",Mediator}),function(root,factory){"function"==typeof define&&define.amd?define("router/utils",[],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&(module.exports=factory())}(void 0,function(){function parseParams(value){try{return decodeURIComponent(value.replace(/\+/g," "))}catch(err){return value}}function iterateQueryString(queryString,callback){var keyValues=queryString.split("&");keyValues.forEach(function(keyValue){var arr=keyValue.split("=");callback(arr.shift(),arr.join("="))})}function setQuery(parts){var query={};return parts&&iterateQueryString(parts,function(name,value){value=parseParams(value),query[name]?"string"==typeof query[name]?query[name]=[query[name],value]:query[name].push(value):query[name]=value}),query}function serialize(obj){var str=[];for(var p in obj)obj.hasOwnProperty(p)&&str.push(encodeURIComponent(p)+"="+encodeURIComponent(obj[p]));return str.join("&")}function getLocation(params,pattern){return{getQuery:function(){return params.query},getLocation:function(){var fragment=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",isQuery=arguments[1],current=params.root.substring(0,params.root.length-pattern.length),newQuery=void 0;return newQuery=isQuery===!0?serialize(params.query):isQuery===!1?"":serialize(isQuery),current+fragment+(0===newQuery.length?"":"?"+newQuery)}}}function equals(arr1,arr2){if(!arr2)return!1;if(arr1.length!==arr2.length)return!1;for(var i=0,l=arr1.length;l>i;i++)if(arr1[i]instanceof Array&&arr2[i]instanceof Array){if(!equals(arr1[i],arr2[i]))return!1}else if(arr1[i]!==arr2[i])return!1;return!0}function getArgs(func){var oneOf=function(){for(var _len6=arguments.length,patterns=Array(_len6),_key6=0;_len6>_key6;_key6++)patterns[_key6]=arguments[_key6];return function(string,pos){return patterns.map(function(pattern){return string.indexOf(pattern)}).filter(function(index){return index===pos}).length>0}},fnStr=func.toString().replace(STRIP_COMMENTS,""),first=oneOf("(","function (","function(")(fnStr,0)?fnStr.indexOf("(")+1:0,last=oneOf("=>")(fnStr,-1)?fnStr.indexOf(")"):fnStr.indexOf("=>"),argsList=fnStr.slice(first,last).trim(),result=argsList.match(ARGUMENT_NAMES);return null===result?[]:result.map(function(item){return item.replace(/[\s,]/g,"")})}var STRIP_COMMENTS=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,ARGUMENT_NAMES=/(?:^|,)\s*([^\s,=]+)/g;return{serialize:serialize,getLocation:getLocation,equals:equals,setQuery:setQuery,getArgs:getArgs}}),function(root,factory){"function"==typeof define&&define.amd?define("router/MatchBinding",["./utils"],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&(module.exports=factory(require("./utils")))}(void 0,function(utils){var MatchBinding=function(){function MatchBinding(pattern,location,binder){if(_classCallCheck(this,MatchBinding),binder&&(this.binder=binder),""===location)this.pattern=pattern.replace(/^\(\/\)/g,"").replace(/^\/|$/g,"");else{var match=pattern.match(/^(\/|\(\/)/g);null===match&&(pattern="("===pattern[0]?"(/"+pattern.substring(1):"/"+pattern),this.pattern=pattern}var route=this.pattern.replace(MatchBinding.ESCAPE_PARAM,"\\$&").replace(MatchBinding.OPTIONAL_PARAM,"(?:$1)?").replace(MatchBinding.NAMED_PARAM,function(match,optional){return optional?match:"([^/]+)"}).replace(MatchBinding.SPLAT_PARAM,"(.*)");this.patternRegExp=new RegExp("^"+route),this.routeHandler=new Set,this.leaveHandler=new Set,this.queryHandler=new Set,this._active=!1}return _createClass(MatchBinding,[{key:"setRoutes",value:function(mapHandler){var subBinder=this.subBinder;return mapHandler({match:subBinder.match.bind(subBinder)}),this}},{key:"reTrigger",value:function(){this.binder.reTrigger()}},{key:"match",value:function(_match){var subBinder=this.subBinder;return _match(subBinder.match.bind(subBinder)),this}},{key:"to",value:function(routeHandler){return this.routeHandler.add({handler:routeHandler,done:!1}),this.reTrigger(),this}},{key:"leave",value:function(leaveHandler){var args=utils.getArgs(leaveHandler);return this.leaveHandler.add({handler:leaveHandler,done:args.length>0&&"done"===args[0]}),this}},{key:"query",value:function(queryHandler){return this.queryHandler.add({handler:queryHandler,done:!1}),this}},{key:"remove",value:function(){return this.routeHandler.clear(),this.leaveHandler.clear(),this.queryHandler.clear(),this.subBinder.remove(),this}},{key:"test",value:function(location){return this.patternRegExp.test(location)}},{key:"getFragment",value:function(location){var matches=location.match(this.patternRegExp);return null===matches?"":location.substring(matches[0].length)}},{key:"extractParams",value:function(fragment){var params=this.patternRegExp.exec(fragment);return params&¶ms.length>0?params.slice(1).map(function(param){return param?decodeURIComponent(param):null}):[]}},{key:"setSubBinder",value:function(MatchBinder,pattern,mapHandler){var subBinder=new MatchBinder(pattern,this);return this.subBinder=subBinder,"function"==typeof mapHandler&&mapHandler(subBinder.match.bind(subBinder)),subBinder}},{key:"checkSegment",value:function(matched,params){var status=[];if(this._active){var pattern=this.pattern.replace(/\((.*?)\)/g,"$1").replace(/^\//,"").split("/"),prevLoc=this.prevLoc.replace(/^\//,"").split("/"),currSegment=matched.slice(0,pattern.length),prevSegment=prevLoc.slice(0,pattern.length),equals=utils.equals(currSegment,prevSegment);equals?matched.length>1?status=this.subBinder.checkStatus(matched.slice(pattern.length),params):equals&&(status=this.subBinder.clearActive(params)):status=this.clearActive(params)}return status}},{key:"clearActive",value:function(params){var active=[];return this._active&&active.push({handler:this.triggerLeave(params),disable:this.disable.bind(this)}),active.concat(this.subBinder.clearActive())}},{key:"disable",value:function(){this._active=!1}},{key:"triggerTo",value:function(location,params){if(this.test(location)){if(!this._active){this.prevLoc=location;var args=this.extractParams(location).concat(utils.getLocation(params,location));this.applyHandlers(this.routeHandler,args),this._active=!0}this.applyHandlers(this.queryHandler,[utils.getLocation(params,location)]);var fragment=this.getFragment(location);if(""!==fragment.trim()){var subBinder=this.subBinder;subBinder&&subBinder.triggerRoutes(fragment,params)}}}},{key:"applyHandlers",value:function(handlers){var _this10=this,args=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];handlers&&handlers.size>0&&handlers.forEach(function(item){item.handler.apply(_this10,args)})}},{key:"triggerLeave",value:function(params){var _this11=this;return new Promise(function(resolve){var handlers=_this11.leaveHandler,location=utils.getLocation(params,_this11.prevLoc),items=0,stopped=!1;handlers&&handlers.size>0&&handlers.forEach(function(item){item.done&&items++,item.handler(function(){var done=arguments.length>0&&void 0!==arguments[0]?arguments[0]:!0;done?(items--,0!==items||stopped||resolve(!0)):done||stopped||(stopped=!0,resolve(!1))},location)}),0===items&&resolve(!0)})}}]),MatchBinding}();return Object.assign(MatchBinding,{OPTIONAL_PARAM:/\((.*?)\)/g,NAMED_PARAM:/(\(\?)?:\w+/g,SPLAT_PARAM:/\*\w+/g,ESCAPE_PARAM:/[\-{}\[\]+?.,\\\^$|#\s]/g}),MatchBinding}),function(root,factory){"function"==typeof define&&define.amd?define("router/MatchBinder",["./MatchBinding"],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))?module.exports=factory(require("./MatchBinding")):(root.UrlManager=root.UrlManager||{},root.UrlManager.MatchBinder=factory(root.UrlManager.MatchBinding))}(void 0,function(MatchBinding){var MatchBinder=function(){function MatchBinder(location,parent){_classCallCheck(this,MatchBinder),this._parent=parent,this.bindings=new Set,this.location=location||"",this._active=!1}return _createClass(MatchBinder,[{key:"reTrigger",value:function(){this._parent.reTrigger()}},{key:"match",value:function(pattern,mapHandler){return"function"==typeof pattern&&(mapHandler=pattern,pattern=!1),""===pattern&&(pattern=!1),this.getMatchBinding(pattern,mapHandler)}},{key:"getMatchBinding",value:function(pattern,mapHandler){if(pattern){var binding=new MatchBinding(pattern,this.location,this);return binding.setSubBinder(MatchBinder,this.location+(pattern||""),mapHandler),this.bindings.add(binding),binding}return"function"==typeof mapHandler&&mapHandler(this.match.bind(this)),{match:this.match.bind(this)}}},{key:"clearActive",value:function(params,location){var active=[];return this.bindings.size>0&&this.bindings.forEach(function(binding){active=active.concat(binding.clearActive(params,location))}),active}},{key:"checkStatus",value:function(matched,params){var active=[];return this.bindings.size>0&&this.bindings.forEach(function(binding){active=active.concat(binding.checkSegment(matched,params))}),active}},{key:"remove",value:function(){this.bindings.size>0&&this.bindings.forEach(function(binding){return binding.remove()})}},{key:"triggerRoutes",value:function(location,params){this.bindings.size>0&&this.bindings.forEach(function(binding){return binding.triggerTo(location,params)})}}]),MatchBinder}();return MatchBinder}),function(root,factory){"function"==typeof define&&define.amd?define("router/Router",["./MatchBinder","./utils"],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&(module.exports=factory(require("./MatchBinder"),require("./utils")))}(void 0,function(MatchBinder,utils){var Router=function(){function Router(location){_classCallCheck(this,Router),void 0!==location&&""!==location&&(this._location=location.replace(/^\/|\/$/g,"")+"/"),this.root=this.getBinder(),this._listeners=new Set,this._handlers=new Set}return _createClass(Router,[{key:"getBinder",value:function(){return new MatchBinder("",this)}},{key:"test",value:function(loc){return new RegExp("^"+this._location,"g").test(loc)}},{key:"getLocation",value:function(loc){var location=loc.replace(/^\/|$/g,"");return void 0!==this._location?this.test(location)?location.replace(this._location,""):!1:location}},{key:"reTrigger",value:function(){this.currLocation&&this.trigger(this.currLocation)}},{key:"trigger",value:function(location){var _this12=this;if(this.started){this.currLocation=location;var parts=location.split("?",2),segments=this.getLocation(parts[0]);if(segments||""===segments){var query=utils.setQuery(parts[1]),params={root:segments,query:query};this.execute(segments,params).then(function(move){return _this12.setRoutes(move,segments,params)}).then(function(move){return _this12.setLocation(move)})}}}},{key:"execute",value:function(location,params){var _this13=this;return new Promise(function(resolve){var matched=location.replace(/^\/|$/g,"").split("/"),binder=_this13.root,active=binder.checkStatus(matched,params);active.length>0?active.forEach(function(item){item.handler.then(function(applied){item.triggered||(item.triggered=!0,item.applied=applied,active.filter(function(item){return item.applied}).length===active.length?(active.forEach(function(item){return item.disable()}),resolve(!0)):active.filter(function(item){return item.triggered}).length===active.length&&resolve(!1))})}):resolve(!0)})}},{key:"setRoutes",value:function(move,location,params){return move&&(this._handlers.forEach(function(handler){return handler()}),this.root.triggerRoutes(location,params)),move}},{key:"setListener",value:function(listener){var listeners=this._listeners;return listeners.add(listener),{remove:function(){listeners["delete"](listener)}}}},{key:"onRouteChange",value:function(handler){var handlers=this._handlers;return handlers.add(handler),{remove:function(){handlers["delete"](handler)}}}},{key:"setLocation",value:function(move){var location=move?this.currLocation:this.prevLocation;this.prevLocation=location,this._listeners.forEach(function(listener){return listener(location,move)})}},{key:"match",value:function(mapHandler){mapHandler(this.root.match.bind(this.root))}},{key:"start",value:function(){this.started=!0}},{key:"stop",value:function(){this.started=!1}}]),Router}();return Router}),define("widget/App",["./Mediator","router/Router"],function(Mediator,Router){function triggerRoute(router,active){function onHashChange(){var match=window.location.href.match(/#(.*)$/),route=match?match[1]:"";activeLocation!==route&&router.trigger(route)}var activeLocation="";router.setListener(function(location,move){activeLocation=location,move||(window.location.hash=location)}),router.onRouteChange(function(){active.size>0&&(active.forEach(function(handler){return handler()}),active.clear())}),router.start(),window.addEventListener("hashchange",onHashChange,!1),onHashChange()}var App=function(){function App(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,App),this.options=options,this.beforeInit.apply(this,arguments)}return _createClass(App,null,[{key:"extend",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Surrogate=function(_App){function Surrogate(){return _classCallCheck(this,Surrogate),_possibleConstructorReturn(this,(Surrogate.__proto__||Object.getPrototypeOf(Surrogate)).apply(this,arguments))}return _inherits(Surrogate,_App),Surrogate}(App);return Object.assign(Surrogate.prototype,options),Surrogate}}]),_createClass(App,[{key:"beforeInit",value:function(){}},{key:"init",value:function(){}},{key:"setContext",value:function(){return{}}},{key:"start",value:function(container){if(container instanceof HTMLElement!=!0)throw Error("Contaner should be a HTML element");this.el=container,this.context=this.setContext.apply(this,arguments),void 0!==this.AppContainer&&(this.appContainer=new this.AppContainer),this.init(this.options);var el=document.createElement("div");this.el.appendChild(el),this.appContainer.ready(el), -this.appContainer.setContext(this.context),setTimeout(function(){container.classList.add("show")},100)}},{key:"context",set:function(context){var _this15=this,router=new Router(this.options.rootRoute);router.match(function(match){Object.assign(context,{eventBus:new Mediator(_this15.context,function(channel,scope){scope._globalEvents=scope._globalEvents||[],-1===scope._globalEvents.indexOf(channel)&&scope._globalEvents.push(channel)}),active:new Map,match:match,container:_this15.el,_cssReady:context._cssReady||[]}),triggerRoute(router,context.active),_this15._context=context})},get:function(){return this._context}}]),App}();return App}); \ No newline at end of file +watch(obj,objKey,function(prop,action,newValue,oldValue){var clonedData=bindedData.slice(0);if(void 0===oldValue&&-1!==insertMethodNames.indexOf(action)){var filter=clonedData.filter(function(item){return item.data===newValue[0]});0===filter.length&&addItem(newValue[0],"unshift"===action?0:clonedData.length)}else if(-1!==removeMethodNames.indexOf(action)){if(clonedData.forEach(function(binder){-1===obj[objKey].indexOf(binder.data)&&(binder.binder.remove(),bindedData.splice(bindedData.indexOf(binder),1))}),"splice"===action){var vals=Array.prototype.slice.call(newValue,2);vals&&vals.length>0&&vals.forEach(function(val){var index=obj[objKey].indexOf(val);-1!==index&&addItem(val,index)})}}else-1!==sortingMethodNames.indexOf(action)&&data.forEach(function(value,index){var element=clonedData.filter(function(item){return item.data===value})[0];bindedData.splice(index,0,bindedData.splice(bindedData.indexOf(element),1)[0]),element.binder.changePosition(index)})})}}else if(utils.isObject(data)){var _element=binder.run(data);if("cp"!==_element.data.type){applyAttribute(context,_element,data),addChildren.applyEvents(context,_element,data),addChildren.elReady(context,_element,data);var _handler=addChildren.elOnChange(context,_element);_handler&&_handler(data),_element.children&&(_element.bindings=setBinders(_element.children),applyBinders(context,data,_element))}}}else{var element=binder.run(!0);element.text(data),addChildren.applyEvents(context,element,data),addChildren.elReady(context,element,data);var handler=addChildren.elOnChange(context,element);handler&&handler(data),element.data.tplSet.update&&watch(obj,objKey,function(){element.text(obj[objKey]);var handler=addChildren.elOnChange(context,element);handler&&handler(obj[objKey])})}}}function applyBinders(child,obj,instance){var binders=instance.bindings;if(binders){binders.__cp__.length>0&&binders.__cp__.forEach(function(binder){var component=binder.run(obj);component.setContext(child.context),addChildren.elReady(child,component,obj);var handler=addChildren.elOnChange(child,component);handler&&handler(obj)});var keys=Object.keys(binders);obj&&keys.length>0&&keys.forEach(function(binderKey){if(void 0!==obj[binderKey])binders[binderKey].forEach(function(binder){return parseBinder(child,binderKey,obj,binder)});else{var fn=function fn(prop,action,newValue,oldValue){void 0!==newValue&&void 0===oldValue&&(binders[binderKey].forEach(function(binder){return parseBinder(child,binderKey,obj,binder)}),unwatch(obj,binderKey,fn))};watch(obj,binderKey,fn,0)}})}}var watch=WatchJS.watch,unwatch=WatchJS.unwatch;return applyBinders}),define("widget/parsers/setRoutes",["templating/dom"],function(dom){function getArgs(func){var fnStr=func.toString().replace(STRIP_COMMENTS,""),argsList=fnStr.slice(fnStr.indexOf("(")+1,fnStr.indexOf(")")),result=argsList.match(ARGUMENT_NAMES);return null===result?[]:result.map(function(item){return item.replace(/[\s,]/g,"")})}function destroyComponent(cp){void 0!==cp.remove&&cp.remove()}function applyToChildren(children,cb){void 0!==children&&Object.keys(children).forEach(function(name){var instance=children[name];applyToGroup(instance,cb)||cb(instance)})}function applyToGroup(child,cb){return child.elGroup&&child.elGroup.size>0?(child.elGroup.forEach(function(childInstance){cb(childInstance)}),!0):!1}function matchRoute(child,context){if(child.setContext)child.setContext(context);else{var route=void 0!==child.data?child.data.route:void 0;if(void 0!==route&&"rt"===child.data.type){var id=void 0,match=context.match,active=context.active,matches=match(route);matches.to(function(){for(var _len3=arguments.length,args=Array(_len3),_key3=0;_len3>_key3;_key3++)args[_key3]=arguments[_key3];var params=args.pop();if(id=args.length>0?params.getLocation()+"_"+args.join("_"):void 0,!applyToGroup(child,function(instance){return dom.attach(instance)})){var childInstance=child.run(!0);applyToChildren(childInstance.children,function(instance){instance&&match(route,function(match){return matchRoute(instance,Object.assign({},context,{match:match,active:active}))})})}applyToGroup(child,function(childInstance){applyToChildren(childInstance.children,function(instance){instance&&instance.to&&instance.to.apply(instance,_toConsumableArray(args.concat(params)))})})}),matches.leave(function(done){var items=0,stopped=!1;applyToGroup(child,function(childInstance){var finish=function(){id?destroyComponent(childInstance):dom.detach(childInstance)},close=function close(){var close=arguments.length>0&&void 0!==arguments[0]?arguments[0]:!0;close?items--:(stopped=!0,done(!1)),0!==items||stopped||(active.set(childInstance,finish),done(!0))};applyToChildren(childInstance.children,function(instance){if(instance&&void 0!==instance.leave){var args=getArgs(instance.leave);args.length>0&&items++,instance.leave(close)}}),0===items&&(active.set(childInstance,finish),done(!0))})}),matches.query(function(params){applyToGroup(child,function(childInstance){applyToChildren(childInstance.children,function(instance){instance&&void 0!==instance.query&&instance.query(params)})})}),applyToGroup(child,function(instance){return instance._activeRoute=matches})}else void 0!==child.children&&-1===["cp"].indexOf(child.data.type)&&applyToChildren(child.children,function(instance){return matchRoute(instance,context)})}}function setRoutes(children,context){applyToChildren(children,function(child){return matchRoute(child,context)})}var STRIP_COMMENTS=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,ARGUMENT_NAMES=/(?:^|,)\s*([^\s,=]+)/g;return setRoutes}),define("widget/parsers/applyElement",["templating/dom"],function(dom){function applyElement(){var elements=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},params=arguments[1],instances={};return Object.keys(elements).forEach(function(key){var instance=elements[key];if("string"!=typeof instance){var element=instance.elGroup.first;if(element){if(instances[key]=element,element instanceof dom.Element==!0&&-1!==["pl"].indexOf(element.data.type)){var bind=element.data.tplSet.bind;bind&&Object.keys(bind).forEach(function(attr){void 0!==params[bind[attr]]&&("class"!==attr?element.setAttribute(attr,params[bind[attr]]):element.addClass(params[bind[attr]]))})}}else instances[key]=instance}}),instances}return applyElement}),define("widget/Constructor",["require","templating/Decoder","templating/dom","./Mediator","./parsers/applyAttribute","./parsers/applyParent","./parsers/applyBinders","./parsers/setBinders","./parsers/setRoutes","./parsers/applyElement","./parsers/addChildren"],function(require,Decoder,dom,Mediator,applyAttribute,applyParent,_applyBinders,setBinders,setRoutes,applyElement,addChildren){function _destroy(instance){var keys=Object.keys(instance);keys.length>0&&keys.forEach(function(key){if("root"!==key){var children=instance[key];void 0!==children.elGroup&&children.elGroup.size>0&&children.elGroup.forEach(function(child){void 0!==child&&void 0!==child.remove&&child.remove(!0)})}})}var Constructor=function(){function Constructor(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},parentChildren=arguments[1],dataSet=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},node=arguments[3];_classCallCheck(this,Constructor),this.instance=this,this._events=[],this._globalEvents=[],this._parentChildren=parentChildren,this._options=options,this._rendered=!1,this._arguments=Array.from(arguments),this._dataSet=dataSet,this.eventBus=new Mediator(this),void 0!==node&&void 0!==node.name&&(this.name=node.name),this.beforeInit.apply(this,_toConsumableArray(this._arguments))}return _createClass(Constructor,null,[{key:"extend",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Surrogate=function(_Constructor){function Surrogate(){return _classCallCheck(this,Surrogate),_possibleConstructorReturn(this,(Surrogate.__proto__||Object.getPrototypeOf(Surrogate)).apply(this,arguments))}return _inherits(Surrogate,_Constructor),Surrogate}(Constructor);return Object.assign(Surrogate.prototype,options),Surrogate}}]),_createClass(Constructor,[{key:"ready",value:function(el){this.el=el}},{key:"setContext",value:function(context){this.context||(this.context=context,this.async||this.render(),this.init.apply(this,_toConsumableArray(this._arguments)))}},{key:"render",value:function(data){if(!this._rendered)if(this.template){data&&(this.data=data);var options=this._options,parentChildren=this._parentChildren,decoder=new Decoder(this.template),template=decoder.render(this.data);if(this.el){var parent=this.el.parentNode;parent&&parent.replaceChild(template.fragment,this.el),this.elGroup&&this.elGroup.get(this.el)&&(this.elGroup["delete"](this.el),this.el=template.fragment,this.elGroup.set(template.fragment,this))}else this.el=template.fragment;this.root=new dom.Element(template.fragment,{name:"root",data:{}}),this.children=applyElement(template.children,options),applyParent(this,parentChildren,this.data),this.bindings=setBinders(this.children,!0),this.data&&this.applyBinders(this.data,this),setRoutes(this.children,this.context),addChildren(this,this.root),this.rendered.apply(this,_toConsumableArray(this._arguments)),this._rendered=!0}else{var HTMLelement=document.createElement("div");if(this.root=new dom.Element(HTMLelement,{name:"root",data:{}}),this.el){var _parent=this.el.parentNode;_parent&&_parent.replaceChild(HTMLelement,this.el)}this.el=HTMLelement,this.children={},addChildren(this,this.root),this.rendered.apply(this,_toConsumableArray(this._arguments)),this._rendered=!0}}},{key:"beforeInit",value:function(data,children,dataSet){}},{key:"init",value:function(data,children,dataSet){}},{key:"rendered",value:function(data,children,dataSet){}},{key:"loadCss",value:function(url){if(-1===this.context._cssReady.indexOf(url)){this.context._cssReady.push(url);var linkRef=document.createElement("link");linkRef.setAttribute("rel","stylesheet"),linkRef.setAttribute("type","text/css"),linkRef.setAttribute("href",url),"undefined"!=typeof linkRef&&document.getElementsByTagName("head")[0].appendChild(linkRef)}}},{key:"detach",value:function(){this._placeholder||(this._placeholder=document.createElement(this.el.tagName)),this._parent||(this._parent=this.el.parentNode),this.el&&this._parent&&this._parent.replaceChild(this._placeholder,this.el)}},{key:"attach",value:function(){this._placeholder&&this._parent&&this._parent.replaceChild(this.el,this._placeholder)}},{key:"onDestroy",value:function(){}},{key:"destroy",value:function(){for(this.onDestroy(),this.eventBus.clear();this._events.length>0;)this._events.shift().remove();for(;this._globalEvents.length>0;)this._globalEvents.shift().remove();_destroy(this.children),void 0!==this.elGroup&&void 0!==this.el&&this.elGroup["delete"](this.el),this.root&&this.root.remove&&this.root.remove(),delete this.el}},{key:"remove",value:function(){this.destroy.apply(this,arguments)}},{key:"setChildren",value:function(el,data){var name=el.data.name,instance=this.children[name];void 0!==instance&&void 0!==instance.el&&instance.remove();var newInstance=el.run(data||!0);return newInstance.setContext&&newInstance.setContext(this.context),addChildren(this,newInstance,data),newInstance}},{key:"addComponent",value:function(Component,options){var name=options.name,container=options.container;if(void 0===name)throw"you have to define data.name for component.";if(void 0===container)throw"You have to define container for component.";if(void 0!==this.children[name])throw"Component using name:"+name+"! already defined.";var component=this.setComponent(Component,options),instance=component.run(options.container);return instance.setContext(this.context),this.children[name]=instance,instance}},{key:"setComponent",value:function(Component,options){var _this8=this,instance={name:options.name,data:{tag:"div",type:"cp"},run:function(container){options.appContext=_this8.context;var cp=new Component(options,options.children,options.data),el=document.createElement("div");return el.setAttribute("style","display:none;"),cp.ready(el),container instanceof HTMLElement==!0?container.parentNode.replaceChild(cp.el,container):void 0!==container.el&&void 0!==options.pos?dom.insertBefore(container,cp,options.pos):void 0!==container.el&&dom.append(container,cp),cp}};return instance}},{key:"applyBinders",value:function(){for(var _len4=arguments.length,args=Array(_len4),_key4=0;_len4>_key4;_key4++)args[_key4]=arguments[_key4];return _applyBinders.apply(void 0,[this].concat(args))}},{key:"context",set:function(context){var _this9=this;if(!this.data){var keys=this._dataSet?Object.keys(this._dataSet):[],contextData=keys.length>0?this._dataSet:context.data;contextData&&(this.data=contextData[this._options.bind]||contextData)}context.match(function(match){_this9.match&&_this9.match(match),_this9._context=Object.assign({match:match},context)})},get:function(){return this._context}}]),Constructor}();return Object.assign(Constructor.prototype,{nodes:{},events:{},elReady:{},elOnChange:{}}),Constructor}),function(global,factory){"function"==typeof define&&define.amd?define("widget/Mediator",[],function(){return factory()}):"undefined"!=typeof exports?exports.Mediator=factory():global.Mediator=factory()}(void 0,function(){var Subscriber=function(){function Subscriber(fn,options){var context=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},channel=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;_classCallCheck(this,Subscriber),this.fn=fn,this.channel=channel,this.context=context,this.options=options}return _createClass(Subscriber,[{key:"update",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,options),this.channel&&this.setPriority(this.priority)}},{key:"setHook",value:function(context){var channel=this.channel;channel&&channel.hook(this,context)}},{key:"_reduceCalls",value:function(){void 0!==this.calls&&(this.calls--,this.calls<1&&this.remove())}},{key:"remove",value:function(){var channel=this.channel;channel&&channel.removeSubscriber(this)}},{key:"setPriority",value:function(priority){var channel=this.channel;channel&&channel.setPriority(this,priority)}},{key:"run",value:function(data){this.channel.stopped||"function"==typeof this.predicate&&!this.predicate.apply(this.context,data)||(this._reduceCalls(),this.fn.apply(this.context,data))}},{key:"options",set:function(options){this.update(options)}},{key:"context",set:function(context){this.setHook(context),this._context=context},get:function(){return this._context}}]),Subscriber}(),Channel=function(){function Channel(namespace,parent,context,hook){_classCallCheck(this,Channel),this.namespace=namespace||"",this._subscribers=[],this._channels=new Map,this._parent=parent,this.stopped=!1,this.context=context,this.hook=hook}return _createClass(Channel,[{key:"addSubscriber",value:function(fn,options){var context=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.context;return new Subscriber(fn,options,context,this)}},{key:"stopPropagation",value:function(){this.stopped=!0}},{key:"setPriority",value:function(subscriber,priority){var subscribers=this._subscribers,index=subscribers.indexOf(subscriber);-1!==index&&subscribers.splice(subscribers.indexOf(subscriber),1),void 0!==priority&&priority0){var channel=channels.shift(),returnChannel=this.setChannel(channel,readOnly);return returnChannel&&channels.length>0?returnChannel.returnChannel(channels,readOnly):returnChannel}}},{key:"removeSubscriber",value:function(subscriber){var subscribers=this._subscribers,index=subscribers.indexOf(subscriber);subscriber?-1!==index&&subscribers.splice(index,1):subscribers.splice(0,subscribers.length),0===this._subscribers.length&&this._parent&&this._parent.removeChannel(this)}},{key:"removeChannel",value:function(channel){channel===this.getChannel(channel.namespace)&&this._channels["delete"](channel.namespace)}},{key:"clear",value:function(){this._channels.forEach(function(channel){return channel.clear()}),this.removeSubscriber()}},{key:"publish",value:function(data){this._subscribers.slice().forEach(function(subscriber){return subscriber.run(data)}),this._parent&&this._parent.publish(data),this.stopped=!1}}]),Channel}(),Mediator=function(){function Mediator(){var context=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},hook=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};return _classCallCheck(this,Mediator),this instanceof Mediator?void(this.channel=new Channel("",!1,context,hook)):new Mediator(context,hook)}return _createClass(Mediator,[{key:"getChannel",value:function(namespace,readOnly){var namespaceHierarchy=namespace.split(":");return namespaceHierarchy.length>0?this.channel.returnChannel(namespaceHierarchy,readOnly):void 0}},{key:"subscribe",value:function(channelName,fn){var options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},context=arguments[3];if(channelName&&""!==channelName){var channel=this.getChannel(channelName,!1);return channel.addSubscriber(fn,options,context)}throw Error("Namespace should be provided!")}},{key:"once",value:function(channelName,fn){var options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},context=arguments[3];return options.calls=1,this.subscribe(channelName,fn,options,context)}},{key:"publish",value:function(channelName){if(channelName&&""!==channelName){var channel=this.getChannel(channelName,!0);if(channel&&channel.namespace===channelName){for(var _len5=arguments.length,args=Array(_len5>1?_len5-1:0),_key5=1;_len5>_key5;_key5++)args[_key5-1]=arguments[_key5];args.push(channel),channel.publish(args)}}}},{key:"clear",value:function(){this.channel.clear()}}]),Mediator}();return Mediator.prototype.on=Mediator.prototype.subscribe,Mediator.prototype.trigger=Mediator.prototype.publish,Mediator.version="0.9.9",Mediator}),function(root,factory){"function"==typeof define&&define.amd?define("router/utils",[],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&(module.exports=factory())}(void 0,function(){function parseParams(value){try{return decodeURIComponent(value.replace(/\+/g," "))}catch(err){return value}}function iterateQueryString(queryString,callback){var keyValues=queryString.split("&");keyValues.forEach(function(keyValue){var arr=keyValue.split("=");callback(arr.shift(),arr.join("="))})}function setQuery(parts){var query={};return parts&&iterateQueryString(parts,function(name,value){value=parseParams(value),query[name]?"string"==typeof query[name]?query[name]=[query[name],value]:query[name].push(value):query[name]=value}),query}function serialize(obj){var str=[];for(var p in obj)obj.hasOwnProperty(p)&&str.push(encodeURIComponent(p)+"="+encodeURIComponent(obj[p]));return str.join("&")}function getLocation(params,pattern){return{getQuery:function(){return params.query},getLocation:function(){var fragment=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",isQuery=arguments[1],current=params.root.substring(0,params.root.length-pattern.length),newQuery=void 0;return newQuery=isQuery===!0?serialize(params.query):isQuery===!1?"":serialize(isQuery),current+fragment+(0===newQuery.length?"":"?"+newQuery)}}}function equals(arr1,arr2){if(!arr2)return!1;if(arr1.length!==arr2.length)return!1;for(var i=0,l=arr1.length;l>i;i++)if(arr1[i]instanceof Array&&arr2[i]instanceof Array){if(!equals(arr1[i],arr2[i]))return!1}else if(arr1[i]!==arr2[i])return!1;return!0}function getArgs(func){var oneOf=function(){for(var _len6=arguments.length,patterns=Array(_len6),_key6=0;_len6>_key6;_key6++)patterns[_key6]=arguments[_key6];return function(string,pos){return patterns.map(function(pattern){return string.indexOf(pattern)}).filter(function(index){return index===pos}).length>0}},fnStr=func.toString().replace(STRIP_COMMENTS,""),first=oneOf("(","function (","function(")(fnStr,0)?fnStr.indexOf("(")+1:0,last=oneOf("=>")(fnStr,-1)?fnStr.indexOf(")"):fnStr.indexOf("=>"),argsList=fnStr.slice(first,last).trim(),result=argsList.match(ARGUMENT_NAMES);return null===result?[]:result.map(function(item){return item.replace(/[\s,]/g,"")})}var STRIP_COMMENTS=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,ARGUMENT_NAMES=/(?:^|,)\s*([^\s,=]+)/g;return{serialize:serialize,getLocation:getLocation,equals:equals,setQuery:setQuery,getArgs:getArgs}}),function(root,factory){"function"==typeof define&&define.amd?define("router/MatchBinding",["./utils"],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&(module.exports=factory(require("./utils")))}(void 0,function(utils){var MatchBinding=function(){function MatchBinding(pattern,location,binder){if(_classCallCheck(this,MatchBinding),binder&&(this.binder=binder),""===location)this.pattern=pattern.replace(/^\(\/\)/g,"").replace(/^\/|$/g,"");else{var match=pattern.match(/^(\/|\(\/)/g);null===match&&(pattern="("===pattern[0]?"(/"+pattern.substring(1):"/"+pattern),this.pattern=pattern}var route=this.pattern.replace(MatchBinding.ESCAPE_PARAM,"\\$&").replace(MatchBinding.OPTIONAL_PARAM,"(?:$1)?").replace(MatchBinding.NAMED_PARAM,function(match,optional){return optional?match:"([^/]+)"}).replace(MatchBinding.SPLAT_PARAM,"(.*)");this.patternRegExp=new RegExp("^"+route),this.routeHandler=new Set,this.leaveHandler=new Set,this.queryHandler=new Set,this._active=!1}return _createClass(MatchBinding,[{key:"setRoutes",value:function(mapHandler){var subBinder=this.subBinder;return mapHandler({match:subBinder.match.bind(subBinder)}),this}},{key:"reTrigger",value:function(){this.binder.reTrigger()}},{key:"match",value:function(_match){var subBinder=this.subBinder;return _match(subBinder.match.bind(subBinder)),this}},{key:"to",value:function(routeHandler){return this.routeHandler.add({handler:routeHandler,done:!1}),this.reTrigger(),this}},{key:"leave",value:function(leaveHandler){var args=utils.getArgs(leaveHandler);return this.leaveHandler.add({handler:leaveHandler,done:args.length>0&&"done"===args[0]}),this}},{key:"query",value:function(queryHandler){return this.queryHandler.add({handler:queryHandler,done:!1}),this}},{key:"remove",value:function(){return this.routeHandler.clear(),this.leaveHandler.clear(),this.queryHandler.clear(),this.subBinder.remove(),this}},{key:"test",value:function(location){return this.patternRegExp.test(location)}},{key:"getFragment",value:function(location){var matches=location.match(this.patternRegExp);return null===matches?"":location.substring(matches[0].length)}},{key:"extractParams",value:function(fragment){var params=this.patternRegExp.exec(fragment);return params&¶ms.length>0?params.slice(1).map(function(param){return param?decodeURIComponent(param):null}):[]}},{key:"setSubBinder",value:function(MatchBinder,pattern,mapHandler){var subBinder=new MatchBinder(pattern,this);return this.subBinder=subBinder,"function"==typeof mapHandler&&mapHandler(subBinder.match.bind(subBinder)),subBinder}},{key:"checkSegment",value:function(matched,params){var status=[];if(this._active){var pattern=this.pattern.replace(/\((.*?)\)/g,"$1").replace(/^\//,"").split("/"),prevLoc=this.prevLoc.replace(/^\//,"").split("/"),currSegment=matched.slice(0,pattern.length),prevSegment=prevLoc.slice(0,pattern.length),equals=utils.equals(currSegment,prevSegment);equals?matched.length>1?status=this.subBinder.checkStatus(matched.slice(pattern.length),params):equals&&(status=this.subBinder.clearActive(params)):status=this.clearActive(params)}return status}},{key:"clearActive",value:function(params){var active=[];return this._active&&active.push({handler:this.triggerLeave(params),disable:this.disable.bind(this)}),active.concat(this.subBinder.clearActive())}},{key:"disable",value:function(){this._active=!1}},{key:"triggerTo",value:function(location,params){if(this.test(location)){if(!this._active){this.prevLoc=location;var args=this.extractParams(location).concat(utils.getLocation(params,location));this.applyHandlers(this.routeHandler,args),this._active=!0}this.applyHandlers(this.queryHandler,[utils.getLocation(params,location)]);var fragment=this.getFragment(location);if(""!==fragment.trim()){var subBinder=this.subBinder;subBinder&&subBinder.triggerRoutes(fragment,params)}}}},{key:"applyHandlers",value:function(handlers){var _this10=this,args=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];handlers&&handlers.size>0&&handlers.forEach(function(item){item.handler.apply(_this10,args)})}},{key:"triggerLeave",value:function(params){var _this11=this;return new Promise(function(resolve){var handlers=_this11.leaveHandler,location=utils.getLocation(params,_this11.prevLoc),items=0,stopped=!1;handlers&&handlers.size>0&&handlers.forEach(function(item){item.done&&items++,item.handler(function(){var done=arguments.length>0&&void 0!==arguments[0]?arguments[0]:!0;done?(items--,0!==items||stopped||resolve(!0)):done||stopped||(stopped=!0,resolve(!1))},location)}),0===items&&resolve(!0)})}}]),MatchBinding}();return Object.assign(MatchBinding,{OPTIONAL_PARAM:/\((.*?)\)/g,NAMED_PARAM:/(\(\?)?:\w+/g,SPLAT_PARAM:/\*\w+/g,ESCAPE_PARAM:/[\-{}\[\]+?.,\\\^$|#\s]/g}),MatchBinding}),function(root,factory){"function"==typeof define&&define.amd?define("router/MatchBinder",["./MatchBinding"],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))?module.exports=factory(require("./MatchBinding")):(root.UrlManager=root.UrlManager||{},root.UrlManager.MatchBinder=factory(root.UrlManager.MatchBinding))}(void 0,function(MatchBinding){var MatchBinder=function(){function MatchBinder(location,parent){_classCallCheck(this,MatchBinder),this._parent=parent,this.bindings=new Set,this.location=location||"",this._active=!1}return _createClass(MatchBinder,[{key:"reTrigger",value:function(){this._parent.reTrigger()}},{key:"match",value:function(pattern,mapHandler){return"function"==typeof pattern&&(mapHandler=pattern,pattern=!1),""===pattern&&(pattern=!1),this.getMatchBinding(pattern,mapHandler)}},{key:"getMatchBinding",value:function(pattern,mapHandler){if(pattern){var binding=new MatchBinding(pattern,this.location,this);return binding.setSubBinder(MatchBinder,this.location+(pattern||""),mapHandler),this.bindings.add(binding),binding}return"function"==typeof mapHandler&&mapHandler(this.match.bind(this)),{match:this.match.bind(this)}}},{key:"clearActive",value:function(params,location){var active=[];return this.bindings.size>0&&this.bindings.forEach(function(binding){active=active.concat(binding.clearActive(params,location))}),active}},{key:"checkStatus",value:function(matched,params){var active=[];return this.bindings.size>0&&this.bindings.forEach(function(binding){active=active.concat(binding.checkSegment(matched,params))}),active}},{key:"remove",value:function(){this.bindings.size>0&&this.bindings.forEach(function(binding){return binding.remove()})}},{key:"triggerRoutes",value:function(location,params){this.bindings.size>0&&this.bindings.forEach(function(binding){return binding.triggerTo(location,params)})}}]),MatchBinder}();return MatchBinder}),function(root,factory){"function"==typeof define&&define.amd?define("router/Router",["./MatchBinder","./utils"],factory):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&(module.exports=factory(require("./MatchBinder"),require("./utils")))}(void 0,function(MatchBinder,utils){var Router=function(){function Router(location){_classCallCheck(this,Router),void 0!==location&&""!==location&&(this._location=location.replace(/^\/|\/$/g,"")+"/"),this.root=this.getBinder(),this._listeners=new Set,this._handlers=new Set}return _createClass(Router,[{key:"getBinder",value:function(){return new MatchBinder("",this)}},{key:"test",value:function(loc){return new RegExp("^"+this._location,"g").test(loc)}},{key:"getLocation",value:function(loc){var location=loc.replace(/^\/|$/g,"");return void 0!==this._location?this.test(location)?location.replace(this._location,""):!1:location}},{key:"reTrigger",value:function(){this.currLocation&&this.trigger(this.currLocation)}},{key:"trigger",value:function(location){var _this12=this;if(this.started){this.currLocation=location;var parts=location.split("?",2),segments=this.getLocation(parts[0]);if(segments||""===segments){var query=utils.setQuery(parts[1]),params={root:segments,query:query};this.execute(segments,params).then(function(move){return _this12.setRoutes(move,segments,params)}).then(function(move){return _this12.setLocation(move)})}}}},{key:"execute",value:function(location,params){var _this13=this;return new Promise(function(resolve){var matched=location.replace(/^\/|$/g,"").split("/"),binder=_this13.root,active=binder.checkStatus(matched,params);active.length>0?active.forEach(function(item){item.handler.then(function(applied){item.triggered||(item.triggered=!0,item.applied=applied,active.filter(function(item){return item.applied}).length===active.length?(active.forEach(function(item){return item.disable()}),resolve(!0)):active.filter(function(item){return item.triggered}).length===active.length&&resolve(!1))})}):resolve(!0)})}},{key:"setRoutes",value:function(move,location,params){return move&&(this._handlers.forEach(function(handler){return handler()}),this.root.triggerRoutes(location,params)),move}},{key:"setListener",value:function(listener){var listeners=this._listeners;return listeners.add(listener),{remove:function(){listeners["delete"](listener)}}}},{key:"onRouteChange",value:function(handler){var handlers=this._handlers;return handlers.add(handler),{remove:function(){handlers["delete"](handler)}}}},{key:"setLocation",value:function(move){var location=move?this.currLocation:this.prevLocation;this.prevLocation=location,this._listeners.forEach(function(listener){return listener(location,move)})}},{key:"match",value:function(mapHandler){mapHandler(this.root.match.bind(this.root))}},{key:"start",value:function(){this.started=!0}},{key:"stop",value:function(){this.started=!1}}]),Router}();return Router}),define("widget/App",["./Mediator","router/Router"],function(Mediator,Router){function triggerRoute(router,active){function onHashChange(){var match=window.location.href.match(/#(.*)$/),route=match?match[1]:"";activeLocation!==route&&router.trigger(route)}var activeLocation="";router.setListener(function(location,move){activeLocation=location,move||(window.location.hash=location)}),router.onRouteChange(function(){active.size>0&&(active.forEach(function(handler){return handler()}),active.clear())}),router.start(),window.addEventListener("hashchange",onHashChange,!1),onHashChange()}var App=function(){function App(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,App),this.options=options,this.beforeInit.apply(this,arguments)}return _createClass(App,null,[{key:"extend",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Surrogate=function(_App){function Surrogate(){return _classCallCheck(this,Surrogate),_possibleConstructorReturn(this,(Surrogate.__proto__||Object.getPrototypeOf(Surrogate)).apply(this,arguments))}return _inherits(Surrogate,_App),Surrogate}(App);return Object.assign(Surrogate.prototype,options),Surrogate}}]),_createClass(App,[{key:"beforeInit",value:function(){}},{key:"init",value:function(){}},{key:"setContext",value:function(){return{}}},{key:"start",value:function(container){if(container instanceof HTMLElement!=!0)throw Error("Contaner should be a HTML element");this.el=container,this.context=this.setContext.apply(this,arguments), +void 0!==this.AppContainer&&(this.appContainer=new this.AppContainer),this.init(this.options);var el=document.createElement("div");this.el.appendChild(el),this.appContainer.ready(el),this.appContainer.setContext(this.context),setTimeout(function(){container.classList.add("show")},100)}},{key:"context",set:function(context){var _this15=this,router=new Router(this.options.rootRoute);router.match(function(match){Object.assign(context,{eventBus:new Mediator(_this15.context,function(channel,scope){scope._globalEvents=scope._globalEvents||[],-1===scope._globalEvents.indexOf(channel)&&scope._globalEvents.push(channel)}),active:new Map,match:match,container:_this15.el,_cssReady:context._cssReady||[]}),triggerRoute(router,context.active),_this15._context=context})},get:function(){return this._context}}]),App}();return App}); \ No newline at end of file diff --git a/dist/es6/dev/widget/Constructor.js b/dist/es6/dev/widget/Constructor.js index 8c4b135..59e21c7 100644 --- a/dist/es6/dev/widget/Constructor.js +++ b/dist/es6/dev/widget/Constructor.js @@ -1313,11 +1313,20 @@ define('widget/Constructor',[ this.rendered(...this._arguments); this._rendered = true; } else { - this.root = new dom.Element('
', { + let HTMLelement = document.createElement('div'); + this.root = new dom.Element(HTMLelement, { name: 'root', data: {} }); - this.el = this.root.el; + if (this.el) { + let parent = this.el.parentNode; + if (parent) { + parent.replaceChild(HTMLelement, this.el); + } + } + this.el = HTMLelement; + this.children = {}; + addChildren(this, this.root); this.rendered(...this._arguments); this._rendered = true; diff --git a/dist/es6/prod/widget/App.js b/dist/es6/prod/widget/App.js index da3e166..1c589ca 100644 --- a/dist/es6/prod/widget/App.js +++ b/dist/es6/prod/widget/App.js @@ -1,2 +1,2 @@ -define("templating/utils/List",[],function(){"use strict";class t{constructor(t){this._map=new Map(t),this._indexes=[...this._map.keys()],this._onDelete=[]}keys(){return this._indexes}values(){return this.entries().map(t=>{return t[1]})}entries(){return this._indexes.map(t=>{return[t,this._map.get(t)]})}get(t){return this._map.get(t)}forEach(t){return this.values().forEach((e,n,...i)=>{return t.apply(null,[e,n,...i])})}getIndex(t){return this._indexes.indexOf(t)}changeIndex(t,e){if(t){let n=this._indexes,i=n.indexOf(t);i!==-1&&e!==i&&this._indexes.splice(e,0,this._indexes.splice(i,1)[0])}}getValueByIndex(t){return this._map.get(this._indexes[t])}get first(){return this.getValueByIndex(0)}get last(){return this.getValueByIndex(this._indexes.length-1)}getKeyByIndex(t){return this._indexes[t]}set(t,e,n){this._map.set(t,e),void 0!==n?this._indexes.splice(n,0,t):this._indexes.push(t)}has(t){return this._map.has(t)}clear(){this._map.clear(),this._indexes.splice(0,this._indexes.length)}onDelete(t){let e=(...e)=>t(...e);return this._onDelete.push(e),{remove(){this._onDelete.splice(this._onDelete.indexOf(e,1))}}}delete(t){if(this.has(t)){let e=this._map.get(t);this._map.delete(t),this._indexes.splice(this._indexes.indexOf(t),1),this._onDelete.forEach(n=>n(t,this.size,e))}}deleteByIndex(t){this.delete(this._indexes[t])}get size(){return this._map.size}}return t}),define("templating/dom",[],function(){"use strict";function t(t){var e=typeof t;return"function"===e||"object"===e&&!!t}function e(t){var e=document.createElement(t||"div");return e.setAttribute("style","display:none;"),e}function n(t){let e=Object.keys(t);e.length>0&&e.forEach(e=>{if("root"!==e){let n=t[e];void 0!==n.elGroup&&n.elGroup.size>0&&n.elGroup.forEach(t=>{void 0!==t&&void 0!==t.remove&&t.remove(!0)})}})}class i{constructor(t,e){this.el=t,this._events=[],this.name=e.name||e.data.name;let n=this.data=e.data;n&&n.bind&&(this.bind=n.bind)}clone(...t){return this.run(...t)}text(t){r.text(this,t)}detach(){r.detach(this)}attach(){r.attach(this)}changePosition(t){r.changePosition(this,t)}setAttribute(t,e){r.setAttribute(this,t,e)}getAttribute(t){return r.getAttribute(this,t)}removeAttribute(t){r.removeAttribute(this,t)}setStyle(t,e){r.setStyle(this,t,e)}getStyle(t){return r.getStyle(this,t)}removeStyle(t){r.removeStyle(this,t)}addClass(t){r.addClass(this,t)}hasClass(t){return r.hasClass(this,t)}removeClass(t){r.removeClass(this,t)}val(t){return r.val(this,t)}on(t,e,n){var i=Array.prototype.slice.call(arguments,0);return r.on.apply(!1,[this].concat(i))}onDOMAttached(){return r.onDOMAttached(this)}remove(t){r.remove(this,t)}}var r={detach(t){t.placeholder instanceof HTMLElement==!1&&(t.placeholder=e(t.data.tag||t.el.tagName)),t&&t.el&&t.el.parentNode&&t.el.parentNode.replaceChild(t.placeholder,t.el)},attach(t){t&&t.el&&t.placeholder&&t.placeholder.parentNode&&t.placeholder.parentNode.replaceChild(t.el,t.placeholder)},append(t,e){void 0!==t.el&&void 0!==e.el&&t.el.appendChild(e.el)},prepend(t,e){r.insertBefore(t,e,0)},insertBefore(t,e,n){let i=t.el,r=e.el;void 0!==i&&void 0!==r&&(void 0!==i.childNodes[n]?i.insertBefore(r,i.childNodes[n]):i.appendChild(r))},changePosition(t,e){let n=t.el;if(n&&n.parentNode){let i=n.parentNode,r=t.elGroup,o=r.size,s=r.getKeyByIndex(e)||r.getLast();s!==n&&(o-1>=e?i.insertBefore(n,s):null!==s.nextSibling?i.insertBefore(n,s.nextSibling):i.appendChild(n),t.elGroup.changeIndex(n,e))}},text(t,e){t&&t.el&&(t.el.innerHTML=e)},setAttribute(e,n,i){e&&e.el&&(t(n)?Object.keys(n).forEach(t=>{e.el.setAttribute(t,n[t])}):e.el.setAttribute(n,i))},getAttribute(t,e){return t&&t.el?t.el.getAttribute(e):void 0},removeAttribute(t,e){t&&t.el&&t.el.removeAttribute(e)},setStyle(e,n,i){e&&e.el&&(t(n)?Object.keys(n).forEach(t=>{e.el.style[t]=n[t]}):e.el.style[n]=i)},getStyle(t,e){if(t&&t.el)return void 0!==t.el&&void 0!==t.el.style?t.el.style[e]:void 0},removeStyle(t,e){t&&t.el&&(t.el.style[e]="")},addClass(t,e){t&&t.el&&t.el.classList.add(e)},hasClass(t,e){return!(!t||!t.el)&&t.el.classList.contains(e)},removeClass(t,e){t&&t.el&&t.el.classList.remove(e)},val(t,e){if(t&&t.el){var n=t.el;if(void 0===e)return n.value;n.value=e}},on(t,e,n,i,...r){var o=t.el,s=e.split(" "),c=e=>{n.apply(i||this,[e,t].concat(r))};s.forEach(t=>{o.addEventListener(t,c)});var a={remove:()=>{s.forEach(t=>o.removeEventListener(t,c));let e=t._events;e.splice(e.indexOf(a),1)}};return t._events.push(a),a},remove(t){for(;t._events.length>0;)t._events.shift().remove();t.children&&n(t.children),void 0!==t.elGroup&&t.elGroup.delete(t.el),void 0!==t.el&&(t.el.remove?t.el.remove():t.el.parentNode&&t.el.parentNode.removeChild(t.el),delete t.el)},onDOMAttached(t){let e,n=[],i=!1;return void 0!==t.el&&(e=(()=>{if(i)for(;n.length>0;)n.shift()();else window.requestAnimationFrame(e),document.body.contains(t.el)&&(i=!0)})),{then:(t,i)=>{n.push(t.bind(i||this)),window.requestAnimationFrame(e)}}},Element:i};return r}),function(t,e){"function"==typeof define&&define.amd?define("templating/DomFragment",e):"object"==typeof exports&&(module.exports=e())}(0,function(){"use strict";function t(t){var e=document.createElement(t||"div");return e.setAttribute("style","display:none;"),e}class e{constructor(t,e,n,i,r,o){return Object.assign(this,{_node:t,placeholder:e,childNodes:n,elGroup:i,index:r,obj:o}),this.render()}applyAttributes(t){let e=this._node.data.attribs;Object.keys(e).forEach(function(n){t.setAttribute(n,e[n])})}applyFragment(t){let e=this._node,n=e.template();if(n)for(;n.childNodes.length>0;)t.appendChild(n.childNodes[0])}appendToBody(t){let e=this.elGroup,n=this.placeholder,i=e.size;if(i>0){let n=void 0===this.index||this.index>i-1?i-1:this.index-1,r=e.keys()[n!==-1?n:0],o=r.parentNode;n===-1?o.insertBefore(t,r):null!==r.nextSibling?o.insertBefore(t,r.nextSibling):o.appendChild(t)}else{let e=n.parentNode;e&&e.replaceChild(t,n)}}render(){let e=this.placeholder,n=this._node,i=!e.id&&0===this.elGroup.size,r=n.tmpEl(!!i&&e,this.obj,this.childNodes,n),o=r.el||t(n.data.tag);return i||n.replace?n.replace||(o.innerHTML=""):this.applyAttributes(o),n.replace||this.applyFragment(o),this.appendToBody(o),r.ready&&r.ready(o),r}}return e}),function(t,e){"function"==typeof define&&define.amd?define("templating/Decoder",["./utils/List","./dom","./DomFragment"],e):"object"==typeof exports&&(module.exports=e(require("./utils/List"),require("./dom"),require("./DomFragment")))}(0,function(t,e,n){"use strict";function i(t){return t===Object(t)}function r(t){return Array.isArray?Array.isArray(t):"[object Array]"===toString.call(t)}var o={};class s{static addDecoder(t){void 0===o[t.tagName]&&(o[t.tagName]=t)}constructor(t){this._root="string"==typeof t?JSON.parse(t):t,t.children&&t.children.length>0&&(this.children=this._parseElements(t.children))}renderFragment(t,e){let n=document.createElement("template");return void 0===n.content&&("td"===e?n=document.createElement("tr"):"tr"===e&&(n=document.createElement("tbody"))),n.innerHTML=t,void 0!==n.content?n.content.firstChild:n.firstChild}_parseElements(t){var e={};return t.forEach(t=>{let n=t.data.name;var i=t.tagName;if(i){let r=o[i].decode(t);if(r){let s={name:r.name,data:r.data,tmpEl:r.tmpEl,parse:r.parse,replace:r.replace,id:t.id,template:()=>{return this.renderFragment(t.template,t.data.tag)},noAttach:o[i].noAttach||t.data.tplSet.noattach};t.children&&t.children.length>0&&(s.children=this._parseElements(t.children)),e[n]=s}}else n&&(e[n]={id:t.id,data:t.data,name:n})}),e}renderTemplate(o={},s={},c){let a={},u=[];Object.keys(o).forEach(h=>{let l=c,d=o[h],f=d.children,p=new t,g=document.createElement(d.data.tplSet.tag||"div");if(g.setAttribute("style","display:none;"),g.id=d.id,p.onDelete((t,e)=>{0===e&&t.parentNode&&(t.parentNode.replaceChild(g,t),l=(()=>g))}),d.template){let t=(e,o)=>{let c=l();e instanceof HTMLElement==!0&&(c=e);let a,u=c!==e&&(i(e)||r(e))?e:s;if(!d.noAttach||e){let e=c.querySelector("#"+d.id)||c;f&&(a=this.renderTemplate(f,u,()=>{return c}));let i=new n(d,e,a,p,o,u);return c=i.el,a&&a.runAll&&d.parse&&a.runAll(),a&&!i.children&&(i.children=a),i.elGroup=p,i.run=t,p.set(i.el,i,o),i}};u.push(t),a[h]={data:d.data,run:t,elGroup:p}}else{let t=new e.Element(l().querySelector("#"+d.id),d);t.removeAttribute("id"),t.elGroup=p,p.set(t.el,t),a[h]=t}});let h=(t,e,n)=>{Object.defineProperty(t,e,{enumerable:!1,value:n})},l=t=>{return u.forEach(e=>e(t)),a};return h(a,"runAll",l),a}render(t){var e=this.renderFragment(this._root.template);return{fragment:e,children:this.renderTemplate(this.children,t,()=>e).runAll(),templateId:this._root.templateId}}}return s}),function(t,e){"function"==typeof define&&define.amd?define("coders/component/cpDecoder",["templating/Decoder"],e):"object"==typeof exports&&(module.exports=e(require("./Decoder")))}(0,function(t){"use strict";var e={tagName:"cp",decode:function(t){var e=t.data,n={name:e.name,replace:!0,tmpEl:function(t,n,i,r){return new e.src(e.dataset,i,n,r)},data:e||{}};return void 0!==e.dataset.bind&&(n.bind=e.dataset.bind),n}};return t&&t.addDecoder(e),e}),function(t,e){"function"==typeof define&&define.amd?define("coders/placeholders/plDecoder",["templating/Decoder","templating/dom"],e):"object"==typeof exports&&(module.exports=e(require("./Decoder"),require("./dom")))}(0,function(t,e){"use strict";var n={tagName:"pl",decode:function(t){var n=t.data;return{name:n.name,tmpEl:function(t,i,r,o){return new e.Element(t||document.createElement(n.tag),o)},parse:!0,data:n}}};return t&&t.addDecoder(n),n}),function(t,e){"function"==typeof define&&define.amd?define("coders/databind/bdDecoder",["templating/Decoder","templating/dom"],e):"object"==typeof exports&&(module.exports=e(require("./Decoder"),require("./dom")))}(0,function(t,e){"use strict";var n={tagName:"bd",noAttach:!0,decode:function(t){var n=this.data=t.data;return{name:n.name,tmpEl:function(t,i,r,o){return new e.Element(t||document.createElement(n.tag),o)},data:n}}};return t&&t.addDecoder(n),n}),function(t,e){"function"==typeof define&&define.amd?define("coders/router/routerDecoder",["templating/Decoder","templating/dom"],e):"object"==typeof exports&&(module.exports=e(require("./Decoder"),require("./dom")))}(0,function(t,e){"use strict";var n={tagName:"rt",noAttach:!0,decode:function(t){var n=t.data;return{name:n.name,tmpEl:function(t,i,r,o){return new e.Element(t||document.createElement(n.tag),o)},parse:!0,data:n||{}}}};return t&&t.addDecoder(n),n}),function(t,e){"function"==typeof define&&define.amd?define("coders/style/styleDecoder",["templating/Decoder"],e):"object"==typeof exports&&(module.exports=e(require("./Decoder")))}(0,function(t){"use strict";var e={tagName:"style",decode:function(t){if(void 0===t.data.styleAttached){t.data.styleAttached=!0;let e=t.data.style,n=t=>{let e=document.createElement("style");e.innerHTML=t,document.head.appendChild(e)};"string"==typeof e?n(e):e.then(n)}}};return t&&t.addDecoder(e),e}),function(t){"object"==typeof exports?module.exports=t():"function"==typeof define&&define.amd?define("watch",t):(window.WatchJS=t(),window.watch=window.WatchJS.watch,window.unwatch=window.WatchJS.unwatch,window.callWatchers=window.WatchJS.callWatchers)}(function(){var t={noMore:!1},e=[],n=function(t){var e={};return t&&"[object Function]"==e.toString.call(t)},i=function(t){return"[object Array]"===Object.prototype.toString.call(t)},r=function(t,e){var n=[],r=[];if("string"!=typeof t&&"string"!=typeof e){if(i(t))for(var o=0;o0)&&u(t[e],r,void 0!==o?o-1:o),g(t,e,r,o),s&&(void 0===o||o>0)&&w(t,e,r,o)))},d=function(){n(arguments[1])?f.apply(this,arguments):i(arguments[1])?p.apply(this,arguments):_.apply(this,arguments)},f=function(t,e){if(!(t instanceof String)&&(t instanceof Object||i(t)))if(i(t)){for(var n=[],r=0;rt.elOnChange[e.name].call(t,e,n))}function n(t,e,n){void 0!==t.elReady[e.name]&&t.elReady[e.name].call(t,e,n)}function i(t,e,n){var i=t.events[e.name];void 0!==i&&void 0!==e.el&&"cp"!==e.data.type&&i.forEach(i=>{t._events.push(e.on(i.name,i.action,t,n))})}return Object.assign(t,{elOnChange:e,elReady:n,applyEvents:i}),t}),define("widget/parsers/applyAttribute",["watch","./addChildren"],function(t,e){function n(t,n,r){var o=n.data.tplSet.bind,s=n.data.tplSet.update;o&&Object.keys(o).forEach(c=>{let a=o[c],u=r[a];switch(c){case"class":let t=t=>{return void 0!==t&&""!==t&&(n.addClass(t),t)},e=t(u);s===!0&&i(r,a,()=>{e&&n.removeClass(e),e=t(r[a])});break;case"checked":void 0!==u&&(n.el.checked=u),s===!0&&i(r,a,()=>n.el.checked=r[a]);break;case"value":void 0!==u&&(n.el.value=u),s===!0&&i(r,a,()=>n.el.value=r[a]);break;case"required":void 0!==u&&(n.el.required=u),s===!0&&i(r,a,()=>n.el.required=r[a]);break;case"text":void 0!==u&&n.text(u),s===!0&&i(r,a,()=>n.text(r[a]));break;default:void 0!==u&&n.setAttribute(c,u),s===!0&&i(r,a,()=>n.setAttribute(c,r[a]))}if(void 0!==r.text&&"text"!==c&&(n.text(r.text),s===!0&&"text"!==c&&i(r,"text",()=>n.text(r.text))),s===!0){let o=e.elOnChange(t,n);o&&i(r,a,()=>o(r))}})}var i=t.watch;return n}),define("widget/parsers/applyParent",["templating/dom","./addChildren"],function(t,e){function n(n,i={},r={}){if(n){let o=n.children;o&&Object.keys(o).forEach(s=>{let c=!0,a=o[s],u=i[s];void 0!==u?void 0!==n.nodes[s]?n.nodes[s].call(n,a,u,r):void 0!==a&&("string"==typeof u?t.text(a,u):a=u.run(a.el)):void 0!==n.nodes[s]&&a.data.tplSet.noattach&&(n.nodes[s].call(n,a,r),c=!1),c&&a.elGroup.size>0&&e(n,a,r)})}}return n}),define("widget/utils",[],function(){function t(t){var e=typeof t;if(!("function"===e||"object"===e&&t))return t;for(var n,i,r=1,o=arguments.length;r{let r=t[i];r&&r.data&&void 0!==r.data.bind&&"cp"!==r.data.type?(n[r.data.bind]=n[r.data.bind]||[],n[r.data.bind].push(r)):e||"cp"!==r.data.type||n.__cp__.push(r)}),n}return t}),define("widget/parsers/applyBinders",["templating/dom","../utils","watch","./setBinders","./addChildren","./applyAttribute"],function(t,e,n,i,r,o){function s(t,n,s,u){if(void 0!==u){var h=s[n];if(t.nodes[n])t.nodes[n].call(t,u,h);else if(e.isArray(h)||e.isObject(h)){if(e.isArray(h)){let l=[],d=(n,s)=>{let a=!1;e.isArray(n)||e.isObject(n)||(a=!0);let h=u.run(!0,s);a&&h.text(n),l.push({binder:h,data:n}),o(t,h,n),r.applyEvents(t,h,n),r.elReady(t,h,n);let d=r.elOnChange(t,h);d&&d(n),h.children&&(h.bindings=i(h.children),c(t,n,h))};h.forEach(d);let f=u.data.tplSet.update;if(f){let t=["pop","shift","splice"],e=["push","unshift"],i=["reverse","sort"];a(s,n,(r,o,c,a)=>{let u=l.slice(0);if(void 0===a&&e.indexOf(o)!==-1){let t=u.filter(t=>t.data===c[0]);0===t.length&&d(c[0],"unshift"===o?0:u.length)}else if(t.indexOf(o)!==-1){if(u.forEach(t=>{s[n].indexOf(t.data)===-1&&(t.binder.remove(),l.splice(l.indexOf(t),1))}),"splice"===o){let t=Array.prototype.slice.call(c,2);t&&t.length>0&&t.forEach(t=>{let e=s[n].indexOf(t);e!==-1&&d(t,e)})}}else i.indexOf(o)!==-1&&h.forEach((t,e)=>{let n=u.filter(e=>e.data===t)[0];l.splice(e,0,l.splice(l.indexOf(n),1)[0]),n.binder.changePosition(e)})})}}else if(e.isObject(h)){let e=u.run(h);if("cp"!==e.data.type){o(t,e,h),r.applyEvents(t,e,h),r.elReady(t,e,h);let n=r.elOnChange(t,e);n&&n(h),e.children&&(e.bindings=i(e.children),c(t,h,e))}}}else{let e=u.run(!0);e.text(h),r.applyEvents(t,e,h),r.elReady(t,e,h);let i=r.elOnChange(t,e);i&&i(h),e.data.tplSet.update&&a(s,n,()=>{e.text(s[n]);let i=r.elOnChange(t,e);i&&i(s[n])})}}}function c(t,e,n){let i=n.bindings;if(i){i.__cp__.length>0&&i.__cp__.forEach(n=>{let i=n.run(e);i.setContext(t.context),r.elReady(t,i,e);let o=r.elOnChange(t,i);o&&o(e)});let n=Object.keys(i);e&&n.length>0&&n.forEach(n=>{if(void 0!==e[n])i[n].forEach(i=>s(t,n,e,i));else{let r=(o,c,a,h)=>{void 0!==a&&void 0===h&&(i[n].forEach(i=>s(t,n,e,i)),u(e,n,r))};a(e,n,r,0)}})}}var a=n.watch,u=n.unwatch;return c}),define("widget/parsers/setRoutes",["templating/dom"],function(t){function e(t){let e=t.toString().replace(c,""),n=e.slice(e.indexOf("(")+1,e.indexOf(")")),i=n.match(a);return null===i?[]:i.map(t=>t.replace(/[\s,]/g,""))}function n(t){void 0!==t.remove&&t.remove()}function i(t,e){void 0!==t&&Object.keys(t).forEach(n=>{let i=t[n];r(i,e)||e(i)})}function r(t,e){return!!(t.elGroup&&t.elGroup.size>0)&&(t.elGroup.forEach(t=>{e(t)}),!0)}function o(s,c){if(s.setContext)s.setContext(c);else{let a=void 0!==s.data?s.data.route:void 0;if(void 0!==a&&"rt"===s.data.type){let u,h=c.match,l=c.active,d=h(a);d.to((...e)=>{let n=e.pop();if(u=e.length>0?n.getLocation()+"_"+e.join("_"):void 0,!r(s,e=>t.attach(e))){let t=s.run(!0);i(t.children,t=>{t&&h(a,e=>o(t,Object.assign({},c,{match:e,active:l})))})}r(s,t=>{i(t.children,t=>{t&&t.to&&t.to(...e.concat(n))})})}),d.leave(done=>{let o=0,c=!1;r(s,r=>{let s=()=>{u?n(r):t.detach(r)},a=(t=!0)=>{t?o--:(c=!0,done(!1)),0!==o||c||(l.set(r,s),done(!0))};i(r.children,t=>{if(t&&void 0!==t.leave){let n=e(t.leave);n.length>0&&o++,t.leave(a)}}),0===o&&(l.set(r,s),done(!0))})}),d.query(t=>{r(s,e=>{i(e.children,e=>{e&&void 0!==e.query&&e.query(t)})})}),r(s,t=>t._activeRoute=d)}else void 0!==s.children&&["cp"].indexOf(s.data.type)===-1&&i(s.children,t=>o(t,c))}}function s(t,e){i(t,t=>o(t,e))}const c=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,a=/(?:^|,)\s*([^\s,=]+)/g;return s}),define("widget/parsers/applyElement",["templating/dom"],function(t){function e(e={},n){let i={};return Object.keys(e).forEach(r=>{let o=e[r];if("string"!=typeof o){let e=o.elGroup.first;if(e){if(i[r]=e,e instanceof t.Element==!0&&["pl"].indexOf(e.data.type)!==-1){let t=e.data.tplSet.bind;t&&Object.keys(t).forEach(i=>{void 0!==n[t[i]]&&("class"!==i?e.setAttribute(i,n[t[i]]):e.addClass(n[t[i]]))})}}else i[r]=o}}),i}return e}),define("widget/Constructor",["require","templating/Decoder","templating/dom","./Mediator","./parsers/applyAttribute","./parsers/applyParent","./parsers/applyBinders","./parsers/setBinders","./parsers/setRoutes","./parsers/applyElement","./parsers/addChildren"],function(t,e,n,i,r,o,s,c,a,u,h){"use strict";function l(t){let e=Object.keys(t);e.length>0&&e.forEach(e=>{if("root"!==e){let n=t[e];void 0!==n.elGroup&&n.elGroup.size>0&&n.elGroup.forEach(t=>{void 0!==t&&void 0!==t.remove&&t.remove(!0)})}})}class d{static extend(t={}){class e extends d{}return Object.assign(e.prototype,t),e}constructor(t={},e,n={},r){this.instance=this,this._events=[],this._globalEvents=[],this._parentChildren=e,this._options=t,this._rendered=!1,this._arguments=Array.from(arguments),this._dataSet=n,this.eventBus=new i(this),void 0!==r&&void 0!==r.name&&(this.name=r.name),this.beforeInit(...this._arguments)}ready(t){this.el=t}setContext(t){this.context||(this.context=t,this.async||this.render(),this.init(...this._arguments))}set context(t){if(!this.data){let e=this._dataSet?Object.keys(this._dataSet):[],n=e.length>0?this._dataSet:t.data;n&&(this.data=n[this._options.bind]||n)}t.match(e=>{this.match&&this.match(e),this._context=Object.assign({match:e},t)})}get context(){return this._context}render(t){if(!this._rendered)if(this.template){t&&(this.data=t);let i=this._options,r=this._parentChildren,s=new e(this.template),l=s.render(this.data);if(this.el){let t=this.el.parentNode;t&&t.replaceChild(l.fragment,this.el),this.elGroup&&this.elGroup.get(this.el)&&(this.elGroup.delete(this.el),this.el=l.fragment,this.elGroup.set(l.fragment,this))}else this.el=l.fragment;this.root=new n.Element(l.fragment,{name:"root",data:{}}),this.children=u(l.children,i),o(this,r,this.data),this.bindings=c(this.children,!0),this.data&&this.applyBinders(this.data,this),a(this.children,this.context),h(this,this.root),this.rendered(...this._arguments),this._rendered=!0}else this.root=new n.Element("
",{name:"root",data:{}}),this.el=this.root.el,this.rendered(...this._arguments),this._rendered=!0}beforeInit(t,e,n){}init(t,e,n){}rendered(t,e,n){}loadCss(t){if(this.context._cssReady.indexOf(t)===-1){this.context._cssReady.push(t);let e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),e.setAttribute("href",t),void 0!==e&&document.getElementsByTagName("head")[0].appendChild(e)}}detach(){this._placeholder||(this._placeholder=document.createElement(this.el.tagName)),this._parent||(this._parent=this.el.parentNode),this.el&&this._parent&&this._parent.replaceChild(this._placeholder,this.el)}attach(){this._placeholder&&this._parent&&this._parent.replaceChild(this.el,this._placeholder)}onDestroy(){}destroy(){for(this.onDestroy(),this.eventBus.clear();this._events.length>0;)this._events.shift().remove();for(;this._globalEvents.length>0;)this._globalEvents.shift().remove();l(this.children),void 0!==this.elGroup&&void 0!==this.el&&this.elGroup.delete(this.el),this.root&&this.root.remove&&this.root.remove(),delete this.el}remove(...t){this.destroy(...t)}setChildren(t,e){let n=t.data.name,i=this.children[n];void 0!==i&&void 0!==i.el&&i.remove();let r=t.run(e||!0);return r.setContext&&r.setContext(this.context),h(this,r,e),r}addComponent(t,e){let n=e.name,i=e.container;if(void 0===n)throw"you have to define data.name for component.";if(void 0===i)throw"You have to define container for component.";if(void 0!==this.children[n])throw"Component using name:"+n+"! already defined.";let r=this.setComponent(t,e),o=r.run(e.container);return o.setContext(this.context),this.children[n]=o,o}setComponent(t,e){return{name:e.name,data:{tag:"div",type:"cp"},run:i=>{e.appContext=this.context;let r=new t(e,e.children,e.data),o=document.createElement("div");return o.setAttribute("style","display:none;"),r.ready(o),i instanceof HTMLElement==!0?i.parentNode.replaceChild(r.el,i):void 0!==i.el&&void 0!==e.pos?n.insertBefore(i,r,e.pos):void 0!==i.el&&n.append(i,r),r}}}applyBinders(...t){return s(this,...t)}}return Object.assign(d.prototype,{nodes:{},events:{},elReady:{},elOnChange:{}}),d}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("widget/Mediator",[],function(){return e()}):"undefined"!=typeof exports?exports.Mediator=e():t.Mediator=e()}(this,function(){"use strict";class t{constructor(t,e,n={},i=null){this.fn=t,this.channel=i,this.context=n,this.options=e}update(t={}){Object.assign(this,t),this.channel&&this.setPriority(this.priority)}set options(t){this.update(t)}set context(t){this.setHook(t),this._context=t}get context(){return this._context}setHook(t){let e=this.channel;e&&e.hook(this,t)}_reduceCalls(){void 0!==this.calls&&--this.calls<1&&this.remove()}remove(){let t=this.channel;t&&t.removeSubscriber(this)}setPriority(t){let e=this.channel;e&&e.setPriority(this,t)}run(t){this.channel.stopped||"function"==typeof this.predicate&&!this.predicate.apply(this.context,t)||(this._reduceCalls(),this.fn.apply(this.context,t))}}class e{constructor(t,e,n,i){this.namespace=t||"",this._subscribers=[],this._channels=new Map,this._parent=e,this.stopped=!1,this.context=n,this.hook=i}addSubscriber(e,n,i=this.context){return new t(e,n,i,this)}stopPropagation(){this.stopped=!0}setPriority(t,e){let n=this._subscribers;n.indexOf(t)!==-1&&n.splice(n.indexOf(t),1),void 0!==e&&e0){let n=t.shift(),i=this.setChannel(n,e);return i&&t.length>0?i.returnChannel(t,e):i}}removeSubscriber(t){let e=this._subscribers,n=e.indexOf(t);t?n!==-1&&e.splice(n,1):e.splice(0,e.length),0===this._subscribers.length&&this._parent&&this._parent.removeChannel(this)}removeChannel(t){t===this.getChannel(t.namespace)&&this._channels.delete(t.namespace)}clear(){this._channels.forEach(t=>t.clear()),this.removeSubscriber()}publish(t){this._subscribers.slice().forEach(e=>e.run(t)),this._parent&&this._parent.publish(t),this.stopped=!1}}class n{constructor(t={},i=(()=>{})){if(!(this instanceof n))return new n(t,i);this.channel=new e("",!1,t,i)}getChannel(t,e){let n=t.split(":");if(n.length>0)return this.channel.returnChannel(n,e)}subscribe(t,e,n={},i){if(t&&""!==t){let r=this.getChannel(t,!1);return r.addSubscriber(e,n,i)}throw Error("Namespace should be provided!")}once(t,e,n={},i){return n.calls=1,this.subscribe(t,e,n,i)}publish(t,...e){if(t&&""!==t){let n=this.getChannel(t,!0);n&&n.namespace===t&&(e.push(n),n.publish(e))}}clear(){this.channel.clear()}}return n.prototype.on=n.prototype.subscribe,n.prototype.trigger=n.prototype.publish,n.version="0.9.9",n}),function(t,e){"function"==typeof define&&define.amd?define("router/utils",[],e):"object"==typeof exports&&(module.exports=e())}(0,function(){"use strict";function t(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}}function e(t,e){t.split("&").forEach(t=>{let n=t.split("=");e(n.shift(),n.join("="))})}function n(n){let i={};return n&&e(n,(e,n)=>{n=t(n),i[e]?"string"==typeof i[e]?i[e]=[i[e],n]:i[e].push(n):i[e]=n}),i}function i(t){let e=[];for(let n in t)t.hasOwnProperty(n)&&e.push(encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e.join("&")}function r(t,e){return{getQuery(){return t.query},getLocation(n="",r){let o,s=t.root.substring(0,t.root.length-e.length);return o=r===!0?i(t.query):r===!1?"":i(r),s+n+(0===o.length?"":"?"+o)}}}function o(t,e){if(!e)return!1;if(t.length!==e.length)return!1;for(let n=0,i=t.length;n(e,n)=>t.map(t=>e.indexOf(t)).filter(t=>t===n).length>0,n=t.toString().replace(c,""),i=e("(","function (","function(")(n,0)?n.indexOf("(")+1:0,r=e("=>")(n,-1)?n.indexOf(")"):n.indexOf("=>"),o=n.slice(i,r).trim(),s=o.match(a);return null===s?[]:s.map(t=>t.replace(/[\s,]/g,""))}const c=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,a=/(?:^|,)\s*([^\s,=]+)/g;return{serialize:i,getLocation:r,equals:o,setQuery:n,getArgs:s}}),function(t,e){"function"==typeof define&&define.amd?define("router/MatchBinding",["./utils"],e):"object"==typeof exports&&(module.exports=e(require("./utils")))}(0,function(t){"use strict";class e{constructor(t,n,i){if(i&&(this.binder=i),""===n)this.pattern=t.replace(/^\(\/\)/g,"").replace(/^\/|$/g,"");else{let e=t.match(/^(\/|\(\/)/g);null===e&&(t="("===t[0]?"(/"+t.substring(1):"/"+t),this.pattern=t}let r=this.pattern.replace(e.ESCAPE_PARAM,"\\$&").replace(e.OPTIONAL_PARAM,"(?:$1)?").replace(e.NAMED_PARAM,function(t,e){return e?t:"([^/]+)"}).replace(e.SPLAT_PARAM,"(.*)");this.patternRegExp=new RegExp("^"+r),this.routeHandler=new Set,this.leaveHandler=new Set,this.queryHandler=new Set,this._active=!1}setRoutes(t){var e=this.subBinder;return t({match:e.match.bind(e)}),this}reTrigger(){this.binder.reTrigger()}match(t){var e=this.subBinder;return t(e.match.bind(e)),this}to(t){return this.routeHandler.add({handler:t,done:!1}),this.reTrigger(),this}leave(e){var n=t.getArgs(e);return this.leaveHandler.add({handler:e,done:n.length>0&&"done"===n[0]}),this}query(t){return this.queryHandler.add({handler:t,done:!1}),this}remove(){return this.routeHandler.clear(),this.leaveHandler.clear(),this.queryHandler.clear(),this.subBinder.remove(),this}test(t){return this.patternRegExp.test(t)}getFragment(t){let e=t.match(this.patternRegExp);return null===e?"":t.substring(e[0].length)}extractParams(t){let e=this.patternRegExp.exec(t);return e&&e.length>0?e.slice(1).map(function(t){return t?decodeURIComponent(t):null}):[]}setSubBinder(t,e,n){let i=new t(e,this);return this.subBinder=i,"function"==typeof n&&n(i.match.bind(i)),i}checkSegment(e,n){let i=[];if(this._active){ +define("templating/utils/List",[],function(){"use strict";class t{constructor(t){this._map=new Map(t),this._indexes=[...this._map.keys()],this._onDelete=[]}keys(){return this._indexes}values(){return this.entries().map(t=>{return t[1]})}entries(){return this._indexes.map(t=>{return[t,this._map.get(t)]})}get(t){return this._map.get(t)}forEach(t){return this.values().forEach((e,n,...i)=>{return t.apply(null,[e,n,...i])})}getIndex(t){return this._indexes.indexOf(t)}changeIndex(t,e){if(t){let n=this._indexes,i=n.indexOf(t);i!==-1&&e!==i&&this._indexes.splice(e,0,this._indexes.splice(i,1)[0])}}getValueByIndex(t){return this._map.get(this._indexes[t])}get first(){return this.getValueByIndex(0)}get last(){return this.getValueByIndex(this._indexes.length-1)}getKeyByIndex(t){return this._indexes[t]}set(t,e,n){this._map.set(t,e),void 0!==n?this._indexes.splice(n,0,t):this._indexes.push(t)}has(t){return this._map.has(t)}clear(){this._map.clear(),this._indexes.splice(0,this._indexes.length)}onDelete(t){let e=(...e)=>t(...e);return this._onDelete.push(e),{remove(){this._onDelete.splice(this._onDelete.indexOf(e,1))}}}delete(t){if(this.has(t)){let e=this._map.get(t);this._map.delete(t),this._indexes.splice(this._indexes.indexOf(t),1),this._onDelete.forEach(n=>n(t,this.size,e))}}deleteByIndex(t){this.delete(this._indexes[t])}get size(){return this._map.size}}return t}),define("templating/dom",[],function(){"use strict";function t(t){var e=typeof t;return"function"===e||"object"===e&&!!t}function e(t){var e=document.createElement(t||"div");return e.setAttribute("style","display:none;"),e}function n(t){let e=Object.keys(t);e.length>0&&e.forEach(e=>{if("root"!==e){let n=t[e];void 0!==n.elGroup&&n.elGroup.size>0&&n.elGroup.forEach(t=>{void 0!==t&&void 0!==t.remove&&t.remove(!0)})}})}class i{constructor(t,e){this.el=t,this._events=[],this.name=e.name||e.data.name;let n=this.data=e.data;n&&n.bind&&(this.bind=n.bind)}clone(...t){return this.run(...t)}text(t){r.text(this,t)}detach(){r.detach(this)}attach(){r.attach(this)}changePosition(t){r.changePosition(this,t)}setAttribute(t,e){r.setAttribute(this,t,e)}getAttribute(t){return r.getAttribute(this,t)}removeAttribute(t){r.removeAttribute(this,t)}setStyle(t,e){r.setStyle(this,t,e)}getStyle(t){return r.getStyle(this,t)}removeStyle(t){r.removeStyle(this,t)}addClass(t){r.addClass(this,t)}hasClass(t){return r.hasClass(this,t)}removeClass(t){r.removeClass(this,t)}val(t){return r.val(this,t)}on(t,e,n){var i=Array.prototype.slice.call(arguments,0);return r.on.apply(!1,[this].concat(i))}onDOMAttached(){return r.onDOMAttached(this)}remove(t){r.remove(this,t)}}var r={detach(t){t.placeholder instanceof HTMLElement==!1&&(t.placeholder=e(t.data.tag||t.el.tagName)),t&&t.el&&t.el.parentNode&&t.el.parentNode.replaceChild(t.placeholder,t.el)},attach(t){t&&t.el&&t.placeholder&&t.placeholder.parentNode&&t.placeholder.parentNode.replaceChild(t.el,t.placeholder)},append(t,e){void 0!==t.el&&void 0!==e.el&&t.el.appendChild(e.el)},prepend(t,e){r.insertBefore(t,e,0)},insertBefore(t,e,n){let i=t.el,r=e.el;void 0!==i&&void 0!==r&&(void 0!==i.childNodes[n]?i.insertBefore(r,i.childNodes[n]):i.appendChild(r))},changePosition(t,e){let n=t.el;if(n&&n.parentNode){let i=n.parentNode,r=t.elGroup,o=r.size,s=r.getKeyByIndex(e)||r.getLast();s!==n&&(o-1>=e?i.insertBefore(n,s):null!==s.nextSibling?i.insertBefore(n,s.nextSibling):i.appendChild(n),t.elGroup.changeIndex(n,e))}},text(t,e){t&&t.el&&(t.el.innerHTML=e)},setAttribute(e,n,i){e&&e.el&&(t(n)?Object.keys(n).forEach(t=>{e.el.setAttribute(t,n[t])}):e.el.setAttribute(n,i))},getAttribute(t,e){return t&&t.el?t.el.getAttribute(e):void 0},removeAttribute(t,e){t&&t.el&&t.el.removeAttribute(e)},setStyle(e,n,i){e&&e.el&&(t(n)?Object.keys(n).forEach(t=>{e.el.style[t]=n[t]}):e.el.style[n]=i)},getStyle(t,e){if(t&&t.el)return void 0!==t.el&&void 0!==t.el.style?t.el.style[e]:void 0},removeStyle(t,e){t&&t.el&&(t.el.style[e]="")},addClass(t,e){t&&t.el&&t.el.classList.add(e)},hasClass(t,e){return!(!t||!t.el)&&t.el.classList.contains(e)},removeClass(t,e){t&&t.el&&t.el.classList.remove(e)},val(t,e){if(t&&t.el){var n=t.el;if(void 0===e)return n.value;n.value=e}},on(t,e,n,i,...r){var o=t.el,s=e.split(" "),c=e=>{n.apply(i||this,[e,t].concat(r))};s.forEach(t=>{o.addEventListener(t,c)});var a={remove:()=>{s.forEach(t=>o.removeEventListener(t,c));let e=t._events;e.splice(e.indexOf(a),1)}};return t._events.push(a),a},remove(t){for(;t._events.length>0;)t._events.shift().remove();t.children&&n(t.children),void 0!==t.elGroup&&t.elGroup.delete(t.el),void 0!==t.el&&(t.el.remove?t.el.remove():t.el.parentNode&&t.el.parentNode.removeChild(t.el),delete t.el)},onDOMAttached(t){let e,n=[],i=!1;return void 0!==t.el&&(e=(()=>{if(i)for(;n.length>0;)n.shift()();else window.requestAnimationFrame(e),document.body.contains(t.el)&&(i=!0)})),{then:(t,i)=>{n.push(t.bind(i||this)),window.requestAnimationFrame(e)}}},Element:i};return r}),function(t,e){"function"==typeof define&&define.amd?define("templating/DomFragment",e):"object"==typeof exports&&(module.exports=e())}(0,function(){"use strict";function t(t){var e=document.createElement(t||"div");return e.setAttribute("style","display:none;"),e}class e{constructor(t,e,n,i,r,o){return Object.assign(this,{_node:t,placeholder:e,childNodes:n,elGroup:i,index:r,obj:o}),this.render()}applyAttributes(t){let e=this._node.data.attribs;Object.keys(e).forEach(function(n){t.setAttribute(n,e[n])})}applyFragment(t){let e=this._node,n=e.template();if(n)for(;n.childNodes.length>0;)t.appendChild(n.childNodes[0])}appendToBody(t){let e=this.elGroup,n=this.placeholder,i=e.size;if(i>0){let n=void 0===this.index||this.index>i-1?i-1:this.index-1,r=e.keys()[n!==-1?n:0],o=r.parentNode;n===-1?o.insertBefore(t,r):null!==r.nextSibling?o.insertBefore(t,r.nextSibling):o.appendChild(t)}else{let e=n.parentNode;e&&e.replaceChild(t,n)}}render(){let e=this.placeholder,n=this._node,i=!e.id&&0===this.elGroup.size,r=n.tmpEl(!!i&&e,this.obj,this.childNodes,n),o=r.el||t(n.data.tag);return i||n.replace?n.replace||(o.innerHTML=""):this.applyAttributes(o),n.replace||this.applyFragment(o),this.appendToBody(o),r.ready&&r.ready(o),r}}return e}),function(t,e){"function"==typeof define&&define.amd?define("templating/Decoder",["./utils/List","./dom","./DomFragment"],e):"object"==typeof exports&&(module.exports=e(require("./utils/List"),require("./dom"),require("./DomFragment")))}(0,function(t,e,n){"use strict";function i(t){return t===Object(t)}function r(t){return Array.isArray?Array.isArray(t):"[object Array]"===toString.call(t)}var o={};class s{static addDecoder(t){void 0===o[t.tagName]&&(o[t.tagName]=t)}constructor(t){this._root="string"==typeof t?JSON.parse(t):t,t.children&&t.children.length>0&&(this.children=this._parseElements(t.children))}renderFragment(t,e){let n=document.createElement("template");return void 0===n.content&&("td"===e?n=document.createElement("tr"):"tr"===e&&(n=document.createElement("tbody"))),n.innerHTML=t,void 0!==n.content?n.content.firstChild:n.firstChild}_parseElements(t){var e={};return t.forEach(t=>{let n=t.data.name;var i=t.tagName;if(i){let r=o[i].decode(t);if(r){let s={name:r.name,data:r.data,tmpEl:r.tmpEl,parse:r.parse,replace:r.replace,id:t.id,template:()=>{return this.renderFragment(t.template,t.data.tag)},noAttach:o[i].noAttach||t.data.tplSet.noattach};t.children&&t.children.length>0&&(s.children=this._parseElements(t.children)),e[n]=s}}else n&&(e[n]={id:t.id,data:t.data,name:n})}),e}renderTemplate(o={},s={},c){let a={},u=[];Object.keys(o).forEach(h=>{let l=c,d=o[h],f=d.children,p=new t,g=document.createElement(d.data.tplSet.tag||"div");if(g.setAttribute("style","display:none;"),g.id=d.id,p.onDelete((t,e)=>{0===e&&t.parentNode&&(t.parentNode.replaceChild(g,t),l=(()=>g))}),d.template){let t=(e,o)=>{let c=l();e instanceof HTMLElement==!0&&(c=e);let a,u=c!==e&&(i(e)||r(e))?e:s;if(!d.noAttach||e){let e=c.querySelector("#"+d.id)||c;f&&(a=this.renderTemplate(f,u,()=>{return c}));let i=new n(d,e,a,p,o,u);return c=i.el,a&&a.runAll&&d.parse&&a.runAll(),a&&!i.children&&(i.children=a),i.elGroup=p,i.run=t,p.set(i.el,i,o),i}};u.push(t),a[h]={data:d.data,run:t,elGroup:p}}else{let t=new e.Element(l().querySelector("#"+d.id),d);t.removeAttribute("id"),t.elGroup=p,p.set(t.el,t),a[h]=t}});let h=(t,e,n)=>{Object.defineProperty(t,e,{enumerable:!1,value:n})},l=t=>{return u.forEach(e=>e(t)),a};return h(a,"runAll",l),a}render(t){var e=this.renderFragment(this._root.template);return{fragment:e,children:this.renderTemplate(this.children,t,()=>e).runAll(),templateId:this._root.templateId}}}return s}),function(t,e){"function"==typeof define&&define.amd?define("coders/component/cpDecoder",["templating/Decoder"],e):"object"==typeof exports&&(module.exports=e(require("./Decoder")))}(0,function(t){"use strict";var e={tagName:"cp",decode:function(t){var e=t.data,n={name:e.name,replace:!0,tmpEl:function(t,n,i,r){return new e.src(e.dataset,i,n,r)},data:e||{}};return void 0!==e.dataset.bind&&(n.bind=e.dataset.bind),n}};return t&&t.addDecoder(e),e}),function(t,e){"function"==typeof define&&define.amd?define("coders/placeholders/plDecoder",["templating/Decoder","templating/dom"],e):"object"==typeof exports&&(module.exports=e(require("./Decoder"),require("./dom")))}(0,function(t,e){"use strict";var n={tagName:"pl",decode:function(t){var n=t.data;return{name:n.name,tmpEl:function(t,i,r,o){return new e.Element(t||document.createElement(n.tag),o)},parse:!0,data:n}}};return t&&t.addDecoder(n),n}),function(t,e){"function"==typeof define&&define.amd?define("coders/databind/bdDecoder",["templating/Decoder","templating/dom"],e):"object"==typeof exports&&(module.exports=e(require("./Decoder"),require("./dom")))}(0,function(t,e){"use strict";var n={tagName:"bd",noAttach:!0,decode:function(t){var n=this.data=t.data;return{name:n.name,tmpEl:function(t,i,r,o){return new e.Element(t||document.createElement(n.tag),o)},data:n}}};return t&&t.addDecoder(n),n}),function(t,e){"function"==typeof define&&define.amd?define("coders/router/routerDecoder",["templating/Decoder","templating/dom"],e):"object"==typeof exports&&(module.exports=e(require("./Decoder"),require("./dom")))}(0,function(t,e){"use strict";var n={tagName:"rt",noAttach:!0,decode:function(t){var n=t.data;return{name:n.name,tmpEl:function(t,i,r,o){return new e.Element(t||document.createElement(n.tag),o)},parse:!0,data:n||{}}}};return t&&t.addDecoder(n),n}),function(t,e){"function"==typeof define&&define.amd?define("coders/style/styleDecoder",["templating/Decoder"],e):"object"==typeof exports&&(module.exports=e(require("./Decoder")))}(0,function(t){"use strict";var e={tagName:"style",decode:function(t){if(void 0===t.data.styleAttached){t.data.styleAttached=!0;let e=t.data.style,n=t=>{let e=document.createElement("style");e.innerHTML=t,document.head.appendChild(e)};"string"==typeof e?n(e):e.then(n)}}};return t&&t.addDecoder(e),e}),function(t){"object"==typeof exports?module.exports=t():"function"==typeof define&&define.amd?define("watch",t):(window.WatchJS=t(),window.watch=window.WatchJS.watch,window.unwatch=window.WatchJS.unwatch,window.callWatchers=window.WatchJS.callWatchers)}(function(){var t={noMore:!1},e=[],n=function(t){var e={};return t&&"[object Function]"==e.toString.call(t)},i=function(t){return"[object Array]"===Object.prototype.toString.call(t)},r=function(t,e){var n=[],r=[];if("string"!=typeof t&&"string"!=typeof e){if(i(t))for(var o=0;o0)&&u(t[e],r,void 0!==o?o-1:o),g(t,e,r,o),s&&(void 0===o||o>0)&&w(t,e,r,o)))},d=function(){n(arguments[1])?f.apply(this,arguments):i(arguments[1])?p.apply(this,arguments):_.apply(this,arguments)},f=function(t,e){if(!(t instanceof String)&&(t instanceof Object||i(t)))if(i(t)){for(var n=[],r=0;rt.elOnChange[e.name].call(t,e,n))}function n(t,e,n){void 0!==t.elReady[e.name]&&t.elReady[e.name].call(t,e,n)}function i(t,e,n){var i=t.events[e.name];void 0!==i&&void 0!==e.el&&"cp"!==e.data.type&&i.forEach(i=>{t._events.push(e.on(i.name,i.action,t,n))})}return Object.assign(t,{elOnChange:e,elReady:n,applyEvents:i}),t}),define("widget/parsers/applyAttribute",["watch","./addChildren"],function(t,e){function n(t,n,r){var o=n.data.tplSet.bind,s=n.data.tplSet.update;o&&Object.keys(o).forEach(c=>{let a=o[c],u=r[a];switch(c){case"class":let t=t=>{return void 0!==t&&""!==t&&(n.addClass(t),t)},e=t(u);s===!0&&i(r,a,()=>{e&&n.removeClass(e),e=t(r[a])});break;case"checked":void 0!==u&&(n.el.checked=u),s===!0&&i(r,a,()=>n.el.checked=r[a]);break;case"value":void 0!==u&&(n.el.value=u),s===!0&&i(r,a,()=>n.el.value=r[a]);break;case"required":void 0!==u&&(n.el.required=u),s===!0&&i(r,a,()=>n.el.required=r[a]);break;case"text":void 0!==u&&n.text(u),s===!0&&i(r,a,()=>n.text(r[a]));break;default:void 0!==u&&n.setAttribute(c,u),s===!0&&i(r,a,()=>n.setAttribute(c,r[a]))}if(void 0!==r.text&&"text"!==c&&(n.text(r.text),s===!0&&"text"!==c&&i(r,"text",()=>n.text(r.text))),s===!0){let o=e.elOnChange(t,n);o&&i(r,a,()=>o(r))}})}var i=t.watch;return n}),define("widget/parsers/applyParent",["templating/dom","./addChildren"],function(t,e){function n(n,i={},r={}){if(n){let o=n.children;o&&Object.keys(o).forEach(s=>{let c=!0,a=o[s],u=i[s];void 0!==u?void 0!==n.nodes[s]?n.nodes[s].call(n,a,u,r):void 0!==a&&("string"==typeof u?t.text(a,u):a=u.run(a.el)):void 0!==n.nodes[s]&&a.data.tplSet.noattach&&(n.nodes[s].call(n,a,r),c=!1),c&&a.elGroup.size>0&&e(n,a,r)})}}return n}),define("widget/utils",[],function(){function t(t){var e=typeof t;if(!("function"===e||"object"===e&&t))return t;for(var n,i,r=1,o=arguments.length;r{let r=t[i];r&&r.data&&void 0!==r.data.bind&&"cp"!==r.data.type?(n[r.data.bind]=n[r.data.bind]||[],n[r.data.bind].push(r)):e||"cp"!==r.data.type||n.__cp__.push(r)}),n}return t}),define("widget/parsers/applyBinders",["templating/dom","../utils","watch","./setBinders","./addChildren","./applyAttribute"],function(t,e,n,i,r,o){function s(t,n,s,u){if(void 0!==u){var h=s[n];if(t.nodes[n])t.nodes[n].call(t,u,h);else if(e.isArray(h)||e.isObject(h)){if(e.isArray(h)){let l=[],d=(n,s)=>{let a=!1;e.isArray(n)||e.isObject(n)||(a=!0);let h=u.run(!0,s);a&&h.text(n),l.push({binder:h,data:n}),o(t,h,n),r.applyEvents(t,h,n),r.elReady(t,h,n);let d=r.elOnChange(t,h);d&&d(n),h.children&&(h.bindings=i(h.children),c(t,n,h))};h.forEach(d);let f=u.data.tplSet.update;if(f){let t=["pop","shift","splice"],e=["push","unshift"],i=["reverse","sort"];a(s,n,(r,o,c,a)=>{let u=l.slice(0);if(void 0===a&&e.indexOf(o)!==-1){let t=u.filter(t=>t.data===c[0]);0===t.length&&d(c[0],"unshift"===o?0:u.length)}else if(t.indexOf(o)!==-1){if(u.forEach(t=>{s[n].indexOf(t.data)===-1&&(t.binder.remove(),l.splice(l.indexOf(t),1))}),"splice"===o){let t=Array.prototype.slice.call(c,2);t&&t.length>0&&t.forEach(t=>{let e=s[n].indexOf(t);e!==-1&&d(t,e)})}}else i.indexOf(o)!==-1&&h.forEach((t,e)=>{let n=u.filter(e=>e.data===t)[0];l.splice(e,0,l.splice(l.indexOf(n),1)[0]),n.binder.changePosition(e)})})}}else if(e.isObject(h)){let e=u.run(h);if("cp"!==e.data.type){o(t,e,h),r.applyEvents(t,e,h),r.elReady(t,e,h);let n=r.elOnChange(t,e);n&&n(h),e.children&&(e.bindings=i(e.children),c(t,h,e))}}}else{let e=u.run(!0);e.text(h),r.applyEvents(t,e,h),r.elReady(t,e,h);let i=r.elOnChange(t,e);i&&i(h),e.data.tplSet.update&&a(s,n,()=>{e.text(s[n]);let i=r.elOnChange(t,e);i&&i(s[n])})}}}function c(t,e,n){let i=n.bindings;if(i){i.__cp__.length>0&&i.__cp__.forEach(n=>{let i=n.run(e);i.setContext(t.context),r.elReady(t,i,e);let o=r.elOnChange(t,i);o&&o(e)});let n=Object.keys(i);e&&n.length>0&&n.forEach(n=>{if(void 0!==e[n])i[n].forEach(i=>s(t,n,e,i));else{let r=(o,c,a,h)=>{void 0!==a&&void 0===h&&(i[n].forEach(i=>s(t,n,e,i)),u(e,n,r))};a(e,n,r,0)}})}}var a=n.watch,u=n.unwatch;return c}),define("widget/parsers/setRoutes",["templating/dom"],function(t){function e(t){let e=t.toString().replace(c,""),n=e.slice(e.indexOf("(")+1,e.indexOf(")")),i=n.match(a);return null===i?[]:i.map(t=>t.replace(/[\s,]/g,""))}function n(t){void 0!==t.remove&&t.remove()}function i(t,e){void 0!==t&&Object.keys(t).forEach(n=>{let i=t[n];r(i,e)||e(i)})}function r(t,e){return!!(t.elGroup&&t.elGroup.size>0)&&(t.elGroup.forEach(t=>{e(t)}),!0)}function o(s,c){if(s.setContext)s.setContext(c);else{let a=void 0!==s.data?s.data.route:void 0;if(void 0!==a&&"rt"===s.data.type){let u,h=c.match,l=c.active,d=h(a);d.to((...e)=>{let n=e.pop();if(u=e.length>0?n.getLocation()+"_"+e.join("_"):void 0,!r(s,e=>t.attach(e))){let t=s.run(!0);i(t.children,t=>{t&&h(a,e=>o(t,Object.assign({},c,{match:e,active:l})))})}r(s,t=>{i(t.children,t=>{t&&t.to&&t.to(...e.concat(n))})})}),d.leave(done=>{let o=0,c=!1;r(s,r=>{let s=()=>{u?n(r):t.detach(r)},a=(t=!0)=>{t?o--:(c=!0,done(!1)),0!==o||c||(l.set(r,s),done(!0))};i(r.children,t=>{if(t&&void 0!==t.leave){let n=e(t.leave);n.length>0&&o++,t.leave(a)}}),0===o&&(l.set(r,s),done(!0))})}),d.query(t=>{r(s,e=>{i(e.children,e=>{e&&void 0!==e.query&&e.query(t)})})}),r(s,t=>t._activeRoute=d)}else void 0!==s.children&&["cp"].indexOf(s.data.type)===-1&&i(s.children,t=>o(t,c))}}function s(t,e){i(t,t=>o(t,e))}const c=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,a=/(?:^|,)\s*([^\s,=]+)/g;return s}),define("widget/parsers/applyElement",["templating/dom"],function(t){function e(e={},n){let i={};return Object.keys(e).forEach(r=>{let o=e[r];if("string"!=typeof o){let e=o.elGroup.first;if(e){if(i[r]=e,e instanceof t.Element==!0&&["pl"].indexOf(e.data.type)!==-1){let t=e.data.tplSet.bind;t&&Object.keys(t).forEach(i=>{void 0!==n[t[i]]&&("class"!==i?e.setAttribute(i,n[t[i]]):e.addClass(n[t[i]]))})}}else i[r]=o}}),i}return e}),define("widget/Constructor",["require","templating/Decoder","templating/dom","./Mediator","./parsers/applyAttribute","./parsers/applyParent","./parsers/applyBinders","./parsers/setBinders","./parsers/setRoutes","./parsers/applyElement","./parsers/addChildren"],function(t,e,n,i,r,o,s,c,a,u,h){"use strict";function l(t){let e=Object.keys(t);e.length>0&&e.forEach(e=>{if("root"!==e){let n=t[e];void 0!==n.elGroup&&n.elGroup.size>0&&n.elGroup.forEach(t=>{void 0!==t&&void 0!==t.remove&&t.remove(!0)})}})}class d{static extend(t={}){class e extends d{}return Object.assign(e.prototype,t),e}constructor(t={},e,n={},r){this.instance=this,this._events=[],this._globalEvents=[],this._parentChildren=e,this._options=t,this._rendered=!1,this._arguments=Array.from(arguments),this._dataSet=n,this.eventBus=new i(this),void 0!==r&&void 0!==r.name&&(this.name=r.name),this.beforeInit(...this._arguments)}ready(t){this.el=t}setContext(t){this.context||(this.context=t,this.async||this.render(),this.init(...this._arguments))}set context(t){if(!this.data){let e=this._dataSet?Object.keys(this._dataSet):[],n=e.length>0?this._dataSet:t.data;n&&(this.data=n[this._options.bind]||n)}t.match(e=>{this.match&&this.match(e),this._context=Object.assign({match:e},t)})}get context(){return this._context}render(t){if(!this._rendered)if(this.template){t&&(this.data=t);let i=this._options,r=this._parentChildren,s=new e(this.template),l=s.render(this.data);if(this.el){let t=this.el.parentNode;t&&t.replaceChild(l.fragment,this.el),this.elGroup&&this.elGroup.get(this.el)&&(this.elGroup.delete(this.el),this.el=l.fragment,this.elGroup.set(l.fragment,this))}else this.el=l.fragment;this.root=new n.Element(l.fragment,{name:"root",data:{}}),this.children=u(l.children,i),o(this,r,this.data),this.bindings=c(this.children,!0),this.data&&this.applyBinders(this.data,this),a(this.children,this.context),h(this,this.root),this.rendered(...this._arguments),this._rendered=!0}else{let t=document.createElement("div");if(this.root=new n.Element(t,{name:"root",data:{}}),this.el){let e=this.el.parentNode;e&&e.replaceChild(t,this.el)}this.el=t,this.children={},h(this,this.root),this.rendered(...this._arguments),this._rendered=!0}}beforeInit(t,e,n){}init(t,e,n){}rendered(t,e,n){}loadCss(t){if(this.context._cssReady.indexOf(t)===-1){this.context._cssReady.push(t);let e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),e.setAttribute("href",t),void 0!==e&&document.getElementsByTagName("head")[0].appendChild(e)}}detach(){this._placeholder||(this._placeholder=document.createElement(this.el.tagName)),this._parent||(this._parent=this.el.parentNode),this.el&&this._parent&&this._parent.replaceChild(this._placeholder,this.el)}attach(){this._placeholder&&this._parent&&this._parent.replaceChild(this.el,this._placeholder)}onDestroy(){}destroy(){for(this.onDestroy(),this.eventBus.clear();this._events.length>0;)this._events.shift().remove();for(;this._globalEvents.length>0;)this._globalEvents.shift().remove();l(this.children),void 0!==this.elGroup&&void 0!==this.el&&this.elGroup.delete(this.el),this.root&&this.root.remove&&this.root.remove(),delete this.el}remove(...t){this.destroy(...t)}setChildren(t,e){let n=t.data.name,i=this.children[n];void 0!==i&&void 0!==i.el&&i.remove();let r=t.run(e||!0);return r.setContext&&r.setContext(this.context),h(this,r,e),r}addComponent(t,e){let n=e.name,i=e.container;if(void 0===n)throw"you have to define data.name for component.";if(void 0===i)throw"You have to define container for component.";if(void 0!==this.children[n])throw"Component using name:"+n+"! already defined.";let r=this.setComponent(t,e),o=r.run(e.container);return o.setContext(this.context),this.children[n]=o,o}setComponent(t,e){return{name:e.name,data:{tag:"div",type:"cp"},run:i=>{e.appContext=this.context;let r=new t(e,e.children,e.data),o=document.createElement("div");return o.setAttribute("style","display:none;"),r.ready(o),i instanceof HTMLElement==!0?i.parentNode.replaceChild(r.el,i):void 0!==i.el&&void 0!==e.pos?n.insertBefore(i,r,e.pos):void 0!==i.el&&n.append(i,r),r}}}applyBinders(...t){return s(this,...t)}}return Object.assign(d.prototype,{nodes:{},events:{},elReady:{},elOnChange:{}}),d}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("widget/Mediator",[],function(){return e()}):"undefined"!=typeof exports?exports.Mediator=e():t.Mediator=e()}(this,function(){"use strict";class t{constructor(t,e,n={},i=null){this.fn=t,this.channel=i,this.context=n,this.options=e}update(t={}){Object.assign(this,t),this.channel&&this.setPriority(this.priority)}set options(t){this.update(t)}set context(t){this.setHook(t),this._context=t}get context(){return this._context}setHook(t){let e=this.channel;e&&e.hook(this,t)}_reduceCalls(){void 0!==this.calls&&--this.calls<1&&this.remove()}remove(){let t=this.channel;t&&t.removeSubscriber(this)}setPriority(t){let e=this.channel;e&&e.setPriority(this,t)}run(t){this.channel.stopped||"function"==typeof this.predicate&&!this.predicate.apply(this.context,t)||(this._reduceCalls(),this.fn.apply(this.context,t))}}class e{constructor(t,e,n,i){this.namespace=t||"",this._subscribers=[],this._channels=new Map,this._parent=e,this.stopped=!1,this.context=n,this.hook=i}addSubscriber(e,n,i=this.context){return new t(e,n,i,this)}stopPropagation(){this.stopped=!0}setPriority(t,e){let n=this._subscribers;n.indexOf(t)!==-1&&n.splice(n.indexOf(t),1),void 0!==e&&e0){let n=t.shift(),i=this.setChannel(n,e);return i&&t.length>0?i.returnChannel(t,e):i}}removeSubscriber(t){let e=this._subscribers,n=e.indexOf(t);t?n!==-1&&e.splice(n,1):e.splice(0,e.length),0===this._subscribers.length&&this._parent&&this._parent.removeChannel(this)}removeChannel(t){t===this.getChannel(t.namespace)&&this._channels.delete(t.namespace)}clear(){this._channels.forEach(t=>t.clear()),this.removeSubscriber()}publish(t){this._subscribers.slice().forEach(e=>e.run(t)),this._parent&&this._parent.publish(t),this.stopped=!1}}class n{constructor(t={},i=(()=>{})){if(!(this instanceof n))return new n(t,i);this.channel=new e("",!1,t,i)}getChannel(t,e){let n=t.split(":");if(n.length>0)return this.channel.returnChannel(n,e)}subscribe(t,e,n={},i){if(t&&""!==t){let r=this.getChannel(t,!1);return r.addSubscriber(e,n,i)}throw Error("Namespace should be provided!")}once(t,e,n={},i){return n.calls=1,this.subscribe(t,e,n,i)}publish(t,...e){if(t&&""!==t){let n=this.getChannel(t,!0);n&&n.namespace===t&&(e.push(n),n.publish(e))}}clear(){this.channel.clear()}}return n.prototype.on=n.prototype.subscribe,n.prototype.trigger=n.prototype.publish,n.version="0.9.9",n}),function(t,e){"function"==typeof define&&define.amd?define("router/utils",[],e):"object"==typeof exports&&(module.exports=e())}(0,function(){"use strict";function t(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}}function e(t,e){t.split("&").forEach(t=>{let n=t.split("=");e(n.shift(),n.join("="))})}function n(n){let i={};return n&&e(n,(e,n)=>{n=t(n),i[e]?"string"==typeof i[e]?i[e]=[i[e],n]:i[e].push(n):i[e]=n}),i}function i(t){let e=[];for(let n in t)t.hasOwnProperty(n)&&e.push(encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e.join("&")}function r(t,e){return{getQuery(){return t.query},getLocation(n="",r){let o,s=t.root.substring(0,t.root.length-e.length);return o=r===!0?i(t.query):r===!1?"":i(r),s+n+(0===o.length?"":"?"+o)}}}function o(t,e){if(!e)return!1;if(t.length!==e.length)return!1;for(let n=0,i=t.length;n(e,n)=>t.map(t=>e.indexOf(t)).filter(t=>t===n).length>0,n=t.toString().replace(c,""),i=e("(","function (","function(")(n,0)?n.indexOf("(")+1:0,r=e("=>")(n,-1)?n.indexOf(")"):n.indexOf("=>"),o=n.slice(i,r).trim(),s=o.match(a);return null===s?[]:s.map(t=>t.replace(/[\s,]/g,""))}const c=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,a=/(?:^|,)\s*([^\s,=]+)/g;return{serialize:i,getLocation:r,equals:o,setQuery:n,getArgs:s}}),function(t,e){"function"==typeof define&&define.amd?define("router/MatchBinding",["./utils"],e):"object"==typeof exports&&(module.exports=e(require("./utils")))}(0,function(t){"use strict";class e{constructor(t,n,i){if(i&&(this.binder=i),""===n)this.pattern=t.replace(/^\(\/\)/g,"").replace(/^\/|$/g,"");else{let e=t.match(/^(\/|\(\/)/g);null===e&&(t="("===t[0]?"(/"+t.substring(1):"/"+t),this.pattern=t}let r=this.pattern.replace(e.ESCAPE_PARAM,"\\$&").replace(e.OPTIONAL_PARAM,"(?:$1)?").replace(e.NAMED_PARAM,function(t,e){return e?t:"([^/]+)"}).replace(e.SPLAT_PARAM,"(.*)");this.patternRegExp=new RegExp("^"+r),this.routeHandler=new Set,this.leaveHandler=new Set,this.queryHandler=new Set,this._active=!1}setRoutes(t){var e=this.subBinder;return t({match:e.match.bind(e)}),this}reTrigger(){this.binder.reTrigger()}match(t){var e=this.subBinder;return t(e.match.bind(e)),this}to(t){return this.routeHandler.add({handler:t,done:!1}),this.reTrigger(),this}leave(e){var n=t.getArgs(e);return this.leaveHandler.add({handler:e,done:n.length>0&&"done"===n[0]}),this}query(t){return this.queryHandler.add({handler:t,done:!1}),this}remove(){return this.routeHandler.clear(),this.leaveHandler.clear(),this.queryHandler.clear(),this.subBinder.remove(),this}test(t){return this.patternRegExp.test(t)}getFragment(t){let e=t.match(this.patternRegExp);return null===e?"":t.substring(e[0].length)}extractParams(t){let e=this.patternRegExp.exec(t);return e&&e.length>0?e.slice(1).map(function(t){return t?decodeURIComponent(t):null}):[]}setSubBinder(t,e,n){let i=new t(e,this);return this.subBinder=i,"function"==typeof n&&n(i.match.bind(i)),i}checkSegment(e,n){let i=[];if(this._active){ let r=this.pattern.replace(/\((.*?)\)/g,"$1").replace(/^\//,"").split("/"),o=this.prevLoc.replace(/^\//,"").split("/"),s=e.slice(0,r.length),c=o.slice(0,r.length),a=t.equals(s,c);a?e.length>1?i=this.subBinder.checkStatus(e.slice(r.length),n):a&&(i=this.subBinder.clearActive(n)):i=this.clearActive(n)}return i}clearActive(t){let e=[];return this._active&&e.push({handler:this.triggerLeave(t),disable:this.disable.bind(this)}),e.concat(this.subBinder.clearActive())}disable(){this._active=!1}triggerTo(e,n){if(this.test(e)){if(!this._active){this.prevLoc=e;let i=this.extractParams(e).concat(t.getLocation(n,e));this.applyHandlers(this.routeHandler,i),this._active=!0}this.applyHandlers(this.queryHandler,[t.getLocation(n,e)]);let i=this.getFragment(e);if(""!==i.trim()){let t=this.subBinder;t&&t.triggerRoutes(i,n)}}}applyHandlers(t,e=[]){t&&t.size>0&&t.forEach(t=>{t.handler.apply(this,e)})}triggerLeave(e){return new Promise(n=>{let i=this.leaveHandler,r=t.getLocation(e,this.prevLoc),o=0,s=!1;i&&i.size>0&&i.forEach(t=>{t.done&&o++,t.handler((done=!0)=>{done?0!==--o||s||n(!0):done||s||(s=!0,n(!1))},r)}),0===o&&n(!0)})}}return Object.assign(e,{OPTIONAL_PARAM:/\((.*?)\)/g,NAMED_PARAM:/(\(\?)?:\w+/g,SPLAT_PARAM:/\*\w+/g,ESCAPE_PARAM:/[\-{}\[\]+?.,\\\^$|#\s]/g}),e}),function(t,e){"function"==typeof define&&define.amd?define("router/MatchBinder",["./MatchBinding"],e):"object"==typeof exports?module.exports=e(require("./MatchBinding")):(t.UrlManager=t.UrlManager||{},t.UrlManager.MatchBinder=e(t.UrlManager.MatchBinding))}(this,function(t){"use strict";class e{constructor(t,e){this._parent=e,this.bindings=new Set,this.location=t||"",this._active=!1}reTrigger(){this._parent.reTrigger()}match(t,e){return"function"==typeof t&&(e=t,t=!1),""===t&&(t=!1),this.getMatchBinding(t,e)}getMatchBinding(n,i){if(n){let r=new t(n,this.location,this);return r.setSubBinder(e,this.location+(n||""),i),this.bindings.add(r),r}return"function"==typeof i&&i(this.match.bind(this)),{match:this.match.bind(this)}}clearActive(t,e){let n=[];return this.bindings.size>0&&this.bindings.forEach(i=>{n=n.concat(i.clearActive(t,e))}),n}checkStatus(t,e){let n=[];return this.bindings.size>0&&this.bindings.forEach(i=>{n=n.concat(i.checkSegment(t,e))}),n}remove(){this.bindings.size>0&&this.bindings.forEach(t=>t.remove())}triggerRoutes(t,e){this.bindings.size>0&&this.bindings.forEach(n=>n.triggerTo(t,e))}}return e}),function(t,e){"function"==typeof define&&define.amd?define("router/Router",["./MatchBinder","./utils"],e):"object"==typeof exports&&(module.exports=e(require("./MatchBinder"),require("./utils")))}(0,function(t,e){"use strict";class n{constructor(t){void 0!==t&&""!==t&&(this._location=t.replace(/^\/|\/$/g,"")+"/"),this.root=this.getBinder(),this._listeners=new Set,this._handlers=new Set}getBinder(){return new t("",this)}test(t){return new RegExp("^"+this._location,"g").test(t)}getLocation(t){let e=t.replace(/^\/|$/g,"");return void 0!==this._location?!!this.test(e)&&e.replace(this._location,""):e}reTrigger(){this.currLocation&&this.trigger(this.currLocation)}trigger(t){if(this.started){this.currLocation=t;let n=t.split("?",2),i=this.getLocation(n[0]);if(i||""===i){let t=e.setQuery(n[1]),r={root:i,query:t};this.execute(i,r).then(t=>this.setRoutes(t,i,r)).then(t=>this.setLocation(t))}}}execute(t,e){return new Promise(n=>{let i=t.replace(/^\/|$/g,"").split("/"),r=this.root,o=r.checkStatus(i,e);o.length>0?o.forEach(t=>{t.handler.then(e=>{t.triggered||(t.triggered=!0,t.applied=e,o.filter(t=>t.applied).length===o.length?(o.forEach(t=>t.disable()),n(!0)):o.filter(t=>t.triggered).length===o.length&&n(!1))})}):n(!0)})}setRoutes(t,e,n){return t&&(this._handlers.forEach(t=>t()),this.root.triggerRoutes(e,n)),t}setListener(t){let e=this._listeners;return e.add(t),{remove(){e.delete(t)}}}onRouteChange(t){let e=this._handlers;return e.add(t),{remove(){e.delete(t)}}}setLocation(t){let e=t?this.currLocation:this.prevLocation;this.prevLocation=e,this._listeners.forEach(n=>n(e,t))}match(t){t(this.root.match.bind(this.root))}start(){this.started=!0}stop(){this.started=!1}}return n}),define("widget/App",["./Mediator","router/Router"],function(t,e){"use strict";function n(t,e){function n(){let e=window.location.href.match(/#(.*)$/),n=e?e[1]:"";i!==n&&t.trigger(n)}var i="";t.setListener((t,e)=>{i=t,e||(window.location.hash=t)}),t.onRouteChange(()=>{e.size>0&&(e.forEach(t=>t()),e.clear())}),t.start(),window.addEventListener("hashchange",n,!1),n()}class i{static extend(t={}){class e extends i{}return Object.assign(e.prototype,t),e}constructor(t={}){this.options=t,this.beforeInit(...arguments)}beforeInit(){}init(){}setContext(){return{}}set context(i){let r=new e(this.options.rootRoute);r.match(e=>{Object.assign(i,{eventBus:new t(this.context,(t,e)=>{e._globalEvents=e._globalEvents||[],e._globalEvents.indexOf(t)===-1&&e._globalEvents.push(t)}),active:new Map,match:e,container:this.el,_cssReady:i._cssReady||[]}),n(r,i.active),this._context=i})}get context(){return this._context}start(t){if(t instanceof HTMLElement!=!0)throw Error("Contaner should be a HTML element");{this.el=t,this.context=this.setContext(...arguments),void 0!==this.AppContainer&&(this.appContainer=new this.AppContainer),this.init(this.options);let e=document.createElement("div");this.el.appendChild(e),this.appContainer.ready(e),this.appContainer.setContext(this.context),setTimeout(()=>{t.classList.add("show")},100)}}}return i}); \ No newline at end of file diff --git a/dist/package.json b/dist/package.json index 818ad5f..9dc80a7 100644 --- a/dist/package.json +++ b/dist/package.json @@ -1,6 +1,6 @@ { "name": "stonewalljs", - "version": "1.0.15", + "version": "1.0.16", "repository": { "type": "git", "url": "https://github.com/gunins/stonewall" diff --git a/package.json b/package.json index 818ad5f..9dc80a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stonewalljs", - "version": "1.0.15", + "version": "1.0.16", "repository": { "type": "git", "url": "https://github.com/gunins/stonewall"