File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 1
- # 1.16 .0-1 / Unreleased
1
+ # 1.17 .0-1 / Unreleased
2
2
3
3
* [ FEATURE] #116 ` autoFocus ` skips leading disabled entries.
4
+ * [ FEATURE] #118 New option ` closeOnWindowBlur `
4
5
* Use ` .on() ` / ` .off() ` syntax
5
6
* Add check for missing ` .delegate ` option
6
7
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ $.widget("moogle.contextmenu", {
34
34
version : "@VERSION" ,
35
35
options : {
36
36
addClass : "ui-contextmenu" , // Add this class to the outer <ul>
37
+ closeOnWindowBlur : true , // Close menu when window loses focus
37
38
autoFocus : false , // Set keyboard focus to first entry on open
38
39
autoTrigger : true , // open menu on browser's `contextmenu` event
39
40
delegate : null , // selector
@@ -244,6 +245,11 @@ $.widget("moogle.contextmenu", {
244
245
self . _closeMenu ( ) ;
245
246
}
246
247
} ) ;
248
+ $ ( window ) . on ( "blur" + this . eventNamespace , function ( event ) {
249
+ if ( opts . closeOnWindowBlur ) {
250
+ self . _closeMenu ( ) ;
251
+ }
252
+ } ) ;
247
253
248
254
// required for custom positioning (issue #18 and #13).
249
255
if ( $ . isFunction ( posOption ) ) {
@@ -299,6 +305,8 @@ $.widget("moogle.contextmenu", {
299
305
. off ( "mousedown" + this . eventNamespace )
300
306
. off ( "touchstart" + this . eventNamespace )
301
307
. off ( "keydown" + this . eventNamespace ) ;
308
+ $ ( window )
309
+ . off ( "blur" + this . eventNamespace ) ;
302
310
303
311
self . currentTarget = null ; // issue #44 after hide animation is too late
304
312
self . extraData = { } ;
You can’t perform that action at this time.
0 commit comments