mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
alias ui mostly done...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c074793aef
commit
bf2f485ff7
@ -44,12 +44,16 @@ module.Alias = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
Object.keys(aliases)
|
Object.keys(aliases)
|
||||||
.forEach(function(alias){
|
.forEach(function(alias){
|
||||||
that.alias(alias, aliases[alias]) })
|
that.alias.apply(that, [alias].concat(aliases[alias])) })
|
||||||
}],
|
}],
|
||||||
// store aliases in .config.aliases
|
// store aliases in .config.aliases
|
||||||
// XXX should we guard from overriding actions???
|
// XXX should we guard from overriding actions???
|
||||||
['alias',
|
['alias',
|
||||||
function(_, alias, target){
|
function(_, alias, target){
|
||||||
|
var args = [].slice.call(arguments, 1)
|
||||||
|
var alias = args.shift()
|
||||||
|
var target = args[args.length-1]
|
||||||
|
|
||||||
// remove alias...
|
// remove alias...
|
||||||
// XXX is this test enough??? ...see ActionSet.alias(..)
|
// XXX is this test enough??? ...see ActionSet.alias(..)
|
||||||
if(arguments.length == 3
|
if(arguments.length == 3
|
||||||
@ -58,7 +62,7 @@ module.Alias = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
delete aliases[alias]
|
delete aliases[alias]
|
||||||
|
|
||||||
if(Object.keys(alias).length == 0){
|
if(Object.keys(aliases).length == 0){
|
||||||
delete this.config.aliases
|
delete this.config.aliases
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +70,7 @@ module.Alias = core.ImageGridFeatures.Feature({
|
|||||||
} else {
|
} else {
|
||||||
var aliases = this.config.aliases = this.config.aliases || {}
|
var aliases = this.config.aliases = this.config.aliases || {}
|
||||||
|
|
||||||
aliases[alias] = target
|
aliases[alias] = args
|
||||||
}
|
}
|
||||||
}]],
|
}]],
|
||||||
})
|
})
|
||||||
@ -76,11 +80,17 @@ module.Alias = core.ImageGridFeatures.Feature({
|
|||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
var UIAliasActions = actions.Actions({
|
var UIAliasActions = actions.Actions({
|
||||||
|
// XXX add run button (???)
|
||||||
|
// XXX show alias docs (???)
|
||||||
|
// XXX show key bindings
|
||||||
|
// XXX edit key bindings (???)
|
||||||
|
// XXX should this update the parent???
|
||||||
browseAliases: ['System/Aliases...',
|
browseAliases: ['System/Aliases...',
|
||||||
widgets.makeUIDialog(function(){
|
widgets.makeUIDialog(function(){
|
||||||
var that = this
|
var that = this
|
||||||
return browse.makeLister(null,
|
return browse.makeLister(null,
|
||||||
function(path, make){
|
function(path, make){
|
||||||
|
var dialog = this
|
||||||
var aliases = that.config.aliases || {}
|
var aliases = that.config.aliases || {}
|
||||||
|
|
||||||
var names = Object.keys(aliases)
|
var names = Object.keys(aliases)
|
||||||
@ -88,49 +98,120 @@ var UIAliasActions = actions.Actions({
|
|||||||
names.length > 0 ?
|
names.length > 0 ?
|
||||||
names
|
names
|
||||||
.forEach(function(name){
|
.forEach(function(name){
|
||||||
make([name, aliases[name]])
|
make([name, (aliases[name]).slice(-1)[0]])
|
||||||
.on('open', function(){ that.editAlias(name) })
|
.on('open', function(){
|
||||||
|
that.editAlias(name)
|
||||||
|
.on('close', function(){ dialog.update() })
|
||||||
|
})
|
||||||
})
|
})
|
||||||
: make.Empty()
|
: make.Empty()
|
||||||
|
|
||||||
|
make('---')
|
||||||
|
|
||||||
|
make('New...')
|
||||||
|
.on('open', function(){
|
||||||
|
that.editAlias()
|
||||||
|
.on('close', function(){ dialog.update() })
|
||||||
|
})
|
||||||
}, {
|
}, {
|
||||||
cls: 'table-view',
|
cls: 'table-view',
|
||||||
})
|
})
|
||||||
})],
|
})],
|
||||||
|
|
||||||
|
// NOTE: this does not include an attr editor by design...
|
||||||
editAlias: ['- System/Edit alias...',
|
editAlias: ['- System/Edit alias...',
|
||||||
widgets.makeUIDialog(function(alias){
|
widgets.makeUIDialog(function(alias){
|
||||||
var that = this
|
var that = this
|
||||||
return browse.makeLister(null,
|
return browse.makeLister(null,
|
||||||
function(path, make){
|
function(path, make){
|
||||||
make.Editable(['Alias:', alias],
|
var dialog = this
|
||||||
{
|
|
||||||
start_on: 'open',
|
|
||||||
edit_text: 'last',
|
|
||||||
clear_on_edit: false,
|
|
||||||
reset_on_commit: false,
|
|
||||||
})
|
|
||||||
.on('edit-commit',
|
|
||||||
function(evt, text){
|
|
||||||
})
|
|
||||||
|
|
||||||
make.Editable(['Code:', that.config.aliases[alias]],
|
var item_opts = {
|
||||||
{
|
|
||||||
start_on: 'open',
|
start_on: 'open',
|
||||||
edit_text: 'last',
|
edit_text: 'last',
|
||||||
clear_on_edit: false,
|
clear_on_edit: false,
|
||||||
reset_on_commit: false,
|
reset_on_commit: false,
|
||||||
})
|
// XXX bug -- error + clear field???
|
||||||
|
//abort_on_deselect: false,
|
||||||
|
}
|
||||||
|
var data = (that.config.aliases || {})[alias] || ['']
|
||||||
|
|
||||||
|
// doc fields...
|
||||||
|
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')){
|
||||||
|
data[0] = text
|
||||||
|
|
||||||
|
// no previous docs...
|
||||||
|
} else {
|
||||||
|
data.splice(0, 0, text)
|
||||||
|
}
|
||||||
|
|
||||||
|
that.alias.apply(that, [alias].concat(data))
|
||||||
|
})
|
||||||
|
make.Editable(['Doc:', that.getActionAttr(alias, 'long_doc')], item_opts)
|
||||||
|
.on('edit-commit',
|
||||||
|
function(evt, text){
|
||||||
|
// existing .doc and .long_doc -> replace .long_doc...
|
||||||
|
if(data.length > 2
|
||||||
|
&& typeof(data[0]) == typeof('str')
|
||||||
|
&& typeof(data[1] == typeof('str'))){
|
||||||
|
data[1] = text
|
||||||
|
|
||||||
|
// existing .doc -> add .long_doc only...
|
||||||
|
} else if(data.length > 1 && typeof(data[0]) == typeof('str')){
|
||||||
|
data.splice(1, 0, text)
|
||||||
|
|
||||||
|
// no previous docs -> add empty .doc and set .long_doc...
|
||||||
|
} else {
|
||||||
|
data.splice(0, 0, '', text)
|
||||||
|
}
|
||||||
|
|
||||||
|
that.alias.apply(that, [alias].concat(data))
|
||||||
})
|
})
|
||||||
|
|
||||||
make('---')
|
make('---')
|
||||||
|
|
||||||
make.ConfirmAction('Delete', {})
|
// alias fields...
|
||||||
|
make.Editable(['Alias:', alias || ''], item_opts)
|
||||||
|
.on('edit-commit',
|
||||||
|
function(evt, 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)
|
||||||
|
.on('edit-commit',
|
||||||
|
function(evt, text){
|
||||||
|
data[data.length-1] = text
|
||||||
|
that.alias.apply(that, [alias].concat(data))
|
||||||
|
})
|
||||||
|
|
||||||
|
make('---')
|
||||||
|
|
||||||
|
make.ConfirmAction('Delete', {
|
||||||
|
callback: function(){
|
||||||
|
that.alias(alias, null)
|
||||||
|
dialog.close()
|
||||||
|
},
|
||||||
|
})
|
||||||
}, {
|
}, {
|
||||||
cls: 'table-view',
|
cls: 'table-view',
|
||||||
})
|
})
|
||||||
})],
|
})],
|
||||||
|
|
||||||
|
|
||||||
|
/* XXX do we need this???
|
||||||
|
_browseAliases: ['System/Aliases/*',
|
||||||
|
function(path, make){
|
||||||
|
var that = this
|
||||||
|
this.aliases.forEach(function(alias){
|
||||||
|
make(alias)
|
||||||
|
.on('open', function(){ that[alias]() })
|
||||||
|
})
|
||||||
|
}],
|
||||||
|
//*/
|
||||||
})
|
})
|
||||||
|
|
||||||
var UIAlias =
|
var UIAlias =
|
||||||
|
|||||||
@ -1131,6 +1131,10 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
'browse-actions-shortcut-marker': '\\$(\\w)',
|
'browse-actions-shortcut-marker': '\\$(\\w)',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Hide alias action...
|
||||||
|
alias: ['- System/', ''],
|
||||||
|
|
||||||
|
|
||||||
// Browse actions dialog...
|
// Browse actions dialog...
|
||||||
//
|
//
|
||||||
// This uses action definition to build and present an action tree.
|
// This uses action definition to build and present an action tree.
|
||||||
|
|||||||
@ -272,6 +272,9 @@ function(text, options){
|
|||||||
// // (see: util.makeEditable(..) for more info)
|
// // (see: util.makeEditable(..) for more info)
|
||||||
// clear_on_edit: false,
|
// clear_on_edit: false,
|
||||||
//
|
//
|
||||||
|
// // Keep item selection after abort/commit...
|
||||||
|
// keep_selection: true,
|
||||||
|
//
|
||||||
// // Events to stop propagating up...
|
// // Events to stop propagating up...
|
||||||
// //
|
// //
|
||||||
// // This is useful to prevent actions that start should an edit
|
// // This is useful to prevent actions that start should an edit
|
||||||
@ -296,6 +299,7 @@ function(text, options){
|
|||||||
var dialog = this.dialog
|
var dialog = this.dialog
|
||||||
var start_on = options.start_on || 'select'
|
var start_on = options.start_on || 'select'
|
||||||
var stop_propagation = options.stop_propagation === false ? false : 'open'
|
var stop_propagation = options.stop_propagation === false ? false : 'open'
|
||||||
|
var keep_selection = options.keep_selection === undefined ? true : false
|
||||||
|
|
||||||
var getEditable = function(){
|
var getEditable = function(){
|
||||||
var editable = elem.find('.text')
|
var editable = elem.find('.text')
|
||||||
@ -327,7 +331,10 @@ function(text, options){
|
|||||||
reset_on_commit: options.reset_on_commit,
|
reset_on_commit: options.reset_on_commit,
|
||||||
reset_on_abort: options.reset_on_abort,
|
reset_on_abort: options.reset_on_abort,
|
||||||
})
|
})
|
||||||
// XXX not sure about this...
|
|
||||||
|
!keep_selection
|
||||||
|
// deselect on abort/commit...
|
||||||
|
&& editable
|
||||||
.on('blur', function(){ dialog.select(null) })
|
.on('blur', function(){ dialog.select(null) })
|
||||||
|
|
||||||
// deselect on abort -- if we started with a select...
|
// deselect on abort -- if we started with a select...
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
"fs-walk": "^0.0.1",
|
"fs-walk": "^0.0.1",
|
||||||
"glob": "^4.0.6",
|
"glob": "^4.0.6",
|
||||||
"guarantee-events": "^1.0.0",
|
"guarantee-events": "^1.0.0",
|
||||||
"ig-actions": "^3.5.3",
|
"ig-actions": "^3.5.4",
|
||||||
"ig-features": "^3.2.6",
|
"ig-features": "^3.2.6",
|
||||||
"ig-object": "^1.0.1",
|
"ig-object": "^1.0.1",
|
||||||
"openseadragon": "^2.3.0",
|
"openseadragon": "^2.3.0",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user