mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
some refining and cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
e4897d5c31
commit
a62e144570
@ -1111,6 +1111,15 @@ module.FileSystemWriter = core.ImageGridFeatures.Feature({
|
||||
// - save as.. (browser)
|
||||
// - save if not base path present (browser)
|
||||
var FileSystemWriterUIActions = actions.Actions({
|
||||
config: {
|
||||
'export-dialog-mode': 'Directories',
|
||||
|
||||
'export-dialog-modes': {
|
||||
'Images only': 'exportDirs',
|
||||
'Full index': 'exportIndex',
|
||||
},
|
||||
},
|
||||
|
||||
// XXX this needs feedback...
|
||||
// XXX should this return a promise???
|
||||
saveIndexHere: ['File/Save',
|
||||
@ -1151,12 +1160,24 @@ var FileSystemWriterUIActions = actions.Actions({
|
||||
// - dirs
|
||||
// - ...
|
||||
// XXX indicate export state: index, crop, image...
|
||||
exportDirsDialog: ['File/Export/Images...',
|
||||
exportDialog: ['File/Export/Images...',
|
||||
function(){
|
||||
var that = this
|
||||
|
||||
var o = overlay.Overlay(this.ribbons.viewer,
|
||||
browse.makeLister(null, function(path, make){
|
||||
// XXX disable 'x' buttons...
|
||||
make(['Export mode: ',
|
||||
function(){ return that.config['export-dialog-mode'] || 'Directories' }])
|
||||
.on('open',
|
||||
widgets.makeNestedConfigListEditor(that, o,
|
||||
'export-dialog-modes',
|
||||
'export-dialog-mode',
|
||||
{
|
||||
new_button: false,
|
||||
itemButtons: [],
|
||||
}))
|
||||
|
||||
make(['Filename pattern: ',
|
||||
function(){ return that.config['export-preview-name-pattern'] || '%f' }])
|
||||
.on('open',
|
||||
@ -1182,8 +1203,10 @@ var FileSystemWriterUIActions = actions.Actions({
|
||||
make(['To: ',
|
||||
function(){ return that.config['export-path'] || './' }],
|
||||
{ buttons: [
|
||||
['browse', function(){
|
||||
var path = $(this).find('.text').last().text()
|
||||
['browse', function(p){
|
||||
var e = this.filter('"'+p+'"', false)
|
||||
var path = e.find('.text').last().text()
|
||||
var txt = e.find('.text').first().text()
|
||||
|
||||
// XXX add new dir global button...
|
||||
return that.browsePath(path,
|
||||
@ -1191,6 +1214,9 @@ var FileSystemWriterUIActions = actions.Actions({
|
||||
that.config['export-path'] = path
|
||||
that.config['export-paths'].splice(0, 0, path)
|
||||
|
||||
o.client.update()
|
||||
o.client.select(txt)
|
||||
|
||||
// XXX ugly...
|
||||
o.focus()
|
||||
})
|
||||
@ -1199,7 +1225,11 @@ var FileSystemWriterUIActions = actions.Actions({
|
||||
.on('open',
|
||||
widgets.makeNestedConfigListEditor(that, o,
|
||||
'export-paths',
|
||||
'export-path'))
|
||||
'export-path',
|
||||
{
|
||||
// XXX add 'edit' button...
|
||||
//itemButtons: []
|
||||
}))
|
||||
|
||||
// Start/stop...
|
||||
make([function(){
|
||||
@ -1208,7 +1238,7 @@ var FileSystemWriterUIActions = actions.Actions({
|
||||
.on('open', function(){
|
||||
// XXX is this correct???
|
||||
// XXX handle relative paths!!!
|
||||
that.exportDirs(that.config['export-path'] || that.location.path)
|
||||
that[that.config['export-mode']](that.config['export-path'] || that.location.path)
|
||||
o.close()
|
||||
})
|
||||
}))
|
||||
|
||||
@ -53,6 +53,9 @@ var browseWalk = require('lib/widget/browse-walk')
|
||||
// // this is called when a new value is added via new_button but
|
||||
// // list length limit is reached...
|
||||
// callback: function(selected){ ... },
|
||||
//
|
||||
// // see: itemButtons doc in browse.js for more info...
|
||||
// itemButtons: [..]
|
||||
// }
|
||||
//
|
||||
// XXX add sort buttons: up/down/top/bottom...
|
||||
@ -92,13 +95,18 @@ function(actions, list_key, options){
|
||||
|
||||
// list length limit
|
||||
if(options.length_limit
|
||||
&& (actions.config[list_key].length >= options.length_limit)){
|
||||
&& (lst.length >= options.length_limit)){
|
||||
|
||||
options.callback && options.callback.call(list, txt)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// prevent editing non-arrays...
|
||||
if(!(actions.config[list_key] instanceof Array)){
|
||||
return
|
||||
}
|
||||
|
||||
// save the new version...
|
||||
actions.config[list_key] = actions.config[list_key].slice()
|
||||
// add new value and sort list...
|
||||
@ -134,9 +142,12 @@ function(actions, list_key, options){
|
||||
|
||||
var to_remove = []
|
||||
|
||||
var lst = actions.config[list_key]
|
||||
lst = lst instanceof Array ? lst : Object.keys(lst)
|
||||
|
||||
var list = browse.makeList( null,
|
||||
actions.config[list_key].concat(new_button ? [ new_button ] : []),
|
||||
{itemButtons: [
|
||||
lst.concat(new_button ? [ new_button ] : []),
|
||||
{itemButtons: options.itemButtons || [
|
||||
// mark for removal...
|
||||
['×',
|
||||
function(p){
|
||||
@ -174,6 +185,11 @@ function(actions, list_key, options){
|
||||
|
||||
var o = overlay.Overlay(actions.ribbons.viewer, list)
|
||||
.close(function(){
|
||||
// prevent editing non-arrays...
|
||||
if(!(actions.config[list_key] instanceof Array)){
|
||||
return
|
||||
}
|
||||
|
||||
// remove striked items...
|
||||
to_remove.forEach(function(e){
|
||||
var lst = actions.config[list_key].slice()
|
||||
@ -198,7 +214,7 @@ function(actions, list_key, options){
|
||||
// XXX should this be more generic...
|
||||
var makeNestedConfigListEditor =
|
||||
module.makeNestedConfigListEditor =
|
||||
function(actions, parent, list_name, value_name, options){
|
||||
function(actions, parent, list_key, value_key, options){
|
||||
return function(){
|
||||
var txt = $(this).find('.text').first().text()
|
||||
|
||||
@ -209,14 +225,14 @@ function(actions, parent, list_name, value_name, options){
|
||||
// NOTE: this is called when adding a new value and
|
||||
// list maximum length is reached...
|
||||
callback: function(value){
|
||||
actions.config[value_name] = value
|
||||
actions.config[value_key] = value
|
||||
|
||||
o.close()
|
||||
},
|
||||
}
|
||||
options.__proto__ = dfl_options
|
||||
|
||||
var o = makeConfigListEditor(actions, list_name, options)
|
||||
var o = makeConfigListEditor(actions, list_key, options)
|
||||
|
||||
// update slideshow menu...
|
||||
o.client.open(function(){
|
||||
@ -229,7 +245,7 @@ function(actions, parent, list_name, value_name, options){
|
||||
parent.focus()
|
||||
})
|
||||
|
||||
o.client.select(actions.config[value_name])
|
||||
o.client.select(actions.config[value_key])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user