diff -r 15e048e00002 -r 2a2fcec209d0 client/js/paper-renderer.js --- a/client/js/paper-renderer.js Wed Jul 03 13:42:59 2013 +0200 +++ b/client/js/paper-renderer.js Thu Jul 04 12:43:30 2013 +0200 @@ -282,7 +282,13 @@ var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_nodes) || ""; _text = shortenText(_text, this.options.node_label_max_length); - this.title.text(_text); + + if (typeof this.highlighted === "object") { + this.title.html(this.highlighted.replace(_(_text).escape(),'$1')); + } else { + this.title.text(_text); + } + this.title.css({ left: this.paper_coords.x, top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance, @@ -512,11 +518,12 @@ this._super("unselect"); } }, -highlight: function() { - if (this.highlighted) { +highlight: function(textToReplace) { + var hlvalue = textToReplace || true; + if (this.highlighted === hlvalue) { return; } - this.highlighted = true; + this.highlighted = hlvalue; this.redraw(); this.renderer.throttledPaperDraw(); }, @@ -935,7 +942,7 @@ '

×<% if (options.show_node_tooltip_color) { %><% } %>' + '<% if (node.uri) { %><% } %><%-node.title%><% if (node.uri) { %><% } %>

' + '<% if (node.uri && options.show_node_tooltip_uri) { %>

<%-node.short_uri%>

<% } %>' - + '<% if (options.show_node_tooltip_description) { %>

<%-node.description%>

<% } %>' + + '<% if (options.show_node_tooltip_description) { %>

<%-node.description%>

<% } %>' + '<% if (node.image && options.show_node_tooltip_image) { %><% } %>' + '<% if (node.has_creator && options.show_node_tooltip_creator) { %>

<%-renkan.translate("Created by:")%><%- shortenText(node.created_by_title, 25) %>

<% } %>' ), @@ -1089,6 +1096,14 @@ shiftSize(1); return false; }); + } else { + if (typeof this.source_representation.highlighted === "object") { + var titlehtml = this.source_representation.highlighted.replace(_(_model.get("title")).escape(),'$1'); + this.editor_$.find(".Rk-Display-Title" + (_model.get("uri") ? " a" : "")).html(titlehtml); + if (this.options.show_node_tooltip_description) { + this.editor_$.find(".Rk-Display-Description").html(this.source_representation.highlighted.replace(_(_model.get("description")).escape(),'$1')) + } + } } this.editor_$.find("img").load(function() { _this.redraw(); @@ -1863,6 +1878,33 @@ ); } + if (_renkan.options.show_search_field) { + + var lastval = ''; + + this.$.find(".Rk-GraphSearch-Field").on("keyup change paste input", function() { + var $this = $(this), + val = $this.val(); + if (val === lastval) { + return; + } + if (val.length < 2) { + _renkan.project.get("nodes").each(function(n) { + _this.getRepresentationByModel(n).unhighlight(); + }); + } else { + var rxs = Rkns.Utils.regexpFromTextOrArray(val); + _renkan.project.get("nodes").each(function(n) { + if (rxs.test(n.get("title")) || rxs.test(n.get("description"))) { + _this.getRepresentationByModel(n).highlight(rxs); + } else { + _this.getRepresentationByModel(n).unhighlight(); + } + }); + } + }); + } + this.redraw(); window.setInterval(function() { @@ -1910,8 +1952,8 @@ + '<% if (options.show_open_button) { %>
<%-translate("Open Project")%>
<% } %>' + '<% if (options.show_bookmarklet) { %>
' + '<%-translate("Renkan \'Drag-to-Add\' bookmarklet")%>
<% } %>' - + '
' - + '<% } %><% } %>' + + '
<% }; if (options.show_search_field) { %>' + + '
" />
<% } %><% } %>' + '
' + '
' + '<% if (options.show_bins) { %>
«
<% } %>'