29 uri: _model.get("uri"), |
29 uri: _model.get("uri"), |
30 short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
30 short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
31 description: _model.get("description"), |
31 description: _model.get("description"), |
32 color: (_model.has("style") && _model.get("style").color) || _created_by.get("color"), |
32 color: (_model.has("style") && _model.get("style").color) || _created_by.get("color"), |
33 dash: _model.has("style") && _model.get("style").dash ? "checked" : "", |
33 dash: _model.has("style") && _model.get("style").dash ? "checked" : "", |
|
34 arrow: (_model.has("style") && _model.get("style").arrow) || !_model.has("style") || (typeof _model.get("style").arrow === 'undefined') ? "checked" : "", |
|
35 thickness: (_model.has("style") && _model.get("style").thickness) || 1, |
34 from_title: _from_model.get("title"), |
36 from_title: _from_model.get("title"), |
35 to_title: _to_model.get("title"), |
37 to_title: _to_model.get("title"), |
36 from_color: (_from_model.has("style") && _from_model.get("style").color) || (_from_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"), |
38 from_color: (_from_model.has("style") && _from_model.get("style").color) || (_from_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"), |
37 to_color: (_to_model.has("style") && _to_model.get("style").color) || (_to_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"), |
39 to_color: (_to_model.has("style") && _to_model.get("style").color) || (_to_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"), |
38 created_by_color: _created_by.get("color"), |
40 created_by_color: _created_by.get("color"), |
44 })); |
46 })); |
45 this.redraw(); |
47 this.redraw(); |
46 var _this = this, |
48 var _this = this, |
47 closeEditor = function() { |
49 closeEditor = function() { |
48 _this.renderer.removeRepresentation(_this); |
50 _this.renderer.removeRepresentation(_this); |
|
51 _this.editor_$.find(".Rk-Edit-Size-Btn").off('click'); |
49 paper.view.draw(); |
52 paper.view.draw(); |
50 }; |
53 }; |
51 this.editor_$.find(".Rk-CloseX").click(closeEditor); |
54 this.editor_$.find(".Rk-CloseX").click(closeEditor); |
52 this.editor_$.find(".Rk-Edit-Goto").click(function() { |
55 this.editor_$.find(".Rk-Edit-Goto").click(function() { |
53 if (!_model.get("uri")) { |
56 if (!_model.get("uri")) { |
67 _data.uri = _this.editor_$.find(".Rk-Edit-URI").val(); |
70 _data.uri = _this.editor_$.find(".Rk-Edit-URI").val(); |
68 } |
71 } |
69 if (_this.options.show_node_editor_style) { |
72 if (_this.options.show_node_editor_style) { |
70 var dash = _this.editor_$.find(".Rk-Edit-Dash").is(':checked'); |
73 var dash = _this.editor_$.find(".Rk-Edit-Dash").is(':checked'); |
71 _data.style = _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {dash: dash}); |
74 _data.style = _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {dash: dash}); |
|
75 var arrow = _this.editor_$.find(".Rk-Edit-Arrow").is(':checked'); |
|
76 _data.style = _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {arrow: arrow}); |
72 } |
77 } |
73 _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#"); |
78 _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#"); |
74 _model.set(_data); |
79 _model.set(_data); |
75 paper.view.draw(); |
80 paper.view.draw(); |
76 } else { |
81 } else { |
138 paper.view.draw(); |
143 paper.view.draw(); |
139 } else { |
144 } else { |
140 closeEditor(); |
145 closeEditor(); |
141 } |
146 } |
142 }); |
147 }); |
|
148 var shiftThickness = function(n) { |
|
149 if (_this.renderer.isEditable()) { |
|
150 var _oldThickness = ((_model.has('style') && _model.get('style').thickness) || 1), |
|
151 _newThickness = n + _oldThickness; |
|
152 if(_newThickness < 1 ) { |
|
153 _newThickness = 1; |
|
154 } |
|
155 else if (_newThickness > _this.options.node_stroke_witdh_scale) { |
|
156 _newThickness = _this.options.node_stroke_witdh_scale; |
|
157 } |
|
158 if (_newThickness !== _oldThickness) { |
|
159 _this.editor_$.find("#Rk-Edit-Thickness-Value").text(_newThickness); |
|
160 _model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {thickness: _newThickness})); |
|
161 paper.view.draw(); |
|
162 } |
|
163 } |
|
164 else { |
|
165 closeEditor(); |
|
166 } |
|
167 }; |
|
168 |
|
169 this.editor_$.find("#Rk-Edit-Thickness-Down").click(function() { |
|
170 shiftThickness(-1); |
|
171 return false; |
|
172 }); |
|
173 this.editor_$.find("#Rk-Edit-Thickness-Up").click(function() { |
|
174 shiftThickness(1); |
|
175 return false; |
|
176 }); |
143 } |
177 } |
144 }, |
178 }, |
145 redraw: function() { |
179 redraw: function() { |
146 var _coords = this.source_representation.paper_coords; |
180 var _coords = this.source_representation.paper_coords; |
147 Utils.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$); |
181 Utils.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$); |