jenkins-bot has submitted this change and it was merged.

Change subject: Support variadic arguments for event dispatcher
......................................................................


Support variadic arguments for event dispatcher

Change-Id: I7607311db9a2237c1dc026e984ec7ced0bcfe502
---
M modules/tools/ext.cx.tools.manager.js
1 file changed, 8 insertions(+), 4 deletions(-)

Approvals:
  Amire80: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/tools/ext.cx.tools.manager.js 
b/modules/tools/ext.cx.tools.manager.js
index 9768262..2291fd9 100644
--- a/modules/tools/ext.cx.tools.manager.js
+++ b/modules/tools/ext.cx.tools.manager.js
@@ -64,12 +64,13 @@
         * @param {string} eventName event name
         * @param {Array|Object|string} The data passed by the event.
         */
-       CXToolManager.prototype.dispatch = function ( eventName, data ) {
-               var index, tools, cxToolManager = this;
+       CXToolManager.prototype.dispatch = function ( eventName ) {
+               var index, tools, cxToolManager = this,
+                       data = Array.prototype.slice.apply( arguments );
 
-               //this.hideCards();
                mw.log( '[CX] event:' + eventName + ' , data:' + data );
                tools = this.eventRegistry[ eventName ];
+               data = data.splice( 1 );
                for ( index in tools ) {
                        // Call render function on the current setting module.
                        this.showCard( tools[ index ], data );
@@ -113,7 +114,10 @@
                }
                tool = new mw.cx.tools[ toolName ]();
                this.$container.append( tool.getCard() );
-               tool.start( data );
+               if ( typeof data === 'string' ) {
+                       data = new Array( data );
+               }
+               tool.start.apply( tool, data );
                this.tools[ toolName ] = tool;
        };
 

-- 
To view, visit https://gerrit.wikimedia.org/r/137868
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7607311db9a2237c1dc026e984ec7ced0bcfe502
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>
Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to