Santhosh has uploaded a new change for review.

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

Change subject: Suggestions: Wrap the personal and public collections
......................................................................

Suggestions: Wrap the personal and public collections

So that hide/show of tabs becomes more simple.

Change-Id: I60fa914dd8058a34553a287d80a1d926a0c8744e
---
M modules/dashboard/ext.cx.suggestionlist.js
1 file changed, 18 insertions(+), 25 deletions(-)


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

diff --git a/modules/dashboard/ext.cx.suggestionlist.js 
b/modules/dashboard/ext.cx.suggestionlist.js
index 9237093..b357c5b 100644
--- a/modules/dashboard/ext.cx.suggestionlist.js
+++ b/modules/dashboard/ext.cx.suggestionlist.js
@@ -40,11 +40,12 @@
                        sourceLanguage: null,
                        targetLanguage: null
                };
+               this.$suggestionsContainer = null;
                this.$personalCollection = null;
                this.$publicCollection = null;
                this.seed = null;
-               this.listen();
                this.init();
+               this.listen();
        }
 
        CXSuggestionList.prototype.init = function () {
@@ -57,7 +58,10 @@
                $publicCollectionTitle = $( '<h2>' )
                        .text( mw.msg( 'cx-suggestionlist-title' ) )
                        .addClass( 'cx-suggestionlist__public-title' );
-               this.$container.append( this.$personalCollection, 
$publicCollectionTitle, this.$publicCollection );
+               this.$suggestionsContainer = $( '<div>' )
+                       .addClass( 'cx-suggestionlist-container' )
+                       .append( this.$personalCollection, 
$publicCollectionTitle, this.$publicCollection );
+               this.$container.append( this.$suggestionsContainer );
                this.initLanguages();
        };
 
@@ -213,11 +217,7 @@
 
        CXSuggestionList.prototype.show = function () {
                this.active = true;
-               $.each( this.lists, function ( index, list ) {
-                       if ( list.$list ) {
-                               list.$list.show();
-                       }
-               } );
+               this.$suggestionsContainer.show();
                if ( !Object.keys( this.lists ).length ) {
                        this.loadItems();
                        this.loadItems( {
@@ -228,11 +228,7 @@
 
        CXSuggestionList.prototype.hide = function () {
                this.active = false;
-               $.each( this.lists, function ( index, list ) {
-                       if ( list.$list ) {
-                               list.$list.hide();
-                       }
-               } );
+               this.$suggestionsContainer.hide();
        };
 
        CXSuggestionList.prototype.applyFilters = function () {
@@ -252,6 +248,9 @@
                } );
                this.lists = {};
                this.recommendtool = null;
+               this.$personalCollection.empty().show();
+               this.$publicCollection.empty().show();
+
                this.loadItems();
                this.loadItems( {
                        id: 'trex'
@@ -646,16 +645,10 @@
                                )
                        );
 
-                       this.$container.append( this.lists[ listId ].$list );
+                       this.$suggestionsContainer.append( this.lists[ listId 
].$list );
                }
-
-               // Hide all other lists, if any.
-               $.each( this.lists, function ( index, list ) {
-                       if ( list.$list ) {
-                               list.$list.hide();
-                       }
-               } );
-
+               this.$personalCollection.hide();
+               this.$publicCollection.hide();
                this.lists[ listId ].$list.show();
        };
 
@@ -681,7 +674,7 @@
         * Event handlers
         */
        CXSuggestionList.prototype.listen = function () {
-               this.$container.on( 'click', '.cx-suggestionlist .cx-slitem', 
function () {
+               this.$suggestionsContainer.on( 'click', '.cx-suggestionlist 
.cx-slitem', function () {
                        var cxSelector, suggestion;
 
                        cxSelector = $( this ).data( 'cxsourceselector' );
@@ -805,7 +798,7 @@
 
                if ( list.$list.is( '.cx-suggestionlist--collapsed' ) ) {
                        // Collapse all expended lists.
-                       this.$container.find( '.cx-suggestionlist__collapse' 
).trigger( 'click' );
+                       this.$suggestionsContainer.find( 
'.cx-suggestionlist__collapse' ).trigger( 'click' );
                        $trigger.text( mw.msg( 'cx-suggestionlist-collapse' ) );
                } else {
                        $trigger.text( mw.msg( 'cx-suggestionlist-expand' ) );
@@ -821,11 +814,11 @@
        CXSuggestionList.prototype.addRefreshTrigger = function () {
                var self = this;
 
-               if ( this.$container.find( '.cx-suggestionlist__refresh' 
).length ) {
+               if ( this.$suggestionsContainer.find( 
'.cx-suggestionlist__refresh' ).length ) {
                        return;
                }
 
-               this.$container.append( $( '<div>' )
+               this.$publicCollection.append( $( '<div>' )
                        .addClass( 'cx-suggestionlist__refresh' )
                        .text( mw.msg( 'cx-suggestionlist-refresh' ) )
                        .on( 'click', function () {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I60fa914dd8058a34553a287d80a1d926a0c8744e
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