Catrope has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/345644 )
Change subject: MenuSelectWidget: Add config.$autoCloseIgnore
......................................................................
MenuSelectWidget: Add config.$autoCloseIgnore
The only way to control auto-closing behavior was through
config.widget, which expects a widget and only took
one element.
Change-Id: I3029fd478ce220a7f3a925314fb6d0ea0469c54b
---
M src/widgets/MenuSelectWidget.js
1 file changed, 8 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/44/345644/1
diff --git a/src/widgets/MenuSelectWidget.js b/src/widgets/MenuSelectWidget.js
index e71f34b..236ef3a 100644
--- a/src/widgets/MenuSelectWidget.js
+++ b/src/widgets/MenuSelectWidget.js
@@ -37,6 +37,7 @@
* that toggles the menu's visibility on click, the menu will be hidden then
re-shown when the user clicks
* that button, unless the button (or its parent widget) is passed in here.
* @cfg {boolean} [autoHide=true] Hide the menu when the mouse is pressed
outside the menu.
+ * @cfg {jQuery} [$autoCloseIgnore] If these elements are clicked, don't
auto-hide the menu.
* @cfg {boolean} [hideOnChoose=true] Hide the menu when the user chooses an
option.
* @cfg {boolean} [filterFromInput=false] Filter the displayed options from
the input
*/
@@ -56,6 +57,7 @@
this.filterFromInput = !!config.filterFromInput;
this.$input = config.$input ? config.$input : config.input ?
config.input.$input : null;
this.$widget = config.widget ? config.widget.$element : null;
+ this.$autoCloseIgnore = config.$autoCloseIgnore || $( [] );
this.onDocumentMouseDownHandler = this.onDocumentMouseDown.bind( this );
this.onInputEditHandler = OO.ui.debounce(
this.updateItemVisibility.bind( this ), 100 );
@@ -86,8 +88,12 @@
*/
OO.ui.MenuSelectWidget.prototype.onDocumentMouseDown = function ( e ) {
if (
- !OO.ui.contains( this.$element[ 0 ], e.target, true ) &&
- ( !this.$widget || !OO.ui.contains( this.$widget[ 0 ],
e.target, true ) )
+ this.isVisible() &&
+ !OO.ui.contains(
+ this.$element.add( this.$widget ).add(
this.$autoCloseIgnore ).get(),
+ e.target,
+ true
+ )
) {
this.toggle( false );
}
--
To view, visit https://gerrit.wikimedia.org/r/345644
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3029fd478ce220a7f3a925314fb6d0ea0469c54b
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits