Santhosh has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/342822 )
Change subject: CX2: Use OO.ui.Toolbar for Formatter tool
......................................................................
CX2: Use OO.ui.Toolbar for Formatter tool
Change-Id: I5e63ef5ca6158e8534283413b21ac09ab962e419
---
M modules/tools/mw.cx.tools.FormatterTool.js
M modules/tools/styles/mw.cx.tools.FormatterTool.less
2 files changed, 81 insertions(+), 23 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation
refs/changes/22/342822/1
diff --git a/modules/tools/mw.cx.tools.FormatterTool.js
b/modules/tools/mw.cx.tools.FormatterTool.js
index 6ad3971..b4e65d1 100644
--- a/modules/tools/mw.cx.tools.FormatterTool.js
+++ b/modules/tools/mw.cx.tools.FormatterTool.js
@@ -27,29 +27,86 @@
* @inheritDoc
*/
mw.cx.tools.FormatterTool.prototype.getActions = function () {
- var formatterButtonGroup, undoButton, redoButton, boldButton,
italicButton, orderedlistButton, unOrderedlistButton;
- undoButton = new OO.ui.ButtonWidget( {
- icon: 'undo'
- } );
- redoButton = new OO.ui.ButtonWidget( {
- icon: 'redo'
- } );
- boldButton = new OO.ui.ButtonWidget( {
- icon: 'bold'
- } );
- italicButton = new OO.ui.ButtonWidget( {
- icon: 'italic'
- } );
- orderedlistButton = new OO.ui.ButtonWidget( {
- icon: 'listBullet'
- } );
- unOrderedlistButton = new OO.ui.ButtonWidget( {
- icon: 'listNumbered'
- } );
- formatterButtonGroup = new OO.ui.ButtonGroupWidget( {
- items: [ undoButton, redoButton, boldButton, italicButton,
orderedlistButton, unOrderedlistButton ]
- } );
- return [ formatterButtonGroup ];
+ var toolFactory, toolGroupFactory, toolbar;
+
+ // Create the toolbar
+ toolFactory = new OO.ui.ToolFactory();
+ toolGroupFactory = new OO.ui.ToolGroupFactory();
+ // Define the tools that we're going to place in our toolbar
+
+ // Create a class inheriting from OO.ui.Tool
+ function UndoTool() {
+ UndoTool.parent.apply( this, arguments );
+ }
+ OO.inheritClass( UndoTool, OO.ui.Tool );
+ UndoTool.static.name = 'undo';
+ UndoTool.static.icon = 'undo';
+ UndoTool.prototype.onUpdateState = function () {};
+ toolFactory.register( UndoTool );
+
+ function RedoTool() {
+ RedoTool.parent.apply( this, arguments );
+ }
+ OO.inheritClass( RedoTool, OO.ui.Tool );
+ RedoTool.static.name = 'redo';
+ RedoTool.static.icon = 'redo';
+ RedoTool.prototype.onUpdateState = function () {};
+ toolFactory.register( RedoTool );
+
+ function BoldTool() {
+ RedoTool.parent.apply( this, arguments );
+ }
+ OO.inheritClass( BoldTool, OO.ui.Tool );
+ BoldTool.static.name = 'bold';
+ BoldTool.static.icon = 'bold';
+ BoldTool.prototype.onUpdateState = function () {};
+ toolFactory.register( BoldTool );
+
+ function ItalicTool() {
+ RedoTool.parent.apply( this, arguments );
+ }
+ OO.inheritClass( ItalicTool, OO.ui.Tool );
+ ItalicTool.static.name = 'italic';
+ ItalicTool.static.icon = 'italic';
+ ItalicTool.prototype.onUpdateState = function () {};
+ toolFactory.register( ItalicTool );
+
+ function ListBulletTool() {
+ RedoTool.parent.apply( this, arguments );
+ }
+ OO.inheritClass( ListBulletTool, OO.ui.Tool );
+ ListBulletTool.static.name = 'listBullet';
+ ListBulletTool.static.icon = 'listBullet';
+ ListBulletTool.prototype.onUpdateState = function () {};
+ toolFactory.register( ListBulletTool );
+
+ function ListNumberedTool() {
+ RedoTool.parent.apply( this, arguments );
+ }
+ OO.inheritClass( ListNumberedTool, OO.ui.Tool );
+ ListNumberedTool.static.name = 'listNumbered';
+ ListNumberedTool.static.icon = 'listNumbered';
+ ListNumberedTool.prototype.onUpdateState = function () {};
+ toolFactory.register( ListNumberedTool );
+
+ toolbar = new OO.ui.Toolbar( toolFactory, toolGroupFactory );
+ // Finally define which tools and in what order appear in the toolbar.
Each tool may only be
+ // used once (but not all defined tools must be used).
+ toolbar.setup( [
+ {
+ type: 'bar',
+ include: [ 'undo', 'redo' ]
+ },
+ {
+ type: 'bar',
+ include: [ 'bold', 'italic' ]
+ },
+ {
+ type: 'bar',
+ include: [ 'listBullet', 'listNumbered' ]
+ }
+ ] );
+ return [ toolbar ];
};
/**
diff --git a/modules/tools/styles/mw.cx.tools.FormatterTool.less
b/modules/tools/styles/mw.cx.tools.FormatterTool.less
index 28c49c2..c9cdb24 100644
--- a/modules/tools/styles/mw.cx.tools.FormatterTool.less
+++ b/modules/tools/styles/mw.cx.tools.FormatterTool.less
@@ -10,4 +10,5 @@
border: 0;
}
border: 0;
+ padding: 0;
}
--
To view, visit https://gerrit.wikimedia.org/r/342822
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5e63ef5ca6158e8534283413b21ac09ab962e419
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits