2013-10-17 17:35:16 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki UserInterface popup tool classes.
|
|
|
|
*
|
2014-01-05 12:05:05 +00:00
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
2013-10-17 17:35:16 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki UserInterface notices popup tool.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends OO.ui.PopupTool
|
|
|
|
* @constructor
|
|
|
|
* @param {OO.ui.ToolGroup} toolGroup Tool group. Must belong to a ve.ui.TargetToolbar
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
|
|
|
ve.ui.MWNoticesPopupTool = function VeUiMWNoticesPopupTool( toolGroup, config ) {
|
|
|
|
var key,
|
|
|
|
items = toolGroup.getToolbar().getTarget().getEditNotices(),
|
|
|
|
count = ve.getObjectKeys( items ).length,
|
|
|
|
title = ve.msg( 'visualeditor-editnotices-tool', count );
|
|
|
|
|
|
|
|
// Configuration initialization
|
|
|
|
config = ve.extendObject( true, { 'popup': { 'head': true, 'label': title } }, config );
|
|
|
|
|
|
|
|
// Parent constructor
|
|
|
|
OO.ui.PopupTool.call( this, toolGroup, config );
|
|
|
|
|
|
|
|
// Properties
|
2014-03-12 22:09:47 +00:00
|
|
|
this.$items = this.$( '<div>' ).addClass( 've-ui-mwNoticesPopupTool-items' );
|
2013-10-17 17:35:16 +00:00
|
|
|
|
|
|
|
// Initialization
|
|
|
|
for ( key in items ) {
|
2014-03-12 22:09:47 +00:00
|
|
|
$( items[key] )
|
2013-10-17 17:35:16 +00:00
|
|
|
.addClass( 've-ui-mwNoticesPopupTool-item' )
|
|
|
|
.find( 'a' )
|
|
|
|
.attr( 'target', '_blank' );
|
2014-03-12 22:09:47 +00:00
|
|
|
|
|
|
|
this.$items.append( items[key] );
|
|
|
|
}
|
|
|
|
|
2013-10-17 17:35:16 +00:00
|
|
|
this.popup.$body.append( this.$items );
|
|
|
|
|
|
|
|
// Automatically show/hide
|
|
|
|
if ( count ) {
|
2014-07-08 22:33:32 +00:00
|
|
|
setTimeout( function () {
|
2014-07-14 21:32:49 +00:00
|
|
|
this.popup.toggle( true );
|
2014-07-08 22:33:32 +00:00
|
|
|
}.bind( this ), 500 );
|
2013-10-17 17:35:16 +00:00
|
|
|
} else {
|
2013-11-01 19:45:59 +00:00
|
|
|
this.$element.hide();
|
2013-10-17 17:35:16 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWNoticesPopupTool, OO.ui.PopupTool );
|
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
ve.ui.MWNoticesPopupTool.static.name = 'notices';
|
|
|
|
ve.ui.MWNoticesPopupTool.static.group = 'utility';
|
|
|
|
ve.ui.MWNoticesPopupTool.static.icon = 'alert';
|
2014-02-26 23:51:54 +00:00
|
|
|
ve.ui.MWNoticesPopupTool.static.title = OO.ui.deferMsg( 'visualeditor-editnotices-tooltip' );
|
2014-03-21 18:46:02 +00:00
|
|
|
ve.ui.MWNoticesPopupTool.static.autoAddToCatchall = false;
|
|
|
|
ve.ui.MWNoticesPopupTool.static.autoAddToGroup = false;
|
2013-10-17 17:35:16 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the tool title.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWNoticesPopupTool.prototype.getTitle = function () {
|
|
|
|
var items = this.toolbar.getTarget().getEditNotices(),
|
|
|
|
count = ve.getObjectKeys( items ).length;
|
|
|
|
|
2014-02-12 21:45:37 +00:00
|
|
|
return ve.msg( this.constructor.static.title, count );
|
2013-10-17 17:35:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ui.toolFactory.register( ve.ui.MWNoticesPopupTool );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki UserInterface help popup tool.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends OO.ui.PopupTool
|
|
|
|
* @constructor
|
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
|
|
|
ve.ui.MWHelpPopupTool = function VeUiMWHelpPopupTool( toolGroup, config ) {
|
|
|
|
var title = ve.msg( 'visualeditor-help-tool' );
|
|
|
|
|
|
|
|
// Configuration initialization
|
|
|
|
config = ve.extendObject( true, { 'popup': { 'head': true, 'label': title } }, config );
|
|
|
|
|
|
|
|
// Parent constructor
|
|
|
|
OO.ui.PopupTool.call( this, toolGroup, config );
|
|
|
|
|
|
|
|
// Properties
|
2013-11-01 19:45:59 +00:00
|
|
|
this.$items = this.$( '<div>' );
|
2013-10-17 17:35:16 +00:00
|
|
|
this.feedback = null;
|
2014-01-17 14:24:12 +00:00
|
|
|
this.helpButton = new OO.ui.ButtonWidget( {
|
|
|
|
'$': this.$,
|
2014-07-14 21:32:49 +00:00
|
|
|
'framed': false,
|
2013-10-17 17:35:16 +00:00
|
|
|
'icon': 'help',
|
|
|
|
'title': ve.msg( 'visualeditor-help-title' ),
|
|
|
|
'href': new mw.Title( ve.msg( 'visualeditor-help-link' ) ).getUrl(),
|
|
|
|
'target': '_blank',
|
|
|
|
'label': ve.msg( 'visualeditor-help-label' )
|
|
|
|
} );
|
2014-05-11 22:54:58 +00:00
|
|
|
this.keyboardShortcutsButton = new OO.ui.ButtonWidget( {
|
|
|
|
'$': this.$,
|
2014-07-14 21:32:49 +00:00
|
|
|
'framed': false,
|
2014-05-11 22:54:58 +00:00
|
|
|
'icon': 'help',
|
|
|
|
'label': ve.msg( 'visualeditor-dialog-command-help-title' )
|
|
|
|
} );
|
2014-01-17 14:24:12 +00:00
|
|
|
this.feedbackButton = new OO.ui.ButtonWidget( {
|
|
|
|
'$': this.$,
|
2014-07-14 21:32:49 +00:00
|
|
|
'framed': false,
|
2013-10-17 17:35:16 +00:00
|
|
|
'icon': 'comment',
|
|
|
|
'label': ve.msg( 'visualeditor-feedback-tool' )
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Events
|
|
|
|
this.feedbackButton.connect( this, { 'click': 'onFeedbackClick' } );
|
2014-05-11 22:54:58 +00:00
|
|
|
this.keyboardShortcutsButton.connect( this, { 'click': 'onKeyboardShortcutsClick' } );
|
2013-10-17 17:35:16 +00:00
|
|
|
|
|
|
|
// Initialization
|
|
|
|
this.$items
|
|
|
|
.addClass( 've-ui-mwHelpPopupTool-items' )
|
|
|
|
.append(
|
2013-11-01 19:45:59 +00:00
|
|
|
this.$( '<div>' )
|
2013-10-17 17:35:16 +00:00
|
|
|
.addClass( 've-ui-mwHelpPopupTool-item' )
|
|
|
|
.text( ve.msg( 'visualeditor-beta-warning' ) )
|
|
|
|
)
|
|
|
|
.append(
|
2013-11-01 19:45:59 +00:00
|
|
|
this.$( '<div>' )
|
2013-10-17 17:35:16 +00:00
|
|
|
.addClass( 've-ui-mwHelpPopupTool-item' )
|
2013-11-01 19:45:59 +00:00
|
|
|
.append( this.helpButton.$element )
|
2014-05-11 22:54:58 +00:00
|
|
|
.append( this.keyboardShortcutsButton.$element )
|
2013-11-01 19:45:59 +00:00
|
|
|
.append( this.feedbackButton.$element )
|
2013-10-17 17:35:16 +00:00
|
|
|
);
|
|
|
|
if ( ve.version.id !== false ) {
|
|
|
|
this.$items
|
2013-11-01 19:45:59 +00:00
|
|
|
.append( this.$( '<div>' )
|
2013-10-17 17:35:16 +00:00
|
|
|
.addClass( 've-ui-mwHelpPopupTool-item' )
|
2013-11-01 19:45:59 +00:00
|
|
|
.append( this.$( '<span>' )
|
2013-10-17 17:35:16 +00:00
|
|
|
.addClass( 've-ui-mwHelpPopupTool-version-label' )
|
|
|
|
.text( ve.msg( 'visualeditor-version-label' ) )
|
|
|
|
)
|
|
|
|
.append( ' ' )
|
2013-11-01 19:45:59 +00:00
|
|
|
.append( this.$( '<a>' )
|
2013-10-17 17:35:16 +00:00
|
|
|
.addClass( 've-ui-mwHelpPopupTool-version-link' )
|
|
|
|
.attr( 'target', '_blank' )
|
|
|
|
.attr( 'href', ve.version.url )
|
|
|
|
.text( ve.version.id )
|
|
|
|
)
|
|
|
|
.append( ' ' )
|
2013-11-01 19:45:59 +00:00
|
|
|
.append( this.$( '<span>' )
|
2013-10-17 17:35:16 +00:00
|
|
|
.addClass( 've-ui-mwHelpPopupTool-version-date' )
|
|
|
|
.text( ve.version.dateString )
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
this.$items.find( 'a' ).attr( 'target', '_blank' );
|
|
|
|
this.popup.$body.append( this.$items );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWHelpPopupTool, OO.ui.PopupTool );
|
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
ve.ui.MWHelpPopupTool.static.name = 'help';
|
|
|
|
ve.ui.MWHelpPopupTool.static.group = 'utility';
|
|
|
|
ve.ui.MWHelpPopupTool.static.icon = 'help';
|
2014-02-12 21:45:37 +00:00
|
|
|
ve.ui.MWHelpPopupTool.static.title = OO.ui.deferMsg( 'visualeditor-help-tool' );
|
2014-03-21 18:46:02 +00:00
|
|
|
ve.ui.MWHelpPopupTool.static.autoAddToCatchall = false;
|
|
|
|
ve.ui.MWHelpPopupTool.static.autoAddToGroup = false;
|
2013-10-17 17:35:16 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle clicks on the feedback button.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.ui.MWHelpPopupTool.prototype.onFeedbackClick = function () {
|
2014-07-14 21:32:49 +00:00
|
|
|
this.popup.toggle( false );
|
2013-10-17 17:35:16 +00:00
|
|
|
if ( !this.feedback ) {
|
|
|
|
// This can't be constructed until the editor has loaded as it uses special messages
|
|
|
|
this.feedback = new mw.Feedback( {
|
|
|
|
'title': new mw.Title( ve.msg( 'visualeditor-feedback-link' ) ),
|
|
|
|
'bugsLink': new mw.Uri( 'https://bugzilla.wikimedia.org/enter_bug.cgi?product=VisualEditor&component=General' ),
|
|
|
|
'bugsListLink': new mw.Uri( 'https://bugzilla.wikimedia.org/buglist.cgi?query_format=advanced&resolution=---&resolution=LATER&resolution=DUPLICATE&product=VisualEditor&list_id=166234' )
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
this.feedback.launch();
|
|
|
|
};
|
|
|
|
|
2014-05-11 22:54:58 +00:00
|
|
|
/**
|
|
|
|
* Handle clicks on the keyboard shortcuts button.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.ui.MWHelpPopupTool.prototype.onKeyboardShortcutsClick = function () {
|
2014-07-14 21:32:49 +00:00
|
|
|
this.popup.toggle( false );
|
2014-05-11 22:54:58 +00:00
|
|
|
ve.ui.commandRegistry.lookup( 'commandHelp' ).execute( this.toolbar.getSurface() );
|
|
|
|
};
|
|
|
|
|
2013-10-17 17:35:16 +00:00
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ui.toolFactory.register( ve.ui.MWHelpPopupTool );
|