Renamed "Magic Condensation" to "Magic Fusion"

This commit is contained in:
Oliver Sartun 2013-10-29 22:47:34 +01:00
parent 82112bd479
commit b02b3e6278

View File

@ -62,9 +62,9 @@
* Returns a number that is unique per call stack. The number gets * Returns a number that is unique per call stack. The number gets
* changed after the call stack has been completely processed. * changed after the call stack has been completely processed.
* *
* @return {number} MagicCondensationIndex * @return {number} MagicFusionIndex
*/ */
var getMagicCondensationIndex = (function () { var getMagicFusionIndex = (function () {
// If you add several models to a collection or set several // If you add several models to a collection or set several
// attributes on a model all in sequence and yet all for // attributes on a model all in sequence and yet all for
// example in one function, then several Undo-Actions are // example in one function, then several Undo-Actions are
@ -80,9 +80,9 @@
// Instead we take advantage of the single-threadedness of // Instead we take advantage of the single-threadedness of
// JavaScript: // JavaScript:
var callstackWasIndexed = false, magicCondensationIndex = -1; var callstackWasIndexed = false, magicFusionIndex = -1;
function indexCycle() { function indexCycle() {
magicCondensationIndex++; magicFusionIndex++;
callstackWasIndexed = true; callstackWasIndexed = true;
_.defer(function () { _.defer(function () {
// Here comes the magic. With a Timeout of 0 // Here comes the magic. With a Timeout of 0
@ -95,7 +95,7 @@
if (!callstackWasIndexed) { if (!callstackWasIndexed) {
indexCycle(); indexCycle();
} }
return magicCondensationIndex; return magicFusionIndex;
} }
})(); })();
@ -239,7 +239,7 @@
* @param {String} which Either "undo" or "redo" * @param {String} which Either "undo" or "redo"
* @param {UndoManager} manager The UndoManager-instance on which an "undo"/"redo"-Event is triggered afterwards * @param {UndoManager} manager The UndoManager-instance on which an "undo"/"redo"-Event is triggered afterwards
* @param {UndoStack} stack The UndoStack on which we perform * @param {UndoStack} stack The UndoStack on which we perform
* @param {Boolean} magic If true, undoes / redoes all actions with the same magicCondensationIndex * @param {Boolean} magic If true, undoes / redoes all actions with the same magicFusionIndex
* @return {undefined} * @return {undefined}
*/ */
function managerUndoRedo (which, manager, stack, magic) { function managerUndoRedo (which, manager, stack, magic) {
@ -259,7 +259,7 @@
stack.pointer++; stack.pointer++;
action = stack.at(stack.pointer); action = stack.at(stack.pointer);
} }
actions = magic ? stack.where({"magicCondensationIndex": action.get("magicCondensationIndex")}) : [action]; actions = magic ? stack.where({"magicFusionIndex": action.get("magicFusionIndex")}) : [action];
stack.pointer += (isUndo ? -1 : 1) * (actions.length - 1); stack.pointer += (isUndo ? -1 : 1) * (actions.length - 1);
while (action = isUndo ? actions.pop() : actions.shift()) { while (action = isUndo ? actions.pop() : actions.shift()) {
// Here we're calling the Action's undo / redo method // Here we're calling the Action's undo / redo method
@ -303,7 +303,7 @@
var res = apply(undoTypes[type]["on"], undoTypes[type], args), diff; var res = apply(undoTypes[type]["on"], undoTypes[type], args), diff;
if (hasKeys(res, "object", "before", "after")) { if (hasKeys(res, "object", "before", "after")) {
res.type = type; res.type = type;
res.magicCondensationIndex = getMagicCondensationIndex(); res.magicFusionIndex = getMagicFusionIndex();
res.undoTypes = undoTypes; res.undoTypes = undoTypes;
if (stack.pointer < stack.length - 1) { if (stack.pointer < stack.length - 1) {
// New Actions must always be added to the end of the stack. // New Actions must always be added to the end of the stack.
@ -528,7 +528,7 @@
object: null, // The object on which the action occurred object: null, // The object on which the action occurred
before: null, // The previous values which were changed with this action before: null, // The previous values which were changed with this action
after: null, // The values after this action after: null, // The values after this action
magicCondensationIndex: null // The magicCondensationIndex helps to combine magicFusionIndex: null // The magicFusionIndex helps to combine
// all actions that occurred "at the same time" to undo/redo them altogether // all actions that occurred "at the same time" to undo/redo them altogether
}, },
/** /**