mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
some refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f6d999b09e
commit
6f60d79b6a
@ -1154,8 +1154,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
}
|
}
|
||||||
this.keyboard.handler('General', 'e', 'editKeys')
|
this.keyboard.handler('General', 'e', 'editKeys')
|
||||||
}
|
}
|
||||||
})
|
}) })],
|
||||||
})],
|
|
||||||
// XXX this does not handle the passed container protocol...
|
// XXX this does not handle the passed container protocol...
|
||||||
// .editKeyboardBindings('Drawer') is broken...
|
// .editKeyboardBindings('Drawer') is broken...
|
||||||
editKeyboardBindings: ['Interface/Keyboard bindings editor...',
|
editKeyboardBindings: ['Interface/Keyboard bindings editor...',
|
||||||
@ -1183,7 +1182,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
.unique())
|
.unique())
|
||||||
}
|
}
|
||||||
|
|
||||||
var dialog = this.browseKeyboardBindings(
|
return this.browseKeyboardBindings(
|
||||||
path,
|
path,
|
||||||
{
|
{
|
||||||
cls: 'edit',
|
cls: 'edit',
|
||||||
@ -1204,7 +1203,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
cur.parent().find('[mode="'+prev+'"]')
|
cur.parent().find('[mode="'+prev+'"]')
|
||||||
.first()
|
.first()
|
||||||
.before(elems)
|
.before(elems)
|
||||||
dialog.select(elems.first())
|
this.select(elems.first())
|
||||||
|
|
||||||
// do the actual section ordering...
|
// do the actual section ordering...
|
||||||
sortModes(cur.parent())
|
sortModes(cur.parent())
|
||||||
@ -1221,7 +1220,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
cur.parent().find('[mode="'+next+'"]')
|
cur.parent().find('[mode="'+next+'"]')
|
||||||
.last()
|
.last()
|
||||||
.after(elems)
|
.after(elems)
|
||||||
dialog.select(elems.first())
|
this.select(elems.first())
|
||||||
|
|
||||||
// do the actual section ordering...
|
// do the actual section ordering...
|
||||||
sortModes(cur.parent())
|
sortModes(cur.parent())
|
||||||
@ -1231,6 +1230,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
mode_actions: [
|
mode_actions: [
|
||||||
// XXX focus resulting key...
|
// XXX focus resulting key...
|
||||||
['key', function(_, cur){
|
['key', function(_, cur){
|
||||||
|
var dialog = this
|
||||||
that.editKeyBinding(
|
that.editKeyBinding(
|
||||||
cur.attr('mode'),
|
cur.attr('mode'),
|
||||||
null,
|
null,
|
||||||
@ -1239,6 +1239,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
// XXX place element...
|
// XXX place element...
|
||||||
// XXX focus resulting mode...
|
// XXX focus resulting mode...
|
||||||
['mode', function(_, cur){
|
['mode', function(_, cur){
|
||||||
|
var dialog = this
|
||||||
// XXX need to pass order info...
|
// XXX need to pass order info...
|
||||||
that.editKeyboardMode(
|
that.editKeyboardMode(
|
||||||
null,
|
null,
|
||||||
@ -1249,7 +1250,8 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
// XXX should this be only a button thing (done in .browseKeyboardBindings(..))
|
// XXX should this be only a button thing (done in .browseKeyboardBindings(..))
|
||||||
// or also the main action???
|
// or also the main action???
|
||||||
.open(function(){
|
.open(function(){
|
||||||
var cur = dialog.select('!')
|
var dialog = this
|
||||||
|
var cur = this.select('!')
|
||||||
var sub_dialog
|
var sub_dialog
|
||||||
|
|
||||||
// key...
|
// key...
|
||||||
@ -1277,29 +1279,33 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
sub_dialog
|
sub_dialog
|
||||||
&& sub_dialog
|
&& sub_dialog
|
||||||
.close(function(evt, mode){
|
.close(function(evt, mode){
|
||||||
mode != 'cancel' && dialog.update() })
|
dialog.update() })
|
||||||
})
|
})
|
||||||
// select updated/new items...
|
// select updated/new items...
|
||||||
.on('update', function(){
|
.on('update', function(){
|
||||||
to_select
|
to_select
|
||||||
// XXX this does not work for modes...
|
// XXX this does not work for modes...
|
||||||
&& dialog.select(to_select)
|
&& this.select(to_select)
|
||||||
to_select = null
|
to_select = null
|
||||||
})
|
})
|
||||||
|
// setup keyboard...
|
||||||
|
.run(function(){
|
||||||
|
this.newKey = function(){
|
||||||
|
that.editKeyBinding(
|
||||||
|
this.select('!').attr('mode')
|
||||||
|
|| Object.keys(kb.keyboard)[0])
|
||||||
|
.close(function(evt, mode){
|
||||||
|
this.update() }.bind(this)) }
|
||||||
|
this.newMode = function(){
|
||||||
|
that.editKeyboardMode()
|
||||||
|
.close(function(evt, mode){
|
||||||
|
this.update() }.bind(this)) }
|
||||||
|
|
||||||
dialog.newKey = function(){
|
this.keyboard
|
||||||
that.editKeyBinding(this.select('!').attr('mode')
|
|
||||||
|| Object.keys(kb.keyboard)[0]) }
|
|
||||||
dialog.newMode = function(){
|
|
||||||
that.editKeyboardMode() }
|
|
||||||
|
|
||||||
dialog.keyboard
|
|
||||||
.handler('General', 'N', 'newKey')
|
.handler('General', 'N', 'newKey')
|
||||||
.handler('General', 'K', 'newKey')
|
.handler('General', 'K', 'newKey')
|
||||||
.handler('General', 'M', 'newMode')
|
.handler('General', 'M', 'newMode')
|
||||||
|
}) })],
|
||||||
return dialog
|
|
||||||
})],
|
|
||||||
// XXX add action completion... (???)
|
// XXX add action completion... (???)
|
||||||
editKeyBinding: ['- Interface/Key mapping...',
|
editKeyBinding: ['- Interface/Key mapping...',
|
||||||
core.doc`Key mapping editor...
|
core.doc`Key mapping editor...
|
||||||
@ -1322,7 +1328,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
: []
|
: []
|
||||||
var orig_keys = keys.slice()
|
var orig_keys = keys.slice()
|
||||||
|
|
||||||
var dialog = browse.makeLister(null,
|
return browse.makeLister(null,
|
||||||
function(path, make){
|
function(path, make){
|
||||||
var cfg = {
|
var cfg = {
|
||||||
start_on: 'open',
|
start_on: 'open',
|
||||||
@ -1384,7 +1390,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
make.ConfirmAction('Delete', {
|
make.ConfirmAction('Delete', {
|
||||||
callback: function(){
|
callback: function(){
|
||||||
keys = []
|
keys = []
|
||||||
dialog.close()
|
make.dialog.close()
|
||||||
},
|
},
|
||||||
timeout: that.config['ui-confirm-timeout'] || 2000,
|
timeout: that.config['ui-confirm-timeout'] || 2000,
|
||||||
buttons: [
|
buttons: [
|
||||||
@ -1423,15 +1429,11 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
callback
|
callback
|
||||||
&& callback.call(that, code)
|
&& callback.call(that, code)
|
||||||
})
|
})
|
||||||
|
.run(function(){
|
||||||
dialog.abort = function(){
|
this.abort = function(){
|
||||||
this.close('cancel')
|
this.close('cancel') }
|
||||||
}
|
this.keyboard.handler('General', 'Q', 'abort')
|
||||||
dialog.keyboard
|
}) })],
|
||||||
.handler('General', 'Q', 'abort')
|
|
||||||
|
|
||||||
return dialog
|
|
||||||
})],
|
|
||||||
editKeyboardMode: ['- Interface/Mode...',
|
editKeyboardMode: ['- Interface/Mode...',
|
||||||
core.doc`Mode editor...
|
core.doc`Mode editor...
|
||||||
|
|
||||||
@ -1461,7 +1463,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
|
|
||||||
var orig_mode = mode in that.keybindings ? mode : null
|
var orig_mode = mode in that.keybindings ? mode : null
|
||||||
|
|
||||||
var dialog = browse.makeLister(null,
|
return browse.makeLister(null,
|
||||||
function(path, make){
|
function(path, make){
|
||||||
var cfg = {
|
var cfg = {
|
||||||
start_on: 'open',
|
start_on: 'open',
|
||||||
@ -1487,7 +1489,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
if(mode in that.keybindings){
|
if(mode in that.keybindings){
|
||||||
delete that.keybindings[mode]
|
delete that.keybindings[mode]
|
||||||
}
|
}
|
||||||
dialog.close()
|
make.dialog.close()
|
||||||
},
|
},
|
||||||
timeout: that.config['ui-confirm-timeout'] || 2000,
|
timeout: that.config['ui-confirm-timeout'] || 2000,
|
||||||
buttons: [
|
buttons: [
|
||||||
@ -1527,15 +1529,11 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
callback
|
callback
|
||||||
&& callback.call(that, mode)
|
&& callback.call(that, mode)
|
||||||
})
|
})
|
||||||
|
.run(function(){
|
||||||
dialog.abort = function(){
|
this.abort = function(){
|
||||||
this.close('cancel')
|
this.close('cancel') }
|
||||||
}
|
this.keyboard.handler('General', 'Q', 'abort')
|
||||||
dialog.keyboard
|
}) })],
|
||||||
.handler('General', 'Q', 'abort')
|
|
||||||
|
|
||||||
return dialog
|
|
||||||
})],
|
|
||||||
editKeyboardModeDroppedKeys: ['- Interface/Dropped keys...',
|
editKeyboardModeDroppedKeys: ['- Interface/Dropped keys...',
|
||||||
core.doc`Edit keys dropped after a mode...
|
core.doc`Edit keys dropped after a mode...
|
||||||
|
|
||||||
@ -1568,7 +1566,7 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
|
|
||||||
var drop = (that.keybindings[mode].drop || []).slice()
|
var drop = (that.keybindings[mode].drop || []).slice()
|
||||||
|
|
||||||
var dialog = browse.makeLister(null,
|
return browse.makeLister(null,
|
||||||
function(path, make){
|
function(path, make){
|
||||||
var drop_all
|
var drop_all
|
||||||
|
|
||||||
@ -1613,15 +1611,11 @@ var KeyboardUIActions = actions.Actions({
|
|||||||
that.keybindings[mode].drop = drop
|
that.keybindings[mode].drop = drop
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.run(function(){
|
||||||
dialog.abort = function(){
|
this.abort = function(){
|
||||||
this.close('cancel')
|
this.close('cancel') }
|
||||||
}
|
this.keyboard.handler('General', 'Q', 'abort')
|
||||||
dialog.keyboard
|
}) })],
|
||||||
.handler('General', 'Q', 'abort')
|
|
||||||
|
|
||||||
return dialog
|
|
||||||
})],
|
|
||||||
|
|
||||||
|
|
||||||
/*/ XXX move to gen2
|
/*/ XXX move to gen2
|
||||||
|
|||||||
@ -227,13 +227,12 @@ var SlideshowActions = actions.Actions({
|
|||||||
toggleSlideshowLooping: ['- Slideshow/Slideshow $looping',
|
toggleSlideshowLooping: ['- Slideshow/Slideshow $looping',
|
||||||
core.makeConfigToggler('slideshow-looping', ['on', 'off'])],
|
core.makeConfigToggler('slideshow-looping', ['on', 'off'])],
|
||||||
|
|
||||||
toggleSlideshowLooping: ['Interface|Slideshow/Slideshow $hold',
|
toggleSlideshowHold: ['Interface|Slideshow/Slideshow $hold',
|
||||||
core.makeConfigToggler('slideshow-hold', ['on', 'off'])],
|
core.makeConfigToggler('slideshow-hold', ['on', 'off'])],
|
||||||
|
|
||||||
resetSlideshowTimer: ['- Slideshow/Reset slideshow timer',
|
resetSlideshowTimer: ['- Slideshow/Reset slideshow timer',
|
||||||
function(){
|
function(){
|
||||||
this.__slideshow_timer && this.toggleSlideshow('on')
|
this.__slideshow_timer && this.toggleSlideshow('on') }],
|
||||||
}],
|
|
||||||
suspendSlideshowTimer: ['- Slideshow/Suspend slideshow timer',
|
suspendSlideshowTimer: ['- Slideshow/Suspend slideshow timer',
|
||||||
function(){
|
function(){
|
||||||
if(this.__slideshow_timer){
|
if(this.__slideshow_timer){
|
||||||
|
|||||||
@ -841,7 +841,7 @@ var DialogsActions = actions.Actions({
|
|||||||
})],
|
})],
|
||||||
|
|
||||||
|
|
||||||
listDialogs: ['Interface/Dialog/Dialog list...',
|
listDialogs: ['Interface|System/Dialog/Dialog list...',
|
||||||
makeUIDialog(function(){
|
makeUIDialog(function(){
|
||||||
var actions = this
|
var actions = this
|
||||||
|
|
||||||
@ -1465,18 +1465,15 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
// XXX can this also do a flat mode???
|
// XXX can this also do a flat mode???
|
||||||
// ...this would help with the (global) search -- switch to
|
// ...this would help with the (global) search -- switch to
|
||||||
// flat if searching in root mode...
|
// flat if searching in root mode...
|
||||||
browseActions: ['Interface/Dialog/Actions...',
|
browseActions: ['Interface|System/Dialog/Actions...',
|
||||||
makeUIDialog(function(path, options){
|
makeUIDialog(function(path, options){
|
||||||
var actions = this
|
var actions = this
|
||||||
|
options = options || {}
|
||||||
|
|
||||||
var PRIORITY = /^(-?[0-9]+)\s*:\s*/
|
var PRIORITY = /^(-?[0-9]+)\s*:\s*/
|
||||||
|
|
||||||
var MARKER = RegExp(this.config['browse-actions-shortcut-marker'], 'g')
|
var MARKER = RegExp(this.config['browse-actions-shortcut-marker'], 'g')
|
||||||
MARKER = MARKER || RegExp(MARKER, 'g')
|
MARKER = MARKER || RegExp(MARKER, 'g')
|
||||||
|
|
||||||
var dialog
|
|
||||||
options = options || {}
|
|
||||||
|
|
||||||
// prepare the config...
|
// prepare the config...
|
||||||
var cfg = {
|
var cfg = {
|
||||||
cls: 'browse-actions',
|
cls: 'browse-actions',
|
||||||
@ -1558,7 +1555,7 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for dialog...
|
// Wait for dialog...
|
||||||
var waitFor = (function(child){
|
var waitFor = function(dialog, child){
|
||||||
// we got a widget, wait for it to close...
|
// we got a widget, wait for it to close...
|
||||||
if(child instanceof widget.Widget){
|
if(child instanceof widget.Widget){
|
||||||
child
|
child
|
||||||
@ -1572,7 +1569,7 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return child
|
return child
|
||||||
}).bind(this)
|
}.bind(this)
|
||||||
|
|
||||||
// Tree builder...
|
// Tree builder...
|
||||||
// XXX normalize actions -- whitespace, '!', args...
|
// XXX normalize actions -- whitespace, '!', args...
|
||||||
@ -1658,7 +1655,7 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
//console.log('!!!!', tree)
|
//console.log('!!!!', tree)
|
||||||
|
|
||||||
// now for the dialog...
|
// now for the dialog...
|
||||||
dialog = browse.makeLister(null, function(path, make){
|
return browse.makeLister(null, function(path, make){
|
||||||
var that = this
|
var that = this
|
||||||
var cur = tree
|
var cur = tree
|
||||||
|
|
||||||
@ -1832,7 +1829,7 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
open: function(){
|
open: function(){
|
||||||
options.callback ?
|
options.callback ?
|
||||||
options.callback.call(actions, action)
|
options.callback.call(actions, action)
|
||||||
: waitFor(actions[action]())
|
: waitFor(make.dialog, actions[action]())
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1865,8 +1862,8 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
.on('close', function(){
|
.on('close', function(){
|
||||||
var config = actions.config['browse-actions-settings']
|
var config = actions.config['browse-actions-settings']
|
||||||
|
|
||||||
config.showDisabled = dialog.options.showDisabled
|
config.showDisabled = this.options.showDisabled
|
||||||
config.showHidden = dialog.options.showHidden
|
config.showHidden = this.options.showHidden
|
||||||
})
|
})
|
||||||
.run(function(){
|
.run(function(){
|
||||||
actions.config['browse-actions-keys']
|
actions.config['browse-actions-keys']
|
||||||
@ -1880,10 +1877,7 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
}
|
}
|
||||||
this.keyboard.handler('General', '?', 'showDoc')
|
this.keyboard.handler('General', '?', 'showDoc')
|
||||||
this.menu(showDoc.bind(this))
|
this.menu(showDoc.bind(this))
|
||||||
})
|
}) })],
|
||||||
|
|
||||||
return dialog
|
|
||||||
})],
|
|
||||||
|
|
||||||
toggleBrowseActionKeys: ['Interface/Show keys in menu',
|
toggleBrowseActionKeys: ['Interface/Show keys in menu',
|
||||||
core.makeConfigToggler(
|
core.makeConfigToggler(
|
||||||
|
|||||||
@ -1875,7 +1875,8 @@ var BrowserPrototype = {
|
|||||||
// specific events...
|
// specific events...
|
||||||
focus: function(handler){
|
focus: function(handler){
|
||||||
if(handler != null){
|
if(handler != null){
|
||||||
this.on('focus', handler)
|
//this.on('focus', handler)
|
||||||
|
this.on('focus', handler.bind(this))
|
||||||
|
|
||||||
// focus only if we do not have focus...
|
// focus only if we do not have focus...
|
||||||
} else if(!this.dom.is(':focus')
|
} else if(!this.dom.is(':focus')
|
||||||
@ -3883,9 +3884,8 @@ var BrowserPrototype = {
|
|||||||
// instance or in .options
|
// instance or in .options
|
||||||
open: function(path){
|
open: function(path){
|
||||||
// special case: register the open handler...
|
// special case: register the open handler...
|
||||||
if(typeof(path) == typeof(function(){})){
|
if(path instanceof Function){
|
||||||
return this.on('open', path)
|
return this.on('open', path.bind(this)) }
|
||||||
}
|
|
||||||
|
|
||||||
var elem = this.select('!')
|
var elem = this.select('!')
|
||||||
|
|
||||||
|
|||||||
@ -18,17 +18,22 @@ var object = require('../object')
|
|||||||
var proxyToDom =
|
var proxyToDom =
|
||||||
module.proxyToDom =
|
module.proxyToDom =
|
||||||
function(name){
|
function(name){
|
||||||
return function(){
|
return function(...args){
|
||||||
// proxy handler...
|
// bind functions to this...
|
||||||
if(name in this.dom){
|
// XXX is this the right way to go???
|
||||||
this.dom[name].apply(this.dom, arguments)
|
args = args
|
||||||
|
.map(function(a){
|
||||||
|
return a instanceof Function ?
|
||||||
|
a.bind(this)
|
||||||
|
: a
|
||||||
|
}.bind(this))
|
||||||
|
|
||||||
|
name in this.dom ?
|
||||||
|
// proxy handler...
|
||||||
|
this.dom[name].apply(this.dom, args)
|
||||||
// on/trigger handlers...
|
// on/trigger handlers...
|
||||||
} else {
|
: this.dom.trigger(name, args)
|
||||||
arguments[0] instanceof Function ?
|
|
||||||
this.dom.on(name, arguments[0])
|
|
||||||
: this.dom.trigger(name, [].slice.call(arguments))
|
|
||||||
}
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user