bugfixes and export filename info...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-11-13 23:38:16 +03:00
parent f98ebe8b76
commit acc6d6f60c
5 changed files with 178 additions and 69 deletions

View File

@ -1636,10 +1636,11 @@ var FileSystemWriterActions = actions.Actions({
'export-preview-name-pattern': '%f',
'export-preview-name-patterns': [
'%f',
'%i-%f',
'%n%(-bookmarked)b%e',
'%n%(-marked)m%e',
'%g-%f',
'%n%(-bookmarked)b%(-m)m%(-%c)c%e',
'%n%(-bookmarked)b%(-%c)c%e',
'%f',
],
'export-level-directory-name': 'fav',
@ -2353,15 +2354,66 @@ var FileSystemWriterUIActions = actions.Actions({
// except for the export path...
__export_dialog_fields__: {
'pattern': function(actions, make, parent){
return make(['Filename pattern: ',
function(){
return actions.config['export-preview-name-pattern'] || '%f' }])
.on('open',
widgets.makeNestedConfigListEditor(actions, parent,
'export-preview-name-patterns',
'export-preview-name-pattern', {
length_limit: 10,
}))
var img = actions.current
var pattern = actions.config['export-preview-name-pattern'] || '%f'
var showExaples = function(pattern, img){
img = img || actions.current
return actions.showList([
// current...
['Current:',
actions.formatImageName(pattern, img)],
['Marked:',
actions.formatImageName(pattern,
img,
{tags: ['selected']})],
['Bookmarked:',
actions.formatImageName(pattern,
img,
{tags: ['bookmark']})],
['Repeating:',
actions.formatImageName(pattern,
img,
{conflicts: {[actions.current]: ['', actions.current], }} )],
['All:',
actions.formatImageName(pattern,
img,
{
tags: [
'selected',
'bookmark',
],
conflicts: {
[img]: ['', img],
}
} )],
], {
cls: 'table-view',
})
}
// make this a dialog...
var res = make(['Filename pattern: ', pattern], {
open: widgets.makeNestedConfigListEditor(actions, parent,
'export-preview-name-patterns',
'export-preview-name-pattern', {
length_limit: 10,
events: {
menu: function(_, p){ showExaples(p) },
},
buttons: [
['i', function(p){ showExaples(p) }],
],
}),
})
// show example generated names...
make(['Filename:',
function(){ return actions.formatImageName(pattern, img) }])
.on('open', function(){
showExaples(actions.config['export-preview-name-pattern'] || '%f') })
return res
},
'level_dir': function(actions, make, parent){
return make(['Level directory: ',

View File

@ -1651,28 +1651,35 @@ var BrowseActionsActions = actions.Actions({
// build toggler states...
states.forEach(function(state){
make(state, {
// NOTE: if something is hidden
// it is also disabled...
// ...this is by design.
disabled: options.no_disabled ?
false
: (mode == 'hidden' || mode == 'disabled'),
hidden: options.no_hidden ?
false
: mode == 'hidden',
})
// XXX need to normalize state -- comments, whitespace, etc...
.attr('keys', getKeys(action +': "'+ state +'"'))
.addClass([
state == cur_state ? 'selected highlighted' : '',
mode == 'hidden' ? mode : ''
].join(' '))
.on('open', function(){
options.callback ?
options.callback.call(actions, action)
: actions[action](state)
that.pop()
})
// NOTE: if something is hidden
// it is also disabled...
// ...this is by design.
disabled: options.no_disabled ?
false
: (mode == 'hidden' || mode == 'disabled'),
hidden: options.no_hidden ?
false
: mode == 'hidden',
cls: [
state == cur_state ? 'selected highlighted' : '',
mode == 'hidden' ? mode : ''
].join(' '),
attrs: {
// XXX need to normalize state -- comments, whitespace, etc...
keys: getKeys(action +': "'+ state +'"'),
},
events: {
open: function(){
options.callback ?
options.callback.call(actions, action)
: actions[action](state)
that.pop()
},
},
})
})
// Level: lister -- hand control to lister...
@ -1726,6 +1733,7 @@ var BrowseActionsActions = actions.Actions({
// Action: toggler -> add toggle button...
if(actions.isToggler && actions.isToggler(action)){
make(text + '/', {
cls: mode == 'hidden' ? mode : '',
// NOTE: if something is hidden
// it is also disabled...
// ...this is by design.
@ -1735,6 +1743,10 @@ var BrowseActionsActions = actions.Actions({
hidden: options.no_hidden ?
false
: mode == 'hidden',
attrs: {
keys: getKeys(action),
action: action,
},
buttons: [
[actions[action]('?'),
function(){
@ -1743,20 +1755,16 @@ var BrowseActionsActions = actions.Actions({
that.select('"'+ text +'"')
}],
//[getKeys(action)],
]})
.attr({
keys: getKeys(action),
action: action,
})
.addClass(mode == 'hidden' ? mode : '')
.on('open', function(){
],
open: function(){
options.callback ?
options.callback.call(actions, action)
: actions[action]()
that.update()
that.select('"'+ text +'"')
})
},
})
// Action: normal...
} else {
@ -1770,15 +1778,15 @@ var BrowseActionsActions = actions.Actions({
hidden: options.no_hidden ?
false
: mode == 'hidden',
})
.attr({
keys: getKeys(action),
action: action,
})
.on('open', function(){
options.callback ?
options.callback.call(actions, action)
: waitFor(actions[action]())
attrs: {
keys: getKeys(action),
action: action,
},
open: function(){
options.callback ?
options.callback.call(actions, action)
: waitFor(actions[action]())
},
})
}
@ -1788,13 +1796,15 @@ var BrowseActionsActions = actions.Actions({
&& Object.keys(cur[key]).length > 0)){
var p = '/'+ path.concat([text]).join('/') +'/'
p = MARKER ? p.replace(MARKER, '$1') : p
make(text + '/', { push_on_open: true })
.attr({
make(text + '/', {
push_on_open: true,
attrs: {
keys: [
getKeys('browseActions: "'+ p +'"'),
getKeys('browseActions!: "'+ p +'"'),
].filter(function(e){ return e.trim() != '' }).join(' / '),
})
},
})
// item: line...
} else if(/---+/.test(text)){

View File

@ -1781,11 +1781,6 @@ var DataPrototype = {
if(res == null){
return
}
// clear empty ribbon...
r = r == 0 ? 1 : r
if(this.ribbons[this.ribbon_order[r]].len == 0){
this.clear(this.ribbon_order[r])
}
return res
},
shiftImageDown: function(gid){
@ -1800,10 +1795,6 @@ var DataPrototype = {
if(res == null){
return
}
// clear empty ribbon...
if(this.ribbons[this.ribbon_order[r]].len == 0){
this.clear(this.ribbon_order[r])
}
return res
},

View File

@ -1532,6 +1532,12 @@ var BrowserPrototype = {
//'close',
],
optionsEventShorthands: [
'open',
'menu',
'update',
],
// Shorthand elements...
//
// Format:
@ -1683,9 +1689,9 @@ var BrowserPrototype = {
'#0': 'push!: "9!"',
// handlers for standard shortcuts...
Menu: 'menu!',
ctrl_C: function(){ console.log('!!!!!') },
},
ItemShortcuts: {
@ -1756,7 +1762,20 @@ var BrowserPrototype = {
return this
},
blur: widget.proxyToDom('blur'),
menu: widget.proxyToDom('menu'),
//menu: widget.proxyToDom('menu'),
//* XXX
menu: function(){
arguments[0] instanceof Function ?
this.dom.on('menu', arguments[0])
: this.select('!').trigger('menu',
//: this.dom.trigger('menu',
arguments.length > 0 ?
[].slice.call(arguments)
: [this.selected])
return this
},
//*/
// base api...
@ -2063,6 +2082,15 @@ var BrowserPrototype = {
// // shortcut key to open the item...
// shortcut_key: <key>,
//
// // event handler shorthands...
// //
// // These are the sugar for commonly used events in the events
// // section below...
// // NOTE: these are defined in .options.optionsEventShorthands
// open: <handler>,
// menu: <handler>,
// update: <handler>,
//
// // event handlers...
// events: {
// // item-specific update events...
@ -2449,7 +2477,7 @@ var BrowserPrototype = {
if(debounced){
that.select($(this))
res.trigger('menu', txt)
res.trigger('menu', [txt])
}
})
// append text elements...
@ -2476,6 +2504,9 @@ var BrowserPrototype = {
opts.push_on_open
&& res.attr('push-on-open', 'on')
opts.attrs
&& res.attr(opts.attrs)
//--------------------------------------------- buttons ---
// button container...
var btn = res.find('.button-container')
@ -2543,6 +2574,10 @@ var BrowserPrototype = {
//--------------------------------- user event handlers ---
res.on('update', function(evt){ evt.stopPropagation() })
// shorthands...
;(that.options.optionsEventShorthands || [])
.forEach(function(p){ res.on(p, opts[p]) })
// events...
Object.keys(opts.events || {})
.forEach(function(evt){
res.on(evt, opts.events[evt]) })

View File

@ -19,11 +19,11 @@ var proxyToDom =
module.proxyToDom =
function(name){
return function(){
// easy handler...
// proxy handler...
if(name in this.dom){
this.dom[name].apply(this.dom, arguments)
// trigger...
// on/trigger handlers...
} else {
arguments[0] instanceof Function ?
this.dom.on(name, arguments[0])
@ -33,6 +33,27 @@ function(name){
}
}
var eventToDom =
module.eventToDom =
function(name, defaults){
return function(){
// register...
if(arguments[0] instanceof Function){
this.dom.trigger(name, [].slice.call(arguments))
// trigger...
} else {
var args = (arguments.length == 0 && defaults) ?
defaults.call(this)
: [].slice.call(arguments)
args = args instanceof Array ? args : [args]
this.dom.trigger(name, args)
}
return this
}
}
// XXX triggering events from here and from jQuery/dom has a
// different effect...