From 8877087b5716fde078bab4d303240498f02dd48b Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Thu, 14 Feb 2013 12:16:51 +0100 Subject: [PATCH] adding a compatibility.js as a single source to define all fallback function declarations --- core/js/compatibility.js | 25 +++++++++++++++++++++++++ lib/base.php | 1 + 2 files changed, 26 insertions(+) create mode 100644 core/js/compatibility.js diff --git a/core/js/compatibility.js b/core/js/compatibility.js new file mode 100644 index 0000000000..3e9178f320 --- /dev/null +++ b/core/js/compatibility.js @@ -0,0 +1,25 @@ + +//https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind +if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () {}, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; +} diff --git a/lib/base.php b/lib/base.php index c60a97100f..fd9a1d4112 100644 --- a/lib/base.php +++ b/lib/base.php @@ -278,6 +278,7 @@ class OC { OC_Util::addScript("jquery-showpassword"); OC_Util::addScript("jquery.infieldlabel"); OC_Util::addScript("jquery-tipsy"); + OC_Util::addScript("compatibility"); OC_Util::addScript("oc-dialogs"); OC_Util::addScript("js"); OC_Util::addScript("eventsource");