--- a/client/js/renderer/scene.js Sun Jan 04 22:41:27 2015 +0100
+++ b/client/js/renderer/scene.js Sun Jan 04 22:42:49 2015 +0100
@@ -309,9 +309,30 @@
_thRedrawUsers();
// register model events
+ this.renkan.project.on("change:save_status", function(){
+ switch (_this.renkan.project.get("save_status")) {
+ case 0: //clean
+ _this.$.find(".Rk-Save-Button").removeClass("to-save");
+ _this.$.find(".Rk-Save-Button").removeClass("saving");
+ _this.$.find(".Rk-Save-Button").addClass("saved");
+ break;
+ case 1: //dirty
+ _this.$.find(".Rk-Save-Button").removeClass("saved");
+ _this.$.find(".Rk-Save-Button").removeClass("saving");
+ _this.$.find(".Rk-Save-Button").addClass("to-save");
+ break;
+ case 2: //saving
+ _this.$.find(".Rk-Save-Button").removeClass("saved");
+ _this.$.find(".Rk-Save-Button").removeClass("to-save");
+ _this.$.find(".Rk-Save-Button").addClass("saving");
+ break;
+ }
+ });
+
this.renkan.project.on("add:users remove:users", _thRedrawUsers);
this.renkan.project.on("add:views remove:views", function(_node) {
+ _this.renkan.project.set({dirty:true});
if(_this.renkan.project.get('views').length > 0) {
_this.$.find(".Rk-ZoomSetSaved").show();
}
@@ -321,14 +342,17 @@
});
this.renkan.project.on("add:nodes", function(_node) {
+ _this.renkan.project.set({dirty:true});
_this.addRepresentation("Node", _node);
_thRedraw();
});
this.renkan.project.on("add:edges", function(_edge) {
+ _this.renkan.project.set({dirty:true});
_this.addRepresentation("Edge", _edge);
_thRedraw();
});
this.renkan.project.on("change:title", function(_model, _title) {
+ _this.renkan.project.set({dirty:true});
var el = _this.$.find(".Rk-PadTitle");
if (el.is("input")) {
if (el.val() !== _title) {
--- a/client/js/save-once.js Sun Jan 04 22:41:27 2015 +0100
+++ b/client/js/save-once.js Sun Jan 04 22:42:49 2015 +0100
@@ -21,6 +21,7 @@
data: getdata,
success: function(_data) {
_proj.set(_data, {validate: true});
+ _proj.set({save_status:0});
_renkan.renderer.autoScale();
}
});
@@ -33,15 +34,21 @@
url: _opts.url,
contentType: "application/json",
data: JSON.stringify(_data),
+ beforeSend: function(){
+ _proj.set({save_status:2});
+ },
success: function(data, textStatus, jqXHR) {
$(window).off("beforeunload", _onLeave);
_saveWarn = false;
+ _proj.set({save_status:0});
//document.location.hash = "#id=" + data.id;
//$(".Rk-Notifications").text("Saved as "+document.location.href).fadeIn().delay(2000).fadeOut();
}
});
};
var _checkLeave = function() {
+ _proj.set({save_status:1});
+
var title = _proj.get("title");
if (title && _proj.get("nodes").length) {
$(".Rk-Save-Button").removeClass("disabled");
@@ -58,10 +65,14 @@
};
_load();
_proj.on("add:nodes add:edges add:users change", function(_model) {
- _model.on("change remove", function(_model) {
- _checkLeave();
- });
- _checkLeave();
+ _model.on("change remove", function(_model) {
+ if(!(_model.changedAttributes.length == 1 && _model.hasChanged('save_status'))) {
+ _checkLeave();
+ }
+ });
+ if(!(_proj.changedAttributes.length == 1 && _proj.hasChanged('save_status'))) {
+ _checkLeave();
+ }
});
_renkan.renderer.save = function() {
if ($(".Rk-Save-Button").hasClass("disabled")) {