Mooeypoo has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/83826


Change subject: BlockInspectorTool and StickerToolbar
......................................................................

BlockInspectorTool and StickerToolbar

This change adds a 'BlockInspectorTool' whose purpose is to be used for
block nodes. The tool will have two functions; add a block node or edit
and existing block node. The add functionality is used when the tool is
called from the general toolbar, but the edit functionality is called when
this tool is called from the specific StickerToolbar that is associated
with the existing block node.

For the moment, this functionality is designed to be used mainly with the
languageblock <div> functionality, but it is designed to be generalized so
it can be used with other block nodes, like tables, etc.

In this change:
* BlockInspectorTool - defines a new sublcass for the inspector tool that
  is meant to work with block nodes for either edit or add functions.
* BlockInspectorAction - calls the designated inspector and sends over
  the edit details if needed. If the tool was called from the sticker
  toolbar, there is an associated ve.dm.Node that will be sent to the
  inspector.
* StickerToolbar - defines a new subclass for the toolbar that is
  specifically attached to a blocknode (through the upcoming 'stickernode'
  mixin. The new subclass allows to attach a specific node to the toolbar
  so the buttons and inspectors within it are associated with that node
  for editing.

Change-Id: I5efff0741eec68c820b29a7b8e68729ad2889f3d
---
M VisualEditor.php
A modules/ve/ui/actions/ve.ui.BlockInspectorAction.js
A modules/ve/ui/tools/ve.ui.BlockInspectorTool.js
A modules/ve/ui/ve.ui.StickerToolbar.js
4 files changed, 160 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/26/83826/1

diff --git a/VisualEditor.php b/VisualEditor.php
index 6327d7e..4920ed4 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -702,6 +702,9 @@
                        've/ce/annotations/ve.ce.LanguageAnnotation.js',
                        've/ui/inspectors/ve.ui.LanguageInspector.js',
                        've/ui/widgets/ve.ui.LanguageInputWidget.js',
+                       've/ui/tools/ve.ui.BlockInspectorTool.js',
+                       've/ui/actions/ve.ui.BlockInspectorAction.js',
+                       've/ui/ve.ui.StickerToolbar.js',
                        've/ui/tools/ve.ui.ExperimentalTool.js',
                        've-mw/ui/tools/ve.ui.MWExperimentalTool.js',
                ),
diff --git a/modules/ve/ui/actions/ve.ui.BlockInspectorAction.js 
b/modules/ve/ui/actions/ve.ui.BlockInspectorAction.js
new file mode 100644
index 0000000..ca16783
--- /dev/null
+++ b/modules/ve/ui/actions/ve.ui.BlockInspectorAction.js
@@ -0,0 +1,57 @@
+/*!
+ * VisualEditor UserInterface BlockInspectorAction class.
+ * Handling actions coming from an inspector of blocks or stickeredNodes
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/**
+ * BlockInspector action.
+ *
+ * @class
+ * @extends ve.ui.Action
+ * @constructor
+ * @param {ve.ui.Surface} surface Surface to act on
+ */
+ve.ui.BlockInspectorAction = function VeUiBlockInspectorAction( surface ) {
+       // Parent constructor
+       ve.ui.Action.call( this, surface );
+};
+
+/* Inheritance */
+
+ve.inheritClass( ve.ui.BlockInspectorAction, ve.ui.Action );
+
+/* Static Properties */
+
+/**
+ * List of allowed methods for the action.
+ *
+ * @static
+ * @property
+ */
+ve.ui.BlockInspectorAction.static.methods = ['open', 'close'];
+
+/* Methods */
+
+/**
+ * Open an inspector.
+ *
+ * @method
+ * @param {string} name Symbolic name of inspector to open
+ * @param {boolean} isEditBlockAction dictates whether this is an 'edit' 
action for the block
+ * @param {ve.dm.Node} nodeModel if we are in 'edit' mode, this is the 
nodeModel that is to be edited
+ */
+ve.ui.BlockInspectorAction.prototype.open = function ( name, 
isEditBlockAction, nodeModel ) {
+       var props = {
+                       'isBlock': true,
+                       'isEditBlockAction': isEditBlockAction,
+                       'nodeModel': nodeModel
+               };
+       this.surface.getContext().openInspector( name, props );
+};
+
+/* Registration */
+
+ve.ui.actionFactory.register( 'blockinspector', ve.ui.BlockInspectorAction );
diff --git a/modules/ve/ui/tools/ve.ui.BlockInspectorTool.js 
b/modules/ve/ui/tools/ve.ui.BlockInspectorTool.js
new file mode 100644
index 0000000..0ed759d
--- /dev/null
+++ b/modules/ve/ui/tools/ve.ui.BlockInspectorTool.js
@@ -0,0 +1,61 @@
+/*!
+ * VisualEditor UserInterface InspectorTool classes.
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/**
+ * UserInterface block inspector tool for block nodes and stickeredNodes.
+ *
+ * @abstract
+ * @class
+ * @extends ve.ui.Tool
+ * @constructor
+ * @param {ve.ui.SurfaceToolbar} toolbar
+ * @param {Object} [config] Config options
+ */
+ve.ui.BlockInspectorTool = function VeUiBlockInspectorTool( toolbar, config ) {
+       // Parent constructor
+       ve.ui.InspectorTool.call( this, toolbar, config );
+
+       // Which toolbar is this tool called from:
+       this.toolbar = toolbar;
+
+       this.isEditBlockAction = ( this.toolbar instanceof ve.ui.StickerToolbar 
);
+
+       if ( this.isEditBlockAction ) {
+               // Events
+               this.toolbar.connect( this, { 'updateStickerState': 
'onUpdateStickerState' } );
+       }
+};
+
+/* Inheritance */
+
+ve.inheritClass( ve.ui.BlockInspectorTool, ve.ui.InspectorTool );
+
+/* Methods */
+
+/**
+ * Handle the tool being selected.
+ *
+ * @method
+ */
+ve.ui.BlockInspectorTool.prototype.onSelect = function () {
+       this.toolbar.getSurface().execute( 'blockinspector', 'open', 
this.constructor.static.inspector, this.isEditBlockAction, 
this.toolbar.nodeModel );
+       this.setActive( false );
+};
+
+/**
+ * Handle the sticker toolbar state being updated.
+ *
+ * @method
+ * @param {ve.dm.Node} node the tool will be acting on as edit-mode
+ */
+ve.ui.BlockInspectorTool.prototype.onUpdateStickerState = function ( node ) {
+       if ( node && this.modelClasses && ve.isInstanceOfAny( node , 
this.modelClasses ) ) {
+               this.setActive(
+                               ve.ui.toolFactory.getToolForNode( node ) === 
this.constructor 
+               );
+       }
+};
diff --git a/modules/ve/ui/ve.ui.StickerToolbar.js 
b/modules/ve/ui/ve.ui.StickerToolbar.js
new file mode 100644
index 0000000..46b8fe9
--- /dev/null
+++ b/modules/ve/ui/ve.ui.StickerToolbar.js
@@ -0,0 +1,39 @@
+/*!
+ * VisualEditor UserInterface Toolbar class.
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/**
+ * UserInterface sticker toolbar.
+ *
+ * @class
+ * @extends ve.ui.SurfaceToolbar
+ *
+ * @constructor
+ * @param {ve.ui.Surface} surface
+ * @param {Object} [config] Config options
+ */
+ve.ui.StickerToolbar = function VeUiStickerToolbar( surface, options ) {
+       // Parent:
+       ve.ui.SurfaceToolbar.call( this, surface, options );
+
+       this.nodeView = options.nodeView;
+       this.nodeModel = options.nodeModel;
+};
+
+/* Inheritance */
+
+ve.inheritClass( ve.ui.StickerToolbar, ve.ui.SurfaceToolbar );
+
+/* Methods */
+
+/**
+ * Handle context changes on the surface.
+ *
+ * @emits updateStickerState
+ */
+ve.ui.StickerToolbar.prototype.onContextChange = function () {
+       this.emit( 'updateStickerState', [ this.nodeModel ] );
+};

-- 
To view, visit https://gerrit.wikimedia.org/r/83826
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5efff0741eec68c820b29a7b8e68729ad2889f3d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <mor...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to