diff --git a/lib/client/dom.js b/lib/client/dom.js index 067aecec..9efbbb1d 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1553,13 +1553,10 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; /** prevent default event */ this.preventDefault = function(pEvent) { - var lRet, - lPreventDefault = pEvent && pEvent.preventDefault, - lFunc = Util.bind(lPreventDefault, pEvent); + var prevent = pEvent && pEvent.preventDefault, + func = prevent && prevent.bind(pEvent); - lRet = Util.exec(lFunc); - - return lRet; + Util.exec(func); }; /** diff --git a/lib/client/polyfill.js b/lib/client/polyfill.js index 8e8b54a6..258cef75 100644 --- a/lib/client/polyfill.js +++ b/lib/client/polyfill.js @@ -28,15 +28,15 @@ var Util, DOM, jQuery; .appendTo(pParams_o.parent || document.head); }; } + + if (!Function.bind) + Function.prototype.bind = function(context) { + var _this = this; - /* setting function context (this) */ - Util.bind = function(pFunction, pContext){ - var lRet; - - lRet = $.proxy(pFunction, pContext); - - return lRet; - }; + return function() { + return _this.apply(context, arguments); + }; + }; /* * typeof callback === "function" should not be used, diff --git a/lib/util.js b/lib/util.js index 2c97a27d..491c160c 100644 --- a/lib/util.js +++ b/lib/util.js @@ -438,21 +438,21 @@ * @param pArg */ this.log = function() { - var lArg = arguments, - lConsole = Scope.console, + var arg = arguments, + console = Scope.console, lDate = '[' + Util.getDate() + '] ', - lUnShift = Util.bind([].unshift, lArg), - lShift = Util.bind([].shift, lArg), - lJoin = Util.bind([].join, lArg); + unshift = [].unshift.bind(arg), + shift = [].shift.bind(arg), + join = [].join.bind(arg); - if (lConsole && lArg.length && lArg[0]) { - lUnShift(lDate); - lConsole.log.apply(lConsole, lArg); - lShift(); + if (console && arg.length && arg[0]) { + unshift(lDate); + console.log.apply(console, arg); + shift(); } - return lJoin(' '); + return join(' '); }; /** @@ -953,14 +953,15 @@ * @pArg */ this.execIfExist = function(pObj, pName, pArg) { - var lRet; + var ret, bind, + func = pObj && pObj[pName]; - if (pObj) { - var lFunc = Util.bind(pObj[pName], pObj); - lRet = Util.exec(lFunc, pArg); + if (func) { + func = func.bind(pObj); + ret = Util.exec(func, pArg); } - return lRet; + return ret; }; /**