2013-10-07 10:01:43 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MWSaveDialog class.
|
|
|
|
*
|
2014-01-05 12:05:05 +00:00
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
2013-10-07 10:01:43 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*global mw */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dialog for saving MediaWiki articles.
|
|
|
|
*
|
2013-11-14 23:14:16 +00:00
|
|
|
* Note that most methods are not safe to call before the dialog has initialized, except where
|
|
|
|
* noted otherwise.
|
|
|
|
*
|
2013-10-07 10:01:43 +00:00
|
|
|
* @class
|
2014-04-04 17:42:13 +00:00
|
|
|
* @extends ve.ui.Dialog
|
2013-10-07 10:01:43 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} [config] Config options
|
|
|
|
*/
|
2014-04-04 17:42:13 +00:00
|
|
|
ve.ui.MWSaveDialog = function VeUiMWSaveDialog( config ) {
|
2013-10-07 10:01:43 +00:00
|
|
|
// Parent constructor
|
2014-04-04 17:42:13 +00:00
|
|
|
ve.ui.Dialog.call( this, config );
|
2013-10-07 10:01:43 +00:00
|
|
|
|
|
|
|
// Properties
|
|
|
|
this.sanityCheckVerified = false;
|
|
|
|
this.editSummaryByteLimit = 255;
|
|
|
|
this.restoring = false;
|
|
|
|
this.messages = {};
|
2013-11-14 23:14:16 +00:00
|
|
|
this.setupDeferred = $.Deferred();
|
2014-05-19 16:23:38 +00:00
|
|
|
|
|
|
|
// Events
|
|
|
|
this.connect( this, { 'ready': 'onReady' } );
|
2013-10-07 10:01:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2014-04-04 17:42:13 +00:00
|
|
|
OO.inheritClass( ve.ui.MWSaveDialog, ve.ui.Dialog );
|
2013-10-07 10:01:43 +00:00
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
ve.ui.MWSaveDialog.static.name = 'mwSave';
|
|
|
|
|
2014-02-12 21:45:37 +00:00
|
|
|
ve.ui.MWSaveDialog.static.title =
|
|
|
|
OO.ui.deferMsg( 'visualeditor-savedialog-title-save' );
|
2013-10-07 10:01:43 +00:00
|
|
|
|
2013-11-14 23:14:16 +00:00
|
|
|
/* Events */
|
2013-10-07 10:01:43 +00:00
|
|
|
|
2013-11-14 23:14:16 +00:00
|
|
|
/**
|
|
|
|
* @event save
|
|
|
|
* Emitted when the user clicks the save button
|
|
|
|
*/
|
2013-10-07 10:01:43 +00:00
|
|
|
|
2013-11-14 23:14:16 +00:00
|
|
|
/**
|
|
|
|
* @event review
|
|
|
|
* Emitted when the user clicks the review changes button
|
|
|
|
*/
|
2013-10-07 10:01:43 +00:00
|
|
|
|
2013-11-14 23:14:16 +00:00
|
|
|
/**
|
|
|
|
* @event resolve
|
|
|
|
* Emitted when the user clicks the resolve conflict button
|
|
|
|
*/
|
2013-10-07 10:01:43 +00:00
|
|
|
|
2013-11-14 23:14:16 +00:00
|
|
|
/* Methods */
|
2013-10-07 10:01:43 +00:00
|
|
|
|
2013-11-05 00:29:50 +00:00
|
|
|
/**
|
2013-11-14 23:14:16 +00:00
|
|
|
* Set review content and show review panel.
|
2013-11-05 00:29:50 +00:00
|
|
|
*
|
|
|
|
* @param {string} content Diff HTML or wikitext
|
|
|
|
*/
|
|
|
|
ve.ui.MWSaveDialog.prototype.setDiffAndReview = function ( content ) {
|
|
|
|
this.$reviewViewer.empty().append( content );
|
|
|
|
this.reviewGoodButton.setDisabled( false );
|
2014-04-18 20:32:25 +00:00
|
|
|
this.popPending();
|
2013-11-05 00:29:50 +00:00
|
|
|
this.swapPanel( 'review' );
|
|
|
|
};
|
|
|
|
|
2013-11-14 23:14:16 +00:00
|
|
|
/**
|
|
|
|
* Clear the diff displayed in the review panel, if any.
|
|
|
|
*/
|
|
|
|
ve.ui.MWSaveDialog.prototype.clearDiff = function () {
|
|
|
|
this.$reviewViewer.empty();
|
|
|
|
};
|
|
|
|
|
2013-11-05 00:29:50 +00:00
|
|
|
/**
|
|
|
|
* Set sanity check flag
|
|
|
|
*
|
|
|
|
* @param {boolean} verified Status of sanity check
|
|
|
|
*/
|
|
|
|
ve.ui.MWSaveDialog.prototype.setSanityCheck = function ( verified ) {
|
|
|
|
this.sanityCheckVerified = !!verified;
|
|
|
|
};
|
|
|
|
|
2013-10-07 10:01:43 +00:00
|
|
|
/**
|
|
|
|
* Swap state in the save dialog.
|
|
|
|
*
|
|
|
|
* @param {string} panel One of 'save', 'review', 'conflict' or 'nochanges'
|
|
|
|
* @returns {jQuery} The now active panel
|
|
|
|
* @throws {Error} Unknown saveDialog panel
|
|
|
|
*/
|
|
|
|
ve.ui.MWSaveDialog.prototype.swapPanel = function ( panel ) {
|
2014-02-10 18:33:13 +00:00
|
|
|
var currentEditSummaryWikitext,
|
2014-03-13 00:31:02 +00:00
|
|
|
size = 'medium',
|
2014-02-10 18:33:13 +00:00
|
|
|
dialog = this,
|
2013-10-07 10:01:43 +00:00
|
|
|
panelObj = dialog[panel + 'Panel'];
|
|
|
|
|
|
|
|
if ( ve.indexOf( panel, [ 'save', 'review', 'conflict', 'nochanges' ] ) === -1 ) {
|
|
|
|
throw new Error( 'Unknown saveDialog panel: ' + panel );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the window title
|
|
|
|
this.setTitle( ve.msg( 'visualeditor-savedialog-title-' + panel ) );
|
|
|
|
|
|
|
|
// Reset save button if we disabled it for e.g. unrecoverable spam error
|
|
|
|
this.saveButton.setDisabled( false );
|
|
|
|
|
2013-12-06 02:34:44 +00:00
|
|
|
switch ( panel ) {
|
2013-10-07 10:01:43 +00:00
|
|
|
case 'save':
|
|
|
|
if ( !this.sanityCheckVerified ) {
|
|
|
|
this.showMessage( 'dirtywarning', mw.msg( 'visualeditor-savedialog-warning-dirty' ) );
|
|
|
|
}
|
2013-11-01 19:45:59 +00:00
|
|
|
this.saveButton.$element.show();
|
|
|
|
this.reviewButton.$element.show();
|
|
|
|
this.reviewGoodButton.$element.hide();
|
|
|
|
this.resolveConflictButton.$element.hide();
|
2013-10-17 13:29:03 +00:00
|
|
|
setTimeout( function () {
|
|
|
|
// fix input reference
|
|
|
|
var $textarea = dialog.editSummaryInput.$input;
|
|
|
|
$textarea.focus();
|
|
|
|
// If message has be pre-filled (e.g. section edit), move cursor to end
|
|
|
|
if ( $textarea.val() !== '' ) {
|
|
|
|
ve.selectEnd( $textarea[0] );
|
|
|
|
}
|
|
|
|
} );
|
2013-10-07 10:01:43 +00:00
|
|
|
break;
|
|
|
|
case 'conflict':
|
2014-02-19 21:46:43 +00:00
|
|
|
this.saveButton.setDisabled( true ).$element.hide();
|
2013-11-01 19:45:59 +00:00
|
|
|
this.reviewButton.$element.hide();
|
|
|
|
this.reviewGoodButton.$element.hide();
|
|
|
|
this.resolveConflictButton.$element.show();
|
2013-10-07 10:01:43 +00:00
|
|
|
break;
|
|
|
|
case 'review':
|
2014-03-13 00:31:02 +00:00
|
|
|
size = 'large';
|
2014-02-10 18:33:13 +00:00
|
|
|
currentEditSummaryWikitext = this.editSummaryInput.getValue();
|
|
|
|
if ( this.lastEditSummaryWikitext === undefined || this.lastEditSummaryWikitext !== currentEditSummaryWikitext ) {
|
|
|
|
if ( this.editSummaryXhr ) {
|
|
|
|
this.editSummaryXhr.abort();
|
|
|
|
}
|
|
|
|
this.lastEditSummaryWikitext = currentEditSummaryWikitext;
|
|
|
|
this.$reviewEditSummary.empty()
|
2014-02-21 12:59:37 +00:00
|
|
|
.parent().show().addClass( 'mw-ajax-loader' );
|
2014-02-10 18:33:13 +00:00
|
|
|
this.editSummaryXhr = new mw.Api().post( {
|
|
|
|
action: 'parse',
|
|
|
|
summary: currentEditSummaryWikitext
|
|
|
|
} ).done( function ( result ) {
|
2014-02-21 12:59:37 +00:00
|
|
|
if ( result.parse.parsedsummary['*'] === '' ) {
|
|
|
|
dialog.$reviewEditSummary.parent().hide();
|
|
|
|
} else {
|
|
|
|
dialog.$reviewEditSummary.html( ve.msg( 'parentheses', result.parse.parsedsummary['*'] ) );
|
|
|
|
}
|
|
|
|
} ).fail( function () {
|
|
|
|
dialog.$reviewEditSummary.parent().hide();
|
|
|
|
} ).always( function () {
|
|
|
|
dialog.$reviewEditSummary.parent().removeClass( 'mw-ajax-loader' );
|
2014-02-10 18:33:13 +00:00
|
|
|
} );
|
|
|
|
}
|
2013-10-07 10:01:43 +00:00
|
|
|
/* falls through */
|
|
|
|
case 'nochanges':
|
2013-11-01 19:45:59 +00:00
|
|
|
this.saveButton.$element.hide();
|
|
|
|
this.reviewButton.$element.hide();
|
|
|
|
this.reviewGoodButton.$element.show();
|
|
|
|
this.resolveConflictButton.$element.hide();
|
2013-10-07 10:01:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-03-13 00:31:02 +00:00
|
|
|
// Set the size
|
|
|
|
this.setSize( size );
|
2013-10-07 10:01:43 +00:00
|
|
|
// Show the target panel
|
2013-12-02 20:10:55 +00:00
|
|
|
this.panel.setItem( panelObj );
|
2013-10-07 10:01:43 +00:00
|
|
|
|
|
|
|
mw.hook( 've.saveDialog.stateChanged' ).fire();
|
|
|
|
|
|
|
|
return dialog;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a message in the save dialog.
|
|
|
|
*
|
|
|
|
* @param {string} name Message's unique name
|
|
|
|
* @param {string|jQuery|Array} message Message content (string of HTML, jQuery object or array of
|
|
|
|
* Node objects)
|
|
|
|
* @param {Object} [options]
|
|
|
|
* @param {boolean} [options.wrap="warning"] Whether to wrap the message in a paragraph and if
|
|
|
|
* so, how. One of "warning", "error" or false.
|
|
|
|
*/
|
|
|
|
ve.ui.MWSaveDialog.prototype.showMessage = function ( name, message, options ) {
|
|
|
|
var $message;
|
|
|
|
if ( !this.messages[name] ) {
|
|
|
|
options = options || {};
|
|
|
|
if ( options.wrap === undefined ) {
|
|
|
|
options.wrap = 'warning';
|
|
|
|
}
|
2013-11-01 19:45:59 +00:00
|
|
|
$message = this.$( '<div class="ve-ui-mwSaveDialog-message"></div>' );
|
2013-10-07 10:01:43 +00:00
|
|
|
if ( options.wrap !== false ) {
|
2013-11-01 19:45:59 +00:00
|
|
|
$message.append( this.$( '<p>').append(
|
2014-05-15 16:12:43 +00:00
|
|
|
// visualeditor-savedialog-label-error
|
|
|
|
// visualeditor-savedialog-label-warning
|
2013-11-01 19:45:59 +00:00
|
|
|
this.$( '<strong>' ).text( mw.msg( 'visualeditor-savedialog-label-' + options.wrap ) ),
|
2013-10-07 10:01:43 +00:00
|
|
|
document.createTextNode( mw.msg( 'colon-separator' ) ),
|
|
|
|
message
|
|
|
|
) );
|
|
|
|
} else {
|
|
|
|
$message.append( message );
|
|
|
|
}
|
|
|
|
this.$saveMessages.append( $message );
|
|
|
|
|
|
|
|
this.messages[name] = $message;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a message from the save dialog.
|
|
|
|
* @param {string} name Message's unique name
|
|
|
|
*/
|
|
|
|
ve.ui.MWSaveDialog.prototype.clearMessage = function ( name ) {
|
|
|
|
if ( this.messages[name] ) {
|
|
|
|
this.messages[name].remove();
|
|
|
|
delete this.messages[name];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove all messages from the save dialog.
|
|
|
|
*/
|
|
|
|
ve.ui.MWSaveDialog.prototype.clearAllMessages = function () {
|
|
|
|
this.$saveMessages.empty();
|
|
|
|
this.messages = {};
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset the fields of the save dialog.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.ui.MWSaveDialog.prototype.reset = function () {
|
|
|
|
// Reset summary input
|
|
|
|
this.editSummaryInput.$input.val( '' );
|
|
|
|
// Uncheck minoredit
|
|
|
|
this.$saveOptions.find( '.ve-ui-mwSaveDialog-checkboxes' )
|
|
|
|
.find( '#wpMinoredit' ).prop( 'checked', false );
|
|
|
|
// Clear the diff
|
|
|
|
this.$reviewViewer.empty();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-11-14 23:14:16 +00:00
|
|
|
* Initialize MediaWiki page specific checkboxes.
|
|
|
|
*
|
|
|
|
* This method is safe to call even when the dialog hasn't been initialized yet.
|
2013-10-07 10:01:43 +00:00
|
|
|
*
|
2013-11-15 21:31:40 +00:00
|
|
|
* @param {jQuery} $checkboxes jQuery collection of checkboxes
|
2013-10-07 10:01:43 +00:00
|
|
|
*/
|
2013-11-15 21:31:40 +00:00
|
|
|
ve.ui.MWSaveDialog.prototype.setupCheckboxes = function ( $checkboxes ) {
|
2013-11-14 23:14:16 +00:00
|
|
|
var saveDialog = this;
|
|
|
|
this.setupDeferred.done( function () {
|
|
|
|
saveDialog.$saveOptions.find( '.ve-ui-mwSaveDialog-checkboxes' )
|
2013-11-15 21:31:40 +00:00
|
|
|
.html( $checkboxes )
|
2013-11-14 23:14:16 +00:00
|
|
|
.find( 'a' )
|
|
|
|
.attr( 'target', '_blank' )
|
|
|
|
.end()
|
2013-11-15 21:31:40 +00:00
|
|
|
.find( 'input' )
|
|
|
|
.prop( 'tabIndex', 0 );
|
2013-11-14 23:14:16 +00:00
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Change the edit summary prefilled in the save dialog.
|
|
|
|
*
|
|
|
|
* This method is safe to call even when the dialog hasn't been initialized yet.
|
|
|
|
*
|
|
|
|
* @param {string} summary Edit summary to prefill
|
|
|
|
*/
|
|
|
|
ve.ui.MWSaveDialog.prototype.setEditSummary = function ( summary ) {
|
|
|
|
var saveDialog = this;
|
|
|
|
this.setupDeferred.done( function () {
|
|
|
|
saveDialog.editSummaryInput.setValue( summary );
|
|
|
|
} );
|
2013-10-07 10:01:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-11-05 00:29:50 +00:00
|
|
|
* @inheritdoc
|
2013-10-07 10:01:43 +00:00
|
|
|
*/
|
2013-11-05 00:29:50 +00:00
|
|
|
ve.ui.MWSaveDialog.prototype.initialize = function () {
|
|
|
|
var saveDialog = this;
|
|
|
|
// Parent method
|
2014-04-04 17:42:13 +00:00
|
|
|
ve.ui.Dialog.prototype.initialize.call( this );
|
2013-10-07 10:01:43 +00:00
|
|
|
|
2013-11-05 00:29:50 +00:00
|
|
|
// Properties
|
2014-05-19 17:41:06 +00:00
|
|
|
this.savePanel = new OO.ui.PanelLayout( {
|
|
|
|
'$': this.$,
|
|
|
|
'scrollable': true,
|
|
|
|
'classes': ['ve-ui-mwSaveDialog-savePanel']
|
|
|
|
} );
|
2013-11-05 00:29:50 +00:00
|
|
|
|
|
|
|
// Save panel
|
|
|
|
this.$editSummaryLabel = this.$( '<div>' ).addClass( 've-ui-mwSaveDialog-summaryLabel' )
|
|
|
|
.html( ve.init.platform.getParsedMessage( 'summary' ) )
|
|
|
|
.find( 'a' ).attr( 'target', '_blank' ).end();
|
|
|
|
this.editSummaryInput = new OO.ui.TextInputWidget(
|
|
|
|
{ '$': this.$, 'multiline': true, 'placeholder': ve.msg( 'visualeditor-editsummary' ) }
|
|
|
|
);
|
|
|
|
this.editSummaryInput.$element.addClass( 've-ui-mwSaveDialog-summary' );
|
|
|
|
this.editSummaryInput.$input
|
|
|
|
.byteLimit( this.editSummaryByteLimit )
|
|
|
|
.prop( 'tabIndex', 0 );
|
2013-11-19 07:50:55 +00:00
|
|
|
this.editSummaryInput.on( 'change', function () {
|
2013-11-05 00:29:50 +00:00
|
|
|
// TODO: This looks a bit weird, there is no unit in the UI, just numbers
|
|
|
|
// Users likely assume characters but then it seems to count down quicker
|
|
|
|
// than expected. Facing users with the word "byte" is bad? (bug 40035)
|
2013-11-19 07:50:55 +00:00
|
|
|
saveDialog.savePanel.$element.find( '.ve-ui-mwSaveDialog-editSummary-count' ).text(
|
|
|
|
saveDialog.editSummaryByteLimit - $.byteLength( saveDialog.editSummaryInput.getValue() )
|
|
|
|
);
|
|
|
|
} );
|
2013-11-05 00:29:50 +00:00
|
|
|
|
|
|
|
this.$saveOptions = this.$( '<div>' ).addClass( 've-ui-mwSaveDialog-options' ).append(
|
|
|
|
this.$( '<div>' ).addClass( 've-ui-mwSaveDialog-checkboxes' ),
|
2014-01-22 20:13:59 +00:00
|
|
|
new OO.ui.LabelWidget( { '$': this.$, 'label': 'text' } ).$element
|
2013-11-05 00:29:50 +00:00
|
|
|
.addClass( 've-ui-mwSaveDialog-editSummary-count' ).text( this.editSummaryByteLimit )
|
2014-02-09 03:14:09 +00:00
|
|
|
.attr( 'title', ve.msg( 'visualeditor-editsummary-bytes-remaining' ) )
|
2013-11-05 00:29:50 +00:00
|
|
|
);
|
|
|
|
this.$saveMessages = this.$( '<div>' );
|
|
|
|
this.$saveActions = this.$( '<div>' ).append(
|
|
|
|
this.$( '<div>' ).addClass( 've-ui-mwSaveDialog-dirtymsg' )
|
|
|
|
);
|
|
|
|
this.$saveFoot = this.$( '<div>' ).addClass( 've-ui-mwSaveDialog-foot' ).append(
|
|
|
|
this.$( '<p>' ).addClass( 've-ui-mwSaveDialog-license' )
|
|
|
|
.html( ve.init.platform.getParsedMessage( 'copyrightwarning' ) )
|
|
|
|
.find( 'a' ).attr( 'target', '_blank' ).end()
|
|
|
|
);
|
|
|
|
this.savePanel.$element.append(
|
|
|
|
this.$editSummaryLabel,
|
|
|
|
this.editSummaryInput.$element,
|
|
|
|
this.$saveOptions,
|
|
|
|
this.$saveMessages,
|
|
|
|
this.$saveActions,
|
|
|
|
this.$saveFoot
|
|
|
|
);
|
|
|
|
|
|
|
|
// Review panel
|
|
|
|
this.reviewPanel = new OO.ui.PanelLayout( { '$': this.$, 'scrollable': true } );
|
|
|
|
this.$reviewViewer = this.$( '<div>' ).addClass( 've-ui-mwSaveDialog-viewer' );
|
2014-02-10 18:33:13 +00:00
|
|
|
this.$reviewEditSummary = this.$( '<span>' ).addClass( 've-ui-mwSaveDialog-summaryPreview' ).addClass( 'comment' );
|
2013-11-05 00:29:50 +00:00
|
|
|
this.$reviewActions = this.$( '<div>' ).addClass( 've-ui-mwSaveDialog-actions' );
|
2014-02-10 18:33:13 +00:00
|
|
|
this.reviewPanel.$element.append(
|
|
|
|
$( '<br>' ),
|
|
|
|
$( '<div>' )
|
|
|
|
.addClass( 'mw-summary-preview' )
|
|
|
|
.text( ve.msg( 'summary-preview' ) )
|
|
|
|
.append( $( '<br>' ), this.$reviewEditSummary ),
|
|
|
|
this.$reviewViewer,
|
|
|
|
this.$reviewActions
|
|
|
|
);
|
2013-11-05 00:29:50 +00:00
|
|
|
|
|
|
|
// Conflict panel
|
|
|
|
this.conflictPanel = new OO.ui.PanelLayout( { '$': this.$, 'scrollable': true } );
|
|
|
|
this.$conflict = this.$( '<div>' ).addClass( 've-ui-mwSaveDialog-conflict' )
|
|
|
|
.html( ve.init.platform.getParsedMessage( 'visualeditor-editconflict' ) )
|
|
|
|
.find( 'a' ).attr( 'target', '_blank' ).end();
|
|
|
|
this.conflictPanel.$element.append( this.$conflict );
|
|
|
|
|
|
|
|
// No changes panel
|
|
|
|
this.nochangesPanel = new OO.ui.PanelLayout( { '$': this.$, 'scrollable': true } );
|
|
|
|
this.$noChanges = this.$( '<div>' ).addClass( 've-ui-mwSaveDialog-nochanges' )
|
|
|
|
.html( ve.init.platform.getParsedMessage( 'visualeditor-diff-nochanges' ) )
|
|
|
|
.find( 'a' ).attr( 'target', '_blank' ).end();
|
|
|
|
this.nochangesPanel.$element.append( this.$noChanges );
|
|
|
|
|
|
|
|
// Panel stack
|
2013-12-02 20:10:55 +00:00
|
|
|
this.panel = new OO.ui.StackLayout( { '$': this.$, 'scrollable': true } );
|
2013-11-05 00:29:50 +00:00
|
|
|
this.panel.$element.addClass( 've-ui-mwSaveDialog-panel' );
|
|
|
|
this.panel.addItems( [this.savePanel, this.reviewPanel, this.conflictPanel, this.nochangesPanel], 0 );
|
|
|
|
|
|
|
|
/* Buttons */
|
|
|
|
|
|
|
|
// Save button for "save" panel
|
2014-01-17 14:24:12 +00:00
|
|
|
this.saveButton = new OO.ui.ButtonWidget( {
|
2013-11-05 00:29:50 +00:00
|
|
|
'label': ve.msg(
|
2014-05-15 16:12:43 +00:00
|
|
|
// visualeditor-savedialog-label-restore, visualeditor-savedialog-label-save
|
2013-11-05 00:29:50 +00:00
|
|
|
'visualeditor-savedialog-label-' + ( this.restoring ? 'restore' : 'save' )
|
|
|
|
),
|
|
|
|
'flags': ['constructive']
|
|
|
|
} );
|
2014-01-30 19:33:30 +00:00
|
|
|
if ( ve.msg( 'accesskey-save' ) !== '-' && ve.msg( 'accesskey-save' ) !== '' ) {
|
|
|
|
this.saveButton.$button.attr( 'accesskey', ve.msg( 'accesskey-save' ) );
|
|
|
|
}
|
2013-11-14 23:14:16 +00:00
|
|
|
this.saveButton.connect( this, { 'click': [ 'emit', 'save' ] } );
|
2013-11-05 00:29:50 +00:00
|
|
|
|
|
|
|
// Review button for "save" panel
|
2014-01-17 14:24:12 +00:00
|
|
|
this.reviewButton = new OO.ui.ButtonWidget( {
|
2013-11-05 00:29:50 +00:00
|
|
|
'label': ve.msg( 'visualeditor-savedialog-label-review' )
|
|
|
|
} );
|
2013-11-14 23:14:16 +00:00
|
|
|
this.reviewButton.connect( this, { 'click': [ 'emit', 'review' ] } );
|
2013-11-05 00:29:50 +00:00
|
|
|
|
|
|
|
// Review good button on "review" panel
|
2014-01-17 14:24:12 +00:00
|
|
|
this.reviewGoodButton = new OO.ui.ButtonWidget( {
|
2014-03-31 22:31:43 +00:00
|
|
|
'label': ve.msg( 'visualeditor-savedialog-label-review-good' )
|
2013-11-05 00:29:50 +00:00
|
|
|
} );
|
2013-11-14 23:14:16 +00:00
|
|
|
this.reviewGoodButton.connect( this, { 'click': [ 'swapPanel', 'save' ] } );
|
2013-11-05 00:29:50 +00:00
|
|
|
// Resolve conflict
|
2014-01-17 14:24:12 +00:00
|
|
|
this.resolveConflictButton = new OO.ui.ButtonWidget( {
|
2013-11-05 00:29:50 +00:00
|
|
|
'label': ve.msg( 'visualeditor-savedialog-label-resolve-conflict' ),
|
|
|
|
'flags': ['constructive']
|
|
|
|
} );
|
2013-11-14 23:14:16 +00:00
|
|
|
this.resolveConflictButton.connect( this, { 'click': [ 'emit', 'resolve' ] } );
|
2013-11-05 00:29:50 +00:00
|
|
|
|
|
|
|
// Initialization
|
|
|
|
this.$body.append( this.panel.$element );
|
|
|
|
this.$foot.append(
|
|
|
|
this.reviewButton.$element,
|
|
|
|
this.saveButton.$element,
|
|
|
|
this.reviewGoodButton.$element,
|
2014-04-18 20:32:25 +00:00
|
|
|
this.resolveConflictButton.$element
|
2013-11-05 00:29:50 +00:00
|
|
|
);
|
2013-11-14 23:14:16 +00:00
|
|
|
|
|
|
|
this.setupDeferred.resolve();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWSaveDialog.prototype.setup = function () {
|
2014-04-25 21:44:39 +00:00
|
|
|
// Old messages should not persist after panel changes
|
|
|
|
this.clearAllMessages();
|
2014-05-19 16:23:38 +00:00
|
|
|
};
|
2014-04-25 21:44:39 +00:00
|
|
|
|
2014-05-19 16:23:38 +00:00
|
|
|
/**
|
|
|
|
* Handle window ready events
|
|
|
|
*/
|
|
|
|
ve.ui.MWSaveDialog.prototype.onReady = function () {
|
2013-11-14 23:14:16 +00:00
|
|
|
this.swapPanel( 'save' );
|
2013-10-07 10:01:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
2014-04-21 22:31:21 +00:00
|
|
|
ve.ui.windowFactory.register( ve.ui.MWSaveDialog );
|