From c9f5c056862553d5102d1dfb7d964ea449573d59 Mon Sep 17 00:00:00 2001 From: ewinslow Date: Sun, 14 Nov 2010 11:33:29 +0000 Subject: Refs #2538: Added vsprintf support to elgg.echo. Added unit tests for normalize_url, added prototype definitions for Array#forEach for compatibility with IE. git-svn-id: http://code.elgg.org/elgg/trunk@7313 36083f99-b078-4883-b0ff-0f9b5a30f544 --- js/lib/prototypes.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 js/lib/prototypes.js (limited to 'js/lib/prototypes.js') diff --git a/js/lib/prototypes.js b/js/lib/prototypes.js new file mode 100644 index 000000000..0f0014818 --- /dev/null +++ b/js/lib/prototypes.js @@ -0,0 +1,44 @@ +/** + * + */ +if (!Array.prototype.every) { + Array.prototype.every = function(callback) { + var len = this.length, i; + + for (i = 0; i < len; i++) { + if (i in this && !callback.call(null, this[i], i)) { + return false; + } + } + + return true; + }; +} + +/** + * + */ +if (!Array.prototype.forEach) { + Array.prototype.forEach = function(callback) { + var len = this.length, i; + + for (i = 0; i < len; i++) { + if (i in this) { + callback.call(null, this[i], i); + } + } + }; +} + +/** + * + */ +if (!String.prototype.ltrim) { + String.prototype.ltrim = function(str) { + if (this.indexOf(str) === 0) { + return this.substring(str.length); + } else { + return this; + } + }; +} \ No newline at end of file -- cgit v1.2.3