Showing the changes to Source/Libraries/Adapters/ModbusAdapters/Scripts (3 of 36 files). Show all
Unified · Split
| @@ -1,123 +0,0 @@ | ||
| 1 | −/*! | |
| 2 | − * Knockout JavaScript library v3.4.0 | |
| 3 | − * (c) Steven Sanderson - http://knockoutjs.com/ | |
| 4 | − * License: MIT (http://www.opensource.org/licenses/mit-license.php) | |
| 5 | − */ | |
| 6 | − | |
| 7 | −(function() {(function(n){var x=this||(0,eval)("this"),u=x.document,M=x.navigator,v=x.jQuery,F=x.JSON;(function(n){"function"===typeof define&&define.amd?define(["exports","require"],n):"object"===typeof exports&&"object"===typeof module?n(module.exports||exports):n(x.ko={})})(function(N,O){function J(a,c){return null===a||typeof a in T?a===c:!1}function U(b,c){var d;return function(){d||(d=a.a.setTimeout(function(){d=n;b()},c))}}function V(b,c){var d;return function(){clearTimeout(d);d=a.a.setTimeout(b,c)}}function W(a, | |
| 8 | −c){c&&c!==I?"beforeChange"===c?this.Kb(a):this.Ha(a,c):this.Lb(a)}function X(a,c){null!==c&&c.k&&c.k()}function Y(a,c){var d=this.Hc,e=d[s];e.R||(this.lb&&this.Ma[c]?(d.Pb(c,a,this.Ma[c]),this.Ma[c]=null,--this.lb):e.r[c]||d.Pb(c,a,e.s?{ia:a}:d.uc(a)))}function K(b,c,d,e){a.d[b]={init:function(b,g,k,l,m){var h,r;a.m(function(){var q=a.a.c(g()),p=!d!==!q,A=!r;if(A||c||p!==h)A&&a.va.Aa()&&(r=a.a.ua(a.f.childNodes(b),!0)),p?(A||a.f.da(b,a.a.ua(r)),a.eb(e?e(m,q):m,b)):a.f.xa(b),h=p},null,{i:b});return{controlsDescendantBindings:!0}}}; | |
| 9 | −a.h.ta[b]=!1;a.f.Z[b]=!0}var a="undefined"!==typeof N?N:{};a.b=function(b,c){for(var d=b.split("."),e=a,f=0;f<d.length-1;f++)e=e[d[f]];e[d[d.length-1]]=c};a.G=function(a,c,d){a[c]=d};a.version="3.4.0";a.b("version",a.version);a.options={deferUpdates:!1,useOnlyNativeEvents:!1};a.a=function(){function b(a,b){for(var c in a)a.hasOwnProperty(c)&&b(c,a[c])}function c(a,b){if(b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function d(a,b){a.__proto__=b;return a}function e(b,c,d,e){var h=b[c].match(r)|| | |
| 10 | −[];a.a.q(d.match(r),function(b){a.a.pa(h,b,e)});b[c]=h.join(" ")}var f={__proto__:[]}instanceof Array,g="function"===typeof Symbol,k={},l={};k[M&&/Firefox\/2/i.test(M.userAgent)?"KeyboardEvent":"UIEvents"]=["keyup","keydown","keypress"];k.MouseEvents="click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave".split(" ");b(k,function(a,b){if(b.length)for(var c=0,d=b.length;c<d;c++)l[b[c]]=a});var m={propertychange:!0},h=u&&function(){for(var a=3,b=u.createElement("div"),c= | |
| 11 | −b.getElementsByTagName("i");b.innerHTML="\x3c!--[if gt IE "+ ++a+"]><i></i><![endif]--\x3e",c[0];);return 4<a?a:n}(),r=/\S+/g;return{cc:["authenticity_token",/^__RequestVerificationToken(_.*)?$/],q:function(a,b){for(var c=0,d=a.length;c<d;c++)b(a[c],c)},o:function(a,b){if("function"==typeof Array.prototype.indexOf)return Array.prototype.indexOf.call(a,b);for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1},Sb:function(a,b,c){for(var d=0,e=a.length;d<e;d++)if(b.call(c,a[d],d))return a[d]; | |
| 12 | −return null},La:function(b,c){var d=a.a.o(b,c);0<d?b.splice(d,1):0===d&&b.shift()},Tb:function(b){b=b||[];for(var c=[],d=0,e=b.length;d<e;d++)0>a.a.o(c,b[d])&&c.push(b[d]);return c},fb:function(a,b){a=a||[];for(var c=[],d=0,e=a.length;d<e;d++)c.push(b(a[d],d));return c},Ka:function(a,b){a=a||[];for(var c=[],d=0,e=a.length;d<e;d++)b(a[d],d)&&c.push(a[d]);return c},ra:function(a,b){if(b instanceof Array)a.push.apply(a,b);else for(var c=0,d=b.length;c<d;c++)a.push(b[c]);return a},pa:function(b,c,d){var e= | |
| 13 | −a.a.o(a.a.zb(b),c);0>e?d&&b.push(c):d||b.splice(e,1)},ka:f,extend:c,Xa:d,Ya:f?d:c,D:b,Ca:function(a,b){if(!a)return a;var c={},d;for(d in a)a.hasOwnProperty(d)&&(c[d]=b(a[d],d,a));return c},ob:function(b){for(;b.firstChild;)a.removeNode(b.firstChild)},jc:function(b){b=a.a.V(b);for(var c=(b[0]&&b[0].ownerDocument||u).createElement("div"),d=0,e=b.length;d<e;d++)c.appendChild(a.$(b[d]));return c},ua:function(b,c){for(var d=0,e=b.length,h=[];d<e;d++){var m=b[d].cloneNode(!0);h.push(c?a.$(m):m)}return h}, | |
| 14 | −da:function(b,c){a.a.ob(b);if(c)for(var d=0,e=c.length;d<e;d++)b.appendChild(c[d])},qc:function(b,c){var d=b.nodeType?[b]:b;if(0<d.length){for(var e=d[0],h=e.parentNode,m=0,l=c.length;m<l;m++)h.insertBefore(c[m],e);m=0;for(l=d.length;m<l;m++)a.removeNode(d[m])}},za:function(a,b){if(a.length){for(b=8===b.nodeType&&b.parentNode||b;a.length&&a[0].parentNode!==b;)a.splice(0,1);for(;1<a.length&&a[a.length-1].parentNode!==b;)a.length--;if(1<a.length){var c=a[0],d=a[a.length-1];for(a.length=0;c!==d;)a.push(c), | |
| 15 | −c=c.nextSibling;a.push(d)}}return a},sc:function(a,b){7>h?a.setAttribute("selected",b):a.selected=b},$a:function(a){return null===a||a===n?"":a.trim?a.trim():a.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")},nd:function(a,b){a=a||"";return b.length>a.length?!1:a.substring(0,b.length)===b},Mc:function(a,b){if(a===b)return!0;if(11===a.nodeType)return!1;if(b.contains)return b.contains(3===a.nodeType?a.parentNode:a);if(b.compareDocumentPosition)return 16==(b.compareDocumentPosition(a)&16);for(;a&&a!= | |
| 16 | −b;)a=a.parentNode;return!!a},nb:function(b){return a.a.Mc(b,b.ownerDocument.documentElement)},Qb:function(b){return!!a.a.Sb(b,a.a.nb)},A:function(a){return a&&a.tagName&&a.tagName.toLowerCase()},Wb:function(b){return a.onError?function(){try{return b.apply(this,arguments)}catch(c){throw a.onError&&a.onError(c),c;}}:b},setTimeout:function(b,c){return setTimeout(a.a.Wb(b),c)},$b:function(b){setTimeout(function(){a.onError&&a.onError(b);throw b;},0)},p:function(b,c,d){var e=a.a.Wb(d);d=h&&m[c];if(a.options.useOnlyNativeEvents|| | |
| 17 | −d||!v)if(d||"function"!=typeof b.addEventListener)if("undefined"!=typeof b.attachEvent){var l=function(a){e.call(b,a)},f="on"+c;b.attachEvent(f,l);a.a.F.oa(b,function(){b.detachEvent(f,l)})}else throw Error("Browser doesn't support addEventListener or attachEvent");else b.addEventListener(c,e,!1);else v(b).bind(c,e)},Da:function(b,c){if(!b||!b.nodeType)throw Error("element must be a DOM node when calling triggerEvent");var d;"input"===a.a.A(b)&&b.type&&"click"==c.toLowerCase()?(d=b.type,d="checkbox"== | |
| 18 | −d||"radio"==d):d=!1;if(a.options.useOnlyNativeEvents||!v||d)if("function"==typeof u.createEvent)if("function"==typeof b.dispatchEvent)d=u.createEvent(l[c]||"HTMLEvents"),d.initEvent(c,!0,!0,x,0,0,0,0,0,!1,!1,!1,!1,0,b),b.dispatchEvent(d);else throw Error("The supplied element doesn't support dispatchEvent");else if(d&&b.click)b.click();else if("undefined"!=typeof b.fireEvent)b.fireEvent("on"+c);else throw Error("Browser doesn't support triggering events");else v(b).trigger(c)},c:function(b){return a.H(b)? | |
| 19 | −b():b},zb:function(b){return a.H(b)?b.t():b},bb:function(b,c,d){var h;c&&("object"===typeof b.classList?(h=b.classList[d?"add":"remove"],a.a.q(c.match(r),function(a){h.call(b.classList,a)})):"string"===typeof b.className.baseVal?e(b.className,"baseVal",c,d):e(b,"className",c,d))},Za:function(b,c){var d=a.a.c(c);if(null===d||d===n)d="";var e=a.f.firstChild(b);!e||3!=e.nodeType||a.f.nextSibling(e)?a.f.da(b,[b.ownerDocument.createTextNode(d)]):e.data=d;a.a.Rc(b)},rc:function(a,b){a.name=b;if(7>=h)try{a.mergeAttributes(u.createElement("<input name='"+ | |
| 20 | −a.name+"'/>"),!1)}catch(c){}},Rc:function(a){9<=h&&(a=1==a.nodeType?a:a.parentNode,a.style&&(a.style.zoom=a.style.zoom))},Nc:function(a){if(h){var b=a.style.width;a.style.width=0;a.style.width=b}},hd:function(b,c){b=a.a.c(b);c=a.a.c(c);for(var d=[],e=b;e<=c;e++)d.push(e);return d},V:function(a){for(var b=[],c=0,d=a.length;c<d;c++)b.push(a[c]);return b},Yb:function(a){return g?Symbol(a):a},rd:6===h,sd:7===h,C:h,ec:function(b,c){for(var d=a.a.V(b.getElementsByTagName("input")).concat(a.a.V(b.getElementsByTagName("textarea"))), | |
| 21 | −e="string"==typeof c?function(a){return a.name===c}:function(a){return c.test(a.name)},h=[],m=d.length-1;0<=m;m--)e(d[m])&&h.push(d[m]);return h},ed:function(b){return"string"==typeof b&&(b=a.a.$a(b))?F&&F.parse?F.parse(b):(new Function("return "+b))():null},Eb:function(b,c,d){if(!F||!F.stringify)throw Error("Cannot find JSON.stringify(). Some browsers (e.g., IE < 8) don't support it natively, but you can overcome this by adding a script reference to json2.js, downloadable from http://www.json.org/json2.js"); | |
| 22 | −return F.stringify(a.a.c(b),c,d)},fd:function(c,d,e){e=e||{};var h=e.params||{},m=e.includeFields||this.cc,l=c;if("object"==typeof c&&"form"===a.a.A(c))for(var l=c.action,f=m.length-1;0<=f;f--)for(var g=a.a.ec(c,m[f]),k=g.length-1;0<=k;k--)h[g[k].name]=g[k].value;d=a.a.c(d);var r=u.createElement("form");r.style.display="none";r.action=l;r.method="post";for(var n in d)c=u.createElement("input"),c.type="hidden",c.name=n,c.value=a.a.Eb(a.a.c(d[n])),r.appendChild(c);b(h,function(a,b){var c=u.createElement("input"); | |
| 23 | −c.type="hidden";c.name=a;c.value=b;r.appendChild(c)});u.body.appendChild(r);e.submitter?e.submitter(r):r.submit();setTimeout(function(){r.parentNode.removeChild(r)},0)}}}();a.b("utils",a.a);a.b("utils.arrayForEach",a.a.q);a.b("utils.arrayFirst",a.a.Sb);a.b("utils.arrayFilter",a.a.Ka);a.b("utils.arrayGetDistinctValues",a.a.Tb);a.b("utils.arrayIndexOf",a.a.o);a.b("utils.arrayMap",a.a.fb);a.b("utils.arrayPushAll",a.a.ra);a.b("utils.arrayRemoveItem",a.a.La);a.b("utils.extend",a.a.extend);a.b("utils.fieldsIncludedWithJsonPost", | |
| 24 | −a.a.cc);a.b("utils.getFormFields",a.a.ec);a.b("utils.peekObservable",a.a.zb);a.b("utils.postJson",a.a.fd);a.b("utils.parseJson",a.a.ed);a.b("utils.registerEventHandler",a.a.p);a.b("utils.stringifyJson",a.a.Eb);a.b("utils.range",a.a.hd);a.b("utils.toggleDomNodeCssClass",a.a.bb);a.b("utils.triggerEvent",a.a.Da);a.b("utils.unwrapObservable",a.a.c);a.b("utils.objectForEach",a.a.D);a.b("utils.addOrRemoveItem",a.a.pa);a.b("utils.setTextContent",a.a.Za);a.b("unwrap",a.a.c);Function.prototype.bind||(Function.prototype.bind= | |
| 25 | −function(a){var c=this;if(1===arguments.length)return function(){return c.apply(a,arguments)};var d=Array.prototype.slice.call(arguments,1);return function(){var e=d.slice(0);e.push.apply(e,arguments);return c.apply(a,e)}});a.a.e=new function(){function a(b,g){var k=b[d];if(!k||"null"===k||!e[k]){if(!g)return n;k=b[d]="ko"+c++;e[k]={}}return e[k]}var c=0,d="__ko__"+(new Date).getTime(),e={};return{get:function(c,d){var e=a(c,!1);return e===n?n:e[d]},set:function(c,d,e){if(e!==n||a(c,!1)!==n)a(c,!0)[d]= | |
| 26 | −e},clear:function(a){var b=a[d];return b?(delete e[b],a[d]=null,!0):!1},I:function(){return c++ +d}}};a.b("utils.domData",a.a.e);a.b("utils.domData.clear",a.a.e.clear);a.a.F=new function(){function b(b,c){var e=a.a.e.get(b,d);e===n&&c&&(e=[],a.a.e.set(b,d,e));return e}function c(d){var e=b(d,!1);if(e)for(var e=e.slice(0),l=0;l<e.length;l++)e[l](d);a.a.e.clear(d);a.a.F.cleanExternalData(d);if(f[d.nodeType])for(e=d.firstChild;d=e;)e=d.nextSibling,8===d.nodeType&&c(d)}var d=a.a.e.I(),e={1:!0,8:!0,9:!0}, | |
| 27 | −f={1:!0,9:!0};return{oa:function(a,c){if("function"!=typeof c)throw Error("Callback must be a function");b(a,!0).push(c)},pc:function(c,e){var l=b(c,!1);l&&(a.a.La(l,e),0==l.length&&a.a.e.set(c,d,n))},$:function(b){if(e[b.nodeType]&&(c(b),f[b.nodeType])){var d=[];a.a.ra(d,b.getElementsByTagName("*"));for(var l=0,m=d.length;l<m;l++)c(d[l])}return b},removeNode:function(b){a.$(b);b.parentNode&&b.parentNode.removeChild(b)},cleanExternalData:function(a){v&&"function"==typeof v.cleanData&&v.cleanData([a])}}}; | |
| 28 | −a.$=a.a.F.$;a.removeNode=a.a.F.removeNode;a.b("cleanNode",a.$);a.b("removeNode",a.removeNode);a.b("utils.domNodeDisposal",a.a.F);a.b("utils.domNodeDisposal.addDisposeCallback",a.a.F.oa);a.b("utils.domNodeDisposal.removeDisposeCallback",a.a.F.pc);(function(){var b=[0,"",""],c=[1,"<table>","</table>"],d=[3,"<table><tbody><tr>","</tr></tbody></table>"],e=[1,"<select multiple='multiple'>","</select>"],f={thead:c,tbody:c,tfoot:c,tr:[2,"<table><tbody>","</tbody></table>"],td:d,th:d,option:e,optgroup:e}, | |
| 29 | −g=8>=a.a.C;a.a.ma=function(c,d){var e;if(v)if(v.parseHTML)e=v.parseHTML(c,d)||[];else{if((e=v.clean([c],d))&&e[0]){for(var h=e[0];h.parentNode&&11!==h.parentNode.nodeType;)h=h.parentNode;h.parentNode&&h.parentNode.removeChild(h)}}else{(e=d)||(e=u);var h=e.parentWindow||e.defaultView||x,r=a.a.$a(c).toLowerCase(),q=e.createElement("div"),p;p=(r=r.match(/^<([a-z]+)[ >]/))&&f[r[1]]||b;r=p[0];p="ignored<div>"+p[1]+c+p[2]+"</div>";"function"==typeof h.innerShiv?q.appendChild(h.innerShiv(p)):(g&&e.appendChild(q), | |
| 30 | −q.innerHTML=p,g&&q.parentNode.removeChild(q));for(;r--;)q=q.lastChild;e=a.a.V(q.lastChild.childNodes)}return e};a.a.Cb=function(b,c){a.a.ob(b);c=a.a.c(c);if(null!==c&&c!==n)if("string"!=typeof c&&(c=c.toString()),v)v(b).html(c);else for(var d=a.a.ma(c,b.ownerDocument),e=0;e<d.length;e++)b.appendChild(d[e])}})();a.b("utils.parseHtmlFragment",a.a.ma);a.b("utils.setHtml",a.a.Cb);a.M=function(){function b(c,e){if(c)if(8==c.nodeType){var f=a.M.lc(c.nodeValue);null!=f&&e.push({Lc:c,cd:f})}else if(1==c.nodeType)for(var f= | |
| 31 | −0,g=c.childNodes,k=g.length;f<k;f++)b(g[f],e)}var c={};return{wb:function(a){if("function"!=typeof a)throw Error("You can only pass a function to ko.memoization.memoize()");var b=(4294967296*(1+Math.random())|0).toString(16).substring(1)+(4294967296*(1+Math.random())|0).toString(16).substring(1);c[b]=a;return"\x3c!--[ko_memo:"+b+"]--\x3e"},xc:function(a,b){var f=c[a];if(f===n)throw Error("Couldn't find any memo with ID "+a+". Perhaps it's already been unmemoized.");try{return f.apply(null,b||[]), | |
| 32 | −!0}finally{delete c[a]}},yc:function(c,e){var f=[];b(c,f);for(var g=0,k=f.length;g<k;g++){var l=f[g].Lc,m=[l];e&&a.a.ra(m,e);a.M.xc(f[g].cd,m);l.nodeValue="";l.parentNode&&l.parentNode.removeChild(l)}},lc:function(a){return(a=a.match(/^\[ko_memo\:(.*?)\]$/))?a[1]:null}}}();a.b("memoization",a.M);a.b("memoization.memoize",a.M.wb);a.b("memoization.unmemoize",a.M.xc);a.b("memoization.parseMemoText",a.M.lc);a.b("memoization.unmemoizeDomNodeAndDescendants",a.M.yc);a.Y=function(){function b(){if(e)for(var b= | |
| 33 | −e,c=0,m;g<e;)if(m=d[g++]){if(g>b){if(5E3<=++c){g=e;a.a.$b(Error("'Too much recursion' after processing "+c+" task groups."));break}b=e}try{m()}catch(h){a.a.$b(h)}}}function c(){b();g=e=d.length=0}var d=[],e=0,f=1,g=0;return{scheduler:x.MutationObserver?function(a){var b=u.createElement("div");(new MutationObserver(a)).observe(b,{attributes:!0});return function(){b.classList.toggle("foo")}}(c):u&&"onreadystatechange"in u.createElement("script")?function(a){var b=u.createElement("script");b.onreadystatechange= | |
| 34 | −function(){b.onreadystatechange=null;u.documentElement.removeChild(b);b=null;a()};u.documentElement.appendChild(b)}:function(a){setTimeout(a,0)},Wa:function(b){e||a.Y.scheduler(c);d[e++]=b;return f++},cancel:function(a){a-=f-e;a>=g&&a<e&&(d[a]=null)},resetForTesting:function(){var a=e-g;g=e=d.length=0;return a},md:b}}();a.b("tasks",a.Y);a.b("tasks.schedule",a.Y.Wa);a.b("tasks.runEarly",a.Y.md);a.ya={throttle:function(b,c){b.throttleEvaluation=c;var d=null;return a.B({read:b,write:function(e){clearTimeout(d); | |
| 35 | −d=a.a.setTimeout(function(){b(e)},c)}})},rateLimit:function(a,c){var d,e,f;"number"==typeof c?d=c:(d=c.timeout,e=c.method);a.cb=!1;f="notifyWhenChangesStop"==e?V:U;a.Ta(function(a){return f(a,d)})},deferred:function(b,c){if(!0!==c)throw Error("The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled.");b.cb||(b.cb=!0,b.Ta(function(c){var e;return function(){a.Y.cancel(e);e=a.Y.Wa(c);b.notifySubscribers(n,"dirty")}}))},notify:function(a,c){a.equalityComparer= | |
| 36 | −"always"==c?null:J}};var T={undefined:1,"boolean":1,number:1,string:1};a.b("extenders",a.ya);a.vc=function(b,c,d){this.ia=b;this.gb=c;this.Kc=d;this.R=!1;a.G(this,"dispose",this.k)};a.vc.prototype.k=function(){this.R=!0;this.Kc()};a.J=function(){a.a.Ya(this,D);D.rb(this)};var I="change",D={rb:function(a){a.K={};a.Nb=1},X:function(b,c,d){var e=this;d=d||I;var f=new a.vc(e,c?b.bind(c):b,function(){a.a.La(e.K[d],f);e.Ia&&e.Ia(d)});e.sa&&e.sa(d);e.K[d]||(e.K[d]=[]);e.K[d].push(f);return f},notifySubscribers:function(b, | |
| 37 | −c){c=c||I;c===I&&this.zc();if(this.Pa(c))try{a.l.Ub();for(var d=this.K[c].slice(0),e=0,f;f=d[e];++e)f.R||f.gb(b)}finally{a.l.end()}},Na:function(){return this.Nb},Uc:function(a){return this.Na()!==a},zc:function(){++this.Nb},Ta:function(b){var c=this,d=a.H(c),e,f,g;c.Ha||(c.Ha=c.notifySubscribers,c.notifySubscribers=W);var k=b(function(){c.Mb=!1;d&&g===c&&(g=c());e=!1;c.tb(f,g)&&c.Ha(f=g)});c.Lb=function(a){c.Mb=e=!0;g=a;k()};c.Kb=function(a){e||(f=a,c.Ha(a,"beforeChange"))}},Pa:function(a){return this.K[a]&& | |
| 38 | −this.K[a].length},Sc:function(b){if(b)return this.K[b]&&this.K[b].length||0;var c=0;a.a.D(this.K,function(a,b){"dirty"!==a&&(c+=b.length)});return c},tb:function(a,c){return!this.equalityComparer||!this.equalityComparer(a,c)},extend:function(b){var c=this;b&&a.a.D(b,function(b,e){var f=a.ya[b];"function"==typeof f&&(c=f(c,e)||c)});return c}};a.G(D,"subscribe",D.X);a.G(D,"extend",D.extend);a.G(D,"getSubscriptionsCount",D.Sc);a.a.ka&&a.a.Xa(D,Function.prototype);a.J.fn=D;a.hc=function(a){return null!= | |
| 39 | −a&&"function"==typeof a.X&&"function"==typeof a.notifySubscribers};a.b("subscribable",a.J);a.b("isSubscribable",a.hc);a.va=a.l=function(){function b(a){d.push(e);e=a}function c(){e=d.pop()}var d=[],e,f=0;return{Ub:b,end:c,oc:function(b){if(e){if(!a.hc(b))throw Error("Only subscribable things can act as dependencies");e.gb.call(e.Gc,b,b.Cc||(b.Cc=++f))}},w:function(a,d,e){try{return b(),a.apply(d,e||[])}finally{c()}},Aa:function(){if(e)return e.m.Aa()},Sa:function(){if(e)return e.Sa}}}();a.b("computedContext", | |
| 40 | −a.va);a.b("computedContext.getDependenciesCount",a.va.Aa);a.b("computedContext.isInitial",a.va.Sa);a.b("ignoreDependencies",a.qd=a.l.w);var E=a.a.Yb("_latestValue");a.N=function(b){function c(){if(0<arguments.length)return c.tb(c[E],arguments[0])&&(c.ga(),c[E]=arguments[0],c.fa()),this;a.l.oc(c);return c[E]}c[E]=b;a.a.ka||a.a.extend(c,a.J.fn);a.J.fn.rb(c);a.a.Ya(c,B);a.options.deferUpdates&&a.ya.deferred(c,!0);return c};var B={equalityComparer:J,t:function(){return this[E]},fa:function(){this.notifySubscribers(this[E])}, | |
| 41 | −ga:function(){this.notifySubscribers(this[E],"beforeChange")}};a.a.ka&&a.a.Xa(B,a.J.fn);var H=a.N.gd="__ko_proto__";B[H]=a.N;a.Oa=function(b,c){return null===b||b===n||b[H]===n?!1:b[H]===c?!0:a.Oa(b[H],c)};a.H=function(b){return a.Oa(b,a.N)};a.Ba=function(b){return"function"==typeof b&&b[H]===a.N||"function"==typeof b&&b[H]===a.B&&b.Vc?!0:!1};a.b("observable",a.N);a.b("isObservable",a.H);a.b("isWriteableObservable",a.Ba);a.b("isWritableObservable",a.Ba);a.b("observable.fn",B);a.G(B,"peek",B.t);a.G(B, | |
| 42 | −"valueHasMutated",B.fa);a.G(B,"valueWillMutate",B.ga);a.la=function(b){b=b||[];if("object"!=typeof b||!("length"in b))throw Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");b=a.N(b);a.a.Ya(b,a.la.fn);return b.extend({trackArrayChanges:!0})};a.la.fn={remove:function(b){for(var c=this.t(),d=[],e="function"!=typeof b||a.H(b)?function(a){return a===b}:b,f=0;f<c.length;f++){var g=c[f];e(g)&&(0===d.length&&this.ga(),d.push(g),c.splice(f,1),f--)}d.length&& | |
| 43 | −this.fa();return d},removeAll:function(b){if(b===n){var c=this.t(),d=c.slice(0);this.ga();c.splice(0,c.length);this.fa();return d}return b?this.remove(function(c){return 0<=a.a.o(b,c)}):[]},destroy:function(b){var c=this.t(),d="function"!=typeof b||a.H(b)?function(a){return a===b}:b;this.ga();for(var e=c.length-1;0<=e;e--)d(c[e])&&(c[e]._destroy=!0);this.fa()},destroyAll:function(b){return b===n?this.destroy(function(){return!0}):b?this.destroy(function(c){return 0<=a.a.o(b,c)}):[]},indexOf:function(b){var c= | |
| 44 | −this();return a.a.o(c,b)},replace:function(a,c){var d=this.indexOf(a);0<=d&&(this.ga(),this.t()[d]=c,this.fa())}};a.a.ka&&a.a.Xa(a.la.fn,a.N.fn);a.a.q("pop push reverse shift sort splice unshift".split(" "),function(b){a.la.fn[b]=function(){var a=this.t();this.ga();this.Vb(a,b,arguments);var d=a[b].apply(a,arguments);this.fa();return d===a?this:d}});a.a.q(["slice"],function(b){a.la.fn[b]=function(){var a=this();return a[b].apply(a,arguments)}});a.b("observableArray",a.la);a.ya.trackArrayChanges=function(b, | |
| 45 | −c){function d(){if(!e){e=!0;var c=b.notifySubscribers;b.notifySubscribers=function(a,b){b&&b!==I||++k;return c.apply(this,arguments)};var d=[].concat(b.t()||[]);f=null;g=b.X(function(c){c=[].concat(c||[]);if(b.Pa("arrayChange")){var e;if(!f||1<k)f=a.a.ib(d,c,b.hb);e=f}d=c;f=null;k=0;e&&e.length&&b.notifySubscribers(e,"arrayChange")})}}b.hb={};c&&"object"==typeof c&&a.a.extend(b.hb,c);b.hb.sparse=!0;if(!b.Vb){var e=!1,f=null,g,k=0,l=b.sa,m=b.Ia;b.sa=function(a){l&&l.call(b,a);"arrayChange"===a&&d()}; | |
| 46 | −b.Ia=function(a){m&&m.call(b,a);"arrayChange"!==a||b.Pa("arrayChange")||(g.k(),e=!1)};b.Vb=function(b,c,d){function m(a,b,c){return l[l.length]={status:a,value:b,index:c}}if(e&&!k){var l=[],g=b.length,t=d.length,G=0;switch(c){case "push":G=g;case "unshift":for(c=0;c<t;c++)m("added",d[c],G+c);break;case "pop":G=g-1;case "shift":g&&m("deleted",b[G],G);break;case "splice":c=Math.min(Math.max(0,0>d[0]?g+d[0]:d[0]),g);for(var g=1===t?g:Math.min(c+(d[1]||0),g),t=c+t-2,G=Math.max(g,t),P=[],n=[],Q=2;c<G;++c, | |
| 47 | −++Q)c<g&&n.push(m("deleted",b[c],c)),c<t&&P.push(m("added",d[Q],c));a.a.dc(n,P);break;default:return}f=l}}}};var s=a.a.Yb("_state");a.m=a.B=function(b,c,d){function e(){if(0<arguments.length){if("function"===typeof f)f.apply(g.pb,arguments);else throw Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");return this}a.l.oc(e);(g.S||g.s&&e.Qa())&&e.aa();return g.T}"object"===typeof b?d=b:(d=d||{},b&&(d.read= | |
| 48 | −b));if("function"!=typeof d.read)throw Error("Pass a function that returns the value of the ko.computed");var f=d.write,g={T:n,S:!0,Ra:!1,Fb:!1,R:!1,Va:!1,s:!1,jd:d.read,pb:c||d.owner,i:d.disposeWhenNodeIsRemoved||d.i||null,wa:d.disposeWhen||d.wa,mb:null,r:{},L:0,bc:null};e[s]=g;e.Vc="function"===typeof f;a.a.ka||a.a.extend(e,a.J.fn);a.J.fn.rb(e);a.a.Ya(e,z);d.pure?(g.Va=!0,g.s=!0,a.a.extend(e,$)):d.deferEvaluation&&a.a.extend(e,aa);a.options.deferUpdates&&a.ya.deferred(e,!0);g.i&&(g.Fb=!0,g.i.nodeType|| | |
| 49 | −(g.i=null));g.s||d.deferEvaluation||e.aa();g.i&&e.ba()&&a.a.F.oa(g.i,g.mb=function(){e.k()});return e};var z={equalityComparer:J,Aa:function(){return this[s].L},Pb:function(a,c,d){if(this[s].Va&&c===this)throw Error("A 'pure' computed must not be called recursively");this[s].r[a]=d;d.Ga=this[s].L++;d.na=c.Na()},Qa:function(){var a,c,d=this[s].r;for(a in d)if(d.hasOwnProperty(a)&&(c=d[a],c.ia.Uc(c.na)))return!0},bd:function(){this.Fa&&!this[s].Ra&&this.Fa()},ba:function(){return this[s].S||0<this[s].L}, | |
| 50 | −ld:function(){this.Mb||this.ac()},uc:function(a){if(a.cb&&!this[s].i){var c=a.X(this.bd,this,"dirty"),d=a.X(this.ld,this);return{ia:a,k:function(){c.k();d.k()}}}return a.X(this.ac,this)},ac:function(){var b=this,c=b.throttleEvaluation;c&&0<=c?(clearTimeout(this[s].bc),this[s].bc=a.a.setTimeout(function(){b.aa(!0)},c)):b.Fa?b.Fa():b.aa(!0)},aa:function(b){var c=this[s],d=c.wa;if(!c.Ra&&!c.R){if(c.i&&!a.a.nb(c.i)||d&&d()){if(!c.Fb){this.k();return}}else c.Fb=!1;c.Ra=!0;try{this.Qc(b)}finally{c.Ra=!1}c.L|| | |
| 51 | −this.k()}},Qc:function(b){var c=this[s],d=c.Va?n:!c.L,e={Hc:this,Ma:c.r,lb:c.L};a.l.Ub({Gc:e,gb:Y,m:this,Sa:d});c.r={};c.L=0;e=this.Pc(c,e);this.tb(c.T,e)&&(c.s||this.notifySubscribers(c.T,"beforeChange"),c.T=e,c.s?this.zc():b&&this.notifySubscribers(c.T));d&&this.notifySubscribers(c.T,"awake")},Pc:function(b,c){try{var d=b.jd;return b.pb?d.call(b.pb):d()}finally{a.l.end(),c.lb&&!b.s&&a.a.D(c.Ma,X),b.S=!1}},t:function(){var a=this[s];(a.S&&!a.L||a.s&&this.Qa())&&this.aa();return a.T},Ta:function(b){a.J.fn.Ta.call(this, | |
| 52 | −b);this.Fa=function(){this.Kb(this[s].T);this[s].S=!0;this.Lb(this)}},k:function(){var b=this[s];!b.s&&b.r&&a.a.D(b.r,function(a,b){b.k&&b.k()});b.i&&b.mb&&a.a.F.pc(b.i,b.mb);b.r=null;b.L=0;b.R=!0;b.S=!1;b.s=!1;b.i=null}},$={sa:function(b){var c=this,d=c[s];if(!d.R&&d.s&&"change"==b){d.s=!1;if(d.S||c.Qa())d.r=null,d.L=0,d.S=!0,c.aa();else{var e=[];a.a.D(d.r,function(a,b){e[b.Ga]=a});a.a.q(e,function(a,b){var e=d.r[a],l=c.uc(e.ia);l.Ga=b;l.na=e.na;d.r[a]=l})}d.R||c.notifySubscribers(d.T,"awake")}}, | |
| 53 | −Ia:function(b){var c=this[s];c.R||"change"!=b||this.Pa("change")||(a.a.D(c.r,function(a,b){b.k&&(c.r[a]={ia:b.ia,Ga:b.Ga,na:b.na},b.k())}),c.s=!0,this.notifySubscribers(n,"asleep"))},Na:function(){var b=this[s];b.s&&(b.S||this.Qa())&&this.aa();return a.J.fn.Na.call(this)}},aa={sa:function(a){"change"!=a&&"beforeChange"!=a||this.t()}};a.a.ka&&a.a.Xa(z,a.J.fn);var R=a.N.gd;a.m[R]=a.N;z[R]=a.m;a.Xc=function(b){return a.Oa(b,a.m)};a.Yc=function(b){return a.Oa(b,a.m)&&b[s]&&b[s].Va};a.b("computed",a.m); | |
| 54 | −a.b("dependentObservable",a.m);a.b("isComputed",a.Xc);a.b("isPureComputed",a.Yc);a.b("computed.fn",z);a.G(z,"peek",z.t);a.G(z,"dispose",z.k);a.G(z,"isActive",z.ba);a.G(z,"getDependenciesCount",z.Aa);a.nc=function(b,c){if("function"===typeof b)return a.m(b,c,{pure:!0});b=a.a.extend({},b);b.pure=!0;return a.m(b,c)};a.b("pureComputed",a.nc);(function(){function b(a,f,g){g=g||new d;a=f(a);if("object"!=typeof a||null===a||a===n||a instanceof RegExp||a instanceof Date||a instanceof String||a instanceof | |
| 55 | −Number||a instanceof Boolean)return a;var k=a instanceof Array?[]:{};g.save(a,k);c(a,function(c){var d=f(a[c]);switch(typeof d){case "boolean":case "number":case "string":case "function":k[c]=d;break;case "object":case "undefined":var h=g.get(d);k[c]=h!==n?h:b(d,f,g)}});return k}function c(a,b){if(a instanceof Array){for(var c=0;c<a.length;c++)b(c);"function"==typeof a.toJSON&&b("toJSON")}else for(c in a)b(c)}function d(){this.keys=[];this.Ib=[]}a.wc=function(c){if(0==arguments.length)throw Error("When calling ko.toJS, pass the object you want to convert."); | |
| 56 | −return b(c,function(b){for(var c=0;a.H(b)&&10>c;c++)b=b();return b})};a.toJSON=function(b,c,d){b=a.wc(b);return a.a.Eb(b,c,d)};d.prototype={save:function(b,c){var d=a.a.o(this.keys,b);0<=d?this.Ib[d]=c:(this.keys.push(b),this.Ib.push(c))},get:function(b){b=a.a.o(this.keys,b);return 0<=b?this.Ib[b]:n}}})();a.b("toJS",a.wc);a.b("toJSON",a.toJSON);(function(){a.j={u:function(b){switch(a.a.A(b)){case "option":return!0===b.__ko__hasDomDataOptionValue__?a.a.e.get(b,a.d.options.xb):7>=a.a.C?b.getAttributeNode("value")&& | |
| 57 | −b.getAttributeNode("value").specified?b.value:b.text:b.value;case "select":return 0<=b.selectedIndex?a.j.u(b.options[b.selectedIndex]):n;default:return b.value}},ha:function(b,c,d){switch(a.a.A(b)){case "option":switch(typeof c){case "string":a.a.e.set(b,a.d.options.xb,n);"__ko__hasDomDataOptionValue__"in b&&delete b.__ko__hasDomDataOptionValue__;b.value=c;break;default:a.a.e.set(b,a.d.options.xb,c),b.__ko__hasDomDataOptionValue__=!0,b.value="number"===typeof c?c:""}break;case "select":if(""===c|| | |
| 58 | −null===c)c=n;for(var e=-1,f=0,g=b.options.length,k;f<g;++f)if(k=a.j.u(b.options[f]),k==c||""==k&&c===n){e=f;break}if(d||0<=e||c===n&&1<b.size)b.selectedIndex=e;break;default:if(null===c||c===n)c="";b.value=c}}}})();a.b("selectExtensions",a.j);a.b("selectExtensions.readValue",a.j.u);a.b("selectExtensions.writeValue",a.j.ha);a.h=function(){function b(b){b=a.a.$a(b);123===b.charCodeAt(0)&&(b=b.slice(1,-1));var c=[],d=b.match(e),r,k=[],p=0;if(d){d.push(",");for(var A=0,y;y=d[A];++A){var t=y.charCodeAt(0); | |
| 59 | −if(44===t){if(0>=p){c.push(r&&k.length?{key:r,value:k.join("")}:{unknown:r||k.join("")});r=p=0;k=[];continue}}else if(58===t){if(!p&&!r&&1===k.length){r=k.pop();continue}}else 47===t&&A&&1<y.length?(t=d[A-1].match(f))&&!g[t[0]]&&(b=b.substr(b.indexOf(y)+1),d=b.match(e),d.push(","),A=-1,y="/"):40===t||123===t||91===t?++p:41===t||125===t||93===t?--p:r||k.length||34!==t&&39!==t||(y=y.slice(1,-1));k.push(y)}}return c}var c=["true","false","null","undefined"],d=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i, | |
| 60 | −e=RegExp("\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*'|/(?:[^/\\\\]|\\\\.)*/w*|[^\\s:,/][^,\"'{}()/:[\\]]*[^\\s,\"'{}()/:[\\]]|[^\\s]","g"),f=/[\])"'A-Za-z0-9_$]+$/,g={"in":1,"return":1,"typeof":1},k={};return{ta:[],ea:k,yb:b,Ua:function(e,m){function h(b,e){var m;if(!A){var l=a.getBindingHandler(b);if(l&&l.preprocess&&!(e=l.preprocess(e,b,h)))return;if(l=k[b])m=e,0<=a.a.o(c,m)?m=!1:(l=m.match(d),m=null===l?!1:l[1]?"Object("+l[1]+")"+l[2]:m),l=m;l&&g.push("'"+b+"':function(_z){"+m+"=_z}")}p&&(e= | |
| 61 | −"function(){return "+e+" }");f.push("'"+b+"':"+e)}m=m||{};var f=[],g=[],p=m.valueAccessors,A=m.bindingParams,y="string"===typeof e?b(e):e;a.a.q(y,function(a){h(a.key||a.unknown,a.value)});g.length&&h("_ko_property_writers","{"+g.join(",")+" }");return f.join(",")},ad:function(a,b){for(var c=0;c<a.length;c++)if(a[c].key==b)return!0;return!1},Ea:function(b,c,d,e,f){if(b&&a.H(b))!a.Ba(b)||f&&b.t()===e||b(e);else if((b=c.get("_ko_property_writers"))&&b[d])b[d](e)}}}();a.b("expressionRewriting",a.h);a.b("expressionRewriting.bindingRewriteValidators", | |
| 62 | −a.h.ta);a.b("expressionRewriting.parseObjectLiteral",a.h.yb);a.b("expressionRewriting.preProcessBindings",a.h.Ua);a.b("expressionRewriting._twoWayBindings",a.h.ea);a.b("jsonExpressionRewriting",a.h);a.b("jsonExpressionRewriting.insertPropertyAccessorsIntoJson",a.h.Ua);(function(){function b(a){return 8==a.nodeType&&g.test(f?a.text:a.nodeValue)}function c(a){return 8==a.nodeType&&k.test(f?a.text:a.nodeValue)}function d(a,d){for(var e=a,f=1,l=[];e=e.nextSibling;){if(c(e)&&(f--,0===f))return l;l.push(e); | |
| 63 | −b(e)&&f++}if(!d)throw Error("Cannot find closing comment tag to match: "+a.nodeValue);return null}function e(a,b){var c=d(a,b);return c?0<c.length?c[c.length-1].nextSibling:a.nextSibling:null}var f=u&&"\x3c!--test--\x3e"===u.createComment("test").text,g=f?/^\x3c!--\s*ko(?:\s+([\s\S]+))?\s*--\x3e$/:/^\s*ko(?:\s+([\s\S]+))?\s*$/,k=f?/^\x3c!--\s*\/ko\s*--\x3e$/:/^\s*\/ko\s*$/,l={ul:!0,ol:!0};a.f={Z:{},childNodes:function(a){return b(a)?d(a):a.childNodes},xa:function(c){if(b(c)){c=a.f.childNodes(c);for(var d= | |
| 64 | −0,e=c.length;d<e;d++)a.removeNode(c[d])}else a.a.ob(c)},da:function(c,d){if(b(c)){a.f.xa(c);for(var e=c.nextSibling,f=0,l=d.length;f<l;f++)e.parentNode.insertBefore(d[f],e)}else a.a.da(c,d)},mc:function(a,c){b(a)?a.parentNode.insertBefore(c,a.nextSibling):a.firstChild?a.insertBefore(c,a.firstChild):a.appendChild(c)},gc:function(c,d,e){e?b(c)?c.parentNode.insertBefore(d,e.nextSibling):e.nextSibling?c.insertBefore(d,e.nextSibling):c.appendChild(d):a.f.mc(c,d)},firstChild:function(a){return b(a)?!a.nextSibling|| | |
| 65 | −c(a.nextSibling)?null:a.nextSibling:a.firstChild},nextSibling:function(a){b(a)&&(a=e(a));return a.nextSibling&&c(a.nextSibling)?null:a.nextSibling},Tc:b,pd:function(a){return(a=(f?a.text:a.nodeValue).match(g))?a[1]:null},kc:function(d){if(l[a.a.A(d)]){var h=d.firstChild;if(h){do if(1===h.nodeType){var f;f=h.firstChild;var g=null;if(f){do if(g)g.push(f);else if(b(f)){var k=e(f,!0);k?f=k:g=[f]}else c(f)&&(g=[f]);while(f=f.nextSibling)}if(f=g)for(g=h.nextSibling,k=0;k<f.length;k++)g?d.insertBefore(f[k], | |
| 66 | −g):d.appendChild(f[k])}while(h=h.nextSibling)}}}}})();a.b("virtualElements",a.f);a.b("virtualElements.allowedBindings",a.f.Z);a.b("virtualElements.emptyNode",a.f.xa);a.b("virtualElements.insertAfter",a.f.gc);a.b("virtualElements.prepend",a.f.mc);a.b("virtualElements.setDomNodeChildren",a.f.da);(function(){a.Q=function(){this.Fc={}};a.a.extend(a.Q.prototype,{nodeHasBindings:function(b){switch(b.nodeType){case 1:return null!=b.getAttribute("data-bind")||a.g.getComponentNameForNode(b);case 8:return a.f.Tc(b); | |
| 67 | −default:return!1}},getBindings:function(b,c){var d=this.getBindingsString(b,c),d=d?this.parseBindingsString(d,c,b):null;return a.g.Ob(d,b,c,!1)},getBindingAccessors:function(b,c){var d=this.getBindingsString(b,c),d=d?this.parseBindingsString(d,c,b,{valueAccessors:!0}):null;return a.g.Ob(d,b,c,!0)},getBindingsString:function(b){switch(b.nodeType){case 1:return b.getAttribute("data-bind");case 8:return a.f.pd(b);default:return null}},parseBindingsString:function(b,c,d,e){try{var f=this.Fc,g=b+(e&&e.valueAccessors|| | |
| 68 | −""),k;if(!(k=f[g])){var l,m="with($context){with($data||{}){return{"+a.h.Ua(b,e)+"}}}";l=new Function("$context","$element",m);k=f[g]=l}return k(c,d)}catch(h){throw h.message="Unable to parse bindings.\nBindings value: "+b+"\nMessage: "+h.message,h;}}});a.Q.instance=new a.Q})();a.b("bindingProvider",a.Q);(function(){function b(a){return function(){return a}}function c(a){return a()}function d(b){return a.a.Ca(a.l.w(b),function(a,c){return function(){return b()[c]}})}function e(c,e,h){return"function"=== | |
| 69 | −typeof c?d(c.bind(null,e,h)):a.a.Ca(c,b)}function f(a,b){return d(this.getBindings.bind(this,a,b))}function g(b,c,d){var e,h=a.f.firstChild(c),f=a.Q.instance,m=f.preprocessNode;if(m){for(;e=h;)h=a.f.nextSibling(e),m.call(f,e);h=a.f.firstChild(c)}for(;e=h;)h=a.f.nextSibling(e),k(b,e,d)}function k(b,c,d){var e=!0,h=1===c.nodeType;h&&a.f.kc(c);if(h&&d||a.Q.instance.nodeHasBindings(c))e=m(c,null,b,d).shouldBindDescendants;e&&!r[a.a.A(c)]&&g(b,c,!h)}function l(b){var c=[],d={},e=[];a.a.D(b,function Z(h){if(!d[h]){var f= | |
| 70 | −a.getBindingHandler(h);f&&(f.after&&(e.push(h),a.a.q(f.after,function(c){if(b[c]){if(-1!==a.a.o(e,c))throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+e.join(", "));Z(c)}}),e.length--),c.push({key:h,fc:f}));d[h]=!0}});return c}function m(b,d,e,h){var m=a.a.e.get(b,q);if(!d){if(m)throw Error("You cannot apply bindings multiple times to the same element.");a.a.e.set(b,q,!0)}!m&&h&&a.tc(b,e);var g;if(d&&"function"!==typeof d)g=d;else{var k=a.Q.instance,r=k.getBindingAccessors|| | |
| 71 | −f,p=a.B(function(){(g=d?d(e,b):r.call(k,b,e))&&e.P&&e.P();return g},null,{i:b});g&&p.ba()||(p=null)}var u;if(g){var v=p?function(a){return function(){return c(p()[a])}}:function(a){return g[a]},s=function(){return a.a.Ca(p?p():g,c)};s.get=function(a){return g[a]&&c(v(a))};s.has=function(a){return a in g};h=l(g);a.a.q(h,function(c){var d=c.fc.init,h=c.fc.update,f=c.key;if(8===b.nodeType&&!a.f.Z[f])throw Error("The binding '"+f+"' cannot be used with virtual elements");try{"function"==typeof d&&a.l.w(function(){var a= | |
| 72 | −d(b,v(f),s,e.$data,e);if(a&&a.controlsDescendantBindings){if(u!==n)throw Error("Multiple bindings ("+u+" and "+f+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");u=f}}),"function"==typeof h&&a.B(function(){h(b,v(f),s,e.$data,e)},null,{i:b})}catch(m){throw m.message='Unable to process binding "'+f+": "+g[f]+'"\nMessage: '+m.message,m;}})}return{shouldBindDescendants:u===n}}function h(b){return b&&b instanceof a.U?b:new a.U(b)} | |
| 73 | −a.d={};var r={script:!0,textarea:!0,template:!0};a.getBindingHandler=function(b){return a.d[b]};a.U=function(b,c,d,e){var h=this,f="function"==typeof b&&!a.H(b),m,g=a.B(function(){var m=f?b():b,l=a.a.c(m);c?(c.P&&c.P(),a.a.extend(h,c),g&&(h.P=g)):(h.$parents=[],h.$root=l,h.ko=a);h.$rawData=m;h.$data=l;d&&(h[d]=l);e&&e(h,c,l);return h.$data},null,{wa:function(){return m&&!a.a.Qb(m)},i:!0});g.ba()&&(h.P=g,g.equalityComparer=null,m=[],g.Ac=function(b){m.push(b);a.a.F.oa(b,function(b){a.a.La(m,b);m.length|| | |
| 74 | −(g.k(),h.P=g=n)})})};a.U.prototype.createChildContext=function(b,c,d){return new a.U(b,this,c,function(a,b){a.$parentContext=b;a.$parent=b.$data;a.$parents=(b.$parents||[]).slice(0);a.$parents.unshift(a.$parent);d&&d(a)})};a.U.prototype.extend=function(b){return new a.U(this.P||this.$data,this,null,function(c,d){c.$rawData=d.$rawData;a.a.extend(c,"function"==typeof b?b():b)})};var q=a.a.e.I(),p=a.a.e.I();a.tc=function(b,c){if(2==arguments.length)a.a.e.set(b,p,c),c.P&&c.P.Ac(b);else return a.a.e.get(b, | |
| 75 | −p)};a.Ja=function(b,c,d){1===b.nodeType&&a.f.kc(b);return m(b,c,h(d),!0)};a.Dc=function(b,c,d){d=h(d);return a.Ja(b,e(c,d,b),d)};a.eb=function(a,b){1!==b.nodeType&&8!==b.nodeType||g(h(a),b,!0)};a.Rb=function(a,b){!v&&x.jQuery&&(v=x.jQuery);if(b&&1!==b.nodeType&&8!==b.nodeType)throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");b=b||x.document.body;k(h(a),b,!0)};a.kb=function(b){switch(b.nodeType){case 1:case 8:var c=a.tc(b);if(c)return c; | |
| 76 | −if(b.parentNode)return a.kb(b.parentNode)}return n};a.Jc=function(b){return(b=a.kb(b))?b.$data:n};a.b("bindingHandlers",a.d);a.b("applyBindings",a.Rb);a.b("applyBindingsToDescendants",a.eb);a.b("applyBindingAccessorsToNode",a.Ja);a.b("applyBindingsToNode",a.Dc);a.b("contextFor",a.kb);a.b("dataFor",a.Jc)})();(function(b){function c(c,e){var m=f.hasOwnProperty(c)?f[c]:b,h;m?m.X(e):(m=f[c]=new a.J,m.X(e),d(c,function(b,d){var e=!(!d||!d.synchronous);g[c]={definition:b,Zc:e};delete f[c];h||e?m.notifySubscribers(b): | |
| 77 | −a.Y.Wa(function(){m.notifySubscribers(b)})}),h=!0)}function d(a,b){e("getConfig",[a],function(c){c?e("loadComponent",[a,c],function(a){b(a,c)}):b(null,null)})}function e(c,d,f,h){h||(h=a.g.loaders.slice(0));var g=h.shift();if(g){var q=g[c];if(q){var p=!1;if(q.apply(g,d.concat(function(a){p?f(null):null!==a?f(a):e(c,d,f,h)}))!==b&&(p=!0,!g.suppressLoaderExceptions))throw Error("Component loaders must supply values by invoking the callback, not by returning values synchronously.");}else e(c,d,f,h)}else f(null)} | |
| 78 | −var f={},g={};a.g={get:function(d,e){var f=g.hasOwnProperty(d)?g[d]:b;f?f.Zc?a.l.w(function(){e(f.definition)}):a.Y.Wa(function(){e(f.definition)}):c(d,e)},Xb:function(a){delete g[a]},Jb:e};a.g.loaders=[];a.b("components",a.g);a.b("components.get",a.g.get);a.b("components.clearCachedDefinition",a.g.Xb)})();(function(){function b(b,c,d,e){function g(){0===--y&&e(k)}var k={},y=2,t=d.template;d=d.viewModel;t?f(c,t,function(c){a.g.Jb("loadTemplate",[b,c],function(a){k.template=a;g()})}):g();d?f(c,d,function(c){a.g.Jb("loadViewModel", | |
| 79 | −[b,c],function(a){k[l]=a;g()})}):g()}function c(a,b,d){if("function"===typeof b)d(function(a){return new b(a)});else if("function"===typeof b[l])d(b[l]);else if("instance"in b){var e=b.instance;d(function(){return e})}else"viewModel"in b?c(a,b.viewModel,d):a("Unknown viewModel value: "+b)}function d(b){switch(a.a.A(b)){case "script":return a.a.ma(b.text);case "textarea":return a.a.ma(b.value);case "template":if(e(b.content))return a.a.ua(b.content.childNodes)}return a.a.ua(b.childNodes)}function e(a){return x.DocumentFragment? | |
| 80 | −a instanceof DocumentFragment:a&&11===a.nodeType}function f(a,b,c){"string"===typeof b.require?O||x.require?(O||x.require)([b.require],c):a("Uses require, but no AMD loader is present"):c(b)}function g(a){return function(b){throw Error("Component '"+a+"': "+b);}}var k={};a.g.register=function(b,c){if(!c)throw Error("Invalid configuration for "+b);if(a.g.ub(b))throw Error("Component "+b+" is already registered");k[b]=c};a.g.ub=function(a){return k.hasOwnProperty(a)};a.g.od=function(b){delete k[b]; | |
| 81 | −a.g.Xb(b)};a.g.Zb={getConfig:function(a,b){b(k.hasOwnProperty(a)?k[a]:null)},loadComponent:function(a,c,d){var e=g(a);f(e,c,function(c){b(a,e,c,d)})},loadTemplate:function(b,c,f){b=g(b);if("string"===typeof c)f(a.a.ma(c));else if(c instanceof Array)f(c);else if(e(c))f(a.a.V(c.childNodes));else if(c.element)if(c=c.element,x.HTMLElement?c instanceof HTMLElement:c&&c.tagName&&1===c.nodeType)f(d(c));else if("string"===typeof c){var l=u.getElementById(c);l?f(d(l)):b("Cannot find element with ID "+c)}else b("Unknown element type: "+ | |
| 82 | −c);else b("Unknown template value: "+c)},loadViewModel:function(a,b,d){c(g(a),b,d)}};var l="createViewModel";a.b("components.register",a.g.register);a.b("components.isRegistered",a.g.ub);a.b("components.unregister",a.g.od);a.b("components.defaultLoader",a.g.Zb);a.g.loaders.push(a.g.Zb);a.g.Bc=k})();(function(){function b(b,e){var f=b.getAttribute("params");if(f){var f=c.parseBindingsString(f,e,b,{valueAccessors:!0,bindingParams:!0}),f=a.a.Ca(f,function(c){return a.m(c,null,{i:b})}),g=a.a.Ca(f,function(c){var e= | |
| 83 | −c.t();return c.ba()?a.m({read:function(){return a.a.c(c())},write:a.Ba(e)&&function(a){c()(a)},i:b}):e});g.hasOwnProperty("$raw")||(g.$raw=f);return g}return{$raw:{}}}a.g.getComponentNameForNode=function(b){var c=a.a.A(b);if(a.g.ub(c)&&(-1!=c.indexOf("-")||"[object HTMLUnknownElement]"==""+b||8>=a.a.C&&b.tagName===c))return c};a.g.Ob=function(c,e,f,g){if(1===e.nodeType){var k=a.g.getComponentNameForNode(e);if(k){c=c||{};if(c.component)throw Error('Cannot use the "component" binding on a custom element matching a component'); | |
| 84 | −var l={name:k,params:b(e,f)};c.component=g?function(){return l}:l}}return c};var c=new a.Q;9>a.a.C&&(a.g.register=function(a){return function(b){u.createElement(b);return a.apply(this,arguments)}}(a.g.register),u.createDocumentFragment=function(b){return function(){var c=b(),f=a.g.Bc,g;for(g in f)f.hasOwnProperty(g)&&c.createElement(g);return c}}(u.createDocumentFragment))})();(function(b){function c(b,c,d){c=c.template;if(!c)throw Error("Component '"+b+"' has no template");b=a.a.ua(c);a.f.da(d,b)} | |
| 85 | −function d(a,b,c,d){var e=a.createViewModel;return e?e.call(a,d,{element:b,templateNodes:c}):d}var e=0;a.d.component={init:function(f,g,k,l,m){function h(){var a=r&&r.dispose;"function"===typeof a&&a.call(r);q=r=null}var r,q,p=a.a.V(a.f.childNodes(f));a.a.F.oa(f,h);a.m(function(){var l=a.a.c(g()),k,t;"string"===typeof l?k=l:(k=a.a.c(l.name),t=a.a.c(l.params));if(!k)throw Error("No component name specified");var n=q=++e;a.g.get(k,function(e){if(q===n){h();if(!e)throw Error("Unknown component '"+k+ | |
| 86 | −"'");c(k,e,f);var g=d(e,f,p,t);e=m.createChildContext(g,b,function(a){a.$component=g;a.$componentTemplateNodes=p});r=g;a.eb(e,f)}})},null,{i:f});return{controlsDescendantBindings:!0}}};a.f.Z.component=!0})();var S={"class":"className","for":"htmlFor"};a.d.attr={update:function(b,c){var d=a.a.c(c())||{};a.a.D(d,function(c,d){d=a.a.c(d);var g=!1===d||null===d||d===n;g&&b.removeAttribute(c);8>=a.a.C&&c in S?(c=S[c],g?b.removeAttribute(c):b[c]=d):g||b.setAttribute(c,d.toString());"name"===c&&a.a.rc(b, | |
| 87 | −g?"":d.toString())})}};(function(){a.d.checked={after:["value","attr"],init:function(b,c,d){function e(){var e=b.checked,f=p?g():e;if(!a.va.Sa()&&(!l||e)){var m=a.l.w(c);if(h){var k=r?m.t():m;q!==f?(e&&(a.a.pa(k,f,!0),a.a.pa(k,q,!1)),q=f):a.a.pa(k,f,e);r&&a.Ba(m)&&m(k)}else a.h.Ea(m,d,"checked",f,!0)}}function f(){var d=a.a.c(c());b.checked=h?0<=a.a.o(d,g()):k?d:g()===d}var g=a.nc(function(){return d.has("checkedValue")?a.a.c(d.get("checkedValue")):d.has("value")?a.a.c(d.get("value")):b.value}),k= | |
| 88 | −"checkbox"==b.type,l="radio"==b.type;if(k||l){var m=c(),h=k&&a.a.c(m)instanceof Array,r=!(h&&m.push&&m.splice),q=h?g():n,p=l||h;l&&!b.name&&a.d.uniqueName.init(b,function(){return!0});a.m(e,null,{i:b});a.a.p(b,"click",e);a.m(f,null,{i:b});m=n}}};a.h.ea.checked=!0;a.d.checkedValue={update:function(b,c){b.value=a.a.c(c())}}})();a.d.css={update:function(b,c){var d=a.a.c(c());null!==d&&"object"==typeof d?a.a.D(d,function(c,d){d=a.a.c(d);a.a.bb(b,c,d)}):(d=a.a.$a(String(d||"")),a.a.bb(b,b.__ko__cssValue, | |
| 89 | −!1),b.__ko__cssValue=d,a.a.bb(b,d,!0))}};a.d.enable={update:function(b,c){var d=a.a.c(c());d&&b.disabled?b.removeAttribute("disabled"):d||b.disabled||(b.disabled=!0)}};a.d.disable={update:function(b,c){a.d.enable.update(b,function(){return!a.a.c(c())})}};a.d.event={init:function(b,c,d,e,f){var g=c()||{};a.a.D(g,function(g){"string"==typeof g&&a.a.p(b,g,function(b){var m,h=c()[g];if(h){try{var r=a.a.V(arguments);e=f.$data;r.unshift(e);m=h.apply(e,r)}finally{!0!==m&&(b.preventDefault?b.preventDefault(): | |
| 90 | −b.returnValue=!1)}!1===d.get(g+"Bubble")&&(b.cancelBubble=!0,b.stopPropagation&&b.stopPropagation())}})})}};a.d.foreach={ic:function(b){return function(){var c=b(),d=a.a.zb(c);if(!d||"number"==typeof d.length)return{foreach:c,templateEngine:a.W.sb};a.a.c(c);return{foreach:d.data,as:d.as,includeDestroyed:d.includeDestroyed,afterAdd:d.afterAdd,beforeRemove:d.beforeRemove,afterRender:d.afterRender,beforeMove:d.beforeMove,afterMove:d.afterMove,templateEngine:a.W.sb}}},init:function(b,c){return a.d.template.init(b, | |
| 91 | −a.d.foreach.ic(c))},update:function(b,c,d,e,f){return a.d.template.update(b,a.d.foreach.ic(c),d,e,f)}};a.h.ta.foreach=!1;a.f.Z.foreach=!0;a.d.hasfocus={init:function(b,c,d){function e(e){b.__ko_hasfocusUpdating=!0;var f=b.ownerDocument;if("activeElement"in f){var g;try{g=f.activeElement}catch(h){g=f.body}e=g===b}f=c();a.h.Ea(f,d,"hasfocus",e,!0);b.__ko_hasfocusLastValue=e;b.__ko_hasfocusUpdating=!1}var f=e.bind(null,!0),g=e.bind(null,!1);a.a.p(b,"focus",f);a.a.p(b,"focusin",f);a.a.p(b,"blur",g);a.a.p(b, | |
| 92 | −"focusout",g)},update:function(b,c){var d=!!a.a.c(c());b.__ko_hasfocusUpdating||b.__ko_hasfocusLastValue===d||(d?b.focus():b.blur(),!d&&b.__ko_hasfocusLastValue&&b.ownerDocument.body.focus(),a.l.w(a.a.Da,null,[b,d?"focusin":"focusout"]))}};a.h.ea.hasfocus=!0;a.d.hasFocus=a.d.hasfocus;a.h.ea.hasFocus=!0;a.d.html={init:function(){return{controlsDescendantBindings:!0}},update:function(b,c){a.a.Cb(b,c())}};K("if");K("ifnot",!1,!0);K("with",!0,!1,function(a,c){return a.createChildContext(c)});var L={}; | |
| 93 | −a.d.options={init:function(b){if("select"!==a.a.A(b))throw Error("options binding applies only to SELECT elements");for(;0<b.length;)b.remove(0);return{controlsDescendantBindings:!0}},update:function(b,c,d){function e(){return a.a.Ka(b.options,function(a){return a.selected})}function f(a,b,c){var d=typeof b;return"function"==d?b(a):"string"==d?a[b]:c}function g(c,e){if(A&&h)a.j.ha(b,a.a.c(d.get("value")),!0);else if(p.length){var f=0<=a.a.o(p,a.j.u(e[0]));a.a.sc(e[0],f);A&&!f&&a.l.w(a.a.Da,null,[b, | |
| 94 | −"change"])}}var k=b.multiple,l=0!=b.length&&k?b.scrollTop:null,m=a.a.c(c()),h=d.get("valueAllowUnset")&&d.has("value"),r=d.get("optionsIncludeDestroyed");c={};var q,p=[];h||(k?p=a.a.fb(e(),a.j.u):0<=b.selectedIndex&&p.push(a.j.u(b.options[b.selectedIndex])));m&&("undefined"==typeof m.length&&(m=[m]),q=a.a.Ka(m,function(b){return r||b===n||null===b||!a.a.c(b._destroy)}),d.has("optionsCaption")&&(m=a.a.c(d.get("optionsCaption")),null!==m&&m!==n&&q.unshift(L)));var A=!1;c.beforeRemove=function(a){b.removeChild(a)}; | |
| 95 | −m=g;d.has("optionsAfterRender")&&"function"==typeof d.get("optionsAfterRender")&&(m=function(b,c){g(0,c);a.l.w(d.get("optionsAfterRender"),null,[c[0],b!==L?b:n])});a.a.Bb(b,q,function(c,e,g){g.length&&(p=!h&&g[0].selected?[a.j.u(g[0])]:[],A=!0);e=b.ownerDocument.createElement("option");c===L?(a.a.Za(e,d.get("optionsCaption")),a.j.ha(e,n)):(g=f(c,d.get("optionsValue"),c),a.j.ha(e,a.a.c(g)),c=f(c,d.get("optionsText"),g),a.a.Za(e,c));return[e]},c,m);a.l.w(function(){h?a.j.ha(b,a.a.c(d.get("value")), | |
| 96 | −!0):(k?p.length&&e().length<p.length:p.length&&0<=b.selectedIndex?a.j.u(b.options[b.selectedIndex])!==p[0]:p.length||0<=b.selectedIndex)&&a.a.Da(b,"change")});a.a.Nc(b);l&&20<Math.abs(l-b.scrollTop)&&(b.scrollTop=l)}};a.d.options.xb=a.a.e.I();a.d.selectedOptions={after:["options","foreach"],init:function(b,c,d){a.a.p(b,"change",function(){var e=c(),f=[];a.a.q(b.getElementsByTagName("option"),function(b){b.selected&&f.push(a.j.u(b))});a.h.Ea(e,d,"selectedOptions",f)})},update:function(b,c){if("select"!= | |
| 97 | −a.a.A(b))throw Error("values binding applies only to SELECT elements");var d=a.a.c(c()),e=b.scrollTop;d&&"number"==typeof d.length&&a.a.q(b.getElementsByTagName("option"),function(b){var c=0<=a.a.o(d,a.j.u(b));b.selected!=c&&a.a.sc(b,c)});b.scrollTop=e}};a.h.ea.selectedOptions=!0;a.d.style={update:function(b,c){var d=a.a.c(c()||{});a.a.D(d,function(c,d){d=a.a.c(d);if(null===d||d===n||!1===d)d="";b.style[c]=d})}};a.d.submit={init:function(b,c,d,e,f){if("function"!=typeof c())throw Error("The value for a submit binding must be a function"); | |
| 98 | −a.a.p(b,"submit",function(a){var d,e=c();try{d=e.call(f.$data,b)}finally{!0!==d&&(a.preventDefault?a.preventDefault():a.returnValue=!1)}})}};a.d.text={init:function(){return{controlsDescendantBindings:!0}},update:function(b,c){a.a.Za(b,c())}};a.f.Z.text=!0;(function(){if(x&&x.navigator)var b=function(a){if(a)return parseFloat(a[1])},c=x.opera&&x.opera.version&&parseInt(x.opera.version()),d=x.navigator.userAgent,e=b(d.match(/^(?:(?!chrome).)*version\/([^ ]*) safari/i)),f=b(d.match(/Firefox\/([^ ]*)/)); | |
| 99 | −if(10>a.a.C)var g=a.a.e.I(),k=a.a.e.I(),l=function(b){var c=this.activeElement;(c=c&&a.a.e.get(c,k))&&c(b)},m=function(b,c){var d=b.ownerDocument;a.a.e.get(d,g)||(a.a.e.set(d,g,!0),a.a.p(d,"selectionchange",l));a.a.e.set(b,k,c)};a.d.textInput={init:function(b,d,g){function l(c,d){a.a.p(b,c,d)}function k(){var c=a.a.c(d());if(null===c||c===n)c="";v!==n&&c===v?a.a.setTimeout(k,4):b.value!==c&&(u=c,b.value=c)}function y(){s||(v=b.value,s=a.a.setTimeout(t,4))}function t(){clearTimeout(s);v=s=n;var c= | |
| 100 | −b.value;u!==c&&(u=c,a.h.Ea(d(),g,"textInput",c))}var u=b.value,s,v,x=9==a.a.C?y:t;10>a.a.C?(l("propertychange",function(a){"value"===a.propertyName&&x(a)}),8==a.a.C&&(l("keyup",t),l("keydown",t)),8<=a.a.C&&(m(b,x),l("dragend",y))):(l("input",t),5>e&&"textarea"===a.a.A(b)?(l("keydown",y),l("paste",y),l("cut",y)):11>c?l("keydown",y):4>f&&(l("DOMAutoComplete",t),l("dragdrop",t),l("drop",t)));l("change",t);a.m(k,null,{i:b})}};a.h.ea.textInput=!0;a.d.textinput={preprocess:function(a,b,c){c("textInput", | |
| 101 | −a)}}})();a.d.uniqueName={init:function(b,c){if(c()){var d="ko_unique_"+ ++a.d.uniqueName.Ic;a.a.rc(b,d)}}};a.d.uniqueName.Ic=0;a.d.value={after:["options","foreach"],init:function(b,c,d){if("input"!=b.tagName.toLowerCase()||"checkbox"!=b.type&&"radio"!=b.type){var e=["change"],f=d.get("valueUpdate"),g=!1,k=null;f&&("string"==typeof f&&(f=[f]),a.a.ra(e,f),e=a.a.Tb(e));var l=function(){k=null;g=!1;var e=c(),f=a.j.u(b);a.h.Ea(e,d,"value",f)};!a.a.C||"input"!=b.tagName.toLowerCase()||"text"!=b.type|| | |
| 102 | −"off"==b.autocomplete||b.form&&"off"==b.form.autocomplete||-1!=a.a.o(e,"propertychange")||(a.a.p(b,"propertychange",function(){g=!0}),a.a.p(b,"focus",function(){g=!1}),a.a.p(b,"blur",function(){g&&l()}));a.a.q(e,function(c){var d=l;a.a.nd(c,"after")&&(d=function(){k=a.j.u(b);a.a.setTimeout(l,0)},c=c.substring(5));a.a.p(b,c,d)});var m=function(){var e=a.a.c(c()),f=a.j.u(b);if(null!==k&&e===k)a.a.setTimeout(m,0);else if(e!==f)if("select"===a.a.A(b)){var g=d.get("valueAllowUnset"),f=function(){a.j.ha(b, | |
| 103 | −e,g)};f();g||e===a.j.u(b)?a.a.setTimeout(f,0):a.l.w(a.a.Da,null,[b,"change"])}else a.j.ha(b,e)};a.m(m,null,{i:b})}else a.Ja(b,{checkedValue:c})},update:function(){}};a.h.ea.value=!0;a.d.visible={update:function(b,c){var d=a.a.c(c()),e="none"!=b.style.display;d&&!e?b.style.display="":!d&&e&&(b.style.display="none")}};(function(b){a.d[b]={init:function(c,d,e,f,g){return a.d.event.init.call(this,c,function(){var a={};a[b]=d();return a},e,f,g)}}})("click");a.O=function(){};a.O.prototype.renderTemplateSource= | |
| 104 | −function(){throw Error("Override renderTemplateSource");};a.O.prototype.createJavaScriptEvaluatorBlock=function(){throw Error("Override createJavaScriptEvaluatorBlock");};a.O.prototype.makeTemplateSource=function(b,c){if("string"==typeof b){c=c||u;var d=c.getElementById(b);if(!d)throw Error("Cannot find template with ID "+b);return new a.v.n(d)}if(1==b.nodeType||8==b.nodeType)return new a.v.qa(b);throw Error("Unknown template type: "+b);};a.O.prototype.renderTemplate=function(a,c,d,e){a=this.makeTemplateSource(a, | |
| 105 | −e);return this.renderTemplateSource(a,c,d,e)};a.O.prototype.isTemplateRewritten=function(a,c){return!1===this.allowTemplateRewriting?!0:this.makeTemplateSource(a,c).data("isRewritten")};a.O.prototype.rewriteTemplate=function(a,c,d){a=this.makeTemplateSource(a,d);c=c(a.text());a.text(c);a.data("isRewritten",!0)};a.b("templateEngine",a.O);a.Gb=function(){function b(b,c,d,k){b=a.h.yb(b);for(var l=a.h.ta,m=0;m<b.length;m++){var h=b[m].key;if(l.hasOwnProperty(h)){var r=l[h];if("function"===typeof r){if(h= | |
| 106 | −r(b[m].value))throw Error(h);}else if(!r)throw Error("This template engine does not support the '"+h+"' binding within its templates");}}d="ko.__tr_ambtns(function($context,$element){return(function(){return{ "+a.h.Ua(b,{valueAccessors:!0})+" } })()},'"+d.toLowerCase()+"')";return k.createJavaScriptEvaluatorBlock(d)+c}var c=/(<([a-z]+\d*)(?:\s+(?!data-bind\s*=\s*)[a-z0-9\-]+(?:=(?:\"[^\"]*\"|\'[^\']*\'|[^>]*))?)*\s+)data-bind\s*=\s*(["'])([\s\S]*?)\3/gi,d=/\x3c!--\s*ko\b\s*([\s\S]*?)\s*--\x3e/g;return{Oc:function(b, | |
| 107 | −c,d){c.isTemplateRewritten(b,d)||c.rewriteTemplate(b,function(b){return a.Gb.dd(b,c)},d)},dd:function(a,f){return a.replace(c,function(a,c,d,e,h){return b(h,c,d,f)}).replace(d,function(a,c){return b(c,"\x3c!-- ko --\x3e","#comment",f)})},Ec:function(b,c){return a.M.wb(function(d,k){var l=d.nextSibling;l&&l.nodeName.toLowerCase()===c&&a.Ja(l,b,k)})}}}();a.b("__tr_ambtns",a.Gb.Ec);(function(){a.v={};a.v.n=function(b){if(this.n=b){var c=a.a.A(b);this.ab="script"===c?1:"textarea"===c?2:"template"==c&& | |
| 108 | −b.content&&11===b.content.nodeType?3:4}};a.v.n.prototype.text=function(){var b=1===this.ab?"text":2===this.ab?"value":"innerHTML";if(0==arguments.length)return this.n[b];var c=arguments[0];"innerHTML"===b?a.a.Cb(this.n,c):this.n[b]=c};var b=a.a.e.I()+"_";a.v.n.prototype.data=function(c){if(1===arguments.length)return a.a.e.get(this.n,b+c);a.a.e.set(this.n,b+c,arguments[1])};var c=a.a.e.I();a.v.n.prototype.nodes=function(){var b=this.n;if(0==arguments.length)return(a.a.e.get(b,c)||{}).jb||(3===this.ab? | |
| 109 | −b.content:4===this.ab?b:n);a.a.e.set(b,c,{jb:arguments[0]})};a.v.qa=function(a){this.n=a};a.v.qa.prototype=new a.v.n;a.v.qa.prototype.text=function(){if(0==arguments.length){var b=a.a.e.get(this.n,c)||{};b.Hb===n&&b.jb&&(b.Hb=b.jb.innerHTML);return b.Hb}a.a.e.set(this.n,c,{Hb:arguments[0]})};a.b("templateSources",a.v);a.b("templateSources.domElement",a.v.n);a.b("templateSources.anonymousTemplate",a.v.qa)})();(function(){function b(b,c,d){var e;for(c=a.f.nextSibling(c);b&&(e=b)!==c;)b=a.f.nextSibling(e), | |
| 110 | −d(e,b)}function c(c,d){if(c.length){var e=c[0],f=c[c.length-1],g=e.parentNode,k=a.Q.instance,n=k.preprocessNode;if(n){b(e,f,function(a,b){var c=a.previousSibling,d=n.call(k,a);d&&(a===e&&(e=d[0]||b),a===f&&(f=d[d.length-1]||c))});c.length=0;if(!e)return;e===f?c.push(e):(c.push(e,f),a.a.za(c,g))}b(e,f,function(b){1!==b.nodeType&&8!==b.nodeType||a.Rb(d,b)});b(e,f,function(b){1!==b.nodeType&&8!==b.nodeType||a.M.yc(b,[d])});a.a.za(c,g)}}function d(a){return a.nodeType?a:0<a.length?a[0]:null}function e(b, | |
| 111 | −e,f,k,q){q=q||{};var p=(b&&d(b)||f||{}).ownerDocument,n=q.templateEngine||g;a.Gb.Oc(f,n,p);f=n.renderTemplate(f,k,q,p);if("number"!=typeof f.length||0<f.length&&"number"!=typeof f[0].nodeType)throw Error("Template engine must return an array of DOM nodes");p=!1;switch(e){case "replaceChildren":a.f.da(b,f);p=!0;break;case "replaceNode":a.a.qc(b,f);p=!0;break;case "ignoreTargetNode":break;default:throw Error("Unknown renderMode: "+e);}p&&(c(f,k),q.afterRender&&a.l.w(q.afterRender,null,[f,k.$data])); | |
| 112 | −return f}function f(b,c,d){return a.H(b)?b():"function"===typeof b?b(c,d):b}var g;a.Db=function(b){if(b!=n&&!(b instanceof a.O))throw Error("templateEngine must inherit from ko.templateEngine");g=b};a.Ab=function(b,c,h,k,q){h=h||{};if((h.templateEngine||g)==n)throw Error("Set a template engine before calling renderTemplate");q=q||"replaceChildren";if(k){var p=d(k);return a.B(function(){var g=c&&c instanceof a.U?c:new a.U(a.a.c(c)),n=f(b,g.$data,g),g=e(k,q,n,g,h);"replaceNode"==q&&(k=g,p=d(k))},null, | |
| 113 | −{wa:function(){return!p||!a.a.nb(p)},i:p&&"replaceNode"==q?p.parentNode:p})}return a.M.wb(function(d){a.Ab(b,c,h,d,"replaceNode")})};a.kd=function(b,d,g,k,q){function p(a,b){c(b,s);g.afterRender&&g.afterRender(b,a);s=null}function u(a,c){s=q.createChildContext(a,g.as,function(a){a.$index=c});var d=f(b,a,s);return e(null,"ignoreTargetNode",d,s,g)}var s;return a.B(function(){var b=a.a.c(d)||[];"undefined"==typeof b.length&&(b=[b]);b=a.a.Ka(b,function(b){return g.includeDestroyed||b===n||null===b||!a.a.c(b._destroy)}); | |
| 114 | −a.l.w(a.a.Bb,null,[k,b,u,g,p])},null,{i:k})};var k=a.a.e.I();a.d.template={init:function(b,c){var d=a.a.c(c());if("string"==typeof d||d.name)a.f.xa(b);else{if("nodes"in d){if(d=d.nodes||[],a.H(d))throw Error('The "nodes" option must be a plain, non-observable array.');}else d=a.f.childNodes(b);d=a.a.jc(d);(new a.v.qa(b)).nodes(d)}return{controlsDescendantBindings:!0}},update:function(b,c,d,e,f){var g=c(),s;c=a.a.c(g);d=!0;e=null;"string"==typeof c?c={}:(g=c.name,"if"in c&&(d=a.a.c(c["if"])),d&&"ifnot"in | |
| 115 | −c&&(d=!a.a.c(c.ifnot)),s=a.a.c(c.data));"foreach"in c?e=a.kd(g||b,d&&c.foreach||[],c,b,f):d?(f="data"in c?f.createChildContext(s,c.as):f,e=a.Ab(g||b,f,c,b)):a.f.xa(b);f=e;(s=a.a.e.get(b,k))&&"function"==typeof s.k&&s.k();a.a.e.set(b,k,f&&f.ba()?f:n)}};a.h.ta.template=function(b){b=a.h.yb(b);return 1==b.length&&b[0].unknown||a.h.ad(b,"name")?null:"This template engine does not support anonymous templates nested within its templates"};a.f.Z.template=!0})();a.b("setTemplateEngine",a.Db);a.b("renderTemplate", | |
| 116 | −a.Ab);a.a.dc=function(a,c,d){if(a.length&&c.length){var e,f,g,k,l;for(e=f=0;(!d||e<d)&&(k=a[f]);++f){for(g=0;l=c[g];++g)if(k.value===l.value){k.moved=l.index;l.moved=k.index;c.splice(g,1);e=g=0;break}e+=g}}};a.a.ib=function(){function b(b,d,e,f,g){var k=Math.min,l=Math.max,m=[],h,n=b.length,q,p=d.length,s=p-n||1,u=n+p+1,t,v,x;for(h=0;h<=n;h++)for(v=t,m.push(t=[]),x=k(p,h+s),q=l(0,h-1);q<=x;q++)t[q]=q?h?b[h-1]===d[q-1]?v[q-1]:k(v[q]||u,t[q-1]||u)+1:q+1:h+1;k=[];l=[];s=[];h=n;for(q=p;h||q;)p=m[h][q]- | |
| 117 | −1,q&&p===m[h][q-1]?l.push(k[k.length]={status:e,value:d[--q],index:q}):h&&p===m[h-1][q]?s.push(k[k.length]={status:f,value:b[--h],index:h}):(--q,--h,g.sparse||k.push({status:"retained",value:d[q]}));a.a.dc(s,l,!g.dontLimitMoves&&10*n);return k.reverse()}return function(a,d,e){e="boolean"===typeof e?{dontLimitMoves:e}:e||{};a=a||[];d=d||[];return a.length<d.length?b(a,d,"added","deleted",e):b(d,a,"deleted","added",e)}}();a.b("utils.compareArrays",a.a.ib);(function(){function b(b,c,d,k,l){var m=[], | |
| 118 | −h=a.B(function(){var h=c(d,l,a.a.za(m,b))||[];0<m.length&&(a.a.qc(m,h),k&&a.l.w(k,null,[d,h,l]));m.length=0;a.a.ra(m,h)},null,{i:b,wa:function(){return!a.a.Qb(m)}});return{ca:m,B:h.ba()?h:n}}var c=a.a.e.I(),d=a.a.e.I();a.a.Bb=function(e,f,g,k,l){function m(b,c){w=q[c];v!==c&&(D[b]=w);w.qb(v++);a.a.za(w.ca,e);u.push(w);z.push(w)}function h(b,c){if(b)for(var d=0,e=c.length;d<e;d++)c[d]&&a.a.q(c[d].ca,function(a){b(a,d,c[d].ja)})}f=f||[];k=k||{};var r=a.a.e.get(e,c)===n,q=a.a.e.get(e,c)||[],p=a.a.fb(q, | |
| 119 | −function(a){return a.ja}),s=a.a.ib(p,f,k.dontLimitMoves),u=[],t=0,v=0,x=[],z=[];f=[];for(var D=[],p=[],w,C=0,B,E;B=s[C];C++)switch(E=B.moved,B.status){case "deleted":E===n&&(w=q[t],w.B&&(w.B.k(),w.B=n),a.a.za(w.ca,e).length&&(k.beforeRemove&&(u.push(w),z.push(w),w.ja===d?w=null:f[C]=w),w&&x.push.apply(x,w.ca)));t++;break;case "retained":m(C,t++);break;case "added":E!==n?m(C,E):(w={ja:B.value,qb:a.N(v++)},u.push(w),z.push(w),r||(p[C]=w))}a.a.e.set(e,c,u);h(k.beforeMove,D);a.a.q(x,k.beforeRemove?a.$: | |
| 120 | −a.removeNode);for(var C=0,r=a.f.firstChild(e),F;w=z[C];C++){w.ca||a.a.extend(w,b(e,g,w.ja,l,w.qb));for(t=0;s=w.ca[t];r=s.nextSibling,F=s,t++)s!==r&&a.f.gc(e,s,F);!w.Wc&&l&&(l(w.ja,w.ca,w.qb),w.Wc=!0)}h(k.beforeRemove,f);for(C=0;C<f.length;++C)f[C]&&(f[C].ja=d);h(k.afterMove,D);h(k.afterAdd,p)}})();a.b("utils.setDomNodeChildrenFromArrayMapping",a.a.Bb);a.W=function(){this.allowTemplateRewriting=!1};a.W.prototype=new a.O;a.W.prototype.renderTemplateSource=function(b,c,d,e){if(c=(9>a.a.C?0:b.nodes)? | |
| 121 | −b.nodes():null)return a.a.V(c.cloneNode(!0).childNodes);b=b.text();return a.a.ma(b,e)};a.W.sb=new a.W;a.Db(a.W.sb);a.b("nativeTemplateEngine",a.W);(function(){a.vb=function(){var a=this.$c=function(){if(!v||!v.tmpl)return 0;try{if(0<=v.tmpl.tag.tmpl.open.toString().indexOf("__"))return 2}catch(a){}return 1}();this.renderTemplateSource=function(b,e,f,g){g=g||u;f=f||{};if(2>a)throw Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later.");var k=b.data("precompiled"); | |
| 122 | −k||(k=b.text()||"",k=v.template(null,"{{ko_with $item.koBindingContext}}"+k+"{{/ko_with}}"),b.data("precompiled",k));b=[e.$data];e=v.extend({koBindingContext:e},f.templateOptions);e=v.tmpl(k,b,e);e.appendTo(g.createElement("div"));v.fragments={};return e};this.createJavaScriptEvaluatorBlock=function(a){return"{{ko_code ((function() { return "+a+" })()) }}"};this.addTemplate=function(a,b){u.write("<script type='text/html' id='"+a+"'>"+b+"\x3c/script>")};0<a&&(v.tmpl.tag.ko_code={open:"__.push($1 || '');"}, | |
| 123 | −v.tmpl.tag.ko_with={open:"with($1) {",close:"} "})};a.vb.prototype=new a.O;var b=new a.vb;0<b.$c&&a.Db(b);a.b("jqueryTmplTemplateEngine",a.vb)})()})})();})(); | |
| @@ -1,21 +0,0 @@ | ||
| 1 | −/// Knockout Mapping plugin v2.4.0 | |
| 2 | −/// (c) 2013 Steven Sanderson, Roy Jacobs - http://knockoutjs.com/ | |
| 3 | −/// License: MIT (http://www.opensource.org/licenses/mit-license.php) | |
| 4 | −(function(d){"function"===typeof require&&"object"===typeof exports&&"object"===typeof module?d(require("knockout"),exports):"function"===typeof define&&define.amd?define(["knockout","exports"],d):d(ko,ko.mapping={})})(function(d,f){function y(b,c){var a,e;for(e in c)if(c.hasOwnProperty(e)&&c[e])if(a=f.getType(b[e]),e&&b[e]&&"array"!==a&&"string"!==a)y(b[e],c[e]);else if("array"===f.getType(b[e])&&"array"===f.getType(c[e])){a=b;for(var d=e,l=b[e],n=c[e],t={},g=l.length-1;0<=g;--g)t[l[g]]=l[g];for(g= | |
| 5 | −n.length-1;0<=g;--g)t[n[g]]=n[g];l=[];n=void 0;for(n in t)l.push(t[n]);a[d]=l}else b[e]=c[e]}function E(b,c){var a={};y(a,b);y(a,c);return a}function z(b,c){for(var a=E({},b),d=L.length-1;0<=d;d--){var f=L[d];a[f]&&(a[""]instanceof Object||(a[""]={}),a[""][f]=a[f],delete a[f])}c&&(a.ignore=h(c.ignore,a.ignore),a.include=h(c.include,a.include),a.copy=h(c.copy,a.copy),a.observe=h(c.observe,a.observe));a.ignore=h(a.ignore,j.ignore);a.include=h(a.include,j.include);a.copy=h(a.copy,j.copy);a.observe=h(a.observe, | |
| 6 | −j.observe);a.mappedProperties=a.mappedProperties||{};a.copiedProperties=a.copiedProperties||{};return a}function h(b,c){"array"!==f.getType(b)&&(b="undefined"===f.getType(b)?[]:[b]);"array"!==f.getType(c)&&(c="undefined"===f.getType(c)?[]:[c]);return d.utils.arrayGetDistinctValues(b.concat(c))}function F(b,c,a,e,k,l,n){var t="array"===f.getType(d.utils.unwrapObservable(c));l=l||"";if(f.isMapped(b)){var g=d.utils.unwrapObservable(b)[p];a=E(g,a)}var j=n||k,h=function(){return a[e]&&a[e].create instanceof | |
| 7 | −Function},x=function(b){var f=G,g=d.dependentObservable;d.dependentObservable=function(a,b,c){c=c||{};a&&"object"==typeof a&&(c=a);var e=c.deferEvaluation,M=!1;c.deferEvaluation=!0;a=new H(a,b,c);if(!e){var g=a,e=d.dependentObservable;d.dependentObservable=H;a=d.isWriteableObservable(g);d.dependentObservable=e;a=H({read:function(){M||(d.utils.arrayRemoveItem(f,g),M=!0);return g.apply(g,arguments)},write:a&&function(a){return g(a)},deferEvaluation:!0});f.push(a)}return a};d.dependentObservable.fn= | |
| 8 | −H.fn;d.computed=d.dependentObservable;b=d.utils.unwrapObservable(k)instanceof Array?a[e].create({data:b||c,parent:j,skip:N}):a[e].create({data:b||c,parent:j});d.dependentObservable=g;d.computed=d.dependentObservable;return b},u=function(){return a[e]&&a[e].update instanceof Function},v=function(b,f){var g={data:f||c,parent:j,target:d.utils.unwrapObservable(b)};d.isWriteableObservable(b)&&(g.observable=b);return a[e].update(g)};if(n=I.get(c))return n;e=e||"";if(t){var t=[],s=!1,m=function(a){return a}; | |
| 9 | −a[e]&&a[e].key&&(m=a[e].key,s=!0);d.isObservable(b)||(b=d.observableArray([]),b.mappedRemove=function(a){var c="function"==typeof a?a:function(b){return b===m(a)};return b.remove(function(a){return c(m(a))})},b.mappedRemoveAll=function(a){var c=C(a,m);return b.remove(function(a){return-1!=d.utils.arrayIndexOf(c,m(a))})},b.mappedDestroy=function(a){var c="function"==typeof a?a:function(b){return b===m(a)};return b.destroy(function(a){return c(m(a))})},b.mappedDestroyAll=function(a){var c=C(a,m);return b.destroy(function(a){return-1!= | |
| 10 | −d.utils.arrayIndexOf(c,m(a))})},b.mappedIndexOf=function(a){var c=C(b(),m);a=m(a);return d.utils.arrayIndexOf(c,a)},b.mappedCreate=function(a){if(-1!==b.mappedIndexOf(a))throw Error("There already is an object with the key that you specified.");var c=h()?x(a):a;u()&&(a=v(c,a),d.isWriteableObservable(c)?c(a):c=a);b.push(c);return c});n=C(d.utils.unwrapObservable(b),m).sort();g=C(c,m);s&&g.sort();s=d.utils.compareArrays(n,g);n={};var J,A=d.utils.unwrapObservable(c),y={},z=!0,g=0;for(J=A.length;g<J;g++){var r= | |
| 11 | −m(A[g]);if(void 0===r||r instanceof Object){z=!1;break}y[r]=A[g]}var A=[],B=0,g=0;for(J=s.length;g<J;g++){var r=s[g],q,w=l+"["+g+"]";switch(r.status){case "added":var D=z?y[r.value]:K(d.utils.unwrapObservable(c),r.value,m);q=F(void 0,D,a,e,b,w,k);h()||(q=d.utils.unwrapObservable(q));w=O(d.utils.unwrapObservable(c),D,n);q===N?B++:A[w-B]=q;n[w]=!0;break;case "retained":D=z?y[r.value]:K(d.utils.unwrapObservable(c),r.value,m);q=K(b,r.value,m);F(q,D,a,e,b,w,k);w=O(d.utils.unwrapObservable(c),D,n);A[w]= | |
| 12 | −q;n[w]=!0;break;case "deleted":q=K(b,r.value,m)}t.push({event:r.status,item:q})}b(A);a[e]&&a[e].arrayChanged&&d.utils.arrayForEach(t,function(b){a[e].arrayChanged(b.event,b.item)})}else if(P(c)){b=d.utils.unwrapObservable(b);if(!b){if(h())return s=x(),u()&&(s=v(s)),s;if(u())return v(s);b={}}u()&&(b=v(b));I.save(c,b);if(u())return b;Q(c,function(e){var f=l.length?l+"."+e:e;if(-1==d.utils.arrayIndexOf(a.ignore,f))if(-1!=d.utils.arrayIndexOf(a.copy,f))b[e]=c[e];else if("object"!=typeof c[e]&&"array"!= | |
| 13 | −typeof c[e]&&0<a.observe.length&&-1==d.utils.arrayIndexOf(a.observe,f))b[e]=c[e],a.copiedProperties[f]=!0;else{var g=I.get(c[e]),k=F(b[e],c[e],a,e,b,f,b),g=g||k;if(0<a.observe.length&&-1==d.utils.arrayIndexOf(a.observe,f))b[e]=g(),a.copiedProperties[f]=!0;else{if(d.isWriteableObservable(b[e]))b[e](d.utils.unwrapObservable(g));else g=void 0===b[e]?g:d.utils.unwrapObservable(g),b[e]=g;a.mappedProperties[f]=!0}}})}else switch(f.getType(c)){case "function":u()?d.isWriteableObservable(c)?(c(v(c)),b=c): | |
| 14 | −b=v(c):b=c;break;default:if(d.isWriteableObservable(b))return q=u()?v(b):d.utils.unwrapObservable(c),b(q),q;h()||u();b=h()?x():d.observable(d.utils.unwrapObservable(c));u()&&b(v(b))}return b}function O(b,c,a){for(var e=0,d=b.length;e<d;e++)if(!0!==a[e]&&b[e]===c)return e;return null}function R(b,c){var a;c&&(a=c(b));"undefined"===f.getType(a)&&(a=b);return d.utils.unwrapObservable(a)}function K(b,c,a){b=d.utils.unwrapObservable(b);for(var e=0,f=b.length;e<f;e++){var l=b[e];if(R(l,a)===c)return l}throw Error("When calling ko.update*, the key '"+ | |
| 15 | −c+"' was not found!");}function C(b,c){return d.utils.arrayMap(d.utils.unwrapObservable(b),function(a){return c?R(a,c):a})}function Q(b,c){if("array"===f.getType(b))for(var a=0;a<b.length;a++)c(a);else for(a in b)c(a)}function P(b){var c=f.getType(b);return("object"===c||"array"===c)&&null!==b}function T(){var b=[],c=[];this.save=function(a,e){var f=d.utils.arrayIndexOf(b,a);0<=f?c[f]=e:(b.push(a),c.push(e))};this.get=function(a){a=d.utils.arrayIndexOf(b,a);return 0<=a?c[a]:void 0}}function S(){var b= | |
| 16 | −{},c=function(a){var c;try{c=a}catch(d){c="$$$"}a=b[c];void 0===a&&(a=new T,b[c]=a);return a};this.save=function(a,b){c(a).save(a,b)};this.get=function(a){return c(a).get(a)}}var p="__ko_mapping__",H=d.dependentObservable,B=0,G,I,L=["create","update","key","arrayChanged"],N={},x={include:["_destroy"],ignore:[],copy:[],observe:[]},j=x;f.isMapped=function(b){return(b=d.utils.unwrapObservable(b))&&b[p]};f.fromJS=function(b){if(0==arguments.length)throw Error("When calling ko.fromJS, pass the object you want to convert."); | |
| 17 | −try{B++||(G=[],I=new S);var c,a;2==arguments.length&&(arguments[1][p]?a=arguments[1]:c=arguments[1]);3==arguments.length&&(c=arguments[1],a=arguments[2]);a&&(c=E(c,a[p]));c=z(c);var e=F(a,b,c);a&&(e=a);if(!--B)for(;G.length;){var d=G.pop();d&&d()}e[p]=E(e[p],c);return e}catch(f){throw B=0,f;}};f.fromJSON=function(b){var c=d.utils.parseJson(b);arguments[0]=c;return f.fromJS.apply(this,arguments)};f.updateFromJS=function(){throw Error("ko.mapping.updateFromJS, use ko.mapping.fromJS instead. Please note that the order of parameters is different!"); | |
| 18 | −};f.updateFromJSON=function(){throw Error("ko.mapping.updateFromJSON, use ko.mapping.fromJSON instead. Please note that the order of parameters is different!");};f.toJS=function(b,c){j||f.resetDefaultOptions();if(0==arguments.length)throw Error("When calling ko.mapping.toJS, pass the object you want to convert.");if("array"!==f.getType(j.ignore))throw Error("ko.mapping.defaultOptions().ignore should be an array.");if("array"!==f.getType(j.include))throw Error("ko.mapping.defaultOptions().include should be an array."); | |
| 19 | −if("array"!==f.getType(j.copy))throw Error("ko.mapping.defaultOptions().copy should be an array.");c=z(c,b[p]);return f.visitModel(b,function(a){return d.utils.unwrapObservable(a)},c)};f.toJSON=function(b,c){var a=f.toJS(b,c);return d.utils.stringifyJson(a)};f.defaultOptions=function(){if(0<arguments.length)j=arguments[0];else return j};f.resetDefaultOptions=function(){j={include:x.include.slice(0),ignore:x.ignore.slice(0),copy:x.copy.slice(0)}};f.getType=function(b){if(b&&"object"===typeof b){if(b.constructor=== | |
| 20 | −Date)return"date";if(b.constructor===Array)return"array"}return typeof b};f.visitModel=function(b,c,a){a=a||{};a.visitedObjects=a.visitedObjects||new S;var e,k=d.utils.unwrapObservable(b);if(P(k))a=z(a,k[p]),c(b,a.parentName),e="array"===f.getType(k)?[]:{};else return c(b,a.parentName);a.visitedObjects.save(b,e);var l=a.parentName;Q(k,function(b){if(!(a.ignore&&-1!=d.utils.arrayIndexOf(a.ignore,b))){var j=k[b],g=a,h=l||"";"array"===f.getType(k)?l&&(h+="["+b+"]"):(l&&(h+="."),h+=b);g.parentName=h; | |
| 21 | −if(!(-1===d.utils.arrayIndexOf(a.copy,b)&&-1===d.utils.arrayIndexOf(a.include,b)&&k[p]&&k[p].mappedProperties&&!k[p].mappedProperties[b]&&k[p].copiedProperties&&!k[p].copiedProperties[b]&&"array"!==f.getType(k)))switch(f.getType(d.utils.unwrapObservable(j))){case "object":case "array":case "undefined":g=a.visitedObjects.get(j);e[b]="undefined"!==f.getType(g)?g:f.visitModel(j,c,a);break;default:e[b]=c(j,a.parentName)}}});return e}}); | |
| @@ -1,1511 +0,0 @@ | ||
| 1 | −/*============================================================================= | |
| 2 | − Author: Eric M. Barnard - @ericmbarnard | |
| 3 | − License: MIT (http://opensource.org/licenses/mit-license.php) | |
| 4 | − | |
| 5 | − Description: Validation Library for KnockoutJS | |
| 6 | − Version: 2.0.3 | |
| 7 | −=============================================================================== | |
| 8 | −*/ | |
| 9 | −/*globals require: false, exports: false, define: false, ko: false */ | |
| 10 | − | |
| 11 | −(function (factory) { | |
| 12 | − // Module systems magic dance. | |
| 13 | − | |
| 14 | − if (typeof require === "function" && typeof exports === "object" && typeof module === "object") { | |
| 15 | − // CommonJS or Node: hard-coded dependency on "knockout" | |
| 16 | − factory(require("knockout"), exports); | |
| 17 | − } else if (typeof define === "function" && define["amd"]) { | |
| 18 | − // AMD anonymous module with hard-coded dependency on "knockout" | |
| 19 | − define(["knockout", "exports"], factory); | |
| 20 | − } else { | |
| 21 | − // <script> tag: use the global `ko` object, attaching a `mapping` property | |
| 22 | − factory(ko, ko.validation = {}); | |
| 23 | − } | |
| 24 | −}(function ( ko, exports ) { | |
| 25 | − | |
| 26 | − if (typeof (ko) === 'undefined') { | |
| 27 | − throw new Error('Knockout is required, please ensure it is loaded before loading this validation plug-in'); | |
| 28 | − } | |
| 29 | − | |
| 30 | − // create our namespace object | |
| 31 | − ko.validation = exports; | |
| 32 | − | |
| 33 | − var kv = ko.validation, | |
| 34 | − koUtils = ko.utils, | |
| 35 | − unwrap = koUtils.unwrapObservable, | |
| 36 | − forEach = koUtils.arrayForEach, | |
| 37 | − extend = koUtils.extend; | |
| 38 | −;/*global ko: false*/ | |
| 39 | − | |
| 40 | −var defaults = { | |
| 41 | − registerExtenders: true, | |
| 42 | − messagesOnModified: true, | |
| 43 | − errorsAsTitle: true, // enables/disables showing of errors as title attribute of the target element. | |
| 44 | − errorsAsTitleOnModified: false, // shows the error when hovering the input field (decorateElement must be true) | |
| 45 | − messageTemplate: null, | |
| 46 | − insertMessages: true, // automatically inserts validation messages as <span></span> | |
| 47 | − parseInputAttributes: false, // parses the HTML5 validation attribute from a form element and adds that to the object | |
| 48 | − writeInputAttributes: false, // adds HTML5 input validation attributes to form elements that ko observable's are bound to | |
| 49 | − decorateInputElement: false, // false to keep backward compatibility | |
| 50 | − decorateElementOnModified: true,// true to keep backward compatibility | |
| 51 | − errorClass: null, // single class for error message and element | |
| 52 | − errorElementClass: 'validationElement', // class to decorate error element | |
| 53 | − errorMessageClass: 'validationMessage', // class to decorate error message | |
| 54 | − allowHtmlMessages: false, // allows HTML in validation messages | |
| 55 | − grouping: { | |
| 56 | − deep: false, //by default grouping is shallow | |
| 57 | − observable: true, //and using observables | |
| 58 | − live: false //react to changes to observableArrays if observable === true | |
| 59 | − }, | |
| 60 | − validate: { | |
| 61 | − // throttle: 10 | |
| 62 | − } | |
| 63 | −}; | |
| 64 | − | |
| 65 | −// make a copy so we can use 'reset' later | |
| 66 | −var configuration = extend({}, defaults); | |
| 67 | − | |
| 68 | −configuration.html5Attributes = ['required', 'pattern', 'min', 'max', 'step']; | |
| 69 | −configuration.html5InputTypes = ['email', 'number', 'date']; | |
| 70 | − | |
| 71 | −configuration.reset = function () { | |
| 72 | − extend(configuration, defaults); | |
| 73 | −}; | |
| 74 | − | |
| 75 | −kv.configuration = configuration; | |
| 76 | −;kv.utils = (function () { | |
| 77 | − var seedId = new Date().getTime(); | |
| 78 | − | |
| 79 | − var domData = {}; //hash of data objects that we reference from dom elements | |
| 80 | − var domDataKey = '__ko_validation__'; | |
| 81 | − | |
| 82 | − return { | |
| 83 | − isArray: function (o) { | |
| 84 | − return o.isArray || Object.prototype.toString.call(o) === '[object Array]'; | |
| 85 | − }, | |
| 86 | − isObject: function (o) { | |
| 87 | − return o !== null && typeof o === 'object'; | |
| 88 | − }, | |
| 89 | − isNumber: function(o) { | |
| 90 | − return !isNaN(o); | |
| 91 | − }, | |
| 92 | − isObservableArray: function(instance) { | |
| 93 | − return !!instance && | |
| 94 | − typeof instance["remove"] === "function" && | |
| 95 | − typeof instance["removeAll"] === "function" && | |
| 96 | − typeof instance["destroy"] === "function" && | |
| 97 | − typeof instance["destroyAll"] === "function" && | |
| 98 | − typeof instance["indexOf"] === "function" && | |
| 99 | − typeof instance["replace"] === "function"; | |
| 100 | − }, | |
| 101 | − values: function (o) { | |
| 102 | − var r = []; | |
| 103 | − for (var i in o) { | |
| 104 | − if (o.hasOwnProperty(i)) { | |
| 105 | − r.push(o[i]); | |
| 106 | − } | |
| 107 | − } | |
| 108 | − return r; | |
| 109 | − }, | |
| 110 | − getValue: function (o) { | |
| 111 | − return (typeof o === 'function' ? o() : o); | |
| 112 | − }, | |
| 113 | − hasAttribute: function (node, attr) { | |
| 114 | − return node.getAttribute(attr) !== null; | |
| 115 | − }, | |
| 116 | − getAttribute: function (element, attr) { | |
| 117 | − return element.getAttribute(attr); | |
| 118 | − }, | |
| 119 | − setAttribute: function (element, attr, value) { | |
| 120 | − return element.setAttribute(attr, value); | |
| 121 | − }, | |
| 122 | − isValidatable: function (o) { | |
| 123 | − return !!(o && o.rules && o.isValid && o.isModified); | |
| 124 | − }, | |
| 125 | − insertAfter: function (node, newNode) { | |
| 126 | − node.parentNode.insertBefore(newNode, node.nextSibling); | |
| 127 | − }, | |
| 128 | − newId: function () { | |
| 129 | − return seedId += 1; | |
| 130 | − }, | |
| 131 | − getConfigOptions: function (element) { | |
| 132 | − var options = kv.utils.contextFor(element); | |
| 133 | − | |
| 134 | − return options || kv.configuration; | |
| 135 | − }, | |
| 136 | − setDomData: function (node, data) { | |
| 137 | − var key = node[domDataKey]; | |
| 138 | − | |
| 139 | − if (!key) { | |
| 140 | − node[domDataKey] = key = kv.utils.newId(); | |
| 141 | − } | |
| 142 | − | |
| 143 | − domData[key] = data; | |
| 144 | − }, | |
| 145 | − getDomData: function (node) { | |
| 146 | − var key = node[domDataKey]; | |
| 147 | − | |
| 148 | − if (!key) { | |
| 149 | − return undefined; | |
| 150 | − } | |
| 151 | − | |
| 152 | − return domData[key]; | |
| 153 | − }, | |
| 154 | − contextFor: function (node) { | |
| 155 | − switch (node.nodeType) { | |
| 156 | − case 1: | |
| 157 | − case 8: | |
| 158 | − var context = kv.utils.getDomData(node); | |
| 159 | − if (context) { return context; } | |
| 160 | − if (node.parentNode) { return kv.utils.contextFor(node.parentNode); } | |
| 161 | − break; | |
| 162 | − } | |
| 163 | − return undefined; | |
| 164 | − }, | |
| 165 | − isEmptyVal: function (val) { | |
| 166 | − if (val === undefined) { | |
| 167 | − return true; | |
| 168 | − } | |
| 169 | − if (val === null) { | |
| 170 | − return true; | |
| 171 | − } | |
| 172 | − if (val === "") { | |
| 173 | − return true; | |
| 174 | − } | |
| 175 | − }, | |
| 176 | − getOriginalElementTitle: function (element) { | |
| 177 | − var savedOriginalTitle = kv.utils.getAttribute(element, 'data-orig-title'), | |
| 178 | − currentTitle = element.title, | |
| 179 | − hasSavedOriginalTitle = kv.utils.hasAttribute(element, 'data-orig-title'); | |
| 180 | − | |
| 181 | − return hasSavedOriginalTitle ? | |
| 182 | − savedOriginalTitle : currentTitle; | |
| 183 | − }, | |
| 184 | − async: function (expr) { | |
| 185 | − if (window.setImmediate) { window.setImmediate(expr); } | |
| 186 | − else { window.setTimeout(expr, 0); } | |
| 187 | − }, | |
| 188 | − forEach: function (object, callback) { | |
| 189 | − if (kv.utils.isArray(object)) { | |
| 190 | − return forEach(object, callback); | |
| 191 | − } | |
| 192 | − for (var prop in object) { | |
| 193 | − if (object.hasOwnProperty(prop)) { | |
| 194 | − callback(object[prop], prop); | |
| 195 | − } | |
| 196 | − } | |
| 197 | − } | |
| 198 | − }; | |
| 199 | −}());;var api = (function () { | |
| 200 | − | |
| 201 | − var isInitialized = 0, | |
| 202 | − configuration = kv.configuration, | |
| 203 | − utils = kv.utils; | |
| 204 | − | |
| 205 | − function cleanUpSubscriptions(context) { | |
| 206 | − forEach(context.subscriptions, function (subscription) { | |
| 207 | − subscription.dispose(); | |
| 208 | − }); | |
| 209 | − context.subscriptions = []; | |
| 210 | − } | |
| 211 | − | |
| 212 | − function dispose(context) { | |
| 213 | − if (context.options.deep) { | |
| 214 | − forEach(context.flagged, function (obj) { | |
| 215 | − delete obj.__kv_traversed; | |
| 216 | − }); | |
| 217 | − context.flagged.length = 0; | |
| 218 | − } | |
| 219 | − | |
| 220 | − if (!context.options.live) { | |
| 221 | − cleanUpSubscriptions(context); | |
| 222 | − } | |
| 223 | − } | |
| 224 | − | |
| 225 | − function runTraversal(obj, context) { | |
| 226 | − context.validatables = []; | |
| 227 | − cleanUpSubscriptions(context); | |
| 228 | − traverseGraph(obj, context); | |
| 229 | − dispose(context); | |
| 230 | − } | |
| 231 | − | |
| 232 | − function traverseGraph(obj, context, level) { | |
| 233 | − var objValues = [], | |
| 234 | − val = obj.peek ? obj.peek() : obj; | |
| 235 | − | |
| 236 | − if (obj.__kv_traversed === true) { | |
| 237 | − return; | |
| 238 | − } | |
| 239 | − | |
| 240 | − if (context.options.deep) { | |
| 241 | − obj.__kv_traversed = true; | |
| 242 | − context.flagged.push(obj); | |
| 243 | − } | |
| 244 | − | |
| 245 | − //default level value depends on deep option. | |
| 246 | − level = (level !== undefined ? level : context.options.deep ? 1 : -1); | |
| 247 | − | |
| 248 | − // if object is observable then add it to the list | |
| 249 | − if (ko.isObservable(obj)) { | |
| 250 | − // ensure it's validatable but don't extend validatedObservable because it | |
| 251 | − // would overwrite isValid property. | |
| 252 | − if (!obj.errors && !utils.isValidatable(obj)) { | |
| 253 | − obj.extend({ validatable: true }); | |
| 254 | − } | |
| 255 | − context.validatables.push(obj); | |
| 256 | − | |
| 257 | − if (context.options.live && utils.isObservableArray(obj)) { | |
| 258 | − context.subscriptions.push(obj.subscribe(function () { | |
| 259 | − context.graphMonitor.valueHasMutated(); | |
| 260 | − })); | |
| 261 | − } | |
| 262 | − } | |
| 263 | − | |
| 264 | − //get list of values either from array or object but ignore non-objects | |
| 265 | − // and destroyed objects | |
| 266 | − if (val && !val._destroy) { | |
| 267 | − if (utils.isArray(val)) { | |
| 268 | − objValues = val; | |
| 269 | − } | |
| 270 | − else if (utils.isObject(val)) { | |
| 271 | − objValues = utils.values(val); | |
| 272 | − } | |
| 273 | − } | |
| 274 | − | |
| 275 | − //process recursively if it is deep grouping | |
| 276 | − if (level !== 0) { | |
| 277 | − utils.forEach(objValues, function (observable) { | |
| 278 | − //but not falsy things and not HTML Elements | |
| 279 | − if (observable && !observable.nodeType && (!ko.isComputed(observable) || observable.rules)) { | |
| 280 | − traverseGraph(observable, context, level + 1); | |
| 281 | − } | |
| 282 | − }); | |
| 283 | − } | |
| 284 | − } | |
| 285 | − | |
| 286 | − function collectErrors(array) { | |
| 287 | − var errors = []; | |
| 288 | − forEach(array, function (observable) { | |
| 289 | − // Do not collect validatedObservable errors | |
| 290 | − if (utils.isValidatable(observable) && !observable.isValid()) { | |
| 291 | − // Use peek because we don't want a dependency for 'error' property because it | |
| 292 | − // changes before 'isValid' does. (Issue #99) | |
| 293 | − errors.push(observable.error.peek()); | |
| 294 | − } | |
| 295 | − }); | |
| 296 | − return errors; | |
| 297 | − } | |
| 298 | − | |
| 299 | − return { | |
| 300 | − //Call this on startup | |
| 301 | − //any config can be overridden with the passed in options | |
| 302 | − init: function (options, force) { | |
| 303 | − //done run this multiple times if we don't really want to | |
| 304 | − if (isInitialized > 0 && !force) { | |
| 305 | − return; | |
| 306 | − } | |
| 307 | − | |
| 308 | − //because we will be accessing options properties it has to be an object at least | |
| 309 | − options = options || {}; | |
| 310 | − //if specific error classes are not provided then apply generic errorClass | |
| 311 | − //it has to be done on option so that options.errorClass can override default | |
| 312 | − //errorElementClass and errorMessage class but not those provided in options | |
| 313 | − options.errorElementClass = options.errorElementClass || options.errorClass || configuration.errorElementClass; | |
| 314 | − options.errorMessageClass = options.errorMessageClass || options.errorClass || configuration.errorMessageClass; | |
| 315 | − | |
| 316 | − extend(configuration, options); | |
| 317 | − | |
| 318 | − if (configuration.registerExtenders) { | |
| 319 | − kv.registerExtenders(); | |
| 320 | − } | |
| 321 | − | |
| 322 | − isInitialized = 1; | |
| 323 | − }, | |
| 324 | − | |
| 325 | − // resets the config back to its original state | |
| 326 | − reset: kv.configuration.reset, | |
| 327 | − | |
| 328 | − // recursively walks a viewModel and creates an object that | |
| 329 | − // provides validation information for the entire viewModel | |
| 330 | − // obj -> the viewModel to walk | |
| 331 | − // options -> { | |
| 332 | − // deep: false, // if true, will walk past the first level of viewModel properties | |
| 333 | − // observable: false // if true, returns a computed observable indicating if the viewModel is valid | |
| 334 | − // } | |
| 335 | − group: function group(obj, options) { // array of observables or viewModel | |
| 336 | − options = extend(extend({}, configuration.grouping), options); | |
| 337 | − | |
| 338 | − var context = { | |
| 339 | − options: options, | |
| 340 | − graphMonitor: ko.observable(), | |
| 341 | − flagged: [], | |
| 342 | − subscriptions: [], | |
| 343 | − validatables: [] | |
| 344 | − }; | |
| 345 | − | |
| 346 | − var result = null; | |
| 347 | − | |
| 348 | − //if using observables then traverse structure once and add observables | |
| 349 | − if (options.observable) { | |
| 350 | − result = ko.computed(function () { | |
| 351 | − context.graphMonitor(); //register dependency | |
| 352 | − runTraversal(obj, context); | |
| 353 | − return collectErrors(context.validatables); | |
| 354 | − }); | |
| 355 | − } | |
| 356 | − else { //if not using observables then every call to error() should traverse the structure | |
| 357 | − result = function () { | |
| 358 | − runTraversal(obj, context); | |
| 359 | − return collectErrors(context.validatables); | |
| 360 | − }; | |
| 361 | − } | |
| 362 | − | |
| 363 | − result.showAllMessages = function (show) { // thanks @heliosPortal | |
| 364 | − if (show === undefined) {//default to true | |
| 365 | − show = true; | |
| 366 | − } | |
| 367 | − | |
| 368 | − result.forEach(function (observable) { | |
| 369 | − if (utils.isValidatable(observable)) { | |
| 370 | − observable.isModified(show); | |
| 371 | − } | |
| 372 | − }); | |
| 373 | − }; | |
| 374 | − | |
| 375 | − result.isAnyMessageShown = function () { | |
| 376 | − var invalidAndModifiedPresent; | |
| 377 | − | |
| 378 | − invalidAndModifiedPresent = !!result.find(function (observable) { | |
| 379 | − return utils.isValidatable(observable) && !observable.isValid() && observable.isModified(); | |
| 380 | − }); | |
| 381 | − return invalidAndModifiedPresent; | |
| 382 | − }; | |
| 383 | − | |
| 384 | − result.filter = function(predicate) { | |
| 385 | − predicate = predicate || function () { return true; }; | |
| 386 | − // ensure we have latest changes | |
| 387 | − result(); | |
| 388 | − | |
| 389 | − return koUtils.arrayFilter(context.validatables, predicate); | |
| 390 | − }; | |
| 391 | − | |
| 392 | − result.find = function(predicate) { | |
| 393 | − predicate = predicate || function () { return true; }; | |
| 394 | − // ensure we have latest changes | |
| 395 | − result(); | |
| 396 | − | |
| 397 | − return koUtils.arrayFirst(context.validatables, predicate); | |
| 398 | − }; | |
| 399 | − | |
| 400 | − result.forEach = function(callback) { | |
| 401 | − callback = callback || function () { }; | |
| 402 | − // ensure we have latest changes | |
| 403 | − result(); | |
| 404 | − | |
| 405 | − forEach(context.validatables, callback); | |
| 406 | − }; | |
| 407 | − | |
| 408 | − result.map = function(mapping) { | |
| 409 | − mapping = mapping || function (item) { return item; }; | |
| 410 | − // ensure we have latest changes | |
| 411 | − result(); | |
| 412 | − | |
| 413 | − return koUtils.arrayMap(context.validatables, mapping); | |
| 414 | − }; | |
| 415 | − | |
| 416 | − /** | |
| 417 | − * @private You should not rely on this method being here. | |
| 418 | − * It's a private method and it may change in the future. | |
| 419 | − * | |
| 420 | − * @description Updates the validated object and collects errors from it. | |
| 421 | − */ | |
| 422 | − result._updateState = function(newValue) { | |
| 423 | − if (!utils.isObject(newValue)) { | |
| 424 | − throw new Error('An object is required.'); | |
| 425 | − } | |
| 426 | − obj = newValue; | |
| 427 | − if (options.observable) { | |
| 428 | − context.graphMonitor.valueHasMutated(); | |
| 429 | − } | |
| 430 | − else { | |
| 431 | − runTraversal(newValue, context); | |
| 432 | − return collectErrors(context.validatables); | |
| 433 | − } | |
| 434 | − }; | |
| 435 | − return result; | |
| 436 | − }, | |
| 437 | − | |
| 438 | − formatMessage: function (message, params, observable) { | |
| 439 | − if (utils.isObject(params) && params.typeAttr) { | |
| 440 | − params = params.value; | |
| 441 | − } | |
| 442 | − if (typeof message === 'function') { | |
| 443 | − return message(params, observable); | |
| 444 | − } | |
| 445 | − var replacements = unwrap(params); | |
| 446 | − if (replacements == null) { | |
| 447 | − replacements = []; | |
| 448 | − } | |
| 449 | − if (!utils.isArray(replacements)) { | |
| 450 | − replacements = [replacements]; | |
| 451 | − } | |
| 452 | − return message.replace(/{(\d+)}/gi, function(match, index) { | |
| 453 | − if (typeof replacements[index] !== 'undefined') { | |
| 454 | − return replacements[index]; | |
| 455 | − } | |
| 456 | − return match; | |
| 457 | − }); | |
| 458 | − }, | |
| 459 | − | |
| 460 | − // addRule: | |
| 461 | − // This takes in a ko.observable and a Rule Context - which is just a rule name and params to supply to the validator | |
| 462 | − // ie: kv.addRule(myObservable, { | |
| 463 | − // rule: 'required', | |
| 464 | − // params: true | |
| 465 | − // }); | |
| 466 | − // | |
| 467 | − addRule: function (observable, rule) { | |
| 468 | − observable.extend({ validatable: true }); | |
| 469 | − | |
| 470 | − var hasRule = !!koUtils.arrayFirst(observable.rules(), function(item) { | |
| 471 | − return item.rule && item.rule === rule.rule; | |
| 472 | − }); | |
| 473 | − | |
| 474 | − if (!hasRule) { | |
| 475 | − //push a Rule Context to the observables local array of Rule Contexts | |
| 476 | − observable.rules.push(rule); | |
| 477 | − } | |
| 478 | − return observable; | |
| 479 | − }, | |
| 480 | − | |
| 481 | − // addAnonymousRule: | |
| 482 | − // Anonymous Rules essentially have all the properties of a Rule, but are only specific for a certain property | |
| 483 | − // and developers typically are wanting to add them on the fly or not register a rule with the 'kv.rules' object | |
| 484 | − // | |
| 485 | − // Example: | |
| 486 | − // var test = ko.observable('something').extend{( | |
| 487 | − // validation: { | |
| 488 | − // validator: function(val, someOtherVal){ | |
| 489 | − // return true; | |
| 490 | − // }, | |
| 491 | − // message: "Something must be really wrong!', | |
| 492 | − // params: true | |
| 493 | − // } | |
| 494 | − // )}; | |
| 495 | − addAnonymousRule: function (observable, ruleObj) { | |
| 496 | − if (ruleObj['message'] === undefined) { | |
| 497 | − ruleObj['message'] = 'Error'; | |
| 498 | − } | |
| 499 | − | |
| 500 | − //make sure onlyIf is honoured | |
| 501 | − if (ruleObj.onlyIf) { | |
| 502 | − ruleObj.condition = ruleObj.onlyIf; | |
| 503 | − } | |
| 504 | − | |
| 505 | − //add the anonymous rule to the observable | |
| 506 | − kv.addRule(observable, ruleObj); | |
| 507 | − }, | |
| 508 | − | |
| 509 | − addExtender: function (ruleName) { | |
| 510 | − ko.extenders[ruleName] = function (observable, params) { | |
| 511 | − //params can come in a few flavors | |
| 512 | − // 1. Just the params to be passed to the validator | |
| 513 | − // 2. An object containing the Message to be used and the Params to pass to the validator | |
| 514 | − // 3. A condition when the validation rule to be applied | |
| 515 | − // | |
| 516 | − // Example: | |
| 517 | − // var test = ko.observable(3).extend({ | |
| 518 | − // max: { | |
| 519 | − // message: 'This special field has a Max of {0}', | |
| 520 | − // params: 2, | |
| 521 | − // onlyIf: function() { | |
| 522 | − // return specialField.IsVisible(); | |
| 523 | − // } | |
| 524 | − // } | |
| 525 | − // )}; | |
| 526 | − // | |
| 527 | − if (params && (params.message || params.onlyIf)) { //if it has a message or condition object, then its an object literal to use | |
| 528 | − return kv.addRule(observable, { | |
| 529 | − rule: ruleName, | |
| 530 | − message: params.message, | |
| 531 | − params: utils.isEmptyVal(params.params) ? true : params.params, | |
| 532 | − condition: params.onlyIf | |
| 533 | − }); | |
| 534 | − } else { | |
| 535 | − return kv.addRule(observable, { | |
| 536 | − rule: ruleName, | |
| 537 | − params: params | |
| 538 | − }); | |
| 539 | − } | |
| 540 | − }; | |
| 541 | − }, | |
| 542 | − | |
| 543 | − // loops through all kv.rules and adds them as extenders to | |
| 544 | − // ko.extenders | |
| 545 | − registerExtenders: function () { // root extenders optional, use 'validation' extender if would cause conflicts | |
| 546 | − if (configuration.registerExtenders) { | |
| 547 | − for (var ruleName in kv.rules) { | |
| 548 | − if (kv.rules.hasOwnProperty(ruleName)) { | |
| 549 | − if (!ko.extenders[ruleName]) { | |
| 550 | − kv.addExtender(ruleName); | |
| 551 | − } | |
| 552 | − } | |
| 553 | − } | |
| 554 | − } | |
| 555 | − }, | |
| 556 | − | |
| 557 | − //creates a span next to the @element with the specified error class | |
| 558 | − insertValidationMessage: function (element) { | |
| 559 | − var span = document.createElement('SPAN'); | |
| 560 | − span.className = utils.getConfigOptions(element).errorMessageClass; | |
| 561 | − utils.insertAfter(element, span); | |
| 562 | − return span; | |
| 563 | − }, | |
| 564 | − | |
| 565 | − // if html-5 validation attributes have been specified, this parses | |
| 566 | − // the attributes on @element | |
| 567 | − parseInputValidationAttributes: function (element, valueAccessor) { | |
| 568 | − forEach(kv.configuration.html5Attributes, function (attr) { | |
| 569 | − if (utils.hasAttribute(element, attr)) { | |
| 570 | − | |
| 571 | − var params = element.getAttribute(attr) || true; | |
| 572 | − | |
| 573 | − if (attr === 'min' || attr === 'max') | |
| 574 | − { | |
| 575 | − // If we're validating based on the min and max attributes, we'll | |
| 576 | − // need to know what the 'type' attribute is set to | |
| 577 | − var typeAttr = element.getAttribute('type'); | |
| 578 | − if (typeof typeAttr === "undefined" || !typeAttr) | |
| 579 | − { | |
| 580 | − // From http://www.w3.org/TR/html-markup/input: | |
| 581 | − // An input element with no type attribute specified represents the | |
| 582 | − // same thing as an input element with its type attribute set to "text". | |
| 583 | − typeAttr = "text"; | |
| 584 | − } | |
| 585 | − params = {typeAttr: typeAttr, value: params}; | |
| 586 | − } | |
| 587 | − | |
| 588 | − kv.addRule(valueAccessor(), { | |
| 589 | − rule: attr, | |
| 590 | − params: params | |
| 591 | − }); | |
| 592 | − } | |
| 593 | − }); | |
| 594 | − | |
| 595 | − var currentType = element.getAttribute('type'); | |
| 596 | − forEach(kv.configuration.html5InputTypes, function (type) { | |
| 597 | − if (type === currentType) { | |
| 598 | − kv.addRule(valueAccessor(), { | |
| 599 | − rule: (type === 'date') ? 'dateISO' : type, | |
| 600 | − params: true | |
| 601 | − }); | |
| 602 | − } | |
| 603 | − }); | |
| 604 | − }, | |
| 605 | − | |
| 606 | − // writes html5 validation attributes on the element passed in | |
| 607 | − writeInputValidationAttributes: function (element, valueAccessor) { | |
| 608 | − var observable = valueAccessor(); | |
| 609 | − | |
| 610 | − if (!observable || !observable.rules) { | |
| 611 | − return; | |
| 612 | − } | |
| 613 | − | |
| 614 | − var contexts = observable.rules(); // observable array | |
| 615 | − | |
| 616 | − // loop through the attributes and add the information needed | |
| 617 | − forEach(kv.configuration.html5Attributes, function (attr) { | |
| 618 | − var ctx = koUtils.arrayFirst(contexts, function (ctx) { | |
| 619 | − return ctx.rule && ctx.rule.toLowerCase() === attr.toLowerCase(); | |
| 620 | − }); | |
| 621 | − | |
| 622 | − if (!ctx) { | |
| 623 | − return; | |
| 624 | − } | |
| 625 | − | |
| 626 | − // we have a rule matching a validation attribute at this point | |
| 627 | − // so lets add it to the element along with the params | |
| 628 | − ko.computed({ | |
| 629 | − read: function() { | |
| 630 | − var params = ko.unwrap(ctx.params); | |
| 631 | − | |
| 632 | − // we have to do some special things for the pattern validation | |
| 633 | − if (ctx.rule === "pattern" && params instanceof RegExp) { | |
| 634 | − // we need the pure string representation of the RegExpr without the //gi stuff | |
| 635 | − params = params.source; | |
| 636 | − } | |
| 637 | − | |
| 638 | − element.setAttribute(attr, params); | |
| 639 | − }, | |
| 640 | − disposeWhenNodeIsRemoved: element | |
| 641 | − }); | |
| 642 | − }); | |
| 643 | − | |
| 644 | − contexts = null; | |
| 645 | − }, | |
| 646 | − | |
| 647 | − //take an existing binding handler and make it cause automatic validations | |
| 648 | − makeBindingHandlerValidatable: function (handlerName) { | |
| 649 | − var init = ko.bindingHandlers[handlerName].init; | |
| 650 | − | |
| 651 | − ko.bindingHandlers[handlerName].init = function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { | |
| 652 | − | |
| 653 | − init(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext); | |
| 654 | − | |
| 655 | − return ko.bindingHandlers['validationCore'].init(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext); | |
| 656 | − }; | |
| 657 | − }, | |
| 658 | − | |
| 659 | − // visit an objects properties and apply validation rules from a definition | |
| 660 | − setRules: function (target, definition) { | |
| 661 | − var setRules = function (target, definition) { | |
| 662 | − if (!target || !definition) { return; } | |
| 663 | − | |
| 664 | − for (var prop in definition) { | |
| 665 | − if (!definition.hasOwnProperty(prop)) { continue; } | |
| 666 | − var ruleDefinitions = definition[prop]; | |
| 667 | − | |
| 668 | − //check the target property exists and has a value | |
| 669 | − if (!target[prop]) { continue; } | |
| 670 | − var targetValue = target[prop], | |
| 671 | − unwrappedTargetValue = unwrap(targetValue), | |
| 672 | − rules = {}, | |
| 673 | − nonRules = {}; | |
| 674 | − | |
| 675 | − for (var rule in ruleDefinitions) { | |
| 676 | − if (!ruleDefinitions.hasOwnProperty(rule)) { continue; } | |
| 677 | − if (kv.rules[rule]) { | |
| 678 | − rules[rule] = ruleDefinitions[rule]; | |
| 679 | − } else { | |
| 680 | − nonRules[rule] = ruleDefinitions[rule]; | |
| 681 | − } | |
| 682 | − } | |
| 683 | − | |
| 684 | − //apply rules | |
| 685 | − if (ko.isObservable(targetValue)) { | |
| 686 | − targetValue.extend(rules); | |
| 687 | − } | |
| 688 | − | |
| 689 | − //then apply child rules | |
| 690 | − //if it's an array, apply rules to all children | |
| 691 | − if (unwrappedTargetValue && utils.isArray(unwrappedTargetValue)) { | |
| 692 | − for (var i = 0; i < unwrappedTargetValue.length; i++) { | |
| 693 | − setRules(unwrappedTargetValue[i], nonRules); | |
| 694 | − } | |
| 695 | − //otherwise, just apply to this property | |
| 696 | − } else { | |
| 697 | − setRules(unwrappedTargetValue, nonRules); | |
| 698 | − } | |
| 699 | − } | |
| 700 | − }; | |
| 701 | − setRules(target, definition); | |
| 702 | − } | |
| 703 | − }; | |
| 704 | − | |
| 705 | −}()); | |
| 706 | − | |
| 707 | −// expose api publicly | |
| 708 | −extend(ko.validation, api); | |
| 709 | −;//Validation Rules: | |
| 710 | −// You can view and override messages or rules via: | |
| 711 | −// kv.rules[ruleName] | |
| 712 | −// | |
| 713 | −// To implement a custom Rule, simply use this template: | |
| 714 | −// kv.rules['<custom rule name>'] = { | |
| 715 | −// validator: function (val, param) { | |
| 716 | −// <custom logic> | |
| 717 | −// return <true or false>; | |
| 718 | −// }, | |
| 719 | −// message: '<custom validation message>' //optionally you can also use a '{0}' to denote a placeholder that will be replaced with your 'param' | |
| 720 | −// }; | |
| 721 | −// | |
| 722 | −// Example: | |
| 723 | −// kv.rules['mustEqual'] = { | |
| 724 | −// validator: function( val, mustEqualVal ){ | |
| 725 | −// return val === mustEqualVal; | |
| 726 | −// }, | |
| 727 | −// message: 'This field must equal {0}' | |
| 728 | −// }; | |
| 729 | −// | |
| 730 | −kv.rules = {}; | |
| 731 | −kv.rules['required'] = { | |
| 732 | − validator: function (val, required) { | |
| 733 | − var testVal; | |
| 734 | − | |
| 735 | − if (val === undefined || val === null) { | |
| 736 | − return !required; | |
| 737 | − } | |
| 738 | − | |
| 739 | − testVal = val; | |
| 740 | − if (typeof (val) === 'string') { | |
| 741 | − if (String.prototype.trim) { | |
| 742 | − testVal = val.trim(); | |
| 743 | − } | |
| 744 | − else { | |
| 745 | − testVal = val.replace(/^\s+|\s+$/g, ''); | |
| 746 | − } | |
| 747 | − } | |
| 748 | − | |
| 749 | − if (!required) {// if they passed: { required: false }, then don't require this | |
| 750 | − return true; | |
| 751 | − } | |
| 752 | − | |
| 753 | − return ((testVal + '').length > 0); | |
| 754 | − }, | |
| 755 | − message: 'This field is required.' | |
| 756 | −}; | |
| 757 | − | |
| 758 | −function minMaxValidatorFactory(validatorName) { | |
| 759 | − var isMaxValidation = validatorName === "max"; | |
| 760 | − | |
| 761 | − return function (val, options) { | |
| 762 | − if (kv.utils.isEmptyVal(val)) { | |
| 763 | − return true; | |
| 764 | − } | |
| 765 | − | |
| 766 | − var comparisonValue, type; | |
| 767 | − if (options.typeAttr === undefined) { | |
| 768 | − // This validator is being called from javascript rather than | |
| 769 | − // being bound from markup | |
| 770 | − type = "text"; | |
| 771 | − comparisonValue = options; | |
| 772 | − } else { | |
| 773 | − type = options.typeAttr; | |
| 774 | − comparisonValue = options.value; | |
| 775 | − } | |
| 776 | − | |
| 777 | − // From http://www.w3.org/TR/2012/WD-html5-20121025/common-input-element-attributes.html#attr-input-min, | |
| 778 | − // if the value is parseable to a number, then the minimum should be numeric | |
| 779 | − if (!isNaN(comparisonValue) && !(comparisonValue instanceof Date)) { | |
| 780 | − type = "number"; | |
| 781 | − } | |
| 782 | − | |
| 783 | − var regex, valMatches, comparisonValueMatches; | |
| 784 | − switch (type.toLowerCase()) { | |
| 785 | − case "week": | |
| 786 | − regex = /^(\d{4})-W(\d{2})$/; | |
| 787 | − valMatches = val.match(regex); | |
| 788 | − if (valMatches === null) { | |
| 789 | − throw new Error("Invalid value for " + validatorName + " attribute for week input. Should look like " + | |
| 790 | − "'2000-W33' http://www.w3.org/TR/html-markup/input.week.html#input.week.attrs.min"); | |
| 791 | − } | |
| 792 | − comparisonValueMatches = comparisonValue.match(regex); | |
| 793 | − // If no regex matches were found, validation fails | |
| 794 | − if (!comparisonValueMatches) { | |
| 795 | − return false; | |
| 796 | − } | |
| 797 | − | |
| 798 | − if (isMaxValidation) { | |
| 799 | − return (valMatches[1] < comparisonValueMatches[1]) || // older year | |
| 800 | − // same year, older week | |
| 801 | − ((valMatches[1] === comparisonValueMatches[1]) && (valMatches[2] <= comparisonValueMatches[2])); | |
| 802 | − } else { | |
| 803 | − return (valMatches[1] > comparisonValueMatches[1]) || // newer year | |
| 804 | − // same year, newer week | |
| 805 | − ((valMatches[1] === comparisonValueMatches[1]) && (valMatches[2] >= comparisonValueMatches[2])); | |
| 806 | − } | |
| 807 | − break; | |
| 808 | − | |
| 809 | − case "month": | |
| 810 | − regex = /^(\d{4})-(\d{2})$/; | |
| 811 | − valMatches = val.match(regex); | |
| 812 | − if (valMatches === null) { | |
| 813 | − throw new Error("Invalid value for " + validatorName + " attribute for month input. Should look like " + | |
| 814 | − "'2000-03' http://www.w3.org/TR/html-markup/input.month.html#input.month.attrs.min"); | |
| 815 | − } | |
| 816 | − comparisonValueMatches = comparisonValue.match(regex); | |
| 817 | − // If no regex matches were found, validation fails | |
| 818 | − if (!comparisonValueMatches) { | |
| 819 | − return false; | |
| 820 | − } | |
| 821 | − | |
| 822 | − if (isMaxValidation) { | |
| 823 | − return ((valMatches[1] < comparisonValueMatches[1]) || // older year | |
| 824 | − // same year, older month | |
| 825 | − ((valMatches[1] === comparisonValueMatches[1]) && (valMatches[2] <= comparisonValueMatches[2]))); | |
| 826 | − } else { | |
| 827 | − return (valMatches[1] > comparisonValueMatches[1]) || // newer year | |
| 828 | − // same year, newer month | |
| 829 | − ((valMatches[1] === comparisonValueMatches[1]) && (valMatches[2] >= comparisonValueMatches[2])); | |
| 830 | − } | |
| 831 | − break; | |
| 832 | − | |
| 833 | − case "number": | |
| 834 | − case "range": | |
| 835 | − if (isMaxValidation) { | |
| 836 | − return (!isNaN(val) && parseFloat(val) <= parseFloat(comparisonValue)); | |
| 837 | − } else { | |
| 838 | − return (!isNaN(val) && parseFloat(val) >= parseFloat(comparisonValue)); | |
| 839 | − } | |
| 840 | − break; | |
| 841 | − | |
| 842 | − default: | |
| 843 | − if (isMaxValidation) { | |
| 844 | − return val <= comparisonValue; | |
| 845 | − } else { | |
| 846 | − return val >= comparisonValue; | |
| 847 | − } | |
| 848 | − } | |
| 849 | − }; | |
| 850 | −} | |
| 851 | − | |
| 852 | −kv.rules['min'] = { | |
| 853 | − validator: minMaxValidatorFactory("min"), | |
| 854 | − message: 'Please enter a value greater than or equal to {0}.' | |
| 855 | −}; | |
| 856 | − | |
| 857 | −kv.rules['max'] = { | |
| 858 | − validator: minMaxValidatorFactory("max"), | |
| 859 | − message: 'Please enter a value less than or equal to {0}.' | |
| 860 | −}; | |
| 861 | − | |
| 862 | −kv.rules['minLength'] = { | |
| 863 | − validator: function (val, minLength) { | |
| 864 | − if(kv.utils.isEmptyVal(val)) { return true; } | |
| 865 | − var normalizedVal = kv.utils.isNumber(val) ? ('' + val) : val; | |
| 866 | − return normalizedVal.length >= minLength; | |
| 867 | − }, | |
| 868 | − message: 'Please enter at least {0} characters.' | |
| 869 | −}; | |
| 870 | − | |
| 871 | −kv.rules['maxLength'] = { | |
| 872 | − validator: function (val, maxLength) { | |
| 873 | − if(kv.utils.isEmptyVal(val)) { return true; } | |
| 874 | − var normalizedVal = kv.utils.isNumber(val) ? ('' + val) : val; | |
| 875 | − return normalizedVal.length <= maxLength; | |
| 876 | − }, | |
| 877 | − message: 'Please enter no more than {0} characters.' | |
| 878 | −}; | |
| 879 | − | |
| 880 | −kv.rules['pattern'] = { | |
| 881 | − validator: function (val, regex) { | |
| 882 | − return kv.utils.isEmptyVal(val) || val.toString().match(regex) !== null; | |
| 883 | − }, | |
| 884 | − message: 'Please check this value.' | |
| 885 | −}; | |
| 886 | − | |
| 887 | −kv.rules['step'] = { | |
| 888 | − validator: function (val, step) { | |
| 889 | − | |
| 890 | − // in order to handle steps of .1 & .01 etc.. Modulus won't work | |
| 891 | − // if the value is a decimal, so we have to correct for that | |
| 892 | − if (kv.utils.isEmptyVal(val) || step === 'any') { return true; } | |
| 893 | − var dif = (val * 100) % (step * 100); | |
| 894 | − return Math.abs(dif) < 0.00001 || Math.abs(1 - dif) < 0.00001; | |
| 895 | − }, | |
| 896 | − message: 'The value must increment by {0}.' | |
| 897 | −}; | |
| 898 | − | |
| 899 | −kv.rules['email'] = { | |
| 900 | − validator: function (val, validate) { | |
| 901 | − if (!validate) { return true; } | |
| 902 | − | |
| 903 | − //I think an empty email address is also a valid entry | |
| 904 | − //if one want's to enforce entry it should be done with 'required: true' | |
| 905 | − return kv.utils.isEmptyVal(val) || ( | |
| 906 | − // jquery validate regex - thanks Scott Gonzalez | |
| 907 | − validate && /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(val) | |
| 908 | − ); | |
| 909 | − }, | |
| 910 | − message: 'Please enter a proper email address.' | |
| 911 | −}; | |
| 912 | − | |
| 913 | −kv.rules['date'] = { | |
| 914 | − validator: function (value, validate) { | |
| 915 | − if (!validate) { return true; } | |
| 916 | − return kv.utils.isEmptyVal(value) || (validate && !/Invalid|NaN/.test(new Date(value))); | |
| 917 | − }, | |
| 918 | − message: 'Please enter a proper date.' | |
| 919 | −}; | |
| 920 | − | |
| 921 | −kv.rules['dateISO'] = { | |
| 922 | − validator: function (value, validate) { | |
| 923 | − if (!validate) { return true; } | |
| 924 | − return kv.utils.isEmptyVal(value) || (validate && /^\d{4}[-/](?:0?[1-9]|1[012])[-/](?:0?[1-9]|[12][0-9]|3[01])$/.test(value)); | |
| 925 | − }, | |
| 926 | − message: 'Please enter a proper date.' | |
| 927 | −}; | |
| 928 | − | |
| 929 | −kv.rules['number'] = { | |
| 930 | − validator: function (value, validate) { | |
| 931 | − if (!validate) { return true; } | |
| 932 | − return kv.utils.isEmptyVal(value) || (validate && /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value)); | |
| 933 | − }, | |
| 934 | − message: 'Please enter a number.' | |
| 935 | −}; | |
| 936 | − | |
| 937 | −kv.rules['digit'] = { | |
| 938 | − validator: function (value, validate) { | |
| 939 | − if (!validate) { return true; } | |
| 940 | − return kv.utils.isEmptyVal(value) || (validate && /^\d+$/.test(value)); | |
| 941 | − }, | |
| 942 | − message: 'Please enter a digit.' | |
| 943 | −}; | |
| 944 | − | |
| 945 | −kv.rules['phoneUS'] = { | |
| 946 | − validator: function (phoneNumber, validate) { | |
| 947 | − if (!validate) { return true; } | |
| 948 | − if (kv.utils.isEmptyVal(phoneNumber)) { return true; } // makes it optional, use 'required' rule if it should be required | |
| 949 | − if (typeof (phoneNumber) !== 'string') { return false; } | |
| 950 | − phoneNumber = phoneNumber.replace(/\s+/g, ""); | |
| 951 | − return validate && phoneNumber.length > 9 && phoneNumber.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/); | |
| 952 | − }, | |
| 953 | − message: 'Please specify a valid phone number.' | |
| 954 | −}; | |
| 955 | − | |
| 956 | −kv.rules['equal'] = { | |
| 957 | − validator: function (val, params) { | |
| 958 | − var otherValue = params; | |
| 959 | − return val === kv.utils.getValue(otherValue); | |
| 960 | − }, | |
| 961 | − message: 'Values must equal.' | |
| 962 | −}; | |
| 963 | − | |
| 964 | −kv.rules['notEqual'] = { | |
| 965 | − validator: function (val, params) { | |
| 966 | − var otherValue = params; | |
| 967 | − return val !== kv.utils.getValue(otherValue); | |
| 968 | − }, | |
| 969 | − message: 'Please choose another value.' | |
| 970 | −}; | |
| 971 | − | |
| 972 | −//unique in collection | |
| 973 | −// options are: | |
| 974 | −// collection: array or function returning (observable) array | |
| 975 | −// in which the value has to be unique | |
| 976 | −// valueAccessor: function that returns value from an object stored in collection | |
| 977 | −// if it is null the value is compared directly | |
| 978 | −// external: set to true when object you are validating is automatically updating collection | |
| 979 | −kv.rules['unique'] = { | |
| 980 | − validator: function (val, options) { | |
| 981 | − var c = kv.utils.getValue(options.collection), | |
| 982 | − external = kv.utils.getValue(options.externalValue), | |
| 983 | − counter = 0; | |
| 984 | − | |
| 985 | − if (!val || !c) { return true; } | |
| 986 | − | |
| 987 | − koUtils.arrayFilter(c, function (item) { | |
| 988 | − if (val === (options.valueAccessor ? options.valueAccessor(item) : item)) { counter++; } | |
| 989 | − }); | |
| 990 | − // if value is external even 1 same value in collection means the value is not unique | |
| 991 | − return counter < (!!external ? 1 : 2); | |
| 992 | − }, | |
| 993 | − message: 'Please make sure the value is unique.' | |
| 994 | −}; | |
| 995 | − | |
| 996 | − | |
| 997 | −//now register all of these! | |
| 998 | −(function () { | |
| 999 | − kv.registerExtenders(); | |
| 1000 | −}()); | |
| 1001 | −;// The core binding handler | |
| 1002 | −// this allows us to setup any value binding that internally always | |
| 1003 | −// performs the same functionality | |
| 1004 | −ko.bindingHandlers['validationCore'] = (function () { | |
| 1005 | − | |
| 1006 | − return { | |
| 1007 | − init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { | |
| 1008 | − var config = kv.utils.getConfigOptions(element); | |
| 1009 | − var observable = valueAccessor(); | |
| 1010 | − | |
| 1011 | − // parse html5 input validation attributes, optional feature | |
| 1012 | − if (config.parseInputAttributes) { | |
| 1013 | − kv.utils.async(function () { kv.parseInputValidationAttributes(element, valueAccessor); }); | |
| 1014 | − } | |
| 1015 | − | |
| 1016 | − // if requested insert message element and apply bindings | |
| 1017 | − if (config.insertMessages && kv.utils.isValidatable(observable)) { | |
| 1018 | − | |
| 1019 | − // insert the <span></span> | |
| 1020 | − var validationMessageElement = kv.insertValidationMessage(element); | |
| 1021 | − | |
| 1022 | − // if we're told to use a template, make sure that gets rendered | |
| 1023 | − if (config.messageTemplate) { | |
| 1024 | − ko.renderTemplate(config.messageTemplate, { field: observable }, null, validationMessageElement, 'replaceNode'); | |
| 1025 | − } else { | |
| 1026 | − ko.applyBindingsToNode(validationMessageElement, { validationMessage: observable }); | |
| 1027 | − } | |
| 1028 | − } | |
| 1029 | − | |
| 1030 | − // write the html5 attributes if indicated by the config | |
| 1031 | − if (config.writeInputAttributes && kv.utils.isValidatable(observable)) { | |
| 1032 | − | |
| 1033 | − kv.writeInputValidationAttributes(element, valueAccessor); | |
| 1034 | − } | |
| 1035 | − | |
| 1036 | − // if requested, add binding to decorate element | |
| 1037 | − if (config.decorateInputElement && kv.utils.isValidatable(observable)) { | |
| 1038 | − ko.applyBindingsToNode(element, { validationElement: observable }); | |
| 1039 | − } | |
| 1040 | − } | |
| 1041 | − }; | |
| 1042 | − | |
| 1043 | −}()); | |
| 1044 | − | |
| 1045 | −// override for KO's default 'value', 'checked', 'textInput' and selectedOptions bindings | |
| 1046 | −kv.makeBindingHandlerValidatable("value"); | |
| 1047 | −kv.makeBindingHandlerValidatable("checked"); | |
| 1048 | −if (ko.bindingHandlers.textInput) { | |
| 1049 | − kv.makeBindingHandlerValidatable("textInput"); | |
| 1050 | −} | |
| 1051 | −kv.makeBindingHandlerValidatable("selectedOptions"); | |
| 1052 | − | |
| 1053 | − | |
| 1054 | −ko.bindingHandlers['validationMessage'] = { // individual error message, if modified or post binding | |
| 1055 | − update: function (element, valueAccessor) { | |
| 1056 | − var obsv = valueAccessor(), | |
| 1057 | − config = kv.utils.getConfigOptions(element), | |
| 1058 | − val = unwrap(obsv), | |
| 1059 | − msg = null, | |
| 1060 | − isModified = false, | |
| 1061 | − isValid = false; | |
| 1062 | − | |
| 1063 | − if (obsv === null || typeof obsv === 'undefined') { | |
| 1064 | − throw new Error('Cannot bind validationMessage to undefined value. data-bind expression: ' + | |
| 1065 | − element.getAttribute('data-bind')); | |
| 1066 | − } | |
| 1067 | − | |
| 1068 | − isModified = obsv.isModified && obsv.isModified(); | |
| 1069 | − isValid = obsv.isValid && obsv.isValid(); | |
| 1070 | − | |
| 1071 | − var error = null; | |
| 1072 | − if (!config.messagesOnModified || isModified) { | |
| 1073 | − error = isValid ? null : obsv.error; | |
| 1074 | − } | |
| 1075 | − | |
| 1076 | − var isVisible = !config.messagesOnModified || isModified ? !isValid : false; | |
| 1077 | − var isCurrentlyVisible = element.style.display !== "none"; | |
| 1078 | − | |
| 1079 | − if (config.allowHtmlMessages) { | |
| 1080 | − koUtils.setHtml(element, error); | |
| 1081 | − } else { | |
| 1082 | − ko.bindingHandlers.text.update(element, function () { return error; }); | |
| 1083 | − } | |
| 1084 | − | |
| 1085 | − if (isCurrentlyVisible && !isVisible) { | |
| 1086 | − element.style.display = 'none'; | |
| 1087 | − } else if (!isCurrentlyVisible && isVisible) { | |
| 1088 | − element.style.display = ''; | |
| 1089 | − } | |
| 1090 | − } | |
| 1091 | −}; | |
| 1092 | − | |
| 1093 | −ko.bindingHandlers['validationElement'] = { | |
| 1094 | − update: function (element, valueAccessor, allBindingsAccessor) { | |
| 1095 | − var obsv = valueAccessor(), | |
| 1096 | − config = kv.utils.getConfigOptions(element), | |
| 1097 | − val = unwrap(obsv), | |
| 1098 | − msg = null, | |
| 1099 | − isModified = false, | |
| 1100 | − isValid = false; | |
| 1101 | − | |
| 1102 | − if (obsv === null || typeof obsv === 'undefined') { | |
| 1103 | − throw new Error('Cannot bind validationElement to undefined value. data-bind expression: ' + | |
| 1104 | − element.getAttribute('data-bind')); | |
| 1105 | − } | |
| 1106 | − | |
| 1107 | − isModified = obsv.isModified && obsv.isModified(); | |
| 1108 | − isValid = obsv.isValid && obsv.isValid(); | |
| 1109 | − | |
| 1110 | − // create an evaluator function that will return something like: | |
| 1111 | − // css: { validationElement: true } | |
| 1112 | − var cssSettingsAccessor = function () { | |
| 1113 | − var css = {}; | |
| 1114 | − | |
| 1115 | − var shouldShow = ((!config.decorateElementOnModified || isModified) ? !isValid : false); | |
| 1116 | − | |
| 1117 | − // css: { validationElement: false } | |
| 1118 | − css[config.errorElementClass] = shouldShow; | |
| 1119 | − | |
| 1120 | − return css; | |
| 1121 | − }; | |
| 1122 | − | |
| 1123 | − //add or remove class on the element; | |
| 1124 | − ko.bindingHandlers.css.update(element, cssSettingsAccessor, allBindingsAccessor); | |
| 1125 | − if (!config.errorsAsTitle) { return; } | |
| 1126 | − | |
| 1127 | − ko.bindingHandlers.attr.update(element, function () { | |
| 1128 | − var | |
| 1129 | − hasModification = !config.errorsAsTitleOnModified || isModified, | |
| 1130 | − title = kv.utils.getOriginalElementTitle(element); | |
| 1131 | − | |
| 1132 | − if (hasModification && !isValid) { | |
| 1133 | − return { title: obsv.error, 'data-orig-title': title }; | |
| 1134 | − } else if (!hasModification || isValid) { | |
| 1135 | − return { title: title, 'data-orig-title': null }; | |
| 1136 | − } | |
| 1137 | − }); | |
| 1138 | − } | |
| 1139 | −}; | |
| 1140 | − | |
| 1141 | −// ValidationOptions: | |
| 1142 | −// This binding handler allows you to override the initial config by setting any of the options for a specific element or context of elements | |
| 1143 | −// | |
| 1144 | −// Example: | |
| 1145 | −// <div data-bind="validationOptions: { insertMessages: true, messageTemplate: 'customTemplate', errorMessageClass: 'mySpecialClass'}"> | |
| 1146 | −// <input type="text" data-bind="value: someValue"/> | |
| 1147 | −// <input type="text" data-bind="value: someValue2"/> | |
| 1148 | −// </div> | |
| 1149 | −ko.bindingHandlers['validationOptions'] = (function () { | |
| 1150 | − return { | |
| 1151 | − init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { | |
| 1152 | − var options = unwrap(valueAccessor()); | |
| 1153 | − if (options) { | |
| 1154 | − var newConfig = extend({}, kv.configuration); | |
| 1155 | − extend(newConfig, options); | |
| 1156 | − | |
| 1157 | − //store the validation options on the node so we can retrieve it later | |
| 1158 | − kv.utils.setDomData(element, newConfig); | |
| 1159 | − } | |
| 1160 | − } | |
| 1161 | − }; | |
| 1162 | −}()); | |
| 1163 | −;// Validation Extender: | |
| 1164 | −// This is for creating custom validation logic on the fly | |
| 1165 | −// Example: | |
| 1166 | −// var test = ko.observable('something').extend{( | |
| 1167 | −// validation: { | |
| 1168 | −// validator: function(val, someOtherVal){ | |
| 1169 | −// return true; | |
| 1170 | −// }, | |
| 1171 | −// message: "Something must be really wrong!', | |
| 1172 | −// params: true | |
| 1173 | −// } | |
| 1174 | −// )}; | |
| 1175 | −ko.extenders['validation'] = function (observable, rules) { // allow single rule or array | |
| 1176 | − forEach(kv.utils.isArray(rules) ? rules : [rules], function (rule) { | |
| 1177 | − // the 'rule' being passed in here has no name to identify a core Rule, | |
| 1178 | − // so we add it as an anonymous rule | |
| 1179 | − // If the developer is wanting to use a core Rule, but use a different message see the 'addExtender' logic for examples | |
| 1180 | − kv.addAnonymousRule(observable, rule); | |
| 1181 | − }); | |
| 1182 | − return observable; | |
| 1183 | −}; | |
| 1184 | − | |
| 1185 | −//This is the extender that makes a Knockout Observable also 'Validatable' | |
| 1186 | −//examples include: | |
| 1187 | −// 1. var test = ko.observable('something').extend({validatable: true}); | |
| 1188 | −// this will ensure that the Observable object is setup properly to respond to rules | |
| 1189 | −// | |
| 1190 | −// 2. test.extend({validatable: false}); | |
| 1191 | −// this will remove the validation properties from the Observable object should you need to do that. | |
| 1192 | −ko.extenders['validatable'] = function (observable, options) { | |
| 1193 | − if (!kv.utils.isObject(options)) { | |
| 1194 | − options = { enable: options }; | |
| 1195 | − } | |
| 1196 | − | |
| 1197 | − if (!('enable' in options)) { | |
| 1198 | − options.enable = true; | |
| 1199 | − } | |
| 1200 | − | |
| 1201 | − if (options.enable && !kv.utils.isValidatable(observable)) { | |
| 1202 | − var config = kv.configuration.validate || {}; | |
| 1203 | − var validationOptions = { | |
| 1204 | − throttleEvaluation : options.throttle || config.throttle | |
| 1205 | − }; | |
| 1206 | − | |
| 1207 | − observable.error = ko.observable(null); // holds the error message, we only need one since we stop processing validators when one is invalid | |
| 1208 | − | |
| 1209 | − // observable.rules: | |
| 1210 | − // ObservableArray of Rule Contexts, where a Rule Context is simply the name of a rule and the params to supply to it | |
| 1211 | − // | |
| 1212 | − // Rule Context = { rule: '<rule name>', params: '<passed in params>', message: '<Override of default Message>' } | |
| 1213 | − observable.rules = ko.observableArray(); //holds the rule Contexts to use as part of validation | |
| 1214 | − | |
| 1215 | − //in case async validation is occurring | |
| 1216 | − observable.isValidating = ko.observable(false); | |
| 1217 | − | |
| 1218 | − //the true holder of whether the observable is valid or not | |
| 1219 | − observable.__valid__ = ko.observable(true); | |
| 1220 | − | |
| 1221 | − observable.isModified = ko.observable(false); | |
| 1222 | − | |
| 1223 | − // a semi-protected observable | |
| 1224 | − observable.isValid = ko.computed(observable.__valid__); | |
| 1225 | − | |
| 1226 | − //manually set error state | |
| 1227 | − observable.setError = function (error) { | |
| 1228 | − var previousError = observable.error.peek(); | |
| 1229 | − var previousIsValid = observable.__valid__.peek(); | |
| 1230 | − | |
| 1231 | − observable.error(error); | |
| 1232 | − observable.__valid__(false); | |
| 1233 | − | |
| 1234 | − if (previousError !== error && !previousIsValid) { | |
| 1235 | − // if the observable was not valid before then isValid will not mutate, | |
| 1236 | − // hence causing any grouping to not display the latest error. | |
| 1237 | − observable.isValid.notifySubscribers(); | |
| 1238 | − } | |
| 1239 | − }; | |
| 1240 | − | |
| 1241 | − //manually clear error state | |
| 1242 | − observable.clearError = function () { | |
| 1243 | − observable.error(null); | |
| 1244 | − observable.__valid__(true); | |
| 1245 | − return observable; | |
| 1246 | − }; | |
| 1247 | − | |
| 1248 | − //subscribe to changes in the observable | |
| 1249 | − var h_change = observable.subscribe(function () { | |
| 1250 | − observable.isModified(true); | |
| 1251 | − }); | |
| 1252 | − | |
| 1253 | − // we use a computed here to ensure that anytime a dependency changes, the | |
| 1254 | − // validation logic evaluates | |
| 1255 | − var h_obsValidationTrigger = ko.computed(extend({ | |
| 1256 | − read: function () { | |
| 1257 | − var obs = observable(), | |
| 1258 | − ruleContexts = observable.rules(); | |
| 1259 | − | |
| 1260 | − kv.validateObservable(observable); | |
| 1261 | − | |
| 1262 | − return true; | |
| 1263 | − } | |
| 1264 | − }, validationOptions)); | |
| 1265 | − | |
| 1266 | − extend(h_obsValidationTrigger, validationOptions); | |
| 1267 | − | |
| 1268 | − observable._disposeValidation = function () { | |
| 1269 | − //first dispose of the subscriptions | |
| 1270 | − observable.isValid.dispose(); | |
| 1271 | − observable.rules.removeAll(); | |
| 1272 | − h_change.dispose(); | |
| 1273 | − h_obsValidationTrigger.dispose(); | |
| 1274 | − | |
| 1275 | − delete observable['rules']; | |
| 1276 | − delete observable['error']; | |
| 1277 | − delete observable['isValid']; | |
| 1278 | − delete observable['isValidating']; | |
| 1279 | − delete observable['__valid__']; | |
| 1280 | − delete observable['isModified']; | |
| 1281 | − delete observable['setError']; | |
| 1282 | − delete observable['clearError']; | |
| 1283 | − delete observable['_disposeValidation']; | |
| 1284 | − }; | |
| 1285 | − } else if (options.enable === false && observable._disposeValidation) { | |
| 1286 | − observable._disposeValidation(); | |
| 1287 | − } | |
| 1288 | − return observable; | |
| 1289 | −}; | |
| 1290 | − | |
| 1291 | −function validateSync(observable, rule, ctx) { | |
| 1292 | − //Execute the validator and see if its valid | |
| 1293 | − if (!rule.validator(observable(), (ctx.params === undefined ? true : unwrap(ctx.params)))) { // default param is true, eg. required = true | |
| 1294 | − | |
| 1295 | − //not valid, so format the error message and stick it in the 'error' variable | |
| 1296 | − observable.setError(kv.formatMessage( | |
| 1297 | − ctx.message || rule.message, | |
| 1298 | − unwrap(ctx.params), | |
| 1299 | − observable)); | |
| 1300 | − return false; | |
| 1301 | − } else { | |
| 1302 | − return true; | |
| 1303 | − } | |
| 1304 | −} | |
| 1305 | − | |
| 1306 | −function validateAsync(observable, rule, ctx) { | |
| 1307 | − observable.isValidating(true); | |
| 1308 | − | |
| 1309 | − var callBack = function (valObj) { | |
| 1310 | − var isValid = false, | |
| 1311 | − msg = ''; | |
| 1312 | − | |
| 1313 | − if (!observable.__valid__()) { | |
| 1314 | − | |
| 1315 | − // since we're returning early, make sure we turn this off | |
| 1316 | − observable.isValidating(false); | |
| 1317 | − | |
| 1318 | − return; //if its already NOT valid, don't add to that | |
| 1319 | − } | |
| 1320 | − | |
| 1321 | − //we were handed back a complex object | |
| 1322 | − if (valObj['message']) { | |
| 1323 | − isValid = valObj.isValid; | |
| 1324 | − msg = valObj.message; | |
| 1325 | − } else { | |
| 1326 | − isValid = valObj; | |
| 1327 | − } | |
| 1328 | − | |
| 1329 | − if (!isValid) { | |
| 1330 | − //not valid, so format the error message and stick it in the 'error' variable | |
| 1331 | − observable.error(kv.formatMessage( | |
| 1332 | − msg || ctx.message || rule.message, | |
| 1333 | − unwrap(ctx.params), | |
| 1334 | − observable)); | |
| 1335 | − observable.__valid__(isValid); | |
| 1336 | − } | |
| 1337 | − | |
| 1338 | − // tell it that we're done | |
| 1339 | − observable.isValidating(false); | |
| 1340 | − }; | |
| 1341 | − | |
| 1342 | − kv.utils.async(function() { | |
| 1343 | − //fire the validator and hand it the callback | |
| 1344 | − rule.validator(observable(), ctx.params === undefined ? true : unwrap(ctx.params), callBack); | |
| 1345 | − }); | |
| 1346 | −} | |
| 1347 | − | |
| 1348 | −kv.validateObservable = function (observable) { | |
| 1349 | − var i = 0, | |
| 1350 | − rule, // the rule validator to execute | |
| 1351 | − ctx, // the current Rule Context for the loop | |
| 1352 | − ruleContexts = observable.rules(), //cache for iterator | |
| 1353 | − len = ruleContexts.length; //cache for iterator | |
| 1354 | − | |
| 1355 | − for (; i < len; i++) { | |
| 1356 | − | |
| 1357 | − //get the Rule Context info to give to the core Rule | |
| 1358 | − ctx = ruleContexts[i]; | |
| 1359 | − | |
| 1360 | − // checks an 'onlyIf' condition | |
| 1361 | − if (ctx.condition && !ctx.condition()) { | |
| 1362 | − continue; | |
| 1363 | − } | |
| 1364 | − | |
| 1365 | − //get the core Rule to use for validation | |
| 1366 | − rule = ctx.rule ? kv.rules[ctx.rule] : ctx; | |
| 1367 | − | |
| 1368 | − if (rule['async'] || ctx['async']) { | |
| 1369 | − //run async validation | |
| 1370 | − validateAsync(observable, rule, ctx); | |
| 1371 | − | |
| 1372 | − } else { | |
| 1373 | − //run normal sync validation | |
| 1374 | − if (!validateSync(observable, rule, ctx)) { | |
| 1375 | − return false; //break out of the loop | |
| 1376 | − } | |
| 1377 | − } | |
| 1378 | − } | |
| 1379 | − //finally if we got this far, make the observable valid again! | |
| 1380 | − observable.clearError(); | |
| 1381 | − return true; | |
| 1382 | −}; | |
| 1383 | −; | |
| 1384 | −var _locales = {}; | |
| 1385 | −var _currentLocale; | |
| 1386 | − | |
| 1387 | −kv.defineLocale = function(name, values) { | |
| 1388 | − if (name && values) { | |
| 1389 | − _locales[name.toLowerCase()] = values; | |
| 1390 | − return values; | |
| 1391 | − } | |
| 1392 | − return null; | |
| 1393 | −}; | |
| 1394 | − | |
| 1395 | −kv.locale = function(name) { | |
| 1396 | − if (name) { | |
| 1397 | − name = name.toLowerCase(); | |
| 1398 | − | |
| 1399 | − if (_locales.hasOwnProperty(name)) { | |
| 1400 | − kv.localize(_locales[name]); | |
| 1401 | − _currentLocale = name; | |
| 1402 | − } | |
| 1403 | − else { | |
| 1404 | − throw new Error('Localization ' + name + ' has not been loaded.'); | |
| 1405 | − } | |
| 1406 | − } | |
| 1407 | − return _currentLocale; | |
| 1408 | −}; | |
| 1409 | − | |
| 1410 | −//quick function to override rule messages | |
| 1411 | −kv.localize = function (msgTranslations) { | |
| 1412 | − var rules = kv.rules; | |
| 1413 | − | |
| 1414 | − //loop the properties in the object and assign the msg to the rule | |
| 1415 | − for (var ruleName in msgTranslations) { | |
| 1416 | − if (rules.hasOwnProperty(ruleName)) { | |
| 1417 | − rules[ruleName].message = msgTranslations[ruleName]; | |
| 1418 | − } | |
| 1419 | − } | |
| 1420 | −}; | |
| 1421 | − | |
| 1422 | −// Populate default locale (this will make en-US.js somewhat redundant) | |
| 1423 | −(function() { | |
| 1424 | − var localeData = {}; | |
| 1425 | − var rules = kv.rules; | |
| 1426 | − | |
| 1427 | − for (var ruleName in rules) { | |
| 1428 | − if (rules.hasOwnProperty(ruleName)) { | |
| 1429 | − localeData[ruleName] = rules[ruleName].message; | |
| 1430 | − } | |
| 1431 | − } | |
| 1432 | − kv.defineLocale('en-us', localeData); | |
| 1433 | −})(); | |
| 1434 | − | |
| 1435 | −// No need to invoke locale because the messages are already defined along with the rules for en-US | |
| 1436 | −_currentLocale = 'en-us'; | |
| 1437 | −;/** | |
| 1438 | − * Possible invocations: | |
| 1439 | − * applyBindingsWithValidation(viewModel) | |
| 1440 | − * applyBindingsWithValidation(viewModel, options) | |
| 1441 | − * applyBindingsWithValidation(viewModel, rootNode) | |
| 1442 | − * applyBindingsWithValidation(viewModel, rootNode, options) | |
| 1443 | − */ | |
| 1444 | −ko.applyBindingsWithValidation = function (viewModel, rootNode, options) { | |
| 1445 | − var node = document.body, | |
| 1446 | − config; | |
| 1447 | − | |
| 1448 | − if (rootNode && rootNode.nodeType) { | |
| 1449 | − node = rootNode; | |
| 1450 | − config = options; | |
| 1451 | − } | |
| 1452 | − else { | |
| 1453 | − config = rootNode; | |
| 1454 | − } | |
| 1455 | − | |
| 1456 | − kv.init(); | |
| 1457 | − | |
| 1458 | − if (config) { | |
| 1459 | − config = extend(extend({}, kv.configuration), config); | |
| 1460 | − kv.utils.setDomData(node, config); | |
| 1461 | − } | |
| 1462 | − | |
| 1463 | − ko.applyBindings(viewModel, node); | |
| 1464 | −}; | |
| 1465 | − | |
| 1466 | −//override the original applyBindings so that we can ensure all new rules and what not are correctly registered | |
| 1467 | −var origApplyBindings = ko.applyBindings; | |
| 1468 | −ko.applyBindings = function (viewModel, rootNode) { | |
| 1469 | − | |
| 1470 | − kv.init(); | |
| 1471 | − | |
| 1472 | − origApplyBindings(viewModel, rootNode); | |
| 1473 | −}; | |
| 1474 | − | |
| 1475 | −ko.validatedObservable = function (initialValue, options) { | |
| 1476 | − if (!options && !kv.utils.isObject(initialValue)) { | |
| 1477 | − return ko.observable(initialValue).extend({ validatable: true }); | |
| 1478 | − } | |
| 1479 | − | |
| 1480 | − var obsv = ko.observable(initialValue); | |
| 1481 | − obsv.errors = kv.group(kv.utils.isObject(initialValue) ? initialValue : {}, options); | |
| 1482 | − obsv.isValid = ko.observable(obsv.errors().length === 0); | |
| 1483 | − | |
| 1484 | − if (ko.isObservable(obsv.errors)) { | |
| 1485 | − obsv.errors.subscribe(function(errors) { | |
| 1486 | − obsv.isValid(errors.length === 0); | |
| 1487 | − }); | |
| 1488 | − } | |
| 1489 | − else { | |
| 1490 | − ko.computed(obsv.errors).subscribe(function (errors) { | |
| 1491 | − obsv.isValid(errors.length === 0); | |
| 1492 | − }); | |
| 1493 | − } | |
| 1494 | − | |
| 1495 | − obsv.subscribe(function(newValue) { | |
| 1496 | − if (!kv.utils.isObject(newValue)) { | |
| 1497 | − /* | |
| 1498 | − * The validation group works on objects. | |
| 1499 | − * Since the new value is a primitive (scalar, null or undefined) we need | |
| 1500 | − * to create an empty object to pass along. | |
| 1501 | − */ | |
| 1502 | − newValue = {}; | |
| 1503 | − } | |
| 1504 | − // Force the group to refresh | |
| 1505 | − obsv.errors._updateState(newValue); | |
| 1506 | − obsv.isValid(obsv.errors().length === 0); | |
| 1507 | − }); | |
| 1508 | − | |
| 1509 | − return obsv; | |
| 1510 | −}; | |
| 1511 | −;})); | |