client/js/renderer/edgeeditor.js
changeset 472 6dcff4438175
parent 461 48235ed6b07d
child 466 884b35feb04b
--- a/client/js/renderer/edgeeditor.js	Wed Jun 03 17:27:46 2015 +0200
+++ b/client/js/renderer/edgeeditor.js	Fri Jun 05 12:17:16 2015 +0200
@@ -29,11 +29,14 @@
                     uri: _model.get("uri"),
                     short_uri:  Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
                     description: _model.get("description"),
-                    color: _model.get("color") || _created_by.get("color"),
+                    color: (_model.has("style") && _model.get("style").color) || _created_by.get("color"),
+                    dash: _model.has("style") && _model.get("style").dash ? "checked" : "",
+                    arrow: (_model.has("style") && _model.get("style").arrow) || !_model.has("style") || (typeof _model.get("style").arrow === 'undefined') ? "checked" : "",
+                    thickness: (_model.has("style") && _model.get("style").thickness) || 1,
                     from_title: _from_model.get("title"),
                     to_title: _to_model.get("title"),
-                    from_color: _from_model.get("color") || (_from_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
-                    to_color: _to_model.get("color") || (_to_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
+                    from_color: (_from_model.has("style") && _from_model.get("style").color) || (_from_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
+                    to_color: (_to_model.has("style") && _to_model.get("style").color) || (_to_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
                     created_by_color: _created_by.get("color"),
                     created_by_title: _created_by.get("title")
                 },
@@ -45,6 +48,7 @@
             var _this = this,
             closeEditor = function() {
                 _this.renderer.removeRepresentation(_this);
+                _this.editor_$.find(".Rk-Edit-Size-Btn").off('click');
                 paper.view.draw();
             };
             this.editor_$.find(".Rk-CloseX").click(closeEditor);
@@ -65,6 +69,12 @@
                             if (_this.options.show_edge_editor_uri) {
                                 _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
                             }
+                            if (_this.options.show_node_editor_style) {
+                                var dash = _this.editor_$.find(".Rk-Edit-Dash").is(':checked');
+                                _data.style = _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {dash: dash});
+                                var arrow = _this.editor_$.find(".Rk-Edit-Arrow").is(':checked');
+                                _data.style = _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {arrow: arrow});
+                            }
                             _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
                             _model.set(_data);
                             paper.view.draw();
@@ -123,18 +133,47 @@
                         },
                         function(_e) {
                             _e.preventDefault();
-                            _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Utils._USER_PLACEHOLDER(_this.renkan)).get("color"));
+                            _this.editor_$.find(".Rk-Edit-Color").css("background", (_model.has("style") && _model.get("style").color)|| (_model.get("created_by") || Utils._USER_PLACEHOLDER(_this.renkan)).get("color"));
                         }
                 ).click(function(_e) {
                     _e.preventDefault();
                     if (_this.renderer.isEditable()) {
-                        _model.set("color", $(this).attr("data-color"));
+                        _model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {color: $(this).attr("data-color")}));
                         _picker.hide();
                         paper.view.draw();
                     } else {
                         closeEditor();
                     }
                 });
+                var shiftThickness = function(n) {
+                    if (_this.renderer.isEditable()) {
+                        var _oldThickness = ((_model.has('style') && _model.get('style').thickness) || 1),
+                            _newThickness = n + _oldThickness;
+                        if(_newThickness < 1 ) {
+                            _newThickness = 1;
+                        }
+                        else if (_newThickness > _this.options.node_stroke_witdh_scale) {
+                            _newThickness = _this.options.node_stroke_witdh_scale;
+                        }
+                        if (_newThickness !== _oldThickness) {
+                            _this.editor_$.find("#Rk-Edit-Thickness-Value").text(_newThickness);
+                            _model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {thickness: _newThickness}));
+                            paper.view.draw();
+                        }
+                    }
+                    else {
+                        closeEditor();
+                    }
+                };
+
+                this.editor_$.find("#Rk-Edit-Thickness-Down").click(function() {
+                    shiftThickness(-1);
+                    return false;
+                });
+                this.editor_$.find("#Rk-Edit-Thickness-Up").click(function() {
+                    shiftThickness(1);
+                    return false;
+                });
             }
         },
         redraw: function() {