mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
added patterns and fixed several bugs in .browseActions(..) and related config...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
ee455bb41c
commit
e0d3fabaa0
@ -1575,7 +1575,7 @@ module.CropActions = actions.Actions({
|
|||||||
{browseMode: function(){
|
{browseMode: function(){
|
||||||
return this.data.ribbon_order.length <= 1 && 'disabled' }},
|
return this.data.ribbon_order.length <= 1 && 'disabled' }},
|
||||||
function(list){ this.data.length > 0 && this.crop(list, true) }],
|
function(list){ this.data.length > 0 && this.crop(list, true) }],
|
||||||
cropRibbon: ['Crop/Crop ribbon',
|
cropRibbon: ['Crop/Crop $ribbon',
|
||||||
function(ribbon, flatten){
|
function(ribbon, flatten){
|
||||||
if(this.data.length == 0){
|
if(this.data.length == 0){
|
||||||
return
|
return
|
||||||
@ -1618,7 +1618,7 @@ module.CropActions = actions.Actions({
|
|||||||
|
|
||||||
this.crop(crop, flatten)
|
this.crop(crop, flatten)
|
||||||
}],
|
}],
|
||||||
cropOutRibbonsBelow: ['Crop/Crop out ribbons bellow',
|
cropOutRibbonsBelow: ['Crop/Crop out ribbons $bellow',
|
||||||
function(ribbon, flatten){
|
function(ribbon, flatten){
|
||||||
if(this.data.length == 0){
|
if(this.data.length == 0){
|
||||||
return
|
return
|
||||||
@ -1647,7 +1647,7 @@ module.CropActions = actions.Actions({
|
|||||||
}],
|
}],
|
||||||
|
|
||||||
// XXX should this be here???
|
// XXX should this be here???
|
||||||
cropTagged: ['Tag|Crop/Crop tagged images',
|
cropTagged: ['- Tag|Crop/Crop tagged images',
|
||||||
function(tags, mode, flatten){
|
function(tags, mode, flatten){
|
||||||
if(this.data.length == 0){
|
if(this.data.length == 0){
|
||||||
return
|
return
|
||||||
|
|||||||
@ -22,6 +22,9 @@ var widgets = require('features/ui-widgets')
|
|||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
// XXX should collections be in the Crop menu????
|
// XXX should collections be in the Crop menu????
|
||||||
|
// ...essentially a collection is a saved crop, so this would be
|
||||||
|
// logical, would simplify control, etc.
|
||||||
|
//
|
||||||
|
|
||||||
// XXX things we need to do to collections:
|
// XXX things we need to do to collections:
|
||||||
// - auto-collections
|
// - auto-collections
|
||||||
@ -583,17 +586,17 @@ var UICollectionActions = actions.Actions({
|
|||||||
|
|
||||||
// Collections actions with collection selection...
|
// Collections actions with collection selection...
|
||||||
// XXX should we warn the user when overwriting???
|
// XXX should we warn the user when overwriting???
|
||||||
saveAsCollection: ['Collections/$Save as collection...',
|
saveAsCollection: ['Collections|Crop/$Save as collection...',
|
||||||
widgets.uiDialog(function(){
|
widgets.uiDialog(function(){
|
||||||
return this.browseCollections(function(title){
|
return this.browseCollections(function(title){
|
||||||
this.saveCollection(title) }) })],
|
this.saveCollection(title) }) })],
|
||||||
addToCollection: ['Collections|Image/Add $image to collection...',
|
addToCollection: ['Collections|Crop|Image/Add $image to collection...',
|
||||||
widgets.uiDialog(function(gids){
|
widgets.uiDialog(function(gids){
|
||||||
return this.browseCollections(function(title){
|
return this.browseCollections(function(title){
|
||||||
this.collect(gids || this.current, title) }) })],
|
this.collect(gids || this.current, title) }) })],
|
||||||
addLoadedToCollection: ['Collections/$Add loaded images to collection...',
|
addLoadedToCollection: ['Collections|Crop/$Add loaded images to collection...',
|
||||||
widgets.uiDialog(function(){ return this.addToCollection('loaded') })],
|
widgets.uiDialog(function(){ return this.addToCollection('loaded') })],
|
||||||
joinToCollection: ['Collections/$Merge view to collection...',
|
joinToCollection: ['Collections|Crop/$Merge view to collection...',
|
||||||
widgets.uiDialog(function(){
|
widgets.uiDialog(function(){
|
||||||
return this.browseCollections(function(title){
|
return this.browseCollections(function(title){
|
||||||
this.joinCollect(title) }) })],
|
this.joinCollect(title) }) })],
|
||||||
|
|||||||
@ -360,6 +360,7 @@ module.GLOBAL_KEYBOARD = {
|
|||||||
// collections...
|
// collections...
|
||||||
//alt_C: 'browseCollections',
|
//alt_C: 'browseCollections',
|
||||||
alt_C: 'browseActions: "/Collections/" -- Collections menu...',
|
alt_C: 'browseActions: "/Collections/" -- Collections menu...',
|
||||||
|
shift_O: 'browseCollections',
|
||||||
|
|
||||||
|
|
||||||
// metadata...
|
// metadata...
|
||||||
|
|||||||
@ -1085,11 +1085,11 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
config: {
|
config: {
|
||||||
'action-category-order': [
|
'action-category-order': [
|
||||||
'99:$File',
|
'99:$File',
|
||||||
// NOTE: we can order any sub-tree we want in the same
|
// We can order any sub-tree we want in the same manner
|
||||||
// manner as the root...
|
// as the root...
|
||||||
'File/-80:Clear viewer',
|
'File/-80:Clear viewer',
|
||||||
'File/-90:Close viewer',
|
'File/-90:Close viewer',
|
||||||
// NOTE: non existing elements will not get drawn...
|
// Non existing elements will not get drawn...
|
||||||
//'File/-99:moo',
|
//'File/-99:moo',
|
||||||
'80:$Edit',
|
'80:$Edit',
|
||||||
'70:$Navigate',
|
'70:$Navigate',
|
||||||
@ -1098,11 +1098,29 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
'40:$Crop',
|
'40:$Crop',
|
||||||
'Crop/80:Crop $marked images',
|
'Crop/80:Crop $marked images',
|
||||||
'Crop/80:Crop $bookmarked images',
|
'Crop/80:Crop $bookmarked images',
|
||||||
// NOTE: we can also add separators here...
|
|
||||||
//'Crop/70:---',
|
|
||||||
'Crop/60:$Crop',
|
'Crop/60:$Crop',
|
||||||
'Crop/50:$Flatten',
|
'Crop/60:$Flatten',
|
||||||
|
|
||||||
|
// Path patterns...
|
||||||
|
//
|
||||||
|
// Patters must contain ".*" and are case-insensitive...
|
||||||
|
//
|
||||||
|
// NOTE: patterns are used to override priorities of all
|
||||||
|
// the matching paths...
|
||||||
|
'Crop/60:crop .*ribbon.*',
|
||||||
|
'Crop/50:crop.*',
|
||||||
|
|
||||||
|
// We can also add separators here...
|
||||||
|
'Crop/11:---',
|
||||||
|
|
||||||
|
'Crop/10:.*collection.*',
|
||||||
|
|
||||||
|
'Crop/09:---',
|
||||||
|
|
||||||
|
// The rest of the elements in the path will get added
|
||||||
|
// between the positive and negative prioritized items...
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
'Crop/-80:Uncrop and keep crop image order',
|
'Crop/-80:Uncrop and keep crop image order',
|
||||||
'Crop/-81:Uncrop all',
|
'Crop/-81:Uncrop all',
|
||||||
'Crop/-82:$Uncrop',
|
'Crop/-82:$Uncrop',
|
||||||
@ -1215,9 +1233,12 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
browseActions: ['Interface/Dialog/Actions...',
|
browseActions: ['Interface/Dialog/Actions...',
|
||||||
makeUIDialog(function(path, options){
|
makeUIDialog(function(path, options){
|
||||||
var actions = this
|
var actions = this
|
||||||
var priority = /^(-?[0-9]+)\s*:\s*/
|
|
||||||
var marker = RegExp(this.config['browse-actions-shortcut-marker'], 'g')
|
var PRIORITY = /^(-?[0-9]+)\s*:\s*/
|
||||||
marker = marker || RegExp(marker, 'g')
|
|
||||||
|
var MARKER = RegExp(this.config['browse-actions-shortcut-marker'], 'g')
|
||||||
|
MARKER = MARKER || RegExp(MARKER, 'g')
|
||||||
|
|
||||||
var dialog
|
var dialog
|
||||||
options = options || {}
|
options = options || {}
|
||||||
|
|
||||||
@ -1232,7 +1253,7 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
pathPrefix: '/',
|
pathPrefix: '/',
|
||||||
fullPathEdit: true,
|
fullPathEdit: true,
|
||||||
|
|
||||||
item_shortcut_marker: marker,
|
item_shortcut_marker: MARKER,
|
||||||
}
|
}
|
||||||
cfg.__proto__ = this.config['browse-actions-settings']
|
cfg.__proto__ = this.config['browse-actions-settings']
|
||||||
|
|
||||||
@ -1246,23 +1267,37 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
// syntax like prioority...
|
// syntax like prioority...
|
||||||
// returns:
|
// returns:
|
||||||
// [<existing-text>, <new-level>]
|
// [<existing-text>, <new-level>]
|
||||||
|
//
|
||||||
|
// XXX this may mess up the ordering of items when using
|
||||||
|
// item patterns...
|
||||||
var getItem = function(level, text){
|
var getItem = function(level, text){
|
||||||
// direct match...
|
// direct match...
|
||||||
if(text in level){
|
if(text in level){
|
||||||
return [text, level[text]]
|
return [text, level[text]]
|
||||||
|
|
||||||
// check if it's a priority path...
|
// check if it's a priority path or a pattern...
|
||||||
} else {
|
} else {
|
||||||
var t = text.replace(priority, '')
|
var t = text.replace(PRIORITY, '')
|
||||||
t = (marker ? t.replace(marker, '$1') : t).trim()
|
t = (MARKER ? t.replace(MARKER, '$1') : t).trim()
|
||||||
|
|
||||||
for(var e in level){
|
for(var e in level){
|
||||||
var n = e.replace(priority, '')
|
var n = e.replace(PRIORITY, '')
|
||||||
n = (marker ? n.replace(marker, '$1') : n).trim()
|
n = (MARKER ? n.replace(MARKER, '$1') : n).trim()
|
||||||
|
|
||||||
if(n == t){
|
if(n == t){
|
||||||
return [e, level[e]]
|
return [e, level[e]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check pattern...
|
||||||
|
var p = /\.\*/.test(n) ? new RegExp('^'+ n +'$', 'i') : null
|
||||||
|
|
||||||
|
if(p && p.test(t)){
|
||||||
|
// override item priority from pattern...
|
||||||
|
var pr = PRIORITY.exec(e)
|
||||||
|
pr = pr ? pr.pop() + ':' : ''
|
||||||
|
|
||||||
|
return [pr + text.replace(PRIORITY, ''), level[e]]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return []
|
return []
|
||||||
@ -1310,6 +1345,7 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
path = path.slice()
|
path = path.slice()
|
||||||
// build leaf...
|
// build leaf...
|
||||||
if(path.length == 0){
|
if(path.length == 0){
|
||||||
|
// handle "|" in leavs...
|
||||||
leaf.split(/\|/g)
|
leaf.split(/\|/g)
|
||||||
.forEach(function(leaf){
|
.forEach(function(leaf){
|
||||||
var l = getItem(tree, leaf)[0]
|
var l = getItem(tree, leaf)[0]
|
||||||
@ -1351,7 +1387,17 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
|
|
||||||
// pre-order the main categories...
|
// pre-order the main categories...
|
||||||
// NOTE: pre_order can be a list of long paths...
|
// NOTE: pre_order can be a list of long paths...
|
||||||
var pre_order = this.config['action-category-order'] || []
|
var s = ''
|
||||||
|
var pre_order = (this.config['action-category-order'] || [])
|
||||||
|
.map(function(p, i){
|
||||||
|
// make all separators unique...
|
||||||
|
// ...this will prevent us from losing or merging them.
|
||||||
|
if(p.trimRight().endsWith('---')){
|
||||||
|
s += '-'
|
||||||
|
p = p.trimRight() + s
|
||||||
|
}
|
||||||
|
return p
|
||||||
|
})
|
||||||
pre_order.forEach(function(key){
|
pre_order.forEach(function(key){
|
||||||
var path = key.split(/[\\\/]/g)
|
var path = key.split(/[\\\/]/g)
|
||||||
var leaf = path.pop()
|
var leaf = path.pop()
|
||||||
@ -1459,24 +1505,28 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
// NN < 0 - is sorted below the non-prioritized
|
// NN < 0 - is sorted below the non-prioritized
|
||||||
// elements, the lower the number
|
// elements, the lower the number
|
||||||
// the lower the element
|
// the lower the element
|
||||||
|
// other - keep order
|
||||||
.sort(function(a, b){
|
.sort(function(a, b){
|
||||||
var ai = priority.exec(a)
|
var ai = PRIORITY.exec(a)
|
||||||
ai = ai ? ai.pop()*1 : null
|
ai = ai ? ai.pop()*1 : null
|
||||||
ai = ai > 0 ? -ai
|
ai = ai > 0 ? -ai
|
||||||
: ai < 0 ? -ai + level.length
|
: ai < 0 ? -ai + level.length
|
||||||
: level.indexOf(a)
|
: 0 //level.indexOf(a)
|
||||||
|
|
||||||
var bi = priority.exec(b)
|
var bi = PRIORITY.exec(b)
|
||||||
bi = bi ? bi.pop()*1 : null
|
bi = bi ? bi.pop()*1 : null
|
||||||
bi = bi > 0 ? -bi
|
bi = bi > 0 ? -bi
|
||||||
: bi < 0 ? -bi + level.length
|
: bi < 0 ? -bi + level.length
|
||||||
: level.indexOf(b)
|
: 0 //level.indexOf(b)
|
||||||
|
|
||||||
return ai - bi
|
var o = ai - bi
|
||||||
|
return o == 0 ?
|
||||||
|
level.indexOf(a) - level.indexOf(b)
|
||||||
|
: o
|
||||||
})
|
})
|
||||||
.forEach(function(key){
|
.forEach(function(key){
|
||||||
// remove the order...
|
// remove the order...
|
||||||
var text = key.replace(priority, '').trim()
|
var text = key.replace(PRIORITY, '').trim()
|
||||||
|
|
||||||
// Item: action...
|
// Item: action...
|
||||||
if(cur[key] instanceof Array){
|
if(cur[key] instanceof Array){
|
||||||
@ -1550,7 +1600,7 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
|| (cur[key] != null
|
|| (cur[key] != null
|
||||||
&& Object.keys(cur[key]).length > 0)){
|
&& Object.keys(cur[key]).length > 0)){
|
||||||
var p = '/'+ path.concat([text]).join('/') +'/'
|
var p = '/'+ path.concat([text]).join('/') +'/'
|
||||||
p = marker ? p.replace(marker, '$1') : p
|
p = MARKER ? p.replace(MARKER, '$1') : p
|
||||||
make(text + '/', { push_on_open: true })
|
make(text + '/', { push_on_open: true })
|
||||||
.attr({
|
.attr({
|
||||||
keys: [
|
keys: [
|
||||||
@ -1560,8 +1610,8 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// item: line...
|
// item: line...
|
||||||
} else if(text == '---'){
|
} else if(/---+/.test(text)){
|
||||||
make(text)
|
make('---')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user