1801 }); |
1801 }); |
1802 this.$.find(".Rk-ZoomSetSaved").click( function() { |
1802 this.$.find(".Rk-ZoomSetSaved").click( function() { |
1803 var view = _this.renkan.project.get("views")[0]; |
1803 var view = _this.renkan.project.get("views")[0]; |
1804 _this.setScale(view.zoom_level, new paper.Point(view.offset_x, view.offset_y)); |
1804 _this.setScale(view.zoom_level, new paper.Point(view.offset_x, view.offset_y)); |
1805 }); |
1805 }); |
|
1806 if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){ |
|
1807 this.$.find(".Rk-ZoomSetSaved").show(); |
|
1808 } |
1806 this.$.find(".Rk-CurrentUser").mouseenter( |
1809 this.$.find(".Rk-CurrentUser").mouseenter( |
1807 function() { _this.$.find(".Rk-UserList").slideDown(); } |
1810 function() { _this.$.find(".Rk-UserList").slideDown(); } |
1808 ); |
1811 ); |
1809 this.$.find(".Rk-Users").mouseleave( |
1812 this.$.find(".Rk-Users").mouseleave( |
1810 function() { _this.$.find(".Rk-UserList").slideUp(); } |
1813 function() { _this.$.find(".Rk-UserList").slideUp(); } |
2011 + '<form action="#" class="Rk-GraphSearch-Form"><input type="search" class="Rk-GraphSearch-Field" placeholder="<%- translate("Search in graph") %>" /></form><div class="Rk-TopBar-Separator"></div><% } %></div><% } %>' |
2014 + '<form action="#" class="Rk-GraphSearch-Form"><input type="search" class="Rk-GraphSearch-Field" placeholder="<%- translate("Search in graph") %>" /></form><div class="Rk-TopBar-Separator"></div><% } %></div><% } %>' |
2012 + '<div class="Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>">' |
2015 + '<div class="Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>">' |
2013 + '<div class="Rk-Labels"></div><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Notifications"></div><div class="Rk-Editor">' |
2016 + '<div class="Rk-Labels"></div><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Notifications"></div><div class="Rk-Editor">' |
2014 + '<% if (options.show_bins) { %><div class="Rk-Fold-Bins">«</div><% } %>' |
2017 + '<% if (options.show_bins) { %><div class="Rk-Fold-Bins">«</div><% } %>' |
2015 + '<div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomFit" title="<%-translate("Zoom Fit")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div>' |
2018 + '<div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomFit" title="<%-translate("Zoom Fit")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div>' |
2016 + '<div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div></div>' |
2019 + '<% if (options.editor_mode) { %><div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><% } %>' |
|
2020 + '<% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div><% } %></div>' |
2017 + '</div></div>' |
2021 + '</div></div>' |
2018 ), |
2022 ), |
2019 fixSize: function(_autoscale) { |
2023 fixSize: function(_autoscale) { |
2020 console.log("fixSize", _autoscale, this.renkan.project.get("zoom_level")); |
2024 console.log("fixSize", _autoscale, this.renkan.project.get("zoom_level")); |
2021 var w = this.$.width(), |
2025 var w = this.$.width(), |
2029 }); |
2033 }); |
2030 |
2034 |
2031 paper.view.viewSize = new paper.Size([w, h]); |
2035 paper.view.viewSize = new paper.Size([w, h]); |
2032 |
2036 |
2033 if (_autoscale) { |
2037 if (_autoscale) { |
2034 // If _autoscale, we get the initial zoom level set in the project datas. |
2038 // If _autoscale, we get the initial view (zoom+offset) set in the project datas. |
2035 this.autoScale(this.renkan.project.get("zoom_level")); |
2039 if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){ |
|
2040 this.autoScale(this.renkan.project.get("views")[parseInt(this.renkan.options.default_view)]); |
|
2041 } |
|
2042 else{ |
|
2043 this.autoScale(); |
|
2044 } |
2036 } |
2045 } |
2037 }, |
2046 }, |
2038 drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) { |
2047 drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) { |
2039 var _options = this.renkan.options, |
2048 var _options = this.renkan.options, |
2040 _startRads = _startAngle * Math.PI / 180, |
2049 _startRads = _startAngle * Math.PI / 180, |
2189 this.offset = _offset; |
2198 this.offset = _offset; |
2190 } |
2199 } |
2191 this.redraw(); |
2200 this.redraw(); |
2192 } |
2201 } |
2193 }, |
2202 }, |
2194 autoScale: function(force_scale) { |
2203 autoScale: function(force_view) { |
2195 console.log("autoScale", force_scale); |
2204 console.log("autoScale", force_view); |
2196 var nodes = this.renkan.project.get("nodes"); |
2205 var nodes = this.renkan.project.get("nodes"); |
2197 if (nodes.length > 1) { |
2206 if (nodes.length > 1) { |
2198 var _xx = nodes.map(function(_node) { return _node.get("position").x; }), |
2207 var _xx = nodes.map(function(_node) { return _node.get("position").x; }), |
2199 _yy = nodes.map(function(_node) { return _node.get("position").y; }), |
2208 _yy = nodes.map(function(_node) { return _node.get("position").y; }), |
2200 _minx = Math.min.apply(Math, _xx), |
2209 _minx = Math.min.apply(Math, _xx), |
2202 _maxx = Math.max.apply(Math, _xx), |
2211 _maxx = Math.max.apply(Math, _xx), |
2203 _maxy = Math.max.apply(Math, _yy); |
2212 _maxy = Math.max.apply(Math, _yy); |
2204 var _scale = Math.min( (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny)); |
2213 var _scale = Math.min( (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny)); |
2205 this.initialScale = _scale; |
2214 this.initialScale = _scale; |
2206 // Override calculated scale if asked |
2215 // Override calculated scale if asked |
2207 if((typeof force_scale !== "undefined") && parseFloat(force_scale)>0){ |
2216 if((typeof force_view !== "undefined") && parseFloat(force_view.zoom_level)>0 && parseFloat(force_view.offset_x)>0 && parseFloat(force_view.offset_y)>0){ |
2208 _scale = parseFloat(force_scale); |
2217 this.setScale(parseFloat(force_view.zoom_level), new paper.Point(parseFloat(force_view.offset_x), parseFloat(force_view.offset_y))); |
2209 } |
2218 } |
2210 this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale))); |
2219 else{ |
|
2220 this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale))); |
|
2221 } |
2211 } |
2222 } |
2212 if (nodes.length === 1) { |
2223 if (nodes.length === 1) { |
2213 this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y]))); |
2224 this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y]))); |
2214 } |
2225 } |
2215 }, |
2226 }, |