client/js/renderer/nodeeditor.js
changeset 530 9823b527c3a1
parent 482 a55c33989404
child 600 e12243191095
equal deleted inserted replaced
529:6b0659a0e4c3 530:9823b527c3a1
    52             this.redraw();
    52             this.redraw();
    53             var _this = this,
    53             var _this = this,
    54                 editorInstance = _this.options.show_node_editor_description_richtext ?
    54                 editorInstance = _this.options.show_node_editor_description_richtext ?
    55                     $(".Rk-Edit-Description").ckeditor(_this.options.richtext_editor_config) :
    55                     $(".Rk-Edit-Description").ckeditor(_this.options.richtext_editor_config) :
    56                     false,
    56                     false,
       
    57                 editorInstanceTitle = _this.options.show_node_editor_title_richtext ?
       
    58                     $(".Rk-Edit-Title").ckeditor(_this.options.richtext_editor_config) :
       
    59                     false,
    57                 closeEditor = function() {
    60                 closeEditor = function() {
    58                     _this.renderer.removeRepresentation(_this);
    61                     _this.renderer.removeRepresentation(_this);
    59                     paper.view.draw();
    62                     paper.view.draw();
    60                 };
    63                 };
    61 
    64 
    76                         delete editorInstance.editor;
    79                         delete editorInstance.editor;
    77                         _editor.focusManager.blur(true);
    80                         _editor.focusManager.blur(true);
    78                         _editor.destroy();
    81                         _editor.destroy();
    79                     }
    82                     }
    80                 }
    83                 }
       
    84                 if(_this.options.show_node_editor_title_richtext) {
       
    85                     if(typeof editorInstanceTitle.editor !== 'undefined') {
       
    86                         var _editor_title = editorInstanceTitle.editor;
       
    87                         delete editorInstanceTitle.editor;
       
    88                         _editor_title.focusManager.blur(true);
       
    89                         _editor_title.destroy();
       
    90                     }
       
    91                 }
    81             };
    92             };
    82 
    93 
    83             this.editor_$.find(".Rk-CloseX").click(function (e) {
    94             this.editor_$.find(".Rk-CloseX").click(function (e) {
    84                 e.preventDefault();
    95                 e.preventDefault();
    85                 closeEditor();
    96                 closeEditor();
    94             if (this.renderer.isEditable()) {
   105             if (this.renderer.isEditable()) {
    95 
   106 
    96                 var onFieldChange = _.throttle(function() {
   107                 var onFieldChange = _.throttle(function() {
    97                   _.defer(function() {
   108                   _.defer(function() {
    98                     if (_this.renderer.isEditable()) {
   109                     if (_this.renderer.isEditable()) {
    99                         var _data = {
   110                         var _data = {};
   100                             title: _this.editor_$.find(".Rk-Edit-Title").val()
       
   101                         };
       
   102                         if (_this.options.show_node_editor_uri) {
   111                         if (_this.options.show_node_editor_uri) {
   103                             _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
   112                             _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
   104                             _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
   113                             _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
   105                         }
   114                         }
   106                         if (_this.options.show_node_editor_image) {
   115                         if (_this.options.show_node_editor_image) {
   117                             }
   126                             }
   118                             else {
   127                             else {
   119                                 _data.description = _this.editor_$.find(".Rk-Edit-Description").val();
   128                                 _data.description = _this.editor_$.find(".Rk-Edit-Description").val();
   120                             }
   129                             }
   121                         }
   130                         }
       
   131                         if (_this.options.show_node_editor_title) {
       
   132                             if(_this.options.show_node_editor_title_richtext) {
       
   133                                 if(typeof editorInstanceTitle.editor !== 'undefined' &&
       
   134                                         editorInstanceTitle.editor.checkDirty()) {
       
   135                                     _data.title = editorInstanceTitle.editor.getData();
       
   136                                     editorInstanceTitle.editor.resetDirty();
       
   137                                 }
       
   138                             }
       
   139                             else {
       
   140                                 _data.title = _this.editor_$.find(".Rk-Edit-Title").val();
       
   141                             }
       
   142                         }
   122                         if (_this.options.show_node_editor_style) {
   143                         if (_this.options.show_node_editor_style) {
   123                             var dash = _this.editor_$.find(".Rk-Edit-Dash").is(':checked');
   144                             var dash = _this.editor_$.find(".Rk-Edit-Dash").is(':checked');
   124                             _data.style = _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {dash: dash});
   145                             _data.style = _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {dash: dash});
   125                         }
   146                         }
   126                         if (_this.options.change_shapes) {
   147                         if (_this.options.change_shapes) {
   152                     _this.options.show_node_editor_description_richtext &&
   173                     _this.options.show_node_editor_description_richtext &&
   153                     typeof editorInstance.editor !== 'undefined')
   174                     typeof editorInstance.editor !== 'undefined')
   154                 {
   175                 {
   155                     editorInstance.editor.on("change", onFieldChange);
   176                     editorInstance.editor.on("change", onFieldChange);
   156                     editorInstance.editor.on("blur", onFieldChange);
   177                     editorInstance.editor.on("blur", onFieldChange);
       
   178                 }
       
   179                 
       
   180                 if( _this.options.show_node_editor_title &&
       
   181                     _this.options.show_node_editor_title_richtext &&
       
   182                     typeof editorInstanceTitle.editor !== 'undefined')
       
   183                 {
       
   184                     editorInstanceTitle.editor.on("change", onFieldChange);
       
   185                     editorInstanceTitle.editor.on("blur", onFieldChange);
   157                 }
   186                 }
   158 
   187 
   159                 if(_this.options.allow_image_upload) {
   188                 if(_this.options.allow_image_upload) {
   160                     this.editor_$.find(".Rk-Edit-Image-File").change(function() {
   189                     this.editor_$.find(".Rk-Edit-Image-File").change(function() {
   161                         if (this.files.length) {
   190                         if (this.files.length) {