-
Notifications
You must be signed in to change notification settings - Fork 51
/
undo.module.js
103 lines (85 loc) · 2.43 KB
/
undo.module.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
(function() {
if (!this.require) {
var modules = {}, cache = {};
var require = function(name, root) {
var path = expand(root, name), indexPath = expand(path, './index'), module, fn;
module = cache[path] || cache[indexPath];
if (module) {
return module;
} else if (fn = modules[path] || modules[path = indexPath]) {
module = {id: path, exports: {}};
cache[path] = module.exports;
fn(module.exports, function(name) {
return require(name, dirname(path));
}, module);
return cache[path] = module.exports;
} else {
throw 'module ' + name + ' not found';
}
};
var expand = function(root, name) {
var results = [], parts, part;
// If path is relative
if (/^\.\.?(\/|$)/.test(name)) {
parts = [root, name].join('/').split('/');
} else {
parts = name.split('/');
}
for (var i = 0, length = parts.length; i < length; i++) {
part = parts[i];
if (part == '..') {
results.pop();
} else if (part != '.' && part != '') {
results.push(part);
}
}
return results.join('/');
};
var dirname = function(path) {
return path.split('/').slice(0, -1).join('/');
};
this.require = function(name) {
return require(name, '');
};
this.require.define = function(bundle) {
for (var key in bundle) {
modules[key] = bundle[key];
}
};
this.require.modules = modules;
this.require.cache = cache;
}
return this.require;
}).call(this);
this.require.define({"app/models/undo":function(exports, require, module){(function() {
var Undo;
Undo = (function() {
function Undo() {}
Undo.undoStack = [];
Undo.redoStack = [];
Undo.add = function(undo, redo) {
this.undoStack.push([undo, redo]);
this.redoStack = [];
return redo();
};
Undo.undo = function() {
var action, redo, undo;
action = this.undoStack.pop();
if (!action) return;
undo = action[0], redo = action[1];
undo();
return this.redoStack.push(action);
};
Undo.redo = function() {
var action, redo, undo;
action = this.redoStack.pop();
if (!action) return;
undo = action[0], redo = action[1];
redo();
return this.undoStack.push(action);
};
return Undo;
})();
module.exports = Undo;
}).call(this);
;}});