diff --git a/Gruntfile.js b/Gruntfile.js index 1177814..cab16fc 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,7 +12,8 @@ module.exports = function(grunt) { 'src/filter.coffee', 'src/bindings.coffee', 'src/filters.coffee', - 'src/diff.coffee' + 'src/diff.coffee', + 'src/validation.coffee' ]; var libFiles = [ diff --git a/dist/chip.js b/dist/chip.js index 810aae6..6628ff4 100644 --- a/dist/chip.js +++ b/dist/chip.js @@ -3416,4 +3416,108 @@ if (!Date.prototype.toISOString) { chip.diff = diff; + chip.binding('bind-validation', function(element, attr, controller) { + controller[attr.value] = {}; + return controller.validationGroup = attr.value; + }); + + chip.binding('validate-*', function(element, attr, controller) { + var opt, optArry, optionKey, optionValMsg, options, optsArry, type, validateField, validations, _i, _len, _ref; + validations = app.rootController.validations != null; + if (!validations) { + return console.warn('No validation rules found.'); + } else { + type = attr.camel; + if (attr.value === '') { + options = {}; + options["default"] = true; + } else { + if (attr.value.indexOf(':') < 1) { + options = controller["eval"](attr.value); + if (typeof options !== 'object') { + options = {}; + options[attr.value] = true; + } + } else { + options = {}; + optsArry = attr.value.split('|'); + for (_i = 0, _len = optsArry.length; _i < _len; _i++) { + opt = optsArry[_i]; + optArry = opt.split(':'); + optionKey = optArry[0].trim(); + optionValMsg = optArry[1].split('-e'); + options[optionKey] = {}; + options[optionKey].value = optionValMsg[0].trim(); + options[optionKey].errorMessage = (_ref = optionValMsg[1]) != null ? _ref.trim() : void 0; + } + } + } + element.on('change', function() { + var validResponse, value; + value = element.val(); + validResponse = validateField(value, type, options); + if (validResponse.valid) { + element.removeClass('chip_validation_invalid'); + element.addClass('chip_validation_valid'); + } else { + console.error(validResponse.errorMsgs); + element.removeClass('chip_validation_valid'); + element.addClass('chip_validation_invalid'); + } + if (!controller[controller.validationGroup][element.attr('name')]) { + controller[controller.validationGroup][element.attr('name')] = {}; + } + return controller[controller.validationGroup][element.attr('name')] = validResponse; + }); + return validateField = function(value, type, options) { + var errorMsgs, isValid, optionName, optionValue, response, rule, validateMsg, validateVal, validation, _ref1, _ref2; + response = { + valid: true, + message: '', + errorMsgs: [] + }; + validateVal = function(validation) { + if (validation.value != null) { + return validation.value; + } else { + return validation; + } + }; + validateMsg = function(validation) { + if (validation.message != null) { + return validation.message; + } else { + return null; + } + }; + isValid = true; + errorMsgs = []; + for (optionName in options) { + optionValue = options[optionName]; + validation = ((_ref1 = validations[type]) != null ? _ref1[optionName] : void 0) || ((_ref2 = validations.all) != null ? _ref2[optionName] : void 0); + if (validation != null) { + rule = validation.evaluation.replace('{x}', '"' + value + '"').replace('{y}', optionValue.value); + if (eval(rule)) { + isValid = true; + } else { + isValid = false; + if (validation.errorMessage) { + errorMsgs.push(validation.errorMessage.replace('{y}', optionValue.value)); + } else { + validation.errorMessage('Input for this field is invalid.'); + } + } + } else { + 'validation missing'; + response.valid = true; + console.warn('Validation method: ' + optionName + ' not found!'); + } + } + response.valid = isValid; + response.errorMsgs = errorMsgs; + return response; + }; + } + }); + }).call(this); diff --git a/dist/chip.min.js b/dist/chip.min.js index 7b25b0d..abb197f 100644 --- a/dist/chip.min.js +++ b/dist/chip.min.js @@ -1,2 +1,2 @@ -Object.getPrototypeOf||(Object.getPrototypeOf=function(a){if(a!==Object(a))throw new TypeError("Object.getPrototypeOf called on non-object");return a.__proto__||a.constructor.prototype||Object.prototype}),"function"!=typeof Object.getOwnPropertyNames&&(Object.getOwnPropertyNames=function(a){if(a!==Object(a))throw new TypeError("Object.getOwnPropertyNames called on non-object");var b,c=[];for(b in a)Object.prototype.hasOwnProperty.call(a,b)&&c.push(b);return c}),"function"!=typeof Object.create&&(Object.create=function(a,b){"use strict";function c(){}if("object"!=typeof a)throw new TypeError;c.prototype=a;var d=new c;if(a&&(d.constructor=c),arguments.length>1){if(b!==Object(b))throw new TypeError;Object.defineProperties(d,b)}return d}),function(){if(!Object.defineProperty||!function(){try{return Object.defineProperty({},"x",{}),!0}catch(a){return!1}}()){var a=Object.defineProperty;Object.defineProperty=function(b,c,d){"use strict";if(a)try{return a(b,c,d)}catch(e){}if(b!==Object(b))throw new TypeError("Object.defineProperty called on non-object");return Object.prototype.__defineGetter__&&"get"in d&&Object.prototype.__defineGetter__.call(b,c,d.get),Object.prototype.__defineSetter__&&"set"in d&&Object.prototype.__defineSetter__.call(b,c,d.set),"value"in d&&(b[c]=d.value),b}}}(),"function"!=typeof Object.defineProperties&&(Object.defineProperties=function(a,b){"use strict";if(a!==Object(a))throw new TypeError("Object.defineProperties called on non-object");var c;for(c in b)Object.prototype.hasOwnProperty.call(b,c)&&Object.defineProperty(a,c,b[c]);return a}),Object.keys||(Object.keys=function(a){if(a!==Object(a))throw new TypeError("Object.keys called on non-object");var b,c=[];for(b in a)Object.prototype.hasOwnProperty.call(a,b)&&c.push(b);return c}),Function.prototype.bind||(Function.prototype.bind=function(a){function b(){}if("function"!=typeof this)throw new TypeError("Bind must be called on a function");var c=[].slice,d=c.call(arguments,1),e=this,f=function(){return e.apply(this instanceof b?this:a||{},d.concat(c.call(arguments)))};return b.prototype=e.prototype,f.prototype=new b,f}),Array.isArray=Array.isArray||function(a){return Boolean(a&&"[object Array]"===Object.prototype.toString.call(Object(a)))},Array.prototype.indexOf||(Array.prototype.indexOf=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>0&&(d=Number(arguments[1]),isNaN(d)?d=0:0!==d&&d!==1/0&&d!==-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=c;arguments.length>1&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&d!==1/0&&d!==-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d))));for(var e=d>=0?Math.min(d,c-1):c-Math.abs(d);e>=0;e--)if(e in b&&b[e]===a)return e;return-1}),Array.prototype.every||(Array.prototype.every=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;var d,e=arguments[1];for(d=0;c>d;d++)if(d in b&&!a.call(e,b[d],d,b))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;var d,e=arguments[1];for(d=0;c>d;d++)if(d in b&&a.call(e,b[d],d,b))return!0;return!1}),Array.prototype.forEach||(Array.prototype.forEach=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;var d,e=arguments[1];for(d=0;c>d;d++)d in b&&a.call(e,b[d],d,b)}),Array.prototype.map||(Array.prototype.map=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;var d=[];d.length=c;var e,f=arguments[1];for(e=0;c>e;e++)e in b&&(d[e]=a.call(f,b[e],e,b));return d}),Array.prototype.filter||(Array.prototype.filter=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;var d,e=[],f=arguments[1];for(d=0;c>d;d++)if(d in b){var g=b[d];a.call(f,g,d,b)&&e.push(g)}return e}),Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;if(0===c&&1===arguments.length)throw new TypeError;var d,e=0;if(arguments.length>=2)d=arguments[1];else for(;;){if(e in b){d=b[e++];break}if(++e>=c)throw new TypeError}for(;c>e;)e in b&&(d=a.call(void 0,d,b[e],e,b)),e++;return d}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;if(0===c&&1===arguments.length)throw new TypeError;var d,e=c-1;if(arguments.length>=2)d=arguments[1];else for(;;){if(e in this){d=this[e--];break}if(--e<0)throw new TypeError}for(;e>=0;)e in b&&(d=a.call(void 0,d,b[e],e,b)),e--;return d}),String.prototype.trim||(String.prototype.trim=function(){return String(this).replace(/^\s+/,"").replace(/\s+$/,"")}),Date.now||(Date.now=function(){return Number(new Date)}),Date.prototype.toISOString||(Date.prototype.toISOString=function(){function a(a){return("00"+a).slice(-2)}function b(a){return("000"+a).slice(-3)}return this.getUTCFullYear()+"-"+a(this.getUTCMonth()+1)+"-"+a(this.getUTCDate())+"T"+a(this.getUTCHours())+":"+a(this.getUTCMinutes())+":"+a(this.getUTCSeconds())+"."+b(this.getUTCMilliseconds())+"Z"}),function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,_,ab,bb,cb,db,eb=[].slice,fb={}.hasOwnProperty;o={init:function(){return o.rootApp||(o.rootApp=o.app()),o.rootApp.init()},app:function(b){var c;return c=new a(b),b||(o.rootApp=c),c},binding:function(a,c,d){var e;return c||d?b.addBinding(a,c,d):null!=(e=b.bindings[a])?e.handler:void 0},eventBinding:function(a){return b.addEventBinding(a)},keyEventBinding:function(a,c,d){return b.addKeyEventBinding(a,c,d)},attributeBinding:function(a){return b.addAttributeBinding(a)},attributeToggleBinding:function(a){return b.addAttributeToggleBinding(a)},filter:function(a,b,c){return"function"==typeof b||"function"==typeof c?(d.addFilter(a,b,c),this):b?[d.getFilter(a),d.getValueFilter(a)]:d.getFilter(a)}},$(document).on("ready.chip",o.init),window.chip=o,F=function(a,b){if(a.trigger)throw new Error("Object has already become an event emitter");return b=b||$({}),a.on=b.on.bind(b),a.one=b.one.bind(b),a.off=b.off.bind(b),a.trigger=b.trigger.bind(b),b},o.makeEventEmitter=F,g=function(){function a(){this.routes=[],this.params={},this.prefix="",F(this)}return a.prototype.param=function(a,b){if("function"!=typeof b)throw new Error('param must have a callback of type "function". Got '+b+".");return(this.params[a]||(this.params[a]=[])).push(b),this},a.prototype.route=function(a,b){if("function"!=typeof b)throw new Error('route must have a callback of type "function". Got '+b+".");return"/"!==a.charAt(0)&&(a="/"+a),this.routes.push(new f(a,b)),this},a.prototype.redirect=function(a,b){var c,d,e;return null==b&&(b=!1),"."===a.charAt(0)||a.split("//").length>1?(e=document.createElement("a"),e.href=a,a=R(e)+e.search):a=this.prefix+a,this.currentUrl!==a?!this.hashOnly&&this.root&&0!==a.indexOf(this.root)?(location.href=a,void 0):(d=!1,this.on("error",c=function(a){return"notFound"===a?d=!0:void 0}),this.usePushState?(b?history.replaceState({},"",a):history.pushState({},"",a),this.currentUrl=a,this.dispatch(a)):(this.hashOnly||(a=a.replace(this.root,""),"/"!==a.charAt(0)&&(a="/"+a)),location.hash="/"===a?"":"#"+a),this.off("error",c),!d):void 0},a.prototype.listen=function(a){var b,c,d,e=this;return null==a&&(a={}),a.stop?(this._handleChange&&$(window).off("popstate hashChange",this._handleChange),this):(null!=a.root&&(this.root=a.root),null!=a.prefix&&(this.prefix=a.prefix),null!=a.hashOnly&&(this.hashOnly=a.hashOnly),this.usePushState=!this.hashOnly&&null!=(null!=(d=window.history)?d.pushState:void 0),null!=this.root||this.usePushState||(this.hashOnly=!0),this.hashOnly&&(this.prefix=""),b=null,this._handleChange=function(){var a;return a=b(),e.currentUrl!==a?(e.currentUrl=a,e.dispatch(a)):void 0},this.usePushState?(location.hash&&(c=location.pathname.replace(/\/$/,"")+location.hash.replace(/^#?\/?/,"/"),history.replaceState({},"",c)),b=function(){return location.pathname+location.search},$(window).on("popstate",this._handleChange)):(b=function(){return location.hash?location.hash.replace(/^#\/?/,"/"):location.pathname+location.search},$(window).on("hashchange",this._handleChange)),this._handleChange(),this)},a.prototype.getUrlParts=function(a){var b,c;return c=document.createElement("a"),c.href=a,b=R(c),0!==b.indexOf(this.prefix)?null:(b.replace(this.prefix,""),{path:b,query:c.search})},a.prototype.getRoutesMatchingPath=function(a){var b;return"/"!==a.charAt(0)&&(a=null!=(b=this.getUrlParts(a))?b.path:void 0),null==a?[]:this.routes.filter(function(b){return b.match(a)})},a.prototype.dispatch=function(a){var b,c,d,e,f,g,h=this;return(g=this.getUrlParts(a))?(d=g.path,e={url:a,path:d,query:Q(g.query)},this.trigger("change",[d]),f=this.getRoutesMatchingPath(d),b=[],f.forEach(function(a){var c,d,e;b.push(function(b,c){return b.params=a.params,c()}),e=a.params;for(c in e)d=e[c],h.params[c]&&b.push.apply(b,h.params[c]);return b.push(a.callback)}),c=function(a){var d;return a?h.trigger("error",[a]):0===b.length?c("notFound"):(d=b.shift(),d(e,c))},0===b.length?c("notFound"):c(),this):void 0},a}(),o.Router=g,f=function(){function a(a,b){this.path=a,this.callback=b,this.keys=[],this.expr=O(a,this.keys)}return a.prototype.match=function(a){var b,c,d,e,f,g;if(!(d=this.expr.exec(a)))return!1;for(this.params={},b=f=0,g=d.length;g>f;b=++f)e=d[b],0!==b&&(c=this.keys[b-1],"string"==typeof e&&(e=decodeURIComponent(e)),c||(c="*"),this.params[c]=e);return!0},a}(),o.Route=f,O=function(a,b){return a instanceof RegExp?a:(Array.isArray(a)&&(a="("+a.join("|")+")"),a=a.concat("/?").replace(/\/\(/g,"(?:/").replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?(\*)?/g,function(a,c,d,e,f,g,h){var i;return b.push(e),c=c||"",i="",g||(i+=c),i+="(?:",g&&(i+=c),i+=d||"",i+=f||(d&&"([^/.]+?)"||"([^/]+?)")+")",i+=g||"",h&&(i+="(/*)?"),i}).replace(/([\/.])/g,"\\$1").replace(/\*/g,"(.*)"),new RegExp("^"+a+"$","i"))},Q=function(a){var b;return b={},""===a?b:(a.replace(/^\?/,"").split("&").forEach(function(a){var c,d,e;return e=a.split("="),c=e[0],d=e[1],b[decodeURIComponent(c)]=decodeURIComponent(d)}),b)},R=function(a){var b;return b=a.pathname,"/"!==b.charAt(0)&&(b="/"+b),b},e=function(){function a(a,b,c){this.getter=a,this.callback=b,this.oldValue=c}return a.prototype.skipNextSync=function(){return this.skip=!0},a.prototype.sync=function(){var a,b;if(b=this.getter(),this.skip)delete this.skip;else{if(a=s.values(b,this.oldValue),!a)return;Array.isArray(a)?this.callback(b,this.oldValue,a):this.callback(b,this.oldValue)}return this.oldValue=s.clone(b)},a.prototype.close=function(){return a.remove(this)},a.observers=[],a.callbacks=[],a.listeners=[],a.add=function(b,c,d){var e,f;return"function"==typeof c&&(d=c,c=!1),f=b(),e=new a(b,d,s.clone(f)),this.observers.push(e),c||d(f),e},a.remove=function(a){var b;return b=this.observers.indexOf(a),-1!==b?(this.observers.splice(b,1),!0):!1},a.syncing=!1,a.rerun=!1,a.cycles=0,a.max=10,a.timeout=null,a.sync=function(a){var b,c,d,e;if("function"==typeof a&&this.afterSync(a),this.syncing)return this.rerun=!0,!1;for(this.syncing=!0,this.rerun=!0,this.cycles=0;this.rerun;){if(++this.cycles===this.max)throw"Infinite observer syncing, an observer is calling Observer.sync() too many times";this.rerun=!1;for(var f=0;fc;c++)b=e[c],b();return this.syncing=!1,this.cycles=0,!0},a.syncLater=function(a){var b=this;return this.timeout?!1:(this.timeout=setTimeout(function(){return b.timeout=null,b.sync(a)}),!0)},a.afterSync=function(a){if("function"!=typeof a)throw new TypeError("callback must be a function");return this.callbacks.push(a)},a.onSync=function(a){if("function"!=typeof a)throw new TypeError("listener must be a function");return this.listeners.push(a)},a.removeOnSync=function(a){var b;if("function"!=typeof a)throw new TypeError("listener must be a function");return b=this.listeners.indexOf(a),-1!==b?this.listeners.splice(b,1).pop():void 0},a}(),o.Observer=e,c=function(){function a(){this._observers=[],this._children=[],this._closed=!1}return a.prototype.watch=function(a,b,c){var d,f,g,h,i,j=this;return Array.isArray(a)?("function"==typeof b&&(c=b,b=!1),i=c,d=!1,c=function(){var a;if(!d)return d=!0,setTimeout(function(){return d=!1}),a=h.map(function(a){return a.getter()}),i.apply(null,a)},h=a.map(function(a){return j.watch(a,!0,c)}),b||c(),h):(f="function"==typeof a?a:v.bind(a,this),g=e.add(f,b,c),g.expr=a,this._observers.push(g),g)},a.prototype.unwatch=function(a,b){var c=this;return this._observers.some(function(d,e){return d.expr===a&&d.callback===b?(d.close(),c._observers.splice(e,1),!0):!1})},a.prototype.eval=function(a,b){var c,d;return b&&(c={args:Object.keys(b)},d=c.args.map(function(a){return b[a]})),v.get(a,c).apply(this,d)},a.prototype.evalSetter=function(a,b){return this.passthrough()!==this?this.passthrough().evalSetter(a,b):(a=a.replace(/(\s*\||$)/," = value$1"),v.get(a,{args:["value"]}).call(this,b))},a.prototype.getBoundEval=function(){var a,b;return a=arguments[0],b=2<=arguments.length?eb.call(arguments,1):[],v.bind(a,this,{args:b})},a.prototype.redirect=function(a,b){return null==b&&(b=!1),this.app.redirect(a,b),this},a.prototype.cloneValue=function(a){return s.clone(this[a])},a.prototype.closeController=function(){var a,b,c,d,f,g,h,i,j,k,l,m,n;if(!this._closed){for(this._closed=!0,k=this._children,d=0,h=k.length;h>d;d++)a=k[d],a.parent=null,a.closeController();if((null!=(l=this.parent)?l._children:void 0)&&this.parent._children.remove(this),this.hasOwnProperty("beforeClose")&&this.beforeClose(),this._syncListeners){for(m=this._syncListeners,f=0,i=m.length;i>f;f++)b=m[f],e.removeOnSync(b);delete this._syncListeners}for(n=this._observers,g=0,j=n.length;j>g;g++)c=n[g],c.close();this._observers.length=0,this.hasOwnProperty("onClose")&&this.onClose()}},a.prototype.sync=function(a){return e.sync(a),this},a.prototype.syncLater=function(a){return e.syncLater(a),this},a.prototype.afterSync=function(a){return e.afterSync(a),this},a.prototype.onSync=function(a){return this._syncListeners||(this._syncListeners=[]),this._syncListeners.push(a),e.onSync(a),this},a.prototype.removeOnSync=function(a){var b;return b=this._syncListeners.indexOf(a),-1!==b&&this._syncListeners.splice(b,1),e.removeOnSync(a),this},a.prototype.passthrough=function(a){return arguments.length?this._passthrough=a:this.hasOwnProperty("_passthrough")?this._passthrough:this},a}(),$.fn.controller=function(a){var b,c;for(c=this;c.length;){if(b=c.data("controller"))return a?b.passthrough():b;c=c.parent()}return null},$.widget||($.cleanData=function(a){return function(b){var c,d,e,f;for(e=0,f=b.length;f>e;e++){d=b[e];try{$(d).triggerHandler("remove")}catch(g){c=g}}return a(b)}}($.cleanData)),o.Controller=c,v={cache:{},globals:["true","false","window","this"]},v.isInverted=function(a){return a.match(C)&&!0},v.revert=function(a){return a='"'+a.replace(C,function(a,b){return'" + ('+b+') + "'})+'"',a.replace(/^"" \+ | \+ ""$/g,"")},v.get=function(a,b){var c,d,e,f,g;if(null==b&&(b={}),c=b.args||[],e=a+"|"+c.join(","),g=v.cache[e])return g;d=v.parse(a,b);try{g=v.cache[e]=Function.apply(null,eb.call(c).concat([d]))}catch(h){throw f=h,console&&console.error("Bad expression:\n`"+a+"`\n"+"Compiled expression:\n"+d),new Error(f.message)}return g},v.bind=function(a,b,c){return v.get(a,c).bind(b)},C=/{{(.*)}}/g,X=/(['"\/])(\\\1|[^\1])*?\1/g,u=/(['"\/])\1/g,S=/\|(\|)?/g,k=/\s*:\s*/g,U=/((\{|,|\.)?\s*)([a-z$_\$](?:[a-z_\$0-9\.-]|\[['"\d]+\])*)(\s*(:|\(|\[)?)/gi,n=/\.|\[/g,m=/\.|\[|\(/,Z=/\s=\s/,A=null,bb=[],Y=0,r=0,q=0,x=!1,p=!1,v.parse=function(a,b){return B(a,b),a=V(a),a=L(a),a=K(a),a="return "+a,a=W(a),a=i(a)},B=function(a,b){return Y=r=0,A=v.globals.concat((null!=b?b.globals:void 0)||[],(null!=b?b.args:void 0)||[]),bb.length=0},V=function(a){var b;return b=a.replace(X,function(a,b){return bb.push(a),b+b})},W=function(a){return a=a.replace(u,function(){return bb.shift()})},i=function(a){var b,c,d;if(Y){for(c=[],b=d=1;Y>=1?Y>=d:d>=Y;b=Y>=1?++d:--d)c.push("_ref"+b);a="var "+c.join(", ")+";\n"+a}return a},L=function(a){var b,c,d,e;return a=a.replace(S,function(a,b){return b?a:"@@@"}),b=a.split(/\s*@@@\s*/),a=b.shift(),b.length?(Z.test(a)?(e=a.split(Z),c=e[0],d=e[1],c+=" = "):(c="",d=a),b.forEach(function(a){var b,e;return b=a.split(k),e=b.shift(),b.unshift(d),c&&b.push(!0),d="_filters."+e+".call(this, "+b.join(", ")+")"}),c+d):a},K=function(a){var b,c,d;return Z.test(a)?(d=a.split(" = "),b=d[0],c=d[1],b=P(b).replace(/^\(|\)$/g,"")+" = ",c=P(c),b+c):P(a)},P=function(a){var b,c,d;for(b="",d=[q,U.lastIndex],q=0,U.lastIndex=0;(c=H(a))!==!1;)b+=c;return U.lastIndex=d.pop(),q=d.pop(),b},H=function(a){var b,c,d,e,f,g,h,i;return x?x=!1:(c=U.exec(a))?(i=c,c=i[0],f=i[1],d=i[2],g=i[3],e=i[4],b=i[5],h=a.slice(q,U.lastIndex-c.length),q=U.lastIndex,d&&":"===b?h+c:h+J(f,g,e,b,a)):(x=!0,a.slice(q))},ab=function(a){var b,c,d;for(b=0,d=[];c=n.exec(a);)1!==n.lastIndex&&(d.push(a.slice(b,n.lastIndex-1)),b=n.lastIndex-1);return d.push(a.slice(b)),d},j=function(a){return-1===A.indexOf(a.split(m).shift())?"this."+a:a},J=function(a,b,c,d,e){var f,g,h;return p="."===a,p&&(b="."+b,a=""),g=ab(b),h="",1!==g.length||p||d?(p||(h="("),g.forEach(function(a,b){b!==g.length-1?h+=N(a,b):I[d]?(c=c.replace(d,""),h+=M(a,b,e)):h+="_ref"+r+a+")"})):(f=g[0],h=j(f)),a+h+c},I={"(":")","[":"]"},M=function(a,b,c){var d,e,f;return d=z(c),a+=d.slice(0,1)+"~~insideParens~~"+d.slice(-1),e=d.slice(1,-1),"."===c.charAt(U.lastIndex)?a=N(a,b):0===b?(a=N(a,b),a+="_ref"+r+")"):a="_ref"+r+a+")",f=r,a=a.replace("~~insideParens~~",P(e)),r=f,a},z=function(a){var b,c,d,e,f;for(f=U.lastIndex,d=a.charAt(f-1),b=I[d],c=f-1,e=1;c++1)return this.templates[a]=b,this;if(!this.templates.hasOwnProperty(a))throw'Template "'+a+'" does not exist';return $(this.templates[a].trim())},a.prototype.translate=function(a,b){var c,d,e;if(!b){e=this.translations;for(c in e)d=e[c],delete this.translations[c]}for(c in a)d=a[c],this.translations[c]=d;return this.trigger("translationChange",[this.translations])},a.prototype.controller=function(a,b){return arguments.length>1?(this.controllers[a]=b,this):this.controllers[a]||window[a+"Controller"]},a.prototype.createController=function(a){var b,e,f,g,h,i,j,k=this;if(null==a&&(a={}),a.parent instanceof c?(b=function(){return c.call(this)},a.parent&&(b.prototype=a.parent),e=new b,e.parent=a.parent,a.parent._children.push(e),a.passthrough&&e.passthrough(a.parent.passthrough())):(e=new c,F(e,this._emitter),e.app=this,e.translations=this.translations,e._filters=d.filters),a.properties){j=a.properties;for(f in j)fb.call(j,f)&&(h=j[f],e[f]=h)}return e.child=function(a){return null==a&&(a={}),a.parent=e,k.createController(a)},e.template=function(a){return k.template(a)},a.element&&((g=a.element.data("controller"))&&(a.element.off("remove.controller"),g.closeController()),a.element.one("remove.controller",function(){return e.closeController()}),e.element=a.element,a.element.data("controller",e)),a.name&&"function"==typeof(i=this.controller(a.name))&&i(e),a.element&&a.element.bindTo(e),e},a.prototype.param=function(a,b){var c,d=this;return c=function(a,c){return d.rootController.params=a.params,d.rootController.query=a.query,b(d.rootController,c)},this.router.param(a,c),this},a.prototype.route=function(a,b,c){var d,e=this;return d=function(a,b,c,f,g){var h,i;if("function"==typeof b&&b.toString().match(/\(route\)/)&&(c=b,b=null),b||(b=a.replace(/^\//,"")),"string"==typeof b){if(i=b,h=function(a,b){var d,j,k,l,m,n;if(g&&!a.calledBefore)return a.calledBefore=!0,g(a,h),void 0;for(e.rootController.params=a.params,e.rootController.query=a.query,l=[],j=n=0;f>=0?f>=n:n>=f;j=f>=0?++n:--n)l.push("[bind-route]");return d=e.rootElement.find(l.join(" ")+":first"),k=e.rootController.route,null==a.isSamePath&&(a.isSamePath=a.path===e.rootController.path),d.length?(m=function(){var f,g;return d.attr("bind-route",i),e.rootController.route=i,e.rootController.path=a.path,e.trigger("routeChange",[i]),a.isSamePath?d.animateIn():(d.willAnimate()&&(g=$("").insertBefore(d),d.detach(),setTimeout(function(){return g.after(d).remove(),d.animateIn()})),d.html(e.template(i)),f=d.parent().controller()||e.rootController,e.createController({element:d,parent:f,name:i})),e.rootController.sync(),window.scrollTo(0,0),c?b(a,b):void 0},k?d.animateOut(a.isSamePath,m):m()):void 0},"function"==typeof c)return c(function(b,c,e){return"/"===b&&(b=""),d(a+b,c,e,f+1,h)}),void 0}else{if("function"!=typeof b)throw new Error("route handler must be a string path or a function");h=function(a,c){return e.rootController.params=a.params,e.rootController.query=a.query,b(e.rootController,c)}}return e.router.route(a,h)},d(a,b,c,0),this},a.prototype.redirect=function(a,b){return null==b&&(b=!1),this.router.redirect(a,b)},a.prototype.hasMatchingRoutes=function(a){return this.router.getRoutesMatchingPath(a).length>0},a.prototype.mount=function(){},a.prototype.listen=function(a){var b=this;return null==a&&(a={}),$(function(){var c;return a.stop?(b._routeHandler&&b.router.off("change",b._routeHandler),b._clickHandler&&b.rootElement.off("click","a[href]",b._clickHandler),b.router.listen(a)):(c=b,b._routeHandler=function(a,c){return b.trigger("urlChange",[c])},b._clickHandler=function(b){var d,e;if(!(b.isDefaultPrevented()||(d=this.host.replace(/:80$|:443$/,""),e=$(this).attr("href").replace(/^#/,""),d&&d!==location.host||b.metaKey||b.ctrlKey||$(b.target).attr("target")||a.dontHandle404s&&!c.hasMatchingRoutes(e)||(b.preventDefault(),this.href===location.href+"#"))))return $(this).attr("disabled")?void 0:c.redirect(e)},b.router.on("change",b._routeHandler),b.rootElement.on("click","a[href]",b._clickHandler),b.router.listen(a))}),this},a}(),o.App=a,b=function(){function a(a,b){this.name=a,this.expr=b}return a.bindings=[],a.addBinding=function(a,b,c){var d;return"function"==typeof b?(c=b,b={}):b||(b={}),d={name:b.name||a,priority:b.priority||0,keepAttribute:b.keepAttribute,handler:c},this.bindings[a]=d,this.bindings.push(d),this.bindings.sort(l),d},a.removeBinding=function(a){var b;return(b=this.bindings[a])?(delete this.bindings[a],this.bindings.splice(this.bindings.indexOf(b),1)):void 0},a.addEventBinding=function(a,b){var c;return c=a.split("-").slice(1).join("-"),this.addBinding(a,b,function(a,b,d){var e;return e=b.value,a.on(c,function(b){return b.preventDefault(),a.attr("disabled")?void 0:(d.thisElement=a,d.eval(e),delete d.thisElement)})})},a.addKeyEventBinding=function(a,b,c,d){return this.addBinding(a,d,function(a,d,e){var f;return f=d.value,a.on("keydown",function(d){return null!=c&&d.ctrlKey!==c&&d.metaKey!==c||d.keyCode!==b?void 0:(d.preventDefault(),a.attr("disabled")?void 0:(e.thisElement=a,e.eval(f),delete e.thisElement))})})},a.addAttributeBinding=function(a,b){var c;return c=a.split("-").slice(1).join("-"),this.addBinding(a,b,function(a,b,d){var e;return e=b.value,d.watch(e,function(b){return null!=b?(a.attr(c,b),a.trigger(c+"Changed")):a.removeAttr(c)})})},a.addAttributeToggleBinding=function(a,b){var c;return c=a.split("-").slice(1).join("-"),this.addBinding(a,b,function(a,b,d){var e;return e=b.value,d.watch(e,function(b){return a.prop(c,b&&!0||!1)})})},a.process=function(a,b){var d,e,f,g,i,j,k,l,m;if(!(b instanceof c))throw new Error("A Controller is required to bind a jQuery element.");for(l=Array.prototype.slice,m=new h(a.get(0)),j=[],m.onElementDone=function(a){return j.length&&j[j.length-1].get(0)===a?j.pop().trigger("processed"):void 0};g=m.next();)for(g!==m.root&&(a=$(g)),i=g.parentNode,e=l.call(g.attributes).map(y).filter(w).sort(_),e.length&&j.push(a);e.length;){if(d=e.shift(),f=d.binding,f.keepAttribute||a.removeAttr(d.name),"-*"===f.name.slice(-2)&&(d.match=d.name.replace(f.name.slice(0,-1),""),d.camel=d.match.replace(/[-_]+(\w)/g,function(a,b){return b.toUpperCase()})),k=f.handler(a,d,b),g.parentNode!==i){j.pop();break}if(k===!1){m.skip();break}}return a},a}(),y=function(a){var c,d;if(c=b.bindings[a.name],!c)for(d=a.name.split("-");d.length>1&&(d.pop(),!(c=b.bindings[d.join("-")+"-*"])););return c||v.isInverted(a.value)&&(c=b.bindings["attr-*"]),c?{binding:c,name:a.name,value:a.value}:void 0},w=function(a){return a},_=function(a,b){return b.binding.priority-a.binding.priority},l=function(a,b){return b.priority-a.priority},jQuery.fn.bindTo=function(a){return 0!==this.length?b.process(this,a):void 0},o.Binding=b,h=function(){function a(a){this.root=a,this.current=null}return a.prototype.onElementDone=function(){},a.prototype.next=function(){return null===this.current?this.current=this.root:(this.current!==this.root&&null===this.current.parentNode&&(this.current=this.placeholder),this.current=this.traverse(this.current)),this.current?this.placeholder={parentNode:this.current.parentNode,nextElementSibling:this.current.nextElementSibling}:(this.placeholder=null,this.onElementDone(this.root)),this.current},a.prototype.traverse=function(a){var b,c;if(a.nodeType&&(b=a.firstElementChild))return b;for(;null!==a;){if(a.nodeType&&this.onElementDone(a),a===this.root)return null;if(c=a.nextElementSibling)return c;a=a.parentNode}return a},a.prototype.skip=function(){return this.current=this.placeholder},a}(),d=function(){function a(a,b){this.name=a,this.filter=b}return a.filters={},a.addFilter=function(a,b){return null!=b&&(this.filters[a]=b),this},a.getFilter=function(a){return this.filters[a]},a}(),o.binding("bind-debug",{priority:200},function(a,b,c){var d;return d=b.value,c.watch(d,function(a){return"undefined"!=typeof console&&null!==console?console.info("Debug:",d,"=",a):void 0})}),o.binding("bind-route",{keepAttribute:!0},function(){}),o.binding("bind-text",function(a,b,c){var d;return d=b.value,c.watch(d,function(b){return a.text(null!=b?b:"")})}),o.binding("bind-html",function(a,b,c){var d;return d=b.value,c.watch(d,function(b){return a.html(null!=b?b:"")})}),o.binding("bind-trim",function(a){var b,c,d;for(c=a.get(0).firstChild,d=[];c;)b=c.nextSibling,c.nodeType===Node.TEXT_NODE&&(c.nodeValue.match(/^\s*$/)?c.parentNode.removeChild(c):c.textContent=c.textContent.trim()),d.push(c=b);return d}),o.binding("bind-translate",function(a,b,c){var d,e,f,g,h,i,j,k;for(f=a.get(0).childNodes,i="",g=[],d=j=0,k=f.length;k>j;d=++j)e=f[d],3===e.nodeType?(""!==e.nodeValue.trim()||0!==d&&d!==f.length-1)&&(i+=e.nodeValue):1===e.nodeType&&(i+="%{"+g.length+"}",g.push(e));return h=function(){var b,d,e,h,j;for(j=c.translations[i]||i,b=/%{(\d+)}/g,f=[],d=0;e=b.exec(j);)h=b.lastIndex-e[0].length,d!==h&&f.push(document.createTextNode(j.slice(d,h))),f.push(g[e[1]]),d=b.lastIndex;return d!==j.length&&f.push(document.createTextNode(j.slice(d))),a.html(f)},a.on("remove",function(){return c.off("translationChange",h)}),c.on("translationChange",h),c.translations[i]?h():void 0}),o.binding("bind-class",function(a,b,c){var d,e;return d=b.value,e=(a.attr("class")||"").split(/\s+/),""===e[0]&&e.pop(),c.watch(d,function(b){var c,d,f;if(Array.isArray(b)&&(b=b.join(" ")),"string"==typeof b)return a.attr("class",b.split(/\s+/).concat(e).join(" "));if(b&&"object"==typeof b){f=[];for(c in b)fb.call(b,c)&&(d=b[c],d?f.push(a.addClass(c)):f.push(a.removeClass(c)));return f}})}),o.binding("bind-attr",function(a,b,c){var d;return d=b.value,c.watch(d,function(b,c,d){var e,f,g;if(d)return d.forEach(function(c){return"deleted"===c.type||null==b[c.name]?(a.removeAttr(c.name),a.trigger(c.name+"Changed")):(a.attr(c.name,b[c.name]),a.trigger(c.name+"Changed"))});if(b&&"object"==typeof b){g=[];for(e in b)fb.call(b,e)&&(f=b[e],null!=f?(a.attr(e,f),g.push(a.trigger(e+"Changed"))):(a.removeAttr(e),g.push(a.trigger(e+"Changed"))));return g}})}),o.binding("bind-active",function(a,b,c){var d,e,f;return d=b.value,d?c.watch(d,function(b){return b?a.addClass("active"):a.removeClass("active")}):(f=function(){return e.length&&e.get(0).href===location.href?a.addClass("active"):a.removeClass("active")},e=a.filter("a").add(a.find("a")).first(),e.on("hrefChanged",f),c.on("urlChange",f),a.on("remove",function(){return c.off("urlChange",f)}),f())}),o.binding("bind-active-section",function(a,b,c){var d,e;return e=function(){return d.length&&0===location.href.indexOf(d.get(0).href)?a.addClass("active"):a.removeClass("active")},d=a.filter("a").add(a.find("a")).first(),d.on("hrefChanged",e),c.on("urlChange",e),a.on("remove",function(){return c.off("urlChange",e)}),e()}),o.binding("bind-change-action",function(a,b,c){var d,e,f;return e=b.value,f=e.split(/\s*!\s*/),e=f[0],d=f[1],c.watch(e,function(){return c.thisElement=a,c.eval(d),delete c.thisElement})}),o.binding("bind-show",function(a,b,c){var d;return d=b.value,c.watch(d,function(b){return b?a.show():a.hide()})}),o.binding("bind-hide",function(a,b,c){var d;return d=b.value,c.watch(d,function(b){return b?a.hide():a.show()})}),o.binding("bind-value",function(a,b,c){var d,e,f,g,h,i,j,k;return e=b.value,k=e,f=a.attr("bind-value-field"),a.removeAttr("bind-value-field"),a.is("select")&&(i=f?c.eval(f):null,o.lastSelectValueField=i),a.is("option")&&(f||o.lastSelectValueField)&&(i=f?c.eval(f):o.lastSelectValueField,k+="."+i),g="checkbox"===a.attr("type")?function(){return a.prop("checked")}:"file"===a.attr("type")?function(){var b;return null!=(b=a.get(0).files)?b[0]:void 0}:a.is(":not(input,select,textarea,option)")?function(){return a.find("input:radio:checked").val()}:i&&a.is("select")?function(b){return b?$(a.get(0).options[a.get(0).selectedIndex]).data("value"):a.val()}:function(){return a.val()},j="checkbox"===a.attr("type")?function(b){return a.prop("checked",b)}:"file"===a.attr("type")?function(){}:a.is(":not(input,select,textarea,option)")?function(b){return a.find("input:radio:checked").prop("checked",!1),a.find('input:radio[value="'+b+'"]').prop("checked",!0)}:function(b){var c;return c=i&&(null!=b?b[i]:void 0)||b,null!=c&&(c=""+c),a.val(c),i?a.data("value",b):void 0},h=c.watch(k,function(a){return g()!==""+a?j(c.eval(e)):void 0 -}),a.is("option")?void 0:(a.is("select")?a.one("processed",function(){return j(c.eval(e)),a.is("[readonly]")?void 0:c.evalSetter(e,g(!0))}):a.is("[readonly]")||c.evalSetter(e,g()),d=a.attr("bind-value-events")||"change",a.removeAttr("bind-value-events"),a.is(":text")&&a.on("keydown",function(b){return 13===b.keyCode?a.trigger("change"):void 0}),a.on(d,function(){return g()===h.oldValue||a.is("[readonly]")?void 0:(c.evalSetter(e,g(!0)),h.skipNextSync(),c.sync())}))}),o.binding("on-*",function(a,b,c){var d,e;return d=b.match,e=b.value,a.on(d,function(b){return b.originalEvent&&b.preventDefault(),a.attr("disabled")?void 0:c.eval(e,{event:b,element:a})})}),E={enter:13,esc:27};for(G in E)fb.call(E,G)&&(D=E[G],o.keyEventBinding("on-"+G,D));o.keyEventBinding("on-ctrl-enter",E.enter,!0),o.binding("attr-*",function(a,b,c){var d,e;return b.name!==b.match?(d=b.match,e=b.value):(d=b.name,e=v.revert(b.value)),c.watch(e,function(b){return null!=b?(a.attr(d,b),a.trigger(d+"Changed")):a.removeAttr(d)})}),["attr-checked","attr-disabled","attr-multiple","attr-readonly","attr-selected"].forEach(function(a){return o.attributeToggleBinding(a)}),$.fn.animateIn=function(a){var b,c=this;return this.parent().length&&(b=$(""),this.before(b),this.detach()),this.addClass("animate-in"),b&&(b.after(this),b.remove()),setTimeout(function(){return c.removeClass("animate-in"),a?c.willAnimate()?c.one("webkittransitionend transitionend webkitanimationend animationend",function(){return a()}):a():void 0}),this},$.fn.animateOut=function(a,b){var c,d,e,f=this;return"function"==typeof a&&(b=a,a=!1),a||this.triggerHandler("remove"),d=this.cssDuration("transition")||this.cssDuration("animation"),d?(this.addClass("animate-out"),c=function(){return clearTimeout(e),f.off("webkittransitionend transitionend webkitanimationend animationend",c),f.removeClass("animate-out"),b?b():f.remove()},this.one("webkittransitionend transitionend webkitanimationend animationend",c),e=setTimeout(c,d+100)):b?b():a||this.remove(),this},$.fn.cssDuration=function(a){var b,c;return c=this.css(a+"-duration")||this.css("-webkit-"+a+"-duration"),b=parseFloat(c),/\ds/.test(c)&&(b*=1e3),b||0},$.fn.willAnimate=function(){return this.cssDuration("transition")&&!0},o.binding.prepareScope=T=function(a,b,c){var d,e,f,g;return g=$(a),f=$("'),c.element[0]===a[0]?(e=document.createDocumentFragment(),e.appendChild(f[0]),a[0]=e):a.replaceWith(f),d=a.attr("bind-controller"),a.removeAttr("bind-controller"),{template:g,placeholder:f,controllerName:d}},o.binding.swapPlaceholder=cb=function(a,b){return a[0].parentNode.replaceChild(b[0],a[0])},o.binding("bind-if",{priority:50},function(a,b,c){var d,e,f,g,h;return e=b.value,h=T(a,b,c),g=h.template,f=h.placeholder,d=h.controllerName,c.watch(e,function(b){if(b){if(f[0].parentNode)return a=g.clone().animateIn(),c.child({element:a,name:d,passthrough:!0}),cb(f,a)}else if(!f[0].parentNode)return a.before(f),a.animateOut()}),!1}),o.binding("bind-unless",{priority:50},function(a,b,c){var d,e,f,g,h;return e=b.value,h=T(a,b,c),g=h.template,f=h.placeholder,d=h.controllerName,c.watch(e,function(b){if(b){if(!f[0].parentNode)return a.before(f),a.animateOut()}else if(f[0].parentNode)return a=g.clone().animateIn(),c.child({element:a,name:d,passthrough:!0}),cb(f,a)}),!1}),o.binding("bind-each",{priority:100},function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q;if(i=g=b.value,o=T(a,b,c),m=o.template,j=o.placeholder,d=o.controllerName,p=g.split(/\s+in\s+/),h=p[0],g=p[1],q=h.split(/\s*,\s*/),h=q[0],k=q[1],!h||!g)throw'Invalid bind-each="'+i+'". Requires the format "item in list"'+' or "key, propery in object".';return f=$(),l={},n=null,e=function(a,b){var e;return e=m.clone(),Array.isArray(n)?(l[h]=a,l.index=b):(k&&(l[k]=a),l[h]=n[a]),c.child({element:e,name:d,properties:l}),e.get(0)},c.watch(g,function(a,b,c){var d;if(n=a,c){if(Array.isArray(n)||n&&"object"==typeof n)return Array.isArray(n)||(c=s.arrays(Object.keys(n),Object.keys(b))),d=0,c.forEach(function(a){return d+=a.addedCount}),c.forEach(function(a){var b,c,g,h,i;for(c=[a.index,a.removed.length],h=[],b=a.index;b\nbody {\n background: none transparent;\n width: auto;\n min-width: 0;\n margin: 0;\n padding: 0;\n}\n"),e.html(c.template(b)),d=c.child({element:e,name:b,properties:f}),a.height(e.outerHeight()),a.data("body",e)};try{return g(a.contents().find("body"))}catch(j){return e=j,a.one("load",function(){return g(a.contents().find("body"))}),a.attr("src","about:blank")}}}),!1}),o.binding("local-*",{priority:20},function(a,b,c){var d,e;return d=b.value,e=b.camel,d?(c.watch(d,function(a){return c[e]=a}),")"!==d.slice(-1)?c.watch(e,!0,function(a){return c.parent.passthrough().evalSetter(d,a)}):void 0):c[e]=!0}),o.binding("bind-content",{priority:40},function(a,b,c){return c._partialContent?a.html(c._partialContent):void 0}),o.binding("bind-controller",{priority:30},function(a,b,c){var d;return d=b.value,c.child({element:a,name:d}),!1}),o.filter("filter",function(a,b){return Array.isArray(a)?b?a.filter(b,this):a:[]}),o.filter("map",function(a,b){return null!=a&&b?Array.isArray(a)?a.map(b,this):b.call(this,a):a}),o.filter("reduce",function(a,b,c){return null!=a&&b?Array.isArray(a)?3===arguments.length?a.reduce(b,c):a.reduce(b):3===arguments.length?b(c,a):void 0:a}),o.filter("slice",function(a,b,c){return Array.isArray(a)?a.slice(b,c):a}),o.filter("date",function(a){return a?(a instanceof Date||(a=new Date(a)),isNaN(a.getTime())?"":a.toLocaleString()):""}),o.filter("log",function(a,b){return null==b&&(b="Log"),console.log(b+":",a),a}),o.filter("limit",function(a,b){return a&&"function"==typeof a.slice?0>b?a.slice(b):a.slice(0,b):a}),o.filter("sort",function(a,b){var c,d,e;return b?("string"==typeof b&&(e=b.split(":"),d=e[0],c=e[1],c="desc"===c?-1:1,b=function(a,b){return a[d]>b[d]?c:a[d]")),t.text(a||"").text()}),o.filter("p",function(a){var b,c;return t||(t=$("
")),c=(a||"").split(/\r?\n/),b=c.map(function(a){return t.text(a).text()||"
"}),"

"+b.join("

")+"

"}),o.filter("br",function(a){var b,c;return t||(t=$("
")),c=(a||"").split(/\r?\n/),b=c.map(function(a){return t.text(a).text()}),b.join("
")}),o.filter("newline",function(a){var b,c;return t||(t=$("
")),c=(a||"").split(/\r?\n\s*\r?\n/),b=c.map(function(a){var c;return c=a.split(/\r?\n/),b=c.map(function(a){return t.text(a).text()}),b.join("
")}),"

"+b.join("

")+"

"}),db=/(^|\s|\()((?:https?|ftp):\/\/[\-A-Z0-9+\u0026@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~(_|])/gi,o.filter("autolink",function(a,b){return b=b?' target="_blank"':"",(""+a).replace(/<[^>]+>|[^<]+/g,function(a){return"<"===a.charAt(0)?a:a.replace(db,'$1$2")})}),o.filter("int",function(a){return a=parseInt(a),isNaN(a)?null:a}),o.filter("float",function(a){return a=parseFloat(a),isNaN(a)?null:a}),o.filter("bool",function(a){return a&&"0"!==a&&"false"!==a}),s={},function(){var a,b,c,d,e,f,g,h,i,j;return s.clone=function(a,b){var c,d,e;if(Array.isArray(a))return b?a.map(function(a){return s.clone(a,b)}):a.slice();if(a&&"object"==typeof a){if(a.valueOf()!==a)return new a.constructor(a.valueOf());c={};for(d in a)e=a[d],b&&(e=s.clone(e,b)),c[d]=e;return c}return a},s.values=function(a,b){var c,d,e,f;return Array.isArray(a)&&Array.isArray(b)?(e=s.arrays(a,b),e.length?e:!1):a&&b&&"object"==typeof a&&"object"==typeof b?(f=a.valueOf(),d=b.valueOf(),"object"!=typeof f&&"object"!=typeof d?f!==d:(c=s.objects(a,b),c.length?c:!1)):s.basic(a,b)},s.basic=function(a,b){var c,d;return a&&b&&"object"==typeof a&&"object"==typeof b&&(d=a.valueOf(),c=b.valueOf(),"object"!=typeof d&&"object"!=typeof c)?s.basic(d,c):"number"==typeof a&&"number"==typeof b&&isNaN(a)&&isNaN(b)?!1:a!==b},s.objects=function(a,b){var c,d,e,g;c=[];for(e in b)d=b[e],g=a[e],(void 0===g||s.basic(g,d))&&(e in a?s.basic(g,d)&&c.push(f(a,"updated",e,d)):c.push(f(a,"deleted",e,d)));for(e in a)g=a[e],e in b||c.push(f(a,"new",e));return Array.isArray(a)&&a.length!==b.length&&c.push(f(a,"updated","length",b.length)),c},f=function(a,b,c,d){return{object:a,type:b,name:c,oldValue:d}},c=0,d=1,a=2,b=3,s.arrays=function(f,k){var l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A;if(m=0,l=f.length,s=0,q=k.length,p=Math.min(l,q),v=h(f,k,p),y=i(f,k,p-v),m+=v,s+=v,l-=y,q-=y,0===l-m&&0===q-s)return[];if(m===l)return[g(m,k.slice(s,q),0)];if(s===q)return[g(m,[],l-m)];for(n=e(f,m,l,k,s,q),u=j(n),w=void 0,x=[],o=m,r=s,z=0,A=u.length;A>z;z++)t=u[z],t===c?(w&&(x.push(w),w=void 0),o++,r++):t===d?(w||(w=g(o,[],0)),w.addedCount++,o++,w.removed.push(k[r]),r++):t===a?(w||(w=g(o,[],0)),w.addedCount++,o++):t===b&&(w||(w=g(o,[],0)),w.removed.push(k[r]),r++);return w&&x.push(w),x},h=function(a,b,c){var d,e;for(d=e=0;c>=0?c>e:e>c;d=c>=0?++e:--e)if(s.basic(a[d],b[d]))return d;return c},i=function(a,b,c){var d,e,f;for(e=a.length,f=b.length,d=0;c>d&&!s.basic(a[--e],b[--f]);)d++;return d},g=function(a,b,c){return{index:a,removed:b,addedCount:c}},j=function(e){var f,g,h,i,j,k,l,m;for(h=e.length-1,i=e[0].length-1,f=e[h][i],g=[];h>0||i>0;)0!==h?0!==i?(l=e[h-1][i-1],m=e[h-1][i],k=e[h][i-1],j=k>m?l>m?m:l:l>k?k:l,j===l?(l===f?g.push(c):(g.push(d),f=l),h--,i--):j===m?(g.push(b),h--,f=m):(g.push(a),i--,f=k)):(g.push(b),h--):(g.push(a),i--);return g.reverse(),g},e=function(a,b,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q;for(l=f-e+1,g=c-b+1,h=new Array(l),i=n=0;l>=0?l>n:n>l;i=l>=0?++n:--n)h[i]=new Array(g),h[i][0]=i;for(j=o=0;g>=0?g>o:o>g;j=g>=0?++o:--o)h[0][j]=j;for(i=p=1;l>=1?l>p:p>l;i=l>=1?++p:--p)for(j=q=1;g>=1?g>q:q>g;j=g>=1?++q:--q)s.basic(a[b+j-1],d[e+i-1])?(k=h[i-1][j]+1,m=h[i][j-1]+1,h[i][j]=m>k?k:m):h[i][j]=h[i-1][j-1];return h}}.call(this),o.diff=s}.call(this); \ No newline at end of file +Object.getPrototypeOf||(Object.getPrototypeOf=function(a){if(a!==Object(a))throw new TypeError("Object.getPrototypeOf called on non-object");return a.__proto__||a.constructor.prototype||Object.prototype}),"function"!=typeof Object.getOwnPropertyNames&&(Object.getOwnPropertyNames=function(a){if(a!==Object(a))throw new TypeError("Object.getOwnPropertyNames called on non-object");var b,c=[];for(b in a)Object.prototype.hasOwnProperty.call(a,b)&&c.push(b);return c}),"function"!=typeof Object.create&&(Object.create=function(a,b){"use strict";function c(){}if("object"!=typeof a)throw new TypeError;c.prototype=a;var d=new c;if(a&&(d.constructor=c),arguments.length>1){if(b!==Object(b))throw new TypeError;Object.defineProperties(d,b)}return d}),function(){if(!Object.defineProperty||!function(){try{return Object.defineProperty({},"x",{}),!0}catch(a){return!1}}()){var a=Object.defineProperty;Object.defineProperty=function(b,c,d){"use strict";if(a)try{return a(b,c,d)}catch(e){}if(b!==Object(b))throw new TypeError("Object.defineProperty called on non-object");return Object.prototype.__defineGetter__&&"get"in d&&Object.prototype.__defineGetter__.call(b,c,d.get),Object.prototype.__defineSetter__&&"set"in d&&Object.prototype.__defineSetter__.call(b,c,d.set),"value"in d&&(b[c]=d.value),b}}}(),"function"!=typeof Object.defineProperties&&(Object.defineProperties=function(a,b){"use strict";if(a!==Object(a))throw new TypeError("Object.defineProperties called on non-object");var c;for(c in b)Object.prototype.hasOwnProperty.call(b,c)&&Object.defineProperty(a,c,b[c]);return a}),Object.keys||(Object.keys=function(a){if(a!==Object(a))throw new TypeError("Object.keys called on non-object");var b,c=[];for(b in a)Object.prototype.hasOwnProperty.call(a,b)&&c.push(b);return c}),Function.prototype.bind||(Function.prototype.bind=function(a){function b(){}if("function"!=typeof this)throw new TypeError("Bind must be called on a function");var c=[].slice,d=c.call(arguments,1),e=this,f=function(){return e.apply(this instanceof b?this:a||{},d.concat(c.call(arguments)))};return b.prototype=e.prototype,f.prototype=new b,f}),Array.isArray=Array.isArray||function(a){return Boolean(a&&"[object Array]"===Object.prototype.toString.call(Object(a)))},Array.prototype.indexOf||(Array.prototype.indexOf=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>0&&(d=Number(arguments[1]),isNaN(d)?d=0:0!==d&&d!==1/0&&d!==-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=c;arguments.length>1&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&d!==1/0&&d!==-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d))));for(var e=d>=0?Math.min(d,c-1):c-Math.abs(d);e>=0;e--)if(e in b&&b[e]===a)return e;return-1}),Array.prototype.every||(Array.prototype.every=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;var d,e=arguments[1];for(d=0;c>d;d++)if(d in b&&!a.call(e,b[d],d,b))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;var d,e=arguments[1];for(d=0;c>d;d++)if(d in b&&a.call(e,b[d],d,b))return!0;return!1}),Array.prototype.forEach||(Array.prototype.forEach=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;var d,e=arguments[1];for(d=0;c>d;d++)d in b&&a.call(e,b[d],d,b)}),Array.prototype.map||(Array.prototype.map=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;var d=[];d.length=c;var e,f=arguments[1];for(e=0;c>e;e++)e in b&&(d[e]=a.call(f,b[e],e,b));return d}),Array.prototype.filter||(Array.prototype.filter=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;var d,e=[],f=arguments[1];for(d=0;c>d;d++)if(d in b){var g=b[d];a.call(f,g,d,b)&&e.push(g)}return e}),Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;if(0===c&&1===arguments.length)throw new TypeError;var d,e=0;if(arguments.length>=2)d=arguments[1];else for(;;){if(e in b){d=b[e++];break}if(++e>=c)throw new TypeError}for(;c>e;)e in b&&(d=a.call(void 0,d,b[e],e,b)),e++;return d}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;if(0===c&&1===arguments.length)throw new TypeError;var d,e=c-1;if(arguments.length>=2)d=arguments[1];else for(;;){if(e in this){d=this[e--];break}if(--e<0)throw new TypeError}for(;e>=0;)e in b&&(d=a.call(void 0,d,b[e],e,b)),e--;return d}),String.prototype.trim||(String.prototype.trim=function(){return String(this).replace(/^\s+/,"").replace(/\s+$/,"")}),Date.now||(Date.now=function(){return Number(new Date)}),Date.prototype.toISOString||(Date.prototype.toISOString=function(){function a(a){return("00"+a).slice(-2)}function b(a){return("000"+a).slice(-3)}return this.getUTCFullYear()+"-"+a(this.getUTCMonth()+1)+"-"+a(this.getUTCDate())+"T"+a(this.getUTCHours())+":"+a(this.getUTCMinutes())+":"+a(this.getUTCSeconds())+"."+b(this.getUTCMilliseconds())+"Z"}),function(){var App,Binding,Controller,Filter,Observer,Route,Router,Walker,addReferences,addThis,argSeparator,bindingSort,chainLink,chainLinks,chip,continuation,currentIndex,currentReference,diff,div,emptyQuoteExpr,expression,filterAttributes,finishedChain,getBoundAttributes,getFunctionCall,ignore,initParse,invertedExpr,keyCode,keyCodes,makeEventEmitter,name,nextChain,parens,parseChain,parseExpr,parseFilters,parseFunction,parsePart,parsePath,parsePropertyChains,parseQuery,pathname,pipeExpr,prepareScope,propExpr,pullOutStrings,putInStrings,quoteExpr,referenceCount,setterExpr,sortAttributes,splitLinks,strings,swapPlaceholder,urlExp,__slice=[].slice,__hasProp={}.hasOwnProperty;chip={init:function(){return chip.rootApp||(chip.rootApp=chip.app()),chip.rootApp.init()},app:function(a){var b;return b=new App(a),a||(chip.rootApp=b),b},binding:function(a,b,c){var d;return b||c?Binding.addBinding(a,b,c):null!=(d=Binding.bindings[a])?d.handler:void 0},eventBinding:function(a){return Binding.addEventBinding(a)},keyEventBinding:function(a,b,c){return Binding.addKeyEventBinding(a,b,c)},attributeBinding:function(a){return Binding.addAttributeBinding(a)},attributeToggleBinding:function(a){return Binding.addAttributeToggleBinding(a)},filter:function(a,b,c){return"function"==typeof b||"function"==typeof c?(Filter.addFilter(a,b,c),this):b?[Filter.getFilter(a),Filter.getValueFilter(a)]:Filter.getFilter(a)}},$(document).on("ready.chip",chip.init),window.chip=chip,makeEventEmitter=function(a,b){if(a.trigger)throw new Error("Object has already become an event emitter");return b=b||$({}),a.on=b.on.bind(b),a.one=b.one.bind(b),a.off=b.off.bind(b),a.trigger=b.trigger.bind(b),b},chip.makeEventEmitter=makeEventEmitter,Router=function(){function a(){this.routes=[],this.params={},this.prefix="",makeEventEmitter(this)}return a.prototype.param=function(a,b){if("function"!=typeof b)throw new Error('param must have a callback of type "function". Got '+b+".");return(this.params[a]||(this.params[a]=[])).push(b),this},a.prototype.route=function(a,b){if("function"!=typeof b)throw new Error('route must have a callback of type "function". Got '+b+".");return"/"!==a.charAt(0)&&(a="/"+a),this.routes.push(new Route(a,b)),this},a.prototype.redirect=function(a,b){var c,d,e;return null==b&&(b=!1),"."===a.charAt(0)||a.split("//").length>1?(e=document.createElement("a"),e.href=a,a=pathname(e)+e.search):a=this.prefix+a,this.currentUrl!==a?!this.hashOnly&&this.root&&0!==a.indexOf(this.root)?void(location.href=a):(d=!1,this.on("error",c=function(a){return"notFound"===a?d=!0:void 0}),this.usePushState?(b?history.replaceState({},"",a):history.pushState({},"",a),this.currentUrl=a,this.dispatch(a)):(this.hashOnly||(a=a.replace(this.root,""),"/"!==a.charAt(0)&&(a="/"+a)),location.hash="/"===a?"":"#"+a),this.off("error",c),!d):void 0},a.prototype.listen=function(a){var b,c,d,e=this;return null==a&&(a={}),a.stop?(this._handleChange&&$(window).off("popstate hashChange",this._handleChange),this):(null!=a.root&&(this.root=a.root),null!=a.prefix&&(this.prefix=a.prefix),null!=a.hashOnly&&(this.hashOnly=a.hashOnly),this.usePushState=!this.hashOnly&&null!=(null!=(d=window.history)?d.pushState:void 0),null!=this.root||this.usePushState||(this.hashOnly=!0),this.hashOnly&&(this.prefix=""),b=null,this._handleChange=function(){var a;return a=b(),e.currentUrl!==a?(e.currentUrl=a,e.dispatch(a)):void 0},this.usePushState?(location.hash&&(c=location.pathname.replace(/\/$/,"")+location.hash.replace(/^#?\/?/,"/"),history.replaceState({},"",c)),b=function(){return location.pathname+location.search},$(window).on("popstate",this._handleChange)):(b=function(){return location.hash?location.hash.replace(/^#\/?/,"/"):location.pathname+location.search},$(window).on("hashchange",this._handleChange)),this._handleChange(),this)},a.prototype.getUrlParts=function(a){var b,c;return c=document.createElement("a"),c.href=a,b=pathname(c),0!==b.indexOf(this.prefix)?null:(b.replace(this.prefix,""),{path:b,query:c.search})},a.prototype.getRoutesMatchingPath=function(a){var b;return"/"!==a.charAt(0)&&(a=null!=(b=this.getUrlParts(a))?b.path:void 0),null==a?[]:this.routes.filter(function(b){return b.match(a)})},a.prototype.dispatch=function(a){var b,c,d,e,f,g,h=this;return(g=this.getUrlParts(a))?(d=g.path,e={url:a,path:d,query:parseQuery(g.query)},this.trigger("change",[d]),f=this.getRoutesMatchingPath(d),b=[],f.forEach(function(a){var c,d,e;b.push(function(b,c){return b.params=a.params,c()}),e=a.params;for(c in e)d=e[c],h.params[c]&&b.push.apply(b,h.params[c]);return b.push(a.callback)}),c=function(a){var d;return a?h.trigger("error",[a]):0===b.length?c("notFound"):(d=b.shift())(e,c)},0===b.length?c("notFound"):c(),this):void 0},a}(),chip.Router=Router,Route=function(){function a(a,b){this.path=a,this.callback=b,this.keys=[],this.expr=parsePath(a,this.keys)}return a.prototype.match=function(a){var b,c,d,e,f,g;if(!(d=this.expr.exec(a)))return!1;for(this.params={},b=f=0,g=d.length;g>f;b=++f)e=d[b],0!==b&&(c=this.keys[b-1],"string"==typeof e&&(e=decodeURIComponent(e)),c||(c="*"),this.params[c]=e);return!0},a}(),chip.Route=Route,parsePath=function(a,b){return a instanceof RegExp?a:(Array.isArray(a)&&(a="("+a.join("|")+")"),a=a.concat("/?").replace(/\/\(/g,"(?:/").replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?(\*)?/g,function(a,c,d,e,f,g,h){var i;return b.push(e),c=c||"",i="",g||(i+=c),i+="(?:",g&&(i+=c),i+=d||"",i+=f||(d&&"([^/.]+?)"||"([^/]+?)")+")",i+=g||"",h&&(i+="(/*)?"),i}).replace(/([\/.])/g,"\\$1").replace(/\*/g,"(.*)"),new RegExp("^"+a+"$","i"))},parseQuery=function(a){var b;return b={},""===a?b:(a.replace(/^\?/,"").split("&").forEach(function(a){var c,d,e;return e=a.split("="),c=e[0],d=e[1],b[decodeURIComponent(c)]=decodeURIComponent(d)}),b)},pathname=function(a){var b;return b=a.pathname,"/"!==b.charAt(0)&&(b="/"+b),b},Observer=function(){function a(a,b,c){this.getter=a,this.callback=b,this.oldValue=c}return a.prototype.skipNextSync=function(){return this.skip=!0},a.prototype.sync=function(){var a,b;if(b=this.getter(),this.skip)delete this.skip;else{if(a=diff.values(b,this.oldValue),!a)return;Array.isArray(a)?this.callback(b,this.oldValue,a):this.callback(b,this.oldValue)}return this.oldValue=diff.clone(b)},a.prototype.close=function(){return a.remove(this)},a.observers=[],a.callbacks=[],a.listeners=[],a.add=function(b,c,d){var e,f;return"function"==typeof c&&(d=c,c=!1),f=b(),e=new a(b,d,diff.clone(f)),this.observers.push(e),c||d(f),e},a.remove=function(a){var b;return b=this.observers.indexOf(a),-1!==b?(this.observers.splice(b,1),!0):!1},a.syncing=!1,a.rerun=!1,a.cycles=0,a.max=10,a.timeout=null,a.sync=function(a){var b,c,d,e;if("function"==typeof a&&this.afterSync(a),this.syncing)return this.rerun=!0,!1;for(this.syncing=!0,this.rerun=!0,this.cycles=0;this.rerun;){if(++this.cycles===this.max)throw"Infinite observer syncing, an observer is calling Observer.sync() too many times";this.rerun=!1;for(var f=0;fc;c++)(b=e[c])();return this.syncing=!1,this.cycles=0,!0},a.syncLater=function(a){var b=this;return this.timeout?!1:(this.timeout=setTimeout(function(){return b.timeout=null,b.sync(a)}),!0)},a.afterSync=function(a){if("function"!=typeof a)throw new TypeError("callback must be a function");return this.callbacks.push(a)},a.onSync=function(a){if("function"!=typeof a)throw new TypeError("listener must be a function");return this.listeners.push(a)},a.removeOnSync=function(a){var b;if("function"!=typeof a)throw new TypeError("listener must be a function");return b=this.listeners.indexOf(a),-1!==b?this.listeners.splice(b,1).pop():void 0},a}(),chip.Observer=Observer,Controller=function(){function a(){this._observers=[],this._children=[],this._closed=!1}return a.prototype.watch=function(a,b,c){var d,e,f,g,h,i=this;return Array.isArray(a)?("function"==typeof b&&(c=b,b=!1),h=c,d=!1,c=function(){var a;if(!d)return d=!0,setTimeout(function(){return d=!1}),a=g.map(function(a){return a.getter()}),h.apply(null,a)},g=a.map(function(a){return i.watch(a,!0,c)}),b||c(),g):(e="function"==typeof a?a:expression.bind(a,this),f=Observer.add(e,b,c),f.expr=a,this._observers.push(f),f)},a.prototype.unwatch=function(a,b){var c=this;return this._observers.some(function(d,e){return d.expr===a&&d.callback===b?(d.close(),c._observers.splice(e,1),!0):!1})},a.prototype.eval=function(a,b){var c,d;return b&&(c={args:Object.keys(b)},d=c.args.map(function(a){return b[a]})),expression.get(a,c).apply(this,d)},a.prototype.evalSetter=function(a,b){return this.passthrough()!==this?this.passthrough().evalSetter(a,b):(a=a.replace(/(\s*\||$)/," = value$1"),expression.get(a,{args:["value"]}).call(this,b))},a.prototype.getBoundEval=function(){var a,b;return a=arguments[0],b=2<=arguments.length?__slice.call(arguments,1):[],expression.bind(a,this,{args:b})},a.prototype.redirect=function(a,b){return null==b&&(b=!1),this.app.redirect(a,b),this},a.prototype.cloneValue=function(a){return diff.clone(this[a])},a.prototype.closeController=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m;if(!this._closed){for(this._closed=!0,j=this._children,d=0,g=j.length;g>d;d++)a=j[d],a.parent=null,a.closeController();if((null!=(k=this.parent)?k._children:void 0)&&this.parent._children.remove(this),this.hasOwnProperty("beforeClose")&&this.beforeClose(),this._syncListeners){for(l=this._syncListeners,e=0,h=l.length;h>e;e++)b=l[e],Observer.removeOnSync(b);delete this._syncListeners}for(m=this._observers,f=0,i=m.length;i>f;f++)c=m[f],c.close();this._observers.length=0,this.hasOwnProperty("onClose")&&this.onClose()}},a.prototype.sync=function(a){return Observer.sync(a),this},a.prototype.syncLater=function(a){return Observer.syncLater(a),this},a.prototype.afterSync=function(a){return Observer.afterSync(a),this},a.prototype.onSync=function(a){return this._syncListeners||(this._syncListeners=[]),this._syncListeners.push(a),Observer.onSync(a),this},a.prototype.removeOnSync=function(a){var b;return b=this._syncListeners.indexOf(a),-1!==b&&this._syncListeners.splice(b,1),Observer.removeOnSync(a),this},a.prototype.passthrough=function(a){return arguments.length?this._passthrough=a:this.hasOwnProperty("_passthrough")?this._passthrough:this},a}(),$.fn.controller=function(a){var b,c;for(c=this;c.length;){if(b=c.data("controller"))return a?b.passthrough():b;c=c.parent()}return null},$.widget||($.cleanData=function(a){return function(b){var c,d,e,f;for(e=0,f=b.length;f>e;e++){d=b[e];try{$(d).triggerHandler("remove")}catch(g){c=g}}return a(b)}}($.cleanData)),chip.Controller=Controller,expression={cache:{},globals:["true","false","window","this"]},expression.isInverted=function(a){return a.match(invertedExpr)&&!0},expression.revert=function(a){return a='"'+a.replace(invertedExpr,function(a,b){return'" + ('+b+') + "'})+'"',a.replace(/^"" \+ | \+ ""$/g,"")},expression.get=function(a,b){var c,d,e,f,g;if(null==b&&(b={}),c=b.args||[],e=a+"|"+c.join(","),g=expression.cache[e])return g;d=expression.parse(a,b);try{g=expression.cache[e]=Function.apply(null,__slice.call(c).concat([d]))}catch(h){throw f=h,console&&console.error("Bad expression:\n`"+a+"`\nCompiled expression:\n"+d),new Error(f.message)}return g},expression.bind=function(a,b,c){return expression.get(a,c).bind(b)},invertedExpr=/{{(.*)}}/g,quoteExpr=/(['"\/])(\\\1|[^\1])*?\1/g,emptyQuoteExpr=/(['"\/])\1/g,pipeExpr=/\|(\|)?/g,argSeparator=/\s*:\s*/g,propExpr=/((\{|,|\.)?\s*)([a-z$_\$](?:[a-z_\$0-9\.-]|\[['"\d]+\])*)(\s*(:|\(|\[)?)/gi,chainLinks=/\.|\[/g,chainLink=/\.|\[|\(/,setterExpr=/\s=\s/,ignore=null,strings=[],referenceCount=0,currentReference=0,currentIndex=0,finishedChain=!1,continuation=!1,expression.parse=function(a,b){return initParse(a,b),a=pullOutStrings(a),a=parseFilters(a),a=parseExpr(a),a="return "+a,a=putInStrings(a),a=addReferences(a)},initParse=function(a,b){return referenceCount=currentReference=0,ignore=expression.globals.concat((null!=b?b.globals:void 0)||[],(null!=b?b.args:void 0)||[]),strings.length=0},pullOutStrings=function(a){var b;return b=a.replace(quoteExpr,function(a,b){return strings.push(a),b+b})},putInStrings=function(a){return a=a.replace(emptyQuoteExpr,function(){return strings.shift()})},addReferences=function(a){var b,c,d;if(referenceCount){for(c=[],b=d=1;referenceCount>=1?referenceCount>=d:d>=referenceCount;b=referenceCount>=1?++d:--d)c.push("_ref"+b);a="var "+c.join(", ")+";\n"+a}return a},parseFilters=function(a){var b,c,d,e;return a=a.replace(pipeExpr,function(a,b){return b?a:"@@@"}),b=a.split(/\s*@@@\s*/),a=b.shift(),b.length?(setterExpr.test(a)?(e=a.split(setterExpr),c=e[0],d=e[1],c+=" = "):(c="",d=a),b.forEach(function(a){var b,e;return b=a.split(argSeparator),e=b.shift(),b.unshift(d),c&&b.push(!0),d="_filters."+e+".call(this, "+b.join(", ")+")"}),c+d):a},parseExpr=function(a){var b,c,d;return setterExpr.test(a)?(d=a.split(" = "),b=d[0],c=d[1],b=parsePropertyChains(b).replace(/^\(|\)$/g,"")+" = ",c=parsePropertyChains(c),b+c):parsePropertyChains(a)},parsePropertyChains=function(a){var b,c,d;for(b="",d=[currentIndex,propExpr.lastIndex],currentIndex=0,propExpr.lastIndex=0;(c=nextChain(a))!==!1;)b+=c;return propExpr.lastIndex=d.pop(),currentIndex=d.pop(),b},nextChain=function(a){var b,c,d,e,f,g,h,i;return finishedChain?finishedChain=!1:(c=propExpr.exec(a))?(i=c,c=i[0],f=i[1],d=i[2],g=i[3],e=i[4],b=i[5],h=a.slice(currentIndex,propExpr.lastIndex-c.length),currentIndex=propExpr.lastIndex,d&&":"===b?h+c:h+parseChain(f,g,e,b,a)):(finishedChain=!0,a.slice(currentIndex))},splitLinks=function(a){var b,c,d;for(b=0,d=[];c=chainLinks.exec(a);)1!==chainLinks.lastIndex&&(d.push(a.slice(b,chainLinks.lastIndex-1)),b=chainLinks.lastIndex-1);return d.push(a.slice(b)),d},addThis=function(a){return-1===ignore.indexOf(a.split(chainLink).shift())?"this."+a:a},parseChain=function(a,b,c,d,e){var f,g,h;return continuation="."===a,continuation&&(b="."+b,a=""),g=splitLinks(b),h="",1!==g.length||continuation||d?(continuation||(h="("),g.forEach(function(a,b){b!==g.length-1?h+=parsePart(a,b):parens[d]?(c=c.replace(d,""),h+=parseFunction(a,b,e)):h+="_ref"+currentReference+a+")"})):(f=g[0],h=addThis(f)),a+h+c},parens={"(":")","[":"]"},parseFunction=function(a,b,c){var d,e,f;return d=getFunctionCall(c),a+=d.slice(0,1)+"~~insideParens~~"+d.slice(-1),e=d.slice(1,-1),"."===c.charAt(propExpr.lastIndex)?a=parsePart(a,b):0===b?(a=parsePart(a,b),a+="_ref"+currentReference+")"):a="_ref"+currentReference+a+")",f=currentReference,a=a.replace("~~insideParens~~",parsePropertyChains(e)),currentReference=f,a},getFunctionCall=function(a){var b,c,d,e,f;for(f=propExpr.lastIndex,d=a.charAt(f-1),b=parens[d],c=f-1,e=1;c++1)return this.templates[a]=b,this;if(!this.templates.hasOwnProperty(a))throw'Template "'+a+'" does not exist';return $(this.templates[a].trim())},a.prototype.translate=function(a,b){var c,d,e;if(!b){e=this.translations;for(c in e)d=e[c],delete this.translations[c]}for(c in a)d=a[c],this.translations[c]=d;return this.trigger("translationChange",[this.translations])},a.prototype.controller=function(a,b){return arguments.length>1?(this.controllers[a]=b,this):this.controllers[a]||window[a+"Controller"]},a.prototype.createController=function(a){var b,c,d,e,f,g,h,i=this;if(null==a&&(a={}),a.parent instanceof Controller?(b=function(){return Controller.call(this)},a.parent&&(b.prototype=a.parent),c=new b,c.parent=a.parent,a.parent._children.push(c),a.passthrough&&c.passthrough(a.parent.passthrough())):(c=new Controller,makeEventEmitter(c,this._emitter),c.app=this,c.translations=this.translations,c._filters=Filter.filters),a.properties){h=a.properties;for(d in h)__hasProp.call(h,d)&&(f=h[d],c[d]=f)}return c.child=function(a){return null==a&&(a={}),a.parent=c,i.createController(a)},c.template=function(a){return i.template(a)},a.element&&((e=a.element.data("controller"))&&(a.element.off("remove.controller"),e.closeController()),a.element.one("remove.controller",function(){return c.closeController()}),c.element=a.element,a.element.data("controller",c)),a.name&&"function"==typeof(g=this.controller(a.name))&&g(c),a.element&&a.element.bindTo(c),c},a.prototype.param=function(a,b){var c,d=this;return c=function(a,c){return d.rootController.params=a.params,d.rootController.query=a.query,b(d.rootController,c)},this.router.param(a,c),this},a.prototype.route=function(a,b,c){var d,e=this;return d=function(a,b,c,f,g){var h,i;if("function"==typeof b&&b.toString().match(/\(route\)/)&&(c=b,b=null),b||(b=a.replace(/^\//,"")),"string"==typeof b){if(i=b,h=function(a,b){var d,j,k,l,m,n;if(g&&!a.calledBefore)return a.calledBefore=!0,void g(a,h);for(e.rootController.params=a.params,e.rootController.query=a.query,l=[],j=n=0;f>=0?f>=n:n>=f;j=f>=0?++n:--n)l.push("[bind-route]");return d=e.rootElement.find(l.join(" ")+":first"),k=e.rootController.route,null==a.isSamePath&&(a.isSamePath=a.path===e.rootController.path),d.length?(m=function(){var f,g;return d.attr("bind-route",i),e.rootController.route=i,e.rootController.path=a.path,e.trigger("routeChange",[i]),a.isSamePath?d.animateIn():(d.willAnimate()&&(g=$("").insertBefore(d),d.detach(),setTimeout(function(){return g.after(d).remove(),d.animateIn()})),d.html(e.template(i)),f=d.parent().controller()||e.rootController,e.createController({element:d,parent:f,name:i})),e.rootController.sync(),window.scrollTo(0,0),c?b(a,b):void 0},k?d.animateOut(a.isSamePath,m):m()):void 0},"function"==typeof c)return void c(function(b,c,e){return"/"===b&&(b=""),d(a+b,c,e,f+1,h)})}else{if("function"!=typeof b)throw new Error("route handler must be a string path or a function");h=function(a,c){return e.rootController.params=a.params,e.rootController.query=a.query,b(e.rootController,c)}}return e.router.route(a,h)},d(a,b,c,0),this},a.prototype.redirect=function(a,b){return null==b&&(b=!1),this.router.redirect(a,b)},a.prototype.hasMatchingRoutes=function(a){return this.router.getRoutesMatchingPath(a).length>0},a.prototype.mount=function(){},a.prototype.listen=function(a){var b=this;return null==a&&(a={}),$(function(){var c;return a.stop?(b._routeHandler&&b.router.off("change",b._routeHandler),b._clickHandler&&b.rootElement.off("click","a[href]",b._clickHandler),b.router.listen(a)):(c=b,b._routeHandler=function(a,c){return b.trigger("urlChange",[c])},b._clickHandler=function(b){var d,e;if(!(b.isDefaultPrevented()||(d=this.host.replace(/:80$|:443$/,""),e=$(this).attr("href").replace(/^#/,""),d&&d!==location.host||b.metaKey||b.ctrlKey||$(b.target).attr("target")||a.dontHandle404s&&!c.hasMatchingRoutes(e)||(b.preventDefault(),this.href===location.href+"#"))))return $(this).attr("disabled")?void 0:c.redirect(e)},b.router.on("change",b._routeHandler),b.rootElement.on("click","a[href]",b._clickHandler),b.router.listen(a))}),this},a}(),chip.App=App,Binding=function(){function a(a,b){this.name=a,this.expr=b}return a.bindings=[],a.addBinding=function(a,b,c){var d;return"function"==typeof b?(c=b,b={}):b||(b={}),d={name:b.name||a,priority:b.priority||0,keepAttribute:b.keepAttribute,handler:c},this.bindings[a]=d,this.bindings.push(d),this.bindings.sort(bindingSort),d},a.removeBinding=function(a){var b;return(b=this.bindings[a])?(delete this.bindings[a],this.bindings.splice(this.bindings.indexOf(b),1)):void 0},a.addEventBinding=function(a,b){var c;return c=a.split("-").slice(1).join("-"),this.addBinding(a,b,function(a,b,d){var e;return e=b.value,a.on(c,function(b){return b.preventDefault(),a.attr("disabled")?void 0:(d.thisElement=a,d.eval(e),delete d.thisElement)})})},a.addKeyEventBinding=function(a,b,c,d){return this.addBinding(a,d,function(a,d,e){var f;return f=d.value,a.on("keydown",function(d){return null!=c&&d.ctrlKey!==c&&d.metaKey!==c||d.keyCode!==b?void 0:(d.preventDefault(),a.attr("disabled")?void 0:(e.thisElement=a,e.eval(f),delete e.thisElement))})})},a.addAttributeBinding=function(a,b){var c;return c=a.split("-").slice(1).join("-"),this.addBinding(a,b,function(a,b,d){var e;return e=b.value,d.watch(e,function(b){return null!=b?(a.attr(c,b),a.trigger(c+"Changed")):a.removeAttr(c)})})},a.addAttributeToggleBinding=function(a,b){var c;return c=a.split("-").slice(1).join("-"),this.addBinding(a,b,function(a,b,d){var e;return e=b.value,d.watch(e,function(b){return a.prop(c,b&&!0||!1)})})},a.process=function(a,b){var c,d,e,f,g,h,i,j,k;if(!(b instanceof Controller))throw new Error("A Controller is required to bind a jQuery element.");for(j=Array.prototype.slice,k=new Walker(a.get(0)),h=[],k.onElementDone=function(a){return h.length&&h[h.length-1].get(0)===a?h.pop().trigger("processed"):void 0};f=k.next();)for(f!==k.root&&(a=$(f)),g=f.parentNode,d=j.call(f.attributes).map(getBoundAttributes).filter(filterAttributes).sort(sortAttributes),d.length&&h.push(a);d.length;){if(c=d.shift(),e=c.binding,e.keepAttribute||a.removeAttr(c.name),"-*"===e.name.slice(-2)&&(c.match=c.name.replace(e.name.slice(0,-1),""),c.camel=c.match.replace(/[-_]+(\w)/g,function(a,b){return b.toUpperCase()})),i=e.handler(a,c,b),f.parentNode!==g){h.pop();break}if(i===!1){k.skip();break}}return a},a}(),getBoundAttributes=function(a){var b,c;if(b=Binding.bindings[a.name],!b)for(c=a.name.split("-");c.length>1&&(c.pop(),!(b=Binding.bindings[c.join("-")+"-*"])););return b||expression.isInverted(a.value)&&(b=Binding.bindings["attr-*"]),b?{binding:b,name:a.name,value:a.value}:void 0},filterAttributes=function(a){return a},sortAttributes=function(a,b){return b.binding.priority-a.binding.priority},bindingSort=function(a,b){return b.priority-a.priority},jQuery.fn.bindTo=function(a){return 0!==this.length?Binding.process(this,a):void 0},chip.Binding=Binding,Walker=function(){function a(a){this.root=a,this.current=null}return a.prototype.onElementDone=function(){},a.prototype.next=function(){return null===this.current?this.current=this.root:(this.current!==this.root&&null===this.current.parentNode&&(this.current=this.placeholder),this.current=this.traverse(this.current)),this.current?this.placeholder={parentNode:this.current.parentNode,nextElementSibling:this.current.nextElementSibling}:(this.placeholder=null,this.onElementDone(this.root)),this.current},a.prototype.traverse=function(a){var b,c;if(a.nodeType&&(b=a.firstElementChild))return b;for(;null!==a;){if(a.nodeType&&this.onElementDone(a),a===this.root)return null;if(c=a.nextElementSibling)return c;a=a.parentNode}return a},a.prototype.skip=function(){return this.current=this.placeholder},a}(),Filter=function(){function a(a,b){this.name=a,this.filter=b}return a.filters={},a.addFilter=function(a,b){return null!=b&&(this.filters[a]=b),this},a.getFilter=function(a){return this.filters[a]},a}(),chip.binding("bind-debug",{priority:200},function(a,b,c){var d;return d=b.value,c.watch(d,function(a){return"undefined"!=typeof console&&null!==console?console.info("Debug:",d,"=",a):void 0})}),chip.binding("bind-route",{keepAttribute:!0},function(){}),chip.binding("bind-text",function(a,b,c){var d;return d=b.value,c.watch(d,function(b){return a.text(null!=b?b:"")})}),chip.binding("bind-html",function(a,b,c){var d;return d=b.value,c.watch(d,function(b){return a.html(null!=b?b:"")})}),chip.binding("bind-trim",function(a){var b,c,d;for(c=a.get(0).firstChild,d=[];c;)b=c.nextSibling,c.nodeType===Node.TEXT_NODE&&(c.nodeValue.match(/^\s*$/)?c.parentNode.removeChild(c):c.textContent=c.textContent.trim()),d.push(c=b);return d}),chip.binding("bind-translate",function(a,b,c){var d,e,f,g,h,i,j,k;for(f=a.get(0).childNodes,i="",g=[],d=j=0,k=f.length;k>j;d=++j)e=f[d],3===e.nodeType?(""!==e.nodeValue.trim()||0!==d&&d!==f.length-1)&&(i+=e.nodeValue):1===e.nodeType&&(i+="%{"+g.length+"}",g.push(e));return h=function(){var b,d,e,h,j;for(j=c.translations[i]||i,b=/%{(\d+)}/g,f=[],d=0;e=b.exec(j);)h=b.lastIndex-e[0].length,d!==h&&f.push(document.createTextNode(j.slice(d,h))),f.push(g[e[1]]),d=b.lastIndex;return d!==j.length&&f.push(document.createTextNode(j.slice(d))),a.html(f)},a.on("remove",function(){return c.off("translationChange",h)}),c.on("translationChange",h),c.translations[i]?h():void 0}),chip.binding("bind-class",function(a,b,c){var d,e;return d=b.value,e=(a.attr("class")||"").split(/\s+/),""===e[0]&&e.pop(),c.watch(d,function(b){var c,d,f;if(Array.isArray(b)&&(b=b.join(" ")),"string"==typeof b)return a.attr("class",b.split(/\s+/).concat(e).join(" "));if(b&&"object"==typeof b){f=[];for(c in b)__hasProp.call(b,c)&&(d=b[c],f.push(d?a.addClass(c):a.removeClass(c)));return f}})}),chip.binding("bind-attr",function(a,b,c){var d;return d=b.value,c.watch(d,function(b,c,d){var e,f,g;if(d)return d.forEach(function(c){return"deleted"===c.type||null==b[c.name]?(a.removeAttr(c.name),a.trigger(c.name+"Changed")):(a.attr(c.name,b[c.name]),a.trigger(c.name+"Changed"))});if(b&&"object"==typeof b){g=[]; +for(e in b)__hasProp.call(b,e)&&(f=b[e],null!=f?(a.attr(e,f),g.push(a.trigger(e+"Changed"))):(a.removeAttr(e),g.push(a.trigger(e+"Changed"))));return g}})}),chip.binding("bind-active",function(a,b,c){var d,e,f;return d=b.value,d?c.watch(d,function(b){return b?a.addClass("active"):a.removeClass("active")}):(f=function(){return e.length&&e.get(0).href===location.href?a.addClass("active"):a.removeClass("active")},e=a.filter("a").add(a.find("a")).first(),e.on("hrefChanged",f),c.on("urlChange",f),a.on("remove",function(){return c.off("urlChange",f)}),f())}),chip.binding("bind-active-section",function(a,b,c){var d,e;return e=function(){return d.length&&0===location.href.indexOf(d.get(0).href)?a.addClass("active"):a.removeClass("active")},d=a.filter("a").add(a.find("a")).first(),d.on("hrefChanged",e),c.on("urlChange",e),a.on("remove",function(){return c.off("urlChange",e)}),e()}),chip.binding("bind-change-action",function(a,b,c){var d,e,f;return e=b.value,f=e.split(/\s*!\s*/),e=f[0],d=f[1],c.watch(e,function(){return c.thisElement=a,c.eval(d),delete c.thisElement})}),chip.binding("bind-show",function(a,b,c){var d;return d=b.value,c.watch(d,function(b){return b?a.show():a.hide()})}),chip.binding("bind-hide",function(a,b,c){var d;return d=b.value,c.watch(d,function(b){return b?a.hide():a.show()})}),chip.binding("bind-value",function(a,b,c){var d,e,f,g,h,i,j,k;return e=b.value,k=e,f=a.attr("bind-value-field"),a.removeAttr("bind-value-field"),a.is("select")&&(i=f?c.eval(f):null,chip.lastSelectValueField=i),a.is("option")&&(f||chip.lastSelectValueField)&&(i=f?c.eval(f):chip.lastSelectValueField,k+="."+i),g="checkbox"===a.attr("type")?function(){return a.prop("checked")}:"file"===a.attr("type")?function(){var b;return null!=(b=a.get(0).files)?b[0]:void 0}:a.is(":not(input,select,textarea,option)")?function(){return a.find("input:radio:checked").val()}:i&&a.is("select")?function(b){return b?$(a.get(0).options[a.get(0).selectedIndex]).data("value"):a.val()}:function(){return a.val()},j="checkbox"===a.attr("type")?function(b){return a.prop("checked",b)}:"file"===a.attr("type")?function(){}:a.is(":not(input,select,textarea,option)")?function(b){return a.find("input:radio:checked").prop("checked",!1),a.find('input:radio[value="'+b+'"]').prop("checked",!0)}:function(b){var c;return c=i&&(null!=b?b[i]:void 0)||b,null!=c&&(c=""+c),a.val(c),i?a.data("value",b):void 0},h=c.watch(k,function(a){return g()!==""+a?j(c.eval(e)):void 0}),a.is("option")?void 0:(a.is("select")?a.one("processed",function(){return j(c.eval(e)),a.is("[readonly]")?void 0:c.evalSetter(e,g(!0))}):a.is("[readonly]")||c.evalSetter(e,g()),d=a.attr("bind-value-events")||"change",a.removeAttr("bind-value-events"),a.is(":text")&&a.on("keydown",function(b){return 13===b.keyCode?a.trigger("change"):void 0}),a.on(d,function(){return g()===h.oldValue||a.is("[readonly]")?void 0:(c.evalSetter(e,g(!0)),h.skipNextSync(),c.sync())}))}),chip.binding("on-*",function(a,b,c){var d,e;return d=b.match,e=b.value,a.on(d,function(b){return b.originalEvent&&b.preventDefault(),a.attr("disabled")?void 0:c.eval(e,{event:b,element:a})})}),keyCodes={enter:13,esc:27};for(name in keyCodes)__hasProp.call(keyCodes,name)&&(keyCode=keyCodes[name],chip.keyEventBinding("on-"+name,keyCode));chip.keyEventBinding("on-ctrl-enter",keyCodes.enter,!0),chip.binding("attr-*",function(a,b,c){var d,e;return b.name!==b.match?(d=b.match,e=b.value):(d=b.name,e=expression.revert(b.value)),c.watch(e,function(b){return null!=b?(a.attr(d,b),a.trigger(d+"Changed")):a.removeAttr(d)})}),["attr-checked","attr-disabled","attr-multiple","attr-readonly","attr-selected"].forEach(function(a){return chip.attributeToggleBinding(a)}),$.fn.animateIn=function(a){var b,c=this;return this.parent().length&&(b=$(""),this.before(b),this.detach()),this.addClass("animate-in"),b&&(b.after(this),b.remove()),setTimeout(function(){return c.removeClass("animate-in"),a?c.willAnimate()?c.one("webkittransitionend transitionend webkitanimationend animationend",function(){return a()}):a():void 0}),this},$.fn.animateOut=function(a,b){var c,d,e,f=this;return"function"==typeof a&&(b=a,a=!1),a||this.triggerHandler("remove"),d=this.cssDuration("transition")||this.cssDuration("animation"),d?(this.addClass("animate-out"),c=function(){return clearTimeout(e),f.off("webkittransitionend transitionend webkitanimationend animationend",c),f.removeClass("animate-out"),b?b():f.remove()},this.one("webkittransitionend transitionend webkitanimationend animationend",c),e=setTimeout(c,d+100)):b?b():a||this.remove(),this},$.fn.cssDuration=function(a){var b,c;return c=this.css(a+"-duration")||this.css("-webkit-"+a+"-duration"),b=parseFloat(c),/\ds/.test(c)&&(b*=1e3),b||0},$.fn.willAnimate=function(){return this.cssDuration("transition")&&!0},chip.binding.prepareScope=prepareScope=function(a,b,c){var d,e,f,g;return g=$(a),f=$("'),c.element[0]===a[0]?(e=document.createDocumentFragment(),e.appendChild(f[0]),a[0]=e):a.replaceWith(f),d=a.attr("bind-controller"),a.removeAttr("bind-controller"),{template:g,placeholder:f,controllerName:d}},chip.binding.swapPlaceholder=swapPlaceholder=function(a,b){return a[0].parentNode.replaceChild(b[0],a[0])},chip.binding("bind-if",{priority:50},function(a,b,c){var d,e,f,g,h;return e=b.value,h=prepareScope(a,b,c),g=h.template,f=h.placeholder,d=h.controllerName,c.watch(e,function(b){if(b){if(f[0].parentNode)return a=g.clone().animateIn(),c.child({element:a,name:d,passthrough:!0}),swapPlaceholder(f,a)}else if(!f[0].parentNode)return a.before(f),a.animateOut()}),!1}),chip.binding("bind-unless",{priority:50},function(a,b,c){var d,e,f,g,h;return e=b.value,h=prepareScope(a,b,c),g=h.template,f=h.placeholder,d=h.controllerName,c.watch(e,function(b){if(b){if(!f[0].parentNode)return a.before(f),a.animateOut()}else if(f[0].parentNode)return a=g.clone().animateIn(),c.child({element:a,name:d,passthrough:!0}),swapPlaceholder(f,a)}),!1}),chip.binding("bind-each",{priority:100},function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q;if(i=g=b.value,o=prepareScope(a,b,c),m=o.template,j=o.placeholder,d=o.controllerName,p=g.split(/\s+in\s+/),h=p[0],g=p[1],q=h.split(/\s*,\s*/),h=q[0],k=q[1],!h||!g)throw'Invalid bind-each="'+i+'". Requires the format "item in list" or "key, propery in object".';return f=$(),l={},n=null,e=function(a,b){var e;return e=m.clone(),Array.isArray(n)?(l[h]=a,l.index=b):(k&&(l[k]=a),l[h]=n[a]),c.child({element:e,name:d,properties:l}),e.get(0)},c.watch(g,function(a,b,c){var d;if(n=a,c){if(Array.isArray(n)||n&&"object"==typeof n)return Array.isArray(n)||(c=diff.arrays(Object.keys(n),Object.keys(b))),d=0,c.forEach(function(a){return d+=a.addedCount}),c.forEach(function(a){var b,c,g,h,i;for(c=[a.index,a.removed.length],h=[],b=a.index;b\nbody {\n background: none transparent;\n width: auto;\n min-width: 0;\n margin: 0;\n padding: 0;\n}\n"),e.html(c.template(b)),d=c.child({element:e,name:b,properties:f}),a.height(e.outerHeight()),a.data("body",e)};try{return g(a.contents().find("body"))}catch(j){return e=j,a.one("load",function(){return g(a.contents().find("body"))}),a.attr("src","about:blank")}}}),!1}),chip.binding("local-*",{priority:20},function(a,b,c){var d,e;return d=b.value,e=b.camel,d?(c.watch(d,function(a){return c[e]=a}),")"!==d.slice(-1)?c.watch(e,!0,function(a){return c.parent.passthrough().evalSetter(d,a)}):void 0):c[e]=!0}),chip.binding("bind-content",{priority:40},function(a,b,c){return c._partialContent?a.html(c._partialContent):void 0}),chip.binding("bind-controller",{priority:30},function(a,b,c){var d;return d=b.value,c.child({element:a,name:d}),!1}),chip.filter("filter",function(a,b){return Array.isArray(a)?b?a.filter(b,this):a:[]}),chip.filter("map",function(a,b){return null!=a&&b?Array.isArray(a)?a.map(b,this):b.call(this,a):a}),chip.filter("reduce",function(a,b,c){return null!=a&&b?Array.isArray(a)?3===arguments.length?a.reduce(b,c):a.reduce(b):3===arguments.length?b(c,a):void 0:a}),chip.filter("slice",function(a,b,c){return Array.isArray(a)?a.slice(b,c):a}),chip.filter("date",function(a){return a?(a instanceof Date||(a=new Date(a)),isNaN(a.getTime())?"":a.toLocaleString()):""}),chip.filter("log",function(a,b){return null==b&&(b="Log"),console.log(b+":",a),a}),chip.filter("limit",function(a,b){return a&&"function"==typeof a.slice?0>b?a.slice(b):a.slice(0,b):a}),chip.filter("sort",function(a,b){var c,d,e;return b?("string"==typeof b&&(e=b.split(":"),d=e[0],c=e[1],c="desc"===c?-1:1,b=function(a,b){return a[d]>b[d]?c:a[d]")),div.text(a||"").text()}),chip.filter("p",function(a){var b,c;return div||(div=$("
")),c=(a||"").split(/\r?\n/),b=c.map(function(a){return div.text(a).text()||"
"}),"

"+b.join("

")+"

"}),chip.filter("br",function(a){var b,c;return div||(div=$("
")),c=(a||"").split(/\r?\n/),b=c.map(function(a){return div.text(a).text()}),b.join("
")}),chip.filter("newline",function(a){var b,c;return div||(div=$("
")),c=(a||"").split(/\r?\n\s*\r?\n/),b=c.map(function(a){var c;return c=a.split(/\r?\n/),b=c.map(function(a){return div.text(a).text()}),b.join("
")}),"

"+b.join("

")+"

"}),urlExp=/(^|\s|\()((?:https?|ftp):\/\/[\-A-Z0-9+\u0026@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~(_|])/gi,chip.filter("autolink",function(a,b){return b=b?' target="_blank"':"",(""+a).replace(/<[^>]+>|[^<]+/g,function(a){return"<"===a.charAt(0)?a:a.replace(urlExp,'$1$2")})}),chip.filter("int",function(a){return a=parseInt(a),isNaN(a)?null:a}),chip.filter("float",function(a){return a=parseFloat(a),isNaN(a)?null:a}),chip.filter("bool",function(a){return a&&"0"!==a&&"false"!==a}),diff={},function(){var a,b,c,d,e,f,g,h,i,j;return diff.clone=function(a,b){var c,d,e;if(Array.isArray(a))return b?a.map(function(a){return diff.clone(a,b)}):a.slice();if(a&&"object"==typeof a){if(a.valueOf()!==a)return new a.constructor(a.valueOf());c={};for(d in a)e=a[d],b&&(e=diff.clone(e,b)),c[d]=e;return c}return a},diff.values=function(a,b){var c,d,e,f;return Array.isArray(a)&&Array.isArray(b)?(e=diff.arrays(a,b),e.length?e:!1):a&&b&&"object"==typeof a&&"object"==typeof b?(f=a.valueOf(),d=b.valueOf(),"object"!=typeof f&&"object"!=typeof d?f!==d:(c=diff.objects(a,b),c.length?c:!1)):diff.basic(a,b)},diff.basic=function(a,b){var c,d;return a&&b&&"object"==typeof a&&"object"==typeof b&&(d=a.valueOf(),c=b.valueOf(),"object"!=typeof d&&"object"!=typeof c)?diff.basic(d,c):"number"==typeof a&&"number"==typeof b&&isNaN(a)&&isNaN(b)?!1:a!==b},diff.objects=function(a,b){var c,d,e,g;c=[];for(e in b)d=b[e],g=a[e],(void 0===g||diff.basic(g,d))&&(e in a?diff.basic(g,d)&&c.push(f(a,"updated",e,d)):c.push(f(a,"deleted",e,d)));for(e in a)g=a[e],e in b||c.push(f(a,"new",e));return Array.isArray(a)&&a.length!==b.length&&c.push(f(a,"updated","length",b.length)),c},f=function(a,b,c,d){return{object:a,type:b,name:c,oldValue:d}},c=0,d=1,a=2,b=3,diff.arrays=function(f,k){var l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A;if(m=0,l=f.length,s=0,q=k.length,p=Math.min(l,q),v=h(f,k,p),y=i(f,k,p-v),m+=v,s+=v,l-=y,q-=y,l-m===0&&q-s===0)return[];if(m===l)return[g(m,k.slice(s,q),0)];if(s===q)return[g(m,[],l-m)];for(n=e(f,m,l,k,s,q),u=j(n),w=void 0,x=[],o=m,r=s,z=0,A=u.length;A>z;z++)t=u[z],t===c?(w&&(x.push(w),w=void 0),o++,r++):t===d?(w||(w=g(o,[],0)),w.addedCount++,o++,w.removed.push(k[r]),r++):t===a?(w||(w=g(o,[],0)),w.addedCount++,o++):t===b&&(w||(w=g(o,[],0)),w.removed.push(k[r]),r++);return w&&x.push(w),x},h=function(a,b,c){var d,e;for(d=e=0;c>=0?c>e:e>c;d=c>=0?++e:--e)if(diff.basic(a[d],b[d]))return d;return c},i=function(a,b,c){var d,e,f;for(e=a.length,f=b.length,d=0;c>d&&!diff.basic(a[--e],b[--f]);)d++;return d},g=function(a,b,c){return{index:a,removed:b,addedCount:c}},j=function(e){var f,g,h,i,j,k,l,m;for(h=e.length-1,i=e[0].length-1,f=e[h][i],g=[];h>0||i>0;)0!==h?0!==i?(l=e[h-1][i-1],m=e[h-1][i],k=e[h][i-1],j=k>m?l>m?m:l:l>k?k:l,j===l?(l===f?g.push(c):(g.push(d),f=l),h--,i--):j===m?(g.push(b),h--,f=m):(g.push(a),i--,f=k)):(g.push(b),h--):(g.push(a),i--);return g.reverse(),g},e=function(a,b,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q;for(l=f-e+1,g=c-b+1,h=new Array(l),i=n=0;l>=0?l>n:n>l;i=l>=0?++n:--n)h[i]=new Array(g),h[i][0]=i;for(j=o=0;g>=0?g>o:o>g;j=g>=0?++o:--o)h[0][j]=j;for(i=p=1;l>=1?l>p:p>l;i=l>=1?++p:--p)for(j=q=1;g>=1?g>q:q>g;j=g>=1?++q:--q)diff.basic(a[b+j-1],d[e+i-1])?(k=h[i-1][j]+1,m=h[i][j-1]+1,h[i][j]=m>k?k:m):h[i][j]=h[i-1][j-1];return h}}.call(this),chip.diff=diff,chip.binding("bind-validation",function(a,b,c){return c[b.value]={},c.validationGroup=b.value}),chip.binding("validate-*",function(element,attr,controller){var opt,optArry,optionKey,optionValMsg,options,optsArry,type,validateField,validations,_i,_len,_ref;if(validations=null!=app.rootController.validations){if(type=attr.camel,""===attr.value)options={},options["default"]=!0;else if(attr.value.indexOf(":")<1)options=controller.eval(attr.value),"object"!=typeof options&&(options={},options[attr.value]=!0);else for(options={},optsArry=attr.value.split("|"),_i=0,_len=optsArry.length;_len>_i;_i++)opt=optsArry[_i],optArry=opt.split(":"),optionKey=optArry[0].trim(),optionValMsg=optArry[1].split("-e"),options[optionKey]={},options[optionKey].value=optionValMsg[0].trim(),options[optionKey].errorMessage=null!=(_ref=optionValMsg[1])?_ref.trim():void 0;return element.on("change",function(){var a,b;return b=element.val(),a=validateField(b,type,options),a.valid?(element.removeClass("chip_validation_invalid"),element.addClass("chip_validation_valid")):(console.error(a.errorMsgs),element.removeClass("chip_validation_valid"),element.addClass("chip_validation_invalid")),controller[controller.validationGroup][element.attr("name")]||(controller[controller.validationGroup][element.attr("name")]={}),controller[controller.validationGroup][element.attr("name")]=a}),validateField=function(value,type,options){var errorMsgs,isValid,optionName,optionValue,response,rule,validateMsg,validateVal,validation,_ref1,_ref2;response={valid:!0,message:"",errorMsgs:[]},validateVal=function(a){return null!=a.value?a.value:a},validateMsg=function(a){return null!=a.message?a.message:null},isValid=!0,errorMsgs=[];for(optionName in options)optionValue=options[optionName],validation=(null!=(_ref1=validations[type])?_ref1[optionName]:void 0)||(null!=(_ref2=validations.all)?_ref2[optionName]:void 0),null!=validation?(rule=validation.evaluation.replace("{x}",'"'+value+'"').replace("{y}",optionValue.value),eval(rule)?isValid=!0:(isValid=!1,validation.errorMessage?errorMsgs.push(validation.errorMessage.replace("{y}",optionValue.value)):validation.errorMessage("Input for this field is invalid."))):(response.valid=!0,console.warn("Validation method: "+optionName+" not found!"));return response.valid=isValid,response.errorMsgs=errorMsgs,response}}return console.warn("No validation rules found.")})}.call(this); \ No newline at end of file diff --git a/src/validation.coffee b/src/validation.coffee new file mode 100644 index 0000000..4d300da --- /dev/null +++ b/src/validation.coffee @@ -0,0 +1,136 @@ +# ## bind-validation +chip.binding 'bind-validation', (element, attr, controller) -> + controller[attr.value] = {} + controller.validationGroup = attr.value + +# ## validate-* +chip.binding 'validate-*', (element,attr,controller) -> + # When defining a validation rule, use the following: + # {x} = field value, {y} = validation option value + + ## Example + # validations = + # all: + # required: + # evaluation: '{x} != ""' + # errorMessage: 'This is a required field.' + # text: + # minLength: + # evaluation: '{x}.length >= {y}' + # errorMessage: 'This field must be at least {y} characters long.' + # maxLength: + # evaluation: '{x}.length <= {y}' + # errorMessage: 'This field must be at most {y} characters long.' + # number: + # minValue: + # evaluation: '{x} >= {y}' + # errorMessage: 'This value must be greater than {y}.' + # maxValue: + # evaluation: '{x} <= {y}' + # errorMessage: 'This value must be less than {y}.' + # email: + # default: + # evaluation: '{y}.match(/@/)' + # errorMessage: 'Please enter a valid email address.' + + validations = app.rootController.validations? + if !validations + console.warn 'No validation rules found.' + else + type = attr.camel + # Initially tested for a validation object with typeof, but that felt too + # rigid, so I simplfied it a bit. + + if attr.value is '' + options = {} + options.default = true + else + if attr.value.indexOf(':') < 1 + # Loading options as an object passed from the controller + options = controller.eval(attr.value) + unless typeof options is 'object' + options = {} + options[attr.value] = true + else + # Attempt to parse options directly from validation attribute + # We will probably need to spend more time working out the best format here + # since passing an object string in the attribute isn't going to work. + # + # Currently using the following 'shortcode' for validation options: + # option:value -e 'This is an optional message' + # + # Seperate options with | character (do not love this). + options = {} + optsArry = attr.value.split '|' + for opt in optsArry + optArry = opt.split ':' + optionKey = optArry[0].trim() + optionValMsg = optArry[1].split '-e' + options[optionKey] = {} + options[optionKey].value = optionValMsg[0].trim() + options[optionKey].errorMessage = optionValMsg[1]?.trim() + + element.on 'change', -> + value = element.val() + validResponse = validateField(value,type,options) + if validResponse.valid + # Do some happy, positive things + element.removeClass('chip_validation_invalid') + element.addClass('chip_validation_valid') + else + # Scorch the earth with shameful red error messages + console.error validResponse.errorMsgs + element.removeClass('chip_validation_valid') + element.addClass('chip_validation_invalid') + # In addition to adding / removing CSS classes to elements being validated, + # a validation object is added to the `validationController` under the + # named `validationGroup` by the element name. + # (will only work with simple field names) + unless controller[controller.validationGroup][element.attr('name')] + controller[controller.validationGroup][element.attr('name')] = {} + controller[controller.validationGroup][element.attr('name')] = + validResponse + + validateField = (value,type,options) -> + response = { + valid:true + message:'' + errorMsgs:[] + } + + validateVal = (validation) -> + if validation.value? + return validation.value + else + return validation + + validateMsg = (validation) -> + if validation.message? + return validation.message + else + return null + + isValid = true + errorMsgs = [] + for optionName, optionValue of options + validation = validations[type]?[optionName] || + validations.all?[optionName] + if validation? + rule = validation.evaluation.replace('{x}','"' + value + '"') + .replace('{y}',optionValue.value) + if eval rule + isValid = true; + else + isValid = false + if validation.errorMessage + errorMsgs.push validation.errorMessage.replace '{y}', + optionValue.value + else + validation.errorMessage 'Input for this field is invalid.' + else + 'validation missing' + response.valid = true; + console.warn 'Validation method: ' + optionName + ' not found!' + response.valid = isValid + response.errorMsgs = errorMsgs + return response