Merge "Make the "show help" button a OOjs ButtonWidget"

This commit is contained in:
jenkins-bot 2016-08-09 08:08:42 +00:00 committed by Gerrit Code Review
commit fe9a7f39c5
6 changed files with 26 additions and 32 deletions

View file

@ -93,7 +93,9 @@
], ],
"dependencies": [ "dependencies": [
"jquery.ui.draggable", "jquery.ui.draggable",
"oojs-ui",
"ext.RevisionSlider.DiffPage", "ext.RevisionSlider.DiffPage",
"ext.RevisionSlider.HelpDialog",
"ext.RevisionSlider.Pointer" "ext.RevisionSlider.Pointer"
], ],
"messages": [ "messages": [

View file

@ -20,7 +20,6 @@
"revisionslider-loading-failed": "The RevisionSlider failed to load.", "revisionslider-loading-failed": "The RevisionSlider failed to load.",
"revisionslider-arrow-tooltip-newer": "See newer revisions", "revisionslider-arrow-tooltip-newer": "See newer revisions",
"revisionslider-arrow-tooltip-older": "See older revisions", "revisionslider-arrow-tooltip-older": "See older revisions",
"revisionslider-show-help": "?",
"revisionslider-show-help-tooltip": "Show help text", "revisionslider-show-help-tooltip": "Show help text",
"revisionslider-help-dialog-slide1": "The RevisionSlider helps you to navigate and compare revisions on the diff page. It is based on a [[m:WMDE_Technical_Wishes/RevisionSlider|community wish]] from the German-speaking community technical wishlist.", "revisionslider-help-dialog-slide1": "The RevisionSlider helps you to navigate and compare revisions on the diff page. It is based on a [[m:WMDE_Technical_Wishes/RevisionSlider|community wish]] from the German-speaking community technical wishlist.",
"revisionslider-help-dialog-slide2": "Each bar represents a page revision. Bars on the top show growth in size of the page, bars on the bottom show a reduction. In the image, revision 1 represents added content, while revision 2 represents removal of content.", "revisionslider-help-dialog-slide2": "Each bar represents a page revision. Bars on the top show growth in size of the page, bars on the bottom show a reduction. In the image, revision 1 represents added content, while revision 2 represents removal of content.",

View file

@ -22,7 +22,6 @@
"revisionslider-loading-failed": "Message shown if the RevisionSlider fails to initially load.", "revisionslider-loading-failed": "Message shown if the RevisionSlider fails to initially load.",
"revisionslider-arrow-tooltip-newer": "Text shown after hovering the button scrolling to newer revisions.", "revisionslider-arrow-tooltip-newer": "Text shown after hovering the button scrolling to newer revisions.",
"revisionslider-arrow-tooltip-older": "Text shown after hovering the button scrolling to older revisions.", "revisionslider-arrow-tooltip-older": "Text shown after hovering the button scrolling to older revisions.",
"revisionslider-show-help": "A symbol shown in the \"Show help\" button.",
"revisionslider-show-help-tooltip": "Text shown in a tooltip for the \"Show help\" button.", "revisionslider-show-help-tooltip": "Text shown in a tooltip for the \"Show help\" button.",
"revisionslider-help-dialog-slide1": "Text shown on the first slide of the help dialog.", "revisionslider-help-dialog-slide1": "Text shown on the first slide of the help dialog.",
"revisionslider-help-dialog-slide2": "Text shown on the second slide of the help dialog.", "revisionslider-help-dialog-slide2": "Text shown on the second slide of the help dialog.",

View file

@ -13,7 +13,7 @@
$.extend( SliderView.prototype, { $.extend( SliderView.prototype, {
revisionWidth: 16, revisionWidth: 16,
containerMargin: 120, containerMargin: 140,
/** /**
* @type {jQuery} * @type {jQuery}
@ -70,6 +70,7 @@
$slider = $( '<div>' ) $slider = $( '<div>' )
.addClass( 'mw-revslider-revision-slider' ) .addClass( 'mw-revslider-revision-slider' )
.css( { direction: $container.css( 'direction' ) } ), .css( { direction: $container.css( 'direction' ) } ),
helpButton,
self = this; self = this;
if ( $slider.css( 'direction' ) === 'rtl' ) { if ( $slider.css( 'direction' ) === 'rtl' ) {
@ -79,6 +80,23 @@
this.pointerOlder = new mw.libs.revisionSlider.Pointer( 'mw-revslider-pointer-older' ); this.pointerOlder = new mw.libs.revisionSlider.Pointer( 'mw-revslider-pointer-older' );
this.pointerNewer = new mw.libs.revisionSlider.Pointer( 'mw-revslider-pointer-newer' ); this.pointerNewer = new mw.libs.revisionSlider.Pointer( 'mw-revslider-pointer-newer' );
helpButton = new OO.ui.ButtonWidget( {
icon: 'help',
framed: false,
classes: [ 'mw-revslider-show-help' ]
} );
helpButton.$element
.click( function () {
mw.libs.revisionSlider.HelpDialog.show();
} )
.tipsy( {
gravity: $( 'body' ).hasClass( 'ltr' ) ? 'se' : 'sw',
offset: 15,
title: function () {
return mw.msg( 'revisionslider-show-help-tooltip' );
}
} );
pointerContainerStyle = { left: pointerContainerPosition + 'px', width: pointerContainerWidth + 'px' }; pointerContainerStyle = { left: pointerContainerPosition + 'px', width: pointerContainerWidth + 'px' };
if ( $slider.css( 'direction' ) === 'rtl' ) { if ( $slider.css( 'direction' ) === 'rtl' ) {
// Due to properly limit dragging a pointer on the right side of the screen, // Due to properly limit dragging a pointer on the right side of the screen,
@ -127,6 +145,7 @@
return mw.message( 'revisionslider-arrow-tooltip-newer' ).text(); return mw.message( 'revisionslider-arrow-tooltip-newer' ).text();
} }
} ), } ),
helpButton.$element,
$( '<div>' ).css( { clear: 'both' } ), $( '<div>' ).css( { clear: 'both' } ),
$( '<div>' ) $( '<div>' )
.addClass( 'mw-revslider-pointer-container' ) .addClass( 'mw-revslider-pointer-container' )

View file

@ -232,16 +232,7 @@
.mw-revslider-show-help { .mw-revslider-show-help {
position: absolute; position: absolute;
right: -18px; right: 0;
bottom: 7px; bottom: 0;
color: #347bff; margin-right: 0;
border: 2px solid #347bff;
padding: 0;
background: #fff;
font-size: 15px;
line-height: 15px;
font-weight: bold;
cursor: pointer;
height: 25px;
width: 25px;
} }

View file

@ -7,7 +7,7 @@
api.fetchRevisionData( mw.config.get( 'wgPageName' ), { api.fetchRevisionData( mw.config.get( 'wgPageName' ), {
startId: mw.config.values.extRevisionSliderNewRev, startId: mw.config.values.extRevisionSliderNewRev,
limit: mw.libs.revisionSlider.calculateRevisionsPerWindow( 120, 16 ), limit: mw.libs.revisionSlider.calculateRevisionsPerWindow( 140, 16 ),
success: function ( data ) { success: function ( data ) {
var revs, var revs,
@ -32,22 +32,6 @@
( new mw.Api() ).saveOption( 'userjs-revslider-hidehelp', true ); ( new mw.Api() ).saveOption( 'userjs-revslider-hidehelp', true );
} }
$container.append(
$( '<button>' )
.click( function () {
mw.libs.revisionSlider.HelpDialog.show();
} )
.text( mw.message( 'revisionslider-show-help' ).text() )
.addClass( 'mw-revslider-show-help' )
.tipsy( {
gravity: $( 'body' ).hasClass( 'ltr' ) ? 'se' : 'sw',
offset: 15,
title: function () {
return mw.msg( 'revisionslider-show-help-tooltip' );
}
} )
);
$( '#mw-revslider-placeholder' ).remove(); $( '#mw-revslider-placeholder' ).remove();
mw.track( 'timing.MediaWiki.RevisionSlider.timing.init', mw.now() - startTime ); mw.track( 'timing.MediaWiki.RevisionSlider.timing.init', mw.now() - startTime );
} catch ( err ) { } catch ( err ) {