mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-02 01:46:47 +00:00
eca0a08ad9
Update VE core submodule to master (84ced37) and update calling code for changes in OOUI. Depends on Ic967b88d55daf48d365487e17f76488b3f02c60f and Ib599b9bd5028e2df084fcc3da657aeb7f1569d2a New changes: 94f03c3 Undefined variables first in selectNodes 62b5648 Localisation updates from https://translatewiki.net. 10c5a18 Don't descend into handlesOwnChildren nodes in selectNodes 4ed2432 Update jquery.client to MW's master (45192156d7) d7e24b8 Localisation updates from https://translatewiki.net. babb9da Localisation updates from https://translatewiki.net. 4639d18 Localisation updates from https://translatewiki.net. a561537 Localisation updates from https://translatewiki.net. 8f7053a Localisation updates from https://translatewiki.net. 7112cc2 Update OOjs UI to v0.1.0-pre (a290673bbd) Change-Id: Ie7d58472619509782f23a7dedc1ec27c3dcc7543
106 lines
2.8 KiB
JavaScript
106 lines
2.8 KiB
JavaScript
/*!
|
|
* VisualEditor user interface MWSyntaxHighlightDialog class.
|
|
*
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Document dialog.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.MWDialog
|
|
*
|
|
* @constructor
|
|
* @param {OO.ui.WindowSet} windowSet Window set this dialog is part of
|
|
* @param {Object} [config] Config options
|
|
*/
|
|
ve.ui.MWSyntaxHighlightDialog = function VeUiMWSyntaxHighlightDialog( windowSet, config ) {
|
|
// Parent constructor
|
|
ve.ui.MWDialog.call( this, windowSet, config );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWSyntaxHighlightDialog, ve.ui.MWDialog );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ui.MWSyntaxHighlightDialog.static.title =
|
|
OO.ui.deferMsg( 'visualeditor-dialog-syntaxhighlight-title' );
|
|
|
|
ve.ui.MWSyntaxHighlightDialog.static.icon = 'syntaxHighlight';
|
|
|
|
ve.ui.MWSyntaxHighlightDialog.static.name = 'mwSyntaxHighlight';
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWSyntaxHighlightDialog.prototype.initialize = function () {
|
|
// Call parent method
|
|
ve.ui.MWDialog.prototype.initialize.call( this );
|
|
this.editPanel = new OO.ui.PanelLayout( {
|
|
'$': this.$, 'scrollable': false, 'padded': false
|
|
} );
|
|
this.applyButton = new OO.ui.ButtonWidget( {
|
|
'$': this.$, 'label': ve.msg( 'visualeditor-dialog-action-apply' ), 'flags': ['primary']
|
|
} );
|
|
this.applyButton.connect( this, { 'click': [ 'close', { 'action': 'apply' } ] } );
|
|
this.$body.append( this.editPanel.$element );
|
|
this.$foot.append( this.applyButton.$element );
|
|
};
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWSyntaxHighlightDialog.prototype.setup = function ( data ) {
|
|
// Parent method
|
|
ve.ui.MWDialog.prototype.setup.call( this, data );
|
|
|
|
// Properties
|
|
this.sourceNode = this.surface.getView().getFocusedNode();
|
|
this.sourceText = this.sourceNode.getModel().getAttribute( 'body' );
|
|
this.sourceLang = this.sourceNode.getModel().getAttribute( 'lang' );
|
|
this.editSurface = new ve.ui.MWSyntaxHighlightSimpleSurface( this.sourceText, this.sourceLang );
|
|
|
|
// Initialization
|
|
this.editPanel.$element.append( this.editSurface.$element );
|
|
this.editSurface.initialize();
|
|
};
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWSyntaxHighlightDialog.prototype.teardown = function ( data ) {
|
|
// Data initialization
|
|
data = data || {};
|
|
|
|
var tx,
|
|
doc = this.surface.getModel().getDocument();
|
|
|
|
// Save changes via Transaction
|
|
if ( data.action === 'apply' ) {
|
|
tx = ve.dm.Transaction.newFromAttributeChanges(
|
|
doc,
|
|
this.sourceNode.getModel().getOffset(),
|
|
{
|
|
'body':this.editSurface.getModel(),
|
|
'lang':this.editSurface.getLang()
|
|
}
|
|
);
|
|
this.surface.getModel().change( tx );
|
|
}
|
|
|
|
// Cleanup
|
|
this.editSurface.destroy();
|
|
|
|
// Parent method
|
|
ve.ui.MWDialog.prototype.teardown.call( this, data );
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.dialogFactory.register( ve.ui.MWSyntaxHighlightDialog );
|