equal
deleted
inserted
replaced
22 success: function(_data) { |
22 success: function(_data) { |
23 _proj.set(_data, {validate: true}); |
23 _proj.set(_data, {validate: true}); |
24 _renkan.renderer.autoScale(); |
24 _renkan.renderer.autoScale(); |
25 } |
25 } |
26 }); |
26 }); |
27 } |
27 }; |
28 var _save = function() { |
28 var _save = function() { |
29 _proj.set("saved_at", new Date()); |
29 _proj.set("saved_at", new Date()); |
30 var _data = _proj.toJSON(); |
30 var _data = _proj.toJSON(); |
31 Rkns.$.ajax({ |
31 Rkns.$.ajax({ |
32 type: _opts.http_method, |
32 type: _opts.http_method, |
38 _saveWarn = false; |
38 _saveWarn = false; |
39 document.location.hash = "#id=" + data.id; |
39 document.location.hash = "#id=" + data.id; |
40 $(".Rk-Notifications").text("Saved as "+document.location.href).fadeIn().delay(2000).fadeOut(); |
40 $(".Rk-Notifications").text("Saved as "+document.location.href).fadeIn().delay(2000).fadeOut(); |
41 } |
41 } |
42 }); |
42 }); |
43 } |
43 }; |
44 var _checkLeave = function() { |
44 var _checkLeave = function() { |
45 var title = _proj.get("title"); |
45 var title = _proj.get("title"); |
46 if (title && _proj.get("nodes").length) { |
46 if (title && _proj.get("nodes").length) { |
47 $(".Rk-Save-Button").removeClass("disabled"); |
47 $(".Rk-Save-Button").removeClass("disabled"); |
48 } else { |
48 } else { |
53 } |
53 } |
54 if (!_saveWarn) { |
54 if (!_saveWarn) { |
55 _saveWarn = true; |
55 _saveWarn = true; |
56 $(window).on("beforeunload", _onLeave); |
56 $(window).on("beforeunload", _onLeave); |
57 } |
57 } |
58 } |
58 }; |
59 _load(); |
59 _load(); |
60 _proj.on("add:nodes add:edges add:users change", function(_model) { |
60 _proj.on("add:nodes add:edges add:users change", function(_model) { |
61 _model.on("change remove", function(_model) { |
61 _model.on("change remove", function(_model) { |
62 _checkLeave(); |
62 _checkLeave(); |
63 }); |
63 }); |
70 } |
70 } |
71 } else { |
71 } else { |
72 _save(); |
72 _save(); |
73 } |
73 } |
74 }); |
74 }); |
75 } |
75 }; |