Comparing version 0.8.4 to 0.8.7
@@ -7,3 +7,4 @@ # Vue.js Contributing Guide | ||
- Work in a topic branch and merge against `dev`. | ||
- Checkout a topic branch from `dev` and merge back against `dev`. | ||
- Work in the `src` folder and **DO NOT** checkin `dist` in the commits. | ||
- Squash the commit if there are too many small ones. | ||
@@ -10,0 +11,0 @@ - Follow the [code style](#code-style). |
/* | ||
Vue.js v0.8.4 | ||
Vue.js v0.8.7 | ||
(c) 2014 Evan You | ||
License: MIT | ||
*/ | ||
!function(){"use strict";function e(t,i,n){var r=e.resolve(t);if(null==r){n=n||t,i=i||"root";var s=new Error('Failed to require "'+n+'" from "'+i+'"');throw s.path=n,s.parent=i,s.require=!0,s}var o=e.modules[r];if(!o._resolving&&!o.exports){var a={};a.exports={},a.client=a.component=!0,o._resolving=!0,o.call(this,a.exports,e.relative(r),a),delete o._resolving,o.exports=a.exports}return o.exports}e.modules={},e.aliases={},e.resolve=function(t){"/"===t.charAt(0)&&(t=t.slice(1));for(var i=[t,t+".js",t+".json",t+"/index.js",t+"/index.json"],n=0;n<i.length;n++){var t=i[n];if(e.modules.hasOwnProperty(t))return t;if(e.aliases.hasOwnProperty(t))return e.aliases[t]}},e.normalize=function(e,t){var i=[];if("."!=t.charAt(0))return t;e=e.split("/"),t=t.split("/");for(var n=0;n<t.length;++n)".."==t[n]?e.pop():"."!=t[n]&&""!=t[n]&&i.push(t[n]);return e.concat(i).join("/")},e.register=function(t,i){e.modules[t]=i},e.alias=function(t,i){if(!e.modules.hasOwnProperty(t))throw new Error('Failed to alias "'+t+'", it does not exist');e.aliases[i]=t},e.relative=function(t){function i(e,t){for(var i=e.length;i--;)if(e[i]===t)return i;return-1}function n(i){var r=n.resolve(i);return e(r,t,i)}var r=e.normalize(t,"..");return n.resolve=function(n){var s=n.charAt(0);if("/"==s)return n.slice(1);if("."==s)return e.normalize(r,n);var o=t.split("/"),a=i(o,"deps")+1;return a||(a=0),n=o.slice(0,a+1).join("/")+"/deps/"+n},n.exists=function(t){return e.modules.hasOwnProperty(n.resolve(t))},n},e.register("component-emitter/index.js",function(e,t,i){function n(e){return e?r(e):void 0}function r(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}i.exports=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[e]=this._callbacks[e]||[]).push(t),this},n.prototype.once=function(e,t){function i(){n.off(e,i),t.apply(this,arguments)}var n=this;return this._callbacks=this._callbacks||{},i.fn=t,this.on(e,i),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var i=this._callbacks[e];if(!i)return this;if(1==arguments.length)return delete this._callbacks[e],this;for(var n,r=0;r<i.length;r++)if(n=i[r],n===t||n.fn===t){i.splice(r,1);break}return this},n.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),i=this._callbacks[e];if(i){i=i.slice(0);for(var n=0,r=i.length;r>n;++n)i[n].apply(this,t)}return this},n.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[e]||[]},n.prototype.hasListeners=function(e){return!!this.listeners(e).length}}),e.register("vue/src/main.js",function(e,t,i){function n(e){var t=this;e=r(e,t.options,!0),u.processOptions(e);var i=function(i,n){n||(i=r(i,e,!0)),t.call(this,i,!0)},s=i.prototype=Object.create(t.prototype);u.defProtected(s,"constructor",i);var a=e.methods;if(a)for(var c in a)c in o.prototype||"function"!=typeof a[c]||(s[c]=a[c]);return i.extend=n,i.super=t,i.options=e,i}function r(e,t,i){if(e=e||u.hash(),!t)return e;for(var n in t)if("el"!==n&&"methods"!==n){var s=e[n],o=t[n],a=u.typeOf(s);i&&"Function"===a&&o?(e[n]=[s],Array.isArray(o)?e[n]=e[n].concat(o):e[n].push(o)):i&&"Object"===a?r(s,o):void 0===s&&(e[n]=o)}return e}var s=t("./config"),o=t("./viewmodel"),a=t("./directives"),c=t("./filters"),u=t("./utils");o.config=function(e,t){if("string"==typeof e){if(void 0===t)return s[e];s[e]=t}else u.extend(s,e);return this},o.directive=function(e,t){return t?(a[e]=t,this):a[e]},o.filter=function(e,t){return t?(c[e]=t,this):c[e]},o.component=function(e,t){return t?(u.components[e]=u.toConstructor(t),this):u.components[e]},o.partial=function(e,t){return t?(u.partials[e]=u.toFragment(t),this):u.partials[e]},o.transition=function(e,t){return t?(u.transitions[e]=t,this):u.transitions[e]},o.extend=n,o.nextTick=u.nextTick,i.exports=o}),e.register("vue/src/emitter.js",function(e,t,i){var n,r="emitter";try{n=t(r)}catch(s){n=t("events").EventEmitter,n.prototype.off=function(){var e=arguments.length>1?this.removeListener:this.removeAllListeners;return e.apply(this,arguments)}}i.exports=n}),e.register("vue/src/config.js",function(e,t,i){function n(){s.forEach(function(e){o.attrs[e]=r+"-"+e})}var r="v",s=["pre","text","repeat","partial","with","component","component-id","transition"],o=i.exports={debug:!1,silent:!1,enterClass:"v-enter",leaveClass:"v-leave",attrs:{},get prefix(){return r},set prefix(e){r=e,n()}};n()}),e.register("vue/src/utils.js",function(e,t,i){function n(){return Object.create(null)}var r,s=t("./config"),o=s.attrs,a=Object.prototype.toString,c=Array.prototype.join,u=window.console,l="classList"in document.documentElement,h=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.setTimeout,f=i.exports={hash:n,components:n(),partials:n(),transitions:n(),attr:function(e,t,i){var n=o[t],r=e.getAttribute(n);return i||null===r||e.removeAttribute(n),r},defProtected:function(e,t,i,n,r){e.hasOwnProperty(t)||Object.defineProperty(e,t,{value:i,enumerable:!!n,configurable:!!r})},typeOf:function(e){return a.call(e).slice(8,-1)},bind:function(e,t){return function(i){return e.call(t,i)}},toText:function(e){return"string"==typeof e||"boolean"==typeof e||"number"==typeof e&&e==e?e:""},extend:function(e,t,i){for(var n in t)i&&e[n]||(e[n]=t[n])},unique:function(e){for(var t,i=f.hash(),n=e.length,r=[];n--;)t=e[n],i[t]||(i[t]=1,r.push(t));return r},toFragment:function(e){if("string"!=typeof e)return e;if("#"===e.charAt(0)){var t=document.getElementById(e.slice(1));if(!t)return;e=t.innerHTML}var i,n=document.createElement("div"),r=document.createDocumentFragment();for(n.innerHTML=e.trim();i=n.firstChild;)r.appendChild(i);return r},toConstructor:function(e){return r=r||t("./viewmodel"),"Object"===f.typeOf(e)?r.extend(e):"function"==typeof e?e:null},processOptions:function(e){var t,i=e.components,n=e.partials,r=e.template;if(i)for(t in i)i[t]=f.toConstructor(i[t]);if(n)for(t in n)n[t]=f.toFragment(n[t]);r&&(e.template=f.toFragment(r))},log:function(){s.debug&&u&&u.log(c.call(arguments," "))},warn:function(){!s.silent&&u&&(u.warn(c.call(arguments," ")),s.debug&&u.trace())},nextTick:function(e){h(e,0)},addClass:function(e,t){if(l)e.classList.add(t);else{var i=" "+e.className+" ";i.indexOf(" "+t+" ")<0&&(e.className=(i+t).trim())}},removeClass:function(e,t){if(l)e.classList.remove(t);else{for(var i=" "+e.className+" ",n=" "+t+" ";i.indexOf(n)>=0;)i=i.replace(n," ");e.className=i.trim()}}}}),e.register("vue/src/compiler.js",function(e,t,i){function n(e,t){var i=this;i.init=!0,t=i.options=t||m(),c.processOptions(t);var n=i.data=t.data||{};g(e,n,!0),g(e,t.methods,!0),g(i,t.compilerOptions);var a=i.setupElement(t);v("\nnew VM instance:",a.tagName,"\n"),i.vm=e,i.bindings=m(),i.dirs=[],i.deferred=[],i.exps=[],i.computed=[],i.childCompilers=[],i.emitter=new s,b(e,"$",m()),b(e,"$el",a),b(e,"$compiler",i),b(e,"$root",r(i).vm);var u=i.parentCompiler,l=c.attr(a,"component-id");u&&(u.childCompilers.push(i),b(e,"$parent",u.vm),l&&(i.childId=l,u.vm.$[l]=e)),i.setupObserver();var h=t.computed;if(h)for(var f in h)i.createBinding(f);i.execHook("created"),g(n,e),o.observe(n,"",i.observer),i.repeat&&(b(n,"$index",i.repeatIndex,!1,!0),i.createBinding("$index")),Object.defineProperty(e,"$data",{enumerable:!1,get:function(){return i.data},set:function(e){var t=i.data;o.unobserve(t,"",i.observer),i.data=e,o.copyPaths(e,t),o.observe(e,"",i.observer)}}),i.compile(a,!0),i.deferred.forEach(i.bindDirective,i),i.parseDeps(),i.init=!1,i.execHook("ready")}function r(e){for(;e.parentCompiler;)e=e.parentCompiler;return e}var s=t("./emitter"),o=t("./observer"),a=t("./config"),c=t("./utils"),u=t("./binding"),l=t("./directive"),h=t("./text-parser"),f=t("./deps-parser"),p=t("./exp-parser"),d=Array.prototype.slice,v=c.log,m=c.hash,g=c.extend,b=c.defProtected,y=Object.prototype.hasOwnProperty,_=["created","ready","beforeDestroy","afterDestroy","enteredView","leftView"],x=n.prototype;x.setupElement=function(e){var t=this.el="string"==typeof e.el?document.querySelector(e.el):e.el||document.createElement(e.tagName||"div"),i=e.template;if(i)if(e.replace&&1===i.childNodes.length){var n=i.childNodes[0].cloneNode(!0);t.parentNode&&(t.parentNode.insertBefore(n,t),t.parentNode.removeChild(t)),t=n}else t.innerHTML="",t.appendChild(i.cloneNode(!0));e.id&&(t.id=e.id),e.className&&(t.className=e.className);var r=e.attributes;if(r)for(var s in r)t.setAttribute(s,r[s]);return t},x.setupObserver=function(){function e(e,t){o.on("hook:"+e,function(){t.call(i.vm,r)})}function t(e){n[e]||i.createBinding(e)}var i=this,n=i.bindings,r=i.options,o=i.observer=new s;o.proxies=m(),o.on("get",function(e){t(e),f.catcher.emit("get",n[e])}).on("set",function(e,i){o.emit("change:"+e,i),t(e),n[e].update(i)}).on("mutate",function(e,i,r){o.emit("change:"+e,i,r),t(e),n[e].pub()}),_.forEach(function(t){var i=r[t];if(Array.isArray(i))for(var n=i.length;n--;)e(t,i[n]);else i&&e(t,i)})},x.compile=function(e,t){var i=this,n=e.nodeType,r=e.tagName;if(1===n&&"SCRIPT"!==r){if(null!==c.attr(e,"pre"))return;var s,o,a,u,h=c.attr(e,"component")||r.toLowerCase(),f=i.getOption("components",h);if(s=c.attr(e,"repeat"))u=l.parse("repeat",s,i,e),u&&(u.Ctor=f,i.deferred.push(u));else if(t!==!0&&((o=c.attr(e,"with"))||f))u=l.parse("with",o||"",i,e),u&&(u.Ctor=f,i.deferred.push(u));else{if(e.vue_trans=c.attr(e,"transition"),a=c.attr(e,"partial")){var p=i.getOption("partials",a);p&&(e.innerHTML="",e.appendChild(p.cloneNode(!0)))}i.compileNode(e)}}else 3===n&&i.compileTextNode(e)},x.compileNode=function(e){var t,i,n=d.call(e.attributes),r=a.prefix+"-";if(n&&n.length){var s,o,c,u,f;for(t=n.length;t--;){if(s=n[t],o=!1,0===s.name.indexOf(r))for(o=!0,c=l.split(s.value),i=c.length;i--;)u=c[i],f=l.parse(s.name.slice(r.length),u,this,e),f&&this.bindDirective(f);else u=h.parseAttr(s.value),u&&(f=l.parse("attr",s.name+":"+u,this,e),f&&this.bindDirective(f));o&&e.removeAttribute(s.name)}}e.childNodes.length&&d.call(e.childNodes).forEach(this.compile,this)},x.compileTextNode=function(e){var t=h.parse(e.nodeValue);if(t){for(var i,n,r,s,o,c,u=0,f=t.length;f>u;u++)n=t[u],r=c=null,n.key?">"===n.key.charAt(0)?(o=n.key.slice(1).trim(),s=this.getOption("partials",o),s&&(i=s.cloneNode(!0),c=d.call(i.childNodes))):n.html?(i=document.createComment(a.prefix+"-html"),r=l.parse("html",n.key,this,i)):(i=document.createTextNode(""),r=l.parse("text",n.key,this,i)):i=document.createTextNode(n),e.parentNode.insertBefore(i,e),r&&this.bindDirective(r),c&&c.forEach(this.compile,this);e.parentNode.removeChild(e)}},x.bindDirective=function(e){if(this.dirs.push(e),e.isEmpty||e.isLiteral)return e.bind&&e.bind(),void 0;var t,i=this,n=e.key;if(e.isExp)t=i.createBinding(n,!0,e.isFn);else{for(;i&&!i.hasKey(n);)i=i.parentCompiler;i=i||this,t=i.bindings[n]||i.createBinding(n)}t.instances.push(e),e.binding=t,e.bind&&e.bind(),e.update(t.val(),!0)},x.createBinding=function(e,t,i){v(" created binding: "+e);var n=this,r=n.bindings,s=n.options.computed,a=new u(n,e,t,i);if(t)n.defineExp(e,a);else if(r[e]=a,a.root)s&&s[e]?n.defineComputed(e,a,s[e]):n.defineProp(e,a);else{o.ensurePath(n.data,e);var c=e.slice(0,e.lastIndexOf("."));r[c]||n.createBinding(c)}return a},x.defineProp=function(e,t){var i=this,n=i.data,r=n.__observer__;e in n||(n[e]=void 0),!r||e in r.values||o.convert(n,e),t.value=n[e],Object.defineProperty(i.vm,e,{get:function(){return i.data[e]},set:function(t){i.data[e]=t}})},x.defineExp=function(e,t){var i=p.parse(e,this);i&&(this.markComputed(t,i),this.exps.push(t))},x.defineComputed=function(e,t,i){this.markComputed(t,i);var n={get:t.value.$get,set:t.value.$set};Object.defineProperty(this.vm,e,n)},x.markComputed=function(e,t){e.isComputed=!0,e.isFn?e.value=t:("function"==typeof t&&(t={$get:t}),e.value={$get:c.bind(t.$get,this.vm),$set:t.$set?c.bind(t.$set,this.vm):void 0}),this.computed.push(e)},x.getOption=function(e,t){var i=this.options,n=this.parentCompiler;return i[e]&&i[e][t]||(n?n.getOption(e,t):c[e]&&c[e][t])},x.execHook=function(e){e="hook:"+e,this.observer.emit(e),this.emitter.emit(e)},x.hasKey=function(e){var t=e.split(".")[0];return y.call(this.data,t)||y.call(this.vm,t)},x.parseDeps=function(){this.computed.length&&f.parse(this.computed)},x.destroy=function(){if(!this.destroyed){var e,t,i,n,r,s=this,a=s.vm,c=s.el,u=s.dirs,l=s.exps,h=s.bindings;for(s.execHook("beforeDestroy"),e=u.length;e--;)i=u[e],i.isEmpty||i.binding.compiler===s||(n=i.binding.instances,n&&n.splice(n.indexOf(i),1)),i.unbind();for(e=l.length;e--;)l[e].unbind();for(t in h)r=h[t],r&&(r.root&&o.unobserve(r.value,r.key,s.observer),r.unbind());var f=s.parentCompiler,p=s.childId;f&&(f.childCompilers.splice(f.childCompilers.indexOf(s),1),p&&delete f.vm.$[p]),c===document.body?c.innerHTML="":a.$remove(),this.destroyed=!0,s.execHook("afterDestroy"),s.observer.off(),s.emitter.off()}},i.exports=n}),e.register("vue/src/viewmodel.js",function(e,t,i){function n(e){new o(this,e)}function r(e){return"string"==typeof e?document.querySelector(e):e}function s(e,t){var i=t[0],n=e.$compiler.bindings[i];return n?n.compiler.vm:null}var o=t("./compiler"),a=t("./utils"),c=t("./transition"),u=a.defProtected,l=a.nextTick,h=n.prototype;u(h,"$set",function(e,t){var i=e.split("."),n=s(this,i);if(n){for(var r=0,o=i.length-1;o>r;r++)n=n[i[r]];n[i[r]]=t}}),u(h,"$watch",function(e,t){function i(){var e=arguments;a.nextTick(function(){t.apply(n,e)})}var n=this;t._fn=i,n.$compiler.observer.on("change:"+e,i)}),u(h,"$unwatch",function(e,t){var i=["change:"+e],n=this.$compiler.observer;t&&i.push(t._fn),n.off.apply(n,i)}),u(h,"$destroy",function(){this.$compiler.destroy()}),u(h,"$broadcast",function(){for(var e,t=this.$compiler.childCompilers,i=t.length;i--;)e=t[i],e.emitter.emit.apply(e.emitter,arguments),e.vm.$broadcast.apply(e.vm,arguments)}),u(h,"$dispatch",function(){var e=this.$compiler,t=e.emitter,i=e.parentCompiler;t.emit.apply(t,arguments),i&&i.vm.$dispatch.apply(i.vm,arguments)}),["emit","on","off","once"].forEach(function(e){u(h,"$"+e,function(){var t=this.$compiler.emitter;t[e].apply(t,arguments)})}),u(h,"$appendTo",function(e,t){e=r(e);var i=this.$el;c(i,1,function(){e.appendChild(i),t&&l(t)},this.$compiler)}),u(h,"$remove",function(e){var t=this.$el,i=t.parentNode;i&&c(t,-1,function(){i.removeChild(t),e&&l(e)},this.$compiler)}),u(h,"$before",function(e,t){e=r(e);var i=this.$el,n=e.parentNode;n&&c(i,1,function(){n.insertBefore(i,e),t&&l(t)},this.$compiler)}),u(h,"$after",function(e,t){e=r(e);var i=this.$el,n=e.parentNode,s=e.nextSibling;n&&c(i,1,function(){s?n.insertBefore(i,s):n.appendChild(i),t&&l(t)},this.$compiler)}),i.exports=n}),e.register("vue/src/binding.js",function(e,t,i){function n(e,t,i,n){this.id=s++,this.value=void 0,this.isExp=!!i,this.isFn=n,this.root=!this.isExp&&-1===t.indexOf("."),this.compiler=e,this.key=t,this.instances=[],this.subs=[],this.deps=[],this.unbound=!1}var r=t("./batcher"),s=0,o=n.prototype;o.update=function(e){(!this.isComputed||this.isFn)&&(this.value=e),r.queue(this)},o._update=function(){for(var e=this.instances.length,t=this.val();e--;)this.instances[e].update(t);this.pub()},o.val=function(){return this.isComputed&&!this.isFn?this.value.$get():this.value},o.pub=function(){for(var e=this.subs.length;e--;)this.subs[e].update()},o.unbind=function(){this.unbound=!0;for(var e=this.instances.length;e--;)this.instances[e].unbind();e=this.deps.length;for(var t;e--;)t=this.deps[e].subs,t.splice(t.indexOf(this),1)},i.exports=n}),e.register("vue/src/observer.js",function(e,t,i){function n(e){for(var t in e)s(e,t)}function r(e,t){var i=e.__observer__;if(i||(i=new p,m(e,"__observer__",i)),i.path=t,x)e.__proto__=k;else for(var n in k)m(e,n,k[n])}function s(e,t){var i=t.charAt(0);if("$"!==i&&"_"!==i||"$index"===t){var n=e.__observer__,r=n.values,s=r[t]=e[t];n.emit("set",t,s),Array.isArray(s)&&n.emit("set",t+".length",s.length),Object.defineProperty(e,t,{get:function(){var e=r[t];return C.shouldGet&&v(e)!==b&&n.emit("get",t),e},set:function(e){var i=r[t];h(i,t,n),r[t]=e,c(e,i),n.emit("set",t,e),l(e,t,n)}}),l(s,t,n)}}function o(e){f=f||t("./viewmodel");var i=v(e);return!(i!==b&&i!==y||e instanceof f)}function a(e){var t=v(e),i=e&&e.__observer__;if(t===y)i.emit("set","length",e.length);else if(t===b){var n,r;for(n in e)r=e[n],i.emit("set",n,r),a(r)}}function c(e,t){if(v(t)===b&&v(e)===b){var i,n,r,s;for(i in t)i in e||(r=t[i],n=v(r),n===b?(s=e[i]={},c(s,r)):e[i]=n===y?[]:void 0)}}function u(e,t){for(var i,n=t.split("."),r=0,o=n.length-1;o>r;r++)i=n[r],e[i]||(e[i]={},e.__observer__&&s(e,i)),e=e[i];v(e)===b&&(i=n[r],i in e||(e[i]=void 0,e.__observer__&&s(e,i)))}function l(e,t,i){if(o(e)){var s,c=t?t+".":"",u=!!e.__observer__;u||m(e,"__observer__",new p),s=e.__observer__,s.values=s.values||d.hash(),i.proxies=i.proxies||{};var l=i.proxies[c]={get:function(e){i.emit("get",c+e)},set:function(e,t){i.emit("set",c+e,t)},mutate:function(e,n,r){var s=e?c+e:t;i.emit("mutate",s,n,r);var o=r.method;"sort"!==o&&"reverse"!==o&&i.emit("set",s+".length",n.length)}};if(s.on("get",l.get).on("set",l.set).on("mutate",l.mutate),u)a(e);else{var h=v(e);h===b?n(e):h===y&&r(e)}}}function h(e,t,i){if(e&&e.__observer__){t=t?t+".":"";var n=i.proxies[t];n&&(e.__observer__.off("get",n.get).off("set",n.set).off("mutate",n.mutate),i.proxies[t]=null)}}var f,p=t("./emitter"),d=t("./utils"),v=d.typeOf,m=d.defProtected,g=Array.prototype.slice,b="Object",y="Array",_=["push","pop","shift","unshift","splice","sort","reverse"],x={}.__proto__,k=Object.create(Array.prototype);_.forEach(function(e){m(k,e,function(){var t=Array.prototype[e].apply(this,arguments);return this.__observer__.emit("mutate",this.__observer__.path,this,{method:e,args:g.call(arguments),result:t}),t},!x)});var w={remove:function(e){if("function"==typeof e){for(var t=this.length,i=[];t--;)e(this[t])&&i.push(this.splice(t,1)[0]);return i.reverse()}return"number"!=typeof e&&(e=this.indexOf(e)),e>-1?this.splice(e,1)[0]:void 0},replace:function(e,t){if("function"==typeof e){for(var i,n=this.length,r=[];n--;)i=e(this[n]),void 0!==i&&r.push(this.splice(n,1,i)[0]);return r.reverse()}return"number"!=typeof e&&(e=this.indexOf(e)),e>-1?this.splice(e,1,t)[0]:void 0}};for(var $ in w)m(k,$,w[$],!x);var C=i.exports={shouldGet:!1,observe:l,unobserve:h,ensurePath:u,convert:s,copyPaths:c,watchArray:r}}),e.register("vue/src/directive.js",function(e,t,i){function n(e,t,i,n,o){this.compiler=n,this.vm=n.vm,this.el=o;var a=""===t;if("function"==typeof e)this[a?"bind":"_update"]=e;else for(var c in e)"unbind"===c||"update"===c?this["_"+c]=e[c]:this[c]=e[c];if(a)return this.isEmpty=!0,void 0;if(this.isLiteral)return this.value=t.trim(),void 0;this.expression=t.trim(),this.rawKey=i,r(this,i),this.isExp=!v.test(this.key)||d.test(this.key);var u=this.expression.slice(i.length).match(f);if(u){this.filters=[];for(var l,h=0,p=u.length;p>h;h++)l=s(u[h],this.compiler),l&&this.filters.push(l);this.filters.length||(this.filters=null)}else this.filters=null}function r(e,t){var i=t;if(t.indexOf(":")>-1){var n=t.match(h);i=n?n[2].trim():i,e.arg=n?n[1].trim():null}e.key=i}function s(e,t){var i=e.slice(1).match(p);if(i){i=i.map(function(e){return e.replace(/'/g,"").trim()});var n=i[0],r=t.getOption("filters",n)||c[n];return r?{name:n,apply:r,args:i.length>1?i.slice(1):null}:(o.warn("Unknown filter: "+n),void 0)}}var o=t("./utils"),a=t("./directives"),c=t("./filters"),u=/(?:['"](?:\\.|[^'"])*['"]|\((?:\\.|[^\)])*\)|\\.|[^,])+/g,l=/^(?:['"](?:\\.|[^'"])*['"]|\\.|[^\|]|\|\|)+/,h=/^([\w-$ ]+):(.+)$/,f=/\|[^\|]+/g,p=/[^\s']+|'[^']+'/g,d=/^\$(parent|root)\./,v=/^[\w\.$]+$/,m=n.prototype;m.update=function(e,t){(t||e!==this.value)&&(this.value=e,this._update&&this._update(this.filters?this.applyFilters(e):e))},m.applyFilters=function(e){for(var t,i=e,n=0,r=this.filters.length;r>n;n++)t=this.filters[n],i=t.apply.call(this.vm,i,t.args);return i},m.unbind=function(e){this.el&&(this._unbind&&this._unbind(e),e||(this.vm=this.el=this.binding=this.compiler=null))},n.split=function(e){return e.indexOf(",")>-1?e.match(u)||[""]:[e]},n.parse=function(e,t,i,r){var s=i.getOption("directives",e)||a[e];if(!s)return o.warn("unknown directive: "+e);var c;if(t.indexOf("|")>-1){var u=t.match(l);u&&(c=u[0].trim())}else c=t.trim();return c||""===t?new n(s,t,c,i,r):o.warn("invalid directive expression: "+t)},i.exports=n}),e.register("vue/src/exp-parser.js",function(e,t,i){function n(e){return e=e.replace(f,"").replace(p,",").replace(h,"").replace(d,"").replace(v,""),e?e.split(/,+/):[]}function r(e,t){for(var i="",n=0,r=t;t&&!t.hasKey(e);)t=t.parentCompiler,n++;if(t){for(;n--;)i+="$parent.";t.bindings[e]||"$"===e.charAt(0)||t.createBinding(e)}else r.createBinding(e);return i}function s(e,t){var i;try{i=new Function(e)}catch(n){a.warn("Invalid expression: "+t)}return i}function o(e){return"$"===e.charAt(0)?"\\"+e:e}var a=t("./utils"),c=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,u=/"(\d+)"/g,l="break,case,catch,continue,debugger,default,delete,do,else,false,finally,for,function,if,in,instanceof,new,null,return,switch,this,throw,true,try,typeof,var,void,while,with,undefined,abstract,boolean,byte,char,class,const,double,enum,export,extends,final,float,goto,implements,import,int,interface,long,native,package,private,protected,public,short,static,super,synchronized,throws,transient,volatile,arguments,let,yield,Math",h=new RegExp(["\\b"+l.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),f=/\/\*(?:.|\n)*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|'[^']*'|"[^"]*"|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,p=/[^\w$]+/g,d=/\b\d[^,]*/g,v=/^,+|,+$/g;i.exports={parse:function(e,t){function i(e){var t=v.length;return v[t]=e,'"'+t+'"'}function l(e){var i=e.charAt(0);e=e.slice(1);var n="this."+r(e,t)+e;return d[e]||(p+=n+";",d[e]=1),i+n}function h(e,t){return v[t]}var f=n(e);if(!f.length)return s("return "+e,e);f=a.unique(f);var p="",d=a.hash(),v=[],m=new RegExp("[^$\\w\\.]("+f.map(o).join("|")+")[$\\w\\.]*\\b","g"),g=("return "+e).replace(c,i).replace(m,l).replace(u,h);return g=p+g,s(g,e)}}}),e.register("vue/src/text-parser.js",function(e){function t(e){if(!n.test(e))return null;for(var t,i,s,o=[];t=e.match(n);)i=t.index,i>0&&o.push(e.slice(0,i)),s={key:t[1].trim()},r.test(t[0])&&(s.html=!0),o.push(s),e=e.slice(i+t[0].length);return e.length&&o.push(e),o}function i(e){var i=t(e);if(!i)return null;for(var n,r=[],s=0,o=i.length;o>s;s++)n=i[s],r.push(n.key||'"'+n+'"');return r.join("+")}var n=/{{{?([^{}]+?)}?}}/,r=/{{{[^{}]+}}}/;e.parse=t,e.parseAttr=i}),e.register("vue/src/deps-parser.js",function(e,t,i){function n(e){if(!e.isFn){s.log("\n- "+e.key);var t=s.hash();e.deps=[],a.on("get",function(i){var n=t[i.key];n&&n.compiler===i.compiler||(t[i.key]=i,s.log(" - "+i.key),e.deps.push(i),i.subs.push(e))}),e.value.$get(),a.off("get")}}var r=t("./emitter"),s=t("./utils"),o=t("./observer"),a=new r;i.exports={catcher:a,parse:function(e){s.log("\nparsing dependencies..."),o.shouldGet=!0,e.forEach(n),o.shouldGet=!1,s.log("\ndone.")}}}),e.register("vue/src/filters.js",function(e,t,i){var n={enter:13,tab:9,"delete":46,up:38,left:37,right:39,down:40,esc:27};i.exports={capitalize:function(e){return e||0===e?(e=e.toString(),e.charAt(0).toUpperCase()+e.slice(1)):""},uppercase:function(e){return e||0===e?e.toString().toUpperCase():""},lowercase:function(e){return e||0===e?e.toString().toLowerCase():""},currency:function(e,t){if(!e&&0!==e)return"";var i=t&&t[0]||"$",n=Math.floor(e).toString(),r=n.length%3,s=r>0?n.slice(0,r)+(n.length>3?",":""):"",o="."+e.toFixed(2).slice(-2);return i+s+n.slice(r).replace(/(\d{3})(?=\d)/g,"$1,")+o},pluralize:function(e,t){return t.length>1?t[e-1]||t[t.length-1]:t[e-1]||t[0]+"s"},key:function(e,t){if(e){var i=n[t[0]];return i||(i=parseInt(t[0],10)),function(t){t.keyCode===i&&e.call(this,t)}}}}}),e.register("vue/src/transition.js",function(e,t,i){function n(e,t,i){if(!o)return i(),c.CSS_SKIP;var n=e.classList,r=e.vue_trans_cb;if(t>0){r&&(e.removeEventListener(o,r),e.vue_trans_cb=null),n.add(a.enterClass),i();{e.clientHeight}return n.remove(a.enterClass),c.CSS_E}n.add(a.leaveClass);var s=function(t){t.target===e&&(e.removeEventListener(o,s),e.vue_trans_cb=null,i(),n.remove(a.leaveClass))};return e.addEventListener(o,s),e.vue_trans_cb=s,c.CSS_L}function r(e,t,i,n,r){var s=r.getOption("transitions",n);if(!s)return i(),c.JS_SKIP;var o=s.enter,a=s.leave;return t>0?"function"!=typeof o?(i(),c.JS_SKIP_E):(o(e,i),c.JS_E):"function"!=typeof a?(i(),c.JS_SKIP_L):(a(e,i),c.JS_L)}function s(){var e=document.createElement("vue"),t="transitionend",i={transition:t,mozTransition:t,webkitTransition:"webkitTransitionEnd"};for(var n in i)if(void 0!==e.style[n])return i[n]}var o=s(),a=t("./config"),c={CSS_E:1,CSS_L:2,JS_E:3,JS_L:4,CSS_SKIP:-1,JS_SKIP:-2,JS_SKIP_E:-3,JS_SKIP_L:-4,INIT:-5,SKIP:-6},u=i.exports=function(e,t,i,s){var o=function(){i(),s.execHook(t>0?"enteredView":"leftView")};if(s.init)return o(),c.INIT;var a=e.vue_trans;return a?r(e,t,o,a,s):""===a?n(e,t,o):(o(),c.SKIP)};u.codes=c}),e.register("vue/src/batcher.js",function(e,t){function i(){for(var e=0;e<r.length;e++){var t=r[e];t.unbound||(t._update(),s[t.id]=!1)}n()}function n(){r=[],s=a.hash(),o=!1}var r,s,o,a=t("./utils");n(),e.queue=function(e){s[e.id]||(r.push(e),s[e.id]=!0,o||(o=!0,a.nextTick(i)))}}),e.register("vue/src/directives/index.js",function(e,t,i){var n=t("../utils"),r=t("../transition");i.exports={on:t("./on"),repeat:t("./repeat"),model:t("./model"),"if":t("./if"),"with":t("./with"),html:t("./html"),style:t("./style"),attr:function(e){this.el.setAttribute(this.arg,e)},text:function(e){this.el.textContent=n.toText(e)},show:function(e){var t=this.el,i=e?"":"none",n=function(){t.style.display=i};r(t,e?1:-1,n,this.compiler)},"class":function(e){this.arg?n[e?"addClass":"removeClass"](this.el,this.arg):(this.lastVal&&n.removeClass(this.el,this.lastVal),e&&(n.addClass(this.el,e),this.lastVal=e))}}}),e.register("vue/src/directives/if.js",function(e,t,i){var n=t("../config"),r=t("../transition");i.exports={bind:function(){this.parent=this.el.parentNode,this.ref=document.createComment(n.prefix+"-if-"+this.key),this.el.vue_ref=this.ref},update:function(e){function t(){if(n.parentNode){var e=n.nextSibling;e?s.insertBefore(o,e):s.appendChild(o),s.removeChild(n)}}function i(){n.parentNode||(s.insertBefore(n,o),s.removeChild(o))}var n=this.el;if(!this.parent){if(!n.parentNode)return;this.parent=n.parentNode}var s=this.parent,o=this.ref,a=this.compiler;e?r(n,1,i,a):r(n,-1,t,a)},unbind:function(){this.el.vue_ref=null}}}),e.register("vue/src/directives/repeat.js",function(e,t,i){var n,r=t("../observer"),s=t("../emitter"),o=t("../utils"),a=t("../config"),c=t("../transition"),u={push:function(e){var t,i=e.args.length,n=this.collection.length-i;for(t=0;i>t;t++)this.buildItem(e.args[t],n+t)},pop:function(){var e=this.vms.pop();e&&e.$destroy()},unshift:function(e){e.args.forEach(this.buildItem,this)},shift:function(){var e=this.vms.shift();e&&e.$destroy()},splice:function(e){var t,i,n=e.args[0],r=e.args[1],s=e.args.length-2,o=this.vms.splice(n,r);for(t=0,i=o.length;i>t;t++)o[t].$destroy();for(t=0;s>t;t++)this.buildItem(e.args[t+2],n+t)},sort:function(){var e,t,i,n,r=this.vms,s=this.collection,o=s.length,a=new Array(o);for(e=0;o>e;e++)for(n=s[e],t=0;o>t;t++)if(i=r[t],i.$data===n){a[e]=i;break}for(e=0;o>e;e++)this.container.insertBefore(a[e].$el,this.ref);this.vms=a},reverse:function(){var e=this.vms;e.reverse();for(var t=0,i=e.length;i>t;t++)this.container.insertBefore(e[t].$el,this.ref)}};i.exports={bind:function(){var e=this.el,i=this.container=e.parentNode;n=n||t("../viewmodel"),this.Ctor=this.Ctor||n,this.hasTrans=e.hasAttribute(a.attrs.transition),this.childId=o.attr(e,"component-id"),this.ref=document.createComment(a.prefix+"-repeat-"+this.key),i.insertBefore(this.ref,e),i.removeChild(e),this.initiated=!1,this.collection=null,this.vms=null;var r=this;this.mutationListener=function(e,t,i){var n=i.method;u[n].call(r,i),"push"!==n&&"pop"!==n&&r.updateIndex(),("push"===n||"unshift"===n||"splice"===n)&&r.changed()}},update:function(e,t){this.unbind(!0),this.container.vue_dHandlers=o.hash(),this.initiated||e&&e.length||(this.buildItem(),this.initiated=!0),e=this.collection=e||[],this.vms=[],this.childId&&(this.vm.$[this.childId]=this.vms),e.__observer__||r.watchArray(e,null,new s),e.__observer__.on("mutate",this.mutationListener),e.length&&(e.forEach(this.buildItem,this),t||this.changed())},changed:function(){if(!this.queued){this.queued=!0;var e=this;setTimeout(function(){e.compiler.parseDeps(),e.queued=!1},0)}},buildItem:function(e,t){var i,n,r=this.el.cloneNode(!0),s=this.container,a=this.vms,u=this.collection;e&&(i=a.length>t?a[t].$el:this.ref,i.parentNode||(i=i.vue_ref),r.vue_trans=o.attr(r,"transition",!0),c(r,1,function(){s.insertBefore(r,i)},this.compiler)),n=new this.Ctor({el:r,data:e,compilerOptions:{repeat:!0,repeatIndex:t,parentCompiler:this.compiler,delegator:s}}),e?(a.splice(t,0,n),n.$compiler.observer.on("hook:afterDestroy",function(){u.remove(e)})):n.$destroy()},updateIndex:function(){for(var e=this.vms.length;e--;)this.vms[e].$data.$index=e},unbind:function(){if(this.childId&&delete this.vm.$[this.childId],this.collection){this.collection.__observer__.off("mutate",this.mutationListener);for(var e=this.vms.length;e--;)this.vms[e].$destroy()}var t=this.container,i=t.vue_dHandlers;for(var n in i)t.removeEventListener(i[n].event,i[n]);t.vue_dHandlers=null}}}),e.register("vue/src/directives/on.js",function(e,t,i){function n(e,t,i){for(;e&&e!==t;){if(e[i])return e;e=e.parentNode}}var r=t("../utils");i.exports={isFn:!0,bind:function(){this.compiler.repeat&&(this.el[this.expression]=!0,this.el.vue_viewmodel=this.vm)},update:function(e){if(this.unbind(!0),"function"!=typeof e)return r.warn('Directive "on" expects a function value.');var t=this.compiler,i=this.arg,s=this.binding.isExp,o=this.binding.compiler.vm;if(t.repeat&&!this.vm.constructor.super&&"blur"!==i&&"focus"!==i){var a=t.delegator,c=this.expression,u=a.vue_dHandlers[c];if(u)return;u=a.vue_dHandlers[c]=function(t){var i=n(t.target,a,c);i&&(t.el=i,t.targetVM=i.vue_viewmodel,e.call(s?t.targetVM:o,t))},u.event=i,a.addEventListener(i,u)}else{var l=this.vm;this.handler=function(t){t.el=t.currentTarget,t.targetVM=l,e.call(o,t)},this.el.addEventListener(i,this.handler)}},unbind:function(e){this.el.removeEventListener(this.arg,this.handler),this.handler=null,e||(this.el.vue_viewmodel=null)}}}),e.register("vue/src/directives/model.js",function(e,t,i){var n=t("../utils"),r=navigator.userAgent.indexOf("MSIE 9.0")>0;i.exports={bind:function(){var e=this,t=e.el,i=t.type,s=t.tagName;e.lock=!1,e.event=e.compiler.options.lazy||"SELECT"===s||"checkbox"===i||"radio"===i?"change":"input";var o=e.attr="checkbox"===i?"checked":"INPUT"===s||"SELECT"===s||"TEXTAREA"===s?"value":"innerHTML",a=!1;this.cLock=function(){a=!0},this.cUnlock=function(){a=!1},t.addEventListener("compositionstart",this.cLock),t.addEventListener("compositionend",this.cUnlock),e.set=e.filters?function(){if(!a){var i;try{i=t.selectionStart}catch(r){}e.vm.$set(e.key,t[o]),n.nextTick(function(){void 0!==i&&t.setSelectionRange(i,i)})}}:function(){a||(e.lock=!0,e.vm.$set(e.key,t[o]),n.nextTick(function(){e.lock=!1}))},t.addEventListener(e.event,e.set),r&&(e.onCut=function(){n.nextTick(function(){e.set()})},e.onDel=function(t){(46===t.keyCode||8===t.keyCode)&&e.set()},t.addEventListener("cut",e.onCut),t.addEventListener("keyup",e.onDel))},update:function(e){if(!this.lock){var t=this,i=t.el;if("SELECT"===i.tagName){for(var r=i.options,s=r.length,o=-1;s--;)if(r[s].value==e){o=s;break}r.selectedIndex=o}else"radio"===i.type?i.checked=e==i.value:"checkbox"===i.type?i.checked=!!e:i[t.attr]=n.toText(e)}},unbind:function(){var e=this.el;e.removeEventListener(this.event,this.set),e.removeEventListener("compositionstart",this.cLock),e.removeEventListener("compositionend",this.cUnlock),r&&(e.removeEventListener("cut",this.onCut),e.removeEventListener("keyup",this.onDel))}}}),e.register("vue/src/directives/with.js",function(e,t,i){var n; | ||
i.exports={bind:function(){this.isEmpty&&this.build()},update:function(e){this.component?this.component.$data=e:this.build(e)},build:function(e){n=n||t("../viewmodel");var i=this.Ctor||n;this.component=new i({el:this.el,data:e,compilerOptions:{parentCompiler:this.compiler}})},unbind:function(){this.component.$destroy()}}}),e.register("vue/src/directives/html.js",function(e,t,i){var n=t("../utils").toText,r=Array.prototype.slice;i.exports={bind:function(){8===this.el.nodeType&&(this.holder=document.createElement("div"),this.nodes=[])},update:function(e){e=n(e),this.holder?this.swap(e):this.el.innerHTML=e},swap:function(e){for(var t,i=this.el.parentNode,n=this.holder,s=this.nodes,o=s.length;o--;)i.removeChild(s[o]);for(n.innerHTML=e,s=this.nodes=r.call(n.childNodes),o=0,t=s.length;t>o;o++)i.insertBefore(s[o],this.el)}}}),e.register("vue/src/directives/style.js",function(e,t,i){function n(e){return e[1].toUpperCase()}var r=/-([a-z])/g,s=["webkit","moz","ms"];i.exports={bind:function(){var e=this.arg,t=e.charAt(0);"$"===t?(e=e.slice(1),this.prefixed=!0):"-"===t&&(e=e.slice(1)),this.prop=e.replace(r,n)},update:function(e){var t=this.prop;if(this.el.style[t]=e,this.prefixed){t=t.charAt(0).toUpperCase()+t.slice(1);for(var i=s.length;i--;)this.el.style[s[i]+t]=e}}}}),e.alias("component-emitter/index.js","vue/deps/emitter/index.js"),e.alias("component-emitter/index.js","emitter/index.js"),e.alias("vue/src/main.js","vue/index.js"),"object"==typeof exports?module.exports=e("vue"):"function"==typeof define&&define.amd?define(function(){return e("vue")}):window.Vue=e("vue")}(); | ||
!function(){"use strict";function e(t,i,n){var r=e.resolve(t);if(null==r){n=n||t,i=i||"root";var s=new Error('Failed to require "'+n+'" from "'+i+'"');throw s.path=n,s.parent=i,s.require=!0,s}var o=e.modules[r];if(!o._resolving&&!o.exports){var a={};a.exports={},a.client=a.component=!0,o._resolving=!0,o.call(this,a.exports,e.relative(r),a),delete o._resolving,o.exports=a.exports}return o.exports}e.modules={},e.aliases={},e.resolve=function(t){"/"===t.charAt(0)&&(t=t.slice(1));for(var i=[t,t+".js",t+".json",t+"/index.js",t+"/index.json"],n=0;n<i.length;n++){var t=i[n];if(e.modules.hasOwnProperty(t))return t;if(e.aliases.hasOwnProperty(t))return e.aliases[t]}},e.normalize=function(e,t){var i=[];if("."!=t.charAt(0))return t;e=e.split("/"),t=t.split("/");for(var n=0;n<t.length;++n)".."==t[n]?e.pop():"."!=t[n]&&""!=t[n]&&i.push(t[n]);return e.concat(i).join("/")},e.register=function(t,i){e.modules[t]=i},e.alias=function(t,i){if(!e.modules.hasOwnProperty(t))throw new Error('Failed to alias "'+t+'", it does not exist');e.aliases[i]=t},e.relative=function(t){function i(e,t){for(var i=e.length;i--;)if(e[i]===t)return i;return-1}function n(i){var r=n.resolve(i);return e(r,t,i)}var r=e.normalize(t,"..");return n.resolve=function(n){var s=n.charAt(0);if("/"==s)return n.slice(1);if("."==s)return e.normalize(r,n);var o=t.split("/"),a=i(o,"deps")+1;return a||(a=0),n=o.slice(0,a+1).join("/")+"/deps/"+n},n.exists=function(t){return e.modules.hasOwnProperty(n.resolve(t))},n},e.register("component-emitter/index.js",function(e,t,i){function n(e){return e?r(e):void 0}function r(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}i.exports=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[e]=this._callbacks[e]||[]).push(t),this},n.prototype.once=function(e,t){function i(){n.off(e,i),t.apply(this,arguments)}var n=this;return this._callbacks=this._callbacks||{},i.fn=t,this.on(e,i),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var i=this._callbacks[e];if(!i)return this;if(1==arguments.length)return delete this._callbacks[e],this;for(var n,r=0;r<i.length;r++)if(n=i[r],n===t||n.fn===t){i.splice(r,1);break}return this},n.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),i=this._callbacks[e];if(i){i=i.slice(0);for(var n=0,r=i.length;r>n;++n)i[n].apply(this,t)}return this},n.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[e]||[]},n.prototype.hasListeners=function(e){return!!this.listeners(e).length}}),e.register("vue/src/main.js",function(e,t,i){function n(e){var t=this;e=r(e,t.options,!0),a.processOptions(e);var i=function(i,n){n||(i=r(i,e,!0)),t.call(this,i,!0)},s=i.prototype=Object.create(t.prototype);a.defProtected(s,"constructor",i);var c=e.methods;if(c)for(var u in c)u in o.prototype||"function"!=typeof c[u]||(s[u]=c[u]);return i.extend=n,i.super=t,i.options=e,l.forEach(function(e){i[e]=o[e]}),i}function r(e,t,i){if(e=e||c(),!t)return e;for(var n in t)if("el"!==n&&"methods"!==n){var s=e[n],o=t[n],l=a.typeOf(s);i&&"Function"===l&&o?(e[n]=[s],Array.isArray(o)?e[n]=e[n].concat(o):e[n].push(o)):i&&"Object"===l?r(s,o):void 0===s&&(e[n]=o)}return e}var s=t("./config"),o=t("./viewmodel"),a=t("./utils"),c=a.hash,l=["directive","filter","partial","transition","component"];o.options=s.globalAssets={directives:t("./directives"),filters:t("./filters"),partials:c(),transitions:c(),components:c()},l.forEach(function(e){o[e]=function(t,i){var n=this.options[e+"s"];return n||(n=this.options[e+"s"]=c()),i?("partial"===e?i=a.toFragment(i):"component"===e&&(i=a.toConstructor(i)),n[t]=i,this):n[t]}}),o.config=function(e,t){if("string"==typeof e){if(void 0===t)return s[e];s[e]=t}else a.extend(s,e);return this},o.require=function(e){return t("./"+e)},o.use=function(e){if("string"==typeof e)try{e=t(e)}catch(i){return a.warn("Cannot find plugin: "+e)}var n=[].slice.call(arguments,1);n.unshift(o),"function"==typeof e.install?e.install.apply(e,n):e.apply(null,n)},o.extend=n,o.nextTick=a.nextTick,i.exports=o}),e.register("vue/src/emitter.js",function(e,t,i){var n,r="emitter";try{n=t(r)}catch(s){n=t("events").EventEmitter,n.prototype.off=function(){var e=arguments.length>1?this.removeListener:this.removeAllListeners;return e.apply(this,arguments)}}i.exports=n}),e.register("vue/src/config.js",function(e,t,i){function n(){s.forEach(function(e){o.attrs[e]=r+"-"+e})}var r="v",s=["pre","ref","with","text","repeat","partial","component","transition"],o=i.exports={debug:!1,silent:!1,enterClass:"v-enter",leaveClass:"v-leave",attrs:{},get prefix(){return r},set prefix(e){r=e,n()}};n()}),e.register("vue/src/utils.js",function(e,t,i){var n,r=t("./config"),s=r.attrs,o={}.toString,a=[].join,c=window,l=c.console,u="classList"in document.documentElement,h=c.requestAnimationFrame||c.webkitRequestAnimationFrame||c.setTimeout,f=i.exports={hash:function(){return Object.create(null)},attr:function(e,t,i){var n=s[t],r=e.getAttribute(n);return i||null===r||e.removeAttribute(n),r},defProtected:function(e,t,i,n,r){e.hasOwnProperty(t)||Object.defineProperty(e,t,{value:i,enumerable:!!n,configurable:!!r})},typeOf:function(e){return o.call(e).slice(8,-1)},bind:function(e,t){return function(i){return e.call(t,i)}},toText:function(e){var t=typeof e;return"string"===t||"boolean"===t||"number"===t&&e==e?e:"object"===t&&null!==e?JSON.stringify(e):""},extend:function(e,t,i){for(var n in t)i&&e[n]||(e[n]=t[n])},unique:function(e){for(var t,i=f.hash(),n=e.length,r=[];n--;)t=e[n],i[t]||(i[t]=1,r.push(t));return r},toFragment:function(e){if("string"!=typeof e)return e;if("#"===e.charAt(0)){var t=document.getElementById(e.slice(1));if(!t)return;e=t.innerHTML}var i,n=document.createElement("div"),r=document.createDocumentFragment();for(n.innerHTML=e.trim();i=n.firstChild;)1===n.nodeType&&r.appendChild(i);return r},toConstructor:function(e){return n=n||t("./viewmodel"),"Object"===f.typeOf(e)?n.extend(e):"function"==typeof e?e:null},processOptions:function(e){var t,i=e.components,n=e.partials,r=e.template;if(i)for(t in i)i[t]=f.toConstructor(i[t]);if(n)for(t in n)n[t]=f.toFragment(n[t]);r&&(e.template=f.toFragment(r))},log:function(){r.debug&&l&&l.log(a.call(arguments," "))},warn:function(){!r.silent&&l&&(l.warn(a.call(arguments," ")),r.debug&&l.trace())},nextTick:function(e){h(e,0)},addClass:function(e,t){if(u)e.classList.add(t);else{var i=" "+e.className+" ";i.indexOf(" "+t+" ")<0&&(e.className=(i+t).trim())}},removeClass:function(e,t){if(u)e.classList.remove(t);else{for(var i=" "+e.className+" ",n=" "+t+" ";i.indexOf(n)>=0;)i=i.replace(n," ");e.className=i.trim()}}}}),e.register("vue/src/compiler.js",function(e,t,i){function n(e,t){var i=this;i.init=!0,t=i.options=t||m(),c.processOptions(t);var n=i.data=t.data||{};g(e,n,!0),g(e,t.methods,!0),g(i,t.compilerOptions);var o=i.setupElement(t);v("\nnew VM instance:",o.tagName,"\n"),i.vm=e,i.bindings=m(),i.dirs=[],i.deferred=[],i.exps=[],i.computed=[],i.childCompilers=[],i.emitter=new s,b(e,"$",m()),b(e,"$el",o),b(e,"$compiler",i),b(e,"$root",r(i).vm);var a=i.parentCompiler,l=c.attr(o,"ref");a&&(a.childCompilers.push(i),b(e,"$parent",a.vm),l&&(i.childId=l,a.vm.$[l]=e)),i.setupObserver();var u=t.computed;if(u)for(var h in u)i.createBinding(h);i.execHook("created"),g(n,e),i.observeData(n),i.repeat&&(i.createBinding("$index"),n.$key&&i.createBinding("$key")),i.compile(o,!0),i.deferred.forEach(i.bindDirective,i),i.parseDeps(),i.rawContent=null,i.init=!1,i.execHook("ready")}function r(e){for(;e.parentCompiler;)e=e.parentCompiler;return e}var s=t("./emitter"),o=t("./observer"),a=t("./config"),c=t("./utils"),l=t("./binding"),u=t("./directive"),h=t("./text-parser"),f=t("./deps-parser"),p=t("./exp-parser"),d=[].slice,v=c.log,m=c.hash,g=c.extend,b=c.defProtected,y={}.hasOwnProperty,_=["created","ready","beforeDestroy","afterDestroy","attached","detached"],x=n.prototype;x.setupElement=function(e){var t=this.el="string"==typeof e.el?document.querySelector(e.el):e.el||document.createElement(e.tagName||"div"),i=e.template;if(i){for(var n,r=this.rawContent=document.createDocumentFragment();n=t.firstChild;)r.appendChild(n);if(e.replace&&1===i.childNodes.length){var s=i.childNodes[0].cloneNode(!0);t.parentNode&&(t.parentNode.insertBefore(s,t),t.parentNode.removeChild(t)),t=s}else t.appendChild(i.cloneNode(!0))}e.id&&(t.id=e.id),e.className&&(t.className=e.className);var o=e.attributes;if(o)for(var a in o)t.setAttribute(a,o[a]);return t},x.setupObserver=function(){function e(e){n(e),f.catcher.emit("get",o[e])}function t(e,t,i){c.emit("change:"+e,t,i),n(e),o[e].update(t)}function i(e,t){c.on("hook:"+e,function(){t.call(r.vm,a)})}function n(e){o[e]||r.createBinding(e)}var r=this,o=r.bindings,a=r.options,c=r.observer=new s;c.proxies=m(),c.on("get",e).on("set",t).on("mutate",t),_.forEach(function(e){var t=a[e];if(Array.isArray(t))for(var n=t.length;n--;)i(e,t[n]);else t&&i(e,t)})},x.observeData=function(e){function t(e){"$data"!==e&&r.update(i.data)}var i=this,n=i.observer;o.observe(e,"",n);var r=i.bindings.$data=new l(i,"$data");r.update(e),Object.defineProperty(i.vm,"$data",{enumerable:!1,get:function(){return i.observer.emit("get","$data"),i.data},set:function(e){var t=i.data;o.unobserve(t,"",n),i.data=e,o.copyPaths(e,t),o.observe(e,"",n),i.observer.emit("set","$data",e)}}),n.on("set",t).on("mutate",t)},x.compile=function(e,t){var i=this,n=e.nodeType,r=e.tagName;if(1===n&&"SCRIPT"!==r){if(null!==c.attr(e,"pre"))return;var s,o,a,l,h=c.attr(e,"component")||r.toLowerCase(),f=i.getOption("components",h);if(s=c.attr(e,"repeat"))l=u.parse("repeat",s,i,e),l&&(l.Ctor=f,i.deferred.push(l));else if(t!==!0&&((o=c.attr(e,"with"))||f))l=u.parse("with",o||"",i,e),l&&(l.Ctor=f,i.deferred.push(l));else{if(e.vue_trans=c.attr(e,"transition"),a=c.attr(e,"partial")){var p=i.getOption("partials",a);p&&(e.innerHTML="",e.appendChild(p.cloneNode(!0)))}i.compileNode(e)}}else 3===n&&i.compileTextNode(e)},x.compileNode=function(e){var t,i,n=d.call(e.attributes),r=a.prefix+"-";if(n&&n.length){var s,o,c,l,f,p;for(t=n.length;t--;){if(s=n[t],o=!1,0===s.name.indexOf(r))for(o=!0,c=u.split(s.value),i=c.length;i--;)l=c[i],p=s.name.slice(r.length),f=u.parse(p,l,this,e),f&&this.bindDirective(f);else l=h.parseAttr(s.value),l&&(f=u.parse("attr",s.name+":"+l,this,e),f&&this.bindDirective(f));o&&"cloak"!==p&&e.removeAttribute(s.name)}}e.childNodes.length&&d.call(e.childNodes).forEach(this.compile,this)},x.compileTextNode=function(e){var t=h.parse(e.nodeValue);if(t){for(var i,n,r,s,o,l,f=0,p=t.length;p>f;f++){if(n=t[f],r=l=null,n.key)if(">"===n.key.charAt(0)){if(o=n.key.slice(1).trim(),"yield"===o)i=this.rawContent;else{if(s=this.getOption("partials",o),!s){c.warn("Unknown partial: "+o);continue}i=s.cloneNode(!0)}i&&(l=d.call(i.childNodes))}else n.html?(i=document.createComment(a.prefix+"-html"),r=u.parse("html",n.key,this,i)):(i=document.createTextNode(""),r=u.parse("text",n.key,this,i));else i=document.createTextNode(n);e.parentNode.insertBefore(i,e),r&&this.bindDirective(r),l&&l.forEach(this.compile,this)}e.parentNode.removeChild(e)}},x.bindDirective=function(e){if(this.dirs.push(e),e.isEmpty||!e._update)return void(e.bind&&e.bind());var t,i=this,n=e.key;if(e.isExp)t=i.createBinding(n,!0,e.isFn);else{for(;i&&!i.hasKey(n);)i=i.parentCompiler;i=i||this,t=i.bindings[n]||i.createBinding(n)}t.dirs.push(e),e.binding=t,e.bind&&e.bind(),e.update(t.val(),!0)},x.createBinding=function(e,t,i){v(" created binding: "+e);var n=this,r=n.bindings,s=n.options.computed,a=new l(n,e,t,i);if(t)n.defineExp(e,a);else if(r[e]=a,a.root)s&&s[e]?n.defineComputed(e,a,s[e]):n.defineProp(e,a);else{o.ensurePath(n.data,e);var c=e.slice(0,e.lastIndexOf("."));r[c]||n.createBinding(c)}return a},x.defineProp=function(e,t){var i=this,n=i.data,r=n.__emitter__;e in n||(n[e]=void 0),!r||e in r.values||o.convert(n,e),t.value=n[e],Object.defineProperty(i.vm,e,{get:function(){return i.data[e]},set:function(t){i.data[e]=t}})},x.defineExp=function(e,t){var i=p.parse(e,this);i&&(this.markComputed(t,i),this.exps.push(t))},x.defineComputed=function(e,t,i){this.markComputed(t,i),Object.defineProperty(this.vm,e,{get:t.value.$get,set:t.value.$set})},x.markComputed=function(e,t){e.isComputed=!0,e.isFn?e.value=t:("function"==typeof t&&(t={$get:t}),e.value={$get:c.bind(t.$get,this.vm),$set:t.$set?c.bind(t.$set,this.vm):void 0}),this.computed.push(e)},x.getOption=function(e,t){var i=this.options,n=this.parentCompiler,r=a.globalAssets;return i[e]&&i[e][t]||(n?n.getOption(e,t):r[e]&&r[e][t])},x.execHook=function(e){e="hook:"+e,this.observer.emit(e),this.emitter.emit(e)},x.hasKey=function(e){var t=e.split(".")[0];return y.call(this.data,t)||y.call(this.vm,t)},x.parseDeps=function(){this.computed.length&&f.parse(this.computed)},x.destroy=function(){if(!this.destroyed){var e,t,i,n,r,s=this,a=s.vm,c=s.el,l=s.dirs,u=s.exps,h=s.bindings;for(s.execHook("beforeDestroy"),o.unobserve(s.data,"",s.observer),e=l.length;e--;)i=l[e],i.binding&&i.binding.compiler!==s&&(n=i.binding.dirs,n&&n.splice(n.indexOf(i),1)),i.unbind();for(e=u.length;e--;)u[e].unbind();for(t in h)r=h[t],r&&r.unbind();var f=s.parentCompiler,p=s.childId;f&&(f.childCompilers.splice(f.childCompilers.indexOf(s),1),p&&delete f.vm.$[p]),c===document.body?c.innerHTML="":a.$remove(),this.destroyed=!0,s.execHook("afterDestroy"),s.observer.off(),s.emitter.off()}},i.exports=n}),e.register("vue/src/viewmodel.js",function(e,t,i){function n(e){new s(this,e)}function r(e){return"string"==typeof e?document.querySelector(e):e}var s=t("./compiler"),o=t("./utils"),a=t("./transition"),c=o.defProtected,l=o.nextTick,u=n.prototype;c(u,"$set",function(e,t){for(var i=e.split("."),n=this,r=0,s=i.length-1;s>r;r++)n=n[i[r]];n[i[r]]=t}),c(u,"$watch",function(e,t){function i(){var e=arguments;o.nextTick(function(){t.apply(n,e)})}var n=this;t._fn=i,n.$compiler.observer.on("change:"+e,i)}),c(u,"$unwatch",function(e,t){var i=["change:"+e],n=this.$compiler.observer;t&&i.push(t._fn),n.off.apply(n,i)}),c(u,"$destroy",function(){this.$compiler.destroy()}),c(u,"$broadcast",function(){for(var e,t=this.$compiler.childCompilers,i=t.length;i--;)e=t[i],e.emitter.emit.apply(e.emitter,arguments),e.vm.$broadcast.apply(e.vm,arguments)}),c(u,"$dispatch",function(){var e=this.$compiler,t=e.emitter,i=e.parentCompiler;t.emit.apply(t,arguments),i&&i.vm.$dispatch.apply(i.vm,arguments)}),["emit","on","off","once"].forEach(function(e){c(u,"$"+e,function(){var t=this.$compiler.emitter;t[e].apply(t,arguments)})}),c(u,"$appendTo",function(e,t){e=r(e);var i=this.$el;a(i,1,function(){e.appendChild(i),t&&l(t)},this.$compiler)}),c(u,"$remove",function(e){var t=this.$el,i=t.parentNode;i&&a(t,-1,function(){i.removeChild(t),e&&l(e)},this.$compiler)}),c(u,"$before",function(e,t){e=r(e);var i=this.$el,n=e.parentNode;n&&a(i,1,function(){n.insertBefore(i,e),t&&l(t)},this.$compiler)}),c(u,"$after",function(e,t){e=r(e);var i=this.$el,n=e.parentNode,s=e.nextSibling;n&&a(i,1,function(){s?n.insertBefore(i,s):n.appendChild(i),t&&l(t)},this.$compiler)}),i.exports=n}),e.register("vue/src/binding.js",function(e,t,i){function n(e,t,i,n){this.id=s++,this.value=void 0,this.isExp=!!i,this.isFn=n,this.root=!this.isExp&&-1===t.indexOf("."),this.compiler=e,this.key=t,this.dirs=[],this.subs=[],this.deps=[],this.unbound=!1}var r=t("./batcher"),s=0,o=n.prototype;o.update=function(e){(!this.isComputed||this.isFn)&&(this.value=e),(this.dirs.length||this.subs.length)&&r.queue(this)},o._update=function(){for(var e=this.dirs.length,t=this.val();e--;)this.dirs[e].update(t);this.pub()},o.val=function(){return this.isComputed&&!this.isFn?this.value.$get():this.value},o.pub=function(){for(var e=this.subs.length;e--;)this.subs[e].update()},o.unbind=function(){this.unbound=!0;for(var e=this.dirs.length;e--;)this.dirs[e].unbind();e=this.deps.length;for(var t;e--;)t=this.deps[e].subs,t.splice(t.indexOf(this),1)},i.exports=n}),e.register("vue/src/observer.js",function(e,t,i){function n(e){if("function"==typeof e){for(var t=this.length,i=[];t--;)e(this[t])&&i.push(this.splice(t,1)[0]);return i.reverse()}return"number"!=typeof e&&(e=this.indexOf(e)),e>-1?this.splice(e,1)[0]:void 0}function r(e,t){if("function"==typeof e){for(var i,n=this.length,r=[];n--;)i=e(this[n]),void 0!==i&&r.push(this.splice(n,1,i)[0]);return r.reverse()}return"number"!=typeof e&&(e=this.indexOf(e)),e>-1?this.splice(e,1,t)[0]:void 0}function s(e){for(var t in e)a(e,t)}function o(e){var t=e.__emitter__;if(t||(t=new v,b(e,"__emitter__",t)),k)e.__proto__=w;else for(var i in w)b(e,i,w[i])}function a(e,t){function i(e,i){s[t]=e,r.emit("set",t,e,i),Array.isArray(e)&&r.emit("set",t+".length",e.length),f(e,t,r)}var n=t.charAt(0);if("$"!==n&&"_"!==n||"$index"===t||"$key"===t||"$value"===t){var r=e.__emitter__,s=r.values;i(e[t]),Object.defineProperty(e,t,{get:function(){var e=s[t];return C.shouldGet&&g(e)!==_&&r.emit("get",t),e},set:function(e){var n=s[t];p(n,t,r),u(e,n),i(e,!0)}})}}function c(e){d=d||t("./viewmodel");var i=g(e);return!(i!==_&&i!==x||e instanceof d)}function l(e){var t=g(e),i=e&&e.__emitter__;if(t===x)i.emit("set","length",e.length);else if(t===_){var n,r;for(n in e)r=e[n],i.emit("set",n,r),l(r)}}function u(e,t){if(g(t)===_&&g(e)===_){var i,n,r,s;for(i in t)i in e||(r=t[i],n=g(r),n===_?(s=e[i]={},u(s,r)):e[i]=n===x?[]:void 0)}}function h(e,t){for(var i,n=t.split("."),r=0,s=n.length-1;s>r;r++)i=n[r],e[i]||(e[i]={},e.__emitter__&&a(e,i)),e=e[i];g(e)===_&&(i=n[r],i in e||(e[i]=void 0,e.__emitter__&&a(e,i)))}function f(e,t,i){if(c(e)){var n,r=t?t+".":"",a=!!e.__emitter__;a||b(e,"__emitter__",new v),n=e.__emitter__,n.values=n.values||m.hash(),i.proxies=i.proxies||{};var u=i.proxies[r]={get:function(e){i.emit("get",r+e)},set:function(n,s,o){i.emit("set",r+n,s),t&&o&&i.emit("set",t,e,!0)},mutate:function(e,n,s){var o=e?r+e:t;i.emit("mutate",o,n,s);var a=s.method;"sort"!==a&&"reverse"!==a&&i.emit("set",o+".length",n.length)}};if(n.on("get",u.get).on("set",u.set).on("mutate",u.mutate),a)l(e);else{var h=g(e);h===_?s(e):h===x&&o(e)}}}function p(e,t,i){if(e&&e.__emitter__){t=t?t+".":"";var n=i.proxies[t];n&&(e.__emitter__.off("get",n.get).off("set",n.set).off("mutate",n.mutate),i.proxies[t]=null)}}var d,v=t("./emitter"),m=t("./utils"),g=m.typeOf,b=m.defProtected,y=[].slice,_="Object",x="Array",$=["push","pop","shift","unshift","splice","sort","reverse"],k={}.__proto__,w=Object.create(Array.prototype);$.forEach(function(e){b(w,e,function(){var t=Array.prototype[e].apply(this,arguments);return this.__emitter__.emit("mutate",null,this,{method:e,args:y.call(arguments),result:t}),t},!k)}),b(w,"remove",n,!k),b(w,"set",r,!k),b(w,"replace",r,!k);var C=i.exports={shouldGet:!1,observe:f,unobserve:p,ensurePath:h,convert:a,copyPaths:u,watchArray:o}}),e.register("vue/src/directive.js",function(e,t,i){function n(e,t,i,n,o){this.compiler=n,this.vm=n.vm,this.el=o;var a=""===t;if("function"==typeof e)this[a?"bind":"_update"]=e;else for(var c in e)"unbind"===c||"update"===c?this["_"+c]=e[c]:this[c]=e[c];if(a)return void(this.isEmpty=!0);this.expression=t.trim(),this.rawKey=i,r(this,i),this.isExp=!v.test(this.key)||d.test(this.key);var l=this.expression.slice(i.length).match(f);if(l){this.filters=[];for(var u,h=0,p=l.length;p>h;h++)u=s(l[h],this.compiler),u&&this.filters.push(u);this.filters.length||(this.filters=null)}else this.filters=null}function r(e,t){var i=t;if(t.indexOf(":")>-1){var n=t.match(h);i=n?n[2].trim():i,e.arg=n?n[1].trim():null}e.key=i}function s(e,t){var i=e.slice(1).match(p);if(i){i=i.map(function(e){return e.replace(/'/g,"").trim()});var n=i[0],r=t.getOption("filters",n)||c[n];return r?{name:n,apply:r,args:i.length>1?i.slice(1):null}:void o.warn("Unknown filter: "+n)}}var o=t("./utils"),a=t("./directives"),c=t("./filters"),l=/(?:['"](?:\\.|[^'"])*['"]|\((?:\\.|[^\)])*\)|\\.|[^,])+/g,u=/^(?:['"](?:\\.|[^'"])*['"]|\\.|[^\|]|\|\|)+/,h=/^([\w-$ ]+):(.+)$/,f=/\|[^\|]+/g,p=/[^\s']+|'[^']+'/g,d=/^\$(parent|root)\./,v=/^[\w\.$]+$/,m=n.prototype;m.update=function(e,t){var i=o.typeOf(e);(t||e!==this.value||"Object"===i||"Array"===i)&&(this.value=e,this._update&&this._update(this.filters?this.applyFilters(e):e,t))},m.applyFilters=function(e){for(var t,i=e,n=0,r=this.filters.length;r>n;n++)t=this.filters[n],i=t.apply.call(this.vm,i,t.args);return i},m.unbind=function(){this.el&&this.vm&&(this._unbind&&this._unbind(),this.vm=this.el=this.binding=this.compiler=null)},n.split=function(e){return e.indexOf(",")>-1?e.match(l)||[""]:[e]},n.parse=function(e,t,i,r){var s=i.getOption("directives",e)||a[e];if(!s)return o.warn("unknown directive: "+e);var c;if(t.indexOf("|")>-1){var l=t.match(u);l&&(c=l[0].trim())}else c=t.trim();return c||""===t?new n(s,t,c,i,r):o.warn("invalid directive expression: "+t)},i.exports=n}),e.register("vue/src/exp-parser.js",function(e,t,i){function n(e){return e=e.replace(d,"").replace(v,",").replace(p,"").replace(m,"").replace(g,""),e?e.split(/,+/):[]}function r(e,t){for(var i="",n=0,r=t;t&&!t.hasKey(e);)t=t.parentCompiler,n++;if(t){for(;n--;)i+="$parent.";t.bindings[e]||"$"===e.charAt(0)||t.createBinding(e)}else r.createBinding(e);return i}function s(e,t){var i;try{i=new Function(e)}catch(n){a.warn("Invalid expression: "+t)}return i}function o(e){return"$"===e.charAt(0)?"\\"+e:e}var a=t("./utils"),c=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,l=/"(\d+)"/g,u=new RegExp("constructor".split("").join("['\"+, ]*")),h=/\\u\d\d\d\d/,f="break,case,catch,continue,debugger,default,delete,do,else,false,finally,for,function,if,in,instanceof,new,null,return,switch,this,throw,true,try,typeof,var,void,while,with,undefined,abstract,boolean,byte,char,class,const,double,enum,export,extends,final,float,goto,implements,import,int,interface,long,native,package,private,protected,public,short,static,super,synchronized,throws,transient,volatile,arguments,let,yield,Math",p=new RegExp(["\\b"+f.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),d=/\/\*(?:.|\n)*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|'[^']*'|"[^"]*"|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,v=/[^\w$]+/g,m=/\b\d[^,]*/g,g=/^,+|,+$/g;i.exports={parse:function(e,t){function i(e){var t=g.length;return g[t]=e,'"'+t+'"'}function f(e){var i=e.charAt(0);e=e.slice(1);var n="this."+r(e,t)+e;return m[e]||(v+=n+";",m[e]=1),i+n}function p(e,t){return g[t]}if(h.test(e)||u.test(e))return a.warn("Unsafe expression: "+e),function(){};var d=n(e);if(!d.length)return s("return "+e,e);d=a.unique(d);var v="",m=a.hash(),g=[],b=new RegExp("[^$\\w\\.]("+d.map(o).join("|")+")[$\\w\\.]*\\b","g"),y=("return "+e).replace(c,i).replace(b,f).replace(l,p);return y=v+y,s(y,e)}}}),e.register("vue/src/text-parser.js",function(e){function t(e){if(!n.test(e))return null;for(var t,i,s,o=[];t=e.match(n);)i=t.index,i>0&&o.push(e.slice(0,i)),s={key:t[1].trim()},r.test(t[0])&&(s.html=!0),o.push(s),e=e.slice(i+t[0].length);return e.length&&o.push(e),o}function i(e){var i=t(e);if(!i)return null;for(var n,r=[],s=0,o=i.length;o>s;s++)n=i[s],r.push(n.key||'"'+n+'"');return r.join("+")}var n=/{{{?([^{}]+?)}?}}/,r=/{{{[^{}]+}}}/;e.parse=t,e.parseAttr=i}),e.register("vue/src/deps-parser.js",function(e,t,i){function n(e){if(!e.isFn){s.log("\n- "+e.key);var t=s.hash();e.deps=[],a.on("get",function(i){var n=t[i.key];n&&n.compiler===i.compiler||(t[i.key]=i,s.log(" - "+i.key),e.deps.push(i),i.subs.push(e))}),e.value.$get(),a.off("get")}}var r=t("./emitter"),s=t("./utils"),o=t("./observer"),a=new r;i.exports={catcher:a,parse:function(e){s.log("\nparsing dependencies..."),o.shouldGet=!0,e.forEach(n),o.shouldGet=!1,s.log("\ndone.")}}}),e.register("vue/src/filters.js",function(e,t,i){var n={enter:13,tab:9,"delete":46,up:38,left:37,right:39,down:40,esc:27};i.exports={capitalize:function(e){return e||0===e?(e=e.toString(),e.charAt(0).toUpperCase()+e.slice(1)):""},uppercase:function(e){return e||0===e?e.toString().toUpperCase():""},lowercase:function(e){return e||0===e?e.toString().toLowerCase():""},currency:function(e,t){if(!e&&0!==e)return"";var i=t&&t[0]||"$",n=Math.floor(e).toString(),r=n.length%3,s=r>0?n.slice(0,r)+(n.length>3?",":""):"",o="."+e.toFixed(2).slice(-2);return i+s+n.slice(r).replace(/(\d{3})(?=\d)/g,"$1,")+o},pluralize:function(e,t){return t.length>1?t[e-1]||t[t.length-1]:t[e-1]||t[0]+"s"},key:function(e,t){if(e){var i=n[t[0]];return i||(i=parseInt(t[0],10)),function(t){t.keyCode===i&&e.call(this,t)}}}}}),e.register("vue/src/transition.js",function(e,t,i){function n(e,t,i){if(!o)return i(),c.CSS_SKIP;var n=e.classList,r=e.vue_trans_cb;if(t>0){r&&(e.removeEventListener(o,r),e.vue_trans_cb=null),n.add(a.enterClass),i();{e.clientHeight}return n.remove(a.enterClass),c.CSS_E}if(e.offsetWidth||e.offsetHeight){n.add(a.leaveClass);var s=function(t){t.target===e&&(e.removeEventListener(o,s),e.vue_trans_cb=null,i(),n.remove(a.leaveClass))};e.addEventListener(o,s),e.vue_trans_cb=s}else i();return c.CSS_L}function r(e,t,i,n,r){var s=r.getOption("transitions",n);if(!s)return i(),c.JS_SKIP;var o=s.enter,a=s.leave;return t>0?"function"!=typeof o?(i(),c.JS_SKIP_E):(o(e,i),c.JS_E):"function"!=typeof a?(i(),c.JS_SKIP_L):(a(e,i),c.JS_L)}function s(){var e=document.createElement("vue"),t="transitionend",i={transition:t,mozTransition:t,webkitTransition:"webkitTransitionEnd"};for(var n in i)if(void 0!==e.style[n])return i[n]}var o=s(),a=t("./config"),c={CSS_E:1,CSS_L:2,JS_E:3,JS_L:4,CSS_SKIP:-1,JS_SKIP:-2,JS_SKIP_E:-3,JS_SKIP_L:-4,INIT:-5,SKIP:-6},l=i.exports=function(e,t,i,s){var o=function(){i(),s.execHook(t>0?"attached":"detached")};if(s.init)return o(),c.INIT;var a=e.vue_trans;return a?r(e,t,o,a,s):""===a?n(e,t,o):(o(),c.SKIP)};l.codes=c}),e.register("vue/src/batcher.js",function(e,t){function i(){for(var e=0;e<r.length;e++){var t=r[e];t.unbound||(t._update(),s[t.id]=!1)}n()}function n(){r=[],s=a.hash(),o=!1}var r,s,o,a=t("./utils");n(),e.queue=function(e){s[e.id]||(r.push(e),s[e.id]=!0,o||(o=!0,a.nextTick(i)))}}),e.register("vue/src/directives/index.js",function(e,t,i){var n=t("../utils"),r=t("../config"),s=t("../transition"),o=/^[\d\.]+$/,a=/\\,/g;i.exports={on:t("./on"),repeat:t("./repeat"),model:t("./model"),"if":t("./if"),"with":t("./with"),html:t("./html"),style:t("./style"),attr:function(e){e||0===e?this.el.setAttribute(this.arg,e):this.el.removeAttribute(this.arg)},text:function(e){this.el.textContent=n.toText(e)},show:function(e){var t=this.el,i=e?"":"none",n=function(){t.style.display=i};s(t,e?1:-1,n,this.compiler)},"class":function(e){this.arg?n[e?"addClass":"removeClass"](this.el,this.arg):(this.lastVal&&n.removeClass(this.el,this.lastVal),e&&(n.addClass(this.el,e),this.lastVal=e))},cloak:{bind:function(){var e=this.el;this.compiler.observer.once("hook:ready",function(){e.removeAttribute(r.prefix+"-cloak")})}},data:{bind:function(){var e=this.key;this.vm.$set(this.arg,o.test(e)?+e:e.replace(a,","))}}}}),e.register("vue/src/directives/if.js",function(e,t,i){var n=t("../config"),r=t("../transition");i.exports={bind:function(){this.parent=this.el.parentNode,this.ref=document.createComment(n.prefix+"-if-"+this.key),this.el.vue_ref=this.ref},update:function(e){function t(){if(n.parentNode){var e=n.nextSibling;e?s.insertBefore(o,e):s.appendChild(o),s.removeChild(n)}}function i(){n.parentNode||(s.insertBefore(n,o),s.removeChild(o))}var n=this.el;if(!this.parent){if(!n.parentNode)return;this.parent=n.parentNode}var s=this.parent,o=this.ref,a=this.compiler;e?r(n,1,i,a):r(n,-1,t,a)},unbind:function(){this.el.vue_ref=null;var e=this.ref;e.parentNode&&e.parentNode.removeChild(e)}}}),e.register("vue/src/directives/repeat.js",function(e,t,i){function n(e){var t,i,n=[];for(var r in e)t=e[r],i="Object"===a.typeOf(t)?t:{$value:t},u(i,"$key",r,!1,!0),n.push(i);return n}function r(e,t){for(var i=0,n=e.length;n>i;i++)if(e[i]===t||t.$value&&e[i].$value===t.$value)return i;return-1}var s,o=t("../observer"),a=t("../utils"),c=t("../config"),l=t("../transition"),u=a.defProtected,h={push:function(e){for(var t=e.args.length,i=this.collection.length-t,n=0;t>n;n++)this.buildItem(e.args[n],i+n),this.updateObject(e.args[n],1)},pop:function(){var e=this.vms.pop();e&&(e.$destroy(),this.updateObject(e.$data,-1))},unshift:function(e){for(var t=0,i=e.args.length;i>t;t++)this.buildItem(e.args[t],t),this.updateObject(e.args[t],1)},shift:function(){var e=this.vms.shift();e&&(e.$destroy(),this.updateObject(e.$data,-1))},splice:function(e){var t,i,n=e.args[0],r=e.args[1],s=e.args.length-2,o=this.vms.splice(n,r);for(t=0,i=o.length;i>t;t++)o[t].$destroy(),this.updateObject(o[t].$data,-1);for(t=0;s>t;t++)this.buildItem(e.args[t+2],n+t),this.updateObject(e.args[t+2],1)},sort:function(){var e,t,i,n,r=this.vms,s=this.collection,o=s.length,a=new Array(o);for(e=0;o>e;e++)for(n=s[e],t=0;o>t;t++)if(i=r[t],i.$data===n){a[e]=i;break}for(e=0;o>e;e++)this.container.insertBefore(a[e].$el,this.ref);this.vms=a},reverse:function(){var e=this.vms;e.reverse();for(var t=0,i=e.length;i>t;t++)this.container.insertBefore(e[t].$el,this.ref)}};i.exports={bind:function(){var e=this.el,i=this.container=e.parentNode;s=s||t("../viewmodel"),this.Ctor=this.Ctor||s,this.hasTrans=e.hasAttribute(c.attrs.transition),this.childId=a.attr(e,"ref"),this.ref=document.createComment(c.prefix+"-repeat-"+this.key),i.insertBefore(this.ref,e),i.removeChild(e),this.initiated=!1,this.collection=null,this.vms=null;var n=this;this.mutationListener=function(e,t,i){var r=i.method;if(h[r].call(n,i),"push"!==r&&"pop"!==r)for(var s=t.length;s--;)t[s].$index=s;("push"===r||"unshift"===r||"splice"===r)&&n.changed()}},update:function(e,t){if(e!==this.collection&&e!==this.object){"Object"===a.typeOf(e)&&(this.object&&delete this.object.$repeater,this.object=e,e=n(e),u(this.object,"$repeater",e,!1,!0)),this.reset(),this.container.vue_dHandlers=a.hash(),this.initiated||e&&e.length||(this.buildItem(),this.initiated=!0),this.old=this.collection;var i=this.oldVMs=this.vms;if(e=this.collection=e||[],this.vms=[],this.childId&&(this.vm.$[this.childId]=this.vms),e.__emitter__||o.watchArray(e),e.__emitter__.on("mutate",this.mutationListener),e.length&&(e.forEach(this.buildItem,this),t||this.changed()),i)for(var r,s=i.length;s--;)r=i[s],r.$reused?r.$reused=!1:r.$destroy();this.old=this.oldVMs=null}},changed:function(){if(!this.queued){this.queued=!0;var e=this;setTimeout(function(){e.compiler&&(e.compiler.parseDeps(),e.queued=!1)},0)}},buildItem:function(e,t){var i,n,s,o,c,h,f=this.container,p=this.vms,d=this.collection;e&&(this.old&&(n=r(this.old,e)),n>-1?(o=this.oldVMs[n],o.$reused=!0,i=o.$el,e.$index=t,h=!i.parentNode):(i=this.el.cloneNode(!0),i.vue_trans=a.attr(i,"transition",!0),"Object"!==a.typeOf(e)&&(c=!0,e={$value:e}),u(e,"$index",t,!1,!0)),s=p.length>t?p[t].$el:this.ref,s.parentNode||(s=s.vue_ref),h?f.insertBefore(i.vue_ref,s):n>-1?f.insertBefore(i,s):l(i,1,function(){f.insertBefore(i,s)},this.compiler)),o=o||new this.Ctor({el:i,data:e,compilerOptions:{repeat:!0,parentCompiler:this.compiler,delegator:f}}),e?(p.splice(t,0,o),c&&e.__emitter__.on("set",function(e,t){"$value"===e&&(d[o.$index]=t)})):o.$destroy()},updateObject:function(e,t){if(this.object&&e.$key){var i=e.$key,n=e.$value||e;t>0?(delete e.$key,u(e,"$key",i,!1,!0),this.object[i]=n):delete this.object[i],this.object.__emitter__.emit("set",i,n,!0)}},reset:function(e){if(this.childId&&delete this.vm.$[this.childId],this.collection&&(this.collection.__emitter__.off("mutate",this.mutationListener),e))for(var t=this.vms.length;t--;)this.vms[t].$destroy();var i=this.container,n=i.vue_dHandlers;for(var r in n)i.removeEventListener(n[r].event,n[r]);i.vue_dHandlers=null},unbind:function(){this.reset(!0)}}}),e.register("vue/src/directives/on.js",function(e,t,i){function n(e,t,i){for(;e&&e!==t;){if(e[i])return e;e=e.parentNode}}var r=t("../utils");i.exports={isFn:!0,bind:function(){this.compiler.repeat&&(this.el[this.expression]=!0,this.el.vue_viewmodel=this.vm)},update:function(e){if(this.reset(),"function"!=typeof e)return r.warn('Directive "on" expects a function value.'); | ||
var t=this.compiler,i=this.arg,s=this.binding.isExp,o=this.binding.compiler.vm;if(t.repeat&&!this.vm.constructor.super&&"blur"!==i&&"focus"!==i){var a=t.delegator,c=this.expression,l=a.vue_dHandlers[c];if(l)return;l=a.vue_dHandlers[c]=function(t){var i=n(t.target,a,c);i&&(t.el=i,t.targetVM=i.vue_viewmodel,e.call(s?t.targetVM:o,t))},l.event=i,a.addEventListener(i,l)}else{var u=this.vm;this.handler=function(t){t.el=t.currentTarget,t.targetVM=u,e.call(o,t)},this.el.addEventListener(i,this.handler)}},reset:function(){this.el.removeEventListener(this.arg,this.handler),this.handler=null},unbind:function(){this.reset(),this.el.vue_viewmodel=null}}}),e.register("vue/src/directives/model.js",function(e,t,i){function n(e){return o.call(e.options,function(e){return e.selected}).map(function(e){return e.value||e.text})}var r=t("../utils"),s=navigator.userAgent.indexOf("MSIE 9.0")>0,o=[].filter;i.exports={bind:function(){var e=this,t=e.el,i=t.type,n=t.tagName;e.lock=!1,e.ownerVM=e.binding.compiler.vm,e.event=e.compiler.options.lazy||"SELECT"===n||"checkbox"===i||"radio"===i?"change":"input",e.attr="checkbox"===i?"checked":"INPUT"===n||"SELECT"===n||"TEXTAREA"===n?"value":"innerHTML","SELECT"===n&&t.hasAttribute("multiple")&&(this.multi=!0);var o=!1;e.cLock=function(){o=!0},e.cUnlock=function(){o=!1},t.addEventListener("compositionstart",this.cLock),t.addEventListener("compositionend",this.cUnlock),e.set=e.filters?function(){if(!o){var i;try{i=t.selectionStart}catch(n){}e._set(),r.nextTick(function(){void 0!==i&&t.setSelectionRange(i,i)})}}:function(){o||(e.lock=!0,e._set(),r.nextTick(function(){e.lock=!1}))},t.addEventListener(e.event,e.set),s&&(e.onCut=function(){r.nextTick(function(){e.set()})},e.onDel=function(t){(46===t.keyCode||8===t.keyCode)&&e.set()},t.addEventListener("cut",e.onCut),t.addEventListener("keyup",e.onDel))},_set:function(){this.ownerVM.$set(this.key,this.multi?n(this.el):this.el[this.attr])},update:function(e,t){if(t&&void 0===e)return this._set();if(!this.lock){var i=this.el;"SELECT"===i.tagName?(i.selectedIndex=-1,this.multi&&Array.isArray(e)?e.forEach(this.updateSelect,this):this.updateSelect(e)):"radio"===i.type?i.checked=e==i.value:"checkbox"===i.type?i.checked=!!e:i[this.attr]=r.toText(e)}},updateSelect:function(e){for(var t=this.el.options,i=t.length;i--;)if(t[i].value==e){t[i].selected=!0;break}},unbind:function(){var e=this.el;e.removeEventListener(this.event,this.set),e.removeEventListener("compositionstart",this.cLock),e.removeEventListener("compositionend",this.cUnlock),s&&(e.removeEventListener("cut",this.onCut),e.removeEventListener("keyup",this.onDel))}}}),e.register("vue/src/directives/with.js",function(e,t,i){var n;i.exports={bind:function(){this.isEmpty&&this.build()},update:function(e){this.component?this.component.$data=e:this.build(e)},build:function(e){n=n||t("../viewmodel");var i=this.Ctor||n;this.component=new i({el:this.el,data:e,compilerOptions:{parentCompiler:this.compiler}})},unbind:function(){this.component.$destroy()}}}),e.register("vue/src/directives/html.js",function(e,t,i){var n=t("../utils").toText,r=[].slice;i.exports={bind:function(){8===this.el.nodeType&&(this.holder=document.createElement("div"),this.nodes=[])},update:function(e){e=n(e),this.holder?this.swap(e):this.el.innerHTML=e},swap:function(e){for(var t,i=this.el.parentNode,n=this.holder,s=this.nodes,o=s.length;o--;)i.removeChild(s[o]);for(n.innerHTML=e,s=this.nodes=r.call(n.childNodes),o=0,t=s.length;t>o;o++)i.insertBefore(s[o],this.el)}}}),e.register("vue/src/directives/style.js",function(e,t,i){function n(e){return e[1].toUpperCase()}var r=/-([a-z])/g,s=["webkit","moz","ms"];i.exports={bind:function(){var e=this.arg;if(e){var t=e.charAt(0);"$"===t?(e=e.slice(1),this.prefixed=!0):"-"===t&&(e=e.slice(1)),this.prop=e.replace(r,n)}},update:function(e){var t=this.prop;if(t){if(this.el.style[t]=e,this.prefixed){t=t.charAt(0).toUpperCase()+t.slice(1);for(var i=s.length;i--;)this.el.style[s[i]+t]=e}}else this.el.style.cssText=e}}}),e.alias("component-emitter/index.js","vue/deps/emitter/index.js"),e.alias("component-emitter/index.js","emitter/index.js"),e.alias("vue/src/main.js","vue/index.js"),"object"==typeof exports?module.exports=e("vue"):"function"==typeof define&&define.amd?define(function(){return e("vue")}):window.Vue=e("vue")}(); |
{ | ||
"name": "vue", | ||
"version": "0.8.4", | ||
"version": "0.8.7", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Evan You", |
@@ -47,2 +47,3 @@ <p align="center"><a href="http://vuejs.org" target="_blank"><img width="100"src="http://vuejs.org/images/logo.png"></a></p> | ||
- If you have a Vue-related project/component/tool, add it to the [Wiki page](https://github.com/yyx990803/vue/wiki/User-Contributed-Components-&-Tools)! | ||
- Bugs, suggestions & feature requests: [open an issue](https://github.com/yyx990803/vue/issues) | ||
@@ -49,0 +50,0 @@ - Twitter: [@vuejs](https://twitter.com/vuejs) |
@@ -19,3 +19,3 @@ var batcher = require('./batcher'), | ||
this.key = key | ||
this.instances = [] | ||
this.dirs = [] | ||
this.subs = [] | ||
@@ -35,13 +35,15 @@ this.deps = [] | ||
} | ||
batcher.queue(this) | ||
if (this.dirs.length || this.subs.length) { | ||
batcher.queue(this) | ||
} | ||
} | ||
/** | ||
* Actually update the instances. | ||
* Actually update the directives. | ||
*/ | ||
BindingProto._update = function () { | ||
var i = this.instances.length, | ||
var i = this.dirs.length, | ||
value = this.val() | ||
while (i--) { | ||
this.instances[i].update(value) | ||
this.dirs[i].update(value) | ||
} | ||
@@ -81,5 +83,5 @@ this.pub() | ||
this.unbound = true | ||
var i = this.instances.length | ||
var i = this.dirs.length | ||
while (i--) { | ||
this.instances[i].unbind() | ||
this.dirs[i].unbind() | ||
} | ||
@@ -86,0 +88,0 @@ i = this.deps.length |
@@ -12,3 +12,3 @@ var Emitter = require('./emitter'), | ||
// cache methods | ||
slice = Array.prototype.slice, | ||
slice = [].slice, | ||
log = utils.log, | ||
@@ -18,3 +18,3 @@ makeHash = utils.hash, | ||
def = utils.defProtected, | ||
hasOwn = Object.prototype.hasOwnProperty, | ||
hasOwn = ({}).hasOwnProperty, | ||
@@ -25,3 +25,3 @@ // hooks to register | ||
'beforeDestroy', 'afterDestroy', | ||
'enteredView', 'leftView' | ||
'attached', 'detached' | ||
] | ||
@@ -73,3 +73,3 @@ | ||
var parent = compiler.parentCompiler, | ||
childId = utils.attr(el, 'component-id') | ||
childId = utils.attr(el, 'ref') | ||
if (parent) { | ||
@@ -103,27 +103,11 @@ parent.childCompilers.push(compiler) | ||
// observe the data | ||
Observer.observe(data, '', compiler.observer) | ||
compiler.observeData(data) | ||
// for repeated items, create an index binding | ||
// which should be inenumerable but configurable | ||
// for repeated items, create index/key bindings | ||
// because they are ienumerable | ||
if (compiler.repeat) { | ||
//data.$index = compiler.repeatIndex | ||
def(data, '$index', compiler.repeatIndex, false, true) | ||
compiler.createBinding('$index') | ||
if (data.$key) compiler.createBinding('$key') | ||
} | ||
// allow the $data object to be swapped | ||
Object.defineProperty(vm, '$data', { | ||
enumerable: false, | ||
get: function () { | ||
return compiler.data | ||
}, | ||
set: function (newData) { | ||
var oldData = compiler.data | ||
Observer.unobserve(oldData, '', compiler.observer) | ||
compiler.data = newData | ||
Observer.copyPaths(newData, oldData) | ||
Observer.observe(newData, '', compiler.observer) | ||
} | ||
}) | ||
// now parse the DOM, during which we will create necessary bindings | ||
@@ -140,2 +124,3 @@ // and bind the parsed directives | ||
// done! | ||
compiler.rawContent = null | ||
compiler.init = false | ||
@@ -161,2 +146,9 @@ | ||
if (template) { | ||
// collect anything already in there | ||
/* jshint boss: true */ | ||
var child, | ||
frag = this.rawContent = document.createDocumentFragment() | ||
while (child = el.firstChild) { | ||
frag.appendChild(child) | ||
} | ||
// replace option: use the first node in | ||
@@ -172,3 +164,2 @@ // the template directly | ||
} else { | ||
el.innerHTML = '' | ||
el.appendChild(template.cloneNode(true)) | ||
@@ -210,17 +201,6 @@ } | ||
observer | ||
.on('get', function (key) { | ||
check(key) | ||
DepsParser.catcher.emit('get', bindings[key]) | ||
}) | ||
.on('set', function (key, val) { | ||
observer.emit('change:' + key, val) | ||
check(key) | ||
bindings[key].update(val) | ||
}) | ||
.on('mutate', function (key, val, mutation) { | ||
observer.emit('change:' + key, val, mutation) | ||
check(key) | ||
bindings[key].pub() | ||
}) | ||
.on('get', onGet) | ||
.on('set', onSet) | ||
.on('mutate', onSet) | ||
// register hooks | ||
@@ -241,2 +221,13 @@ hooks.forEach(function (hook) { | ||
function onGet (key) { | ||
check(key) | ||
DepsParser.catcher.emit('get', bindings[key]) | ||
} | ||
function onSet (key, val, mutation) { | ||
observer.emit('change:' + key, val, mutation) | ||
check(key) | ||
bindings[key].update(val) | ||
} | ||
function register (hook, fn) { | ||
@@ -255,2 +246,44 @@ observer.on('hook:' + hook, function () { | ||
CompilerProto.observeData = function (data) { | ||
var compiler = this, | ||
observer = compiler.observer | ||
// recursively observe nested properties | ||
Observer.observe(data, '', observer) | ||
// also create binding for top level $data | ||
// so it can be used in templates too | ||
var $dataBinding = compiler.bindings['$data'] = new Binding(compiler, '$data') | ||
$dataBinding.update(data) | ||
// allow $data to be swapped | ||
Object.defineProperty(compiler.vm, '$data', { | ||
enumerable: false, | ||
get: function () { | ||
compiler.observer.emit('get', '$data') | ||
return compiler.data | ||
}, | ||
set: function (newData) { | ||
var oldData = compiler.data | ||
Observer.unobserve(oldData, '', observer) | ||
compiler.data = newData | ||
Observer.copyPaths(newData, oldData) | ||
Observer.observe(newData, '', observer) | ||
compiler.observer.emit('set', '$data', newData) | ||
} | ||
}) | ||
// emit $data change on all changes | ||
observer | ||
.on('set', onSet) | ||
.on('mutate', onSet) | ||
function onSet (key) { | ||
if (key !== '$data') { | ||
$dataBinding.update(compiler.data) | ||
} | ||
} | ||
} | ||
/** | ||
@@ -344,3 +377,3 @@ * Compile a DOM node (recursive) | ||
if (attrs && attrs.length) { | ||
var attr, isDirective, exps, exp, directive | ||
var attr, isDirective, exps, exp, directive, dirname | ||
// loop through all attributes | ||
@@ -361,3 +394,4 @@ i = attrs.length | ||
exp = exps[j] | ||
directive = Directive.parse(attr.name.slice(prefix.length), exp, this, node) | ||
dirname = attr.name.slice(prefix.length) | ||
directive = Directive.parse(dirname, exp, this, node) | ||
if (directive) { | ||
@@ -378,3 +412,5 @@ this.bindDirective(directive) | ||
if (isDirective) node.removeAttribute(attr.name) | ||
if (isDirective && dirname !== 'cloak') { | ||
node.removeAttribute(attr.name) | ||
} | ||
} | ||
@@ -403,5 +439,14 @@ } | ||
partialId = token.key.slice(1).trim() | ||
partial = this.getOption('partials', partialId) | ||
if (partial) { | ||
el = partial.cloneNode(true) | ||
if (partialId === 'yield') { | ||
el = this.rawContent | ||
} else { | ||
partial = this.getOption('partials', partialId) | ||
if (partial) { | ||
el = partial.cloneNode(true) | ||
} else { | ||
utils.warn('Unknown partial: ' + partialId) | ||
continue | ||
} | ||
} | ||
if (el) { | ||
// save an Array reference of the partial's nodes | ||
@@ -453,3 +498,3 @@ // so we can compile them AFTER appending the fragment | ||
// and we're done. | ||
if (directive.isEmpty || directive.isLiteral) { | ||
if (directive.isEmpty || !directive._update) { | ||
if (directive.bind) directive.bind() | ||
@@ -479,4 +524,3 @@ return | ||
} | ||
binding.instances.push(directive) | ||
binding.dirs.push(directive) | ||
directive.binding = binding | ||
@@ -541,3 +585,3 @@ | ||
data = compiler.data, | ||
ob = data.__observer__ | ||
ob = data.__emitter__ | ||
@@ -585,7 +629,6 @@ // make sure the key is present in data | ||
this.markComputed(binding, value) | ||
var def = { | ||
Object.defineProperty(this.vm, key, { | ||
get: binding.value.$get, | ||
set: binding.value.$set | ||
} | ||
Object.defineProperty(this.vm, key, def) | ||
}) | ||
} | ||
@@ -622,7 +665,8 @@ | ||
var opts = this.options, | ||
parent = this.parentCompiler | ||
parent = this.parentCompiler, | ||
globalAssets = config.globalAssets | ||
return (opts[type] && opts[type][id]) || ( | ||
parent | ||
? parent.getOption(type, id) | ||
: utils[type] && utils[type][id] | ||
: globalAssets[type] && globalAssets[type][id] | ||
) | ||
@@ -667,3 +711,3 @@ } | ||
var compiler = this, | ||
i, key, dir, instances, binding, | ||
i, key, dir, dirs, binding, | ||
vm = compiler.vm, | ||
@@ -677,2 +721,5 @@ el = compiler.el, | ||
// unobserve data | ||
Observer.unobserve(compiler.data, '', compiler.observer) | ||
// unbind all direcitves | ||
@@ -684,6 +731,7 @@ i = directives.length | ||
// e.g. a directive that refers to a variable on the parent VM | ||
// we need to remove it from that binding's instances | ||
if (!dir.isEmpty && dir.binding.compiler !== compiler) { | ||
instances = dir.binding.instances | ||
if (instances) instances.splice(instances.indexOf(dir), 1) | ||
// we need to remove it from that binding's directives | ||
// * empty and literal bindings do not have binding. | ||
if (dir.binding && dir.binding.compiler !== compiler) { | ||
dirs = dir.binding.dirs | ||
if (dirs) dirs.splice(dirs.indexOf(dir), 1) | ||
} | ||
@@ -699,9 +747,6 @@ dir.unbind() | ||
// unbind/unobserve all own bindings | ||
// unbind all own bindings | ||
for (key in bindings) { | ||
binding = bindings[key] | ||
if (binding) { | ||
if (binding.root) { | ||
Observer.unobserve(binding.value, binding.key, compiler.observer) | ||
} | ||
binding.unbind() | ||
@@ -708,0 +753,0 @@ } |
var prefix = 'v', | ||
specialAttributes = [ | ||
'pre', | ||
'ref', | ||
'with', | ||
'text', | ||
'repeat', | ||
'partial', | ||
'with', | ||
'component', | ||
'component-id', | ||
'transition' | ||
@@ -11,0 +11,0 @@ ], |
@@ -51,9 +51,2 @@ var utils = require('./utils'), | ||
// for literal directives, all we need | ||
// is the expression as the value. | ||
if (this.isLiteral) { | ||
this.value = expression.trim() | ||
return | ||
} | ||
this.expression = expression.trim() | ||
@@ -131,10 +124,13 @@ this.rawKey = rawKey | ||
DirProto.update = function (value, init) { | ||
if (!init && value === this.value) return | ||
this.value = value | ||
if (this._update) { | ||
this._update( | ||
this.filters | ||
? this.applyFilters(value) | ||
: value | ||
) | ||
var type = utils.typeOf(value) | ||
if (init || value !== this.value || type === 'Object' || type === 'Array') { | ||
this.value = value | ||
if (this._update) { | ||
this._update( | ||
this.filters | ||
? this.applyFilters(value) | ||
: value, | ||
init | ||
) | ||
} | ||
} | ||
@@ -157,12 +153,8 @@ } | ||
* Unbind diretive | ||
* @ param {Boolean} update | ||
* Sometimes we call unbind before an update (i.e. not destroy) | ||
* just to teardown previous stuff, in that case we do not want | ||
* to null everything. | ||
*/ | ||
DirProto.unbind = function (update) { | ||
DirProto.unbind = function () { | ||
// this can be called before the el is even assigned... | ||
if (!this.el) return | ||
if (this._unbind) this._unbind(update) | ||
if (!update) this.vm = this.el = this.binding = this.compiler = null | ||
if (!this.el || !this.vm) return | ||
if (this._unbind) this._unbind() | ||
this.vm = this.el = this.binding = this.compiler = null | ||
} | ||
@@ -169,0 +161,0 @@ |
var toText = require('../utils').toText, | ||
slice = Array.prototype.slice | ||
slice = [].slice | ||
@@ -4,0 +4,0 @@ module.exports = { |
@@ -56,3 +56,7 @@ var config = require('../config'), | ||
this.el.vue_ref = null | ||
var ref = this.ref | ||
if (ref.parentNode) { | ||
ref.parentNode.removeChild(ref) | ||
} | ||
} | ||
} |
var utils = require('../utils'), | ||
transition = require('../transition') | ||
config = require('../config'), | ||
transition = require('../transition'), | ||
NumberRE = /^[\d\.]+$/, | ||
CommaRE = /\\,/g | ||
@@ -15,3 +18,7 @@ module.exports = { | ||
attr: function (value) { | ||
this.el.setAttribute(this.arg, value) | ||
if (value || value === 0) { | ||
this.el.setAttribute(this.arg, value) | ||
} else { | ||
this.el.removeAttribute(this.arg) | ||
} | ||
}, | ||
@@ -44,4 +51,25 @@ | ||
} | ||
}, | ||
cloak: { | ||
bind: function () { | ||
var el = this.el | ||
this.compiler.observer.once('hook:ready', function () { | ||
el.removeAttribute(config.prefix + '-cloak') | ||
}) | ||
} | ||
}, | ||
data: { | ||
bind: function () { | ||
var val = this.key | ||
this.vm.$set( | ||
this.arg, | ||
NumberRE.test(val) | ||
? +val | ||
: val.replace(CommaRE, ',') | ||
) | ||
} | ||
} | ||
} |
var utils = require('../utils'), | ||
isIE9 = navigator.userAgent.indexOf('MSIE 9.0') > 0 | ||
isIE9 = navigator.userAgent.indexOf('MSIE 9.0') > 0, | ||
filter = [].filter | ||
/** | ||
* Returns an array of values from a multiple select | ||
*/ | ||
function getMultipleSelectOptions (select) { | ||
return filter | ||
.call(select.options, function (option) { | ||
return option.selected | ||
}) | ||
.map(function (option) { | ||
return option.value || option.text | ||
}) | ||
} | ||
module.exports = { | ||
@@ -14,2 +28,3 @@ | ||
self.lock = false | ||
self.ownerVM = self.binding.compiler.vm | ||
@@ -25,3 +40,3 @@ // determine what event to listen to | ||
// determine the attribute to change when updating | ||
var attr = self.attr = type === 'checkbox' | ||
self.attr = type === 'checkbox' | ||
? 'checked' | ||
@@ -32,7 +47,12 @@ : (tag === 'INPUT' || tag === 'SELECT' || tag === 'TEXTAREA') | ||
// select[multiple] support | ||
if(tag === 'SELECT' && el.hasAttribute('multiple')) { | ||
this.multi = true | ||
} | ||
var compositionLock = false | ||
this.cLock = function () { | ||
self.cLock = function () { | ||
compositionLock = true | ||
} | ||
this.cUnlock = function () { | ||
self.cUnlock = function () { | ||
compositionLock = false | ||
@@ -54,6 +74,6 @@ } | ||
var cursorPos | ||
try { | ||
cursorPos = el.selectionStart | ||
} catch (e) {} | ||
self.vm.$set(self.key, el[attr]) | ||
try { cursorPos = el.selectionStart } catch (e) {} | ||
self._set() | ||
// since updates are async | ||
@@ -71,3 +91,5 @@ // we need to reset cursor position async too | ||
self.lock = true | ||
self.vm.$set(self.key, el[attr]) | ||
self._set() | ||
utils.nextTick(function () { | ||
@@ -98,19 +120,25 @@ self.lock = false | ||
update: function (value) { | ||
_set: function () { | ||
this.ownerVM.$set( | ||
this.key, this.multi | ||
? getMultipleSelectOptions(this.el) | ||
: this.el[this.attr] | ||
) | ||
}, | ||
update: function (value, init) { | ||
/* jshint eqeqeq: false */ | ||
// sync back inline value if initial data is undefined | ||
if (init && value === undefined) { | ||
return this._set() | ||
} | ||
if (this.lock) return | ||
/* jshint eqeqeq: false */ | ||
var self = this, | ||
el = self.el | ||
var el = this.el | ||
if (el.tagName === 'SELECT') { // select dropdown | ||
// setting <select>'s value in IE9 doesn't work | ||
var o = el.options, | ||
i = o.length, | ||
index = -1 | ||
while (i--) { | ||
if (o[i].value == value) { | ||
index = i | ||
break | ||
} | ||
el.selectedIndex = -1 | ||
if(this.multi && Array.isArray(value)) { | ||
value.forEach(this.updateSelect, this) | ||
} else { | ||
this.updateSelect(value) | ||
} | ||
o.selectedIndex = index | ||
} else if (el.type === 'radio') { // radio button | ||
@@ -121,6 +149,20 @@ el.checked = value == el.value | ||
} else { | ||
el[self.attr] = utils.toText(value) | ||
el[this.attr] = utils.toText(value) | ||
} | ||
}, | ||
updateSelect: function (value) { | ||
/* jshint eqeqeq: false */ | ||
// setting <select>'s value in IE9 doesn't work | ||
// we have to manually loop through the options | ||
var options = this.el.options, | ||
i = options.length | ||
while (i--) { | ||
if (options[i].value == value) { | ||
options[i].selected = true | ||
break | ||
} | ||
} | ||
}, | ||
unbind: function () { | ||
@@ -127,0 +169,0 @@ var el = this.el |
@@ -25,3 +25,3 @@ var utils = require('../utils') | ||
update: function (handler) { | ||
this.unbind(true) | ||
this.reset() | ||
if (typeof handler !== 'function') { | ||
@@ -76,7 +76,11 @@ return utils.warn('Directive "on" expects a function value.') | ||
unbind: function (update) { | ||
reset: function () { | ||
this.el.removeEventListener(this.arg, this.handler) | ||
this.handler = null | ||
if (!update) this.el.vue_viewmodel = null | ||
}, | ||
unbind: function () { | ||
this.reset() | ||
this.el.vue_viewmodel = null | ||
} | ||
} |
var Observer = require('../observer'), | ||
Emitter = require('../emitter'), | ||
utils = require('../utils'), | ||
config = require('../config'), | ||
transition = require('../transition'), | ||
def = utils.defProtected, | ||
ViewModel // lazy def to avoid circular dependency | ||
@@ -15,6 +15,7 @@ | ||
push: function (m) { | ||
var i, l = m.args.length, | ||
var l = m.args.length, | ||
base = this.collection.length - l | ||
for (i = 0; i < l; i++) { | ||
for (var i = 0; i < l; i++) { | ||
this.buildItem(m.args[i], base + i) | ||
this.updateObject(m.args[i], 1) | ||
} | ||
@@ -25,7 +26,13 @@ }, | ||
var vm = this.vms.pop() | ||
if (vm) vm.$destroy() | ||
if (vm) { | ||
vm.$destroy() | ||
this.updateObject(vm.$data, -1) | ||
} | ||
}, | ||
unshift: function (m) { | ||
m.args.forEach(this.buildItem, this) | ||
for (var i = 0, l = m.args.length; i < l; i++) { | ||
this.buildItem(m.args[i], i) | ||
this.updateObject(m.args[i], 1) | ||
} | ||
}, | ||
@@ -35,3 +42,6 @@ | ||
var vm = this.vms.shift() | ||
if (vm) vm.$destroy() | ||
if (vm) { | ||
vm.$destroy() | ||
this.updateObject(vm.$data, -1) | ||
} | ||
}, | ||
@@ -47,5 +57,7 @@ | ||
removedVMs[i].$destroy() | ||
this.updateObject(removedVMs[i].$data, -1) | ||
} | ||
for (i = 0; i < added; i++) { | ||
this.buildItem(m.args[i + 2], index + i) | ||
this.updateObject(m.args[i + 2], 1) | ||
} | ||
@@ -85,2 +97,31 @@ }, | ||
/** | ||
* Convert an Object to a v-repeat friendly Array | ||
*/ | ||
function objectToArray (obj) { | ||
var res = [], val, data | ||
for (var key in obj) { | ||
val = obj[key] | ||
data = utils.typeOf(val) === 'Object' | ||
? val | ||
: { $value: val } | ||
def(data, '$key', key, false, true) | ||
res.push(data) | ||
} | ||
return res | ||
} | ||
/** | ||
* Find an object or a wrapped data object | ||
* from an Array | ||
*/ | ||
function indexOf (arr, obj) { | ||
for (var i = 0, l = arr.length; i < l; i++) { | ||
if (arr[i] === obj || (obj.$value && arr[i].$value === obj.$value)) { | ||
return i | ||
} | ||
} | ||
return -1 | ||
} | ||
module.exports = { | ||
@@ -99,3 +140,3 @@ | ||
// extract child Id, if any | ||
this.childId = utils.attr(el, 'component-id') | ||
this.childId = utils.attr(el, 'ref') | ||
@@ -116,5 +157,10 @@ // create a comment node as a reference node for DOM insertions | ||
if (method !== 'push' && method !== 'pop') { | ||
self.updateIndex() | ||
// update index | ||
var i = arr.length | ||
while (i--) { | ||
arr[i].$index = i | ||
} | ||
} | ||
if (method === 'push' || method === 'unshift' || method === 'splice') { | ||
// recalculate dependency | ||
self.changed() | ||
@@ -128,3 +174,17 @@ } | ||
this.unbind(true) | ||
if ( | ||
collection === this.collection || | ||
collection === this.object | ||
) return | ||
if (utils.typeOf(collection) === 'Object') { | ||
if (this.object) { | ||
delete this.object.$repeater | ||
} | ||
this.object = collection | ||
collection = objectToArray(collection) | ||
def(this.object, '$repeater', collection, false, true) | ||
} | ||
this.reset() | ||
// attach an object to container to hold handlers | ||
@@ -139,2 +199,8 @@ this.container.vue_dHandlers = utils.hash() | ||
} | ||
// keep reference of old data and VMs | ||
// so we can reuse them if possible | ||
this.old = this.collection | ||
var oldVMs = this.oldVMs = this.vms | ||
collection = this.collection = collection || [] | ||
@@ -148,6 +214,6 @@ this.vms = [] | ||
// the collection has been augmented during Binding.set() | ||
if (!collection.__observer__) Observer.watchArray(collection, null, new Emitter()) | ||
collection.__observer__.on('mutate', this.mutationListener) | ||
if (!collection.__emitter__) Observer.watchArray(collection) | ||
collection.__emitter__.on('mutate', this.mutationListener) | ||
// create child-vms and append to DOM | ||
// create new VMs and append to DOM | ||
if (collection.length) { | ||
@@ -157,2 +223,16 @@ collection.forEach(this.buildItem, this) | ||
} | ||
// destroy unused old VMs | ||
if (oldVMs) { | ||
var i = oldVMs.length, vm | ||
while (i--) { | ||
vm = oldVMs[i] | ||
if (vm.$reused) { | ||
vm.$reused = false | ||
} else { | ||
vm.$destroy() | ||
} | ||
} | ||
} | ||
this.old = this.oldVMs = null | ||
}, | ||
@@ -171,2 +251,3 @@ | ||
setTimeout(function () { | ||
if (!self.compiler) return | ||
self.compiler.parseDeps() | ||
@@ -184,7 +265,6 @@ self.queued = false | ||
var el = this.el.cloneNode(true), | ||
ctn = this.container, | ||
var ctn = this.container, | ||
vms = this.vms, | ||
col = this.collection, | ||
ref, item | ||
el, i, ref, item, primitive, detached | ||
@@ -194,2 +274,34 @@ // append node into DOM first | ||
if (data) { | ||
if (this.old) { | ||
i = indexOf(this.old, data) | ||
} | ||
if (i > -1) { // existing, reuse the old VM | ||
item = this.oldVMs[i] | ||
// mark, so it won't be destroyed | ||
item.$reused = true | ||
el = item.$el | ||
// don't forget to update index | ||
data.$index = index | ||
// existing VM's el can possibly be detached by v-if. | ||
// in that case don't insert. | ||
detached = !el.parentNode | ||
} else { // new data, need to create new VM | ||
el = this.el.cloneNode(true) | ||
// process transition info before appending | ||
el.vue_trans = utils.attr(el, 'transition', true) | ||
// wrap primitive element in an object | ||
if (utils.typeOf(data) !== 'Object') { | ||
primitive = true | ||
data = { $value: data } | ||
} | ||
// define index | ||
def(data, '$index', index, false, true) | ||
} | ||
ref = vms.length > index | ||
@@ -200,10 +312,20 @@ ? vms[index].$el | ||
if (!ref.parentNode) ref = ref.vue_ref | ||
// process transition info before appending | ||
el.vue_trans = utils.attr(el, 'transition', true) | ||
transition(el, 1, function () { | ||
ctn.insertBefore(el, ref) | ||
}, this.compiler) | ||
if (!detached) { | ||
if (i > -1) { | ||
// no need to transition existing node | ||
ctn.insertBefore(el, ref) | ||
} else { | ||
// insert new node with transition | ||
transition(el, 1, function () { | ||
ctn.insertBefore(el, ref) | ||
}, this.compiler) | ||
} | ||
} else { | ||
// detached by v-if | ||
// just move the comment ref node | ||
ctn.insertBefore(el.vue_ref, ref) | ||
} | ||
} | ||
item = new this.Ctor({ | ||
item = item || new this.Ctor({ | ||
el: el, | ||
@@ -213,3 +335,2 @@ data: data, | ||
repeat: true, | ||
repeatIndex: index, | ||
parentCompiler: this.compiler, | ||
@@ -226,7 +347,10 @@ delegator: ctn | ||
vms.splice(index, 0, item) | ||
// in case `$destroy` is called directly on a repeated vm | ||
// make sure the vm's data is properly removed | ||
item.$compiler.observer.on('hook:afterDestroy', function () { | ||
col.remove(data) | ||
}) | ||
// for primitive values, listen for value change | ||
if (primitive) { | ||
data.__emitter__.on('set', function (key, val) { | ||
if (key === '$value') { | ||
col[item.$index] = val | ||
} | ||
}) | ||
} | ||
} | ||
@@ -236,12 +360,22 @@ }, | ||
/** | ||
* Update index of each item after a mutation | ||
* Sync changes in the $repeater Array | ||
* back to the represented Object | ||
*/ | ||
updateIndex: function () { | ||
var i = this.vms.length | ||
while (i--) { | ||
this.vms[i].$data.$index = i | ||
updateObject: function (data, action) { | ||
if (this.object && data.$key) { | ||
var key = data.$key, | ||
val = data.$value || data | ||
if (action > 0) { // new property | ||
// make key ienumerable | ||
delete data.$key | ||
def(data, '$key', key, false, true) | ||
this.object[key] = val | ||
} else { | ||
delete this.object[key] | ||
} | ||
this.object.__emitter__.emit('set', key, val, true) | ||
} | ||
}, | ||
unbind: function () { | ||
reset: function (destroyAll) { | ||
if (this.childId) { | ||
@@ -251,6 +385,8 @@ delete this.vm.$[this.childId] | ||
if (this.collection) { | ||
this.collection.__observer__.off('mutate', this.mutationListener) | ||
var i = this.vms.length | ||
while (i--) { | ||
this.vms[i].$destroy() | ||
this.collection.__emitter__.off('mutate', this.mutationListener) | ||
if (destroyAll) { | ||
var i = this.vms.length | ||
while (i--) { | ||
this.vms[i].$destroy() | ||
} | ||
} | ||
@@ -264,3 +400,7 @@ } | ||
ctn.vue_dHandlers = null | ||
}, | ||
unbind: function () { | ||
this.reset(true) | ||
} | ||
} |
@@ -11,4 +11,5 @@ var camelRE = /-([a-z])/g, | ||
bind: function () { | ||
var prop = this.arg, | ||
first = prop.charAt(0) | ||
var prop = this.arg | ||
if (!prop) return | ||
var first = prop.charAt(0) | ||
if (first === '$') { | ||
@@ -27,9 +28,13 @@ // properties that start with $ will be auto-prefixed | ||
var prop = this.prop | ||
this.el.style[prop] = value | ||
if (this.prefixed) { | ||
prop = prop.charAt(0).toUpperCase() + prop.slice(1) | ||
var i = prefixes.length | ||
while (i--) { | ||
this.el.style[prefixes[i] + prop] = value | ||
if (prop) { | ||
this.el.style[prop] = value | ||
if (this.prefixed) { | ||
prop = prop.charAt(0).toUpperCase() + prop.slice(1) | ||
var i = prefixes.length | ||
while (i--) { | ||
this.el.style[prefixes[i] + prop] = value | ||
} | ||
} | ||
} else { | ||
this.el.style.cssText = value | ||
} | ||
@@ -36,0 +41,0 @@ } |
@@ -1,4 +0,6 @@ | ||
var utils = require('./utils'), | ||
stringSaveRE = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g, | ||
stringRestoreRE = /"(\d+)"/g | ||
var utils = require('./utils'), | ||
stringSaveRE = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g, | ||
stringRestoreRE = /"(\d+)"/g, | ||
constructorRE = new RegExp('constructor'.split('').join('[\'"+, ]*')), | ||
unicodeRE = /\\u\d\d\d\d/ | ||
@@ -112,2 +114,7 @@ // Variable extraction scooped from https://github.com/RubyLouvre/avalon | ||
parse: function (exp, compiler) { | ||
// unicode and 'constructor' are not allowed for XSS security. | ||
if (unicodeRE.test(exp) || constructorRE.test(exp)) { | ||
utils.warn('Unsafe expression: ' + exp) | ||
return function () {} | ||
} | ||
// extract variable names | ||
@@ -114,0 +121,0 @@ var vars = getVariables(exp) |
var config = require('./config'), | ||
ViewModel = require('./viewmodel'), | ||
directives = require('./directives'), | ||
filters = require('./filters'), | ||
utils = require('./utils') | ||
utils = require('./utils'), | ||
makeHash = utils.hash, | ||
assetTypes = ['directive', 'filter', 'partial', 'transition', 'component'] | ||
ViewModel.options = config.globalAssets = { | ||
directives : require('./directives'), | ||
filters : require('./filters'), | ||
partials : makeHash(), | ||
transitions : makeHash(), | ||
components : makeHash() | ||
} | ||
/** | ||
* Expose asset registration methods | ||
*/ | ||
assetTypes.forEach(function (type) { | ||
ViewModel[type] = function (id, value) { | ||
var hash = this.options[type + 's'] | ||
if (!hash) { | ||
hash = this.options[type + 's'] = makeHash() | ||
} | ||
if (!value) return hash[id] | ||
if (type === 'partial') { | ||
value = utils.toFragment(value) | ||
} else if (type === 'component') { | ||
value = utils.toConstructor(value) | ||
} | ||
hash[id] = value | ||
return this | ||
} | ||
}) | ||
/** | ||
* Set config options | ||
@@ -24,46 +52,31 @@ */ | ||
/** | ||
* Allows user to register/retrieve a directive definition | ||
* Expose internal modules for plugins | ||
*/ | ||
ViewModel.directive = function (id, fn) { | ||
if (!fn) return directives[id] | ||
directives[id] = fn | ||
return this | ||
ViewModel.require = function (path) { | ||
return require('./' + path) | ||
} | ||
/** | ||
* Allows user to register/retrieve a filter function | ||
* Expose an interface for plugins | ||
*/ | ||
ViewModel.filter = function (id, fn) { | ||
if (!fn) return filters[id] | ||
filters[id] = fn | ||
return this | ||
} | ||
ViewModel.use = function (plugin) { | ||
if (typeof plugin === 'string') { | ||
try { | ||
plugin = require(plugin) | ||
} catch (e) { | ||
return utils.warn('Cannot find plugin: ' + plugin) | ||
} | ||
} | ||
/** | ||
* Allows user to register/retrieve a ViewModel constructor | ||
*/ | ||
ViewModel.component = function (id, Ctor) { | ||
if (!Ctor) return utils.components[id] | ||
utils.components[id] = utils.toConstructor(Ctor) | ||
return this | ||
} | ||
// additional parameters | ||
var args = [].slice.call(arguments, 1) | ||
args.unshift(ViewModel) | ||
/** | ||
* Allows user to register/retrieve a template partial | ||
*/ | ||
ViewModel.partial = function (id, partial) { | ||
if (!partial) return utils.partials[id] | ||
utils.partials[id] = utils.toFragment(partial) | ||
return this | ||
if (typeof plugin.install === 'function') { | ||
plugin.install.apply(plugin, args) | ||
} else { | ||
plugin.apply(null, args) | ||
} | ||
} | ||
/** | ||
* Allows user to register/retrieve a transition definition object | ||
*/ | ||
ViewModel.transition = function (id, transition) { | ||
if (!transition) return utils.transitions[id] | ||
utils.transitions[id] = transition | ||
return this | ||
} | ||
ViewModel.extend = extend | ||
@@ -112,2 +125,8 @@ ViewModel.nextTick = utils.nextTick | ||
ExtendedVM.options = options | ||
// allow extended VM to add its own assets | ||
assetTypes.forEach(function (type) { | ||
ExtendedVM[type] = ViewModel[type] | ||
}) | ||
return ExtendedVM | ||
@@ -130,3 +149,3 @@ } | ||
function inheritOptions (child, parent, topLevel) { | ||
child = child || utils.hash() | ||
child = child || makeHash() | ||
if (!parent) return child | ||
@@ -133,0 +152,0 @@ for (var key in parent) { |
@@ -9,3 +9,3 @@ /* jshint proto:true */ | ||
def = utils.defProtected, | ||
slice = Array.prototype.slice, | ||
slice = [].slice, | ||
@@ -36,3 +36,3 @@ // types | ||
var result = Array.prototype[method].apply(this, arguments) | ||
this.__observer__.emit('mutate', this.__observer__.path, this, { | ||
this.__emitter__.emit('mutate', null, this, { | ||
method: method, | ||
@@ -46,50 +46,57 @@ args: slice.call(arguments), | ||
// Augment it with several convenience methods | ||
var extensions = { | ||
remove: function (index) { | ||
if (typeof index === 'function') { | ||
var i = this.length, | ||
removed = [] | ||
while (i--) { | ||
if (index(this[i])) { | ||
removed.push(this.splice(i, 1)[0]) | ||
} | ||
/** | ||
* Convenience method to remove an element in an Array | ||
* This will be attached to observed Array instances | ||
*/ | ||
function removeElement (index) { | ||
if (typeof index === 'function') { | ||
var i = this.length, | ||
removed = [] | ||
while (i--) { | ||
if (index(this[i])) { | ||
removed.push(this.splice(i, 1)[0]) | ||
} | ||
return removed.reverse() | ||
} else { | ||
if (typeof index !== 'number') { | ||
index = this.indexOf(index) | ||
} | ||
if (index > -1) { | ||
return this.splice(index, 1)[0] | ||
} | ||
} | ||
}, | ||
replace: function (index, data) { | ||
if (typeof index === 'function') { | ||
var i = this.length, | ||
replaced = [], | ||
replacer | ||
while (i--) { | ||
replacer = index(this[i]) | ||
if (replacer !== undefined) { | ||
replaced.push(this.splice(i, 1, replacer)[0]) | ||
} | ||
} | ||
return replaced.reverse() | ||
} else { | ||
if (typeof index !== 'number') { | ||
index = this.indexOf(index) | ||
} | ||
if (index > -1) { | ||
return this.splice(index, 1, data)[0] | ||
} | ||
return removed.reverse() | ||
} else { | ||
if (typeof index !== 'number') { | ||
index = this.indexOf(index) | ||
} | ||
if (index > -1) { | ||
return this.splice(index, 1)[0] | ||
} | ||
} | ||
} | ||
for (var method in extensions) { | ||
def(ArrayProxy, method, extensions[method], !hasProto) | ||
/** | ||
* Convenience method to replace an element in an Array | ||
* This will be attached to observed Array instances | ||
*/ | ||
function replaceElement (index, data) { | ||
if (typeof index === 'function') { | ||
var i = this.length, | ||
replaced = [], | ||
replacer | ||
while (i--) { | ||
replacer = index(this[i]) | ||
if (replacer !== undefined) { | ||
replaced.push(this.splice(i, 1, replacer)[0]) | ||
} | ||
} | ||
return replaced.reverse() | ||
} else { | ||
if (typeof index !== 'number') { | ||
index = this.indexOf(index) | ||
} | ||
if (index > -1) { | ||
return this.splice(index, 1, data)[0] | ||
} | ||
} | ||
} | ||
// Augment the ArrayProxy with convenience methods | ||
def(ArrayProxy, 'remove', removeElement, !hasProto) | ||
def(ArrayProxy, 'set', replaceElement, !hasProto) | ||
def(ArrayProxy, 'replace', replaceElement, !hasProto) | ||
/** | ||
@@ -108,9 +115,8 @@ * Watch an Object, recursive. | ||
*/ | ||
function watchArray (arr, path) { | ||
var observer = arr.__observer__ | ||
if (!observer) { | ||
observer = new Emitter() | ||
def(arr, '__observer__', observer) | ||
function watchArray (arr) { | ||
var emitter = arr.__emitter__ | ||
if (!emitter) { | ||
emitter = new Emitter() | ||
def(arr, '__emitter__', emitter) | ||
} | ||
observer.path = path | ||
if (hasProto) { | ||
@@ -132,3 +138,8 @@ arr.__proto__ = ArrayProxy | ||
var keyPrefix = key.charAt(0) | ||
if ((keyPrefix === '$' || keyPrefix === '_') && key !== '$index') { | ||
if ( | ||
(keyPrefix === '$' || keyPrefix === '_') && | ||
key !== '$index' && | ||
key !== '$key' && | ||
key !== '$value' | ||
) { | ||
return | ||
@@ -139,9 +150,7 @@ } | ||
// a first batch of set events. | ||
var observer = obj.__observer__, | ||
values = observer.values, | ||
val = values[key] = obj[key] | ||
observer.emit('set', key, val) | ||
if (Array.isArray(val)) { | ||
observer.emit('set', key + '.length', val.length) | ||
} | ||
var emitter = obj.__emitter__, | ||
values = emitter.values | ||
init(obj[key]) | ||
Object.defineProperty(obj, key, { | ||
@@ -152,3 +161,3 @@ get: function () { | ||
if (pub.shouldGet && typeOf(value) !== OBJECT) { | ||
observer.emit('get', key) | ||
emitter.emit('get', key) | ||
} | ||
@@ -159,10 +168,18 @@ return value | ||
var oldVal = values[key] | ||
unobserve(oldVal, key, observer) | ||
values[key] = newVal | ||
unobserve(oldVal, key, emitter) | ||
copyPaths(newVal, oldVal) | ||
observer.emit('set', key, newVal) | ||
observe(newVal, key, observer) | ||
// an immediate property should notify its parent | ||
// to emit set for itself too | ||
init(newVal, true) | ||
} | ||
}) | ||
observe(val, key, observer) | ||
function init (val, propagate) { | ||
values[key] = val | ||
emitter.emit('set', key, val, propagate) | ||
if (Array.isArray(val)) { | ||
emitter.emit('set', key + '.length', val.length) | ||
} | ||
observe(val, key, emitter) | ||
} | ||
} | ||
@@ -187,3 +204,3 @@ | ||
var type = typeOf(obj), | ||
emitter = obj && obj.__observer__ | ||
emitter = obj && obj.__emitter__ | ||
if (type === ARRAY) { | ||
@@ -238,3 +255,3 @@ emitter.emit('set', 'length', obj.length) | ||
obj[sec] = {} | ||
if (obj.__observer__) convert(obj, sec) | ||
if (obj.__emitter__) convert(obj, sec) | ||
} | ||
@@ -247,3 +264,3 @@ obj = obj[sec] | ||
obj[sec] = undefined | ||
if (obj.__observer__) convert(obj, sec) | ||
if (obj.__emitter__) convert(obj, sec) | ||
} | ||
@@ -258,10 +275,19 @@ } | ||
function observe (obj, rawPath, observer) { | ||
if (!isWatchable(obj)) return | ||
var path = rawPath ? rawPath + '.' : '', | ||
ob, alreadyConverted = !!obj.__observer__ | ||
alreadyConverted = !!obj.__emitter__, | ||
emitter | ||
if (!alreadyConverted) { | ||
def(obj, '__observer__', new Emitter()) | ||
def(obj, '__emitter__', new Emitter()) | ||
} | ||
ob = obj.__observer__ | ||
ob.values = ob.values || utils.hash() | ||
emitter = obj.__emitter__ | ||
emitter.values = emitter.values || utils.hash() | ||
// setup proxy listeners on the parent observer. | ||
// we need to keep reference to them so that they | ||
// can be removed when the object is un-observed. | ||
observer.proxies = observer.proxies || {} | ||
@@ -272,4 +298,10 @@ var proxies = observer.proxies[path] = { | ||
}, | ||
set: function (key, val) { | ||
set: function (key, val, propagate) { | ||
observer.emit('set', path + key, val) | ||
// also notify observer that the object itself changed | ||
// but only do so when it's a immediate property. this | ||
// avoids duplicate event firing. | ||
if (rawPath && propagate) { | ||
observer.emit('set', rawPath, obj, true) | ||
} | ||
}, | ||
@@ -288,7 +320,13 @@ mutate: function (key, val, mutation) { | ||
} | ||
ob | ||
// attach the listeners to the child observer. | ||
// now all the events will propagate upwards. | ||
emitter | ||
.on('get', proxies.get) | ||
.on('set', proxies.set) | ||
.on('mutate', proxies.mutate) | ||
if (alreadyConverted) { | ||
// for objects that have already been converted, | ||
// emit set events for everything inside | ||
emitSet(obj) | ||
@@ -309,10 +347,16 @@ } else { | ||
function unobserve (obj, path, observer) { | ||
if (!obj || !obj.__observer__) return | ||
if (!obj || !obj.__emitter__) return | ||
path = path ? path + '.' : '' | ||
var proxies = observer.proxies[path] | ||
if (!proxies) return | ||
obj.__observer__ | ||
// turn off listeners | ||
obj.__emitter__ | ||
.off('get', proxies.get) | ||
.off('set', proxies.set) | ||
.off('mutate', proxies.mutate) | ||
// remove reference | ||
observer.proxies[path] = null | ||
@@ -319,0 +363,0 @@ } |
@@ -26,3 +26,3 @@ var endEvent = sniffTransitionEndEvent(), | ||
cb() | ||
compiler.execHook(stage > 0 ? 'enteredView' : 'leftView') | ||
compiler.execHook(stage > 0 ? 'attached' : 'detached') | ||
} | ||
@@ -96,16 +96,21 @@ | ||
// trigger hide transition | ||
classList.add(config.leaveClass) | ||
var onEnd = function (e) { | ||
if (e.target === el) { | ||
el.removeEventListener(endEvent, onEnd) | ||
el.vue_trans_cb = null | ||
// actually remove node here | ||
changeState() | ||
classList.remove(config.leaveClass) | ||
if (el.offsetWidth || el.offsetHeight) { | ||
// trigger hide transition | ||
classList.add(config.leaveClass) | ||
var onEnd = function (e) { | ||
if (e.target === el) { | ||
el.removeEventListener(endEvent, onEnd) | ||
el.vue_trans_cb = null | ||
// actually remove node here | ||
changeState() | ||
classList.remove(config.leaveClass) | ||
} | ||
} | ||
// attach transition end listener | ||
el.addEventListener(endEvent, onEnd) | ||
el.vue_trans_cb = onEnd | ||
} else { | ||
// directly remove invisible elements | ||
changeState() | ||
} | ||
// attach transition end listener | ||
el.addEventListener(endEvent, onEnd) | ||
el.vue_trans_cb = onEnd | ||
return codes.CSS_L | ||
@@ -112,0 +117,0 @@ |
var config = require('./config'), | ||
attrs = config.attrs, | ||
toString = Object.prototype.toString, | ||
join = Array.prototype.join, | ||
console = window.console, | ||
toString = ({}).toString, | ||
join = [].join, | ||
win = window, | ||
console = win.console, | ||
@@ -11,24 +12,16 @@ hasClassList = 'classList' in document.documentElement, | ||
var defer = | ||
window.requestAnimationFrame || | ||
window.webkitRequestAnimationFrame || | ||
window.setTimeout | ||
win.requestAnimationFrame || | ||
win.webkitRequestAnimationFrame || | ||
win.setTimeout | ||
/** | ||
* Create a prototype-less object | ||
* which is a better hash/map | ||
*/ | ||
function makeHash () { | ||
return Object.create(null) | ||
} | ||
var utils = module.exports = { | ||
hash: makeHash, | ||
/** | ||
* Create a prototype-less object | ||
* which is a better hash/map | ||
*/ | ||
hash: function () { | ||
return Object.create(null) | ||
}, | ||
// global storage for user-registered | ||
// vms, partials and transitions | ||
components : makeHash(), | ||
partials : makeHash(), | ||
transitions : makeHash(), | ||
/** | ||
@@ -77,12 +70,15 @@ * get an attribute and remove it. | ||
/** | ||
* Make sure only strings and numbers are output to html | ||
* output empty string is value is not string or number | ||
* Make sure only strings, booleans, numbers and | ||
* objects are output to html. otherwise, ouput empty string. | ||
*/ | ||
toText: function (value) { | ||
/* jshint eqeqeq: false */ | ||
return (typeof value === 'string' || | ||
typeof value === 'boolean' || | ||
(typeof value === 'number' && value == value)) // deal with NaN | ||
? value | ||
: '' | ||
var type = typeof value | ||
return (type === 'string' || | ||
type === 'boolean' || | ||
(type === 'number' && value == value)) // deal with NaN | ||
? value | ||
: type === 'object' && value !== null | ||
? JSON.stringify(value) | ||
: '' | ||
}, | ||
@@ -134,3 +130,5 @@ | ||
while (child = node.firstChild) { | ||
frag.appendChild(child) | ||
if (node.nodeType === 1) { | ||
frag.appendChild(child) | ||
} | ||
} | ||
@@ -137,0 +135,0 @@ return frag |
@@ -27,4 +27,3 @@ var Compiler = require('./compiler'), | ||
var path = key.split('.'), | ||
obj = getTargetVM(this, path) | ||
if (!obj) return | ||
obj = this | ||
for (var d = 0, l = path.length - 1; d < l; d++) { | ||
@@ -163,14 +162,2 @@ obj = obj[path[d]] | ||
/** | ||
* If a VM doesn't contain a path, go up the prototype chain | ||
* to locate the ancestor that has it. | ||
*/ | ||
function getTargetVM (vm, path) { | ||
var baseKey = path[0], | ||
binding = vm.$compiler.bindings[baseKey] | ||
return binding | ||
? binding.compiler.vm | ||
: null | ||
} | ||
module.exports = ViewModel |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
242841
30
6578
61
11