diff options
| author | Antony Lesuisse <al@openerp.com> | 2012-07-21 22:12:53 +0200 |
|---|---|---|
| committer | Antony Lesuisse <al@openerp.com> | 2012-07-21 22:12:53 +0200 |
| commit | a6e85cfd5a533e5d9ff83121ae901978029bc0b5 (patch) | |
| tree | 018abf453bc26022f09457bfcada74568c4a62fb /addons/web/static/src/js | |
| parent | 3611d585b3e75b895f52868c75d8b213cc39e831 (diff) | |
[REM] setValue, event namespacing
bzr revid: al@openerp.com-20120721201253-z35xjhao0r1mv6l1
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/corelib.js | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index 5ecd6dbb07d..dcaaa864fc8 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -238,20 +238,6 @@ instance.web.ParentedMixin = { }; /** - * Utility function for APIs which can take either a value or a function which - * returns a value - * - * @param {Object} object - * @param {String} property - * @returns {Object} - */ -var getValue = function (object, property) { - if (object == null) { return null; } - var value = object[property]; - return _.isFunction(value) ? value.call(object) : value; -}; - -/** * Backbone's events. Do not ever use it directly, use EventDispatcherMixin instead. * * (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc. @@ -677,6 +663,12 @@ instance.web.CallbackEnabled = instance.web.Class.extend(instance.web.CallbackEn * That will kill the widget in a clean way and erase its content from the dom. */ instance.web.Widget = instance.web.Class.extend(instance.web.WidgetMixin, { + // Backbone-ish API + tagName: 'div', + id: null, + className: null, + attributes: {}, + events: {}, /** * The name of the QWeb template that will be used for rendering. Must be * redefined in subclasses or the default render() method can not be used. @@ -695,7 +687,6 @@ instance.web.Widget = instance.web.Class.extend(instance.web.WidgetMixin, { * destroyed too. Can be null. */ init: function(parent) { - this._uid = _.uniqueId('-widget-'); instance.web.WidgetMixin.init.call(this,parent); this.session = instance.connection; }, @@ -746,12 +737,6 @@ instance.web.Widget = instance.web.Class.extend(instance.web.WidgetMixin, { return this; }, - - // Backbone-ish API - tagName: 'div', - id: null, - className: null, - attributes: {}, /** * Utility function to build small DOM elements. * @@ -770,9 +755,8 @@ instance.web.Widget = instance.web.Class.extend(instance.web.WidgetMixin, { } return el; }, - events: {}, delegateEvents: function () { - var events = getValue(this, 'events'); + var events = this.events; if (_.isEmpty(events)) { return; } for(var key in events) { @@ -784,8 +768,7 @@ instance.web.Widget = instance.web.Class.extend(instance.web.WidgetMixin, { var event = match[1]; var selector = match[3]; - // add namespace for easy un-delegation - event += '.delegated-events' + this._uid; + event += '.delegated-events'; if (!selector) { this.$el.on(event, method); } else { @@ -794,7 +777,7 @@ instance.web.Widget = instance.web.Class.extend(instance.web.WidgetMixin, { } }, undelegateEvents: function () { - this.$el.off('.delegated-events' + this._uid); + this.$el.off('.delegated-events'); }, /** * Shortcut for ``this.$el.find(selector)`` |
