diff --git a/dist/regular.js b/dist/regular.js index c1d9ebf..b50d017 100644 --- a/dist/regular.js +++ b/dist/regular.js @@ -237,20 +237,22 @@ var doc = dom.doc; * @constructor * @param {Object} options specification of the component */ -var Regular = function(options){ +var Regular = function(definition, options){ var prevRunning = env.isRunning; env.isRunning = true; var node, template; + definition = definition || {}; options = options || {}; - options.data = options.data || {}; - options.computed = options.computed || {}; - options.events = options.events || {}; - if(this.data) _.extend(options.data, this.data); - if(this.computed) _.extend(options.computed, this.computed); - if(this.events) _.extend(options.events, this.events); - - _.extend(this, options, true); + + definition.data = definition.data || {}; + definition.computed = definition.computed || {}; + definition.events = definition.events || {}; + if(this.data) _.extend(definition.data, this.data); + if(this.computed) _.extend(definition.computed, this.computed); + if(this.events) _.extend(definition.events, this.events); + + _.extend(this, definition, true); if(this.$parent){ this.$parent._append(this); } @@ -273,14 +275,17 @@ var Regular = function(options){ if(this.events){ this.$on(this.events); } - // if(this.$body){ - this._getTransclude = function(transclude){ - var ctx = this.$parent || this; - if( transclude || this.$body ) return ctx.$compile(transclude || this.$body, {namespace: options.namespace, outer: this, extra: options.extra}) - } - // } this.$emit("$config"); this.config && this.config(this.data); + if(this._body && this._body.length){ + this.$body = _.getCompileFn(this._body, this.$parent, { + outer: this, + namespace: options.namespace, + extra: options.extra, + record: true + }) + this._body = null; + } // handle computed if(template){ this.group = this.$compile(this.template, {namespace: options.namespace}); @@ -669,7 +674,7 @@ Regular.implement({ _f_: function(name){ var Component = this.constructor; var filter = Component.filter(name); - if(!filter) throw 'filter ' + name + ' is undefined'; + if(!filter) throw Error('filter ' + name + ' is undefined'); return filter; }, // simple accessor get @@ -731,7 +736,6 @@ Regular.prototype.inject = function(){ } - // only one builtin filter Regular.filter(filter); @@ -784,7 +788,7 @@ var handleComputed = (function(){ }); require.register("regularjs/src/util.js", function(exports, require, module){ -require('./helper/shim.js'); +require('./helper/shim.js')(); var _ = module.exports; var entities = require('./helper/entities.js'); var slice = [].slice; @@ -800,6 +804,31 @@ _.uid = (function(){ } })(); +_.extend = function( o1, o2, override ){ + // if(_.typeOf(override) === 'array'){ + // for(var i = 0, len = override.length; i < len; i++ ){ + // var key = override[i]; + // o1[key] = o2[key]; + // } + // }else{ + for(var i in o2){ + if( typeof o1[i] === "undefined" || override === true ){ + o1[i] = o2[i] + } + } + // } + return o1; +} + +_.keys = function(obj){ + if(Object.keys) return Object.keys(obj); + var res = []; + for(var i in obj) if(obj.hasOwnProperty(i)){ + res.push(i); + } + return res; +} + _.varName = 'd'; _.setName = 'p_'; _.ctxName = 'c'; @@ -832,26 +861,6 @@ _.typeOf = function (o) { return o == null ? String(o) :o2str.call(o).slice(8, -1).toLowerCase(); } -_.isExpression = function( expr ){ - return expr && expr.type === 'expression'; -} - - -_.extend = function( o1, o2, override ){ - if(_.typeOf(override) === 'array'){ - for(var i = 0, len = override.length; i < len; i++ ){ - var key = override[i]; - o1[key] = o2[key]; - } - }else{ - for(var i in o2){ - if( typeof o1[i] === "undefined" || override === true ){ - o1[i] = o2[i] - } - } - } - return o1; -} _.makePredicate = function makePredicate(words, prefix) { if (typeof words === "string") { @@ -971,7 +980,7 @@ _.escapeRegExp = function( str){// Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Le }; -var rEntity = new RegExp("&(" + Object.keys(entities).join('|') + ');', 'gi'); +var rEntity = new RegExp("&(" + _.keys(entities).join('|') + ');', 'gi'); _.convertEntity = function(chr){ @@ -1166,12 +1175,12 @@ _.fixObjStr = function(str){ _.log = function(msg, type){ - return "" if(typeof console !== "undefined") console[type || "log"](msg); } + //http://www.w3.org/html/wg/drafts/html/master/single-page.html#void-elements _.isVoidTag = _.makePredicate("area base br col embed hr img input keygen link menuitem meta param source track wbr r-content"); _.isBooleanAttr = _.makePredicate('selected checked disabled readOnly required open autofocus controls autoplay compact loop defer multiple'); @@ -1182,12 +1191,17 @@ _.isTrue - function(){return true} _.isExpr = function(expr){ return expr && expr.type === 'expression'; } +// @TODO: make it more strict +_.isGroup = function(group){ + return group.inject || group.$inject; +} -_.assert = function(test, msg){ - if(!test) throw msg; +_.getCompileFn = function(source, ctx, options){ + return ctx.$compile.bind(ctx,source, options) } + }); require.register("regularjs/src/walkers.js", function(exports, require, module){ var diffArray = require('./helper/arrayDiff.js'); @@ -1263,14 +1277,18 @@ walkers.list = function(ast, options){ } function updateLD(newValue, oldValue, splices){ - if(!newValue) { - newValue = []; + if(!oldValue) oldValue = []; + if(!newValue) newValue = []; + + + var cur = placeholder; + var m = 0, len = newValue.length; + + if(!splices && (len !==0 || oldValue.length !==0) ){ splices = diffArray(newValue, oldValue); } - + if(!splices || !splices.length) return; - var cur = placeholder; - var m = 0, len = newValue.length; for(var i = 0; i < splices.length; i++){ //init var splice = splices[i]; @@ -1370,12 +1388,16 @@ walkers.template = function(ast, options){ if(content){ var self = this; this.$watch(content, function(value){ - if( compiled = group.get(1)){ - compiled.destroy(true); + var removed = group.get(1), type= typeof value; + if( removed){ + removed.destroy(true); group.children.pop(); } - group.push( compiled = self.$compile(value, {record: true, outer: options.outer,namespace: namespace, extra: extra}) ); - if(placeholder.parentNode) animate.inject(combine.node(compiled), placeholder, 'before') + if(!value) return; + group.push( compiled = (typeof value === 'function') ? value(): self.$compile(value, {record: true, outer: options.outer,namespace: namespace, extra: extra}) ); + if(placeholder.parentNode) { + compiled.$inject(placeholder, 'before') + } }, { init: true }); @@ -1463,7 +1485,6 @@ walkers.text = function(ast, options){ var eventReg = /^on-(.+)$/ - /** * walkers element (contains component) */ @@ -1477,8 +1498,9 @@ walkers.element = function(ast, options){ Component = Constructor.component(tag), ref, group, element; - if( tag === 'r-content' && this._getTransclude ){ - return this._getTransclude(); + if( tag === 'r-content' ){ + _.log('r-content is deprecated, use {#inc this.$body} instead (`{#include}` as same)', 'error'); + return this.$body && this.$body(); } if(Component || tag === 'r-component'){ @@ -1550,109 +1572,130 @@ walkers.component = function(ast, options){ var attrs = ast.attrs, Component = options.Component, Constructor = this.constructor, - isolate, namespace = options.namespace, + isolate, + extra = options.extra, + namespace = options.namespace, ref, self = this, is; - var data = {}, events; - for(var i = 0, len = attrs.length; i < len; i++){ - var attr = attrs[i]; - // consider disabled equlasto disabled={true} - var value = this._touchExpr(attr.value===undefined? true: attr.value); - if(value.constant) value = attr.value = value.get(this); - if(attr.value && attr.value.constant === true){ - value = value.get(this); - } - var name = attr.name; - if(!attr.event){ - var etest = name.match(eventReg); - // event: 'nav' - if(etest) attr.event = etest[1]; - } - - // @if is r-component . we need to find the target Component - if(name === 'is' && !Component){ - is = value; - var componentName = this.$get(value, true); - Component = Constructor.component(componentName) - if(typeof Component !== 'function') throw new Error("component " + componentName + " has not registed!"); - } - // bind event proxy - var eventName; - if(eventName = attr.event){ - events = events || {}; - events[eventName] = _.handleEvent.call(this, value, eventName); - continue; - }else { - name = attr.name = _.camelCase(name); - } - if(value.type !== 'expression'){ - data[name] = value; - }else{ - data[name] = value.get(self); - } - if( name === 'ref' && value != null){ - ref = value.type === 'expression'? value.get(self): value; - } - if( name === 'isolate'){ - // 1: stop: composite -> parent - // 2. stop: composite <- parent - // 3. stop 1 and 2: composite <-> parent - // 0. stop nothing (defualt) - isolate = value.type === 'expression'? value.get(self): parseInt(value === true? 3: value, 10); - data.isolate = isolate; - } - } + var data = {}, events; - var config = { - data: data, - events: events, - $parent: this, - $outer: options.outer, - namespace: namespace, - $root: this.$root, - $body: ast.children - } + for(var i = 0, len = attrs.length; i < len; i++){ + var attr = attrs[i]; + // consider disabled equlasto disabled={true} + var value = this._touchExpr(attr.value === undefined? true: attr.value); + if(value.constant) value = attr.value = value.get(this); + if(attr.value && attr.value.constant === true){ + value = value.get(this); + } + var name = attr.name; + if(!attr.event){ + var etest = name.match(eventReg); + // event: 'nav' + if(etest) attr.event = etest[1]; + } + + // @compile modifier + if(attr.mdf === 'cmpl'){ + value = _.getCompileFn(value, this, { + record: true, + namespace:namespace, + extra: extra, + outer: options.outer + }) + } + + // @if is r-component . we need to find the target Component + if(name === 'is' && !Component){ + is = value; + var componentName = this.$get(value, true); + Component = Constructor.component(componentName) + if(typeof Component !== 'function') throw new Error("component " + componentName + " has not registed!"); + } + // bind event proxy + var eventName; + if(eventName = attr.event){ + events = events || {}; + events[eventName] = _.handleEvent.call(this, value, eventName); + continue; + }else { + name = attr.name = _.camelCase(name); + } - var component = new Component(config); - if(ref && self.$refs) self.$refs[ref] = component; - for(var i = 0, len = attrs.length; i < len; i++){ - var attr = attrs[i]; - var value = attr.value||true; - var name = attr.name; - if(value.type === 'expression' && !attr.event){ - value = self._touchExpr(value); - // use bit operate to control scope - if( !(isolate & 2) ) - this.$watch(value, component.$update.bind(component, name)) - if( value.set && !(isolate & 1 ) ) - // sync the data. it force the component don't trigger attr.name's first dirty echeck - component.$watch(name, self.$update.bind(self, value), {sync: true}); - } - } + if(value.type !== 'expression'){ + data[name] = value; + }else{ + data[name] = value.get(self); + } + if( name === 'ref' && value != null){ + ref = value + } + if( name === 'isolate'){ + // 1: stop: composite -> parent + // 2. stop: composite <- parent + // 3. stop 1 and 2: composite <-> parent + // 0. stop nothing (defualt) + isolate = value.type === 'expression'? value.get(self): parseInt(value === true? 3: value, 10); + data.isolate = isolate; + } + } + + var definition = { + data: data, + events: events, + $parent: this, + $root: this.$root, + $outer: options.outer, + _body: ast.children + } + var options = { + namespace: namespace, + extra: options.extra + } + + + var component = new Component(definition, options), reflink; + + + if(ref && this.$refs){ + reflink = Component.directive('ref').link + this.$on('$destroy', reflink.call(this, component, ref) ) + } + if(ref && self.$refs) self.$refs[ref] = component; + for(var i = 0, len = attrs.length; i < len; i++){ + var attr = attrs[i]; + var value = attr.value||true; + var name = attr.name; + // need compiled + if(value.type === 'expression' && !attr.event){ + value = self._touchExpr(value); + // use bit operate to control scope + if( !(isolate & 2) ) + this.$watch(value, component.$update.bind(component, name)) + if( value.set && !(isolate & 1 ) ) + // sync the data. it force the component don't trigger attr.name's first dirty echeck + component.$watch(name, self.$update.bind(self, value), {sync: true}); + } + } + if(is && is.type === 'expression' ){ + var group = new Group(); + group.push(component); + this.$watch(is, function(value){ + // found the new component + var Component = Constructor.component(value); + if(!Component) throw new Error("component " + value + " has not registed!"); + var ncomponent = new Component(definition); + var component = group.children.pop(); + group.push(ncomponent); + ncomponent.$inject(combine.last(component), 'after') + component.destroy(); + // @TODO if component changed , we need update ref if(ref){ - component.$on('destroy', function(){ - if(self.$refs) self.$refs[ref] = null; - }) + self.$refs[ref] = ncomponent; } - if(is && is.type === 'expression' ){ - var group = new Group(); - group.push(component); - this.$watch(is, function(value){ - // found the new component - var Component = Constructor.component(value); - if(!Component) throw new Error("component " + value + " has not registed!"); - var ncomponent = new Component(config); - var component = group.children.pop(); - group.push(ncomponent); - ncomponent.$inject(combine.last(component), 'after') - component.destroy(); - if(ref){ - self.$refs[ref] = ncomponent; - } - }, {sync: true}) - return group; - } - return component; + }, {sync: true}) + return group; + } + return component; } function walkAttributes(attrs, element, extra){ @@ -1827,7 +1870,7 @@ dom.find = function(sl){ dom.inject = function(node, refer, position){ position = position || 'bottom'; - + if(!node) return ; if(Array.isArray(node)){ var tmp = node; node = dom.fragment(); @@ -2133,12 +2176,12 @@ dom.nextFrame = (function(){ // 3ks for angular's raf service var k; -dom.nextReflow = function(callback){ - dom.nextFrame(function(){ +dom.nextReflow = dom.msie? function(callback){ + return dom.nextFrame(function(){ k = document.body.offsetWidth; callback(); }) -} +}: dom.nextFrame; @@ -2153,7 +2196,7 @@ function Group(list){ } -_.extend(Group.prototype, { +var o = _.extend(Group.prototype, { destroy: function(first){ combine.destroy(this.children, first); if(this.ondestroy) this.ondestroy(); @@ -2164,9 +2207,9 @@ _.extend(Group.prototype, { }, push: function(item){ this.children.push( item ); - }, - inject: combine.inject + } }) +o.inject = o.$inject = combine.inject @@ -2262,7 +2305,7 @@ lo.lex = function(str){ } lo.error = function(msg){ - throw "Parse Error: " + msg + ':\n' + _.trackErrorPos(this.input, this.index); + throw Error("Parse Error: " + msg + ':\n' + _.trackErrorPos(this.input, this.index)); } lo._process = function(args, split,str){ @@ -2552,11 +2595,12 @@ module.exports = { children: children } }, - attribute: function(name, value){ + attribute: function(name, value, mdf){ return { type: 'attribute', name: name, - value: value + value: value, + mdf: mdf } }, "if": function(test, consequent, alternate){ @@ -2754,10 +2798,17 @@ op.xml = function(){ // {{#if name}}on-click={{xx}}{{#else}}on-tap={{}}{{/if}} op.xentity = function(ll){ - var name = ll.value, value; + var name = ll.value, value, modifier; if(ll.type === 'NAME'){ - if( this.eat("=") ) value = this.attvalue(); - return node.attribute( name, value ); + //@ only for test + if(~name.indexOf('.')){ + var tmp = name.split('.'); + name = tmp[0]; + modifier = tmp[1] + + } + if( this.eat("=") ) value = this.attvalue(modifier); + return node.attribute( name, value, modifier ); }else{ if( name !== 'if') this.error("current version. ONLY RULE #if #else #elseif is valid in tag, the rule #" + name + ' is invalid'); return this['if'](true); @@ -2785,7 +2836,7 @@ op.attrs = function(isAttribute){ // attvalue // : STRING // | NAME -op.attvalue = function(){ +op.attvalue = function(mdf){ var ll = this.ll(); switch(ll.type){ case "NAME": @@ -2793,7 +2844,7 @@ op.attvalue = function(){ case "STRING": this.next(); var value = ll.value; - if(~value.indexOf(config.BEGIN) && ~value.indexOf(config.END)){ + if(~value.indexOf(config.BEGIN) && ~value.indexOf(config.END) && mdf!=='cmpl'){ var constant = true; var parsed = new Parser(value, { mode: 2 }).parse(); if(parsed.length === 1 && parsed[0].type === 'expression') return parsed[0]; @@ -3413,82 +3464,69 @@ function extend(o1, o2 ){ for(var i in o2) if( o1[i] === undefined){ o1[i] = o2[i] } + return o2; } -// String proto ; -extend(String.prototype, { - trim: function(){ - return this.replace(/^\s+|\s+$/g, ''); - } -}); +module.exports = function(){ + // String proto ; + extend(String.prototype, { + trim: function(){ + return this.replace(/^\s+|\s+$/g, ''); + } + }); -// Array proto; -extend(Array.prototype, { - indexOf: function(obj, from){ - from = from || 0; - for (var i = from, len = this.length; i < len; i++) { - if (this[i] === obj) return i; - } - return -1; - }, - forEach: function(callback, context){ - for (var i = 0, len = this.length; i < len; i++) { - callback.call(context, this[i], i, this); - } - }, - filter: function(callback, context){ - var res = []; - for (var i = 0, length = this.length; i < length; i++) { - var pass = callback.call(context, this[i], i, this); - if(pass) res.push(this[i]); - } - return res; - }, - map: function(callback, context){ - var res = []; - for (var i = 0, length = this.length; i < length; i++) { - res.push(callback.call(context, this[i], i, this)); + // Array proto; + extend(Array.prototype, { + indexOf: function(obj, from){ + from = from || 0; + for (var i = from, len = this.length; i < len; i++) { + if (this[i] === obj) return i; + } + return -1; + }, + forEach: function(callback, context){ + for (var i = 0, len = this.length; i < len; i++) { + callback.call(context, this[i], i, this); + } + }, + filter: function(callback, context){ + var res = []; + for (var i = 0, length = this.length; i < length; i++) { + var pass = callback.call(context, this[i], i, this); + if(pass) res.push(this[i]); + } + return res; + }, + map: function(callback, context){ + var res = []; + for (var i = 0, length = this.length; i < length; i++) { + res.push(callback.call(context, this[i], i, this)); + } + return res; } - return res; - } -}); + }); -// Function proto; -extend(Function.prototype, { - bind: function(context){ - var fn = this; - var preArgs = slice.call(arguments, 1); - return function(){ - var args = preArgs.concat(slice.call(arguments)); - return fn.apply(context, args); + // Function proto; + extend(Function.prototype, { + bind: function(context){ + var fn = this; + var preArgs = slice.call(arguments, 1); + return function(){ + var args = preArgs.concat(slice.call(arguments)); + return fn.apply(context, args); + } } - } -}) - -// Object -extend(Object, { - keys: function(obj){ - var keys = []; - for(var i in obj) if(obj.hasOwnProperty(i)){ - keys.push(i); + }) + + // Array + extend(Array, { + isArray: function(arr){ + return tstr.call(arr) === "[object Array]"; } - return keys; - } -}) + }) +} -// Date -extend(Date, { - now: function(){ - return +new Date; - } -}) -// Array -extend(Array, { - isArray: function(arr){ - return tstr.call(arr) === "[object Array]"; - } -}) }); require.register("regularjs/src/helper/parse.js", function(exports, require, module){ @@ -3615,7 +3653,7 @@ var methods = { while(dirty = this._digest()){ if((++n) > 20){ // max loop - throw 'there may a circular dependencies reaches' + throw Error('there may a circular dependencies reaches') } } if( n > 0 && this.$emit) this.$emit("$update"); @@ -3638,7 +3676,7 @@ var methods = { children = this._children; if(children && children.length){ for(var m = 0, mlen = children.length; m < mlen; m++){ - if(children[m]._digest()) dirty = true; + if(children[m] && children[m]._digest()) dirty = true; } } return dirty; @@ -3773,72 +3811,70 @@ require.register("regularjs/src/helper/event.js", function(exports, require, mod // =============================== var slice = [].slice, _ = require("../util.js"); var API = { - $on: function(event, fn) { - if(typeof event === "object"){ - for (var i in event) { - this.$on(i, event[i]); - } - }else{ - // @patch: for list - var context = this; - var handles = context._handles || (context._handles = {}), - calls = handles[event] || (handles[event] = []); - calls.push(fn); - } - return this; - }, - $off: function(event, fn) { - var context = this; - if(!context._handles) return; - if(!event) this._handles = {}; - var handles = context._handles, - calls; - - if (calls = handles[event]) { - if (!fn) { - handles[event] = []; - return context; - } - for (var i = 0, len = calls.length; i < len; i++) { - if (fn === calls[i]) { - calls.splice(i, 1); - return context; - } - } - } + $on: function(event, fn) { + if(typeof event === "object"){ + for (var i in event) { + this.$on(i, event[i]); + } + }else{ + // @patch: for list + var context = this; + var handles = context._handles || (context._handles = {}), + calls = handles[event] || (handles[event] = []); + calls.push(fn); + } + return this; + }, + $off: function(event, fn) { + var context = this; + if(!context._handles) return; + if(!event) this._handles = {}; + var handles = context._handles, + calls; + + if (calls = handles[event]) { + if (!fn) { + handles[event] = []; return context; - }, - // bubble event - $emit: function(event){ - // @patch: for list - var context = this; - var handles = context._handles, calls, args, type; - if(!event) return; - var args = slice.call(arguments, 1); - var type = event; - - if(!handles) return context; - if(calls = handles[type.slice(1)]){ - for (var j = 0, len = calls.length; j < len; j++) { - calls[j].apply(context, args) - } - } - if (!(calls = handles[type])) return context; - for (var i = 0, len = calls.length; i < len; i++) { - calls[i].apply(context, args) + } + for (var i = 0, len = calls.length; i < len; i++) { + if (fn === calls[i]) { + calls.splice(i, 1); + return context; } - // if(calls.length) context.$update(); - return context; - }, - // capture event - $broadcast: function(){ - + } } + return context; + }, + // bubble event + $emit: function(event){ + // @patch: for list + var context = this; + var handles = context._handles, calls, args, type; + if(!event) return; + var args = slice.call(arguments, 1); + var type = event; + + if(!handles) return context; + if(calls = handles[type.slice(1)]){ + for (var j = 0, len = calls.length; j < len; j++) { + calls[j].apply(context, args) + } + } + if (!(calls = handles[type])) return context; + for (var i = 0, len = calls.length; i < len; i++) { + calls[i].apply(context, args) + } + // if(calls.length) context.$update(); + return context; + }, + // capture event + $one: function(){ + } -// container class -function Event() { - if (arguments.length) this.$on.apply(this, arguments); } +// container class +function Event() {} _.extend(Event.prototype, API) Event.mixTo = function(obj){ @@ -3934,6 +3970,18 @@ animate.inject = function( node, refer ,direction, callback ){ * @return {[type]} [description] */ animate.remove = function(node, callback){ + if(!node) throw new Error('node to be removed is undefined') + var count = 0; + function loop(){ + count++; + if(count === len) callback && callback() + } + if(Array.isArray(node)){ + for(var i = 0, len = node.length; i < len ; i++){ + animate.remove(node[i], loop) + } + return node; + } if(node.onleave){ node.onleave(function(){ removeDone(node, callback) @@ -3956,21 +4004,28 @@ animate.startClassAnimate = function ( node, className, callback, mode ){ return callback(); } - onceAnim = _.once(function onAnimateEnd(){ - if(tid) clearTimeout(tid); + if(mode !== 4){ + onceAnim = _.once(function onAnimateEnd(){ + if(tid) clearTimeout(tid); - if(mode === 2) { - dom.delClass(node, activeClassName); - } - if(mode !== 3){ // mode hold the class - dom.delClass(node, className); - } - dom.off(node, animationEnd, onceAnim) - dom.off(node, transitionEnd, onceAnim) + if(mode === 2) { + dom.delClass(node, activeClassName); + } + if(mode !== 3){ // mode hold the class + dom.delClass(node, className); + } + dom.off(node, animationEnd, onceAnim) + dom.off(node, transitionEnd, onceAnim) - callback(); + callback(); - }); + }); + }else{ + onceAnim = _.once(function onAnimateEnd(){ + if(tid) clearTimeout(tid); + callback(); + }); + } if(mode === 2){ // auto removed dom.addClass( node, className ); @@ -3984,17 +4039,23 @@ animate.startClassAnimate = function ( node, className, callback, mode ){ tid = setTimeout( onceAnim, timeout ); }); - }else{ + }else if(mode===4){ + dom.nextReflow(function(){ + dom.delClass( node, className ); + timeout = getMaxTimeout( node ); + tid = setTimeout( onceAnim, timeout ); + }); + }else{ dom.nextReflow(function(){ dom.addClass( node, className ); timeout = getMaxTimeout( node ); tid = setTimeout( onceAnim, timeout ); }); - } + dom.on( node, animationEnd, onceAnim ) dom.on( node, transitionEnd, onceAnim ) return onceAnim; @@ -4078,12 +4139,14 @@ require.register("regularjs/src/helper/combine.js", function(exports, require, m // -------------------------------- var dom = require("../dom.js"); +var animate = require("./animate.js"); var combine = module.exports = { // get the initial dom in object node: function(item){ var children,node, nodes; + if(!item) return; if(item.element) return item.element; if(typeof item.node === "function") return item.node(); if(typeof item.nodeType === "number") return item; @@ -4104,24 +4167,25 @@ var combine = module.exports = { return nodes; } }, - inject: function(node, pos, group ){ - if(!group) group = this; + // @TODO remove _gragContainer + inject: function(node, pos ){ + var group = this; + var fragment = combine.node(group.group || group); if(node === false) { - if(!group._fragContainer) group._fragContainer = dom.fragment(); - return combine.inject( group._fragContainer, pos, group); + animate.remove(fragment) + return group; + }else{ + if(!fragment) return group; + if(typeof node === 'string') node = dom.find(node); + if(!node) throw Error('injected node is not found'); + // use animate to animate firstchildren + animate.inject(fragment, node, pos); } - var fragment = combine.node(group.group || group); - if(!fragment) return group; - if(typeof node === 'string') node = dom.find(node); - if(!node) throw 'injected node is not found'; - dom.inject(fragment, node, pos); // if it is a component if(group.$emit) { group.$emit("$inject", node, pos); group.parentNode = (pos ==='after' || pos === 'before')? node.parentNode : node; } - - return group; }, @@ -4800,7 +4864,7 @@ function initText(elem, parsed){ }); // @TODO to fixed event - var handler = function handler(ev){ + var handler = function (ev){ var that = this; if(ev.type==='cut' || ev.type==='paste'){ _.nextTick(function(){ @@ -4828,7 +4892,7 @@ function initText(elem, parsed){ if(parsed.get(self) === undefined && elem.value){ parsed.set(self, elem.value); } - return function destroy(){ + return function (){ if(dom.msie !== 9 && "oninput" in dom.tNode ){ elem.removeEventListener("input", handler ); }else{ @@ -4999,7 +5063,7 @@ Regular.animation({ evt = tmp[0] || "", args = tmp[1]? this.$expression(tmp[1]).get: null; - if(!evt) throw "you shoud specified a eventname in emit command"; + if(!evt) throw Error("you shoud specified a eventname in emit command"); var self = this; return function(done){ @@ -5019,7 +5083,7 @@ Regular.animation({ name = tmp.shift(), value = tmp.join(" "); - if( !name || !value ) throw "invalid style in command: style"; + if( !name || !value ) throw Error("invalid style in command: style"); styles[name] = value; valid = true; } @@ -5041,6 +5105,7 @@ Regular.animation({ // el : the element to process // value: the directive value function processAnimate( element, value ){ + var Component = this.constructor; value = value.trim(); var composites = value.split(";"), @@ -5097,7 +5162,7 @@ function processAnimate( element, value ){ continue } - var animator = Regular.animation(command) + var animator = Component.animation(command) if( animator && seed ){ seed.push( animator.call(this,{ @@ -5107,7 +5172,7 @@ function processAnimate( element, value ){ }) ) }else{ - throw "you need start with `on` or `event` in r-animation"; + throw Error( animator? "you should start with `on` or `event` in animation" : ("undefined animator 【" + command +"】" )); } } @@ -5122,7 +5187,7 @@ function processAnimate( element, value ){ Regular.directive( "r-animation", processAnimate) -Regular.directive( "r-sequence", processAnimate) +Regular.directive( "r-anim", processAnimate) }); diff --git a/dist/regular.min.js b/dist/regular.min.js index faa5fc8..04874c5 100644 --- a/dist/regular.min.js +++ b/dist/regular.min.js @@ -1,2 +1,2 @@ -!function(){"use strict";function t(e,n,r){function i(){r=r||e,n=n||"root";var t=new Error('Failed to require "'+r+'" from "'+n+'"');throw t.path=r,t.parent=n,t.require=!0,t}var s=t.resolve(e);if(null==s)return void i();var a=t.modules[s];if(!a._resolving&&!a.exports){var o={};o.exports={},o.client=o.component=!0,a._resolving=!0,a.call(this,o.exports,t.relative(s),o),delete a._resolving,a.exports=o.exports}return a.exports}t.modules={},t.aliases={},t.exts=["",".js",".json","/index.js","/index.json"],t.resolve=function(e){"/"===e.charAt(0)&&(e=e.slice(1));for(var n=0;5>n;n++){var r=e+t.exts[n];if(t.modules.hasOwnProperty(r))return r;if(t.aliases.hasOwnProperty(r))return t.aliases[r]}},t.normalize=function(t,e){var n=[];if("."!=e.charAt(0))return e;t=t.split("/"),e=e.split("/");for(var r=0;ru;u++){r=a[u];var l=r.regexp.test(t);if(l)return r}return void 0}return"function"==typeof e&&(e={link:e}),"string"===i?s[t]=e:"regexp"===i&&(e.regexp=t,s.__regexp__.push(e)),this},plugin:function(t,e){var n=this._plugins;return null==e?n[t]:(n[t]=e,this)},use:function(t){return"string"==typeof t&&(t=y.plugin(t)),"function"!=typeof t?this:(t(this,y),this)},config:function(t){var e=!1;if("object"==typeof t)for(var n in t)("END"===n||"BEGIN"===n)&&(e=!0),a[n]=t[n];e&&i.setup()},expression:v.expression,Parser:s,Lexer:i,_addProtoInheritCache:function(t,e){if(Array.isArray(t))return t.forEach(y._addProtoInheritCache);var n="_"+t+"s";y._protoInheritCache.push(t),y[n]={},y[t]||(y[t]=function(r,i){var s=this[n];if("object"==typeof r){for(var a in r)r.hasOwnProperty(a)&&this[t](a,r[a]);return this}return null==i?s[r]:(s[r]=e?e(i):i,this)})},_inheritConfig:function(t,e){var n=y._protoInheritCache,r=o.slice(n);return r.forEach(function(n){t[n]=e[n];var r="_"+n+"s";e[r]&&(t[r]=o.createObject(e[r]))}),t}}),u(y),y._addProtoInheritCache("component"),y._addProtoInheritCache("filter",function(t){return"function"==typeof t?{get:t}:t}),p.mixTo(y),d.mixTo(y),y.implement({init:function(){},config:function(){},destroy:function(){this.$emit("$destroy"),this.group&&this.group.destroy(!0),this.group=null,this.parentNode=null,this._watchers=null,this._children=[];var t=this.$parent;if(t){var e=t._children.indexOf(this);t._children.splice(e,1)}this.$parent=null,this.$root=null,this._handles=null,this.$refs=null},$compile:function(t,e){e=e||{},"string"==typeof t&&(t=new s(t).parse());var n,r=this.__ext__,i=e.record;e.extra&&(this.__ext__=e.extra),i&&this._record();var a=this._walk(t,e);if(i){n=this._release();var o=this;n.length&&(a.ondestroy=function(){o.$unwatch(n)})}return e.extra&&(this.__ext__=r),a},$bind:function(t,e,n){var r=o.typeOf(e);if("expression"===e.type||"string"===r)this._bind(t,e,n);else if("array"===r)for(var i=0,s=e.length;s>i;i++)this._bind(t,e[i]);else if("object"===r)for(var i in e)e.hasOwnProperty(i)&&this._bind(t,i,e[i]);return t.$update(),this},$unbind:function(){},$inject:c.inject,$mute:function(t){t=!!t;var e=t===!1&&this._mute;return this._mute=!!t,e&&this.$update(),this},_bind:function(t,e,n){var r=this;if(!(t&&t instanceof y))throw"$bind() should pass Regular component as first argument";if(!e)throw"$bind() should pass as least one expression to bind";if(n||(n=e),e=v.expression(e),n=v.expression(n),n.set){var i=this.$watch(e,function(e){t.$update(n,e)});t.$on("$destroy",function(){r.$unwatch(i)})}if(e.set){var s=t.$watch(n,function(t){r.$update(e,t)});this.$on("$destroy",t.$unwatch.bind(t,s))}n.set(t,e.get(this))},_walk:function(t,e){if("array"===o.typeOf(t)){for(var n=[],r=0,i=t.length;i>r;r++)n.push(this._walk(t[r],e));return new f(n)}return"string"==typeof t?g.createTextNode(t):h[t.type||"default"].call(this,t,e)},_append:function(t){this._children.push(t),t.$parent=this},_handleEvent:function(t,e,n,r){var i,s=this.constructor,a="function"!=typeof n?o.handleEvent.call(this,n,e):n,u=s.event(e);return u?i=u.call(this,t,a,r):l.on(t,e,a),u?i:function(){l.off(t,e,a)}},_touchExpr:function(t){var e,n=this.__ext__,r={};if("expression"!==t.type||t.touched)return t;if(e=t.get||(t.get=new Function(o.ctxName,o.extName,o.prefix+"return ("+t.body+")")),r.get=n?function(t){return e(t,n)}:e,t.setbody&&!t.set){var i=t.setbody;t.set=function(e,n,r){return t.set=new Function(o.ctxName,o.setName,o.extName,o.prefix+i),t.set(e,n,r)},t.setbody=null}return t.set&&(r.set=n?function(e,r){return t.set(e,r,n)}:t.set),o.extend(r,{type:"expression",touched:!0,once:t.once||t.constant}),r},_f_:function(t){var e=this.constructor,n=e.filter(t);if(!n)throw"filter "+t+" is undefined";return n},_sg_:function(t,e,n){if("undefined"!=typeof n){var r=this.computed,i=r[t];if(i){if("expression"!==i.type||i.get||this._touchExpr(i),i.get)return i.get(this);o.log("the computed '"+t+"' don't define the get function, get data."+t+" altnately","error")}}return"undefined"==typeof e||"undefined"==typeof t?void 0:n&&"undefined"!=typeof n[t]?n[t]:e[t]},_ss_:function(t,e,n,r,i){var s,i=this.computed,r=r||"=",a=i?i[t]:null;if("="!==r)switch(s=a?a.get(this):n[t],r){case"+=":e=s+e;break;case"-=":e=s-e;break;case"*=":e=s*e;break;case"/=":e=s/e;break;case"%=":e=s%e}if(a){if(a.set)return a.set(this,e);o.log("the computed '"+t+"' don't define the set function, assign data."+t+" altnately","error")}return n[t]=e,e}}),y.prototype.inject=function(){return o.log("use $inject instead of inject","error"),this.$inject.apply(this,arguments)},y.filter(m),n.exports=y;var x=function(){function t(t){return function(e){return t.call(e,e.data)}}function e(t){return function(e,n){return t.call(e,n,e.data),n}}return function(n){if(n){var r,i,s,a={};for(var o in n)r=n[o],s=typeof r,"expression"!==r.type?"string"===s?a[o]=v.expression(r):(i=a[o]={type:"expression"},"function"===s?i.get=t(r):(r.get&&(i.get=t(r.get)),r.set&&(i.set=e(r.set)))):a[o]=r;return a}}}()}),t.register("regularjs/src/util.js",function(t,e,n){e("./helper/shim.js");var r=n.exports,i=e("./helper/entities.js"),s=[].slice,a={}.toString,o="undefined"!=typeof window?window:global;r.noop=function(){},r.uid=function(){var t=0;return function(){return t++}}(),r.varName="d",r.setName="p_",r.ctxName="c",r.extName="e",r.rWord=/^[\$\w]+$/,r.rSimpleAccessor=/^[\$\w]+(\.[\$\w]+)*$/,r.nextTick="function"==typeof setImmediate?setImmediate.bind(o):function(t){setTimeout(t,0)},r.prefix="var "+r.varName+"="+r.ctxName+".data;"+r.extName+"="+r.extName+"||'';",r.slice=function(t,e,n){for(var r=[],i=e||0,s=n||t.length;s>i;i++){var a=t[i];r.push(a)}return r},r.typeOf=function(t){return null==t?String(t):a.call(t).slice(8,-1).toLowerCase()},r.isExpression=function(t){return t&&"expression"===t.type},r.extend=function(t,e,n){if("array"===r.typeOf(n))for(var i=0,s=n.length;s>i;i++){var a=n[i];t[a]=e[a]}else for(var i in e)("undefined"==typeof t[i]||n===!0)&&(t[i]=e[i]);return t},r.makePredicate=function(t){function e(t){if(1===t.length)return n+="return str === '"+t[0]+"';";n+="switch(str){";for(var e=0;e3){r.sort(function(t,e){return e.length-t.length}),n+="switch(str.length){";for(var i=0;ir;r++){var s=(t[r]||"").length;if(n+s>e)return{num:r,line:t[r],start:e-r-n,prev:t[r-1],next:t[r+1]};n+=s}}function e(t,e,n,s){var a=t.length,o=e-r;0>o&&(o=0);var u=e+i;u>a&&(u=a);var c=t.slice(o,u),l="["+(n+1)+"] "+(o>0?"..":""),h=a>u?"..":"",f=l+c+h;return s&&(f+="\n"+new Array(e-o+l.length+1).join(" ")+"^^^"),f}var n=/\r\n|[\n\r\u2028\u2029]/g,r=20,i=20;return function(r,i){i>r.length-1&&(i=r.length-1),n.lastIndex=0;var s=r.split(n),a=t(s,i),o=a.start,u=a.num;return(a.prev?e(a.prev,o,u-1)+"\n":"")+e(a.line,o,u,!0)+"\n"+(a.next?e(a.next,o,u+1)+"\n":"")}}();var u=/\((\?\!|\?\:|\?\=)/g;r.findSubCapture=function(t){var e=0,n=0,r=t.length,i=t.match(u);for(i=i?i.length:0;r--;){var s=t.charAt(r);(0===r||"\\"!==t.charAt(r-1))&&("("===s&&e++,")"===s&&n++)}if(e!==n)throw"RegExp: "+t+"'s bracket is not marched";return e-i},r.escapeRegExp=function(t){return t.replace(/[-[\]{}()*+?.\\^$|,#\s]/g,function(t){return"\\"+t})};var c=new RegExp("&("+Object.keys(i).join("|")+");","gi");r.convertEntity=function(t){return(""+t).replace(c,function(t,e){return String.fromCharCode(i[e])})},r.createObject=function(t,e){function n(){}n.prototype=t;var i=new n;return e&&r.extend(i,e),i},r.createProto=function(t,e){function n(){this.constructor=t}return n.prototype=e,t.prototype=new n},r.clone=function(t){var e=r.typeOf(t);if("array"===e){for(var n=[],i=0,s=t.length;s>i;i++)n[i]=t[i];return n}if("object"===e){var n={};for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);return n}return t},r.equals=function(t,e){var n=typeof t;return"number"===n&&"number"==typeof e&&isNaN(t)&&isNaN(e)?!0:t===e};var l=/-([a-z])/g;r.camelCase=function(t){return t.replace(l,function(t,e){return e.toUpperCase()})},r.throttle=function(t,e){var n,r,i,e=e||100,s=null,a=0,o=function(){a=+new Date,s=null,i=t.apply(n,r),n=r=null};return function(){var u=+new Date,c=e-(u-a);return n=this,r=arguments,0>=c||c>e?(clearTimeout(s),s=null,a=u,i=t.apply(n,r),n=r=null):s||(s=setTimeout(o,c)),i}},r.escape=function(){var t=/&/g,e=//g,r=/\'/g,i=/\"/g,s=/[&<>\"\']/;return function(a){return s.test(a)?a.replace(t,"&").replace(e,"<").replace(n,">").replace(r,"'").replace(i,"""):a}}(),r.cache=function(t){t=t||1e3;var e=[],n={};return{set:function(t,r){return e.length>this.max&&(n[e.shift()]=void 0),void 0===n[t]&&e.push(t),n[t]=r,r},get:function(t){return void 0===t?n:n[t]},max:t,len:function(){return e.length}}},r.handleEvent=function(t){var e,n=this;return"expression"===t.type&&(e=t.get),e?function(t){n.data.$event=t;var r=e(n);r===!1&&t&&t.preventDefault&&t.preventDefault(),n.data.$event=void 0,n.$update()}:function(){var e=s.call(arguments);e.unshift(t),n.$emit.apply(n,e),n.$update()}},r.once=function(t){var e=0;return function(){0===e++&&t.apply(this,arguments)}},r.fixObjStr=function(t){return 0!==t.trim().indexOf("{")?"{"+t+"}":t},r.log=function(t,e){return""},r.isVoidTag=r.makePredicate("area base br col embed hr img input keygen link menuitem meta param source track wbr r-content"),r.isBooleanAttr=r.makePredicate("selected checked disabled readOnly required open autofocus controls autoplay compact loop defer multiple"),r.isFalse-function(){return!1},r.isTrue-function(){return!0},r.isExpr=function(t){return t&&"expression"===t.type},r.assert=function(t,e){if(!t)throw e}}),t.register("regularjs/src/walkers.js",function(t,e,n){function r(t,e,n){for(var r=[],i=0,s=t.length;s>i;i++){var a=this._walk(t[i],{element:e,fromElement:!0,attrs:t,extra:n});a&&r.push(a)}return r}var i=e("./helper/arrayDiff.js"),s=e("./helper/combine.js"),a=e("./helper/animate.js"),o=(e("./parser/node.js"),e("./group.js")),u=e("./dom.js"),c=e("./util"),l=n.exports={};l.list=function(t,e){function n(t,e){for(var n=0;e>n;n++){var r=E.children.splice(t+1,1)[0];r.destroy(!0)}}function r(n,r,i){for(var o=n;r>o;o++){var u=i[o],l={};l[_]=o,l[T]=u,l=c.createObject(y,l);var h=x.$compile(t.body,{extra:l,namespace:g,record:!0,outer:e.outer});h.data=l;var f=s.last(E.get(o));f.parentNode&&a.inject(s.node(h),f,"after"),E.children.splice(o+1,0,h)}}function u(t,e,n){for(var r=t;e>r;r++){var i=E.get(r+1);i.data[_]=r,i.data[T]=n[r]}}function h(t,e,s){if(t||(t=[],s=i(t,e)),s&&s.length){for(var a=0,o=t.length,c=0;cg;)d(t[h],h)!==d(f[0],h)&&(n(h,1),r(h,h+1,t)),f.shift(),p--,h++,g++;v=f.length}u(a,h,t),n(h,v),r(h,h+p,t),a=h+p-v,a=0>a?0:a}if(o>a)for(var c=a;o>c;c++){var y=E.get(c+1);y.data[_]=c}}}function f(t,e){t=t||[],e=e||[];var i=t.length||0,s=e.length||0,a=Math.min(i,s);u(0,a,t),s>i?n(i,s-i):i>s&&r(s,i,t)}function p(t,n,r){var i=t&&t.length,o=n&&n.length;if(!o&&i&&E.get(1)){var u=E.children.pop();u.destroy&&u.destroy(!0)}if(w===!0?f(t,n,r):h(t,n,r),!i&&N&&N.length){var c=x.$compile(N,{extra:y,record:!0,outer:e.outer,namespace:g});E.children.push(c),m.parentNode&&a.inject(s.node(c),m,"after")}}var d,v,m=(l.Regular,document.createComment("Regular list")),g=e.namespace,y=e.extra,x=this,E=new o([m]),_=t.variable+"_index",T=t.variable,N=t.alternate,w=t.track;return w&&w!==!0&&(w=this._touchExpr(w),v=c.createObject(y),d=function(t,e){return v[T]=t,v[_]=e,w.get(x,v)}),this.$watch(t.sequence,p,{init:!0,indexTrack:w===!0}),E},l.template=function(t,e){var n,n,r=t.content,i=document.createComment("inlcude"),u=e.namespace,c=e.extra,l=new o([i]);if(r){var h=this;this.$watch(r,function(t){(n=l.get(1))&&(n.destroy(!0),l.children.pop()),l.push(n=h.$compile(t,{record:!0,outer:e.outer,namespace:u,extra:c})),i.parentNode&&a.inject(s.node(n),i,"before")},{init:!0})}return l};var h=0;l["if"]=function(t,e){var n,r,i=this,u=e.extra;if(e&&e.element){var c=function(a){a?(r&&s.destroy(r),t.consequent&&(n=i.$compile(t.consequent,{record:!0,element:e.element,extra:u}))):(n&&s.destroy(n),t.alternate&&(r=i.$compile(t.alternate,{record:!0,element:e.element,extra:u})))};return this.$watch(t.test,c,{force:!0}),{destroy:function(){n?s.destroy(n):r&&s.destroy(r)}}}var n,r,l=document.createComment("Regular if"+h++),f=new o;f.push(l);var p=null,d=e.namespace,c=function(o){var c=!!o;c!==p&&(p=c,f.children[1]&&(f.children[1].destroy(!0),f.children.pop()),c?t.consequent&&t.consequent.length&&(n=i.$compile(t.consequent,{record:!0,outer:e.outer,namespace:d,extra:u}),f.push(n),l.parentNode&&a.inject(s.node(n),l,"before")):t.alternate&&t.alternate.length&&(r=i.$compile(t.alternate,{record:!0,outer:e.outer,namespace:d,extra:u}),f.push(r),l.parentNode&&a.inject(s.node(r),l,"before")))};return this.$watch(t.test,c,{force:!0,init:!0}),f},l.expression=function(t){var e=document.createTextNode("");return this.$watch(t,function(t){u.text(e,""+(null==t?"":""+t))}),e},l.text=function(t){var e=document.createTextNode(c.convertEntity(t.text));return e};var f=/^on-(.+)$/;l.element=function(t,e){var n,i,o=t.attrs,h=this.constructor,f=t.children,p=e.namespace,d=e.extra,v=t.tag,m=h.component(v);if("r-content"===v&&this._getTransclude)return this._getTransclude();if(m||"r-component"===v)return e.Component=m,l.component.call(this,t,e);"svg"===v&&(p="svg"),f&&f.length&&(n=this.$compile(f,{outer:e.outer,namespace:p,extra:d})),i=u.create(v,p,o),n&&!c.isVoidTag(v)&&u.inject(s.node(n),i),t.touched||(o.sort(function(t,e){var n=h.directive(t.name),r=h.directive(e.name);return n&&r?(r.priority||1)-(n.priority||1):n?1:r?-1:"type"===e.name?1:-1}),t.touched=!0);var g=r.call(this,o,i,d);return{type:"element",group:n,node:function(){return i},last:function(){return i},destroy:function(t){t?a.remove(i,n?n.destroy.bind(n):c.noop):n&&n.destroy(),g.length&&g.forEach(function(t){t&&("function"==typeof t.destroy?t.destroy():t())})}}},l.component=function(t,e){for(var n,r,i,a,u=t.attrs,l=e.Component,h=this.constructor,p=e.namespace,d=this,v={},m=0,g=u.length;g>m;m++){var y=u[m],x=this._touchExpr(void 0===y.value?!0:y.value);x.constant&&(x=y.value=x.get(this)),y.value&&y.value.constant===!0&&(x=x.get(this));var E=y.name;if(!y.event){var _=E.match(f);_&&(y.event=_[1])}if("is"===E&&!l){i=x;var T=this.$get(x,!0);if(l=h.component(T),"function"!=typeof l)throw new Error("component "+T+" has not registed!")}var N;(N=y.event)?(a=a||{},a[N]=c.handleEvent.call(this,x,N)):(E=y.name=c.camelCase(E),v[E]="expression"!==x.type?x:x.get(d),"ref"===E&&null!=x&&(r="expression"===x.type?x.get(d):x),"isolate"===E&&(n="expression"===x.type?x.get(d):parseInt(x===!0?3:x,10),v.isolate=n))}var w={data:v,events:a,$parent:this,$outer:e.outer,namespace:p,$root:this.$root,$body:t.children},j=new l(w);r&&d.$refs&&(d.$refs[r]=j);for(var m=0,g=u.length;g>m;m++){var y=u[m],x=y.value||!0,E=y.name;"expression"!==x.type||y.event||(x=d._touchExpr(x),2&n||this.$watch(x,j.$update.bind(j,E)),!x.set||1&n||j.$watch(E,d.$update.bind(d,x),{sync:!0}))}if(r&&j.$on("destroy",function(){d.$refs&&(d.$refs[r]=null)}),i&&"expression"===i.type){var b=new o;return b.push(j),this.$watch(i,function(t){var e=h.component(t);if(!e)throw new Error("component "+t+" has not registed!");var n=new e(w),i=b.children.pop();b.push(n),n.$inject(s.last(i),"after"),i.destroy(),r&&(d.$refs[r]=n)},{sync:!0}),b}return j},l.attribute=function(t,e){var n=t,r=n.name,i=n.value||"",s=i.constant,a=this.constructor,o=a.directive(r),l=e.element,h=this;if(i=this._touchExpr(i),s&&(i=i.get(this)),o&&o.link){var f=o.link.call(h,l,i,r,e.attrs);return"function"==typeof f&&(f={destroy:f}),f}return"expression"===i.type?this.$watch(i,function(t){u.attr(l,r,t)},{init:!0}):c.isBooleanAttr(r)?u.attr(l,r,!0):u.attr(l,r,i),e.fromElement?void 0:{destroy:function(){u.attr(l,r,null)}}}}),t.register("regularjs/src/env.js",function(t,e){var n=e("./util");t.svg=function(){return"undefined"!=typeof document&&document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")}(),t.browser="undefined"!=typeof document&&document.nodeType,t.exprCache=n.cache(1e3),t.isRunning=!1}),t.register("regularjs/src/index.js",function(t,e,n){var r=e("./env.js"),i=e("./config"),s=n.exports=e("./Regular.js"),a=s.Parser,o=s.Lexer;r.browser&&(e("./directive/base.js"),e("./directive/animation.js"),e("./module/timeout.js"),s.dom=e("./dom.js")),s.env=r,s.util=e("./util.js"),s.parse=function(t,e){e=e||{},(e.BEGIN||e.END)&&(e.BEGIN&&(i.BEGIN=e.BEGIN),e.END&&(i.END=e.END),o.setup());var n=new a(t).parse();return e.stringify?JSON.stringify(n):n}}),t.register("regularjs/src/dom.js",function(t,e,n){function r(t){return(""+t).replace(/-\D/g,function(t){return t.charAt(1).toUpperCase()})}function i(t,e){return"change"===e&&u.msie<9&&t&&t.tagName&&"input"===t.tagName.toLowerCase()&&("checkbox"===t.type||"radio"===t.type)?"click":e}function s(t){if(t=t||window.event,t._fixed)return t;this.event=t,this.target=t.target||t.srcElement;var e=this.type=t.type,n=this.button=t.button;if(v.test(e)&&(this.pageX=null!=t.pageX?t.pageX:t.clientX+m.scrollLeft,this.pageY=null!=t.pageX?t.pageY:t.clientY+m.scrollTop,"mouseover"===e||"mouseout"===e)){for(var r=t.relatedTarget||t[("mouseover"===e?"from":"to")+"Element"];r&&3===r.nodeType;)r=r.parentNode;this.relatedTarget=r}("DOMMouseScroll"===e||"mousewheel"===e)&&(this.wheelDelta=t.wheelDelta?t.wheelDelta/120:-(t.detail||0)/3),this.which=t.which||t.keyCode,this.which||void 0===n||(this.which=1&n?1:2&n?3:4&n?2:0),this._fixed=!0}var a,o,u=n.exports,c=e("./env.js"),l=e("./util"),h=document.createElement("div"),f=function(){},p={html:"http://www.w3.org/1999/xhtml",svg:"http://www.w3.org/2000/svg"};u.body=document.body,u.doc=document,u.tNode=h,h.addEventListener?(a=function(t,e,n){t.addEventListener(e,n,!1)},o=function(t,e,n){t.removeEventListener(e,n,!1)}):(a=function(t,e,n){t.attachEvent("on"+e,n)},o=function(t,e,n){t.detachEvent("on"+e,n)}),u.msie=parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase())||[])[1]),isNaN(u.msie)&&(u.msie=parseInt((/trident\/.*; rv:(\d+)/.exec(navigator.userAgent.toLowerCase())||[])[1])),u.find=function(t){if(document.querySelector)try{return document.querySelector(t)}catch(e){}return-1!==t.indexOf("#")?document.getElementById(t.slice(1)):void 0},u.inject=function(t,e,n){if(n=n||"bottom",Array.isArray(t)){var r=t;t=u.fragment();for(var i=0,s=r.length;s>i;i++)t.appendChild(r[i])}var a,o;switch(n){case"bottom":e.appendChild(t);break;case"top":(a=e.firstChild)?e.insertBefore(t,e.firstChild):e.appendChild(t);break;case"after":(o=e.nextSibling)?o.parentNode.insertBefore(t,o):e.parentNode.appendChild(t);break;case"before":e.parentNode.insertBefore(t,e)}},u.id=function(t){return document.getElementById(t)},u.create=function(t,e){if("svg"===e){if(!c.svg)throw Error("the env need svg support");e=p.svg}return e?document.createElementNS(e,t):document.createElement(t)},u.fragment=function(){return document.createDocumentFragment()};var d={"class":function(t,e){"className"in t&&(t.namespaceURI===p.html||!t.namespaceURI)?t.className=e||"":t.setAttribute("class",e)},"for":function(t,e){"htmlFor"in t?t.htmlFor=e:t.setAttribute("for",e)},style:function(t,e){t.style?t.style.cssText=e:t.setAttribute("style",e)},value:function(t,e){t.value=null!=e?e:""}};u.attr=function(t,e,n){if(l.isBooleanAttr(e)){if("undefined"==typeof n)return t[e]||(t.attributes.getNamedItem(e)||f).specified?e:void 0;n?(t[e]=!0,t.setAttribute(e,e),u.msie&&u.msie<=7&&(t.defaultChecked=!0)):(t[e]=!1,t.removeAttribute(e))}else if("undefined"!=typeof n)d[e]?d[e](t,n):null===n?t.removeAttribute(e):t.setAttribute(e,n);else if(t.getAttribute){var r=t.getAttribute(e,2);return null===r?void 0:r}},u.on=function(t,e,n){var r=e.split(" ");n.real=function(e){var r=new s(e);r.origin=t,n.call(t,r)},r.forEach(function(e){e=i(t,e),a(t,e,n.real)})},u.off=function(t,e,n){var r=e.split(" ");n=n.real||n,r.forEach(function(e){e=i(t,e),o(t,e,n)})},u.text=function(){var t={};return u.msie&&u.msie<9?(t[1]="innerText",t[3]="nodeValue"):t[1]=t[3]="textContent",function(e,n){var r=t[e.nodeType];return null==n?r?e[r]:"":void(e[r]=n)}}(),u.html=function(t,e){return"undefined"==typeof e?t.innerHTML:void(t.innerHTML=e)},u.replace=function(t,e){e.parentNode&&e.parentNode.replaceChild(t,e)},u.remove=function(t){t.parentNode&&t.parentNode.removeChild(t)},u.css=function(t,e,n){if("object"!==l.typeOf(e)){if("undefined"==typeof n){var i;return u.msie<=8&&(i=t.currentStyle&&t.currentStyle[e],""===i&&(i="auto")),i=i||t.style[e],u.msie<=8&&(i=""===i?void 0:i),i}e=r(e),e&&(t.style[e]=n)}else for(var s in e)e.hasOwnProperty(s)&&u.css(t,s,e[s])},u.addClass=function(t,e){var n=t.className||"";-1===(" "+n+" ").indexOf(" "+e+" ")&&(t.className=n?n+" "+e:e)},u.delClass=function(t,e){var n=t.className||"";t.className=(" "+n+" ").replace(" "+e+" "," ").trim()},u.hasClass=function(t,e){var n=t.className||"";return-1!==(" "+n+" ").indexOf(" "+e+" ")};var v=/^(?:click|dblclick|contextmenu|DOMMouseScroll|mouse(?:\w+))$/,m=document;m=m.compatMode&&"CSS1Compat"!==m.compatMode?m.body:m.documentElement,l.extend(s.prototype,{immediateStop:l.isFalse,stop:function(){this.preventDefault().stopPropagation()},preventDefault:function(){return this.event.preventDefault?this.event.preventDefault():this.event.returnValue=!1,this},stopPropagation:function(){return this.event.stopPropagation?this.event.stopPropagation():this.event.cancelBubble=!0,this},stopImmediatePropagation:function(){this.event.stopImmediatePropagation&&this.event.stopImmediatePropagation()}}),u.nextFrame=function(){var t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){setTimeout(t,16)},e=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||function(t){clearTimeout(t)};return function(n){var r=t(n);return function(){e(r)}}}();var g;u.nextReflow=function(t){u.nextFrame(function(){g=document.body.offsetWidth,t()})}}),t.register("regularjs/src/group.js",function(t,e,n){function r(t){this.children=t||[]}var i=e("./util"),s=e("./helper/combine");i.extend(r.prototype,{destroy:function(t){s.destroy(this.children,t),this.ondestroy&&this.ondestroy(),this.children=null},get:function(t){return this.children[t]},push:function(t){this.children.push(t)},inject:s.inject}),n.exports=r}),t.register("regularjs/src/config.js",function(t,e,n){n.exports={BEGIN:"{",END:"}"}}),t.register("regularjs/src/const.js",function(t,e,n){n.exports={COMPONENT_TYPE:1,ELEMENT_TYPE:2}}),t.register("regularjs/src/parser/Lexer.js",function(t,e,n){function r(t){return function(e){return{type:t,value:e}}}function i(t,e){h[l.END]&&(this.markStart=h[l.END],this.markEnd=l.END),this.input=(t||"").trim(),this.opts=e||{},this.map=2!==this.opts.mode?o:u,this.states=["INIT"],e&&e.expression&&(this.states.push("JST"),this.expression=!0)}function s(t){for(var e,n,r={},i=0,s=t.length;s>i;i++)e=t[i],n=e[2]||"INIT",(r[n]||(r[n]={rules:[],links:[]})).rules.push(e);return a(r)}function a(t){function e(t,e){return"string"==typeof f[e]?c.escapeRegExp(f[e]):String(f[e]).slice(1,-1)}var n,i,s,a,o,u,l;for(var h in t){n=t[h],n.curIndex=1,i=n.rules,s=[];for(var p=0,d=i.length;d>p;p++)l=i[p],o=l[0],a=l[1],"string"==typeof a&&(a=r(a)),"regexp"===c.typeOf(o)&&(o=o.toString().slice(1,-1)),o=o.replace(/\{(\w+)\}/g,e),u=c.findSubCapture(o)+1,n.links.push([n.curIndex,u,a]),n.curIndex+=u,s.push(o);n.TRUNK=new RegExp("^(?:("+s.join(")|(")+"))")}return t}var o,u,c=e("../util.js"),l=e("../config.js"),h={"}":"{","]":"["},f={NAME:/(?:[:_A-Za-z][-\.:_0-9A-Za-z]*)/,IDENT:/[\$_A-Za-z][_0-9A-Za-z\$]*/,SPACE:/[\r\n\f ]/},p=/a|(b)/.exec("a"),d=p&&void 0===p[1]?function(t){return void 0!==t}:function(t){return!!t},v=i.prototype;v.lex=function(t){t=(t||this.input).trim();var e,n,r,i,s,a=[];this.input=t,this.marks=0,this.index=0;for(var o=0;t;)o++,s=this.state(),e=this.map[s],n=e.TRUNK.exec(t),n||this.error("Unrecoginized Token"),r=n[0].length,t=t.slice(r),i=this._process.call(this,n,e,t),i&&a.push(i),this.index+=r;return a.push({type:"EOF"}),a},v.error=function(t){throw"Parse Error: "+t+":\n"+c.trackErrorPos(this.input,this.index)},v._process=function(t,e,n){for(var r,i=e.links,s=!1,a=i.length,o=0;a>o;o++){var u=i[o],c=u[2],l=u[0];if(d(t[l])){s=!0,c&&(r=c.apply(this,t.slice(l,l+u[1])),r&&(r.pos=this.index));break}}if(!s)switch(n.charAt(0)){case"<":this.enter("TAG");break;default:this.enter("JST")}return r},v.enter=function(t){return this.states.push(t),this},v.state=function(){var t=this.states;return t[t.length-1]},v.leave=function(t){var e=this.states;t&&e[e.length-1]!==t||e.pop()},i.setup=function(){f.END=l.END,f.BEGIN=l.BEGIN,o=s([m.ENTER_JST,m.ENTER_TAG,m.TEXT,m.TAG_NAME,m.TAG_OPEN,m.TAG_CLOSE,m.TAG_PUNCHOR,m.TAG_ENTER_JST,m.TAG_UNQ_VALUE,m.TAG_STRING,m.TAG_SPACE,m.TAG_COMMENT,m.JST_OPEN,m.JST_CLOSE,m.JST_COMMENT,m.JST_EXPR_OPEN,m.JST_IDENT,m.JST_SPACE,m.JST_LEAVE,m.JST_NUMBER,m.JST_PUNCHOR,m.JST_STRING,m.JST_COMMENT]),u=s([m.ENTER_JST2,m.TEXT,m.JST_COMMENT,m.JST_OPEN,m.JST_CLOSE,m.JST_EXPR_OPEN,m.JST_IDENT,m.JST_SPACE,m.JST_LEAVE,m.JST_NUMBER,m.JST_PUNCHOR,m.JST_STRING,m.JST_COMMENT])};var m={ENTER_JST:[/[^\x00<]*?(?={BEGIN})/,function(t){return this.enter("JST"),t?{type:"TEXT",value:t}:void 0}],ENTER_JST2:[/[^\x00]*?(?={BEGIN})/,function(t){return this.enter("JST"),t?{type:"TEXT",value:t}:void 0}],ENTER_TAG:[/[^\x00<>]*?(?=<)/,function(t){return this.enter("TAG"),t?{type:"TEXT",value:t}:void 0}],TEXT:[/[^\x00]+/,"TEXT"],TAG_NAME:[/{NAME}/,"NAME","TAG"],TAG_UNQ_VALUE:[/[^\{}&"'=><`\r\n\f ]+/,"UNQ","TAG"],TAG_OPEN:[/<({NAME})\s*/,function(t,e){return{type:"TAG_OPEN",value:e}},"TAG"],TAG_CLOSE:[/<\/({NAME})[\r\n\f ]*>/,function(t,e){return this.leave(),{type:"TAG_CLOSE",value:e}},"TAG"],TAG_ENTER_JST:[/(?={BEGIN})/,function(){this.enter("JST")},"TAG"],TAG_PUNCHOR:[/[\>\/=&]/,function(t){return">"===t&&this.leave(),{type:t,value:t}},"TAG"],TAG_STRING:[/'([^']*)'|"([^"]*)\"/,function(t,e,n){var r=e||n||"";return{type:"STRING",value:r}},"TAG"],TAG_SPACE:[/{SPACE}+/,null,"TAG"],TAG_COMMENT:[/<\!--([^\x00]*?)--\>/,function(){this.leave()},"TAG"],JST_OPEN:["{BEGIN}#{SPACE}*({IDENT})",function(t,e){return{type:"OPEN",value:e}},"JST"],JST_LEAVE:[/{END}/,function(t){return this.markEnd===t&&this.expression?{type:this.markEnd,value:this.markEnd}:this.markEnd&&this.marks?(this.marks--,{type:this.markEnd,value:this.markEnd}):(this.firstEnterStart=!1,this.leave("JST"),{type:"END"})},"JST"],JST_CLOSE:[/{BEGIN}\s*\/({IDENT})\s*{END}/,function(t,e){return this.leave("JST"),{type:"CLOSE",value:e}},"JST"],JST_COMMENT:[/{BEGIN}\!([^\x00]*?)\!{END}/,function(){this.leave()},"JST"],JST_EXPR_OPEN:["{BEGIN}",function(t){if(t===this.markStart){if(this.expression)return{type:this.markStart,value:this.markStart};if(this.firstEnterStart||this.marks)return this.marks++,this.firstEnterStart=!1,{type:this.markStart,value:this.markStart};this.firstEnterStart=!0}return{type:"EXPR_OPEN",escape:!1}},"JST"],JST_IDENT:["{IDENT}","IDENT","JST"],JST_SPACE:[/[ \r\n\f]+/,null,"JST"],JST_PUNCHOR:[/[=!]?==|[-=><+*\/%\!]?\=|\|\||&&|\@\(|\.\.|[<\>\[\]\(\)\-\|\{}\+\*\/%?:\.!,]/,function(t){return{type:t,value:t}},"JST"],JST_STRING:[/'([^']*)'|"([^"]*)"/,function(t,e,n){return{type:"STRING",value:e||n||""}},"JST"],JST_NUMBER:[/(?:[0-9]*\.[0-9]+|[0-9]+)(e\d+)?/,function(t){return{type:"NUMBER",value:parseFloat(t,10)}},"JST"]};i.setup(),n.exports=i}),t.register("regularjs/src/parser/node.js",function(t,e,n){n.exports={element:function(t,e,n){return{type:"element",tag:t,attrs:e,children:n}},attribute:function(t,e){return{type:"attribute",name:t,value:e}},"if":function(t,e,n){return{type:"if",test:t,consequent:e,alternate:n}},list:function(t,e,n,r,i){return{type:"list",sequence:t,alternate:r,variable:e,body:n,track:i}},expression:function(t,e,n){return{type:"expression",body:t,constant:n||!1,setbody:e||!1}},text:function(t){return{type:"text",text:t}},template:function(t){return{type:"template",content:t}}}}),t.register("regularjs/src/parser/Parser.js",function(t,e,n){function r(t,e){e=e||{},this.input=t,this.tokens=new o(t,e).lex(),this.pos=0,this.length=this.tokens.length -}var i=e("../util.js"),s=e("../config.js"),a=e("./node.js"),o=e("./Lexer.js"),u=i.varName,c=i.ctxName,l=i.extName,h=i.makePredicate("STRING IDENT NUMBER"),f=i.makePredicate("true false undefined null this Array Date JSON Math NaN RegExp decodeURI decodeURIComponent encodeURI encodeURIComponent parseFloat parseInt Object"),p=r.prototype;p.parse=function(){this.pos=0;var t=this.program();return"TAG_CLOSE"===this.ll().type&&this.error("You may got a unclosed Tag"),t},p.ll=function(t){t=t||1,0>t&&(t+=1);var e=this.pos+t-1;return e>this.length-1?this.tokens[this.length-1]:this.tokens[e]},p.la=function(t){return(this.ll(t)||"").type},p.match=function(t,e){var n;return(n=this.eat(t,e))?n:(n=this.ll(),void this.error("expect ["+t+(null==e?"":":"+e)+']" -> got "['+n.type+(null==e?"":":"+n.value)+"]",n.pos))},p.error=function(t,e){throw t="\n【 parse failed 】 "+t+":\n\n"+i.trackErrorPos(this.input,"number"==typeof e?e:this.ll().pos||0),new Error(t)},p.next=function(t){t=t||1,this.pos+=t},p.eat=function(t,e){var n=this.ll();if("string"!=typeof t){for(var r=t.length;r--;)if(n.type===t[r])return this.next(),n}else if(n.type===t&&("undefined"==typeof e||n.value===e))return this.next(),n;return!1},p.program=function(){for(var t=[],e=this.ll();"EOF"!==e.type&&"TAG_CLOSE"!==e.type;)t.push(this.statement()),e=this.ll();return t},p.statement=function(){var t=this.ll();switch(t.type){case"NAME":case"TEXT":var e=t.value;for(this.next();t=this.eat(["NAME","TEXT"]);)e+=t.value;return a.text(e);case"TAG_OPEN":return this.xml();case"OPEN":return this.directive();case"EXPR_OPEN":return this.interplation();default:this.error("Unexpected token: "+this.la())}},p.xml=function(){var t,e,n,r;return t=this.match("TAG_OPEN").value,e=this.attrs(),r=this.eat("/"),this.match(">"),r||i.isVoidTag(t)||(n=this.program(),this.eat("TAG_CLOSE",t)||this.error("expect gotno matched closeTag")),a.element(t,e,n)},p.xentity=function(t){var e,n=t.value;return"NAME"===t.type?(this.eat("=")&&(e=this.attvalue()),a.attribute(n,e)):("if"!==n&&this.error("current version. ONLY RULE #if #else #elseif is valid in tag, the rule #"+n+" is invalid"),this["if"](!0))},p.attrs=function(t){var e;e=t?["NAME"]:["NAME","OPEN"];for(var n,r=[];n=this.eat(e);)r.push(this.xentity(n));return r},p.attvalue=function(){var t=this.ll();switch(t.type){case"NAME":case"UNQ":case"STRING":this.next();var e=t.value;if(~e.indexOf(s.BEGIN)&&~e.indexOf(s.END)){var n=!0,i=new r(e,{mode:2}).parse();if(1===i.length&&"expression"===i[0].type)return i[0];var o=[];i.forEach(function(t){t.constant||(n=!1),o.push(t.body||"'"+t.text.replace(/'/g,"\\'")+"'")}),o="["+o.join(",")+"].join('')",e=a.expression(o,null,n)}return e;case"EXPR_OPEN":return this.interplation();default:this.error("Unexpected token: "+this.la())}},p.directive=function(){var t=this.ll().value;return this.next(),"function"==typeof this[t]?this[t]():void this.error("Undefined directive["+t+"]")},p.interplation=function(){this.match("EXPR_OPEN");var t=this.expression(!0);return this.match("END"),t},p.inc=p.include=function(){var t=this.expression();return this.match("END"),a.template(t)},p["if"]=function(t){var e=this.expression(),n=[],r=[],i=n,s=t?"attrs":"statement";this.match("END");for(var o,u;!(u=this.eat("CLOSE"));)if(o=this.ll(),"OPEN"===o.type)switch(o.value){case"else":i=r,this.next(),this.match("END");break;case"elseif":return this.next(),r.push(this["if"](t)),a["if"](e,n,r);default:i.push(this[s](!0))}else i.push(this[s](!0));return"if"!==u.value&&this.error("Unmatched if directive"),a["if"](e,n,r)},p.list=function(){var t,e,n,r=this.expression(),i=[],s=[],o=i;for(this.match("IDENT","as"),t=this.match("IDENT").value,this.eat("IDENT","by")&&(this.eat("IDENT",t+"_index")?n=!0:(n=this.expression(),n.constant&&(n=!0))),this.match("END");!(e=this.eat("CLOSE"));)this.eat("OPEN","else")?(o=s,this.match("END")):o.push(this.statement());return"list"!==e.value&&this.error("expect list got /"+e.value+" ",e.pos),a.list(r,t,i,s,n)},p.expression=function(){var t;return this.eat("@(")?(t=this.expr(),t.once=!0,this.match(")")):t=this.expr(),t},p.expr=function(){this.depend=[];var t=this.filter(),e=t.get||t,n=t.set;return a.expression(e,n,!this.depend.length)},p.filter=function(){var t,e,n,r=this.assign(),s=this.eat("|"),a=[],o="t",u=r.set,l="";if(s){u&&(t=[]),e="(function("+o+"){";do l=o+" = "+c+"._f_('"+this.match("IDENT").value+"' ).get.call( "+i.ctxName+","+o,l+=this.eat(":")?", "+this.arguments("|").join(",")+");":");",a.push(l),t&&t.unshift(l.replace(" ).get.call"," ).set.call"));while(s=this.eat("|"));return a.push("return "+o),t&&t.push("return "+o),n=e+a.join("")+"})("+r.get+")",t&&(u=u.replace(i.setName,e+t.join("")+"})("+i.setName+")")),this.getset(n,u)}return r},p.assign=function(){var t,e=this.condition();return(t=this.eat(["=","+=","-=","*=","/=","%="]))?(e.set||this.error("invalid lefthand expression in assignment expression"),this.getset(e.set.replace(","+i.setName,","+this.condition().get).replace("'='","'"+t.type+"'"),e.set)):e},p.condition=function(){var t=this.or();return this.eat("?")?this.getset([t.get+"?",this.assign().get,this.match(":").type,this.assign().get].join("")):t},p.or=function(){var t=this.and();return this.eat("||")?this.getset(t.get+"||"+this.or().get):t},p.and=function(){var t=this.equal();return this.eat("&&")?this.getset(t.get+"&&"+this.and().get):t},p.equal=function(){var t,e=this.relation();return(t=this.eat(["==","!=","===","!=="]))?this.getset(e.get+t.type+this.equal().get):e},p.relation=function(){var t,e=this.additive();return(t=this.eat(["<",">",">=","<="])||this.eat("IDENT","in"))?this.getset(e.get+t.value+this.relation().get):e},p.additive=function(){var t,e=this.multive();return(t=this.eat(["+","-"]))?this.getset(e.get+t.value+this.additive().get):e},p.multive=function(){var t,e=this.range();return(t=this.eat(["*","/","%"]))?this.getset(e.get+t.type+this.multive().get):e},p.range=function(){var t,e,n=this.unary();if(t=this.eat("..")){e=this.unary();var r="(function(start,end){var res = [],step=end>start?1:-1; for(var i = start; end>start?i <= end: i>=end; i=i+step){res.push(i); } return res })("+n.get+","+e.get+")";return this.getset(r)}return n},p.unary=function(){var t;return(t=this.eat(["+","-","~","!"]))?this.getset("("+t.type+this.unary().get+")"):this.member()},p.member=function(t,e,n,r){var s,a,o,f=!1;if(t)"string"==typeof e&&h(e)?n.push(e):(n&&n.length&&this.depend.push(n),n=null);else{a=this.primary();var p=typeof a;"string"===p?(n=[],n.push(a),e=a,o=l+"."+a,t=c+"._sg_('"+a+"', "+u+", "+l+")",f=!0):"this"===a.get?(t=c,n=["this"]):(n=null,t=a.get)}if(s=this.eat(["[",".","("]))switch(s.type){case".":var d=this.match("IDENT").value;return r=t,"("!==this.la()?t=c+"._sg_('"+d+"', "+t+")":t+="['"+d+"']",this.member(t,d,n,r);case"[":return a=this.assign(),r=t,"("!==this.la()?t=c+"._sg_("+a.get+", "+t+")":t+="["+a.get+"]",this.match("]"),this.member(t,a,n,r);case"(":var v=this.arguments().join(",");return t=t+"("+v+")",this.match(")"),this.member(t,null,n)}n&&n.length&&this.depend.push(n);var m={get:t};return e&&(m.set=c+"._ss_("+(e.get?e.get:"'"+e+"'")+","+i.setName+","+(r?r:i.varName)+", '=', "+(f?1:0)+")"),m},p.arguments=function(t){t=t||")";var e=[];do this.la()!==t&&e.push(this.assign().get);while(this.eat(","));return e},p.primary=function(){var t=this.ll();switch(t.type){case"{":return this.object();case"[":return this.array();case"(":return this.paren();case"STRING":return this.next(),this.getset("'"+t.value+"'");case"NUMBER":return this.next(),this.getset(""+t.value);case"IDENT":return this.next(),f(t.value)?this.getset(t.value):t.value;default:this.error("Unexpected Token: "+t.type)}},p.object=function(){for(var t=[this.match("{").type],e=this.eat(["STRING","IDENT","NUMBER"]);e;){t.push("'"+e.value+"'"+this.match(":").type);var n=this.assign().get;t.push(n),e=null,this.eat(",")&&(e=this.eat(["STRING","IDENT","NUMBER"]))&&t.push(",")}return t.push(this.match("}").type),{get:t.join("")}},p.array=function(){var t,e=[this.match("[").type];if(this.eat("]"))e.push("]");else{for(;(t=this.assign())&&(e.push(t.get),this.eat(","));)e.push(",");e.push(this.match("]").type)}return{get:e.join("")}},p.paren=function(){this.match("(");var t=this.filter();return t.get="("+t.get+")",this.match(")"),t},p.getset=function(t,e){return{get:t,set:e}},n.exports=r}),t.register("regularjs/src/helper/extend.js",function(t,e,n){function r(t,e,n){return function(){var r=this.supr;this.supr=n[t];var i=e.apply(this,arguments);return this.supr=r,i}}function i(t,e,n){for(var i in e)e.hasOwnProperty(i)&&(t[i]=o(e[i])&&o(n[i])&&a.test(e[i])?r(i,e[i],n):e[i])}var s=e("../util.js"),a=/xy/.test(function(){"xy"})?/\bsupr\b/:/.*/,o=function(t){return"function"==typeof t},u=["events","data","computed"],c=u.length;n.exports=function l(t){function e(){a.apply(this,arguments)}function n(t){for(var e=c;e--;){var n=u[e];t.hasOwnProperty(n)&&r.hasOwnProperty(n)&&(s.extend(r[n],t[n],!0),delete t[n])}return i(r,t,o),this}t=t||{};var r,a=this,o=a&&a.prototype||{};return"function"==typeof t?(r=t.prototype,t.implement=n,t.extend=l,t):(r=s.createProto(e,o),e.implement=n,e.implement(t),a.__after__&&a.__after__.call(e,a,t),e.extend=l,e)}}),t.register("regularjs/src/helper/shim.js",function(){function t(t,e){for(var n in e)void 0===t[n]&&(t[n]=e[n])}var e=[].slice,n={}.toString;t(String.prototype,{trim:function(){return this.replace(/^\s+|\s+$/g,"")}}),t(Array.prototype,{indexOf:function(t,e){e=e||0;for(var n=e,r=this.length;r>n;n++)if(this[n]===t)return n;return-1},forEach:function(t,e){for(var n=0,r=this.length;r>n;n++)t.call(e,this[n],n,this)},filter:function(t,e){for(var n=[],r=0,i=this.length;i>r;r++){var s=t.call(e,this[r],r,this);s&&n.push(this[r])}return n},map:function(t,e){for(var n=[],r=0,i=this.length;i>r;r++)n.push(t.call(e,this[r],r,this));return n}}),t(Function.prototype,{bind:function(t){var n=this,r=e.call(arguments,1);return function(){var i=r.concat(e.call(arguments));return n.apply(t,i)}}}),t(Object,{keys:function(t){var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(n);return e}}),t(Date,{now:function(){return+new Date}}),t(Array,{isArray:function(t){return"[object Array]"===n.call(t)}})}),t.register("regularjs/src/helper/parse.js",function(t,e,n){var r=e("../env").exprCache,i=(e("../util"),e("../parser/Parser.js"));n.exports={expression:function(t){return"string"==typeof t&&(t=t.trim())&&(t=r.get(t)||r.set(t,new i(t,{mode:2,expression:!0}).expression())),t?t:void 0},parse:function(t){return new i(t).parse()}}}),t.register("regularjs/src/helper/watcher.js",function(t,e,n){function r(){}var i=e("../util.js"),s=e("./parse.js").expression,a=e("./arrayDiff.js"),o={$watch:function(t,e,n){var r,a,o,u,c=this.__ext__;this._watchers||(this._watchers=[]),n=n||{},n===!0&&(n={deep:!0});var l=i.uid("w_");if(Array.isArray(t)){for(var h=[],f=0,p=t.length;p>f;f++)h.push(this.$expression(t[f]).get);var d=[];o=function(t){for(var e=!0,n=0,r=h.length;r>n;n++){var s=h[n](t,c);i.equals(s,d[n])||(e=!1,d[n]=i.clone(s))}return e?!1:d}}else"function"==typeof t?r=t.bind(this):(t=this._touchExpr(s(t)),r=t.get,a=t.once);var v={id:l,get:r,fn:e,once:a,force:n.force,notld:n.indexTrack,test:o,deep:n.deep,last:n.sync?r(this):n.last};if(this._watchers.push(v),u=this._records&&this._records.length,u&&this._records[u-1].push(l),n.init===!0){var m=this.$phase;this.$phase="digest",this._checkSingleWatch(v,this._watchers.length-1),this.$phase=m}return v},$unwatch:function(t){if(t=t.uid||t,this._watchers||(this._watchers=[]),Array.isArray(t))for(var e=0,n=t.length;n>e;e++)this.$unwatch(t[e]);else{var r,i,s=this._watchers;if(!t||!s||!(i=s.length))return;for(;i--;)r=s[i],r&&r.id===t&&s.splice(i,1)}},$expression:function(t){return this._touchExpr(s(t))},$digest:function(){if("digest"!==this.$phase&&!this._mute){this.$phase="digest";for(var t=!1,e=0;t=this._digest();)if(++e>20)throw"there may a circular dependencies reaches";e>0&&this.$emit&&this.$emit("$update"),this.$phase=null}},_digest:function(){var t,e,n,r=this._watchers,i=!1;if(r&&r.length)for(var s=0,a=r.length;a>s;s++)e=r[s],n=this._checkSingleWatch(e,s),n&&(i=!0);if(t=this._children,t&&t.length)for(var o=0,u=t.length;u>o;o++)t[o]._digest()&&(i=!0);return i},_checkSingleWatch:function(t,e){var n=!1;if(t){var r,s,o,u,c,l;if(t.test){var h=t.test(this);h&&(n=!0,t.fn.apply(this,h))}else if(r=t.get(this),s=t.last,o=i.typeOf(s),u=i.typeOf(r),c=!0,l,"object"===u&&"object"===o&&t.deep){for(var f in r)if(s[f]!==r[f]){n=!0;break}if(n!==!0)for(var p in s)if(s[p]!==r[p]){n=!0;break}}else"array"!==u||"undefined"!=o&&"array"!==o?(c=i.equals(r,s),(!c||t.force)&&(t.force=null,n=!0)):(l=a(r,t.last||[],t.notld),("array"!==o||l===!0||l.length)&&(n=!0));return n&&!t.test&&(t.last="object"===u&&t.deep||"array"===u?i.clone(r):r,t.fn.call(this,r,s,l),t.once&&this._watchers.splice(e,1)),n}},$set:function(t,e){if(null!=t){var n=i.typeOf(t);if("string"===n||"expression"===t.type)t=this.$expression(t),t.set(this,e);else if("function"===n)t.call(this,this.data);else for(var r in t)this.$set(r,t[r])}},$get:function(t,e){return e&&"string"==typeof t?t:this.$expression(t).get(this)},$update:function(){this.$set.apply(this,arguments);var t=this;do{if(t.data.isolate||!t.$parent)break;t=t.$parent}while(t);t.$digest()},_record:function(){this._records||(this._records=[]),this._records.push([])},_release:function(){return this._records.pop()}};i.extend(r.prototype,o),r.mixTo=function(t){return t="function"==typeof t?t.prototype:t,i.extend(t,o)},n.exports=r}),t.register("regularjs/src/helper/event.js",function(t,e,n){function r(){arguments.length&&this.$on.apply(this,arguments)}var i=[].slice,s=e("../util.js"),a={$on:function(t,e){if("object"==typeof t)for(var n in t)this.$on(n,t[n]);else{var r=this,i=r._handles||(r._handles={}),s=i[t]||(i[t]=[]);s.push(e)}return this},$off:function(t,e){var n=this;if(n._handles){t||(this._handles={});var r,i=n._handles;if(r=i[t]){if(!e)return i[t]=[],n;for(var s=0,a=r.length;a>s;s++)if(e===r[s])return r.splice(s,1),n}return n}},$emit:function(t){var e,n,r,s=this,a=s._handles;if(t){var n=i.call(arguments,1),r=t;if(!a)return s;if(e=a[r.slice(1)])for(var o=0,u=e.length;u>o;o++)e[o].apply(s,n);if(!(e=a[r]))return s;for(var c=0,u=e.length;u>c;c++)e[c].apply(s,n);return s}},$broadcast:function(){}};s.extend(r.prototype,a),r.mixTo=function(t){t="function"==typeof t?t.prototype:t,s.extend(t,a)},n.exports=r}),t.register("regularjs/src/helper/animate.js",function(t,e,n){function r(t){var e,n=0,r=0,s=0,a=0,o=0,u=5/3;return window.getComputedStyle&&(e=window.getComputedStyle(t),r=i(e[h+"Duration"])||r,s=i(e[h+"Delay"])||s,a=i(e[f+"Duration"])||a,o=i(e[f+"Delay"])||o,n=Math.max(r+s,a+o)),1e3*n*u}function i(t){var e,n=0;return t?(t.split(",").forEach(function(t){e=parseFloat(t),e>n&&(n=e)}),n):0}var s=e("../util"),a=e("../dom.js"),o={},u=e("../env.js"),c="transitionend",l="animationend",h="transition",f="animation";"ontransitionend"in window||("onwebkittransitionend"in window?(c+=" webkitTransitionEnd",h="webkitTransition"):("onotransitionend"in a.tNode||"Opera"===navigator.appName)&&(c+=" oTransitionEnd",h="oTransition")),"onanimationend"in window||("onwebkitanimationend"in window?(l+=" webkitAnimationEnd",f="webkitAnimation"):"onoanimationend"in a.tNode&&(l+=" oAnimationEnd",f="oAnimation")),o.inject=function(t,e,n,r){if(r=r||s.noop,Array.isArray(t)){for(var i=a.fragment(),o=0,u=0,c=t.length;c>u;u++)i.appendChild(t[u]);a.inject(i,e,n);var l=function(){o++,o===c&&r()};for(c===o&&r(),u=0;c>u;u++)t[u].onenter?t[u].onenter(l):l()}else a.inject(t,e,n),t.onenter?t.onenter(r):r()},o.remove=function(t,e){t.onleave?t.onleave(function(){p(t,e)}):p(t,e)};var p=function(t,e){a.remove(t),e&&e()};o.startClassAnimate=function(t,e,n,i){var o,h,f,p;return!l&&!c||u.isRunning?n():(p=s.once(function(){f&&clearTimeout(f),2===i&&a.delClass(t,o),3!==i&&a.delClass(t,e),a.off(t,l,p),a.off(t,c,p),n()}),2===i?(a.addClass(t,e),o=e.split(/\s+/).map(function(t){return t+"-active"}).join(" "),a.nextReflow(function(){a.addClass(t,o),h=r(t),f=setTimeout(p,h)})):a.nextReflow(function(){a.addClass(t,e),h=r(t),f=setTimeout(p,h)}),a.on(t,l,p),a.on(t,c,p),p)},o.startStyleAnimate=function(t,e,n){var i,o,u;return a.nextReflow(function(){a.css(t,e),i=r(t),u=setTimeout(o,i)}),o=s.once(function(){u&&clearTimeout(u),a.off(t,l,o),a.off(t,c,o),n()}),a.on(t,l,o),a.on(t,c,o),o},n.exports=o}),t.register("regularjs/src/helper/combine.js",function(t,e,n){var r=e("../dom.js"),i=n.exports={node:function(t){var e,n,r;if(t.element)return t.element;if("function"==typeof t.node)return t.node();if("number"==typeof t.nodeType)return t;if(t.group)return i.node(t.group);if(e=t.children){if(1===e.length)return i.node(e[0]);r=[];for(var s=0,a=e.length;a>s;s++)n=i.node(e[s]),Array.isArray(n)?r.push.apply(r,n):n&&r.push(n);return r}},inject:function(t,e,n){if(n||(n=this),t===!1)return n._fragContainer||(n._fragContainer=r.fragment()),i.inject(n._fragContainer,e,n);var s=i.node(n.group||n);if(!s)return n;if("string"==typeof t&&(t=r.find(t)),!t)throw"injected node is not found";return r.inject(s,t,e),n.$emit&&(n.$emit("$inject",t,e),n.parentNode="after"===e||"before"===e?t.parentNode:t),n},last:function(t){var e=t.children;return"function"==typeof t.last?t.last():"number"==typeof t.nodeType?t:e&&e.length?i.last(e[e.length-1]):t.group?i.last(t.group):void 0},destroy:function(t,e){if(t){if(Array.isArray(t))for(var n=0,s=t.length;s>n;n++)i.destroy(t[n],e);var a=t.children;if("function"==typeof t.destroy)return t.destroy(e);"number"==typeof t.nodeType&&e&&r.remove(t),a&&a.length&&(i.destroy(a,!0),t.children=null)}}}}),t.register("regularjs/src/helper/arrayDiff.js",function(t,e,n){function r(t,e){var n=t.length,r=e.length;if(n!==r)return!0;for(var i=0;n>i;i++)if(t[i]!==e[i])return!0;return!1}function i(t,e){return t===e}function s(t,e){for(var n=t.length,r=e.length,s=[],a=0;n>=a;a++)s.push([a]);for(var o=1;r>=o;o++)s[0][o]=o;for(var a=1;n>=a;a++)for(var o=1;r>=o;o++)s[a][o]=i(t[a-1],e[o-1])?s[a-1][o-1]:Math.min(s[a-1][o]+1,s[a][o-1]+1);return s}function a(t,e,n){if(n)return r(t,e);for(var i=s(e,t),a=e.length,o=a,u=t.length,c=u,l=[],h=i[o][c];o>0||c>0;)if(0!==o)if(0!==c){var f=i[o-1][c-1],p=i[o-1][c],d=i[o][c-1],v=Math.min(d,p,f);v===p?(l.unshift(2),o--,h=p):v===f?(f===h?l.unshift(0):(l.unshift(1),h=f),o--,c--):(l.unshift(3),c--,h=d)}else l.unshift(2),o--;else l.unshift(3),c--;var m=0,g=3,y=2,x=1,a=0;u=0;for(var E=[],_={index:null,add:0,removed:[]},o=0;o0?null===_.index&&(_.index=u):null!=_.index&&(E.push(_),_={index:null,add:0,removed:[]}),l[o]){case m:a++,u++;break;case g:_.add++,u++;break;case y:_.removed.push(e[a]),a++;break;case x:_.add++,_.removed.push(e[a]),a++,u++}return null!=_.index&&E.push(_),E}n.exports=a}),t.register("regularjs/src/helper/entities.js",function(t,e,n){var r={quot:34,amp:38,apos:39,lt:60,gt:62,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,copy:169,ordf:170,laquo:171,not:172,shy:173,reg:174,macr:175,deg:176,plusmn:177,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,sup1:185,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,Agrave:192,Aacute:193,Acirc:194,Atilde:195,Auml:196,Aring:197,AElig:198,Ccedil:199,Egrave:200,Eacute:201,Ecirc:202,Euml:203,Igrave:204,Iacute:205,Icirc:206,Iuml:207,ETH:208,Ntilde:209,Ograve:210,Oacute:211,Ocirc:212,Otilde:213,Ouml:214,times:215,Oslash:216,Ugrave:217,Uacute:218,Ucirc:219,Uuml:220,Yacute:221,THORN:222,szlig:223,agrave:224,aacute:225,acirc:226,atilde:227,auml:228,aring:229,aelig:230,ccedil:231,egrave:232,eacute:233,ecirc:234,euml:235,igrave:236,iacute:237,icirc:238,iuml:239,eth:240,ntilde:241,ograve:242,oacute:243,ocirc:244,otilde:245,ouml:246,divide:247,oslash:248,ugrave:249,uacute:250,ucirc:251,uuml:252,yacute:253,thorn:254,yuml:255,fnof:402,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,bull:8226,hellip:8230,prime:8242,Prime:8243,oline:8254,frasl:8260,weierp:8472,image:8465,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,"int":8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,circ:710,tilde:732,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,permil:8240,lsaquo:8249,rsaquo:8250,euro:8364};n.exports=r}),t.register("regularjs/src/helper/filter.js",function(t,e,n){var r=n.exports={};r.json={get:function(t){return"undefined"!=typeof JSON?JSON.stringify(t):t},set:function(t){return"undefined"!=typeof JSON?JSON.parse(t):t}},r.last=function(t){return t&&t[t.length-1]},r.average=function(t,e){return t=t||[],t.length?r.total(t,e)/t.length:0},r.total=function(t,e){var n=0;if(t)return t.forEach(function(t){n+=e?t[e]:t}),n}}),t.register("regularjs/src/directive/base.js",function(t,e,n){var r=e("../util.js"),i=e("../dom.js"),s=(e("../helper/animate.js"),e("../Regular.js")),a=e("../const");e("./event.js"),e("./form.js"),n.exports={"r-class":function(t,e){"string"==typeof e&&(e=r.fixObjStr(e)),this.$watch(e,function(e){var n=" "+t.className.replace(/\s+/g," ")+" ";for(var r in e)e.hasOwnProperty(r)&&(n=n.replace(" "+r+" "," "),e[r]===!0&&(n+=r+" "));t.className=n.trim()},!0)},"r-style":function(t,e){"string"==typeof e&&(e=r.fixObjStr(e)),this.$watch(e,function(e){for(var n in e)e.hasOwnProperty(n)&&i.css(t,n,e[n])},!0)},"r-hide":function(t,e){var n,r=null;this.$watch(e,function(e){var i=!!e;i!==r&&(r=i,i?t.onleave?n=t.onleave(function(){t.style.display="none",n=null}):t.style.display="none":(n&&n(),t.style.display="",t.onenter&&t.onenter()))})},"r-html":function(t,e){this.$watch(e,function(e){e=e||"",i.html(t,e)},{force:!0})},ref:{accept:a.COMPONENT_TYPE+a.ELEMENT_TYPE,link:function(t,e){var n,i=this.$refs||(this.$refs={});return r.isExpr(e)?this.$watch(e,function(e,r){n=e,i[r]===t&&(i[r]=null),n&&(i[n]=t)}):i[n=e]=t,function(){i[n]=null}}}},s.directive(n.exports)}),t.register("regularjs/src/directive/form.js",function(t,e){function n(t,e){function n(){e.set(r,this.value),i.last=this.value,r.$update()}var r=this,i=this.$watch(e,function(e){var n=a.slice(t.getElementsByTagName("option"));n.forEach(function(n,r){n.value==e&&(t.selectedIndex=r)})});return o.on(t,"change",n),void 0===e.get(r)&&t.value&&e.set(r,t.value),function(){o.off(t,"change",n)}}function r(t,e){var n=this,r=this.$watch(e,function(e){t.value!==e&&(t.value=null==e?"":""+e)}),i=function(t){var i=this;if("cut"===t.type||"paste"===t.type)a.nextTick(function(){var t=i.value;e.set(n,t),r.last=t,n.$update()});else{var s=i.value;e.set(n,s),r.last=s,n.$update()}};return 9!==o.msie&&"oninput"in o.tNode?t.addEventListener("input",i):(o.on(t,"paste",i),o.on(t,"keyup",i),o.on(t,"cut",i),o.on(t,"change",i)),void 0===e.get(n)&&t.value&&e.set(n,t.value),function(){9!==o.msie&&"oninput"in o.tNode?t.removeEventListener("input",i):(o.off(t,"paste",i),o.off(t,"keyup",i),o.off(t,"cut",i),o.off(t,"change",i))}}function i(t,e){var n=this,r=this.$watch(e,function(e){o.attr(t,"checked",!!e)}),i=function(){var t=this.checked;e.set(n,t),r.last=t,n.$update()};return e.set&&o.on(t,"change",i),void 0===e.get(n)&&e.set(n,!!t.checked),function(){e.set&&o.off(t,"change",i)}}function s(t,e){var n=this,r=(this.$watch(e,function(e){t.checked=e==t.value?!0:!1}),function(){var t=this.value;e.set(n,t),n.$update()});return e.set&&o.on(t,"change",r),void 0===e.get(n)&&t.checked&&e.set(n,t.value),function(){e.set&&o.off(t,"change",r)}}var a=e("../util.js"),o=e("../dom.js"),u=e("../Regular.js"),c={text:r,select:n,checkbox:i,radio:s};u.directive("r-model",function(t,e){var n=t.tagName.toLowerCase(),r=n;return"input"===r?r=t.type||"text":"textarea"===r&&(r="text"),"string"==typeof e&&(e=this.$expression(e)),c[r]?c[r].call(this,t,e):"input"===n?c.text.call(this,t,e):void 0})}),t.register("regularjs/src/directive/animation.js",function(t,e){function n(t){var e,n=[],r=0,s=i.noop,a={type:t,start:function(t){return e=i.uid(),"function"==typeof t&&(s=t),r>0?r=0:a.step(),a.compelete},compelete:function(){e=null,s&&s(),s=i.noop,r=0},step:function(){n[r]&&n[r](a.done.bind(a,e))},done:function(t){t===e&&(ry;y++)if(o=v[y],p=o.split(":"),h=p[0]&&p[0].trim(),f=p[1]&&p[1].trim(),h)if(h!==u)if(h!==c){var d=a.animation(h);if(!d||!l)throw"you need start with `on` or `event` in r-animation";l.push(d.call(this,{element:t,done:l.done,param:f}))}else r(f),"leave"===f?(t.onleave=l.start,g.push(s(t))):"enter"===f?(t.onenter=l.start,g.push(s(t))):"on"+f in t?g.push(this._handleEvent(t,f,l.start)):(this.$on(f,l.start),g.push(this.$off.bind(this,f,l.start)));else r("when"),this.$watch(f,i.bind(this,l.start));return g.length?function(){g.forEach(function(t){t()})}:void 0}var i=e("../util.js"),s=e("../helper/animate.js"),a=(e("../dom.js"),e("../Regular.js")),o=/\s+/,u="when",c="on";a._addProtoInheritCache("animation"),a.animation({wait:function(t){var e=parseInt(t.param)||0;return function(t){setTimeout(t,e)}},"class":function(t){var e=t.param.split(","),n=e[0]||"",r=parseInt(e[1])||1;return function(e){s.startClassAnimate(t.element,n,e,r)}},call:function(t){var e=this.$expression(t.param).get,n=this;return function(t){e(n),n.$update(),t()}},emit:function(t){var e=t.param,n=e.split(","),r=n[0]||"",i=n[1]?this.$expression(n[1]).get:null;if(!r)throw"you shoud specified a eventname in emit command";var s=this;return function(t){s.$emit(r,i?i(s):void 0),t()}},style:function(t){var e,n={},r=t.param,i=r.split(",");return i.forEach(function(t){if(t=t.trim()){var r=t.split(o),i=r.shift(),s=r.join(" ");if(!i||!s)throw"invalid style in command: style";n[i]=s,e=!0}}),function(r){e?s.startStyleAnimate(t.element,n,r):r()}}}),a.directive("r-animation",r),a.directive("r-sequence",r)}),t.register("regularjs/src/directive/event.js",function(t,e){function n(t,e,n){if(n)for(var r,i=t.target;i&&i!==n;){for(var s=0,a=e.length;a>s;s++)r=e[s],r&&r.element===i&&r.fire(t);i=i.parentNode}}var r=e("../util.js"),i=e("../dom.js"),s=e("../Regular.js");s._addProtoInheritCache("event"),s.directive(/^on-\w+$/,function(t,e,n,r){if(n&&e){var i=n.split("-")[1];return this._handleEvent(t,i,e,r)}}),s.directive(/^(delegate|de)-\w+$/,function(t,e,s){function a(t){n(t,u[c],o.parentNode)}var o=this.$root,u=o._delegates||(o._delegates={});if(s&&e){var c=s.split("-")[1],l=r.handleEvent.call(this,e,c);u[c]||(u[c]=[],o.parentNode?i.on(o.parentNode,c,a):o.$on("$inject",function(t){var e=this.parentNode;e&&i.off(e,c,a),i.on(t,c,a)}),o.$on("$destroy",function(){o.parentNode&&i.off(o.parentNode,c,a),u[c]=null}));var h={element:t,fire:l};return u[c].push(h),function(){var t=u[c];if(t&&t.length)for(var e=0,n=t.length;n>e;e++)t[e]===h&&t.splice(e,1)}}})}),t.register("regularjs/src/module/timeout.js",function(t,e){function n(t){t.implement({$timeout:function(t,e){return e=e||0,setTimeout(function(){t.call(this),this.$update()}.bind(this),e)},$interval:function(t,e){return e=e||1e3/60,setInterval(function(){t.call(this),this.$update()}.bind(this),e)}})}var r=e("../Regular.js");r.plugin("timeout",n),r.plugin("$timeout",n)}),t.alias("regularjs/src/index.js","regularjs/index.js"),"object"==typeof exports?module.exports=t("regularjs"):"function"==typeof define&&define.amd?define(function(){return t("regularjs")}):window.Regular=t("regularjs")}(); \ No newline at end of file +!function(){"use strict";function t(e,n,r){function i(){r=r||e,n=n||"root";var t=new Error('Failed to require "'+r+'" from "'+n+'"');throw t.path=r,t.parent=n,t.require=!0,t}var s=t.resolve(e);if(null==s)return void i();var a=t.modules[s];if(!a._resolving&&!a.exports){var o={};o.exports={},o.client=o.component=!0,a._resolving=!0,a.call(this,o.exports,t.relative(s),o),delete a._resolving,a.exports=o.exports}return a.exports}t.modules={},t.aliases={},t.exts=["",".js",".json","/index.js","/index.json"],t.resolve=function(e){"/"===e.charAt(0)&&(e=e.slice(1));for(var n=0;5>n;n++){var r=e+t.exts[n];if(t.modules.hasOwnProperty(r))return r;if(t.aliases.hasOwnProperty(r))return t.aliases[r]}},t.normalize=function(t,e){var n=[];if("."!=e.charAt(0))return e;t=t.split("/"),e=e.split("/");for(var r=0;ru;u++){r=a[u];var l=r.regexp.test(t);if(l)return r}return void 0}return"function"==typeof e&&(e={link:e}),"string"===i?s[t]=e:"regexp"===i&&(e.regexp=t,s.__regexp__.push(e)),this},plugin:function(t,e){var n=this._plugins;return null==e?n[t]:(n[t]=e,this)},use:function(t){return"string"==typeof t&&(t=y.plugin(t)),"function"!=typeof t?this:(t(this,y),this)},config:function(t){var e=!1;if("object"==typeof t)for(var n in t)("END"===n||"BEGIN"===n)&&(e=!0),a[n]=t[n];e&&i.setup()},expression:v.expression,Parser:s,Lexer:i,_addProtoInheritCache:function(t,e){if(Array.isArray(t))return t.forEach(y._addProtoInheritCache);var n="_"+t+"s";y._protoInheritCache.push(t),y[n]={},y[t]||(y[t]=function(r,i){var s=this[n];if("object"==typeof r){for(var a in r)r.hasOwnProperty(a)&&this[t](a,r[a]);return this}return null==i?s[r]:(s[r]=e?e(i):i,this)})},_inheritConfig:function(t,e){var n=y._protoInheritCache,r=o.slice(n);return r.forEach(function(n){t[n]=e[n];var r="_"+n+"s";e[r]&&(t[r]=o.createObject(e[r]))}),t}}),u(y),y._addProtoInheritCache("component"),y._addProtoInheritCache("filter",function(t){return"function"==typeof t?{get:t}:t}),p.mixTo(y),d.mixTo(y),y.implement({init:function(){},config:function(){},destroy:function(){this.$emit("$destroy"),this.group&&this.group.destroy(!0),this.group=null,this.parentNode=null,this._watchers=null,this._children=[];var t=this.$parent;if(t){var e=t._children.indexOf(this);t._children.splice(e,1)}this.$parent=null,this.$root=null,this._handles=null,this.$refs=null},$compile:function(t,e){e=e||{},"string"==typeof t&&(t=new s(t).parse());var n,r=this.__ext__,i=e.record;e.extra&&(this.__ext__=e.extra),i&&this._record();var a=this._walk(t,e);if(i){n=this._release();var o=this;n.length&&(a.ondestroy=function(){o.$unwatch(n)})}return e.extra&&(this.__ext__=r),a},$bind:function(t,e,n){var r=o.typeOf(e);if("expression"===e.type||"string"===r)this._bind(t,e,n);else if("array"===r)for(var i=0,s=e.length;s>i;i++)this._bind(t,e[i]);else if("object"===r)for(var i in e)e.hasOwnProperty(i)&&this._bind(t,i,e[i]);return t.$update(),this},$unbind:function(){},$inject:c.inject,$mute:function(t){t=!!t;var e=t===!1&&this._mute;return this._mute=!!t,e&&this.$update(),this},_bind:function(t,e,n){var r=this;if(!(t&&t instanceof y))throw"$bind() should pass Regular component as first argument";if(!e)throw"$bind() should pass as least one expression to bind";if(n||(n=e),e=v.expression(e),n=v.expression(n),n.set){var i=this.$watch(e,function(e){t.$update(n,e)});t.$on("$destroy",function(){r.$unwatch(i)})}if(e.set){var s=t.$watch(n,function(t){r.$update(e,t)});this.$on("$destroy",t.$unwatch.bind(t,s))}n.set(t,e.get(this))},_walk:function(t,e){if("array"===o.typeOf(t)){for(var n=[],r=0,i=t.length;i>r;r++)n.push(this._walk(t[r],e));return new f(n)}return"string"==typeof t?g.createTextNode(t):h[t.type||"default"].call(this,t,e)},_append:function(t){this._children.push(t),t.$parent=this},_handleEvent:function(t,e,n,r){var i,s=this.constructor,a="function"!=typeof n?o.handleEvent.call(this,n,e):n,u=s.event(e);return u?i=u.call(this,t,a,r):l.on(t,e,a),u?i:function(){l.off(t,e,a)}},_touchExpr:function(t){var e,n=this.__ext__,r={};if("expression"!==t.type||t.touched)return t;if(e=t.get||(t.get=new Function(o.ctxName,o.extName,o.prefix+"return ("+t.body+")")),r.get=n?function(t){return e(t,n)}:e,t.setbody&&!t.set){var i=t.setbody;t.set=function(e,n,r){return t.set=new Function(o.ctxName,o.setName,o.extName,o.prefix+i),t.set(e,n,r)},t.setbody=null}return t.set&&(r.set=n?function(e,r){return t.set(e,r,n)}:t.set),o.extend(r,{type:"expression",touched:!0,once:t.once||t.constant}),r},_f_:function(t){var e=this.constructor,n=e.filter(t);if(!n)throw Error("filter "+t+" is undefined");return n},_sg_:function(t,e,n){if("undefined"!=typeof n){var r=this.computed,i=r[t];if(i){if("expression"!==i.type||i.get||this._touchExpr(i),i.get)return i.get(this);o.log("the computed '"+t+"' don't define the get function, get data."+t+" altnately","error")}}return"undefined"==typeof e||"undefined"==typeof t?void 0:n&&"undefined"!=typeof n[t]?n[t]:e[t]},_ss_:function(t,e,n,r,i){var s,i=this.computed,r=r||"=",a=i?i[t]:null;if("="!==r)switch(s=a?a.get(this):n[t],r){case"+=":e=s+e;break;case"-=":e=s-e;break;case"*=":e=s*e;break;case"/=":e=s/e;break;case"%=":e=s%e}if(a){if(a.set)return a.set(this,e);o.log("the computed '"+t+"' don't define the set function, assign data."+t+" altnately","error")}return n[t]=e,e}}),y.prototype.inject=function(){return o.log("use $inject instead of inject","error"),this.$inject.apply(this,arguments)},y.filter(m),n.exports=y;var x=function(){function t(t){return function(e){return t.call(e,e.data)}}function e(t){return function(e,n){return t.call(e,n,e.data),n}}return function(n){if(n){var r,i,s,a={};for(var o in n)r=n[o],s=typeof r,"expression"!==r.type?"string"===s?a[o]=v.expression(r):(i=a[o]={type:"expression"},"function"===s?i.get=t(r):(r.get&&(i.get=t(r.get)),r.set&&(i.set=e(r.set)))):a[o]=r;return a}}}()}),t.register("regularjs/src/util.js",function(t,e,n){e("./helper/shim.js")();var r=n.exports,i=e("./helper/entities.js"),s=[].slice,a={}.toString,o="undefined"!=typeof window?window:global;r.noop=function(){},r.uid=function(){var t=0;return function(){return t++}}(),r.extend=function(t,e,n){for(var r in e)("undefined"==typeof t[r]||n===!0)&&(t[r]=e[r]);return t},r.keys=function(t){if(Object.keys)return Object.keys(t);var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(n);return e},r.varName="d",r.setName="p_",r.ctxName="c",r.extName="e",r.rWord=/^[\$\w]+$/,r.rSimpleAccessor=/^[\$\w]+(\.[\$\w]+)*$/,r.nextTick="function"==typeof setImmediate?setImmediate.bind(o):function(t){setTimeout(t,0)},r.prefix="var "+r.varName+"="+r.ctxName+".data;"+r.extName+"="+r.extName+"||'';",r.slice=function(t,e,n){for(var r=[],i=e||0,s=n||t.length;s>i;i++){var a=t[i];r.push(a)}return r},r.typeOf=function(t){return null==t?String(t):a.call(t).slice(8,-1).toLowerCase()},r.makePredicate=function(t){function e(t){if(1===t.length)return n+="return str === '"+t[0]+"';";n+="switch(str){";for(var e=0;e3){r.sort(function(t,e){return e.length-t.length}),n+="switch(str.length){";for(var i=0;ir;r++){var s=(t[r]||"").length;if(n+s>e)return{num:r,line:t[r],start:e-r-n,prev:t[r-1],next:t[r+1]};n+=s}}function e(t,e,n,s){var a=t.length,o=e-r;0>o&&(o=0);var u=e+i;u>a&&(u=a);var c=t.slice(o,u),l="["+(n+1)+"] "+(o>0?"..":""),h=a>u?"..":"",f=l+c+h;return s&&(f+="\n"+new Array(e-o+l.length+1).join(" ")+"^^^"),f}var n=/\r\n|[\n\r\u2028\u2029]/g,r=20,i=20;return function(r,i){i>r.length-1&&(i=r.length-1),n.lastIndex=0;var s=r.split(n),a=t(s,i),o=a.start,u=a.num;return(a.prev?e(a.prev,o,u-1)+"\n":"")+e(a.line,o,u,!0)+"\n"+(a.next?e(a.next,o,u+1)+"\n":"")}}();var u=/\((\?\!|\?\:|\?\=)/g;r.findSubCapture=function(t){var e=0,n=0,r=t.length,i=t.match(u);for(i=i?i.length:0;r--;){var s=t.charAt(r);(0===r||"\\"!==t.charAt(r-1))&&("("===s&&e++,")"===s&&n++)}if(e!==n)throw"RegExp: "+t+"'s bracket is not marched";return e-i},r.escapeRegExp=function(t){return t.replace(/[-[\]{}()*+?.\\^$|,#\s]/g,function(t){return"\\"+t})};var c=new RegExp("&("+r.keys(i).join("|")+");","gi");r.convertEntity=function(t){return(""+t).replace(c,function(t,e){return String.fromCharCode(i[e])})},r.createObject=function(t,e){function n(){}n.prototype=t;var i=new n;return e&&r.extend(i,e),i},r.createProto=function(t,e){function n(){this.constructor=t}return n.prototype=e,t.prototype=new n},r.clone=function(t){var e=r.typeOf(t);if("array"===e){for(var n=[],i=0,s=t.length;s>i;i++)n[i]=t[i];return n}if("object"===e){var n={};for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);return n}return t},r.equals=function(t,e){var n=typeof t;return"number"===n&&"number"==typeof e&&isNaN(t)&&isNaN(e)?!0:t===e};var l=/-([a-z])/g;r.camelCase=function(t){return t.replace(l,function(t,e){return e.toUpperCase()})},r.throttle=function(t,e){var n,r,i,e=e||100,s=null,a=0,o=function(){a=+new Date,s=null,i=t.apply(n,r),n=r=null};return function(){var u=+new Date,c=e-(u-a);return n=this,r=arguments,0>=c||c>e?(clearTimeout(s),s=null,a=u,i=t.apply(n,r),n=r=null):s||(s=setTimeout(o,c)),i}},r.escape=function(){var t=/&/g,e=//g,r=/\'/g,i=/\"/g,s=/[&<>\"\']/;return function(a){return s.test(a)?a.replace(t,"&").replace(e,"<").replace(n,">").replace(r,"'").replace(i,"""):a}}(),r.cache=function(t){t=t||1e3;var e=[],n={};return{set:function(t,r){return e.length>this.max&&(n[e.shift()]=void 0),void 0===n[t]&&e.push(t),n[t]=r,r},get:function(t){return void 0===t?n:n[t]},max:t,len:function(){return e.length}}},r.handleEvent=function(t){var e,n=this;return"expression"===t.type&&(e=t.get),e?function(t){n.data.$event=t;var r=e(n);r===!1&&t&&t.preventDefault&&t.preventDefault(),n.data.$event=void 0,n.$update()}:function(){var e=s.call(arguments);e.unshift(t),n.$emit.apply(n,e),n.$update()}},r.once=function(t){var e=0;return function(){0===e++&&t.apply(this,arguments)}},r.fixObjStr=function(t){return 0!==t.trim().indexOf("{")?"{"+t+"}":t},r.log=function(t,e){"undefined"!=typeof console&&console[e||"log"](t)},r.isVoidTag=r.makePredicate("area base br col embed hr img input keygen link menuitem meta param source track wbr r-content"),r.isBooleanAttr=r.makePredicate("selected checked disabled readOnly required open autofocus controls autoplay compact loop defer multiple"),r.isFalse-function(){return!1},r.isTrue-function(){return!0},r.isExpr=function(t){return t&&"expression"===t.type},r.isGroup=function(t){return t.inject||t.$inject},r.getCompileFn=function(t,e,n){return e.$compile.bind(e,t,n)}}),t.register("regularjs/src/walkers.js",function(t,e,n){function r(t,e,n){for(var r=[],i=0,s=t.length;s>i;i++){var a=this._walk(t[i],{element:e,fromElement:!0,attrs:t,extra:n});a&&r.push(a)}return r}var i=e("./helper/arrayDiff.js"),s=e("./helper/combine.js"),a=e("./helper/animate.js"),o=(e("./parser/node.js"),e("./group.js")),u=e("./dom.js"),c=e("./util"),l=n.exports={};l.list=function(t,e){function n(t,e){for(var n=0;e>n;n++){var r=E.children.splice(t+1,1)[0];r.destroy(!0)}}function r(n,r,i){for(var o=n;r>o;o++){var u=i[o],l={};l[_]=o,l[N]=u,l=c.createObject(y,l);var h=x.$compile(t.body,{extra:l,namespace:g,record:!0,outer:e.outer});h.data=l;var f=s.last(E.get(o));f.parentNode&&a.inject(s.node(h),f,"after"),E.children.splice(o+1,0,h)}}function u(t,e,n){for(var r=t;e>r;r++){var i=E.get(r+1);i.data[_]=r,i.data[N]=n[r]}}function h(t,e,s){e||(e=[]),t||(t=[]);var a=0,o=t.length;if(s||0===o&&0===e.length||(s=i(t,e)),s&&s.length){for(var c=0;cg;)d(t[h],h)!==d(f[0],h)&&(n(h,1),r(h,h+1,t)),f.shift(),p--,h++,g++;v=f.length}u(a,h,t),n(h,v),r(h,h+p,t),a=h+p-v,a=0>a?0:a}if(o>a)for(var c=a;o>c;c++){var y=E.get(c+1);y.data[_]=c}}}function f(t,e){t=t||[],e=e||[];var i=t.length||0,s=e.length||0,a=Math.min(i,s);u(0,a,t),s>i?n(i,s-i):i>s&&r(s,i,t)}function p(t,n,r){var i=t&&t.length,o=n&&n.length;if(!o&&i&&E.get(1)){var u=E.children.pop();u.destroy&&u.destroy(!0)}if(w===!0?f(t,n,r):h(t,n,r),!i&&T&&T.length){var c=x.$compile(T,{extra:y,record:!0,outer:e.outer,namespace:g});E.children.push(c),m.parentNode&&a.inject(s.node(c),m,"after")}}var d,v,m=(l.Regular,document.createComment("Regular list")),g=e.namespace,y=e.extra,x=this,E=new o([m]),_=t.variable+"_index",N=t.variable,T=t.alternate,w=t.track;return w&&w!==!0&&(w=this._touchExpr(w),v=c.createObject(y),d=function(t,e){return v[N]=t,v[_]=e,w.get(x,v)}),this.$watch(t.sequence,p,{init:!0,indexTrack:w===!0}),E},l.template=function(t,e){var n,n,r=t.content,i=document.createComment("inlcude"),s=e.namespace,a=e.extra,u=new o([i]);if(r){var c=this;this.$watch(r,function(t){var r=u.get(1);r&&(r.destroy(!0),u.children.pop()),t&&(u.push(n="function"==typeof t?t():c.$compile(t,{record:!0,outer:e.outer,namespace:s,extra:a})),i.parentNode&&n.$inject(i,"before"))},{init:!0})}return u};var h=0;l["if"]=function(t,e){var n,r,i=this,u=e.extra;if(e&&e.element){var c=function(a){a?(r&&s.destroy(r),t.consequent&&(n=i.$compile(t.consequent,{record:!0,element:e.element,extra:u}))):(n&&s.destroy(n),t.alternate&&(r=i.$compile(t.alternate,{record:!0,element:e.element,extra:u})))};return this.$watch(t.test,c,{force:!0}),{destroy:function(){n?s.destroy(n):r&&s.destroy(r)}}}var n,r,l=document.createComment("Regular if"+h++),f=new o;f.push(l);var p=null,d=e.namespace,c=function(o){var c=!!o;c!==p&&(p=c,f.children[1]&&(f.children[1].destroy(!0),f.children.pop()),c?t.consequent&&t.consequent.length&&(n=i.$compile(t.consequent,{record:!0,outer:e.outer,namespace:d,extra:u}),f.push(n),l.parentNode&&a.inject(s.node(n),l,"before")):t.alternate&&t.alternate.length&&(r=i.$compile(t.alternate,{record:!0,outer:e.outer,namespace:d,extra:u}),f.push(r),l.parentNode&&a.inject(s.node(r),l,"before")))};return this.$watch(t.test,c,{force:!0,init:!0}),f},l.expression=function(t){var e=document.createTextNode("");return this.$watch(t,function(t){u.text(e,""+(null==t?"":""+t))}),e},l.text=function(t){var e=document.createTextNode(c.convertEntity(t.text));return e};var f=/^on-(.+)$/;l.element=function(t,e){var n,i,o=t.attrs,h=this.constructor,f=t.children,p=e.namespace,d=e.extra,v=t.tag,m=h.component(v);if("r-content"===v)return c.log("r-content is deprecated, use {#inc this.$body} instead (`{#include}` as same)","error"),this.$body&&this.$body();if(m||"r-component"===v)return e.Component=m,l.component.call(this,t,e);"svg"===v&&(p="svg"),f&&f.length&&(n=this.$compile(f,{outer:e.outer,namespace:p,extra:d})),i=u.create(v,p,o),n&&!c.isVoidTag(v)&&u.inject(s.node(n),i),t.touched||(o.sort(function(t,e){var n=h.directive(t.name),r=h.directive(e.name);return n&&r?(r.priority||1)-(n.priority||1):n?1:r?-1:"type"===e.name?1:-1}),t.touched=!0);var g=r.call(this,o,i,d);return{type:"element",group:n,node:function(){return i},last:function(){return i},destroy:function(t){t?a.remove(i,n?n.destroy.bind(n):c.noop):n&&n.destroy(),g.length&&g.forEach(function(t){t&&("function"==typeof t.destroy?t.destroy():t())})}}},l.component=function(t,e){for(var n,r,i,a,u=t.attrs,l=e.Component,h=this.constructor,p=e.extra,d=e.namespace,v=this,m={},g=0,y=u.length;y>g;g++){var x=u[g],E=this._touchExpr(void 0===x.value?!0:x.value);E.constant&&(E=x.value=E.get(this)),x.value&&x.value.constant===!0&&(E=E.get(this));var _=x.name;if(!x.event){var N=_.match(f);N&&(x.event=N[1])}if("cmpl"===x.mdf&&(E=c.getCompileFn(E,this,{record:!0,namespace:d,extra:p,outer:e.outer})),"is"===_&&!l){i=E;var T=this.$get(E,!0);if(l=h.component(T),"function"!=typeof l)throw new Error("component "+T+" has not registed!")}var w;(w=x.event)?(a=a||{},a[w]=c.handleEvent.call(this,E,w)):(_=x.name=c.camelCase(_),m[_]="expression"!==E.type?E:E.get(v),"ref"===_&&null!=E&&(r=E),"isolate"===_&&(n="expression"===E.type?E.get(v):parseInt(E===!0?3:E,10),m.isolate=n))}var j,b={data:m,events:a,$parent:this,$root:this.$root,$outer:e.outer,_body:t.children},e={namespace:d,extra:e.extra},$=new l(b,e);r&&this.$refs&&(j=l.directive("ref").link,this.$on("$destroy",j.call(this,$,r))),r&&v.$refs&&(v.$refs[r]=$);for(var g=0,y=u.length;y>g;g++){var x=u[g],E=x.value||!0,_=x.name;"expression"!==E.type||x.event||(E=v._touchExpr(E),2&n||this.$watch(E,$.$update.bind($,_)),!E.set||1&n||$.$watch(_,v.$update.bind(v,E),{sync:!0}))}if(i&&"expression"===i.type){var A=new o;return A.push($),this.$watch(i,function(t){var e=h.component(t);if(!e)throw new Error("component "+t+" has not registed!");var n=new e(b),i=A.children.pop();A.push(n),n.$inject(s.last(i),"after"),i.destroy(),r&&(v.$refs[r]=n)},{sync:!0}),A}return $},l.attribute=function(t,e){var n=t,r=n.name,i=n.value||"",s=i.constant,a=this.constructor,o=a.directive(r),l=e.element,h=this;if(i=this._touchExpr(i),s&&(i=i.get(this)),o&&o.link){var f=o.link.call(h,l,i,r,e.attrs);return"function"==typeof f&&(f={destroy:f}),f}return"expression"===i.type?this.$watch(i,function(t){u.attr(l,r,t)},{init:!0}):c.isBooleanAttr(r)?u.attr(l,r,!0):u.attr(l,r,i),e.fromElement?void 0:{destroy:function(){u.attr(l,r,null)}}}}),t.register("regularjs/src/env.js",function(t,e){var n=e("./util");t.svg=function(){return"undefined"!=typeof document&&document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")}(),t.browser="undefined"!=typeof document&&document.nodeType,t.exprCache=n.cache(1e3),t.isRunning=!1}),t.register("regularjs/src/index.js",function(t,e,n){var r=e("./env.js"),i=e("./config"),s=n.exports=e("./Regular.js"),a=s.Parser,o=s.Lexer;r.browser&&(e("./directive/base.js"),e("./directive/animation.js"),e("./module/timeout.js"),s.dom=e("./dom.js")),s.env=r,s.util=e("./util.js"),s.parse=function(t,e){e=e||{},(e.BEGIN||e.END)&&(e.BEGIN&&(i.BEGIN=e.BEGIN),e.END&&(i.END=e.END),o.setup());var n=new a(t).parse();return e.stringify?JSON.stringify(n):n}}),t.register("regularjs/src/dom.js",function(t,e,n){function r(t){return(""+t).replace(/-\D/g,function(t){return t.charAt(1).toUpperCase()})}function i(t,e){return"change"===e&&u.msie<9&&t&&t.tagName&&"input"===t.tagName.toLowerCase()&&("checkbox"===t.type||"radio"===t.type)?"click":e}function s(t){if(t=t||window.event,t._fixed)return t;this.event=t,this.target=t.target||t.srcElement;var e=this.type=t.type,n=this.button=t.button;if(v.test(e)&&(this.pageX=null!=t.pageX?t.pageX:t.clientX+m.scrollLeft,this.pageY=null!=t.pageX?t.pageY:t.clientY+m.scrollTop,"mouseover"===e||"mouseout"===e)){for(var r=t.relatedTarget||t[("mouseover"===e?"from":"to")+"Element"];r&&3===r.nodeType;)r=r.parentNode;this.relatedTarget=r}("DOMMouseScroll"===e||"mousewheel"===e)&&(this.wheelDelta=t.wheelDelta?t.wheelDelta/120:-(t.detail||0)/3),this.which=t.which||t.keyCode,this.which||void 0===n||(this.which=1&n?1:2&n?3:4&n?2:0),this._fixed=!0}var a,o,u=n.exports,c=e("./env.js"),l=e("./util"),h=document.createElement("div"),f=function(){},p={html:"http://www.w3.org/1999/xhtml",svg:"http://www.w3.org/2000/svg"};u.body=document.body,u.doc=document,u.tNode=h,h.addEventListener?(a=function(t,e,n){t.addEventListener(e,n,!1)},o=function(t,e,n){t.removeEventListener(e,n,!1)}):(a=function(t,e,n){t.attachEvent("on"+e,n)},o=function(t,e,n){t.detachEvent("on"+e,n)}),u.msie=parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase())||[])[1]),isNaN(u.msie)&&(u.msie=parseInt((/trident\/.*; rv:(\d+)/.exec(navigator.userAgent.toLowerCase())||[])[1])),u.find=function(t){if(document.querySelector)try{return document.querySelector(t)}catch(e){}return-1!==t.indexOf("#")?document.getElementById(t.slice(1)):void 0},u.inject=function(t,e,n){if(n=n||"bottom",t){if(Array.isArray(t)){var r=t;t=u.fragment();for(var i=0,s=r.length;s>i;i++)t.appendChild(r[i])}var a,o;switch(n){case"bottom":e.appendChild(t);break;case"top":(a=e.firstChild)?e.insertBefore(t,e.firstChild):e.appendChild(t);break;case"after":(o=e.nextSibling)?o.parentNode.insertBefore(t,o):e.parentNode.appendChild(t);break;case"before":e.parentNode.insertBefore(t,e)}}},u.id=function(t){return document.getElementById(t)},u.create=function(t,e){if("svg"===e){if(!c.svg)throw Error("the env need svg support");e=p.svg}return e?document.createElementNS(e,t):document.createElement(t)},u.fragment=function(){return document.createDocumentFragment()};var d={"class":function(t,e){"className"in t&&(t.namespaceURI===p.html||!t.namespaceURI)?t.className=e||"":t.setAttribute("class",e)},"for":function(t,e){"htmlFor"in t?t.htmlFor=e:t.setAttribute("for",e)},style:function(t,e){t.style?t.style.cssText=e:t.setAttribute("style",e)},value:function(t,e){t.value=null!=e?e:""}};u.attr=function(t,e,n){if(l.isBooleanAttr(e)){if("undefined"==typeof n)return t[e]||(t.attributes.getNamedItem(e)||f).specified?e:void 0;n?(t[e]=!0,t.setAttribute(e,e),u.msie&&u.msie<=7&&(t.defaultChecked=!0)):(t[e]=!1,t.removeAttribute(e))}else if("undefined"!=typeof n)d[e]?d[e](t,n):null===n?t.removeAttribute(e):t.setAttribute(e,n);else if(t.getAttribute){var r=t.getAttribute(e,2);return null===r?void 0:r}},u.on=function(t,e,n){var r=e.split(" ");n.real=function(e){var r=new s(e);r.origin=t,n.call(t,r)},r.forEach(function(e){e=i(t,e),a(t,e,n.real)})},u.off=function(t,e,n){var r=e.split(" ");n=n.real||n,r.forEach(function(e){e=i(t,e),o(t,e,n)})},u.text=function(){var t={};return u.msie&&u.msie<9?(t[1]="innerText",t[3]="nodeValue"):t[1]=t[3]="textContent",function(e,n){var r=t[e.nodeType];return null==n?r?e[r]:"":void(e[r]=n)}}(),u.html=function(t,e){return"undefined"==typeof e?t.innerHTML:void(t.innerHTML=e)},u.replace=function(t,e){e.parentNode&&e.parentNode.replaceChild(t,e)},u.remove=function(t){t.parentNode&&t.parentNode.removeChild(t)},u.css=function(t,e,n){if("object"!==l.typeOf(e)){if("undefined"==typeof n){var i;return u.msie<=8&&(i=t.currentStyle&&t.currentStyle[e],""===i&&(i="auto")),i=i||t.style[e],u.msie<=8&&(i=""===i?void 0:i),i}e=r(e),e&&(t.style[e]=n)}else for(var s in e)e.hasOwnProperty(s)&&u.css(t,s,e[s])},u.addClass=function(t,e){var n=t.className||"";-1===(" "+n+" ").indexOf(" "+e+" ")&&(t.className=n?n+" "+e:e)},u.delClass=function(t,e){var n=t.className||"";t.className=(" "+n+" ").replace(" "+e+" "," ").trim()},u.hasClass=function(t,e){var n=t.className||"";return-1!==(" "+n+" ").indexOf(" "+e+" ")};var v=/^(?:click|dblclick|contextmenu|DOMMouseScroll|mouse(?:\w+))$/,m=document;m=m.compatMode&&"CSS1Compat"!==m.compatMode?m.body:m.documentElement,l.extend(s.prototype,{immediateStop:l.isFalse,stop:function(){this.preventDefault().stopPropagation()},preventDefault:function(){return this.event.preventDefault?this.event.preventDefault():this.event.returnValue=!1,this},stopPropagation:function(){return this.event.stopPropagation?this.event.stopPropagation():this.event.cancelBubble=!0,this},stopImmediatePropagation:function(){this.event.stopImmediatePropagation&&this.event.stopImmediatePropagation()}}),u.nextFrame=function(){var t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){setTimeout(t,16)},e=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||function(t){clearTimeout(t)};return function(n){var r=t(n);return function(){e(r)}}}();var g;u.nextReflow=u.msie?function(t){return u.nextFrame(function(){g=document.body.offsetWidth,t()})}:u.nextFrame}),t.register("regularjs/src/group.js",function(t,e,n){function r(t){this.children=t||[]}var i=e("./util"),s=e("./helper/combine"),a=i.extend(r.prototype,{destroy:function(t){s.destroy(this.children,t),this.ondestroy&&this.ondestroy(),this.children=null},get:function(t){return this.children[t]},push:function(t){this.children.push(t)}});a.inject=a.$inject=s.inject,n.exports=r}),t.register("regularjs/src/config.js",function(t,e,n){n.exports={BEGIN:"{",END:"}"}}),t.register("regularjs/src/const.js",function(t,e,n){n.exports={COMPONENT_TYPE:1,ELEMENT_TYPE:2}}),t.register("regularjs/src/parser/Lexer.js",function(t,e,n){function r(t){return function(e){return{type:t,value:e}}}function i(t,e){h[l.END]&&(this.markStart=h[l.END],this.markEnd=l.END),this.input=(t||"").trim(),this.opts=e||{},this.map=2!==this.opts.mode?o:u,this.states=["INIT"],e&&e.expression&&(this.states.push("JST"),this.expression=!0)}function s(t){for(var e,n,r={},i=0,s=t.length;s>i;i++)e=t[i],n=e[2]||"INIT",(r[n]||(r[n]={rules:[],links:[]})).rules.push(e);return a(r)}function a(t){function e(t,e){return"string"==typeof f[e]?c.escapeRegExp(f[e]):String(f[e]).slice(1,-1)}var n,i,s,a,o,u,l;for(var h in t){n=t[h],n.curIndex=1,i=n.rules,s=[];for(var p=0,d=i.length;d>p;p++)l=i[p],o=l[0],a=l[1],"string"==typeof a&&(a=r(a)),"regexp"===c.typeOf(o)&&(o=o.toString().slice(1,-1)),o=o.replace(/\{(\w+)\}/g,e),u=c.findSubCapture(o)+1,n.links.push([n.curIndex,u,a]),n.curIndex+=u,s.push(o);n.TRUNK=new RegExp("^(?:("+s.join(")|(")+"))")}return t}var o,u,c=e("../util.js"),l=e("../config.js"),h={"}":"{","]":"["},f={NAME:/(?:[:_A-Za-z][-\.:_0-9A-Za-z]*)/,IDENT:/[\$_A-Za-z][_0-9A-Za-z\$]*/,SPACE:/[\r\n\f ]/},p=/a|(b)/.exec("a"),d=p&&void 0===p[1]?function(t){return void 0!==t}:function(t){return!!t},v=i.prototype;v.lex=function(t){t=(t||this.input).trim();var e,n,r,i,s,a=[];this.input=t,this.marks=0,this.index=0;for(var o=0;t;)o++,s=this.state(),e=this.map[s],n=e.TRUNK.exec(t),n||this.error("Unrecoginized Token"),r=n[0].length,t=t.slice(r),i=this._process.call(this,n,e,t),i&&a.push(i),this.index+=r;return a.push({type:"EOF"}),a},v.error=function(t){throw Error("Parse Error: "+t+":\n"+c.trackErrorPos(this.input,this.index))},v._process=function(t,e,n){for(var r,i=e.links,s=!1,a=i.length,o=0;a>o;o++){var u=i[o],c=u[2],l=u[0];if(d(t[l])){s=!0,c&&(r=c.apply(this,t.slice(l,l+u[1])),r&&(r.pos=this.index));break}}if(!s)switch(n.charAt(0)){case"<":this.enter("TAG");break;default:this.enter("JST")}return r},v.enter=function(t){return this.states.push(t),this},v.state=function(){var t=this.states;return t[t.length-1]},v.leave=function(t){var e=this.states;t&&e[e.length-1]!==t||e.pop()},i.setup=function(){f.END=l.END,f.BEGIN=l.BEGIN,o=s([m.ENTER_JST,m.ENTER_TAG,m.TEXT,m.TAG_NAME,m.TAG_OPEN,m.TAG_CLOSE,m.TAG_PUNCHOR,m.TAG_ENTER_JST,m.TAG_UNQ_VALUE,m.TAG_STRING,m.TAG_SPACE,m.TAG_COMMENT,m.JST_OPEN,m.JST_CLOSE,m.JST_COMMENT,m.JST_EXPR_OPEN,m.JST_IDENT,m.JST_SPACE,m.JST_LEAVE,m.JST_NUMBER,m.JST_PUNCHOR,m.JST_STRING,m.JST_COMMENT]),u=s([m.ENTER_JST2,m.TEXT,m.JST_COMMENT,m.JST_OPEN,m.JST_CLOSE,m.JST_EXPR_OPEN,m.JST_IDENT,m.JST_SPACE,m.JST_LEAVE,m.JST_NUMBER,m.JST_PUNCHOR,m.JST_STRING,m.JST_COMMENT])};var m={ENTER_JST:[/[^\x00<]*?(?={BEGIN})/,function(t){return this.enter("JST"),t?{type:"TEXT",value:t}:void 0}],ENTER_JST2:[/[^\x00]*?(?={BEGIN})/,function(t){return this.enter("JST"),t?{type:"TEXT",value:t}:void 0}],ENTER_TAG:[/[^\x00<>]*?(?=<)/,function(t){return this.enter("TAG"),t?{type:"TEXT",value:t}:void 0}],TEXT:[/[^\x00]+/,"TEXT"],TAG_NAME:[/{NAME}/,"NAME","TAG"],TAG_UNQ_VALUE:[/[^\{}&"'=><`\r\n\f ]+/,"UNQ","TAG"],TAG_OPEN:[/<({NAME})\s*/,function(t,e){return{type:"TAG_OPEN",value:e}},"TAG"],TAG_CLOSE:[/<\/({NAME})[\r\n\f ]*>/,function(t,e){return this.leave(),{type:"TAG_CLOSE",value:e}},"TAG"],TAG_ENTER_JST:[/(?={BEGIN})/,function(){this.enter("JST")},"TAG"],TAG_PUNCHOR:[/[\>\/=&]/,function(t){return">"===t&&this.leave(),{type:t,value:t}},"TAG"],TAG_STRING:[/'([^']*)'|"([^"]*)\"/,function(t,e,n){var r=e||n||"";return{type:"STRING",value:r}},"TAG"],TAG_SPACE:[/{SPACE}+/,null,"TAG"],TAG_COMMENT:[/<\!--([^\x00]*?)--\>/,function(){this.leave()},"TAG"],JST_OPEN:["{BEGIN}#{SPACE}*({IDENT})",function(t,e){return{type:"OPEN",value:e}},"JST"],JST_LEAVE:[/{END}/,function(t){return this.markEnd===t&&this.expression?{type:this.markEnd,value:this.markEnd}:this.markEnd&&this.marks?(this.marks--,{type:this.markEnd,value:this.markEnd}):(this.firstEnterStart=!1,this.leave("JST"),{type:"END"})},"JST"],JST_CLOSE:[/{BEGIN}\s*\/({IDENT})\s*{END}/,function(t,e){return this.leave("JST"),{type:"CLOSE",value:e}},"JST"],JST_COMMENT:[/{BEGIN}\!([^\x00]*?)\!{END}/,function(){this.leave()},"JST"],JST_EXPR_OPEN:["{BEGIN}",function(t){if(t===this.markStart){if(this.expression)return{type:this.markStart,value:this.markStart};if(this.firstEnterStart||this.marks)return this.marks++,this.firstEnterStart=!1,{type:this.markStart,value:this.markStart};this.firstEnterStart=!0}return{type:"EXPR_OPEN",escape:!1}},"JST"],JST_IDENT:["{IDENT}","IDENT","JST"],JST_SPACE:[/[ \r\n\f]+/,null,"JST"],JST_PUNCHOR:[/[=!]?==|[-=><+*\/%\!]?\=|\|\||&&|\@\(|\.\.|[<\>\[\]\(\)\-\|\{}\+\*\/%?:\.!,]/,function(t){return{type:t,value:t}},"JST"],JST_STRING:[/'([^']*)'|"([^"]*)"/,function(t,e,n){return{type:"STRING",value:e||n||""}},"JST"],JST_NUMBER:[/(?:[0-9]*\.[0-9]+|[0-9]+)(e\d+)?/,function(t){return{type:"NUMBER",value:parseFloat(t,10)}},"JST"]};i.setup(),n.exports=i}),t.register("regularjs/src/parser/node.js",function(t,e,n){n.exports={element:function(t,e,n){return{type:"element",tag:t,attrs:e,children:n}},attribute:function(t,e,n){return{type:"attribute",name:t,value:e,mdf:n} +},"if":function(t,e,n){return{type:"if",test:t,consequent:e,alternate:n}},list:function(t,e,n,r,i){return{type:"list",sequence:t,alternate:r,variable:e,body:n,track:i}},expression:function(t,e,n){return{type:"expression",body:t,constant:n||!1,setbody:e||!1}},text:function(t){return{type:"text",text:t}},template:function(t){return{type:"template",content:t}}}}),t.register("regularjs/src/parser/Parser.js",function(t,e,n){function r(t,e){e=e||{},this.input=t,this.tokens=new o(t,e).lex(),this.pos=0,this.length=this.tokens.length}var i=e("../util.js"),s=e("../config.js"),a=e("./node.js"),o=e("./Lexer.js"),u=i.varName,c=i.ctxName,l=i.extName,h=i.makePredicate("STRING IDENT NUMBER"),f=i.makePredicate("true false undefined null this Array Date JSON Math NaN RegExp decodeURI decodeURIComponent encodeURI encodeURIComponent parseFloat parseInt Object"),p=r.prototype;p.parse=function(){this.pos=0;var t=this.program();return"TAG_CLOSE"===this.ll().type&&this.error("You may got a unclosed Tag"),t},p.ll=function(t){t=t||1,0>t&&(t+=1);var e=this.pos+t-1;return e>this.length-1?this.tokens[this.length-1]:this.tokens[e]},p.la=function(t){return(this.ll(t)||"").type},p.match=function(t,e){var n;return(n=this.eat(t,e))?n:(n=this.ll(),void this.error("expect ["+t+(null==e?"":":"+e)+']" -> got "['+n.type+(null==e?"":":"+n.value)+"]",n.pos))},p.error=function(t,e){throw t="\n【 parse failed 】 "+t+":\n\n"+i.trackErrorPos(this.input,"number"==typeof e?e:this.ll().pos||0),new Error(t)},p.next=function(t){t=t||1,this.pos+=t},p.eat=function(t,e){var n=this.ll();if("string"!=typeof t){for(var r=t.length;r--;)if(n.type===t[r])return this.next(),n}else if(n.type===t&&("undefined"==typeof e||n.value===e))return this.next(),n;return!1},p.program=function(){for(var t=[],e=this.ll();"EOF"!==e.type&&"TAG_CLOSE"!==e.type;)t.push(this.statement()),e=this.ll();return t},p.statement=function(){var t=this.ll();switch(t.type){case"NAME":case"TEXT":var e=t.value;for(this.next();t=this.eat(["NAME","TEXT"]);)e+=t.value;return a.text(e);case"TAG_OPEN":return this.xml();case"OPEN":return this.directive();case"EXPR_OPEN":return this.interplation();default:this.error("Unexpected token: "+this.la())}},p.xml=function(){var t,e,n,r;return t=this.match("TAG_OPEN").value,e=this.attrs(),r=this.eat("/"),this.match(">"),r||i.isVoidTag(t)||(n=this.program(),this.eat("TAG_CLOSE",t)||this.error("expect gotno matched closeTag")),a.element(t,e,n)},p.xentity=function(t){var e,n,r=t.value;if("NAME"===t.type){if(~r.indexOf(".")){var i=r.split(".");r=i[0],n=i[1]}return this.eat("=")&&(e=this.attvalue(n)),a.attribute(r,e,n)}return"if"!==r&&this.error("current version. ONLY RULE #if #else #elseif is valid in tag, the rule #"+r+" is invalid"),this["if"](!0)},p.attrs=function(t){var e;e=t?["NAME"]:["NAME","OPEN"];for(var n,r=[];n=this.eat(e);)r.push(this.xentity(n));return r},p.attvalue=function(t){var e=this.ll();switch(e.type){case"NAME":case"UNQ":case"STRING":this.next();var n=e.value;if(~n.indexOf(s.BEGIN)&&~n.indexOf(s.END)&&"cmpl"!==t){var i=!0,o=new r(n,{mode:2}).parse();if(1===o.length&&"expression"===o[0].type)return o[0];var u=[];o.forEach(function(t){t.constant||(i=!1),u.push(t.body||"'"+t.text.replace(/'/g,"\\'")+"'")}),u="["+u.join(",")+"].join('')",n=a.expression(u,null,i)}return n;case"EXPR_OPEN":return this.interplation();default:this.error("Unexpected token: "+this.la())}},p.directive=function(){var t=this.ll().value;return this.next(),"function"==typeof this[t]?this[t]():void this.error("Undefined directive["+t+"]")},p.interplation=function(){this.match("EXPR_OPEN");var t=this.expression(!0);return this.match("END"),t},p.inc=p.include=function(){var t=this.expression();return this.match("END"),a.template(t)},p["if"]=function(t){var e=this.expression(),n=[],r=[],i=n,s=t?"attrs":"statement";this.match("END");for(var o,u;!(u=this.eat("CLOSE"));)if(o=this.ll(),"OPEN"===o.type)switch(o.value){case"else":i=r,this.next(),this.match("END");break;case"elseif":return this.next(),r.push(this["if"](t)),a["if"](e,n,r);default:i.push(this[s](!0))}else i.push(this[s](!0));return"if"!==u.value&&this.error("Unmatched if directive"),a["if"](e,n,r)},p.list=function(){var t,e,n,r=this.expression(),i=[],s=[],o=i;for(this.match("IDENT","as"),t=this.match("IDENT").value,this.eat("IDENT","by")&&(this.eat("IDENT",t+"_index")?n=!0:(n=this.expression(),n.constant&&(n=!0))),this.match("END");!(e=this.eat("CLOSE"));)this.eat("OPEN","else")?(o=s,this.match("END")):o.push(this.statement());return"list"!==e.value&&this.error("expect list got /"+e.value+" ",e.pos),a.list(r,t,i,s,n)},p.expression=function(){var t;return this.eat("@(")?(t=this.expr(),t.once=!0,this.match(")")):t=this.expr(),t},p.expr=function(){this.depend=[];var t=this.filter(),e=t.get||t,n=t.set;return a.expression(e,n,!this.depend.length)},p.filter=function(){var t,e,n,r=this.assign(),s=this.eat("|"),a=[],o="t",u=r.set,l="";if(s){u&&(t=[]),e="(function("+o+"){";do l=o+" = "+c+"._f_('"+this.match("IDENT").value+"' ).get.call( "+i.ctxName+","+o,l+=this.eat(":")?", "+this.arguments("|").join(",")+");":");",a.push(l),t&&t.unshift(l.replace(" ).get.call"," ).set.call"));while(s=this.eat("|"));return a.push("return "+o),t&&t.push("return "+o),n=e+a.join("")+"})("+r.get+")",t&&(u=u.replace(i.setName,e+t.join("")+"})("+i.setName+")")),this.getset(n,u)}return r},p.assign=function(){var t,e=this.condition();return(t=this.eat(["=","+=","-=","*=","/=","%="]))?(e.set||this.error("invalid lefthand expression in assignment expression"),this.getset(e.set.replace(","+i.setName,","+this.condition().get).replace("'='","'"+t.type+"'"),e.set)):e},p.condition=function(){var t=this.or();return this.eat("?")?this.getset([t.get+"?",this.assign().get,this.match(":").type,this.assign().get].join("")):t},p.or=function(){var t=this.and();return this.eat("||")?this.getset(t.get+"||"+this.or().get):t},p.and=function(){var t=this.equal();return this.eat("&&")?this.getset(t.get+"&&"+this.and().get):t},p.equal=function(){var t,e=this.relation();return(t=this.eat(["==","!=","===","!=="]))?this.getset(e.get+t.type+this.equal().get):e},p.relation=function(){var t,e=this.additive();return(t=this.eat(["<",">",">=","<="])||this.eat("IDENT","in"))?this.getset(e.get+t.value+this.relation().get):e},p.additive=function(){var t,e=this.multive();return(t=this.eat(["+","-"]))?this.getset(e.get+t.value+this.additive().get):e},p.multive=function(){var t,e=this.range();return(t=this.eat(["*","/","%"]))?this.getset(e.get+t.type+this.multive().get):e},p.range=function(){var t,e,n=this.unary();if(t=this.eat("..")){e=this.unary();var r="(function(start,end){var res = [],step=end>start?1:-1; for(var i = start; end>start?i <= end: i>=end; i=i+step){res.push(i); } return res })("+n.get+","+e.get+")";return this.getset(r)}return n},p.unary=function(){var t;return(t=this.eat(["+","-","~","!"]))?this.getset("("+t.type+this.unary().get+")"):this.member()},p.member=function(t,e,n,r){var s,a,o,f=!1;if(t)"string"==typeof e&&h(e)?n.push(e):(n&&n.length&&this.depend.push(n),n=null);else{a=this.primary();var p=typeof a;"string"===p?(n=[],n.push(a),e=a,o=l+"."+a,t=c+"._sg_('"+a+"', "+u+", "+l+")",f=!0):"this"===a.get?(t=c,n=["this"]):(n=null,t=a.get)}if(s=this.eat(["[",".","("]))switch(s.type){case".":var d=this.match("IDENT").value;return r=t,"("!==this.la()?t=c+"._sg_('"+d+"', "+t+")":t+="['"+d+"']",this.member(t,d,n,r);case"[":return a=this.assign(),r=t,"("!==this.la()?t=c+"._sg_("+a.get+", "+t+")":t+="["+a.get+"]",this.match("]"),this.member(t,a,n,r);case"(":var v=this.arguments().join(",");return t=t+"("+v+")",this.match(")"),this.member(t,null,n)}n&&n.length&&this.depend.push(n);var m={get:t};return e&&(m.set=c+"._ss_("+(e.get?e.get:"'"+e+"'")+","+i.setName+","+(r?r:i.varName)+", '=', "+(f?1:0)+")"),m},p.arguments=function(t){t=t||")";var e=[];do this.la()!==t&&e.push(this.assign().get);while(this.eat(","));return e},p.primary=function(){var t=this.ll();switch(t.type){case"{":return this.object();case"[":return this.array();case"(":return this.paren();case"STRING":return this.next(),this.getset("'"+t.value+"'");case"NUMBER":return this.next(),this.getset(""+t.value);case"IDENT":return this.next(),f(t.value)?this.getset(t.value):t.value;default:this.error("Unexpected Token: "+t.type)}},p.object=function(){for(var t=[this.match("{").type],e=this.eat(["STRING","IDENT","NUMBER"]);e;){t.push("'"+e.value+"'"+this.match(":").type);var n=this.assign().get;t.push(n),e=null,this.eat(",")&&(e=this.eat(["STRING","IDENT","NUMBER"]))&&t.push(",")}return t.push(this.match("}").type),{get:t.join("")}},p.array=function(){var t,e=[this.match("[").type];if(this.eat("]"))e.push("]");else{for(;(t=this.assign())&&(e.push(t.get),this.eat(","));)e.push(",");e.push(this.match("]").type)}return{get:e.join("")}},p.paren=function(){this.match("(");var t=this.filter();return t.get="("+t.get+")",this.match(")"),t},p.getset=function(t,e){return{get:t,set:e}},n.exports=r}),t.register("regularjs/src/helper/extend.js",function(t,e,n){function r(t,e,n){return function(){var r=this.supr;this.supr=n[t];var i=e.apply(this,arguments);return this.supr=r,i}}function i(t,e,n){for(var i in e)e.hasOwnProperty(i)&&(t[i]=o(e[i])&&o(n[i])&&a.test(e[i])?r(i,e[i],n):e[i])}var s=e("../util.js"),a=/xy/.test(function(){"xy"})?/\bsupr\b/:/.*/,o=function(t){return"function"==typeof t},u=["events","data","computed"],c=u.length;n.exports=function l(t){function e(){a.apply(this,arguments)}function n(t){for(var e=c;e--;){var n=u[e];t.hasOwnProperty(n)&&r.hasOwnProperty(n)&&(s.extend(r[n],t[n],!0),delete t[n])}return i(r,t,o),this}t=t||{};var r,a=this,o=a&&a.prototype||{};return"function"==typeof t?(r=t.prototype,t.implement=n,t.extend=l,t):(r=s.createProto(e,o),e.implement=n,e.implement(t),a.__after__&&a.__after__.call(e,a,t),e.extend=l,e)}}),t.register("regularjs/src/helper/shim.js",function(t,e,n){function r(t,e){for(var n in e)void 0===t[n]&&(t[n]=e[n]);return e}var i=[].slice,s={}.toString;n.exports=function(){r(String.prototype,{trim:function(){return this.replace(/^\s+|\s+$/g,"")}}),r(Array.prototype,{indexOf:function(t,e){e=e||0;for(var n=e,r=this.length;r>n;n++)if(this[n]===t)return n;return-1},forEach:function(t,e){for(var n=0,r=this.length;r>n;n++)t.call(e,this[n],n,this)},filter:function(t,e){for(var n=[],r=0,i=this.length;i>r;r++){var s=t.call(e,this[r],r,this);s&&n.push(this[r])}return n},map:function(t,e){for(var n=[],r=0,i=this.length;i>r;r++)n.push(t.call(e,this[r],r,this));return n}}),r(Function.prototype,{bind:function(t){var e=this,n=i.call(arguments,1);return function(){var r=n.concat(i.call(arguments));return e.apply(t,r)}}}),r(Array,{isArray:function(t){return"[object Array]"===s.call(t)}})}}),t.register("regularjs/src/helper/parse.js",function(t,e,n){var r=e("../env").exprCache,i=(e("../util"),e("../parser/Parser.js"));n.exports={expression:function(t){return"string"==typeof t&&(t=t.trim())&&(t=r.get(t)||r.set(t,new i(t,{mode:2,expression:!0}).expression())),t?t:void 0},parse:function(t){return new i(t).parse()}}}),t.register("regularjs/src/helper/watcher.js",function(t,e,n){function r(){}var i=e("../util.js"),s=e("./parse.js").expression,a=e("./arrayDiff.js"),o={$watch:function(t,e,n){var r,a,o,u,c=this.__ext__;this._watchers||(this._watchers=[]),n=n||{},n===!0&&(n={deep:!0});var l=i.uid("w_");if(Array.isArray(t)){for(var h=[],f=0,p=t.length;p>f;f++)h.push(this.$expression(t[f]).get);var d=[];o=function(t){for(var e=!0,n=0,r=h.length;r>n;n++){var s=h[n](t,c);i.equals(s,d[n])||(e=!1,d[n]=i.clone(s))}return e?!1:d}}else"function"==typeof t?r=t.bind(this):(t=this._touchExpr(s(t)),r=t.get,a=t.once);var v={id:l,get:r,fn:e,once:a,force:n.force,notld:n.indexTrack,test:o,deep:n.deep,last:n.sync?r(this):n.last};if(this._watchers.push(v),u=this._records&&this._records.length,u&&this._records[u-1].push(l),n.init===!0){var m=this.$phase;this.$phase="digest",this._checkSingleWatch(v,this._watchers.length-1),this.$phase=m}return v},$unwatch:function(t){if(t=t.uid||t,this._watchers||(this._watchers=[]),Array.isArray(t))for(var e=0,n=t.length;n>e;e++)this.$unwatch(t[e]);else{var r,i,s=this._watchers;if(!t||!s||!(i=s.length))return;for(;i--;)r=s[i],r&&r.id===t&&s.splice(i,1)}},$expression:function(t){return this._touchExpr(s(t))},$digest:function(){if("digest"!==this.$phase&&!this._mute){this.$phase="digest";for(var t=!1,e=0;t=this._digest();)if(++e>20)throw Error("there may a circular dependencies reaches");e>0&&this.$emit&&this.$emit("$update"),this.$phase=null}},_digest:function(){var t,e,n,r=this._watchers,i=!1;if(r&&r.length)for(var s=0,a=r.length;a>s;s++)e=r[s],n=this._checkSingleWatch(e,s),n&&(i=!0);if(t=this._children,t&&t.length)for(var o=0,u=t.length;u>o;o++)t[o]&&t[o]._digest()&&(i=!0);return i},_checkSingleWatch:function(t,e){var n=!1;if(t){var r,s,o,u,c,l;if(t.test){var h=t.test(this);h&&(n=!0,t.fn.apply(this,h))}else if(r=t.get(this),s=t.last,o=i.typeOf(s),u=i.typeOf(r),c=!0,l,"object"===u&&"object"===o&&t.deep){for(var f in r)if(s[f]!==r[f]){n=!0;break}if(n!==!0)for(var p in s)if(s[p]!==r[p]){n=!0;break}}else"array"!==u||"undefined"!=o&&"array"!==o?(c=i.equals(r,s),(!c||t.force)&&(t.force=null,n=!0)):(l=a(r,t.last||[],t.notld),("array"!==o||l===!0||l.length)&&(n=!0));return n&&!t.test&&(t.last="object"===u&&t.deep||"array"===u?i.clone(r):r,t.fn.call(this,r,s,l),t.once&&this._watchers.splice(e,1)),n}},$set:function(t,e){if(null!=t){var n=i.typeOf(t);if("string"===n||"expression"===t.type)t=this.$expression(t),t.set(this,e);else if("function"===n)t.call(this,this.data);else for(var r in t)this.$set(r,t[r])}},$get:function(t,e){return e&&"string"==typeof t?t:this.$expression(t).get(this)},$update:function(){this.$set.apply(this,arguments);var t=this;do{if(t.data.isolate||!t.$parent)break;t=t.$parent}while(t);t.$digest()},_record:function(){this._records||(this._records=[]),this._records.push([])},_release:function(){return this._records.pop()}};i.extend(r.prototype,o),r.mixTo=function(t){return t="function"==typeof t?t.prototype:t,i.extend(t,o)},n.exports=r}),t.register("regularjs/src/helper/event.js",function(t,e,n){function r(){}var i=[].slice,s=e("../util.js"),a={$on:function(t,e){if("object"==typeof t)for(var n in t)this.$on(n,t[n]);else{var r=this,i=r._handles||(r._handles={}),s=i[t]||(i[t]=[]);s.push(e)}return this},$off:function(t,e){var n=this;if(n._handles){t||(this._handles={});var r,i=n._handles;if(r=i[t]){if(!e)return i[t]=[],n;for(var s=0,a=r.length;a>s;s++)if(e===r[s])return r.splice(s,1),n}return n}},$emit:function(t){var e,n,r,s=this,a=s._handles;if(t){var n=i.call(arguments,1),r=t;if(!a)return s;if(e=a[r.slice(1)])for(var o=0,u=e.length;u>o;o++)e[o].apply(s,n);if(!(e=a[r]))return s;for(var c=0,u=e.length;u>c;c++)e[c].apply(s,n);return s}},$one:function(){}};s.extend(r.prototype,a),r.mixTo=function(t){t="function"==typeof t?t.prototype:t,s.extend(t,a)},n.exports=r}),t.register("regularjs/src/helper/animate.js",function(t,e,n){function r(t){var e,n=0,r=0,s=0,a=0,o=0,u=5/3;return window.getComputedStyle&&(e=window.getComputedStyle(t),r=i(e[h+"Duration"])||r,s=i(e[h+"Delay"])||s,a=i(e[f+"Duration"])||a,o=i(e[f+"Delay"])||o,n=Math.max(r+s,a+o)),1e3*n*u}function i(t){var e,n=0;return t?(t.split(",").forEach(function(t){e=parseFloat(t),e>n&&(n=e)}),n):0}var s=e("../util"),a=e("../dom.js"),o={},u=e("../env.js"),c="transitionend",l="animationend",h="transition",f="animation";"ontransitionend"in window||("onwebkittransitionend"in window?(c+=" webkitTransitionEnd",h="webkitTransition"):("onotransitionend"in a.tNode||"Opera"===navigator.appName)&&(c+=" oTransitionEnd",h="oTransition")),"onanimationend"in window||("onwebkitanimationend"in window?(l+=" webkitAnimationEnd",f="webkitAnimation"):"onoanimationend"in a.tNode&&(l+=" oAnimationEnd",f="oAnimation")),o.inject=function(t,e,n,r){if(r=r||s.noop,Array.isArray(t)){for(var i=a.fragment(),o=0,u=0,c=t.length;c>u;u++)i.appendChild(t[u]);a.inject(i,e,n);var l=function(){o++,o===c&&r()};for(c===o&&r(),u=0;c>u;u++)t[u].onenter?t[u].onenter(l):l()}else a.inject(t,e,n),t.onenter?t.onenter(r):r()},o.remove=function(t,e){function n(){r++,r===s&&e&&e()}if(!t)throw new Error("node to be removed is undefined");var r=0;if(Array.isArray(t)){for(var i=0,s=t.length;s>i;i++)o.remove(t[i],n);return t}t.onleave?t.onleave(function(){p(t,e)}):p(t,e)};var p=function(t,e){a.remove(t),e&&e()};o.startClassAnimate=function(t,e,n,i){var o,h,f,p;return!l&&!c||u.isRunning?n():(p=s.once(4!==i?function(){f&&clearTimeout(f),2===i&&a.delClass(t,o),3!==i&&a.delClass(t,e),a.off(t,l,p),a.off(t,c,p),n()}:function(){f&&clearTimeout(f),n()}),2===i?(a.addClass(t,e),o=e.split(/\s+/).map(function(t){return t+"-active"}).join(" "),a.nextReflow(function(){a.addClass(t,o),h=r(t),f=setTimeout(p,h)})):a.nextReflow(4===i?function(){a.delClass(t,e),h=r(t),f=setTimeout(p,h)}:function(){a.addClass(t,e),h=r(t),f=setTimeout(p,h)}),a.on(t,l,p),a.on(t,c,p),p)},o.startStyleAnimate=function(t,e,n){var i,o,u;return a.nextReflow(function(){a.css(t,e),i=r(t),u=setTimeout(o,i)}),o=s.once(function(){u&&clearTimeout(u),a.off(t,l,o),a.off(t,c,o),n()}),a.on(t,l,o),a.on(t,c,o),o},n.exports=o}),t.register("regularjs/src/helper/combine.js",function(t,e,n){var r=e("../dom.js"),i=e("./animate.js"),s=n.exports={node:function(t){var e,n,r;if(t){if(t.element)return t.element;if("function"==typeof t.node)return t.node();if("number"==typeof t.nodeType)return t;if(t.group)return s.node(t.group);if(e=t.children){if(1===e.length)return s.node(e[0]);r=[];for(var i=0,a=e.length;a>i;i++)n=s.node(e[i]),Array.isArray(n)?r.push.apply(r,n):n&&r.push(n);return r}}},inject:function(t,e){var n=this,a=s.node(n.group||n);if(t===!1)return i.remove(a),n;if(!a)return n;if("string"==typeof t&&(t=r.find(t)),!t)throw Error("injected node is not found");return i.inject(a,t,e),n.$emit&&(n.$emit("$inject",t,e),n.parentNode="after"===e||"before"===e?t.parentNode:t),n},last:function(t){var e=t.children;return"function"==typeof t.last?t.last():"number"==typeof t.nodeType?t:e&&e.length?s.last(e[e.length-1]):t.group?s.last(t.group):void 0},destroy:function(t,e){if(t){if(Array.isArray(t))for(var n=0,i=t.length;i>n;n++)s.destroy(t[n],e);var a=t.children;if("function"==typeof t.destroy)return t.destroy(e);"number"==typeof t.nodeType&&e&&r.remove(t),a&&a.length&&(s.destroy(a,!0),t.children=null)}}}}),t.register("regularjs/src/helper/arrayDiff.js",function(t,e,n){function r(t,e){var n=t.length,r=e.length;if(n!==r)return!0;for(var i=0;n>i;i++)if(t[i]!==e[i])return!0;return!1}function i(t,e){return t===e}function s(t,e){for(var n=t.length,r=e.length,s=[],a=0;n>=a;a++)s.push([a]);for(var o=1;r>=o;o++)s[0][o]=o;for(var a=1;n>=a;a++)for(var o=1;r>=o;o++)s[a][o]=i(t[a-1],e[o-1])?s[a-1][o-1]:Math.min(s[a-1][o]+1,s[a][o-1]+1);return s}function a(t,e,n){if(n)return r(t,e);for(var i=s(e,t),a=e.length,o=a,u=t.length,c=u,l=[],h=i[o][c];o>0||c>0;)if(0!==o)if(0!==c){var f=i[o-1][c-1],p=i[o-1][c],d=i[o][c-1],v=Math.min(d,p,f);v===p?(l.unshift(2),o--,h=p):v===f?(f===h?l.unshift(0):(l.unshift(1),h=f),o--,c--):(l.unshift(3),c--,h=d)}else l.unshift(2),o--;else l.unshift(3),c--;var m=0,g=3,y=2,x=1,a=0;u=0;for(var E=[],_={index:null,add:0,removed:[]},o=0;o0?null===_.index&&(_.index=u):null!=_.index&&(E.push(_),_={index:null,add:0,removed:[]}),l[o]){case m:a++,u++;break;case g:_.add++,u++;break;case y:_.removed.push(e[a]),a++;break;case x:_.add++,_.removed.push(e[a]),a++,u++}return null!=_.index&&E.push(_),E}n.exports=a}),t.register("regularjs/src/helper/entities.js",function(t,e,n){var r={quot:34,amp:38,apos:39,lt:60,gt:62,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,copy:169,ordf:170,laquo:171,not:172,shy:173,reg:174,macr:175,deg:176,plusmn:177,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,sup1:185,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,Agrave:192,Aacute:193,Acirc:194,Atilde:195,Auml:196,Aring:197,AElig:198,Ccedil:199,Egrave:200,Eacute:201,Ecirc:202,Euml:203,Igrave:204,Iacute:205,Icirc:206,Iuml:207,ETH:208,Ntilde:209,Ograve:210,Oacute:211,Ocirc:212,Otilde:213,Ouml:214,times:215,Oslash:216,Ugrave:217,Uacute:218,Ucirc:219,Uuml:220,Yacute:221,THORN:222,szlig:223,agrave:224,aacute:225,acirc:226,atilde:227,auml:228,aring:229,aelig:230,ccedil:231,egrave:232,eacute:233,ecirc:234,euml:235,igrave:236,iacute:237,icirc:238,iuml:239,eth:240,ntilde:241,ograve:242,oacute:243,ocirc:244,otilde:245,ouml:246,divide:247,oslash:248,ugrave:249,uacute:250,ucirc:251,uuml:252,yacute:253,thorn:254,yuml:255,fnof:402,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,bull:8226,hellip:8230,prime:8242,Prime:8243,oline:8254,frasl:8260,weierp:8472,image:8465,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,"int":8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,circ:710,tilde:732,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,permil:8240,lsaquo:8249,rsaquo:8250,euro:8364};n.exports=r}),t.register("regularjs/src/helper/filter.js",function(t,e,n){var r=n.exports={};r.json={get:function(t){return"undefined"!=typeof JSON?JSON.stringify(t):t},set:function(t){return"undefined"!=typeof JSON?JSON.parse(t):t}},r.last=function(t){return t&&t[t.length-1]},r.average=function(t,e){return t=t||[],t.length?r.total(t,e)/t.length:0},r.total=function(t,e){var n=0;if(t)return t.forEach(function(t){n+=e?t[e]:t}),n}}),t.register("regularjs/src/directive/base.js",function(t,e,n){var r=e("../util.js"),i=e("../dom.js"),s=(e("../helper/animate.js"),e("../Regular.js")),a=e("../const");e("./event.js"),e("./form.js"),n.exports={"r-class":function(t,e){"string"==typeof e&&(e=r.fixObjStr(e)),this.$watch(e,function(e){var n=" "+t.className.replace(/\s+/g," ")+" ";for(var r in e)e.hasOwnProperty(r)&&(n=n.replace(" "+r+" "," "),e[r]===!0&&(n+=r+" "));t.className=n.trim()},!0)},"r-style":function(t,e){"string"==typeof e&&(e=r.fixObjStr(e)),this.$watch(e,function(e){for(var n in e)e.hasOwnProperty(n)&&i.css(t,n,e[n])},!0)},"r-hide":function(t,e){var n,r=null;this.$watch(e,function(e){var i=!!e;i!==r&&(r=i,i?t.onleave?n=t.onleave(function(){t.style.display="none",n=null}):t.style.display="none":(n&&n(),t.style.display="",t.onenter&&t.onenter()))})},"r-html":function(t,e){this.$watch(e,function(e){e=e||"",i.html(t,e)},{force:!0})},ref:{accept:a.COMPONENT_TYPE+a.ELEMENT_TYPE,link:function(t,e){var n,i=this.$refs||(this.$refs={});return r.isExpr(e)?this.$watch(e,function(e,r){n=e,i[r]===t&&(i[r]=null),n&&(i[n]=t)}):i[n=e]=t,function(){i[n]=null}}}},s.directive(n.exports)}),t.register("regularjs/src/directive/form.js",function(t,e){function n(t,e){function n(){e.set(r,this.value),i.last=this.value,r.$update()}var r=this,i=this.$watch(e,function(e){var n=a.slice(t.getElementsByTagName("option"));n.forEach(function(n,r){n.value==e&&(t.selectedIndex=r)})});return o.on(t,"change",n),void 0===e.get(r)&&t.value&&e.set(r,t.value),function(){o.off(t,"change",n)}}function r(t,e){var n=this,r=this.$watch(e,function(e){t.value!==e&&(t.value=null==e?"":""+e)}),i=function(t){var i=this;if("cut"===t.type||"paste"===t.type)a.nextTick(function(){var t=i.value;e.set(n,t),r.last=t,n.$update()});else{var s=i.value;e.set(n,s),r.last=s,n.$update()}};return 9!==o.msie&&"oninput"in o.tNode?t.addEventListener("input",i):(o.on(t,"paste",i),o.on(t,"keyup",i),o.on(t,"cut",i),o.on(t,"change",i)),void 0===e.get(n)&&t.value&&e.set(n,t.value),function(){9!==o.msie&&"oninput"in o.tNode?t.removeEventListener("input",i):(o.off(t,"paste",i),o.off(t,"keyup",i),o.off(t,"cut",i),o.off(t,"change",i))}}function i(t,e){var n=this,r=this.$watch(e,function(e){o.attr(t,"checked",!!e)}),i=function(){var t=this.checked;e.set(n,t),r.last=t,n.$update()};return e.set&&o.on(t,"change",i),void 0===e.get(n)&&e.set(n,!!t.checked),function(){e.set&&o.off(t,"change",i)}}function s(t,e){var n=this,r=(this.$watch(e,function(e){t.checked=e==t.value?!0:!1}),function(){var t=this.value;e.set(n,t),n.$update()});return e.set&&o.on(t,"change",r),void 0===e.get(n)&&t.checked&&e.set(n,t.value),function(){e.set&&o.off(t,"change",r)}}var a=e("../util.js"),o=e("../dom.js"),u=e("../Regular.js"),c={text:r,select:n,checkbox:i,radio:s};u.directive("r-model",function(t,e){var n=t.tagName.toLowerCase(),r=n;return"input"===r?r=t.type||"text":"textarea"===r&&(r="text"),"string"==typeof e&&(e=this.$expression(e)),c[r]?c[r].call(this,t,e):"input"===n?c.text.call(this,t,e):void 0})}),t.register("regularjs/src/directive/animation.js",function(t,e){function n(t){var e,n=[],r=0,s=i.noop,a={type:t,start:function(t){return e=i.uid(),"function"==typeof t&&(s=t),r>0?r=0:a.step(),a.compelete},compelete:function(){e=null,s&&s(),s=i.noop,r=0},step:function(){n[r]&&n[r](a.done.bind(a,e))},done:function(t){t===e&&(ry;y++)if(o=v[y],p=o.split(":"),h=p[0]&&p[0].trim(),f=p[1]&&p[1].trim(),h)if(h!==u)if(h!==c){var d=a.animation(h);if(!d||!l)throw Error(d?"you should start with `on` or `event` in animation":"undefined animator 【"+h+"】");l.push(d.call(this,{element:t,done:l.done,param:f}))}else r(f),"leave"===f?(t.onleave=l.start,g.push(s(t))):"enter"===f?(t.onenter=l.start,g.push(s(t))):"on"+f in t?g.push(this._handleEvent(t,f,l.start)):(this.$on(f,l.start),g.push(this.$off.bind(this,f,l.start)));else r("when"),this.$watch(f,i.bind(this,l.start));return g.length?function(){g.forEach(function(t){t()})}:void 0}var i=e("../util.js"),s=e("../helper/animate.js"),a=(e("../dom.js"),e("../Regular.js")),o=/\s+/,u="when",c="on";a._addProtoInheritCache("animation"),a.animation({wait:function(t){var e=parseInt(t.param)||0;return function(t){setTimeout(t,e)}},"class":function(t){var e=t.param.split(","),n=e[0]||"",r=parseInt(e[1])||1;return function(e){s.startClassAnimate(t.element,n,e,r)}},call:function(t){var e=this.$expression(t.param).get,n=this;return function(t){e(n),n.$update(),t()}},emit:function(t){var e=t.param,n=e.split(","),r=n[0]||"",i=n[1]?this.$expression(n[1]).get:null;if(!r)throw Error("you shoud specified a eventname in emit command");var s=this;return function(t){s.$emit(r,i?i(s):void 0),t()}},style:function(t){var e,n={},r=t.param,i=r.split(",");return i.forEach(function(t){if(t=t.trim()){var r=t.split(o),i=r.shift(),s=r.join(" ");if(!i||!s)throw Error("invalid style in command: style");n[i]=s,e=!0}}),function(r){e?s.startStyleAnimate(t.element,n,r):r()}}}),a.directive("r-animation",r),a.directive("r-anim",r)}),t.register("regularjs/src/directive/event.js",function(t,e){function n(t,e,n){if(n)for(var r,i=t.target;i&&i!==n;){for(var s=0,a=e.length;a>s;s++)r=e[s],r&&r.element===i&&r.fire(t);i=i.parentNode}}var r=e("../util.js"),i=e("../dom.js"),s=e("../Regular.js");s._addProtoInheritCache("event"),s.directive(/^on-\w+$/,function(t,e,n,r){if(n&&e){var i=n.split("-")[1];return this._handleEvent(t,i,e,r)}}),s.directive(/^(delegate|de)-\w+$/,function(t,e,s){function a(t){n(t,u[c],o.parentNode)}var o=this.$root,u=o._delegates||(o._delegates={});if(s&&e){var c=s.split("-")[1],l=r.handleEvent.call(this,e,c);u[c]||(u[c]=[],o.parentNode?i.on(o.parentNode,c,a):o.$on("$inject",function(t){var e=this.parentNode;e&&i.off(e,c,a),i.on(t,c,a)}),o.$on("$destroy",function(){o.parentNode&&i.off(o.parentNode,c,a),u[c]=null}));var h={element:t,fire:l};return u[c].push(h),function(){var t=u[c];if(t&&t.length)for(var e=0,n=t.length;n>e;e++)t[e]===h&&t.splice(e,1)}}})}),t.register("regularjs/src/module/timeout.js",function(t,e){function n(t){t.implement({$timeout:function(t,e){return e=e||0,setTimeout(function(){t.call(this),this.$update()}.bind(this),e)},$interval:function(t,e){return e=e||1e3/60,setInterval(function(){t.call(this),this.$update()}.bind(this),e)}})}var r=e("../Regular.js");r.plugin("timeout",n),r.plugin("$timeout",n)}),t.alias("regularjs/src/index.js","regularjs/index.js"),"object"==typeof exports?module.exports=t("regularjs"):"function"==typeof define&&define.amd?define(function(){return t("regularjs")}):window.Regular=t("regularjs")}(); \ No newline at end of file diff --git a/example/feature-collection/include-advanced.html b/example/feature-collection/include-advanced.html new file mode 100644 index 0000000..eb3fc5a --- /dev/null +++ b/example/feature-collection/include-advanced.html @@ -0,0 +1,104 @@ + + + + + Include advanced + + + + + + + + + + + + + + diff --git a/example/pager/index.html b/example/pager/index.html index e47bc20..d57fcc2 100644 --- a/example/pager/index.html +++ b/example/pager/index.html @@ -7,18 +7,27 @@ + - -
- {title} -
-
diff --git a/example/pager/pager.js b/example/pager/pager.js index 39ae74f..bc45292 100644 --- a/example/pager/pager.js +++ b/example/pager/pager.js @@ -2,8 +2,7 @@ void function(){ window.Pager = Regular.extend({ name: 'pager', template: - "
\ - {title}\ + "

{#inc title}

\ Prev\ {#if total - 5 > show * 2}\ 1\ diff --git a/src/Regular.js b/src/Regular.js index df6af79..79ae775 100644 --- a/src/Regular.js +++ b/src/Regular.js @@ -26,20 +26,22 @@ var doc = dom.doc; * @constructor * @param {Object} options specification of the component */ -var Regular = function(options){ +var Regular = function(definition, options){ var prevRunning = env.isRunning; env.isRunning = true; var node, template; + definition = definition || {}; options = options || {}; - options.data = options.data || {}; - options.computed = options.computed || {}; - options.events = options.events || {}; - if(this.data) _.extend(options.data, this.data); - if(this.computed) _.extend(options.computed, this.computed); - if(this.events) _.extend(options.events, this.events); - - _.extend(this, options, true); + + definition.data = definition.data || {}; + definition.computed = definition.computed || {}; + definition.events = definition.events || {}; + if(this.data) _.extend(definition.data, this.data); + if(this.computed) _.extend(definition.computed, this.computed); + if(this.events) _.extend(definition.events, this.events); + + _.extend(this, definition, true); if(this.$parent){ this.$parent._append(this); } @@ -62,14 +64,17 @@ var Regular = function(options){ if(this.events){ this.$on(this.events); } - // if(this.$body){ - this._getTransclude = function(transclude){ - var ctx = this.$parent || this; - if( transclude || this.$body ) return ctx.$compile(transclude || this.$body, {namespace: options.namespace, outer: this, extra: options.extra}) - } - // } this.$emit("$config"); this.config && this.config(this.data); + if(this._body && this._body.length){ + this.$body = _.getCompileFn(this._body, this.$parent, { + outer: this, + namespace: options.namespace, + extra: options.extra, + record: true + }) + this._body = null; + } // handle computed if(template){ this.group = this.$compile(this.template, {namespace: options.namespace}); @@ -458,7 +463,7 @@ Regular.implement({ _f_: function(name){ var Component = this.constructor; var filter = Component.filter(name); - if(!filter) throw 'filter ' + name + ' is undefined'; + if(!filter) throw Error('filter ' + name + ' is undefined'); return filter; }, // simple accessor get @@ -520,7 +525,6 @@ Regular.prototype.inject = function(){ } - // only one builtin filter Regular.filter(filter); diff --git a/src/directive/animation.js b/src/directive/animation.js index 1387750..cfb2dc6 100644 --- a/src/directive/animation.js +++ b/src/directive/animation.js @@ -100,7 +100,7 @@ Regular.animation({ evt = tmp[0] || "", args = tmp[1]? this.$expression(tmp[1]).get: null; - if(!evt) throw "you shoud specified a eventname in emit command"; + if(!evt) throw Error("you shoud specified a eventname in emit command"); var self = this; return function(done){ @@ -120,7 +120,7 @@ Regular.animation({ name = tmp.shift(), value = tmp.join(" "); - if( !name || !value ) throw "invalid style in command: style"; + if( !name || !value ) throw Error("invalid style in command: style"); styles[name] = value; valid = true; } @@ -142,6 +142,7 @@ Regular.animation({ // el : the element to process // value: the directive value function processAnimate( element, value ){ + var Component = this.constructor; value = value.trim(); var composites = value.split(";"), @@ -198,7 +199,7 @@ function processAnimate( element, value ){ continue } - var animator = Regular.animation(command) + var animator = Component.animation(command) if( animator && seed ){ seed.push( animator.call(this,{ @@ -208,7 +209,7 @@ function processAnimate( element, value ){ }) ) }else{ - throw "you need start with `on` or `event` in r-animation"; + throw Error( animator? "you should start with `on` or `event` in animation" : ("undefined animator 【" + command +"】" )); } } @@ -223,5 +224,5 @@ function processAnimate( element, value ){ Regular.directive( "r-animation", processAnimate) -Regular.directive( "r-sequence", processAnimate) +Regular.directive( "r-anim", processAnimate) diff --git a/src/directive/form.js b/src/directive/form.js index 303eee5..ab95894 100644 --- a/src/directive/form.js +++ b/src/directive/form.js @@ -70,7 +70,7 @@ function initText(elem, parsed){ }); // @TODO to fixed event - var handler = function handler(ev){ + var handler = function (ev){ var that = this; if(ev.type==='cut' || ev.type==='paste'){ _.nextTick(function(){ @@ -98,7 +98,7 @@ function initText(elem, parsed){ if(parsed.get(self) === undefined && elem.value){ parsed.set(self, elem.value); } - return function destroy(){ + return function (){ if(dom.msie !== 9 && "oninput" in dom.tNode ){ elem.removeEventListener("input", handler ); }else{ diff --git a/src/dom.js b/src/dom.js index 022bf53..4442b25 100644 --- a/src/dom.js +++ b/src/dom.js @@ -71,7 +71,7 @@ dom.find = function(sl){ dom.inject = function(node, refer, position){ position = position || 'bottom'; - + if(!node) return ; if(Array.isArray(node)){ var tmp = node; node = dom.fragment(); @@ -377,12 +377,12 @@ dom.nextFrame = (function(){ // 3ks for angular's raf service var k; -dom.nextReflow = function(callback){ - dom.nextFrame(function(){ +dom.nextReflow = dom.msie? function(callback){ + return dom.nextFrame(function(){ k = document.body.offsetWidth; callback(); }) -} +}: dom.nextFrame; diff --git a/src/group.js b/src/group.js index e5a4d2b..bacc18d 100644 --- a/src/group.js +++ b/src/group.js @@ -6,7 +6,7 @@ function Group(list){ } -_.extend(Group.prototype, { +var o = _.extend(Group.prototype, { destroy: function(first){ combine.destroy(this.children, first); if(this.ondestroy) this.ondestroy(); @@ -17,9 +17,9 @@ _.extend(Group.prototype, { }, push: function(item){ this.children.push( item ); - }, - inject: combine.inject + } }) +o.inject = o.$inject = combine.inject diff --git a/src/helper/animate.js b/src/helper/animate.js index 96fb1b1..6e4870b 100644 --- a/src/helper/animate.js +++ b/src/helper/animate.js @@ -84,6 +84,18 @@ animate.inject = function( node, refer ,direction, callback ){ * @return {[type]} [description] */ animate.remove = function(node, callback){ + if(!node) throw new Error('node to be removed is undefined') + var count = 0; + function loop(){ + count++; + if(count === len) callback && callback() + } + if(Array.isArray(node)){ + for(var i = 0, len = node.length; i < len ; i++){ + animate.remove(node[i], loop) + } + return node; + } if(node.onleave){ node.onleave(function(){ removeDone(node, callback) @@ -106,21 +118,28 @@ animate.startClassAnimate = function ( node, className, callback, mode ){ return callback(); } - onceAnim = _.once(function onAnimateEnd(){ - if(tid) clearTimeout(tid); + if(mode !== 4){ + onceAnim = _.once(function onAnimateEnd(){ + if(tid) clearTimeout(tid); - if(mode === 2) { - dom.delClass(node, activeClassName); - } - if(mode !== 3){ // mode hold the class - dom.delClass(node, className); - } - dom.off(node, animationEnd, onceAnim) - dom.off(node, transitionEnd, onceAnim) + if(mode === 2) { + dom.delClass(node, activeClassName); + } + if(mode !== 3){ // mode hold the class + dom.delClass(node, className); + } + dom.off(node, animationEnd, onceAnim) + dom.off(node, transitionEnd, onceAnim) - callback(); + callback(); - }); + }); + }else{ + onceAnim = _.once(function onAnimateEnd(){ + if(tid) clearTimeout(tid); + callback(); + }); + } if(mode === 2){ // auto removed dom.addClass( node, className ); @@ -134,17 +153,23 @@ animate.startClassAnimate = function ( node, className, callback, mode ){ tid = setTimeout( onceAnim, timeout ); }); - }else{ + }else if(mode===4){ + dom.nextReflow(function(){ + dom.delClass( node, className ); + timeout = getMaxTimeout( node ); + tid = setTimeout( onceAnim, timeout ); + }); + }else{ dom.nextReflow(function(){ dom.addClass( node, className ); timeout = getMaxTimeout( node ); tid = setTimeout( onceAnim, timeout ); }); - } + dom.on( node, animationEnd, onceAnim ) dom.on( node, transitionEnd, onceAnim ) return onceAnim; diff --git a/src/helper/combine.js b/src/helper/combine.js index 31b61e2..c130c9a 100644 --- a/src/helper/combine.js +++ b/src/helper/combine.js @@ -2,12 +2,14 @@ // -------------------------------- var dom = require("../dom.js"); +var animate = require("./animate.js"); var combine = module.exports = { // get the initial dom in object node: function(item){ var children,node, nodes; + if(!item) return; if(item.element) return item.element; if(typeof item.node === "function") return item.node(); if(typeof item.nodeType === "number") return item; @@ -28,24 +30,25 @@ var combine = module.exports = { return nodes; } }, - inject: function(node, pos, group ){ - if(!group) group = this; + // @TODO remove _gragContainer + inject: function(node, pos ){ + var group = this; + var fragment = combine.node(group.group || group); if(node === false) { - if(!group._fragContainer) group._fragContainer = dom.fragment(); - return combine.inject( group._fragContainer, pos, group); + animate.remove(fragment) + return group; + }else{ + if(!fragment) return group; + if(typeof node === 'string') node = dom.find(node); + if(!node) throw Error('injected node is not found'); + // use animate to animate firstchildren + animate.inject(fragment, node, pos); } - var fragment = combine.node(group.group || group); - if(!fragment) return group; - if(typeof node === 'string') node = dom.find(node); - if(!node) throw 'injected node is not found'; - dom.inject(fragment, node, pos); // if it is a component if(group.$emit) { group.$emit("$inject", node, pos); group.parentNode = (pos ==='after' || pos === 'before')? node.parentNode : node; } - - return group; }, diff --git a/src/helper/event.js b/src/helper/event.js index 573b1fc..a916850 100644 --- a/src/helper/event.js +++ b/src/helper/event.js @@ -2,72 +2,70 @@ // =============================== var slice = [].slice, _ = require("../util.js"); var API = { - $on: function(event, fn) { - if(typeof event === "object"){ - for (var i in event) { - this.$on(i, event[i]); - } - }else{ - // @patch: for list - var context = this; - var handles = context._handles || (context._handles = {}), - calls = handles[event] || (handles[event] = []); - calls.push(fn); - } - return this; - }, - $off: function(event, fn) { - var context = this; - if(!context._handles) return; - if(!event) this._handles = {}; - var handles = context._handles, - calls; + $on: function(event, fn) { + if(typeof event === "object"){ + for (var i in event) { + this.$on(i, event[i]); + } + }else{ + // @patch: for list + var context = this; + var handles = context._handles || (context._handles = {}), + calls = handles[event] || (handles[event] = []); + calls.push(fn); + } + return this; + }, + $off: function(event, fn) { + var context = this; + if(!context._handles) return; + if(!event) this._handles = {}; + var handles = context._handles, + calls; - if (calls = handles[event]) { - if (!fn) { - handles[event] = []; - return context; - } - for (var i = 0, len = calls.length; i < len; i++) { - if (fn === calls[i]) { - calls.splice(i, 1); - return context; - } - } - } + if (calls = handles[event]) { + if (!fn) { + handles[event] = []; return context; - }, - // bubble event - $emit: function(event){ - // @patch: for list - var context = this; - var handles = context._handles, calls, args, type; - if(!event) return; - var args = slice.call(arguments, 1); - var type = event; - - if(!handles) return context; - if(calls = handles[type.slice(1)]){ - for (var j = 0, len = calls.length; j < len; j++) { - calls[j].apply(context, args) - } - } - if (!(calls = handles[type])) return context; - for (var i = 0, len = calls.length; i < len; i++) { - calls[i].apply(context, args) + } + for (var i = 0, len = calls.length; i < len; i++) { + if (fn === calls[i]) { + calls.splice(i, 1); + return context; } - // if(calls.length) context.$update(); - return context; - }, - // capture event - $broadcast: function(){ - + } } + return context; + }, + // bubble event + $emit: function(event){ + // @patch: for list + var context = this; + var handles = context._handles, calls, args, type; + if(!event) return; + var args = slice.call(arguments, 1); + var type = event; + + if(!handles) return context; + if(calls = handles[type.slice(1)]){ + for (var j = 0, len = calls.length; j < len; j++) { + calls[j].apply(context, args) + } + } + if (!(calls = handles[type])) return context; + for (var i = 0, len = calls.length; i < len; i++) { + calls[i].apply(context, args) + } + // if(calls.length) context.$update(); + return context; + }, + // capture event + $one: function(){ + } -// container class -function Event() { - if (arguments.length) this.$on.apply(this, arguments); } +// container class +function Event() {} _.extend(Event.prototype, API) Event.mixTo = function(obj){ diff --git a/src/helper/shim.js b/src/helper/shim.js index e07f787..62fa3b3 100644 --- a/src/helper/shim.js +++ b/src/helper/shim.js @@ -6,79 +6,66 @@ function extend(o1, o2 ){ for(var i in o2) if( o1[i] === undefined){ o1[i] = o2[i] } + return o2; } -// String proto ; -extend(String.prototype, { - trim: function(){ - return this.replace(/^\s+|\s+$/g, ''); - } -}); +module.exports = function(){ + // String proto ; + extend(String.prototype, { + trim: function(){ + return this.replace(/^\s+|\s+$/g, ''); + } + }); -// Array proto; -extend(Array.prototype, { - indexOf: function(obj, from){ - from = from || 0; - for (var i = from, len = this.length; i < len; i++) { - if (this[i] === obj) return i; - } - return -1; - }, - forEach: function(callback, context){ - for (var i = 0, len = this.length; i < len; i++) { - callback.call(context, this[i], i, this); + // Array proto; + extend(Array.prototype, { + indexOf: function(obj, from){ + from = from || 0; + for (var i = from, len = this.length; i < len; i++) { + if (this[i] === obj) return i; + } + return -1; + }, + forEach: function(callback, context){ + for (var i = 0, len = this.length; i < len; i++) { + callback.call(context, this[i], i, this); + } + }, + filter: function(callback, context){ + var res = []; + for (var i = 0, length = this.length; i < length; i++) { + var pass = callback.call(context, this[i], i, this); + if(pass) res.push(this[i]); + } + return res; + }, + map: function(callback, context){ + var res = []; + for (var i = 0, length = this.length; i < length; i++) { + res.push(callback.call(context, this[i], i, this)); + } + return res; } - }, - filter: function(callback, context){ - var res = []; - for (var i = 0, length = this.length; i < length; i++) { - var pass = callback.call(context, this[i], i, this); - if(pass) res.push(this[i]); - } - return res; - }, - map: function(callback, context){ - var res = []; - for (var i = 0, length = this.length; i < length; i++) { - res.push(callback.call(context, this[i], i, this)); - } - return res; - } -}); + }); -// Function proto; -extend(Function.prototype, { - bind: function(context){ - var fn = this; - var preArgs = slice.call(arguments, 1); - return function(){ - var args = preArgs.concat(slice.call(arguments)); - return fn.apply(context, args); + // Function proto; + extend(Function.prototype, { + bind: function(context){ + var fn = this; + var preArgs = slice.call(arguments, 1); + return function(){ + var args = preArgs.concat(slice.call(arguments)); + return fn.apply(context, args); + } } - } -}) - -// Object -extend(Object, { - keys: function(obj){ - var keys = []; - for(var i in obj) if(obj.hasOwnProperty(i)){ - keys.push(i); + }) + + // Array + extend(Array, { + isArray: function(arr){ + return tstr.call(arr) === "[object Array]"; } - return keys; - } -}) + }) +} -// Date -extend(Date, { - now: function(){ - return +new Date; - } -}) -// Array -extend(Array, { - isArray: function(arr){ - return tstr.call(arr) === "[object Array]"; - } -}) diff --git a/src/helper/watcher.js b/src/helper/watcher.js index b67ab60..2f450d7 100644 --- a/src/helper/watcher.js +++ b/src/helper/watcher.js @@ -102,7 +102,7 @@ var methods = { while(dirty = this._digest()){ if((++n) > 20){ // max loop - throw 'there may a circular dependencies reaches' + throw Error('there may a circular dependencies reaches') } } if( n > 0 && this.$emit) this.$emit("$update"); @@ -125,7 +125,7 @@ var methods = { children = this._children; if(children && children.length){ for(var m = 0, mlen = children.length; m < mlen; m++){ - if(children[m]._digest()) dirty = true; + if(children[m] && children[m]._digest()) dirty = true; } } return dirty; diff --git a/src/parser/Lexer.js b/src/parser/Lexer.js index 2702d73..5407fba 100644 --- a/src/parser/Lexer.js +++ b/src/parser/Lexer.js @@ -71,7 +71,7 @@ lo.lex = function(str){ } lo.error = function(msg){ - throw "Parse Error: " + msg + ':\n' + _.trackErrorPos(this.input, this.index); + throw Error("Parse Error: " + msg + ':\n' + _.trackErrorPos(this.input, this.index)); } lo._process = function(args, split,str){ diff --git a/src/parser/Parser.js b/src/parser/Parser.js index 15278f4..4a15fa5 100644 --- a/src/parser/Parser.js +++ b/src/parser/Parser.js @@ -151,10 +151,17 @@ op.xml = function(){ // {{#if name}}on-click={{xx}}{{#else}}on-tap={{}}{{/if}} op.xentity = function(ll){ - var name = ll.value, value; + var name = ll.value, value, modifier; if(ll.type === 'NAME'){ - if( this.eat("=") ) value = this.attvalue(); - return node.attribute( name, value ); + //@ only for test + if(~name.indexOf('.')){ + var tmp = name.split('.'); + name = tmp[0]; + modifier = tmp[1] + + } + if( this.eat("=") ) value = this.attvalue(modifier); + return node.attribute( name, value, modifier ); }else{ if( name !== 'if') this.error("current version. ONLY RULE #if #else #elseif is valid in tag, the rule #" + name + ' is invalid'); return this['if'](true); @@ -182,7 +189,7 @@ op.attrs = function(isAttribute){ // attvalue // : STRING // | NAME -op.attvalue = function(){ +op.attvalue = function(mdf){ var ll = this.ll(); switch(ll.type){ case "NAME": @@ -190,7 +197,7 @@ op.attvalue = function(){ case "STRING": this.next(); var value = ll.value; - if(~value.indexOf(config.BEGIN) && ~value.indexOf(config.END)){ + if(~value.indexOf(config.BEGIN) && ~value.indexOf(config.END) && mdf!=='cmpl'){ var constant = true; var parsed = new Parser(value, { mode: 2 }).parse(); if(parsed.length === 1 && parsed[0].type === 'expression') return parsed[0]; diff --git a/src/parser/node.js b/src/parser/node.js index f15f6ea..fce1be7 100644 --- a/src/parser/node.js +++ b/src/parser/node.js @@ -7,11 +7,12 @@ module.exports = { children: children } }, - attribute: function(name, value){ + attribute: function(name, value, mdf){ return { type: 'attribute', name: name, - value: value + value: value, + mdf: mdf } }, "if": function(test, consequent, alternate){ diff --git a/src/util.js b/src/util.js index a15af9f..4f5256a 100644 --- a/src/util.js +++ b/src/util.js @@ -1,4 +1,4 @@ -require('./helper/shim.js'); +require('./helper/shim.js')(); var _ = module.exports; var entities = require('./helper/entities.js'); var slice = [].slice; @@ -14,6 +14,31 @@ _.uid = (function(){ } })(); +_.extend = function( o1, o2, override ){ + // if(_.typeOf(override) === 'array'){ + // for(var i = 0, len = override.length; i < len; i++ ){ + // var key = override[i]; + // o1[key] = o2[key]; + // } + // }else{ + for(var i in o2){ + if( typeof o1[i] === "undefined" || override === true ){ + o1[i] = o2[i] + } + } + // } + return o1; +} + +_.keys = function(obj){ + if(Object.keys) return Object.keys(obj); + var res = []; + for(var i in obj) if(obj.hasOwnProperty(i)){ + res.push(i); + } + return res; +} + _.varName = 'd'; _.setName = 'p_'; _.ctxName = 'c'; @@ -46,26 +71,6 @@ _.typeOf = function (o) { return o == null ? String(o) :o2str.call(o).slice(8, -1).toLowerCase(); } -_.isExpression = function( expr ){ - return expr && expr.type === 'expression'; -} - - -_.extend = function( o1, o2, override ){ - if(_.typeOf(override) === 'array'){ - for(var i = 0, len = override.length; i < len; i++ ){ - var key = override[i]; - o1[key] = o2[key]; - } - }else{ - for(var i in o2){ - if( typeof o1[i] === "undefined" || override === true ){ - o1[i] = o2[i] - } - } - } - return o1; -} _.makePredicate = function makePredicate(words, prefix) { if (typeof words === "string") { @@ -185,7 +190,7 @@ _.escapeRegExp = function( str){// Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Le }; -var rEntity = new RegExp("&(" + Object.keys(entities).join('|') + ');', 'gi'); +var rEntity = new RegExp("&(" + _.keys(entities).join('|') + ');', 'gi'); _.convertEntity = function(chr){ @@ -385,6 +390,7 @@ _.log = function(msg, type){ + //http://www.w3.org/html/wg/drafts/html/master/single-page.html#void-elements _.isVoidTag = _.makePredicate("area base br col embed hr img input keygen link menuitem meta param source track wbr r-content"); _.isBooleanAttr = _.makePredicate('selected checked disabled readOnly required open autofocus controls autoplay compact loop defer multiple'); @@ -395,8 +401,13 @@ _.isTrue - function(){return true} _.isExpr = function(expr){ return expr && expr.type === 'expression'; } +// @TODO: make it more strict +_.isGroup = function(group){ + return group.inject || group.$inject; +} -_.assert = function(test, msg){ - if(!test) throw msg; +_.getCompileFn = function(source, ctx, options){ + return ctx.$compile.bind(ctx,source, options) } + diff --git a/src/walkers.js b/src/walkers.js index f619f1c..4673785 100644 --- a/src/walkers.js +++ b/src/walkers.js @@ -71,14 +71,18 @@ walkers.list = function(ast, options){ } function updateLD(newValue, oldValue, splices){ - if(!newValue) { - newValue = []; + if(!oldValue) oldValue = []; + if(!newValue) newValue = []; + + + var cur = placeholder; + var m = 0, len = newValue.length; + + if(!splices && (len !==0 || oldValue.length !==0) ){ splices = diffArray(newValue, oldValue); } - + if(!splices || !splices.length) return; - var cur = placeholder; - var m = 0, len = newValue.length; for(var i = 0; i < splices.length; i++){ //init var splice = splices[i]; @@ -178,12 +182,16 @@ walkers.template = function(ast, options){ if(content){ var self = this; this.$watch(content, function(value){ - if( compiled = group.get(1)){ - compiled.destroy(true); + var removed = group.get(1), type= typeof value; + if( removed){ + removed.destroy(true); group.children.pop(); } - group.push( compiled = self.$compile(value, {record: true, outer: options.outer,namespace: namespace, extra: extra}) ); - if(placeholder.parentNode) animate.inject(combine.node(compiled), placeholder, 'before') + if(!value) return; + group.push( compiled = (typeof value === 'function') ? value(): self.$compile(value, {record: true, outer: options.outer,namespace: namespace, extra: extra}) ); + if(placeholder.parentNode) { + compiled.$inject(placeholder, 'before') + } }, { init: true }); @@ -271,7 +279,6 @@ walkers.text = function(ast, options){ var eventReg = /^on-(.+)$/ - /** * walkers element (contains component) */ @@ -285,8 +292,9 @@ walkers.element = function(ast, options){ Component = Constructor.component(tag), ref, group, element; - if( tag === 'r-content' && this._getTransclude ){ - return this._getTransclude(); + if( tag === 'r-content' ){ + _.log('r-content is deprecated, use {#inc this.$body} instead (`{#include}` as same)', 'error'); + return this.$body && this.$body(); } if(Component || tag === 'r-component'){ @@ -358,109 +366,130 @@ walkers.component = function(ast, options){ var attrs = ast.attrs, Component = options.Component, Constructor = this.constructor, - isolate, namespace = options.namespace, + isolate, + extra = options.extra, + namespace = options.namespace, ref, self = this, is; - var data = {}, events; - for(var i = 0, len = attrs.length; i < len; i++){ - var attr = attrs[i]; - // consider disabled equlasto disabled={true} - var value = this._touchExpr(attr.value===undefined? true: attr.value); - if(value.constant) value = attr.value = value.get(this); - if(attr.value && attr.value.constant === true){ - value = value.get(this); - } - var name = attr.name; - if(!attr.event){ - var etest = name.match(eventReg); - // event: 'nav' - if(etest) attr.event = etest[1]; - } - - // @if is r-component . we need to find the target Component - if(name === 'is' && !Component){ - is = value; - var componentName = this.$get(value, true); - Component = Constructor.component(componentName) - if(typeof Component !== 'function') throw new Error("component " + componentName + " has not registed!"); - } - // bind event proxy - var eventName; - if(eventName = attr.event){ - events = events || {}; - events[eventName] = _.handleEvent.call(this, value, eventName); - continue; - }else { - name = attr.name = _.camelCase(name); - } - if(value.type !== 'expression'){ - data[name] = value; - }else{ - data[name] = value.get(self); - } - if( name === 'ref' && value != null){ - ref = value.type === 'expression'? value.get(self): value; - } - if( name === 'isolate'){ - // 1: stop: composite -> parent - // 2. stop: composite <- parent - // 3. stop 1 and 2: composite <-> parent - // 0. stop nothing (defualt) - isolate = value.type === 'expression'? value.get(self): parseInt(value === true? 3: value, 10); - data.isolate = isolate; - } - } + var data = {}, events; - var config = { - data: data, - events: events, - $parent: this, - $outer: options.outer, - namespace: namespace, - $root: this.$root, - $body: ast.children - } + for(var i = 0, len = attrs.length; i < len; i++){ + var attr = attrs[i]; + // consider disabled equlasto disabled={true} + var value = this._touchExpr(attr.value === undefined? true: attr.value); + if(value.constant) value = attr.value = value.get(this); + if(attr.value && attr.value.constant === true){ + value = value.get(this); + } + var name = attr.name; + if(!attr.event){ + var etest = name.match(eventReg); + // event: 'nav' + if(etest) attr.event = etest[1]; + } - var component = new Component(config); - if(ref && self.$refs) self.$refs[ref] = component; - for(var i = 0, len = attrs.length; i < len; i++){ - var attr = attrs[i]; - var value = attr.value||true; - var name = attr.name; - if(value.type === 'expression' && !attr.event){ - value = self._touchExpr(value); - // use bit operate to control scope - if( !(isolate & 2) ) - this.$watch(value, component.$update.bind(component, name)) - if( value.set && !(isolate & 1 ) ) - // sync the data. it force the component don't trigger attr.name's first dirty echeck - component.$watch(name, self.$update.bind(self, value), {sync: true}); - } - } + // @compile modifier + if(attr.mdf === 'cmpl'){ + value = _.getCompileFn(value, this, { + record: true, + namespace:namespace, + extra: extra, + outer: options.outer + }) + } + + // @if is r-component . we need to find the target Component + if(name === 'is' && !Component){ + is = value; + var componentName = this.$get(value, true); + Component = Constructor.component(componentName) + if(typeof Component !== 'function') throw new Error("component " + componentName + " has not registed!"); + } + // bind event proxy + var eventName; + if(eventName = attr.event){ + events = events || {}; + events[eventName] = _.handleEvent.call(this, value, eventName); + continue; + }else { + name = attr.name = _.camelCase(name); + } + + if(value.type !== 'expression'){ + data[name] = value; + }else{ + data[name] = value.get(self); + } + if( name === 'ref' && value != null){ + ref = value + } + if( name === 'isolate'){ + // 1: stop: composite -> parent + // 2. stop: composite <- parent + // 3. stop 1 and 2: composite <-> parent + // 0. stop nothing (defualt) + isolate = value.type === 'expression'? value.get(self): parseInt(value === true? 3: value, 10); + data.isolate = isolate; + } + } + + var definition = { + data: data, + events: events, + $parent: this, + $root: this.$root, + $outer: options.outer, + _body: ast.children + } + var options = { + namespace: namespace, + extra: options.extra + } + + + var component = new Component(definition, options), reflink; + + + if(ref && this.$refs){ + reflink = Component.directive('ref').link + this.$on('$destroy', reflink.call(this, component, ref) ) + } + if(ref && self.$refs) self.$refs[ref] = component; + for(var i = 0, len = attrs.length; i < len; i++){ + var attr = attrs[i]; + var value = attr.value||true; + var name = attr.name; + // need compiled + if(value.type === 'expression' && !attr.event){ + value = self._touchExpr(value); + // use bit operate to control scope + if( !(isolate & 2) ) + this.$watch(value, component.$update.bind(component, name)) + if( value.set && !(isolate & 1 ) ) + // sync the data. it force the component don't trigger attr.name's first dirty echeck + component.$watch(name, self.$update.bind(self, value), {sync: true}); + } + } + if(is && is.type === 'expression' ){ + var group = new Group(); + group.push(component); + this.$watch(is, function(value){ + // found the new component + var Component = Constructor.component(value); + if(!Component) throw new Error("component " + value + " has not registed!"); + var ncomponent = new Component(definition); + var component = group.children.pop(); + group.push(ncomponent); + ncomponent.$inject(combine.last(component), 'after') + component.destroy(); + // @TODO if component changed , we need update ref if(ref){ - component.$on('destroy', function(){ - if(self.$refs) self.$refs[ref] = null; - }) + self.$refs[ref] = ncomponent; } - if(is && is.type === 'expression' ){ - var group = new Group(); - group.push(component); - this.$watch(is, function(value){ - // found the new component - var Component = Constructor.component(value); - if(!Component) throw new Error("component " + value + " has not registed!"); - var ncomponent = new Component(config); - var component = group.children.pop(); - group.push(ncomponent); - ncomponent.$inject(combine.last(component), 'after') - component.destroy(); - if(ref){ - self.$refs[ref] = ncomponent; - } - }, {sync: true}) - return group; - } - return component; + }, {sync: true}) + return group; + } + return component; } function walkAttributes(attrs, element, extra){ diff --git a/test/regular.js b/test/regular.js index 8221f12..4d3abfe 100644 --- a/test/regular.js +++ b/test/regular.js @@ -235,20 +235,22 @@ var doc = dom.doc; * @constructor * @param {Object} options specification of the component */ -var Regular = function(options){ +var Regular = function(definition, options){ var prevRunning = env.isRunning; env.isRunning = true; var node, template; + definition = definition || {}; options = options || {}; - options.data = options.data || {}; - options.computed = options.computed || {}; - options.events = options.events || {}; - if(this.data) _.extend(options.data, this.data); - if(this.computed) _.extend(options.computed, this.computed); - if(this.events) _.extend(options.events, this.events); - - _.extend(this, options, true); + + definition.data = definition.data || {}; + definition.computed = definition.computed || {}; + definition.events = definition.events || {}; + if(this.data) _.extend(definition.data, this.data); + if(this.computed) _.extend(definition.computed, this.computed); + if(this.events) _.extend(definition.events, this.events); + + _.extend(this, definition, true); if(this.$parent){ this.$parent._append(this); } @@ -271,14 +273,17 @@ var Regular = function(options){ if(this.events){ this.$on(this.events); } - // if(this.$body){ - this._getTransclude = function(transclude){ - var ctx = this.$parent || this; - if( transclude || this.$body ) return ctx.$compile(transclude || this.$body, {namespace: options.namespace, outer: this, extra: options.extra}) - } - // } this.$emit("$config"); this.config && this.config(this.data); + if(this._body && this._body.length){ + this.$body = _.getCompileFn(this._body, this.$parent, { + outer: this, + namespace: options.namespace, + extra: options.extra, + record: true + }) + this._body = null; + } // handle computed if(template){ this.group = this.$compile(this.template, {namespace: options.namespace}); @@ -667,7 +672,7 @@ Regular.implement({ _f_: function(name){ var Component = this.constructor; var filter = Component.filter(name); - if(!filter) throw 'filter ' + name + ' is undefined'; + if(!filter) throw Error('filter ' + name + ' is undefined'); return filter; }, // simple accessor get @@ -729,7 +734,6 @@ Regular.prototype.inject = function(){ } - // only one builtin filter Regular.filter(filter); @@ -782,7 +786,7 @@ var handleComputed = (function(){ }); require.register("regularjs/src/util.js", function(exports, require, module){ -require('./helper/shim.js'); +require('./helper/shim.js')(); var _ = module.exports; var entities = require('./helper/entities.js'); var slice = [].slice; @@ -798,6 +802,31 @@ _.uid = (function(){ } })(); +_.extend = function( o1, o2, override ){ + // if(_.typeOf(override) === 'array'){ + // for(var i = 0, len = override.length; i < len; i++ ){ + // var key = override[i]; + // o1[key] = o2[key]; + // } + // }else{ + for(var i in o2){ + if( typeof o1[i] === "undefined" || override === true ){ + o1[i] = o2[i] + } + } + // } + return o1; +} + +_.keys = function(obj){ + if(Object.keys) return Object.keys(obj); + var res = []; + for(var i in obj) if(obj.hasOwnProperty(i)){ + res.push(i); + } + return res; +} + _.varName = 'd'; _.setName = 'p_'; _.ctxName = 'c'; @@ -830,26 +859,6 @@ _.typeOf = function (o) { return o == null ? String(o) :o2str.call(o).slice(8, -1).toLowerCase(); } -_.isExpression = function( expr ){ - return expr && expr.type === 'expression'; -} - - -_.extend = function( o1, o2, override ){ - if(_.typeOf(override) === 'array'){ - for(var i = 0, len = override.length; i < len; i++ ){ - var key = override[i]; - o1[key] = o2[key]; - } - }else{ - for(var i in o2){ - if( typeof o1[i] === "undefined" || override === true ){ - o1[i] = o2[i] - } - } - } - return o1; -} _.makePredicate = function makePredicate(words, prefix) { if (typeof words === "string") { @@ -969,7 +978,7 @@ _.escapeRegExp = function( str){// Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Le }; -var rEntity = new RegExp("&(" + Object.keys(entities).join('|') + ');', 'gi'); +var rEntity = new RegExp("&(" + _.keys(entities).join('|') + ');', 'gi'); _.convertEntity = function(chr){ @@ -1164,12 +1173,12 @@ _.fixObjStr = function(str){ _.log = function(msg, type){ - return "" if(typeof console !== "undefined") console[type || "log"](msg); } + //http://www.w3.org/html/wg/drafts/html/master/single-page.html#void-elements _.isVoidTag = _.makePredicate("area base br col embed hr img input keygen link menuitem meta param source track wbr r-content"); _.isBooleanAttr = _.makePredicate('selected checked disabled readOnly required open autofocus controls autoplay compact loop defer multiple'); @@ -1180,12 +1189,17 @@ _.isTrue - function(){return true} _.isExpr = function(expr){ return expr && expr.type === 'expression'; } +// @TODO: make it more strict +_.isGroup = function(group){ + return group.inject || group.$inject; +} -_.assert = function(test, msg){ - if(!test) throw msg; +_.getCompileFn = function(source, ctx, options){ + return ctx.$compile.bind(ctx,source, options) } + }); require.register("regularjs/src/walkers.js", function(exports, require, module){ var diffArray = require('./helper/arrayDiff.js'); @@ -1261,14 +1275,18 @@ walkers.list = function(ast, options){ } function updateLD(newValue, oldValue, splices){ - if(!newValue) { - newValue = []; + if(!oldValue) oldValue = []; + if(!newValue) newValue = []; + + + var cur = placeholder; + var m = 0, len = newValue.length; + + if(!splices && (len !==0 || oldValue.length !==0) ){ splices = diffArray(newValue, oldValue); } - + if(!splices || !splices.length) return; - var cur = placeholder; - var m = 0, len = newValue.length; for(var i = 0; i < splices.length; i++){ //init var splice = splices[i]; @@ -1368,12 +1386,16 @@ walkers.template = function(ast, options){ if(content){ var self = this; this.$watch(content, function(value){ - if( compiled = group.get(1)){ - compiled.destroy(true); + var removed = group.get(1), type= typeof value; + if( removed){ + removed.destroy(true); group.children.pop(); } - group.push( compiled = self.$compile(value, {record: true, outer: options.outer,namespace: namespace, extra: extra}) ); - if(placeholder.parentNode) animate.inject(combine.node(compiled), placeholder, 'before') + if(!value) return; + group.push( compiled = (typeof value === 'function') ? value(): self.$compile(value, {record: true, outer: options.outer,namespace: namespace, extra: extra}) ); + if(placeholder.parentNode) { + compiled.$inject(placeholder, 'before') + } }, { init: true }); @@ -1461,7 +1483,6 @@ walkers.text = function(ast, options){ var eventReg = /^on-(.+)$/ - /** * walkers element (contains component) */ @@ -1475,8 +1496,9 @@ walkers.element = function(ast, options){ Component = Constructor.component(tag), ref, group, element; - if( tag === 'r-content' && this._getTransclude ){ - return this._getTransclude(); + if( tag === 'r-content' ){ + _.log('r-content is deprecated, use {#inc this.$body} instead (`{#include}` as same)', 'error'); + return this.$body && this.$body(); } if(Component || tag === 'r-component'){ @@ -1548,109 +1570,130 @@ walkers.component = function(ast, options){ var attrs = ast.attrs, Component = options.Component, Constructor = this.constructor, - isolate, namespace = options.namespace, + isolate, + extra = options.extra, + namespace = options.namespace, ref, self = this, is; - var data = {}, events; - for(var i = 0, len = attrs.length; i < len; i++){ - var attr = attrs[i]; - // consider disabled equlasto disabled={true} - var value = this._touchExpr(attr.value===undefined? true: attr.value); - if(value.constant) value = attr.value = value.get(this); - if(attr.value && attr.value.constant === true){ - value = value.get(this); - } - var name = attr.name; - if(!attr.event){ - var etest = name.match(eventReg); - // event: 'nav' - if(etest) attr.event = etest[1]; - } - - // @if is r-component . we need to find the target Component - if(name === 'is' && !Component){ - is = value; - var componentName = this.$get(value, true); - Component = Constructor.component(componentName) - if(typeof Component !== 'function') throw new Error("component " + componentName + " has not registed!"); - } - // bind event proxy - var eventName; - if(eventName = attr.event){ - events = events || {}; - events[eventName] = _.handleEvent.call(this, value, eventName); - continue; - }else { - name = attr.name = _.camelCase(name); - } - if(value.type !== 'expression'){ - data[name] = value; - }else{ - data[name] = value.get(self); - } - if( name === 'ref' && value != null){ - ref = value.type === 'expression'? value.get(self): value; - } - if( name === 'isolate'){ - // 1: stop: composite -> parent - // 2. stop: composite <- parent - // 3. stop 1 and 2: composite <-> parent - // 0. stop nothing (defualt) - isolate = value.type === 'expression'? value.get(self): parseInt(value === true? 3: value, 10); - data.isolate = isolate; - } - } + var data = {}, events; - var config = { - data: data, - events: events, - $parent: this, - $outer: options.outer, - namespace: namespace, - $root: this.$root, - $body: ast.children - } + for(var i = 0, len = attrs.length; i < len; i++){ + var attr = attrs[i]; + // consider disabled equlasto disabled={true} + var value = this._touchExpr(attr.value === undefined? true: attr.value); + if(value.constant) value = attr.value = value.get(this); + if(attr.value && attr.value.constant === true){ + value = value.get(this); + } + var name = attr.name; + if(!attr.event){ + var etest = name.match(eventReg); + // event: 'nav' + if(etest) attr.event = etest[1]; + } + + // @compile modifier + if(attr.mdf === 'cmpl'){ + value = _.getCompileFn(value, this, { + record: true, + namespace:namespace, + extra: extra, + outer: options.outer + }) + } + + // @if is r-component . we need to find the target Component + if(name === 'is' && !Component){ + is = value; + var componentName = this.$get(value, true); + Component = Constructor.component(componentName) + if(typeof Component !== 'function') throw new Error("component " + componentName + " has not registed!"); + } + // bind event proxy + var eventName; + if(eventName = attr.event){ + events = events || {}; + events[eventName] = _.handleEvent.call(this, value, eventName); + continue; + }else { + name = attr.name = _.camelCase(name); + } - var component = new Component(config); - if(ref && self.$refs) self.$refs[ref] = component; - for(var i = 0, len = attrs.length; i < len; i++){ - var attr = attrs[i]; - var value = attr.value||true; - var name = attr.name; - if(value.type === 'expression' && !attr.event){ - value = self._touchExpr(value); - // use bit operate to control scope - if( !(isolate & 2) ) - this.$watch(value, component.$update.bind(component, name)) - if( value.set && !(isolate & 1 ) ) - // sync the data. it force the component don't trigger attr.name's first dirty echeck - component.$watch(name, self.$update.bind(self, value), {sync: true}); - } - } + if(value.type !== 'expression'){ + data[name] = value; + }else{ + data[name] = value.get(self); + } + if( name === 'ref' && value != null){ + ref = value + } + if( name === 'isolate'){ + // 1: stop: composite -> parent + // 2. stop: composite <- parent + // 3. stop 1 and 2: composite <-> parent + // 0. stop nothing (defualt) + isolate = value.type === 'expression'? value.get(self): parseInt(value === true? 3: value, 10); + data.isolate = isolate; + } + } + + var definition = { + data: data, + events: events, + $parent: this, + $root: this.$root, + $outer: options.outer, + _body: ast.children + } + var options = { + namespace: namespace, + extra: options.extra + } + + + var component = new Component(definition, options), reflink; + + + if(ref && this.$refs){ + reflink = Component.directive('ref').link + this.$on('$destroy', reflink.call(this, component, ref) ) + } + if(ref && self.$refs) self.$refs[ref] = component; + for(var i = 0, len = attrs.length; i < len; i++){ + var attr = attrs[i]; + var value = attr.value||true; + var name = attr.name; + // need compiled + if(value.type === 'expression' && !attr.event){ + value = self._touchExpr(value); + // use bit operate to control scope + if( !(isolate & 2) ) + this.$watch(value, component.$update.bind(component, name)) + if( value.set && !(isolate & 1 ) ) + // sync the data. it force the component don't trigger attr.name's first dirty echeck + component.$watch(name, self.$update.bind(self, value), {sync: true}); + } + } + if(is && is.type === 'expression' ){ + var group = new Group(); + group.push(component); + this.$watch(is, function(value){ + // found the new component + var Component = Constructor.component(value); + if(!Component) throw new Error("component " + value + " has not registed!"); + var ncomponent = new Component(definition); + var component = group.children.pop(); + group.push(ncomponent); + ncomponent.$inject(combine.last(component), 'after') + component.destroy(); + // @TODO if component changed , we need update ref if(ref){ - component.$on('destroy', function(){ - if(self.$refs) self.$refs[ref] = null; - }) + self.$refs[ref] = ncomponent; } - if(is && is.type === 'expression' ){ - var group = new Group(); - group.push(component); - this.$watch(is, function(value){ - // found the new component - var Component = Constructor.component(value); - if(!Component) throw new Error("component " + value + " has not registed!"); - var ncomponent = new Component(config); - var component = group.children.pop(); - group.push(ncomponent); - ncomponent.$inject(combine.last(component), 'after') - component.destroy(); - if(ref){ - self.$refs[ref] = ncomponent; - } - }, {sync: true}) - return group; - } - return component; + }, {sync: true}) + return group; + } + return component; } function walkAttributes(attrs, element, extra){ @@ -1825,7 +1868,7 @@ dom.find = function(sl){ dom.inject = function(node, refer, position){ position = position || 'bottom'; - + if(!node) return ; if(Array.isArray(node)){ var tmp = node; node = dom.fragment(); @@ -2131,12 +2174,12 @@ dom.nextFrame = (function(){ // 3ks for angular's raf service var k; -dom.nextReflow = function(callback){ - dom.nextFrame(function(){ +dom.nextReflow = dom.msie? function(callback){ + return dom.nextFrame(function(){ k = document.body.offsetWidth; callback(); }) -} +}: dom.nextFrame; @@ -2151,7 +2194,7 @@ function Group(list){ } -_.extend(Group.prototype, { +var o = _.extend(Group.prototype, { destroy: function(first){ combine.destroy(this.children, first); if(this.ondestroy) this.ondestroy(); @@ -2162,9 +2205,9 @@ _.extend(Group.prototype, { }, push: function(item){ this.children.push( item ); - }, - inject: combine.inject + } }) +o.inject = o.$inject = combine.inject @@ -2260,7 +2303,7 @@ lo.lex = function(str){ } lo.error = function(msg){ - throw "Parse Error: " + msg + ':\n' + _.trackErrorPos(this.input, this.index); + throw Error("Parse Error: " + msg + ':\n' + _.trackErrorPos(this.input, this.index)); } lo._process = function(args, split,str){ @@ -2550,11 +2593,12 @@ module.exports = { children: children } }, - attribute: function(name, value){ + attribute: function(name, value, mdf){ return { type: 'attribute', name: name, - value: value + value: value, + mdf: mdf } }, "if": function(test, consequent, alternate){ @@ -2752,10 +2796,17 @@ op.xml = function(){ // {{#if name}}on-click={{xx}}{{#else}}on-tap={{}}{{/if}} op.xentity = function(ll){ - var name = ll.value, value; + var name = ll.value, value, modifier; if(ll.type === 'NAME'){ - if( this.eat("=") ) value = this.attvalue(); - return node.attribute( name, value ); + //@ only for test + if(~name.indexOf('.')){ + var tmp = name.split('.'); + name = tmp[0]; + modifier = tmp[1] + + } + if( this.eat("=") ) value = this.attvalue(modifier); + return node.attribute( name, value, modifier ); }else{ if( name !== 'if') this.error("current version. ONLY RULE #if #else #elseif is valid in tag, the rule #" + name + ' is invalid'); return this['if'](true); @@ -2783,7 +2834,7 @@ op.attrs = function(isAttribute){ // attvalue // : STRING // | NAME -op.attvalue = function(){ +op.attvalue = function(mdf){ var ll = this.ll(); switch(ll.type){ case "NAME": @@ -2791,7 +2842,7 @@ op.attvalue = function(){ case "STRING": this.next(); var value = ll.value; - if(~value.indexOf(config.BEGIN) && ~value.indexOf(config.END)){ + if(~value.indexOf(config.BEGIN) && ~value.indexOf(config.END) && mdf!=='cmpl'){ var constant = true; var parsed = new Parser(value, { mode: 2 }).parse(); if(parsed.length === 1 && parsed[0].type === 'expression') return parsed[0]; @@ -3411,82 +3462,69 @@ function extend(o1, o2 ){ for(var i in o2) if( o1[i] === undefined){ o1[i] = o2[i] } + return o2; } -// String proto ; -extend(String.prototype, { - trim: function(){ - return this.replace(/^\s+|\s+$/g, ''); - } -}); +module.exports = function(){ + // String proto ; + extend(String.prototype, { + trim: function(){ + return this.replace(/^\s+|\s+$/g, ''); + } + }); -// Array proto; -extend(Array.prototype, { - indexOf: function(obj, from){ - from = from || 0; - for (var i = from, len = this.length; i < len; i++) { - if (this[i] === obj) return i; - } - return -1; - }, - forEach: function(callback, context){ - for (var i = 0, len = this.length; i < len; i++) { - callback.call(context, this[i], i, this); - } - }, - filter: function(callback, context){ - var res = []; - for (var i = 0, length = this.length; i < length; i++) { - var pass = callback.call(context, this[i], i, this); - if(pass) res.push(this[i]); - } - return res; - }, - map: function(callback, context){ - var res = []; - for (var i = 0, length = this.length; i < length; i++) { - res.push(callback.call(context, this[i], i, this)); + // Array proto; + extend(Array.prototype, { + indexOf: function(obj, from){ + from = from || 0; + for (var i = from, len = this.length; i < len; i++) { + if (this[i] === obj) return i; + } + return -1; + }, + forEach: function(callback, context){ + for (var i = 0, len = this.length; i < len; i++) { + callback.call(context, this[i], i, this); + } + }, + filter: function(callback, context){ + var res = []; + for (var i = 0, length = this.length; i < length; i++) { + var pass = callback.call(context, this[i], i, this); + if(pass) res.push(this[i]); + } + return res; + }, + map: function(callback, context){ + var res = []; + for (var i = 0, length = this.length; i < length; i++) { + res.push(callback.call(context, this[i], i, this)); + } + return res; } - return res; - } -}); + }); -// Function proto; -extend(Function.prototype, { - bind: function(context){ - var fn = this; - var preArgs = slice.call(arguments, 1); - return function(){ - var args = preArgs.concat(slice.call(arguments)); - return fn.apply(context, args); + // Function proto; + extend(Function.prototype, { + bind: function(context){ + var fn = this; + var preArgs = slice.call(arguments, 1); + return function(){ + var args = preArgs.concat(slice.call(arguments)); + return fn.apply(context, args); + } } - } -}) - -// Object -extend(Object, { - keys: function(obj){ - var keys = []; - for(var i in obj) if(obj.hasOwnProperty(i)){ - keys.push(i); + }) + + // Array + extend(Array, { + isArray: function(arr){ + return tstr.call(arr) === "[object Array]"; } - return keys; - } -}) + }) +} -// Date -extend(Date, { - now: function(){ - return +new Date; - } -}) -// Array -extend(Array, { - isArray: function(arr){ - return tstr.call(arr) === "[object Array]"; - } -}) }); require.register("regularjs/src/helper/parse.js", function(exports, require, module){ @@ -3613,7 +3651,7 @@ var methods = { while(dirty = this._digest()){ if((++n) > 20){ // max loop - throw 'there may a circular dependencies reaches' + throw Error('there may a circular dependencies reaches') } } if( n > 0 && this.$emit) this.$emit("$update"); @@ -3636,7 +3674,7 @@ var methods = { children = this._children; if(children && children.length){ for(var m = 0, mlen = children.length; m < mlen; m++){ - if(children[m]._digest()) dirty = true; + if(children[m] && children[m]._digest()) dirty = true; } } return dirty; @@ -3771,72 +3809,70 @@ require.register("regularjs/src/helper/event.js", function(exports, require, mod // =============================== var slice = [].slice, _ = require("../util.js"); var API = { - $on: function(event, fn) { - if(typeof event === "object"){ - for (var i in event) { - this.$on(i, event[i]); - } - }else{ - // @patch: for list - var context = this; - var handles = context._handles || (context._handles = {}), - calls = handles[event] || (handles[event] = []); - calls.push(fn); - } - return this; - }, - $off: function(event, fn) { - var context = this; - if(!context._handles) return; - if(!event) this._handles = {}; - var handles = context._handles, - calls; - - if (calls = handles[event]) { - if (!fn) { - handles[event] = []; - return context; - } - for (var i = 0, len = calls.length; i < len; i++) { - if (fn === calls[i]) { - calls.splice(i, 1); - return context; - } - } - } + $on: function(event, fn) { + if(typeof event === "object"){ + for (var i in event) { + this.$on(i, event[i]); + } + }else{ + // @patch: for list + var context = this; + var handles = context._handles || (context._handles = {}), + calls = handles[event] || (handles[event] = []); + calls.push(fn); + } + return this; + }, + $off: function(event, fn) { + var context = this; + if(!context._handles) return; + if(!event) this._handles = {}; + var handles = context._handles, + calls; + + if (calls = handles[event]) { + if (!fn) { + handles[event] = []; return context; - }, - // bubble event - $emit: function(event){ - // @patch: for list - var context = this; - var handles = context._handles, calls, args, type; - if(!event) return; - var args = slice.call(arguments, 1); - var type = event; - - if(!handles) return context; - if(calls = handles[type.slice(1)]){ - for (var j = 0, len = calls.length; j < len; j++) { - calls[j].apply(context, args) - } - } - if (!(calls = handles[type])) return context; - for (var i = 0, len = calls.length; i < len; i++) { - calls[i].apply(context, args) + } + for (var i = 0, len = calls.length; i < len; i++) { + if (fn === calls[i]) { + calls.splice(i, 1); + return context; } - // if(calls.length) context.$update(); - return context; - }, - // capture event - $broadcast: function(){ - + } } + return context; + }, + // bubble event + $emit: function(event){ + // @patch: for list + var context = this; + var handles = context._handles, calls, args, type; + if(!event) return; + var args = slice.call(arguments, 1); + var type = event; + + if(!handles) return context; + if(calls = handles[type.slice(1)]){ + for (var j = 0, len = calls.length; j < len; j++) { + calls[j].apply(context, args) + } + } + if (!(calls = handles[type])) return context; + for (var i = 0, len = calls.length; i < len; i++) { + calls[i].apply(context, args) + } + // if(calls.length) context.$update(); + return context; + }, + // capture event + $one: function(){ + } -// container class -function Event() { - if (arguments.length) this.$on.apply(this, arguments); } +// container class +function Event() {} _.extend(Event.prototype, API) Event.mixTo = function(obj){ @@ -3932,6 +3968,18 @@ animate.inject = function( node, refer ,direction, callback ){ * @return {[type]} [description] */ animate.remove = function(node, callback){ + if(!node) throw new Error('node to be removed is undefined') + var count = 0; + function loop(){ + count++; + if(count === len) callback && callback() + } + if(Array.isArray(node)){ + for(var i = 0, len = node.length; i < len ; i++){ + animate.remove(node[i], loop) + } + return node; + } if(node.onleave){ node.onleave(function(){ removeDone(node, callback) @@ -3954,21 +4002,28 @@ animate.startClassAnimate = function ( node, className, callback, mode ){ return callback(); } - onceAnim = _.once(function onAnimateEnd(){ - if(tid) clearTimeout(tid); + if(mode !== 4){ + onceAnim = _.once(function onAnimateEnd(){ + if(tid) clearTimeout(tid); - if(mode === 2) { - dom.delClass(node, activeClassName); - } - if(mode !== 3){ // mode hold the class - dom.delClass(node, className); - } - dom.off(node, animationEnd, onceAnim) - dom.off(node, transitionEnd, onceAnim) + if(mode === 2) { + dom.delClass(node, activeClassName); + } + if(mode !== 3){ // mode hold the class + dom.delClass(node, className); + } + dom.off(node, animationEnd, onceAnim) + dom.off(node, transitionEnd, onceAnim) - callback(); + callback(); - }); + }); + }else{ + onceAnim = _.once(function onAnimateEnd(){ + if(tid) clearTimeout(tid); + callback(); + }); + } if(mode === 2){ // auto removed dom.addClass( node, className ); @@ -3982,17 +4037,23 @@ animate.startClassAnimate = function ( node, className, callback, mode ){ tid = setTimeout( onceAnim, timeout ); }); - }else{ + }else if(mode===4){ + dom.nextReflow(function(){ + dom.delClass( node, className ); + timeout = getMaxTimeout( node ); + tid = setTimeout( onceAnim, timeout ); + }); + }else{ dom.nextReflow(function(){ dom.addClass( node, className ); timeout = getMaxTimeout( node ); tid = setTimeout( onceAnim, timeout ); }); - } + dom.on( node, animationEnd, onceAnim ) dom.on( node, transitionEnd, onceAnim ) return onceAnim; @@ -4076,12 +4137,14 @@ require.register("regularjs/src/helper/combine.js", function(exports, require, m // -------------------------------- var dom = require("../dom.js"); +var animate = require("./animate.js"); var combine = module.exports = { // get the initial dom in object node: function(item){ var children,node, nodes; + if(!item) return; if(item.element) return item.element; if(typeof item.node === "function") return item.node(); if(typeof item.nodeType === "number") return item; @@ -4102,24 +4165,25 @@ var combine = module.exports = { return nodes; } }, - inject: function(node, pos, group ){ - if(!group) group = this; + // @TODO remove _gragContainer + inject: function(node, pos ){ + var group = this; + var fragment = combine.node(group.group || group); if(node === false) { - if(!group._fragContainer) group._fragContainer = dom.fragment(); - return combine.inject( group._fragContainer, pos, group); + animate.remove(fragment) + return group; + }else{ + if(!fragment) return group; + if(typeof node === 'string') node = dom.find(node); + if(!node) throw Error('injected node is not found'); + // use animate to animate firstchildren + animate.inject(fragment, node, pos); } - var fragment = combine.node(group.group || group); - if(!fragment) return group; - if(typeof node === 'string') node = dom.find(node); - if(!node) throw 'injected node is not found'; - dom.inject(fragment, node, pos); // if it is a component if(group.$emit) { group.$emit("$inject", node, pos); group.parentNode = (pos ==='after' || pos === 'before')? node.parentNode : node; } - - return group; }, @@ -4798,7 +4862,7 @@ function initText(elem, parsed){ }); // @TODO to fixed event - var handler = function handler(ev){ + var handler = function (ev){ var that = this; if(ev.type==='cut' || ev.type==='paste'){ _.nextTick(function(){ @@ -4826,7 +4890,7 @@ function initText(elem, parsed){ if(parsed.get(self) === undefined && elem.value){ parsed.set(self, elem.value); } - return function destroy(){ + return function (){ if(dom.msie !== 9 && "oninput" in dom.tNode ){ elem.removeEventListener("input", handler ); }else{ @@ -4997,7 +5061,7 @@ Regular.animation({ evt = tmp[0] || "", args = tmp[1]? this.$expression(tmp[1]).get: null; - if(!evt) throw "you shoud specified a eventname in emit command"; + if(!evt) throw Error("you shoud specified a eventname in emit command"); var self = this; return function(done){ @@ -5017,7 +5081,7 @@ Regular.animation({ name = tmp.shift(), value = tmp.join(" "); - if( !name || !value ) throw "invalid style in command: style"; + if( !name || !value ) throw Error("invalid style in command: style"); styles[name] = value; valid = true; } @@ -5039,6 +5103,7 @@ Regular.animation({ // el : the element to process // value: the directive value function processAnimate( element, value ){ + var Component = this.constructor; value = value.trim(); var composites = value.split(";"), @@ -5095,7 +5160,7 @@ function processAnimate( element, value ){ continue } - var animator = Regular.animation(command) + var animator = Component.animation(command) if( animator && seed ){ seed.push( animator.call(this,{ @@ -5105,7 +5170,7 @@ function processAnimate( element, value ){ }) ) }else{ - throw "you need start with `on` or `event` in r-animation"; + throw Error( animator? "you should start with `on` or `event` in animation" : ("undefined animator 【" + command +"】" )); } } @@ -5120,7 +5185,7 @@ function processAnimate( element, value ){ Regular.directive( "r-animation", processAnimate) -Regular.directive( "r-sequence", processAnimate) +Regular.directive( "r-anim", processAnimate) }); diff --git a/test/spec/browser-animate.js b/test/spec/browser-animate.js index 703d0c0..20cbac5 100644 --- a/test/spec/browser-animate.js +++ b/test/spec/browser-animate.js @@ -23,6 +23,7 @@ void function(){ var Component = Regular.extend(); describe("helper.animate ", function(){ var container = document.createElement("div"); + var processAnimate = Regular.directive("r-animation"); before(function(){ document.body.appendChild( container ); }); @@ -30,41 +31,101 @@ void function(){ document.body.removeChild( container ); }); - // it("animation can triggered by event", function(done){ - // var component = new Regular({ - // template: "
" - // }).$inject(container); - - - // var node = nes.one('div', container) - - // dispatchMockEvent(nes.one('div', container), 'click'); - - // Regular.dom.nextReflow(function(){ - - // expect(node.className ).to.equal("animated"); - - // Regular.dom.nextReflow(function(){ + it("animate.inject is async when on:enter is specified", function(done){ + var div1 =document.createElement("div"); + var div2 =document.createElement("div"); + var component = new Component; + processAnimate.link.call(component, div1, "on: enter; class: anim"); - // expect(node.className ).to.equal(""); + // to judge async or sync + var a = 1; + animate.inject(div1, div2, 'bottom', function(){ + a = 2; + expect(div2.getElementsByTagName("div")[0]).to.equal(div1); + dom.nextReflow(function(){done()}) + }) + expect(a).to.equal(1) - // destroy(component, container); - // done(); - // }) - // }) + }) + it("animate.inject is async without on:enter", function(done){ - it("animate.inject", function(done){ var div1 =document.createElement("div"); var div2 =document.createElement("div"); + var component = new Component; + processAnimate.link.call(component, div1, "on: click; class: anim"); + var a = 1; animate.inject(div1, div2, 'bottom', function(){ + a = 2; expect(div2.getElementsByTagName("div")[0]).to.equal(div1); - done() + dom.nextReflow(function(){done()}) }) + expect(a).to.equal(2) }) + it("animate.inject accept [Array]", function(done){ - it("animate.inject%animate.remove with callback", function(done){ + var div1 =document.createElement("div"); + var div2 =document.createElement("div"); + var component = new Component; + processAnimate.link.call(component, div1, "on: click; class: anim"); + var a = 1; + animate.inject([div1, div2], container, 'bottom', function(){ + a = 2; + expect(container.getElementsByTagName("div")[1]).to.equal(div2); + container.innerHTML = ""; + dom.nextReflow(function(){done()}) + }) + expect(a).to.equal(2) + }) + + it("animate.remove accept Array", function(done){ + var div1 =document.createElement("div"); + var div2 =document.createElement("div"); + animate.inject([div1, div2], container) + + var divs = container.getElementsByTagName("div"); + expect(divs.length).to.equal(2); + animate.remove([div1, div2], function(){ + var divs = container.getElementsByTagName("div"); + expect(divs.length).to.equal(0); + dom.nextReflow(function(){done()}) + }) + }) + it("animate.remove is sync without on:leave ", function(done){ + var div1 =document.createElement("div"); + var div2 =document.createElement("div"); + var component = new Component; + processAnimate.link.call(component, div1, "on: enter; class: anim"); + dom.inject(div1, div2); + expect(div2.firstChild).to.equal(div1); + var a = 1; + animate.remove(div1, function(){ + a = 2; + expect(div2.firstChild).to.be.an.undefined; + dom.nextReflow(function(){done()}) + }) + expect(a).to.equal(2); + + }) + it("animate.remove is async without on:leave ", function(done){ + var div1 =document.createElement("div"); + var div2 =document.createElement("div"); + var component = new Component; + processAnimate.link.call(component, div1, "on: leave; class: anim"); + dom.inject([div1, div2], container); + expect(container.childNodes.length).to.equal(2); + var a = 1; + animate.remove([div1, div2], function(){ + a = 2; + expect(container.childNodes.length).to.equal(0); + dom.nextReflow(function(){done()}) + }) + expect(a).to.equal(1); + + }) + + it("animate.inject&animate.remove with callback", function(done){ var div1 =document.createElement("div"); var div2 =document.createElement("div"); var enter = false; @@ -72,7 +133,6 @@ void function(){ enter = true cb() } - animate.inject(div1, div2, 'bottom', function(){ expect(div2.getElementsByTagName("div")[0]).to.equal(div1); div1.enter = true; @@ -118,6 +178,16 @@ void function(){ // will add nextFlow expect(dom.hasClass(div1, 'bouceOut')).to.equal(false) }) + it("animate.startClass with no transition in mode 4", function(done){ + var div = document.createElement("div"); + div.className = "bouceOut in" + animate.startClassAnimate(div, 'bouceOut', function(){ + expect(div.className).to.equal('in'); + done() + }, 4) + // will add nextFlow + expect(dom.hasClass(div, 'bouceOut')).to.equal(true) + }) it("animate.startStyle with no transition", function(done){ var div1 = document.createElement("div"); animate.startStyleAnimate(div1,{width: '10px',height:"10px"}, function(){ @@ -130,11 +200,6 @@ void function(){ expect(div1.style.height).to.not.equal("10px") }) - // it("animation.event should bind emit", function(done){ - // var component = new Component({ - // template: "
" - // }).$inject(container); - // }) }) describe("Animator", function(){ @@ -146,7 +211,7 @@ void function(){ after(function(){ document.body.removeChild( container ); }); - + it("animator: wait", function(done){ var wait = Regular.animation("wait"); var complete = false; @@ -207,6 +272,20 @@ void function(){ expect(element.className).to.equal("bouceOut animated"); }) }) + it("animator: class, 4", function(done){ + var element = document.createElement("div"); + var klass = Regular.animation("class"); + + element.className = "bouceOut animated hello"; + + klass({ + element: element, + param: "bouceOut animated,4"})(function(){ + expect(element.className).to.equal("hello"); + done(); + }) + expect(element.className).to.equal("bouceOut animated hello"); + }) it("animator: style", function(done){ var element = document.createElement("div"); var style = Regular.animation("style"); @@ -214,16 +293,12 @@ void function(){ element: element, param: "left 10px, right 20px" })(function(){ - done(); expect(element.style.left).to.equal("10px"); expect(element.style.right).to.equal("20px"); + done(); }) expect(element.style.left).to.equal(""); expect(element.style.right).to.equal(""); - dom.nextReflow(function(){ - expect(element.style.left).to.equal("10px"); - expect(element.style.right).to.equal("20px"); - }) }) it("animator: call", function(done){ var element = document.createElement("div"); @@ -314,6 +389,17 @@ void function(){ expect(dom.hasClass(element, 'animated')).to.equal(true); }) }) + it("undefined aniamtion should not throw error", function(done){ + var element = document.createElement("div"); + var component = new Component(); + var animator = function(){ } + Component.animation('hello', animator) + expect(Component.animation('hello')).to.equal(animator) + expect(function(){ + processAnimate.link.call(component, element, "on: enter; notfound:;"); + }).throwError() + done(); + }) }) }) diff --git a/test/spec/browser-api.js b/test/spec/browser-api.js index 3ffdee4..77edfdf 100644 --- a/test/spec/browser-api.js +++ b/test/spec/browser-api.js @@ -1,9 +1,44 @@ void function(){ - var Regular = require_lib("index.js") + var Regular = require_lib("index.js"); + var combine = require_lib("helper/combine.js"); function destroy(component, container){ component.destroy(); expect(container.innerHTML).to.equal(''); } + describe("combine api", function(){ + + var container; + before(function(){ + container = document.createElement("div"); + }) + after(function(){ + container = null; + }) + it("combine.inject can be used in group", function( done){ + var component = new Regular({ + data: {name: 'hello'} + }); + var group = component.$compile("
{name}
") + component.$update(); + group.inject(container) + expect(container.innerHTML.toLowerCase()).to.equal('
hello
') + group.destroy(true); + expect(container.innerHTML).to.equal('') + done() + }) + it("combine.inject can be pass false to remove group or component", function(){ + var component = new Regular({ + data: {name: 'hello'} + }); + var group = component.$compile("
{name}
") + component.$update(); + group.inject(container) + expect(container.innerHTML.toLowerCase()).to.equal('
hello
') + group.inject(false) + expect(container.innerHTML).to.equal(''); + group.destroy(true); + }) + }) describe("instance API", function(){ var container, container2; before(function(){ @@ -14,7 +49,7 @@ void function(){ container = null; container2 = null; }) - it("component.$inject should use twice", function(){ + it("component.$inject can use twice", function(){ var component = new Regular({ template:"{hello}
hello

name

" }).$inject(container); @@ -109,6 +144,27 @@ void function(){ container.innerHTML = ""; }) + it("component.$inject(false) remove component from document", function(){ + + var component = new Regular({ + template:"
hello

name

" + }).$inject(container); + + expect(container.childNodes.length).to.equal(2); + expect(container.childNodes[0].innerHTML).to.equal('hello'); + + component.$inject(false); + expect(container.innerHTML).to.equal(''); + destroy(component, container); + }) + it("directly inject component to false, won't throw Error", function(){ + + var component = new Regular({ + template:"
hello

name

" + }).$inject(false); + + }) + }) }() diff --git a/test/spec/browser-bugfix.js b/test/spec/browser-bugfix.js index 2ee3360..71d6f65 100644 --- a/test/spec/browser-bugfix.js +++ b/test/spec/browser-bugfix.js @@ -25,7 +25,6 @@ void function(){ it("bugfix #10, if svg namespace ", function(){ //https://github.com/regularjs/regular/issues/10 - if(Regular.env.svg){ // if support svg var Bugfix10 = Component.extend({ @@ -424,6 +423,50 @@ var template = (function(){/* // @TODO: }) + it('bugfix : #list null->undefined', function(){ + + // 必须加入 if 来触发single check + var Outer = Regular.extend({ + template: '
{#list list as item}
{item}
{/list}
', + config:function(data){ + data.list = null; + } + }) + + + var outer = new Outer({}).$inject(container); + + outer.$update('list', null); + outer.$update('list', undefined); + + expect(nes.all('div', outer.$refs.div).length).to.equal(0) + + outer.destroy(); + + }) + it('bugfix : #list [1]->null', function(){ + + // 必须加入 if 来触发single check + var Outer = Regular.extend({ + template: '
{#list list as item}
{item}
{/list}
', + config:function(data){ + data.list = null; + } + }) + + + var outer = new Outer({}).$inject(container); + + outer.$update('list', [1]); + expect(nes.all('div', outer.$refs.div).length).to.equal(1) + outer.$update('list', undefined); + + expect(nes.all('div', outer.$refs.div).length).to.equal(0) + + outer.destroy(); + + }) + }) diff --git a/test/spec/browser-directive.js b/test/spec/browser-directive.js index 8b891bb..a9c4688 100644 --- a/test/spec/browser-directive.js +++ b/test/spec/browser-directive.js @@ -664,6 +664,64 @@ describe("refs attribute", function(){ destroy(component, container); expect(component.$refs).to.equal(null); }) + it("ref updated when value update:[element]", function(){ + var component = new Component({ + template: "
{#list items as item}
{item}
{/list}", + data: { + name: "haha", + items: [1,2,3] + } + }) + + expect(component.$refs.haha.id).to.equal('100') + component.$update('name', 'hehe') + expect(component.$refs.hehe.id).to.equal('100') + expect(component.$refs.haha==null).to.true + + expect(component.$refs.hehe1.innerHTML).to.equal('1') + expect(component.$refs.hehe2.innerHTML).to.equal('2') + expect(component.$refs.hehe3.innerHTML).to.equal('3') + + component.$update('items', [2,3,4, 5]) + + expect(component.$refs.hehe2.innerHTML).to.equal('2') + expect(component.$refs.hehe3.innerHTML).to.equal('3') + expect(component.$refs.hehe4.innerHTML).to.equal('4') + expect(component.$refs.hehe5.innerHTML).to.equal('5') + + destroy(component, container); + }) + it("ref updated when value update:[component]", function(){ + + Component.extend({ + name: 'nested' + }) + var component = new Component({ + template: "{#list items as item}{/list}", + data: { + name: "haha", + items: [1,2,3] + } + }) + + expect(component.$refs.haha.data.id).to.equal('100') + component.$update('name', 'hehe') + expect(component.$refs.hehe.data.id).to.equal('100') + expect(component.$refs.haha==null).to.true + + expect(component.$refs.hehe1.data.value).to.equal(1) + expect(component.$refs.hehe2.data.value).to.equal(2) + expect(component.$refs.hehe3.data.value).to.equal(3) + + component.$update('items', [2,3,4, 5]) + + expect(component.$refs.hehe2.data.value).to.equal(2) + expect(component.$refs.hehe3.data.value).to.equal(3) + expect(component.$refs.hehe4.data.value).to.equal(4) + expect(component.$refs.hehe5.data.value).to.equal(5) + + destroy(component, container); + }) }) diff --git a/test/spec/browser-dom.js b/test/spec/browser-dom.js index d5c5e93..569d523 100644 --- a/test/spec/browser-dom.js +++ b/test/spec/browser-dom.js @@ -333,7 +333,7 @@ void function(){ it('delegate Event should work when the directive is linked after node being injected', function(){ var Nested = Regular.extend({ name: "nest", - template: "{#if show}
{/if}", + template: "{#if show}
{/if}" }) var component = new Component({ diff --git a/test/spec/browser-filter.js b/test/spec/browser-filter.js index b60a24e..7780406 100644 --- a/test/spec/browser-filter.js +++ b/test/spec/browser-filter.js @@ -23,7 +23,7 @@ Component.filter("format",function(value, format){ 'mm': function(date){ return fix(date.getMinutes())} } - var trunk = new RegExp(Object.keys(maps).join('|'),'g'); + var trunk = new RegExp(Regular.util.keys(maps).join('|'),'g'); return function(value, format){ @@ -184,6 +184,13 @@ function destroy(component, container){ var expr = Regular.expression("a+1|format") expect(expr.setbody).to.equal(false) }) + + it("undefined filter should throw error", function(){ + var component = new Regular(); + expect(function(){ + component.$set('tmp|undefinedfilter') + }).to.throwError(); + }) }) diff --git a/test/spec/browser-include.js b/test/spec/browser-include.js index 601fee9..55c566c 100644 --- a/test/spec/browser-include.js +++ b/test/spec/browser-include.js @@ -8,6 +8,7 @@ void function(){ } describe("Dynamic include", function(){ + var Component = Regular.extend(); it("#include should compile value at runtime correctly", function(){ var container = document.createElement('div'); var component = new Regular({ @@ -67,17 +68,152 @@ void function(){ }); var container = document.createElement('div'); var component = new Component({ - template: "{item_index}:{item}", + template: "{list.length}:{list[0]}", data: {list: ["hello", "name"]} }).$inject(container); var nodes = nes.all("span", container); expect(nodes.length).to.equal(2); - expect(nodes[1].innerHTML).to.equal("1:name"); + expect(nodes[0].innerHTML).to.equal("2:hello"); destroy(component, container) }) + it("include can pass anything that compiled to Group", function(){ + var Component = Regular.extend({}); + var container = Regular.dom.create('div'); + var Nested = Component.extend({ + name: 'nested', + template: '
{#inc hd}
{#inc this.$body}
{#inc ft}
', + config: function(data){ + data.head = 'InnerHEAD' + data.foot = 'InnerFoot' + } + }) + var component = new Component({ + template: '{foot}

"}>{head + foot}
', + data: {head: 'OuterHead', foot: 'OuterFoot'} + }).$inject(container); + + + + var head = nes.one('.head p', container); + var foot = nes.one('.foot p', container); + var body = nes.one('.body strong', container); + + expect(head.innerHTML).to.equal('OuterHead'); + expect(foot.innerHTML).to.equal('InnerFoot'); + expect(body.innerHTML).to.equal('OuterHeadOuterFoot'); + + component.$update('head', 'OuterUpdate'); + expect(head.innerHTML).to.equal('OuterUpdate'); + + + destroy(component, container) + }) + + it("group switch twice works as expect", function(){ + var container = Regular.dom.create('div'); + var Nested = Component.extend({ + name: 'nested', + template: '
{head}
', + config: function(data){ + data.head = 'InnerHEAD' + data.foot = 'InnerFoot' + } + }) + var component = new Component({ + template: '
{#inc body || this.$refs.nested.$body}
InnerBody', + data: {head: 'OuterHead'} + }).$inject(container); + + var body = nes.one('.body strong', container); + + expect(body.innerHTML).to.equal('InnerBody') + component.$update('body', 'OuterBody') + var body = nes.one('.body strong', container); + component.$update('body', null) + var body = nes.one('.body strong', container); + expect(body.innerHTML).to.equal('InnerBody') + + destroy(component, container) + }) + it("extra should pass to Component", function(){ + var container = Regular.dom.create('div'); + var Nested = Component.extend({ + name: 'nested', + template: '
{head}
', + config: function(data){ + data.head = 'InnerHEAD' + data.foot = 'InnerFoot' + } + }) + + var component = new Component({ + template: '
{#inc this.$refs.nested.$body}
{#list [1] as item}{item}{/list}' + }).$inject(container); + + var body = nes.one('.body strong', container); + + expect(body.innerHTML).to.equal('1') + destroy(component, container) + + }) + it("data.body is inner outer $body, if combine with {#inc body || this.$body} should not throw error during digest", function(){ + var container = Regular.dom.create('div'); + var Modal = Regular.extend({ + name: 'modal', + // if body is exsits , this.$body will be destroied + template: '
{#inc body || this.$body}
' + }) + + Modal.body = Regular.extend({ + name: 'modal.body', + + init: function(){ + // this.$outer point to modal + this.$outer.data['body'] = this.$body; + } + }) + + var component = new Regular({ + template: '

{name}

{#list [1] as item}{item}{/list}', + data: {name: 'hzzhenghaibo'} + }).$inject(container); + + var body = nes.one('.body p', container); + + expect(body.innerHTML).to.equal('hzzhenghaibo') + destroy(component, container) + + }) + // @REMOVE supoort for {#inc component} + // it("include can pass anything that compiled to Component", function(){ + // var Component = Regular.extend({}); + // var container = Regular.dom.create('div'); + // var Nested = Component.extend({ + // name: 'nested', + // template: '
Nested
', + // config: function(data){ + // data.head = 'InnerHEAD' + // data.foot = 'InnerFoot' + // } + // }) + + // var nested = new Nested() + // var component = new Component({ + // template: '
{#inc component}
', + // data: {component: nested } + // }).$inject(container); + + + + // var nested = nes.one('.nested', container); + + // expect(nested.innerHTML).to.equal('Nested'); + + // destroy(component, container) + // }) }) }() diff --git a/test/spec/browser-nested.js b/test/spec/browser-nested.js index 4938c99..45f3b14 100644 --- a/test/spec/browser-nested.js +++ b/test/spec/browser-nested.js @@ -14,7 +14,7 @@ void function(){ var NameSpace = Regular.extend(); var containerAll = document.createElement("div"); var Test = NameSpace.extend({ - template: "
" + template: "
{#inc this.$body}
" }) NameSpace.component('test', Test); @@ -82,7 +82,7 @@ void function(){ var container = document.createElement("div"); var Component = NameSpace.extend({ name: "nested1", - template: "

haha

" + template: "

haha{#inc this.$body}

" }) var i = 0; @@ -150,10 +150,20 @@ void function(){ step.push("init "+data.step); } }) + var Child2 = NameSpace.extend({ + template: "

{#inc this.$body}

", + config: function(data){ + step.push( "config " + data.step); + }, + init: function(){ + var data = this.data; + step.push("init "+data.step); + } + }) NameSpace.component("child1", Child); NameSpace.component("child2", Child); - NameSpace.component("child3", Child); - NameSpace.component("child4", Child); + NameSpace.component("child3", Child2); + NameSpace.component("child4", Child2); var component = new NameSpace({ template: diff --git a/test/spec/browser-syntax.js b/test/spec/browser-syntax.js index 9ee2e5c..0c36fdd 100644 --- a/test/spec/browser-syntax.js +++ b/test/spec/browser-syntax.js @@ -155,6 +155,17 @@ void function(){ destroy(component, container) }) + it("Invalid Lefthand Expression should throw Error" , function(){ + var component = new Regular({ + data: {name: 2} + }) + + expect(function(){ + component.$get("name + 1 = 3") + }).to.throwError(); + + }) + diff --git a/test/spec/browser-watcher.js b/test/spec/browser-watcher.js index 7253795..4613678 100644 --- a/test/spec/browser-watcher.js +++ b/test/spec/browser-watcher.js @@ -272,9 +272,19 @@ describe("Watcher-System", function(){ component.$update("name", "leeluolee"); expect(component.hello).to.equal("leeluolee"); + component.destroy(); }) + it("digest will throw Error when watching dynamic 【Object】 without deep", function(){ + var component = new Regular(); + // every time call hello, a new Object will be return + component.hello = function(){return {}} + component.$watch('this.hello()', function(){}) + expect(function(){ + component.$update() + }).to.throwError(); + }) it("$watch should accpect [Expression] param", function(){ @@ -548,6 +558,14 @@ void function(){ watcher.$digest(); expect(trigger).to.equal(1); expect(trigger2).to.equal(3); + watcher.data.obj.key = 2; + watcher.$digest(); + expect(trigger).to.equal(1); + expect(trigger2).to.equal(4); + delete watcher.data.obj.name; + watcher.$digest(); + expect(trigger).to.equal(1); + expect(trigger2).to.equal(5); }) }) diff --git a/test/spec/test-lexer.js b/test/spec/test-lexer.js index 92b9b1e..f20e670 100644 --- a/test/spec/test-lexer.js +++ b/test/spec/test-lexer.js @@ -32,9 +32,6 @@ describe("Lexer under mode 1 and 2", function(){ expect(l(input_attr_jst)).typeEqual("TAG_OPEN,NAME,=,EXPR_OPEN,IDENT,END,>,TAG_CLOSE,EOF") - // expect(function(){ - // l("<
") - // }).to.throwError(); }) diff --git a/test/spec/test-util.js b/test/spec/test-util.js index 82055da..3904dce 100644 --- a/test/spec/test-util.js +++ b/test/spec/test-util.js @@ -1,4 +1,5 @@ var _ = require_lib("util.js"); +var shim = require_lib("helper/shim.js"); var extend = require_lib('helper/extend.js'); var diffArray = require_lib('helper/arrayDiff.js'); @@ -104,7 +105,7 @@ describe("Regular.util", function(){ _.extend(c, {a:2}) expect(c).to.eql({a:1}) - expect(_.extend(c, {b:1,c:2},["c"])).to.eql({a:1,c:2}) + // expect(_.extend(c, {b:1,c:2},["c"])).to.eql({a:1,c:2}) }) it('diffArray should works as expect', function(){ @@ -181,16 +182,95 @@ describe("Regular.util", function(){ }) - describe('Error Track should work as expected', function(){ - it("_.trackErrorPos should have no '...' prefix if not slice", function(){ - expect(_.trackErrorPos("abcdefghi", 1)).to.equal('[1] abcdefghi\n ^^^\n'); - expect(_.trackErrorPos("abcdefghi", 2)).to.equal('[1] abcdefghi\n ^^^\n'); + it("_.trackErrorPos should have no '...' prefix if not slice", function(){ + expect(_.trackErrorPos("abcdefghi", 1)).to.equal('[1] abcdefghi\n ^^^\n'); + expect(_.trackErrorPos("abcdefghi", 2)).to.equal('[1] abcdefghi\n ^^^\n'); + }) + + + describe("shim should work as expect", function(){ + var map = { + string: { + pro: String.prototype, + methods: ['trim'] + }, + array: { + pro: Array.prototype, + methods: ['indexOf', 'forEach', 'filter', 'map'] + }, + array_static: { + pro: Array, + methods: ['isArray'] + }, + fn: { + pro: Function.prototype, + methods: ['bind'] + } + } + for(var i in map){ + var pair = map[i]; + pair.preCache = {}; + var methods = pair.methods + for(var i = 0; i < methods.length ; i++){ + var method = methods[i]; + pair.preCache[method] = pair.pro[method]; + delete pair.pro[method]; + } + } + shim(); + after( function(){ + // for(var i in map){ + // _.extend(map.pro, map.proCache, true); + // } + }) + + it("string.trim", function(){ + expect(' dada '.trim()).to.equal('dada') + }) + it("array.indexOf", function(){ + expect([1,2,3].indexOf(1)).to.equal(0) + expect([1,2,3].indexOf(-1)).to.equal(-1) + }) + it("array.forEach", function(){ + var arr = [1,2,3]; + var res = ""; + arr.forEach(function(item, index){ + res += item + ':' + index + '-'; + }) + expect(res).to.equal('1:0-2:1-3:2-'); + }) + it("array.filter", function(){ + var arr = [3,4,5, 1]; + var res = arr.filter(function(item, index){ + return index < 2 || item < 2; + }) + expect(res).to.eql([3,4,1]); + }) + it("array.map", function(){ + var arr = [3,4,5, 1]; + var res = arr.map(function(item, index){ + return item+ index + }) + expect(res).to.eql([3,5,7, 4]); + }) + it("array.isArray", function(){ + expect(Array.isArray([])).to.equal(true); + expect(Array.isArray({})).to.equal(false); + }) + it("function.bind", function(){ + var fn = function(first, two, three){ + expect(this.a).to.equal(1) + expect(first).to.equal(1) + expect(two).to.equal(2) + expect(three).to.equal(3) + }.bind({a:1}, 1, 2)(3) }) }) + })