2013-10-17 17:35:16 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki UserInterface popup tool classes.
|
|
|
|
*
|
2015-01-08 23:54:03 +00:00
|
|
|
* @copyright 2011-2015 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
|
2014-08-22 20:50:48 +00:00
|
|
|
config = ve.extendObject( true, { popup: { head: true, label: title } }, config );
|
2013-10-17 17:35:16 +00:00
|
|
|
|
|
|
|
// 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 );
|
|
|
|
|
2015-01-16 07:21:15 +00:00
|
|
|
if ( !count ) {
|
2014-11-25 14:17:53 +00:00
|
|
|
this.$element = $( [] );
|
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
|
2014-08-22 20:50:48 +00:00
|
|
|
config = ve.extendObject( true, { popup: { head: true, label: title } }, config );
|
2013-10-17 17:35:16 +00:00
|
|
|
|
|
|
|
// Parent constructor
|
|
|
|
OO.ui.PopupTool.call( this, toolGroup, config );
|
|
|
|
|
|
|
|
// Properties
|
2013-11-01 19:45:59 +00:00
|
|
|
this.$items = this.$( '<div>' );
|
2015-02-23 19:37:03 +00:00
|
|
|
this.feedbackPromise = null;
|
2014-01-17 14:24:12 +00:00
|
|
|
this.helpButton = new OO.ui.ButtonWidget( {
|
2014-08-22 20:50:48 +00:00
|
|
|
$: this.$,
|
|
|
|
framed: false,
|
|
|
|
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' )
|
2013-10-17 17:35:16 +00:00
|
|
|
} );
|
2014-05-11 22:54:58 +00:00
|
|
|
this.keyboardShortcutsButton = new OO.ui.ButtonWidget( {
|
2014-08-22 20:50:48 +00:00
|
|
|
$: this.$,
|
|
|
|
framed: false,
|
|
|
|
icon: 'help',
|
|
|
|
label: ve.msg( 'visualeditor-dialog-command-help-title' )
|
2014-05-11 22:54:58 +00:00
|
|
|
} );
|
2014-01-17 14:24:12 +00:00
|
|
|
this.feedbackButton = new OO.ui.ButtonWidget( {
|
2014-08-22 20:50:48 +00:00
|
|
|
$: this.$,
|
|
|
|
framed: false,
|
|
|
|
icon: 'comment',
|
|
|
|
label: ve.msg( 'visualeditor-feedback-tool' )
|
2013-10-17 17:35:16 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
// Events
|
2014-08-22 20:50:48 +00:00
|
|
|
this.feedbackButton.connect( this, { click: 'onFeedbackClick' } );
|
|
|
|
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 );
|
2015-02-23 19:37:03 +00:00
|
|
|
if ( !this.feedbackPromise ) {
|
|
|
|
this.feedbackPromise = mw.loader.using( 'mediawiki.feedback' ).then( function () {
|
|
|
|
// This can't be constructed until the editor has loaded as it uses special messages
|
|
|
|
return new mw.Feedback( {
|
|
|
|
title: new mw.Title( ve.msg( 'visualeditor-feedback-link' ) ),
|
|
|
|
bugsLink: new mw.Uri( 'https://phabricator.wikimedia.org/maniphest/task/create/?projects=VisualEditor' ),
|
2015-03-03 18:44:11 +00:00
|
|
|
bugsListLink: new mw.Uri( 'https://phabricator.wikimedia.org/maniphest/query/eSHgNozkIsuv/' ),
|
|
|
|
showUseragentCheckbox: true,
|
|
|
|
useragentCheckboxMandatory: true
|
2015-02-23 19:37:03 +00:00
|
|
|
} );
|
2013-10-17 17:35:16 +00:00
|
|
|
} );
|
|
|
|
}
|
2015-02-23 19:37:03 +00:00
|
|
|
this.feedbackPromise.done( function ( feedback ) {
|
|
|
|
feedback.launch();
|
|
|
|
} );
|
2013-10-17 17:35:16 +00:00
|
|
|
};
|
|
|
|
|
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 );
|