mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
lots of minor tweaks and some refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
5b4c7353ef
commit
924f88fdae
@ -1030,20 +1030,24 @@ actions.Actions({
|
||||
}
|
||||
if(target == 'cw' || target == 'ccw'){
|
||||
direction = target
|
||||
target = null
|
||||
target = this.data.getImage()
|
||||
} else {
|
||||
target = this.data.getImages(target instanceof Array ? target : [target])
|
||||
}
|
||||
this.images
|
||||
&& this.images.rotateImage(this.data.getImage(target), direction || 'cw')
|
||||
&& this.images.rotateImage(target, direction || 'cw')
|
||||
}],
|
||||
flip: ['- Image|Edit/Flip image',
|
||||
{journal: true},
|
||||
function(target, direction){
|
||||
if(target == 'vertical' || target == 'horizontal'){
|
||||
direction = target
|
||||
target = null
|
||||
target = this.data.getImage()
|
||||
} else {
|
||||
target = this.data.getImages(target instanceof Array ? target : [target])
|
||||
}
|
||||
this.images
|
||||
&& this.images.flipImage(this.data.getImage(target), direction || 'horizontal')
|
||||
&& this.images.flipImage(target, direction || 'horizontal')
|
||||
}],
|
||||
|
||||
// shorthands...
|
||||
|
||||
@ -513,7 +513,7 @@ var KeyboardActions = actions.Actions({
|
||||
return
|
||||
}
|
||||
|
||||
var a = keyboard.parseActionCall(code)
|
||||
var a = keyboard.parseActionCall(code, that)
|
||||
var doc = a.doc || that.getDocTitle(a.action) || null
|
||||
|
||||
// check if we have no doc...
|
||||
@ -667,7 +667,7 @@ var KeyboardActions = actions.Actions({
|
||||
// - .no_default
|
||||
// - .stop_propagation
|
||||
var normalizeHandler = function(action){
|
||||
var a = keyboard.parseActionCall(action.doc || action)
|
||||
var a = keyboard.parseActionCall(action.doc || action, that)
|
||||
return a.action in that ?
|
||||
a.action
|
||||
+(a.arguments.length > 0 ?
|
||||
@ -991,7 +991,7 @@ var KeyboardUIActions = actions.Actions({
|
||||
var c = 0
|
||||
Object.keys(keys[mode] || {}).forEach(function(action){
|
||||
|
||||
var o = keyboard.parseActionCall(action)
|
||||
var o = keyboard.parseActionCall(action, that)
|
||||
|
||||
if(getKeyText){
|
||||
var doc = ''
|
||||
@ -1325,7 +1325,7 @@ var KeyboardUIActions = actions.Actions({
|
||||
['⋯', function(evt, elem){
|
||||
code = code || ''
|
||||
// highlight the current action...
|
||||
var a = keyboard.parseActionCall(code)
|
||||
var a = keyboard.parseActionCall(code, that)
|
||||
var p = a.action in that ?
|
||||
that.getDocPath(a.action)
|
||||
: ''
|
||||
|
||||
@ -244,7 +244,20 @@ var ImageMarkActions = actions.Actions({
|
||||
removeMarkedFromCrop: ['Mark|Crop/Remove marked from crop',
|
||||
{browseMode: function(target){
|
||||
return (this.marked.length == 0 || !this.cropped) && 'disabled' }},
|
||||
function(){ this.removeFromCrop(this.marked) }],
|
||||
'removeFromCrop: marked'],
|
||||
|
||||
rotateMarkedCW: ['Mark/Rotate marked clockwise',
|
||||
{browseMode: 'cropMarked'},
|
||||
'rotateCW: marked'],
|
||||
rotateMarkedCCW: ['Mark/Rotate marked counterclockwise',
|
||||
{browseMode: 'cropMarked'},
|
||||
'rotateCCW: marked'],
|
||||
flipMarkedVertical: ['Mark/Flip marked vertically',
|
||||
{browseMode: 'cropMarked'},
|
||||
'flipVertical: marked'],
|
||||
flipMarkedHorizontal: ['Mark/Flip marked horizontally',
|
||||
{browseMode: 'cropMarked'},
|
||||
'flipHorizontal: marked'],
|
||||
})
|
||||
|
||||
|
||||
|
||||
@ -93,11 +93,11 @@ function(context, cls, data){
|
||||
primary.pop()
|
||||
: null
|
||||
secondary = typeof(secondary) == typeof('str') ?
|
||||
keyboard.parseActionCall(secondary)
|
||||
keyboard.parseActionCall(secondary, context)
|
||||
: secondary
|
||||
primary = primary instanceof Array ? primary.shift() : primary
|
||||
primary = typeof(primary) == typeof('str') ?
|
||||
keyboard.parseActionCall(primary)
|
||||
keyboard.parseActionCall(primary, context)
|
||||
: primary
|
||||
|
||||
var click = primary instanceof Function ?
|
||||
@ -785,7 +785,7 @@ var DialogsActions = actions.Actions({
|
||||
var loaders = {}
|
||||
|
||||
list.forEach(function(m){
|
||||
var a = keyboard.parseActionCall(m)
|
||||
var a = keyboard.parseActionCall(m, that)
|
||||
|
||||
if(a.action in that){
|
||||
var args = a.arguments
|
||||
|
||||
@ -1073,6 +1073,7 @@ var DataPrototype = {
|
||||
// NOTE: this is a partial rewrite avoiding .compact() as much as
|
||||
// possible and restricting it to as small a subset as possible
|
||||
getImages: function(target, count, mode){
|
||||
var that = this
|
||||
target = (target == null && count == null) ? 'loaded' : target
|
||||
mode = mode == null ? 'around' : mode
|
||||
var list
|
||||
@ -1106,9 +1107,11 @@ var DataPrototype = {
|
||||
: this.getImages('loaded')
|
||||
count = null
|
||||
|
||||
list = target.filter(function(e){
|
||||
return loaded.indexOf(e) >= 0
|
||||
})
|
||||
list = target
|
||||
.map(function(e){
|
||||
return that.getImage(e) })
|
||||
.filter(function(e){
|
||||
return loaded.indexOf(e) >= 0 })
|
||||
|
||||
target = null
|
||||
|
||||
|
||||
@ -155,6 +155,9 @@ function doc(text, func){
|
||||
// - strings
|
||||
// - non-nested arrays or objects
|
||||
//
|
||||
// XXX EXPERIMENTAL...
|
||||
// This will resolve names to context attributes
|
||||
//
|
||||
// XXX should this be here???
|
||||
// XXX add support for suffix to return false / stop_propagation...
|
||||
// XXX should this handle calls???
|
||||
@ -162,7 +165,8 @@ function doc(text, func){
|
||||
// XXX this is the same as actions.parseStringAction(..), reuse in a logical manner...
|
||||
var parseActionCall =
|
||||
module.parseActionCall =
|
||||
function parseActionCall(txt){
|
||||
function parseActionCall(txt, context){
|
||||
context = context || this
|
||||
// split off the doc...
|
||||
var c = txt.split('--')
|
||||
var doc = (c[1] || '').trim()
|
||||
@ -175,11 +179,35 @@ function parseActionCall(txt){
|
||||
action = no_default ? action.slice(0, -1) : action
|
||||
|
||||
// parse arguments...
|
||||
/*
|
||||
var args = JSON.parse('['+(
|
||||
((c[1] || '')
|
||||
.match(/"[^"]*"|'[^']*'|\{[^\}]*\}|\[[^\]]*\]|\d+|\d+\.\d*|null/gm)
|
||||
|| [])
|
||||
.join(','))+']')
|
||||
//*/
|
||||
// XXX EXPERIMENTAL -- is this safe???
|
||||
var args = ((c[1] || '')
|
||||
.match(RegExp([
|
||||
'"[^"]*"',
|
||||
"'[^']*",
|
||||
'`[^`]*`',
|
||||
|
||||
'\\{[^\\}]*\\}',
|
||||
'\\[[^\\]]*\\]',
|
||||
|
||||
'\\d+|\\d+\\.\\d*',
|
||||
|
||||
'[a-zA-Z$@#_][0-9a-zA-Z$@#_]*',
|
||||
|
||||
'null',
|
||||
].join('|'), 'gm'))
|
||||
|| [])
|
||||
.map(function(e){
|
||||
// resolve vars to context attrs...
|
||||
return /^[a-zA-Z$@#_][0-9a-zA-Z$@#_]*$/.test(e) ?
|
||||
(context || {})[e]
|
||||
: JSON.parse(e) })
|
||||
|
||||
return {
|
||||
action: action,
|
||||
@ -1159,7 +1187,7 @@ function makeKeyboardHandler(keyboard, unhandled, actions){
|
||||
// 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 = (actions.parseStringHandler || kb.parseStringHandler)(handler, actions)
|
||||
//var h = kb.parseStringHandler(handler)
|
||||
|
||||
if(h && h.action in actions){
|
||||
|
||||
1002
ui (gen4)/package-lock.json
generated
1002
ui (gen4)/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -22,7 +22,7 @@
|
||||
"fs-walk": "^0.0.1",
|
||||
"glob": "^4.0.6",
|
||||
"guarantee-events": "^1.0.0",
|
||||
"ig-actions": "^3.9.0",
|
||||
"ig-actions": "^3.10.0",
|
||||
"ig-features": "^3.3.2",
|
||||
"ig-object": "^1.0.2",
|
||||
"openseadragon": "^2.3.1",
|
||||
@ -41,7 +41,7 @@
|
||||
"devDependencies": {
|
||||
"less": "*",
|
||||
"nwjs": "*",
|
||||
"webdriverio": "^4.0.4",
|
||||
"webdriverio": "^4.9.8",
|
||||
"webpack": "^2.7.0"
|
||||
},
|
||||
"bin": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user