mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 22:17:03 +03: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
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…
Add table
Add a link
Reference in a new issue