reworked the widget.close event workings, now alot more uniform...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-01-06 05:17:14 +03:00
parent 6a7f440bc7
commit 096fb9957e
3 changed files with 36 additions and 30 deletions

View File

@ -312,9 +312,9 @@ var BrowserPrototype = {
'select',
'deselect',
//'keydown',
'keydown',
'close',
//'close',
],
// Shorthand elements...
@ -1140,7 +1140,7 @@ var BrowserPrototype = {
hidden ? 'hidden' : '',
opts.hide_on_search ? 'hide-on-search' : '',
(opts.hide_on_search || opts.not_searchable) ? 'not-searchable' : '',
opts.not_filtered_out ? 'not_filtered_out' : '',
opts.not_filtered_out ? 'not-filtered-out' : '',
].join(' '))
opts.push_on_open && res.attr('push-on-open', 'on')
@ -1520,7 +1520,7 @@ var BrowserPrototype = {
this.filter(pattern,
// rejected...
function(i, e){
!e.hasClass('not-filterd-out')
!e.hasClass('not-filtered-out')
&& e.addClass('filtered-out')
e.removeClass('selected')

View File

@ -71,23 +71,6 @@ var OverlayPrototype = {
},
},
// custom events...
close: function(handler){
// trigger the event...
if(handler == null){
this.dom.detach()
if(this.parent.children('.overlay-widget').length == 0){
this.parent.removeClass('blur')
}
this.trigger('close')
// register a handler...
} else {
this.on('close', handler)
}
return this
},
__init__: function(parent, client, options){
var that = this
@ -128,10 +111,18 @@ var OverlayPrototype = {
.addClass('blur')
.append(this.dom)
// pass focus to the client if it is not focused already...
this.on('focus click', function(){
client.focus && client.focus()
})
this
// pass focus to the client if it is not focused already...
.on('focus click', function(){
client.focus && client.focus()
})
// close...
.close(function(){
that.dom.detach()
if(that.parent.children('.overlay-widget').length == 0){
that.parent.removeClass('blur')
}
})
this.focus()

View File

@ -85,6 +85,20 @@ var WidgetPrototype = {
deligate: proxyToDom('deligate'),
undeligate: proxyToDom('undeligate'),
// custom events...
close: function(handler){
// trigger...
if(handler == null){
this.parent.close
&& this.parent.close()
this.trigger('close')
// register new handler...
} else {
this.on('close', handler)
}
return this
},
// XXX this will not:
// - attach dom to parent... (???)
@ -117,11 +131,12 @@ var WidgetPrototype = {
// add keyboard handler...
if(this.keyboard && this.dom){
this.dom.keydown(
keyboard.makeKeyboardHandler(
this.keyboard,
options.logKeys,
this))
this.dom
.keydown(
keyboard.makeKeyboardHandler(
this.keyboard,
options.logKeys,
this))
}
if(this.options.nonPropagatedEvents != null){