11 _IMAGE_MAX_KB : 500, |
10 _IMAGE_MAX_KB : 500, |
12 _NODE_SIZE_STEP: Math.LN2/4, |
11 _NODE_SIZE_STEP: Math.LN2/4, |
13 _MIN_SCALE: 1/20, |
12 _MIN_SCALE: 1/20, |
14 _MAX_SCALE: 20, |
13 _MAX_SCALE: 20, |
15 _AUTOSCALE_MARGIN: 50, |
14 _AUTOSCALE_MARGIN: 50, |
16 _USER_PLACEHOLDER : { |
15 _USER_PLACEHOLDER : function(_renkan) { |
17 color: "#000000", |
16 return { |
18 title: "(unknown user)", |
17 color: _renkan.options.default_user_color, |
19 get: function(attr) { |
18 title: _renkan.translate("(unknown user)"), |
20 return this[attr] || false; |
19 get: function(attr) { |
21 } |
20 return this[attr] || false; |
|
21 } |
|
22 } |
22 }, |
23 }, |
23 _BOOKMARKLET_CODE: function(_renkan) { |
24 _BOOKMARKLET_CODE: function(_renkan) { |
24 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;\">" |
25 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;\">" |
25 + _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_") |
26 + _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_") |
26 + "</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);})();" |
27 + "</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);})();" |
232 this.model.off("change", this._changeBinding ); |
227 this.model.off("change", this._changeBinding ); |
233 this.model.off("remove", this._removeBinding ); |
228 this.model.off("remove", this._removeBinding ); |
234 } |
229 } |
235 } |
230 } |
236 |
231 |
|
232 /* */ |
|
233 |
|
234 Rkns.Renderer._BaseButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
|
235 |
|
236 Rkns.Renderer._BaseButton.prototype.moveTo = function(_pos) { |
|
237 this.sector.moveTo(_pos); |
|
238 } |
|
239 |
|
240 Rkns.Renderer._BaseButton.prototype.show = function() { |
|
241 this.sector.show(); |
|
242 } |
|
243 |
|
244 Rkns.Renderer._BaseButton.prototype.hide = function() { |
|
245 this.sector.hide(); |
|
246 } |
|
247 |
|
248 Rkns.Renderer._BaseButton.prototype.select = function() { |
|
249 this.sector.select(); |
|
250 } |
|
251 |
|
252 Rkns.Renderer._BaseButton.prototype.unselect = function(_newTarget) { |
|
253 this.sector.unselect(); |
|
254 if (!_newTarget || (_newTarget !== this.source_representation && _newTarget.source_representation !== this.source_representation)) { |
|
255 this.source_representation.unselect(); |
|
256 } |
|
257 } |
|
258 |
|
259 Rkns.Renderer._BaseButton.prototype.destroy = function() { |
|
260 this.sector.destroy(); |
|
261 } |
|
262 |
|
263 /* */ |
|
264 |
237 Rkns.Renderer.Node = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
265 Rkns.Renderer.Node = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
238 |
266 |
239 Rkns.Renderer.Node.prototype._init = function() { |
267 Rkns.Renderer.Node.prototype._init = function() { |
240 this.renderer.node_layer.activate(); |
268 this.renderer.node_layer.activate(); |
241 this.type = "Node"; |
269 this.type = "Node"; |
242 this.circle = new paper.Path.Circle([0, 0], 1); |
270 this.circle = new paper.Path.Circle([0, 0], 1); |
243 this.circle.__representation = this; |
271 this.circle.__representation = this; |
244 this.circle.fillColor = '#ffffff'; |
272 this.circle.fillColor = this.options.node_fill_color; |
245 if (this.renderer.renkan.options.show_node_circles) { |
273 if (this.options.show_node_circles) { |
246 this.circle.strokeWidth = this.renderer.renkan.options.node_stroke_width; |
274 this.circle.strokeWidth = this.options.node_stroke_width; |
247 this.h_ratio = 1; |
275 this.h_ratio = 1; |
248 } else { |
276 } else { |
249 this.circle.opacity = .01; |
277 this.circle.opacity = .01; |
250 this.h_ratio = 0; |
278 this.h_ratio = 0; |
251 } |
279 } |
252 this.title = new paper.PointText([0,0]); |
280 this.title = new paper.PointText([0,0]); |
253 this.title.characterStyle = { |
281 this.title.characterStyle = { |
254 font: this.renderer.renkan.options.node_label_font, |
282 font: this.options.node_label_font, |
255 fontSize: this.renderer.renkan.options.node_label_font_size, |
283 fontSize: this.options.node_label_font_size, |
256 fillColor: this.renderer.renkan.options.node_label_color |
284 fillColor: this.options.node_label_color |
257 }; |
285 }; |
258 if (this.renderer.renkan.options.editor_mode) { |
286 if (this.options.editor_mode) { |
259 this.edit_button = new Rkns.Renderer.NodeEditButton(this.renderer, null); |
287 this.buttons = [ |
260 this.edit_button.node_representation = this; |
288 new Rkns.Renderer.NodeEditButton(this.renderer, null), |
261 this.remove_button = new Rkns.Renderer.NodeRemoveButton(this.renderer, null); |
289 new Rkns.Renderer.NodeRemoveButton(this.renderer, null), |
262 this.remove_button.node_representation = this; |
290 new Rkns.Renderer.NodeLinkButton(this.renderer, null), |
263 this.link_button = new Rkns.Renderer.NodeLinkButton(this.renderer, null); |
291 new Rkns.Renderer.NodeEnlargeButton(this.renderer, null), |
264 this.link_button.node_representation = this; |
292 new Rkns.Renderer.NodeShrinkButton(this.renderer, null) |
|
293 ]; |
|
294 for (var i = 0; i < this.buttons.length; i++) { |
|
295 this.buttons[i].source_representation = this; |
|
296 } |
|
297 } else { |
|
298 this.buttons = []; |
265 } |
299 } |
266 this.last_circle_radius = 1; |
300 this.last_circle_radius = 1; |
267 this.title.paragraphStyle.justification = 'center'; |
301 this.title.paragraphStyle.justification = 'center'; |
268 |
302 |
269 if (this.renderer.minimap) { |
303 if (this.renderer.minimap) { |
299 this.node_image.position = this.paper_coords; |
331 this.node_image.position = this.paper_coords; |
300 } |
332 } |
301 } |
333 } |
302 this.last_circle_radius = this.circle_radius; |
334 this.last_circle_radius = this.circle_radius; |
303 |
335 |
304 var _text = this.model.get("title") || this.renderer.renkan.translate("(untitled)"); |
336 var _text = this.model.get("title") || this.renkan.translate("(untitled)"); |
305 this.title.content = Rkns.Renderer.Utils.shortenText(_text, this.renderer.renkan.options.node_label_max_length); |
337 this.title.content = Rkns.Renderer.Utils.shortenText(_text, this.options.node_label_max_length); |
306 |
338 |
307 this.title.position = this.paper_coords.add([ |
339 this.title.position = this.paper_coords.add([ |
308 0, |
340 0, |
309 this.circle_radius * this.h_ratio + this.renderer.renkan.options.node_label_font_size + this.renderer.renkan.options.node_label_distance |
341 this.circle_radius * this.h_ratio + this.options.node_label_font_size + this.options.node_label_distance |
310 ]); |
342 ]); |
311 var _color = this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER).get("color"); |
343 var _color = this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color"); |
312 this.circle.strokeColor = _color; |
344 this.circle.strokeColor = _color; |
313 if (this.renderer.renkan.options.editor_mode) { |
345 var _pc = this.paper_coords; |
314 this.edit_button.moveTo(this.paper_coords); |
346 this.buttons.forEach(function(b) { |
315 this.remove_button.moveTo(this.paper_coords); |
347 b.moveTo(_pc); |
316 this.link_button.moveTo(this.paper_coords); |
348 }); |
317 } |
|
318 var _img = this.model.get("image"); |
349 var _img = this.model.get("image"); |
319 if (_img && _img !== this.img) { |
350 if (_img && _img !== this.img) { |
320 var _image = new Image(), |
351 var _image = new Image(), |
321 _this = this; |
352 _this = this; |
322 _image.onload = function() { |
353 _image.onload = function() { |
323 if (_this.node_image) { |
354 if (_this.node_image) { |
324 _this.node_image.remove(); |
355 _this.node_image.remove(); |
325 } |
356 } |
326 _this.renderer.node_layer.activate(); |
357 _this.renderer.node_layer.activate(); |
327 var _ratio = Math.min(2 / _image.width, 2 / _image.height ); |
358 var _ratio = Math.min(2 / _image.width, 2 / _image.height ); |
328 if (!_this.renderer.renkan.options.show_node_circles) { |
359 if (!_this.options.show_node_circles) { |
329 _this.h_ratio = Math.min(1, _image.height / _image.width); |
360 _this.h_ratio = Math.min(1, _image.height / _image.width); |
330 } |
361 } |
331 var _raster = new paper.Raster(_image); |
362 var _raster = new paper.Raster(_image); |
332 if (_this.renderer.renkan.options.clip_node_images) { |
363 if (_this.options.clip_node_images) { |
333 var _clip = new paper.Path.Circle([0, 0], 1); |
364 var _clip = new paper.Path.Circle([0, 0], 1); |
334 _raster.scale(_ratio); |
365 _raster.scale(_ratio); |
335 _this.node_image = new paper.Group(_clip, _raster); |
366 _this.node_image = new paper.Group(_clip, _raster); |
336 _this.node_image.opacity = .99; |
367 _this.node_image.opacity = .99; |
337 /* This is a workaround to allow clipping at group level |
368 /* This is a workaround to allow clipping at group level |
389 } |
421 } |
390 |
422 |
391 Rkns.Renderer.Node.prototype.openEditor = function() { |
423 Rkns.Renderer.Node.prototype.openEditor = function() { |
392 this.renderer.removeRepresentationsOfType("editor"); |
424 this.renderer.removeRepresentationsOfType("editor"); |
393 var _editor = this.renderer.addRepresentation("NodeEditor",null); |
425 var _editor = this.renderer.addRepresentation("NodeEditor",null); |
394 _editor.node_representation = this; |
426 _editor.source_representation = this; |
395 _editor.draw(); |
427 _editor.draw(); |
396 } |
428 } |
397 |
429 |
398 Rkns.Renderer.Node.prototype.select = function() { |
430 Rkns.Renderer.Node.prototype.select = function() { |
399 this.circle.strokeWidth = this.renderer.renkan.options.selected_node_stroke_width; |
431 this.circle.strokeWidth = this.options.selected_node_stroke_width; |
400 if (this.renderer.isEditable()) { |
432 if (this.renderer.isEditable()) { |
401 this.edit_button.show(); |
433 this.buttons.forEach(function(b) { |
402 this.remove_button.show(); |
434 b.show(); |
403 this.link_button.show(); |
435 }); |
404 } |
436 } |
405 var _uri = this.model.get("uri"); |
437 var _uri = this.model.get("uri"); |
406 if (_uri) { |
438 if (_uri) { |
407 Rkns.$('.Rk-Bin-Item').each(function() { |
439 Rkns.$('.Rk-Bin-Item').each(function() { |
408 var _el = Rkns.$(this); |
440 var _el = Rkns.$(this); |
409 if (_el.attr("data-uri") == _uri) { |
441 if (_el.attr("data-uri") == _uri) { |
410 _el.addClass("selected"); |
442 _el.addClass("selected"); |
411 } |
443 } |
412 }); |
444 }); |
413 } |
445 } |
414 if (!this.renderer.renkan.options.editor_mode) { |
446 if (!this.options.editor_mode) { |
415 this.openEditor(); |
447 this.openEditor(); |
416 } |
448 } |
417 |
449 |
418 if (this.renderer.minimap) { |
450 if (this.renderer.minimap) { |
419 this.minimap_circle.fillColor = "#ff00fc"; |
451 this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight; |
|
452 this.minimap_circle.strokeColor = this.options.minimap_highlight_color; |
420 } |
453 } |
421 } |
454 } |
422 |
455 |
423 Rkns.Renderer.Node.prototype.unselect = function(_newTarget) { |
456 Rkns.Renderer.Node.prototype.unselect = function(_newTarget) { |
424 if (!_newTarget || _newTarget.node_representation !== this) { |
457 if (!_newTarget || _newTarget.source_representation !== this) { |
425 if (this.renderer.renkan.options.editor_mode) { |
458 this.buttons.forEach(function(b) { |
426 this.edit_button.hide(); |
459 b.hide(); |
427 this.remove_button.hide(); |
460 }); |
428 this.link_button.hide(); |
461 this.circle.strokeWidth = this.options.node_stroke_width; |
429 } |
|
430 this.circle.strokeWidth = this.renderer.renkan.options.node_stroke_width; |
|
431 Rkns.$('.Rk-Bin-Item').removeClass("selected"); |
462 Rkns.$('.Rk-Bin-Item').removeClass("selected"); |
432 if (this.renderer.minimap) { |
463 if (this.renderer.minimap) { |
433 this.minimap_circle.fillColor = this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER).get("color"); |
464 this.minimap_circle.strokeColor = undefined; |
434 } |
465 } |
435 } |
466 } |
436 } |
467 } |
437 |
468 |
438 Rkns.Renderer.Node.prototype.highlight = function() { |
469 Rkns.Renderer.Node.prototype.highlight = function() { |
439 this.circle.fillColor = "#ffff80"; |
470 this.circle.fillColor = this.options.highlighted_node_fill_color; |
440 if (this.node_image) { |
471 if (this.node_image) { |
441 this.node_image.opacity = .5; |
472 this.node_image.opacity = .5; |
442 } |
473 } |
443 } |
474 } |
444 |
475 |
445 Rkns.Renderer.Node.prototype.unhighlight = function(_newTarget) { |
476 Rkns.Renderer.Node.prototype.unhighlight = function(_newTarget) { |
446 this.circle.fillColor = "#ffffff"; |
477 this.circle.fillColor = this.options.node_fill_color; |
447 if (this.node_image) { |
478 if (this.node_image) { |
448 this.node_image.opacity = .99; |
479 this.node_image.opacity = .99; |
449 } |
480 } |
450 } |
481 } |
451 |
482 |
502 this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to")); |
531 this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to")); |
503 this.bundle = this.renderer.addToBundles(this); |
532 this.bundle = this.renderer.addToBundles(this); |
504 this.line = new paper.Path(); |
533 this.line = new paper.Path(); |
505 this.line.add([0,0],[0,0],[0,0]); |
534 this.line.add([0,0],[0,0],[0,0]); |
506 this.line.__representation = this; |
535 this.line.__representation = this; |
507 this.line.strokeWidth = this.renderer.renkan.options.edge_stroke_width; |
536 this.line.strokeWidth = this.options.edge_stroke_width; |
508 this.arrow = new paper.Path(); |
537 this.arrow = new paper.Path(); |
509 this.arrow.add( |
538 this.arrow.add( |
510 [ 0, 0 ], |
539 [ 0, 0 ], |
511 [ this.renderer.renkan.options.edge_arrow_length, this.renderer.renkan.options.edge_arrow_width / 2 ], |
540 [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ], |
512 [ 0, this.renderer.renkan.options.edge_arrow_width ] |
541 [ 0, this.options.edge_arrow_width ] |
513 ); |
542 ); |
514 this.arrow.__representation = this; |
543 this.arrow.__representation = this; |
515 this.text = new paper.PointText(); |
544 this.text = new paper.PointText(); |
516 this.text.characterStyle = { |
545 this.text.characterStyle = { |
517 font: this.renderer.renkan.options.edge_label_font, |
546 font: this.options.edge_label_font, |
518 fontSize: this.renderer.renkan.options.edge_label_font_size, |
547 fontSize: this.options.edge_label_font_size, |
519 fillColor: this.renderer.renkan.options.edge_label_color |
548 fillColor: this.options.edge_label_color |
520 }; |
549 }; |
521 this.text.paragraphStyle.justification = 'center'; |
550 this.text.paragraphStyle.justification = 'center'; |
522 this.text_angle = 0; |
551 this.text_angle = 0; |
523 this.arrow_angle = 0; |
552 this.arrow_angle = 0; |
524 if (this.renderer.renkan.options.editor_mode) { |
553 if (this.options.editor_mode) { |
525 this.edit_button = new Rkns.Renderer.EdgeEditButton(this.renderer, null); |
554 this.edit_button = new Rkns.Renderer.EdgeEditButton(this.renderer, null); |
526 this.edit_button.edge_representation = this; |
555 this.edit_button.source_representation = this; |
527 this.remove_button = new Rkns.Renderer.EdgeRemoveButton(this.renderer, null); |
556 this.remove_button = new Rkns.Renderer.EdgeRemoveButton(this.renderer, null); |
528 this.remove_button.edge_representation = this; |
557 this.remove_button.source_representation = this; |
529 } |
558 } |
530 |
559 |
531 if (this.renderer.minimap) { |
560 if (this.renderer.minimap) { |
532 this.renderer.minimap.edge_layer.activate(); |
561 this.renderer.minimap.edge_layer.activate(); |
533 this.minimap_line = new paper.Path(); |
562 this.minimap_line = new paper.Path(); |
777 + '<div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-translate("Node color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-node.color%>;"><span class="Rk-Edit-ColorTip"></span></span><ul class="Rk-Edit-ColorPicker">' |
805 + '<div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-translate("Node color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-node.color%>;"><span class="Rk-Edit-ColorTip"></span></span><ul class="Rk-Edit-ColorPicker">' |
778 + '<% _(Rkns.pickerColors).each(function(c) { %><li data-color="<%=c%>" style="background: <%=c%>"></li><% }); %></ul><span class="Rk-Edit-ColorPicker-Text"><%- translate("Choose color") %></span></div></div>' |
806 + '<% _(Rkns.pickerColors).each(function(c) { %><li data-color="<%=c%>" style="background: <%=c%>"></li><% }); %></ul><span class="Rk-Edit-ColorPicker-Text"><%- translate("Choose color") %></span></div></div>' |
779 + '<img class="Rk-Edit-ImgPreview" src="<%-node.image || node.image_placeholder%>" />' |
807 + '<img class="Rk-Edit-ImgPreview" src="<%-node.image || node.image_placeholder%>" />' |
780 + '<p><label><%-translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p>' |
808 + '<p><label><%-translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p>' |
781 + '<p><label><%-translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p>' |
809 + '<p><label><%-translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p>' |
782 + '<p><span class="Rk-Editor-Label"><%-translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(node.created_by_title, 25) %></p>' |
810 + '<% if (node.has_creator) { %><p><span class="Rk-Editor-Label"><%-translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(node.created_by_title, 25) %></p><% } %>' |
783 ); |
811 ); |
784 |
812 |
785 Rkns.Renderer.NodeEditor.prototype.readOnlyTemplate = Rkns._.template( |
813 Rkns.Renderer.NodeEditor.prototype.readOnlyTemplate = Rkns._.template( |
786 '<h2><span class="Rk-CloseX">×</span><span class="Rk-UserColor" style="background:<%-node.color%>;"></span>' |
814 '<h2><span class="Rk-CloseX">×</span><span class="Rk-UserColor" style="background:<%-node.color%>;"></span>' |
787 + '<span class="Rk-Display-Title"><% if (node.uri) { %><a href="<%-node.uri%>" target="_blank"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2>' |
815 + '<span class="Rk-Display-Title"><% if (node.uri) { %><a href="<%-node.uri%>" target="_blank"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2>' |
788 + '<% if (node.uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %>' |
816 + '<% if (node.uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %>' |
789 + '<p><%-node.description%></p>' |
817 + '<p><%-node.description%></p>' |
790 + '<p><span class="Rk-Editor-Label"><%-translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(node.created_by_title, 25) %></p>' |
818 + '<% if (node.has_creator) { %><p><span class="Rk-Editor-Label"><%-translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(node.created_by_title, 25) %></p><% } %>' |
791 ); |
819 ); |
792 |
820 |
793 Rkns.Renderer.NodeEditor.prototype.draw = function() { |
821 Rkns.Renderer.NodeEditor.prototype.draw = function() { |
794 var _model = this.node_representation.model, |
822 var _model = this.source_representation.model, |
795 _created_by = _model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER, |
823 _created_by = _model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan), |
796 _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ), |
824 _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ), |
797 _image_placeholder = this.renderer.renkan.options.static_url + "img/image-placeholder.png", |
825 _image_placeholder = this.options.static_url + "img/image-placeholder.png", |
798 _size = (_model.get("size") || 0); |
826 _size = (_model.get("size") || 0); |
799 this.editor_$ |
827 this.editor_$ |
800 .html(_template({ |
828 .html(_template({ |
801 node: { |
829 node: { |
|
830 has_creator: !!_model.get("created_by"), |
802 title: _model.get("title"), |
831 title: _model.get("title"), |
803 uri: _model.get("uri"), |
832 uri: _model.get("uri"), |
804 short_uri: Rkns.Renderer.Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
833 short_uri: Rkns.Renderer.Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
805 description: _model.get("description"), |
834 description: _model.get("description"), |
806 image: _model.get("image") || "", |
835 image: _model.get("image") || "", |
955 + '<div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-translate("Edge color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-edge.color%>;"><span class="Rk-Edit-ColorTip"></span></span><ul class="Rk-Edit-ColorPicker">' |
983 + '<div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-translate("Edge color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-edge.color%>;"><span class="Rk-Edit-ColorTip"></span></span><ul class="Rk-Edit-ColorPicker">' |
956 + '<% _(Rkns.pickerColors).each(function(c) { %><li data-color="<%=c%>" style="background: <%=c%>"></li><% }); %></ul><span class="Rk-Edit-ColorPicker-Text"><%- translate("Choose color") %></span></div></div>' |
984 + '<% _(Rkns.pickerColors).each(function(c) { %><li data-color="<%=c%>" style="background: <%=c%>"></li><% }); %></ul><span class="Rk-Edit-ColorPicker-Text"><%- translate("Choose color") %></span></div></div>' |
957 + '<p><span class="Rk-Edit-Direction"><%- translate("Change edge direction") %></span></p>' |
985 + '<p><span class="Rk-Edit-Direction"><%- translate("Change edge direction") %></span></p>' |
958 + '<p><span class="Rk-Editor-Label"><%-translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(edge.from_title, 25) %></p>' |
986 + '<p><span class="Rk-Editor-Label"><%-translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(edge.from_title, 25) %></p>' |
959 + '<p><span class="Rk-Editor-Label"><%-translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(edge.to_title, 25) %></p>' |
987 + '<p><span class="Rk-Editor-Label"><%-translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(edge.to_title, 25) %></p>' |
960 + '<p><span class="Rk-Editor-Label"><%-translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(edge.created_by_title, 25) %></p>' |
988 + '<% if (edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(edge.created_by_title, 25) %></p><% } %>' |
961 ); |
989 ); |
962 |
990 |
963 Rkns.Renderer.EdgeEditor.prototype.readOnlyTemplate = Rkns._.template( |
991 Rkns.Renderer.EdgeEditor.prototype.readOnlyTemplate = Rkns._.template( |
964 '<h2><span class="Rk-CloseX">×</span><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span>' |
992 '<h2><span class="Rk-CloseX">×</span><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span>' |
965 + '<span class="Rk-Display-Title"><% if (edge.uri) { %><a href="<%-edge.uri%>" target="_blank"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2>' |
993 + '<span class="Rk-Display-Title"><% if (edge.uri) { %><a href="<%-edge.uri%>" target="_blank"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2>' |
966 + '<% if (edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %>' |
994 + '<% if (edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %>' |
967 + '<p><%-edge.description%></p>' |
995 + '<p><%-edge.description%></p>' |
968 + '<p><span class="Rk-Editor-Label"><%-translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(edge.from_title, 25) %></p>' |
996 + '<p><span class="Rk-Editor-Label"><%-translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(edge.from_title, 25) %></p>' |
969 + '<p><span class="Rk-Editor-Label"><%-translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(edge.to_title, 25) %></p>' |
997 + '<p><span class="Rk-Editor-Label"><%-translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(edge.to_title, 25) %></p>' |
970 + '<p><span class="Rk-Editor-Label"><%-translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(edge.created_by_title, 25) %></p>' |
998 + '<% if (edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- Rkns.Renderer.Utils.shortenText(edge.created_by_title, 25) %></p><% } %>' |
971 ); |
999 ); |
972 |
1000 |
973 Rkns.Renderer.EdgeEditor.prototype.draw = function() { |
1001 Rkns.Renderer.EdgeEditor.prototype.draw = function() { |
974 var _model = this.edge_representation.model, |
1002 var _model = this.source_representation.model, |
975 _from_model = _model.get("from"), |
1003 _from_model = _model.get("from"), |
976 _to_model = _model.get("to"), |
1004 _to_model = _model.get("to"), |
977 _created_by = _model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER, |
1005 _created_by = _model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan), |
978 _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate); |
1006 _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate); |
979 this.editor_$ |
1007 this.editor_$ |
980 .html(_template({ |
1008 .html(_template({ |
981 edge: { |
1009 edge: { |
|
1010 has_creator: !!_model.get("created_by"), |
982 title: _model.get("title"), |
1011 title: _model.get("title"), |
983 uri: _model.get("uri"), |
1012 uri: _model.get("uri"), |
984 short_uri: Rkns.Renderer.Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
1013 short_uri: Rkns.Renderer.Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
985 description: _model.get("description"), |
1014 description: _model.get("description"), |
986 color: _model.get("color") || _created_by.get("color"), |
1015 color: _model.get("color") || _created_by.get("color"), |
987 from_title: _from_model.get("title"), |
1016 from_title: _from_model.get("title"), |
988 to_title: _to_model.get("title"), |
1017 to_title: _to_model.get("title"), |
989 from_color: _from_model.get("color") || (_from_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER).get("color"), |
1018 from_color: _from_model.get("color") || (_from_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color"), |
990 to_color: _to_model.get("color") || (_to_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER).get("color"), |
1019 to_color: _to_model.get("color") || (_to_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color"), |
991 created_by_color: _created_by.get("color"), |
1020 created_by_color: _created_by.get("color"), |
992 created_by_title: _created_by.get("title") |
1021 created_by_title: _created_by.get("title") |
993 }, |
1022 }, |
994 translate: this.renderer.renkan.translate, |
1023 translate: this.renkan.translate, |
995 properties: this.renderer.renkan.options.properties |
1024 properties: this.options.properties |
996 })); |
1025 })); |
997 this.redraw(); |
1026 this.redraw(); |
998 var _this = this, |
1027 var _this = this, |
999 closeEditor = function() { |
1028 closeEditor = function() { |
1000 _this.renderer.removeRepresentation(_this); |
1029 _this.renderer.removeRepresentation(_this); |
1071 this.editor_$.detach(); |
1100 this.editor_$.detach(); |
1072 } |
1101 } |
1073 |
1102 |
1074 /* */ |
1103 /* */ |
1075 |
1104 |
1076 Rkns.Renderer.NodeEditButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
1105 Rkns.Renderer._NodeButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton); |
1077 |
1106 |
1078 Rkns.Renderer.NodeEditButton.prototype._init = function() { |
1107 Rkns.Renderer._NodeButton.prototype.setSectorSize = function() { |
1079 this.type = "Node-edit-button"; |
1108 var sectorInner = this.source_representation.circle_radius; |
1080 this.lastSectorInner = 0; |
|
1081 } |
|
1082 |
|
1083 Rkns.Renderer.NodeEditButton.prototype.setSectorSize = function() { |
|
1084 var sectorInner = this.node_representation.circle_radius; |
|
1085 if (sectorInner !== this.lastSectorInner) { |
1109 if (sectorInner !== this.lastSectorInner) { |
1086 if (this.sector) { |
1110 if (this.sector) { |
1087 this.sector.destroy(); |
1111 this.sector.destroy(); |
1088 } |
1112 } |
1089 this.sector = Rkns.Renderer.Utils.sector(this, 1 + sectorInner, Rkns.Renderer._NODE_BUTTON_WIDTH + sectorInner, - 90, 30, 1, this.renderer.renkan.options.static_url+'img/edit.png', this.renderer.renkan.translate("Edit")); |
1113 this.sector = Rkns.Renderer.Utils.sector( |
|
1114 this, 1 + sectorInner, |
|
1115 Rkns.Renderer._NODE_BUTTON_WIDTH + sectorInner, |
|
1116 this.startAngle, |
|
1117 this.endAngle, |
|
1118 1, |
|
1119 this.options.static_url + this.imageFile, |
|
1120 this.renkan.translate(this.text) |
|
1121 ); |
1090 this.lastSectorInner = sectorInner; |
1122 this.lastSectorInner = sectorInner; |
1091 } |
1123 } |
1092 } |
1124 } |
1093 |
1125 |
1094 Rkns.Renderer.NodeEditButton.prototype.moveTo = function(_pos) { |
1126 /* */ |
1095 this.sector.moveTo(_pos); |
1127 |
1096 } |
1128 Rkns.Renderer.NodeEditButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); |
1097 |
1129 |
1098 Rkns.Renderer.NodeEditButton.prototype.show = function() { |
1130 Rkns.Renderer.NodeEditButton.prototype._init = function() { |
1099 this.sector.show(); |
1131 this.type = "Node-edit-button"; |
1100 } |
1132 this.lastSectorInner = 0; |
1101 |
1133 this.startAngle = -225; |
1102 Rkns.Renderer.NodeEditButton.prototype.hide = function() { |
1134 this.endAngle = -135; |
1103 this.sector.hide(); |
1135 this.imageFile = 'img/edit.png'; |
1104 } |
1136 this.text = "Edit"; |
1105 |
|
1106 Rkns.Renderer.NodeEditButton.prototype.select = function() { |
|
1107 this.sector.select(); |
|
1108 } |
|
1109 |
|
1110 Rkns.Renderer.NodeEditButton.prototype.unselect = function(_newTarget) { |
|
1111 this.sector.unselect(); |
|
1112 if (!_newTarget || (_newTarget !== this.node_representation && _newTarget.node_representation !== this.node_representation)) { |
|
1113 this.node_representation.unselect(); |
|
1114 } |
|
1115 } |
1137 } |
1116 |
1138 |
1117 Rkns.Renderer.NodeEditButton.prototype.mouseup = function() { |
1139 Rkns.Renderer.NodeEditButton.prototype.mouseup = function() { |
1118 if (!this.renderer.is_dragging) { |
1140 if (!this.renderer.is_dragging) { |
1119 this.node_representation.openEditor(); |
1141 this.source_representation.openEditor(); |
1120 } |
1142 } |
1121 } |
|
1122 |
|
1123 Rkns.Renderer.NodeEditButton.prototype.destroy = function() { |
|
1124 this.sector.destroy(); |
|
1125 } |
1143 } |
1126 |
1144 |
1127 /* */ |
1145 /* */ |
1128 |
1146 |
1129 Rkns.Renderer.NodeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
1147 Rkns.Renderer.NodeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); |
1130 |
1148 |
1131 Rkns.Renderer.NodeRemoveButton.prototype._init = function() { |
1149 Rkns.Renderer.NodeRemoveButton.prototype._init = function() { |
1132 this.type = "Node-remove-button"; |
1150 this.type = "Node-remove-button"; |
1133 this.lastSectorInner = 0; |
1151 this.lastSectorInner = 0; |
1134 } |
1152 this.startAngle = -45; |
1135 |
1153 this.endAngle = 45; |
1136 Rkns.Renderer.NodeRemoveButton.prototype.setSectorSize = function() { |
1154 this.imageFile = 'img/remove.png'; |
1137 var sectorInner = this.node_representation.circle_radius; |
1155 this.text = "Remove"; |
1138 if (sectorInner !== this.lastSectorInner) { |
|
1139 if (this.sector) { |
|
1140 this.sector.destroy(); |
|
1141 } |
|
1142 this.sector = Rkns.Renderer.Utils.sector(this, 1 + sectorInner, Rkns.Renderer._NODE_BUTTON_WIDTH + sectorInner, - 210, - 90, 1, this.renderer.renkan.options.static_url+'img/remove.png', this.renderer.renkan.translate("Remove")); |
|
1143 this.lastSectorInner = sectorInner; |
|
1144 } |
|
1145 } |
|
1146 |
|
1147 Rkns.Renderer.NodeRemoveButton.prototype.moveTo = function(_pos) { |
|
1148 this.sector.moveTo(_pos); |
|
1149 } |
|
1150 |
|
1151 Rkns.Renderer.NodeRemoveButton.prototype.show = function() { |
|
1152 this.sector.show(); |
|
1153 } |
|
1154 |
|
1155 Rkns.Renderer.NodeRemoveButton.prototype.hide = function() { |
|
1156 this.sector.hide(); |
|
1157 } |
|
1158 |
|
1159 Rkns.Renderer.NodeRemoveButton.prototype.select = function() { |
|
1160 this.sector.select(); |
|
1161 } |
|
1162 |
|
1163 Rkns.Renderer.NodeRemoveButton.prototype.unselect = function(_newTarget) { |
|
1164 this.sector.unselect(); |
|
1165 if (!_newTarget || (_newTarget !== this.node_representation && _newTarget.node_representation !== this.node_representation)) { |
|
1166 this.node_representation.unselect(); |
|
1167 } |
|
1168 } |
1156 } |
1169 |
1157 |
1170 Rkns.Renderer.NodeRemoveButton.prototype.mouseup = function() { |
1158 Rkns.Renderer.NodeRemoveButton.prototype.mouseup = function() { |
1171 this.renderer.removeRepresentationsOfType("editor"); |
1159 this.renderer.removeRepresentationsOfType("editor"); |
1172 if (this.renderer.isEditable() && confirm(this.renderer.renkan.translate('Do you really wish to remove node ') + '"' + this.node_representation.model.get("title") + '"?')) { |
1160 if (this.renderer.isEditable() && confirm(this.renkan.translate('Do you really wish to remove node ') + '"' + this.source_representation.model.get("title") + '"?')) { |
1173 this.project.removeNode(this.node_representation.model); |
1161 this.project.removeNode(this.source_representation.model); |
1174 } |
1162 } |
1175 } |
|
1176 |
|
1177 Rkns.Renderer.NodeRemoveButton.prototype.destroy = function() { |
|
1178 this.sector.destroy(); |
|
1179 } |
1163 } |
1180 |
1164 |
1181 /* */ |
1165 /* */ |
1182 |
1166 |
1183 Rkns.Renderer.NodeLinkButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
1167 Rkns.Renderer.NodeLinkButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); |
1184 |
1168 |
1185 Rkns.Renderer.NodeLinkButton.prototype._init = function() { |
1169 Rkns.Renderer.NodeLinkButton.prototype._init = function() { |
1186 this.type = "Node-link-button"; |
1170 this.type = "Node-link-button"; |
1187 this.lastSectorInner = 0; |
1171 this.lastSectorInner = 0; |
1188 } |
1172 this.startAngle = -135; |
1189 |
1173 this.endAngle = -45; |
1190 Rkns.Renderer.NodeLinkButton.prototype.setSectorSize = function() { |
1174 this.imageFile = 'img/link.png'; |
1191 var sectorInner = this.node_representation.circle_radius; |
1175 this.text = "Link to another node"; |
1192 if (sectorInner !== this.lastSectorInner) { |
|
1193 if (this.sector) { |
|
1194 this.sector.destroy(); |
|
1195 } |
|
1196 this.sector = Rkns.Renderer.Utils.sector(this, 1 + sectorInner, Rkns.Renderer._NODE_BUTTON_WIDTH + sectorInner, 30, 150, 1, this.renderer.renkan.options.static_url+'img/link.png', this.renderer.renkan.translate("Link to another node")); |
|
1197 this.lastSectorInner = sectorInner; |
|
1198 } |
|
1199 } |
|
1200 |
|
1201 Rkns.Renderer.NodeLinkButton.prototype.moveTo = function(_pos) { |
|
1202 this.sector.moveTo(_pos); |
|
1203 } |
|
1204 |
|
1205 Rkns.Renderer.NodeLinkButton.prototype.show = function() { |
|
1206 this.sector.show(); |
|
1207 } |
|
1208 |
|
1209 Rkns.Renderer.NodeLinkButton.prototype.hide = function() { |
|
1210 this.sector.hide(); |
|
1211 } |
|
1212 |
|
1213 Rkns.Renderer.NodeLinkButton.prototype.select = function() { |
|
1214 this.sector.select(); |
|
1215 } |
|
1216 |
|
1217 Rkns.Renderer.NodeLinkButton.prototype.unselect = function(_newTarget) { |
|
1218 this.sector.unselect(); |
|
1219 if (!_newTarget || (_newTarget !== this.node_representation && _newTarget.node_representation !== this.node_representation)) { |
|
1220 this.node_representation.unselect(); |
|
1221 } |
|
1222 } |
|
1223 |
|
1224 Rkns.Renderer.NodeLinkButton.prototype.destroy = function() { |
|
1225 this.sector.destroy(); |
|
1226 } |
1176 } |
1227 |
1177 |
1228 /* */ |
1178 /* */ |
1229 |
1179 |
1230 Rkns.Renderer.EdgeEditButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
1180 Rkns.Renderer.NodeEnlargeButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); |
|
1181 |
|
1182 Rkns.Renderer.NodeEnlargeButton.prototype._init = function() { |
|
1183 this.type = "Node-enlarge-button"; |
|
1184 this.lastSectorInner = 0; |
|
1185 this.startAngle = 45; |
|
1186 this.endAngle = 90; |
|
1187 this.imageFile = 'img/enlarge.png'; |
|
1188 this.text = "Enlarge"; |
|
1189 } |
|
1190 |
|
1191 Rkns.Renderer.NodeEnlargeButton.prototype.mouseup = function() { |
|
1192 var _newsize = 1 + (this.source_representation.model.get("size") || 0); |
|
1193 this.source_representation.model.set("size", _newsize); |
|
1194 this.source_representation.select(); |
|
1195 this.select(); |
|
1196 paper.view.draw(); |
|
1197 } |
|
1198 |
|
1199 /* */ |
|
1200 |
|
1201 Rkns.Renderer.NodeShrinkButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); |
|
1202 |
|
1203 Rkns.Renderer.NodeShrinkButton.prototype._init = function() { |
|
1204 this.type = "Node-shrink-button"; |
|
1205 this.lastSectorInner = 0; |
|
1206 this.startAngle = 90; |
|
1207 this.endAngle = 135; |
|
1208 this.imageFile = 'img/shrink.png'; |
|
1209 this.text = "Shrink"; |
|
1210 } |
|
1211 |
|
1212 Rkns.Renderer.NodeShrinkButton.prototype.mouseup = function() { |
|
1213 var _newsize = -1 + (this.source_representation.model.get("size") || 0); |
|
1214 this.source_representation.model.set("size", _newsize); |
|
1215 this.source_representation.select(); |
|
1216 this.select(); |
|
1217 paper.view.draw(); |
|
1218 } |
|
1219 |
|
1220 /* */ |
|
1221 |
|
1222 Rkns.Renderer.EdgeEditButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton); |
1231 |
1223 |
1232 Rkns.Renderer.EdgeEditButton.prototype._init = function() { |
1224 Rkns.Renderer.EdgeEditButton.prototype._init = function() { |
1233 this.type = "Edge-edit-button"; |
1225 this.type = "Edge-edit-button"; |
1234 this.sector = Rkns.Renderer.Utils.sector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, - 90, 90, 1, this.renderer.renkan.options.static_url+'img/edit.png', this.renderer.renkan.translate("Edit")); |
1226 this.sector = Rkns.Renderer.Utils.sector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, - 90, 90, 1, this.options.static_url+'img/edit.png', this.renkan.translate("Edit")); |
1235 } |
|
1236 |
|
1237 Rkns.Renderer.EdgeEditButton.prototype.moveTo = function(_pos) { |
|
1238 this.sector.moveTo(_pos); |
|
1239 } |
|
1240 |
|
1241 Rkns.Renderer.EdgeEditButton.prototype.show = function() { |
|
1242 this.sector.show(); |
|
1243 } |
|
1244 |
|
1245 Rkns.Renderer.EdgeEditButton.prototype.hide = function() { |
|
1246 this.sector.hide(); |
|
1247 } |
|
1248 |
|
1249 Rkns.Renderer.EdgeEditButton.prototype.select = function() { |
|
1250 this.sector.select(); |
|
1251 } |
|
1252 |
|
1253 Rkns.Renderer.EdgeEditButton.prototype.unselect = function(_newTarget) { |
|
1254 this.sector.unselect(); |
|
1255 if (!_newTarget || (_newTarget !== this.edge_representation && _newTarget.edge_representation !== this.edge_representation)) { |
|
1256 this.edge_representation.unselect(); |
|
1257 } |
|
1258 } |
1227 } |
1259 |
1228 |
1260 Rkns.Renderer.EdgeEditButton.prototype.mouseup = function() { |
1229 Rkns.Renderer.EdgeEditButton.prototype.mouseup = function() { |
1261 if (!this.renderer.is_dragging) { |
1230 if (!this.renderer.is_dragging) { |
1262 this.edge_representation.openEditor(); |
1231 this.source_representation.openEditor(); |
1263 } |
1232 } |
1264 } |
|
1265 |
|
1266 Rkns.Renderer.EdgeEditButton.prototype.destroy = function() { |
|
1267 this.sector.destroy(); |
|
1268 } |
1233 } |
1269 |
1234 |
1270 /* */ |
1235 /* */ |
1271 |
1236 |
1272 Rkns.Renderer.EdgeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
1237 Rkns.Renderer.EdgeRemoveButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton); |
1273 |
1238 |
1274 Rkns.Renderer.EdgeRemoveButton.prototype._init = function() { |
1239 Rkns.Renderer.EdgeRemoveButton.prototype._init = function() { |
1275 this.type = "Edge-remove-button"; |
1240 this.type = "Edge-remove-button"; |
1276 this.sector = Rkns.Renderer.Utils.sector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, - 270, -90, 1, this.renderer.renkan.options.static_url+'img/remove.png', this.renderer.renkan.translate("Remove")); |
1241 this.sector = Rkns.Renderer.Utils.sector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, - 270, -90, 1, this.options.static_url+'img/remove.png', this.renkan.translate("Remove")); |
1277 } |
|
1278 Rkns.Renderer.EdgeRemoveButton.prototype.moveTo = function(_pos) { |
|
1279 this.sector.moveTo(_pos); |
|
1280 } |
|
1281 |
|
1282 Rkns.Renderer.EdgeRemoveButton.prototype.show = function() { |
|
1283 this.sector.show(); |
|
1284 } |
|
1285 |
|
1286 Rkns.Renderer.EdgeRemoveButton.prototype.hide = function() { |
|
1287 this.sector.hide(); |
|
1288 } |
|
1289 |
|
1290 Rkns.Renderer.EdgeRemoveButton.prototype.select = function() { |
|
1291 this.sector.select(); |
|
1292 } |
|
1293 |
|
1294 Rkns.Renderer.EdgeRemoveButton.prototype.unselect = function(_newTarget) { |
|
1295 this.sector.unselect(); |
|
1296 if (!_newTarget || (_newTarget !== this.edge_representation && _newTarget.edge_representation !== this.edge_representation)) { |
|
1297 this.edge_representation.unselect(); |
|
1298 } |
|
1299 } |
1242 } |
1300 |
1243 |
1301 Rkns.Renderer.EdgeRemoveButton.prototype.mouseup = function() { |
1244 Rkns.Renderer.EdgeRemoveButton.prototype.mouseup = function() { |
1302 this.renderer.removeRepresentationsOfType("editor"); |
1245 this.renderer.removeRepresentationsOfType("editor"); |
1303 if (this.renderer.isEditable() && confirm(this.renderer.renkan.translate('Do you really wish to remove edge ') + '"' + this.edge_representation.model.get("title") + '"?')) { |
1246 if (this.renderer.isEditable() && confirm(this.renkan.translate('Do you really wish to remove edge ') + '"' + this.source_representation.model.get("title") + '"?')) { |
1304 this.project.removeEdge(this.edge_representation.model); |
1247 this.project.removeEdge(this.source_representation.model); |
1305 } |
1248 } |
1306 } |
|
1307 |
|
1308 Rkns.Renderer.EdgeRemoveButton.prototype.destroy = function() { |
|
1309 this.sector.destroy(); |
|
1310 } |
1249 } |
1311 |
1250 |
1312 /* */ |
1251 /* */ |
1313 |
1252 |
1314 Rkns.Renderer.MiniFrame = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
1253 Rkns.Renderer.MiniFrame = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); |
1700 }, 2000); |
1639 }, 2000); |
1701 } |
1640 } |
1702 } |
1641 } |
1703 |
1642 |
1704 Rkns.Renderer.Scene.prototype.template = Rkns._.template( |
1643 Rkns.Renderer.Scene.prototype.template = Rkns._.template( |
1705 '<div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2>' |
1644 '<% if (options.show_top_bar) { %><div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2>' |
1706 + '<% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %>' |
1645 + '<% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %>' |
1707 + '<div class="Rk-Users"><div class="Rk-CurrentUser"><span class="Rk-CurrentUser-Color"></span><span class="Rk-CurrentUser-Name"><unknown user></span></div><ul class="Rk-UserList"></ul></div>' |
1646 + '<div class="Rk-Users"><div class="Rk-CurrentUser"><span class="Rk-CurrentUser-Color"></span><span class="Rk-CurrentUser-Name"><unknown user></span></div><ul class="Rk-UserList"></ul></div>' |
1708 + '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-FullScreen-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Full Screen")%></div></div></div>' |
1647 + '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-FullScreen-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Full Screen")%></div></div></div>' |
1709 + '<% if (options.editor_mode) { %>' |
1648 + '<% if (options.editor_mode) { %>' |
1710 + '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddNode-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Node")%></div></div></div>' |
1649 + '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddNode-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Node")%></div></div></div>' |
1711 + '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddEdge-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Edge")%></div></div></div>' |
1650 + '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddEdge-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Edge")%></div></div></div>' |
1712 + '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Save-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"> </div></div></div>' |
1651 + '<div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Save-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents"> </div></div></div>' |
1713 + '<div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Bookmarklet-Button" href="#"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents">' |
1652 + '<div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Bookmarklet-Button" href="#"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Tip"></div><div class="Rk-TopBar-Tooltip-Contents">' |
1714 + '<%-translate("Renkan \'Drag-to-Add\' bookmarklet")%></div></div></a>' |
1653 + '<%-translate("Renkan \'Drag-to-Add\' bookmarklet")%></div></div></a>' |
1715 + '<div class="Rk-TopBar-Separator"></div></div>' |
1654 + '<div class="Rk-TopBar-Separator"></div></div>' |
1716 + '<% } %>' |
1655 + '<% } } %>' |
1717 + '<canvas class="Rk-Canvas" resize></canvas><div class="Rk-Editor"><div class="Rk-Notifications"></div>' |
1656 + '<div class="Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>"><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Editor"><div class="Rk-Notifications"></div>' |
1718 + '<% if (options.show_bins) { %><div class="Rk-Fold-Bins">«</div><% } %>' |
1657 + '<% if (options.show_bins) { %><div class="Rk-Fold-Bins">«</div><% } %>' |
1719 + '<div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div></div>' |
1658 + '<div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div></div>' |
1720 + '</div>' |
1659 + '</div></div>' |
1721 ); |
1660 ); |
1722 |
1661 |
1723 Rkns.Renderer.Scene.prototype.addToBundles = function(_edgeRepr) { |
1662 Rkns.Renderer.Scene.prototype.addToBundles = function(_edgeRepr) { |
1724 var _bundle = Rkns._(this.bundles).find(function(_bundle) { |
1663 var _bundle = Rkns._(this.bundles).find(function(_bundle) { |
1725 return ( |
1664 return ( |