--- a/client/js/paper-renderer.js Mon Feb 17 17:58:39 2014 +0100
+++ b/client/js/paper-renderer.js Tue Feb 18 16:54:41 2014 +0100
@@ -1803,6 +1803,9 @@
var view = _this.renkan.project.get("views")[0];
_this.setScale(view.zoom_level, new paper.Point(view.offset_x, view.offset_y));
});
+ if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){
+ this.$.find(".Rk-ZoomSetSaved").show();
+ }
this.$.find(".Rk-CurrentUser").mouseenter(
function() { _this.$.find(".Rk-UserList").slideDown(); }
);
@@ -2013,7 +2016,8 @@
+ '<div class="Rk-Labels"></div><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Notifications"></div><div class="Rk-Editor">'
+ '<% if (options.show_bins) { %><div class="Rk-Fold-Bins">«</div><% } %>'
+ '<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>'
- + '<div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div></div>'
+ + '<% if (options.editor_mode) { %><div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><% } %>'
+ + '<% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div><% } %></div>'
+ '</div></div>'
),
fixSize: function(_autoscale) {
@@ -2031,8 +2035,13 @@
paper.view.viewSize = new paper.Size([w, h]);
if (_autoscale) {
- // If _autoscale, we get the initial zoom level set in the project datas.
- this.autoScale(this.renkan.project.get("zoom_level"));
+ // If _autoscale, we get the initial view (zoom+offset) set in the project datas.
+ if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){
+ this.autoScale(this.renkan.project.get("views")[parseInt(this.renkan.options.default_view)]);
+ }
+ else{
+ this.autoScale();
+ }
}
},
drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
@@ -2191,8 +2200,8 @@
this.redraw();
}
},
-autoScale: function(force_scale) {
- console.log("autoScale", force_scale);
+autoScale: function(force_view) {
+ console.log("autoScale", force_view);
var nodes = this.renkan.project.get("nodes");
if (nodes.length > 1) {
var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
@@ -2204,10 +2213,12 @@
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));
this.initialScale = _scale;
// Override calculated scale if asked
- if((typeof force_scale !== "undefined") && parseFloat(force_scale)>0){
- _scale = parseFloat(force_scale);
+ if((typeof force_view !== "undefined") && parseFloat(force_view.zoom_level)>0 && parseFloat(force_view.offset_x)>0 && parseFloat(force_view.offset_y)>0){
+ this.setScale(parseFloat(force_view.zoom_level), new paper.Point(parseFloat(force_view.offset_x), parseFloat(force_view.offset_y)));
}
- this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)));
+ else{
+ this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)));
+ }
}
if (nodes.length === 1) {
this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y])));