jenkins-bot has submitted this change and it was merged. 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, 77 insertions(+), 43 deletions(-) Approvals: Trevor Parscal: Looks good to me, approved jenkins-bot: Verified diff --git a/.docs/eg-iframe.html b/.docs/eg-iframe.html index c95f847..3f3c28e 100644 --- a/.docs/eg-iframe.html +++ b/.docs/eg-iframe.html @@ -348,7 +348,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 9b7126b..5ce4e1f 100644 --- a/build/modules.json +++ b/build/modules.json @@ -376,7 +376,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 0b686e8..35a939f 100644 --- a/demos/ve/desktop.html +++ b/demos/ve/desktop.html @@ -366,7 +366,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 ec72fa0..e1a5d33 100644 --- a/demos/ve/mobile.html +++ b/demos/ve/mobile.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/src/ui/tools/ve.ui.DialogTool.js b/src/ui/tools/ve.ui.DialogTool.js index 4bc51af..ac05718 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 ); }; 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..0cfbf36 --- /dev/null +++ b/src/ui/tools/ve.ui.ToolbarDialogTool.js @@ -0,0 +1,67 @@ +/*! + * 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 ); +}; + +/** + * 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 563f554..2ee0aa9 100644 --- a/tests/index.html +++ b/tests/index.html @@ -307,7 +307,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: merged Gerrit-Change-Id: Ia587ba2a5b453dcdf99d0a3badc7f4861dd04a90 Gerrit-PatchSet: 2 Gerrit-Project: VisualEditor/VisualEditor Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Trevor Parscal <tpars...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits