Jdlrobson has uploaded a new change for review.

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

Change subject: Hygiene: Add _getFooterElement method
......................................................................

Hygiene: Add _getFooterElement method

Continue to shrink down the size of buildOverlay

Change-Id: I69b339947bfe4d5e73c6d293f0ae5e9e494ec6ca
---
M modules/overlay/ext.echo.overlay.js
1 file changed, 51 insertions(+), 47 deletions(-)


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

diff --git a/modules/overlay/ext.echo.overlay.js 
b/modules/overlay/ext.echo.overlay.js
index de737ac..c724e1e 100644
--- a/modules/overlay/ext.echo.overlay.js
+++ b/modules/overlay/ext.echo.overlay.js
@@ -73,6 +73,55 @@
                                        } );
                                } );
                },
+
+               _getFooterElement: function() {
+                       var $overlayFooter,
+                               $prefLink = $( '#pt-preferences a' );
+
+                       $overlayFooter = $( '<div>' )
+                               .attr( 'id', 'mw-echo-overlay-footer' );
+
+                       // add link to notifications archive
+                       $overlayFooter.append(
+                               $( '<a>' )
+                                       .attr( 'id', 'mw-echo-overlay-link' )
+                                       .addClass( 'mw-echo-grey-link' )
+                                       .attr( 'href', getUrl( 
'Special:Notifications' ) )
+                                       .text( mw.msg( 'echo-overlay-link' ) )
+                                       .click( function () {
+                                               mw.echo.logInteraction( 
'ui-archive-link-click', 'flyout' );
+                                       } )
+                                       .hover(
+                                               function() {
+                                                       $( this ).removeClass( 
'mw-echo-grey-link' );
+                                               },
+                                               function() {
+                                                       $( this ).addClass( 
'mw-echo-grey-link' );
+                                               }
+                                       )
+                       );
+
+                       // add link to notification preferences
+                       $overlayFooter.append(
+                               $( '<a>' )
+                                       .html( $prefLink.html() )
+                                       .attr( 'id', 
'mw-echo-overlay-pref-link' )
+                                       .addClass( 'mw-echo-grey-link' )
+                                       .attr( 'href', $prefLink.attr( 'href' ) 
+ '#mw-prefsection-echo' )
+                                       .click( function () {
+                                               mw.echo.logInteraction( 
'ui-prefs-click', 'flyout' );
+                                       } )
+                                       .hover(
+                                               function() {
+                                                       $( this ).removeClass( 
'mw-echo-grey-link' );
+                                               },
+                                               function() {
+                                                       $( this ).addClass( 
'mw-echo-grey-link' );
+                                               }
+                                       )
+                       );
+                       return $overlayFooter;
+               },
                /**
                 * Builds an overlay element
                 * @method
@@ -81,7 +130,6 @@
                buildOverlay: function ( callback ) {
                        var notificationLimit = this.getNotificationLimit(),
                                $overlay = $( '<div>' ).addClass( 
'mw-echo-overlay' ),
-                               $prefLink = $( '#pt-preferences a' ),
                                self = this,
                                apiData;
 
@@ -101,8 +149,7 @@
                                        $title = $( '<div>' ).addClass( 
'mw-echo-overlay-title' ),
                                        $ul = $( '<ul>' ).addClass( 
'mw-echo-notifications' ),
                                        titleText,
-                                       overflow,
-                                       $overlayFooter;
+                                       overflow;
 
                                if ( unreadTotalCount !== undefined ) {
                                        mw.echo.overlay.updateCount( 
unreadTotalCount, unreadRawTotalCount );
@@ -223,50 +270,7 @@
                                        $ul.appendTo( $overlay );
                                }
 
-                               $overlayFooter = $( '<div>' )
-                                       .attr( 'id', 'mw-echo-overlay-footer' );
-
-                               // add link to notifications archive
-                               $overlayFooter.append(
-                                       $( '<a>' )
-                                               .attr( 'id', 
'mw-echo-overlay-link' )
-                                               .addClass( 'mw-echo-grey-link' )
-                                               .attr( 'href', getUrl( 
'Special:Notifications' ) )
-                                               .text( mw.msg( 
'echo-overlay-link' ) )
-                                               .click( function () {
-                                                       mw.echo.logInteraction( 
'ui-archive-link-click', 'flyout' );
-                                               } )
-                                               .hover(
-                                                       function() {
-                                                               $( this 
).removeClass( 'mw-echo-grey-link' );
-                                                       },
-                                                       function() {
-                                                               $( this 
).addClass( 'mw-echo-grey-link' );
-                                                       }
-                                               )
-                               );
-
-                               // add link to notification preferences
-                               $overlayFooter.append(
-                                       $( '<a>' )
-                                               .html( $prefLink.html() )
-                                               .attr( 'id', 
'mw-echo-overlay-pref-link' )
-                                               .addClass( 'mw-echo-grey-link' )
-                                               .attr( 'href', $prefLink.attr( 
'href' ) + '#mw-prefsection-echo' )
-                                               .click( function () {
-                                                       mw.echo.logInteraction( 
'ui-prefs-click', 'flyout' );
-                                               } )
-                                               .hover(
-                                                       function() {
-                                                               $( this 
).removeClass( 'mw-echo-grey-link' );
-                                                       },
-                                                       function() {
-                                                               $( this 
).addClass( 'mw-echo-grey-link' );
-                                                       }
-                                               )
-                               );
-
-                               $overlay.append( $overlayFooter );
+                               $overlay.append( self._getFooterElement() );
 
                                callback( $overlay );
                                self.markAllAsRead( unread );

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

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