-
Notifications
You must be signed in to change notification settings - Fork 0
/
UndoManager.js
34 lines (32 loc) · 1.01 KB
/
UndoManager.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
(function (Backbone, root) {
var changingItem, prevAttrs, uistate;
Backbone.UndoManager.changeUndoType("change", {
"on": function (model, options) {
if (model.get && model.get("content") && model.get("content").getModel) {
// This seems to be an Item
uistate = model.get("content").getModel().get("uistate");
if (uistate === "resize" && !changingItem) {
changingItem = model;
prevAttrs = model.previousAttributes();
} else if (uistate !== "resize" && changingItem === model) {
changingItem = false;
return {
object: model,
before: prevAttrs,
after: _.pick(model.attributes, _.keys(prevAttrs))
}
}
} else {
var
changedAttributes = model.changedAttributes(),
previousAttributes = _.pick(model.previousAttributes(), _.keys(changedAttributes));
return {
object: model,
before: previousAttributes,
after: changedAttributes
}
}
}
})
root.supply({"UndoManager": new Backbone.UndoManager});
})(window.Backbone, window.ds);