Change "view terms" to "hide terms" once clicked

metadataPanel overrides the grow() and shrink() methods in Permission
class instance, so the text is changed also when user clicks the
"view more" link inside the box.

Bug: T71233
Change-Id: I66fe57980c6f469d86e3d52b67d01e06a3a14270
This commit is contained in:
m4tx 2014-12-28 22:19:42 +01:00
parent ed5d49f1b6
commit dac77cafc4
6 changed files with 43 additions and 3 deletions

View file

@ -594,6 +594,7 @@ $wgResourceModules += array(
// for license messages see end of file
'multimediaviewer-permission-link',
'multimediaviewer-permission-link-hide',
'multimediaviewer-geoloc-north',
'multimediaviewer-geoloc-east',

View file

@ -38,6 +38,7 @@
"multimediaviewer-license-default": "View license",
"multimediaviewer-permission-title": "Permission details",
"multimediaviewer-permission-link": "view terms",
"multimediaviewer-permission-link-hide": "hide terms",
"multimediaviewer-permission-viewmore": "View more",
"multimediaviewer-about-mmv": "About Media Viewer",
"multimediaviewer-discuss-mmv": "Discuss this feature",

View file

@ -44,7 +44,8 @@
"multimediaviewer-license-pd": "Very short label for Public Domain images, used in a link to the file information page that has more licensing information.\n{{Identical|Public domain}}",
"multimediaviewer-license-default": "Short label for a link to generic license information.",
"multimediaviewer-permission-title": "Title of the box containing additional permission (by the copyright owner via OTRS) terms",
"multimediaviewer-permission-link": "Text of the link (on top of the metadata box) which shows additional permission (by the copyright owner via OTRS) terms",
"multimediaviewer-permission-link": "Text of the link (on top of the metadata box) which shows additional permission (by the copyright owner via OTRS) terms\n\nSee also:\n* {{msg-mw|multimediaviewer-permission-link-hide}}",
"multimediaviewer-permission-link-hide": "Text of the link (on top of the metadata box) which hides additional permission terms\n\nSee also:\n* {{msg-mw|multimediaviewer-permission-link}}",
"multimediaviewer-permission-viewmore": "Text of the link (at the cutoff of the permission term preview) which shows additional permission (by the copyright owner via OTRS) terms.\n{{Identical|View more}}",
"multimediaviewer-about-mmv": "Text for a link to a page with more information about Media Viewer software.",
"multimediaviewer-discuss-mmv": "Text for a link to a page where the user can discuss the Media Viewer software.",

View file

@ -104,6 +104,12 @@
}
} ).on( 'mouseenter.mmv-mp', function () {
clearTimeout( panel.panelShrinkTimeout );
} ).on( 'mmv-permission-grow.mmv-mp', function() {
panel.$permissionLink
.text( mw.message( 'multimediaviewer-permission-link-hide' ).text() );
} ).on( 'mmv-permission-shrink.mmv-mp', function() {
panel.$permissionLink
.text( mw.message( 'multimediaviewer-permission-link' ).text() );
} );
this.handleEvent( 'jq-fullscreen-change.lip', function() {
@ -321,8 +327,12 @@
.appendTo( this.$licenseLi )
.hide()
.on( 'click', function() {
panel.permission.grow();
panel.scroller.toggle( 'up' );
if ( panel.permission.isFullSize() ) {
panel.permission.shrink();
} else {
panel.permission.grow();
panel.scroller.toggle( 'up' );
}
return false;
} );
};

View file

@ -135,6 +135,7 @@
/**
* Enlarge the box, show HTML instead of text.
* @fires mmv-permission-grow
*/
P.grow = function() {
mw.mmv.actionLogger.log( 'terms-open' );
@ -143,13 +144,24 @@
.stop( true )
.animate( { backgroundColor: '#FFFFA0' }, 500)
.animate( { backgroundColor: '#FFFFFF' }, 500);
this.$container.trigger( 'mmv-permission-grow' );
};
/**
* Limit the size of the box, show text only.
* @fires mmv-permission-shrink
*/
P.shrink = function() {
this.$box.removeClass( 'full-size' );
this.$container.trigger( 'mmv-permission-shrink' );
};
/**
* Returns whether the box is full-size.
* @returns boolean
*/
P.isFullSize = function() {
return this.$box.hasClass( 'full-size' );
};
mw.mmv.ui.Permission = Permission;

View file

@ -101,4 +101,19 @@
$.fn.animate = oldAnimate;
} );
QUnit.test( 'isFullSize()', 3, function( assert ) {
var $qf = $( '#qunit-fixture' ),
permission = new mw.mmv.ui.Permission( $qf ),
text = 'Nothing to see here.';
// animation would keep running, conflict with other tests
this.sandbox.stub( $.fn, 'animate' ).returnsThis();
permission.set( text );
assert.ok( !permission.isFullSize(), 'permission is not full-size' );
permission.grow();
assert.ok( permission.isFullSize(), 'permission is full-size' );
permission.shrink();
assert.ok( !permission.isFullSize(), 'permission is not full-size again' );
} );
}( mediaWiki, jQuery ) );