mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
fixes and tweaks...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c584ec1c46
commit
2f7348e3a3
@ -3081,7 +3081,7 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
buttons: [
|
buttons: [
|
||||||
['<i><small>Save preset</small></i>',
|
['<i><small>Save preset</small></i>',
|
||||||
function(_, elem){
|
function(_, elem){
|
||||||
that.exportPresetSave()
|
that.exportPresetSave(settings)
|
||||||
|
|
||||||
// button press feedback...
|
// button press feedback...
|
||||||
var e = elem.find('.button small')
|
var e = elem.find('.button small')
|
||||||
@ -3123,9 +3123,11 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
var that = this
|
var that = this
|
||||||
var logger = this.logger && this.logger.push('exportPresets')
|
var logger = this.logger && this.logger.push('exportPresets')
|
||||||
|
|
||||||
|
// XXX should this show date???
|
||||||
var getName = function(preset){
|
var getName = function(preset){
|
||||||
return preset.name
|
return preset.name
|
||||||
|| `${ preset.mode }: "${ preset.path }"` }
|
|| `${ preset.mode }: "${ preset.path }"` }
|
||||||
|
|
||||||
var buildIndex = function(presets){
|
var buildIndex = function(presets){
|
||||||
var index
|
var index
|
||||||
return [
|
return [
|
||||||
@ -3138,11 +3140,16 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
Object.keys(index), ] }
|
Object.keys(index), ] }
|
||||||
var getPreset = function(title, presets, index){
|
var getPreset = function(title, presets, index){
|
||||||
return presets[index[title]] }
|
return presets[index[title]] }
|
||||||
|
|
||||||
// presets...
|
// presets...
|
||||||
var presets = that.config['export-presets'] || []
|
var presets = that.config['export-presets'] || []
|
||||||
var [index, keys] = buildIndex(presets)
|
var [index, keys] = buildIndex(presets)
|
||||||
|
|
||||||
|
var updateIndex = function(){
|
||||||
|
var [idx, k] = buildIndex(presets)
|
||||||
|
index = idx
|
||||||
|
// NOTE: keys must be updated in-place...
|
||||||
|
keys.splice(0, keys.length, ...k) }
|
||||||
|
|
||||||
// history...
|
// history...
|
||||||
var history = that.config['export-history'] || []
|
var history = that.config['export-history'] || []
|
||||||
var [history_index, history_keys] = buildIndex(history)
|
var [history_index, history_keys] = buildIndex(history)
|
||||||
@ -3214,7 +3221,7 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
return make.dialog.close() }
|
return make.dialog.close() }
|
||||||
// error...
|
// error...
|
||||||
logger
|
logger
|
||||||
&& logger.emit('error', 'preset not found.') }, })
|
&& logger.emit('error', `preset not found: "${ title }"`) }, })
|
||||||
|
|
||||||
// export dialog...
|
// export dialog...
|
||||||
make.Separator({ style: { opacity: '0.1' } })
|
make.Separator({ style: { opacity: '0.1' } })
|
||||||
@ -3223,10 +3230,7 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
that.exportDialog()
|
that.exportDialog()
|
||||||
// new preset saved...
|
// new preset saved...
|
||||||
.on('save-preset', function(){
|
.on('save-preset', function(){
|
||||||
var [idx, k] = buildIndex(presets)
|
updateIndex()
|
||||||
index = idx
|
|
||||||
// NOTE: keys must be updated in-place...
|
|
||||||
keys.splice(0, keys.length, ...k)
|
|
||||||
make.dialog.update() })
|
make.dialog.update() })
|
||||||
// close dialog on export...
|
// close dialog on export...
|
||||||
.close(function(evt, reason){
|
.close(function(evt, reason){
|
||||||
@ -3243,26 +3247,52 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
new_item: false,
|
new_item: false,
|
||||||
editable_items: false,
|
editable_items: false,
|
||||||
buttons: [
|
buttons: [
|
||||||
|
// view...
|
||||||
|
['<small class="show-on-hover">view</small>',
|
||||||
|
function(title){
|
||||||
|
var preset = getPreset(title, history, history_index)
|
||||||
|
preset
|
||||||
|
&& that.exportDialog(
|
||||||
|
// prevent editing history...
|
||||||
|
JSON.parse(JSON.stringify( preset )) )
|
||||||
|
// new preset saved...
|
||||||
|
.on('save-preset', function(){
|
||||||
|
updateIndex()
|
||||||
|
make.dialog.update() })
|
||||||
|
// close dialog on export...
|
||||||
|
.close(function(evt, reason){
|
||||||
|
reason != 'reject'
|
||||||
|
&& make.dialog.close() }) }],
|
||||||
// to preset...
|
// to preset...
|
||||||
['<small class="show-on-hover">save</small>',
|
['<small class="show-on-hover">save</small>',
|
||||||
function(){
|
function(title){
|
||||||
// XXX
|
var preset = getPreset(title, history, history_index)
|
||||||
}],
|
if(preset){
|
||||||
|
that.exportPresetSave(preset)
|
||||||
|
updateIndex()
|
||||||
|
make.dialog.update() } }],
|
||||||
'REMOVE',
|
'REMOVE',
|
||||||
],
|
],
|
||||||
// XXX export...
|
// export...
|
||||||
open: function(evt, title){
|
open: function(evt, title){
|
||||||
that.exportAs(getPreset(title, presets, index))
|
var preset = getPreset(title, history, history_index)
|
||||||
make.dialog.close() },
|
// export only if we get a good preset...
|
||||||
})
|
if(preset && getName(preset) == title){
|
||||||
|
that.exportAs(preset)
|
||||||
|
return make.dialog.close() }
|
||||||
|
// error...
|
||||||
|
logger
|
||||||
|
&& logger.emit('error', `history item not found: "${ title }"`) }, })
|
||||||
})
|
})
|
||||||
|
// keyboard...
|
||||||
.run(function(){
|
.run(function(){
|
||||||
var that = this
|
var that = this
|
||||||
// XXX this does not work yet...
|
// XXX for some reason this does not work yet...
|
||||||
this.keyboard.on('E', function(){
|
this.keyboard.on('E', function(){
|
||||||
console.log('!!!!!!!!!!!!!', that.selected)
|
console.log('!!!!!!!!!!!!!', that.selected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
// save things after we are done...
|
||||||
.close(function(){
|
.close(function(){
|
||||||
// update preset order and count...
|
// update preset order and count...
|
||||||
that.config['export-presets'] = keys
|
that.config['export-presets'] = keys
|
||||||
@ -3295,7 +3325,8 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
exportPresetRun: ['- File/',
|
exportPresetRun: ['- File/',
|
||||||
function(){}],
|
function(){}],
|
||||||
|
|
||||||
// XXX need to check item uniqueness...
|
// XXX need to check item uniqueness???
|
||||||
|
// XXX add date???
|
||||||
exportHistoryPush: ['- File/',
|
exportHistoryPush: ['- File/',
|
||||||
function(settings){
|
function(settings){
|
||||||
settings = settings
|
settings = settings
|
||||||
@ -3305,9 +3336,12 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
this.config['export-history'] =
|
this.config['export-history'] =
|
||||||
this.config['export-history'] || []
|
this.config['export-history'] || []
|
||||||
// add...
|
// add...
|
||||||
// XXX need to check item uniqueness...
|
|
||||||
settings
|
settings
|
||||||
&& history.push(JSON.parse(JSON.stringify( settings )))
|
&& history.push(Object.assign(
|
||||||
|
JSON.parse(JSON.stringify( settings )),
|
||||||
|
{
|
||||||
|
date: Date.timeStamp(true),
|
||||||
|
}))
|
||||||
// trim the history...
|
// trim the history...
|
||||||
history.length > l
|
history.length > l
|
||||||
&& history.splice(0, history.length - l) }],
|
&& history.splice(0, history.length - l) }],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user