unified marks and bookmarks, now almost complete. image update still not done...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-11-20 21:45:06 +03:00
parent 82cd756fd9
commit 7b7070c8b1
2 changed files with 56 additions and 43 deletions

View File

@ -95,7 +95,6 @@ module.GLOBAL_KEYBOARD = {
// XXX testing... // XXX testing...
Enter: 'toggleSingleImage', Enter: 'toggleSingleImage',
B: 'toggleTheme',
Home: { Home: {
default: 'firstImage', default: 'firstImage',
@ -169,6 +168,9 @@ module.GLOBAL_KEYBOARD = {
}, },
// marking... // marking...
M: {
default: 'toggleMark',
},
A: { A: {
ctrl: 'toggleMark!: "ribbon" "on"', ctrl: 'toggleMark!: "ribbon" "on"',
}, },
@ -179,6 +181,10 @@ module.GLOBAL_KEYBOARD = {
ctrl: 'toggleMark!: "ribbon"', ctrl: 'toggleMark!: "ribbon"',
}, },
B: {
default: 'toggleBookmark',
ctrl: 'toggleTheme',
},
}, },
} }

View File

@ -1767,44 +1767,51 @@ module.GlobalStateIndicator = Feature({
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// target can be:
// 'all'
// 'loaded'
// 'ribbon' - current ribbon
// ribbon - specific ribbon (gid)
// Array
//
// XXX make this a real toggler... ???
function makeTagTogglerAction(tag){
return function(target, action){
if(target == '?' || target == 'on' || target == 'off'){
var x = action
action = target
target = x
}
target = target || 'current'
target = target == 'all'
|| target == 'loaded'
|| target in this.data.ribbons
? this.data.getImages(target)
: target == 'ribbon' ? this.data.getImages('current')
: target
target = target.constructor !== Array ? [target] : target
var res = this.data.toggleTag(tag, target, action)
if(action != '?' && this.ribbons != null){
var that = this
target.forEach(function(t){
that.ribbons.toggleImageMark(t, tag, action)
})
}
return res
}
}
// XXX add image updater... // XXX add image updater...
var ImageMarkActions = actions.Actions({ var ImageMarkActions = actions.Actions({
// target can be: toggleMark: ['Toggle image mark',
// 'all' makeTagTogglerAction('selected')],
// 'loaded' toggleMarkBlock: ['Toggle block marks',
// 'ribbon' - current ribbon 'A block is a set of adjacent images either marked on unmarked '
// ribbon - specific ribbon (gid) +'in the same way',
// Array
//
// XXX make this a real toggler... ???
toggleMark: ['',
function(target, action){
if(target == '?' || target == 'on' || target == 'off'){
var x = action
action = target
target = x
}
target = target || 'current'
target = target == 'all'
|| target == 'loaded'
|| target in this.data.ribbons
? this.data.getImages(target)
: target == 'ribbon' ? this.data.getImages('current')
: target
target = target.constructor !== Array ? [target] : target
var res = this.data.toggleTag('selected', target, action)
if(action != '?' && this.ribbons != null){
var that = this
target.forEach(function(t){
that.ribbons.toggleImageMark(t, 'selected', action)
})
}
return res
}],
toggleMarkBlock: ['',
function(target){ function(target){
var cur = this.toggleMark(target, '?') var cur = this.toggleMark(target, '?')
@ -1812,7 +1819,7 @@ var ImageMarkActions = actions.Actions({
// XXX // XXX
}], }],
markTagged: ['', markTagged: ['Mark images by tags',
function(tags, mode){ function(tags, mode){
var selector = mode == 'any' ? 'getTaggedByAny' : 'getTaggedByAll' var selector = mode == 'any' ? 'getTaggedByAny' : 'getTaggedByAll'
@ -1823,12 +1830,12 @@ var ImageMarkActions = actions.Actions({
}], }],
// XXX do we need first/last marked??? // XXX do we need first/last marked???
prevMarked: ['', prevMarked: ['Focus previous marked image',
function(mode){ this.prevTagged('selected', mode) }], function(mode){ this.prevTagged('selected', mode) }],
nextMarked: ['', nextMarked: ['Focus next marked image',
function(mode){ this.nextTagged('selected', mode) }], function(mode){ this.nextTagged('selected', mode) }],
cropMarked: ['', cropMarked: ['Crop marked images',
function(flatten){ this.cropTagged('selected', 'any', flatten) }], function(flatten){ this.cropTagged('selected', 'any', flatten) }],
}) })
@ -1848,14 +1855,14 @@ module.ImageMarks = Feature({
//--------------------------------------------------------------------- //---------------------------------------------------------------------
var ImageBookmarkActions = actions.Actions({ var ImageBookmarkActions = actions.Actions({
toggleBookmark: ['', toggleBookmark: ['',
function(){ makeTagTogglerAction('bookmark')],
}],
// action can be: // action can be:
// 'on' - toggle all on // 'on' - toggle all on
// 'off' - toggle all off // 'off' - toggle all off
// 'next' - toggle each image to next state // 'next' - toggle each image to next state
toggleBookmarkOnMarked: ['', toggleBookmarkOnMarked: ['',
function(action){ function(action){
return this.toggleBookmark(this.data.getTaggedByAny('selected'), action)
}], }],
prevBookmarked: ['', prevBookmarked: ['',