Robmoen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/103062
Change subject: Create mixin for node that responds to node click events
......................................................................
Create mixin for node that responds to node click events
Currently this mixin responds to double clicks by trying to open
a dialog for the tool associated with the focused node.
Method could be enhanced to support inspectors, but at the moment
I believe nodes are only related to dialogs.
Bug: 50996
Change-Id: I8df07f413d9e295b960b7d0c82224aa37fdd637e
---
A modules/ve/ce/ve.ce.ClickableNode.js
M modules/ve/ce/ve.ce.FocusableNode.js
M modules/ve/ce/ve.ce.ProtectedNode.js
M modules/ve/ce/ve.ce.RelocatableNode.js
4 files changed, 47 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/62/103062/1
diff --git a/modules/ve/ce/ve.ce.ClickableNode.js
b/modules/ve/ce/ve.ce.ClickableNode.js
new file mode 100644
index 0000000..e4a3c47
--- /dev/null
+++ b/modules/ve/ce/ve.ce.ClickableNode.js
@@ -0,0 +1,31 @@
+/*!
+ * VisualEditor ContentEditable ClickableNode class.
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/**
+ * ContentEditable clickable node.
+ *
+ * @class
+ * @abstract
+ *
+ * @constructor
+ */
+ve.ce.ClickableNode = function VeCeClickableNode() {
+ // Events
+ this.connect( this, { 'dblclick': 'onDblClick' } );
+
+};
+ve.ce.ClickableNode.prototype.onDblClick = function () {
+ var ceSurface = this.getRoot().getSurface(),
+ veSurface = ceSurface.getSurface(),
+ name;
+
+ name = ve.ui.toolFactory.getToolForNode(
+ ceSurface.getFocusedNode().getModel()
+ );
+
+ veSurface.execute( 'dialog', 'open', name );
+};
diff --git a/modules/ve/ce/ve.ce.FocusableNode.js
b/modules/ve/ce/ve.ce.FocusableNode.js
index a8a84d7..6ff9747 100644
--- a/modules/ve/ce/ve.ce.FocusableNode.js
+++ b/modules/ve/ce/ve.ce.FocusableNode.js
@@ -169,6 +169,7 @@
* @method
*/
ve.ce.FocusableNode.prototype.createHighlight = function () {
+ var node = this;
this.$focusable.find( '*' ).add( this.$focusable ).each(
ve.bind( function ( i, el ) {
var offset, $el = this.$( el );
@@ -187,6 +188,9 @@
left: offset.left
} )
.addClass(
've-ce-focusableNode-highlight' )
+ .on( 'dblclick', function () {
+ node.emit( 'dblclick' );
+ } )
);
}, this )
);
diff --git a/modules/ve/ce/ve.ce.ProtectedNode.js
b/modules/ve/ce/ve.ce.ProtectedNode.js
index 407ec37..c7eb416 100644
--- a/modules/ve/ce/ve.ce.ProtectedNode.js
+++ b/modules/ve/ce/ve.ce.ProtectedNode.js
@@ -97,6 +97,9 @@
return;
}
$shield = node.$( node.$.context.importNode(
$shieldTemplate[0], true ) ).appendTo( $this );
+ $shield.on( 'dblclick', function () {
+ node.emit( 'dblclick' );
+ } );
node.$shields = node.$shields.add( $shield );
}
} );
@@ -212,13 +215,17 @@
*/
ve.ce.ProtectedNode.prototype.createPhantoms = function () {
var $phantomTemplate = this.constructor.static.$phantomTemplate,
- surface = this.root.getSurface();
+ surface = this.root.getSurface(),
+ node = this;
this.$phantomable.find( '.ve-ce-protectedNode-shield' ).each(
ve.bind( function () {
this.$phantoms = this.$phantoms.add(
this.$( this.$.context.importNode(
$phantomTemplate[0], true ) )
.on( 'mousedown', ve.bind(
this.onPhantomMouseDown, this ) )
+ .on( 'dblclick', function () {
+ node.emit( 'dblclick' );
+ } )
);
}, this )
);
diff --git a/modules/ve/ce/ve.ce.RelocatableNode.js
b/modules/ve/ce/ve.ce.RelocatableNode.js
index 475e691..c3a0eda 100644
--- a/modules/ve/ce/ve.ce.RelocatableNode.js
+++ b/modules/ve/ce/ve.ce.RelocatableNode.js
@@ -37,7 +37,10 @@
.attr( 'src',
'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' )
.on( {
'dragstart': ve.bind( this.onRelocatableDragStart, this
),
- 'dragend': ve.bind( this.onRelocatableDragEnd, this )
+ 'dragend': ve.bind( this.onRelocatableDragEnd, this ),
+ 'dblclick': ve.bind( function () {
+ this.emit( 'dblclick' );
+ }, this )
} );
};
--
To view, visit https://gerrit.wikimedia.org/r/103062
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8df07f413d9e295b960b7d0c82224aa37fdd637e
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Robmoen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits