# HG changeset patch # User veltr # Date 1347033017 -7200 # Node ID 84eea249ce7e6b2576d411fda203bcd8b2ea818f # Parent 092fc99f7558cf320110583af5e412fa276952b9 Added multiple graph publishing diff -r 092fc99f7558 -r 84eea249ce7e client/css/renkan-publish.css --- a/client/css/renkan-publish.css Fri Sep 07 12:26:16 2012 +0200 +++ b/client/css/renkan-publish.css Fri Sep 07 17:50:17 2012 +0200 @@ -47,15 +47,33 @@ } a { - color: #6060c0; + color: #303080; +} + +.Rk-ProjectList { + position: absolute; left: 0; top: 0; list-style: none; padding: 0; margin: 0; +} + +.Rk-Project { + list-style: none; margin-right: 5px; padding: 5px; height: 15px; font-size: 13px; font-weight: bold; + float: left; border-top-left-radius: 8px; border-top-right-radius: 8px; + background: #505050; color: #E0E0E0; cursor: pointer; + background: -moz-linear-gradient(top, #333333 20%, #666666 80%); +} + +.Rk-Project:hover { + background: -moz-linear-gradient(bottom, #333333 20%, #666666 80%); +} + +.Rk-Project.active { + background: #505080; + color: #ffffc0; + background: -moz-linear-gradient(bottom, #333366 20%, #666699 80%); } .Rk-Render { - position: absolute; left: 0; top: 0; right: 0; bottom: 0; background: -moz-linear-gradient(top, rgba(180,180,180,.2) 0, rgba(255,255,255,.2) 30%, rgba(255,255,255,.2) 70%, rgba(180,180,180,.2) 100%); -} - -.Rk-Render-Panel { - position: absolute; left: 300px; top: 0; right: 0; bottom: 0; + position: absolute; left: 0; top: 25px; right: 0; bottom: 0; + background: -moz-linear-gradient(top, rgba(180,180,180,.2) 0, rgba(255,255,255,.2) 30%, rgba(255,255,255,.2) 70%, rgba(180,180,180,.2) 100%); } .Rk-Canvas { @@ -79,6 +97,22 @@ margin: 5px 0; font-size: 11px; } +.Rk-RelatedList { + list-style: none; +} + +.Rk-Related { + color: #a000c0; cursor: pointer; +} + +.Rk-Related b { + font-weight: bolder; +} + +.Rk-Related:hover { + text-decoration: underline; +} + .Rk-ZoomButtons { position: absolute; left: 0; top: 0; cursor: pointer; } diff -r 092fc99f7558 -r 84eea249ce7e client/js/paper-renderer.js --- a/client/js/paper-renderer.js Fri Sep 07 12:26:16 2012 +0200 +++ b/client/js/paper-renderer.js Fri Sep 07 17:50:17 2012 +0200 @@ -192,9 +192,25 @@ this.renderer = _renderer; this.project = _renderer.renkan.project; this.model = _model; + if (this.model) { + var _this = this; + this._changeBinding = function() { + _this.redraw(); + } + this._removeBinding = function() { + _renderer.removeRepresentation(_this); + _renderer.redraw(); + } + this.model.on("change", this._changeBinding ); + this.model.on("remove", this._removeBinding ); + } } } +Rkns.Renderer._BaseRepresentation.prototype.super = function(_func) { + Rkns.Renderer._BaseRepresentation.prototype[_func].apply(this, Array.prototype.slice.call(arguments, 1)); +} + Rkns.Renderer._BaseRepresentation.prototype.select = function() {} Rkns.Renderer._BaseRepresentation.prototype.unselect = function() {} @@ -205,7 +221,12 @@ Rkns.Renderer._BaseRepresentation.prototype.mouseup = function() {} -Rkns.Renderer._BaseRepresentation.prototype.destroy = function() {} +Rkns.Renderer._BaseRepresentation.prototype.destroy = function() { + if (this.model) { + this.model.off("change", this._changeBinding ); + this.model.off("remove", this._removeBinding ); + } +} Rkns.Renderer.Node = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); @@ -220,11 +241,11 @@ fontSize: Rkns.Renderer._NODE_FONT_SIZE, fillColor: 'black' }; - this.edit_button = new Rkns.Renderer.NodeEditButton(this.renderer, {}); + this.edit_button = new Rkns.Renderer.NodeEditButton(this.renderer, null); this.edit_button.node_representation = this; - this.remove_button = new Rkns.Renderer.NodeRemoveButton(this.renderer, {}); + this.remove_button = new Rkns.Renderer.NodeRemoveButton(this.renderer, null); this.remove_button.node_representation = this; - this.link_button = new Rkns.Renderer.NodeLinkButton(this.renderer, {}); + this.link_button = new Rkns.Renderer.NodeLinkButton(this.renderer, null); this.link_button.node_representation = this; this.title.paragraphStyle.justification = 'center'; } @@ -342,6 +363,7 @@ } Rkns.Renderer.Node.prototype.destroy = function(_event) { + this.super("destroy"); this.edit_button.destroy(); this.remove_button.destroy(); this.link_button.destroy(); @@ -376,9 +398,9 @@ this.text.paragraphStyle.justification = 'center'; this.text_angle = 0; this.arrow_angle = 0; - this.edit_button = new Rkns.Renderer.EdgeEditButton(this.renderer, {}); + this.edit_button = new Rkns.Renderer.EdgeEditButton(this.renderer, null); this.edit_button.edge_representation = this; - this.remove_button = new Rkns.Renderer.EdgeRemoveButton(this.renderer, {}); + this.remove_button = new Rkns.Renderer.EdgeRemoveButton(this.renderer, null); this.remove_button.edge_representation = this; } @@ -456,6 +478,7 @@ } Rkns.Renderer.Edge.prototype.destroy = function() { + this.super("destroy"); this.line.remove(); this.arrow.remove(); this.text.remove(); @@ -1121,16 +1144,6 @@ Rkns.Renderer.Scene.prototype.addRepresentation = function(_type, _model) { var _repr = new Rkns.Renderer[_type](this, _model); this.representations.push(_repr); - if (_model) { - var _this = this; - _model.on("change", function() { - _repr.redraw(); - }); - _model.on("remove", function() { - _this.removeRepresentation(_repr); - _this.redraw(); - }); - } return _repr; } 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( - '