Esanders has uploaded a new change for review. https://gerrit.wikimedia.org/r/193125
Change subject: Create toolbar dialog tools ...................................................................... Create toolbar dialog tools These set their activeness based on whether their dialogs are currently open. Add an 'updateToolState' call to the onToolbarWindowOpeningOrClosing event in the toolbar. Change-Id: Ia587ba2a5b453dcdf99d0a3badc7f4861dd04a90 --- M .docs/eg-iframe.html M build/modules.json M demos/ve/desktop.html M demos/ve/mobile.html M src/ui/tools/ve.ui.DialogTool.js D src/ui/tools/ve.ui.FindAndReplaceTool.js A src/ui/tools/ve.ui.ToolbarDialogTool.js M src/ui/ve.ui.Toolbar.js M tests/index.html 9 files changed, 101 insertions(+), 66 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor refs/changes/25/193125/1 diff --git a/.docs/eg-iframe.html b/.docs/eg-iframe.html index a2678c9..f129a7a 100644 --- a/.docs/eg-iframe.html +++ b/.docs/eg-iframe.html @@ -349,7 +349,7 @@ <script src="../src/ui/tools/ve.ui.AnnotationTool.js"></script> <script src="../src/ui/tools/ve.ui.ClearAnnotationTool.js"></script> <script src="../src/ui/tools/ve.ui.DialogTool.js"></script> - <script src="../src/ui/tools/ve.ui.FindAndReplaceTool.js"></script> + <script src="../src/ui/tools/ve.ui.ToolbarDialogTool.js"></script> <script src="../src/ui/tools/ve.ui.FormatTool.js"></script> <script src="../src/ui/tools/ve.ui.HistoryTool.js"></script> <script src="../src/ui/tools/ve.ui.IndentationTool.js"></script> diff --git a/build/modules.json b/build/modules.json index e0dabb4..90b1a2f 100644 --- a/build/modules.json +++ b/build/modules.json @@ -377,7 +377,7 @@ "src/ui/tools/ve.ui.AnnotationTool.js", "src/ui/tools/ve.ui.ClearAnnotationTool.js", "src/ui/tools/ve.ui.DialogTool.js", - "src/ui/tools/ve.ui.FindAndReplaceTool.js", + "src/ui/tools/ve.ui.ToolbarDialogTool.js", "src/ui/tools/ve.ui.FormatTool.js", "src/ui/tools/ve.ui.HistoryTool.js", "src/ui/tools/ve.ui.IndentationTool.js", diff --git a/demos/ve/desktop.html b/demos/ve/desktop.html index 15c13ac..41bf478 100644 --- a/demos/ve/desktop.html +++ b/demos/ve/desktop.html @@ -367,7 +367,7 @@ <script src="../../src/ui/tools/ve.ui.AnnotationTool.js"></script> <script src="../../src/ui/tools/ve.ui.ClearAnnotationTool.js"></script> <script src="../../src/ui/tools/ve.ui.DialogTool.js"></script> - <script src="../../src/ui/tools/ve.ui.FindAndReplaceTool.js"></script> + <script src="../../src/ui/tools/ve.ui.ToolbarDialogTool.js"></script> <script src="../../src/ui/tools/ve.ui.FormatTool.js"></script> <script src="../../src/ui/tools/ve.ui.HistoryTool.js"></script> <script src="../../src/ui/tools/ve.ui.IndentationTool.js"></script> diff --git a/demos/ve/mobile.html b/demos/ve/mobile.html index 20a0f10..0323239 100644 --- a/demos/ve/mobile.html +++ b/demos/ve/mobile.html @@ -368,7 +368,7 @@ <script src="../../src/ui/tools/ve.ui.AnnotationTool.js"></script> <script src="../../src/ui/tools/ve.ui.ClearAnnotationTool.js"></script> <script src="../../src/ui/tools/ve.ui.DialogTool.js"></script> - <script src="../../src/ui/tools/ve.ui.FindAndReplaceTool.js"></script> + <script src="../../src/ui/tools/ve.ui.ToolbarDialogTool.js"></script> <script src="../../src/ui/tools/ve.ui.FormatTool.js"></script> <script src="../../src/ui/tools/ve.ui.HistoryTool.js"></script> <script src="../../src/ui/tools/ve.ui.IndentationTool.js"></script> diff --git a/src/ui/tools/ve.ui.DialogTool.js b/src/ui/tools/ve.ui.DialogTool.js index e4ee3ed..cecc2d3 100644 --- a/src/ui/tools/ve.ui.DialogTool.js +++ b/src/ui/tools/ve.ui.DialogTool.js @@ -50,7 +50,7 @@ */ ve.ui.DialogTool.prototype.onUpdateState = function () { // Parent method - ve.ui.Tool.prototype.onUpdateState.apply( this, arguments ); + ve.ui.DialogTool.super.prototype.onUpdateState.apply( this, arguments ); // Never show the tool as active this.setActive( false ); }; @@ -77,26 +77,3 @@ ve.ui.CommandHelpDialogTool.static.autoAddToGroup = false; ve.ui.CommandHelpDialogTool.static.commandName = 'commandHelp'; ve.ui.toolFactory.register( ve.ui.CommandHelpDialogTool ); - -/** - * Special character tool. - * - * @class - * @extends ve.ui.DialogTool - * @constructor - * @param {OO.ui.ToolGroup} toolGroup - * @param {Object} [config] Configuration options - */ -ve.ui.SpecialCharacterDialogTool = function VeUiSpecialCharacterDialogTool() { - ve.ui.SpecialCharacterDialogTool.super.apply( this, arguments ); -}; -OO.inheritClass( ve.ui.SpecialCharacterDialogTool, ve.ui.DialogTool ); -ve.ui.SpecialCharacterDialogTool.static.name = 'specialCharacter'; -ve.ui.SpecialCharacterDialogTool.static.group = 'dialog'; -ve.ui.SpecialCharacterDialogTool.static.icon = 'special-character'; -ve.ui.SpecialCharacterDialogTool.static.title = - OO.ui.deferMsg( 'visualeditor-specialcharacter-button-tooltip' ); -ve.ui.SpecialCharacterDialogTool.static.autoAddToCatchall = false; -ve.ui.SpecialCharacterDialogTool.static.autoAddToGroup = false; -ve.ui.SpecialCharacterDialogTool.static.commandName = 'specialCharacter'; -ve.ui.toolFactory.register( ve.ui.SpecialCharacterDialogTool ); diff --git a/src/ui/tools/ve.ui.FindAndReplaceTool.js b/src/ui/tools/ve.ui.FindAndReplaceTool.js deleted file mode 100644 index 866181a..0000000 --- a/src/ui/tools/ve.ui.FindAndReplaceTool.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * VisualEditor UserInterface FindAndReplaceTool classes. - * - * @copyright 2011-2015 VisualEditor Team and others; see http://ve.mit-license.org - */ - -/** - * UserInterface FindAndReplace tool. - * - * @abstract - * @class - * @extends ve.ui.Tool - * @constructor - * @param {OO.ui.ToolGroup} toolGroup - * @param {Object} [config] Configuration options - */ -ve.ui.FindAndReplaceTool = function VeUiFindAndReplaceTool( toolGroup, config ) { - // Parent constructor - ve.ui.Tool.call( this, toolGroup, config ); -}; - -/* Inheritance */ - -OO.inheritClass( ve.ui.FindAndReplaceTool, ve.ui.Tool ); - -ve.ui.FindAndReplaceTool.static.name = 'findAndReplace'; -ve.ui.FindAndReplaceTool.static.group = 'dialog'; -ve.ui.FindAndReplaceTool.static.icon = 'find'; -ve.ui.FindAndReplaceTool.static.title = - OO.ui.deferMsg( 'visualeditor-find-and-replace-title' ); -ve.ui.FindAndReplaceTool.static.autoAddToCatchall = false; -ve.ui.FindAndReplaceTool.static.autoAddToGroup = false; -ve.ui.FindAndReplaceTool.static.commandName = 'findAndReplace'; -ve.ui.toolFactory.register( ve.ui.FindAndReplaceTool ); diff --git a/src/ui/tools/ve.ui.ToolbarDialogTool.js b/src/ui/tools/ve.ui.ToolbarDialogTool.js new file mode 100644 index 0000000..e1828d7 --- /dev/null +++ b/src/ui/tools/ve.ui.ToolbarDialogTool.js @@ -0,0 +1,91 @@ +/*! + * VisualEditor UserInterface ToolbarDialogTool class. + * + * @copyright 2011-2015 VisualEditor Team and others; see http://ve.mit-license.org + */ + +/** + * UserInterface toolbar dialog tool. + * + * @abstract + * @class + * @extends ve.ui.DialogTool + * @constructor + * @param {OO.ui.ToolGroup} toolGroup + * @param {Object} [config] Configuration options + */ +ve.ui.ToolbarDialogTool = function VeUiToolbarDialogTool() { + // Parent constructor + ve.ui.ToolbarDialogTool.super.apply( this, arguments ); +}; + +/* Inheritance */ + +OO.inheritClass( ve.ui.ToolbarDialogTool, ve.ui.DialogTool ); + +/* Static Properties */ + +ve.ui.ToolbarDialogTool.static.deactivateOnSelect = false; + +ve.ui.ToolbarDialogTool.static.activeWindow = null; + +/* Methods */ + +/** + * @inheritdoc + */ +ve.ui.ToolbarDialogTool.prototype.onUpdateState = function () { + // Parent method + ve.ui.ToolbarDialogTool.super.prototype.onUpdateState.apply( this, arguments ); + // Never show the tool as active + var currentWindow = this.toolbar.getSurface().getToolbarDialogs().currentWindow; + this.setActive( currentWindow && currentWindow.constructor.static.name === this.constructor.static.activeWindow ); +}; + +/** + * Special character tool. + * + * @class + * @extends ve.ui.ToolbarDialogTool + * @constructor + * @param {OO.ui.ToolGroup} toolGroup + * @param {Object} [config] Configuration options + */ +ve.ui.SpecialCharacterDialogTool = function VeUiSpecialCharacterDialogTool() { + ve.ui.SpecialCharacterDialogTool.super.apply( this, arguments ); +}; +OO.inheritClass( ve.ui.SpecialCharacterDialogTool, ve.ui.ToolbarDialogTool ); +ve.ui.SpecialCharacterDialogTool.static.name = 'specialCharacter'; +ve.ui.SpecialCharacterDialogTool.static.group = 'dialog'; +ve.ui.SpecialCharacterDialogTool.static.icon = 'special-character'; +ve.ui.SpecialCharacterDialogTool.static.title = + OO.ui.deferMsg( 'visualeditor-specialcharacter-button-tooltip' ); +ve.ui.SpecialCharacterDialogTool.static.autoAddToCatchall = false; +ve.ui.SpecialCharacterDialogTool.static.autoAddToGroup = false; +ve.ui.SpecialCharacterDialogTool.static.commandName = 'specialCharacter'; +ve.ui.SpecialCharacterDialogTool.static.activeWindow = 'specialCharacter'; +ve.ui.toolFactory.register( ve.ui.SpecialCharacterDialogTool ); + +/** + * Find and replace tool. + * + * @class + * @extends ve.ui.ToolbarDialogTool + * @constructor + * @param {OO.ui.ToolGroup} toolGroup + * @param {Object} [config] Configuration options + */ +ve.ui.FindAndReplaceTool = function VeUiFindAndReplaceTool() { + ve.ui.FindAndReplaceTool.super.apply( this, arguments ); +}; +OO.inheritClass( ve.ui.FindAndReplaceTool, ve.ui.ToolbarDialogTool ); +ve.ui.FindAndReplaceTool.static.name = 'findAndReplace'; +ve.ui.FindAndReplaceTool.static.group = 'dialog'; +ve.ui.FindAndReplaceTool.static.icon = 'find'; +ve.ui.FindAndReplaceTool.static.title = + OO.ui.deferMsg( 'visualeditor-find-and-replace-title' ); +ve.ui.FindAndReplaceTool.static.autoAddToCatchall = false; +ve.ui.FindAndReplaceTool.static.autoAddToGroup = false; +ve.ui.FindAndReplaceTool.static.commandName = 'findAndReplace'; +ve.ui.FindAndReplaceTool.static.activeWindow = 'findAndReplace'; +ve.ui.toolFactory.register( ve.ui.FindAndReplaceTool ); diff --git a/src/ui/ve.ui.Toolbar.js b/src/ui/ve.ui.Toolbar.js index f48c770..28986d4 100644 --- a/src/ui/ve.ui.Toolbar.js +++ b/src/ui/ve.ui.Toolbar.js @@ -76,8 +76,8 @@ // Events this.getSurface().getModel().connect( this, { contextChange: 'onContextChange' } ); this.getSurface().getToolbarDialogs().connect( this, { - opening: 'onToolbarWindowOpeningOrClosing', - closing: 'onToolbarWindowOpeningOrClosing' + opening: 'onToolbarDialogsOpeningOrClosing', + closing: 'onToolbarDialogsOpeningOrClosing' } ); }; @@ -141,9 +141,10 @@ * @param {jQuery.Promise} openingOrClosing * @param {Object} data */ -ve.ui.Toolbar.prototype.onToolbarWindowOpeningOrClosing = function ( win, openingOrClosing ) { +ve.ui.Toolbar.prototype.onToolbarDialogsOpeningOrClosing = function ( win, openingOrClosing ) { var toolbar = this; openingOrClosing.then( function () { + toolbar.updateToolState(); // Wait for window transition setTimeout( function () { if ( toolbar.floating ) { diff --git a/tests/index.html b/tests/index.html index 52eb1ed..551deb4 100644 --- a/tests/index.html +++ b/tests/index.html @@ -308,7 +308,7 @@ <script src="../src/ui/tools/ve.ui.AnnotationTool.js"></script> <script src="../src/ui/tools/ve.ui.ClearAnnotationTool.js"></script> <script src="../src/ui/tools/ve.ui.DialogTool.js"></script> - <script src="../src/ui/tools/ve.ui.FindAndReplaceTool.js"></script> + <script src="../src/ui/tools/ve.ui.ToolbarDialogTool.js"></script> <script src="../src/ui/tools/ve.ui.FormatTool.js"></script> <script src="../src/ui/tools/ve.ui.HistoryTool.js"></script> <script src="../src/ui/tools/ve.ui.IndentationTool.js"></script> -- To view, visit https://gerrit.wikimedia.org/r/193125 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia587ba2a5b453dcdf99d0a3badc7f4861dd04a90 Gerrit-PatchSet: 1 Gerrit-Project: VisualEditor/VisualEditor Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits