mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
more work on alias ui...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
bf2f485ff7
commit
fdab009bd1
@ -321,7 +321,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* XXX experimental key mappings... */
|
/* XXX experimental key mappings... */
|
||||||
.browse-widget.browse-actions.show-keys .list .item:after {
|
.browse-widget.show-keys .list .item:after {
|
||||||
display: inline;
|
display: inline;
|
||||||
position: relative;
|
position: relative;
|
||||||
content: attr(keys);
|
content: attr(keys);
|
||||||
@ -333,14 +333,14 @@ body {
|
|||||||
opacity: 0.3;
|
opacity: 0.3;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
.browse-widget.browse-actions.show-keys .list .item.disabled:after {
|
.browse-widget.show-keys .list .item.disabled:after {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.browse-widget.browse-actions.show-keys .list .item:hover:after {
|
.browse-widget.show-keys .list .item:hover:after {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
.browse-widget.browse-actions.show-keys .list .item.disabled:hover:after {
|
.browse-widget.show-keys .list .item.disabled:hover:after {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -72,7 +72,33 @@ module.Alias = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
aliases[alias] = args
|
aliases[alias] = args
|
||||||
}
|
}
|
||||||
}]],
|
}],
|
||||||
|
|
||||||
|
/*/ XXX not sure if this is the correct way to go...
|
||||||
|
['selfTest',
|
||||||
|
function(){
|
||||||
|
var alias = [
|
||||||
|
'testRuntimeAlias',
|
||||||
|
'Test/',
|
||||||
|
core.doc`Rumtime-defined test alias.
|
||||||
|
|
||||||
|
NOTE: this will get overwritten on start.`,
|
||||||
|
'focusImage: "next"',
|
||||||
|
]
|
||||||
|
|
||||||
|
this.alias.apply(this, alias)
|
||||||
|
|
||||||
|
if(!this.config.aliases
|
||||||
|
|| !(alias[0] in this.config.aliases)
|
||||||
|
|| this.config.aliases[alias[0]].length != alias.length-1
|
||||||
|
|| this.config.aliases[alias[0]].filter(function(e, i){ return e != alias[i+1] }).length > 0){
|
||||||
|
console.error('Alias save fail:',
|
||||||
|
'\n written:', alias,
|
||||||
|
'\n saved:', [alias[0]].concat((this.config.aliases || {})[alias[0]]))
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
//*/
|
||||||
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -82,12 +108,17 @@ module.Alias = core.ImageGridFeatures.Feature({
|
|||||||
var UIAliasActions = actions.Actions({
|
var UIAliasActions = actions.Actions({
|
||||||
// XXX add run button (???)
|
// XXX add run button (???)
|
||||||
// XXX show alias docs (???)
|
// XXX show alias docs (???)
|
||||||
// XXX show key bindings
|
|
||||||
// XXX edit key bindings (???)
|
|
||||||
// XXX should this update the parent???
|
// XXX should this update the parent???
|
||||||
browseAliases: ['System/Aliases...',
|
browseAliases: ['System/Aliases...',
|
||||||
widgets.makeUIDialog(function(){
|
widgets.makeUIDialog(function(){
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
|
// get keys for each action...
|
||||||
|
var keys = that.getKeysForAction ? that.getKeysForAction() : {}
|
||||||
|
// Get keys for action...
|
||||||
|
var getKeys = function(action){
|
||||||
|
return (keys[action] || []).join(' / ') }
|
||||||
|
|
||||||
return browse.makeLister(null,
|
return browse.makeLister(null,
|
||||||
function(path, make){
|
function(path, make){
|
||||||
var dialog = this
|
var dialog = this
|
||||||
@ -98,7 +129,12 @@ var UIAliasActions = actions.Actions({
|
|||||||
names.length > 0 ?
|
names.length > 0 ?
|
||||||
names
|
names
|
||||||
.forEach(function(name){
|
.forEach(function(name){
|
||||||
make([name, (aliases[name]).slice(-1)[0]])
|
//make([name, (aliases[name]).slice(-1)[0]])
|
||||||
|
make([name])
|
||||||
|
.attr({
|
||||||
|
keys: getKeys(name),
|
||||||
|
action: name,
|
||||||
|
})
|
||||||
.on('open', function(){
|
.on('open', function(){
|
||||||
that.editAlias(name)
|
that.editAlias(name)
|
||||||
.on('close', function(){ dialog.update() })
|
.on('close', function(){ dialog.update() })
|
||||||
@ -114,18 +150,32 @@ var UIAliasActions = actions.Actions({
|
|||||||
.on('close', function(){ dialog.update() })
|
.on('close', function(){ dialog.update() })
|
||||||
})
|
})
|
||||||
}, {
|
}, {
|
||||||
cls: 'table-view',
|
cls: 'table-view show-keys',
|
||||||
|
})
|
||||||
|
.run(function(){
|
||||||
|
// XXX this is a copy from .browseActions(..)
|
||||||
|
this.showDoc = function(){
|
||||||
|
var action = this.select('!').attr('action')
|
||||||
|
action
|
||||||
|
&& that.showDoc(action)
|
||||||
|
}
|
||||||
|
this.keyboard.handler('General', '?', 'showDoc')
|
||||||
})
|
})
|
||||||
})],
|
})],
|
||||||
|
|
||||||
// NOTE: this does not include an attr editor by design...
|
// NOTE: this does not include an attr editor by design...
|
||||||
|
//
|
||||||
|
// XXX should we set white-space: pre on doc here or in css???
|
||||||
|
// XXX edit key bindings (???)
|
||||||
editAlias: ['- System/Edit alias...',
|
editAlias: ['- System/Edit alias...',
|
||||||
widgets.makeUIDialog(function(alias){
|
widgets.makeUIDialog(function(alias){
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
|
var name = alias
|
||||||
|
var data = ((that.config.aliases || {})[alias] || ['']).slice()
|
||||||
|
|
||||||
return browse.makeLister(null,
|
return browse.makeLister(null,
|
||||||
function(path, make){
|
function(path, make){
|
||||||
var dialog = this
|
|
||||||
|
|
||||||
var item_opts = {
|
var item_opts = {
|
||||||
start_on: 'open',
|
start_on: 'open',
|
||||||
edit_text: 'last',
|
edit_text: 'last',
|
||||||
@ -134,71 +184,82 @@ var UIAliasActions = actions.Actions({
|
|||||||
// XXX bug -- error + clear field???
|
// XXX bug -- error + clear field???
|
||||||
//abort_on_deselect: false,
|
//abort_on_deselect: false,
|
||||||
}
|
}
|
||||||
var data = (that.config.aliases || {})[alias] || ['']
|
|
||||||
|
|
||||||
// doc fields...
|
// doc fields...
|
||||||
make.Editable(['Path:', that.getActionAttr(alias, 'doc')], item_opts)
|
make.Editable(['Path:', that.getActionAttr(alias, 'doc')], item_opts)
|
||||||
.on('edit-commit',
|
.on('edit-commit', function(evt, text){
|
||||||
function(evt, text){
|
if(data.length > 1 && typeof(data[0]) == typeof('str')){
|
||||||
if(data.length > 1 && typeof(data[0]) == typeof('str')){
|
data[0] = text
|
||||||
data[0] = text
|
|
||||||
|
|
||||||
// no previous docs...
|
// no previous docs...
|
||||||
} else {
|
} else {
|
||||||
data.splice(0, 0, text)
|
data.splice(0, 0, text)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
that.alias.apply(that, [alias].concat(data))
|
|
||||||
})
|
|
||||||
make.Editable(['Doc:', that.getActionAttr(alias, 'long_doc')], item_opts)
|
make.Editable(['Doc:', that.getActionAttr(alias, 'long_doc')], item_opts)
|
||||||
.on('edit-commit',
|
.on('edit-commit', function(evt, text){
|
||||||
function(evt, text){
|
// existing .doc and .long_doc -> replace .long_doc...
|
||||||
// existing .doc and .long_doc -> replace .long_doc...
|
if(data.length > 2
|
||||||
if(data.length > 2
|
&& typeof(data[0]) == typeof('str')
|
||||||
&& typeof(data[0]) == typeof('str')
|
&& typeof(data[1] == typeof('str'))){
|
||||||
&& typeof(data[1] == typeof('str'))){
|
data[1] = text
|
||||||
data[1] = text
|
|
||||||
|
|
||||||
// existing .doc -> add .long_doc only...
|
// existing .doc -> add .long_doc only...
|
||||||
} else if(data.length > 1 && typeof(data[0]) == typeof('str')){
|
} else if(data.length > 1 && typeof(data[0]) == typeof('str')){
|
||||||
data.splice(1, 0, text)
|
data.splice(1, 0, text)
|
||||||
|
|
||||||
// no previous docs -> add empty .doc and set .long_doc...
|
// no previous docs -> add empty .doc and set .long_doc...
|
||||||
} else {
|
} else {
|
||||||
data.splice(0, 0, '', text)
|
data.splice(0, 0, '', text)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
that.alias.apply(that, [alias].concat(data))
|
// XXX HACK???
|
||||||
})
|
.find('.text').last()
|
||||||
|
.css({'white-space': 'pre'})
|
||||||
|
|
||||||
make('---')
|
make('---')
|
||||||
|
|
||||||
// alias fields...
|
// alias fields...
|
||||||
make.Editable(['Alias:', alias || ''], item_opts)
|
make.Editable(['Alias:', alias || ''], item_opts)
|
||||||
.on('edit-commit',
|
.on('edit-commit', function(evt, text){
|
||||||
function(evt, text){
|
name = text
|
||||||
that.alias(alias, null)
|
})
|
||||||
that.alias.apply(that, [text].concat(data))
|
|
||||||
alias = text
|
|
||||||
})
|
|
||||||
make.Editable(['Code:', ((that.config.aliases || {})[alias] || ['']).slice(-1)[0]], item_opts)
|
make.Editable(['Code:', ((that.config.aliases || {})[alias] || ['']).slice(-1)[0]], item_opts)
|
||||||
.on('edit-commit',
|
.on('edit-commit', function(evt, text){
|
||||||
function(evt, text){
|
data[data.length-1] = text
|
||||||
data[data.length-1] = text
|
})
|
||||||
that.alias.apply(that, [alias].concat(data))
|
|
||||||
})
|
|
||||||
|
|
||||||
make('---')
|
make('---')
|
||||||
|
|
||||||
|
// delete / cancel...
|
||||||
make.ConfirmAction('Delete', {
|
make.ConfirmAction('Delete', {
|
||||||
callback: function(){
|
callback: function(){
|
||||||
that.alias(alias, null)
|
data = [null]
|
||||||
dialog.close()
|
make.dialog.close()
|
||||||
},
|
},
|
||||||
|
buttons: [
|
||||||
|
['Cancel edit', function(){
|
||||||
|
make.dialog.close('cancel')
|
||||||
|
}],
|
||||||
|
],
|
||||||
})
|
})
|
||||||
}, {
|
}, {
|
||||||
cls: 'table-view',
|
cls: 'table-view',
|
||||||
})
|
})
|
||||||
|
.on('close', function(_, mode){
|
||||||
|
// do not save on cancel...
|
||||||
|
if(mode == 'cancel'){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// renaming the alias -> clear the old value...
|
||||||
|
if(name != alias){
|
||||||
|
that.alias(alias, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
// save the alias...
|
||||||
|
that.alias.apply(that, [name].concat(data))
|
||||||
|
})
|
||||||
})],
|
})],
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1189,6 +1189,11 @@ module.Tasks = ImageGridFeatures.Feature({
|
|||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// Self test framework...
|
// Self test framework...
|
||||||
|
|
||||||
|
// Indicate an action to be a self-test action...
|
||||||
|
//
|
||||||
|
// Self test actions are run by .selfTest(..)
|
||||||
|
//
|
||||||
|
// XXX should we set an action attr or a func attr here???
|
||||||
var selfTest =
|
var selfTest =
|
||||||
module.selfTest = function(func){
|
module.selfTest = function(func){
|
||||||
func.__self_test__ = true
|
func.__self_test__ = true
|
||||||
@ -1200,14 +1205,14 @@ var SelfTestActions = actions.Actions({
|
|||||||
'run-selftest-on-start': true,
|
'run-selftest-on-start': true,
|
||||||
},
|
},
|
||||||
|
|
||||||
runSelfTest: ['System/Run self test',
|
selfTest: ['System/Run self test',
|
||||||
selfTest(function(mode){
|
selfTest(function(mode){
|
||||||
var that = this
|
var that = this
|
||||||
var logger = this.logger && this.logger.push('Self test')
|
var logger = this.logger && this.logger.push('Self test')
|
||||||
|
|
||||||
var tests = this.actions
|
var tests = this.actions
|
||||||
.filter(function(action){
|
.filter(function(action){
|
||||||
return action != 'runSelfTest'
|
return action != 'selfTest'
|
||||||
&& (that[action].func.__self_test__
|
&& (that[action].func.__self_test__
|
||||||
|| that.getActionAttr(action, 'self_test'))})
|
|| that.getActionAttr(action, 'self_test'))})
|
||||||
|
|
||||||
@ -1241,7 +1246,7 @@ module.SelfTest = ImageGridFeatures.Feature({
|
|||||||
['start',
|
['start',
|
||||||
function(){
|
function(){
|
||||||
this.config['run-selftest-on-start']
|
this.config['run-selftest-on-start']
|
||||||
&& this.runSelfTest() }]
|
&& this.selfTest() }]
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -1252,7 +1252,6 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
`,
|
`,
|
||||||
widgets.makeUIDialog(function(mode, code, callback){
|
widgets.makeUIDialog(function(mode, code, callback){
|
||||||
var that = this
|
var that = this
|
||||||
var abort = false
|
|
||||||
var orig_code = code
|
var orig_code = code
|
||||||
|
|
||||||
// list the keys (cache)...
|
// list the keys (cache)...
|
||||||
@ -1329,7 +1328,6 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
timeout: that.config['ui-confirm-timeout'] || 2000,
|
timeout: that.config['ui-confirm-timeout'] || 2000,
|
||||||
buttons: [
|
buttons: [
|
||||||
['Cancel edit', function(){
|
['Cancel edit', function(){
|
||||||
abort = true
|
|
||||||
make.dialog.close('cancel')
|
make.dialog.close('cancel')
|
||||||
}],
|
}],
|
||||||
],
|
],
|
||||||
@ -1340,8 +1338,8 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
})
|
})
|
||||||
// save the keys...
|
// save the keys...
|
||||||
// XXX for some reason when Esc this is called twice...
|
// XXX for some reason when Esc this is called twice...
|
||||||
.on('close', function(){
|
.on('close', function(_, m){
|
||||||
if(abort){
|
if(m == 'cancel'){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1366,8 +1364,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
})
|
})
|
||||||
|
|
||||||
dialog.abort = function(){
|
dialog.abort = function(){
|
||||||
abort = true
|
this.close('cancel')
|
||||||
this.close()
|
|
||||||
}
|
}
|
||||||
dialog.keyboard
|
dialog.keyboard
|
||||||
.handler('General', 'Q', 'abort')
|
.handler('General', 'Q', 'abort')
|
||||||
@ -1398,7 +1395,6 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
`,
|
`,
|
||||||
widgets.makeUIDialog(function(mode, callback){
|
widgets.makeUIDialog(function(mode, callback){
|
||||||
var that = this
|
var that = this
|
||||||
var abort = false
|
|
||||||
var doc = (that.keybindings[mode] || {}).doc
|
var doc = (that.keybindings[mode] || {}).doc
|
||||||
var pattern = (that.keybindings[mode] || {}).pattern || mode
|
var pattern = (that.keybindings[mode] || {}).pattern || mode
|
||||||
|
|
||||||
@ -1435,7 +1431,6 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
timeout: that.config['ui-confirm-timeout'] || 2000,
|
timeout: that.config['ui-confirm-timeout'] || 2000,
|
||||||
buttons: [
|
buttons: [
|
||||||
['Cancel edit', function(){
|
['Cancel edit', function(){
|
||||||
abort = true
|
|
||||||
make.dialog.close('cancel')
|
make.dialog.close('cancel')
|
||||||
}],
|
}],
|
||||||
],
|
],
|
||||||
@ -1444,8 +1439,8 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
{
|
{
|
||||||
cls: 'table-view',
|
cls: 'table-view',
|
||||||
})
|
})
|
||||||
.on('close', function(){
|
.on('close', function(_, m){
|
||||||
if(abort){
|
if(m == 'cancel'){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1473,7 +1468,6 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
})
|
})
|
||||||
|
|
||||||
dialog.abort = function(){
|
dialog.abort = function(){
|
||||||
abort = true
|
|
||||||
this.close('cancel')
|
this.close('cancel')
|
||||||
}
|
}
|
||||||
dialog.keyboard
|
dialog.keyboard
|
||||||
@ -1504,7 +1498,6 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
`,
|
`,
|
||||||
widgets.makeUIDialog(function(mode){
|
widgets.makeUIDialog(function(mode){
|
||||||
var that = this
|
var that = this
|
||||||
var abort = false
|
|
||||||
|
|
||||||
mode = mode || Object.keys(that.keybindings)[0]
|
mode = mode || Object.keys(that.keybindings)[0]
|
||||||
|
|
||||||
@ -1549,21 +1542,19 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
timeout: that.config['ui-confirm-timeout'] || 2000,
|
timeout: that.config['ui-confirm-timeout'] || 2000,
|
||||||
buttons: [
|
buttons: [
|
||||||
['Cancel edit', function(){
|
['Cancel edit', function(){
|
||||||
abort = true
|
|
||||||
make.dialog.close('cancel')
|
make.dialog.close('cancel')
|
||||||
}],
|
}],
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.on('close', function(){
|
.on('close', function(_, m){
|
||||||
if(!abort){
|
if(m != 'cancel'){
|
||||||
that.keybindings[mode].drop = drop
|
that.keybindings[mode].drop = drop
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
dialog.abort = function(){
|
dialog.abort = function(){
|
||||||
abort = true
|
this.close('cancel')
|
||||||
this.close()
|
|
||||||
}
|
}
|
||||||
dialog.keyboard
|
dialog.keyboard
|
||||||
.handler('General', 'Q', 'abort')
|
.handler('General', 'Q', 'abort')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user