Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/138576

Change subject: Cards: Check for no cards in regular interval, show default card
......................................................................

Cards: Check for no cards in regular interval, show default card

Change-Id: I248f6e380961f998e77000ca1f76051388766f06
---
M modules/tools/ext.cx.tools.manager.js
1 file changed, 10 insertions(+), 11 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/76/138576/1

diff --git a/modules/tools/ext.cx.tools.manager.js 
b/modules/tools/ext.cx.tools.manager.js
index 2291fd9..680bc0f 100644
--- a/modules/tools/ext.cx.tools.manager.js
+++ b/modules/tools/ext.cx.tools.manager.js
@@ -65,7 +65,7 @@
         * @param {Array|Object|string} The data passed by the event.
         */
        CXToolManager.prototype.dispatch = function ( eventName ) {
-               var index, tools, cxToolManager = this,
+               var index, tools,
                        data = Array.prototype.slice.apply( arguments );
 
                mw.log( '[CX] event:' + eventName + ' , data:' + data );
@@ -75,15 +75,6 @@
                        // Call render function on the current setting module.
                        this.showCard( tools[ index ], data );
                }
-
-               // Wait for a while before checking if any cards are shown
-               // XXX This works, but can go wrong as we have more cards. Need
-               // to think more robust way.
-               window.setTimeout( function () {
-                       if ( !cxToolManager.$container.find( '.card' ).length ) 
{
-                               cxToolManager.showCard( 
cxToolManager.options.defaultTool );
-                       }
-               }, 1000 );
        };
 
        /**
@@ -91,13 +82,21 @@
         * dispatch them
         */
        CXToolManager.prototype.listen = function () {
-               var event;
+               var event, cxToolManager = this;
 
                for ( event in this.eventRegistry ) {
                        mw.hook( event ).add(
                                $.proxy( this.dispatch, this, event )
                        );
                }
+
+               // Check if there are any cards shown in regular time intervals
+               // If not show the default tool
+               window.setInterval( function () {
+                       if ( !cxToolManager.$container.find( '.card' ).length ) 
{
+                               cxToolManager.showCard( 
cxToolManager.options.defaultTool );
+                       }
+               }, 5000 );
        };
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I248f6e380961f998e77000ca1f76051388766f06
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

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

Reply via email to