mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-04 14:02:17 +08:00
Drop support for old browsers and some jQuery
This commit is contained in:
parent
091c4ec811
commit
d06fed09d6
38 changed files with 6137 additions and 872 deletions
6
vendors/knockout/Gruntfile.js
vendored
6
vendors/knockout/Gruntfile.js
vendored
|
@ -4,6 +4,8 @@ module.exports = function(grunt) {
|
|||
|
||||
// Project configuration
|
||||
grunt.initConfig({
|
||||
// language_in:'ECMASCRIPT6',
|
||||
// language_out:'ECMASCRIPT6',
|
||||
// Metadata
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
fragments: './build/fragments/',
|
||||
|
@ -109,6 +111,8 @@ module.exports = function(grunt) {
|
|||
function buildMin(output, done) {
|
||||
var cc = require('closure-compiler');
|
||||
var options = {
|
||||
// language_in:'ECMASCRIPT6',
|
||||
// language_out:'ECMASCRIPT6',
|
||||
compilation_level: 'ADVANCED_OPTIMIZATIONS',
|
||||
output_wrapper: '(function() {%output%})();'
|
||||
};
|
||||
|
@ -156,6 +160,7 @@ module.exports = function(grunt) {
|
|||
});
|
||||
|
||||
grunt.registerMultiTask('testtypes', 'Run types tests', function () {
|
||||
/*
|
||||
var done = this.async(),
|
||||
target = this.target;
|
||||
|
||||
|
@ -171,6 +176,7 @@ module.exports = function(grunt) {
|
|||
done(!error);
|
||||
}
|
||||
);
|
||||
*/
|
||||
});
|
||||
|
||||
grunt.registerTask('dist', function() {
|
||||
|
|
|
@ -16,7 +16,6 @@ knockoutDebugCallback([
|
|||
'src/subscribables/observableArray.js',
|
||||
'src/subscribables/observableArray.changeTracking.js',
|
||||
'src/subscribables/dependentObservable.js',
|
||||
'src/subscribables/mappingHelpers.js',
|
||||
'src/subscribables/observableUtils.js',
|
||||
'src/binding/selectExtensions.js',
|
||||
'src/binding/expressionRewriting.js',
|
||||
|
@ -55,6 +54,5 @@ knockoutDebugCallback([
|
|||
'src/templating/templating.js',
|
||||
'src/binding/editDetection/compareArrays.js',
|
||||
'src/binding/editDetection/arrayToDomNodeChildren.js',
|
||||
'src/templating/native/nativeTemplateEngine.js',
|
||||
'src/templating/jquery.tmpl/jqueryTmplTemplateEngine.js'
|
||||
'src/templating/native/nativeTemplateEngine.js'
|
||||
]);
|
||||
|
|
5877
vendors/knockout/build/output/knockout-latest.debug.js
vendored
Normal file
5877
vendors/knockout/build/output/knockout-latest.debug.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
122
vendors/knockout/build/output/knockout-latest.js
vendored
Normal file
122
vendors/knockout/build/output/knockout-latest.js
vendored
Normal file
|
@ -0,0 +1,122 @@
|
|||
/*!
|
||||
* Knockout JavaScript library v3.5.1-pre
|
||||
* (c) The Knockout.js team - http://knockoutjs.com/
|
||||
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
(function() {(function(n){var G=this||(0,eval)("this"),z=G.document,I=G.jQuery;I||"undefined"===typeof jQuery||(I=jQuery);(function(n){"function"===typeof define&&define.amd?define(["exports","require"],n):"object"===typeof exports&&"object"===typeof module?n(module.exports||exports):n(G.ko={})})(function(I,R){function L(a,c){return null===a||typeof a in U?a===c:!1}function V(b,c){var d;return function(){d||(d=a.a.setTimeout(function(){d=n;b()},c))}}function W(b,c){var d;return function(){clearTimeout(d);d=a.a.setTimeout(b,
|
||||
c)}}function X(a,c){c&&"change"!==c?"beforeChange"===c?this.hc(a):this.bb(a,c):this.ic(a)}function Y(a,c){null!==c&&c.s&&c.s()}function Z(a,c){var d=this.bd,e=d[q];e.pa||(this.Jb&&this.ib[c]?(d.mc(c,a,this.ib[c]),this.ib[c]=null,--this.Jb):e.F[c]||d.mc(c,a,e.G?{aa:a}:d.Oc(a)),a.Ga&&a.Tc())}function O(a,c,d){if(c){var e=d?"add":"remove";c.split(/\s+/).forEach(function(c){a.classList[e](c)})}}var a="undefined"!==typeof I?I:{};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.I=function(a,c,d){a[c]=d};a.version="3.5.1-pre";a.b("version",a.version);a.options={deferUpdates:!1,useOnlyNativeEvents:!1,foreachHidesDestroyed:!1};a.a=function(){function b(a,b){b&&Object.entries(b).forEach(function(b){a[b[0]]=b[1]});return a}function c(a,b){a.__proto__=b;return a}var d={__proto__:[]}instanceof Array,e={Kd:"KeyboardEvent",Id:"KeyboardEvent",Jd:"KeyboardEvent",click:"MouseEvent",Gd:"MouseEvent",Ld:"MouseEvent",Rd:"MouseEvent",Od:"MouseEvent",Qd:"MouseEvent",
|
||||
Pd:"MouseEvent",Md:"MouseEvent",Nd:"MouseEvent"};return{K:function(a,b,c){for(var d=0,e=a.length;d<e;d++)b.call(c,a[d],d,a)},L:function(a,b){return Array.prototype.indexOf.call(a,b)},Fb:function(a,b,c){for(var d=0,e=a.length;d<e;d++)if(b.call(c,a[d],d,a))return a[d];return n},Ma:function(b,c){var d=a.a.L(b,c);0<d?b.splice(d,1):0===d&&b.shift()},fb:function(a,b,c){return a?Array.prototype.filter.call(a,b,c):[]},Gb: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},ya:d,extend:b,setPrototypeOf:c,wb:d?c:b,O:function(a,b){a&&Object.entries(a).forEach(function(a){b(a[0],a[1])})},Da:function(a,b,c){if(!a)return a;var d={};Object.entries(a).forEach(function(e){d[e[0]]=b.call(c,e[1],e[0],a)});return d},Mb:function(b){for(;b.firstChild;)a.removeNode(b.firstChild)},Rb:function(b){b=a.a.Ca(b);for(var c=(b[0]&&b[0].ownerDocument||z).createElement("div"),d=0,e=b.length;d<e;d++)c.appendChild(a.ma(b[d]));return c},za:function(b,c){for(var d=
|
||||
0,e=b.length,k=[];d<e;d++){var l=b[d].cloneNode(!0);k.push(c?a.ma(l):l)}return k},ta:function(b,c){a.a.Mb(b);if(c)for(var d=0,e=c.length;d<e;d++)b.appendChild(c[d])},Mc:function(b,c){var d=b.nodeType?[b]:b;if(0<d.length){var e=d[0],k=e.parentNode,l,p;l=0;for(p=c.length;l<p;l++)k.insertBefore(c[l],e);l=0;for(p=d.length;l<p;l++)a.removeNode(d[l])}},Ra: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),c=c.nextSibling;a.push(d)}}return a},$b:function(a){return null===a||a===n?"":a.trim?a.trim():a.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")},Bd:function(a,b){a=a||"";return b.length>a.length?!1:a.substring(0,b.length)===b},fd:function(a,b){return b.contains(1!==a.nodeType?a.parentNode:a)},Lb:function(b){return a.a.fd(b,b.ownerDocument.documentElement)},Wc:function(b){return!!a.a.Fb(b,a.a.Lb)},$:function(a){return a&&
|
||||
a.tagName&&a.tagName.toLowerCase()},rc: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.rc(b),c)},xc:function(b){setTimeout(function(){a.onError&&a.onError(b);throw b;},0)},H:function(b,c,d){d=a.a.rc(d);if(!a.options.useOnlyNativeEvents&&jQuery)jQuery(b).on(c,d);else b.addEventListener(c,d,!1)},zb:function(b,c){if(!b||!b.nodeType)throw Error("element must be a DOM node when calling triggerEvent");
|
||||
var d;"INPUT"===b.nodeName&&b.type&&"click"==c.toLowerCase()?(d=b.type,d="checkbox"==d||"radio"==d):d=!1;a.options.useOnlyNativeEvents||!jQuery||d?(d=z.createEvent(e[c]||"HTMLEvents"),d.initEvent(c,!0,!0,G,0,0,0,0,0,!1,!1,!1,!1,0,b),b.dispatchEvent(d)):jQuery(b).trigger(c)},g:function(b){return a.R(b)?b():b},Vb:function(b){return a.R(b)?b.v():b},xb:function(b,c){var d=a.a.g(c);if(null===d||d===n)d="";var e=a.f.firstChild(b);!e||3!=e.nodeType||a.f.nextSibling(e)?a.f.ta(b,[b.ownerDocument.createTextNode(d)]):
|
||||
e.data=d},Ca:function(a){return Array.from(a)}}}();a.b("utils",a.a);a.b("utils.arrayForEach",a.a.K);a.b("utils.arrayFirst",a.a.Fb);a.b("utils.arrayFilter",a.a.fb);a.b("utils.arrayIndexOf",a.a.L);a.b("utils.arrayPushAll",a.a.Gb);a.b("utils.arrayRemoveItem",a.a.Ma);a.b("utils.cloneNodes",a.a.za);a.b("utils.extend",a.a.extend);a.b("utils.objectMap",a.a.Da);a.b("utils.peekObservable",a.a.Vb);a.b("utils.registerEventHandler",a.a.H);a.b("utils.stringifyJson",a.a.Sd);a.b("utils.triggerEvent",a.a.zb);a.b("utils.unwrapObservable",
|
||||
a.a.g);a.b("utils.objectForEach",a.a.O);a.b("utils.setTextContent",a.a.xb);a.b("unwrap",a.a.g);a.a.h=new function(){var a=0,c="__ko__"+Date.now(),d;d=function(a,b){var d=a[c];!d&&b&&(d=a[c]={});return d};return{get:function(a,b){var c=d(a,!1);return c&&c[b]},set:function(a,b,c){(a=d(a,c!==n))&&(a[b]=c)},Nb:function(a,b,c){a=d(a,!0);return a[b]||(a[b]=c)},clear:function(a){return a[c]?(delete a[c],!0):!1},fa:function(){return a++ +c}}};a.b("utils.domData",a.a.h);a.b("utils.domData.clear",a.a.h.clear);
|
||||
a.a.N=new function(){function b(b,c){var d=a.a.h.get(b,e);d===n&&c&&(d=[],a.a.h.set(b,e,d));return d}function c(c){var e=b(c,!1);if(e)for(var e=e.slice(0),k=0;k<e.length;k++)e[k](c);a.a.h.clear(c);a.a.N.cleanExternalData(c);g[c.nodeType]&&d(c.childNodes,!0)}function d(b,d){for(var e=[],l,f=0;f<b.length;f++)if(!d||8===b[f].nodeType)if(c(e[e.length]=l=b[f]),b[f]!==l)for(;f--&&-1==a.a.L(e,b[f]););}var e=a.a.h.fa(),f={1:!0,8:!0,9:!0},g={1:!0,9:!0};return{Ka:function(a,c){if("function"!=typeof c)throw Error("Callback must be a function");
|
||||
b(a,!0).push(c)},ub:function(c,d){var k=b(c,!1);k&&(a.a.Ma(k,d),0==k.length&&a.a.h.set(c,e,n))},ma:function(b){a.u.C(function(){f[b.nodeType]&&(c(b),g[b.nodeType]&&d(b.getElementsByTagName("*")))});return b},removeNode:function(b){a.ma(b);b.parentNode&&b.parentNode.removeChild(b)},cleanExternalData:function(a){jQuery&&jQuery.cleanData&&jQuery.cleanData([a])}}};a.ma=a.a.N.ma;a.removeNode=a.a.N.removeNode;a.b("cleanNode",a.ma);a.b("removeNode",a.removeNode);a.b("utils.domNodeDisposal",a.a.N);a.b("utils.domNodeDisposal.addDisposeCallback",
|
||||
a.a.N.Ka);a.b("utils.domNodeDisposal.removeDisposeCallback",a.a.N.ub);(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};a.a.sa=function(c,d){var e=d;e||(e=z);var k=e.parentWindow||e.defaultView||G,l=a.a.$b(c).toLowerCase(),e=e.createElement("div"),p;p=(l=l.match(/^(?:\x3c!--.*?--\x3e\s*?)*?<([a-z]+)[\s>]/))&&
|
||||
f[l[1]]||b;l=p[0];p="ignored<div>"+p[1]+c+p[2]+"</div>";for("function"==typeof k.innerShiv?e.appendChild(k.innerShiv(p)):e.innerHTML=p;l--;)e=e.lastChild;return a.a.Ca(e.lastChild.childNodes)};a.a.wd=function(b,c){var d=a.a.sa(b,c);return d.length&&d[0].parentElement||a.a.Rb(d)};a.a.Zb=function(b,c){a.a.Mb(b);c=a.a.g(c);if(null!==c&&c!==n){"string"!=typeof c&&(c=c.toString());for(var d=a.a.sa(c,b.ownerDocument),e=0;e<d.length;e++)b.appendChild(d[e])}}})();a.b("utils.parseHtmlFragment",a.a.sa);a.b("utils.setHtml",
|
||||
a.a.Zb);a.Y=function(){function b(c,e){if(c)if(8==c.nodeType){var f=a.Y.Jc(c.nodeValue);null!=f&&e.push({ed:c,sd:f})}else if(1==c.nodeType)for(var f=0,g=c.childNodes,h=g.length;f<h;f++)b(g[f],e)}var c={};return{Qb: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"},Pc: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||[]),!0}finally{delete c[a]}},Qc:function(c,e){var f=[];b(c,f);for(var g=0,h=f.length;g<h;g++){var m=f[g].ed,k=[m];e&&a.a.Gb(k,e);a.Y.Pc(f[g].sd,k);m.nodeValue="";m.parentNode&&m.parentNode.removeChild(m)}},Jc:function(a){return(a=a.match(/^\[ko_memo\:(.*?)\]$/))?a[1]:null}}}();a.b("memoization",a.Y);a.b("memoization.memoize",a.Y.Qb);a.b("memoization.unmemoize",
|
||||
a.Y.Pc);a.b("memoization.parseMemoText",a.Y.Jc);a.b("memoization.unmemoizeDomNodeAndDescendants",a.Y.Qc);a.la=function(){function b(){if(f)for(var b=f,c=0,d;h<f;)if(d=e[h++]){if(h>b){if(5E3<=++c){h=f;a.a.xc(Error("'Too much recursion' after processing "+c+" task groups."));break}b=f}try{d()}catch(p){a.a.xc(p)}}}function c(){b();h=f=e.length=0}var d,e=[],f=0,g=1,h=0;G.MutationObserver?d=function(a){var b=z.createElement("div");(new MutationObserver(a)).observe(b,{attributes:!0});return function(){b.classList.toggle("foo")}}(c):
|
||||
d=z&&"onreadystatechange"in z.createElement("script")?function(a){var b=z.createElement("script");b.onreadystatechange=function(){b.onreadystatechange=null;z.documentElement.removeChild(b);b=null;a()};z.documentElement.appendChild(b)}:function(a){setTimeout(a,0)};return{scheduler:d,vb:function(b){f||a.la.scheduler(c);e[f++]=b;return g++},cancel:function(a){a=a-(g-f);a>=h&&a<f&&(e[a]=null)},resetForTesting:function(){var a=f-h;h=f=e.length=0;return a},zd:b}}();a.b("tasks",a.la);a.b("tasks.schedule",
|
||||
a.la.vb);a.b("tasks.runEarly",a.la.zd);a.Qa={throttle:function(b,c){b.throttleEvaluation=c;var d=null;return a.X({read:b,write:function(e){clearTimeout(d);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.Bb=!1;f="function"==typeof e?e:"notifyWhenChangesStop"==e?W:V;a.qb(function(a){return f(a,d,c)})},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.Bb||(b.Bb=!0,b.qb(function(c){var e,f=!1;return function(){if(!f){a.la.cancel(e);e=a.la.vb(c);try{f=!0,b.notifySubscribers(n,"dirty")}finally{f=!1}}}}))},notify:function(a,c){a.equalityComparer="always"==c?null:L}};var U={undefined:1,"boolean":1,number:1,string:1};a.b("extenders",a.Qa);a.ac=function(b,c,d){this.aa=b;this.dc=c;this.ec=d;this.Cb=!1;this.ab=this.Db=null;a.I(this,"dispose",this.s);a.I(this,"disposeWhenNodeIsRemoved",this.l)};a.ac.prototype.s=function(){this.Cb||(this.ab&&a.a.N.ub(this.Db,
|
||||
this.ab),this.Cb=!0,this.ec(),this.aa=this.dc=this.ec=this.Db=this.ab=null)};a.ac.prototype.l=function(b){this.Db=b;a.a.N.Ka(b,this.ab=this.s.bind(this))};a.S=function(){a.a.wb(this,C);C.mb(this)};var C={mb:function(a){a.T={change:[]};a.kc=1},subscribe:function(b,c,d){var e=this;d=d||"change";var f=new a.ac(e,c?b.bind(c):b,function(){a.a.Ma(e.T[d],f);e.cb&&e.cb(d)});e.Na&&e.Na(d);e.T[d]||(e.T[d]=[]);e.T[d].push(f);return f},notifySubscribers:function(b,c){c=c||"change";"change"===c&&this.Ab();if(this.Ta(c)){var d=
|
||||
"change"===c&&this.Rc||this.T[c].slice(0);try{a.u.oc();for(var e=0,f;f=d[e];++e)f.Cb||f.dc(b)}finally{a.u.end()}}},kb:function(){return this.kc},md:function(a){return this.kb()!==a},Ab:function(){++this.kc},qb:function(b){var c=this,d=a.R(c),e,f,g,h,m;c.bb||(c.bb=c.notifySubscribers,c.notifySubscribers=X);var k=b(function(){c.Ga=!1;d&&h===c&&(h=c.fc?c.fc():c());var a=f||m&&c.ob(g,h);m=f=e=!1;a&&c.bb(g=h)});c.ic=function(a,b){b&&c.Ga||(m=!b);c.Rc=c.T.change.slice(0);c.Ga=e=!0;h=a;k()};c.hc=function(a){e||
|
||||
(g=a,c.bb(a,"beforeChange"))};c.jc=function(){m=!0};c.Tc=function(){c.ob(g,c.v(!0))&&(f=!0)}},Ta:function(a){return this.T[a]&&this.T[a].length},kd:function(b){if(b)return this.T[b]&&this.T[b].length||0;var c=0;a.a.O(this.T,function(a,b){"dirty"!==a&&(c+=b.length)});return c},ob:function(a,c){return!this.equalityComparer||!this.equalityComparer(a,c)},toString:function(){return"[object Object]"},extend:function(b){var c=this;b&&a.a.O(b,function(b,e){var f=a.Qa[b];"function"==typeof f&&(c=f(c,e)||c)});
|
||||
return c}};a.I(C,"init",C.mb);a.I(C,"subscribe",C.subscribe);a.I(C,"extend",C.extend);a.I(C,"getSubscriptionsCount",C.kd);a.a.ya&&a.a.setPrototypeOf(C,Function.prototype);a.S.fn=C;a.Fc=function(a){return null!=a&&"function"==typeof a.subscribe&&"function"==typeof a.notifySubscribers};a.b("subscribable",a.S);a.b("isSubscribable",a.Fc);a.P=a.u=function(){function b(a){d.push(e);e=a}function c(){e=d.pop()}var d=[],e,f=0;return{oc:b,end:c,Wb:function(b){if(e){if(!a.Fc(b))throw Error("Only subscribable things can act as dependencies");
|
||||
e.$c.call(e.ad,b,b.Sc||(b.Sc=++f))}},C:function(a,d,e){try{return b(),a.apply(d,e||[])}finally{c()}},oa:function(){if(e)return e.o.oa()},Sa:function(){if(e)return e.o.Sa()},Va:function(){if(e)return e.Va},o:function(){if(e)return e.o}}}();a.b("computedContext",a.P);a.b("computedContext.getDependenciesCount",a.P.oa);a.b("computedContext.getDependencies",a.P.Sa);a.b("computedContext.isInitial",a.P.Va);a.b("computedContext.registerDependency",a.P.Wb);a.b("ignoreDependencies",a.Hd=a.u.C);var F=Symbol("_latestValue");
|
||||
a.ra=function(b){function c(){if(0<arguments.length)return c.ob(c[F],arguments[0])&&(c.wa(),c[F]=arguments[0],c.va()),this;a.u.Wb(c);return c[F]}c[F]=b;a.a.ya||a.a.extend(c,a.S.fn);a.S.fn.mb(c);a.a.wb(c,D);a.options.deferUpdates&&a.Qa.deferred(c,!0);return c};var D={equalityComparer:L,v:function(){return this[F]},va:function(){this.notifySubscribers(this[F],"spectate");this.notifySubscribers(this[F])},wa:function(){this.notifySubscribers(this[F],"beforeChange")}};a.a.ya&&a.a.setPrototypeOf(D,a.S.fn);
|
||||
var H=a.ra.Ja="__ko_proto__";D[H]=a.ra;a.R=function(b){if((b="function"==typeof b&&b[H])&&b!==D[H]&&b!==a.o.fn[H])throw Error("Invalid object that looks like an observable; possibly from another Knockout instance");return!!b};a.Wa=function(b){return"function"==typeof b&&(b[H]===D[H]||b[H]===a.o.fn[H]&&b.Cc)};a.b("observable",a.ra);a.b("isObservable",a.R);a.b("isWriteableObservable",a.Wa);a.b("isWritableObservable",a.Wa);a.b("observable.fn",D);a.I(D,"peek",D.v);a.I(D,"valueHasMutated",D.va);a.I(D,
|
||||
"valueWillMutate",D.wa);a.Ea=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.ra(b);a.a.wb(b,a.Ea.fn);return b.extend({trackArrayChanges:!0})};a.Ea.fn={remove:function(b){for(var c=this.v(),d=[],e="function"!=typeof b||a.R(b)?function(a){return a===b}:b,f=0;f<c.length;f++){var g=c[f];if(e(g)){0===d.length&&this.wa();if(c[f]!==g)throw Error("Array modified during remove; cannot remove item");
|
||||
d.push(g);c.splice(f,1);f--}}d.length&&this.va();return d},removeAll:function(b){if(b===n){var c=this.v(),d=c.slice(0);this.wa();c.splice(0,c.length);this.va();return d}return b?this.remove(function(c){return 0<=a.a.L(b,c)}):[]},destroy:function(b){var c=this.v(),d="function"!=typeof b||a.R(b)?function(a){return a===b}:b;this.wa();for(var e=c.length-1;0<=e;e--){var f=c[e];d(f)&&(f._destroy=!0)}this.va()},destroyAll:function(b){return b===n?this.destroy(function(){return!0}):b?this.destroy(function(c){return 0<=
|
||||
a.a.L(b,c)}):[]},indexOf:function(b){var c=this();return a.a.L(c,b)},replace:function(a,c){var d=this.indexOf(a);0<=d&&(this.wa(),this.v()[d]=c,this.va())},sorted:function(a){var c=this().slice(0);return a?c.sort(a):c.sort()},reversed:function(){return this().slice(0).reverse()}};a.a.ya&&a.a.setPrototypeOf(a.Ea.fn,a.ra.fn);a.a.K("pop push reverse shift sort splice unshift".split(" "),function(b){a.Ea.fn[b]=function(){var a=this.v();this.wa();this.qc(a,b,arguments);var d=a[b].apply(a,arguments);this.va();
|
||||
return d===a?this:d}});a.a.K(["slice"],function(b){a.Ea.fn[b]=function(){var a=this();return a[b].apply(a,arguments)}});a.Ec=function(b){return a.R(b)&&"function"==typeof b.remove&&"function"==typeof b.push};a.b("observableArray",a.Ea);a.b("isObservableArray",a.Ec);a.Qa.trackArrayChanges=function(b,c){function d(){function c(){if(m){var d=[].concat(b.v()||[]),e;if(b.Ta("arrayChange")){if(!f||1<m)f=a.a.Ib(k,d,b.Hb);e=f}k=d;f=null;m=0;e&&e.length&&b.notifySubscribers(e,"arrayChange")}}e?c():(e=!0,h=
|
||||
b.subscribe(function(){++m},null,"spectate"),k=[].concat(b.v()||[]),f=null,g=b.subscribe(c))}b.Hb={};c&&"object"==typeof c&&a.a.extend(b.Hb,c);b.Hb.sparse=!0;if(!b.qc){var e=!1,f=null,g,h,m=0,k,l=b.Na,p=b.cb;b.Na=function(a){l&&l.call(b,a);"arrayChange"===a&&d()};b.cb=function(a){p&&p.call(b,a);"arrayChange"!==a||b.Ta("arrayChange")||(g&&g.s(),h&&h.s(),h=g=null,e=!1,k=n)};b.qc=function(b,c,d){function l(a,b,c){return k[k.length]={status:a,value:b,index:c}}if(e&&!m){var k=[],p=b.length,h=d.length,
|
||||
g=0;switch(c){case "push":g=p;case "unshift":for(c=0;c<h;c++)l("added",d[c],g+c);break;case "pop":g=p-1;case "shift":p&&l("deleted",b[g],g);break;case "splice":c=Math.min(Math.max(0,0>d[0]?p+d[0]:d[0]),p);for(var p=1===h?p:Math.min(c+(d[1]||0),p),h=c+h-2,g=Math.max(p,h),S=[],T=[],n=2;c<g;++c,++n)c<p&&T.push(l("deleted",b[c],c)),c<h&&S.push(l("added",d[n],c));a.a.Ac(T,S);break;default:return}f=k}}}};var q=Symbol("_state");a.o=a.X=function(b,c,d){function e(){if(0<arguments.length){if("function"===
|
||||
typeof f)f.apply(g.jb,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}g.pa||a.u.Wb(e);(g.ja||g.G&&e.Ua())&&e.ea();return g.V}"object"===typeof b?d=b:(d=d||{},b&&(d.read=b));if("function"!=typeof d.read)throw Error("Pass a function that returns the value of the ko.computed");var f=d.write,g={V:n,qa:!0,ja:!0,nb:!1,bc:!1,pa:!1,sb:!1,G:!1,Lc:d.read,jb:c||d.owner,l:d.disposeWhenNodeIsRemoved||
|
||||
d.l||null,Pa:d.disposeWhen||d.Pa,Kb:null,F:{},U:0,zc:null};e[q]=g;e.Cc="function"===typeof f;a.a.ya||a.a.extend(e,a.S.fn);a.S.fn.mb(e);a.a.wb(e,y);d.pure?(g.sb=!0,g.G=!0,a.a.extend(e,ba)):d.deferEvaluation&&a.a.extend(e,ca);a.options.deferUpdates&&a.Qa.deferred(e,!0);g.l&&(g.bc=!0,g.l.nodeType||(g.l=null));g.G||d.deferEvaluation||e.ea();g.l&&e.ia()&&a.a.N.Ka(g.l,g.Kb=function(){e.s()});return e};var y={equalityComparer:L,oa:function(){return this[q].U},Sa:function(){var b=[];a.a.O(this[q].F,function(a,
|
||||
d){b[d.Ha]=d.aa});return b},Ob:function(b){if(!this[q].U)return!1;var c=this.Sa();return-1!==a.a.L(c,b)?!0:!!a.a.Fb(c,function(a){return a.Ob&&a.Ob(b)})},mc:function(a,c,d){if(this[q].sb&&c===this)throw Error("A 'pure' computed must not be called recursively");this[q].F[a]=d;d.Ha=this[q].U++;d.Ia=c.kb()},Ua:function(){var a,c,d=this[q].F;for(a in d)if(Object.prototype.hasOwnProperty.call(d,a)&&(c=d[a],this.Fa&&c.aa.Ga||c.aa.md(c.Ia)))return!0},rd:function(){this.Fa&&!this[q].nb&&this.Fa(!1)},ia:function(){var a=
|
||||
this[q];return a.ja||0<a.U},yd:function(){this.Ga?this[q].ja&&(this[q].qa=!0):this.yc()},Oc:function(a){if(a.Bb){var c=a.subscribe(this.rd,this,"dirty"),d=a.subscribe(this.yd,this);return{aa:a,s:function(){c.s();d.s()}}}return a.subscribe(this.yc,this)},yc:function(){var b=this,c=b.throttleEvaluation;c&&0<=c?(clearTimeout(this[q].zc),this[q].zc=a.a.setTimeout(function(){b.ea(!0)},c)):b.Fa?b.Fa(!0):b.ea(!0)},ea:function(b){var c=this[q],d=c.Pa,e=!1;if(!c.nb&&!c.pa){if(c.l&&!a.a.Lb(c.l)||d&&d()){if(!c.bc){this.s();
|
||||
return}}else c.bc=!1;c.nb=!0;try{e=this.jd(b)}finally{c.nb=!1}return e}},jd:function(b){var c=this[q],d=!1,e=c.sb?n:!c.U,d={bd:this,ib:c.F,Jb:c.U};a.u.oc({ad:d,$c:Z,o:this,Va:e});c.F={};c.U=0;var f=this.hd(c,d);c.U?d=this.ob(c.V,f):(this.s(),d=!0);d&&(c.G?this.Ab():this.notifySubscribers(c.V,"beforeChange"),c.V=f,this.notifySubscribers(c.V,"spectate"),!c.G&&b&&this.notifySubscribers(c.V),this.jc&&this.jc());e&&this.notifySubscribers(c.V,"awake");return d},hd:function(b,c){try{var d=b.Lc;return b.jb?
|
||||
d.call(b.jb):d()}finally{a.u.end(),c.Jb&&!b.G&&a.a.O(c.ib,Y),b.qa=b.ja=!1}},v:function(a){var c=this[q];(c.ja&&(a||!c.U)||c.G&&this.Ua())&&this.ea();return c.V},qb:function(b){a.S.fn.qb.call(this,b);this.fc=function(){this[q].G||(this[q].qa?this.ea():this[q].ja=!1);return this[q].V};this.Fa=function(a){this.hc(this[q].V);this[q].ja=!0;a&&(this[q].qa=!0);this.ic(this,!a)}},s:function(){var b=this[q];!b.G&&b.F&&a.a.O(b.F,function(a,b){b.s&&b.s()});b.l&&b.Kb&&a.a.N.ub(b.l,b.Kb);b.F=n;b.U=0;b.pa=!0;b.qa=
|
||||
!1;b.ja=!1;b.G=!1;b.l=n;b.Pa=n;b.Lc=n;this.Cc||(b.jb=n)}},ba={Na:function(b){var c=this,d=c[q];if(!d.pa&&d.G&&"change"==b){d.G=!1;if(d.qa||c.Ua())d.F=null,d.U=0,c.ea()&&c.Ab();else{var e=[];a.a.O(d.F,function(a,b){e[b.Ha]=a});a.a.K(e,function(a,b){var e=d.F[a],m=c.Oc(e.aa);m.Ha=b;m.Ia=e.Ia;d.F[a]=m});c.Ua()&&c.ea()&&c.Ab()}d.pa||c.notifySubscribers(d.V,"awake")}},cb:function(b){var c=this[q];c.pa||"change"!=b||this.Ta("change")||(a.a.O(c.F,function(a,b){b.s&&(c.F[a]={aa:b.aa,Ha:b.Ha,Ia:b.Ia},b.s())}),
|
||||
c.G=!0,this.notifySubscribers(n,"asleep"))},kb:function(){var b=this[q];b.G&&(b.qa||this.Ua())&&this.ea();return a.S.fn.kb.call(this)}},ca={Na:function(a){"change"!=a&&"beforeChange"!=a||this.v()}};a.a.ya&&a.a.setPrototypeOf(y,a.S.fn);var P=a.ra.Ja;y[P]=a.o;a.Dc=function(a){return"function"==typeof a&&a[P]===y[P]};a.od=function(b){return a.Dc(b)&&b[q]&&b[q].sb};a.b("computed",a.o);a.b("dependentObservable",a.o);a.b("isComputed",a.Dc);a.b("isPureComputed",a.od);a.b("computed.fn",y);a.I(y,"peek",y.v);
|
||||
a.I(y,"dispose",y.s);a.I(y,"isActive",y.ia);a.I(y,"getDependenciesCount",y.oa);a.I(y,"getDependencies",y.Sa);a.tb=function(b,c){if("function"===typeof b)return a.o(b,c,{pure:!0});b=a.a.extend({},b);b.pure=!0;return a.o(b,c)};a.b("pureComputed",a.tb);a.Dd=function(b,c,d){function e(c){var e=a.tb(b,d).extend({ka:"always"}),h=e.subscribe(function(a){a&&(h.s(),c(a))});e.notifySubscribers(e.v());return h}return c?e(c.bind(d)):new Promise(e)};a.b("when",a.Dd);(function(){a.w={J:function(b){switch(a.a.$(b)){case "option":return!0===
|
||||
b.__ko__hasDomDataOptionValue__?a.a.h.get(b,a.c.options.Tb):b.value;case "select":return 0<=b.selectedIndex?a.w.J(b.options[b.selectedIndex]):n;default:return b.value}},Za:function(b,c,d){switch(a.a.$(b)){case "option":"string"===typeof c?(a.a.h.set(b,a.c.options.Tb,n),"__ko__hasDomDataOptionValue__"in b&&delete b.__ko__hasDomDataOptionValue__,b.value=c):(a.a.h.set(b,a.c.options.Tb,c),b.__ko__hasDomDataOptionValue__=!0,b.value="number"===typeof c?c:"");break;case "select":if(""===c||null===c)c=n;
|
||||
for(var e=-1,f=0,g=b.options.length,h;f<g;++f)if(h=a.w.J(b.options[f]),h==c||""===h&&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.w);a.b("selectExtensions.readValue",a.w.J);a.b("selectExtensions.writeValue",a.w.Za);a.m=function(){function b(b){b=a.a.$b(b);123===b.charCodeAt(0)&&(b=b.slice(1,-1));b+="\n,";var c=[],d=b.match(e),p,v=[],h=0;if(1<d.length){for(var w=0,u;u=d[w];++w){var t=u.charCodeAt(0);if(44===
|
||||
t){if(0>=h){c.push(p&&v.length?{key:p,value:v.join("")}:{unknown:p||v.join("")});p=h=0;v=[];continue}}else if(58===t){if(!h&&!p&&1===v.length){p=v.pop();continue}}else if(47===t&&1<u.length&&(47===u.charCodeAt(1)||42===u.charCodeAt(1)))continue;else 47===t&&w&&1<u.length?(t=d[w-1].match(f))&&!g[t[0]]&&(b=b.substr(b.indexOf(u)+1),d=b.match(e),w=-1,u="/"):40===t||123===t||91===t?++h:41===t||125===t||93===t?--h:p||v.length||34!==t&&39!==t||(u=u.slice(1,-1));v.push(u)}if(0<h)throw Error("Unbalanced parentheses, braces, or brackets");
|
||||
}return c}var c=["true","false","null","undefined"],d=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i,e=RegExp("\"(?:\\\\.|[^\"])*\"|'(?:\\\\.|[^'])*'|`(?:\\\\.|[^`])*`|/\\*(?:[^*]|\\*+[^*/])*\\*+/|//.*\n|/(?:\\\\.|[^/])+/w*|[^\\s:,/][^,\"'`{}()/:[\\]]*[^\\s,\"'`{}()/:[\\]]|[^\\s]","g"),f=/[\])"'A-Za-z0-9_$]+$/,g={"in":1,"return":1,"typeof":1},h={};return{Oa:[],ua:h,Ub:b,rb:function(e,k){function l(b,e){var k;if(!w){var B=a.getBindingHandler(b);if(B&&B.preprocess&&!(e=B.preprocess(e,b,l)))return;
|
||||
if(B=h[b])k=e,0<=a.a.L(c,k)?k=!1:(B=k.match(d),k=null===B?!1:B[1]?"Object("+B[1]+")"+B[2]:k),B=k;B&&v.push("'"+("string"==typeof h[b]?h[b]:b)+"':function(_z){"+k+"=_z}")}g&&(e="function(){return "+e+" }");f.push("'"+b+"':"+e)}k=k||{};var f=[],v=[],g=k.valueAccessors,w=k.bindingParams,u="string"===typeof e?b(e):e;a.a.K(u,function(a){l(a.key||a.unknown,a.value)});v.length&&l("_ko_property_writers","{"+v.join(",")+" }");return f.join(",")},qd:function(a,b){for(var c=0;c<a.length;c++)if(a[c].key==b)return!0;
|
||||
return!1},$a:function(b,c,d,e,f){if(b&&a.R(b))!a.Wa(b)||f&&b.v()===e||b(e);else if((b=c.get("_ko_property_writers"))&&b[d])b[d](e)}}}();a.b("expressionRewriting",a.m);a.b("expressionRewriting.bindingRewriteValidators",a.m.Oa);a.b("expressionRewriting.parseObjectLiteral",a.m.Ub);a.b("expressionRewriting.preProcessBindings",a.m.rb);a.b("expressionRewriting._twoWayBindings",a.m.ua);a.b("jsonExpressionRewriting",a.m);a.b("jsonExpressionRewriting.insertPropertyAccessorsIntoJson",a.m.rb);(function(){function b(a){return 8==
|
||||
a.nodeType&&g.test(f?a.text:a.nodeValue)}function c(a){return 8==a.nodeType&&h.test(f?a.text:a.nodeValue)}function d(d,e){for(var f=d,h=1,g=[];f=f.nextSibling;){if(c(f)&&(a.a.h.set(f,k,!0),h--,0===h))return g;g.push(f);b(f)&&h++}if(!e)throw Error("Cannot find closing comment tag to match: "+d.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=z&&"\x3c!--test--\x3e"===z.createComment("test").text,g=f?/^\x3c!--\s*ko(?:\s+([\s\S]+))?\s*--\x3e$/:
|
||||
/^\s*ko(?:\s+([\s\S]+))?\s*$/,h=f?/^\x3c!--\s*\/ko\s*--\x3e$/:/^\s*\/ko\s*$/,m={ul:!0,ol:!0},k="__ko_matchedEndComment__";a.f={ba:{},childNodes:function(a){return b(a)?d(a):a.childNodes},Aa:function(c){if(b(c)){c=a.f.childNodes(c);for(var d=0,e=c.length;d<e;d++)a.removeNode(c[d])}else a.a.Mb(c)},ta:function(c,d){if(b(c)){a.f.Aa(c);for(var e=c.nextSibling,f=0,k=d.length;f<k;f++)e.parentNode.insertBefore(d[f],e)}else a.a.ta(c,d)},Kc:function(a,c){var d;b(a)?(d=a.nextSibling,a=a.parentNode):d=a.firstChild;
|
||||
d?c!==d&&a.insertBefore(c,d):a.appendChild(c)},Pb:function(c,d,e){e?(e=e.nextSibling,b(c)&&(c=c.parentNode),e?d!==e&&c.insertBefore(d,e):c.appendChild(d)):a.f.Kc(c,d)},firstChild:function(a){if(b(a))return!a.nextSibling||c(a.nextSibling)?null:a.nextSibling;if(a.firstChild&&c(a.firstChild))throw Error("Found invalid end comment, as the first child of "+a);return a.firstChild},nextSibling:function(d){b(d)&&(d=e(d));if(d.nextSibling&&c(d.nextSibling)){var f=d.nextSibling;if(c(f)&&!a.a.h.get(f,k))throw Error("Found end comment without a matching opening comment, as child of "+
|
||||
d);return null}return d.nextSibling},ld:b,Cd:function(a){return(a=(f?a.text:a.nodeValue).match(g))?a[1]:null},Hc:function(d){if(m[a.a.$(d)]){var f=d.firstChild;if(f){do if(1===f.nodeType){var k;k=f.firstChild;var h=null;if(k){do if(h)h.push(k);else if(b(k)){var g=e(k,!0);g?k=g:h=[k]}else c(k)&&(h=[k]);while(k=k.nextSibling)}if(k=h)for(h=f.nextSibling,g=0;g<k.length;g++)h?d.insertBefore(k[g],h):d.appendChild(k[g])}while(f=f.nextSibling)}}}}})();a.b("virtualElements",a.f);a.b("virtualElements.allowedBindings",
|
||||
a.f.ba);a.b("virtualElements.emptyNode",a.f.Aa);a.b("virtualElements.insertAfter",a.f.Pb);a.b("virtualElements.prepend",a.f.Kc);a.b("virtualElements.setDomNodeChildren",a.f.ta);(function(){a.da=function(){this.Zc={}};a.a.extend(a.da.prototype,{nodeHasBindings:function(b){switch(b.nodeType){case 1:return null!=b.getAttribute("data-bind")||a.j.getComponentNameForNode(b);case 8:return a.f.ld(b);default:return!1}},getBindings:function(b,c){var d=this.getBindingsString(b,c),d=d?this.parseBindingsString(d,
|
||||
c,b):null;return a.j.lc(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.j.lc(d,b,c,!0)},getBindingsString:function(b){switch(b.nodeType){case 1:return b.getAttribute("data-bind");case 8:return a.f.Cd(b);default:return null}},parseBindingsString:function(b,c,d,e){try{var f=this.Zc,g=b+(e&&e.valueAccessors||""),h;if(!(h=f[g])){var m,k="with($context){with($data||{}){return{"+a.m.rb(b,e)+"}}}";m=new Function("$context",
|
||||
"$element",k);h=f[g]=m}return h(c,d)}catch(l){throw l.message="Unable to parse bindings.\nBindings value: "+b+"\nMessage: "+l.message,l;}}});a.da.instance=new a.da})();a.b("bindingProvider",a.da);(function(){function b(b){var c=(b=a.a.h.get(b,A))&&b.M;c&&(b.M=null,c.Ic())}function c(c,d,e){this.node=c;this.pc=d;this.gb=[];this.D=!1;d.M||a.a.N.Ka(c,b);e&&e.M&&(e.M.gb.push(c),this.Eb=e)}function d(a){return function(){return a}}function e(a){return a()}function f(b){return a.a.Da(a.u.C(b),function(a,
|
||||
c){return function(){return b()[c]}})}function g(b,c,e){return"function"===typeof b?f(b.bind(null,c,e)):a.a.Da(b,d)}function h(a,b){return f(this.getBindings.bind(this,a,b))}function m(b,c){var d=a.f.firstChild(c);if(d){var e,f=a.da.instance,l=f.preprocessNode;if(l){for(;e=d;)d=a.f.nextSibling(e),l.call(f,e);d=a.f.firstChild(c)}for(;e=d;)d=a.f.nextSibling(e),k(b,e)}a.i.ka(c,a.i.D)}function k(b,c){var d=b,e=1===c.nodeType;e&&a.f.Hc(c);if(e||a.da.instance.nodeHasBindings(c))d=p(c,null,b).bindingContextForDescendants;
|
||||
d&&!t[a.a.$(c)]&&m(d,c)}function l(b){var c=[],d={},e=[];a.a.O(b,function aa(f){if(!d[f]){var k=a.getBindingHandler(f);k&&(k.after&&(e.push(f),a.a.K(k.after,function(c){if(b[c]){if(-1!==a.a.L(e,c))throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+e.join(", "));aa(c)}}),e.length--),c.push({key:f,Bc:k}));d[f]=!0}});return c}function p(b,c,d){var f=a.a.h.Nb(b,A,{}),k=f.Uc;if(!c){if(k)throw Error("You cannot apply bindings multiple times to the same element.");
|
||||
f.Uc=!0}k||(f.context=d);f.Sb||(f.Sb={});var p;if(c&&"function"!==typeof c)p=c;else{var g=a.da.instance,v=g.getBindingAccessors||h,m=a.X(function(){if(p=c?c(d,b):v.call(g,b,d)){if(d[r])d[r]();if(d[u])d[u]()}return p},null,{l:b});p&&m.ia()||(m=null)}var t=d,w;if(p){var J=function(){return a.a.Da(m?m():p,e)},q=m?function(a){return function(){return e(m()[a])}}:function(a){return p[a]};J.get=function(a){return p[a]&&e(q(a))};J.has=function(a){return a in p};a.i.D in p&&a.i.subscribe(b,a.i.D,function(){var c=
|
||||
(0,p[a.i.D])();if(c){var d=a.f.childNodes(b);d.length&&c(d,a.vc(d[0]))}});a.i.na in p&&(t=a.i.yb(b,d),a.i.subscribe(b,a.i.na,function(){var c=(0,p[a.i.na])();c&&a.f.firstChild(b)&&c(b)}));f=l(p);a.a.K(f,function(c){var d=c.Bc.init,e=c.Bc.update,f=c.key;if(8===b.nodeType&&!a.f.ba[f])throw Error("The binding '"+f+"' cannot be used with virtual elements");try{"function"==typeof d&&a.u.C(function(){var a=d(b,q(f),J,t.$data,t);if(a&&a.controlsDescendantBindings){if(w!==n)throw Error("Multiple bindings ("+
|
||||
w+" and "+f+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");w=f}}),"function"==typeof e&&a.X(function(){e(b,q(f),J,t.$data,t)},null,{l:b})}catch(k){throw k.message='Unable to process binding "'+f+": "+p[f]+'"\nMessage: '+k.message,k;}})}f=w===n;return{shouldBindDescendants:f,bindingContextForDescendants:f&&t}}function v(b,c){return b&&b instanceof a.ca?b:new a.ca(b,n,n,c)}var r=Symbol("_subscribable"),w=Symbol("_ancestorBindingInfo"),
|
||||
u=Symbol("_dataDependency");a.c={};var t={script:!0,textarea:!0,template:!0};a.getBindingHandler=function(b){return a.c[b]};var J={};a.ca=function(b,c,d,e,f){function k(){var b=g?p():p,f=a.a.g(b);c?(a.a.extend(l,c),w in c&&(l[w]=c[w])):(l.$parents=[],l.$root=f,l.ko=a);l[r]=v;h?f=l.$data:(l.$rawData=b,l.$data=f);d&&(l[d]=f);e&&e(l,c,f);if(c&&c[r]&&!a.P.o().Ob(c[r]))c[r]();m&&(l[u]=m);return l.$data}var l=this,h=b===J,p=h?n:b,g="function"==typeof p&&!a.R(p),v,m=f&&f.dataDependency;f&&f.exportDependencies?
|
||||
k():(v=a.tb(k),v.v(),v.ia()?v.equalityComparer=null:l[r]=n)};a.ca.prototype.createChildContext=function(b,c,d,e){!e&&c&&"object"==typeof c&&(e=c,c=e.as,d=e.extend);if(c&&e&&e.noChildContext){var f="function"==typeof b&&!a.R(b);return new a.ca(J,this,null,function(a){d&&d(a);a[c]=f?b():b},e)}return new a.ca(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)},e)};a.ca.prototype.extend=function(b,c){return new a.ca(J,
|
||||
this,null,function(c){a.a.extend(c,"function"==typeof b?b(c):b)},c)};var A=a.a.h.fa();c.prototype.Ic=function(){this.Eb&&this.Eb.M&&this.Eb.M.dd(this.node)};c.prototype.dd=function(b){a.a.Ma(this.gb,b);!this.gb.length&&this.D&&this.tc()};c.prototype.tc=function(){this.D=!0;this.pc.M&&!this.gb.length&&(this.pc.M=null,a.a.N.ub(this.node,b),a.i.ka(this.node,a.i.na),this.Ic())};a.i={D:"childrenComplete",na:"descendantsComplete",subscribe:function(b,c,d,e,f){var k=a.a.h.Nb(b,A,{});k.Ba||(k.Ba=new a.S);
|
||||
f&&f.notifyImmediately&&k.Sb[c]&&a.u.C(d,e,[b]);return k.Ba.subscribe(d,e,c)},ka:function(b,c){var d=a.a.h.get(b,A);if(d&&(d.Sb[c]=!0,d.Ba&&d.Ba.notifySubscribers(b,c),c==a.i.D))if(d.M)d.M.tc();else if(d.M===n&&d.Ba&&d.Ba.Ta(a.i.na))throw Error("descendantsComplete event not supported for bindings on this node");},yb:function(b,d){var e=a.a.h.Nb(b,A,{});e.M||(e.M=new c(b,e,d[w]));return d[w]==e?d:d.extend(function(a){a[w]=e})}};a.Ad=function(b){return(b=a.a.h.get(b,A))&&b.context};a.eb=function(b,
|
||||
c,d){1===b.nodeType&&a.f.Hc(b);return p(b,c,v(d))};a.Xc=function(b,c,d){d=v(d);return a.eb(b,g(c,d,b),d)};a.La=function(a,b){1!==b.nodeType&&8!==b.nodeType||m(v(a),b)};a.nc=function(a,b,c){if(2>arguments.length){if(b=z.body,!b)throw Error("ko.applyBindings: could not find document.body; has the document been loaded?");}else 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");k(v(a,c),b)};a.uc=function(b){return!b||
|
||||
1!==b.nodeType&&8!==b.nodeType?n:a.Ad(b)};a.vc=function(b){return(b=a.uc(b))?b.$data:n};a.b("bindingHandlers",a.c);a.b("bindingEvent",a.i);a.b("bindingEvent.subscribe",a.i.subscribe);a.b("bindingEvent.startPossiblyAsyncContentBinding",a.i.yb);a.b("applyBindings",a.nc);a.b("applyBindingsToDescendants",a.La);a.b("applyBindingAccessorsToNode",a.eb);a.b("applyBindingsToNode",a.Xc);a.b("contextFor",a.uc);a.b("dataFor",a.vc)})();(function(b){function c(c,e){var k=Object.prototype.hasOwnProperty.call(f,
|
||||
c)?f[c]:b,l;k?k.subscribe(e):(k=f[c]=new a.S,k.subscribe(e),d(c,function(b,d){var e=!(!d||!d.synchronous);g[c]={definition:b,pd:e};delete f[c];l||e?k.notifySubscribers(b):a.la.vb(function(){k.notifySubscribers(b)})}),l=!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,l){l||(l=a.j.loaders.slice(0));var p=l.shift();if(p){var g=p[c];if(g){var r=!1;if(g.apply(p,d.concat(function(a){r?f(null):null!==a?f(a):e(c,d,f,l)}))!==
|
||||
b&&(r=!0,!p.suppressLoaderExceptions))throw Error("Component loaders must supply values by invoking the callback, not by returning values synchronously.");}else e(c,d,f,l)}else f(null)}var f={},g={};a.j={get:function(d,e){var f=Object.prototype.hasOwnProperty.call(g,d)?g[d]:b;f?f.pd?a.u.C(function(){e(f.definition)}):a.la.vb(function(){e(f.definition)}):c(d,e)},sc:function(a){delete g[a]},gc:e};a.j.loaders=[];a.b("components",a.j);a.b("components.get",a.j.get);a.b("components.clearCachedDefinition",
|
||||
a.j.sc)})();(function(){function b(b,c,d,e){function g(){0===--u&&e(h)}var h={},u=2,t=d.template;d=d.viewModel;t?f(c,t,function(c){a.j.gc("loadTemplate",[b,c],function(a){h.template=a;g()})}):g();d?f(c,d,function(c){a.j.gc("loadViewModel",[b,c],function(a){h[m]=a;g()})}):g()}function c(a,b,d){if("function"===typeof b)d(function(a){return new b(a)});else if("function"===typeof b[m])d(b[m]);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.$(b)){case "script":return a.a.sa(b.text);case "textarea":return a.a.sa(b.value);case "template":if(e(b.content))return a.a.za(b.content.childNodes)}return a.a.za(b.childNodes)}function e(a){return G.DocumentFragment?a instanceof DocumentFragment:a&&11===a.nodeType}function f(a,b,c){"string"===typeof b.require?R||G.require?(R||G.require)([b.require],function(a){a&&"object"===typeof a&&a.Ed&&a["default"]&&(a=a["default"]);c(a)}):a("Uses require, but no AMD loader is present"):
|
||||
c(b)}function g(a){return function(b){throw Error("Component '"+a+"': "+b);}}var h={};a.j.register=function(b,c){if(!c)throw Error("Invalid configuration for "+b);if(a.j.pb(b))throw Error("Component "+b+" is already registered");h[b]=c};a.j.pb=function(a){return Object.prototype.hasOwnProperty.call(h,a)};a.j.unregister=function(b){delete h[b];a.j.sc(b)};a.j.wc={getConfig:function(b,c){c(a.j.pb(b)?h[b]: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.sa(c));else if(c instanceof Array)f(c);else if(e(c))f(a.a.Ca(c.childNodes));else if(c.element)if(c=c.element,G.HTMLElement?c instanceof HTMLElement:c&&c.tagName&&1===c.nodeType)f(d(c));else if("string"===typeof c){var h=z.getElementById(c);h?f(d(h)):b("Cannot find element with ID "+c)}else b("Unknown element type: "+c);else b("Unknown template value: "+c)},loadViewModel:function(a,b,d){c(g(a),b,d)}};var m="createViewModel";a.b("components.register",a.j.register);
|
||||
a.b("components.isRegistered",a.j.pb);a.b("components.unregister",a.j.unregister);a.b("components.defaultLoader",a.j.wc);a.j.loaders.push(a.j.wc);a.j.Fd=h})();(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.Da(f,function(c){return a.o(c,null,{l:b})}),g=a.a.Da(f,function(c){var e=c.v();return c.ia()?a.o({read:function(){return a.a.g(c())},write:a.Wa(e)&&function(a){c()(a)},l:b}):e});Object.prototype.hasOwnProperty.call(g,
|
||||
"$raw")||(g.$raw=f);return g}return{$raw:{}}}a.j.getComponentNameForNode=function(b){var c=a.a.$(b);if(a.j.pb(c)&&(-1!=c.indexOf("-")||"[object HTMLUnknownElement]"==""+b))return c};a.j.lc=function(c,e,f,g){if(1===e.nodeType){var h=a.j.getComponentNameForNode(e);if(h){c=c||{};if(c.component)throw Error('Cannot use the "component" binding on a custom element matching a component');var m={name:h,params:b(e,f)};c.component=g?function(){return m}:m}}return c};var c=new a.da})();(function(){function b(b,
|
||||
c,d){c=c.template;if(!c)throw Error("Component '"+b+"' has no template");b=a.a.za(c);a.f.ta(d,b)}function c(a,b,c){var d=a.createViewModel;return d?d.call(a,b,c):b}var d=0;a.c.component={init:function(e,f,g,h,m){function k(){var a=l&&l.dispose;"function"===typeof a&&a.call(l);v&&v.s();p=l=v=null}var l,p,v,r=a.a.Ca(a.f.childNodes(e));a.f.Aa(e);a.a.N.Ka(e,k);a.o(function(){var g=a.a.g(f()),h,t;"string"===typeof g?h=g:(h=a.a.g(g.name),t=a.a.g(g.params));if(!h)throw Error("No component name specified");
|
||||
var n=a.i.yb(e,m),A=p=++d;a.j.get(h,function(d){if(p===A){k();if(!d)throw Error("Unknown component '"+h+"'");b(h,d,e);var f=c(d,t,{element:e,templateNodes:r});d=n.createChildContext(f,{extend:function(a){a.$component=f;a.$componentTemplateNodes=r}});f&&f.koDescendantsComplete&&(v=a.i.subscribe(e,a.i.na,f.koDescendantsComplete,f));l=f;a.La(d,e)}})},null,{l:e});return{controlsDescendantBindings:!0}}};a.f.ba.component=!0})();a.c.attr={update:function(b,c){var d=a.a.g(c())||{};a.a.O(d,function(c,d){d=
|
||||
a.a.g(d);var g=c.indexOf(":"),g="lookupNamespaceURI"in b&&0<g&&b.lookupNamespaceURI(c.substr(0,g)),h=!1===d||null===d||d===n;h?g?b.removeAttributeNS(g,c):b.removeAttribute(c):d=d.toString();h||(g?b.setAttributeNS(g,c,d):b.setAttribute(c,d));"name"===c&&(b.name=h?"":d)})}};(function(){function b(b,d,e){var f=a.a.L(a.a.Vb(b),d);0>f?e&&b.push(d):e||b.splice(f,1)}a.c.checked={after:["value","attr"],init:function(c,d,e){function f(){var f=c.checked,g=h();if(!a.P.Va()&&(f||!k&&!a.P.oa())){var l=a.u.C(d);
|
||||
if(p){var r=v?l.v():l,q=w;w=g;q!==g?f&&(b(r,g,!0),b(r,q,!1)):b(r,g,f);v&&a.Wa(l)&&l(r)}else m&&(g===n?g=f:f||(g=n)),a.m.$a(l,e,"checked",g,!0)}}function g(){var b=a.a.g(d()),e=h();p?(c.checked=0<=a.a.L(b,e),w=e):c.checked=m&&e===n?!!b:h()===b}var h=a.tb(function(){if(e.has("checkedValue"))return a.a.g(e.get("checkedValue"));if(r)return e.has("value")?a.a.g(e.get("value")):c.value}),m="checkbox"==c.type,k="radio"==c.type;if(m||k){var l=d(),p=m&&a.a.g(l)instanceof Array,v=!(p&&l.push&&l.splice),r=k||
|
||||
p,w=p?h():n;k&&!c.name&&a.c.uniqueName.init(c,function(){return!0});a.o(f,null,{l:c});a.a.H(c,"click",f);a.o(g,null,{l:c});l=n}}};a.m.ua.checked=!0;a.c.checkedValue={update:function(b,d){b.value=a.a.g(d())}}})();a.c["class"]={update:function(b,c){var d=a.a.$b(a.a.g(c()));O(b,b.__ko__cssValue,!1);b.__ko__cssValue=d;O(b,d,!0)}};a.c.css={update:function(b,c){var d=a.a.g(c());null!==d&&"object"==typeof d?a.a.O(d,function(c,d){d=a.a.g(d);O(b,c,d)}):a.c["class"].update(b,c)}};a.c.enable={update:function(b,
|
||||
c){var d=a.a.g(c());d&&b.disabled?b.removeAttribute("disabled"):d||b.disabled||(b.disabled=!0)}};a.c.disable={update:function(b,c){a.c.enable.update(b,function(){return!a.a.g(c())})}};a.c.event={init:function(b,c,d,e,f){var g=c()||{};a.a.O(g,function(g){"string"==typeof g&&a.a.H(b,g,function(b){var k,l=c()[g];if(l){try{var p=a.a.Ca(arguments);e=f.$data;p.unshift(e);k=l.apply(e,p)}finally{!0!==k&&(b.preventDefault?b.preventDefault():b.returnValue=!1)}!1===d.get(g+"Bubble")&&(b.cancelBubble=!0,b.stopPropagation&&
|
||||
b.stopPropagation())}})})}};a.c.foreach={Gc:function(b){return function(){var c=b(),d=a.a.Vb(c);if(!d||"number"==typeof d.length)return{foreach:c,templateEngine:a.Z.Ja};a.a.g(c);return{foreach:d.data,as:d.as,noChildContext:d.noChildContext,includeDestroyed:d.includeDestroyed,afterAdd:d.afterAdd,beforeRemove:d.beforeRemove,afterRender:d.afterRender,beforeMove:d.beforeMove,afterMove:d.afterMove,templateEngine:a.Z.Ja}}},init:function(b,c){return a.c.template.init(b,a.c.foreach.Gc(c))},update:function(b,
|
||||
c,d,e,f){return a.c.template.update(b,a.c.foreach.Gc(c),d,e,f)}};a.m.Oa.foreach=!1;a.f.ba.foreach=!0;a.c.hasfocus={init:function(b,c,d){function e(e){b.__ko_hasfocusUpdating=!0;e=b.ownerDocument.activeElement===b;var f=c();a.m.$a(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.H(b,"focus",f);a.a.H(b,"focusin",f);a.a.H(b,"blur",g);a.a.H(b,"focusout",g);b.__ko_hasfocusLastValue=!1},update:function(b,c){var d=!!a.a.g(c());b.__ko_hasfocusUpdating||
|
||||
b.__ko_hasfocusLastValue===d||(d?b.focus():b.blur(),!d&&b.__ko_hasfocusLastValue&&b.ownerDocument.body.focus(),a.u.C(a.a.zb,null,[b,d?"focusin":"focusout"]))}};a.m.ua.hasfocus=!0;a.c.hasFocus=a.c.hasfocus;a.m.ua.hasFocus="hasfocus";a.c.html={init:function(){return{controlsDescendantBindings:!0}},update:function(b,c){a.a.Zb(b,c())}};(function(){function b(b,d,e){a.c[b]={init:function(b,c,h,m,k){var l,p,v={},r,n,u;if(d){m=h.get("as");var t=h.get("noChildContext");u=!(m&&t);v={as:m,noChildContext:t,
|
||||
exportDependencies:u}}n=(r="render"==h.get("completeOn"))||h.has(a.i.na);a.o(function(){var h=a.a.g(c()),m=!e!==!h,t=!p,q;if(u||m!==l){n&&(k=a.i.yb(b,k));if(m){if(!d||u)v.dataDependency=a.P.o();q=d?k.createChildContext("function"==typeof h?h:c,v):a.P.oa()?k.extend(null,v):k}t&&a.P.oa()&&(p=a.a.za(a.f.childNodes(b),!0));m?(t||a.f.ta(b,a.a.za(p)),a.La(q,b)):(a.f.Aa(b),r||a.i.ka(b,a.i.D));l=m}},null,{l:b});return{controlsDescendantBindings:!0}}};a.m.Oa[b]=!1;a.f.ba[b]=!0}b("if");b("ifnot",!1,!0);b("with",
|
||||
!0)})();a.c.let={init:function(b,c,d,e,f){c=f.extend(c);a.La(c,b);return{controlsDescendantBindings:!0}}};a.f.ba.let=!0;var Q={};a.c.options={init:function(b){if("select"!==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.fb(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,d){if(w&&
|
||||
l)a.i.ka(b,a.i.D);else if(r.length){var e=0<=a.a.L(r,a.w.J(d[0]));d[0].selected=e;w&&!e&&a.u.C(a.a.zb,null,[b,"change"])}}var h=b.multiple,m=0!=b.length&&h?b.scrollTop:null,k=a.a.g(c()),l=d.get("valueAllowUnset")&&d.has("value"),p=d.get("optionsIncludeDestroyed");c={};var v,r=[];l||(h?r=e().map(a.w.J):0<=b.selectedIndex&&r.push(a.w.J(b.options[b.selectedIndex])));k&&("undefined"==typeof k.length&&(k=[k]),v=a.a.fb(k,function(b){return p||b===n||null===b||!a.a.g(b._destroy)}),d.has("optionsCaption")&&
|
||||
(k=a.a.g(d.get("optionsCaption")),null!==k&&k!==n&&v.unshift(Q)));var w=!1;c.beforeRemove=function(a){b.removeChild(a)};k=g;d.has("optionsAfterRender")&&"function"==typeof d.get("optionsAfterRender")&&(k=function(b,c){g(0,c);a.u.C(d.get("optionsAfterRender"),null,[c[0],b!==Q?b:n])});a.a.Yb(b,v,function(c,e,k){k.length&&(r=!l&&k[0].selected?[a.w.J(k[0])]:[],w=!0);e=b.ownerDocument.createElement("option");c===Q?(a.a.xb(e,d.get("optionsCaption")),a.w.Za(e,n)):(k=f(c,d.get("optionsValue"),c),a.w.Za(e,
|
||||
a.a.g(k)),c=f(c,d.get("optionsText"),k),a.a.xb(e,c));return[e]},c,k);if(!l){var u;h?u=r.length&&e().length<r.length:u=r.length&&0<=b.selectedIndex?a.w.J(b.options[b.selectedIndex])!==r[0]:r.length||0<=b.selectedIndex;u&&a.u.C(a.a.zb,null,[b,"change"])}(l||a.P.Va())&&a.i.ka(b,a.i.D);m&&20<Math.abs(m-b.scrollTop)&&(b.scrollTop=m)}};a.c.options.Tb=a.a.h.fa();a.c.selectedOptions={init:function(b,c,d){function e(){var e=c(),f=[];a.a.K(b.getElementsByTagName("option"),function(b){b.selected&&f.push(a.w.J(b))});
|
||||
a.m.$a(e,d,"selectedOptions",f)}function f(){var d=a.a.g(c()),e=b.scrollTop;d&&"number"==typeof d.length&&a.a.K(b.getElementsByTagName("option"),function(b){var c=0<=a.a.L(d,a.w.J(b));b.selected!=c&&(b.selected=c)});b.scrollTop=e}if("select"!=a.a.$(b))throw Error("selectedOptions binding applies only to SELECT elements");var g;a.i.subscribe(b,a.i.D,function(){g?e():(a.a.H(b,"change",e),g=a.o(f,null,{l:b}))},null,{notifyImmediately:!0})},update:function(){}};a.m.ua.selectedOptions=!0;a.c.style={update:function(b,
|
||||
c){var d=a.a.g(c()||{});a.a.O(d,function(c,d){d=a.a.g(d);if(null===d||d===n||!1===d)d="";if(/^--/.test(c))b.style.setProperty(c,d);else{c=c.replace(/-(\w)/g,function(a,b){return b.toUpperCase()});var g=b.style[c];b.style[c]=d;d===g||b.style[c]!=g||isNaN(d)||(b.style[c]=d+"px")}})}};a.c.submit={init:function(b,c,d,e,f){if("function"!=typeof c())throw Error("The value for a submit binding must be a function");a.a.H(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.c.text={init:function(){return{controlsDescendantBindings:!0}},update:function(b,c){a.a.xb(b,c())}};a.f.ba.text=!0;(function(){a.c.textInput={init:function(b,c,d){function e(){var d=a.a.g(c());if(null===d||d===n)d="";m!==n&&d===m?a.a.setTimeout(e,4):b.value!==d&&(b.value=d,g=b.value)}function f(){clearTimeout(h);m=h=n;var e=b.value;g!==e&&(g=e,a.m.$a(c(),d,"textInput",e))}var g=b.value,h,m;a.a.H(b,"input",f);a.a.H(b,"change",f);a.a.H(b,"blur",f);a.o(e,null,
|
||||
{l:b})}};a.m.ua.textInput=!0;a.c.textinput={preprocess:function(a,c,d){d("textInput",a)}}})();a.c.uniqueName={init:function(b,c){c()&&(b.name="ko_unique_"+ ++a.c.uniqueName.cd)}};a.c.uniqueName.cd=0;a.c.using={init:function(b,c,d,e,f){var g;d.has("as")&&(g={as:d.get("as"),noChildContext:d.get("noChildContext")});c=f.createChildContext(c,g);a.La(c,b);return{controlsDescendantBindings:!0}}};a.f.ba.using=!0;a.c.value={init:function(b,c,d){var e=a.a.$(b),f="input"==e;if(!f||"checkbox"!=b.type&&"radio"!=
|
||||
b.type){var g=[],h=d.get("valueUpdate"),m=null;h&&("string"==typeof h?g=[h]:g=h?h.filter(function(a,b){return h.indexOf(a)===b}):[],a.a.Ma(g,"change"));var k=function(){m=null;var e=c(),f=a.w.J(b);a.m.$a(e,d,"value",f)};a.a.K(g,function(c){var d=k;a.a.Bd(c,"after")&&(d=function(){m=a.w.J(b);a.a.setTimeout(k,0)},c=c.substring(5));a.a.H(b,c,d)});var l;l=f&&"file"==b.type?function(){var d=a.a.g(c());null===d||d===n||""===d?b.value="":a.u.C(k)}:function(){var f=a.a.g(c()),g=a.w.J(b);if(null!==m&&f===
|
||||
m)a.a.setTimeout(l,0);else if(f!==g||g===n)"select"===e?(g=d.get("valueAllowUnset"),a.w.Za(b,f,g),g||f===a.w.J(b)||a.u.C(k)):a.w.Za(b,f)};if("select"===e){var p;a.i.subscribe(b,a.i.D,function(){p?d.get("valueAllowUnset")?l():k():(a.a.H(b,"change",k),p=a.o(l,null,{l:b}))},null,{notifyImmediately:!0})}else a.a.H(b,"change",k),a.o(l,null,{l:b})}else a.eb(b,{checkedValue:c})},update:function(){}};a.m.ua.value=!0;a.c.visible={update:function(b,c){var d=a.a.g(c()),e="none"!=b.style.display;d&&!e?b.style.display=
|
||||
"":!d&&e&&(b.style.display="none")}};a.c.hidden={update:function(b,c){a.c.visible.update(b,function(){return!a.a.g(c())})}};(function(b){a.c[b]={init:function(c,d,e,f,g){return a.c.event.init.call(this,c,function(){var a={};a[b]=d();return a},e,f,g)}}})("click");a.ga=function(){};a.ga.prototype.renderTemplateSource=function(){throw Error("Override renderTemplateSource");};a.ga.prototype.createJavaScriptEvaluatorBlock=function(){throw Error("Override createJavaScriptEvaluatorBlock");};a.ga.prototype.makeTemplateSource=
|
||||
function(b,c){if("string"==typeof b){c=c||z;var d=c.getElementById(b);if(!d)throw Error("Cannot find template with ID "+b);return new a.A.B(d)}if(1==b.nodeType||8==b.nodeType)return new a.A.ha(b);throw Error("Unknown template type: "+b);};a.ga.prototype.renderTemplate=function(a,c,d,e){a=this.makeTemplateSource(a,e);return this.renderTemplateSource(a,c,d,e)};a.ga.prototype.isTemplateRewritten=function(a,c){return!1===this.allowTemplateRewriting?!0:this.makeTemplateSource(a,c).data("isRewritten")};
|
||||
a.ga.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.ga);a.cc=function(){function b(b,c,d,h){b=a.m.Ub(b);for(var m=a.m.Oa,k=0;k<b.length;k++){var l=b[k].key;if(Object.prototype.hasOwnProperty.call(m,l)){var p=m[l];if("function"===typeof p){if(l=p(b[k].value))throw Error(l);}else if(!p)throw Error("This template engine does not support the '"+l+"' binding within its templates");}}d="ko.__tr_ambtns(function($context,$element){return(function(){return{ "+
|
||||
a.m.rb(b,{valueAccessors:!0})+" } })()},'"+d.toLowerCase()+"')";return h.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{gd:function(b,c,d){c.isTemplateRewritten(b,d)||c.rewriteTemplate(b,function(b){return a.cc.ud(b,c)},d)},ud:function(a,f){return a.replace(c,function(a,c,d,e,l){return b(l,c,d,f)}).replace(d,function(a,c){return b(c,
|
||||
"\x3c!-- ko --\x3e","#comment",f)})},Yc:function(b,c){return a.Y.Qb(function(d,h){var m=d.nextSibling;m&&m.nodeName.toLowerCase()===c&&a.eb(m,b,h)})}}}();a.b("__tr_ambtns",a.cc.Yc);(function(){a.A={};a.A.B=function(b){if(this.B=b){var c=a.a.$(b);this.Xa="script"===c?1:"textarea"===c?2:"template"==c&&b.content&&11===b.content.nodeType?3:4}};a.A.B.prototype.text=function(){var b=1===this.Xa?"text":2===this.Xa?"value":"innerHTML";if(0==arguments.length)return this.B[b];var c=arguments[0];"innerHTML"===
|
||||
b?a.a.Zb(this.B,c):this.B[b]=c};var b=a.a.h.fa()+"_";a.A.B.prototype.data=function(c){if(1===arguments.length)return a.a.h.get(this.B,b+c);a.a.h.set(this.B,b+c,arguments[1])};var c=a.a.h.fa();a.A.B.prototype.nodes=function(){var b=this.B;if(0==arguments.length){var e=a.a.h.get(b,c)||{},f=e.hb||(3===this.Xa?b.content:4===this.Xa?b:n);if(!f||e.Vc){var g=this.text();g&&g!==e.Ya&&(f=a.a.wd(g,b.ownerDocument),a.a.h.set(b,c,{hb:f,Ya:g,Vc:!0}))}return f}e=arguments[0];this.Xa!==n&&this.text("");a.a.h.set(b,
|
||||
c,{hb:e})};a.A.ha=function(a){this.B=a};a.A.ha.prototype=new a.A.B;a.A.ha.prototype.constructor=a.A.ha;a.A.ha.prototype.text=function(){if(0==arguments.length){var b=a.a.h.get(this.B,c)||{};b.Ya===n&&b.hb&&(b.Ya=b.hb.innerHTML);return b.Ya}a.a.h.set(this.B,c,{Ya:arguments[0]})};a.b("templateSources",a.A);a.b("templateSources.domElement",a.A.B);a.b("templateSources.anonymousTemplate",a.A.ha)})();(function(){function b(b,c,d){var e;for(c=a.f.nextSibling(c);b&&(e=b)!==c;)b=a.f.nextSibling(e),d(e,b)}
|
||||
function c(c,d){if(c.length){var e=c[0],f=c[c.length-1],g=e.parentNode,h=a.da.instance,m=h.preprocessNode;if(m){b(e,f,function(a,b){var c=a.previousSibling,d=m.call(h,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.Ra(c,g))}b(e,f,function(b){1!==b.nodeType&&8!==b.nodeType||a.nc(d,b)});b(e,f,function(b){1!==b.nodeType&&8!==b.nodeType||a.Y.Qc(b,[d])});a.a.Ra(c,g)}}function d(a){return a.nodeType?a:0<a.length?a[0]:null}function e(b,e,
|
||||
f,h,m){m=m||{};var n=(b&&d(b)||f||{}).ownerDocument,u=m.templateEngine||g;a.cc.gd(f,u,n);f=u.renderTemplate(f,h,m,n);if("number"!=typeof f.length||0<f.length&&"number"!=typeof f[0].nodeType)throw Error("Template engine must return an array of DOM nodes");n=!1;switch(e){case "replaceChildren":a.f.ta(b,f);n=!0;break;case "replaceNode":a.a.Mc(b,f);n=!0;break;case "ignoreTargetNode":break;default:throw Error("Unknown renderMode: "+e);}n&&(c(f,h),m.afterRender&&a.u.C(m.afterRender,null,[f,h[m.as||"$data"]]),
|
||||
"replaceChildren"==e&&a.i.ka(b,a.i.D));return f}function f(b,c,d){return a.R(b)?b():"function"===typeof b?b(c,d):b}var g;a.Nc=function(b){if(b!=n&&!(b instanceof a.ga))throw Error("templateEngine must inherit from ko.templateEngine");g=b};a.Xb=function(b,c,h,m,r){h=h||{};if((h.templateEngine||g)==n)throw Error("Set a template engine before calling renderTemplate");r=r||"replaceChildren";if(m){var w=d(m);return a.X(function(){var g=c&&c instanceof a.ca?c:new a.ca(c,null,null,null,{exportDependencies:!0}),
|
||||
n=f(b,g.$data,g),g=e(m,r,n,g,h);"replaceNode"==r&&(m=g,w=d(m))},null,{Pa:function(){return!w||!a.a.Lb(w)},l:w&&"replaceNode"==r?w.parentNode:w})}return a.Y.Qb(function(d){a.Xb(b,c,h,d,"replaceNode")})};a.xd=function(b,d,g,h,m){function w(b,c){a.u.C(a.a.Yb,null,[h,b,t,g,u,c]);a.i.ka(h,a.i.D)}function u(a,b){c(b,q);g.afterRender&&g.afterRender(b,a);q=null}function t(a,c){q=m.createChildContext(a,{as:A,noChildContext:g.noChildContext,extend:function(a){a.$index=c;A&&(a[A+"Index"]=c)}});var d=f(b,a,q);
|
||||
return e(h,"ignoreTargetNode",d,q,g)}var q,A=g.as,B=!1===g.includeDestroyed||a.options.foreachHidesDestroyed&&!g.includeDestroyed;if(B||g.beforeRemove||!a.Ec(d))return a.X(function(){var b=a.a.g(d)||[];"undefined"==typeof b.length&&(b=[b]);B&&(b=a.a.fb(b,function(b){return b===n||null===b||!a.a.g(b._destroy)}));w(b)},null,{l:h});w(d.v());var y=d.subscribe(function(a){w(d(),a)},null,"arrayChange");y.l(h);return y};var h=a.a.h.fa(),m=a.a.h.fa();a.c.template={init:function(b,c){var d=a.a.g(c());if("string"==
|
||||
typeof d||"name"in d)a.f.Aa(b);else if("nodes"in d){d=d.nodes||[];if(a.R(d))throw Error('The "nodes" option must be a plain, non-observable array.');var e=d[0]&&d[0].parentNode;e&&a.a.h.get(e,m)||(e=a.a.Rb(d),a.a.h.set(e,m,!0));(new a.A.ha(b)).nodes(e)}else if(d=a.f.childNodes(b),0<d.length)e=a.a.Rb(d),(new a.A.ha(b)).nodes(e);else throw Error("Anonymous template defined, but no template content was provided");return{controlsDescendantBindings:!0}},update:function(b,c,d,e,f){var g=c();c=a.a.g(g);
|
||||
d=!0;e=null;"string"==typeof c?c={}:(g="name"in c?c.name:b,"if"in c&&(d=a.a.g(c["if"])),d&&"ifnot"in c&&(d=!a.a.g(c.ifnot)),d&&!g&&(d=!1));"foreach"in c?e=a.xd(g,d&&c.foreach||[],c,b,f):d?(d=f,"data"in c&&(d=f.createChildContext(c.data,{as:c.as,noChildContext:c.noChildContext,exportDependencies:!0})),e=a.Xb(g,d,c,b)):a.f.Aa(b);f=e;(c=a.a.h.get(b,h))&&"function"==typeof c.s&&c.s();a.a.h.set(b,h,!f||f.ia&&!f.ia()?n:f)}};a.m.Oa.template=function(b){b=a.m.Ub(b);return 1==b.length&&b[0].unknown||a.m.qd(b,
|
||||
"name")?null:"This template engine does not support anonymous templates nested within its templates"};a.f.ba.template=!0})();a.b("setTemplateEngine",a.Nc);a.b("renderTemplate",a.Xb);a.a.Ac=function(a,c,d){if(a.length&&c.length){var e,f,g,h,m;for(e=f=0;(!d||e<d)&&(h=a[f]);++f){for(g=0;m=c[g];++g)if(h.value===m.value){h.moved=m.index;m.moved=h.index;c.splice(g,1);e=g=0;break}e+=g}}};a.a.Ib=function(){function b(b,d,e,f,g){var h=Math.min,m=Math.max,k=[],l,p=b.length,n,r=d.length,q=r-p||1,u=p+r+1,t,y,
|
||||
A;for(l=0;l<=p;l++)for(y=t,k.push(t=[]),A=h(r,l+q),n=m(0,l-1);n<=A;n++)t[n]=n?l?b[l-1]===d[n-1]?y[n-1]:h(y[n]||u,t[n-1]||u)+1:n+1:l+1;h=[];m=[];q=[];l=p;for(n=r;l||n;)r=k[l][n]-1,n&&r===k[l][n-1]?m.push(h[h.length]={status:e,value:d[--n],index:n}):l&&r===k[l-1][n]?q.push(h[h.length]={status:f,value:b[--l],index:l}):(--n,--l,g.sparse||h.push({status:"retained",value:d[n]}));a.a.Ac(q,m,!g.dontLimitMoves&&10*p);return h.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,h,m){var k=[],l=a.X(function(){var l=c(d,m,a.a.Ra(k,b))||[];0<k.length&&(a.a.Mc(k,l),h&&a.u.C(h,null,[d,l,m]));k.length=0;a.a.Gb(k,l)},null,{l:b,Pa:function(){return!a.a.Wc(k)}});return{W:k,X:l.ia()?l:n}}var c=a.a.h.fa(),d=a.a.h.fa();a.a.Yb=function(e,f,g,h,m,k){function l(b){x={xa:b,lb:a.ra(y++)};u.push(x);w||D.push(x)}function p(b){x=r[b];
|
||||
y!==x.lb.v()&&C.push(x);x.lb(y++);a.a.Ra(x.W,e);u.push(x)}function q(b,c){if(b)for(var d=0,e=c.length;d<e;d++)a.a.K(c[d].W,function(a){b(a,d,c[d].xa)})}f=f||[];"undefined"==typeof f.length&&(f=[f]);h=h||{};var r=a.a.h.get(e,c),w=!r,u=[],t=0,y=0,A=[],B=[],z=[],C=[],D=[],x,G=0;if(w)a.a.K(f,l);else{if(!k||r&&r._countWaitingForRemove){var E=Array.prototype.map.call(r,function(a){return a.xa});k=a.a.Ib(E,f,{dontLimitMoves:h.dontLimitMoves,sparse:!0})}for(var E=0,F,H,I;F=k[E];E++)switch(H=F.moved,I=F.index,
|
||||
F.status){case "deleted":for(;t<I;)p(t++);H===n&&(x=r[t],x.X&&(x.X.s(),x.X=n),a.a.Ra(x.W,e).length&&(h.beforeRemove&&(u.push(x),G++,x.xa===d?x=null:z.push(x)),x&&A.push.apply(A,x.W)));t++;break;case "added":for(;y<I;)p(t++);H!==n?(B.push(u.length),p(H)):l(F.value)}for(;y<f.length;)p(t++);u._countWaitingForRemove=G}a.a.h.set(e,c,u);q(h.beforeMove,C);a.a.K(A,h.beforeRemove?a.ma:a.removeNode);var K,M,N;try{N=e.ownerDocument.activeElement}catch(L){}if(B.length)for(;(E=B.shift())!=n;){x=u[E];for(K=n;E;)if((M=
|
||||
u[--E].W)&&M.length){K=M[M.length-1];break}for(f=0;t=x.W[f];K=t,f++)a.f.Pb(e,t,K)}for(E=0;x=u[E];E++){x.W||a.a.extend(x,b(e,g,x.xa,m,x.lb));for(f=0;t=x.W[f];K=t,f++)a.f.Pb(e,t,K);!x.nd&&m&&(m(x.xa,x.W,x.lb),x.nd=!0,K=x.W[x.W.length-1])}N&&e.ownerDocument.activeElement!=N&&N.focus();q(h.beforeRemove,z);for(E=0;E<z.length;++E)z[E].xa=d;q(h.afterMove,C);q(h.afterAdd,D)}})();a.b("utils.setDomNodeChildrenFromArrayMapping",a.a.Yb);a.Z=function(){this.allowTemplateRewriting=!1};a.Z.prototype=new a.ga;a.Z.prototype.constructor=
|
||||
a.Z;a.Z.prototype.renderTemplateSource=function(b,c,d,e){if(c=b.vd?b.vd():null)return a.a.Ca(c.cloneNode(!0).childNodes);b=b.text();return a.a.sa(b,e)};a.Z.Ja=new a.Z;a.Nc(a.Z.Ja);a.b("nativeTemplateEngine",a.Z)})})();})();
|
7
vendors/knockout/package.json
vendored
7
vendors/knockout/package.json
vendored
|
@ -20,10 +20,9 @@
|
|||
"preprocess": "build/build.sh",
|
||||
"html": "spec/runner.html?src=build/output/knockout-latest.js&testling=true",
|
||||
"browsers": [
|
||||
"ie/6..latest",
|
||||
"chrome/20..latest",
|
||||
"firefox/3..latest",
|
||||
"safari/5.0.5..latest",
|
||||
"chrome/68..latest",
|
||||
"firefox/56..latest",
|
||||
"safari/10..latest",
|
||||
"opera/11.0..latest",
|
||||
"iphone/6..latest",
|
||||
"ipad/6..latest"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
(function () {
|
||||
// Hide or don't minify context properties, see https://github.com/knockout/knockout/issues/2294
|
||||
var contextSubscribable = ko.utils.createSymbolOrString('_subscribable');
|
||||
var contextAncestorBindingInfo = ko.utils.createSymbolOrString('_ancestorBindingInfo');
|
||||
var contextDataDependency = ko.utils.createSymbolOrString('_dataDependency');
|
||||
var contextSubscribable = Symbol('_subscribable');
|
||||
var contextAncestorBindingInfo = Symbol('_ancestorBindingInfo');
|
||||
var contextDataDependency = Symbol('_dataDependency');
|
||||
|
||||
ko.bindingHandlers = {};
|
||||
|
||||
|
@ -565,11 +565,6 @@
|
|||
};
|
||||
|
||||
ko.applyBindings = function (viewModelOrBindingContext, rootNode, extendContextCallback) {
|
||||
// If jQuery is loaded after Knockout, we won't initially have access to it. So save it here.
|
||||
if (!jQueryInstance && window['jQuery']) {
|
||||
jQueryInstance = window['jQuery'];
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
rootNode = document.body;
|
||||
if (!rootNode) {
|
||||
|
|
14
vendors/knockout/src/binding/defaultBindings/attr.js
vendored
Executable file → Normal file
14
vendors/knockout/src/binding/defaultBindings/attr.js
vendored
Executable file → Normal file
|
@ -19,17 +19,7 @@ ko.bindingHandlers['attr'] = {
|
|||
attrValue = attrValue.toString();
|
||||
}
|
||||
|
||||
// In IE <= 7 and IE8 Quirks Mode, you have to use the JavaScript property name instead of the
|
||||
// HTML attribute name for certain attributes. IE8 Standards Mode supports the correct behavior,
|
||||
// but instead of figuring out the mode, we'll just set the attribute through the JavaScript
|
||||
// property for IE <= 8.
|
||||
if (ko.utils.ieVersion <= 8 && attrName in attrHtmlToJavaScriptMap) {
|
||||
attrName = attrHtmlToJavaScriptMap[attrName];
|
||||
if (toRemove)
|
||||
element.removeAttribute(attrName);
|
||||
else
|
||||
element[attrName] = attrValue;
|
||||
} else if (!toRemove) {
|
||||
if (!toRemove) {
|
||||
namespace ? element.setAttributeNS(namespace, attrName, attrValue) : element.setAttribute(attrName, attrValue);
|
||||
}
|
||||
|
||||
|
@ -38,7 +28,7 @@ ko.bindingHandlers['attr'] = {
|
|||
// Deliberately being case-sensitive here because XHTML would regard "Name" as a different thing
|
||||
// entirely, and there's no strong reason to allow for such casing in HTML.
|
||||
if (attrName === "name") {
|
||||
ko.utils.setElementName(element, toRemove ? "" : attrValue);
|
||||
element.name = toRemove ? "" : attrValue;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
19
vendors/knockout/src/binding/defaultBindings/checked.js
vendored
Executable file → Normal file
19
vendors/knockout/src/binding/defaultBindings/checked.js
vendored
Executable file → Normal file
|
@ -1,5 +1,16 @@
|
|||
(function() {
|
||||
|
||||
function addOrRemoveItem(array, value, included) {
|
||||
var existingEntryIndex = ko.utils.arrayIndexOf(ko.utils.peekObservable(array), value);
|
||||
if (existingEntryIndex < 0) {
|
||||
if (included)
|
||||
array.push(value);
|
||||
} else {
|
||||
if (!included)
|
||||
array.splice(existingEntryIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
ko.bindingHandlers['checked'] = {
|
||||
'after': ['value', 'attr'],
|
||||
'init': function (element, valueAccessor, allBindings) {
|
||||
|
@ -45,13 +56,13 @@ ko.bindingHandlers['checked'] = {
|
|||
// currently checked, replace the old elem value with the new elem value
|
||||
// in the model array.
|
||||
if (isChecked) {
|
||||
ko.utils.addOrRemoveItem(writableValue, elemValue, true);
|
||||
ko.utils.addOrRemoveItem(writableValue, saveOldValue, false);
|
||||
addOrRemoveItem(writableValue, elemValue, true);
|
||||
addOrRemoveItem(writableValue, saveOldValue, false);
|
||||
}
|
||||
} else {
|
||||
// When we're responding to the user having checked/unchecked a checkbox,
|
||||
// add/remove the element value to the model array.
|
||||
ko.utils.addOrRemoveItem(writableValue, elemValue, isChecked);
|
||||
addOrRemoveItem(writableValue, elemValue, isChecked);
|
||||
}
|
||||
|
||||
if (rawValueIsNonArrayObservable && ko.isWriteableObservable(modelValue)) {
|
||||
|
@ -127,4 +138,4 @@ ko.bindingHandlers['checkedValue'] = {
|
|||
}
|
||||
};
|
||||
|
||||
})();
|
||||
})();
|
||||
|
|
0
vendors/knockout/src/binding/defaultBindings/click.js
vendored
Executable file → Normal file
0
vendors/knockout/src/binding/defaultBindings/click.js
vendored
Executable file → Normal file
18
vendors/knockout/src/binding/defaultBindings/css.js
vendored
Executable file → Normal file
18
vendors/knockout/src/binding/defaultBindings/css.js
vendored
Executable file → Normal file
|
@ -1,10 +1,22 @@
|
|||
var classesWrittenByBindingKey = '__ko__cssValue';
|
||||
|
||||
// For details on the pattern for changing node classes
|
||||
// see: https://github.com/knockout/knockout/issues/1597
|
||||
function toggleDomNodeCssClass(node, classNames, shouldHaveClass) {
|
||||
if (classNames) {
|
||||
var addOrRemoveFn = shouldHaveClass ? 'add' : 'remove';
|
||||
classNames.split(/\s+/).forEach(function(className) {
|
||||
node.classList[addOrRemoveFn](className);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ko.bindingHandlers['class'] = {
|
||||
'update': function (element, valueAccessor) {
|
||||
var value = ko.utils.stringTrim(ko.utils.unwrapObservable(valueAccessor()));
|
||||
ko.utils.toggleDomNodeCssClass(element, element[classesWrittenByBindingKey], false);
|
||||
toggleDomNodeCssClass(element, element[classesWrittenByBindingKey], false);
|
||||
element[classesWrittenByBindingKey] = value;
|
||||
ko.utils.toggleDomNodeCssClass(element, value, true);
|
||||
toggleDomNodeCssClass(element, value, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -14,7 +26,7 @@ ko.bindingHandlers['css'] = {
|
|||
if (value !== null && typeof value == "object") {
|
||||
ko.utils.objectForEach(value, function(className, shouldHaveClass) {
|
||||
shouldHaveClass = ko.utils.unwrapObservable(shouldHaveClass);
|
||||
ko.utils.toggleDomNodeCssClass(element, className, shouldHaveClass);
|
||||
toggleDomNodeCssClass(element, className, shouldHaveClass);
|
||||
});
|
||||
} else {
|
||||
ko.bindingHandlers['class']['update'](element, valueAccessor);
|
||||
|
|
0
vendors/knockout/src/binding/defaultBindings/enableDisable.js
vendored
Executable file → Normal file
0
vendors/knockout/src/binding/defaultBindings/enableDisable.js
vendored
Executable file → Normal file
0
vendors/knockout/src/binding/defaultBindings/event.js
vendored
Executable file → Normal file
0
vendors/knockout/src/binding/defaultBindings/event.js
vendored
Executable file → Normal file
0
vendors/knockout/src/binding/defaultBindings/foreach.js
vendored
Executable file → Normal file
0
vendors/knockout/src/binding/defaultBindings/foreach.js
vendored
Executable file → Normal file
16
vendors/knockout/src/binding/defaultBindings/hasfocus.js
vendored
Executable file → Normal file
16
vendors/knockout/src/binding/defaultBindings/hasfocus.js
vendored
Executable file → Normal file
|
@ -10,17 +10,7 @@ ko.bindingHandlers['hasfocus'] = {
|
|||
// from calling 'blur()' on the element when it loses focus.
|
||||
// Discussion at https://github.com/SteveSanderson/knockout/pull/352
|
||||
element[hasfocusUpdatingProperty] = true;
|
||||
var ownerDoc = element.ownerDocument;
|
||||
if ("activeElement" in ownerDoc) {
|
||||
var active;
|
||||
try {
|
||||
active = ownerDoc.activeElement;
|
||||
} catch(e) {
|
||||
// IE9 throws if you access activeElement during page load (see issue #703)
|
||||
active = ownerDoc.body;
|
||||
}
|
||||
isFocused = (active === element);
|
||||
}
|
||||
isFocused = (element.ownerDocument.activeElement === element);
|
||||
var modelValue = valueAccessor();
|
||||
ko.expressionRewriting.writeValueToProperty(modelValue, allBindings, 'hasfocus', isFocused, true);
|
||||
|
||||
|
@ -32,9 +22,9 @@ ko.bindingHandlers['hasfocus'] = {
|
|||
var handleElementFocusOut = handleElementFocusChange.bind(null, false);
|
||||
|
||||
ko.utils.registerEventHandler(element, "focus", handleElementFocusIn);
|
||||
ko.utils.registerEventHandler(element, "focusin", handleElementFocusIn); // For IE
|
||||
ko.utils.registerEventHandler(element, "focusin", handleElementFocusIn);
|
||||
ko.utils.registerEventHandler(element, "blur", handleElementFocusOut);
|
||||
ko.utils.registerEventHandler(element, "focusout", handleElementFocusOut); // For IE
|
||||
ko.utils.registerEventHandler(element, "focusout", handleElementFocusOut);
|
||||
|
||||
// Assume element is not focused (prevents "blur" being called initially)
|
||||
element[hasfocusLastValue] = false;
|
||||
|
|
0
vendors/knockout/src/binding/defaultBindings/html.js
vendored
Executable file → Normal file
0
vendors/knockout/src/binding/defaultBindings/html.js
vendored
Executable file → Normal file
0
vendors/knockout/src/binding/defaultBindings/ifIfnotWith.js
vendored
Executable file → Normal file
0
vendors/knockout/src/binding/defaultBindings/ifIfnotWith.js
vendored
Executable file → Normal file
7
vendors/knockout/src/binding/defaultBindings/options.js
vendored
Executable file → Normal file
7
vendors/knockout/src/binding/defaultBindings/options.js
vendored
Executable file → Normal file
|
@ -30,7 +30,7 @@ ko.bindingHandlers['options'] = {
|
|||
|
||||
if (!valueAllowUnset) {
|
||||
if (multiple) {
|
||||
previousSelectedValues = ko.utils.arrayMap(selectedOptions(), ko.selectExtensions.readValue);
|
||||
previousSelectedValues = selectedOptions().map(ko.selectExtensions.readValue);
|
||||
} else if (element.selectedIndex >= 0) {
|
||||
previousSelectedValues.push(ko.selectExtensions.readValue(element.options[element.selectedIndex]));
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ ko.bindingHandlers['options'] = {
|
|||
// IE6 doesn't like us to assign selection to OPTION nodes before they're added to the document.
|
||||
// That's why we first added them without selection. Now it's time to set the selection.
|
||||
var isSelected = ko.utils.arrayIndexOf(previousSelectedValues, ko.selectExtensions.readValue(newOptions[0])) >= 0;
|
||||
ko.utils.setOptionNodeSelectionState(newOptions[0], isSelected);
|
||||
newOptions[0].selected = isSelected;
|
||||
|
||||
// If this option was changed from being selected during a single-item update, notify the change
|
||||
if (itemUpdate && !isSelected) {
|
||||
|
@ -154,9 +154,6 @@ ko.bindingHandlers['options'] = {
|
|||
ko.bindingEvent.notify(element, ko.bindingEvent.childrenComplete);
|
||||
}
|
||||
|
||||
// Workaround for IE bug
|
||||
ko.utils.ensureSelectElementIsRenderedCorrectly(element);
|
||||
|
||||
if (previousScrollTop && Math.abs(previousScrollTop - element.scrollTop) > 20)
|
||||
element.scrollTop = previousScrollTop;
|
||||
}
|
||||
|
|
2
vendors/knockout/src/binding/defaultBindings/selectedOptions.js
vendored
Executable file → Normal file
2
vendors/knockout/src/binding/defaultBindings/selectedOptions.js
vendored
Executable file → Normal file
|
@ -17,7 +17,7 @@ ko.bindingHandlers['selectedOptions'] = {
|
|||
ko.utils.arrayForEach(element.getElementsByTagName("option"), function(node) {
|
||||
var isSelected = ko.utils.arrayIndexOf(newValue, ko.selectExtensions.readValue(node)) >= 0;
|
||||
if (node.selected != isSelected) { // This check prevents flashing of the select element in IE
|
||||
ko.utils.setOptionNodeSelectionState(node, isSelected);
|
||||
node.selected = isSelected;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
4
vendors/knockout/src/binding/defaultBindings/style.js
vendored
Executable file → Normal file
4
vendors/knockout/src/binding/defaultBindings/style.js
vendored
Executable file → Normal file
|
@ -9,9 +9,7 @@ ko.bindingHandlers['style'] = {
|
|||
styleValue = "";
|
||||
}
|
||||
|
||||
if (jQueryInstance) {
|
||||
jQueryInstance(element)['css'](styleName, styleValue);
|
||||
} else if (/^--/.test(styleName)) {
|
||||
if (/^--/.test(styleName)) {
|
||||
// Is styleName a custom CSS property?
|
||||
element.style.setProperty(styleName, styleValue);
|
||||
} else {
|
||||
|
|
0
vendors/knockout/src/binding/defaultBindings/submit.js
vendored
Executable file → Normal file
0
vendors/knockout/src/binding/defaultBindings/submit.js
vendored
Executable file → Normal file
0
vendors/knockout/src/binding/defaultBindings/text.js
vendored
Executable file → Normal file
0
vendors/knockout/src/binding/defaultBindings/text.js
vendored
Executable file → Normal file
|
@ -1,51 +1,5 @@
|
|||
(function () {
|
||||
|
||||
if (window && window.navigator) {
|
||||
var parseVersion = function (matches) {
|
||||
if (matches) {
|
||||
return parseFloat(matches[1]);
|
||||
}
|
||||
};
|
||||
|
||||
// Detect various browser versions because some old versions don't fully support the 'input' event
|
||||
var userAgent = window.navigator.userAgent,
|
||||
operaVersion, chromeVersion, safariVersion, firefoxVersion, ieVersion, edgeVersion;
|
||||
|
||||
(operaVersion = window.opera && window.opera.version && parseInt(window.opera.version()))
|
||||
|| (edgeVersion = parseVersion(userAgent.match(/Edge\/([^ ]+)$/)))
|
||||
|| (chromeVersion = parseVersion(userAgent.match(/Chrome\/([^ ]+)/)))
|
||||
|| (safariVersion = parseVersion(userAgent.match(/Version\/([^ ]+) Safari/)))
|
||||
|| (firefoxVersion = parseVersion(userAgent.match(/Firefox\/([^ ]+)/)))
|
||||
|| (ieVersion = ko.utils.ieVersion || parseVersion(userAgent.match(/MSIE ([^ ]+)/))) // Detects up to IE 10
|
||||
|| (ieVersion = parseVersion(userAgent.match(/rv:([^ )]+)/))); // Detects IE 11
|
||||
}
|
||||
|
||||
// IE 8 and 9 have bugs that prevent the normal events from firing when the value changes.
|
||||
// But it does fire the 'selectionchange' event on many of those, presumably because the
|
||||
// cursor is moving and that counts as the selection changing. The 'selectionchange' event is
|
||||
// fired at the document level only and doesn't directly indicate which element changed. We
|
||||
// set up just one event handler for the document and use 'activeElement' to determine which
|
||||
// element was changed.
|
||||
if (ieVersion >= 8 && ieVersion < 10) {
|
||||
var selectionChangeRegisteredName = ko.utils.domData.nextKey(),
|
||||
selectionChangeHandlerName = ko.utils.domData.nextKey();
|
||||
var selectionChangeHandler = function(event) {
|
||||
var target = this.activeElement,
|
||||
handler = target && ko.utils.domData.get(target, selectionChangeHandlerName);
|
||||
if (handler) {
|
||||
handler(event);
|
||||
}
|
||||
};
|
||||
var registerForSelectionChangeEvent = function (element, handler) {
|
||||
var ownerDoc = element.ownerDocument;
|
||||
if (!ko.utils.domData.get(ownerDoc, selectionChangeRegisteredName)) {
|
||||
ko.utils.domData.set(ownerDoc, selectionChangeRegisteredName, true);
|
||||
ko.utils.registerEventHandler(ownerDoc, 'selectionchange', selectionChangeHandler);
|
||||
}
|
||||
ko.utils.domData.set(element, selectionChangeHandlerName, handler);
|
||||
};
|
||||
}
|
||||
|
||||
ko.bindingHandlers['textInput'] = {
|
||||
'init': function (element, valueAccessor, allBindings) {
|
||||
|
||||
|
@ -80,8 +34,7 @@ ko.bindingHandlers['textInput'] = {
|
|||
|
||||
// IE9 will mess up the DOM if you handle events synchronously which results in DOM changes (such as other bindings);
|
||||
// so we'll make sure all updates are asynchronous
|
||||
var ieUpdateModel = ko.utils.ieVersion == 9 ? deferUpdateModel : updateModel,
|
||||
ourUpdate = false;
|
||||
var ourUpdate = false;
|
||||
|
||||
var updateView = function () {
|
||||
var modelValue = ko.utils.unwrapObservable(valueAccessor());
|
||||
|
@ -119,66 +72,7 @@ ko.bindingHandlers['textInput'] = {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
if (ieVersion) {
|
||||
// All versions (including 11) of Internet Explorer have a bug that they don't generate an input or propertychange event when ESC is pressed
|
||||
onEvent('keypress', updateModel);
|
||||
}
|
||||
if (ieVersion < 11) {
|
||||
// Internet Explorer <= 8 doesn't support the 'input' event, but does include 'propertychange' that fires whenever
|
||||
// any property of an element changes. Unlike 'input', it also fires if a property is changed from JavaScript code,
|
||||
// but that's an acceptable compromise for this binding. IE 9 and 10 support 'input', but since they don't always
|
||||
// fire it when using autocomplete, we'll use 'propertychange' for them also.
|
||||
onEvent('propertychange', function(event) {
|
||||
if (!ourUpdate && event.propertyName === 'value') {
|
||||
ieUpdateModel(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (ieVersion == 8) {
|
||||
// IE 8 has a bug where it fails to fire 'propertychange' on the first update following a value change from
|
||||
// JavaScript code. It also doesn't fire if you clear the entire value. To fix this, we bind to the following
|
||||
// events too.
|
||||
onEvent('keyup', updateModel); // A single keystoke
|
||||
onEvent('keydown', updateModel); // The first character when a key is held down
|
||||
}
|
||||
if (registerForSelectionChangeEvent) {
|
||||
// Internet Explorer 9 doesn't fire the 'input' event when deleting text, including using
|
||||
// the backspace, delete, or ctrl-x keys, clicking the 'x' to clear the input, dragging text
|
||||
// out of the field, and cutting or deleting text using the context menu. 'selectionchange'
|
||||
// can detect all of those except dragging text out of the field, for which we use 'dragend'.
|
||||
// These are also needed in IE8 because of the bug described above.
|
||||
registerForSelectionChangeEvent(element, ieUpdateModel); // 'selectionchange' covers cut, paste, drop, delete, etc.
|
||||
onEvent('dragend', deferUpdateModel);
|
||||
}
|
||||
|
||||
if (!ieVersion || ieVersion >= 9) {
|
||||
// All other supported browsers support the 'input' event, which fires whenever the content of the element is changed
|
||||
// through the user interface.
|
||||
onEvent('input', ieUpdateModel);
|
||||
}
|
||||
|
||||
if (safariVersion < 5 && ko.utils.tagNameLower(element) === "textarea") {
|
||||
// Safari <5 doesn't fire the 'input' event for <textarea> elements (it does fire 'textInput'
|
||||
// but only when typing). So we'll just catch as much as we can with keydown, cut, and paste.
|
||||
onEvent('keydown', deferUpdateModel);
|
||||
onEvent('paste', deferUpdateModel);
|
||||
onEvent('cut', deferUpdateModel);
|
||||
} else if (operaVersion < 11) {
|
||||
// Opera 10 doesn't always fire the 'input' event for cut, paste, undo & drop operations.
|
||||
// We can try to catch some of those using 'keydown'.
|
||||
onEvent('keydown', deferUpdateModel);
|
||||
} else if (firefoxVersion < 4.0) {
|
||||
// Firefox <= 3.6 doesn't fire the 'input' event when text is filled in through autocomplete
|
||||
onEvent('DOMAutoComplete', updateModel);
|
||||
|
||||
// Firefox <=3.5 doesn't fire the 'input' event when text is dropped into the input.
|
||||
onEvent('dragdrop', updateModel); // <3.5
|
||||
onEvent('drop', updateModel); // 3.5
|
||||
} else if (edgeVersion && element.type === "number") {
|
||||
// Microsoft Edge doesn't fire 'input' or 'change' events for number inputs when
|
||||
// the value is changed via the up / down arrow keys
|
||||
onEvent('keydown', deferUpdateModel);
|
||||
}
|
||||
onEvent('input', updateModel);
|
||||
}
|
||||
|
||||
// Bind to the change event so that we can catch programmatic updates of the value that fire this event.
|
||||
|
@ -200,4 +94,4 @@ ko.bindingHandlers['textinput'] = {
|
|||
}
|
||||
};
|
||||
|
||||
})();
|
||||
})();
|
||||
|
|
3
vendors/knockout/src/binding/defaultBindings/uniqueName.js
vendored
Executable file → Normal file
3
vendors/knockout/src/binding/defaultBindings/uniqueName.js
vendored
Executable file → Normal file
|
@ -1,8 +1,7 @@
|
|||
ko.bindingHandlers['uniqueName'] = {
|
||||
'init': function (element, valueAccessor) {
|
||||
if (valueAccessor()) {
|
||||
var name = "ko_unique_" + (++ko.bindingHandlers['uniqueName'].currentIndex);
|
||||
ko.utils.setElementName(element, name);
|
||||
element.name = "ko_unique_" + (++ko.bindingHandlers['uniqueName'].currentIndex);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
20
vendors/knockout/src/binding/defaultBindings/value.js
vendored
Executable file → Normal file
20
vendors/knockout/src/binding/defaultBindings/value.js
vendored
Executable file → Normal file
|
@ -11,7 +11,6 @@ ko.bindingHandlers['value'] = {
|
|||
|
||||
var eventsToCatch = [];
|
||||
var requestedEventsToCatch = allBindings.get("valueUpdate");
|
||||
var propertyChangedFired = false;
|
||||
var elementValueBeforeEvent = null;
|
||||
|
||||
if (requestedEventsToCatch) {
|
||||
|
@ -19,33 +18,20 @@ ko.bindingHandlers['value'] = {
|
|||
if (typeof requestedEventsToCatch == "string") {
|
||||
eventsToCatch = [requestedEventsToCatch];
|
||||
} else {
|
||||
eventsToCatch = ko.utils.arrayGetDistinctValues(requestedEventsToCatch);
|
||||
eventsToCatch = requestedEventsToCatch ? requestedEventsToCatch.filter(function(item, index) {
|
||||
return requestedEventsToCatch.indexOf(item) === index;
|
||||
}) : [];
|
||||
}
|
||||
ko.utils.arrayRemoveItem(eventsToCatch, "change"); // We'll subscribe to "change" events later
|
||||
}
|
||||
|
||||
var valueUpdateHandler = function() {
|
||||
elementValueBeforeEvent = null;
|
||||
propertyChangedFired = false;
|
||||
var modelValue = valueAccessor();
|
||||
var elementValue = ko.selectExtensions.readValue(element);
|
||||
ko.expressionRewriting.writeValueToProperty(modelValue, allBindings, 'value', elementValue);
|
||||
}
|
||||
|
||||
// Workaround for https://github.com/SteveSanderson/knockout/issues/122
|
||||
// IE doesn't fire "change" events on textboxes if the user selects a value from its autocomplete list
|
||||
var ieAutoCompleteHackNeeded = ko.utils.ieVersion && isInputElement && element.type == "text"
|
||||
&& element.autocomplete != "off" && (!element.form || element.form.autocomplete != "off");
|
||||
if (ieAutoCompleteHackNeeded && ko.utils.arrayIndexOf(eventsToCatch, "propertychange") == -1) {
|
||||
ko.utils.registerEventHandler(element, "propertychange", function () { propertyChangedFired = true });
|
||||
ko.utils.registerEventHandler(element, "focus", function () { propertyChangedFired = false });
|
||||
ko.utils.registerEventHandler(element, "blur", function() {
|
||||
if (propertyChangedFired) {
|
||||
valueUpdateHandler();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ko.utils.arrayForEach(eventsToCatch, function(eventName) {
|
||||
// The syntax "after<eventname>" means "run the handler asynchronously after the event"
|
||||
// This is useful, for example, to catch "keydown" events after the browser has updated the control
|
||||
|
|
0
vendors/knockout/src/binding/defaultBindings/visibleHidden.js
vendored
Executable file → Normal file
0
vendors/knockout/src/binding/defaultBindings/visibleHidden.js
vendored
Executable file → Normal file
|
@ -88,7 +88,7 @@
|
|||
} else {
|
||||
if (!editScript || (lastMappingResult && lastMappingResult['_countWaitingForRemove'])) {
|
||||
// Compare the provided array against the previous one
|
||||
var lastArray = ko.utils.arrayMap(lastMappingResult, function (x) { return x.arrayEntry; }),
|
||||
var lastArray = Array.prototype.map.call(lastMappingResult, function (x) { return x.arrayEntry; }),
|
||||
compareOptions = {
|
||||
'dontLimitMoves': options['dontLimitMoves'],
|
||||
'sparse': true
|
||||
|
|
12
vendors/knockout/src/binding/selectExtensions.js
vendored
12
vendors/knockout/src/binding/selectExtensions.js
vendored
|
@ -10,9 +10,7 @@
|
|||
case 'option':
|
||||
if (element[hasDomDataExpandoProperty] === true)
|
||||
return ko.utils.domData.get(element, ko.bindingHandlers.options.optionValueDomDataKey);
|
||||
return ko.utils.ieVersion <= 7
|
||||
? (element.getAttributeNode('value') && element.getAttributeNode('value').specified ? element.value : element.text)
|
||||
: element.value;
|
||||
return element.value;
|
||||
case 'select':
|
||||
return element.selectedIndex >= 0 ? ko.selectExtensions.readValue(element.options[element.selectedIndex]) : undefined;
|
||||
default:
|
||||
|
@ -53,14 +51,6 @@
|
|||
}
|
||||
if (allowUnset || selection >= 0 || (value === undefined && element.size > 1)) {
|
||||
element.selectedIndex = selection;
|
||||
if (ko.utils.ieVersion === 6) {
|
||||
// Workaround for IE6 bug: It won't reliably apply values to SELECT nodes during the same execution thread
|
||||
// right after you've changed the set of OPTION nodes on it. So for that node type, we'll schedule a second thread
|
||||
// to apply the value as well.
|
||||
ko.utils.setTimeout(function () {
|
||||
element.selectedIndex = selection;
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
var tagNameLower = ko.utils.tagNameLower(node);
|
||||
if (ko.components.isRegistered(tagNameLower)) {
|
||||
// Try to determine that this node can be considered a *custom* element; see https://github.com/knockout/knockout/issues/1603
|
||||
if (tagNameLower.indexOf('-') != -1 || ('' + node) == "[object HTMLUnknownElement]" || (ko.utils.ieVersion <= 8 && node.tagName === tagNameLower)) {
|
||||
if (tagNameLower.indexOf('-') != -1 || ('' + node) == "[object HTMLUnknownElement]") {
|
||||
return tagNameLower;
|
||||
}
|
||||
}
|
||||
|
@ -84,32 +84,4 @@
|
|||
return { '$raw': {} };
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// Compatibility code for older (pre-HTML5) IE browsers
|
||||
|
||||
if (ko.utils.ieVersion < 9) {
|
||||
// Whenever you preregister a component, enable it as a custom element in the current document
|
||||
ko.components['register'] = (function(originalFunction) {
|
||||
return function(componentName) {
|
||||
document.createElement(componentName); // Allows IE<9 to parse markup containing the custom element
|
||||
return originalFunction.apply(this, arguments);
|
||||
}
|
||||
})(ko.components['register']);
|
||||
|
||||
// Whenever you create a document fragment, enable all preregistered component names as custom elements
|
||||
// This is needed to make innerShiv/jQuery HTML parsing correctly handle the custom elements
|
||||
document.createDocumentFragment = (function(originalFunction) {
|
||||
return function() {
|
||||
var newDocFrag = originalFunction(),
|
||||
allComponents = ko.components._allRegisteredComponents;
|
||||
for (var componentName in allComponents) {
|
||||
if (Object.prototype.hasOwnProperty.call(allComponents, componentName)) {
|
||||
newDocFrag.createElement(componentName);
|
||||
}
|
||||
}
|
||||
return newDocFrag;
|
||||
};
|
||||
})(document.createDocumentFragment);
|
||||
}
|
||||
})();
|
||||
})();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var computedState = ko.utils.createSymbolOrString('_state');
|
||||
var computedState = Symbol('_state');
|
||||
|
||||
ko.computed = ko.dependentObservable = function (evaluatorFunctionOrOptions, evaluatorFunctionTarget, options) {
|
||||
if (typeof evaluatorFunctionOrOptions === "object") {
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
|
||||
(function() {
|
||||
var maxNestedObservableDepth = 10; // Escape the (unlikely) pathological case where an observable's current value is itself (or similar reference cycle)
|
||||
|
||||
ko.toJS = function(rootObject) {
|
||||
if (arguments.length == 0)
|
||||
throw new Error("When calling ko.toJS, pass the object you want to convert.");
|
||||
|
||||
// We just unwrap everything at every level in the object graph
|
||||
return mapJsObjectGraph(rootObject, function(valueToMap) {
|
||||
// Loop because an observable's value might in turn be another observable wrapper
|
||||
for (var i = 0; ko.isObservable(valueToMap) && (i < maxNestedObservableDepth); i++)
|
||||
valueToMap = valueToMap();
|
||||
return valueToMap;
|
||||
});
|
||||
};
|
||||
|
||||
ko.toJSON = function(rootObject, replacer, space) { // replacer and space are optional
|
||||
var plainJavaScriptObject = ko.toJS(rootObject);
|
||||
return ko.utils.stringifyJson(plainJavaScriptObject, replacer, space);
|
||||
};
|
||||
|
||||
function mapJsObjectGraph(rootObject, mapInputCallback, visitedObjects) {
|
||||
visitedObjects = visitedObjects || new objectLookup();
|
||||
|
||||
rootObject = mapInputCallback(rootObject);
|
||||
var canHaveProperties = (typeof rootObject == "object") && (rootObject !== null) && (rootObject !== undefined) && (!(rootObject instanceof RegExp)) && (!(rootObject instanceof Date)) && (!(rootObject instanceof String)) && (!(rootObject instanceof Number)) && (!(rootObject instanceof Boolean));
|
||||
if (!canHaveProperties)
|
||||
return rootObject;
|
||||
|
||||
var outputProperties = rootObject instanceof Array ? [] : {};
|
||||
visitedObjects.save(rootObject, outputProperties);
|
||||
|
||||
visitPropertiesOrArrayEntries(rootObject, function(indexer) {
|
||||
var propertyValue = mapInputCallback(rootObject[indexer]);
|
||||
|
||||
switch (typeof propertyValue) {
|
||||
case "boolean":
|
||||
case "number":
|
||||
case "string":
|
||||
case "function":
|
||||
outputProperties[indexer] = propertyValue;
|
||||
break;
|
||||
case "object":
|
||||
case "undefined":
|
||||
var previouslyMappedValue = visitedObjects.get(propertyValue);
|
||||
outputProperties[indexer] = (previouslyMappedValue !== undefined)
|
||||
? previouslyMappedValue
|
||||
: mapJsObjectGraph(propertyValue, mapInputCallback, visitedObjects);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
return outputProperties;
|
||||
}
|
||||
|
||||
function visitPropertiesOrArrayEntries(rootObject, visitorCallback) {
|
||||
if (rootObject instanceof Array) {
|
||||
for (var i = 0; i < rootObject.length; i++)
|
||||
visitorCallback(i);
|
||||
|
||||
// For arrays, also respect toJSON property for custom mappings (fixes #278)
|
||||
if (typeof rootObject['toJSON'] == 'function')
|
||||
visitorCallback('toJSON');
|
||||
} else {
|
||||
for (var propertyName in rootObject) {
|
||||
visitorCallback(propertyName);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function objectLookup() {
|
||||
this.keys = [];
|
||||
this.values = [];
|
||||
};
|
||||
|
||||
objectLookup.prototype = {
|
||||
constructor: objectLookup,
|
||||
save: function(key, value) {
|
||||
var existingIndex = ko.utils.arrayIndexOf(this.keys, key);
|
||||
if (existingIndex >= 0)
|
||||
this.values[existingIndex] = value;
|
||||
else {
|
||||
this.keys.push(key);
|
||||
this.values.push(value);
|
||||
}
|
||||
},
|
||||
get: function(key) {
|
||||
var existingIndex = ko.utils.arrayIndexOf(this.keys, key);
|
||||
return (existingIndex >= 0) ? this.values[existingIndex] : undefined;
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
ko.exportSymbol('toJS', ko.toJS);
|
||||
ko.exportSymbol('toJSON', ko.toJSON);
|
|
@ -1,4 +1,4 @@
|
|||
var observableLatestValue = ko.utils.createSymbolOrString('_latestValue');
|
||||
var observableLatestValue = Symbol('_latestValue');
|
||||
|
||||
ko.observable = function (initialValue) {
|
||||
function observable() {
|
||||
|
|
|
@ -12,11 +12,10 @@ ko.when = function(predicate, callback, context) {
|
|||
|
||||
return subscription;
|
||||
}
|
||||
if (typeof Promise === "function" && !callback) {
|
||||
return new Promise(kowhen);
|
||||
} else {
|
||||
if (callback) {
|
||||
return kowhen(callback.bind(context));
|
||||
}
|
||||
return new Promise(kowhen);
|
||||
};
|
||||
|
||||
ko.exportSymbol('when', ko.when);
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
(function() {
|
||||
ko.jqueryTmplTemplateEngine = function () {
|
||||
// Detect which version of jquery-tmpl you're using. Unfortunately jquery-tmpl
|
||||
// doesn't expose a version number, so we have to infer it.
|
||||
// Note that as of Knockout 1.3, we only support jQuery.tmpl 1.0.0pre and later,
|
||||
// which KO internally refers to as version "2", so older versions are no longer detected.
|
||||
var jQueryTmplVersion = this.jQueryTmplVersion = (function() {
|
||||
if (!jQueryInstance || !(jQueryInstance['tmpl']))
|
||||
return 0;
|
||||
// Since it exposes no official version number, we use our own numbering system. To be updated as jquery-tmpl evolves.
|
||||
try {
|
||||
if (jQueryInstance['tmpl']['tag']['tmpl']['open'].toString().indexOf('__') >= 0) {
|
||||
// Since 1.0.0pre, custom tags should append markup to an array called "__"
|
||||
return 2; // Final version of jquery.tmpl
|
||||
}
|
||||
} catch(ex) { /* Apparently not the version we were looking for */ }
|
||||
|
||||
return 1; // Any older version that we don't support
|
||||
})();
|
||||
|
||||
function ensureHasReferencedJQueryTemplates() {
|
||||
if (jQueryTmplVersion < 2)
|
||||
throw new Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later.");
|
||||
}
|
||||
|
||||
function executeTemplate(compiledTemplate, data, jQueryTemplateOptions) {
|
||||
return jQueryInstance['tmpl'](compiledTemplate, data, jQueryTemplateOptions);
|
||||
}
|
||||
|
||||
this['renderTemplateSource'] = function(templateSource, bindingContext, options, templateDocument) {
|
||||
templateDocument = templateDocument || document;
|
||||
options = options || {};
|
||||
ensureHasReferencedJQueryTemplates();
|
||||
|
||||
// Ensure we have stored a precompiled version of this template (don't want to reparse on every render)
|
||||
var precompiled = templateSource['data']('precompiled');
|
||||
if (!precompiled) {
|
||||
var templateText = templateSource['text']() || "";
|
||||
// Wrap in "with($whatever.koBindingContext) { ... }"
|
||||
templateText = "{{ko_with $item.koBindingContext}}" + templateText + "{{/ko_with}}";
|
||||
|
||||
precompiled = jQueryInstance['template'](null, templateText);
|
||||
templateSource['data']('precompiled', precompiled);
|
||||
}
|
||||
|
||||
var data = [bindingContext['$data']]; // Prewrap the data in an array to stop jquery.tmpl from trying to unwrap any arrays
|
||||
var jQueryTemplateOptions = jQueryInstance['extend']({ 'koBindingContext': bindingContext }, options['templateOptions']);
|
||||
|
||||
var resultNodes = executeTemplate(precompiled, data, jQueryTemplateOptions);
|
||||
resultNodes['appendTo'](templateDocument.createElement("div")); // Using "appendTo" forces jQuery/jQuery.tmpl to perform necessary cleanup work
|
||||
|
||||
jQueryInstance['fragments'] = {}; // Clear jQuery's fragment cache to avoid a memory leak after a large number of template renders
|
||||
return resultNodes;
|
||||
};
|
||||
|
||||
this['createJavaScriptEvaluatorBlock'] = function(script) {
|
||||
return "{{ko_code ((function() { return " + script + " })()) }}";
|
||||
};
|
||||
|
||||
this['addTemplate'] = function(templateName, templateMarkup) {
|
||||
document.write("<script type='text/html' id='" + templateName + "'>" + templateMarkup + "<" + "/script>");
|
||||
};
|
||||
|
||||
if (jQueryTmplVersion > 0) {
|
||||
jQueryInstance['tmpl']['tag']['ko_code'] = {
|
||||
open: "__.push($1 || '');"
|
||||
};
|
||||
jQueryInstance['tmpl']['tag']['ko_with'] = {
|
||||
open: "with($1) {",
|
||||
close: "} "
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
ko.jqueryTmplTemplateEngine.prototype = new ko.templateEngine();
|
||||
ko.jqueryTmplTemplateEngine.prototype.constructor = ko.jqueryTmplTemplateEngine;
|
||||
|
||||
// Use this one by default *only if jquery.tmpl is referenced*
|
||||
var jqueryTmplTemplateEngineInstance = new ko.jqueryTmplTemplateEngine();
|
||||
if (jqueryTmplTemplateEngineInstance.jQueryTmplVersion > 0)
|
||||
ko.setTemplateEngine(jqueryTmplTemplateEngineInstance);
|
||||
|
||||
ko.exportSymbol('jqueryTmplTemplateEngine', ko.jqueryTmplTemplateEngine);
|
||||
})();
|
|
@ -5,16 +5,13 @@ ko.nativeTemplateEngine = function () {
|
|||
ko.nativeTemplateEngine.prototype = new ko.templateEngine();
|
||||
ko.nativeTemplateEngine.prototype.constructor = ko.nativeTemplateEngine;
|
||||
ko.nativeTemplateEngine.prototype['renderTemplateSource'] = function (templateSource, bindingContext, options, templateDocument) {
|
||||
var useNodesIfAvailable = !(ko.utils.ieVersion < 9), // IE<9 cloneNode doesn't work properly
|
||||
templateNodesFunc = useNodesIfAvailable ? templateSource['nodes'] : null,
|
||||
templateNodes = templateNodesFunc ? templateSource['nodes']() : null;
|
||||
|
||||
var templateNodesFunc = templateSource.nodes,
|
||||
templateNodes = templateNodesFunc ? templateSource.nodes() : null;
|
||||
if (templateNodes) {
|
||||
return ko.utils.makeArray(templateNodes.cloneNode(true).childNodes);
|
||||
} else {
|
||||
var templateText = templateSource['text']();
|
||||
return ko.utils.parseHtmlFragment(templateText, templateDocument);
|
||||
}
|
||||
var templateText = templateSource['text']();
|
||||
return ko.utils.parseHtmlFragment(templateText, templateDocument);
|
||||
};
|
||||
|
||||
ko.nativeTemplateEngine.instance = new ko.nativeTemplateEngine();
|
||||
|
|
62
vendors/knockout/src/utils.domData.js
vendored
62
vendors/knockout/src/utils.domData.js
vendored
|
@ -1,52 +1,26 @@
|
|||
|
||||
ko.utils.domData = new (function () {
|
||||
var uniqueId = 0;
|
||||
var dataStoreKeyExpandoPropertyName = "__ko__" + (new Date).getTime();
|
||||
var dataStore = {};
|
||||
var dataStoreKeyExpandoPropertyName = "__ko__" + (Date.now());
|
||||
|
||||
var getDataForNode, clear;
|
||||
if (!ko.utils.ieVersion) {
|
||||
// We considered using WeakMap, but it has a problem in IE 11 and Edge that prevents using
|
||||
// it cross-window, so instead we just store the data directly on the node.
|
||||
// See https://github.com/knockout/knockout/issues/2141
|
||||
getDataForNode = function (node, createIfNotFound) {
|
||||
var dataForNode = node[dataStoreKeyExpandoPropertyName];
|
||||
if (!dataForNode && createIfNotFound) {
|
||||
dataForNode = node[dataStoreKeyExpandoPropertyName] = {};
|
||||
}
|
||||
return dataForNode;
|
||||
};
|
||||
clear = function (node) {
|
||||
if (node[dataStoreKeyExpandoPropertyName]) {
|
||||
delete node[dataStoreKeyExpandoPropertyName];
|
||||
return true; // Exposing "did clean" flag purely so specs can infer whether things have been cleaned up as intended
|
||||
}
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
// Old IE versions have memory issues if you store objects on the node, so we use a
|
||||
// separate data storage and link to it from the node using a string key.
|
||||
getDataForNode = function (node, createIfNotFound) {
|
||||
var dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
||||
var hasExistingDataStore = dataStoreKey && (dataStoreKey !== "null") && dataStore[dataStoreKey];
|
||||
if (!hasExistingDataStore) {
|
||||
if (!createIfNotFound)
|
||||
return undefined;
|
||||
dataStoreKey = node[dataStoreKeyExpandoPropertyName] = "ko" + uniqueId++;
|
||||
dataStore[dataStoreKey] = {};
|
||||
}
|
||||
return dataStore[dataStoreKey];
|
||||
};
|
||||
clear = function (node) {
|
||||
var dataStoreKey = node[dataStoreKeyExpandoPropertyName];
|
||||
if (dataStoreKey) {
|
||||
delete dataStore[dataStoreKey];
|
||||
node[dataStoreKeyExpandoPropertyName] = null;
|
||||
return true; // Exposing "did clean" flag purely so specs can infer whether things have been cleaned up as intended
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
// We considered using WeakMap, but it has a problem in IE 11 and Edge that prevents using
|
||||
// it cross-window, so instead we just store the data directly on the node.
|
||||
// See https://github.com/knockout/knockout/issues/2141
|
||||
getDataForNode = function (node, createIfNotFound) {
|
||||
var dataForNode = node[dataStoreKeyExpandoPropertyName];
|
||||
if (!dataForNode && createIfNotFound) {
|
||||
dataForNode = node[dataStoreKeyExpandoPropertyName] = {};
|
||||
}
|
||||
return dataForNode;
|
||||
};
|
||||
clear = function (node) {
|
||||
if (node[dataStoreKeyExpandoPropertyName]) {
|
||||
delete node[dataStoreKeyExpandoPropertyName];
|
||||
return true; // Exposing "did clean" flag purely so specs can infer whether things have been cleaned up as intended
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
return {
|
||||
get: function (node, key) {
|
||||
|
|
56
vendors/knockout/src/utils.domManipulation.js
vendored
56
vendors/knockout/src/utils.domManipulation.js
vendored
|
@ -13,10 +13,7 @@
|
|||
'th': tr,
|
||||
'option': select,
|
||||
'optgroup': select
|
||||
},
|
||||
|
||||
// This is needed for old IE if you're *not* using either jQuery or innerShiv. Doesn't affect other cases.
|
||||
mayRequireCreateElementHack = ko.utils.ieVersion <= 8;
|
||||
};
|
||||
|
||||
function getWrap(tags) {
|
||||
var m = tags.match(/^(?:<!--.*?-->\s*?)*?<([a-z]+)[\s>]/);
|
||||
|
@ -49,17 +46,7 @@
|
|||
// somehow shims the native APIs so it just works anyway)
|
||||
div.appendChild(windowContext['innerShiv'](markup));
|
||||
} else {
|
||||
if (mayRequireCreateElementHack) {
|
||||
// The document.createElement('my-element') trick to enable custom elements in IE6-8
|
||||
// only works if we assign innerHTML on an element associated with that document.
|
||||
documentContext.body.appendChild(div);
|
||||
}
|
||||
|
||||
div.innerHTML = markup;
|
||||
|
||||
if (mayRequireCreateElementHack) {
|
||||
div.parentNode.removeChild(div);
|
||||
}
|
||||
}
|
||||
|
||||
// Move to the right depth
|
||||
|
@ -69,35 +56,8 @@
|
|||
return ko.utils.makeArray(div.lastChild.childNodes);
|
||||
}
|
||||
|
||||
function jQueryHtmlParse(html, documentContext) {
|
||||
// jQuery's "parseHTML" function was introduced in jQuery 1.8.0 and is a documented public API.
|
||||
if (jQueryInstance['parseHTML']) {
|
||||
return jQueryInstance['parseHTML'](html, documentContext) || []; // Ensure we always return an array and never null
|
||||
} else {
|
||||
// For jQuery < 1.8.0, we fall back on the undocumented internal "clean" function.
|
||||
var elems = jQueryInstance['clean']([html], documentContext);
|
||||
|
||||
// As of jQuery 1.7.1, jQuery parses the HTML by appending it to some dummy parent nodes held in an in-memory document fragment.
|
||||
// Unfortunately, it never clears the dummy parent nodes from the document fragment, so it leaks memory over time.
|
||||
// Fix this by finding the top-most dummy parent element, and detaching it from its owner fragment.
|
||||
if (elems && elems[0]) {
|
||||
// Find the top-most parent element that's a direct child of a document fragment
|
||||
var elem = elems[0];
|
||||
while (elem.parentNode && elem.parentNode.nodeType !== 11 /* i.e., DocumentFragment */)
|
||||
elem = elem.parentNode;
|
||||
// ... then detach it
|
||||
if (elem.parentNode)
|
||||
elem.parentNode.removeChild(elem);
|
||||
}
|
||||
|
||||
return elems;
|
||||
}
|
||||
}
|
||||
|
||||
ko.utils.parseHtmlFragment = function(html, documentContext) {
|
||||
return jQueryInstance ?
|
||||
jQueryHtmlParse(html, documentContext) : // As below, benefit from jQuery's optimisations where possible
|
||||
simpleHtmlParse(html, documentContext); // ... otherwise, this simple logic will do in most common cases.
|
||||
return simpleHtmlParse(html, documentContext); // ... otherwise, this simple logic will do in most common cases.
|
||||
};
|
||||
|
||||
ko.utils.parseHtmlForTemplateNodes = function(html, documentContext) {
|
||||
|
@ -118,14 +78,10 @@
|
|||
// jQuery contains a lot of sophisticated code to parse arbitrary HTML fragments,
|
||||
// for example <tr> elements which are not normally allowed to exist on their own.
|
||||
// If you've referenced jQuery we'll use that rather than duplicating its code.
|
||||
if (jQueryInstance) {
|
||||
jQueryInstance(node)['html'](html);
|
||||
} else {
|
||||
// ... otherwise, use KO's own parsing logic.
|
||||
var parsedNodes = ko.utils.parseHtmlFragment(html, node.ownerDocument);
|
||||
for (var i = 0; i < parsedNodes.length; i++)
|
||||
node.appendChild(parsedNodes[i]);
|
||||
}
|
||||
// ... otherwise, use KO's own parsing logic.
|
||||
var parsedNodes = ko.utils.parseHtmlFragment(html, node.ownerDocument);
|
||||
for (var i = 0; i < parsedNodes.length; i++)
|
||||
node.appendChild(parsedNodes[i]);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -88,12 +88,12 @@ ko.utils.domNodeDisposal = new (function () {
|
|||
node.parentNode.removeChild(node);
|
||||
},
|
||||
|
||||
"cleanExternalData" : function (node) {
|
||||
'cleanExternalData' : function (node) {
|
||||
// Special support for jQuery here because it's so commonly used.
|
||||
// Many jQuery plugins (including jquery.tmpl) store data using jQuery's equivalent of domData
|
||||
// so notify it to tear down any resources associated with the node & descendants here.
|
||||
if (jQueryInstance && (typeof jQueryInstance['cleanData'] == "function"))
|
||||
jQueryInstance['cleanData']([node]);
|
||||
if (jQuery && jQuery['cleanData'])
|
||||
jQuery['cleanData']([node]);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
|
397
vendors/knockout/src/utils.js
vendored
397
vendors/knockout/src/utils.js
vendored
|
@ -1,21 +1,15 @@
|
|||
ko.utils = (function () {
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
function objectForEach(obj, action) {
|
||||
for (var prop in obj) {
|
||||
if (hasOwnProperty.call(obj, prop)) {
|
||||
action(prop, obj[prop]);
|
||||
}
|
||||
}
|
||||
obj && Object.entries(obj).forEach(function(prop) {
|
||||
action(prop[0], prop[1]);
|
||||
});
|
||||
}
|
||||
|
||||
function extend(target, source) {
|
||||
if (source) {
|
||||
for(var prop in source) {
|
||||
if(hasOwnProperty.call(source, prop)) {
|
||||
target[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
Object.entries(source).forEach(function(prop) {
|
||||
target[prop[0]] = prop[1];
|
||||
});
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
@ -26,98 +20,32 @@ ko.utils = (function () {
|
|||
}
|
||||
|
||||
var canSetPrototype = ({ __proto__: [] } instanceof Array);
|
||||
var canUseSymbols = !DEBUG && typeof Symbol === 'function';
|
||||
|
||||
// Represent the known event types in a compact way, then at runtime transform it into a hash with event name as key (for fast lookup)
|
||||
var knownEvents = {}, knownEventTypesByEventName = {};
|
||||
var keyEventTypeName = (navigator && /Firefox\/2/i.test(navigator.userAgent)) ? 'KeyboardEvent' : 'UIEvents';
|
||||
knownEvents[keyEventTypeName] = ['keyup', 'keydown', 'keypress'];
|
||||
knownEvents['MouseEvents'] = ['click', 'dblclick', 'mousedown', 'mouseup', 'mousemove', 'mouseover', 'mouseout', 'mouseenter', 'mouseleave'];
|
||||
objectForEach(knownEvents, function(eventType, knownEventsForType) {
|
||||
if (knownEventsForType.length) {
|
||||
for (var i = 0, j = knownEventsForType.length; i < j; i++)
|
||||
knownEventTypesByEventName[knownEventsForType[i]] = eventType;
|
||||
}
|
||||
});
|
||||
var eventsThatMustBeRegisteredUsingAttachEvent = { 'propertychange': true }; // Workaround for an IE9 issue - https://github.com/SteveSanderson/knockout/issues/406
|
||||
|
||||
// Detect IE versions for bug workarounds (uses IE conditionals, not UA string, for robustness)
|
||||
// Note that, since IE 10 does not support conditional comments, the following logic only detects IE < 10.
|
||||
// Currently this is by design, since IE 10+ behaves correctly when treated as a standard browser.
|
||||
// If there is a future need to detect specific versions of IE10+, we will amend this.
|
||||
var ieVersion = document && (function() {
|
||||
var version = 3, div = document.createElement('div'), iElems = div.getElementsByTagName('i');
|
||||
|
||||
// Keep constructing conditional HTML blocks until we hit one that resolves to an empty fragment
|
||||
while (
|
||||
div.innerHTML = '<!--[if gt IE ' + (++version) + ']><i></i><![endif]-->',
|
||||
iElems[0]
|
||||
) {}
|
||||
return version > 4 ? version : undefined;
|
||||
}());
|
||||
var isIe6 = ieVersion === 6,
|
||||
isIe7 = ieVersion === 7;
|
||||
var ke = 'KeyboardEvent', me = 'MouseEvent',
|
||||
knownEventTypesByEventName = {
|
||||
keyup: ke, keydown: ke, keypress: ke,
|
||||
click: me, dblclick: me, mousedown: me, mouseup: me, mousemove: me,
|
||||
mouseover: me, mouseout: me, mouseenter: me, mouseleave: me
|
||||
};
|
||||
|
||||
function isClickOnCheckableElement(element, eventType) {
|
||||
if ((ko.utils.tagNameLower(element) !== "input") || !element.type) return false;
|
||||
if ((element.nodeName !== "INPUT") || !element.type) return false;
|
||||
if (eventType.toLowerCase() != "click") return false;
|
||||
var inputType = element.type;
|
||||
return (inputType == "checkbox") || (inputType == "radio");
|
||||
}
|
||||
|
||||
// For details on the pattern for changing node classes
|
||||
// see: https://github.com/knockout/knockout/issues/1597
|
||||
var cssClassNameRegex = /\S+/g;
|
||||
|
||||
var jQueryEventAttachName;
|
||||
|
||||
function toggleDomNodeCssClass(node, classNames, shouldHaveClass) {
|
||||
var addOrRemoveFn;
|
||||
if (classNames) {
|
||||
if (typeof node.classList === 'object') {
|
||||
addOrRemoveFn = node.classList[shouldHaveClass ? 'add' : 'remove'];
|
||||
ko.utils.arrayForEach(classNames.match(cssClassNameRegex), function(className) {
|
||||
addOrRemoveFn.call(node.classList, className);
|
||||
});
|
||||
} else if (typeof node.className['baseVal'] === 'string') {
|
||||
// SVG tag .classNames is an SVGAnimatedString instance
|
||||
toggleObjectClassPropertyString(node.className, 'baseVal', classNames, shouldHaveClass);
|
||||
} else {
|
||||
// node.className ought to be a string.
|
||||
toggleObjectClassPropertyString(node, 'className', classNames, shouldHaveClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleObjectClassPropertyString(obj, prop, classNames, shouldHaveClass) {
|
||||
// obj/prop is either a node/'className' or a SVGAnimatedString/'baseVal'.
|
||||
var currentClassNames = obj[prop].match(cssClassNameRegex) || [];
|
||||
ko.utils.arrayForEach(classNames.match(cssClassNameRegex), function(className) {
|
||||
ko.utils.addOrRemoveItem(currentClassNames, className, shouldHaveClass);
|
||||
});
|
||||
obj[prop] = currentClassNames.join(" ");
|
||||
}
|
||||
|
||||
return {
|
||||
fieldsIncludedWithJsonPost: ['authenticity_token', /^__RequestVerificationToken(_.*)?$/],
|
||||
|
||||
arrayForEach: function (array, action, actionOwner) {
|
||||
for (var i = 0, j = array.length; i < j; i++) {
|
||||
action.call(actionOwner, array[i], i, array);
|
||||
}
|
||||
},
|
||||
|
||||
arrayIndexOf: typeof Array.prototype.indexOf == "function"
|
||||
? function (array, item) {
|
||||
return Array.prototype.indexOf.call(array, item);
|
||||
}
|
||||
: function (array, item) {
|
||||
for (var i = 0, j = array.length; i < j; i++) {
|
||||
if (array[i] === item)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
},
|
||||
arrayIndexOf: function (array, item) {
|
||||
return Array.prototype.indexOf.call(array, item);
|
||||
},
|
||||
|
||||
arrayFirst: function (array, predicate, predicateOwner) {
|
||||
for (var i = 0, j = array.length; i < j; i++) {
|
||||
|
@ -137,34 +65,8 @@ ko.utils = (function () {
|
|||
}
|
||||
},
|
||||
|
||||
arrayGetDistinctValues: function (array) {
|
||||
var result = [];
|
||||
if (array) {
|
||||
ko.utils.arrayForEach(array, function(item) {
|
||||
if (ko.utils.arrayIndexOf(result, item) < 0)
|
||||
result.push(item);
|
||||
});
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
arrayMap: function (array, mapping, mappingOwner) {
|
||||
var result = [];
|
||||
if (array) {
|
||||
for (var i = 0, j = array.length; i < j; i++)
|
||||
result.push(mapping.call(mappingOwner, array[i], i));
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
arrayFilter: function (array, predicate, predicateOwner) {
|
||||
var result = [];
|
||||
if (array) {
|
||||
for (var i = 0, j = array.length; i < j; i++)
|
||||
if (predicate.call(predicateOwner, array[i], i))
|
||||
result.push(array[i]);
|
||||
}
|
||||
return result;
|
||||
return array ? Array.prototype.filter.call(array, predicate, predicateOwner) : [];
|
||||
},
|
||||
|
||||
arrayPushAll: function (array, valuesToPush) {
|
||||
|
@ -176,17 +78,6 @@ ko.utils = (function () {
|
|||
return array;
|
||||
},
|
||||
|
||||
addOrRemoveItem: function(array, value, included) {
|
||||
var existingEntryIndex = ko.utils.arrayIndexOf(ko.utils.peekObservable(array), value);
|
||||
if (existingEntryIndex < 0) {
|
||||
if (included)
|
||||
array.push(value);
|
||||
} else {
|
||||
if (!included)
|
||||
array.splice(existingEntryIndex, 1);
|
||||
}
|
||||
},
|
||||
|
||||
canSetPrototype: canSetPrototype,
|
||||
|
||||
extend: extend,
|
||||
|
@ -201,11 +92,9 @@ ko.utils = (function () {
|
|||
if (!source)
|
||||
return source;
|
||||
var target = {};
|
||||
for (var prop in source) {
|
||||
if (hasOwnProperty.call(source, prop)) {
|
||||
target[prop] = mapping.call(mappingOwner, source[prop], prop, source);
|
||||
}
|
||||
}
|
||||
Object.entries(source).forEach(function(prop) {
|
||||
target[prop[0]] = mapping.call(mappingOwner, prop[1], prop[0], source);
|
||||
});
|
||||
return target;
|
||||
},
|
||||
|
||||
|
@ -245,13 +134,15 @@ ko.utils = (function () {
|
|||
},
|
||||
|
||||
replaceDomNodes: function (nodeToReplaceOrNodeArray, newNodesArray) {
|
||||
var nodesToReplaceArray = nodeToReplaceOrNodeArray.nodeType ? [nodeToReplaceOrNodeArray] : nodeToReplaceOrNodeArray;
|
||||
var nodesToReplaceArray = nodeToReplaceOrNodeArray.nodeType
|
||||
? [nodeToReplaceOrNodeArray] : nodeToReplaceOrNodeArray;
|
||||
if (nodesToReplaceArray.length > 0) {
|
||||
var insertionPoint = nodesToReplaceArray[0];
|
||||
var parent = insertionPoint.parentNode;
|
||||
for (var i = 0, j = newNodesArray.length; i < j; i++)
|
||||
var insertionPoint = nodesToReplaceArray[0],
|
||||
parent = insertionPoint.parentNode,
|
||||
i, j;
|
||||
for (i = 0, j = newNodesArray.length; i < j; i++)
|
||||
parent.insertBefore(newNodesArray[i], insertionPoint);
|
||||
for (var i = 0, j = nodesToReplaceArray.length; i < j; i++) {
|
||||
for (i = 0, j = nodesToReplaceArray.length; i < j; i++) {
|
||||
ko.removeNode(nodesToReplaceArray[i]);
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +174,8 @@ ko.utils = (function () {
|
|||
continuousNodeArray.splice(0, 1);
|
||||
|
||||
// Rule [B]
|
||||
while (continuousNodeArray.length > 1 && continuousNodeArray[continuousNodeArray.length - 1].parentNode !== parentNode)
|
||||
while (continuousNodeArray.length > 1
|
||||
&& continuousNodeArray[continuousNodeArray.length - 1].parentNode !== parentNode)
|
||||
continuousNodeArray.length--;
|
||||
|
||||
// Rule [C]
|
||||
|
@ -301,14 +193,6 @@ ko.utils = (function () {
|
|||
return continuousNodeArray;
|
||||
},
|
||||
|
||||
setOptionNodeSelectionState: function (optionNode, isSelected) {
|
||||
// IE6 sometimes throws "unknown error" if you try to write to .selected directly, whereas Firefox struggles with setAttribute. Pick one based on browser.
|
||||
if (ieVersion < 7)
|
||||
optionNode.setAttribute("selected", isSelected);
|
||||
else
|
||||
optionNode.selected = isSelected;
|
||||
},
|
||||
|
||||
stringTrim: function (string) {
|
||||
return string === null || string === undefined ? '' :
|
||||
string.trim ?
|
||||
|
@ -324,18 +208,7 @@ ko.utils = (function () {
|
|||
},
|
||||
|
||||
domNodeIsContainedBy: function (node, containedByNode) {
|
||||
if (node === containedByNode)
|
||||
return true;
|
||||
if (node.nodeType === 11)
|
||||
return false; // Fixes issue #1162 - can't use node.contains for document fragments on IE8
|
||||
if (containedByNode.contains)
|
||||
return containedByNode.contains(node.nodeType !== 1 ? node.parentNode : node);
|
||||
if (containedByNode.compareDocumentPosition)
|
||||
return (containedByNode.compareDocumentPosition(node) & 16) == 16;
|
||||
while (node && node != containedByNode) {
|
||||
node = node.parentNode;
|
||||
}
|
||||
return !!node;
|
||||
return containedByNode.contains(node.nodeType !== 1 ? node.parentNode : node);
|
||||
},
|
||||
|
||||
domNodeIsAttachedToDocument: function (node) {
|
||||
|
@ -378,26 +251,10 @@ ko.utils = (function () {
|
|||
registerEventHandler: function (element, eventType, handler) {
|
||||
var wrappedHandler = ko.utils.catchFunctionErrors(handler);
|
||||
|
||||
var mustUseAttachEvent = eventsThatMustBeRegisteredUsingAttachEvent[eventType];
|
||||
if (!ko.options['useOnlyNativeEvents'] && !mustUseAttachEvent && jQueryInstance) {
|
||||
if (!jQueryEventAttachName) {
|
||||
jQueryEventAttachName = (typeof jQueryInstance(element)['on'] == 'function') ? 'on' : 'bind';
|
||||
}
|
||||
jQueryInstance(element)[jQueryEventAttachName](eventType, wrappedHandler);
|
||||
} else if (!mustUseAttachEvent && typeof element.addEventListener == "function")
|
||||
element.addEventListener(eventType, wrappedHandler, false);
|
||||
else if (typeof element.attachEvent != "undefined") {
|
||||
var attachEventHandler = function (event) { wrappedHandler.call(element, event); },
|
||||
attachEventName = "on" + eventType;
|
||||
element.attachEvent(attachEventName, attachEventHandler);
|
||||
|
||||
// IE does not dispose attachEvent handlers automatically (unlike with addEventListener)
|
||||
// so to avoid leaks, we have to remove them manually. See bug #856
|
||||
ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
|
||||
element.detachEvent(attachEventName, attachEventHandler);
|
||||
});
|
||||
if (!ko.options['useOnlyNativeEvents'] && jQuery) {
|
||||
jQuery(element)['on'](eventType, wrappedHandler);
|
||||
} else
|
||||
throw new Error("Browser doesn't support addEventListener or attachEvent");
|
||||
element.addEventListener(eventType, wrappedHandler, false);
|
||||
},
|
||||
|
||||
triggerEvent: function (element, eventType) {
|
||||
|
@ -410,23 +267,13 @@ ko.utils = (function () {
|
|||
// In both cases, we'll use the click method instead.
|
||||
var useClickWorkaround = isClickOnCheckableElement(element, eventType);
|
||||
|
||||
if (!ko.options['useOnlyNativeEvents'] && jQueryInstance && !useClickWorkaround) {
|
||||
jQueryInstance(element)['trigger'](eventType);
|
||||
} else if (typeof document.createEvent == "function") {
|
||||
if (typeof element.dispatchEvent == "function") {
|
||||
var eventCategory = knownEventTypesByEventName[eventType] || "HTMLEvents";
|
||||
var event = document.createEvent(eventCategory);
|
||||
event.initEvent(eventType, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, element);
|
||||
element.dispatchEvent(event);
|
||||
}
|
||||
else
|
||||
throw new Error("The supplied element doesn't support dispatchEvent");
|
||||
} else if (useClickWorkaround && element.click) {
|
||||
element.click();
|
||||
} else if (typeof element.fireEvent != "undefined") {
|
||||
element.fireEvent("on" + eventType);
|
||||
if (!ko.options['useOnlyNativeEvents'] && jQuery && !useClickWorkaround) {
|
||||
jQuery(element)['trigger'](eventType);
|
||||
} else {
|
||||
throw new Error("Browser doesn't support triggering events");
|
||||
var eventCategory = knownEventTypesByEventName[eventType] || "HTMLEvents";
|
||||
var event = document.createEvent(eventCategory);
|
||||
event.initEvent(eventType, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, element);
|
||||
element.dispatchEvent(event);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -438,8 +285,6 @@ ko.utils = (function () {
|
|||
return ko.isObservable(value) ? value.peek() : value;
|
||||
},
|
||||
|
||||
toggleDomNodeCssClass: toggleDomNodeCssClass,
|
||||
|
||||
setTextContent: function(element, textContent) {
|
||||
var value = ko.utils.unwrapObservable(textContent);
|
||||
if ((value === null) || (value === undefined))
|
||||
|
@ -454,142 +299,10 @@ ko.utils = (function () {
|
|||
} else {
|
||||
innerTextNode.data = value;
|
||||
}
|
||||
|
||||
ko.utils.forceRefresh(element);
|
||||
},
|
||||
|
||||
setElementName: function(element, name) {
|
||||
element.name = name;
|
||||
|
||||
// Workaround IE 6/7 issue
|
||||
// - https://github.com/SteveSanderson/knockout/issues/197
|
||||
// - http://www.matts411.com/post/setting_the_name_attribute_in_ie_dom/
|
||||
if (ieVersion <= 7) {
|
||||
try {
|
||||
var escapedName = element.name.replace(/[&<>'"]/g, function(r){ return "&#" + r.charCodeAt(0) + ";"; });
|
||||
element.mergeAttributes(document.createElement("<input name='" + escapedName + "'/>"), false);
|
||||
}
|
||||
catch(e) {} // For IE9 with doc mode "IE9 Standards" and browser mode "IE9 Compatibility View"
|
||||
}
|
||||
},
|
||||
|
||||
forceRefresh: function(node) {
|
||||
// Workaround for an IE9 rendering bug - https://github.com/SteveSanderson/knockout/issues/209
|
||||
if (ieVersion >= 9) {
|
||||
// For text nodes and comment nodes (most likely virtual elements), we will have to refresh the container
|
||||
var elem = node.nodeType == 1 ? node : node.parentNode;
|
||||
if (elem.style)
|
||||
elem.style.zoom = elem.style.zoom;
|
||||
}
|
||||
},
|
||||
|
||||
ensureSelectElementIsRenderedCorrectly: function(selectElement) {
|
||||
// Workaround for IE9 rendering bug - it doesn't reliably display all the text in dynamically-added select boxes unless you force it to re-render by updating the width.
|
||||
// (See https://github.com/SteveSanderson/knockout/issues/312, http://stackoverflow.com/questions/5908494/select-only-shows-first-char-of-selected-option)
|
||||
// Also fixes IE7 and IE8 bug that causes selects to be zero width if enclosed by 'if' or 'with'. (See issue #839)
|
||||
if (ieVersion) {
|
||||
var originalWidth = selectElement.style.width;
|
||||
selectElement.style.width = 0;
|
||||
selectElement.style.width = originalWidth;
|
||||
}
|
||||
},
|
||||
|
||||
range: function (min, max) {
|
||||
min = ko.utils.unwrapObservable(min);
|
||||
max = ko.utils.unwrapObservable(max);
|
||||
var result = [];
|
||||
for (var i = min; i <= max; i++)
|
||||
result.push(i);
|
||||
return result;
|
||||
},
|
||||
|
||||
makeArray: function(arrayLikeObject) {
|
||||
var result = [];
|
||||
for (var i = 0, j = arrayLikeObject.length; i < j; i++) {
|
||||
result.push(arrayLikeObject[i]);
|
||||
};
|
||||
return result;
|
||||
},
|
||||
|
||||
createSymbolOrString: function(identifier) {
|
||||
return canUseSymbols ? Symbol(identifier) : identifier;
|
||||
},
|
||||
|
||||
isIe6 : isIe6,
|
||||
isIe7 : isIe7,
|
||||
ieVersion : ieVersion,
|
||||
|
||||
getFormFields: function(form, fieldName) {
|
||||
var fields = ko.utils.makeArray(form.getElementsByTagName("input")).concat(ko.utils.makeArray(form.getElementsByTagName("textarea")));
|
||||
var isMatchingField = (typeof fieldName == 'string')
|
||||
? function(field) { return field.name === fieldName }
|
||||
: function(field) { return fieldName.test(field.name) }; // Treat fieldName as regex or object containing predicate
|
||||
var matches = [];
|
||||
for (var i = fields.length - 1; i >= 0; i--) {
|
||||
if (isMatchingField(fields[i]))
|
||||
matches.push(fields[i]);
|
||||
};
|
||||
return matches;
|
||||
},
|
||||
|
||||
parseJson: function (jsonString) {
|
||||
if (typeof jsonString == "string") {
|
||||
jsonString = ko.utils.stringTrim(jsonString);
|
||||
if (jsonString) {
|
||||
if (JSON && JSON.parse) // Use native parsing where available
|
||||
return JSON.parse(jsonString);
|
||||
return (new Function("return " + jsonString))(); // Fallback on less safe parsing for older browsers
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
stringifyJson: function (data, replacer, space) { // replacer and space are optional
|
||||
if (!JSON || !JSON.stringify)
|
||||
throw new 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");
|
||||
return JSON.stringify(ko.utils.unwrapObservable(data), replacer, space);
|
||||
},
|
||||
|
||||
postJson: function (urlOrForm, data, options) {
|
||||
options = options || {};
|
||||
var params = options['params'] || {};
|
||||
var includeFields = options['includeFields'] || this.fieldsIncludedWithJsonPost;
|
||||
var url = urlOrForm;
|
||||
|
||||
// If we were given a form, use its 'action' URL and pick out any requested field values
|
||||
if((typeof urlOrForm == 'object') && (ko.utils.tagNameLower(urlOrForm) === "form")) {
|
||||
var originalForm = urlOrForm;
|
||||
url = originalForm.action;
|
||||
for (var i = includeFields.length - 1; i >= 0; i--) {
|
||||
var fields = ko.utils.getFormFields(originalForm, includeFields[i]);
|
||||
for (var j = fields.length - 1; j >= 0; j--)
|
||||
params[fields[j].name] = fields[j].value;
|
||||
}
|
||||
}
|
||||
|
||||
data = ko.utils.unwrapObservable(data);
|
||||
var form = document.createElement("form");
|
||||
form.style.display = "none";
|
||||
form.action = url;
|
||||
form.method = "post";
|
||||
for (var key in data) {
|
||||
// Since 'data' this is a model object, we include all properties including those inherited from its prototype
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = key;
|
||||
input.value = ko.utils.stringifyJson(ko.utils.unwrapObservable(data[key]));
|
||||
form.appendChild(input);
|
||||
}
|
||||
objectForEach(params, function(key, value) {
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = key;
|
||||
input.value = value;
|
||||
form.appendChild(input);
|
||||
});
|
||||
document.body.appendChild(form);
|
||||
options['submitter'] ? options['submitter'](form) : form.submit();
|
||||
setTimeout(function () { form.parentNode.removeChild(form); }, 0);
|
||||
return Array['from'](arrayLikeObject);
|
||||
}
|
||||
}
|
||||
}());
|
||||
|
@ -598,47 +311,17 @@ ko.exportSymbol('utils', ko.utils);
|
|||
ko.exportSymbol('utils.arrayForEach', ko.utils.arrayForEach);
|
||||
ko.exportSymbol('utils.arrayFirst', ko.utils.arrayFirst);
|
||||
ko.exportSymbol('utils.arrayFilter', ko.utils.arrayFilter);
|
||||
ko.exportSymbol('utils.arrayGetDistinctValues', ko.utils.arrayGetDistinctValues);
|
||||
ko.exportSymbol('utils.arrayIndexOf', ko.utils.arrayIndexOf);
|
||||
ko.exportSymbol('utils.arrayMap', ko.utils.arrayMap);
|
||||
ko.exportSymbol('utils.arrayPushAll', ko.utils.arrayPushAll);
|
||||
ko.exportSymbol('utils.arrayRemoveItem', ko.utils.arrayRemoveItem);
|
||||
ko.exportSymbol('utils.cloneNodes', ko.utils.cloneNodes);
|
||||
ko.exportSymbol('utils.createSymbolOrString', ko.utils.createSymbolOrString);
|
||||
ko.exportSymbol('utils.extend', ko.utils.extend);
|
||||
ko.exportSymbol('utils.fieldsIncludedWithJsonPost', ko.utils.fieldsIncludedWithJsonPost);
|
||||
ko.exportSymbol('utils.getFormFields', ko.utils.getFormFields);
|
||||
ko.exportSymbol('utils.objectMap', ko.utils.objectMap);
|
||||
ko.exportSymbol('utils.peekObservable', ko.utils.peekObservable);
|
||||
ko.exportSymbol('utils.postJson', ko.utils.postJson);
|
||||
ko.exportSymbol('utils.parseJson', ko.utils.parseJson);
|
||||
ko.exportSymbol('utils.registerEventHandler', ko.utils.registerEventHandler);
|
||||
ko.exportSymbol('utils.stringifyJson', ko.utils.stringifyJson);
|
||||
ko.exportSymbol('utils.range', ko.utils.range);
|
||||
ko.exportSymbol('utils.toggleDomNodeCssClass', ko.utils.toggleDomNodeCssClass);
|
||||
ko.exportSymbol('utils.triggerEvent', ko.utils.triggerEvent);
|
||||
ko.exportSymbol('utils.unwrapObservable', ko.utils.unwrapObservable);
|
||||
ko.exportSymbol('utils.objectForEach', ko.utils.objectForEach);
|
||||
ko.exportSymbol('utils.addOrRemoveItem', ko.utils.addOrRemoveItem);
|
||||
ko.exportSymbol('utils.setTextContent', ko.utils.setTextContent);
|
||||
ko.exportSymbol('unwrap', ko.utils.unwrapObservable); // Convenient shorthand, because this is used so commonly
|
||||
|
||||
if (!Function.prototype['bind']) {
|
||||
// Function.prototype.bind is a standard part of ECMAScript 5th Edition (December 2009, http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf)
|
||||
// In case the browser doesn't implement it natively, provide a JavaScript implementation. This implementation is based on the one in prototype.js
|
||||
Function.prototype['bind'] = function (object) {
|
||||
var originalFunction = this;
|
||||
if (arguments.length === 1) {
|
||||
return function () {
|
||||
return originalFunction.apply(object, arguments);
|
||||
};
|
||||
} else {
|
||||
var partialArgs = Array.prototype.slice.call(arguments, 1);
|
||||
return function () {
|
||||
var args = partialArgs.slice(0);
|
||||
args.push.apply(args, arguments);
|
||||
return originalFunction.apply(object, args);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue