diff -r b5ada3bb8e53 -r 2fad193bae98 client/js/paper-renderer.js --- a/client/js/paper-renderer.js Tue Aug 21 18:49:41 2012 +0200 +++ b/client/js/paper-renderer.js Wed Aug 22 16:50:42 2012 +0200 @@ -154,6 +154,10 @@ Rkns.Renderer._BaseRepresentation.prototype.unselect = function() {} +Rkns.Renderer._BaseRepresentation.prototype.highlight = function() {} + +Rkns.Renderer._BaseRepresentation.prototype.unhighlight = function() {} + Rkns.Renderer._BaseRepresentation.prototype.mouseup = function() {} Rkns.Renderer._BaseRepresentation.prototype.destroy = function() {} @@ -217,6 +221,13 @@ this.edit_button.show(); this.remove_button.show(); this.link_button.show(); + var _uri = this.model.get("uri"); + Rkns.$('.Rk-Bin-Item').each(function() { + var _el = Rkns.$(this); + if (_el.attr("data-uri") == _uri) { + _el.addClass("selected"); + } + }); } Rkns.Renderer.Node.prototype.unselect = function(_newTarget) { @@ -226,6 +237,15 @@ this.link_button.hide(); } this.circle.strokeWidth = 1; + Rkns.$('.Rk-Bin-Item').removeClass("selected"); +} + +Rkns.Renderer.Node.prototype.highlight = function() { + this.circle.fillColor = "#ffffc0"; +} + +Rkns.Renderer.Node.prototype.unhighlight = function(_newTarget) { + this.circle.fillColor = "#ffffff"; } Rkns.Renderer.Node.prototype.mouseup = function(_event) { @@ -237,6 +257,7 @@ Rkns.Renderer.Node.prototype.destroy = function(_event) { this.edit_button.destroy(); this.remove_button.destroy(); + this.link_button.destroy(); this.circle.remove(); this.title.remove(); } @@ -432,7 +453,7 @@ Rkns.Renderer.NodeEditor.prototype.template = Rkns._.template( '
<%=node.created_by_title%>
' ); @@ -460,6 +481,7 @@ paper.view.draw(); }); this.editor_$.find("input, textarea").bind("keyup change", function() { + _this.editor_$.find(".Rk-Edit-Goto").attr("href",_this.editor_$.find(".Rk-Edit-URI").val()); var _data = { title: _this.editor_$.find(".Rk-Edit-Title").val(), description: _this.editor_$.find(".Rk-Edit-Description").val(), @@ -503,7 +525,7 @@ Rkns.Renderer.EdgeEditor.prototype.template = Rkns._.template( '<%=edge.from_title%>
' + '<%=edge.to_title%>
' + '<%=edge.created_by_title%>
' @@ -850,15 +872,17 @@ ); Rkns.Renderer.Scene.prototype.autoScale = function() { - var _xx = this.renkan.project.get("nodes").map(function(_node) { return _node.get("position").x }), - _yy = this.renkan.project.get("nodes").map(function(_node) { return _node.get("position").y }), - _minx = Math.min.apply(Math, _xx), - _miny = Math.min.apply(Math, _yy), - _maxx = Math.max.apply(Math, _xx), - _maxy = Math.max.apply(Math, _yy); - this.scale = Math.min((paper.view.size.width - 2 * this._MARGIN_X) / (_maxx - _minx), (paper.view.size.height - 2 * this._MARGIN_Y) / (_maxy - _miny)); - this.offset = paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(this.scale)); - this.redraw(); + if (this.renkan.project.get("nodes").length) { + var _xx = this.renkan.project.get("nodes").map(function(_node) { return _node.get("position").x }), + _yy = this.renkan.project.get("nodes").map(function(_node) { return _node.get("position").y }), + _minx = Math.min.apply(Math, _xx), + _miny = Math.min.apply(Math, _yy), + _maxx = Math.max.apply(Math, _xx), + _maxy = Math.max.apply(Math, _yy); + this.scale = Math.min((paper.view.size.width - 2 * this._MARGIN_X) / (_maxx - _minx), (paper.view.size.height - 2 * this._MARGIN_Y) / (_maxy - _miny)); + this.offset = paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(this.scale)); + this.redraw(); + } } Rkns.Renderer.Scene.prototype.toPaperCoords = function(_point) { @@ -918,6 +942,19 @@ }); } +Rkns.Renderer.Scene.prototype.highlightModel = function(_model) { + var _repr = this.getRepresentationByModel(_model); + if (_repr) { + _repr.highlight(); + } +} + +Rkns.Renderer.Scene.prototype.unhighlightAll = function(_model) { + Rkns._(this.representations).each(function(_repr) { + _repr.unhighlight(); + }); +} + Rkns.Renderer.Scene.prototype.redraw = function() { Rkns._(this.representations).each(function(_representation) { _representation.redraw();