mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
cleanup, minor refactoring and tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
fd256fcc6f
commit
82fcaf5f89
@ -918,22 +918,11 @@ var FileSystemLoaderUIActions = actions.Actions({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// show user the list...
|
// show user the list...
|
||||||
var so = that.Overlay(
|
var so = that.showList(loaders, { path: 0 })
|
||||||
browse.makeList(null, loaders,
|
// close self and parent...
|
||||||
{
|
.open(function(){
|
||||||
// select first...
|
so.close()
|
||||||
//path: Object.keys(loaders)[0],
|
o.parent.close()
|
||||||
path: 0,
|
|
||||||
})
|
|
||||||
// close self and parent...
|
|
||||||
.open(function(){
|
|
||||||
so.close()
|
|
||||||
o.parent.close()
|
|
||||||
}))
|
|
||||||
// closed menu...
|
|
||||||
.close(function(){
|
|
||||||
//o.parent.focus()
|
|
||||||
o.select(item)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return so
|
return so
|
||||||
|
|||||||
@ -1129,7 +1129,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
})
|
})
|
||||||
return dialog
|
return dialog
|
||||||
})],
|
})],
|
||||||
// XXX add datalist...
|
// XXX add action completion...
|
||||||
editKeyBinding: ['- Interface/Key mapping...',
|
editKeyBinding: ['- Interface/Key mapping...',
|
||||||
widgets.makeUIDialog(function(mode, code){
|
widgets.makeUIDialog(function(mode, code){
|
||||||
var that = this
|
var that = this
|
||||||
@ -1155,6 +1155,8 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
// XXX make editable???
|
// XXX make editable???
|
||||||
make(['Mode:', mode || ''])
|
make(['Mode:', mode || ''])
|
||||||
|
|
||||||
|
// XXX add completion...
|
||||||
|
// ...datalist seems not to work with non input fields...
|
||||||
make.Editable(['Code:', code || ''], {
|
make.Editable(['Code:', code || ''], {
|
||||||
start_on: 'open',
|
start_on: 'open',
|
||||||
edit_text: 'last',
|
edit_text: 'last',
|
||||||
@ -1162,12 +1164,21 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
reset_on_commit: false,
|
reset_on_commit: false,
|
||||||
buttons: [
|
buttons: [
|
||||||
['⋯', function(evt, elem){
|
['⋯', function(evt, elem){
|
||||||
var dialog = that.listDialog(that.actions)
|
// highlight the current action...
|
||||||
.on('open', function(evt, action){
|
var a = keyboard.parseActionCall(code)
|
||||||
|
var p = a.action in that ?
|
||||||
|
that.getDocPath(a.action)
|
||||||
|
: ''
|
||||||
|
// use the action menu to select actions...
|
||||||
|
var dialog = that.browseActions(p, {
|
||||||
|
no_disabled: true,
|
||||||
|
no_hidden: true,
|
||||||
|
callback: function(action){
|
||||||
code = action
|
code = action
|
||||||
elem.find('.text').last().text(action)
|
elem.find('.text').last().text(action)
|
||||||
dialog.close()
|
dialog.close()
|
||||||
})
|
},
|
||||||
|
})
|
||||||
}],
|
}],
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@ -1195,6 +1206,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
cls: 'metadata-view',
|
cls: 'metadata-view',
|
||||||
})
|
})
|
||||||
// save the keys...
|
// save the keys...
|
||||||
|
// XXX for some reason when Esc this is called twice...
|
||||||
.on('close', function(){
|
.on('close', function(){
|
||||||
if(abort){
|
if(abort){
|
||||||
return
|
return
|
||||||
@ -1207,12 +1219,12 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
that.keyHandler(mode, k, '')
|
that.keyHandler(mode, k, '')
|
||||||
})
|
})
|
||||||
|
|
||||||
keys = code == orig_code ?
|
var new_keys = code == orig_code ?
|
||||||
keys.filter(function(k){ orig_keys.indexOf(k) < 0 })
|
keys.filter(function(k){ orig_keys.indexOf(k) < 0 })
|
||||||
: keys
|
: keys
|
||||||
|
|
||||||
// add keys...
|
// add keys...
|
||||||
keys
|
new_keys
|
||||||
.forEach(function(k){
|
.forEach(function(k){
|
||||||
that.keyHandler(mode, k, code) })
|
that.keyHandler(mode, k, code) })
|
||||||
})
|
})
|
||||||
|
|||||||
@ -408,10 +408,14 @@ var DialogsActions = actions.Actions({
|
|||||||
clean = clean == null ? true : clean
|
clean = clean == null ? true : clean
|
||||||
join = join == null ? '/' : join
|
join = join == null ? '/' : join
|
||||||
var path = (this.getDoc(action)[action].shift() || action)
|
var path = (this.getDoc(action)[action].shift() || action)
|
||||||
|
path = clean ? path.replace(/^- /, '') : path
|
||||||
|
path = path
|
||||||
.split(/[\\\/]/g)
|
.split(/[\\\/]/g)
|
||||||
// remove priority...
|
// remove priority...
|
||||||
.map(function(e){
|
.map(function(e){
|
||||||
return clean ? e.replace(/^[-+]?[0-9]+:\s*/, '') : e })
|
return clean ?
|
||||||
|
e.replace(/^[-+]?[0-9]+:\s*/, '')
|
||||||
|
: e })
|
||||||
return join ? path.join('/') : path
|
return join ? path.join('/') : path
|
||||||
}],
|
}],
|
||||||
getDocBaseDir: ['- Interface/',
|
getDocBaseDir: ['- Interface/',
|
||||||
@ -478,14 +482,12 @@ var DialogsActions = actions.Actions({
|
|||||||
makeDrawer('bottom')],
|
makeDrawer('bottom')],
|
||||||
TopDrawer: ['- Interface/',
|
TopDrawer: ['- Interface/',
|
||||||
makeDrawer('top')],
|
makeDrawer('top')],
|
||||||
|
|
||||||
// like panel but drop down from mouse location or specified position
|
// like panel but drop down from mouse location or specified position
|
||||||
DropDown: ['- Interface/',
|
DropDown: ['- Interface/',
|
||||||
makeUIContainer(function(dialog, options){
|
makeUIContainer(function(dialog, options){
|
||||||
// XXX
|
// XXX
|
||||||
console.error('Not yet implemented.')
|
console.error('Not yet implemented.')
|
||||||
})],
|
})],
|
||||||
|
|
||||||
// XXX STUB -- need a real panel with real docking and closing
|
// XXX STUB -- need a real panel with real docking and closing
|
||||||
// ability...
|
// ability...
|
||||||
// XXX need to:
|
// XXX need to:
|
||||||
@ -523,11 +525,10 @@ var DialogsActions = actions.Actions({
|
|||||||
})],
|
})],
|
||||||
|
|
||||||
|
|
||||||
listDialog: ['- Interface/',
|
// Helper for creating lists fast...
|
||||||
|
showList: ['- Interface/',
|
||||||
makeUIDialog(function(list, options){
|
makeUIDialog(function(list, options){
|
||||||
|
return browse.makeList(null, list, options) })],
|
||||||
return browse.makeList(null, list, options)
|
|
||||||
})],
|
|
||||||
|
|
||||||
|
|
||||||
listDialogs: ['Interface/Dialog/Dialog list...',
|
listDialogs: ['Interface/Dialog/Dialog list...',
|
||||||
@ -699,6 +700,14 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
// though only the last one is called...
|
// though only the last one is called...
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
// options format:
|
||||||
|
// {
|
||||||
|
// callback: <function>,
|
||||||
|
// no_disabled: false,
|
||||||
|
// no_hidden: false,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
// NOTE: if the action returns an instance of overlay.Overlay this
|
// NOTE: if the action returns an instance of overlay.Overlay this
|
||||||
// will not close right away but rather bind to:
|
// will not close right away but rather bind to:
|
||||||
// overlay.close -> self.focus()
|
// overlay.close -> self.focus()
|
||||||
@ -714,10 +723,11 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
//
|
//
|
||||||
// XXX can we do a deep search on '/' -- find any nested action???
|
// XXX can we do a deep search on '/' -- find any nested action???
|
||||||
browseActions: ['Interface/Dialog/Actions...',
|
browseActions: ['Interface/Dialog/Actions...',
|
||||||
makeUIDialog(function(path){
|
makeUIDialog(function(path, options){
|
||||||
var actions = this
|
var actions = this
|
||||||
var priority = /^(-?[0-9]+)\s*:\s*/
|
var priority = /^(-?[0-9]+)\s*:\s*/
|
||||||
var dialog
|
var dialog
|
||||||
|
options = options || {}
|
||||||
|
|
||||||
// prepare the config...
|
// prepare the config...
|
||||||
var cfg = {
|
var cfg = {
|
||||||
@ -793,7 +803,7 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
|
|
||||||
// if it's not a dialog, don't wait...
|
// if it's not a dialog, don't wait...
|
||||||
} else {
|
} else {
|
||||||
dialog.parent.close()
|
dialog.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
return child
|
return child
|
||||||
@ -909,14 +919,18 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
states = ['on', 'off']
|
states = ['on', 'off']
|
||||||
}
|
}
|
||||||
|
|
||||||
// build states...
|
// build toggler states...
|
||||||
states.forEach(function(state){
|
states.forEach(function(state){
|
||||||
make(state, {
|
make(state, {
|
||||||
// NOTE: if something is hidden
|
// NOTE: if something is hidden
|
||||||
// it is also disabled...
|
// it is also disabled...
|
||||||
// ...this is by design.
|
// ...this is by design.
|
||||||
disabled: mode == 'hidden' || mode == 'disabled',
|
disabled: options.no_disabled ?
|
||||||
hidden: mode == 'hidden',
|
false
|
||||||
|
: (mode == 'hidden' || mode == 'disabled'),
|
||||||
|
hidden: options.no_hidden ?
|
||||||
|
false
|
||||||
|
: mode == 'hidden',
|
||||||
})
|
})
|
||||||
// XXX need to normalize state -- comments, whitespace, etc...
|
// XXX need to normalize state -- comments, whitespace, etc...
|
||||||
.attr('keys', getKeys(action +': "'+ state +'"'))
|
.attr('keys', getKeys(action +': "'+ state +'"'))
|
||||||
@ -925,7 +939,9 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
mode == 'hidden' ? mode : ''
|
mode == 'hidden' ? mode : ''
|
||||||
].join(' '))
|
].join(' '))
|
||||||
.on('open', function(){
|
.on('open', function(){
|
||||||
actions[action](state)
|
options.callback ?
|
||||||
|
options.callback.call(actions, action)
|
||||||
|
: actions[action](state)
|
||||||
that.pop()
|
that.pop()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -981,8 +997,12 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
// NOTE: if something is hidden
|
// NOTE: if something is hidden
|
||||||
// it is also disabled...
|
// it is also disabled...
|
||||||
// ...this is by design.
|
// ...this is by design.
|
||||||
disabled: mode == 'hidden' || mode == 'disabled',
|
disabled: options.no_disabled ?
|
||||||
hidden: mode == 'hidden',
|
false
|
||||||
|
: (mode == 'hidden' || mode == 'disabled'),
|
||||||
|
hidden: options.no_hidden ?
|
||||||
|
false
|
||||||
|
: mode == 'hidden',
|
||||||
buttons: [
|
buttons: [
|
||||||
[actions[action]('?'),
|
[actions[action]('?'),
|
||||||
function(){
|
function(){
|
||||||
@ -995,8 +1015,9 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
.attr('keys', getKeys(action))
|
.attr('keys', getKeys(action))
|
||||||
.addClass(mode == 'hidden' ? mode : '')
|
.addClass(mode == 'hidden' ? mode : '')
|
||||||
.on('open', function(){
|
.on('open', function(){
|
||||||
// XXX can this open a dialog???
|
options.callback ?
|
||||||
actions[action]()
|
options.callback.call(actions, action)
|
||||||
|
: actions[action]()
|
||||||
|
|
||||||
that.update()
|
that.update()
|
||||||
that.select('"'+ text +'"')
|
that.select('"'+ text +'"')
|
||||||
@ -1008,12 +1029,18 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
// NOTE: if something is hidden
|
// NOTE: if something is hidden
|
||||||
// it is also disabled...
|
// it is also disabled...
|
||||||
// ...this is by design.
|
// ...this is by design.
|
||||||
disabled: mode == 'hidden' || mode == 'disabled',
|
disabled: options.no_disabled ?
|
||||||
hidden: mode == 'hidden',
|
false
|
||||||
|
: (mode == 'hidden' || mode == 'disabled'),
|
||||||
|
hidden: options.no_hidden ?
|
||||||
|
false
|
||||||
|
: mode == 'hidden',
|
||||||
})
|
})
|
||||||
.attr('keys', getKeys(action))
|
.attr('keys', getKeys(action))
|
||||||
.on('open', function(){
|
.on('open', function(){
|
||||||
waitFor(actions[action]())
|
options.callback ?
|
||||||
|
options.callback.call(actions, action)
|
||||||
|
: waitFor(actions[action]())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1021,10 +1048,7 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
} else if(actions.config['browse-actions-settings'].showEmpty
|
} else if(actions.config['browse-actions-settings'].showEmpty
|
||||||
|| (cur[key] != null
|
|| (cur[key] != null
|
||||||
&& Object.keys(cur[key]).length > 0)){
|
&& Object.keys(cur[key]).length > 0)){
|
||||||
make(text + '/',
|
make(text + '/', { push_on_open: true })
|
||||||
{
|
|
||||||
push_on_open: true
|
|
||||||
})
|
|
||||||
|
|
||||||
// item: line...
|
// item: line...
|
||||||
} else if(text == '---'){
|
} else if(text == '---'){
|
||||||
|
|||||||
@ -302,7 +302,7 @@ function(data, options){
|
|||||||
var pattern = options.disableItemPattern
|
var pattern = options.disableItemPattern
|
||||||
&& RegExp(options.disableItemPattern)
|
&& RegExp(options.disableItemPattern)
|
||||||
|
|
||||||
data.forEach(function(k){
|
keys.forEach(function(k){
|
||||||
var txt = k
|
var txt = k
|
||||||
var opts = Object.create(options)
|
var opts = Object.create(options)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user