Author: ygrego Date: 2015-03-18 09:18:57 +0000 (Wed, 18 Mar 2015) New Revision: 953 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/953 Log: The method "addEventListener" and "fireEvent" have been added to "prototype" of super class "Class". Because these one must be present in each subclass. Modified: oipf/js/lib/Class.js Modified: oipf/js/lib/Class.js =================================================================== --- oipf/js/lib/Class.js 2015-03-17 09:18:21 UTC (rev 952) +++ oipf/js/lib/Class.js 2015-03-18 09:18:57 UTC (rev 953) @@ -10,6 +10,23 @@ child.prototype = proto; child.prototype.__proto__ = parent.prototype; child.prototype.super = parent.prototype; + + child.prototype.addEventListener = function(type, listener) { + var listenersList = this.listeners[type]; + + if (listenersList) { + listenersList.push(listener); + } else { + this.listeners[type] = [listener]; + } + + }; + child.prototype.fireEvent = function(event) { + this.listeners[event.type].forEach(function(element){ + element.apply(this, event.detail); + }); + }; + return child; };