jenkins-bot has submitted this change and it was merged.
Change subject: Make it possible to add interactiveHandlers to elements on focus
......................................................................
Make it possible to add interactiveHandlers to elements on focus
We have things automatically happening on focus already (topic reply form
expanding, for example), but no way to hook into that with interactiveHandler
Change-Id: I319afee108891e9589ff4893f104c1126879c9db
---
M modules/engine/components/common/flow-component-events.js
1 file changed, 43 insertions(+), 13 deletions(-)
Approvals:
EBernhardson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/engine/components/common/flow-component-events.js
b/modules/engine/components/common/flow-component-events.js
index 8cd872e..bbf0a22 100644
--- a/modules/engine/components/common/flow-component-events.js
+++ b/modules/engine/components/common/flow-component-events.js
@@ -46,6 +46,11 @@
_getDispatchCallback( this,
'interactiveHandler' )
)
.on(
+ 'focusin.FlowBoardComponent',
+ 'a, input, button, .flow-click-interactive',
+ _getDispatchCallback( this,
'interactiveHandlerFocus' )
+ )
+ .on(
'click.FlowBoardComponent
focusin.FlowBoardComponent focusout.FlowBoardComponent',
'.flow-menu',
_getDispatchCallback( this, 'toggleHoverMenu' )
@@ -388,7 +393,7 @@
$this.find( 'input, textarea' ).trigger( 'keyup' );
// Find this form's inputs
- $this.find( 'textarea' ).filter(
'[data-flow-expandable]').each( function () {
+ $this.find( 'textarea' ).filter(
'[data-flow-expandable]' ).each( function () {
// Compress textarea if:
// the textarea isn't already focused
// and the textarea doesn't have text typed
into it
@@ -418,19 +423,14 @@
FlowComponentEventsMixin.eventHandlers.loadHandler =
flowLoadHandlerCallback;
/**
- * Triggers both API and interactive handlers.
+ * Executes interactive handlers.
+ *
+ * @param {array} args
+ * @param {jQuery} $context
+ * @param {string} interactiveHandlerName
+ * @param {string} apiHandlerName
*/
- function flowInteractiveHandlerCallback( event ) {
- // Only trigger with enter key, if keypress
- if ( event.type === 'keypress' && ( event.charCode !== 13 ||
event.metaKey || event.shiftKey || event.ctrlKey || event.altKey )) {
- return;
- }
-
- var args = Array.prototype.slice.call( arguments, 0 ),
- $context = $( event.currentTarget ||
event.delegateTarget || event.target ),
- interactiveHandlerName = $context.data(
'flow-interactive-handler' ),
- apiHandlerName = $context.data( 'flow-api-handler' );
-
+ function flowExecuteInteractiveHandler( args, $context,
interactiveHandlerName, apiHandlerName ) {
// Call any matching interactive handlers
if ( this.UI.events.interactiveHandlers[interactiveHandlerName]
) {
$.each(
this.UI.events.interactiveHandlers[interactiveHandlerName], function ( i, fn ) {
@@ -447,10 +447,40 @@
this.debug( 'Failed to find apiHandler',
apiHandlerName, arguments );
}
}
+
+ /**
+ * Triggers both API and interactive handlers, on click/enter.
+ */
+ function flowInteractiveHandlerCallback( event ) {
+ // Only trigger with enter key, if keypress
+ if ( event.type === 'keypress' && ( event.charCode !== 13 ||
event.metaKey || event.shiftKey || event.ctrlKey || event.altKey )) {
+ return;
+ }
+
+ var args = Array.prototype.slice.call( arguments, 0 ),
+ $context = $( event.currentTarget ||
event.delegateTarget || event.target ),
+ interactiveHandlerName = $context.data(
'flow-interactive-handler' ),
+ apiHandlerName = $context.data( 'flow-api-handler' );
+
+ return flowExecuteInteractiveHandler.call( this, args,
$context, interactiveHandlerName, apiHandlerName );
+ }
FlowComponentEventsMixin.eventHandlers.interactiveHandler =
flowInteractiveHandlerCallback;
FlowComponentEventsMixin.eventHandlers.apiRequest =
flowInteractiveHandlerCallback;
/**
+ * Triggers both API and interactive handlers, on focus.
+ */
+ function flowInteractiveHandlerFocusCallback( event ) {
+ var args = Array.prototype.slice.call( arguments, 0 ),
+ $context = $( event.currentTarget ||
event.delegateTarget || event.target ),
+ interactiveHandlerName = $context.data(
'flow-interactive-handler-focus' ),
+ apiHandlerName = $context.data(
'flow-api-handler-focus' );
+
+ return flowExecuteInteractiveHandler.call( this, args,
$context, interactiveHandlerName, apiHandlerName );
+ }
+ FlowComponentEventsMixin.eventHandlers.interactiveHandlerFocus =
flowInteractiveHandlerFocusCallback;
+
+ /**
* When the whole class has been instantiated fully (after every
constructor has been called).
* @param {FlowComponent} component
*/
--
To view, visit https://gerrit.wikimedia.org/r/173325
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I319afee108891e9589ff4893f104c1126879c9db
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits