mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
reworked dialog closing mechanics -- added close reason (accept/reject)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
db078e4ebb
commit
5043e19db8
@ -973,7 +973,7 @@ var FileSystemLoaderUIActions = actions.Actions({
|
||||
// single loader...
|
||||
if(callback && callback.constructor === Function){
|
||||
// close self and parent...
|
||||
o.parent.close()
|
||||
o.close()
|
||||
|
||||
callback(path)
|
||||
|
||||
@ -1014,12 +1014,12 @@ var FileSystemLoaderUIActions = actions.Actions({
|
||||
})
|
||||
}
|
||||
|
||||
// show user the list...
|
||||
// show user the loader list...
|
||||
var so = that.showList(loaders, { path: 0 })
|
||||
// close self and parent...
|
||||
.open(function(){
|
||||
so.close()
|
||||
o.parent.close()
|
||||
o.close()
|
||||
})
|
||||
|
||||
return so
|
||||
@ -1091,7 +1091,7 @@ var FileSystemLoaderUIActions = actions.Actions({
|
||||
})
|
||||
})
|
||||
.on('open', function(){
|
||||
o.parent.close()
|
||||
o.close()
|
||||
})
|
||||
|
||||
return o
|
||||
@ -1627,7 +1627,7 @@ var FileSystemSaveHistoryUIActions = actions.Actions({
|
||||
})
|
||||
})
|
||||
.on('open', function(){
|
||||
o.parent.close()
|
||||
o.close()
|
||||
})
|
||||
|
||||
return o
|
||||
@ -2556,10 +2556,11 @@ var FileSystemWriterUIActions = actions.Actions({
|
||||
// XXX indicate export state: index, crop, image...
|
||||
return 'Export'}])
|
||||
.on('open', function(){
|
||||
var mode = that.config['export-dialog-modes'][that.config['export-dialog-mode']]
|
||||
var mode =
|
||||
that.config['export-dialog-modes'][that.config['export-dialog-mode']]
|
||||
that[mode.action](
|
||||
that.config['export-path'] || undefined)
|
||||
dialog.parent.close()
|
||||
dialog.close()
|
||||
})
|
||||
.addClass('selected')
|
||||
|
||||
|
||||
@ -530,18 +530,6 @@ var URLHistoryUIActions = actions.Actions({
|
||||
|
||||
return list
|
||||
}
|
||||
// this will take care of any number of child dialogs...
|
||||
// XXX should this be generic???
|
||||
var onOpen = function(){
|
||||
// we are the top dialog --> close...
|
||||
if(that.modal.client === o){
|
||||
o.close()
|
||||
|
||||
// child dialog, ask to close us when opening...
|
||||
} else {
|
||||
that.modal.client.open(onOpen)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var o = browse.makeLister(null,
|
||||
@ -601,21 +589,12 @@ var URLHistoryUIActions = actions.Actions({
|
||||
.open(function(evt, path){
|
||||
removeStriked('open')
|
||||
|
||||
o.parent.close()
|
||||
|
||||
// close the parent ui...
|
||||
parent
|
||||
&& parent.close
|
||||
&& parent.close()
|
||||
o.close()
|
||||
|
||||
that.openURLFromHistory(path)
|
||||
})
|
||||
.on('close', function(){
|
||||
removeStriked('close')
|
||||
|
||||
parent
|
||||
&& parent.focus
|
||||
&& parent.focus()
|
||||
})
|
||||
|
||||
// Monkey-patch: fast redraw...
|
||||
@ -643,7 +622,11 @@ var URLHistoryUIActions = actions.Actions({
|
||||
|
||||
// handle 'O' button to browse path...
|
||||
o.browsePath = function(p){
|
||||
that.browsePath(p || this.selected).open(onOpen) }
|
||||
that.browsePath(p || this.selected)
|
||||
.close(function(evt, reason){
|
||||
reason != 'reject'
|
||||
&& o.close(reason)
|
||||
}) }
|
||||
// clone the bindings so as not to mess up the global browser...
|
||||
o.keybindings = JSON.parse(JSON.stringify(o.keybindings))
|
||||
o.keyboard.handler('General', 'O', 'browsePath')
|
||||
|
||||
@ -69,11 +69,11 @@ var SlideshowActions = actions.Actions({
|
||||
// list maximum length is reached...
|
||||
overflow: function(value){
|
||||
that.config['slideshow-interval'] = value
|
||||
o.parent.close()
|
||||
o.close()
|
||||
},
|
||||
itemopen: function(value){
|
||||
that.config['slideshow-interval'] = value
|
||||
o.parent.close()
|
||||
o.close()
|
||||
},
|
||||
})
|
||||
.on('close', function(){
|
||||
@ -97,14 +97,14 @@ var SlideshowActions = actions.Actions({
|
||||
suspended_timer || this.suspendSlideshowTimer()
|
||||
|
||||
// XXX might be a good idea to make this generic...
|
||||
var _makeTogglHandler = function(toggler){
|
||||
var _makeToggleHandler = function(toggler){
|
||||
return function(){
|
||||
var txt = $(this).find('.text').first().text()
|
||||
that[toggler]()
|
||||
o.update()
|
||||
.then(function(){ o.select(txt) })
|
||||
that.toggleSlideshow('?') == 'on'
|
||||
&& o.parent.close()
|
||||
&& o.close()
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ var SlideshowActions = actions.Actions({
|
||||
.on('close', function(){
|
||||
// slideshow is running -- close directly...
|
||||
if(that.toggleSlideshow('?') == 'on'){
|
||||
o.parent.close()
|
||||
o.close()
|
||||
|
||||
} else {
|
||||
o.update()
|
||||
@ -138,17 +138,17 @@ var SlideshowActions = actions.Actions({
|
||||
|
||||
make(['Direction: ',
|
||||
function(){ return that.config['slideshow-direction'] }])
|
||||
.on('open', _makeTogglHandler('toggleSlideshowDirection'))
|
||||
.on('open', _makeToggleHandler('toggleSlideshowDirection'))
|
||||
make(['Looping: ',
|
||||
function(){ return that.config['slideshow-looping'] }])
|
||||
.on('open', _makeTogglHandler('toggleSlideshowLooping'))
|
||||
.on('open', _makeToggleHandler('toggleSlideshowLooping'))
|
||||
|
||||
// Start/stop...
|
||||
make([function(){
|
||||
return that.toggleSlideshow('?') == 'on' ? 'Stop' : 'Start' }])
|
||||
.on('open', function(){
|
||||
that.toggleSlideshow()
|
||||
o.parent.close()
|
||||
o.close()
|
||||
})
|
||||
.addClass('selected')
|
||||
},
|
||||
|
||||
@ -220,7 +220,8 @@ function(actions, list, list_key, value_key, options){
|
||||
actions.config[value_key] = value
|
||||
}
|
||||
|
||||
o.parent.close()
|
||||
// XXX revise...
|
||||
o.close()
|
||||
},
|
||||
}
|
||||
options.__proto__ = dfl_options
|
||||
@ -279,7 +280,7 @@ module.makeUIContainer = function(make){
|
||||
|
||||
o
|
||||
// notify the client that we are closing...
|
||||
.close(function(){ o.client.trigger('close') })
|
||||
.close(function(){ o.client.trigger('close', 'reject') })
|
||||
.client
|
||||
// NOTE: strictly this is the responsibility of the client
|
||||
// but it is less error prone to just in case also do
|
||||
@ -510,7 +511,7 @@ var DialogsActions = actions.Actions({
|
||||
if(func){
|
||||
this.dom.on('close', func)
|
||||
} else {
|
||||
this.dom.trigger('close')
|
||||
this.dom.trigger('close', 'reject')
|
||||
this.dom.remove()
|
||||
}
|
||||
return this
|
||||
@ -518,7 +519,7 @@ var DialogsActions = actions.Actions({
|
||||
}
|
||||
|
||||
dialog.on('blur', function(){
|
||||
panel.close()
|
||||
panel.close('reject')
|
||||
})
|
||||
|
||||
return panel
|
||||
@ -792,14 +793,16 @@ var BrowseActionsActions = actions.Actions({
|
||||
// we got a widget, wait for it to close...
|
||||
if(child instanceof widget.Widget){
|
||||
child
|
||||
.on('open', function(){ dialog.parent.close() })
|
||||
//.on('open', function(){ dialog.close() })
|
||||
.on('close', function(evt, reason){
|
||||
reason != 'reject'
|
||||
&& dialog.close(reason)
|
||||
})
|
||||
// XXX is this a hack???
|
||||
// ...for some reason when clicking child
|
||||
// loses focus while when opening via keyboard
|
||||
// everything is OK...
|
||||
.one('update', function(){ child.focus() })
|
||||
.parent
|
||||
.on('close', function(){ dialog.parent.focus() })
|
||||
//.one('update', function(){ child.focus() })
|
||||
|
||||
// if it's not a dialog, don't wait...
|
||||
} else {
|
||||
|
||||
@ -1007,7 +1007,7 @@ var BrowserPrototype = {
|
||||
|
||||
Enter: 'action',
|
||||
O: 'action',
|
||||
Esc: 'close',
|
||||
Esc: 'close: "reject"',
|
||||
|
||||
'/': 'startFilter!',
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ var OverlayPrototype = {
|
||||
//pattern: '.overlay-widget',
|
||||
pattern: '*',
|
||||
|
||||
Esc: 'close',
|
||||
Esc: 'close: "reject"',
|
||||
},
|
||||
},
|
||||
|
||||
@ -99,7 +99,7 @@ var OverlayPrototype = {
|
||||
this.dom
|
||||
.click(function(){
|
||||
if(that.options.closeOnUnFocusedClick || focused){
|
||||
that.close()
|
||||
that.close('reject')
|
||||
|
||||
// don't make the user wait if they really wants to close...
|
||||
} else {
|
||||
|
||||
@ -87,16 +87,20 @@ var WidgetPrototype = {
|
||||
undeligate: proxyToDom('undeligate'),
|
||||
|
||||
// custom events...
|
||||
close: function(handler){
|
||||
//
|
||||
// NOTE: this can be passed a string that can be used as a reason
|
||||
// for closing...
|
||||
close: function(a){
|
||||
// trigger...
|
||||
if(handler == null){
|
||||
if(a == null || typeof(a) == typeof('str')){
|
||||
a = a || 'accept'
|
||||
this.parent.close
|
||||
&& this.parent.close()
|
||||
this.trigger('close')
|
||||
&& this.parent.close(a)
|
||||
this.trigger('close', a)
|
||||
|
||||
// register new handler...
|
||||
} else {
|
||||
this.on('close', handler)
|
||||
this.on('close', a)
|
||||
}
|
||||
return this
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user