9 Rkns.$.getJSON(_opts.url, function(_data) { |
9 Rkns.$.getJSON(_opts.url, function(_data) { |
10 _proj.set(_data); |
10 _proj.set(_data); |
11 _renkan.renderer.autoScale(); |
11 _renkan.renderer.autoScale(); |
12 }); |
12 }); |
13 } |
13 } |
14 var _save = function() { |
14 if (!_renkan.read_only) { |
15 var _data = _proj.toJSON(); |
15 var _save = function() { |
16 Rkns.$.ajax({ |
16 var _data = _proj.toJSON(); |
17 type: _opts.http_method, |
17 Rkns.$.ajax({ |
18 url: _opts.url, |
18 type: _opts.http_method, |
19 contentType: "application/json", |
19 url: _opts.url, |
20 data: JSON.stringify(_data), |
20 contentType: "application/json", |
21 success: function(data, textStatus, jqXHR) { |
21 data: JSON.stringify(_data), |
22 } |
22 success: function(data, textStatus, jqXHR) { |
23 }); |
23 } |
24 |
24 }); |
25 } |
25 |
26 var _thrSave = Rkns._.throttle( |
26 } |
27 function() { |
27 var _thrSave = Rkns._.throttle( |
28 setTimeout(_save, 100) |
28 function() { |
29 }, 1000); |
29 setTimeout(_save, 100) |
30 _load(); |
30 }, 1000); |
31 _proj.on("add:nodes add:edges add:users", function(_model) { |
31 _proj.on("add:nodes add:edges add:users", function(_model) { |
32 _model.on("change remove", function(_model) { |
32 _model.on("change remove", function(_model) { |
|
33 _thrSave(); |
|
34 }); |
33 _thrSave(); |
35 _thrSave(); |
34 }); |
36 }); |
35 _thrSave(); |
37 _proj.on("change", function() { |
36 }); |
38 _thrSave(); |
|
39 }); |
|
40 } |
|
41 _load(); |
37 } |
42 } |