# HG changeset patch # User cavaliet # Date 1392738881 -3600 # Node ID aaef418cdf8d91fdb7f8d9b12fa7acea1d91c412 # Parent 070528af737532b93793c0cb144e22e758c06a2f set default view on read only mode. diff -r 070528af7375 -r aaef418cdf8d client/data/example-cinema.json --- a/client/data/example-cinema.json Mon Feb 17 17:58:39 2014 +0100 +++ b/client/data/example-cinema.json Tue Feb 18 16:54:41 2014 +0100 @@ -619,5 +619,13 @@ "anonymous": true } ], - "space_id": "17f968e4-2640-4319-aa61-b5b8b527ebb4" + "space_id": "17f968e4-2640-4319-aa61-b5b8b527ebb4", + "views": [ + { + "id": "view-2014-02-18-628af15b-12ad-457a-8ac0-a28c8998cc3b-0001", + "zoom_level": 0.8275032552816195, + "offset_x": 832.0104075533723, + "offset_y": 402.8917139487223 + } + ] } \ No newline at end of file diff -r 070528af7375 -r aaef418cdf8d client/js/defaults.js --- a/client/js/defaults.js Mon Feb 17 17:58:39 2014 +0100 +++ b/client/js/defaults.js Tue Feb 18 16:54:41 2014 +0100 @@ -36,6 +36,8 @@ /* Delay between clicking on the bin on an element and really deleting it Set to 0 for delete confirm */ autoscale_padding: 50, + default_view: false, + /* Allows to load default view (zoom+offset) at start on read_only mode, instead of autoScale. default_view has to be an integer 0,1,2... */ /* TOP BAR BUTTONS */ show_search_field: true, diff -r 070528af7375 -r aaef418cdf8d client/js/paper-renderer.js --- 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 @@ + '
' + '<% if (options.show_bins) { %>
«
<% } %>' + '
">
">
">
' - + '
">
">
' + + '<% if (options.editor_mode) { %>
">
<% } %>' + + '<% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %>
">
<% } %>
' + '' ), 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]))); diff -r 070528af7375 -r aaef418cdf8d client/test/test-readonly-div.html --- a/client/test/test-readonly-div.html Mon Feb 17 17:58:39 2014 +0100 +++ b/client/test/test-readonly-div.html Tue Feb 18 16:54:41 2014 +0100 @@ -12,14 +12,23 @@ - + + + + + + + + +