mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
added undo to marks/bookmarks...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
d524366e3e
commit
804fe63040
@ -631,8 +631,7 @@ var JournalActions = actions.Actions({
|
||||
var cur = this.current
|
||||
var args = args2array(arguments)
|
||||
|
||||
return function(){
|
||||
this.journalPush({
|
||||
var data = {
|
||||
type: 'basic',
|
||||
|
||||
action: action,
|
||||
@ -641,8 +640,16 @@ var JournalActions = actions.Actions({
|
||||
current: cur,
|
||||
// the target (current) image after action...
|
||||
target: this.current,
|
||||
})
|
||||
}
|
||||
|
||||
// test if we need to journal this action signature...
|
||||
var test = that.getActionAttr(action, 'undoable')
|
||||
if(test && !test.call(that, data)){
|
||||
return
|
||||
}
|
||||
|
||||
// journal after the action is done...
|
||||
return function(){ this.journalPush(data) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -278,10 +278,12 @@ module.GLOBAL_KEYBOARD = {
|
||||
shift_Up: 'shiftImageUp',
|
||||
alt_shift_Up: 'travelImageUp',
|
||||
ctrl_shift_Up: 'shiftImageUpNewRibbon',
|
||||
ctrl_Up: 'shiftMarkedUp',
|
||||
|
||||
shift_Down: 'shiftImageDown',
|
||||
alt_shift_Down: 'travelImageDown',
|
||||
ctrl_shift_Down: 'shiftImageDownNewRibbon',
|
||||
ctrl_Down: 'shiftMarkedDown',
|
||||
|
||||
alt_Left: 'shiftImageLeft!',
|
||||
alt_Right: 'shiftImageRight!',
|
||||
@ -351,6 +353,7 @@ module.GLOBAL_KEYBOARD = {
|
||||
// marking...
|
||||
M: 'toggleMark',
|
||||
ctrl_A: 'toggleMark!: "ribbon" "on" -- Mark all images in ribbon',
|
||||
ctrl_shift_A: 'toggleMarkBlock!',
|
||||
ctrl_D: 'toggleMark!: "ribbon" "off" -- Unmark all images in ribbon',
|
||||
ctrl_I: 'toggleMark!: "ribbon" -- Invert marks in ribbon',
|
||||
',': 'prevMarked',
|
||||
|
||||
@ -104,6 +104,24 @@ function makeTagTogglerAction(tag){
|
||||
}
|
||||
|
||||
|
||||
var undoTag = function(action){
|
||||
return {
|
||||
// do not journal calls that have no side-effects, e.g. toggler
|
||||
// introspection...
|
||||
// XXX should this be a generic predicate???
|
||||
undoable: function(a){
|
||||
return a.args.indexOf('?') < 0
|
||||
&& a.args.indexOf('??') < 0 },
|
||||
undo: function(a){
|
||||
this[action].apply(this,
|
||||
// XXX is argument handling here too optimistic???
|
||||
a.args.map(function(e){
|
||||
return e == 'on' ? 'off'
|
||||
: e == 'off' ? 'on'
|
||||
: e })) },
|
||||
} }
|
||||
|
||||
|
||||
//
|
||||
// Direction can be:
|
||||
// - 'up'
|
||||
@ -190,7 +208,9 @@ var ImageMarkActions = actions.Actions({
|
||||
// Invert marks on current ribbon
|
||||
// .toggleMark('ribbon')
|
||||
//
|
||||
//
|
||||
toggleMark: ['Mark|Image/Image $mark',
|
||||
undoTag('toggleMark'),
|
||||
makeTagTogglerAction('selected')],
|
||||
toggleMarkBlock: ['Mark/Mark $block',
|
||||
core.doc`A block is a set of adjacent images either marked on unmarked
|
||||
@ -329,6 +349,7 @@ var ImageBookmarkActions = actions.Actions({
|
||||
},
|
||||
|
||||
toggleBookmark: ['Bookmark|Image/Image $bookmark',
|
||||
undoTag('toggleBookmark'),
|
||||
makeTagTogglerAction('bookmark')],
|
||||
// action can be:
|
||||
// 'on' - toggle all on
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user