189 this.circle.strokeWidth = this.options.node_stroke_width; |
193 this.circle.strokeWidth = this.options.node_stroke_width; |
190 this.h_ratio = 1; |
194 this.h_ratio = 1; |
191 } else { |
195 } else { |
192 this.h_ratio = 0; |
196 this.h_ratio = 0; |
193 } |
197 } |
194 this.title = Rkns.$('<div class="Rk-Label">').appendTo(this.renderer.labels_$); |
198 this.title = $('<div class="Rk-Label">').appendTo(this.renderer.labels_$); |
195 if (this.options.editor_mode) { |
199 if (this.options.editor_mode) { |
196 this.normal_buttons = [ |
200 this.normal_buttons = [ |
197 new NodeEditButton(this.renderer, null), |
201 new NodeEditButton(this.renderer, null), |
198 new NodeRemoveButton(this.renderer, null), |
202 new NodeRemoveButton(this.renderer, null), |
199 new NodeLinkButton(this.renderer, null), |
203 new NodeLinkButton(this.renderer, null), |
307 minisize = new paper.Size([miniradius, miniradius]); |
311 minisize = new paper.Size([miniradius, miniradius]); |
308 this.minimap_circle.fitBounds(minipos.subtract(minisize), minisize.multiply(2)); |
312 this.minimap_circle.fitBounds(minipos.subtract(minisize), minisize.multiply(2)); |
309 } |
313 } |
310 |
314 |
311 if (!_dontRedrawEdges) { |
315 if (!_dontRedrawEdges) { |
312 Rkns._.each(this.project.get("edges").filter(function (ed) { return ((ed.to === this.model) || (ed.from === this.model));}), function(edge, index, list){ |
316 var _this = this; |
313 var repr = this.renderer.getRepresentationByModel(edge); |
317 _.each( |
314 if (repr && typeof repr.from_representation !== "undefined" && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") { |
318 this.project.get("edges").filter( |
315 repr.redraw(); |
319 function (ed) { |
316 } |
320 return ((ed.get("to") === _this.model) || (ed.get("from") === _this.model)); |
317 }, this); |
321 } |
|
322 ), |
|
323 function(edge, index, list) { |
|
324 var repr = _this.renderer.getRepresentationByModel(edge); |
|
325 if (repr && typeof repr.from_representation !== "undefined" && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") { |
|
326 repr.redraw(); |
|
327 } |
|
328 } |
|
329 ); |
318 } |
330 } |
319 |
331 |
320 }, |
332 }, |
321 showImage: function() { |
333 showImage: function() { |
322 if (typeof this.renderer.image_cache[this.img] === "undefined") { |
334 if (typeof this.renderer.image_cache[this.img] === "undefined") { |
583 [ 0, 0 ], |
595 [ 0, 0 ], |
584 [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ], |
596 [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ], |
585 [ 0, this.options.edge_arrow_width ] |
597 [ 0, this.options.edge_arrow_width ] |
586 ); |
598 ); |
587 this.arrow.__representation = this; |
599 this.arrow.__representation = this; |
588 this.text = Rkns.$('<div class="Rk-Label Rk-Edge-Label">').appendTo(this.renderer.labels_$); |
600 this.text = $('<div class="Rk-Label Rk-Edge-Label">').appendTo(this.renderer.labels_$); |
589 this.arrow_angle = 0; |
601 this.arrow_angle = 0; |
590 if (this.options.editor_mode) { |
602 if (this.options.editor_mode) { |
591 this.normal_buttons = [ |
603 this.normal_buttons = [ |
592 new EdgeEditButton(this.renderer, null), |
604 new EdgeEditButton(this.renderer, null), |
593 new EdgeRemoveButton(this.renderer, null), |
605 new EdgeRemoveButton(this.renderer, null), |
874 |
886 |
875 /* */ |
887 /* */ |
876 |
888 |
877 var _BaseEditor = Renderer._BaseEditor = Rkns.Utils.inherit(_BaseRepresentation); |
889 var _BaseEditor = Renderer._BaseEditor = Rkns.Utils.inherit(_BaseRepresentation); |
878 |
890 |
879 Rkns._(_BaseEditor.prototype).extend({ |
891 _(_BaseEditor.prototype).extend({ |
880 _init: function() { |
892 _init: function() { |
881 this.renderer.buttons_layer.activate(); |
893 this.renderer.buttons_layer.activate(); |
882 this.type = "editor"; |
894 this.type = "editor"; |
883 this.editor_block = new paper.Path(); |
895 this.editor_block = new paper.Path(); |
884 var _pts = Rkns._(Rkns._.range(8)).map(function() {return [0,0];}); |
896 var _pts = _(_.range(8)).map(function() {return [0,0];}); |
885 this.editor_block.add.apply(this.editor_block, _pts); |
897 this.editor_block.add.apply(this.editor_block, _pts); |
886 this.editor_block.strokeWidth = this.options.tooltip_border_width; |
898 this.editor_block.strokeWidth = this.options.tooltip_border_width; |
887 this.editor_block.strokeColor = this.options.tooltip_border_color; |
899 this.editor_block.strokeColor = this.options.tooltip_border_color; |
888 this.editor_block.opacity = .8; |
900 this.editor_block.opacity = .8; |
889 this.editor_$ = Rkns.$('<div>') |
901 this.editor_$ = $('<div>') |
890 .appendTo(this.renderer.editor_$) |
902 .appendTo(this.renderer.editor_$) |
891 .css({ |
903 .css({ |
892 position: "absolute", |
904 position: "absolute", |
893 opacity: .8 |
905 opacity: .8 |
894 }) |
906 }) |
902 |
914 |
903 /* */ |
915 /* */ |
904 |
916 |
905 var NodeEditor = Renderer.NodeEditor = Rkns.Utils.inherit(_BaseEditor); |
917 var NodeEditor = Renderer.NodeEditor = Rkns.Utils.inherit(_BaseEditor); |
906 |
918 |
907 Rkns._(NodeEditor.prototype).extend({ |
919 _(NodeEditor.prototype).extend({ |
908 template: Rkns._.template( |
920 template: _.template( |
909 '<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Node")%></span></h2>' |
921 '<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Node")%></span></h2>' |
910 + '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-node.title%>"/></p>' |
922 + '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-node.title%>"/></p>' |
911 + '<% if (options.show_node_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-node.uri%>"/><a class="Rk-Edit-Goto" href="<%-node.uri%>" target="_blank"></a></p><% } %>' |
923 + '<% if (options.show_node_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-node.uri%>"/><a class="Rk-Edit-Goto" href="<%-node.uri%>" target="_blank"></a></p><% } %>' |
912 + '<% if (options.show_node_editor_description) { %><p><label><%-renkan.translate("Description:")%></label><textarea class="Rk-Edit-Description"><%-node.description%></textarea></p><% } %>' |
924 + '<% if (options.show_node_editor_description) { %><p><label><%-renkan.translate("Description:")%></label><textarea class="Rk-Edit-Description"><%-node.description%></textarea></p><% } %>' |
913 + '<% if (options.show_node_editor_size) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Size:")%></span><a href="#" class="Rk-Edit-Size-Down">-</a><span class="Rk-Edit-Size-Value"><%-node.size%></span><a href="#" class="Rk-Edit-Size-Up">+</a></p><% } %>' |
925 + '<% if (options.show_node_editor_size) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Size:")%></span><a href="#" class="Rk-Edit-Size-Down">-</a><span class="Rk-Edit-Size-Value"><%-node.size%></span><a href="#" class="Rk-Edit-Size-Up">+</a></p><% } %>' |
914 + '<% if (options.show_node_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.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">' |
926 + '<% if (options.show_node_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.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>' |
915 + '<% _(Rkns.pickerColors).each(function(c) { %><li data-color="<%=c%>" style="background: <%=c%>"></li><% }); %></ul><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>' |
927 + '<%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>' |
916 + '<% if (options.show_node_editor_image) { %><div class="Rk-Edit-ImgWrap"><div class="Rk-Edit-ImgPreview"><img src="<%-node.image || node.image_placeholder%>" />' |
928 + '<% if (options.show_node_editor_image) { %><div class="Rk-Edit-ImgWrap"><div class="Rk-Edit-ImgPreview"><img src="<%-node.image || node.image_placeholder%>" />' |
917 + '<% if (node.clip_path) { %><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none"><path style="stroke-width: .02; stroke:red; fill-opacity:.3; fill:red;" d="<%- node.clip_path %>"/></svg><% }%>' |
929 + '<% if (node.clip_path) { %><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none"><path style="stroke-width: .02; stroke:red; fill-opacity:.3; fill:red;" d="<%- node.clip_path %>"/></svg><% }%>' |
918 + '</div></div><p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p>' |
930 + '</div></div><p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p>' |
919 + '<p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p><% } %>' |
931 + '<p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p><% } %>' |
920 + '<% if (options.show_node_editor_creator && node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>' |
932 + '<% if (options.show_node_editor_creator && node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>' |
921 ), |
933 ), |
922 readOnlyTemplate: Rkns._.template( |
934 readOnlyTemplate: _.template( |
923 '<h2><span class="Rk-CloseX">×</span><% if (options.show_node_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-node.color%>;"></span><% } %>' |
935 '<h2><span class="Rk-CloseX">×</span><% if (options.show_node_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-node.color%>;"></span><% } %>' |
924 + '<span class="Rk-Display-Title"><% if (node.uri) { %><a href="<%-node.uri%>" target="_blank"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2>' |
936 + '<span class="Rk-Display-Title"><% if (node.uri) { %><a href="<%-node.uri%>" target="_blank"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2>' |
925 + '<% if (node.uri && options.show_node_tooltip_uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %>' |
937 + '<% if (node.uri && options.show_node_tooltip_uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %>' |
926 + '<% if (options.show_node_tooltip_description) { %><p><%-node.description%></p><% } %>' |
938 + '<% if (options.show_node_tooltip_description) { %><p><%-node.description%></p><% } %>' |
927 + '<% if (node.image && options.show_node_tooltip_image) { %><img class="Rk-Display-ImgPreview" src="<%-node.image%>" /><% } %>' |
939 + '<% if (node.image && options.show_node_tooltip_image) { %><img class="Rk-Display-ImgPreview" src="<%-node.image%>" /><% } %>' |
1092 |
1104 |
1093 /* */ |
1105 /* */ |
1094 |
1106 |
1095 var EdgeEditor = Renderer.EdgeEditor = Rkns.Utils.inherit(_BaseEditor); |
1107 var EdgeEditor = Renderer.EdgeEditor = Rkns.Utils.inherit(_BaseEditor); |
1096 |
1108 |
1097 Rkns._(EdgeEditor.prototype).extend({ |
1109 _(EdgeEditor.prototype).extend({ |
1098 template: Rkns._.template( |
1110 template: _.template( |
1099 '<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Edge")%></span></h2>' |
1111 '<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Edge")%></span></h2>' |
1100 + '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-edge.title%>"/></p>' |
1112 + '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-edge.title%>"/></p>' |
1101 + '<% if (options.show_edge_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-edge.uri%>"/><a class="Rk-Edit-Goto" href="<%-edge.uri%>" target="_blank"></a></p>' |
1113 + '<% if (options.show_edge_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-edge.uri%>"/><a class="Rk-Edit-Goto" href="<%-edge.uri%>" target="_blank"></a></p>' |
1102 + '<% if (options.properties.length) { %><p><label><%-renkan.translate("Choose from vocabulary:")%></label><select class="Rk-Edit-Vocabulary">' |
1114 + '<% if (options.properties.length) { %><p><label><%-renkan.translate("Choose from vocabulary:")%></label><select class="Rk-Edit-Vocabulary">' |
1103 + '<% _(options.properties).each(function(ontology) { %><option class="Rk-Edit-Vocabulary-Class" value=""><%- renkan.translate(ontology.label) %></option>' |
1115 + '<% _(options.properties).each(function(ontology) { %><option class="Rk-Edit-Vocabulary-Class" value=""><%- renkan.translate(ontology.label) %></option>' |
1104 + '<% _(ontology.properties).each(function(property) { var uri = ontology["base-uri"] + property.uri; %><option class="Rk-Edit-Vocabulary-Property" value="<%- uri %>' |
1116 + '<% _(ontology.properties).each(function(property) { var uri = ontology["base-uri"] + property.uri; %><option class="Rk-Edit-Vocabulary-Property" value="<%- uri %>' |
1105 + '"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option>' |
1117 + '"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option>' |
1106 + '<% }) %><% }) %></select></p><% } } %>' |
1118 + '<% }) %><% }) %></select></p><% } } %>' |
1107 + '<% if (options.show_edge_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.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">' |
1119 + '<% if (options.show_edge_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.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>' |
1108 + '<% _(Rkns.pickerColors).each(function(c) { %><li data-color="<%=c%>" style="background: <%=c%>"></li><% }); %></ul><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>' |
1120 + '<%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>' |
1109 + '<% if (options.show_edge_editor_direction) { %><p><span class="Rk-Edit-Direction"><%- renkan.translate("Change edge direction") %></span></p><% } %>' |
1121 + '<% if (options.show_edge_editor_direction) { %><p><span class="Rk-Edit-Direction"><%- renkan.translate("Change edge direction") %></span></p><% } %>' |
1110 + '<% if (options.show_edge_editor_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p>' |
1122 + '<% if (options.show_edge_editor_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p>' |
1111 + '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' |
1123 + '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' |
1112 + '<% if (options.show_edge_editor_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>' |
1124 + '<% if (options.show_edge_editor_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>' |
1113 ), |
1125 ), |
1114 readOnlyTemplate: Rkns._.template( |
1126 readOnlyTemplate: _.template( |
1115 '<h2><span class="Rk-CloseX">×</span><% if (options.show_edge_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span><% } %>' |
1127 '<h2><span class="Rk-CloseX">×</span><% if (options.show_edge_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span><% } %>' |
1116 + '<span class="Rk-Display-Title"><% if (edge.uri) { %><a href="<%-edge.uri%>" target="_blank"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2>' |
1128 + '<span class="Rk-Display-Title"><% if (edge.uri) { %><a href="<%-edge.uri%>" target="_blank"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2>' |
1117 + '<% if (options.show_edge_tooltip_uri && edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %>' |
1129 + '<% if (options.show_edge_tooltip_uri && edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %>' |
1118 + '<p><%-edge.description%></p>' |
1130 + '<p><%-edge.description%></p>' |
1119 + '<% if (options.show_edge_tooltip_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p>' |
1131 + '<% if (options.show_edge_tooltip_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p>' |
1775 |
1787 |
1776 this.$.find(".Rk-PadTitle").on("keyup input paste", function() { |
1788 this.$.find(".Rk-PadTitle").on("keyup input paste", function() { |
1777 _renkan.project.set({"title": $(this).val()}); |
1789 _renkan.project.set({"title": $(this).val()}); |
1778 }); |
1790 }); |
1779 |
1791 |
1780 this.renkan.project.get("users").each(function(_user) { |
1792 var _thRedrawUsers = _.throttle(function() { |
1781 _this.addUser(_user); |
1793 _this.redrawUsers(); |
1782 }); |
1794 }, 100); |
1783 |
1795 |
1784 this.renkan.project.on("add:users", function(_user) { |
1796 _thRedrawUsers(); |
1785 _this.addUser(_user); |
1797 |
1786 }); |
1798 this.renkan.project.on("add:users remove:users", _thRedrawUsers); |
|
1799 |
1787 this.renkan.project.on("add:nodes", function(_node) { |
1800 this.renkan.project.on("add:nodes", function(_node) { |
1788 _this.addRepresentation("Node", _node); |
1801 _this.addRepresentation("Node", _node); |
1789 _thRedraw(); |
1802 _thRedraw(); |
1790 }); |
1803 }); |
1791 this.renkan.project.on("add:edges", function(_edge) { |
1804 this.renkan.project.on("add:edges", function(_edge) { |
1850 }, 2000); |
1890 }, 2000); |
1851 } |
1891 } |
1852 |
1892 |
1853 }; |
1893 }; |
1854 |
1894 |
1855 Rkns._(Scene.prototype).extend({ |
1895 _(Scene.prototype).extend({ |
1856 template: Rkns._.template( |
1896 template: _.template( |
1857 '<% if (options.show_top_bar) { %><div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2>' |
1897 '<% if (options.show_top_bar) { %><div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2>' |
1858 + '<% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %>' |
1898 + '<% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %>' |
1859 + '<% if (options.show_user_list) { %><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><% } %>' |
1899 + '<% if (options.show_user_list) { %><div class="Rk-Users"><div class="Rk-CurrentUser"><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-CurrentUser-Color"><span class="Rk-Edit-ColorTip"></span></span>' |
|
1900 + '<%= colorPicker %></div><span class="Rk-CurrentUser-Name"><unknown user></span></div><ul class="Rk-UserList"></ul></div><% } %>' |
1860 + '<% if (options.home_button_url) {%><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Home-Button" href="<%- options.home_button_url %>"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents">' |
1901 + '<% if (options.home_button_url) {%><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Home-Button" href="<%- options.home_button_url %>"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents">' |
1861 + '<%- translate(options.home_button_title) %></div></div></a><% } %>' |
1902 + '<%- translate(options.home_button_title) %></div></div></a><% } %>' |
1862 + '<% if (options.show_fullscreen_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-FullScreen-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Full Screen")%></div></div></div><% } %>' |
1903 + '<% if (options.show_fullscreen_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-FullScreen-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Full Screen")%></div></div></div><% } %>' |
1863 + '<% if (options.editor_mode) { %>' |
1904 + '<% if (options.editor_mode) { %>' |
1864 + '<% if (options.show_addnode_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddNode-Button"><div class="Rk-TopBar-Tooltip">' |
1905 + '<% if (options.show_addnode_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddNode-Button"><div class="Rk-TopBar-Tooltip">' |
2111 var _this = this; |
2153 var _this = this; |
2112 _collection.forEach(function(_model) { |
2154 _collection.forEach(function(_model) { |
2113 _this.addRepresentation(_type, _model); |
2155 _this.addRepresentation(_type, _model); |
2114 }); |
2156 }); |
2115 }, |
2157 }, |
2116 userTemplate: Rkns._.template( |
2158 userTemplate: _.template( |
2117 '<li class="Rk-User"><span class="Rk-UserColor" style="background:<%=background%>;"></span><%=name%></li>' |
2159 '<li class="Rk-User"><span class="Rk-UserColor" style="background:<%=background%>;"></span><%=name%></li>' |
2118 ), |
2160 ), |
2119 addUser: function(_user) { |
2161 redrawUsers: function() { |
2120 if (_user.get("_id") === this.renkan.current_user) { |
2162 if (!this.renkan.options.show_user_list) { |
2121 this.$.find(".Rk-CurrentUser-Name").text(_user.get("title")); |
2163 return; |
2122 this.$.find(".Rk-CurrentUser-Color").css("background", _user.get("color")); |
2164 } |
2123 } else { |
2165 var allUsers = [].concat((this.renkan.project.current_user_list || {}).models || [], (this.renkan.project.get("users") || {}).models || []), |
2124 this.$.find(".Rk-UserList").append( |
2166 ulistHtml = '', |
2125 Rkns.$( |
2167 $userpanel = this.$.find(".Rk-Users"), |
2126 this.userTemplate({ |
2168 $name = $userpanel.find(".Rk-CurrentUser-Name"), |
2127 name: _user.get("title"), |
2169 $cpwrapper = $userpanel.find(".Rk-Edit-ColorPicker-Wrapper"), |
2128 background: _user.get("color") |
2170 $cpitems = $userpanel.find(".Rk-Edit-ColorPicker li"), |
2129 }) |
2171 $colorsquare = $userpanel.find(".Rk-CurrentUser-Color"), |
2130 ) |
2172 _this = this; |
2131 ); |
2173 $name.off("click").text(this.renkan.translate("<unknown user>")); |
2132 } |
2174 $cpitems.off("mouseleave click"); |
|
2175 allUsers.forEach(function(_user) { |
|
2176 if (_user.get("_id") === _this.renkan.current_user) { |
|
2177 $name.text(_user.get("title")); |
|
2178 if (_this.isEditable()) { |
|
2179 $name.click(function() { |
|
2180 var $this = $(this), |
|
2181 $input = $('<input>').val(_user.get("title")).blur(function() { |
|
2182 _user.set("title", $(this).val()); |
|
2183 _this.redrawUsers(); |
|
2184 _this.redraw(); |
|
2185 }); |
|
2186 $this.empty().html($input); |
|
2187 $input.select(); |
|
2188 }); |
|
2189 |
|
2190 $cpitems.click( |
|
2191 function(_e) { |
|
2192 _e.preventDefault(); |
|
2193 if (_this.isEditable()) { |
|
2194 _user.set("color", $(this).attr("data-color")); |
|
2195 } |
|
2196 $(this).parent().hide(); |
|
2197 } |
|
2198 ).mouseleave(function() { |
|
2199 $colorsquare.css("background", _user.get("color")); |
|
2200 }); |
|
2201 $colorsquare.css("background", _user.get("color")); |
|
2202 } |
|
2203 |
|
2204 } else { |
|
2205 ulistHtml += _this.userTemplate({ |
|
2206 name: _user.get("title"), |
|
2207 background: _user.get("color") |
|
2208 }); |
|
2209 } |
|
2210 }); |
|
2211 $userpanel.find(".Rk-UserList").html(ulistHtml); |
2133 }, |
2212 }, |
2134 removeRepresentation: function(_representation) { |
2213 removeRepresentation: function(_representation) { |
2135 _representation.destroy(); |
2214 _representation.destroy(); |
2136 this.representations = Rkns._(this.representations).reject( |
2215 this.representations = _(this.representations).reject( |
2137 function(_repr) { |
2216 function(_repr) { |
2138 return _repr == _representation; |
2217 return _repr == _representation; |
2139 } |
2218 } |
2140 ); |
2219 ); |
2141 }, |
2220 }, |
2142 getRepresentationByModel: function(_model) { |
2221 getRepresentationByModel: function(_model) { |
2143 if (!_model) { |
2222 if (!_model) { |
2144 return undefined; |
2223 return undefined; |
2145 } |
2224 } |
2146 return Rkns._(this.representations).find(function(_repr) { |
2225 return _(this.representations).find(function(_repr) { |
2147 return _repr.model === _model; |
2226 return _repr.model === _model; |
2148 }); |
2227 }); |
2149 }, |
2228 }, |
2150 removeRepresentationsOfType: function(_type) { |
2229 removeRepresentationsOfType: function(_type) { |
2151 var _representations = Rkns._(this.representations).filter(function(_repr) { |
2230 var _representations = _(this.representations).filter(function(_repr) { |
2152 return _repr.type == _type; |
2231 return _repr.type == _type; |
2153 }), |
2232 }), |
2154 _this = this; |
2233 _this = this; |
2155 Rkns._(_representations).each(function(_repr) { |
2234 _(_representations).each(function(_repr) { |
2156 _this.removeRepresentation(_repr); |
2235 _this.removeRepresentation(_repr); |
2157 }); |
2236 }); |
2158 }, |
2237 }, |
2159 highlightModel: function(_model) { |
2238 highlightModel: function(_model) { |
2160 var _repr = this.getRepresentationByModel(_model); |
2239 var _repr = this.getRepresentationByModel(_model); |
2161 if (_repr) { |
2240 if (_repr) { |
2162 _repr.highlight(); |
2241 _repr.highlight(); |
2163 } |
2242 } |
2164 }, |
2243 }, |
2165 unhighlightAll: function(_model) { |
2244 unhighlightAll: function(_model) { |
2166 Rkns._(this.representations).each(function(_repr) { |
2245 _(this.representations).each(function(_repr) { |
2167 _repr.unhighlight(); |
2246 _repr.unhighlight(); |
2168 }); |
2247 }); |
2169 }, |
2248 }, |
2170 unselectAll: function(_model) { |
2249 unselectAll: function(_model) { |
2171 Rkns._(this.representations).each(function(_repr) { |
2250 _(this.representations).each(function(_repr) { |
2172 _repr.unselect(); |
2251 _repr.unselect(); |
2173 }); |
2252 }); |
2174 }, |
2253 }, |
2175 redraw: function() { |
2254 redraw: function() { |
2176 Rkns._(this.representations).each(function(_representation) { |
2255 _(this.representations).each(function(_representation) { |
2177 _representation.redraw(true); |
2256 _representation.redraw(true); |
2178 }); |
2257 }); |
2179 if (this.minimap) { |
2258 if (this.minimap) { |
2180 this.redrawMiniframe(); |
2259 this.redrawMiniframe(); |
2181 } |
2260 } |
2354 catch(e) {} |
2433 catch(e) {} |
2355 } |
2434 } |
2356 var newNode = {}; |
2435 var newNode = {}; |
2357 switch(_data["text/x-iri-specific-site"]) { |
2436 switch(_data["text/x-iri-specific-site"]) { |
2358 case "twitter": |
2437 case "twitter": |
2359 var snippet = Rkns.$('<div>').html(_data["text/x-iri-selected-html"]), |
2438 var snippet = $('<div>').html(_data["text/x-iri-selected-html"]), |
2360 tweetdiv = snippet.find(".tweet"); |
2439 tweetdiv = snippet.find(".tweet"); |
2361 newNode.title = _renkan.translate("Tweet by ") + tweetdiv.attr("data-name"); |
2440 newNode.title = _renkan.translate("Tweet by ") + tweetdiv.attr("data-name"); |
2362 newNode.uri = "http://twitter.com/" + tweetdiv.attr("data-screen-name") + "/status/" + tweetdiv.attr("data-tweet-id"); |
2441 newNode.uri = "http://twitter.com/" + tweetdiv.attr("data-screen-name") + "/status/" + tweetdiv.attr("data-tweet-id"); |
2363 newNode.image = tweetdiv.find(".avatar").attr("src"); |
2442 newNode.image = tweetdiv.find(".avatar").attr("src"); |
2364 newNode.description = tweetdiv.find(".js-tweet-text:first").text(); |
2443 newNode.description = tweetdiv.find(".js-tweet-text:first").text(); |
2365 break; |
2444 break; |
2366 case "google": |
2445 case "google": |
2367 var snippet = Rkns.$('<div>').html(_data["text/x-iri-selected-html"]); |
2446 var snippet = $('<div>').html(_data["text/x-iri-selected-html"]); |
2368 newNode.title = snippet.find("h3:first").text().trim(); |
2447 newNode.title = snippet.find("h3:first").text().trim(); |
2369 newNode.uri = snippet.find("h3 a").attr("href"); |
2448 newNode.uri = snippet.find("h3 a").attr("href"); |
2370 newNode.description = snippet.find(".st:first").text().trim(); |
2449 newNode.description = snippet.find(".st:first").text().trim(); |
2371 break; |
2450 break; |
2372 case undefined: |
2451 case undefined: |