client/js/renderer/nodeeditor.js
changeset 433 e457ec945e50
parent 420 22393cbf4467
child 434 0d5998b32a7c
equal deleted inserted replaced
432:24754fe4baaf 433:e457ec945e50
    56                 }
    56                 }
    57             });
    57             });
    58 
    58 
    59             if (this.renderer.isEditable()) {
    59             if (this.renderer.isEditable()) {
    60 
    60 
    61                 var onFieldChange = _(function() {
    61                 var onFieldChange = _.throttle(function() {
    62                     _(function() {
    62                   _.defer(function() {
    63                         if (_this.renderer.isEditable()) {
    63                     if (_this.renderer.isEditable()) {
    64                             var _data = {
    64                         var _data = {
    65                                 title: _this.editor_$.find(".Rk-Edit-Title").val()
    65                             title: _this.editor_$.find(".Rk-Edit-Title").val()
    66                             };
    66                         };
    67                             if (_this.options.show_node_editor_uri) {
    67                         if (_this.options.show_node_editor_uri) {
    68                                 _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
    68                             _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
    69                                 _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
    69                             _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
       
    70                         }
       
    71                         if (_this.options.show_node_editor_image) {
       
    72                             _data.image = _this.editor_$.find(".Rk-Edit-Image").val();
       
    73                             _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder);
       
    74                         }
       
    75                         if (_this.options.show_node_editor_description) {
       
    76                             _data.description = _this.editor_$.find(".Rk-Edit-Description").val();
       
    77                         }
       
    78                         if (_this.options.change_shapes) {
       
    79                             if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){
       
    80                                 _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val();
       
    81                                 _data.shape_changed = true;
    70                             }
    82                             }
    71                             if (_this.options.show_node_editor_image) {
    83                         }
    72                                 _data.image = _this.editor_$.find(".Rk-Edit-Image").val();
    84                         _model.set(_data);
    73                                 _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder);
    85                         _this.redraw();
    74                             }
    86                         // For an unknown reason, we have to set data twice when we change shape, otherwise the image disappears.
    75                             if (_this.options.show_node_editor_description) {
    87                         if(_data.shape_changed===true){
    76                                 _data.description = _this.editor_$.find(".Rk-Edit-Description").val();
       
    77                             }
       
    78                             if (_this.options.change_shapes) {
       
    79                                 if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){
       
    80                                     _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val();
       
    81                                     _data.shape_changed = true;
       
    82                                 }
       
    83                             }
       
    84                             _model.set(_data);
    88                             _model.set(_data);
    85                             _this.redraw();
    89                         }
    86                             // For an unknown reason, we have to set data twice when we change shape, otherwise the image disappears.
    90                     } else {
    87                             if(_data.shape_changed===true){
    91                         closeEditor();
    88                                 _model.set(_data);
    92                     }
    89                             }
    93                   });
    90                         } else {
    94                 }, 500);
    91                             closeEditor();
    95 
    92                         }
       
    93                     }).defer();
       
    94                 }).throttle(500);
       
    95                 
       
    96                 this.editor_$.on("keyup", function(_e) {
    96                 this.editor_$.on("keyup", function(_e) {
    97                     if (_e.keyCode === 27) {
    97                     if (_e.keyCode === 27) {
    98                         closeEditor();
    98                         closeEditor();
    99                     }
    99                     }
   100                 });
   100                 });
   174                 });
   174                 });
   175                 this.editor_$.find(".Rk-Edit-Size-Up").click(function() {
   175                 this.editor_$.find(".Rk-Edit-Size-Up").click(function() {
   176                     shiftSize(1);
   176                     shiftSize(1);
   177                     return false;
   177                     return false;
   178                 });
   178                 });
   179                 
   179 
   180                 this.editor_$.find(".Rk-Edit-Image-Del").click(function() {
   180                 this.editor_$.find(".Rk-Edit-Image-Del").click(function() {
   181                 	_this.editor_$.find(".Rk-Edit-Image").val('');
   181                 	_this.editor_$.find(".Rk-Edit-Image").val('');
   182                 	onFieldChange();
   182                 	onFieldChange();
   183                     return false;
   183                     return false;
   184                 });
   184                 });
   199             var _coords = this.source_representation.paper_coords;
   199             var _coords = this.source_representation.paper_coords;
   200             Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$);
   200             Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$);
   201             this.editor_$.show();
   201             this.editor_$.show();
   202             paper.view.draw();
   202             paper.view.draw();
   203         }
   203         }
   204     });
   204     }).value();
   205 
   205 //    });
   206     /* NodeEditor End */
   206     /* NodeEditor End */
   207 
   207 
   208     return NodeEditor;
   208     return NodeEditor;
   209 
   209 
   210 });
   210 });