Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

a-template

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-template - npm Package Compare versions

Comparing version 0.2.0 to 0.2.2

LICENSE

197

build/a-template.js

@@ -8,8 +8,4 @@ /**

* author: steelydylan
* version: 0.1.4
* version: 0.2.0
*
* delegate:
* license: MIT (http://opensource.org/licenses/MIT)
* version: 3.1.2
*
* morphdom:

@@ -23,80 +19,2 @@ * license: MIT (http://opensource.org/licenses/MIT)

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.aTemplate = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var DOCUMENT_NODE_TYPE = 9;
/**
* A polyfill for Element.matches()
*/
if (typeof Element !== 'undefined' && !Element.prototype.matches) {
var proto = Element.prototype;
proto.matches = proto.matchesSelector ||
proto.mozMatchesSelector ||
proto.msMatchesSelector ||
proto.oMatchesSelector ||
proto.webkitMatchesSelector;
}
/**
* Finds the closest parent that matches a selector.
*
* @param {Element} element
* @param {String} selector
* @return {Function}
*/
function closest (element, selector) {
while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
if (element.matches(selector)) return element;
element = element.parentNode;
}
}
module.exports = closest;
},{}],2:[function(require,module,exports){
var closest = require('./closest');
/**
* Delegates event to a selector.
*
* @param {Element} element
* @param {String} selector
* @param {String} type
* @param {Function} callback
* @param {Boolean} useCapture
* @return {Object}
*/
function delegate(element, selector, type, callback, useCapture) {
var listenerFn = listener.apply(this, arguments);
element.addEventListener(type, listenerFn, useCapture);
return {
destroy: function() {
element.removeEventListener(type, listenerFn, useCapture);
}
}
}
/**
* Finds closest match and invokes callback.
*
* @param {Element} element
* @param {String} selector
* @param {String} type
* @param {Function} callback
* @return {Function}
*/
function listener(element, selector, type, callback) {
return function(e) {
e.delegateTarget = closest(e.target, selector);
if (e.delegateTarget) {
callback.call(element, e);
}
}
}
module.exports = delegate;
},{"./closest":1}],3:[function(require,module,exports){
'use strict';

@@ -776,4 +694,4 @@

},{}],4:[function(require,module,exports){
'use strict';
},{}],2:[function(require,module,exports){
"use strict";

@@ -785,3 +703,2 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var morphdom = require('morphdom');
var delegate = require('delegate');
var objs = [];

@@ -814,10 +731,8 @@ var eventType = "input paste copy click change keydown keyup contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend";

if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector || function (s) {
var matches = (this.document || this.ownerDocument).querySelectorAll(s),
i = matches.length;
while (--i >= 0 && matches.item(i) !== this) {}
return i > -1;
};
}
var matches = function matches(element, query) {
var matches = (element.document || element.ownerDocument).querySelectorAll(query);
var i = matches.length;
while (--i >= 0 && matches.item(i) !== element) {}
return i > -1;
};

@@ -827,2 +742,3 @@ var selector = function selector(_selector) {

};
var getObjectById = function getObjectById(id) {

@@ -846,3 +762,3 @@ for (var i = 0, n = objs.length; i < n; i++) {

while (element) {
if (element.matches(selector)) {
if (matches(element, selector)) {
return element;

@@ -855,6 +771,13 @@ }

var on = function on(element, query, e, fn) {
var events = e.split(' ');
var on = function on(element, query, eventNames, fn) {
var events = eventNames.split(' ');
events.forEach(function (event) {
delegate(element, query, event, fn);
element.addEventListener(event, function (e) {
var target = e.target;
var delegateTarget = findAncestor(e.target, query);
if (delegateTarget) {
e.delegateTarget = delegateTarget;
fn(e);
}
});
});

@@ -879,3 +802,3 @@ };

var arr = [];
var items = document.querySelectorAll('[data-bind="' + data + '"]');
var items = document.querySelectorAll("[data-bind=\"" + data + "\"]");
[].forEach.call(items, function (item) {

@@ -911,3 +834,3 @@ if (item.checked) {

});
var string = target.getAttribute('data-' + action);
var string = target.getAttribute("data-" + action);
if (!string) {

@@ -952,3 +875,3 @@ return;

var template = this.templates[_i];
var html = selector('#' + template).innerHTML;
var html = selector("#" + template).innerHTML;
this.atemplate.push({ id: template, html: html });

@@ -960,3 +883,3 @@ }

_createClass(aTemplate, [{
key: 'addTemplate',
key: "addTemplate",
value: function addTemplate(id, html) {

@@ -967,3 +890,3 @@ this.atemplate.push({ id: id, html: html });

}, {
key: 'loadHtml',
key: "loadHtml",
value: function loadHtml() {

@@ -975,3 +898,3 @@ var templates = this.templates;

promises.push(d);
var src = selector('#' + template).getAttribute('src');
var src = selector("#" + template).getAttribute('src');
$.ajax({

@@ -982,3 +905,3 @@ url: src,

}).success(function (data) {
selector('#' + template).innerHTML = data;
selector("#" + template).innerHTML = data;
d.resolve();

@@ -990,3 +913,3 @@ });

}, {
key: 'getData',
key: "getData",
value: function getData() {

@@ -996,3 +919,3 @@ return JSON.parse(JSON.stringify(this.data));

}, {
key: 'saveData',
key: "saveData",
value: function saveData(key) {

@@ -1003,3 +926,3 @@ var data = JSON.stringify(this.data);

}, {
key: 'setData',
key: "setData",
value: function setData(val) {

@@ -1013,3 +936,3 @@ for (var i in val) {

}, {
key: 'loadData',
key: "loadData",
value: function loadData(key) {

@@ -1026,3 +949,3 @@ var data = JSON.parse(localStorage.getItem(key));

}, {
key: 'getRand',
key: "getRand",
value: function getRand(a, b) {

@@ -1032,3 +955,3 @@ return ~~(Math.random() * (b - a + 1)) + a;

}, {
key: 'getRandText',
key: "getRandText",
value: function getRandText(limit) {

@@ -1044,3 +967,3 @@ var ret = "";

}, {
key: 'setId',
key: "setId",
value: function setId() {

@@ -1064,3 +987,3 @@ var text = void 0;

}, {
key: 'getDataFromObj',
key: "getDataFromObj",
value: function getDataFromObj(s, o) {

@@ -1081,3 +1004,3 @@ s = s.replace(/\[([a-zA-Z0-9._-]+)\]/g, '.$1'); // convert indexes to properties

}, {
key: 'getDataByString',
key: "getDataByString",
value: function getDataByString(s) {

@@ -1088,3 +1011,3 @@ var o = this.data;

}, {
key: 'updateDataByString',
key: "updateDataByString",
value: function updateDataByString(path, newValue) {

@@ -1099,3 +1022,3 @@ var object = this.data;

}, {
key: 'removeDataByString',
key: "removeDataByString",
value: function removeDataByString(path) {

@@ -1115,3 +1038,3 @@ var object = this.data;

}, {
key: 'resolveBlock',
key: "resolveBlock",
value: function resolveBlock(html, item, i) {

@@ -1222,3 +1145,3 @@ var that = this;

}, {
key: 'resolveAbsBlock',
key: "resolveAbsBlock",
value: function resolveAbsBlock(html) {

@@ -1241,7 +1164,7 @@ var that = this;

}, {
key: 'resolveInclude',
key: "resolveInclude",
value: function resolveInclude(html) {
var include = /<!-- #include id="(.*?)" -->/g;
html = html.replace(include, function (m, key) {
return selector('#' + key).innerHTML;
return selector("#" + key).innerHTML;
});

@@ -1251,3 +1174,3 @@ return html;

}, {
key: 'resolveWith',
key: "resolveWith",
value: function resolveWith(html) {

@@ -1262,3 +1185,3 @@ var width = /<!-- BEGIN ([a-zA-Z0-9._-]+):with -->(([\n\r\t]|.)*?)<!-- END ([a-zA-Z0-9._-]+):with -->/g;

}, {
key: 'resolveLoop',
key: "resolveLoop",
value: function resolveLoop(html) {

@@ -1289,3 +1212,3 @@ var loop = /<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g;

}, {
key: 'removeData',
key: "removeData",
value: function removeData(arr) {

@@ -1303,3 +1226,3 @@ var data = this.data;

}, {
key: 'hasLoop',
key: "hasLoop",
value: function hasLoop(txt) {

@@ -1314,3 +1237,3 @@ var loop = /<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g;

}, {
key: 'getHtml',
key: "getHtml",
value: function getHtml(selector, row) {

@@ -1349,3 +1272,3 @@ var template = this.atemplate.find(function (item) {

}, {
key: 'update',
key: "update",
value: function update(txt, part) {

@@ -1362,10 +1285,10 @@ var html = this.getHtml();

var _html = this.getHtml(tem);
var target = selector('[data-id=\'' + tem + '\']');
var target = selector("[data-id='" + tem + "']");
if (!part || part == tem) {
if (!target) {
selector(query).insertAdjacentHTML('afterend', '<div data-id="' + tem + '"></div>');
selector(query).insertAdjacentHTML('afterend', "<div data-id=\"" + tem + "\"></div>");
if (renderWay === 'text') {
selector('[data-id=\'' + tem + '\']').innerText = _html;
selector("[data-id='" + tem + "']").innerText = _html;
} else {
selector('[data-id=\'' + tem + '\']').innerHTML = _html;
selector("[data-id='" + tem + "']").innerHTML = _html;
}

@@ -1376,3 +1299,3 @@ } else {

} else {
morphdom(target, '<div data-id=\'' + tem + '\'>' + _html + '</div>');
morphdom(target, "<div data-id='" + tem + "'>" + _html + "</div>");
}

@@ -1392,3 +1315,3 @@ }

}, {
key: 'updateBindingData',
key: "updateBindingData",
value: function updateBindingData(part) {

@@ -1401,3 +1324,3 @@ var _this = this;

if (!part || part == temp) {
var template = selector('[data-id=\'' + temp + '\']');
var template = selector("[data-id='" + temp + "']");
var binds = template.querySelectorAll('[data-bind]');

@@ -1422,3 +1345,3 @@ [].forEach.call(binds, function (item) {

}, {
key: 'applyMethod',
key: "applyMethod",
value: function applyMethod(method) {

@@ -1430,3 +1353,3 @@ var args = [].splice.call(arguments, 0);

}, {
key: 'getComputedProp',
key: "getComputedProp",
value: function getComputedProp(prop) {

@@ -1436,3 +1359,3 @@ return this.data[prop].apply(this);

}, {
key: 'remove',
key: "remove",
value: function remove(path) {

@@ -1459,3 +1382,3 @@ var object = this.data;

},{"delegate":2,"morphdom":3}]},{},[4])(4)
},{"morphdom":1}]},{},[2])(2)
});

@@ -8,8 +8,4 @@ /**

* author: steelydylan
* version: 0.1.4
* version: 0.2.0
*
* delegate:
* license: MIT (http://opensource.org/licenses/MIT)
* version: 3.1.2
*
* morphdom:

@@ -22,2 +18,2 @@ * license: MIT (http://opensource.org/licenses/MIT)

*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.aTemplate=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var DOCUMENT_NODE_TYPE=9;if(typeof Element!=="undefined"&&!Element.prototype.matches){var proto=Element.prototype;proto.matches=proto.matchesSelector||proto.mozMatchesSelector||proto.msMatchesSelector||proto.oMatchesSelector||proto.webkitMatchesSelector}function closest(element,selector){while(element&&element.nodeType!==DOCUMENT_NODE_TYPE){if(element.matches(selector))return element;element=element.parentNode}}module.exports=closest},{}],2:[function(require,module,exports){var closest=require("./closest");function delegate(element,selector,type,callback,useCapture){var listenerFn=listener.apply(this,arguments);element.addEventListener(type,listenerFn,useCapture);return{destroy:function(){element.removeEventListener(type,listenerFn,useCapture)}}}function listener(element,selector,type,callback){return function(e){e.delegateTarget=closest(e.target,selector);if(e.delegateTarget){callback.call(element,e)}}}module.exports=delegate},{"./closest":1}],3:[function(require,module,exports){"use strict";var range;var NS_XHTML="http://www.w3.org/1999/xhtml";var doc=typeof document==="undefined"?undefined:document;var testEl=doc?doc.body||doc.createElement("div"):{};var actualHasAttributeNS;if(testEl.hasAttributeNS){actualHasAttributeNS=function(el,namespaceURI,name){return el.hasAttributeNS(namespaceURI,name)}}else if(testEl.hasAttribute){actualHasAttributeNS=function(el,namespaceURI,name){return el.hasAttribute(name)}}else{actualHasAttributeNS=function(el,namespaceURI,name){return el.getAttributeNode(namespaceURI,name)!=null}}var hasAttributeNS=actualHasAttributeNS;function toElement(str){if(!range&&doc.createRange){range=doc.createRange();range.selectNode(doc.body)}var fragment;if(range&&range.createContextualFragment){fragment=range.createContextualFragment(str)}else{fragment=doc.createElement("body");fragment.innerHTML=str}return fragment.childNodes[0]}function compareNodeNames(fromEl,toEl){var fromNodeName=fromEl.nodeName;var toNodeName=toEl.nodeName;if(fromNodeName===toNodeName){return true}if(toEl.actualize&&fromNodeName.charCodeAt(0)<91&&toNodeName.charCodeAt(0)>90){return fromNodeName===toNodeName.toUpperCase()}else{return false}}function createElementNS(name,namespaceURI){return!namespaceURI||namespaceURI===NS_XHTML?doc.createElement(name):doc.createElementNS(namespaceURI,name)}function moveChildren(fromEl,toEl){var curChild=fromEl.firstChild;while(curChild){var nextChild=curChild.nextSibling;toEl.appendChild(curChild);curChild=nextChild}return toEl}function morphAttrs(fromNode,toNode){var attrs=toNode.attributes;var i;var attr;var attrName;var attrNamespaceURI;var attrValue;var fromValue;for(i=attrs.length-1;i>=0;--i){attr=attrs[i];attrName=attr.name;attrNamespaceURI=attr.namespaceURI;attrValue=attr.value;if(attrNamespaceURI){attrName=attr.localName||attrName;fromValue=fromNode.getAttributeNS(attrNamespaceURI,attrName);if(fromValue!==attrValue){fromNode.setAttributeNS(attrNamespaceURI,attrName,attrValue)}}else{fromValue=fromNode.getAttribute(attrName);if(fromValue!==attrValue){fromNode.setAttribute(attrName,attrValue)}}}attrs=fromNode.attributes;for(i=attrs.length-1;i>=0;--i){attr=attrs[i];if(attr.specified!==false){attrName=attr.name;attrNamespaceURI=attr.namespaceURI;if(attrNamespaceURI){attrName=attr.localName||attrName;if(!hasAttributeNS(toNode,attrNamespaceURI,attrName)){fromNode.removeAttributeNS(attrNamespaceURI,attrName)}}else{if(!hasAttributeNS(toNode,null,attrName)){fromNode.removeAttribute(attrName)}}}}}function syncBooleanAttrProp(fromEl,toEl,name){if(fromEl[name]!==toEl[name]){fromEl[name]=toEl[name];if(fromEl[name]){fromEl.setAttribute(name,"")}else{fromEl.removeAttribute(name,"")}}}var specialElHandlers={OPTION:function(fromEl,toEl){syncBooleanAttrProp(fromEl,toEl,"selected")},INPUT:function(fromEl,toEl){syncBooleanAttrProp(fromEl,toEl,"checked");syncBooleanAttrProp(fromEl,toEl,"disabled");if(fromEl.value!==toEl.value){fromEl.value=toEl.value}if(!hasAttributeNS(toEl,null,"value")){fromEl.removeAttribute("value")}},TEXTAREA:function(fromEl,toEl){var newValue=toEl.value;if(fromEl.value!==newValue){fromEl.value=newValue}if(fromEl.firstChild){if(newValue===""&&fromEl.firstChild.nodeValue===fromEl.placeholder){return}fromEl.firstChild.nodeValue=newValue}},SELECT:function(fromEl,toEl){if(!hasAttributeNS(toEl,null,"multiple")){var selectedIndex=-1;var i=0;var curChild=toEl.firstChild;while(curChild){var nodeName=curChild.nodeName;if(nodeName&&nodeName.toUpperCase()==="OPTION"){if(hasAttributeNS(curChild,null,"selected")){selectedIndex=i;break}i++}curChild=curChild.nextSibling}fromEl.selectedIndex=i}}};var ELEMENT_NODE=1;var TEXT_NODE=3;var COMMENT_NODE=8;function noop(){}function defaultGetNodeKey(node){return node.id}function morphdomFactory(morphAttrs){return function morphdom(fromNode,toNode,options){if(!options){options={}}if(typeof toNode==="string"){if(fromNode.nodeName==="#document"||fromNode.nodeName==="HTML"){var toNodeHtml=toNode;toNode=doc.createElement("html");toNode.innerHTML=toNodeHtml}else{toNode=toElement(toNode)}}var getNodeKey=options.getNodeKey||defaultGetNodeKey;var onBeforeNodeAdded=options.onBeforeNodeAdded||noop;var onNodeAdded=options.onNodeAdded||noop;var onBeforeElUpdated=options.onBeforeElUpdated||noop;var onElUpdated=options.onElUpdated||noop;var onBeforeNodeDiscarded=options.onBeforeNodeDiscarded||noop;var onNodeDiscarded=options.onNodeDiscarded||noop;var onBeforeElChildrenUpdated=options.onBeforeElChildrenUpdated||noop;var childrenOnly=options.childrenOnly===true;var fromNodesLookup={};var keyedRemovalList;function addKeyedRemoval(key){if(keyedRemovalList){keyedRemovalList.push(key)}else{keyedRemovalList=[key]}}function walkDiscardedChildNodes(node,skipKeyedNodes){if(node.nodeType===ELEMENT_NODE){var curChild=node.firstChild;while(curChild){var key=undefined;if(skipKeyedNodes&&(key=getNodeKey(curChild))){addKeyedRemoval(key)}else{onNodeDiscarded(curChild);if(curChild.firstChild){walkDiscardedChildNodes(curChild,skipKeyedNodes)}}curChild=curChild.nextSibling}}}function removeNode(node,parentNode,skipKeyedNodes){if(onBeforeNodeDiscarded(node)===false){return}if(parentNode){parentNode.removeChild(node)}onNodeDiscarded(node);walkDiscardedChildNodes(node,skipKeyedNodes)}function indexTree(node){if(node.nodeType===ELEMENT_NODE){var curChild=node.firstChild;while(curChild){var key=getNodeKey(curChild);if(key){fromNodesLookup[key]=curChild}indexTree(curChild);curChild=curChild.nextSibling}}}indexTree(fromNode);function handleNodeAdded(el){onNodeAdded(el);var curChild=el.firstChild;while(curChild){var nextSibling=curChild.nextSibling;var key=getNodeKey(curChild);if(key){var unmatchedFromEl=fromNodesLookup[key];if(unmatchedFromEl&&compareNodeNames(curChild,unmatchedFromEl)){curChild.parentNode.replaceChild(unmatchedFromEl,curChild);morphEl(unmatchedFromEl,curChild)}}handleNodeAdded(curChild);curChild=nextSibling}}function morphEl(fromEl,toEl,childrenOnly){var toElKey=getNodeKey(toEl);var curFromNodeKey;if(toElKey){delete fromNodesLookup[toElKey]}if(toNode.isSameNode&&toNode.isSameNode(fromNode)){return}if(!childrenOnly){if(onBeforeElUpdated(fromEl,toEl)===false){return}morphAttrs(fromEl,toEl);onElUpdated(fromEl);if(onBeforeElChildrenUpdated(fromEl,toEl)===false){return}}if(fromEl.nodeName!=="TEXTAREA"){var curToNodeChild=toEl.firstChild;var curFromNodeChild=fromEl.firstChild;var curToNodeKey;var fromNextSibling;var toNextSibling;var matchingFromEl;outer:while(curToNodeChild){toNextSibling=curToNodeChild.nextSibling;curToNodeKey=getNodeKey(curToNodeChild);while(curFromNodeChild){fromNextSibling=curFromNodeChild.nextSibling;if(curToNodeChild.isSameNode&&curToNodeChild.isSameNode(curFromNodeChild)){curToNodeChild=toNextSibling;curFromNodeChild=fromNextSibling;continue outer}curFromNodeKey=getNodeKey(curFromNodeChild);var curFromNodeType=curFromNodeChild.nodeType;var isCompatible=undefined;if(curFromNodeType===curToNodeChild.nodeType){if(curFromNodeType===ELEMENT_NODE){if(curToNodeKey){if(curToNodeKey!==curFromNodeKey){if(matchingFromEl=fromNodesLookup[curToNodeKey]){if(curFromNodeChild.nextSibling===matchingFromEl){isCompatible=false}else{fromEl.insertBefore(matchingFromEl,curFromNodeChild);fromNextSibling=curFromNodeChild.nextSibling;if(curFromNodeKey){addKeyedRemoval(curFromNodeKey)}else{removeNode(curFromNodeChild,fromEl,true)}curFromNodeChild=matchingFromEl}}else{isCompatible=false}}}else if(curFromNodeKey){isCompatible=false}isCompatible=isCompatible!==false&&compareNodeNames(curFromNodeChild,curToNodeChild);if(isCompatible){morphEl(curFromNodeChild,curToNodeChild)}}else if(curFromNodeType===TEXT_NODE||curFromNodeType==COMMENT_NODE){isCompatible=true;curFromNodeChild.nodeValue=curToNodeChild.nodeValue}}if(isCompatible){curToNodeChild=toNextSibling;curFromNodeChild=fromNextSibling;continue outer}if(curFromNodeKey){addKeyedRemoval(curFromNodeKey)}else{removeNode(curFromNodeChild,fromEl,true)}curFromNodeChild=fromNextSibling}if(curToNodeKey&&(matchingFromEl=fromNodesLookup[curToNodeKey])&&compareNodeNames(matchingFromEl,curToNodeChild)){fromEl.appendChild(matchingFromEl);morphEl(matchingFromEl,curToNodeChild)}else{var onBeforeNodeAddedResult=onBeforeNodeAdded(curToNodeChild);if(onBeforeNodeAddedResult!==false){if(onBeforeNodeAddedResult){curToNodeChild=onBeforeNodeAddedResult}if(curToNodeChild.actualize){curToNodeChild=curToNodeChild.actualize(fromEl.ownerDocument||doc)}fromEl.appendChild(curToNodeChild);handleNodeAdded(curToNodeChild)}}curToNodeChild=toNextSibling;curFromNodeChild=fromNextSibling}while(curFromNodeChild){fromNextSibling=curFromNodeChild.nextSibling;if(curFromNodeKey=getNodeKey(curFromNodeChild)){addKeyedRemoval(curFromNodeKey)}else{removeNode(curFromNodeChild,fromEl,true)}curFromNodeChild=fromNextSibling}}var specialElHandler=specialElHandlers[fromEl.nodeName];if(specialElHandler){specialElHandler(fromEl,toEl)}}var morphedNode=fromNode;var morphedNodeType=morphedNode.nodeType;var toNodeType=toNode.nodeType;if(!childrenOnly){if(morphedNodeType===ELEMENT_NODE){if(toNodeType===ELEMENT_NODE){if(!compareNodeNames(fromNode,toNode)){onNodeDiscarded(fromNode);morphedNode=moveChildren(fromNode,createElementNS(toNode.nodeName,toNode.namespaceURI))}}else{morphedNode=toNode}}else if(morphedNodeType===TEXT_NODE||morphedNodeType===COMMENT_NODE){if(toNodeType===morphedNodeType){morphedNode.nodeValue=toNode.nodeValue;return morphedNode}else{morphedNode=toNode}}}if(morphedNode===toNode){onNodeDiscarded(fromNode)}else{morphEl(morphedNode,toNode,childrenOnly);if(keyedRemovalList){for(var i=0,len=keyedRemovalList.length;i<len;i++){var elToRemove=fromNodesLookup[keyedRemovalList[i]];if(elToRemove){removeNode(elToRemove,elToRemove.parentNode,false)}}}}if(!childrenOnly&&morphedNode!==fromNode&&fromNode.parentNode){if(morphedNode.actualize){morphedNode=morphedNode.actualize(fromNode.ownerDocument||doc)}fromNode.parentNode.replaceChild(morphedNode,fromNode)}return morphedNode}}var morphdom=morphdomFactory(morphAttrs);module.exports=morphdom},{}],4:[function(require,module,exports){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var morphdom=require("morphdom");var delegate=require("delegate");var objs=[];var eventType="input paste copy click change keydown keyup contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend";var dataAction=eventType.replace(/([a-z]+)/g,"[data-action-$1],")+"[data-action]";if(!Array.prototype.find){Array.prototype.find=function(predicate){if(this===null){throw new TypeError("Array.prototype.find called on null or undefined")}if(typeof predicate!=="function"){throw new TypeError("predicate must be a function")}var list=Object(this);var length=list.length>>>0;var thisArg=arguments[1];var value=void 0;for(var i=0;i<length;i++){value=list[i];if(predicate.call(thisArg,value,i,list)){return value}}return undefined}}if(!Element.prototype.matches){Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(s){var matches=(this.document||this.ownerDocument).querySelectorAll(s),i=matches.length;while(--i>=0&&matches.item(i)!==this){}return i>-1}}var selector=function selector(_selector){return document.querySelector(_selector)};var getObjectById=function getObjectById(id){for(var i=0,n=objs.length;i<n;i++){var obj=objs[i];var templates=obj.templates;for(var t=0,m=templates.length;t<m;t++){if(templates[t]==id){return obj}}}return null};var findAncestor=function findAncestor(element,selector){if(typeof element.closest==="function"){return element.closest(selector)||null}while(element){if(element.matches(selector)){return element}element=element.parentElement}return null};var on=function on(element,query,e,fn){var events=e.split(" ");events.forEach(function(event){delegate(element,query,event,fn)})};if(typeof document!=="undefined"){on(document,"[data-bind]","input change click",function(e){var target=e.delegateTarget;var data=target.getAttribute("data-bind");var attr=target.getAttribute("href");var id=findAncestor(target,"[data-id]").getAttribute("data-id");var value=target.value;if(attr){value=value.replace("#","")}if(id){var obj=getObjectById(id);if(target.getAttribute("type")==="radio"){}else if(target.getAttribute("type")==="checkbox"){(function(){var arr=[];var items=document.querySelectorAll('[data-bind="'+data+'"]');[].forEach.call(items,function(item){if(item.checked){arr.push(item.value)}})})()}else{obj.updateDataByString(data,value)}}});on(document,dataAction,eventType,function(e){var target=e.delegateTarget;if(e.type==="click"&&target.tagName==="select"){return}if(e.type==="input"&&target.getAttribute("type")==="button"){return}var events=eventType.split(" ");var action="action";events.forEach(function(event){if(target.getAttribute("data-action-"+event)){if(e.type===event){action+="-"+event}}});var string=target.getAttribute("data-"+action);if(!string){return}var method=string.replace(/\(.*?\);?/,"");var parameter=string.replace(/(.*?)\((.*?)\);?/,"$2");var pts=parameter.split(",");var id=findAncestor(target,"[data-id]").getAttribute("data-id");if(!id){return}var obj=getObjectById(id);obj.e=e;if(obj.method&&obj.method[method]){obj.method[method].apply(obj,pts)}else if(obj[method]){obj[method].apply(obj,pts)}})}var aTemplate=function(){function aTemplate(opt){_classCallCheck(this,aTemplate);this.atemplate=[];objs.push(this);for(var i in opt){this[i]=opt[i]}if(!this.data){this.data={}}if(!this.templates){this.templates=[]}var templates=this.templates;var length=templates.length;for(var _i=0,n=length;_i<n;_i++){var template=this.templates[_i];var html=selector("#"+template).innerHTML;this.atemplate.push({id:template,html:html})}this.setId()}_createClass(aTemplate,[{key:"addTemplate",value:function addTemplate(id,html){this.atemplate.push({id:id,html:html});this.templates.push(id)}},{key:"loadHtml",value:function loadHtml(){var templates=this.templates;var promises=[];templates.forEach(function(template){var d=new $.Deferred;promises.push(d);var src=selector("#"+template).getAttribute("src");$.ajax({url:src,type:"GET",dataType:"text"}).success(function(data){selector("#"+template).innerHTML=data;d.resolve()})});return $.when.apply($,promises)}},{key:"getData",value:function getData(){return JSON.parse(JSON.stringify(this.data))}},{key:"saveData",value:function saveData(key){var data=JSON.stringify(this.data);localStorage.setItem(key,data)}},{key:"setData",value:function setData(val){for(var i in val){if(typeof val[i]!=="function"){this.data[i]=val[i]}}}},{key:"loadData",value:function loadData(key){var data=JSON.parse(localStorage.getItem(key));if(data){for(var i in data){if(typeof data[i]!=="function"){this.data[i]=data[i]}}}}},{key:"getRand",value:function getRand(a,b){return~~(Math.random()*(b-a+1))+a}},{key:"getRandText",value:function getRandText(limit){var ret="";var strings="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";var length=strings.length;for(var i=0;i<limit;i++){ret+=strings.charAt(Math.floor(this.getRand(0,length)))}return ret}},{key:"setId",value:function setId(){var text=void 0;var ids=aTemplate.ids;var flag=false;while(1){text=this.getRandText(10);for(var i=0,n=aTemplate.ids;i<n;i++){if(aTemplate.ids[i]===text){flag=true}}if(flag===false){break}}this.data.aTemplate_id=text}},{key:"getDataFromObj",value:function getDataFromObj(s,o){s=s.replace(/\[([a-zA-Z0-9._-]+)\]/g,".$1");s=s.replace(/^\./,"");var a=s.split(".");while(a.length){var n=a.shift();if(n in o){o=o[n]}else{return}}return o}},{key:"getDataByString",value:function getDataByString(s){var o=this.data;return this.getDataFromObj(s,o)}},{key:"updateDataByString",value:function updateDataByString(path,newValue){var object=this.data;var stack=path.split(".");while(stack.length>1){object=object[stack.shift()]}object[stack.shift()]=newValue}},{key:"removeDataByString",value:function removeDataByString(path){var object=this.data;var stack=path.split(".");while(stack.length>1){object=object[stack.shift()]}var shift=stack.shift();if(shift.match(/^\d+$/)){object.splice(Number(shift),1)}else{delete object[shift]}}},{key:"resolveBlock",value:function resolveBlock(html,item,i){var that=this;var touchs=html.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):touch#([a-zA-Z0-9._-]+) -->/g);var touchnots=html.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):touchnot#([a-zA-Z0-9._-]+) -->/g);var exists=html.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):exist -->/g);var empties=html.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):empty -->/g);if(touchs){for(var k=0,n=touchs.length;k<n;k++){var start=touchs[k];start=start.replace(/([a-zA-Z0-9._-]+):touch#([a-zA-Z0-9._-]+)/,"($1):touch#($2)");var end=start.replace(/BEGIN/,"END");var reg=new RegExp(start+"(([\\n\\r\\t]|.)*?)"+end,"g");html=html.replace(reg,function(m,key2,val,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(itemkey==val){return next}else{return""}})}}if(touchnots){for(var _k=0,_n=touchnots.length;_k<_n;_k++){var _start=touchnots[_k];_start=_start.replace(/([a-zA-Z0-9._-]+):touchnot#([a-zA-Z0-9._-]+)/,"($1):touchnot#($2)");var _end=_start.replace(/BEGIN/,"END");var _reg=new RegExp(_start+"(([\\n\\r\\t]|.)*?)"+_end,"g");html=html.replace(_reg,function(m,key2,val,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(itemkey!=val){return next}else{return""}})}}if(exists){for(var _k2=0,_n2=exists.length;_k2<_n2;_k2++){var _start2=exists[_k2];_start2=_start2.replace(/([a-zA-Z0-9._-]+):exist/,"($1):exist");var _end2=_start2.replace(/BEGIN/,"END");var _reg2=new RegExp(_start2+"(([\\n\\r\\t]|.)*?)"+_end2,"g");html=html.replace(_reg2,function(m,key2,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(itemkey||itemkey===0){return next}else{return""}})}}if(empties){for(var _k3=0,_n3=empties.length;_k3<_n3;_k3++){var _start3=empties[_k3];_start3=_start3.replace(/([a-zA-Z0-9._-]+):empty/,"($1):empty");var _end3=_start3.replace(/BEGIN/,"END");var empty=new RegExp(_start3+"(([\\n\\r\\t]|.)*?)"+_end3,"g");html=html.replace(empty,function(m,key2,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(!itemkey&&itemkey!==0){return next}else{return""}})}}html=html.replace(/{([a-zA-Z0-9._-]+)}(\[([a-zA-Z0-9._-]+)\])*/g,function(n,key3,key4,converter){var data=void 0;if(key3=="i"){data=i}else{if(item[key3]||item[key3]===0){if(typeof item[key3]==="function"){data=item[key3].apply(that)}else{data=item[key3]}}else{if(converter&&that.convert&&that.convert[converter]){return that.convert[converter].call(that,"")}else{return""}}}if(converter&&that.convert&&that.convert[converter]){return that.convert[converter].call(that,data)}else{return data}});return html}},{key:"resolveAbsBlock",value:function resolveAbsBlock(html){var that=this;html=html.replace(/{(.*?)}/g,function(n,key3){var data=that.getDataByString(key3);if(typeof data!=="undefined"){if(typeof data==="function"){return data.apply(that)}else{return data}}else{return n}});return html}},{key:"resolveInclude",value:function resolveInclude(html){var include=/<!-- #include id="(.*?)" -->/g;html=html.replace(include,function(m,key){return selector("#"+key).innerHTML});return html}},{key:"resolveWith",value:function resolveWith(html){var width=/<!-- BEGIN ([a-zA-Z0-9._-]+):with -->(([\n\r\t]|.)*?)<!-- END ([a-zA-Z0-9._-]+):with -->/g;html=html.replace(width,function(m,key,val){m=m.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+key+".$1'");return m});return html}},{key:"resolveLoop",value:function resolveLoop(html){var loop=/<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g;var that=this;html=html.replace(loop,function(m,key,val){var keyItem=that.getDataByString(key);var keys=[];if(typeof keyItem==="function"){keys=keyItem.apply(that)}else{keys=keyItem}var ret="";if(keys instanceof Array){for(var i=0,n=keys.length;i<n;i++){ret+=that.resolveBlock(val,keys[i],i)}}ret=ret.replace(/\\([^\\])/g,"$1");return ret});return html}},{key:"removeData",value:function removeData(arr){var data=this.data;for(var i in data){for(var t=0,n=arr.length;t<n;t++){if(i===arr[t]){delete data[i]}}}return this}},{key:"hasLoop",value:function hasLoop(txt){var loop=/<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g;if(txt.match(loop)){return true}else{return false}}},{key:"getHtml",value:function getHtml(selector,row){var template=this.atemplate.find(function(item){return item.id===selector});var html="";if(template&&template.html){html=template.html}if(row){html=selector}if(!html){return""}var data=this.data;html=this.resolveInclude(html);html=this.resolveWith(html);while(this.hasLoop(html)){html=this.resolveLoop(html)}html=this.resolveBlock(html,data);html=html.replace(/\\([^\\])/g,"$1");html=this.resolveAbsBlock(html);return html.replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function update(txt,part){var html=this.getHtml();var templates=this.templates;var renderWay=txt||"html";if(this.beforeUpdated){this.beforeUpdated()}for(var i=0,n=templates.length;i<n;i++){var tem=templates[i];var query="#"+tem;var _html=this.getHtml(tem);var target=selector("[data-id='"+tem+"']");if(!part||part==tem){if(!target){selector(query).insertAdjacentHTML("afterend",'<div data-id="'+tem+'"></div>');if(renderWay==="text"){selector("[data-id='"+tem+"']").innerText=_html}else{selector("[data-id='"+tem+"']").innerHTML=_html}}else{if(renderWay==="text"){target.innerText=_html}else{morphdom(target,"<div data-id='"+tem+"'>"+_html+"</div>")}}if(part){break}}}this.updateBindingData(part);if(this.onUpdated){this.onUpdated(part)}return this}},{key:"updateBindingData",value:function updateBindingData(part){var _this=this;var templates=this.templates;for(var i=0,n=templates.length;i<n;i++){var temp=templates[i];if(!part||part==temp){var template=selector("[data-id='"+temp+"']");var binds=template.querySelectorAll("[data-bind]");[].forEach.call(binds,function(item){var data=_this.getDataByString(item.getAttribute("data-bind"));if(item.getAttribute("type")==="checkbox"||item.getAttribute("type")==="radio"){if(data==item.value){item.checked=true}}else{item.value=data}});if(part){break}}}return this}},{key:"applyMethod",value:function applyMethod(method){var args=[].splice.call(arguments,0);args.shift();return this.method[method].apply(this,args)}},{key:"getComputedProp",value:function getComputedProp(prop){return this.data[prop].apply(this)}},{key:"remove",value:function remove(path){var object=this.data;var stack=path.split(".");while(stack.length>1){object=object[stack.shift()]}var shift=stack.shift();if(shift.match(/^\d+$/)){object.splice(Number(shift),1)}else{delete object[shift]}return this}}]);return aTemplate}();module.exports=aTemplate},{delegate:2,morphdom:3}]},{},[4])(4)});
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.aTemplate=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";var range;var NS_XHTML="http://www.w3.org/1999/xhtml";var doc=typeof document==="undefined"?undefined:document;var testEl=doc?doc.body||doc.createElement("div"):{};var actualHasAttributeNS;if(testEl.hasAttributeNS){actualHasAttributeNS=function(el,namespaceURI,name){return el.hasAttributeNS(namespaceURI,name)}}else if(testEl.hasAttribute){actualHasAttributeNS=function(el,namespaceURI,name){return el.hasAttribute(name)}}else{actualHasAttributeNS=function(el,namespaceURI,name){return el.getAttributeNode(namespaceURI,name)!=null}}var hasAttributeNS=actualHasAttributeNS;function toElement(str){if(!range&&doc.createRange){range=doc.createRange();range.selectNode(doc.body)}var fragment;if(range&&range.createContextualFragment){fragment=range.createContextualFragment(str)}else{fragment=doc.createElement("body");fragment.innerHTML=str}return fragment.childNodes[0]}function compareNodeNames(fromEl,toEl){var fromNodeName=fromEl.nodeName;var toNodeName=toEl.nodeName;if(fromNodeName===toNodeName){return true}if(toEl.actualize&&fromNodeName.charCodeAt(0)<91&&toNodeName.charCodeAt(0)>90){return fromNodeName===toNodeName.toUpperCase()}else{return false}}function createElementNS(name,namespaceURI){return!namespaceURI||namespaceURI===NS_XHTML?doc.createElement(name):doc.createElementNS(namespaceURI,name)}function moveChildren(fromEl,toEl){var curChild=fromEl.firstChild;while(curChild){var nextChild=curChild.nextSibling;toEl.appendChild(curChild);curChild=nextChild}return toEl}function morphAttrs(fromNode,toNode){var attrs=toNode.attributes;var i;var attr;var attrName;var attrNamespaceURI;var attrValue;var fromValue;for(i=attrs.length-1;i>=0;--i){attr=attrs[i];attrName=attr.name;attrNamespaceURI=attr.namespaceURI;attrValue=attr.value;if(attrNamespaceURI){attrName=attr.localName||attrName;fromValue=fromNode.getAttributeNS(attrNamespaceURI,attrName);if(fromValue!==attrValue){fromNode.setAttributeNS(attrNamespaceURI,attrName,attrValue)}}else{fromValue=fromNode.getAttribute(attrName);if(fromValue!==attrValue){fromNode.setAttribute(attrName,attrValue)}}}attrs=fromNode.attributes;for(i=attrs.length-1;i>=0;--i){attr=attrs[i];if(attr.specified!==false){attrName=attr.name;attrNamespaceURI=attr.namespaceURI;if(attrNamespaceURI){attrName=attr.localName||attrName;if(!hasAttributeNS(toNode,attrNamespaceURI,attrName)){fromNode.removeAttributeNS(attrNamespaceURI,attrName)}}else{if(!hasAttributeNS(toNode,null,attrName)){fromNode.removeAttribute(attrName)}}}}}function syncBooleanAttrProp(fromEl,toEl,name){if(fromEl[name]!==toEl[name]){fromEl[name]=toEl[name];if(fromEl[name]){fromEl.setAttribute(name,"")}else{fromEl.removeAttribute(name,"")}}}var specialElHandlers={OPTION:function(fromEl,toEl){syncBooleanAttrProp(fromEl,toEl,"selected")},INPUT:function(fromEl,toEl){syncBooleanAttrProp(fromEl,toEl,"checked");syncBooleanAttrProp(fromEl,toEl,"disabled");if(fromEl.value!==toEl.value){fromEl.value=toEl.value}if(!hasAttributeNS(toEl,null,"value")){fromEl.removeAttribute("value")}},TEXTAREA:function(fromEl,toEl){var newValue=toEl.value;if(fromEl.value!==newValue){fromEl.value=newValue}if(fromEl.firstChild){if(newValue===""&&fromEl.firstChild.nodeValue===fromEl.placeholder){return}fromEl.firstChild.nodeValue=newValue}},SELECT:function(fromEl,toEl){if(!hasAttributeNS(toEl,null,"multiple")){var selectedIndex=-1;var i=0;var curChild=toEl.firstChild;while(curChild){var nodeName=curChild.nodeName;if(nodeName&&nodeName.toUpperCase()==="OPTION"){if(hasAttributeNS(curChild,null,"selected")){selectedIndex=i;break}i++}curChild=curChild.nextSibling}fromEl.selectedIndex=i}}};var ELEMENT_NODE=1;var TEXT_NODE=3;var COMMENT_NODE=8;function noop(){}function defaultGetNodeKey(node){return node.id}function morphdomFactory(morphAttrs){return function morphdom(fromNode,toNode,options){if(!options){options={}}if(typeof toNode==="string"){if(fromNode.nodeName==="#document"||fromNode.nodeName==="HTML"){var toNodeHtml=toNode;toNode=doc.createElement("html");toNode.innerHTML=toNodeHtml}else{toNode=toElement(toNode)}}var getNodeKey=options.getNodeKey||defaultGetNodeKey;var onBeforeNodeAdded=options.onBeforeNodeAdded||noop;var onNodeAdded=options.onNodeAdded||noop;var onBeforeElUpdated=options.onBeforeElUpdated||noop;var onElUpdated=options.onElUpdated||noop;var onBeforeNodeDiscarded=options.onBeforeNodeDiscarded||noop;var onNodeDiscarded=options.onNodeDiscarded||noop;var onBeforeElChildrenUpdated=options.onBeforeElChildrenUpdated||noop;var childrenOnly=options.childrenOnly===true;var fromNodesLookup={};var keyedRemovalList;function addKeyedRemoval(key){if(keyedRemovalList){keyedRemovalList.push(key)}else{keyedRemovalList=[key]}}function walkDiscardedChildNodes(node,skipKeyedNodes){if(node.nodeType===ELEMENT_NODE){var curChild=node.firstChild;while(curChild){var key=undefined;if(skipKeyedNodes&&(key=getNodeKey(curChild))){addKeyedRemoval(key)}else{onNodeDiscarded(curChild);if(curChild.firstChild){walkDiscardedChildNodes(curChild,skipKeyedNodes)}}curChild=curChild.nextSibling}}}function removeNode(node,parentNode,skipKeyedNodes){if(onBeforeNodeDiscarded(node)===false){return}if(parentNode){parentNode.removeChild(node)}onNodeDiscarded(node);walkDiscardedChildNodes(node,skipKeyedNodes)}function indexTree(node){if(node.nodeType===ELEMENT_NODE){var curChild=node.firstChild;while(curChild){var key=getNodeKey(curChild);if(key){fromNodesLookup[key]=curChild}indexTree(curChild);curChild=curChild.nextSibling}}}indexTree(fromNode);function handleNodeAdded(el){onNodeAdded(el);var curChild=el.firstChild;while(curChild){var nextSibling=curChild.nextSibling;var key=getNodeKey(curChild);if(key){var unmatchedFromEl=fromNodesLookup[key];if(unmatchedFromEl&&compareNodeNames(curChild,unmatchedFromEl)){curChild.parentNode.replaceChild(unmatchedFromEl,curChild);morphEl(unmatchedFromEl,curChild)}}handleNodeAdded(curChild);curChild=nextSibling}}function morphEl(fromEl,toEl,childrenOnly){var toElKey=getNodeKey(toEl);var curFromNodeKey;if(toElKey){delete fromNodesLookup[toElKey]}if(toNode.isSameNode&&toNode.isSameNode(fromNode)){return}if(!childrenOnly){if(onBeforeElUpdated(fromEl,toEl)===false){return}morphAttrs(fromEl,toEl);onElUpdated(fromEl);if(onBeforeElChildrenUpdated(fromEl,toEl)===false){return}}if(fromEl.nodeName!=="TEXTAREA"){var curToNodeChild=toEl.firstChild;var curFromNodeChild=fromEl.firstChild;var curToNodeKey;var fromNextSibling;var toNextSibling;var matchingFromEl;outer:while(curToNodeChild){toNextSibling=curToNodeChild.nextSibling;curToNodeKey=getNodeKey(curToNodeChild);while(curFromNodeChild){fromNextSibling=curFromNodeChild.nextSibling;if(curToNodeChild.isSameNode&&curToNodeChild.isSameNode(curFromNodeChild)){curToNodeChild=toNextSibling;curFromNodeChild=fromNextSibling;continue outer}curFromNodeKey=getNodeKey(curFromNodeChild);var curFromNodeType=curFromNodeChild.nodeType;var isCompatible=undefined;if(curFromNodeType===curToNodeChild.nodeType){if(curFromNodeType===ELEMENT_NODE){if(curToNodeKey){if(curToNodeKey!==curFromNodeKey){if(matchingFromEl=fromNodesLookup[curToNodeKey]){if(curFromNodeChild.nextSibling===matchingFromEl){isCompatible=false}else{fromEl.insertBefore(matchingFromEl,curFromNodeChild);fromNextSibling=curFromNodeChild.nextSibling;if(curFromNodeKey){addKeyedRemoval(curFromNodeKey)}else{removeNode(curFromNodeChild,fromEl,true)}curFromNodeChild=matchingFromEl}}else{isCompatible=false}}}else if(curFromNodeKey){isCompatible=false}isCompatible=isCompatible!==false&&compareNodeNames(curFromNodeChild,curToNodeChild);if(isCompatible){morphEl(curFromNodeChild,curToNodeChild)}}else if(curFromNodeType===TEXT_NODE||curFromNodeType==COMMENT_NODE){isCompatible=true;curFromNodeChild.nodeValue=curToNodeChild.nodeValue}}if(isCompatible){curToNodeChild=toNextSibling;curFromNodeChild=fromNextSibling;continue outer}if(curFromNodeKey){addKeyedRemoval(curFromNodeKey)}else{removeNode(curFromNodeChild,fromEl,true)}curFromNodeChild=fromNextSibling}if(curToNodeKey&&(matchingFromEl=fromNodesLookup[curToNodeKey])&&compareNodeNames(matchingFromEl,curToNodeChild)){fromEl.appendChild(matchingFromEl);morphEl(matchingFromEl,curToNodeChild)}else{var onBeforeNodeAddedResult=onBeforeNodeAdded(curToNodeChild);if(onBeforeNodeAddedResult!==false){if(onBeforeNodeAddedResult){curToNodeChild=onBeforeNodeAddedResult}if(curToNodeChild.actualize){curToNodeChild=curToNodeChild.actualize(fromEl.ownerDocument||doc)}fromEl.appendChild(curToNodeChild);handleNodeAdded(curToNodeChild)}}curToNodeChild=toNextSibling;curFromNodeChild=fromNextSibling}while(curFromNodeChild){fromNextSibling=curFromNodeChild.nextSibling;if(curFromNodeKey=getNodeKey(curFromNodeChild)){addKeyedRemoval(curFromNodeKey)}else{removeNode(curFromNodeChild,fromEl,true)}curFromNodeChild=fromNextSibling}}var specialElHandler=specialElHandlers[fromEl.nodeName];if(specialElHandler){specialElHandler(fromEl,toEl)}}var morphedNode=fromNode;var morphedNodeType=morphedNode.nodeType;var toNodeType=toNode.nodeType;if(!childrenOnly){if(morphedNodeType===ELEMENT_NODE){if(toNodeType===ELEMENT_NODE){if(!compareNodeNames(fromNode,toNode)){onNodeDiscarded(fromNode);morphedNode=moveChildren(fromNode,createElementNS(toNode.nodeName,toNode.namespaceURI))}}else{morphedNode=toNode}}else if(morphedNodeType===TEXT_NODE||morphedNodeType===COMMENT_NODE){if(toNodeType===morphedNodeType){morphedNode.nodeValue=toNode.nodeValue;return morphedNode}else{morphedNode=toNode}}}if(morphedNode===toNode){onNodeDiscarded(fromNode)}else{morphEl(morphedNode,toNode,childrenOnly);if(keyedRemovalList){for(var i=0,len=keyedRemovalList.length;i<len;i++){var elToRemove=fromNodesLookup[keyedRemovalList[i]];if(elToRemove){removeNode(elToRemove,elToRemove.parentNode,false)}}}}if(!childrenOnly&&morphedNode!==fromNode&&fromNode.parentNode){if(morphedNode.actualize){morphedNode=morphedNode.actualize(fromNode.ownerDocument||doc)}fromNode.parentNode.replaceChild(morphedNode,fromNode)}return morphedNode}}var morphdom=morphdomFactory(morphAttrs);module.exports=morphdom},{}],2:[function(require,module,exports){"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var morphdom=require("morphdom");var objs=[];var eventType="input paste copy click change keydown keyup contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend";var dataAction=eventType.replace(/([a-z]+)/g,"[data-action-$1],")+"[data-action]";if(!Array.prototype.find){Array.prototype.find=function(predicate){if(this===null){throw new TypeError("Array.prototype.find called on null or undefined")}if(typeof predicate!=="function"){throw new TypeError("predicate must be a function")}var list=Object(this);var length=list.length>>>0;var thisArg=arguments[1];var value=void 0;for(var i=0;i<length;i++){value=list[i];if(predicate.call(thisArg,value,i,list)){return value}}return undefined}}var matches=function matches(element,query){var matches=(element.document||element.ownerDocument).querySelectorAll(query);var i=matches.length;while(--i>=0&&matches.item(i)!==element){}return i>-1};var selector=function selector(_selector){return document.querySelector(_selector)};var getObjectById=function getObjectById(id){for(var i=0,n=objs.length;i<n;i++){var obj=objs[i];var templates=obj.templates;for(var t=0,m=templates.length;t<m;t++){if(templates[t]==id){return obj}}}return null};var findAncestor=function findAncestor(element,selector){if(typeof element.closest==="function"){return element.closest(selector)||null}while(element){if(matches(element,selector)){return element}element=element.parentElement}return null};var on=function on(element,query,eventNames,fn){var events=eventNames.split(" ");events.forEach(function(event){element.addEventListener(event,function(e){var target=e.target;var delegateTarget=findAncestor(e.target,query);if(delegateTarget){e.delegateTarget=delegateTarget;fn(e)}})})};if(typeof document!=="undefined"){on(document,"[data-bind]","input change click",function(e){var target=e.delegateTarget;var data=target.getAttribute("data-bind");var attr=target.getAttribute("href");var id=findAncestor(target,"[data-id]").getAttribute("data-id");var value=target.value;if(attr){value=value.replace("#","")}if(id){var obj=getObjectById(id);if(target.getAttribute("type")==="radio"){}else if(target.getAttribute("type")==="checkbox"){(function(){var arr=[];var items=document.querySelectorAll('[data-bind="'+data+'"]');[].forEach.call(items,function(item){if(item.checked){arr.push(item.value)}})})()}else{obj.updateDataByString(data,value)}}});on(document,dataAction,eventType,function(e){var target=e.delegateTarget;if(e.type==="click"&&target.tagName==="select"){return}if(e.type==="input"&&target.getAttribute("type")==="button"){return}var events=eventType.split(" ");var action="action";events.forEach(function(event){if(target.getAttribute("data-action-"+event)){if(e.type===event){action+="-"+event}}});var string=target.getAttribute("data-"+action);if(!string){return}var method=string.replace(/\(.*?\);?/,"");var parameter=string.replace(/(.*?)\((.*?)\);?/,"$2");var pts=parameter.split(",");var id=findAncestor(target,"[data-id]").getAttribute("data-id");if(!id){return}var obj=getObjectById(id);obj.e=e;if(obj.method&&obj.method[method]){obj.method[method].apply(obj,pts)}else if(obj[method]){obj[method].apply(obj,pts)}})}var aTemplate=function(){function aTemplate(opt){_classCallCheck(this,aTemplate);this.atemplate=[];objs.push(this);for(var i in opt){this[i]=opt[i]}if(!this.data){this.data={}}if(!this.templates){this.templates=[]}var templates=this.templates;var length=templates.length;for(var _i=0,n=length;_i<n;_i++){var template=this.templates[_i];var html=selector("#"+template).innerHTML;this.atemplate.push({id:template,html:html})}this.setId()}_createClass(aTemplate,[{key:"addTemplate",value:function addTemplate(id,html){this.atemplate.push({id:id,html:html});this.templates.push(id)}},{key:"loadHtml",value:function loadHtml(){var templates=this.templates;var promises=[];templates.forEach(function(template){var d=new $.Deferred;promises.push(d);var src=selector("#"+template).getAttribute("src");$.ajax({url:src,type:"GET",dataType:"text"}).success(function(data){selector("#"+template).innerHTML=data;d.resolve()})});return $.when.apply($,promises)}},{key:"getData",value:function getData(){return JSON.parse(JSON.stringify(this.data))}},{key:"saveData",value:function saveData(key){var data=JSON.stringify(this.data);localStorage.setItem(key,data)}},{key:"setData",value:function setData(val){for(var i in val){if(typeof val[i]!=="function"){this.data[i]=val[i]}}}},{key:"loadData",value:function loadData(key){var data=JSON.parse(localStorage.getItem(key));if(data){for(var i in data){if(typeof data[i]!=="function"){this.data[i]=data[i]}}}}},{key:"getRand",value:function getRand(a,b){return~~(Math.random()*(b-a+1))+a}},{key:"getRandText",value:function getRandText(limit){var ret="";var strings="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";var length=strings.length;for(var i=0;i<limit;i++){ret+=strings.charAt(Math.floor(this.getRand(0,length)))}return ret}},{key:"setId",value:function setId(){var text=void 0;var ids=aTemplate.ids;var flag=false;while(1){text=this.getRandText(10);for(var i=0,n=aTemplate.ids;i<n;i++){if(aTemplate.ids[i]===text){flag=true}}if(flag===false){break}}this.data.aTemplate_id=text}},{key:"getDataFromObj",value:function getDataFromObj(s,o){s=s.replace(/\[([a-zA-Z0-9._-]+)\]/g,".$1");s=s.replace(/^\./,"");var a=s.split(".");while(a.length){var n=a.shift();if(n in o){o=o[n]}else{return}}return o}},{key:"getDataByString",value:function getDataByString(s){var o=this.data;return this.getDataFromObj(s,o)}},{key:"updateDataByString",value:function updateDataByString(path,newValue){var object=this.data;var stack=path.split(".");while(stack.length>1){object=object[stack.shift()]}object[stack.shift()]=newValue}},{key:"removeDataByString",value:function removeDataByString(path){var object=this.data;var stack=path.split(".");while(stack.length>1){object=object[stack.shift()]}var shift=stack.shift();if(shift.match(/^\d+$/)){object.splice(Number(shift),1)}else{delete object[shift]}}},{key:"resolveBlock",value:function resolveBlock(html,item,i){var that=this;var touchs=html.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):touch#([a-zA-Z0-9._-]+) -->/g);var touchnots=html.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):touchnot#([a-zA-Z0-9._-]+) -->/g);var exists=html.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):exist -->/g);var empties=html.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):empty -->/g);if(touchs){for(var k=0,n=touchs.length;k<n;k++){var start=touchs[k];start=start.replace(/([a-zA-Z0-9._-]+):touch#([a-zA-Z0-9._-]+)/,"($1):touch#($2)");var end=start.replace(/BEGIN/,"END");var reg=new RegExp(start+"(([\\n\\r\\t]|.)*?)"+end,"g");html=html.replace(reg,function(m,key2,val,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(itemkey==val){return next}else{return""}})}}if(touchnots){for(var _k=0,_n=touchnots.length;_k<_n;_k++){var _start=touchnots[_k];_start=_start.replace(/([a-zA-Z0-9._-]+):touchnot#([a-zA-Z0-9._-]+)/,"($1):touchnot#($2)");var _end=_start.replace(/BEGIN/,"END");var _reg=new RegExp(_start+"(([\\n\\r\\t]|.)*?)"+_end,"g");html=html.replace(_reg,function(m,key2,val,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(itemkey!=val){return next}else{return""}})}}if(exists){for(var _k2=0,_n2=exists.length;_k2<_n2;_k2++){var _start2=exists[_k2];_start2=_start2.replace(/([a-zA-Z0-9._-]+):exist/,"($1):exist");var _end2=_start2.replace(/BEGIN/,"END");var _reg2=new RegExp(_start2+"(([\\n\\r\\t]|.)*?)"+_end2,"g");html=html.replace(_reg2,function(m,key2,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(itemkey||itemkey===0){return next}else{return""}})}}if(empties){for(var _k3=0,_n3=empties.length;_k3<_n3;_k3++){var _start3=empties[_k3];_start3=_start3.replace(/([a-zA-Z0-9._-]+):empty/,"($1):empty");var _end3=_start3.replace(/BEGIN/,"END");var empty=new RegExp(_start3+"(([\\n\\r\\t]|.)*?)"+_end3,"g");html=html.replace(empty,function(m,key2,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(!itemkey&&itemkey!==0){return next}else{return""}})}}html=html.replace(/{([a-zA-Z0-9._-]+)}(\[([a-zA-Z0-9._-]+)\])*/g,function(n,key3,key4,converter){var data=void 0;if(key3=="i"){data=i}else{if(item[key3]||item[key3]===0){if(typeof item[key3]==="function"){data=item[key3].apply(that)}else{data=item[key3]}}else{if(converter&&that.convert&&that.convert[converter]){return that.convert[converter].call(that,"")}else{return""}}}if(converter&&that.convert&&that.convert[converter]){return that.convert[converter].call(that,data)}else{return data}});return html}},{key:"resolveAbsBlock",value:function resolveAbsBlock(html){var that=this;html=html.replace(/{(.*?)}/g,function(n,key3){var data=that.getDataByString(key3);if(typeof data!=="undefined"){if(typeof data==="function"){return data.apply(that)}else{return data}}else{return n}});return html}},{key:"resolveInclude",value:function resolveInclude(html){var include=/<!-- #include id="(.*?)" -->/g;html=html.replace(include,function(m,key){return selector("#"+key).innerHTML});return html}},{key:"resolveWith",value:function resolveWith(html){var width=/<!-- BEGIN ([a-zA-Z0-9._-]+):with -->(([\n\r\t]|.)*?)<!-- END ([a-zA-Z0-9._-]+):with -->/g;html=html.replace(width,function(m,key,val){m=m.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+key+".$1'");return m});return html}},{key:"resolveLoop",value:function resolveLoop(html){var loop=/<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g;var that=this;html=html.replace(loop,function(m,key,val){var keyItem=that.getDataByString(key);var keys=[];if(typeof keyItem==="function"){keys=keyItem.apply(that)}else{keys=keyItem}var ret="";if(keys instanceof Array){for(var i=0,n=keys.length;i<n;i++){ret+=that.resolveBlock(val,keys[i],i)}}ret=ret.replace(/\\([^\\])/g,"$1");return ret});return html}},{key:"removeData",value:function removeData(arr){var data=this.data;for(var i in data){for(var t=0,n=arr.length;t<n;t++){if(i===arr[t]){delete data[i]}}}return this}},{key:"hasLoop",value:function hasLoop(txt){var loop=/<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g;if(txt.match(loop)){return true}else{return false}}},{key:"getHtml",value:function getHtml(selector,row){var template=this.atemplate.find(function(item){return item.id===selector});var html="";if(template&&template.html){html=template.html}if(row){html=selector}if(!html){return""}var data=this.data;html=this.resolveInclude(html);html=this.resolveWith(html);while(this.hasLoop(html)){html=this.resolveLoop(html)}html=this.resolveBlock(html,data);html=html.replace(/\\([^\\])/g,"$1");html=this.resolveAbsBlock(html);return html.replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function update(txt,part){var html=this.getHtml();var templates=this.templates;var renderWay=txt||"html";if(this.beforeUpdated){this.beforeUpdated()}for(var i=0,n=templates.length;i<n;i++){var tem=templates[i];var query="#"+tem;var _html=this.getHtml(tem);var target=selector("[data-id='"+tem+"']");if(!part||part==tem){if(!target){selector(query).insertAdjacentHTML("afterend",'<div data-id="'+tem+'"></div>');if(renderWay==="text"){selector("[data-id='"+tem+"']").innerText=_html}else{selector("[data-id='"+tem+"']").innerHTML=_html}}else{if(renderWay==="text"){target.innerText=_html}else{morphdom(target,"<div data-id='"+tem+"'>"+_html+"</div>")}}if(part){break}}}this.updateBindingData(part);if(this.onUpdated){this.onUpdated(part)}return this}},{key:"updateBindingData",value:function updateBindingData(part){var _this=this;var templates=this.templates;for(var i=0,n=templates.length;i<n;i++){var temp=templates[i];if(!part||part==temp){var template=selector("[data-id='"+temp+"']");var binds=template.querySelectorAll("[data-bind]");[].forEach.call(binds,function(item){var data=_this.getDataByString(item.getAttribute("data-bind"));if(item.getAttribute("type")==="checkbox"||item.getAttribute("type")==="radio"){if(data==item.value){item.checked=true}}else{item.value=data}});if(part){break}}}return this}},{key:"applyMethod",value:function applyMethod(method){var args=[].splice.call(arguments,0);args.shift();return this.method[method].apply(this,args)}},{key:"getComputedProp",value:function getComputedProp(prop){return this.data[prop].apply(this)}},{key:"remove",value:function remove(path){var object=this.data;var stack=path.split(".");while(stack.length>1){object=object[stack.shift()]}var shift=stack.shift();if(shift.match(/^\d+$/)){object.splice(Number(shift),1)}else{delete object[shift]}return this}}]);return aTemplate}();module.exports=aTemplate},{morphdom:1}]},{},[2])(2)});

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -8,3 +8,2 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var morphdom = require('morphdom');
var delegate = require('delegate');
var objs = [];

@@ -37,10 +36,8 @@ var eventType = "input paste copy click change keydown keyup contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend";

if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector || function (s) {
var matches = (this.document || this.ownerDocument).querySelectorAll(s),
i = matches.length;
while (--i >= 0 && matches.item(i) !== this) {}
return i > -1;
};
}
var matches = function matches(element, query) {
var matches = (element.document || element.ownerDocument).querySelectorAll(query);
var i = matches.length;
while (--i >= 0 && matches.item(i) !== element) {}
return i > -1;
};

@@ -50,2 +47,3 @@ var selector = function selector(_selector) {

};
var getObjectById = function getObjectById(id) {

@@ -69,3 +67,3 @@ for (var i = 0, n = objs.length; i < n; i++) {

while (element) {
if (element.matches(selector)) {
if (matches(element, selector)) {
return element;

@@ -78,6 +76,13 @@ }

var on = function on(element, query, e, fn) {
var events = e.split(' ');
var on = function on(element, query, eventNames, fn) {
var events = eventNames.split(' ');
events.forEach(function (event) {
delegate(element, query, event, fn);
element.addEventListener(event, function (e) {
var target = e.target;
var delegateTarget = findAncestor(e.target, query);
if (delegateTarget) {
e.delegateTarget = delegateTarget;
fn(e);
}
});
});

@@ -102,3 +107,3 @@ };

var arr = [];
var items = document.querySelectorAll('[data-bind="' + data + '"]');
var items = document.querySelectorAll("[data-bind=\"" + data + "\"]");
[].forEach.call(items, function (item) {

@@ -134,3 +139,3 @@ if (item.checked) {

});
var string = target.getAttribute('data-' + action);
var string = target.getAttribute("data-" + action);
if (!string) {

@@ -175,3 +180,3 @@ return;

var template = this.templates[_i];
var html = selector('#' + template).innerHTML;
var html = selector("#" + template).innerHTML;
this.atemplate.push({ id: template, html: html });

@@ -183,3 +188,3 @@ }

_createClass(aTemplate, [{
key: 'addTemplate',
key: "addTemplate",
value: function addTemplate(id, html) {

@@ -190,3 +195,3 @@ this.atemplate.push({ id: id, html: html });

}, {
key: 'loadHtml',
key: "loadHtml",
value: function loadHtml() {

@@ -198,3 +203,3 @@ var templates = this.templates;

promises.push(d);
var src = selector('#' + template).getAttribute('src');
var src = selector("#" + template).getAttribute('src');
$.ajax({

@@ -205,3 +210,3 @@ url: src,

}).success(function (data) {
selector('#' + template).innerHTML = data;
selector("#" + template).innerHTML = data;
d.resolve();

@@ -213,3 +218,3 @@ });

}, {
key: 'getData',
key: "getData",
value: function getData() {

@@ -219,3 +224,3 @@ return JSON.parse(JSON.stringify(this.data));

}, {
key: 'saveData',
key: "saveData",
value: function saveData(key) {

@@ -226,3 +231,3 @@ var data = JSON.stringify(this.data);

}, {
key: 'setData',
key: "setData",
value: function setData(val) {

@@ -236,3 +241,3 @@ for (var i in val) {

}, {
key: 'loadData',
key: "loadData",
value: function loadData(key) {

@@ -249,3 +254,3 @@ var data = JSON.parse(localStorage.getItem(key));

}, {
key: 'getRand',
key: "getRand",
value: function getRand(a, b) {

@@ -255,3 +260,3 @@ return ~~(Math.random() * (b - a + 1)) + a;

}, {
key: 'getRandText',
key: "getRandText",
value: function getRandText(limit) {

@@ -267,3 +272,3 @@ var ret = "";

}, {
key: 'setId',
key: "setId",
value: function setId() {

@@ -287,3 +292,3 @@ var text = void 0;

}, {
key: 'getDataFromObj',
key: "getDataFromObj",
value: function getDataFromObj(s, o) {

@@ -304,3 +309,3 @@ s = s.replace(/\[([a-zA-Z0-9._-]+)\]/g, '.$1'); // convert indexes to properties

}, {
key: 'getDataByString',
key: "getDataByString",
value: function getDataByString(s) {

@@ -311,3 +316,3 @@ var o = this.data;

}, {
key: 'updateDataByString',
key: "updateDataByString",
value: function updateDataByString(path, newValue) {

@@ -322,3 +327,3 @@ var object = this.data;

}, {
key: 'removeDataByString',
key: "removeDataByString",
value: function removeDataByString(path) {

@@ -338,3 +343,3 @@ var object = this.data;

}, {
key: 'resolveBlock',
key: "resolveBlock",
value: function resolveBlock(html, item, i) {

@@ -445,3 +450,3 @@ var that = this;

}, {
key: 'resolveAbsBlock',
key: "resolveAbsBlock",
value: function resolveAbsBlock(html) {

@@ -464,7 +469,7 @@ var that = this;

}, {
key: 'resolveInclude',
key: "resolveInclude",
value: function resolveInclude(html) {
var include = /<!-- #include id="(.*?)" -->/g;
html = html.replace(include, function (m, key) {
return selector('#' + key).innerHTML;
return selector("#" + key).innerHTML;
});

@@ -474,3 +479,3 @@ return html;

}, {
key: 'resolveWith',
key: "resolveWith",
value: function resolveWith(html) {

@@ -485,3 +490,3 @@ var width = /<!-- BEGIN ([a-zA-Z0-9._-]+):with -->(([\n\r\t]|.)*?)<!-- END ([a-zA-Z0-9._-]+):with -->/g;

}, {
key: 'resolveLoop',
key: "resolveLoop",
value: function resolveLoop(html) {

@@ -512,3 +517,3 @@ var loop = /<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g;

}, {
key: 'removeData',
key: "removeData",
value: function removeData(arr) {

@@ -526,3 +531,3 @@ var data = this.data;

}, {
key: 'hasLoop',
key: "hasLoop",
value: function hasLoop(txt) {

@@ -537,3 +542,3 @@ var loop = /<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g;

}, {
key: 'getHtml',
key: "getHtml",
value: function getHtml(selector, row) {

@@ -572,3 +577,3 @@ var template = this.atemplate.find(function (item) {

}, {
key: 'update',
key: "update",
value: function update(txt, part) {

@@ -585,10 +590,10 @@ var html = this.getHtml();

var _html = this.getHtml(tem);
var target = selector('[data-id=\'' + tem + '\']');
var target = selector("[data-id='" + tem + "']");
if (!part || part == tem) {
if (!target) {
selector(query).insertAdjacentHTML('afterend', '<div data-id="' + tem + '"></div>');
selector(query).insertAdjacentHTML('afterend', "<div data-id=\"" + tem + "\"></div>");
if (renderWay === 'text') {
selector('[data-id=\'' + tem + '\']').innerText = _html;
selector("[data-id='" + tem + "']").innerText = _html;
} else {
selector('[data-id=\'' + tem + '\']').innerHTML = _html;
selector("[data-id='" + tem + "']").innerHTML = _html;
}

@@ -599,3 +604,3 @@ } else {

} else {
morphdom(target, '<div data-id=\'' + tem + '\'>' + _html + '</div>');
morphdom(target, "<div data-id='" + tem + "'>" + _html + "</div>");
}

@@ -615,3 +620,3 @@ }

}, {
key: 'updateBindingData',
key: "updateBindingData",
value: function updateBindingData(part) {

@@ -624,3 +629,3 @@ var _this = this;

if (!part || part == temp) {
var template = selector('[data-id=\'' + temp + '\']');
var template = selector("[data-id='" + temp + "']");
var binds = template.querySelectorAll('[data-bind]');

@@ -645,3 +650,3 @@ [].forEach.call(binds, function (item) {

}, {
key: 'applyMethod',
key: "applyMethod",
value: function applyMethod(method) {

@@ -653,3 +658,3 @@ var args = [].splice.call(arguments, 0);

}, {
key: 'getComputedProp',
key: "getComputedProp",
value: function getComputedProp(prop) {

@@ -659,3 +664,3 @@ return this.data[prop].apply(this);

}, {
key: 'remove',
key: "remove",
value: function remove(path) {

@@ -662,0 +667,0 @@ var object = this.data;

{
"name": "a-template",
"version": "0.2.0",
"version": "0.2.2",
"author": "steelydylan",

@@ -5,0 +5,0 @@ "description": "Simple Template Engine",

const morphdom = require('morphdom');
const delegate = require('delegate');
const objs = [];

@@ -30,15 +29,7 @@ const eventType = "input paste copy click change keydown keyup contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend";

if (!Element.prototype.matches) {
Element.prototype.matches =
Element.prototype.matchesSelector ||
Element.prototype.mozMatchesSelector ||
Element.prototype.msMatchesSelector ||
Element.prototype.oMatchesSelector ||
Element.prototype.webkitMatchesSelector ||
function(s) {
var matches = (this.document || this.ownerDocument).querySelectorAll(s),
i = matches.length;
while (--i >= 0 && matches.item(i) !== this) {}
return i > -1;
};
const matches = (element, query) => {
const matches = (element.document || element.ownerDocument).querySelectorAll(query);
let i = matches.length;
while (--i >= 0 && matches.item(i) !== element) {}
return i > -1;
}

@@ -49,2 +40,3 @@

}
const getObjectById = (id) => {

@@ -68,3 +60,3 @@ for (let i = 0, n = objs.length; i < n; i++) {

while (element) {
if (element.matches(selector)) {
if (matches(element, selector)) {
return element;

@@ -77,8 +69,15 @@ }

const on = (element, query, e, fn) => {
const events = e.split(' ');
const on = (element, query, eventNames, fn) => {
const events = eventNames.split(' ');
events.forEach((event) => {
delegate(element,query,event,fn);
element.addEventListener(event, (e) => {
let target = e.target;
const delegateTarget = findAncestor(e.target, query);
if(delegateTarget) {
e.delegateTarget = delegateTarget;
fn(e);
}
});
});
}
};

@@ -85,0 +84,0 @@ if(typeof document !== "undefined"){

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc