From d0dd746c8bf33b55999cb673babef68987854c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bartelme=C3=9F?= Date: Fri, 16 Mar 2012 18:21:28 +0100 Subject: [PATCH] added .keys method to objects, if not supported, fixes IE issue with pluginfw --- src/static/js/ace2_common.js | 12 ++++++++++-- src/static/js/pluginfw/plugins.js | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/static/js/ace2_common.js b/src/static/js/ace2_common.js index 7fe08a7e..41fb320d 100644 --- a/src/static/js/ace2_common.js +++ b/src/static/js/ace2_common.js @@ -47,7 +47,7 @@ function extend(obj, props) var forEachImpl = function(fn){ for (var i = 0; i < this.length; i++) { - var result = func(this[i], i, this); + var result = fn(this[i], i, this); } } @@ -64,11 +64,19 @@ function mapImpl(fn) return result; } +// From underscore.js +var keysImpl =function(obj) { + if (obj !== Object(obj)) throw new TypeError('Invalid object'); + var keys = []; + for (var key in obj) if (obj.hasOwnProperty(key)) keys.push(key); + + return keys; +}; Array.prototype.forEach = Array.prototype.forEach || forEachImpl; Array.prototype.each = Array.prototype.each || forEachImpl; Array.prototype.map = Array.prototype.map || mapImpl; - +Object.keys = Object.keys || keysImpl; function isArray(testObject) { diff --git a/src/static/js/pluginfw/plugins.js b/src/static/js/pluginfw/plugins.js index c5c21903..b126a6fe 100644 --- a/src/static/js/pluginfw/plugins.js +++ b/src/static/js/pluginfw/plugins.js @@ -10,6 +10,8 @@ if (!exports.isClient) { var fs = require("fs"); var tsort = require("./tsort"); var util = require("util"); +}else{ + require("../ace2_common.js"); } exports.prefix = 'ep_';