client/js/renderer/nodeeditor.js
changeset 459 98cae534083d
parent 458 423bdf56d103
child 461 48235ed6b07d
equal deleted inserted replaced
458:423bdf56d103 459:98cae534083d
    29                     short_uri:  Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
    29                     short_uri:  Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
    30                     description: _model.get("description"),
    30                     description: _model.get("description"),
    31                     image: _model.get("image") || "",
    31                     image: _model.get("image") || "",
    32                     image_placeholder: _image_placeholder,
    32                     image_placeholder: _image_placeholder,
    33                     color: (_model.has("style") && _model.get("style").color) || _created_by.get("color"),
    33                     color: (_model.has("style") && _model.get("style").color) || _created_by.get("color"),
       
    34                     thickness: (_model.has("style") && _model.get("style").thickness) || 1,
    34                     dash: _model.has("style") && _model.get("style").dash ? "checked" : "",
    35                     dash: _model.has("style") && _model.get("style").dash ? "checked" : "",
    35                     clip_path: _model.get("clip_path") || false,
    36                     clip_path: _model.get("clip_path") || false,
    36                     created_by_color: _created_by.get("color"),
    37                     created_by_color: _created_by.get("color"),
    37                     created_by_title: _created_by.get("title"),
    38                     created_by_title: _created_by.get("title"),
    38                     size: (_size > 0 ? "+" : "") + _size,
    39                     size: (_size > 0 ? "+" : "") + _size,
    48             closeEditor = function() {
    49             closeEditor = function() {
    49                 _this.editor_$.off("keyup");
    50                 _this.editor_$.off("keyup");
    50                 _this.editor_$.find("input, textarea, select").off("change keyup paste");
    51                 _this.editor_$.find("input, textarea, select").off("change keyup paste");
    51                 _this.editor_$.find(".Rk-Edit-Image-File").off('change');
    52                 _this.editor_$.find(".Rk-Edit-Image-File").off('change');
    52                 _this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").off('hover');
    53                 _this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").off('hover');
    53                 _this.editor_$.find(".Rk-Edit-Size-Down").off('click');
    54                 _this.editor_$.find(".Rk-Edit-Size-Btn").off('click');
    54                 _this.editor_$.find(".Rk-Edit-Size-Up").off('click');
       
    55                 _this.editor_$.find(".Rk-Edit-Image-Del").off('click');
    55                 _this.editor_$.find(".Rk-Edit-Image-Del").off('click');
    56                 _this.editor_$.find(".Rk-Edit-ColorPicker").find("li").off('hover click');
    56                 _this.editor_$.find(".Rk-Edit-ColorPicker").find("li").off('hover click');
    57                 _this.editor_$.find(".Rk-CloseX").off('click');
    57                 _this.editor_$.find(".Rk-CloseX").off('click');
    58                 _this.editor_$.find(".Rk-Edit-Goto").off('click');
    58                 _this.editor_$.find(".Rk-Edit-Goto").off('click');
    59 
    59 
   170                 });
   170                 });
   171 
   171 
   172                 var shiftSize = function(n) {
   172                 var shiftSize = function(n) {
   173                     if (_this.renderer.isEditable()) {
   173                     if (_this.renderer.isEditable()) {
   174                         var _newsize = n+(_model.get("size") || 0);
   174                         var _newsize = n+(_model.get("size") || 0);
   175                         _this.editor_$.find(".Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize);
   175                         _this.editor_$.find("#Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize);
   176                         _model.set("size", _newsize);
   176                         _model.set("size", _newsize);
   177                         paper.view.draw();
   177                         paper.view.draw();
   178                     } else {
   178                     } else {
   179                         closeEditor();
   179                         closeEditor();
   180                     }
   180                     }
   181                 };
   181                 };
   182 
   182 
   183                 this.editor_$.find(".Rk-Edit-Size-Down").click(function() {
   183                 this.editor_$.find("#Rk-Edit-Size-Down").click(function() {
   184                     shiftSize(-1);
   184                     shiftSize(-1);
   185                     return false;
   185                     return false;
   186                 });
   186                 });
   187                 this.editor_$.find(".Rk-Edit-Size-Up").click(function() {
   187                 this.editor_$.find("#Rk-Edit-Size-Up").click(function() {
   188                     shiftSize(1);
   188                     shiftSize(1);
       
   189                     return false;
       
   190                 });
       
   191 
       
   192                 var shiftThickness = function(n) {
       
   193                     if (_this.renderer.isEditable()) {
       
   194                         var _oldThickness = ((_model.has('style') && _model.get('style').thickness) || 1),
       
   195                             _newThickness = n + _oldThickness;
       
   196                         if(_newThickness < 1 ) {
       
   197                             _newThickness = 1;
       
   198                         }
       
   199                         else if (_newThickness > _this.options.node_stroke_witdh_scale) {
       
   200                             _newThickness = _this.options.node_stroke_witdh_scale;
       
   201                         }
       
   202                         if (_newThickness !== _oldThickness) {
       
   203                             _this.editor_$.find("#Rk-Edit-Thickness-Value").text(_newThickness);
       
   204                             _model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {thickness: _newThickness}));
       
   205                             paper.view.draw();
       
   206                         }
       
   207                     }
       
   208                     else {
       
   209                         closeEditor();
       
   210                     }
       
   211                 };
       
   212 
       
   213                 this.editor_$.find("#Rk-Edit-Thickness-Down").click(function() {
       
   214                     shiftThickness(-1);
       
   215                     return false;
       
   216                 });
       
   217                 this.editor_$.find("#Rk-Edit-Thickness-Up").click(function() {
       
   218                     shiftThickness(1);
   189                     return false;
   219                     return false;
   190                 });
   220                 });
   191 
   221 
   192                 this.editor_$.find(".Rk-Edit-Image-Del").click(function() {
   222                 this.editor_$.find(".Rk-Edit-Image-Del").click(function() {
   193                     _this.editor_$.find(".Rk-Edit-Image").val('');
   223                     _this.editor_$.find(".Rk-Edit-Image").val('');