# HG changeset patch # User rougeronj # Date 1442246520 -7200 # Node ID b94a34c139c1cb4a90474c56ff076c627161089d # Parent 5d15acf5ee2b93cf5d9b6a9e8398f2a0bef993ff update parameters function to accept idView parameter add and update idView in url on save set size_bug_fix to false by default to avoid autoscale everytime diff -r 5d15acf5ee2b -r b94a34c139c1 client/js/defaults.js --- a/client/js/defaults.js Mon Sep 14 17:57:13 2015 +0200 +++ b/client/js/defaults.js Mon Sep 14 18:02:00 2015 +0200 @@ -29,7 +29,7 @@ show_top_bar: true, /* Show the top bar, (title, buttons, users) */ default_user_color: "#303030", - size_bug_fix: true, + size_bug_fix: false, /* Resize the canvas after load (fixes a bug on iPad and FF Mac) */ force_resize: false, allow_double_click: true, diff -r 5d15acf5ee2b -r b94a34c139c1 client/js/renderer/scene.js --- a/client/js/renderer/scene.js Mon Sep 14 17:57:13 2015 +0200 +++ b/client/js/renderer/scene.js Mon Sep 14 18:02:00 2015 +0200 @@ -487,12 +487,13 @@ _(Scene.prototype).extend({ fixSize: function() { -// if(typeothis.view) { -// this.view.setScale(view.get("zoom_level"), new paper.Point(view.get("offset"))); -// } -// else{ -// this.view.autoScale(); -// } + if(typeof this.view === 'undefined') { + this.view = this.addRepresentation("View", this.renkan.project.get("views").last()); + this.view.setScale(view.get("zoom_level"), new paper.Point(view.get("offset"))); + } + else{ + this.view.autoScale(); + } }, drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) { var _options = this.renkan.options, @@ -1201,37 +1202,35 @@ }, parameters: function(_params){ if ($.isEmptyObject(_params)){ - this.view = this.addRepresentation("View", this.renkan.project.get("views").last()); + this.view = this.addRepresentation("View", this.renkan.project.get("views").first()); + this.view.autoScale(); return; } - if (typeof _params.view !== 'undefined'){ + if (typeof _params.idView !== 'undefined' && typeof this.renkan.project.get("views").at(_params.idView) !== 'undefined'){ + this.view = this.addRepresentation("View", this.renkan.project.get("views").at(_params.idView)); + } + if (typeof _params.view !== 'undefined' && _params.view.split(",").length >= 3){ var viewParams = _params.view.split(","); - if (viewParams.length >= 3){ - var params = { - "project": this.renkan.project, - "offset": { - "x": parseFloat(viewParams[0]), - "y": parseFloat(viewParams[1]) - }, - "zoom_level": parseFloat(viewParams[2]) - }; - for (var i = 3; i < viewParams.length; i++){ - params.hidden_nodes.push(viewParams[i]); - } - //var view = new Rkns.Models.View(params); - - if (this.view){ - this.view.showNodes(false); - this.removeRepresentation(this.view); - } - + var params = { + "project": this.renkan.project, + "offset": { + "x": parseFloat(viewParams[0]), + "y": parseFloat(viewParams[1]) + }, + "zoom_level": parseFloat(viewParams[2]) + }; + if (this.view){ + this.view.setScale(params.zoom_level, new paper.Point(params.offset)); + } else{ this.view = this.addRepresentation("View", null); this.view.params = params; - this.view.init(); - } else { - this.view = this.addRepresentation("View", this.renkan.project.get("views").last()); + this.view.init(); } } + if(!this.view){ + this.view = this.addRepresentation("View", this.renkan.project.get("views").first()); + this.view.autoScale(); + } //other parameters must go after because most of them depends on a view that must be initialize before if (typeof _params.idNode !== 'undefined'){ this.unhighlightAll(); diff -r 5d15acf5ee2b -r b94a34c139c1 client/js/renderer/viewrepr.js --- a/client/js/renderer/viewrepr.js Mon Sep 14 17:57:13 2015 +0200 +++ b/client/js/renderer/viewrepr.js Mon Sep 14 18:02:00 2015 +0200 @@ -57,6 +57,7 @@ "offset": _this.model.get("offset"), "hidden_nodes": _this.model.get("hidden_nodes") }; + _this.updateUrl(); }); this.$.find(".Rk-ZoomSetSaved").click( function() { @@ -196,11 +197,16 @@ var item = part.split("="); result[item[0]] = decodeURIComponent(item[1]); }); - } + } result.view = Math.round(this.offset.x*1000)/1000 + ',' + Math.round(this.offset.y*1000)/1000 + ',' + Math.round(this.scale*1000)/1000; -// if (this.hiddenNodes.length > 0){ -// result.hiddenNodes = this.hiddenNodes.join(); -// } + + if (this.renkan.project.get("views").indexOf(this.model) > -1){ + result.idView = this.renkan.project.get("views").indexOf(this.model); + } else { + if (result.idView){ + delete result.idView; + } + } this.renkan.router.navigate("?" + decodeURIComponent($.param(result)), {trigger: false, replace: true}); } },