From c94c4599b2a1e76664db8558bcd973ac6250e18f Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 26 Jul 2013 14:48:37 +0200 Subject: [PATCH] Moved proxy() bzr revid: nicolas.vanhoren@openerp.com-20130726124837-yze64evp7r70uv5y --- addons/web/static/src/js/corelib.js | 26 ------------------ addons/web/static/src/js/openerpframework.js | 28 +++++++++++++++++++- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index 1b93ced09aa..c419685c222 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -26,32 +26,6 @@ openerp.web.corelib = function(instance) { var ControllerMixin = { - /** - * Proxies a method of the object, in order to keep the right ``this`` on - * method invocations. - * - * This method is similar to ``Function.prototype.bind`` or ``_.bind``, and - * even more so to ``jQuery.proxy`` with a fundamental difference: its - * resolution of the method being called is lazy, meaning it will use the - * method as it is when the proxy is called, not when the proxy is created. - * - * Other methods will fix the bound method to what it is when creating the - * binding/proxy, which is fine in most javascript code but problematic in - * OpenERP Web where developers may want to replace existing callbacks with - * theirs. - * - * The semantics of this precisely replace closing over the method call. - * - * @param {String|Function} method function or name of the method to invoke - * @returns {Function} proxied method - */ - proxy: function (method) { - var self = this; - return function () { - var fn = (typeof method === 'string') ? self[method] : method; - return fn.apply(self, arguments); - }; - }, /** * Informs the action manager to do an action. This supposes that * the action manager can be found amongst the ancestors of the current widget. diff --git a/addons/web/static/src/js/openerpframework.js b/addons/web/static/src/js/openerpframework.js index 7774b23eed4..c67d9a34f23 100644 --- a/addons/web/static/src/js/openerpframework.js +++ b/addons/web/static/src/js/openerpframework.js @@ -730,7 +730,33 @@ openerp.web.Widget = openerp.web.Class.extend(openerp.web.PropertiesMixin, { */ $: function(selector) { return this.$el.find(selector); - } + }, + /** + * Proxies a method of the object, in order to keep the right ``this`` on + * method invocations. + * + * This method is similar to ``Function.prototype.bind`` or ``_.bind``, and + * even more so to ``jQuery.proxy`` with a fundamental difference: its + * resolution of the method being called is lazy, meaning it will use the + * method as it is when the proxy is called, not when the proxy is created. + * + * Other methods will fix the bound method to what it is when creating the + * binding/proxy, which is fine in most javascript code but problematic in + * OpenERP Web where developers may want to replace existing callbacks with + * theirs. + * + * The semantics of this precisely replace closing over the method call. + * + * @param {String|Function} method function or name of the method to invoke + * @returns {Function} proxied method + */ + proxy: function (method) { + var self = this; + return function () { + var fn = (typeof method === 'string') ? self[method] : method; + return fn.apply(self, arguments); + }; + }, }); openerp.web.qweb = new QWeb2.Engine();