Jdlrobson has uploaded a new change for review.

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

Change subject: Refactor out mark as read button code
......................................................................

Refactor out mark as read button code

Change-Id: Iad935174925bd1c16e51bbc36c84b48769e9780c
---
M modules/overlay/ext.echo.overlay.js
1 file changed, 24 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/82/151982/1

diff --git a/modules/overlay/ext.echo.overlay.js 
b/modules/overlay/ext.echo.overlay.js
index c0f7cc9..de737ac 100644
--- a/modules/overlay/ext.echo.overlay.js
+++ b/modules/overlay/ext.echo.overlay.js
@@ -51,6 +51,28 @@
                        return notificationLimit;
                },
 
+               _getMarkAsReadButton: function() {
+                       return $( '<button>' )
+                               .addClass( 'mw-ui-button' )
+                               .attr( 'id', 'mw-echo-mark-read-button' )
+                               .text( mw.msg( 'echo-mark-all-as-read' ) )
+                               .click( function ( e ) {
+                                       e.preventDefault();
+                                       this.api.post( 
mw.echo.desktop.appendUseLang( {
+                                               'action' : 'echomarkread',
+                                               'all' : true,
+                                               'token': mw.user.tokens.get( 
'editToken' )
+                                       } ) ).done( function ( result ) {
+                                               var count;
+                                               if ( 
result.query.echomarkread.count !== undefined ) {
+                                                       count = 
result.query.echomarkread.count;
+                                                       
mw.echo.overlay.updateCount( count, result.query.echomarkread.rawcount );
+                                                       // Reset header to 
'Notifications'
+                                                       $( 
'#mw-echo-overlay-title-text' ).html( mw.msg( 'echo-overlay-title' ) );
+                                               }
+                                       } );
+                               } );
+               },
                /**
                 * Builds an overlay element
                 * @method
@@ -60,7 +82,6 @@
                        var notificationLimit = this.getNotificationLimit(),
                                $overlay = $( '<div>' ).addClass( 
'mw-echo-overlay' ),
                                $prefLink = $( '#pt-preferences a' ),
-                               count = 0,
                                self = this,
                                apiData;
 
@@ -81,8 +102,7 @@
                                        $ul = $( '<ul>' ).addClass( 
'mw-echo-notifications' ),
                                        titleText,
                                        overflow,
-                                       $overlayFooter,
-                                       $markReadButton;
+                                       $overlayFooter;
 
                                if ( unreadTotalCount !== undefined ) {
                                        mw.echo.overlay.updateCount( 
unreadTotalCount, unreadRawTotalCount );
@@ -176,26 +196,7 @@
                                if ( overflow && unreadRawTotalCount < 
mw.echo.overlay.configuration['max-notification-count']
                                ) {
                                        // Add the 'mark all as read' button to 
the title area
-                                       $markReadButton = $( '<button>' )
-                                               .addClass( 'mw-ui-button' )
-                                               .attr( 'id', 
'mw-echo-mark-read-button' )
-                                               .text( mw.msg( 
'echo-mark-all-as-read' ) )
-                                               .click( function ( e ) {
-                                                       e.preventDefault();
-                                                       self.api.post( 
mw.echo.desktop.appendUseLang( {
-                                                               'action' : 
'echomarkread',
-                                                               'all' : true,
-                                                               'token': 
mw.user.tokens.get( 'editToken' )
-                                                       } ) ).done( function ( 
result ) {
-                                                               if ( 
result.query.echomarkread.count !== undefined ) {
-                                                                       count = 
result.query.echomarkread.count;
-                                                                       
mw.echo.overlay.updateCount( count, result.query.echomarkread.rawcount );
-                                                                       // 
Reset header to 'Notifications'
-                                                                       $( 
'#mw-echo-overlay-title-text' ).html( mw.msg( 'echo-overlay-title' ) );
-                                                               }
-                                                       } );
-                                               } );
-                                       $title.append( $markReadButton );
+                                       $title.append( 
self._getMarkAsReadButton() );
                                }
 
                                // Add the header to the title area

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad935174925bd1c16e51bbc36c84b48769e9780c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

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

Reply via email to