mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
added persistent aliases...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
3d81db1bc2
commit
00ec10a335
57
ui (gen4)/features/alias.js
Executable file
57
ui (gen4)/features/alias.js
Executable file
@ -0,0 +1,57 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
**********************************************************************/
|
||||
((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define)
|
||||
(function(require){ var module={} // make module AMD/node compatible...
|
||||
/*********************************************************************/
|
||||
|
||||
var actions = require('lib/actions')
|
||||
var features = require('lib/features')
|
||||
|
||||
var core = require('features/core')
|
||||
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
var Alias =
|
||||
module.Alias = core.ImageGridFeatures.Feature({
|
||||
title: '',
|
||||
doc: '',
|
||||
|
||||
tag: 'alias',
|
||||
|
||||
config: {
|
||||
//aliases: {
|
||||
//},
|
||||
},
|
||||
|
||||
handlers: [
|
||||
['alias',
|
||||
function(_, alias, target){
|
||||
console.log(alias, target)
|
||||
// remove alias...
|
||||
if(target === null || target === false){
|
||||
var aliases = this.config.aliases || {}
|
||||
|
||||
delete aliases[alias]
|
||||
|
||||
if(Object.keys(alias).length == 0){
|
||||
delete this.config.aliases
|
||||
}
|
||||
|
||||
// save alias...
|
||||
} else {
|
||||
var aliases = this.config.aliases = this.config.aliases || {}
|
||||
|
||||
aliases[alias] = target
|
||||
}
|
||||
}]],
|
||||
})
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* vim:set ts=4 sw=4 : */ return module })
|
||||
@ -19,6 +19,7 @@ require('features/recover')
|
||||
require('features/history')
|
||||
require('features/app')
|
||||
require('features/peer')
|
||||
require('features/alias')
|
||||
require('features/ui')
|
||||
// XXX
|
||||
require('features/ui-blank-render')
|
||||
|
||||
@ -802,6 +802,9 @@ module.Keyboard = core.ImageGridFeatures.Feature({
|
||||
var that = this
|
||||
this.__keyboard_config = this.keybindings || GLOBAL_KEYBOARD
|
||||
|
||||
// string action call parser...
|
||||
this.parseStringHandler = this.parseStringAction
|
||||
|
||||
this.toggleKeyboardHandling('on')
|
||||
}],
|
||||
|
||||
|
||||
@ -50,6 +50,8 @@ core.ImageGridFeatures.Feature('viewer-testing', [
|
||||
'viewer-commandline',
|
||||
'viewer-minimal',
|
||||
|
||||
'alias',
|
||||
|
||||
// read-only mode...
|
||||
// XXX at this point this needs some more tuneup, the following
|
||||
// features are completely disabled when 'edit' is not present
|
||||
|
||||
@ -2295,6 +2295,10 @@ var WidgetTestActions = actions.Actions({
|
||||
.attr(attrs))
|
||||
}],
|
||||
|
||||
// XXX does not work -- see actions.Actions(..) for details...
|
||||
testAlias: ['Test/Action alias',
|
||||
'focusImage: "prev"'],
|
||||
|
||||
// action constructor for testing...
|
||||
makeAction: ['- Test/',
|
||||
function(name){
|
||||
|
||||
@ -159,6 +159,7 @@ function doc(text, func){
|
||||
// XXX add support for suffix to return false / stop_propagation...
|
||||
// XXX should this handle calls???
|
||||
// i.e. have .call(..) / .apply(..) methods???
|
||||
// XXX this is the same as actions.parseStringAction(..), reuse in a logical manner...
|
||||
var parseActionCall =
|
||||
module.parseActionCall =
|
||||
function parseActionCall(txt){
|
||||
@ -503,6 +504,8 @@ var KeyboardPrototype = {
|
||||
// stop_propagation: <bool>,
|
||||
// }
|
||||
//
|
||||
// XXX should this be a Keyboard thing or a context thing???
|
||||
// XXX revise name...
|
||||
parseStringHandler: parseActionCall,
|
||||
|
||||
|
||||
@ -1097,8 +1100,11 @@ function makeKeyboardHandler(keyboard, unhandled, actions){
|
||||
res = handler.call(actions)
|
||||
|
||||
// action call syntax...
|
||||
} else if(kb.parseStringHandler){
|
||||
var h = kb.parseStringHandler(handler)
|
||||
// XXX should this be a Keyboard thing or a context thing???
|
||||
} else if(actions.parseStringHandler || kb.parseStringHandler){
|
||||
//} else if(kb.parseStringHandler){
|
||||
var h = (actions.parseStringHandler || kb.parseStringHandler)(handler)
|
||||
//var h = kb.parseStringHandler(handler)
|
||||
|
||||
if(h && h.action in actions){
|
||||
did_handling = true
|
||||
|
||||
@ -18,11 +18,11 @@
|
||||
"app-module-path": "^1.0.6",
|
||||
"commander": "^2.11.0",
|
||||
"exiftool": "^0.0.3",
|
||||
"fs-extra": "^4.0.0",
|
||||
"fs-extra": "^4.0.1",
|
||||
"fs-walk": "^0.0.1",
|
||||
"glob": "^4.0.6",
|
||||
"guarantee-events": "^1.0.0",
|
||||
"ig-actions": "^3.2.5",
|
||||
"ig-actions": "^3.5.1",
|
||||
"ig-features": "^3.2.6",
|
||||
"ig-object": "^1.0.1",
|
||||
"openseadragon": "^2.3.0",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user