Comparing version 1.0.7 to 1.0.8
@@ -798,3 +798,3 @@ (function(global) { | ||
// Checking for injectables and saving their pipes & statements. | ||
var pipeSplit = attrValue.split('|'), | ||
var pipeSplit = attrValue.split(' | '), | ||
injectable = global.App.getInjectable(attrName), | ||
@@ -801,0 +801,0 @@ pipes; |
@@ -1,1 +0,1 @@ | ||
Function("return this")().Config={viewOptions:{templatesFolder:"app"}},function(t){var e={clean:function(t){if(!Array.isArray(t))throw{message:"[Array:Clean] Cannot work with a non-array!"};for(var e=0;e<t.length;e++)void 0===t[e]?(t.splice(e,1),e--):Array.isArray(t[e])&&this.clean(t[e])}};t.Utils=t.Utils||{},t.Utils.Array=e}(Function("return this")()),function(t){var e={get:function(t,e,r){var n=new XMLHttpRequest;if("object"==typeof e.headers)for(var i in e.headers)e.headers.hasOwnProperty(i)&&n.setRequestHeader(i,e.headers[i]);if("object"==typeof e.params){var s="?";for(var o in e.params)if(e.params.hasOwnProperty(o))if(Array.isArray(e.params[o]))for(var a=0;a<e.params[o].length;a++)s+=o+"="+e.params[o][a]+"&";else s+=o+"="+e.params[o]+"&";t+=s}n.open("GET",t,!0),n.onreadystatechange=function(){200===n.status&&4===n.readyState&&r(JSON.parse(n.responseText))},n.send()},post:function(t,e,r){var n=new XMLHttpRequest;if(n.open("POST",t,!0),"object"==typeof e.headers)for(var i in e.headers)e.headers.hasOwnProperty(i)&&n.setRequestHeader(i,e.headers[i]);"object"==typeof e.body&&(e=e.body,n.setRequestHeader("Content-Type","application/json")),n.onreadystatechange=function(){200===n.status&&4===n.readyState&&r(JSON.parse(n.responseText))},n.send(JSON.stringify(e))}};t.Utils=t.Utils||{},t.Utils.Http=e}(Function("return this")()),function(t){var e={updateObject:function(t,r,n){if(t&&r){var i=0;if("object"==typeof t&&"object"==typeof r)for(var s in r)if(r.hasOwnProperty(s)&&!function(t){if(Array.isArray(n)){for(var e=0;e<n.length;e++)if(t===n[e])return!0}else if(t===n)return!0;return!1}(s))switch(typeof r[s]){case"object":Array.isArray(r[s])?console.warning('[Utils:Object] "updateObject" does not support merging arrays.'):i+=e.updateObject(t[s],r[s]);break;default:t[s]!==r[s]&&(t[s]=r[s],i++)}}return i}};t.Utils=t.Utils||{},t.Utils.Object=e}(Function("return this")()),function(t){var e=function(){this.listeners=[],this.lastMessage=void 0};e.prototype={subscribe:function(t){if("function"==typeof t)return this.listeners.push(t),{unsubscribe:this.unsubscribe.bind(this,t)};console.error(t,"is not a function. Cannot subscribe to Observable.")},unsubscribe:function(t){for(var e=this.listeners.length-1;e>=0;e--)this.listeners[e]===t&&this.listeners.splice(e,1)},next:function(t){this.listeners.forEach(function(e){e(t)}),this.lastMessage=t}},t.Utils=t.Utils||{},t.Utils.Observable=e}(Function("return this")()),function(t){var e={toKeyValueArray:function(t,e){"string"!=typeof e&&(e=",");var r,n=[];return t.split(e).forEach(function(t){r=/([\w-]+): *(.+)/g.exec(t.trim()),n.push({key:r[1],value:r[2]})}),n},toDictionary:function(t,e,r){"string"!=typeof e&&(e=","),"string"!=typeof r&&(r=":");var n,i={};return t.split(e).forEach(function(t){var e=new RegExp("([\\w-]+)"+r+" *(.+)");n=e.exec(t.trim()),Array.isArray(n)&&3===n.length&&(i[n[1]]=n[2])}),i}};t.Utils=t.Utils||{},t.Utils.String=e}(Function("return this")()),function(t){var e=function(t,e){this.viewNode=t,this.self=t.self.cloneNode(!1),Array.isArray(e)&&(this.values=e),this.children=[]};e.prototype.compare=function(t){var r=!1,n=t.$scope;if(Array.isArray(this.viewNode.directives))for(var i,s,o=this.viewNode.directives,a=0,l=0;l<o.length;l++)if(o[l])if(i=o[l].injectable,s=i.getter(o[l].statement,t),i.compare(this.values[l-a],s)){if(s&&Array.isArray(s.array))break;if(!1===s&&void 0===this.self)break}else{if(this.values[l-a]=s,!i.justModify||!this.self){r=!0;break}i.modifier(this,s)}else a++;if(r){var c=this.viewNode.generate(t);this.iteratorValue&&(c.iteratorValue=this.iteratorValue),this.parent.replaceChild(c,this),c.isComponent()&&c.bootstrap(t)}else if(this.multipleNodes){var h,p=this.viewNode,u=this.iterator,f=n[u.varName],d=p.directives[l],m=l;for(p.directives[m]=void 0,l=0;l<u.array.length;l++)n[u.varName]=u.array[l],this.children[l]instanceof e?(this.children[l].compare(t),this.children[l].iteratorValue=u.array[l]):((h=p.generate(t)).iteratorValue=u.array[l],this.appendChild(h),h.isComponent()&&h.bootstrap());var v=l;for(l;l<this.children.length;l++)this.removeChild(this.children[l]);this.children.splice(v,l-v),n[u.varName]=f,p.directives[m]=d}else this.children.forEach(function(e){e.compare(t)})},e.prototype.appendChild=function(t){this.children.push(t),t.parent=this,t.self&&this.self.appendChild(t.self)},e.prototype.replaceChild=function(t,e){if(t.parent=e.parent,t.self&&e.self)this.removeChild(e,t);else if(t.self&&!e.self){var r=this.children.indexOf(e);if(r>=0){this.children.splice(r,1,t);for(var n;!n&&r<this.children.length-1;)this.children[++r].self&&(n=this.children[r].self);n?n.parentNode.insertBefore(t.self,n):this.self&&this.self.appendChild(t.self)}else console.error("CompNode: replaceChild failed, 2nd parameter is not a child of this node.")}else!t.self&&e.self&&this.removeChild(e)},e.prototype.removeChild=function(e,r){if(e.comp instanceof t.Base.Component)e.comp.onDestroy(),delete e.comp;else if(Array.isArray(e.children)){for(var n=0;n<e.children.length;n++)e.removeChild(e.children[n]);e.children.splice(0,e.children.length)}r?(this.children.splice(this.children.indexOf(e),1,r),this.self.replaceChild(r.self,e.self)):e.self&&(this.self.removeChild(e.self),e.self=void 0)},e.prototype.isComponent=function(){return this.self&&1===this.self.nodeType&&(this.viewNode.controller||"string"==typeof this.self.getAttribute("controller"))&&!this.iterator},e.prototype.bootstrap=function(e){this.comp=t.Core.Bootstrap(this.self,e,this.inputs),this.self=this.comp.nodeTree.self},t.Base=t.Base||{},t.Base.CompNode=e}(Function("return this")()),function(global){var Component=function(t,e,r){this.el=t,e instanceof Component&&(this.parent=e,e.children=e.children||[],e.children.push(this)),this.$scope=r};Component.prototype.setView=function(t){this.el.parentNode.replaceChild(t.self,this.el),this.nodeTree=t,this.el=t.self},Component.prototype.update=function(){this.nodeTree instanceof global.Base.CompNode&&this.nodeTree.compare(this)},Component.prototype.getInput=function(t,e){return this.inputs&&this.inputs.hasOwnProperty(t)?this.inputs[t]:e},Component.prototype.evalWithScope=function(statement){var result;try{with(this.$scope)result=eval(statement)}catch(t){console.log(t.message)}return result},Component.prototype.onDestroy=function(){if(Array.isArray(this.children))for(;this.children.length>0;)this.children[0].onDestroy();Array.isArray(this.subscriptions)&&this.subscriptions.forEach(function(t){t.unsubscribe()}),this.parent instanceof Component&&this.parent.children.splice(this.parent.children.indexOf(this),1)},global.Base=global.Base||{},global.Base.Component=Component}(Function("return this")()),function(t){var e=function(t,e,r){this.name=t,this.view=e,this.constructor=r};e.prototype.generateComponent=function(e,r,n){var i={},s=new t.Base.Component(e,r,i);return e.innerHTML.length>0&&(s.subView=new t.Base.View("content-outlet",null,e.innerHTML)),"object"==typeof n&&(s.inputs=n),i.getInput=function(t,e){i[t]=this.getInput(t,e)}.bind(s),i.addSubscription=function(){this.subscriptions=this.subscriptions||[];for(var t=0;t<arguments.length;t++)this.subscriptions.push(arguments[t])}.bind(s),this.constructor.call(this,i,s.update.bind(s)),s.setView(this.view.generate(s)),s},t.Base=t.Base||{},t.Base.Controller=e}(Function("return this")()),function(global){var TAG="[Injectable]",Injectable=function(t,e){this.name=t;try{this.modifier=e.modifier.bind(this)}catch(t){console.error(TAG,this.name+": No modifier set.")}"function"==typeof e.getter&&(this.getter=e.getter.bind(this)),"function"==typeof e.compare&&(this.compare=e.compare.bind(this)),this.keepAttribute=!!e.keepAttribute,this.justModify=!!e.justModify,this.useComponentInGetter=!!e.useComponentInGetter};Injectable.prototype.getter=function(statement,comp){var result;try{with(comp.$scope)result=eval(statement)}catch(t){console.error(TAG,this.name+":","Couldn't evaluate '"+statement+"'.")}return result},Injectable.prototype.compare=function(t,e){if(t===e)return!0},global.Base=global.Base||{},global.Base.Injectable=Injectable}(Function("return this")()),function(t){var e=function(t,e){this.name=t,this.initFunc=e,this.events={},this.init()};e.prototype.init=function(){if(this.data=[],"function"!=typeof this.initFunc)throw{message:this.name+": Couldn't initialize the model (initFunc err)"};this.initFunc(function(t,e){this.setData(t,!!e)}.bind(this))},e.prototype.setData=function(t,e,r){if((e=!!e)&&this.data)for(var n=0;n<t.length;n++)this.data.push(t[n]);else this.data=t;this.emit(r||"setData",this.data)},e.prototype.emit=function(){for(var t,e=[],r=0;r<arguments.length;r++)0===r?t=arguments[r]:e.push(arguments[r]);if(Array.isArray(this.events[t]))for(var n=0;n<this.events[t].length;n++)this.events[t][n].apply(void 0,e)},e.prototype.subscribe=function(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),{unsubscribe:function(t,e){var r=this.events[t].indexOf(e);this.events[t].splice(r,1)}.bind(this,t,e)}},t.Base=t.Base||{},t.Base.Model=e}(Function("return this")()),function(t){var e=function(t,e){this.name=t,this.func=e};e.prototype.transform=function(t,e){return this.func(t,e)},t.Base=t.Base||{},t.Base.Pipe=e}(Function("return this")()),function(t){var e=function(t){if(!t.hasOwnProperty("path"))throw{message:"[Route] Route must have a path."};if(this.path=t.path.split("/"),t.hasOwnProperty("controller"))this.controller=t.controller;else{if(!t.hasOwnProperty("redirect"))throw{message:"[Route] Route must have a controller."};this.redirect=t.redirect}Array.isArray(t.children)&&(this.children=t.children.map(function(t){return new e(t)}))};e.prototype.checkUrl=function(t,e){var r=0;if(this.path.length>t.length)return!1;for(var n=0;n<this.path.length;n++)this.path[n]===t[n]&&r++;if(this.path.length===r){if(this.redirect)return{redirect:this.redirect};if(Array.isArray(e)||(e=[]),e.push(this.controller),this.path.length<t.length){if(!Array.isArray(this.children))return!1;var i=!1;for(t.splice(0,r),n=0;n<this.children.length;n++)if(this.children[n].checkUrl(t,e)){i=e;break}return i}if(Array.isArray(this.children))for(var s=this.children.filter(function(t){return 1===t.path.length&&""===t.path[0]});Array.isArray(s)&&s.length>0;)s=s[0],e.push(s.controller),Array.isArray(s.children)&&(s=s.children.filter(function(t){return 0===t.path.length}));return{controllers:e}}return!1},t.Base=t.Base||{},t.Base.Route=e}(Function("return this")()),function(t){var e=t.Config.viewOptions,r=function(t,e,r){this.name=t,r?this.templateSrc=r:this.loadTemplate(e),this.buildNodeTree()};r.prototype.loadTemplate=function(t){var r=e.templatesFolder+"/"+t+this.name+".html";r=r.replace(/\/\//g,"/"),this.templateSrc=function(t){var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(),e.responseText}(r)},r.prototype.buildNodeTree=function(){function e(r){for(var n,i=new t.Base.ViewNode(r),s=0;s<r.childNodes.length;s++)(n=e(r.childNodes[s])).parent=i,i.children.push(n);return i}var r=document.createElement("temp");r.innerHTML=this.templateSrc;for(var n=new t.Base.ViewNode(document.createElement(this.name)),i=0;i<r.childNodes.length;i++)n.children.push(e(r.childNodes[i]));this.nodeTree=n},r.prototype.generate=function(e){for(var r=new t.Base.CompNode(this.nodeTree),n=0;n<this.nodeTree.children.length;n++)r.appendChild(this.nodeTree.children[n].generate(e));return r},t.Base=t.Base||{},t.Base.View=r}(Function("return this")()),function(t){var e=function(t){this.self=t,this.children=[],this.parseNode()};e.prototype.parseNode=function(){var e,r,n=this.self.attributes;if(n&&n.length>0)for(var i=0;i<n.length;i++)if(e=n[i].name,r=n[i].value,"controller"===e)this.controller=r;else{var s,o=r.split("|"),a=t.App.getInjectable(e);if(a instanceof t.Base.Injectable){if(r=o[0],o.splice(0,1),o.length>0){s=[];for(var l=0;l<o.length;l++){var c=o[l].trim().split(/:(.+)/g);c=c.filter(function(t){return t.length>0}),s.push({name:c[0],dataStatement:c[1]})}}Array.isArray(this.directives)||(this.directives=[]),this.directives.push({injectable:a,statement:r,pipes:s}),a.keepAttribute||(this.self.removeAttribute(e),i--)}}},e.prototype.generate=function(e){var r=new t.Base.CompNode(this),n=e.$scope;if(Array.isArray(this.directives)){var i,s;for(r.values=[],s=0;s<this.directives.length&&r.self;s++)if(this.directives[s]){var o=(i=this.directives[s]).injectable.getter(i.statement,e);if(Array.isArray(i.pipes)){var a,l,c;for(a=0;a<i.pipes.length;a++)if(l=i.pipes[a],(c=t.App.getPipe(l.name))instanceof t.Base.Pipe){var h;l.dataStatement&&(h=e.evalWithScope(l.dataStatement)),o=c.transform(o,h)}}if(i.injectable.modifier(r,o),r.values.push(o),r.multipleNodes)break}}if(r.self)if(r.multipleNodes){var p,u=r.iterator.array,f=n[r.iterator.varName],d=this.directives[s],m=s;for(this.directives[s]=void 0,s=0;s<u.length;s++)n[r.iterator.varName]=u[s],(p=this.generate(e)).iteratorValue=u[s],r.appendChild(p),p.isComponent()&&p.bootstrap(e);n[r.iterator.varName]=f,this.directives[m]=d}else!function(t,r){for(var n,i=0;i<t.children.length;i++)n=t.children[i].generate(e),r.appendChild(n),n.replaceSelfWith&&(n.self.parentNode.replaceChild(n.replaceSelfWith.self,n.self),delete n.replaceSelfWith),n.isComponent()&&n.bootstrap(e)}(this,r);return r},t.Base=t.Base||{},t.Base.ViewNode=e}(Function("return this")()),function(t){function e(e){var r=e.getAttribute("controller");if("string"==typeof r){var n=t.App.getController(r);if(n instanceof t.Base.Controller)return n}}t.Core=t.Core||{},t.Core.Bootstrap=function(r,n,i){if(1===r.nodeType){var s=e(r);if(s instanceof t.Base.Controller)return s.generateComponent(r,n,i);throw{message:"Controller "+r.getAttribute("controller")+" not found."}}throw{message:"Cannot bootstrap a non-element object."}}}(Function("return this")()),function(t){var e,r=function(r){if(e)return e;if(!Array.isArray(r))throw{message:"[Router] 'routes' should be an array of routes."};window.onhashchange=function(){this.navigateTo(location.hash,!0)}.bind(this);try{this.routes=r.map(function(e){return new t.Base.Route(e)})}catch(t){throw t}this.navigations=0,e=this,this.navigateTo(location.hash)};r.prototype.navigateTo=function(e,r){if("#"===e[0]&&(e="/"!==e[1]?e.slice(1,e.length):e.slice(2,e.length)),e!==this.currentPath){this.navigating=!0,this.navigations++,this.lastPath=this.currentPath||e,this.currentPath=e;var n=this.parseUrl(e);if(n){var i=n.results;i.redirect?this.navigateTo(i.redirect):("string"==typeof n.params&&n.params.length>0&&(n.params=t.Utils.String.toDictionary(n.params,"&","=")),r?history.replaceState(null,"","#/"+e):history.pushState(null,"","#/"+e),this.stateChange(n))}else console.error("UNKNOWN ROUTE "+e);this.navigating=!1}},r.prototype.parseUrl=function(t){var e=t.split("?"),r=e[1];e=e[0].split("/").filter(function(t){return"#"!==t});for(var n,i=0;i<this.routes.length&&!n;i++)n=this.routes[i].checkUrl(e);return!!n&&{results:n,params:r}},r.prototype.stateChange=function(e){var r=e.results;if(this.state){for(var n,i=0;i<r.controllers.length;i++)if(r.controllers[i]!==this.state.controllers[i]){for(var s=i;s<r.controllers.length;s++)this.state.controllers[s]=r.controllers[s];s<this.state.controllers.length&&this.state.controllers.splice(s,this.state.controllers.length),this.state.nextController=r.controllers[i],n=this.state.compNodes[i];break}if("object"==typeof e.params){for(var o in e.params)e.params.hasOwnProperty(o)&&this.updateParam(o,e.params[o]);for(o in this.state.params)this.state.params.hasOwnProperty(o)&&(e.params[o]||this.updateParam(o))}else{var a=this.state.params;if("object"==typeof a)for(o in a)a.hasOwnProperty(o)&&this.updateParam(o)}if(n instanceof t.Base.CompNode){var l=n.comp,c=n.viewNode.generate(l);n.parent.replaceChild(c,n),c.bootstrap(l.parent)}}else this.state={controllers:r.controllers,params:e.params,nextController:r.controllers[0]}},r.prototype.nextController=function(t){if(this.state&&this.state.nextController){var e=this.state.nextController;this.state.nextController=void 0;for(var r=0;r<this.state.controllers.length;r++)if(e===this.state.controllers[r]){Array.isArray(this.state.compNodes)||(this.state.compNodes=[]),this.state.nextController=this.state.controllers[r+1],this.state.compNodes[r]=t;break}return e}console.error("[Router]","Failed to load next controller, end of list.")},r.prototype.updateParam=function(e,r){var n=this.params(),i=0;if(n[e]!==r&&(r&&0!==r.length?n[e]=r:delete n[e],i++,this.paramSubscriptions)){var s=this.paramSubscriptions[e];s instanceof t.Utils.Observable&&s.next(r)}if(i>0){var o=location.hash;o=o.split("?")[0]+"?";for(var a in n)n.hasOwnProperty(a)&&(o+=a+"="+n[a]+"&");o=o.substr(2,o.length-3),this.navigating?history.replaceState(null,"","#/"+o):history.pushState(null,"","#/"+o),this.currentPath=o}this.state&&(this.state.params=n)},r.prototype.subscribeToParam=function(e,r){"object"!=typeof this.paramSubscriptions&&(this.paramSubscriptions={});var n=this.paramSubscriptions;n[e]instanceof t.Utils.Observable||(n[e]=new t.Utils.Observable);var i=n[e].subscribe(r);return this.state&&this.state.params&&r(this.state.params[e]),i},r.prototype.isLandingPage=function(){return this.lastPath===this.currentPath&&1===this.navigations},r.prototype.params=function(){return this.state&&"object"==typeof this.state.params?this.state.params:{}},t.Core=t.Core||{},t.Core.Router=r}(Function("return this")()),function(t){var e,r={},n={},i={},s={};t.App={getController:function(t){return r[t]},getModel:function(t){return n[t]},getInjectable:function(t){return i[t]},getPipe:function(t){return s[t]},Bootstrap:function(e){var r="[Bootstrap]",n=document.querySelector('*[controller="'+e+'"]');if(n&&1===n.nodeType){try{var i=t.Core.Bootstrap(n)}catch(t){console.error(r,t.message||t)}return i}console.error(r,"Could not find placeholder for '"+e+"'.")},Controller:function(e,n,i){try{var s=new t.Base.View(e,n);r[e]=new t.Base.Controller(e,s,i)}catch(t){console.error("[Controller]",t.message)}},Model:function(e,r){try{n[e]=new t.Base.Model(e,r)}catch(t){console.error("[Model]",t.message)}},Injectable:function(e,r){try{i[e]=new t.Base.Injectable(e,r)}catch(t){console.error("[Injectable]",t.message)}},Pipe:function(e,r){try{s[e]=new t.Base.Pipe(e,r)}catch(t){console.error("[Pipe]",t.message)}},Router:function(r){return e||(e=new t.Core.Router(r)),e}}}(Function("return this")()),function(global){global.App.Injectable("bind-class",{justModify:!0,getter:function(statement,comp){var classes=global.Utils.String.toDictionary(statement),value;try{with(comp.$scope)for(var className in classes)classes.hasOwnProperty(className)&&(value=eval(classes[className]),classes[className]=!!value)}catch(t){throw{message:this.name+": "+t.message}}return classes},modifier:function(t,e){var r=0;for(var n in e)e.hasOwnProperty(n)&&(e[n]?(t.self.classList.add(n),r++):t.self.classList.remove(n));0===r&&0===t.self.classList.length&&t.self.removeAttribute("class")}})}(Function("return this")()),function(global){global.App.Injectable("bind-if",{getter:function(statement,comp){var result;try{with(comp.$scope)result=eval(statement)}catch(t){throw this.name+": Couldn't evaluate '"+statement+"'."}return!!result},modifier:function(t,e){e||(t.self=void 0)}})}(Function("return this")()),Function("return this")().App.Injectable("content-outlet",{getter:function(t,e){return e},modifier:function(t,e){e.subView&&(t.replaceSelfWith=e.subView.generate(e.parent))}}),function(global){global.App.Injectable("bind-events",{getter:function(statement,comp){var events=global.Utils.String.toDictionary(statement),matches,funcName,variables;for(var event in events)if(events.hasOwnProperty(event)){var regEx=new RegExp("^(.+)\\((.*)\\)$");if(matches=events[event].match(regEx),!Array.isArray(matches)||matches.length<2)throw this.name+": Invalid statement, expecting: [event: func()]";funcName=matches[1],variables=matches[2].split(",");for(var i=0;i<variables.length;i++)try{with(comp.$scope)variables[i]=eval(variables[i])}catch(t){throw this.name+": "+t.message}events[event]=function(funcName,variables,el){var func;try{with(comp.$scope)func=eval(funcName)}catch(t){throw this.name+": "+t.message}"function"==typeof func&&func.apply(el,variables)}.bind(this,funcName,variables)}return events},modifier:function(t,e){for(var r in e)e.hasOwnProperty(r)&&t.self.addEventListener(r,function(t,e){e&&e.preventDefault&&e.preventDefault();try{t(e.currentTarget)}catch(t){console.error("[Injectable]",t)}}.bind(this,e[r]))},compare:function(t,e){return!0}})}(Function("return this")()),function(global){global.App.Injectable("input",{getter:function(statement,comp){var inputs=global.Utils.String.toDictionary(statement);try{for(var input in inputs)if(inputs.hasOwnProperty(input))with(comp.$scope)inputs[input]=eval(inputs[input])}catch(t){throw{message:this.name+": "+t.message}}return inputs},modifier:function(t,e){t.inputs=e},compare:function(t,e){var r=!0;for(var n in e)if(e.hasOwnProperty(n)&&e[n]!==t[n]){r=!1;break}return r}})}(Function("return this")()),function(global){global.App.Injectable("bind-for",{getter:function(statement,comp){for(var words=statement.split(" "),result={},w=0;w<words.length;w++)if("in"===words[w]&&w>0&&w<words.length-1){try{with(comp.$scope)result.array=eval(words[w+1])}catch(t){throw t}result.varName=words[w-1]}return result},modifier:function(t,e){t.self=document.createElement("iterator"),t.multipleNodes=!0,t.iterator=e},compare:function(t,e){return t.array===e.array}})}(Function("return this")()),function(t){t.App.Injectable("router-outlet",{getter:function(t,e){return!0},modifier:function(e,r){var n=t.App.Router().nextController(e);t.App.getController(n)instanceof t.Base.Controller&&e.self.setAttribute("controller",n)}})}(Function("return this")()),Function("return this")().App.Injectable("bind-value",{justModify:!0,modifier:function(t,e){t.self instanceof HTMLInputElement&&(t.self.value=e),t.self.innerHTML=e}}); | ||
Function("return this")().Config={viewOptions:{templatesFolder:"app"}},function(t){var e={clean:function(t){if(!Array.isArray(t))throw{message:"[Array:Clean] Cannot work with a non-array!"};for(var e=0;e<t.length;e++)void 0===t[e]?(t.splice(e,1),e--):Array.isArray(t[e])&&this.clean(t[e])}};t.Utils=t.Utils||{},t.Utils.Array=e}(Function("return this")()),function(t){var e={get:function(t,e,r){var n=new XMLHttpRequest;if("object"==typeof e.headers)for(var i in e.headers)e.headers.hasOwnProperty(i)&&n.setRequestHeader(i,e.headers[i]);if("object"==typeof e.params){var s="?";for(var o in e.params)if(e.params.hasOwnProperty(o))if(Array.isArray(e.params[o]))for(var a=0;a<e.params[o].length;a++)s+=o+"="+e.params[o][a]+"&";else s+=o+"="+e.params[o]+"&";t+=s}n.open("GET",t,!0),n.onreadystatechange=function(){200===n.status&&4===n.readyState&&r(JSON.parse(n.responseText))},n.send()},post:function(t,e,r){var n=new XMLHttpRequest;if(n.open("POST",t,!0),"object"==typeof e.headers)for(var i in e.headers)e.headers.hasOwnProperty(i)&&n.setRequestHeader(i,e.headers[i]);"object"==typeof e.body&&(e=e.body,n.setRequestHeader("Content-Type","application/json")),n.onreadystatechange=function(){200===n.status&&4===n.readyState&&r(JSON.parse(n.responseText))},n.send(JSON.stringify(e))}};t.Utils=t.Utils||{},t.Utils.Http=e}(Function("return this")()),function(t){var e={updateObject:function(t,r,n){if(t&&r){var i=0;if("object"==typeof t&&"object"==typeof r)for(var s in r)if(r.hasOwnProperty(s)&&!function(t){if(Array.isArray(n)){for(var e=0;e<n.length;e++)if(t===n[e])return!0}else if(t===n)return!0;return!1}(s))switch(typeof r[s]){case"object":Array.isArray(r[s])?console.warning('[Utils:Object] "updateObject" does not support merging arrays.'):i+=e.updateObject(t[s],r[s]);break;default:t[s]!==r[s]&&(t[s]=r[s],i++)}}return i}};t.Utils=t.Utils||{},t.Utils.Object=e}(Function("return this")()),function(t){var e=function(){this.listeners=[],this.lastMessage=void 0};e.prototype={subscribe:function(t){if("function"==typeof t)return this.listeners.push(t),{unsubscribe:this.unsubscribe.bind(this,t)};console.error(t,"is not a function. Cannot subscribe to Observable.")},unsubscribe:function(t){for(var e=this.listeners.length-1;e>=0;e--)this.listeners[e]===t&&this.listeners.splice(e,1)},next:function(t){this.listeners.forEach(function(e){e(t)}),this.lastMessage=t}},t.Utils=t.Utils||{},t.Utils.Observable=e}(Function("return this")()),function(t){var e={toKeyValueArray:function(t,e){"string"!=typeof e&&(e=",");var r,n=[];return t.split(e).forEach(function(t){r=/([\w-]+): *(.+)/g.exec(t.trim()),n.push({key:r[1],value:r[2]})}),n},toDictionary:function(t,e,r){"string"!=typeof e&&(e=","),"string"!=typeof r&&(r=":");var n,i={};return t.split(e).forEach(function(t){var e=new RegExp("([\\w-]+)"+r+" *(.+)");n=e.exec(t.trim()),Array.isArray(n)&&3===n.length&&(i[n[1]]=n[2])}),i}};t.Utils=t.Utils||{},t.Utils.String=e}(Function("return this")()),function(t){var e=function(t,e){this.viewNode=t,this.self=t.self.cloneNode(!1),Array.isArray(e)&&(this.values=e),this.children=[]};e.prototype.compare=function(t){var r=!1,n=t.$scope;if(Array.isArray(this.viewNode.directives))for(var i,s,o=this.viewNode.directives,a=0,l=0;l<o.length;l++)if(o[l])if(i=o[l].injectable,s=i.getter(o[l].statement,t),i.compare(this.values[l-a],s)){if(s&&Array.isArray(s.array))break;if(!1===s&&void 0===this.self)break}else{if(this.values[l-a]=s,!i.justModify||!this.self){r=!0;break}i.modifier(this,s)}else a++;if(r){var c=this.viewNode.generate(t);this.iteratorValue&&(c.iteratorValue=this.iteratorValue),this.parent.replaceChild(c,this),c.isComponent()&&c.bootstrap(t)}else if(this.multipleNodes){var h,p=this.viewNode,u=this.iterator,f=n[u.varName],d=p.directives[l],m=l;for(p.directives[m]=void 0,l=0;l<u.array.length;l++)n[u.varName]=u.array[l],this.children[l]instanceof e?(this.children[l].compare(t),this.children[l].iteratorValue=u.array[l]):((h=p.generate(t)).iteratorValue=u.array[l],this.appendChild(h),h.isComponent()&&h.bootstrap());var v=l;for(l;l<this.children.length;l++)this.removeChild(this.children[l]);this.children.splice(v,l-v),n[u.varName]=f,p.directives[m]=d}else this.children.forEach(function(e){e.compare(t)})},e.prototype.appendChild=function(t){this.children.push(t),t.parent=this,t.self&&this.self.appendChild(t.self)},e.prototype.replaceChild=function(t,e){if(t.parent=e.parent,t.self&&e.self)this.removeChild(e,t);else if(t.self&&!e.self){var r=this.children.indexOf(e);if(r>=0){this.children.splice(r,1,t);for(var n;!n&&r<this.children.length-1;)this.children[++r].self&&(n=this.children[r].self);n?n.parentNode.insertBefore(t.self,n):this.self&&this.self.appendChild(t.self)}else console.error("CompNode: replaceChild failed, 2nd parameter is not a child of this node.")}else!t.self&&e.self&&this.removeChild(e)},e.prototype.removeChild=function(e,r){if(e.comp instanceof t.Base.Component)e.comp.onDestroy(),delete e.comp;else if(Array.isArray(e.children)){for(var n=0;n<e.children.length;n++)e.removeChild(e.children[n]);e.children.splice(0,e.children.length)}r?(this.children.splice(this.children.indexOf(e),1,r),this.self.replaceChild(r.self,e.self)):e.self&&(this.self.removeChild(e.self),e.self=void 0)},e.prototype.isComponent=function(){return this.self&&1===this.self.nodeType&&(this.viewNode.controller||"string"==typeof this.self.getAttribute("controller"))&&!this.iterator},e.prototype.bootstrap=function(e){this.comp=t.Core.Bootstrap(this.self,e,this.inputs),this.self=this.comp.nodeTree.self},t.Base=t.Base||{},t.Base.CompNode=e}(Function("return this")()),function(global){var Component=function(t,e,r){this.el=t,e instanceof Component&&(this.parent=e,e.children=e.children||[],e.children.push(this)),this.$scope=r};Component.prototype.setView=function(t){this.el.parentNode.replaceChild(t.self,this.el),this.nodeTree=t,this.el=t.self},Component.prototype.update=function(){this.nodeTree instanceof global.Base.CompNode&&this.nodeTree.compare(this)},Component.prototype.getInput=function(t,e){return this.inputs&&this.inputs.hasOwnProperty(t)?this.inputs[t]:e},Component.prototype.evalWithScope=function(statement){var result;try{with(this.$scope)result=eval(statement)}catch(t){console.log(t.message)}return result},Component.prototype.onDestroy=function(){if(Array.isArray(this.children))for(;this.children.length>0;)this.children[0].onDestroy();Array.isArray(this.subscriptions)&&this.subscriptions.forEach(function(t){t.unsubscribe()}),this.parent instanceof Component&&this.parent.children.splice(this.parent.children.indexOf(this),1)},global.Base=global.Base||{},global.Base.Component=Component}(Function("return this")()),function(t){var e=function(t,e,r){this.name=t,this.view=e,this.constructor=r};e.prototype.generateComponent=function(e,r,n){var i={},s=new t.Base.Component(e,r,i);return e.innerHTML.length>0&&(s.subView=new t.Base.View("content-outlet",null,e.innerHTML)),"object"==typeof n&&(s.inputs=n),i.getInput=function(t,e){i[t]=this.getInput(t,e)}.bind(s),i.addSubscription=function(){this.subscriptions=this.subscriptions||[];for(var t=0;t<arguments.length;t++)this.subscriptions.push(arguments[t])}.bind(s),this.constructor.call(this,i,s.update.bind(s)),s.setView(this.view.generate(s)),s},t.Base=t.Base||{},t.Base.Controller=e}(Function("return this")()),function(global){var TAG="[Injectable]",Injectable=function(t,e){this.name=t;try{this.modifier=e.modifier.bind(this)}catch(t){console.error(TAG,this.name+": No modifier set.")}"function"==typeof e.getter&&(this.getter=e.getter.bind(this)),"function"==typeof e.compare&&(this.compare=e.compare.bind(this)),this.keepAttribute=!!e.keepAttribute,this.justModify=!!e.justModify,this.useComponentInGetter=!!e.useComponentInGetter};Injectable.prototype.getter=function(statement,comp){var result;try{with(comp.$scope)result=eval(statement)}catch(t){console.error(TAG,this.name+":","Couldn't evaluate '"+statement+"'.")}return result},Injectable.prototype.compare=function(t,e){if(t===e)return!0},global.Base=global.Base||{},global.Base.Injectable=Injectable}(Function("return this")()),function(t){var e=function(t,e){this.name=t,this.initFunc=e,this.events={},this.init()};e.prototype.init=function(){if(this.data=[],"function"!=typeof this.initFunc)throw{message:this.name+": Couldn't initialize the model (initFunc err)"};this.initFunc(function(t,e){this.setData(t,!!e)}.bind(this))},e.prototype.setData=function(t,e,r){if((e=!!e)&&this.data)for(var n=0;n<t.length;n++)this.data.push(t[n]);else this.data=t;this.emit(r||"setData",this.data)},e.prototype.emit=function(){for(var t,e=[],r=0;r<arguments.length;r++)0===r?t=arguments[r]:e.push(arguments[r]);if(Array.isArray(this.events[t]))for(var n=0;n<this.events[t].length;n++)this.events[t][n].apply(void 0,e)},e.prototype.subscribe=function(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),{unsubscribe:function(t,e){var r=this.events[t].indexOf(e);this.events[t].splice(r,1)}.bind(this,t,e)}},t.Base=t.Base||{},t.Base.Model=e}(Function("return this")()),function(t){var e=function(t,e){this.name=t,this.func=e};e.prototype.transform=function(t,e){return this.func(t,e)},t.Base=t.Base||{},t.Base.Pipe=e}(Function("return this")()),function(t){var e=function(t){if(!t.hasOwnProperty("path"))throw{message:"[Route] Route must have a path."};if(this.path=t.path.split("/"),t.hasOwnProperty("controller"))this.controller=t.controller;else{if(!t.hasOwnProperty("redirect"))throw{message:"[Route] Route must have a controller."};this.redirect=t.redirect}Array.isArray(t.children)&&(this.children=t.children.map(function(t){return new e(t)}))};e.prototype.checkUrl=function(t,e){var r=0;if(this.path.length>t.length)return!1;for(var n=0;n<this.path.length;n++)this.path[n]===t[n]&&r++;if(this.path.length===r){if(this.redirect)return{redirect:this.redirect};if(Array.isArray(e)||(e=[]),e.push(this.controller),this.path.length<t.length){if(!Array.isArray(this.children))return!1;var i=!1;for(t.splice(0,r),n=0;n<this.children.length;n++)if(this.children[n].checkUrl(t,e)){i=e;break}return i}if(Array.isArray(this.children))for(var s=this.children.filter(function(t){return 1===t.path.length&&""===t.path[0]});Array.isArray(s)&&s.length>0;)s=s[0],e.push(s.controller),Array.isArray(s.children)&&(s=s.children.filter(function(t){return 0===t.path.length}));return{controllers:e}}return!1},t.Base=t.Base||{},t.Base.Route=e}(Function("return this")()),function(t){var e=t.Config.viewOptions,r=function(t,e,r){this.name=t,r?this.templateSrc=r:this.loadTemplate(e),this.buildNodeTree()};r.prototype.loadTemplate=function(t){var r=e.templatesFolder+"/"+t+this.name+".html";r=r.replace(/\/\//g,"/"),this.templateSrc=function(t){var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(),e.responseText}(r)},r.prototype.buildNodeTree=function(){function e(r){for(var n,i=new t.Base.ViewNode(r),s=0;s<r.childNodes.length;s++)(n=e(r.childNodes[s])).parent=i,i.children.push(n);return i}var r=document.createElement("temp");r.innerHTML=this.templateSrc;for(var n=new t.Base.ViewNode(document.createElement(this.name)),i=0;i<r.childNodes.length;i++)n.children.push(e(r.childNodes[i]));this.nodeTree=n},r.prototype.generate=function(e){for(var r=new t.Base.CompNode(this.nodeTree),n=0;n<this.nodeTree.children.length;n++)r.appendChild(this.nodeTree.children[n].generate(e));return r},t.Base=t.Base||{},t.Base.View=r}(Function("return this")()),function(t){var e=function(t){this.self=t,this.children=[],this.parseNode()};e.prototype.parseNode=function(){var e,r,n=this.self.attributes;if(n&&n.length>0)for(var i=0;i<n.length;i++)if(e=n[i].name,r=n[i].value,"controller"===e)this.controller=r;else{var s,o=r.split(" | "),a=t.App.getInjectable(e);if(a instanceof t.Base.Injectable){if(r=o[0],o.splice(0,1),o.length>0){s=[];for(var l=0;l<o.length;l++){var c=o[l].trim().split(/:(.+)/g);c=c.filter(function(t){return t.length>0}),s.push({name:c[0],dataStatement:c[1]})}}Array.isArray(this.directives)||(this.directives=[]),this.directives.push({injectable:a,statement:r,pipes:s}),a.keepAttribute||(this.self.removeAttribute(e),i--)}}},e.prototype.generate=function(e){var r=new t.Base.CompNode(this),n=e.$scope;if(Array.isArray(this.directives)){var i,s;for(r.values=[],s=0;s<this.directives.length&&r.self;s++)if(this.directives[s]){var o=(i=this.directives[s]).injectable.getter(i.statement,e);if(Array.isArray(i.pipes)){var a,l,c;for(a=0;a<i.pipes.length;a++)if(l=i.pipes[a],(c=t.App.getPipe(l.name))instanceof t.Base.Pipe){var h;l.dataStatement&&(h=e.evalWithScope(l.dataStatement)),o=c.transform(o,h)}}if(i.injectable.modifier(r,o),r.values.push(o),r.multipleNodes)break}}if(r.self)if(r.multipleNodes){var p,u=r.iterator.array,f=n[r.iterator.varName],d=this.directives[s],m=s;for(this.directives[s]=void 0,s=0;s<u.length;s++)n[r.iterator.varName]=u[s],(p=this.generate(e)).iteratorValue=u[s],r.appendChild(p),p.isComponent()&&p.bootstrap(e);n[r.iterator.varName]=f,this.directives[m]=d}else!function(t,r){for(var n,i=0;i<t.children.length;i++)n=t.children[i].generate(e),r.appendChild(n),n.replaceSelfWith&&(n.self.parentNode.replaceChild(n.replaceSelfWith.self,n.self),delete n.replaceSelfWith),n.isComponent()&&n.bootstrap(e)}(this,r);return r},t.Base=t.Base||{},t.Base.ViewNode=e}(Function("return this")()),function(t){function e(e){var r=e.getAttribute("controller");if("string"==typeof r){var n=t.App.getController(r);if(n instanceof t.Base.Controller)return n}}t.Core=t.Core||{},t.Core.Bootstrap=function(r,n,i){if(1===r.nodeType){var s=e(r);if(s instanceof t.Base.Controller)return s.generateComponent(r,n,i);throw{message:"Controller "+r.getAttribute("controller")+" not found."}}throw{message:"Cannot bootstrap a non-element object."}}}(Function("return this")()),function(t){var e,r=function(r){if(e)return e;if(!Array.isArray(r))throw{message:"[Router] 'routes' should be an array of routes."};window.onhashchange=function(){this.navigateTo(location.hash,!0)}.bind(this);try{this.routes=r.map(function(e){return new t.Base.Route(e)})}catch(t){throw t}this.navigations=0,e=this,this.navigateTo(location.hash)};r.prototype.navigateTo=function(e,r){if("#"===e[0]&&(e="/"!==e[1]?e.slice(1,e.length):e.slice(2,e.length)),e!==this.currentPath){this.navigating=!0,this.navigations++,this.lastPath=this.currentPath||e,this.currentPath=e;var n=this.parseUrl(e);if(n){var i=n.results;i.redirect?this.navigateTo(i.redirect):("string"==typeof n.params&&n.params.length>0&&(n.params=t.Utils.String.toDictionary(n.params,"&","=")),r?history.replaceState(null,"","#/"+e):history.pushState(null,"","#/"+e),this.stateChange(n))}else console.error("UNKNOWN ROUTE "+e);this.navigating=!1}},r.prototype.parseUrl=function(t){var e=t.split("?"),r=e[1];e=e[0].split("/").filter(function(t){return"#"!==t});for(var n,i=0;i<this.routes.length&&!n;i++)n=this.routes[i].checkUrl(e);return!!n&&{results:n,params:r}},r.prototype.stateChange=function(e){var r=e.results;if(this.state){for(var n,i=0;i<r.controllers.length;i++)if(r.controllers[i]!==this.state.controllers[i]){for(var s=i;s<r.controllers.length;s++)this.state.controllers[s]=r.controllers[s];s<this.state.controllers.length&&this.state.controllers.splice(s,this.state.controllers.length),this.state.nextController=r.controllers[i],n=this.state.compNodes[i];break}if("object"==typeof e.params){for(var o in e.params)e.params.hasOwnProperty(o)&&this.updateParam(o,e.params[o]);for(o in this.state.params)this.state.params.hasOwnProperty(o)&&(e.params[o]||this.updateParam(o))}else{var a=this.state.params;if("object"==typeof a)for(o in a)a.hasOwnProperty(o)&&this.updateParam(o)}if(n instanceof t.Base.CompNode){var l=n.comp,c=n.viewNode.generate(l);n.parent.replaceChild(c,n),c.bootstrap(l.parent)}}else this.state={controllers:r.controllers,params:e.params,nextController:r.controllers[0]}},r.prototype.nextController=function(t){if(this.state&&this.state.nextController){var e=this.state.nextController;this.state.nextController=void 0;for(var r=0;r<this.state.controllers.length;r++)if(e===this.state.controllers[r]){Array.isArray(this.state.compNodes)||(this.state.compNodes=[]),this.state.nextController=this.state.controllers[r+1],this.state.compNodes[r]=t;break}return e}console.error("[Router]","Failed to load next controller, end of list.")},r.prototype.updateParam=function(e,r){var n=this.params(),i=0;if(n[e]!==r&&(r&&0!==r.length?n[e]=r:delete n[e],i++,this.paramSubscriptions)){var s=this.paramSubscriptions[e];s instanceof t.Utils.Observable&&s.next(r)}if(i>0){var o=location.hash;o=o.split("?")[0]+"?";for(var a in n)n.hasOwnProperty(a)&&(o+=a+"="+n[a]+"&");o=o.substr(2,o.length-3),this.navigating?history.replaceState(null,"","#/"+o):history.pushState(null,"","#/"+o),this.currentPath=o}this.state&&(this.state.params=n)},r.prototype.subscribeToParam=function(e,r){"object"!=typeof this.paramSubscriptions&&(this.paramSubscriptions={});var n=this.paramSubscriptions;n[e]instanceof t.Utils.Observable||(n[e]=new t.Utils.Observable);var i=n[e].subscribe(r);return this.state&&this.state.params&&r(this.state.params[e]),i},r.prototype.isLandingPage=function(){return this.lastPath===this.currentPath&&1===this.navigations},r.prototype.params=function(){return this.state&&"object"==typeof this.state.params?this.state.params:{}},t.Core=t.Core||{},t.Core.Router=r}(Function("return this")()),function(t){var e,r={},n={},i={},s={};t.App={getController:function(t){return r[t]},getModel:function(t){return n[t]},getInjectable:function(t){return i[t]},getPipe:function(t){return s[t]},Bootstrap:function(e){var r="[Bootstrap]",n=document.querySelector('*[controller="'+e+'"]');if(n&&1===n.nodeType){try{var i=t.Core.Bootstrap(n)}catch(t){console.error(r,t.message||t)}return i}console.error(r,"Could not find placeholder for '"+e+"'.")},Controller:function(e,n,i){try{var s=new t.Base.View(e,n);r[e]=new t.Base.Controller(e,s,i)}catch(t){console.error("[Controller]",t.message)}},Model:function(e,r){try{n[e]=new t.Base.Model(e,r)}catch(t){console.error("[Model]",t.message)}},Injectable:function(e,r){try{i[e]=new t.Base.Injectable(e,r)}catch(t){console.error("[Injectable]",t.message)}},Pipe:function(e,r){try{s[e]=new t.Base.Pipe(e,r)}catch(t){console.error("[Pipe]",t.message)}},Router:function(r){return e||(e=new t.Core.Router(r)),e}}}(Function("return this")()),function(global){global.App.Injectable("bind-class",{justModify:!0,getter:function(statement,comp){var classes=global.Utils.String.toDictionary(statement),value;try{with(comp.$scope)for(var className in classes)classes.hasOwnProperty(className)&&(value=eval(classes[className]),classes[className]=!!value)}catch(t){throw{message:this.name+": "+t.message}}return classes},modifier:function(t,e){var r=0;for(var n in e)e.hasOwnProperty(n)&&(e[n]?(t.self.classList.add(n),r++):t.self.classList.remove(n));0===r&&0===t.self.classList.length&&t.self.removeAttribute("class")}})}(Function("return this")()),function(global){global.App.Injectable("bind-if",{getter:function(statement,comp){var result;try{with(comp.$scope)result=eval(statement)}catch(t){throw this.name+": Couldn't evaluate '"+statement+"'."}return!!result},modifier:function(t,e){e||(t.self=void 0)}})}(Function("return this")()),Function("return this")().App.Injectable("content-outlet",{getter:function(t,e){return e},modifier:function(t,e){e.subView&&(t.replaceSelfWith=e.subView.generate(e.parent))}}),function(global){global.App.Injectable("bind-events",{getter:function(statement,comp){var events=global.Utils.String.toDictionary(statement),matches,funcName,variables;for(var event in events)if(events.hasOwnProperty(event)){var regEx=new RegExp("^(.+)\\((.*)\\)$");if(matches=events[event].match(regEx),!Array.isArray(matches)||matches.length<2)throw this.name+": Invalid statement, expecting: [event: func()]";funcName=matches[1],variables=matches[2].split(",");for(var i=0;i<variables.length;i++)try{with(comp.$scope)variables[i]=eval(variables[i])}catch(t){throw this.name+": "+t.message}events[event]=function(funcName,variables,el){var func;try{with(comp.$scope)func=eval(funcName)}catch(t){throw this.name+": "+t.message}"function"==typeof func&&func.apply(el,variables)}.bind(this,funcName,variables)}return events},modifier:function(t,e){for(var r in e)e.hasOwnProperty(r)&&t.self.addEventListener(r,function(t,e){e&&e.preventDefault&&e.preventDefault();try{t(e.currentTarget)}catch(t){console.error("[Injectable]",t)}}.bind(this,e[r]))},compare:function(t,e){return!0}})}(Function("return this")()),function(global){global.App.Injectable("input",{getter:function(statement,comp){var inputs=global.Utils.String.toDictionary(statement);try{for(var input in inputs)if(inputs.hasOwnProperty(input))with(comp.$scope)inputs[input]=eval(inputs[input])}catch(t){throw{message:this.name+": "+t.message}}return inputs},modifier:function(t,e){t.inputs=e},compare:function(t,e){var r=!0;for(var n in e)if(e.hasOwnProperty(n)&&e[n]!==t[n]){r=!1;break}return r}})}(Function("return this")()),function(global){global.App.Injectable("bind-for",{getter:function(statement,comp){for(var words=statement.split(" "),result={},w=0;w<words.length;w++)if("in"===words[w]&&w>0&&w<words.length-1){try{with(comp.$scope)result.array=eval(words[w+1])}catch(t){throw t}result.varName=words[w-1]}return result},modifier:function(t,e){t.self=document.createElement("iterator"),t.multipleNodes=!0,t.iterator=e},compare:function(t,e){return t.array===e.array}})}(Function("return this")()),function(t){t.App.Injectable("router-outlet",{getter:function(t,e){return!0},modifier:function(e,r){var n=t.App.Router().nextController(e);t.App.getController(n)instanceof t.Base.Controller&&e.self.setAttribute("controller",n)}})}(Function("return this")()),Function("return this")().App.Injectable("bind-value",{justModify:!0,modifier:function(t,e){t.self instanceof HTMLInputElement&&(t.self.value=e),t.self.innerHTML=e}}); |
@@ -39,3 +39,3 @@ (function(global) { | ||
} catch(err) { | ||
console.log(err.message); | ||
console.error(err.message); | ||
} | ||
@@ -42,0 +42,0 @@ return result; |
@@ -55,3 +55,5 @@ (function(global) { | ||
} | ||
return wasFound | ||
return { | ||
controllers: wasFound | ||
}; | ||
} else if(Array.isArray(this.children)) { | ||
@@ -58,0 +60,0 @@ var child = this.children.filter(function(c) { |
@@ -7,10 +7,6 @@ (function(global) { | ||
this.name = name; | ||
this.relPath = relPath; | ||
if(!template) | ||
this.loadTemplate(relPath); | ||
else { | ||
if(template) | ||
this.templateSrc = template; | ||
} | ||
this.buildNodeTree(); | ||
}; | ||
@@ -58,2 +54,7 @@ | ||
View.prototype.generate = function(comp) { | ||
if(!this.nodeTree) { | ||
this.loadTemplate(this.relPath); | ||
this.buildNodeTree(); | ||
} | ||
var componentTree = new global.Base.CompNode(this.nodeTree); | ||
@@ -60,0 +61,0 @@ for(var c = 0; c < this.nodeTree.children.length; c++) { |
@@ -22,3 +22,3 @@ (function(global) { | ||
// Checking for injectables and saving their pipes & statements. | ||
var pipeSplit = attrValue.split('|'), | ||
var pipeSplit = attrValue.split(' | '), | ||
injectable = global.App.getInjectable(attrName), | ||
@@ -25,0 +25,0 @@ pipes; |
@@ -24,2 +24,3 @@ (function(global) { | ||
this.navigations = 0; | ||
this.onStateChange = new global.Utils.Observable(); | ||
routerInstance = this; | ||
@@ -67,2 +68,3 @@ this.navigateTo(location.hash); | ||
this.navigating = false; | ||
this.onStateChange.next(this.currentPath); | ||
} | ||
@@ -69,0 +71,0 @@ }; |
(function(global) { | ||
var permaParams = {}; | ||
var Http = { | ||
@@ -12,14 +14,5 @@ get: function(url, data, callback) { | ||
} | ||
if(typeof data.params === 'object') { | ||
var urlParams = '?'; | ||
for(var param in data.params) if(data.params.hasOwnProperty(param)) { | ||
if(Array.isArray(data.params[param])) { | ||
for(var i = 0; i < data.params[param].length; i++) | ||
urlParams += param + '=' + data.params[param][i] + '&'; | ||
} else | ||
urlParams += param + '=' + data.params[param] + '&'; | ||
} | ||
url += urlParams; | ||
} | ||
url += getParamString(permaParams, data.params); | ||
xhr.open('GET', url, true); | ||
@@ -36,2 +29,5 @@ | ||
var xhr = new XMLHttpRequest(); | ||
url += getParamString(permaParams, data.params); | ||
xhr.open('POST', url, true); | ||
@@ -45,4 +41,3 @@ | ||
} | ||
if (typeof data.body === 'object') { | ||
if(typeof data.body === 'object') { | ||
data = data.body; | ||
@@ -58,5 +53,37 @@ xhr.setRequestHeader('Content-Type', 'application/json'); | ||
xhr.send(JSON.stringify(data)); | ||
}, | ||
updatePermaParam: function(key, value) { | ||
if(typeof value === 'undefined') | ||
delete permaParams[key]; | ||
else | ||
permaParams[key] = value; | ||
} | ||
}; | ||
function getParamString() { | ||
var params = {}; | ||
for(var i = 0; i < arguments.length; i++) { | ||
var paramsObj = arguments[i]; | ||
for(var p in paramsObj) if(paramsObj.hasOwnProperty(p)) | ||
params[p] = paramsObj[p]; | ||
} | ||
var paramString; | ||
for(var param in params) if(params.hasOwnProperty(param)) { | ||
if(!paramString) paramString = '?'; | ||
switch(typeof params[param]) { | ||
case 'object': | ||
if(Array.isArray(params[param])) | ||
for(var a = 0; a < params[param].length; a++) | ||
paramString += (param + '=' + params[param][a] + '&'); | ||
break; | ||
default: | ||
paramString += (param + '=' + params[param] + '&'); | ||
break; | ||
} | ||
} | ||
return (paramString && paramString.substr(0, paramString.length-1) || ''); | ||
} | ||
global.Utils = global.Utils || {}; | ||
@@ -63,0 +90,0 @@ global.Utils.Http = Http; |
{ | ||
"name": "mvc-lite", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Lite MVC Library using pure EcmaScript5", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
135941
2692