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

Change subject: Various WikiLove performance clean up
......................................................................


Various WikiLove performance clean up

* Don't export wikilove-recipient and wikilove-anon on all pages.
  - Set "wikilove-recipient" only on user-talk pages.
    (Matching when the module is loaded.)
  - Set "wikilove-anon" only for anon recipient user-talk pages.

* Use mw.html.element() instead of $() and then wrap/html.
  Using DOM nodes with $() is preferable, but they're not used in this case.
  Instead of wasting DOM power to build the nodes and then wrap and serialise
  it again, use simple string manipulation with mw.html.element() instead.

* Don't @embed both the PNG and SVG. @embed is meant to help save data and
  requests. Embedding both means browsers download both and we end up fetching
  more data than without @embed. Also remove the -webkit-prefixed SVG rule,
  since we removed those kinds of rules from MW core too.

* Remove IE 6 hack. The code only applies to Grade A JS clients, which
  no longer includes IE6.

* Remove odd duplication of Vector "div.vectorTabs span" code. This
  already exists in Vector exactly as-is, except nowadays without
  embedding an unused PNG.

* Remove odd duplication of "#ca-unwatch.icon". The default is already
  'margin: 0;'.

Bug: T64000
Change-Id: I696619aacf6dc06a14dfdc7eb6e463a56ebd2655
---
M WikiLove.hooks.php
M resources/ext.wikiLove.core.js
M resources/ext.wikiLove.icon.css
3 files changed, 27 insertions(+), 56 deletions(-)

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



diff --git a/WikiLove.hooks.php b/WikiLove.hooks.php
index f261ec8..82a7a4e 100644
--- a/WikiLove.hooks.php
+++ b/WikiLove.hooks.php
@@ -7,7 +7,7 @@
  */
 
 class WikiLoveHooks {
-       private static $recipient = '';
+       private static $recipient = null;
 
        /**
         * LoadExtensionSchemaUpdates hook
@@ -69,12 +69,12 @@
         * @param array $vars
         */
        public static function onMakeGlobalVariablesScript( &$vars ) {
-               $vars['wikilove-recipient'] = self::$recipient;
-
-               $vars['wikilove-anon'] = 0;
-               if ( self::$recipient !== '' ) {
+               if ( self::$recipient !== null ) {
+                       $vars['wikilove-recipient'] = self::$recipient;
                        $receiver = User::newFromName( self::$recipient );
-                       if ( $receiver === false || $receiver->isAnon() ) 
$vars['wikilove-anon'] = 1;
+                       if ( $receiver === false || $receiver->isAnon() ) {
+                               $vars['wikilove-anon'] = 1;
+                       }
                }
        }
 
diff --git a/resources/ext.wikiLove.core.js b/resources/ext.wikiLove.core.js
index de5c1b1..f61e76a 100644
--- a/resources/ext.wikiLove.core.js
+++ b/resources/ext.wikiLove.core.js
@@ -57,23 +57,17 @@
                                $button.append( '<span>' + mw.html.escape( 
type.name ) + '</span>' );
 
                                $button.data( 'typeId', typeId );
-                               $typeList.append( $( '<li></li>' ).append( 
$button ) );
+                               $typeList.append( $( '<li>' ).append( $button ) 
);
                        }
 
-                       var commonsLink = $( '<a>' )
-                                       .attr( 'href', mw.msg( 
'wikilove-commons-url' ) )
-                                       .attr( 'target', '_blank' )
-                                       .text( mw.msg( 'wikilove-commons-link' 
) )
-                                       .wrap( '<div>' ) // or .html() will 
only return the link text
-                                       .parent()
-                                       .html();
-                       var termsLink = $( '<a> ')
-                                       .attr( 'href', mw.msg( 
'wikilove-terms-url' ) )
-                                       .attr( 'target', '_blank' )
-                                       .text( mw.msg( 'wikilove-terms-link' ) )
-                                       .wrap( '<div>' )
-                                       .parent()
-                                       .html();
+                       var commonsLink = mw.html.element( 'a', {
+                                       href: mw.msg( 'wikilove-commons-url' ),
+                                       target: '_blank'
+                               }, mw.msg( 'wikilove-commons-link' ) );
+                       var termsLink = mw.html.element( 'a', {
+                                       href: mw.msg( 'wikilove-terms-url' ),
+                                       target: '_blank'
+                               }, mw.msg( 'wikilove-terms-link' ) );
 
                        $dialog = $( '<div id="mw-wikilove-dialog">\
 <div id="mw-wikilove-select-type">\
@@ -88,7 +82,7 @@
                <li><html:msg key="wikilove-get-started-list-2"/></li>\
                <li><html:msg key="wikilove-get-started-list-3"/></li>\
        </ol>\
-       <p><a target="_blank" href="' + mw.html.escape( mw.msg( 
'wikilove-what-is-this-link' ) ) + '">\
+       <p><a target="_blank" href="' + mw.message( 
'wikilove-what-is-this-link' ).escaped() + '">\
                <html:msg key="wikilove-what-is-this"/>\
        </a></p>\
        <p id="mw-wikilove-anon-warning"><strong><html:msg 
key="wikilove-anon-warning"/></strong></p>\
@@ -121,7 +115,7 @@
                <span class="mw-wikilove-note" 
id="mw-wikilove-image-note"><html:msg key="wikilove-image-example"/></span>\
                <input type="text" class="text" id="mw-wikilove-image"/>\
                <div id="mw-wikilove-commons-text">\
-               ' + mw.html.escape( mw.msg( 'wikilove-commons-text' ) 
).replace( /\$1/, commonsLink ) + '\
+               ' + mw.message( 'wikilove-commons-text' ).escaped().replace( 
/\$1/, commonsLink ) + '\
                </div>\
                <label for="mw-wikilove-message" 
id="mw-wikilove-message-label"><html:msg key="wikilove-enter-message"/></label>\
                <span class="mw-wikilove-note" 
id="mw-wikilove-message-note"><html:msg key="wikilove-omit-sig"/></span>\
@@ -139,7 +133,7 @@
        <h3><html:msg key="wikilove-preview"/></h3>\
        <div id="mw-wikilove-preview-area"></div>\
        <div id="mw-wikilove-terms">\
-       ' + mw.html.escape( mw.msg( 'wikilove-terms' ) ).replace( /\$1/, 
termsLink ) + '\
+       ' + mw.message( 'wikilove-terms' ).escaped().replace( /\$1/, termsLink 
) + '\
        </div>\
        <form id="mw-wikilove-send-form">\
                <button class="submit mw-ui-button mw-ui-constructive" 
id="mw-wikilove-button-send" type="submit"></button>\
@@ -151,13 +145,13 @@
                        $dialog.localize();
 
                        $dialog.dialog({
-                                       width: 800,
-                                       position: ['center', 80],
-                                       autoOpen: false,
-                                       title: mw.msg( 'wikilove-dialog-title' 
),
-                                       modal: true,
-                                       resizable: false
-                               });
+                               width: 800,
+                               position: ['center', 80],
+                               autoOpen: false,
+                               title: mw.msg( 'wikilove-dialog-title' ),
+                               modal: true,
+                               resizable: false
+                       });
                        $dialog.parent().attr( 'id', 'mw-wikilove-overlay' );
 
                        $( '#mw-wikilove-button-preview' ).text( mw.msg( 
'wikilove-button-preview' ) );
@@ -171,7 +165,7 @@
                        $( '#mw-wikilove-preview-form' ).submit( 
$.wikiLove.validatePreviewForm );
                        $( '#mw-wikilove-send-form' ).click( 
$.wikiLove.submitSend );
 
-                       if ( mw.config.get( 'wikilove-anon' ) === 0 ) {
+                       if ( !mw.config.get( 'wikilove-anon' ) ) {
                                $( '#mw-wikilove-anon-warning' ).hide();
                        }
 
@@ -532,7 +526,7 @@
                msg = msg.replace( '$4', currentTypeOrSubtype.imageSize || 
options.defaultImageSize ); // replace the image size
                msg = msg.replace( '$5', currentTypeOrSubtype.backgroundColor 
|| options.defaultBackgroundColor ); // replace the background color
                msg = msg.replace( '$6', currentTypeOrSubtype.borderColor || 
options.defaultBorderColor ); // replace the border color
-               msg = msg.replace( '$7', '<nowiki>' + mw.config.get( 
'wikilove-recipient' ) + '</nowiki>' ); // replace the username we're sending to
+               msg = msg.replace( '$7', '<nowiki>' + mw.config.get( 
'wikilove-recipient', '' ) + '</nowiki>' ); // replace the username we're 
sending to
 
                return msg;
        },
diff --git a/resources/ext.wikiLove.icon.css b/resources/ext.wikiLove.icon.css
index 318a5fc..2798ade 100644
--- a/resources/ext.wikiLove.icon.css
+++ b/resources/ext.wikiLove.icon.css
@@ -1,23 +1,5 @@
-/* include fix from r87101 here for older versions; these three blocks can 
become deprecated later */
-div.vectorTabs span {
-       display: inline-block;
-       /* @embed */
-       background-image: url(images/tab-break.png);
-       background-position: bottom right;
-       background-repeat: no-repeat;
-}
-
-div.vectorTabs li a {
-       background-image: none;
-}
-
 div.vectorTabs li#ca-wikilove {
        line-height: 1.4em; /* account for scripts with tall ascenders */
-}
-
-#ca-unwatch.icon,
-#ca-watch.icon {
-       margin-right: 0;
 }
 
 /* icon style */
@@ -30,16 +12,11 @@
        /* This hides the text but shows the background image */
        padding-top: 3.1em;
        margin-top: 0;
-       /* Only applied in IE6 */
-       margin-top: -0.8em !ie;
        height: 0;
        overflow: hidden;
-       /* @embed */
        background-image: url(images/heart-icons-red.png);
        /* SVG support using a transparent gradient to guarantee cross-browser
        * compatibility (browsers able to understand gradient syntax support 
also SVG) */
-       /* @embed */
-       background-image: -webkit-linear-gradient(transparent, transparent), 
url(images/heart-icons-red.svg);
        /* @embed */
        background-image: linear-gradient(transparent, transparent), 
url(images/heart-icons-red.svg);
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I696619aacf6dc06a14dfdc7eb6e463a56ebd2655
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/WikiLove
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Kaldari <rkald...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to