2013-07-03 21:56:29 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MWSyntaxHighlightTool class.
|
|
|
|
*
|
2014-01-05 12:05:05 +00:00
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
2013-07-03 21:56:29 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SyntaxHighlight tool group.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.DialogTool
|
|
|
|
* @constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
2013-07-03 21:56:29 +00:00
|
|
|
* @param {Object} [config] Config options
|
|
|
|
*/
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.MWSyntaxHighlightTool = function VeUiMWSyntaxHighlightTool( toolGroup, config ) {
|
2013-07-03 21:56:29 +00:00
|
|
|
// Parent constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.DialogTool.call( this, toolGroup, config );
|
2013-07-03 21:56:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.MWSyntaxHighlightTool, ve.ui.DialogTool );
|
2013-07-03 21:56:29 +00:00
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
ve.ui.MWSyntaxHighlightTool.static.name = 'mwSyntaxHighlight';
|
|
|
|
ve.ui.MWSyntaxHighlightTool.static.icon = 'syntaxHighlight';
|
2014-02-12 21:45:37 +00:00
|
|
|
ve.ui.MWSyntaxHighlightTool.static.title =
|
|
|
|
OO.ui.deferMsg( 'visualeditor-dialogbutton-syntaxhighlight-tooltip' );
|
2013-07-03 21:56:29 +00:00
|
|
|
ve.ui.MWSyntaxHighlightTool.static.dialog = 'mwSyntaxHighlight';
|
|
|
|
ve.ui.MWSyntaxHighlightTool.static.modelClasses = [ ve.dm.MWSyntaxHighlightNode ];
|
|
|
|
ve.ui.MWSyntaxHighlightTool.static.group = 'syntaxHighlight';
|
|
|
|
ve.ui.MWSyntaxHighlightTool.static.autoAdd = true;
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ui.toolFactory.register( ve.ui.MWSyntaxHighlightTool );
|
|
|
|
|
2013-10-03 21:10:06 +00:00
|
|
|
/*
|
|
|
|
* Factory for SyntaxHighlight tools.
|
|
|
|
*/
|
2013-10-09 20:09:59 +00:00
|
|
|
ve.ui.syntaxHighlightEditorToolFactory = new OO.ui.ToolFactory();
|
2013-10-03 21:10:06 +00:00
|
|
|
|
|
|
|
/* SyntaxHighlight Editor Tools */
|
2013-07-03 21:56:29 +00:00
|
|
|
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.MWSyntaxHighlightEditorTool = function VeUiMWSyntaxHighlightEditorTool( toolGroup, config ) {
|
2013-07-03 21:56:29 +00:00
|
|
|
// Parent constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
OO.ui.Tool.call( this, toolGroup, config );
|
2013-07-03 21:56:29 +00:00
|
|
|
};
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.inheritClass( ve.ui.MWSyntaxHighlightEditorTool, OO.ui.Tool );
|
2013-07-03 21:56:29 +00:00
|
|
|
|
|
|
|
ve.ui.MWSyntaxHighlightEditorTool.prototype.onSelect = function () {
|
|
|
|
this.toolbar.context[this.constructor.static.method]();
|
|
|
|
this.setActive( false );
|
|
|
|
};
|
|
|
|
|
|
|
|
ve.ui.MWSyntaxHighlightEditorTool.prototype.onUpdateState = function () {
|
|
|
|
if ( this.constructor.static.name === 'synhiUndo' ){
|
|
|
|
this.setDisabled( this.toolbar.context.undoStack.length === 0 );
|
|
|
|
} else if ( this.constructor.static.name === 'synhiRedo' ){
|
|
|
|
this.setDisabled( this.toolbar.context.redoStack.length === 0 );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.MWSynHiUndoTool = function VeUiMWSynhiUndoTool( toolGroup, config ) {
|
|
|
|
ve.ui.MWSyntaxHighlightEditorTool.call( this, toolGroup, config );
|
2013-07-03 21:56:29 +00:00
|
|
|
};
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.MWSynHiUndoTool, ve.ui.MWSyntaxHighlightEditorTool );
|
2013-07-03 21:56:29 +00:00
|
|
|
ve.ui.MWSynHiUndoTool.static.name = 'synhiUndo';
|
|
|
|
ve.ui.MWSynHiUndoTool.static.group = 'synhiEditorTool';
|
|
|
|
ve.ui.MWSynHiUndoTool.static.method = 'undo';
|
|
|
|
ve.ui.MWSynHiUndoTool.static.icon = 'undo';
|
2014-02-12 21:45:37 +00:00
|
|
|
ve.ui.MWSynHiUndoTool.static.title =
|
|
|
|
OO.ui.deferMsg( 'visualeditor-historybutton-undo-tooltip' );
|
2013-07-03 21:56:29 +00:00
|
|
|
ve.ui.MWSynHiUndoTool.static.autoAdd = false;
|
2013-10-03 21:10:06 +00:00
|
|
|
ve.ui.syntaxHighlightEditorToolFactory.register( ve.ui.MWSynHiUndoTool );
|
2013-07-03 21:56:29 +00:00
|
|
|
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.MWSynHiRedoTool = function VeUiMWSynHiRedoTool( toolGroup, config ) {
|
|
|
|
ve.ui.MWSyntaxHighlightEditorTool.call( this, toolGroup, config );
|
2013-07-03 21:56:29 +00:00
|
|
|
};
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.MWSynHiRedoTool, ve.ui.MWSyntaxHighlightEditorTool );
|
2013-07-03 21:56:29 +00:00
|
|
|
ve.ui.MWSynHiRedoTool.static.name = 'synhiRedo';
|
|
|
|
ve.ui.MWSynHiRedoTool.static.group = 'synhiEditorTool';
|
|
|
|
ve.ui.MWSynHiRedoTool.static.method = 'redo';
|
|
|
|
ve.ui.MWSynHiRedoTool.static.icon = 'redo';
|
2014-02-12 21:45:37 +00:00
|
|
|
ve.ui.MWSynHiRedoTool.static.title =
|
|
|
|
OO.ui.deferMsg( 'visualeditor-historybutton-redo-tooltip' );
|
2013-07-03 21:56:29 +00:00
|
|
|
ve.ui.MWSynHiRedoTool.static.autoAdd = false;
|
2013-10-03 21:10:06 +00:00
|
|
|
ve.ui.syntaxHighlightEditorToolFactory.register( ve.ui.MWSynHiRedoTool );
|
2013-07-03 21:56:29 +00:00
|
|
|
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.MWSynHiIndentTool = function VeUiMWSynHiIndentTool( toolGroup, config ) {
|
|
|
|
ve.ui.MWSyntaxHighlightEditorTool.call( this, toolGroup, config );
|
2013-07-03 21:56:29 +00:00
|
|
|
};
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.MWSynHiIndentTool, ve.ui.MWSyntaxHighlightEditorTool );
|
2013-07-03 21:56:29 +00:00
|
|
|
ve.ui.MWSynHiIndentTool.static.name = 'synhiIndent';
|
|
|
|
ve.ui.MWSynHiIndentTool.static.group = 'synhiEditorTool';
|
|
|
|
ve.ui.MWSynHiIndentTool.static.method = 'indent';
|
|
|
|
ve.ui.MWSynHiIndentTool.static.icon = 'indent-list';
|
2014-02-12 21:45:37 +00:00
|
|
|
ve.ui.MWSynHiIndentTool.static.title = '';
|
2013-07-03 21:56:29 +00:00
|
|
|
ve.ui.MWSynHiIndentTool.static.autoAdd = false;
|
2013-10-03 21:10:06 +00:00
|
|
|
ve.ui.syntaxHighlightEditorToolFactory.register( ve.ui.MWSynHiIndentTool );
|
2013-07-03 21:56:29 +00:00
|
|
|
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.MWSynHiBeautifyTool = function VeUiMWSynHiBeautifyTool( toolGroup, config ) {
|
|
|
|
ve.ui.MWSyntaxHighlightEditorTool.call( this, toolGroup, config );
|
2013-07-03 21:56:29 +00:00
|
|
|
};
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.MWSynHiBeautifyTool, ve.ui.MWSyntaxHighlightEditorTool );
|
2013-07-03 21:56:29 +00:00
|
|
|
ve.ui.MWSynHiBeautifyTool.static.name = 'synhiBeautify';
|
|
|
|
ve.ui.MWSynHiBeautifyTool.static.group = 'synhiEditorTool';
|
|
|
|
ve.ui.MWSynHiBeautifyTool.static.method = 'doBeautify';
|
|
|
|
ve.ui.MWSynHiBeautifyTool.static.icon = 'reformat';
|
2014-02-12 21:45:37 +00:00
|
|
|
ve.ui.MWSynHiBeautifyTool.static.title = '';
|
2013-07-03 21:56:29 +00:00
|
|
|
ve.ui.MWSynHiBeautifyTool.static.autoAdd = false;
|
2014-02-12 21:45:37 +00:00
|
|
|
ve.ui.syntaxHighlightEditorToolFactory.register( ve.ui.MWSynHiBeautifyTool );
|