mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
added better tag sorting and some tweaks...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6cd18e0eff
commit
98bff54606
@ -249,9 +249,9 @@ module.GLOBAL_KEYBOARD = {
|
|||||||
|
|
||||||
// tilt...
|
// tilt...
|
||||||
// XXX experimental, not sure if wee need this with a keyboard...
|
// XXX experimental, not sure if wee need this with a keyboard...
|
||||||
T: 'rotateRibbonCCW -- Tilt ribbons counter clock wise',
|
ctrl_T: 'rotateRibbonCCW -- Tilt ribbons counter clock wise',
|
||||||
shift_T: 'rotateRibbonCW -- Tilt ribbons clock wise',
|
ctrl_shift_T: 'rotateRibbonCW -- Tilt ribbons clock wise',
|
||||||
ctrl_shift_T: 'resetRibbonRotation -- Reset ribbon tilt',
|
ctrl_alt_T: 'resetRibbonRotation -- Reset ribbon tilt',
|
||||||
|
|
||||||
|
|
||||||
// NOTE: this is handled by the wrapper at this point, so we do
|
// NOTE: this is handled by the wrapper at this point, so we do
|
||||||
@ -409,7 +409,7 @@ module.GLOBAL_KEYBOARD = {
|
|||||||
//ctrl_shift_I: 'showMetadata: "current" "full" -- Show full metadata',
|
//ctrl_shift_I: 'showMetadata: "current" "full" -- Show full metadata',
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
ctrl_T: 'showTagCloud',
|
T: 'showTagCloud',
|
||||||
|
|
||||||
|
|
||||||
// marking...
|
// marking...
|
||||||
|
|||||||
@ -186,6 +186,7 @@ var TagUIActions = actions.Actions({
|
|||||||
.showTagCloud(func, gid, ... [, options])
|
.showTagCloud(func, gid, ... [, options])
|
||||||
.showTagCloud(func, [gid, ...] [, options])
|
.showTagCloud(func, [gid, ...] [, options])
|
||||||
-> dialog
|
-> dialog
|
||||||
|
NOTE: for an example see: .cropTaggedFromCloud(..)
|
||||||
|
|
||||||
|
|
||||||
The constructor func is called in the action context and has the
|
The constructor func is called in the action context and has the
|
||||||
@ -195,11 +196,28 @@ var TagUIActions = actions.Actions({
|
|||||||
This uses the same option format as browse.makeLister(..) with
|
This uses the same option format as browse.makeLister(..) with
|
||||||
the following additions:
|
the following additions:
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// this can be:
|
||||||
|
// 'count' (default)
|
||||||
|
// 'name'
|
||||||
|
sortTagsBy: 'count',
|
||||||
|
|
||||||
// callback to be called when a tag state is flipped...
|
// callback to be called when a tag state is flipped...
|
||||||
|
//
|
||||||
|
// NOTE: this if set will disable auto dialog update on
|
||||||
|
// item change, this should be done by itemOpen(..).
|
||||||
itemOpen: <function(tag, state)>,
|
itemOpen: <function(tag, state)>,
|
||||||
|
|
||||||
|
// disable dialog update on item open...
|
||||||
|
//
|
||||||
|
// NOTE: this is ignored if itemOpen is set.
|
||||||
|
lazyDialogUpdate: false,
|
||||||
|
|
||||||
|
//
|
||||||
|
hideTagCount: false,
|
||||||
|
|
||||||
// if false do not show the 'New...' button...
|
// if false do not show the 'New...' button...
|
||||||
noNewButton: <bool>,
|
noNewButton: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -245,12 +263,41 @@ var TagUIActions = actions.Actions({
|
|||||||
// XXX add key binding to delete a tag...
|
// XXX add key binding to delete a tag...
|
||||||
that.tags
|
that.tags
|
||||||
.sort()
|
.sort()
|
||||||
|
// prep for sort...
|
||||||
|
.map(function(t, i){ return [t, i, (that.data.tags[t] || {}).len] })
|
||||||
|
// XXX add ability to sort by popularity, both local
|
||||||
|
// (selected tags) and global...
|
||||||
|
.run(function(){
|
||||||
|
return opts.sortTagsBy == 'name' ?
|
||||||
|
this
|
||||||
|
// count...
|
||||||
|
: this.sort(function(a, b){
|
||||||
|
var ac = a[2]
|
||||||
|
var bc = b[2]
|
||||||
|
|
||||||
|
return ac != null && bc != null ?
|
||||||
|
bc - ac
|
||||||
|
// keep used tags before unused...
|
||||||
|
: ac == null ?
|
||||||
|
1
|
||||||
|
: bc == null ?
|
||||||
|
-1
|
||||||
|
// sort by position...
|
||||||
|
: a[0] - b[0]
|
||||||
|
}) })
|
||||||
.map(function(tag){
|
.map(function(tag){
|
||||||
|
// normalize...
|
||||||
|
var count = tag[2]
|
||||||
|
tag = tag[0]
|
||||||
|
|
||||||
return make(tag, {
|
return make(tag, {
|
||||||
cls: tags.indexOf(tag) >= 0 ? 'tagged' : '',
|
cls: tags.indexOf(tag) >= 0 ? 'tagged' : '',
|
||||||
style: {
|
style: {
|
||||||
opacity: tags.indexOf(tag) >= 0 ? '' : '0.3'
|
opacity: tags.indexOf(tag) >= 0 ? '' : '0.3'
|
||||||
},
|
},
|
||||||
|
attrs: {
|
||||||
|
count: opts.hideTagCount || count,
|
||||||
|
},
|
||||||
open: function(){
|
open: function(){
|
||||||
var e = $(this)
|
var e = $(this)
|
||||||
var on = e.css('opacity')
|
var on = e.css('opacity')
|
||||||
@ -268,6 +315,10 @@ var TagUIActions = actions.Actions({
|
|||||||
:(on ?
|
:(on ?
|
||||||
that.untag(tag, gids)
|
that.untag(tag, gids)
|
||||||
: that.tag(tag, gids))
|
: that.tag(tag, gids))
|
||||||
|
|
||||||
|
opts.itemOpen
|
||||||
|
|| opts.lazyDialogUpdate
|
||||||
|
|| make.dialog.update()
|
||||||
},
|
},
|
||||||
buttons: [
|
buttons: [
|
||||||
// remove tag button...
|
// remove tag button...
|
||||||
@ -308,30 +359,34 @@ var TagUIActions = actions.Actions({
|
|||||||
close: function(){ that.refresh() },
|
close: function(){ that.refresh() },
|
||||||
}, opts))
|
}, opts))
|
||||||
})],
|
})],
|
||||||
showMarkedTagCoud: ['Tag|Mark/$Tags of marked images...',
|
showMarkedTagCoud: ['Tag|Mark/$Tags of $marked images...',
|
||||||
'showTagCloud: "marked"'],
|
'showTagCloud: "marked"'],
|
||||||
// XXX should this show all the tags or just the used???
|
// XXX should this show all the tags or just the used???
|
||||||
cropTaggedFromCloud: ['Tag|Crop/Crop tagged...',
|
// XXX should we add image count to tags???
|
||||||
|
cropTaggedFromCloud: ['Tag|Crop/$Crop $ta$gged...',
|
||||||
widgets.uiDialog(function(){
|
widgets.uiDialog(function(){
|
||||||
var that = this
|
var that = this
|
||||||
var tags = new Set()
|
var tags = new Set()
|
||||||
|
|
||||||
return this.showTagCloud(function(path, make, gids, opts){
|
return this.showTagCloud(
|
||||||
make.Separator()
|
function(path, make, gids, opts){
|
||||||
make.Action('$Crop', {
|
make.Separator()
|
||||||
open: function(){
|
make.Action('$Crop', {
|
||||||
that.cropTagged([...tags])
|
open: function(){
|
||||||
|
that.cropTagged([...tags])
|
||||||
|
|
||||||
make.dialog.close()
|
make.dialog.close()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, [], {
|
},
|
||||||
itemOpen: function(tag, state){
|
[],
|
||||||
state ?
|
{
|
||||||
tags.add(tag)
|
itemOpen: function(tag, state){
|
||||||
: tags.delete(tag) },
|
state ?
|
||||||
'noNewButton': true,
|
tags.add(tag)
|
||||||
}) })],
|
: tags.delete(tag) },
|
||||||
|
'noNewButton': true,
|
||||||
|
}) })],
|
||||||
|
|
||||||
|
|
||||||
// Tag tree...
|
// Tag tree...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user