pull/85/head
nightwing 2015-05-03 14:55:08 +04:00
rodzic d2c6ec3c62
commit 68a6a14d90
2 zmienionych plików z 8 dodań i 9 usunięć

Wyświetl plik

@ -10,7 +10,7 @@ define(function(require, module, exports) {
var plugin = new Plugin("Ajax.org", main.consumes); var plugin = new Plugin("Ajax.org", main.consumes);
var emit = plugin.getEmitter(); var emit = plugin.getEmitter();
var position = -1, mark = null, stack = []; var position = -1, mark = -2, stack = [];
if (options) if (options)
setState(options); setState(options);
@ -55,7 +55,7 @@ define(function(require, module, exports) {
position = 0; position = 0;
if (mark < position) if (mark < position)
mark = -1; mark = -2;
emit("change"); emit("change");
} }
@ -64,7 +64,7 @@ define(function(require, module, exports) {
stack = stack.slice(0, position + 1); stack = stack.slice(0, position + 1);
if (mark > position) if (mark > position)
mark = -1; mark = -2;
if (!noEvent) if (!noEvent)
emit("change"); emit("change");
@ -91,7 +91,7 @@ define(function(require, module, exports) {
position--; position--;
if (mark == idx) if (mark == idx)
mark = -1; mark = -2;
else if (mark > idx) else if (mark > idx)
mark--; mark--;
@ -105,8 +105,7 @@ define(function(require, module, exports) {
} }
function isAtBookmark(){ function isAtBookmark(){
return mark !== null && mark == position return mark == position;
|| mark === null && position == -1;
} }
function item(idx) { function item(idx) {
@ -133,7 +132,7 @@ define(function(require, module, exports) {
return; // guard against broken stack return; // guard against broken stack
stack = state.stack; stack = state.stack;
emit("change"); //If you remove this again, change the test emit("change"); // If you remove this again, change the test
} }
function findItem(compressedItem) { function findItem(compressedItem) {
@ -146,7 +145,7 @@ define(function(require, module, exports) {
position = -1; position = -1;
stack = []; stack = [];
mark = null; mark = -1;
emit("change"); emit("change");
} }

Wyświetl plik

@ -133,7 +133,7 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
expect(undo.position).to.equal(4); expect(undo.position).to.equal(4);
undo.undo(); check++; undo.undo(); check++;
undo.setState({ position : -1, stack : stack, mark : null }); check++; undo.setState({ position : -1, stack : stack, mark : -1 }); check++;
expect(undo.isAtBookmark()).to.equal(true); expect(undo.isAtBookmark()).to.equal(true);
expect(data).to.deep.equal(["a", "q"]); expect(data).to.deep.equal(["a", "q"]);
checkCount(); checkCount();