client/js/renderer/nodeeditor.js
author ymh <ymh.work@gmail.com>
Sun, 14 Jul 2024 22:00:08 +0200
changeset 666 9d6550026232
parent 649 2b9c120dba55
permissions -rw-r--r--
Added tag V00.13.04 for changeset 69d13e7dd286
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
     1
600
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
     2
define(['jquery', 'underscore', 'requtils', 'renderer/baseeditor', 'renderer/shapebuilder', 'ckeditor-core'], function ($, _, requtils, BaseEditor, ShapeBuilder, CKEditor) {
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
            //fusionner avec this.options.node_editor_templates
482
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
    16
            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
    17
        },
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    18
        draw: function() {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    19
            var _model = this.source_representation.model,
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    20
            _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
    21
            _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
    22
            _image_placeholder = this.options.static_url + "img/image-placeholder.png",
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    23
            _size = (_model.get("size") || 0);
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    24
            this.editor_$
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    25
            .html(_template({
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    26
                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
    27
                    _id: _model.get("_id"),
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    28
                    has_creator: !!_model.get("created_by"),
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    29
                    title: _model.get("title"),
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    30
                    uri: _model.get("uri"),
482
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
    31
                    type: _model.get("type") || "default",
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    32
                    short_uri:  Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    33
                    description: _model.get("description"),
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    34
                    image: _model.get("image") || "",
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    35
                    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
    36
                    color: (_model.has("style") && _model.get("style").color) || _created_by.get("color"),
649
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
    37
                    title_size: (_model.has("style") && _model.get("style").title_size) || 1,
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
    38
                    title_color: (_model.has("style") && _model.get("style").title_color) || this.options.node_title_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
    39
                    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
    40
                    dash: _model.has("style") && _model.get("style").dash ? "checked" : "",
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    41
                    clip_path: _model.get("clip_path") || false,
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    42
                    created_by_color: _created_by.get("color"),
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    43
                    created_by_title: _created_by.get("title"),
330
4f92e61f87ba change shape in node editor
cavaliet
parents: 293
diff changeset
    44
                    size: (_size > 0 ? "+" : "") + _size,
4f92e61f87ba change shape in node editor
cavaliet
parents: 293
diff changeset
    45
                    shape: _model.get("shape") || "circle"
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    46
                },
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    47
                renkan: this.renkan,
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    48
                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
    49
                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
    50
                shapes : _(ShapeBuilder.builders).omit('svg').keys().value(),
482
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
    51
                types : _(this.options.node_editor_templates).keys().value(),
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    52
            }));
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    53
            this.redraw();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    54
            var _this = this,
600
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
    55
                editorInstance = (this.renderer.isEditable()  && _this.options.show_node_editor_description_richtext) ?
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
    56
                    CKEditor.inline("Rk-Edit-Description-"+_model.get("_id"), _this.options.richtext_editor_config) :
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
    57
                    false,
600
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
    58
                editorInstanceTitle = (this.renderer.isEditable() && _this.options.show_node_editor_title_richtext) ?
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
    59
                    CKEditor.inline("Rk-Edit-Title-"+_model.get("_id"), _this.options.richtext_editor_config) :
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    60
                    false,
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
    61
                closeEditor = function() {
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
    62
                    _this.renderer.removeRepresentation(_this);
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
    63
                    paper.view.draw();
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
    64
                };
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    65
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
    66
            _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
    67
                _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
    68
                _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
    69
                _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
    70
                _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
    71
                _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
    72
                _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
    73
                _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
    74
                _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
    75
                _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
    76
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(_this.options.show_node_editor_description_richtext) {
600
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
    78
                    if(editorInstance) {
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
    79
                        editorInstance.focusManager.blur(true);
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
    80
                        editorInstance.destroy();
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
    81
                    }
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
                }
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    83
                if(_this.options.show_node_editor_title_richtext) {
600
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
    84
                    if(editorInstanceTitle) {
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
    85
                        editorInstanceTitle.focusManager.blur(true);
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
    86
                        editorInstanceTitle.destroy();
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    87
                    }
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
    88
                }
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
    89
            };
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
    90
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
    91
            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
    92
                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
    93
                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
    94
            });
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    95
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    96
            this.editor_$.find(".Rk-Edit-Goto").click(function() {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    97
                if (!_model.get("uri")) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    98
                    return false;
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
    99
                }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   100
            });
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   101
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   102
            if (this.renderer.isEditable()) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   103
625
4d67ae41b9b3 debounce node and edge edition instead of throttle
ymh <ymh.work@gmail.com>
parents: 600
diff changeset
   104
                var onFieldChange = _.debounce(function() {
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   105
                  _.defer(function() {
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   106
                    if (_this.renderer.isEditable()) {
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   107
                        var _data = {};
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   108
                        if (_this.options.show_node_editor_uri) {
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   109
                            _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   110
                            _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   111
                        }
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   112
                        if (_this.options.show_node_editor_image) {
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   113
                            _data.image = _this.editor_$.find(".Rk-Edit-Image").val();
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   114
                            _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
   115
                        }
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   116
                        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
   117
                            if(_this.options.show_node_editor_description_richtext) {
600
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   118
                                if(editorInstance &&
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   119
                                    editorInstance.checkDirty()) {
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   120
                                    _data.description = editorInstance.getData();
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   121
                                    editorInstance.resetDirty();
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
   122
                                }
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   123
                            }
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   124
                            else {
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   125
                                _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
   126
                            }
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   127
                        }
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   128
                        if (_this.options.show_node_editor_title) {
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   129
                            if(_this.options.show_node_editor_title_richtext) {
600
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   130
                                if(editorInstanceTitle &&
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   131
                                        editorInstanceTitle.checkDirty()) {
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   132
                                    _data.title = editorInstanceTitle.getData();
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   133
                                    editorInstanceTitle.resetDirty();
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   134
                                }
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   135
                            }
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   136
                            else {
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   137
                                _data.title = _this.editor_$.find(".Rk-Edit-Title").val();
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
                        }
458
423bdf56d103 migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents: 435
diff changeset
   140
                        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
   141
                            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
   142
                            _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
   143
                        }
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   144
                        if (_this.options.change_shapes) {
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   145
                            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
   146
                                _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val();
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   147
                            }
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   148
                        }
482
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
   149
                        if (_this.options.change_types) {
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
   150
                            if(_model.get("type")!==_this.editor_$.find(".Rk-Edit-Type").val()){
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
   151
                                _data.type = _this.editor_$.find(".Rk-Edit-Type").val();
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
   152
                            }
a55c33989404 add type selector in the node editor
rougeronj
parents: 480
diff changeset
   153
                        }
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   154
                        _model.set(_data);
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   155
                        _this.redraw();
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   156
                    } else {
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   157
                        closeEditor();
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   158
                    }
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   159
                  });
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   160
                }, 1000);
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   161
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   162
                this.editor_$.on("keyup", function(_e) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   163
                    if (_e.keyCode === 27) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   164
                        closeEditor();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   165
                    }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   166
                });
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   167
330
4f92e61f87ba change shape in node editor
cavaliet
parents: 293
diff changeset
   168
                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
   169
                if( _this.options.show_node_editor_description &&
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   170
                    _this.options.show_node_editor_description_richtext &&
600
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   171
                    editorInstance)
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   172
                {
600
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   173
                    editorInstance.on("change", onFieldChange);
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   174
                    editorInstance.on("blur", onFieldChange);
468
364c367df7fc add rich text editor for description
ymh <ymh.work@gmail.com>
parents: 461
diff changeset
   175
                }
600
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   176
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   177
                if( _this.options.show_node_editor_title &&
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   178
                    _this.options.show_node_editor_title_richtext &&
600
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   179
                    editorInstanceTitle)
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   180
                {
600
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   181
                    editorInstanceTitle.on("change", onFieldChange);
e12243191095 correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents: 530
diff changeset
   182
                    editorInstanceTitle.on("blur", onFieldChange);
530
9823b527c3a1 add rich text editor on title
rougeronj
parents: 482
diff changeset
   183
                }
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   184
385
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   185
                if(_this.options.allow_image_upload) {
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   186
                    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
   187
                        if (this.files.length) {
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   188
                            var f = this.files[0],
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   189
                            fr = new FileReader();
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   190
                            if (f.type.substr(0,5) !== "image") {
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   191
                                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
   192
                                return;
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   193
                            }
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   194
                            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
   195
                                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
   196
                                return;
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   197
                            }
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   198
                            fr.onload = function(e) {
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   199
                                _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
   200
                                onFieldChange();
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   201
                            };
29dcaa4c1748 add option to hide image upload
ymh <ymh.work@gmail.com>
parents: 384
diff changeset
   202
                            fr.readAsDataURL(f);
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   203
                        }
385
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
                }
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   206
                this.editor_$.find(".Rk-Edit-Title")[0].focus();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   207
649
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   208
                var _picker = _this.editor_$.find(".Rk-Editor-ColorPicker-Node");
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   209
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   210
                this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   211
                        function(_e) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   212
                            _e.preventDefault();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   213
                            _picker.show();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   214
                        },
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   215
                        function(_e) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   216
                            _e.preventDefault();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   217
                            _picker.hide();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   218
                        }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   219
                );
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   220
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   221
                _picker.find("li").hover(
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   222
                        function(_e) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   223
                            _e.preventDefault();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   224
                            _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   225
                        },
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   226
                        function(_e) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   227
                            _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
   228
                            _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
   229
                        }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   230
                ).click(function(_e) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   231
                    _e.preventDefault();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   232
                    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
   233
                        _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
   234
                        _picker.hide();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   235
                        paper.view.draw();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   236
                    } else {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   237
                        closeEditor();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   238
                    }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   239
                });
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   240
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   241
                var shiftSize = function(n) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   242
                    if (_this.renderer.isEditable()) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   243
                        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
   244
                        _this.editor_$.find("#Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize);
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   245
                        _model.set("size", _newsize);
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   246
                        paper.view.draw();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   247
                    } else {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   248
                        closeEditor();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   249
                    }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   250
                };
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   251
459
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   252
                this.editor_$.find("#Rk-Edit-Size-Down").click(function() {
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   253
                    shiftSize(-1);
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   254
                    return false;
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   255
                });
459
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   256
                this.editor_$.find("#Rk-Edit-Size-Up").click(function() {
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   257
                    shiftSize(1);
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   258
                    return false;
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   259
                });
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   260
459
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   261
                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
   262
                    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
   263
                        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
   264
                            _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
   265
                        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
   266
                            _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
   267
                        }
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   268
                        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
   269
                            _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
   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
                        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
   272
                            _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
   273
                            _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
   274
                            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
   275
                        }
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   276
                    }
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   277
                    else {
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   278
                        closeEditor();
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
                };
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   281
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   282
                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
   283
                    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
   284
                    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
   285
                });
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   286
                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
   287
                    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
   288
                    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
   289
                });
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 458
diff changeset
   290
649
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   291
                var shiftTitleSize = function(n) {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   292
                    var min = _this.options.node_title_size_min;
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   293
                    var max = _this.options.node_title_size_max;
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   294
                    if (_this.renderer.isEditable()) {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   295
                        var _oldTitleSize = ((_model.has('style') && _model.get('style').title_size) || 1),
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   296
                            _newTitleSize = n + _oldTitleSize;
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   297
                        if(_newTitleSize < min ) {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   298
                            _newTitleSize = min;
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   299
                        }
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   300
                        else if (_newTitleSize > max) {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   301
                            _newTitleSize = max;
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   302
                        }
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   303
                        if (_newTitleSize !== _oldTitleSize) {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   304
                            _this.editor_$.find("#Rk-Edit-Title-Size-Value").text(_newTitleSize.toFixed(1));
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   305
                            _model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {title_size: _newTitleSize}));
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   306
                            paper.view.draw();
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   307
                        }
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   308
                    }
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   309
                    else {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   310
                        closeEditor();
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   311
                    }
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   312
                };
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   313
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   314
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   315
                var _pickerTitle = _this.editor_$.find(".Rk-Editor-ColorPicker-Title");
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   316
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   317
                this.editor_$.find(".Rk-Editor-p-title-color").hover(
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   318
                        function(_e) {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   319
                            _e.preventDefault();
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   320
                            _pickerTitle.show();
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   321
                        },
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   322
                        function(_e) {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   323
                            _e.preventDefault();
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   324
                            _pickerTitle.hide();
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   325
                        }
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   326
                );
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   327
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   328
                _pickerTitle.find("li").hover(
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   329
                        function(_e) {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   330
                            _e.preventDefault();
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   331
                            _this.editor_$.find(".Rk-Editor-p-title-color .Rk-Edit-Color").css("background", $(this).attr("data-color"));
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   332
                        },
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   333
                        function(_e) {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   334
                            _e.preventDefault();
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   335
                            var title_color = (_model.has("style") && _model.get("style").title_color) || _this.options.node_fill_color;
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   336
                            _this.editor_$.find(".Rk-Editor-p-title-color .Rk-Edit-Color").css("background", title_color);
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   337
                        }
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   338
                ).click(function(_e) {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   339
                    _e.preventDefault();
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   340
                    if (_this.renderer.isEditable()) {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   341
                        _model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {title_color: $(this).attr("data-color")}));
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   342
                        _pickerTitle.hide();
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   343
                        paper.view.draw();
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   344
                    } else {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   345
                        closeEditor();
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   346
                    }
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   347
                });
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   348
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   349
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   350
                this.editor_$.find("#Rk-Edit-Title-Size-Down").click(function() {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   351
                    var step = _this.options.node_title_size_step;
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   352
                    shiftTitleSize(-step);
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   353
                    return false;
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   354
                });
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   355
                this.editor_$.find("#Rk-Edit-Title-Size-Up").click(function() {
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   356
                    var step = _this.options.node_title_size_step;
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   357
                    shiftTitleSize(step);
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   358
                    return false;
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   359
                });
2b9c120dba55 first implementation of node title size and color
ymh <ymh.work@gmail.com>
parents: 648
diff changeset
   360
384
6a7930a0d4d1 Close #60 - Add a trash icon to delete the image URL
rougeronj
parents: 331
diff changeset
   361
                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
   362
                    _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
   363
                    onFieldChange();
384
6a7930a0d4d1 Close #60 - Add a trash icon to delete the image URL
rougeronj
parents: 331
diff changeset
   364
                    return false;
6a7930a0d4d1 Close #60 - Add a trash icon to delete the image URL
rougeronj
parents: 331
diff changeset
   365
                });
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   366
            } else {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   367
                if (typeof this.source_representation.highlighted === "object") {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   368
                    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
   369
                    this.editor_$.find(".Rk-Display-Title" + (_model.get("uri") ? " a" : "")).html(titlehtml);
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   370
                    if (this.options.show_node_tooltip_description) {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   371
                        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
   372
                    }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   373
                }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   374
            }
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   375
            this.editor_$.find("img").load(function() {
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   376
                _this.redraw();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   377
            });
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   378
        },
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   379
        redraw: function() {
447
e246651b6626 replace tabs by spaces
rougeronj
parents: 445
diff changeset
   380
            if (this.options.popup_editor){
e246651b6626 replace tabs by spaces
rougeronj
parents: 445
diff changeset
   381
                var _coords = this.source_representation.paper_coords;
648
e388117572d8 Improve display of editor tooltip. Add a vertical scroll if they too tall.
ymh <ymh.work@gmail.com>
parents: 647
diff changeset
   382
                Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$, this.renderer.renkan);
447
e246651b6626 replace tabs by spaces
rougeronj
parents: 445
diff changeset
   383
            }
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   384
            this.editor_$.show();
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   385
            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
   386
        },
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
   387
        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
   388
            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
   389
                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
   390
            }
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
   391
            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
   392
            this.editor_$.remove();
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   393
        }
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 420
diff changeset
   394
    }).value();
434
0d5998b32a7c clean, and finalize lodash migration
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   395
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   396
    /* NodeEditor End */
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 284
diff changeset
   397
284
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   398
    return NodeEditor;
fa8035885814 build renderer with require js
cavaliet
parents:
diff changeset
   399
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 284
diff changeset
   400
});