diff -r 9b8df8d779f5 -r 009427475db2 client/js/paper-renderer.js --- a/client/js/paper-renderer.js Wed Apr 24 10:30:28 2013 +0200 +++ b/client/js/paper-renderer.js Mon May 06 15:14:29 2013 +0200 @@ -1,5 +1,4 @@ Rkns.Renderer = { - _MINIMAP_MARGIN: 20, _MIN_DRAG_DISTANCE: 2, _NODE_BUTTON_WIDTH: 40, _EDGE_BUTTON_INNER: 2, @@ -11,7 +10,6 @@ _NODE_SIZE_STEP: Math.LN2/4, _MIN_SCALE: 1/20, _MAX_SCALE: 20, - _AUTOSCALE_MARGIN: 50, _MOUSEMOVE_RATE: 80, _DOUBLETAP_DELAY: 800, _DOUBLETAP_DISTANCE: 20*20, @@ -838,24 +836,24 @@ Rkns.Renderer.NodeEditor.prototype.template = Rkns._.template( '
<%-renkan.translate("Size:")%>-<%-node.size%>+
' - + '<%-renkan.translate("Size:")%>-<%-node.size%>+
<% } %>' + + '<% if (options.show_node_editor_color) { %><%-renkan.translate("Created by:")%> <%- Rkns.Renderer.shortenText(node.created_by_title, 25) %>
<% } %>' + + '<% } %>' + + '<% if (options.show_node_editor_creator && node.has_creator) { %><%-renkan.translate("Created by:")%> <%- Rkns.Renderer.shortenText(node.created_by_title, 25) %>
<% } %>' ); Rkns.Renderer.NodeEditor.prototype.readOnlyTemplate = Rkns._.template( - '<%-node.description%>
' - + '<% if (node.image) { %><%-renkan.translate("Created by:")%><%- Rkns.Renderer.shortenText(node.created_by_title, 25) %>
<% } %>' + + '<% if (node.uri && options.show_node_tooltip_uri) { %><% } %>' + + '<% if (options.show_node_tooltip_description) { %><%-node.description%>
<% } %>' + + '<% if (node.image && options.show_node_tooltip_image) { %><%-renkan.translate("Created by:")%><%- Rkns.Renderer.shortenText(node.created_by_title, 25) %>
<% } %>' ); Rkns.Renderer.NodeEditor.prototype.draw = function() { @@ -879,7 +877,8 @@ created_by_title: _created_by.get("title"), size: (_size > 0 ? "+" : "") + _size }, - renkan: this.renkan + renkan: this.renkan, + options: this.options })); this.redraw(); var _this = this, @@ -895,16 +894,19 @@ var onFieldChange = Rkns._(function() { Rkns._(function() { if (_this.renderer.isEditable()) { - var _uri = _this.editor_$.find(".Rk-Edit-URI").val(), - _image = _this.editor_$.find(".Rk-Edit-Image").val(); - _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _image || _image_placeholder); - _this.editor_$.find(".Rk-Edit-Goto").attr("href",_uri); var _data = { - title: _this.editor_$.find(".Rk-Edit-Title").val(), - description: _this.editor_$.find(".Rk-Edit-Description").val(), - uri: _uri, - image: _image + title: _this.editor_$.find(".Rk-Edit-Title").val() }; + if (_this.options.show_node_editor_url) { + _data.uri = _this.editor_$.find(".Rk-Edit-URI").val(); + } + if (_this.options.show_node_editor_image) { + _data.image = _this.editor_$.find(".Rk-Edit-Image").val(); + _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder); + } + if (_this.options.show_node_editor_description) { + _data.description = _this.editor_$.find(".Rk-Edit-Description").val(); + } _model.set(_data); _this.redraw(); } else { @@ -1015,28 +1017,28 @@ Rkns.Renderer.EdgeEditor.prototype.template = Rkns._.template( '<%- renkan.translate("Change edge direction") %>
<% } %>' + + '<% if (options.show_edge_editor_nodes) { %><%-renkan.translate("From:")%><%- Rkns.Renderer.shortenText(edge.from_title, 25) %>
' + + '<%-renkan.translate("To:")%><%- Rkns.Renderer.shortenText(edge.to_title, 25) %>
<% } %>' + + '<% if (options.show_edge_editor_creator && edge.has_creator) { %><%-renkan.translate("Created by:")%><%- Rkns.Renderer.shortenText(edge.created_by_title, 25) %>
<% } %>' ); Rkns.Renderer.EdgeEditor.prototype.readOnlyTemplate = Rkns._.template( - '<%-edge.description%>
' - + '<%-renkan.translate("From:")%><%- Rkns.Renderer.shortenText(edge.from_title, 25) %>
' - + '<%-renkan.translate("To:")%><%- Rkns.Renderer.shortenText(edge.to_title, 25) %>
' - + '<% if (edge.has_creator) { %><%-renkan.translate("Created by:")%><%- Rkns.Renderer.shortenText(edge.created_by_title, 25) %>
<% } %>' + + '<% if (options.show_edge_tooltip_nodes) { %><%-renkan.translate("From:")%><%- Rkns.Renderer.shortenText(edge.from_title, 25) %>
' + + '<%-renkan.translate("To:")%><%- Rkns.Renderer.shortenText(edge.to_title, 25) %>
<% } %>' + + '<% if (options.show_edge_tooltip_creator && edge.has_creator) { %><%-renkan.translate("Created by:")%><%- Rkns.Renderer.shortenText(edge.created_by_title, 25) %>
<% } %>' ); Rkns.Renderer.EdgeEditor.prototype.draw = function() { @@ -1062,7 +1064,7 @@ created_by_title: _created_by.get("title") }, renkan: this.renkan, - properties: this.options.properties + options: this.options, })); this.redraw(); var _this = this, @@ -1077,11 +1079,13 @@ var onFieldChange = Rkns._(function() { Rkns._(function() { if (_this.renderer.isEditable()) { - _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(), - uri: _this.editor_$.find(".Rk-Edit-URI").val() + title: _this.editor_$.find(".Rk-Edit-Title").val() }; + if (_this.options.show_edge_editor_uri) { + _data.uri = _this.editor_$.find(".Rk-Edit-URI").val(); + } + _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri); _model.set(_data); paper.view.draw(); } else { @@ -2001,7 +2005,7 @@ _miny = Math.min.apply(Math, _yy), _maxx = Math.max.apply(Math, _xx), _maxy = Math.max.apply(Math, _yy); - var _scale = Math.max(Rkns.Renderer._MIN_SCALE, Math.min(Rkns.Renderer._MAX_SCALE, (paper.view.size.width - 2 * Rkns.Renderer._AUTOSCALE_MARGIN) / (_maxx - _minx), (paper.view.size.height - 2 * Rkns.Renderer._AUTOSCALE_MARGIN) / (_maxy - _miny))); + var _scale = Math.max(Rkns.Renderer._MIN_SCALE, Math.min(Rkns.Renderer._MAX_SCALE, (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny))); this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale))); } if (nodes.length === 1) { @@ -2027,8 +2031,8 @@ var _scale = Math.min( this.scale * .8 * this.renkan.options.minimap_width / paper.view.bounds.width, this.scale * .8 * this.renkan.options.minimap_height / paper.view.bounds.height, - ( this.renkan.options.minimap_width - 2 * Rkns.Renderer._MINIMAP_MARGIN ) / (_maxx - _minx), - ( this.renkan.options.minimap_height - 2 * Rkns.Renderer._MINIMAP_MARGIN ) / (_maxy - _miny) + ( this.renkan.options.minimap_width - 2 * this.renkan.options.minimap_padding ) / (_maxx - _minx), + ( this.renkan.options.minimap_height - 2 * this.renkan.options.minimap_padding ) / (_maxy - _miny) ); this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)); this.minimap.scale = _scale;