client/js/paper-renderer.js
changeset 170 603ffa4c6fa5
parent 169 a60a450b8f3b
child 173 009427475db2
equal deleted inserted replaced
169:a60a450b8f3b 170:603ffa4c6fa5
    20             color: _renkan.options.default_user_color,
    20             color: _renkan.options.default_user_color,
    21             title: _renkan.translate("(unknown user)"),
    21             title: _renkan.translate("(unknown user)"),
    22             get: function(attr) {
    22             get: function(attr) {
    23                 return this[attr] || false;
    23                 return this[attr] || false;
    24             }
    24             }
    25         }
    25         };
    26     },
    26     },
    27     _BOOKMARKLET_CODE: function(_renkan) {
    27     _BOOKMARKLET_CODE: function(_renkan) {
    28         return "(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='<p_style=\"position:fixed;top:0;right:0;font:bold_18px_sans-serif;color:#fff;background:#909;padding:10px;z-index:100000;\">"
    28         return "(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='<p_style=\"position:fixed;top:0;right:0;font:bold_18px_sans-serif;color:#fff;background:#909;padding:10px;z-index:100000;\">"
    29         + _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_")
    29         + _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_")
    30         + "</p>'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\/\\/[^\\/]*twitter\\.com\\//,s:'.tweet',n:'twitter'},{r:/https?:\\/\\/[^\\/]*google\\.[^\\/]+\\//,s:'.g',n:'google'},{r:/https?:\\/\\/[^\\/]*lemonde\\.fr\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();"
    30         + "</p>'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\/\\/[^\\/]*twitter\\.com\\//,s:'.tweet',n:'twitter'},{r:/https?:\\/\\/[^\\/]*google\\.[^\\/]+\\//,s:'.g',n:'google'},{r:/https?:\\/\\/[^\\/]*lemonde\\.fr\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();";
    31     },
    31     },
    32     shortenText : function(_text, _maxlength) {
    32     shortenText : function(_text, _maxlength) {
    33         return (_text.length > _maxlength ? (_text.substr(0,_maxlength) + '…') : _text);
    33         return (_text.length > _maxlength ? (_text.substr(0,_maxlength) + '…') : _text);
    34     },
    34     },
    35     drawEditBox : function(_options, _coords, _path, _xmargin, _selector) {
    35     drawEditBox : function(_options, _coords, _path, _xmargin, _selector) {
    36         _selector.css({
    36         _selector.css({
    37             width: ( _options.tooltip_width - 2* _options.tooltip_padding ),
    37             width: ( _options.tooltip_width - 2* _options.tooltip_padding ),
    38         })
    38         });
    39         var _height = _selector.outerHeight() + 2* _options.tooltip_padding,
    39         var _height = _selector.outerHeight() + 2* _options.tooltip_padding,
    40             _isLeft = (_coords.x < paper.view.center.x ? 1 : -1),
    40             _isLeft = (_coords.x < paper.view.center.x ? 1 : -1),
    41             _left = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length ),
    41             _left = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length ),
    42             _right = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length + _options.tooltip_width ),
    42             _right = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length + _options.tooltip_width ),
    43             _top = _coords.y - _height / 2;
    43             _top = _coords.y - _height / 2;
    73             left: (_options.tooltip_padding + Math.min(_left, _right)),
    73             left: (_options.tooltip_padding + Math.min(_left, _right)),
    74             top: (_options.tooltip_padding + _top)
    74             top: (_options.tooltip_padding + _top)
    75         });
    75         });
    76         return _path;
    76         return _path;
    77     }
    77     }
    78 }
    78 };
    79 
    79 
    80 Rkns.Renderer._BaseRepresentation = function(_renderer, _model) {
    80 Rkns.Renderer._BaseRepresentation = function(_renderer, _model) {
    81     if (typeof _renderer !== "undefined") {
    81     if (typeof _renderer !== "undefined") {
    82         this.renderer = _renderer;
    82         this.renderer = _renderer;
    83         this.renkan = _renderer.renkan;
    83         this.renkan = _renderer.renkan;
    86         this.model = _model;
    86         this.model = _model;
    87         if (this.model) {
    87         if (this.model) {
    88             var _this = this;
    88             var _this = this;
    89             this._changeBinding = function() {
    89             this._changeBinding = function() {
    90                 _this.redraw();
    90                 _this.redraw();
    91             }
    91             };
    92             this._removeBinding = function() {
    92             this._removeBinding = function() {
    93                 _renderer.removeRepresentation(_this);
    93                 _renderer.removeRepresentation(_this);
    94                 _(function() {
    94                 _(function() {
    95                     _renderer.redraw()
    95                     _renderer.redraw();
    96                 }).defer();
    96                 }).defer();
    97             }
    97             };
    98             this._selectBinding = function() {
    98             this._selectBinding = function() {
    99                 _this.select();
    99                 _this.select();
   100             }
   100             };
   101             this._unselectBinding = function() {
   101             this._unselectBinding = function() {
   102                 _this.unselect();
   102                 _this.unselect();
   103             }
   103             };
   104             this.model.on("change", this._changeBinding );
   104             this.model.on("change", this._changeBinding );
   105             this.model.on("remove", this._removeBinding );
   105             this.model.on("remove", this._removeBinding );
   106             this.model.on("select", this._selectBinding );
   106             this.model.on("select", this._selectBinding );
   107             this.model.on("unselect", this._unselectBinding );
   107             this.model.on("unselect", this._unselectBinding );
   108         }
   108         }
   109     }
   109     }
   110 }
   110 };
   111 
   111 
   112 Rkns.Renderer._BaseRepresentation.prototype.super = function(_func) {
   112 Rkns.Renderer._BaseRepresentation.prototype.super = function(_func) {
   113     Rkns.Renderer._BaseRepresentation.prototype[_func].apply(this, Array.prototype.slice.call(arguments, 1));
   113     Rkns.Renderer._BaseRepresentation.prototype[_func].apply(this, Array.prototype.slice.call(arguments, 1));
   114 }
   114 };
   115 
   115 
   116 Rkns.Renderer._BaseRepresentation.prototype.redraw = function() {}
   116 Rkns.Renderer._BaseRepresentation.prototype.redraw = function() {};
   117 
   117 
   118 Rkns.Renderer._BaseRepresentation.prototype.moveTo = function() {}
   118 Rkns.Renderer._BaseRepresentation.prototype.moveTo = function() {};
   119 
   119 
   120 Rkns.Renderer._BaseRepresentation.prototype.show = function() {}
   120 Rkns.Renderer._BaseRepresentation.prototype.show = function() {};
   121 
   121 
   122 Rkns.Renderer._BaseRepresentation.prototype.hide = function() {}
   122 Rkns.Renderer._BaseRepresentation.prototype.hide = function() {};
   123 
   123 
   124 Rkns.Renderer._BaseRepresentation.prototype.select = function() {
   124 Rkns.Renderer._BaseRepresentation.prototype.select = function() {
   125     if (this.model) {
   125     if (this.model) {
   126         this.model.trigger("selected");
   126         this.model.trigger("selected");
   127     }
   127     }
   128 }
   128 };
   129 
   129 
   130 Rkns.Renderer._BaseRepresentation.prototype.unselect = function() {
   130 Rkns.Renderer._BaseRepresentation.prototype.unselect = function() {
   131     if (this.model) {
   131     if (this.model) {
   132         this.model.trigger("unselected");
   132         this.model.trigger("unselected");
   133     }
   133     }
   134 }
   134 };
   135 
   135 
   136 Rkns.Renderer._BaseRepresentation.prototype.highlight = function() {}
   136 Rkns.Renderer._BaseRepresentation.prototype.highlight = function() {};
   137 
   137 
   138 Rkns.Renderer._BaseRepresentation.prototype.unhighlight = function() {}
   138 Rkns.Renderer._BaseRepresentation.prototype.unhighlight = function() {};
   139 
   139 
   140 Rkns.Renderer._BaseRepresentation.prototype.mousedown = function() {}
   140 Rkns.Renderer._BaseRepresentation.prototype.mousedown = function() {};
   141 
   141 
   142 Rkns.Renderer._BaseRepresentation.prototype.mouseup = function() {
   142 Rkns.Renderer._BaseRepresentation.prototype.mouseup = function() {
   143     if (this.model) {
   143     if (this.model) {
   144         this.model.trigger("clicked");
   144         this.model.trigger("clicked");
   145     }
   145     }
   146 }
   146 };
   147 
   147 
   148 Rkns.Renderer._BaseRepresentation.prototype.destroy = function() {
   148 Rkns.Renderer._BaseRepresentation.prototype.destroy = function() {
   149     if (this.model) {
   149     if (this.model) {
   150         this.model.off("change", this._changeBinding );
   150         this.model.off("change", this._changeBinding );
   151         this.model.off("remove", this._removeBinding );
   151         this.model.off("remove", this._removeBinding );
   152         this.model.off("select", this._selectBinding );
   152         this.model.off("select", this._selectBinding );
   153         this.model.off("unselect", this._unselectBinding );
   153         this.model.off("unselect", this._unselectBinding );
   154     }
   154     }
   155 }
   155 };
   156 
   156 
   157 /* */
   157 /* */
   158 
   158 
   159 Rkns.Renderer._BaseButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
   159 Rkns.Renderer._BaseButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
   160 
   160 
   161 Rkns.Renderer._BaseButton.prototype.moveTo = function(_pos) {
   161 Rkns.Renderer._BaseButton.prototype.moveTo = function(_pos) {
   162     this.sector.moveTo(_pos);
   162     this.sector.moveTo(_pos);
   163 }
   163 };
   164 
   164 
   165 Rkns.Renderer._BaseButton.prototype.show = function() {
   165 Rkns.Renderer._BaseButton.prototype.show = function() {
   166     this.sector.show();
   166     this.sector.show();
   167 }
   167 };
   168 
   168 
   169 Rkns.Renderer._BaseButton.prototype.hide = function() {
   169 Rkns.Renderer._BaseButton.prototype.hide = function() {
   170     this.sector.hide();
   170     this.sector.hide();
   171 }
   171 };
   172 
   172 
   173 Rkns.Renderer._BaseButton.prototype.select = function() {
   173 Rkns.Renderer._BaseButton.prototype.select = function() {
   174     this.sector.select();
   174     this.sector.select();
   175 }
   175 };
   176 
   176 
   177 Rkns.Renderer._BaseButton.prototype.unselect = function(_newTarget) {
   177 Rkns.Renderer._BaseButton.prototype.unselect = function(_newTarget) {
   178     this.sector.unselect();
   178     this.sector.unselect();
   179     if (!_newTarget || (_newTarget !== this.source_representation && _newTarget.source_representation !== this.source_representation)) {
   179     if (!_newTarget || (_newTarget !== this.source_representation && _newTarget.source_representation !== this.source_representation)) {
   180         this.source_representation.unselect();
   180         this.source_representation.unselect();
   181     }
   181     }
   182 }
   182 };
   183 
   183 
   184 Rkns.Renderer._BaseButton.prototype.destroy = function() {
   184 Rkns.Renderer._BaseButton.prototype.destroy = function() {
   185     this.sector.destroy();
   185     this.sector.destroy();
   186 }
   186 };
   187 
   187 
   188 /* */
   188 /* */
   189 
   189 
   190 Rkns.Renderer.Node = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
   190 Rkns.Renderer.Node = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
   191 
   191 
   210             new Rkns.Renderer.NodeShrinkButton(this.renderer, null)
   210             new Rkns.Renderer.NodeShrinkButton(this.renderer, null)
   211         ];
   211         ];
   212         this.pending_delete_buttons = [
   212         this.pending_delete_buttons = [
   213             new Rkns.Renderer.NodeRevertButton(this.renderer, null)
   213             new Rkns.Renderer.NodeRevertButton(this.renderer, null)
   214         ];
   214         ];
   215         this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons)
   215         this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);
   216         for (var i = 0; i < this.all_buttons.length; i++) {
   216         for (var i = 0; i < this.all_buttons.length; i++) {
   217             this.all_buttons[i].source_representation = this;
   217             this.all_buttons[i].source_representation = this;
   218         }
   218         }
   219         this.active_buttons = [];
   219         this.active_buttons = [];
   220     } else {
   220     } else {
   226         this.renderer.minimap.node_layer.activate();
   226         this.renderer.minimap.node_layer.activate();
   227         this.minimap_circle = new paper.Path.Circle([0, 0], 1);
   227         this.minimap_circle = new paper.Path.Circle([0, 0], 1);
   228         this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation;
   228         this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation;
   229         this.renderer.minimap.node_group.addChild(this.minimap_circle);
   229         this.renderer.minimap.node_group.addChild(this.minimap_circle);
   230     }
   230     }
   231 }
   231 };
   232 
   232 
   233 Rkns.Renderer.Node.prototype.redraw = function(_dontRedrawEdges) {
   233 Rkns.Renderer.Node.prototype.redraw = function(_dontRedrawEdges) {
   234     var _model_coords = new paper.Point(this.model.get("position")),
   234     var _model_coords = new paper.Point(this.model.get("position")),
   235         _baseRadius = this.options.node_size_base * Math.exp((this.model.get("size") || 0) * Rkns.Renderer._NODE_SIZE_STEP);
   235         _baseRadius = this.options.node_size_base * Math.exp((this.model.get("size") || 0) * Rkns.Renderer._NODE_SIZE_STEP);
   236     if (!this.is_dragging || !this.paper_coords) {
   236     if (!this.is_dragging || !this.paper_coords) {
   292     this.title.text(_text);
   292     this.title.text(_text);
   293     this.title.css({
   293     this.title.css({
   294         left: this.paper_coords.x,
   294         left: this.paper_coords.x,
   295         top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance,
   295         top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance,
   296         opacity: opacity
   296         opacity: opacity
   297     })
   297     });
   298     var _color = this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color");
   298     var _color = this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color");
   299     this.circle.strokeColor = _color;
   299     this.circle.strokeColor = _color;
   300     var _pc = this.paper_coords;
   300     var _pc = this.paper_coords;
   301     this.all_buttons.forEach(function(b) {
   301     this.all_buttons.forEach(function(b) {
   302         b.moveTo(_pc);
   302         b.moveTo(_pc);
   333                 topleft = _this.paper_coords.subtract(square),
   333                 topleft = _this.paper_coords.subtract(square),
   334                 bounds = new paper.Rectangle(topleft, square.multiply(2));
   334                 bounds = new paper.Rectangle(topleft, square.multiply(2));
   335             _this.node_image.fitBounds(bounds);
   335             _this.node_image.fitBounds(bounds);
   336             _this.redraw();
   336             _this.redraw();
   337             paper.view.draw();
   337             paper.view.draw();
   338         }
   338         };
   339         _image.src = _img;
   339         _image.src = _img;
   340     }
   340     }
   341     this.img = _img;
   341     this.img = _img;
   342     if (this.node_image && !this.img) {
   342     if (this.node_image && !this.img) {
   343         this.node_image.remove();
   343         this.node_image.remove();
   359                 repr.redraw();
   359                 repr.redraw();
   360             }
   360             }
   361         }, this);
   361         }, this);
   362     }
   362     }
   363 
   363 
   364 }
   364 };
   365 
   365 
   366 Rkns.Renderer.Node.prototype.paperShift = function(_delta) {
   366 Rkns.Renderer.Node.prototype.paperShift = function(_delta) {
   367     if (this.options.editor_mode) {
   367     if (this.options.editor_mode) {
   368         if (!this.renkan.read_only) {
   368         if (!this.renkan.read_only) {
   369             this.is_dragging = true;
   369             this.is_dragging = true;
   371             this.redraw();
   371             this.redraw();
   372         }
   372         }
   373     } else {
   373     } else {
   374         this.renderer.paperShift(_delta);
   374         this.renderer.paperShift(_delta);
   375     }
   375     }
   376 }
   376 };
   377 
   377 
   378 Rkns.Renderer.Node.prototype.openEditor = function() {
   378 Rkns.Renderer.Node.prototype.openEditor = function() {
   379     this.renderer.removeRepresentationsOfType("editor");
   379     this.renderer.removeRepresentationsOfType("editor");
   380     var _editor = this.renderer.addRepresentation("NodeEditor",null);
   380     var _editor = this.renderer.addRepresentation("NodeEditor",null);
   381     _editor.source_representation = this;
   381     _editor.source_representation = this;
   382     _editor.draw();
   382     _editor.draw();
   383 }
   383 };
   384 
   384 
   385 Rkns.Renderer.Node.prototype.select = function() {
   385 Rkns.Renderer.Node.prototype.select = function() {
   386     this.selected = true;
   386     this.selected = true;
   387     this.circle.strokeWidth = this.options.selected_node_stroke_width;
   387     this.circle.strokeWidth = this.options.selected_node_stroke_width;
   388     if (this.renderer.isEditable()) {
   388     if (this.renderer.isEditable()) {
   406     if (this.renderer.minimap) {
   406     if (this.renderer.minimap) {
   407         this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight;
   407         this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight;
   408         this.minimap_circle.strokeColor = this.options.minimap_highlight_color;
   408         this.minimap_circle.strokeColor = this.options.minimap_highlight_color;
   409     }
   409     }
   410     this.super("select");
   410     this.super("select");
   411 }
   411 };
   412 
   412 
   413 Rkns.Renderer.Node.prototype.unselect = function(_newTarget) {
   413 Rkns.Renderer.Node.prototype.unselect = function(_newTarget) {
   414     if (!_newTarget || _newTarget.source_representation !== this) {
   414     if (!_newTarget || _newTarget.source_representation !== this) {
   415         this.selected = false;
   415         this.selected = false;
   416         this.all_buttons.forEach(function(b) {
   416         this.all_buttons.forEach(function(b) {
   421         if (this.renderer.minimap) {
   421         if (this.renderer.minimap) {
   422             this.minimap_circle.strokeColor = undefined;
   422             this.minimap_circle.strokeColor = undefined;
   423         }
   423         }
   424         this.super("unselect");
   424         this.super("unselect");
   425     }
   425     }
   426 }
   426 };
   427     
   427     
   428 Rkns.Renderer.Node.prototype.highlight = function() {
   428 Rkns.Renderer.Node.prototype.highlight = function() {
   429     if (this.highlighted) {
   429     if (this.highlighted) {
   430         return;
   430         return;
   431     }
   431     }
   432     this.highlighted = true;
   432     this.highlighted = true;
   433     this.redraw();
   433     this.redraw();
   434     this.renderer.throttledPaperDraw();
   434     this.renderer.throttledPaperDraw();
   435 }
   435 };
   436 
   436 
   437 Rkns.Renderer.Node.prototype.unhighlight = function() {
   437 Rkns.Renderer.Node.prototype.unhighlight = function() {
   438     if (!this.highlighted) {
   438     if (!this.highlighted) {
   439         return;
   439         return;
   440     }
   440     }
   441     this.highlighted = false;
   441     this.highlighted = false;
   442     this.redraw();
   442     this.redraw();
   443     this.renderer.throttledPaperDraw();
   443     this.renderer.throttledPaperDraw();
   444 }
   444 };
   445 
   445 
   446 Rkns.Renderer.Node.prototype.saveCoords = function() {
   446 Rkns.Renderer.Node.prototype.saveCoords = function() {
   447     var _coords = this.renderer.toModelCoords(this.paper_coords),
   447     var _coords = this.renderer.toModelCoords(this.paper_coords),
   448         _data = {
   448         _data = {
   449             position: {
   449             position: {
   452             }
   452             }
   453         };
   453         };
   454     if (this.renderer.isEditable()) {
   454     if (this.renderer.isEditable()) {
   455         this.model.set(_data);
   455         this.model.set(_data);
   456     }
   456     }
   457 }
   457 };
   458 
   458 
   459 Rkns.Renderer.Node.prototype.mousedown = function(_event, _isTouch) {
   459 Rkns.Renderer.Node.prototype.mousedown = function(_event, _isTouch) {
   460     if (_isTouch) {
   460     if (_isTouch) {
   461         this.renderer.unselectAll();
   461         this.renderer.unselectAll();
   462         this.select();
   462         this.select();
   463     }
   463     }
   464 }
   464 };
   465 
   465 
   466 Rkns.Renderer.Node.prototype.mouseup = function(_event, _isTouch) {
   466 Rkns.Renderer.Node.prototype.mouseup = function(_event, _isTouch) {
   467     if (this.renderer.is_dragging && this.renderer.isEditable()) {
   467     if (this.renderer.is_dragging && this.renderer.isEditable()) {
   468         this.saveCoords();
   468         this.saveCoords();
   469     } else {
   469     } else {
   473         this.model.trigger("clicked");
   473         this.model.trigger("clicked");
   474     }
   474     }
   475     this.renderer.click_target = null;
   475     this.renderer.click_target = null;
   476     this.renderer.is_dragging = false;
   476     this.renderer.is_dragging = false;
   477     this.is_dragging = false;
   477     this.is_dragging = false;
   478 }
   478 };
   479 
   479 
   480 Rkns.Renderer.Node.prototype.destroy = function(_event) {
   480 Rkns.Renderer.Node.prototype.destroy = function(_event) {
   481     this.super("destroy");
   481     this.super("destroy");
   482     this.all_buttons.forEach(function(b) {
   482     this.all_buttons.forEach(function(b) {
   483         b.destroy();
   483         b.destroy();
   488         this.minimap_circle.remove();
   488         this.minimap_circle.remove();
   489     }
   489     }
   490     if (this.node_image) {
   490     if (this.node_image) {
   491         this.node_image.remove();
   491         this.node_image.remove();
   492     }
   492     }
   493 }
   493 };
   494 
   494 
   495 /* */
   495 /* */
   496 
   496 
   497 Rkns.Renderer.Edge = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
   497 Rkns.Renderer.Edge = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
   498 
   498 
   521             new Rkns.Renderer.EdgeRemoveButton(this.renderer, null),
   521             new Rkns.Renderer.EdgeRemoveButton(this.renderer, null),
   522         ];
   522         ];
   523         this.pending_delete_buttons = [
   523         this.pending_delete_buttons = [
   524             new Rkns.Renderer.EdgeRevertButton(this.renderer, null)
   524             new Rkns.Renderer.EdgeRevertButton(this.renderer, null)
   525         ];
   525         ];
   526         this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons)
   526         this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);
   527         for (var i = 0; i < this.all_buttons.length; i++) {
   527         for (var i = 0; i < this.all_buttons.length; i++) {
   528             this.all_buttons[i].source_representation = this;
   528             this.all_buttons[i].source_representation = this;
   529         }
   529         }
   530         this.active_buttons = [];
   530         this.active_buttons = [];
   531     } else {
   531     } else {
   537         this.minimap_line = new paper.Path();
   537         this.minimap_line = new paper.Path();
   538         this.minimap_line.add([0,0],[0,0]);
   538         this.minimap_line.add([0,0],[0,0]);
   539         this.minimap_line.__representation = this.renderer.minimap.miniframe.__representation;
   539         this.minimap_line.__representation = this.renderer.minimap.miniframe.__representation;
   540         this.minimap_line.strokeWidth = 1;
   540         this.minimap_line.strokeWidth = 1;
   541     }
   541     }
   542 }
   542 };
   543 
   543 
   544 Rkns.Renderer.Edge.prototype.redraw = function() {
   544 Rkns.Renderer.Edge.prototype.redraw = function() {
   545     this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from"));
   545     this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from"));
   546     this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to"));
   546     this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to"));
   547     if (!this.from_representation || !this.to_representation) {
   547     if (!this.from_representation || !this.to_representation) {
   626     if (this.renderer.minimap) {
   626     if (this.renderer.minimap) {
   627         this.minimap_line.strokeColor = _color;
   627         this.minimap_line.strokeColor = _color;
   628         this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position")));
   628         this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position")));
   629          this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position")));
   629          this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position")));
   630     }
   630     }
   631 }
   631 };
   632 
   632 
   633 Rkns.Renderer.Edge.prototype.openEditor = function() {
   633 Rkns.Renderer.Edge.prototype.openEditor = function() {
   634     this.renderer.removeRepresentationsOfType("editor");
   634     this.renderer.removeRepresentationsOfType("editor");
   635     var _editor = this.renderer.addRepresentation("EdgeEditor",null);
   635     var _editor = this.renderer.addRepresentation("EdgeEditor",null);
   636     _editor.source_representation = this;
   636     _editor.source_representation = this;
   637     _editor.draw();
   637     _editor.draw();
   638 }
   638 };
   639 
   639 
   640 Rkns.Renderer.Edge.prototype.select = function() {
   640 Rkns.Renderer.Edge.prototype.select = function() {
   641     this.selected = true;
   641     this.selected = true;
   642     this.line.strokeWidth = this.options.selected_edge_stroke_width;
   642     this.line.strokeWidth = this.options.selected_edge_stroke_width;
   643     if (this.renderer.isEditable()) {
   643     if (this.renderer.isEditable()) {
   647     }
   647     }
   648     if (!this.options.editor_mode) {
   648     if (!this.options.editor_mode) {
   649         this.openEditor();
   649         this.openEditor();
   650     }
   650     }
   651     this.super("select");
   651     this.super("select");
   652 }
   652 };
   653 
   653 
   654 Rkns.Renderer.Edge.prototype.unselect = function(_newTarget) {
   654 Rkns.Renderer.Edge.prototype.unselect = function(_newTarget) {
   655     if (!_newTarget || _newTarget.source_representation !== this) {
   655     if (!_newTarget || _newTarget.source_representation !== this) {
   656         this.selected = false;
   656         this.selected = false;
   657         if (this.options.editor_mode) {
   657         if (this.options.editor_mode) {
   660             });
   660             });
   661         }
   661         }
   662         this.line.strokeWidth = this.options.edge_stroke_width;
   662         this.line.strokeWidth = this.options.edge_stroke_width;
   663         this.super("unselect");
   663         this.super("unselect");
   664     }
   664     }
   665 }
   665 };
   666 
   666 
   667 Rkns.Renderer.Edge.prototype.mousedown = function(_event, _isTouch) {
   667 Rkns.Renderer.Edge.prototype.mousedown = function(_event, _isTouch) {
   668     if (_isTouch) {
   668     if (_isTouch) {
   669         this.renderer.unselectAll();
   669         this.renderer.unselectAll();
   670         this.select();
   670         this.select();
   671     }
   671     }
   672 }
   672 };
   673 
   673 
   674 Rkns.Renderer.Edge.prototype.mouseup = function(_event, _isTouch) {
   674 Rkns.Renderer.Edge.prototype.mouseup = function(_event, _isTouch) {
   675     if (!this.renkan.read_only && this.renderer.is_dragging) {
   675     if (!this.renkan.read_only && this.renderer.is_dragging) {
   676         this.from_representation.saveCoords();
   676         this.from_representation.saveCoords();
   677         this.to_representation.saveCoords();
   677         this.to_representation.saveCoords();
   683         }
   683         }
   684         this.model.trigger("clicked");
   684         this.model.trigger("clicked");
   685     }
   685     }
   686     this.renderer.click_target = null;
   686     this.renderer.click_target = null;
   687     this.renderer.is_dragging = false;
   687     this.renderer.is_dragging = false;
   688 }
   688 };
   689 
   689 
   690 Rkns.Renderer.Edge.prototype.paperShift = function(_delta) {
   690 Rkns.Renderer.Edge.prototype.paperShift = function(_delta) {
   691     if (this.options.editor_mode) {
   691     if (this.options.editor_mode) {
   692         if (!this.options.read_only) {
   692         if (!this.options.read_only) {
   693             this.from_representation.paperShift(_delta);
   693             this.from_representation.paperShift(_delta);
   694             this.to_representation.paperShift(_delta);
   694             this.to_representation.paperShift(_delta);
   695         }
   695         }
   696     } else {
   696     } else {
   697         this.renderer.paperShift(_delta);
   697         this.renderer.paperShift(_delta);
   698     }
   698     }
   699 }
   699 };
   700 
   700 
   701 Rkns.Renderer.Edge.prototype.destroy = function() {
   701 Rkns.Renderer.Edge.prototype.destroy = function() {
   702     this.super("destroy");
   702     this.super("destroy");
   703     this.line.remove();
   703     this.line.remove();
   704     this.arrow.remove();
   704     this.arrow.remove();
   711     });
   711     });
   712     var _this = this;
   712     var _this = this;
   713     this.bundle.edges = Rkns._(this.bundle.edges).reject(function(_edge) {
   713     this.bundle.edges = Rkns._(this.bundle.edges).reject(function(_edge) {
   714         return _edge === _this;
   714         return _edge === _this;
   715     });
   715     });
   716 }
   716 };
   717 
   717 
   718 /* */
   718 /* */
   719 
   719 
   720 Rkns.Renderer.TempEdge = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
   720 Rkns.Renderer.TempEdge = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
   721 
   721 
   737         [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],
   737         [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],
   738         [ 0, this.options.edge_arrow_width ]
   738         [ 0, this.options.edge_arrow_width ]
   739     );
   739     );
   740     this.arrow.__representation = this;
   740     this.arrow.__representation = this;
   741     this.arrow_angle = 0;
   741     this.arrow_angle = 0;
   742 }
   742 };
   743 
   743 
   744 Rkns.Renderer.TempEdge.prototype.redraw = function() {
   744 Rkns.Renderer.TempEdge.prototype.redraw = function() {
   745     var _p0 = this.from_representation.paper_coords,
   745     var _p0 = this.from_representation.paper_coords,
   746         _p1 = this.end_pos,
   746         _p1 = this.end_pos,
   747         _a = _p1.subtract(_p0).angle,
   747         _a = _p1.subtract(_p0).angle,
   749     this.line.segments[0].point = _p0;
   749     this.line.segments[0].point = _p0;
   750     this.line.segments[1].point = _p1;
   750     this.line.segments[1].point = _p1;
   751     this.arrow.rotate(_a - this.arrow_angle);
   751     this.arrow.rotate(_a - this.arrow_angle);
   752     this.arrow.position = _c;
   752     this.arrow.position = _c;
   753     this.arrow_angle = _a;
   753     this.arrow_angle = _a;
   754 }
   754 };
   755 
   755 
   756 Rkns.Renderer.TempEdge.prototype.paperShift = function(_delta) {
   756 Rkns.Renderer.TempEdge.prototype.paperShift = function(_delta) {
   757     if (!this.renderer.isEditable()) {
   757     if (!this.renderer.isEditable()) {
   758         this.renderer.removeRepresentation(_this);
   758         this.renderer.removeRepresentation(_this);
   759         paper.view.draw();
   759         paper.view.draw();
   761     }
   761     }
   762     this.end_pos = this.end_pos.add(_delta);
   762     this.end_pos = this.end_pos.add(_delta);
   763     var _hitResult = paper.project.hitTest(this.end_pos);
   763     var _hitResult = paper.project.hitTest(this.end_pos);
   764     this.renderer.findTarget(_hitResult);
   764     this.renderer.findTarget(_hitResult);
   765     this.redraw();
   765     this.redraw();
   766 }
   766 };
   767 
   767 
   768 Rkns.Renderer.TempEdge.prototype.mouseup = function(_event, _isTouch) {
   768 Rkns.Renderer.TempEdge.prototype.mouseup = function(_event, _isTouch) {
   769     var _hitResult = paper.project.hitTest(_event.point),
   769     var _hitResult = paper.project.hitTest(_event.point),
   770         _model = this.from_representation.model,
   770         _model = this.from_representation.model,
   771         _endDrag = true;
   771         _endDrag = true;
   795         this.renderer.click_target = null;
   795         this.renderer.click_target = null;
   796         this.renderer.is_dragging = false;
   796         this.renderer.is_dragging = false;
   797         this.renderer.removeRepresentation(this);
   797         this.renderer.removeRepresentation(this);
   798         paper.view.draw();
   798         paper.view.draw();
   799     }
   799     }
   800 }
   800 };
   801 
   801 
   802 Rkns.Renderer.TempEdge.prototype.destroy = function() {
   802 Rkns.Renderer.TempEdge.prototype.destroy = function() {
   803     this.arrow.remove();
   803     this.arrow.remove();
   804     this.line.remove();
   804     this.line.remove();
   805 }
   805 };
   806 
   806 
   807 /* */
   807 /* */
   808 
   808 
   809 Rkns.Renderer._BaseEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
   809 Rkns.Renderer._BaseEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
   810 
   810 
   811 Rkns.Renderer._BaseEditor.prototype._init = function() {
   811 Rkns.Renderer._BaseEditor.prototype._init = function() {
   812     this.renderer.buttons_layer.activate();
   812     this.renderer.buttons_layer.activate();
   813     this.type = "editor";
   813     this.type = "editor";
   814     this.editor_block = new paper.Path();
   814     this.editor_block = new paper.Path();
   815     var _pts = Rkns._(Rkns._.range(8)).map(function() {return [0,0]});
   815     var _pts = Rkns._(Rkns._.range(8)).map(function() {return [0,0];});
   816     this.editor_block.add.apply(this.editor_block, _pts);
   816     this.editor_block.add.apply(this.editor_block, _pts);
   817     this.editor_block.strokeWidth = this.options.tooltip_border_width;
   817     this.editor_block.strokeWidth = this.options.tooltip_border_width;
   818     this.editor_block.strokeColor = this.options.tooltip_border_color;
   818     this.editor_block.strokeColor = this.options.tooltip_border_color;
   819     this.editor_block.opacity = .8;
   819     this.editor_block.opacity = .8;
   820     this.editor_$ = Rkns.$('<div>')
   820     this.editor_$ = Rkns.$('<div>')
   822         .css({
   822         .css({
   823             position: "absolute",
   823             position: "absolute",
   824             opacity: .8
   824             opacity: .8
   825         })
   825         })
   826         .hide();
   826         .hide();
   827 }
   827 };
   828 
   828 
   829 Rkns.Renderer._BaseEditor.prototype.destroy = function() {
   829 Rkns.Renderer._BaseEditor.prototype.destroy = function() {
   830     this.editor_block.remove();
   830     this.editor_block.remove();
   831     this.editor_$.remove();
   831     this.editor_$.remove();
   832 }
   832 };
   833 
   833 
   834 /* */
   834 /* */
   835 
   835 
   836 Rkns.Renderer.NodeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseEditor);
   836 Rkns.Renderer.NodeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseEditor);
   837 
   837 
   884     this.redraw();
   884     this.redraw();
   885     var _this = this,
   885     var _this = this,
   886         closeEditor = function() {
   886         closeEditor = function() {
   887             _this.renderer.removeRepresentation(_this);
   887             _this.renderer.removeRepresentation(_this);
   888             paper.view.draw();
   888             paper.view.draw();
   889         }
   889         };
   890         
   890         
   891     this.editor_$.find(".Rk-CloseX").click(closeEditor);
   891     this.editor_$.find(".Rk-CloseX").click(closeEditor);
   892     
   892     
   893     if (this.renderer.isEditable()) {
   893     if (this.renderer.isEditable()) {
   894         
   894         
   902                     var _data = {
   902                     var _data = {
   903                         title: _this.editor_$.find(".Rk-Edit-Title").val(),
   903                         title: _this.editor_$.find(".Rk-Edit-Title").val(),
   904                         description: _this.editor_$.find(".Rk-Edit-Description").val(),
   904                         description: _this.editor_$.find(".Rk-Edit-Description").val(),
   905                         uri: _uri,
   905                         uri: _uri,
   906                         image: _image
   906                         image: _image
   907                     }
   907                     };
   908                     _model.set(_data);
   908                     _model.set(_data);
   909                     _this.redraw();
   909                     _this.redraw();
   910                 } else {
   910                 } else {
   911                     closeEditor();
   911                     closeEditor();
   912                 }
   912                 }
   935                     return;
   935                     return;
   936                 }
   936                 }
   937                 fr.onload = function(e) {
   937                 fr.onload = function(e) {
   938                     _this.editor_$.find(".Rk-Edit-Image").val(e.target.result);
   938                     _this.editor_$.find(".Rk-Edit-Image").val(e.target.result);
   939                     onFieldChange();
   939                     onFieldChange();
   940                 }
   940                 };
   941                 fr.readAsDataURL(f);
   941                 fr.readAsDataURL(f);
   942             }
   942             }
   943         });
   943         });
   944         this.editor_$.find(".Rk-Edit-Title")[0].focus();
   944         this.editor_$.find(".Rk-Edit-Title")[0].focus();
   945         
   945         
   961                 _e.preventDefault();
   961                 _e.preventDefault();
   962                 _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
   962                 _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
   963             },
   963             },
   964             function(_e) {
   964             function(_e) {
   965                 _e.preventDefault();
   965                 _e.preventDefault();
   966                 _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(_this.renkan)).get("color"))
   966                 _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(_this.renkan)).get("color"));
   967             }
   967             }
   968         ).click(function(_e) {
   968         ).click(function(_e) {
   969             _e.preventDefault();
   969             _e.preventDefault();
   970             if (_this.renderer.isEditable()) {
   970             if (_this.renderer.isEditable()) {
   971                 _model.set("color", $(this).attr("data-color"));
   971                 _model.set("color", $(this).attr("data-color"));
   997         });
   997         });
   998     }
   998     }
   999     this.editor_$.find("img").load(function() {
   999     this.editor_$.find("img").load(function() {
  1000         _this.redraw();
  1000         _this.redraw();
  1001     });
  1001     });
  1002 }
  1002 };
  1003 
  1003 
  1004 Rkns.Renderer.NodeEditor.prototype.redraw = function() {
  1004 Rkns.Renderer.NodeEditor.prototype.redraw = function() {
  1005     var _coords = this.source_representation.paper_coords;
  1005     var _coords = this.source_representation.paper_coords;
  1006     Rkns.Renderer.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * .75, this.editor_$);
  1006     Rkns.Renderer.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * .75, this.editor_$);
  1007     this.editor_$.show();
  1007     this.editor_$.show();
  1008     paper.view.draw();
  1008     paper.view.draw();
  1009 }
  1009 };
  1010 
  1010 
  1011 /* */
  1011 /* */
  1012 
  1012 
  1013 Rkns.Renderer.EdgeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseEditor);
  1013 Rkns.Renderer.EdgeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseEditor);
  1014 
  1014 
  1067     this.redraw();
  1067     this.redraw();
  1068     var _this = this,
  1068     var _this = this,
  1069         closeEditor = function() {
  1069         closeEditor = function() {
  1070             _this.renderer.removeRepresentation(_this);
  1070             _this.renderer.removeRepresentation(_this);
  1071             paper.view.draw();
  1071             paper.view.draw();
  1072         }
  1072         };
  1073     this.editor_$.find(".Rk-CloseX").click(closeEditor);
  1073     this.editor_$.find(".Rk-CloseX").click(closeEditor);
  1074     
  1074     
  1075     if (this.renderer.isEditable()) {
  1075     if (this.renderer.isEditable()) {
  1076         
  1076         
  1077         var onFieldChange = Rkns._(function() {
  1077         var onFieldChange = Rkns._(function() {
  1079                 if (_this.renderer.isEditable()) {
  1079                 if (_this.renderer.isEditable()) {
  1080                     _this.editor_$.find(".Rk-Edit-Goto").attr("href",_this.editor_$.find(".Rk-Edit-URI").val());
  1080                     _this.editor_$.find(".Rk-Edit-Goto").attr("href",_this.editor_$.find(".Rk-Edit-URI").val());
  1081                     var _data = {
  1081                     var _data = {
  1082                         title: _this.editor_$.find(".Rk-Edit-Title").val(),
  1082                         title: _this.editor_$.find(".Rk-Edit-Title").val(),
  1083                         uri: _this.editor_$.find(".Rk-Edit-URI").val()
  1083                         uri: _this.editor_$.find(".Rk-Edit-URI").val()
  1084                     }
  1084                     };
  1085                     _model.set(_data);
  1085                     _model.set(_data);
  1086                     paper.view.draw();
  1086                     paper.view.draw();
  1087                 } else {
  1087                 } else {
  1088                     closeEditor();
  1088                     closeEditor();
  1089                 }
  1089                 }
  1137                 _e.preventDefault();
  1137                 _e.preventDefault();
  1138                 _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
  1138                 _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
  1139             },
  1139             },
  1140             function(_e) {
  1140             function(_e) {
  1141                 _e.preventDefault();
  1141                 _e.preventDefault();
  1142                 _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(_this.renkan)).get("color"))
  1142                 _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(_this.renkan)).get("color"));
  1143             }
  1143             }
  1144         ).click(function(_e) {
  1144         ).click(function(_e) {
  1145             _e.preventDefault();
  1145             _e.preventDefault();
  1146             if (_this.renderer.isEditable()) {
  1146             if (_this.renderer.isEditable()) {
  1147                 _model.set("color", $(this).attr("data-color"));
  1147                 _model.set("color", $(this).attr("data-color"));
  1150             } else {
  1150             } else {
  1151                 closeEditor();
  1151                 closeEditor();
  1152             }
  1152             }
  1153         });
  1153         });
  1154     }
  1154     }
  1155 }
  1155 };
  1156 
  1156 
  1157 Rkns.Renderer.EdgeEditor.prototype.redraw = function() {
  1157 Rkns.Renderer.EdgeEditor.prototype.redraw = function() {
  1158     var _coords = this.source_representation.paper_coords;
  1158     var _coords = this.source_representation.paper_coords;
  1159     Rkns.Renderer.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$);
  1159     Rkns.Renderer.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$);
  1160     this.editor_$.show();
  1160     this.editor_$.show();
  1161     paper.view.draw();
  1161     paper.view.draw();
  1162 }
  1162 };
  1163 
  1163 
  1164 /* */
  1164 /* */
  1165 
  1165 
  1166 Rkns.Renderer._NodeButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton);
  1166 Rkns.Renderer._NodeButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton);
  1167 
  1167 
  1180             this.imageName,
  1180             this.imageName,
  1181             this.renkan.translate(this.text)
  1181             this.renkan.translate(this.text)
  1182         );
  1182         );
  1183         this.lastSectorInner = sectorInner;
  1183         this.lastSectorInner = sectorInner;
  1184     }
  1184     }
  1185 }
  1185 };
  1186 
  1186 
  1187 /* */
  1187 /* */
  1188 
  1188 
  1189 Rkns.Renderer.NodeEditButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
  1189 Rkns.Renderer.NodeEditButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
  1190 
  1190 
  1193     this.lastSectorInner = 0;
  1193     this.lastSectorInner = 0;
  1194     this.startAngle = -135;
  1194     this.startAngle = -135;
  1195     this.endAngle = -45;
  1195     this.endAngle = -45;
  1196     this.imageName = "edit";
  1196     this.imageName = "edit";
  1197     this.text = "Edit";
  1197     this.text = "Edit";
  1198 }
  1198 };
  1199 
  1199 
  1200 Rkns.Renderer.NodeEditButton.prototype.mouseup = function() {
  1200 Rkns.Renderer.NodeEditButton.prototype.mouseup = function() {
  1201     if (!this.renderer.is_dragging) {
  1201     if (!this.renderer.is_dragging) {
  1202         this.source_representation.openEditor();
  1202         this.source_representation.openEditor();
  1203     }
  1203     }
  1204 }
  1204 };
  1205 
  1205 
  1206 /* */
  1206 /* */
  1207 
  1207 
  1208 Rkns.Renderer.NodeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
  1208 Rkns.Renderer.NodeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
  1209 
  1209 
  1212     this.lastSectorInner = 0;
  1212     this.lastSectorInner = 0;
  1213     this.startAngle = 0;
  1213     this.startAngle = 0;
  1214     this.endAngle = 90;
  1214     this.endAngle = 90;
  1215     this.imageName = "remove";
  1215     this.imageName = "remove";
  1216     this.text = "Remove";
  1216     this.text = "Remove";
  1217 }
  1217 };
  1218 
  1218 
  1219 Rkns.Renderer.NodeRemoveButton.prototype.mouseup = function() {
  1219 Rkns.Renderer.NodeRemoveButton.prototype.mouseup = function() {
  1220     this.renderer.click_target = null;
  1220     this.renderer.click_target = null;
  1221     this.renderer.is_dragging = false;
  1221     this.renderer.is_dragging = false;
  1222     this.renderer.removeRepresentationsOfType("editor");
  1222     this.renderer.removeRepresentationsOfType("editor");
  1226             id: delid,
  1226             id: delid,
  1227             time: new Date().valueOf() + this.options.element_delete_delay
  1227             time: new Date().valueOf() + this.options.element_delete_delay
  1228         });
  1228         });
  1229         this.source_representation.model.set("delete_scheduled", delid);
  1229         this.source_representation.model.set("delete_scheduled", delid);
  1230     }
  1230     }
  1231 }
  1231 };
  1232 
  1232 
  1233 /* */
  1233 /* */
  1234 
  1234 
  1235 Rkns.Renderer.NodeRevertButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
  1235 Rkns.Renderer.NodeRevertButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
  1236 
  1236 
  1239     this.lastSectorInner = 0;
  1239     this.lastSectorInner = 0;
  1240     this.startAngle = -135;
  1240     this.startAngle = -135;
  1241     this.endAngle = 135;
  1241     this.endAngle = 135;
  1242     this.imageName = "revert";
  1242     this.imageName = "revert";
  1243     this.text = "Cancel deletion";
  1243     this.text = "Cancel deletion";
  1244 }
  1244 };
  1245 
  1245 
  1246 Rkns.Renderer.NodeRevertButton.prototype.mouseup = function() {
  1246 Rkns.Renderer.NodeRevertButton.prototype.mouseup = function() {
  1247     this.renderer.click_target = null;
  1247     this.renderer.click_target = null;
  1248     this.renderer.is_dragging = false;
  1248     this.renderer.is_dragging = false;
  1249     if (this.renderer.isEditable()) {
  1249     if (this.renderer.isEditable()) {
  1250         this.source_representation.model.unset("delete_scheduled");
  1250         this.source_representation.model.unset("delete_scheduled");
  1251     }
  1251     }
  1252 }
  1252 };
  1253 
  1253 
  1254 /* */
  1254 /* */
  1255 
  1255 
  1256 Rkns.Renderer.NodeLinkButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
  1256 Rkns.Renderer.NodeLinkButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
  1257 
  1257 
  1260     this.lastSectorInner = 0;
  1260     this.lastSectorInner = 0;
  1261     this.startAngle = 90;
  1261     this.startAngle = 90;
  1262     this.endAngle = 180;
  1262     this.endAngle = 180;
  1263     this.imageName = "link";
  1263     this.imageName = "link";
  1264     this.text = "Link to another node";
  1264     this.text = "Link to another node";
  1265 }
  1265 };
  1266 
  1266 
  1267 Rkns.Renderer.NodeLinkButton.prototype.mousedown = function(_event, _isTouch) {
  1267 Rkns.Renderer.NodeLinkButton.prototype.mousedown = function(_event, _isTouch) {
  1268     if (this.renderer.isEditable()) {
  1268     if (this.renderer.isEditable()) {
  1269         var _off = this.renderer.canvas_$.offset(),
  1269         var _off = this.renderer.canvas_$.offset(),
  1270             _point = new paper.Point([
  1270             _point = new paper.Point([
  1273             ]);
  1273             ]);
  1274         this.renderer.click_target = null;
  1274         this.renderer.click_target = null;
  1275         this.renderer.removeRepresentationsOfType("editor");
  1275         this.renderer.removeRepresentationsOfType("editor");
  1276         this.renderer.addTempEdge(this.source_representation, _point);
  1276         this.renderer.addTempEdge(this.source_representation, _point);
  1277     }
  1277     }
  1278 }
  1278 };
  1279 
  1279 
  1280 /* */
  1280 /* */
  1281 
  1281 
  1282 Rkns.Renderer.NodeEnlargeButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
  1282 Rkns.Renderer.NodeEnlargeButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
  1283 
  1283 
  1286     this.lastSectorInner = 0;
  1286     this.lastSectorInner = 0;
  1287     this.startAngle = -45;
  1287     this.startAngle = -45;
  1288     this.endAngle = 0;
  1288     this.endAngle = 0;
  1289     this.imageName = "enlarge";
  1289     this.imageName = "enlarge";
  1290     this.text = "Enlarge";
  1290     this.text = "Enlarge";
  1291 }
  1291 };
  1292 
  1292 
  1293 Rkns.Renderer.NodeEnlargeButton.prototype.mouseup = function() {
  1293 Rkns.Renderer.NodeEnlargeButton.prototype.mouseup = function() {
  1294     var _newsize = 1 + (this.source_representation.model.get("size") || 0);
  1294     var _newsize = 1 + (this.source_representation.model.get("size") || 0);
  1295     this.source_representation.model.set("size", _newsize);
  1295     this.source_representation.model.set("size", _newsize);
  1296     this.source_representation.select();
  1296     this.source_representation.select();
  1297     this.select();
  1297     this.select();
  1298     paper.view.draw();
  1298     paper.view.draw();
  1299 }
  1299 };
  1300 
  1300 
  1301 /* */
  1301 /* */
  1302 
  1302 
  1303 Rkns.Renderer.NodeShrinkButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
  1303 Rkns.Renderer.NodeShrinkButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton);
  1304 
  1304 
  1307     this.lastSectorInner = 0;
  1307     this.lastSectorInner = 0;
  1308     this.startAngle = -180;
  1308     this.startAngle = -180;
  1309     this.endAngle = -135;
  1309     this.endAngle = -135;
  1310     this.imageName = "shrink";
  1310     this.imageName = "shrink";
  1311     this.text = "Shrink";
  1311     this.text = "Shrink";
  1312 }
  1312 };
  1313 
  1313 
  1314 Rkns.Renderer.NodeShrinkButton.prototype.mouseup = function() {
  1314 Rkns.Renderer.NodeShrinkButton.prototype.mouseup = function() {
  1315     var _newsize = -1 + (this.source_representation.model.get("size") || 0);
  1315     var _newsize = -1 + (this.source_representation.model.get("size") || 0);
  1316     this.source_representation.model.set("size", _newsize);
  1316     this.source_representation.model.set("size", _newsize);
  1317     this.source_representation.select();
  1317     this.source_representation.select();
  1318     this.select();
  1318     this.select();
  1319     paper.view.draw();
  1319     paper.view.draw();
  1320 }
  1320 };
  1321 
  1321 
  1322 /* */
  1322 /* */
  1323 
  1323 
  1324 Rkns.Renderer.EdgeEditButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton);
  1324 Rkns.Renderer.EdgeEditButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton);
  1325 
  1325 
  1326 Rkns.Renderer.EdgeEditButton.prototype._init = function() {
  1326 Rkns.Renderer.EdgeEditButton.prototype._init = function() {
  1327     this.type = "Edge-edit-button";
  1327     this.type = "Edge-edit-button";
  1328     this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -270, -90, 1, "edit", this.renkan.translate("Edit"));
  1328     this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -270, -90, 1, "edit", this.renkan.translate("Edit"));
  1329 }
  1329 };
  1330 
  1330 
  1331 Rkns.Renderer.EdgeEditButton.prototype.mouseup = function() {
  1331 Rkns.Renderer.EdgeEditButton.prototype.mouseup = function() {
  1332     if (!this.renderer.is_dragging) {
  1332     if (!this.renderer.is_dragging) {
  1333         this.source_representation.openEditor();
  1333         this.source_representation.openEditor();
  1334     }
  1334     }
  1335 }
  1335 };
  1336 
  1336 
  1337 /* */
  1337 /* */
  1338 
  1338 
  1339 Rkns.Renderer.EdgeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton);
  1339 Rkns.Renderer.EdgeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton);
  1340 
  1340 
  1341 Rkns.Renderer.EdgeRemoveButton.prototype._init = function() {
  1341 Rkns.Renderer.EdgeRemoveButton.prototype._init = function() {
  1342     this.type = "Edge-remove-button";
  1342     this.type = "Edge-remove-button";
  1343     this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -90, 90, 1, "remove", this.renkan.translate("Remove"));
  1343     this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -90, 90, 1, "remove", this.renkan.translate("Remove"));
  1344 }
  1344 };
  1345 
  1345 
  1346 Rkns.Renderer.EdgeRemoveButton.prototype.mouseup = function() {
  1346 Rkns.Renderer.EdgeRemoveButton.prototype.mouseup = function() {
  1347     this.renderer.click_target = null;
  1347     this.renderer.click_target = null;
  1348     this.renderer.is_dragging = false;
  1348     this.renderer.is_dragging = false;
  1349     this.renderer.removeRepresentationsOfType("editor");
  1349     this.renderer.removeRepresentationsOfType("editor");
  1353             id: delid,
  1353             id: delid,
  1354             time: new Date().valueOf() + this.options.element_delete_delay
  1354             time: new Date().valueOf() + this.options.element_delete_delay
  1355         });
  1355         });
  1356         this.source_representation.model.set("delete_scheduled", delid);
  1356         this.source_representation.model.set("delete_scheduled", delid);
  1357     }
  1357     }
  1358 }
  1358 };
  1359 
  1359 
  1360 /* */
  1360 /* */
  1361 
  1361 
  1362 Rkns.Renderer.EdgeRevertButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton);
  1362 Rkns.Renderer.EdgeRevertButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton);
  1363 
  1363 
  1364 Rkns.Renderer.EdgeRevertButton.prototype._init = function() {
  1364 Rkns.Renderer.EdgeRevertButton.prototype._init = function() {
  1365     this.type = "Edge-revert-button";
  1365     this.type = "Edge-revert-button";
  1366     this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -135, 135, 1, "revert", this.renkan.translate("Cancel deletion"));
  1366     this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -135, 135, 1, "revert", this.renkan.translate("Cancel deletion"));
  1367 }
  1367 };
  1368 
  1368 
  1369 Rkns.Renderer.EdgeRevertButton.prototype.mouseup = function() {
  1369 Rkns.Renderer.EdgeRevertButton.prototype.mouseup = function() {
  1370     this.renderer.click_target = null;
  1370     this.renderer.click_target = null;
  1371     this.renderer.is_dragging = false;
  1371     this.renderer.is_dragging = false;
  1372     if (this.renderer.isEditable()) {
  1372     if (this.renderer.isEditable()) {
  1373         this.source_representation.model.unset("delete_scheduled");
  1373         this.source_representation.model.unset("delete_scheduled");
  1374     }
  1374     }
  1375 }
  1375 };
  1376 
  1376 
  1377 /* */
  1377 /* */
  1378 
  1378 
  1379 Rkns.Renderer.MiniFrame = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
  1379 Rkns.Renderer.MiniFrame = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation);
  1380 
  1380 
  1381 Rkns.Renderer.MiniFrame.prototype.paperShift = function(_delta) {
  1381 Rkns.Renderer.MiniFrame.prototype.paperShift = function(_delta) {
  1382     this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale));
  1382     this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale));
  1383     this.renderer.redraw();
  1383     this.renderer.redraw();
  1384 }
  1384 };
  1385 
  1385 
  1386 Rkns.Renderer.MiniFrame.prototype.mouseup = function(_delta) {
  1386 Rkns.Renderer.MiniFrame.prototype.mouseup = function(_delta) {
  1387     this.renderer.click_target = null;
  1387     this.renderer.click_target = null;
  1388     this.renderer.is_dragging = false;
  1388     this.renderer.is_dragging = false;
  1389 }
  1389 };
  1390 
  1390 
  1391 /* */
  1391 /* */
  1392 
  1392 
  1393 Rkns.Renderer.Scene = function(_renkan) {
  1393 Rkns.Renderer.Scene = function(_renkan) {
  1394     this.renkan = _renkan;
  1394     this.renkan = _renkan;
  1417             background_layer: new paper.Layer(),
  1417             background_layer: new paper.Layer(),
  1418             edge_layer: new paper.Layer(),
  1418             edge_layer: new paper.Layer(),
  1419             node_layer: new paper.Layer(),
  1419             node_layer: new paper.Layer(),
  1420             node_group: new paper.Group(),
  1420             node_group: new paper.Group(),
  1421             size: new paper.Size( _renkan.options.minimap_width, _renkan.options.minimap_height )
  1421             size: new paper.Size( _renkan.options.minimap_width, _renkan.options.minimap_height )
  1422         }
  1422         };
  1423         
  1423         
  1424         this.minimap.background_layer.activate();
  1424         this.minimap.background_layer.activate();
  1425         this.minimap.topleft = paper.view.bounds.bottomRight.subtract(this.minimap.size);
  1425         this.minimap.topleft = paper.view.bounds.bottomRight.subtract(this.minimap.size);
  1426         this.minimap.rectangle = new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]), this.minimap.size.add([4,4]));
  1426         this.minimap.rectangle = new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]), this.minimap.size.add([4,4]));
  1427         this.minimap.rectangle.fillColor = _renkan.options.minimap_background_color;
  1427         this.minimap.rectangle.fillColor = _renkan.options.minimap_background_color;
  1616                 _this.canvas_$.height()
  1616                 _this.canvas_$.height()
  1617             ]).multiply( .5 * ( 1 - Math.SQRT2 ) ).add(_this.offset.multiply( Math.SQRT2 ));
  1617             ]).multiply( .5 * ( 1 - Math.SQRT2 ) ).add(_this.offset.multiply( Math.SQRT2 ));
  1618         _this.setScale( _newScale, _offset );
  1618         _this.setScale( _newScale, _offset );
  1619     });
  1619     });
  1620     this.$.find(".Rk-CurrentUser").mouseenter(
  1620     this.$.find(".Rk-CurrentUser").mouseenter(
  1621         function() { _this.$.find(".Rk-UserList").slideDown() }
  1621         function() { _this.$.find(".Rk-UserList").slideDown(); }
  1622     );
  1622     );
  1623     this.$.find(".Rk-Users").mouseleave(
  1623     this.$.find(".Rk-Users").mouseleave(
  1624         function() { _this.$.find(".Rk-UserList").slideUp(); }
  1624         function() { _this.$.find(".Rk-UserList").slideUp(); }
  1625     );
  1625     );
  1626     this.$.find(".Rk-FullScreen-Button").click(function() {
  1626     this.$.find(".Rk-FullScreen-Button").click(function() {
  1697     });
  1697     });
  1698     
  1698     
  1699     paper.view.onResize = function(_event) {
  1699     paper.view.onResize = function(_event) {
  1700         _this.offset = _this.offset.add(_event.delta.divide(2));
  1700         _this.offset = _this.offset.add(_event.delta.divide(2));
  1701         if (_this.minimap) {
  1701         if (_this.minimap) {
  1702             _this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size)
  1702             _this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size);
  1703             _this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4]));
  1703             _this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4]));
  1704             _this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size);
  1704             _this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size);
  1705         }
  1705         }
  1706         _this.redraw();
  1706         _this.redraw();
  1707     }
  1707     };
  1708     
  1708     
  1709     var _thRedraw = Rkns._.throttle(function() {
  1709     var _thRedraw = Rkns._.throttle(function() {
  1710         _this.redraw();
  1710         _this.redraw();
  1711     },50);
  1711     },50);
  1712     
  1712     
  1716         _this.$.find(".Rk-PadTitle").val(_renkan.project.get("title"));
  1716         _this.$.find(".Rk-PadTitle").val(_renkan.project.get("title"));
  1717     });
  1717     });
  1718     
  1718     
  1719     this.$.find(".Rk-PadTitle").on("keyup input paste", function() {
  1719     this.$.find(".Rk-PadTitle").on("keyup input paste", function() {
  1720         _renkan.project.set({"title": $(this).val()});
  1720         _renkan.project.set({"title": $(this).val()});
  1721     })
  1721     });
  1722     
  1722     
  1723     this.renkan.project.get("users").each(function(_user) {
  1723     this.renkan.project.get("users").each(function(_user) {
  1724         _this.addUser(_user);
  1724         _this.addUser(_user);
  1725     });
  1725     });
  1726     
  1726     
  1781                     project.removeEdge(el);
  1781                     project.removeEdge(el);
  1782                 }
  1782                 }
  1783             }
  1783             }
  1784         });
  1784         });
  1785         _this.delete_list = _this.delete_list.filter(function(d) {
  1785         _this.delete_list = _this.delete_list.filter(function(d) {
  1786             return _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id}) || _renkan.project.get("edges").findWhere({"delete_scheduled":d.id})
  1786             return _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id}) || _renkan.project.get("edges").findWhere({"delete_scheduled":d.id});
  1787         });
  1787         });
  1788     }, 500);
  1788     }, 500);
  1789     
  1789     
  1790     if (this.minimap) {
  1790     if (this.minimap) {
  1791         window.setInterval(function() {
  1791         window.setInterval(function() {
  1792             _this.rescaleMinimap()
  1792             _this.rescaleMinimap();
  1793         }, 2000);
  1793         }, 2000);
  1794     }
  1794     }
  1795 
  1795 
  1796 }
  1796 };
  1797 
  1797 
  1798 Rkns.Renderer.Scene.prototype.template = Rkns._.template(
  1798 Rkns.Renderer.Scene.prototype.template = Rkns._.template(
  1799     '<% if (options.show_top_bar) { %><div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2>'
  1799     '<% if (options.show_top_bar) { %><div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2>'
  1800     + '<% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %>'
  1800     + '<% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %>'
  1801     + '<div class="Rk-Users"><div class="Rk-CurrentUser"><span class="Rk-CurrentUser-Color"></span><span class="Rk-CurrentUser-Name">&lt;unknown user&gt;</span></div><ul class="Rk-UserList"></ul></div>'
  1801     + '<div class="Rk-Users"><div class="Rk-CurrentUser"><span class="Rk-CurrentUser-Color"></span><span class="Rk-CurrentUser-Name">&lt;unknown user&gt;</span></div><ul class="Rk-UserList"></ul></div>'
  1829     paper.view.viewSize = new paper.Size([w, h]);
  1829     paper.view.viewSize = new paper.Size([w, h]);
  1830     
  1830     
  1831     if (_autoscale) {
  1831     if (_autoscale) {
  1832         this.autoScale();
  1832         this.autoScale();
  1833     }
  1833     }
  1834 }
  1834 };
  1835 
  1835 
  1836 Rkns.Renderer.Scene.prototype.drawSector = function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
  1836 Rkns.Renderer.Scene.prototype.drawSector = function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
  1837     var _options = this.renkan.options,
  1837     var _options = this.renkan.options,
  1838         _startRads = _startAngle * Math.PI / 180,
  1838         _startRads = _startAngle * Math.PI / 180,
  1839         _endRads = _endAngle * Math.PI / 180,
  1839         _endRads = _endAngle * Math.PI / 180,
  1920             _text.visible = false;
  1920             _text.visible = false;
  1921         },
  1921         },
  1922         destroy: function() {
  1922         destroy: function() {
  1923             _grp.remove();
  1923             _grp.remove();
  1924         }
  1924         }
  1925     }
  1925     };
  1926     function showImage() {
  1926     function showImage() {
  1927         var _raster = new paper.Raster(_img);
  1927         var _raster = new paper.Raster(_img);
  1928         _raster.position = _imgdelta.add(_grp.position).subtract(_delta);
  1928         _raster.position = _imgdelta.add(_grp.position).subtract(_delta);
  1929         _grp.addChild(_raster);
  1929         _grp.addChild(_raster);
  1930     }
  1930     }
  1932         showImage();
  1932         showImage();
  1933     } else {
  1933     } else {
  1934         Rkns.$(_img).on("load",showImage);
  1934         Rkns.$(_img).on("load",showImage);
  1935     }
  1935     }
  1936     
  1936     
  1937     return _res
  1937     return _res;
  1938 }
  1938 };
  1939 
  1939 
  1940 Rkns.Renderer.Scene.prototype.addToBundles = function(_edgeRepr) {
  1940 Rkns.Renderer.Scene.prototype.addToBundles = function(_edgeRepr) {
  1941     var _bundle = Rkns._(this.bundles).find(function(_bundle) {
  1941     var _bundle = Rkns._(this.bundles).find(function(_bundle) {
  1942         return ( 
  1942         return ( 
  1943             ( _bundle.from === _edgeRepr.from_representation && _bundle.to === _edgeRepr.to_representation )
  1943             ( _bundle.from === _edgeRepr.from_representation && _bundle.to === _edgeRepr.to_representation )
  1944             || ( _bundle.from === _edgeRepr.to_representation && _bundle.to === _edgeRepr.from_representation )
  1944             || ( _bundle.from === _edgeRepr.to_representation && _bundle.to === _edgeRepr.from_representation )
  1945         );
  1945         );
  1946     });
  1946     });
  1947     if (typeof _bundle !== "undefined") {
  1947     if (typeof _bundle !== "undefined") {
  1948         _bundle.edges.push(_edgeRepr)
  1948         _bundle.edges.push(_edgeRepr);
  1949     } else {
  1949     } else {
  1950         _bundle = {
  1950         _bundle = {
  1951             from: _edgeRepr.from_representation,
  1951             from: _edgeRepr.from_representation,
  1952             to: _edgeRepr.to_representation,
  1952             to: _edgeRepr.to_representation,
  1953             edges: [ _edgeRepr ],
  1953             edges: [ _edgeRepr ],
  1954             getPosition: function(_er) {
  1954             getPosition: function(_er) {
  1955                 var _dir = (_er.from_representation === this.from) ? 1 : -1;
  1955                 var _dir = (_er.from_representation === this.from) ? 1 : -1;
  1956                 return _dir * ( Rkns._(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 );
  1956                 return _dir * ( Rkns._(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 );
  1957             }
  1957             }
  1958         }
  1958         };
  1959         this.bundles.push(_bundle);
  1959         this.bundles.push(_bundle);
  1960     }
  1960     }
  1961     return _bundle;
  1961     return _bundle;
  1962 }
  1962 };
  1963 
  1963 
  1964 Rkns.Renderer.Scene.prototype.isEditable = function() {
  1964 Rkns.Renderer.Scene.prototype.isEditable = function() {
  1965     return (this.renkan.options.editor_mode && !this.renkan.read_only)
  1965     return (this.renkan.options.editor_mode && !this.renkan.read_only);
  1966 }
  1966 };
  1967 
  1967 
  1968 Rkns.Renderer.Scene.prototype.onStatusChange = function() {
  1968 Rkns.Renderer.Scene.prototype.onStatusChange = function() {
  1969     var savebtn = this.$.find(".Rk-Save-Button"),
  1969     var savebtn = this.$.find(".Rk-Save-Button"),
  1970         tip = savebtn.find(".Rk-TopBar-Tooltip-Contents");
  1970         tip = savebtn.find(".Rk-TopBar-Tooltip-Contents");
  1971     if (this.renkan.read_only) {
  1971     if (this.renkan.read_only) {
  1978         } else {
  1978         } else {
  1979             savebtn.removeClass("disabled Rk-Save-ReadOnly").addClass("Rk-Save-Online");
  1979             savebtn.removeClass("disabled Rk-Save-ReadOnly").addClass("Rk-Save-Online");
  1980             tip.text(this.renkan.translate("Auto-save enabled"));
  1980             tip.text(this.renkan.translate("Auto-save enabled"));
  1981         }
  1981         }
  1982     }
  1982     }
  1983 }
  1983 };
  1984 
  1984 
  1985 Rkns.Renderer.Scene.prototype.setScale = function(_newScale, _offset) {
  1985 Rkns.Renderer.Scene.prototype.setScale = function(_newScale, _offset) {
  1986     if (_newScale > Rkns.Renderer._MIN_SCALE && _newScale < Rkns.Renderer._MAX_SCALE) {
  1986     if (_newScale > Rkns.Renderer._MIN_SCALE && _newScale < Rkns.Renderer._MAX_SCALE) {
  1987         this.scale = _newScale;
  1987         this.scale = _newScale;
  1988         if (_offset) {
  1988         if (_offset) {
  1989             this.offset = _offset
  1989             this.offset = _offset;
  1990         }
  1990         }
  1991         this.redraw();
  1991         this.redraw();
  1992     }
  1992     }
  1993 }
  1993 };
  1994 
  1994 
  1995 Rkns.Renderer.Scene.prototype.autoScale = function() {
  1995 Rkns.Renderer.Scene.prototype.autoScale = function() {
  1996     var nodes = this.renkan.project.get("nodes")
  1996     var nodes = this.renkan.project.get("nodes");
  1997     if (nodes.length > 1) {
  1997     if (nodes.length > 1) {
  1998         var _xx = nodes.map(function(_node) { return _node.get("position").x }),
  1998         var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
  1999             _yy = nodes.map(function(_node) { return _node.get("position").y }),
  1999             _yy = nodes.map(function(_node) { return _node.get("position").y; }),
  2000             _minx = Math.min.apply(Math, _xx),
  2000             _minx = Math.min.apply(Math, _xx),
  2001             _miny = Math.min.apply(Math, _yy),
  2001             _miny = Math.min.apply(Math, _yy),
  2002             _maxx = Math.max.apply(Math, _xx),
  2002             _maxx = Math.max.apply(Math, _xx),
  2003             _maxy = Math.max.apply(Math, _yy);
  2003             _maxy = Math.max.apply(Math, _yy);
  2004         var _scale = Math.max(Rkns.Renderer._MIN_SCALE, Math.min(Rkns.Renderer._MAX_SCALE, (paper.view.size.width - 2 * Rkns.Renderer._AUTOSCALE_MARGIN) / (_maxx - _minx), (paper.view.size.height - 2 * Rkns.Renderer._AUTOSCALE_MARGIN) / (_maxy - _miny)));
  2004         var _scale = Math.max(Rkns.Renderer._MIN_SCALE, Math.min(Rkns.Renderer._MAX_SCALE, (paper.view.size.width - 2 * Rkns.Renderer._AUTOSCALE_MARGIN) / (_maxx - _minx), (paper.view.size.height - 2 * Rkns.Renderer._AUTOSCALE_MARGIN) / (_maxy - _miny)));
  2005         this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)));
  2005         this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)));
  2006     }
  2006     }
  2007     if (nodes.length === 1) {
  2007     if (nodes.length === 1) {
  2008         this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y])));
  2008         this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y])));
  2009     }
  2009     }
  2010 }
  2010 };
  2011 
  2011 
  2012 Rkns.Renderer.Scene.prototype.redrawMiniframe = function() {
  2012 Rkns.Renderer.Scene.prototype.redrawMiniframe = function() {
  2013     var topleft = this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))),
  2013     var topleft = this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))),
  2014         bottomright = this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight));
  2014         bottomright = this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight));
  2015     this.minimap.miniframe.fitBounds(topleft, bottomright);
  2015     this.minimap.miniframe.fitBounds(topleft, bottomright);
  2016 }
  2016 };
  2017 
  2017 
  2018 Rkns.Renderer.Scene.prototype.rescaleMinimap = function() {
  2018 Rkns.Renderer.Scene.prototype.rescaleMinimap = function() {
  2019     var nodes = this.renkan.project.get("nodes")
  2019     var nodes = this.renkan.project.get("nodes");
  2020     if (nodes.length > 1) {
  2020     if (nodes.length > 1) {
  2021         var _xx = nodes.map(function(_node) { return _node.get("position").x }),
  2021         var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
  2022             _yy = nodes.map(function(_node) { return _node.get("position").y }),
  2022             _yy = nodes.map(function(_node) { return _node.get("position").y; }),
  2023             _minx = Math.min.apply(Math, _xx),
  2023             _minx = Math.min.apply(Math, _xx),
  2024             _miny = Math.min.apply(Math, _yy),
  2024             _miny = Math.min.apply(Math, _yy),
  2025             _maxx = Math.max.apply(Math, _xx),
  2025             _maxx = Math.max.apply(Math, _xx),
  2026             _maxy = Math.max.apply(Math, _yy);
  2026             _maxy = Math.max.apply(Math, _yy);
  2027         var _scale = Math.min(
  2027         var _scale = Math.min(
  2036     if (nodes.length === 1) {
  2036     if (nodes.length === 1) {
  2037         this.minimap.scale = .1;
  2037         this.minimap.scale = .1;
  2038         this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y]).multiply(this.minimap.scale));
  2038         this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y]).multiply(this.minimap.scale));
  2039     }
  2039     }
  2040     this.redraw();
  2040     this.redraw();
  2041 }
  2041 };
  2042 
  2042 
  2043 Rkns.Renderer.Scene.prototype.toPaperCoords = function(_point) {
  2043 Rkns.Renderer.Scene.prototype.toPaperCoords = function(_point) {
  2044     return _point.multiply(this.scale).add(this.offset);
  2044     return _point.multiply(this.scale).add(this.offset);
  2045 }
  2045 };
  2046 
  2046 
  2047 Rkns.Renderer.Scene.prototype.toMinimapCoords = function(_point) {
  2047 Rkns.Renderer.Scene.prototype.toMinimapCoords = function(_point) {
  2048     return _point.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft);
  2048     return _point.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft);
  2049 }
  2049 };
  2050 
  2050 
  2051 Rkns.Renderer.Scene.prototype.toModelCoords = function(_point) {
  2051 Rkns.Renderer.Scene.prototype.toModelCoords = function(_point) {
  2052     return _point.subtract(this.offset).divide(this.scale);
  2052     return _point.subtract(this.offset).divide(this.scale);
  2053 }
  2053 };
  2054 
  2054 
  2055 Rkns.Renderer.Scene.prototype.addRepresentation = function(_type, _model) {
  2055 Rkns.Renderer.Scene.prototype.addRepresentation = function(_type, _model) {
  2056     var _repr = new Rkns.Renderer[_type](this, _model);
  2056     var _repr = new Rkns.Renderer[_type](this, _model);
  2057     this.representations.push(_repr);
  2057     this.representations.push(_repr);
  2058     return _repr;
  2058     return _repr;
  2059 }
  2059 };
  2060 
  2060 
  2061 Rkns.Renderer.Scene.prototype.addRepresentations = function(_type, _collection) {
  2061 Rkns.Renderer.Scene.prototype.addRepresentations = function(_type, _collection) {
  2062     var _this = this;
  2062     var _this = this;
  2063     _collection.forEach(function(_model) {
  2063     _collection.forEach(function(_model) {
  2064         _this.addRepresentation(_type, _model);
  2064         _this.addRepresentation(_type, _model);
  2065     });
  2065     });
  2066 }
  2066 };
  2067 
  2067 
  2068 Rkns.Renderer.Scene.prototype.userTemplate = Rkns._.template(
  2068 Rkns.Renderer.Scene.prototype.userTemplate = Rkns._.template(
  2069     '<li class="Rk-User"><span class="Rk-UserColor" style="background:<%=background%>;"></span><%=name%></li>'
  2069     '<li class="Rk-User"><span class="Rk-UserColor" style="background:<%=background%>;"></span><%=name%></li>'
  2070 );
  2070 );
  2071 
  2071 
  2081                     background: _user.get("color")
  2081                     background: _user.get("color")
  2082                 })
  2082                 })
  2083             )
  2083             )
  2084         );
  2084         );
  2085     }
  2085     }
  2086 }
  2086 };
  2087 
  2087 
  2088 Rkns.Renderer.Scene.prototype.removeRepresentation = function(_representation) {
  2088 Rkns.Renderer.Scene.prototype.removeRepresentation = function(_representation) {
  2089     _representation.destroy();
  2089     _representation.destroy();
  2090     this.representations = Rkns._(this.representations).reject(
  2090     this.representations = Rkns._(this.representations).reject(
  2091         function(_repr) {
  2091         function(_repr) {
  2092             return _repr == _representation
  2092             return _repr == _representation;
  2093         }
  2093         }
  2094     );
  2094     );
  2095 }
  2095 };
  2096 
  2096 
  2097 Rkns.Renderer.Scene.prototype.getRepresentationByModel = function(_model) {
  2097 Rkns.Renderer.Scene.prototype.getRepresentationByModel = function(_model) {
  2098     return Rkns._(this.representations).find(function(_repr) {
  2098     return Rkns._(this.representations).find(function(_repr) {
  2099         return _repr.model === _model;
  2099         return _repr.model === _model;
  2100     });
  2100     });
  2101 }
  2101 };
  2102 
  2102 
  2103 Rkns.Renderer.Scene.prototype.removeRepresentationsOfType = function(_type) {
  2103 Rkns.Renderer.Scene.prototype.removeRepresentationsOfType = function(_type) {
  2104     var _representations = Rkns._(this.representations).filter(function(_repr) {
  2104     var _representations = Rkns._(this.representations).filter(function(_repr) {
  2105             return _repr.type == _type;
  2105             return _repr.type == _type;
  2106         }),
  2106         }),
  2107         _this = this;
  2107         _this = this;
  2108     Rkns._(_representations).each(function(_repr) {
  2108     Rkns._(_representations).each(function(_repr) {
  2109         _this.removeRepresentation(_repr);
  2109         _this.removeRepresentation(_repr);
  2110     });
  2110     });
  2111 }
  2111 };
  2112 
  2112 
  2113 Rkns.Renderer.Scene.prototype.highlightModel = function(_model) {
  2113 Rkns.Renderer.Scene.prototype.highlightModel = function(_model) {
  2114     var _repr = this.getRepresentationByModel(_model);
  2114     var _repr = this.getRepresentationByModel(_model);
  2115     if (_repr) {
  2115     if (_repr) {
  2116         _repr.highlight();
  2116         _repr.highlight();
  2117     }
  2117     }
  2118 }
  2118 };
  2119 
  2119 
  2120 Rkns.Renderer.Scene.prototype.unhighlightAll = function(_model) {
  2120 Rkns.Renderer.Scene.prototype.unhighlightAll = function(_model) {
  2121     Rkns._(this.representations).each(function(_repr) {
  2121     Rkns._(this.representations).each(function(_repr) {
  2122         _repr.unhighlight();
  2122         _repr.unhighlight();
  2123     });
  2123     });
  2124 }
  2124 };
  2125 
  2125 
  2126 Rkns.Renderer.Scene.prototype.unselectAll = function(_model) {
  2126 Rkns.Renderer.Scene.prototype.unselectAll = function(_model) {
  2127     Rkns._(this.representations).each(function(_repr) {
  2127     Rkns._(this.representations).each(function(_repr) {
  2128         _repr.unselect();
  2128         _repr.unselect();
  2129     });
  2129     });
  2130 }
  2130 };
  2131 
  2131 
  2132 Rkns.Renderer.Scene.prototype.redraw = function() {
  2132 Rkns.Renderer.Scene.prototype.redraw = function() {
  2133     Rkns._(this.representations).each(function(_representation) {
  2133     Rkns._(this.representations).each(function(_representation) {
  2134         _representation.redraw(true);
  2134         _representation.redraw(true);
  2135     });
  2135     });
  2136     if (this.minimap) {
  2136     if (this.minimap) {
  2137         this.redrawMiniframe();
  2137         this.redrawMiniframe();
  2138     }
  2138     }
  2139     paper.view.draw();
  2139     paper.view.draw();
  2140 }
  2140 };
  2141 
  2141 
  2142 Rkns.Renderer.Scene.prototype.addTempEdge = function(_from, _point) {
  2142 Rkns.Renderer.Scene.prototype.addTempEdge = function(_from, _point) {
  2143     var _tmpEdge = this.addRepresentation("TempEdge",null);
  2143     var _tmpEdge = this.addRepresentation("TempEdge",null);
  2144     _tmpEdge.end_pos = _point;
  2144     _tmpEdge.end_pos = _point;
  2145     _tmpEdge.from_representation = _from;
  2145     _tmpEdge.from_representation = _from;
  2146     _tmpEdge.redraw();
  2146     _tmpEdge.redraw();
  2147     this.click_target = _tmpEdge;
  2147     this.click_target = _tmpEdge;
  2148 }
  2148 };
  2149 
  2149 
  2150 Rkns.Renderer.Scene.prototype.findTarget = function(_hitResult) {
  2150 Rkns.Renderer.Scene.prototype.findTarget = function(_hitResult) {
  2151     if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
  2151     if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
  2152         var _newTarget = _hitResult.item.__representation;
  2152         var _newTarget = _hitResult.item.__representation;
  2153         if (this.selected_target !== _hitResult.item.__representation) {
  2153         if (this.selected_target !== _hitResult.item.__representation) {
  2161         if (this.selected_target) {
  2161         if (this.selected_target) {
  2162             this.selected_target.unselect();
  2162             this.selected_target.unselect();
  2163         }
  2163         }
  2164         this.selected_target = null;
  2164         this.selected_target = null;
  2165     }
  2165     }
  2166 }
  2166 };
  2167 
  2167 
  2168 Rkns.Renderer.Scene.prototype.paperShift = function(_delta) {
  2168 Rkns.Renderer.Scene.prototype.paperShift = function(_delta) {
  2169     this.offset = this.offset.add(_delta);
  2169     this.offset = this.offset.add(_delta);
  2170     this.redraw();
  2170     this.redraw();
  2171 }
  2171 };
  2172 
  2172 
  2173 Rkns.Renderer.Scene.prototype.onMouseMove = function(_event) {
  2173 Rkns.Renderer.Scene.prototype.onMouseMove = function(_event) {
  2174     var _off = this.canvas_$.offset(),
  2174     var _off = this.canvas_$.offset(),
  2175         _point = new paper.Point([
  2175         _point = new paper.Point([
  2176             _event.pageX - _off.left,
  2176             _event.pageX - _off.left,
  2190         }
  2190         }
  2191     } else {
  2191     } else {
  2192         this.findTarget(_hitResult);
  2192         this.findTarget(_hitResult);
  2193     }
  2193     }
  2194     paper.view.draw();
  2194     paper.view.draw();
  2195 }
  2195 };
  2196 
  2196 
  2197 Rkns.Renderer.Scene.prototype.onMouseDown = function(_event, _isTouch) {
  2197 Rkns.Renderer.Scene.prototype.onMouseDown = function(_event, _isTouch) {
  2198     var _off = this.canvas_$.offset(),
  2198     var _off = this.canvas_$.offset(),
  2199         _point = new paper.Point([
  2199         _point = new paper.Point([
  2200             _event.pageX - _off.left,
  2200             _event.pageX - _off.left,
  2238             this.notif_$.hide();
  2238             this.notif_$.hide();
  2239             this.click_mode = false;
  2239             this.click_mode = false;
  2240         }
  2240         }
  2241     }
  2241     }
  2242     paper.view.draw();
  2242     paper.view.draw();
  2243 }
  2243 };
  2244 
  2244 
  2245 Rkns.Renderer.Scene.prototype.onMouseUp = function(_event, _isTouch) {
  2245 Rkns.Renderer.Scene.prototype.onMouseUp = function(_event, _isTouch) {
  2246     this.mouse_down = false;
  2246     this.mouse_down = false;
  2247     if (this.click_target) {
  2247     if (this.click_target) {
  2248         var _off = this.canvas_$.offset();
  2248         var _off = this.canvas_$.offset();
  2261         if (_isTouch) {
  2261         if (_isTouch) {
  2262             this.unselectAll();
  2262             this.unselectAll();
  2263         }
  2263         }
  2264     }
  2264     }
  2265     paper.view.draw();
  2265     paper.view.draw();
  2266 }
  2266 };
  2267 
  2267 
  2268 Rkns.Renderer.Scene.prototype.onScroll = function(_event, _scrolldelta) {
  2268 Rkns.Renderer.Scene.prototype.onScroll = function(_event, _scrolldelta) {
  2269     this.totalScroll += _scrolldelta;
  2269     this.totalScroll += _scrolldelta;
  2270     if (Math.abs(this.totalScroll) >= 1) {
  2270     if (Math.abs(this.totalScroll) >= 1) {
  2271         var _off = this.canvas_$.offset(),
  2271         var _off = this.canvas_$.offset(),
  2278         } else {
  2278         } else {
  2279             this.setScale( this.scale * Math.SQRT1_2, this.offset.add(_delta.divide(Math.SQRT2)));
  2279             this.setScale( this.scale * Math.SQRT1_2, this.offset.add(_delta.divide(Math.SQRT2)));
  2280         }
  2280         }
  2281         this.totalScroll = 0;
  2281         this.totalScroll = 0;
  2282     }
  2282     }
  2283 }
  2283 };
  2284 
  2284 
  2285 Rkns.Renderer.Scene.prototype.onDoubleClick = function(_event) {
  2285 Rkns.Renderer.Scene.prototype.onDoubleClick = function(_event) {
  2286     if (!this.isEditable()) {
  2286     if (!this.isEditable()) {
  2287         return;
  2287         return;
  2288     }
  2288     }
  2304             };
  2304             };
  2305             _node = this.renkan.project.addNode(_data);
  2305             _node = this.renkan.project.addNode(_data);
  2306             this.getRepresentationByModel(_node).openEditor();
  2306             this.getRepresentationByModel(_node).openEditor();
  2307     }
  2307     }
  2308     paper.view.draw();
  2308     paper.view.draw();
  2309 }
  2309 };
  2310 
  2310 
  2311 Rkns.Renderer.Scene.prototype.dropData = function(_data, _event) {
  2311 Rkns.Renderer.Scene.prototype.dropData = function(_data, _event) {
  2312     if (!this.isEditable()) {
  2312     if (!this.isEditable()) {
  2313         return;
  2313         return;
  2314     }
  2314     }
  2321     }
  2321     }
  2322     var newNode = {};
  2322     var newNode = {};
  2323     switch(_data["text/x-iri-specific-site"]) {
  2323     switch(_data["text/x-iri-specific-site"]) {
  2324         case "twitter":
  2324         case "twitter":
  2325             var snippet = Rkns.$('<div>').html(_data["text/x-iri-selected-html"]),
  2325             var snippet = Rkns.$('<div>').html(_data["text/x-iri-selected-html"]),
  2326                 tweetdiv = snippet.find(".tweet")
  2326                 tweetdiv = snippet.find(".tweet");
  2327             newNode.title = _renkan.translate("Tweet by ") + tweetdiv.attr("data-name");
  2327             newNode.title = _renkan.translate("Tweet by ") + tweetdiv.attr("data-name");
  2328             newNode.uri = "http://twitter.com/" + tweetdiv.attr("data-screen-name") + "/status/" + tweetdiv.attr("data-tweet-id");
  2328             newNode.uri = "http://twitter.com/" + tweetdiv.attr("data-screen-name") + "/status/" + tweetdiv.attr("data-tweet-id");
  2329             newNode.image = tweetdiv.find(".avatar").attr("src");
  2329             newNode.image = tweetdiv.find(".avatar").attr("src");
  2330             newNode.description = tweetdiv.find(".js-tweet-text:first").text();
  2330             newNode.description = tweetdiv.find(".js-tweet-text:first").text();
  2331         break;
  2331         break;
  2410     var _node = this.renkan.project.addNode(_nodedata),
  2410     var _node = this.renkan.project.addNode(_nodedata),
  2411         _repr = this.getRepresentationByModel(_node);
  2411         _repr = this.getRepresentationByModel(_node);
  2412     if (_event.type === "drop") {
  2412     if (_event.type === "drop") {
  2413         _repr.openEditor();
  2413         _repr.openEditor();
  2414     }
  2414     }
  2415 }
  2415 };