moved more dialogs to the new framework, almost done...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-04-30 05:25:43 +03:00
parent 39a67645de
commit a00cf871c4
2 changed files with 91 additions and 94 deletions

View File

@ -445,22 +445,21 @@ var FileSystemLoaderUIActions = actions.Actions({
// menu is shown... // menu is shown...
// XXX should the loader list be nested or open in overlay (as-is now)??? // XXX should the loader list be nested or open in overlay (as-is now)???
browsePath: ['File/Browse file system...', browsePath: ['File/Browse file system...',
function(base, callback){ widgets.makeUIDialog(function(base, callback){
var that = this var that = this
base = base || this.location.path || '/' base = base || this.location.path || '/'
var o = overlay.Overlay(this.ribbons.viewer, var o = browseWalk.makeWalk(
browseWalk.makeWalk(
null, base, this.config['image-file-pattern'], null, base, this.config['image-file-pattern'],
this.config['file-browser-settings']) this.config['file-browser-settings'])
// path selected... // path selected...
.open(function(evt, path){ .open(function(evt, path){
var item = o.client.selected var item = o.selected
// single loader... // single loader...
if(callback && callback.constructor === Function){ if(callback && callback.constructor === Function){
// close self and parent... // close self and parent...
o.close() o.parent.close()
callback(path) callback(path)
@ -481,36 +480,35 @@ var FileSystemLoaderUIActions = actions.Actions({
} }
// show user the list... // show user the list...
var so = overlay.Overlay(that.ribbons.viewer, var so = that.Overlay(browse.makeList(null, loaders)
browse.makeList(null, loaders)
// close self and parent... // close self and parent...
.open(function(){ .open(function(){
so.close() so.close()
o.close() o.parent.close()
})) }))
// closed menu... // closed menu...
.close(function(){ .close(function(){
o.focus() //o.parent.focus()
o.client.select(item) o.select(item)
}) })
// select top element... // select top element...
so.client.select(0) so.client.select(0)
return so return so
} }
})) })
// we closed the browser -- save settings to .config... // we closed the browser -- save settings to .config...
.close(function(){ .on('close', function(){
var config = that.config['file-browser-settings'] var config = that.config['file-browser-settings']
config.disableFiles = o.client.options.disableFiles config.disableFiles = o.options.disableFiles
config.showDisabled = o.client.options.showDisabled config.showDisabled = o.options.showDisabled
config.showNonTraversable = o.client.options.showNonTraversable config.showNonTraversable = o.options.showNonTraversable
}) })
return o return o
}], })],
// NOTE: if no path is passed (null) these behave just like .browsePath(..) // NOTE: if no path is passed (null) these behave just like .browsePath(..)
// with the appropriate callback otherwise it will just load // with the appropriate callback otherwise it will just load
@ -602,7 +600,7 @@ module.FileSystemLoaderURLHistoryUI = core.ImageGridFeatures.Feature({
['browsePath', ['browsePath',
function(res){ function(res){
var that = this var that = this
res.client.open(function(_, path){ res.open(function(_, path){
that.setTopURLHistory(path) that.setTopURLHistory(path)
}) })
}], }],
@ -1288,7 +1286,7 @@ var FileSystemWriterUIActions = actions.Actions({
// // actions - the actions object // // actions - the actions object
// // make - browse item constructor // // make - browse item constructor
// // (see: browse.Browser.update(..) for more info) // // (see: browse.Browser.update(..) for more info)
// // overlay - the containing overlay object // // parent - the parent dialog
// <key>: function(actions, make, overlay){ ... }, // <key>: function(actions, make, overlay){ ... },
// ... // ...
// } // }
@ -1296,31 +1294,31 @@ var FileSystemWriterUIActions = actions.Actions({
// NOTE: .__export_dialog_fields__ can be defined both in the feature // NOTE: .__export_dialog_fields__ can be defined both in the feature
// as well as in the instance. // as well as in the instance.
__export_dialog_fields__: { __export_dialog_fields__: {
'pattern': function(actions, make, overlay){ 'pattern': function(actions, make, parent){
return make(['Filename pattern: ', return make(['Filename pattern: ',
function(){ function(){
return actions.config['export-preview-name-pattern'] || '%f' }]) return actions.config['export-preview-name-pattern'] || '%f' }])
.on('open', .on('open',
widgets.makeNestedConfigListEditor(actions, overlay, widgets.makeNestedConfigListEditor(actions, parent,
'export-preview-name-patterns', 'export-preview-name-patterns',
'export-preview-name-pattern')) 'export-preview-name-pattern'))
}, },
'level_dir': function(actions, make, overlay){ 'level_dir': function(actions, make, parent){
return make(['Level directory: ', return make(['Level directory: ',
function(){ function(){
return actions.config['export-level-directory-name'] || 'fav' }]) return actions.config['export-level-directory-name'] || 'fav' }])
.on('open', .on('open',
widgets.makeNestedConfigListEditor(actions, overlay, widgets.makeNestedConfigListEditor(actions, parent,
'export-level-directory-names', 'export-level-directory-names',
'export-level-directory-name')) 'export-level-directory-name'))
}, },
'size': function(actions, make, overlay){ 'size': function(actions, make, parent){
return make(['Image size: ', return make(['Image size: ',
function(){ function(){
return actions.config['export-preview-size'] || 1000 }]) return actions.config['export-preview-size'] || 1000 }])
// XXX add validation??? // XXX add validation???
.on('open', .on('open',
widgets.makeNestedConfigListEditor(actions, overlay, widgets.makeNestedConfigListEditor(actions, parent,
'export-preview-sizes', 'export-preview-sizes',
'export-preview-size', 'export-preview-size',
{ {
@ -1329,7 +1327,7 @@ var FileSystemWriterUIActions = actions.Actions({
}, },
// XXX BUG: history closing errors -- non-critical... // XXX BUG: history closing errors -- non-critical...
'target_dir': function(actions, make, overlay){ 'target_dir': function(actions, make, parent){
var elem = make(['To: ', var elem = make(['To: ',
function(){ return actions.config['export-path'] || './' }], function(){ return actions.config['export-path'] || './' }],
{ buttons: [ { buttons: [
@ -1344,15 +1342,12 @@ var FileSystemWriterUIActions = actions.Actions({
actions.config['export-path'] = path actions.config['export-path'] = path
actions.config['export-paths'].splice(0, 0, path) actions.config['export-paths'].splice(0, 0, path)
overlay.client.update() parent.update()
overlay.client.select(txt) parent.select(txt)
// XXX ugly...
overlay.focus()
}) })
}], }],
// XXX BUG: closing this breaks on parant.focus()... // XXX BUG: closing this breaks on parant.focus()...
['histroy', widgets.makeNestedConfigListEditor(actions, overlay, ['histroy', widgets.makeNestedConfigListEditor(actions, parent,
'export-paths', 'export-paths',
'export-path', 'export-path',
{ {
@ -1377,9 +1372,9 @@ var FileSystemWriterUIActions = actions.Actions({
}) })
.on('edit-aborted edit-done', function(evt, path){ .on('edit-aborted edit-done', function(evt, path){
overlay.client.update() parent.update()
.then(function(){ .then(function(){
overlay.client.select(path) parent.select(path)
}) })
}) })
}) })
@ -1387,11 +1382,11 @@ var FileSystemWriterUIActions = actions.Actions({
}, },
// XXX indicate export state: index, crop, image... // XXX indicate export state: index, crop, image...
exportDialog: ['File/Export/Export optioons...', exportDialog: ['File/Export/Export optioons...',
function(){ widgets.makeUIDialog(function(){
var that = this var that = this
var o = overlay.Overlay(this.ribbons.viewer, var o = browse.makeLister(null, function(path, make){
browse.makeLister(null, function(path, make){ var dialog = this
var mode = that.config['export-dialog-mode'] || 'Images only' var mode = that.config['export-dialog-mode'] || 'Images only'
var data = that.config['export-dialog-modes'][mode].data var data = that.config['export-dialog-modes'][mode].data
@ -1413,9 +1408,9 @@ var FileSystemWriterUIActions = actions.Actions({
// build the fields... // build the fields...
data.forEach(function(k){ data.forEach(function(k){
(fields[k] (fields[k]
&& fields[k].call(that, that, make, o)) && fields[k].call(that, that, make, dialog))
|| (base_fields[k] || (base_fields[k]
&& base_fields[k].call(that, that, make, o)) && base_fields[k].call(that, that, make, dialog))
}) })
// Start/stop action... // Start/stop action...
@ -1426,15 +1421,18 @@ var FileSystemWriterUIActions = actions.Actions({
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[mode.action](
that.config['export-path'] || that.location.path) that.config['export-path'] || that.location.path)
o.close() dialog.parent.close()
})
}) })
}))
o.client.dom.addClass('metadata-view tail-action') o.dom.addClass('metadata-view tail-action')
o.client.select(-1)
setTimeout(function(){
o.select(-1)
}, 0)
return o return o
}], })],
}) })

View File

@ -239,7 +239,7 @@ function(actions, list_key, options){
// can this be simpler??? // can this be simpler???
var makeNestedConfigListEditor = var makeNestedConfigListEditor =
module.makeNestedConfigListEditor = module.makeNestedConfigListEditor =
function(actions, parent, list_key, value_key, options){ function(actions, list, list_key, value_key, options){
options = options || {} options = options || {}
return function(){ return function(){
@ -257,7 +257,7 @@ function(actions, parent, list_key, value_key, options){
actions.config[value_key] = value actions.config[value_key] = value
} }
o.close() o.parent.close()
}, },
} }
options.__proto__ = dfl_options options.__proto__ = dfl_options
@ -265,22 +265,21 @@ function(actions, parent, list_key, value_key, options){
var o = makeConfigListEditor(actions, list_key, options) var o = makeConfigListEditor(actions, list_key, options)
// update slideshow menu... // update slideshow menu...
o.client.open(function(){ o.open(function(){
parent.client.update() list.update()
parent.client.select(txt) list.select(txt)
}) })
o.close(function(){ actions.Overlay(o)
// XXX this is ugly...
parent.focus()
})
setTimeout(function(){
if(typeof(value_key) == typeof(function(){})){ if(typeof(value_key) == typeof(function(){})){
o.client.select(value_key()) o.select(value_key())
} else { } else {
o.client.select(actions.config[value_key]) o.select(actions.config[value_key])
} }
}, 0)
} }
} }