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

Change subject: Hide metadata top button texts
......................................................................


Hide metadata top button texts

Also make sure that the reuse dialog is positioned right, no
matter where its button is.

Also fixes some minor documentation problem with mw.mmv.ui.canvas
which I noticed in the process.

Change-Id: I86feed07738ebef012e63861ed909f3449b85a53
---
M MultimediaViewer.php
M resources/mmv/ui/mmv.ui.canvas.js
M resources/mmv/ui/mmv.ui.metadataPanel.js
M resources/mmv/ui/mmv.ui.reuse.dialog.js
M resources/mmv/ui/mmv.ui.reuse.dialog.less
M resources/mmv/ui/mmv.ui.stripeButtons.js
M tests/qunit/mmv/ui/mmv.ui.stripeButtons.test.js
7 files changed, 72 insertions(+), 14 deletions(-)

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



diff --git a/MultimediaViewer.php b/MultimediaViewer.php
index aac211e..177e81d 100644
--- a/MultimediaViewer.php
+++ b/MultimediaViewer.php
@@ -321,6 +321,7 @@
                        'multimediaviewer-description-page-button-text',
                        'multimediaviewer-description-page-popup-text',
                        'multimediaviewer-description-page-popup-text-local',
+                       'multimediaviewer-reuse-link',
                ),
        ), $moduleInfo( 'mmv/ui' ) );
 
@@ -477,10 +478,6 @@
                        'mmv.ui.reuse.share',
                        'mmv.ui.reuse.embed',
                        'mmv.ui.reuse.download',
-               ),
-
-               'messages' => array(
-                       'multimediaviewer-reuse-link',
                ),
        ), $moduleInfo( 'mmv/ui' ) );
 
diff --git a/resources/mmv/ui/mmv.ui.canvas.js 
b/resources/mmv/ui/mmv.ui.canvas.js
index c3bd369..80d6725 100644
--- a/resources/mmv/ui/mmv.ui.canvas.js
+++ b/resources/mmv/ui/mmv.ui.canvas.js
@@ -72,10 +72,18 @@
        oo.inheritClass( Canvas, mw.mmv.ui.Element );
        C = Canvas.prototype;
 
-       /** Maximum blownup factor tolerated */
+       /**
+        * Maximum blownup factor tolerated
+        * @property mw.mmv.ui.Canvas.MAX_BLOWUP_FACTOR
+        * @static
+        */
        Canvas.MAX_BLOWUP_FACTOR = 11;
 
-       /** Blowup factor threshold at which blurring kicks in */
+       /**
+        * Blowup factor threshold at which blurring kicks in
+        * @property mw.mmv.ui.Canvas.BLUR_BLOWUP_FACTOR_THRESHOLD
+        * @static
+        */
        Canvas.BLUR_BLOWUP_FACTOR_THRESHOLD = 2;
 
        /**
diff --git a/resources/mmv/ui/mmv.ui.metadataPanel.js 
b/resources/mmv/ui/mmv.ui.metadataPanel.js
index e92b151..f5588b1 100644
--- a/resources/mmv/ui/mmv.ui.metadataPanel.js
+++ b/resources/mmv/ui/mmv.ui.metadataPanel.js
@@ -256,7 +256,7 @@
                this.initializeDatetime();
                this.initializeLocation();
 
-               this.fileReuse = new mw.mmv.ui.reuse.Dialog( this.$container );
+               this.fileReuse = new mw.mmv.ui.reuse.Dialog( this.$container, 
this.buttons.buttons.$reuse );
                this.categories = new mw.mmv.ui.Categories( this.$imageLinks );
 
                this.fileUsage = new mw.mmv.ui.FileUsage(
diff --git a/resources/mmv/ui/mmv.ui.reuse.dialog.js 
b/resources/mmv/ui/mmv.ui.reuse.dialog.js
index 974b4d8..deac92d 100644
--- a/resources/mmv/ui/mmv.ui.reuse.dialog.js
+++ b/resources/mmv/ui/mmv.ui.reuse.dialog.js
@@ -24,9 +24,12 @@
         * @class mw.mmv.ui.reuse.Dialog
         * @extends mw.mmv.ui.Element
         * @param {jQuery} $container the element to which the dialog will be 
appended
+        * @param {jQuery} $openButton the button which opens the dialog. Only 
used for positioning.
         */
-       function Dialog( $container ) {
+       function Dialog( $container, $openButton ) {
                mw.mmv.ui.Element.call( this, $container );
+
+               this.$openButton = $openButton;
 
                this.$reuseDialog = $( '<div>' )
                        .addClass( 'mw-mmv-reuse-dialog' );
@@ -173,16 +176,25 @@
        };
 
        /**
+        * @event mmv-reuse-opened
+        * Fired when the dialog is opened.
+        */
+       /**
         * Opens a dialog with information about file reuse.
         */
        DP.openDialog = function () {
                this.startListeningToOutsideClick();
                this.$reuseDialog.show();
+               this.fixDownArrowPosition();
                $( document ).trigger( 'mmv-reuse-opened' );
                this.isOpen = true;
                this.tabs[this.selectedTab].show();
        };
 
+       /**
+        * @event mmv-reuse-closed
+        * Fired when the dialog is closed.
+        */
        /**
         * Closes the reuse dialog.
         */
@@ -219,5 +231,27 @@
                $( document ).off( 'click.mmv', this.outsideClickHandler );
        };
 
+       /**
+        * Fixes the tip of the container to point to the icon which opens it.
+        */
+       DP.fixDownArrowPosition = function() {
+               var buttonPosition,
+                       arrowPositionBase,
+                       buttonWidth,
+                       arrowWidth,
+                       offset;
+
+               buttonPosition = this.$openButton.offset().left;
+               arrowPositionBase = 
this.$downArrow.offsetParent().offset().left;
+               buttonWidth = this.$openButton.outerWidth();
+               arrowWidth = this.$downArrow.outerWidth();
+
+               // this is the correct position of the arrow relative to the 
viewport - we want
+               // the middle of the arrow to be positioned over the middle of 
the button
+               offset = buttonPosition + ( buttonWidth - arrowWidth ) / 2;
+
+               this.$downArrow.css( 'left', ( offset - arrowPositionBase ) + 
'px' );
+       };
+
        mw.mmv.ui.reuse.Dialog = Dialog;
 }( mediaWiki, jQuery, OO ) );
diff --git a/resources/mmv/ui/mmv.ui.reuse.dialog.less 
b/resources/mmv/ui/mmv.ui.reuse.dialog.less
index 2f87168..75dc386 100644
--- a/resources/mmv/ui/mmv.ui.reuse.dialog.less
+++ b/resources/mmv/ui/mmv.ui.reuse.dialog.less
@@ -76,7 +76,7 @@
                border-bottom: @arrow-border-size solid @arrow-border-color;
                .rotate(45deg);
                position: absolute;
-               right: 60px;
+               // horizontal positioning will be done in JS
                bottom: -1 * ( @arrow-size / 2 ) - @arrow-border-size;
        }
 }
diff --git a/resources/mmv/ui/mmv.ui.stripeButtons.js 
b/resources/mmv/ui/mmv.ui.stripeButtons.js
index 0328315..d898f0b 100644
--- a/resources/mmv/ui/mmv.ui.stripeButtons.js
+++ b/resources/mmv/ui/mmv.ui.stripeButtons.js
@@ -58,7 +58,7 @@
        SBP.createButton = function ( cssClass, text, popupText ) {
                return $( '<a>' )
                        .addClass( 'mw-mmv-stripe-button empty ' + cssClass )
-                       .text( text )
+                       // .text( text ) // disabled while we have 3 buttons to 
save space
                        .prop( 'title', popupText )
                        // elements are right-floated so we use prepend instead 
of append to keep the order
                        .prependTo( this.$buttonContainer )
@@ -72,10 +72,15 @@
        SBP.initReuseButton = function() {
                this.buttons.$reuse = this.createButton(
                        'mw-mmv-stripe-button-reuse',
+                       mw.message( 'multimediaviewer-reuse-link' ).text(),
                        mw.message( 'multimediaviewer-reuse-link' ).text()
                );
        };
 
+       /**
+        * @protected
+        * Creates a button linking to the file description page.
+        */
        SBP.initDescriptionPageButton = function() {
                this.buttons.$descriptionPage = this.createButton(
                        'mw-mmv-stripe-button-commons',
@@ -103,6 +108,11 @@
                } );
        };
 
+       /**
+        * Generates a survey URL (currently constant but the possibility of 
splitting by
+        * editor cohort was mentioned).
+        * @return {string}
+        */
        SBP.getFeedbackSurveyUrl = function () {
                return 
'https://www.surveymonkey.com/s/media-viewer-1?c=mediaviewer';
        };
@@ -224,6 +234,10 @@
        };
 
        /**
+        * @event mmv-reuse-open
+        * Fired when the buttonto open the reuse dialog is clicked.
+        */
+       /**
         * Registers listeners.
         */
        SBP.attach = function () {
diff --git a/tests/qunit/mmv/ui/mmv.ui.stripeButtons.test.js 
b/tests/qunit/mmv/ui/mmv.ui.stripeButtons.test.js
index 7c09c76..0105907 100644
--- a/tests/qunit/mmv/ui/mmv.ui.stripeButtons.test.js
+++ b/tests/qunit/mmv/ui/mmv.ui.stripeButtons.test.js
@@ -18,13 +18,18 @@
 ( function( mw, $ ) {
        QUnit.module( 'mmv.ui.StripeButtons', QUnit.newMwEnvironment() );
 
+       function createStripeButtons() {
+               var fixture = $( '#qunit-fixture' );
+               return new mw.mmv.ui.StripeButtons( fixture, $( '<div>' 
).appendTo( fixture ) );
+       }
+
        QUnit.test( 'Sanity test, object creation and UI construction', 5, 
function ( assert ) {
                var buttons,
                        oldMwUserIsAnon = mw.user.isAnon;
 
                // first pretend we are anonymous
                mw.user.isAnon = function () { return true; };
-               buttons = new mw.mmv.ui.StripeButtons( $( '#qunit-fixture' ) );
+               buttons = createStripeButtons();
 
                assert.ok( buttons, 'UI element is created.' );
                assert.strictEqual( buttons.buttons.$reuse.length, 1, 'Reuse 
button created.' );
@@ -33,7 +38,7 @@
 
                // now pretend we are logged in
                mw.user.isAnon = function () { return false; };
-               buttons = new mw.mmv.ui.StripeButtons( $( '#qunit-fixture' ) );
+               buttons = createStripeButtons();
 
                assert.strictEqual( buttons.buttons.$descriptionPage.length, 1, 
'File page button created for logged in.' );
 
@@ -41,7 +46,7 @@
        } );
 
        QUnit.test( 'set()/empty() sanity test:', 1, function ( assert ) {
-               var buttons = new mw.mmv.ui.StripeButtons( $( '#qunit-fixture' 
) ),
+               var buttons = createStripeButtons(),
                        fakeImageInfo = { descriptionUrl: 
'//commons.wikimedia.org/wiki/File:Foo.jpg' },
                        fakeRepoInfo = { displayName: 'Wikimedia Commons' };
 
@@ -52,7 +57,7 @@
        } );
 
        QUnit.test( 'attach()/unattach():', 4, function ( assert ) {
-               var buttons = new mw.mmv.ui.StripeButtons( $( '#qunit-fixture' 
) );
+               var buttons = createStripeButtons();
 
                $( document ).on( 'mmv-reuse-open.test', function ( e ) {
                        assert.ok( e, 'Reuse panel opened.' );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I86feed07738ebef012e63861ed909f3449b85a53
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org>
Gerrit-Reviewer: Aarcos <aarcos.w...@gmail.com>
Gerrit-Reviewer: Gergő Tisza <gti...@wikimedia.org>
Gerrit-Reviewer: Gilles <gdu...@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