mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
reworking undo/redo and journaling mchanics...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
3c2106b8e8
commit
17ca051367
@ -2044,15 +2044,18 @@ var JournalActions = actions.Actions({
|
|||||||
that.on(action+'.pre', 'journal-handler', handler(action))
|
that.on(action+'.pre', 'journal-handler', handler(action))
|
||||||
return action }) }],
|
return action }) }],
|
||||||
|
|
||||||
|
// XXX do not clear .rjournal on redo...
|
||||||
journalPush: ['- System/Journal/Add an item to journal',
|
journalPush: ['- System/Journal/Add an item to journal',
|
||||||
function(data){
|
function(data){
|
||||||
// clear the reverse journal...
|
// clear the reverse journal...
|
||||||
|
// XXX we do not want to do this on redo...
|
||||||
this.rjournal
|
this.rjournal
|
||||||
&& (this.rjournal = null)
|
&& (this.rjournal = null)
|
||||||
|
|
||||||
this.journal = (this.hasOwnProperty('journal') || this.journal) ?
|
this.journal =
|
||||||
this.journal || []
|
(this.hasOwnProperty('journal') || this.journal) ?
|
||||||
: []
|
this.journal || []
|
||||||
|
: []
|
||||||
this.journal.push(data) }],
|
this.journal.push(data) }],
|
||||||
clearJournal: ['System/Journal/Clear the action journal',
|
clearJournal: ['System/Journal/Clear the action journal',
|
||||||
function(){
|
function(){
|
||||||
@ -2114,15 +2117,13 @@ var JournalActions = actions.Actions({
|
|||||||
{mode: function(){
|
{mode: function(){
|
||||||
return (this.journal && this.journal.length > 0) || 'disabled' }},
|
return (this.journal && this.journal.length > 0) || 'disabled' }},
|
||||||
function(count=1){
|
function(count=1){
|
||||||
var journal = this.journal.slice() || []
|
|
||||||
var rjournal =
|
|
||||||
this.rjournal =
|
|
||||||
(this.hasOwnProperty('rjournal') || this.rjournal) ?
|
|
||||||
this.rjournal || []
|
|
||||||
: []
|
|
||||||
count = count == 'all' ?
|
count = count == 'all' ?
|
||||||
Infinity
|
Infinity
|
||||||
: count
|
: count
|
||||||
|
// NOTE: these are isolated from any other contexts and will
|
||||||
|
// be saved as own attributes...
|
||||||
|
var journal = (this.journal || []).slice() || []
|
||||||
|
var rjournal = (this.rjournal || []).slice() || []
|
||||||
|
|
||||||
for(var i = journal.length-1; i >= 0; i--){
|
for(var i = journal.length-1; i >= 0; i--){
|
||||||
var a = journal[i]
|
var a = journal[i]
|
||||||
@ -2159,7 +2160,7 @@ var JournalActions = actions.Actions({
|
|||||||
: null }
|
: null }
|
||||||
|
|
||||||
// push the action to the reverse journal...
|
// push the action to the reverse journal...
|
||||||
rjournal.push(journal.splice(i, 1)[0])
|
rjournal.push(journal.pop())
|
||||||
|
|
||||||
// stop when done...
|
// stop when done...
|
||||||
if(undo
|
if(undo
|
||||||
@ -2189,13 +2190,24 @@ var JournalActions = actions.Actions({
|
|||||||
{mode: function(){
|
{mode: function(){
|
||||||
return (this.rjournal && this.rjournal.length > 0) || 'disabled' }},
|
return (this.rjournal && this.rjournal.length > 0) || 'disabled' }},
|
||||||
function(count=1){
|
function(count=1){
|
||||||
|
if(!this.rjournal || this.rjournal.length == 0){
|
||||||
|
return }
|
||||||
|
|
||||||
count = count == 'all' ?
|
count = count == 'all' ?
|
||||||
Infinity
|
Infinity
|
||||||
: count
|
: count
|
||||||
while(count-- > 0
|
var rjournal = this.rjournal
|
||||||
&& (this.rjournal || []).length > 0){
|
var l = rjournal.length
|
||||||
// XXX only run undoable actions... (???)
|
|
||||||
this.runJournal([this.rjournal.pop()]) }],
|
// XXX need to handle un-undoable actions...
|
||||||
|
// XXX need to count undoable actions instead of all actions (like in .undo(..))...
|
||||||
|
this.runJournal(rjournal.splice(l-count || 0, count))
|
||||||
|
|
||||||
|
// restore .rjournal after actions are run...
|
||||||
|
// NOTE: this is done to compensate for .journalPush(..) clearing
|
||||||
|
// the .rjournal in normal operation...
|
||||||
|
// XXX HACK???
|
||||||
|
this.rjournal = rjournal }],
|
||||||
|
|
||||||
//undoUnsaved: ['Edit/Undo unsaved',
|
//undoUnsaved: ['Edit/Undo unsaved',
|
||||||
// 'undo: "unsaved"'],
|
// 'undo: "unsaved"'],
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ImageGrid.Viewer.g4",
|
"name": "ImageGrid.Viewer.g4",
|
||||||
"main": "index.html",
|
"main": "index.html",
|
||||||
"version": "4.0.3a",
|
"version": "4.0.4a",
|
||||||
"author": "Alex A. Naanou <alex.nanou@gmail.com> (https://github.com/flynx)",
|
"author": "Alex A. Naanou <alex.nanou@gmail.com> (https://github.com/flynx)",
|
||||||
"contributors": [],
|
"contributors": [],
|
||||||
"repository": "github:flynx/ImageGrid",
|
"repository": "github:flynx/ImageGrid",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user