Catrope has uploaded a new change for review.
https://gerrit.wikimedia.org/r/98115
Change subject: Add focus and blur events to ce.Surface
......................................................................
Add focus and blur events to ce.Surface
Didn't bother to deduplicate blur-focus event pairs that occur when the
focus moves from the documentNode to the pasteTarget or vice versa
(this happens when switching between normal selection and FocusableNode
selection).
Change-Id: If1ccd2fbf11de956b6c2364ae81b9dc20a1bf409
---
M modules/ve/ce/ve.ce.Surface.js
1 file changed, 18 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/15/98115/1
diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js
index 7f7a57c..3dda86a 100644
--- a/modules/ve/ce/ve.ce.Surface.js
+++ b/modules/ve/ce/ve.ce.Surface.js
@@ -146,6 +146,20 @@
* @event relocationEnd
*/
+/**
+ * @event focus
+ * Note that it's possible for a focus event to occur immediately after a blur
event, if the focus
+ * moves to or from a FocusableNode. In this case the surface doesn't lose
focus conceptually, but
+ * a pair of blur-focus events is emitted anyway.
+ */
+
+/**
+ * @event blur
+ * Note that it's possible for a focus event to occur immediately after a blur
event, if the focus
+ * moves to or from a FocusableNode. In this case the surface doesn't lose
focus conceptually, but
+ * a pair of blur-focus events is emitted anyway.
+ */
+
/* Static methods */
/**
@@ -317,6 +331,7 @@
*
* @method
* @param {Event} e Focus event (native event, NOT a jQuery event!)
+ * @fires focus
*/
ve.ce.Surface.prototype.documentOnFocus = function ( e ) {
if ( e.target === this.documentView.getDocumentNode().$element[0] ) {
@@ -326,6 +341,7 @@
}
this.eventSequencer.attach( this.$element );
this.surfaceObserver.startTimerLoop();
+ this.emit( 'focus' );
};
/**
@@ -333,12 +349,14 @@
*
* @method
* @param {Event} e Blur event (native event, NOT a jQuery event!)
+ * @fires blur
*/
ve.ce.Surface.prototype.documentOnBlur = function () {
this.eventSequencer.detach();
this.surfaceObserver.stopTimerLoop();
this.surfaceObserver.pollOnce();
this.dragging = false;
+ this.emit( 'blur' );
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/98115
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If1ccd2fbf11de956b6c2364ae81b9dc20a1bf409
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits