client/js/renderer/nodeeditor.js
author rougeronj
Fri, 18 Sep 2015 15:36:46 +0200
changeset 530 9823b527c3a1
parent 482 a55c33989404
child 600 e12243191095
permissions -rw-r--r--
add rich text editor on title
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
     1
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
     2
define(['jquery', 'underscore', 'requtils', 'renderer/baseeditor', 'renderer/shapebuilder', 'ckeditor-jquery'], function ($, _, requtils, BaseEditor, ShapeBuilder) {
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 284
diff changeset
     3
    'use strict';
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 284
diff changeset
     4
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
     5
    var Utils = requtils.getUtils();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
     6
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
     7
    /* NodeEditor Begin */
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
     8
    //var NodeEditor = Renderer.NodeEditor = Utils.inherit(Renderer._BaseEditor);
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
     9
    var NodeEditor = Utils.inherit(BaseEditor);
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    10
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    11
    _(NodeEditor.prototype).extend({
435
e529b633c339 Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents: 434
diff changeset
    12
        _init: function() {
e529b633c339 Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents: 434
diff changeset
    13
            BaseEditor.prototype._init.apply(this);
e529b633c339 Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents: 434
diff changeset
    14
            this.template = this.options.templates['templates/nodeeditor.html'];
450
88e8673aaeeb add the hidden/ghost behaviour:
rougeronj
parents: 447
diff changeset
    15
            //this.templates['default']= this.options.templates['templates/nodeeditor.html'];
88e8673aaeeb add the hidden/ghost behaviour:
rougeronj
parents: 447
diff changeset
    16
            //fusionner avec this.options.node_editor_templates
482
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
    17
            this.readOnlyTemplate = this.options.node_editor_templates;
435
e529b633c339 Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents: 434
diff changeset
    18
        },
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    19
        draw: function() {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    20
            var _model = this.source_representation.model,
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    21
            _created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan),
482
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
    22
            _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate[_model.get("type")] || this.readOnlyTemplate["default"]),
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    23
            _image_placeholder = this.options.static_url + "img/image-placeholder.png",
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    24
            _size = (_model.get("size") || 0);
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    25
            this.editor_$
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    26
            .html(_template({
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    27
                node: {
479
be510a7fc5ac send the id to the template and construct an proper url for each node passing the id to the parameter idNode
rougeronj
parents: 469
diff changeset
    28
                    _id: _model.get("_id"),
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    29
                    has_creator: !!_model.get("created_by"),
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    30
                    title: _model.get("title"),
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    31
                    uri: _model.get("uri"),
482
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
    32
                    type: _model.get("type") || "default",
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    33
                    short_uri:  Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    34
                    description: _model.get("description"),
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    35
                    image: _model.get("image") || "",
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    36
                    image_placeholder: _image_placeholder,
458
423bdf56d103 migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents: 435
diff changeset
    37
                    color: (_model.has("style") && _model.get("style").color) || _created_by.get("color"),
459
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
    38
                    thickness: (_model.has("style") && _model.get("style").thickness) || 1,
458
423bdf56d103 migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents: 435
diff changeset
    39
                    dash: _model.has("style") && _model.get("style").dash ? "checked" : "",
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    40
                    clip_path: _model.get("clip_path") || false,
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    41
                    created_by_color: _created_by.get("color"),
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    42
                    created_by_title: _created_by.get("title"),
330
4f92e61f87ba change shape in node editor
cavaliet
parents: 293
diff changeset
    43
                    size: (_size > 0 ? "+" : "") + _size,
4f92e61f87ba change shape in node editor
cavaliet
parents: 293
diff changeset
    44
                    shape: _model.get("shape") || "circle"
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    45
                },
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    46
                renkan: this.renkan,
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    47
                options: this.options,
458
423bdf56d103 migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents: 435
diff changeset
    48
                shortenText: Utils.shortenText,
423bdf56d103 migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents: 435
diff changeset
    49
                shapes : _(ShapeBuilder.builders).omit('svg').keys().value(),
482
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
    50
                types : _(this.options.node_editor_templates).keys().value(),
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    51
            }));
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    52
            this.redraw();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    53
            var _this = this,
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
    54
                editorInstance = _this.options.show_node_editor_description_richtext ?
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
    55
                    $(".Rk-Edit-Description").ckeditor(_this.options.richtext_editor_config) :
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
    56
                    false,
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    57
                editorInstanceTitle = _this.options.show_node_editor_title_richtext ?
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    58
                    $(".Rk-Edit-Title").ckeditor(_this.options.richtext_editor_config) :
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    59
                    false,
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
    60
                closeEditor = function() {
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
    61
                    _this.renderer.removeRepresentation(_this);
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
    62
                    paper.view.draw();
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
    63
                };
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    64
470
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    65
            _this.cleanEditor = function() {
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    66
                _this.editor_$.off("keyup");
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    67
                _this.editor_$.find("input, textarea, select").off("change keyup paste");
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    68
                _this.editor_$.find(".Rk-Edit-Image-File").off('change');
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    69
                _this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").off('hover');
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    70
                _this.editor_$.find(".Rk-Edit-Size-Btn").off('click');
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    71
                _this.editor_$.find(".Rk-Edit-Image-Del").off('click');
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    72
                _this.editor_$.find(".Rk-Edit-ColorPicker").find("li").off('hover click');
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    73
                _this.editor_$.find(".Rk-CloseX").off('click');
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    74
                _this.editor_$.find(".Rk-Edit-Goto").off('click');
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    75
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    76
                if(_this.options.show_node_editor_description_richtext) {
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    77
                    if(typeof editorInstance.editor !== 'undefined') {
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    78
                        var _editor = editorInstance.editor;
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    79
                        delete editorInstance.editor;
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    80
                        _editor.focusManager.blur(true);
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    81
                        _editor.destroy();
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    82
                    }
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    83
                }
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    84
                if(_this.options.show_node_editor_title_richtext) {
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    85
                    if(typeof editorInstanceTitle.editor !== 'undefined') {
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    86
                        var _editor_title = editorInstanceTitle.editor;
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    87
                        delete editorInstanceTitle.editor;
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    88
                        _editor_title.focusManager.blur(true);
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    89
                        _editor_title.destroy();
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    90
                    }
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    91
                }
470
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    92
            };
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    93
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    94
            this.editor_$.find(".Rk-CloseX").click(function (e) {
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    95
                e.preventDefault();
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    96
                closeEditor();
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
    97
            });
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    98
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    99
            this.editor_$.find(".Rk-Edit-Goto").click(function() {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   100
                if (!_model.get("uri")) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   101
                    return false;
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   102
                }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   103
            });
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   104
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   105
            if (this.renderer.isEditable()) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   106
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   107
                var onFieldChange = _.throttle(function() {
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   108
                  _.defer(function() {
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   109
                    if (_this.renderer.isEditable()) {
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   110
                        var _data = {};
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   111
                        if (_this.options.show_node_editor_uri) {
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   112
                            _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   113
                            _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   114
                        }
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   115
                        if (_this.options.show_node_editor_image) {
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   116
                            _data.image = _this.editor_$.find(".Rk-Edit-Image").val();
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   117
                            _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder);
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   118
                        }
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   119
                        if (_this.options.show_node_editor_description) {
470
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   120
                            if(_this.options.show_node_editor_description_richtext) {
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   121
                                if(typeof editorInstance.editor !== 'undefined' &&
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   122
                                    editorInstance.editor.checkDirty()) {
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   123
                                    _data.description = editorInstance.editor.getData();
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   124
                                    editorInstance.editor.resetDirty();
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   125
                                }
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   126
                            }
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   127
                            else {
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   128
                                _data.description = _this.editor_$.find(".Rk-Edit-Description").val();
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   129
                            }
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   130
                        }
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   131
                        if (_this.options.show_node_editor_title) {
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   132
                            if(_this.options.show_node_editor_title_richtext) {
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   133
                                if(typeof editorInstanceTitle.editor !== 'undefined' &&
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   134
                                        editorInstanceTitle.editor.checkDirty()) {
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   135
                                    _data.title = editorInstanceTitle.editor.getData();
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   136
                                    editorInstanceTitle.editor.resetDirty();
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   137
                                }
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   138
                            }
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   139
                            else {
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   140
                                _data.title = _this.editor_$.find(".Rk-Edit-Title").val();
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   141
                            }
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   142
                        }
458
423bdf56d103 migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents: 435
diff changeset
   143
                        if (_this.options.show_node_editor_style) {
423bdf56d103 migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents: 435
diff changeset
   144
                            var dash = _this.editor_$.find(".Rk-Edit-Dash").is(':checked');
423bdf56d103 migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents: 435
diff changeset
   145
                            _data.style = _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {dash: dash});
423bdf56d103 migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents: 435
diff changeset
   146
                        }
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   147
                        if (_this.options.change_shapes) {
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   148
                            if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   149
                                _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val();
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   150
                            }
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   151
                        }
482
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
   152
                        if (_this.options.change_types) {
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
   153
                            if(_model.get("type")!==_this.editor_$.find(".Rk-Edit-Type").val()){
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
   154
                                _data.type = _this.editor_$.find(".Rk-Edit-Type").val();
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
   155
                            }
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
   156
                        }
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   157
                        _model.set(_data);
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   158
                        _this.redraw();
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   159
                    } else {
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   160
                        closeEditor();
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   161
                    }
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   162
                  });
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   163
                }, 1000);
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   164
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   165
                this.editor_$.on("keyup", function(_e) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   166
                    if (_e.keyCode === 27) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   167
                        closeEditor();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   168
                    }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   169
                });
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   170
330
4f92e61f87ba change shape in node editor
cavaliet
parents: 293
diff changeset
   171
                this.editor_$.find("input, textarea, select").on("change keyup paste", onFieldChange);
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   172
                if( _this.options.show_node_editor_description &&
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   173
                    _this.options.show_node_editor_description_richtext &&
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   174
                    typeof editorInstance.editor !== 'undefined')
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   175
                {
470
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   176
                    editorInstance.editor.on("change", onFieldChange);
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   177
                    editorInstance.editor.on("blur", onFieldChange);
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   178
                }
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   179
                
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   180
                if( _this.options.show_node_editor_title &&
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   181
                    _this.options.show_node_editor_title_richtext &&
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   182
                    typeof editorInstanceTitle.editor !== 'undefined')
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   183
                {
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   184
                    editorInstanceTitle.editor.on("change", onFieldChange);
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   185
                    editorInstanceTitle.editor.on("blur", onFieldChange);
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   186
                }
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   187
385
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   188
                if(_this.options.allow_image_upload) {
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   189
                    this.editor_$.find(".Rk-Edit-Image-File").change(function() {
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   190
                        if (this.files.length) {
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   191
                            var f = this.files[0],
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   192
                            fr = new FileReader();
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   193
                            if (f.type.substr(0,5) !== "image") {
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   194
                                alert(_this.renkan.translate("This file is not an image"));
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   195
                                return;
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   196
                            }
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   197
                            if (f.size > (_this.options.uploaded_image_max_kb * 1024)) {
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   198
                                alert(_this.renkan.translate("Image size must be under ") + _this.options.uploaded_image_max_kb + _this.renkan.translate("KB"));
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   199
                                return;
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   200
                            }
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   201
                            fr.onload = function(e) {
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   202
                                _this.editor_$.find(".Rk-Edit-Image").val(e.target.result);
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   203
                                onFieldChange();
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   204
                            };
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   205
                            fr.readAsDataURL(f);
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   206
                        }
385
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   207
                    });
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   208
                }
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   209
                this.editor_$.find(".Rk-Edit-Title")[0].focus();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   210
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   211
                var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker");
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   212
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   213
                this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   214
                        function(_e) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   215
                            _e.preventDefault();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   216
                            _picker.show();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   217
                        },
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   218
                        function(_e) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   219
                            _e.preventDefault();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   220
                            _picker.hide();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   221
                        }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   222
                );
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   223
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   224
                _picker.find("li").hover(
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   225
                        function(_e) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   226
                            _e.preventDefault();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   227
                            _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   228
                        },
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   229
                        function(_e) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   230
                            _e.preventDefault();
458
423bdf56d103 migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents: 435
diff changeset
   231
                            _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"));
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   232
                        }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   233
                ).click(function(_e) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   234
                    _e.preventDefault();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   235
                    if (_this.renderer.isEditable()) {
458
423bdf56d103 migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents: 435
diff changeset
   236
                        _model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {color: $(this).attr("data-color")}));
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   237
                        _picker.hide();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   238
                        paper.view.draw();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   239
                    } else {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   240
                        closeEditor();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   241
                    }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   242
                });
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   243
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   244
                var shiftSize = function(n) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   245
                    if (_this.renderer.isEditable()) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   246
                        var _newsize = n+(_model.get("size") || 0);
459
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   247
                        _this.editor_$.find("#Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize);
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   248
                        _model.set("size", _newsize);
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   249
                        paper.view.draw();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   250
                    } else {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   251
                        closeEditor();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   252
                    }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   253
                };
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   254
459
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   255
                this.editor_$.find("#Rk-Edit-Size-Down").click(function() {
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   256
                    shiftSize(-1);
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   257
                    return false;
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   258
                });
459
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   259
                this.editor_$.find("#Rk-Edit-Size-Up").click(function() {
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   260
                    shiftSize(1);
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   261
                    return false;
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   262
                });
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   263
459
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   264
                var shiftThickness = function(n) {
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   265
                    if (_this.renderer.isEditable()) {
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   266
                        var _oldThickness = ((_model.has('style') && _model.get('style').thickness) || 1),
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   267
                            _newThickness = n + _oldThickness;
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   268
                        if(_newThickness < 1 ) {
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   269
                            _newThickness = 1;
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   270
                        }
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   271
                        else if (_newThickness > _this.options.node_stroke_witdh_scale) {
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   272
                            _newThickness = _this.options.node_stroke_witdh_scale;
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   273
                        }
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   274
                        if (_newThickness !== _oldThickness) {
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   275
                            _this.editor_$.find("#Rk-Edit-Thickness-Value").text(_newThickness);
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   276
                            _model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {thickness: _newThickness}));
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   277
                            paper.view.draw();
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   278
                        }
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   279
                    }
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   280
                    else {
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   281
                        closeEditor();
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   282
                    }
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   283
                };
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   284
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   285
                this.editor_$.find("#Rk-Edit-Thickness-Down").click(function() {
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   286
                    shiftThickness(-1);
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   287
                    return false;
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   288
                });
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   289
                this.editor_$.find("#Rk-Edit-Thickness-Up").click(function() {
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   290
                    shiftThickness(1);
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   291
                    return false;
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   292
                });
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   293
384
6a7930a0d4d1 Close #60 - Add a trash icon to delete the image URL
rougeronj
parents: 331
diff changeset
   294
                this.editor_$.find(".Rk-Edit-Image-Del").click(function() {
435
e529b633c339 Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents: 434
diff changeset
   295
                    _this.editor_$.find(".Rk-Edit-Image").val('');
e529b633c339 Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents: 434
diff changeset
   296
                    onFieldChange();
384
6a7930a0d4d1 Close #60 - Add a trash icon to delete the image URL
rougeronj
parents: 331
diff changeset
   297
                    return false;
6a7930a0d4d1 Close #60 - Add a trash icon to delete the image URL
rougeronj
parents: 331
diff changeset
   298
                });
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   299
            } else {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   300
                if (typeof this.source_representation.highlighted === "object") {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   301
                    var titlehtml = this.source_representation.highlighted.replace(_(_model.get("title")).escape(),'<span class="Rk-Highlighted">$1</span>');
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   302
                    this.editor_$.find(".Rk-Display-Title" + (_model.get("uri") ? " a" : "")).html(titlehtml);
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   303
                    if (this.options.show_node_tooltip_description) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   304
                        this.editor_$.find(".Rk-Display-Description").html(this.source_representation.highlighted.replace(_(_model.get("description")).escape(),'<span class="Rk-Highlighted">$1</span>'));
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   305
                    }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   306
                }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   307
            }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   308
            this.editor_$.find("img").load(function() {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   309
                _this.redraw();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   310
            });
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   311
        },
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   312
        redraw: function() {
447
e246651b6626 replace tabs by spaces
rougeronj
parents: 445
diff changeset
   313
            if (this.options.popup_editor){
e246651b6626 replace tabs by spaces
rougeronj
parents: 445
diff changeset
   314
                var _coords = this.source_representation.paper_coords;
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   315
                Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$);
447
e246651b6626 replace tabs by spaces
rougeronj
parents: 445
diff changeset
   316
            }
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   317
            this.editor_$.show();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   318
            paper.view.draw();
470
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   319
        },
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   320
        destroy: function() {
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   321
            if(typeof this.cleanEditor !== 'undefined') {
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   322
                this.cleanEditor();
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   323
            }
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   324
            this.editor_block.remove();
47308aa6ce94 correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents: 469
diff changeset
   325
            this.editor_$.remove();
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   326
        }
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   327
    }).value();
434
0d5998b32a7c clean, and finalize lodash migration
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   328
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   329
    /* NodeEditor End */
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 284
diff changeset
   330
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   331
    return NodeEditor;
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   332
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 284
diff changeset
   333
});