jenkins-bot has submitted this change and it was merged.
Change subject: MenuWidget: Don't close menu when you click the scroll bar
......................................................................
MenuWidget: Don't close menu when you click the scroll bar
Copies in VE core's contains function
Bug: 65774
Change-Id: I2a059933c8b99c2eb93c0f9aa8075676e5783005
---
M src/core.js
M src/widgets/MenuWidget.js
2 files changed, 28 insertions(+), 1 deletion(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/core.js b/src/core.js
index d3a91f9..96d31e5 100644
--- a/src/core.js
+++ b/src/core.js
@@ -79,6 +79,30 @@
return undefined;
};
+/**
+ * Check if a node is contained within another node
+ *
+ * Similar to jQuery#contains except a list of containers can be supplied
+ * and a boolean argument allows you to include the container in the match list
+ *
+ * @param {HTMLElement|HTMLElement[]} containers Container node(s) to search in
+ * @param {HTMLElement} contained Node to find
+ * @param {boolean} [matchContainers] Include the container(s) in the list of
nodes to match, otherwise only match descendents
+ * @returns {boolean} The node is in the list of target nodes
+ */
+OO.ui.contains = function ( containers, contained, matchContainers ) {
+ var i;
+ if ( !Array.isArray( containers ) ) {
+ containers = [ containers ];
+ }
+ for ( i = containers.length - 1; i >= 0; i-- ) {
+ if ( ( matchContainers && contained === containers[i] ) ||
$.contains( containers[i], contained ) ) {
+ return true;
+ }
+ }
+ return false;
+};
+
( function () {
/**
* Message store for the default implementation of OO.ui.msg
diff --git a/src/widgets/MenuWidget.js b/src/widgets/MenuWidget.js
index dec2baa..2a0467a 100644
--- a/src/widgets/MenuWidget.js
+++ b/src/widgets/MenuWidget.js
@@ -58,7 +58,10 @@
* @param {jQuery.Event} e Key down event
*/
OO.ui.MenuWidget.prototype.onDocumentMouseDown = function ( e ) {
- if ( !$.contains( this.$element[0], e.target ) && ( !this.$widget ||
!$.contains( this.$widget[0], e.target ) ) ) {
+ if (
+ !OO.ui.contains( this.$element[0], e.target, true ) &&
+ ( !this.$widget || !OO.ui.contains( this.$widget[0], e.target,
true ) )
+ ) {
this.toggle( false );
}
};
--
To view, visit https://gerrit.wikimedia.org/r/172723
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2a059933c8b99c2eb93c0f9aa8075676e5783005
Gerrit-PatchSet: 6
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits