From 8b0380b31858bf237e5fec44657f2e7ed4a7f3fd Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 23 Feb 2012 17:13:36 +0100 Subject: [PATCH] [imp] added destroyable mixin bzr revid: nicolas.vanhoren@openerp.com-20120223161336-ea4xbup4teyvereu --- addons/web/static/lib/nivjs/src/niv.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/addons/web/static/lib/nivjs/src/niv.js b/addons/web/static/lib/nivjs/src/niv.js index 893651d8008..76707864a91 100644 --- a/addons/web/static/lib/nivjs/src/niv.js +++ b/addons/web/static/lib/nivjs/src/niv.js @@ -26,6 +26,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. niv = (function() { var lib = {}; + /* + * Unmodified John Resig's inheritance + */ /* * Simple JavaScript Inheritance By John Resig http://ejohn.org/ MIT * Licensed. @@ -91,8 +94,17 @@ niv = (function() { return Class; }; }).call(lib); + + lib.DestroyableMixin = { + isDestroyed : function() { + return this.__destroyable_destroyed; + }, + destroy : function() { + this.__destroyable_destroyed = true; + } + }; - lib.ParentedMixin = { + lib.ParentedMixin = _.extend({}, lib.DestroyableMixin, { __parented_mixin : true, setParent : function(parent) { if (this.getParent()) { @@ -116,17 +128,14 @@ niv = (function() { return this.__parented_children ? _.clone(this.__parented_children) : []; }, - isDestroyed : function() { - return this.__parented_destroyed; - }, destroy : function() { _.each(this.getChildren(), function(el) { el.destroy(); }); this.setParent(undefined); - this.__parented_destroyed = true; + lib.DestroyableMixin.destroy.call(this); } - }; + }); return lib; })();