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

Change subject: Suggestions: Show list headings as part of list
......................................................................


Suggestions: Show list headings as part of list

Show the titles with white background and connected with suggestion
items.

Bug: T115006
Change-Id: Ief8ef1e5ca6721d2a8f81949fb8eeaf8eb23aa35
---
M modules/dashboard/ext.cx.suggestionlist.js
M modules/dashboard/styles/ext.cx.suggestionlist.less
2 files changed, 40 insertions(+), 17 deletions(-)

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



diff --git a/modules/dashboard/ext.cx.suggestionlist.js 
b/modules/dashboard/ext.cx.suggestionlist.js
index 273c565..401d1a4 100644
--- a/modules/dashboard/ext.cx.suggestionlist.js
+++ b/modules/dashboard/ext.cx.suggestionlist.js
@@ -167,7 +167,6 @@
                var params,
                        api = new mw.Api();
 
-
                if ( list.hasMore === false ) {
                        // This method is supposed to be called only if we 
there are items to fetch
                        return $.Deferred().reject();
@@ -729,36 +728,49 @@
         * @param {string} listId
         */
        CXSuggestionList.prototype.makeExpandableList = function ( listId ) {
-               var self = this,
-                       list = this.lists[ listId ];
+               var list = this.lists[ listId ];
+
                if ( list.$list.is( '.cx-suggestionlist--collapsed' ) ||
                        list.$list.is( '.cx-suggestionlist--expanded' )
                ) {
                        return;
                }
 
+               list.$list.find( 'h2' ).on( 'click', $.proxy( 
this.expandOrCollapse, this, list.id ) );
+
                list.$list.append( $( '<div>' )
                        .addClass( 'cx-suggestionlist__expand' )
                        .text( mw.msg( 'cx-suggestionlist-expand' ) )
-                       .on( 'click', function () {
-                               if ( $( this ).is( '.cx-suggestionlist__expand' 
) ) {
-                                       $( this ).text( mw.msg( 
'cx-suggestionlist-collapse' ) );
-                                       // Collapse all expended lists.
-                                       self.$container.find( 
'.cx-suggestionlist__collapse' ).trigger( 'click' );
-                               } else {
-                                       $( this ).text( mw.msg( 
'cx-suggestionlist-expand' ) );
-                               }
-                               $( this )
-                                       .toggleClass( 
'cx-suggestionlist__collapse cx-suggestionlist__expand' )
-                                       .parent()
-                                       .toggleClass( 
'cx-suggestionlist--collapsed cx-suggestionlist--expanded' );
-
-                       } )
+                       .on( 'click', $.proxy( this.expandOrCollapse, this, 
list.id ) )
                );
+               // By default, the list is collapsed.
                list.$list.addClass( 'cx-suggestionlist--collapsed' );
        };
 
        /**
+        * Expand of collapse the list with the given listId.
+        *
+        * @param  {string} listId List identifier.
+        */
+       CXSuggestionList.prototype.expandOrCollapse = function ( listId ) {
+               var $trigger,
+                       list = this.lists[ listId ];
+
+               $trigger = list.$list.find( '.cx-suggestionlist__expand, 
.cx-suggestionlist__collapse' );
+
+               if ( $trigger.is( '.cx-suggestionlist--collapsed' ) ) {
+                       $trigger.text( mw.msg( 'cx-suggestionlist-collapse' ) );
+                       // Collapse all expended lists.
+                       this.$container.find( '.cx-suggestionlist__collapse' 
).trigger( 'click' );
+               } else {
+                       $trigger.text( mw.msg( 'cx-suggestionlist-expand' ) );
+               }
+
+               $trigger.toggleClass( 'cx-suggestionlist__collapse 
cx-suggestionlist__expand' );
+               list.$list.toggleClass( 'cx-suggestionlist--collapsed 
cx-suggestionlist--expanded' );
+       };
+
+       /**
         * Make the list refreshable
         *
         * @param {string} listId
diff --git a/modules/dashboard/styles/ext.cx.suggestionlist.less 
b/modules/dashboard/styles/ext.cx.suggestionlist.less
index a1afbc1..7842c97 100644
--- a/modules/dashboard/styles/ext.cx.suggestionlist.less
+++ b/modules/dashboard/styles/ext.cx.suggestionlist.less
@@ -7,6 +7,17 @@
        border-bottom: none;
 }
 
+.cx-suggestionlist--expanded h2,
+.cx-suggestionlist--collapsed h2 {
+       .mw-ui-one-whole;
+       background-color: #fff;
+       border: 1px solid #ddd;
+       border-bottom: 0;
+       padding: 10px;
+       margin: 20px 0 0 0;
+       cursor: pointer;
+}
+
 .cx-suggestionlist--collapsed {
        // First item is heading and then next 2 items.
        // So hide all items starting at 4th child.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ief8ef1e5ca6721d2a8f81949fb8eeaf8eb23aa35
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to