diff -r 092fc99f7558 -r 84eea249ce7e client/js/renkan-publish.js --- a/client/js/renkan-publish.js Fri Sep 07 12:26:16 2012 +0200 +++ b/client/js/renkan-publish.js Fri Sep 07 17:50:17 2012 +0200 @@ -27,7 +27,8 @@ Rkns.i18n = { en: { zoom_in: "Zoom In", - zoom_out: "Zoom Out" + zoom_out: "Zoom Out", + see_in_project: 'See also "{node}" in "{project}"' } } @@ -57,13 +58,13 @@ Rkns.Models.RenkanModel = Backbone.RelationalModel.extend({ idAttribute : "_id", constructor: function(options) { - + if (typeof options !== "undefined") { options._id = options._id || options.id || Rkns.Models.getUID(this); options.title = options.title || "(untitled " + this.type + ")"; options.description = options.description || ""; options.uri = options.uri || ""; - + if(typeof this.prepare === "function") { options = this.prepare(options); } @@ -264,25 +265,73 @@ if (typeof _opts.search !== "object" || !_opts.search) { _opts.search = []; } - this.project = new Rkns.Models.Project(); + this.projects = []; this.l10n = Rkns.i18n[_opts.language]; this.$ = Rkns.$("#" + _opts.container); this.$.html(this.template()); - this.renderer = new Rkns.Renderer.Scene(this); + this.uris = {}; + this.active_project = null; + this.renderer = null; } + Rkns.Renkan.prototype.template = Rkns._.template( - '
' + '<%=description%>
' + + '<%-description%>
' + + '' ); Rkns.Renderer.NodeTooltip.prototype.draw = function() { @@ -622,12 +695,30 @@ a: (_uri ? '' : '' ) + _title + (_uri ? '' : '' ), description: _model.get("description").replace(/(\n|\r|\r\n)/mg,' ').substr(0,180).replace(/(^.{150,179})[\s].+$/m,'$1…') })) - this.redraw(); - var _this = this; + var _this = this, + _renkan = this.renderer.renkan, + _uris = _renkan.uris[_uri]; + Rkns._(_uris).each(function(_othernode) { + if (_othernode !== _model && _othernode.get("project") !== _this.project) { + var _otherproj = _othernode.get("project"), + _nodetitle = _othernode.get("title") || "Untitled node" + _projtitle = _otherproj.get("title") || "Untitled node", + _html = _renkan.l10n.see_in_project.replace('{node}',Rkns._.escape(_nodetitle)).replace('{project}',Rkns._.escape(_projtitle)), + _li = Rkns.$("<%=description%>
' + + '<%-description%>
' ); Rkns.Renderer.EdgeTooltip.prototype.draw = function() { @@ -700,8 +791,9 @@ /* */ -Rkns.Renderer.Scene = function(_renkan) { +Rkns.Renderer.Scene = function(_renkan, _project) { this.renkan = _renkan; + this.project = _project; this.$ = Rkns.$(".Rk-Render"); this.representations = []; this.$.html(this.template({ @@ -764,24 +856,26 @@ _this.redraw(); },50); - this.addRepresentations("Node", this.renkan.project.get("nodes")); - this.addRepresentations("Edge", this.renkan.project.get("edges")); + this.addRepresentations("Node", this.project.get("nodes")); + this.addRepresentations("Edge", this.project.get("edges")); - this.renkan.project.on("add:nodes", function(_node) { + this._addNodesBinding = function(_node) { _this.addRepresentation("Node", _node); _thRedraw(); - }); - this.renkan.project.on("add:edges", function(_edge) { + } + this._addEdgesBinding = function(_edge) { _this.addRepresentation("Edge", _edge); _thRedraw(); - }); + } + this.project.on("add:nodes", this._addNodesBinding ); + this.project.on("add:edges", this._addEdgesBinding ); this.redraw(); } Rkns.Renderer.Scene.prototype.template = Rkns._.template( - '