now clicking an unfocused window will not close the overlay...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-12-15 03:44:50 +03:00
parent ed0388e852
commit ff6117c1c9
2 changed files with 29 additions and 2 deletions

View File

@ -1122,7 +1122,6 @@ var BrowserPrototype = {
.map(function(e){ return e.replace(/\\(\s)/, '$1') })
.join('|')
+ ')', 'gi')
console.log('>>>>', p, pattern)
// XXX should this be case insensitive???
this.filter(pattern,
// rejected...

View File

@ -55,6 +55,8 @@ var OverlayPrototype = {
'click',
'keydown',
],
closeOnUnFocusedClick: false,
},
// XXX for some reason this does not work...
@ -89,9 +91,35 @@ var OverlayPrototype = {
object.superMethod(Overlay, '__init__').call(this, parent, client, options)
// Prevent closing the overlay if clicked while blurred...
// i.e.
// 1'st click -- focus window
// 2'nd click -- close overlay
//
// XXX HACK: need a better way to do this...
var focused
var unlock = function() { setTimeout(function(){ focused = true }, 200) }
var lock = function() { focused = false }
// blur-lock...
$(window)
.focus(unlock)
.blur(lock)
// cleanup...
this.close(function(){
$(window)
.off('focus', unlock)
.off('blur', lock)
})
this.dom
.click(function(){
if(that.options.closeOnUnFocusedClick || focused){
that.close()
// don't make the user wait if they really wants to close...
} else {
focused = true
}
})
this.parent