From c51628252f802457b7e303404d4056c6ec57c80f Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 11 Aug 2016 14:21:43 +0200 Subject: [PATCH] Fixing tests and documentation --- Event/EventManager.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Event/EventManager.js b/Event/EventManager.js index a644311..a9a1738 100644 --- a/Event/EventManager.js +++ b/Event/EventManager.js @@ -33,15 +33,15 @@ * * Adding the same event overwrites the existing one as "waiting" * - * @param {string|int} id Event id * @param {string|int} group Group id + * @param {string|int} id Event id * * @method * * @since 1.0.0 * @author Dennis Eichhorn */ - jsOMS.Event.EventManager.prototype.addGroup = function (id, group) + jsOMS.Event.EventManager.prototype.addGroup = function (group, id) { if (typeof this.groups[group] === 'undefined') { this.groups[group] = {}; @@ -84,8 +84,8 @@ * * Executes the callback specified for this group if all events are finished * - * @param {string|int} id Event id * @param {string|int} group Group id + * @param {string|int} id Event id * * @return {boolean} * @@ -94,8 +94,10 @@ * @since 1.0.0 * @author Dennis Eichhorn */ - jsOMS.Event.EventManager.prototype.trigger = function (id, group) + jsOMS.Event.EventManager.prototype.trigger = function (group, id) { + id = typeof id !== 'undefined' ? id : 0; + if (typeof this.groups[group] !== 'undefined') { delete this.groups[group][id]; } @@ -145,9 +147,15 @@ */ jsOMS.Event.EventManager.prototype.attach = function (group, callback, remove) { + if(this.callbacks.hasOwnProperty(group)) { + return false; + } + remove = typeof remove === 'undefined' ? false : remove; this.callbacks[group] = {remove: remove, func: callback}; + + return true; }; /**