summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles')
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/move.js8
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/resize.js3
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/undo.js18
-rw-r--r--public/assets/javascripts/rectangles/models/wall.js3
-rw-r--r--public/assets/javascripts/rectangles/util/minotaur.js67
5 files changed, 67 insertions, 32 deletions
diff --git a/public/assets/javascripts/rectangles/engine/scenery/move.js b/public/assets/javascripts/rectangles/engine/scenery/move.js
index c3f78d7..edeb24b 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/move.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/move.js
@@ -30,6 +30,9 @@ Scenery.move = function(base){
redo: { id: base.id },
})
+ // TODO: watch individual scenery object here
+ Minotaur.watch( app.router.editorView.settings )
+
Scenery.remove(base.id)
return
}
@@ -81,7 +84,10 @@ Scenery.move = function(base){
undo: oldState,
redo: base.serialize(),
})
-
+
+ // TODO: watch individual scenery object here
+ Minotaur.watch( app.router.editorView.settings )
+
oldState = null
}
diff --git a/public/assets/javascripts/rectangles/engine/scenery/resize.js b/public/assets/javascripts/rectangles/engine/scenery/resize.js
index c5c754a..6b2e52c 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/resize.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/resize.js
@@ -200,6 +200,9 @@ Scenery.resize = new function(){
redo: obj.serialize(),
})
+ // TODO: watch individual scenery object here
+ Minotaur.watch( app.router.editorView.settings )
+
document.body.classList.remove("dragging")
}
diff --git a/public/assets/javascripts/rectangles/engine/scenery/undo.js b/public/assets/javascripts/rectangles/engine/scenery/undo.js
index 7798550..54ab755 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/undo.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/undo.js
@@ -4,9 +4,15 @@
type: "create-scenery",
undo: function(state){
Scenery.remove(state.id)
+
+ // TODO: watch individual scenery object here
+ Minotaur.watch( app.router.editorView.settings )
},
redo: function(state){
Scenery.deserialize([ state ])
+
+ // TODO: watch individual scenery object here
+ Minotaur.watch( app.router.editorView.settings )
},
},
{
@@ -19,6 +25,9 @@
if (editor.permissions.resize) {
Scenery.resize.show(scenery)
}
+
+ // TODO: watch individual scenery object here
+ Minotaur.watch( app.router.editorView.settings )
},
redo: function(state){
var scenery = Scenery.find(state.id)
@@ -30,15 +39,24 @@
Scenery.resize.rotate_dots()
Scenery.resize.move_dots()
}
+
+ // TODO: watch individual scenery object here
+ Minotaur.watch( app.router.editorView.settings )
},
},
{
type: "destroy-scenery",
undo: function(state){
Scenery.deserialize([ state ])
+
+ // TODO: watch individual scenery object here
+ Minotaur.watch( app.router.editorView.settings )
},
redo: function(state){
Scenery.remove(state.id)
+
+ // TODO: watch individual scenery object here
+ Minotaur.watch( app.router.editorView.settings )
},
},
diff --git a/public/assets/javascripts/rectangles/models/wall.js b/public/assets/javascripts/rectangles/models/wall.js
index 6e2c728..fa09444 100644
--- a/public/assets/javascripts/rectangles/models/wall.js
+++ b/public/assets/javascripts/rectangles/models/wall.js
@@ -50,6 +50,9 @@ window.Wall = (function(){
undo: { id: scenery.id },
redo: scenery.serialize(),
})
+
+ // TODO: watch individual scenery object here
+ Minotaur.watch( app.router.editorView.settings )
}
else if (Scenery.nextWallpaper) {
base.wallpaper()
diff --git a/public/assets/javascripts/rectangles/util/minotaur.js b/public/assets/javascripts/rectangles/util/minotaur.js
index 6eb36ec..039a053 100644
--- a/public/assets/javascripts/rectangles/util/minotaur.js
+++ b/public/assets/javascripts/rectangles/util/minotaur.js
@@ -1,54 +1,59 @@
(function(){
var Monitor = function () {
- var base = this;
- base.$el = $("#minotaur");
- base.timeout = null;
- base.delay = 500;
- base.objects = {};
+ var base = this
+ base.$el = $("#minotaur")
+ base.timeout = null
+ base.delay = 500
+ base.objects = {}
base.init = function () {
- base.$el.addClass('saved');
- base.$el.click(base.save);
+ base.$el.removeClass()
+ base.$el.click(base.save)
}
base.watch = function (object) {
- base.objects[object.type] = base.objects[object.type] || {};
- base.objects[object.type][object.id] = object;
- base.clear();
- base.timeout = setTimeout(base.save, base.delay);
+ base.objects[object.type] = base.objects[object.type] || {}
+ base.objects[object.type][object._id] = object
+ base.clear()
+ base.timeout = setTimeout(base.save, base.delay)
+ }
+
+ base.unwatch = function (object) {
+ if (base.objects[object.type] && base.objects[object.type][object._id]) {
+ delete base.objects[object.type][object._id]
+ }
}
base.clear = function () {
- if (base.timeout) clearTimeout(base.timeout);
- base.timeout = false;
+ if (base.timeout) clearTimeout(base.timeout)
+ base.timeout = false
}
base.save = function () {
- var saving = false;
- base.clear();
+ var saving = false
+ base.clear()
for (var type in base.objects) {
for (var id in base.objects[type]) {
- if (base.timeout)
- return;
- var obj = base.objects[type][id];
- if (obj) obj.save(function(){
- base.$el.removeClass('unsaved saving').addClass('saved');
- saving = true;
- });
- base.objects[type][id] = false;
+ var obj = base.objects[type][id]
+ if (obj) {
+ obj.save(null, function(){ base.hide() }, function(){})
+ }
+ delete base.objects[type][id]
+ saving = true
}
}
- if (saving) {
- base.$el.removeClass('unsaved saved').addClass('saving');
- }
- else {
- base.$el.removeClass('unsaved saving').addClass('saved');
- }
-
- base.objects = {};
+ saving ? base.show() : base.hide()
+ }
+
+ base.show = function () {
+ base.$el.removeClass().addClass('saving')
+ }
+
+ base.hide = function () {
+ base.$el.removeClass()
}
base.init();