# HG changeset patch # User rougeronj # Date 1443545231 -7200 # Node ID 32c7378d1c28d351ede76a37f1949a62815b0e32 # Parent d05ee3bcceabf9b9599ba611f4b2ad52079798f1 - Fix the behavior of views and parameters - Introduce views_parameters and views_nodes to loads or not the view's characteristics - Urls parameters overrides options - SetSavedView loads the current view's characteristics - view = autoscale in url forces autoscale on the current loaded view diff -r d05ee3bcceab -r 32c7378d1c28 client/js/defaults.js --- a/client/js/defaults.js Thu Sep 24 17:47:11 2015 +0200 +++ b/client/js/defaults.js Tue Sep 29 18:47:11 2015 +0200 @@ -47,15 +47,18 @@ /* show zoom buttons */ save_view: true, /* show buttons to save view */ - default_view: false, - /* Allows to load default view (zoom+offset) at start on read_only mode, instead of autoScale. the default_view will be the last */ + views_parameters: true, + /* load parameters (offset + zoom) from the view or use autoscale */ + views_nodes: true, + /* load hidden nodes from the view or show all of them */ default_index_view: -1, - + /* URL parsing */ url_parameters: true, /* accept or not hash parameters in the url */ update_url: true, /* update the url each time the paper shift or on zoom in/out, with the serialized view (offset and scale) */ + /* Considered as false if url_parameters is false */ /* TOP BAR BUTTONS */ diff -r d05ee3bcceab -r 32c7378d1c28 client/js/renderer/scene.js --- a/client/js/renderer/scene.js Thu Sep 24 17:47:11 2015 +0200 +++ b/client/js/renderer/scene.js Tue Sep 29 18:47:11 2015 +0200 @@ -339,6 +339,11 @@ _thRedraw(); }); + //register router events + this.renkan.router.on("router", function(_params){ + _this.setViewparameters(_params); + }); + this.renkan.project.on("change:loadingStatus", function(){ if (_this.renkan.project.get("loadingStatus")){ var animate = _this.$.find(".loader").addClass("run"); @@ -382,11 +387,6 @@ } }); - //register router events - this.renkan.router.on("router", function(_params){ - _this.setViewparameters(_params); - }); - if (_renkan.options.size_bug_fix) { var _delay = ( typeof _renkan.options.size_bug_fix === "number" ? @@ -494,7 +494,7 @@ _(Scene.prototype).extend({ fixSize: function() { if(typeof this.view === 'undefined') { - this.view = this.addRepresentation("View", this.renkan.project.get("views").first()); + this.view = this.addRepresentation("View", this.renkan.project.get("views").last()); } this.view.autoScale(); }, @@ -1207,16 +1207,12 @@ this.removeRepresentationsOfType("View"); if ($.isEmptyObject(_params)){ this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(this.renkan.options.default_index_view))); - if (!this.renkan.options.default_view){ - this.view.autoScale(); - } return; } if (typeof _params.viewIndex !== 'undefined'){ this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(_params.viewIndex))); - if (!this.renkan.options.default_view){ - this.view.autoScale(); - } + } else { + this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(this.renkan.options.default_index_view))); } if (typeof _params.view !== 'undefined' && _params.view.split(",").length >= 3){ var viewParams = _params.view.split(","); @@ -1228,18 +1224,21 @@ }, "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.initWithParams(); + this.view.setScale(params.zoom_level, new paper.Point(params.offset)); + } + //if view parameters = autoscale or views_parameters options is false, we apply a zoom fit on the view. + if ((typeof _params.view !== 'undefined' && _params.view === "autoscale")){ + this.view.autoScale(); + } + //if viewsNodes = false or views_nodes options is false, we show all the node by default. + if (typeof _params.viewsNodes !== 'undefined'){ + if (_params.viewsNodes === "true"){ + this.view.hiddenNodes = (this.view.params.hidden_nodes || []).concat(); + this.view.hideNodes(); + } else { + this.view.showNodes(false); } } - if (!this.view){ - this.view = this.addRepresentation("View", this.renkan.project.get("views").at(this.validViewIndex(this.renkan.options.default_index_view))); - this.view.autoScale(); - } //other parameters must go after because most of them depends on a view that must be initialize before this.unhighlightAll(); if (typeof _params.idNode !== 'undefined'){ diff -r d05ee3bcceab -r 32c7378d1c28 client/js/renderer/viewrepr.js --- a/client/js/renderer/viewrepr.js Thu Sep 24 17:47:11 2015 +0200 +++ b/client/js/renderer/viewrepr.js Tue Sep 29 18:47:11 2015 +0200 @@ -43,12 +43,6 @@ bindClick(".Rk-ZoomSave", "saveView"); this.$.find(".Rk-ZoomSetSaved").click( function() { - _this.model = _this.renkan.project.get("views").at(_this.renkan.project.get("views").length -1); - _this.params = { - "zoom_level": _this.model.get("zoom_level"), - "offset": _this.model.get("offset"), - "hidden_nodes": _this.model.get("hidden_nodes") - }; _this.setScale(_this.params.zoom_level, new paper.Point(_this.params.offset)); _this.showNodes(false); if (_this.options.hide_nodes){ @@ -77,17 +71,20 @@ }, initWithParams: function(){ var _this = this; - - _this.setScale(_this.params.zoom_level, new paper.Point(_this.params.offset)); - if (_this.options.hide_nodes){ + if (_this.options.views_parameters){ + _this.setScale(_this.params.zoom_level, new paper.Point(_this.params.offset)); + } else { + this.autoScale(); + } + + if (_this.options.hide_nodes && _this.options.views_nodes){ _this.hiddenNodes = (_this.params.hidden_nodes || []).concat(); _this.hideNodes(); + } else { + _this.showNodes(false); } - if (_this.renkan.project.get("views").length === 0){ - _this.saveView(); - } }, saveView: function(){ var _this = this; @@ -200,7 +197,7 @@ this.renderer.redraw(); }, updateUrl: function(){ - if(this.options.update_url){ + if(this.options.url_parameters && this.options.update_url){ var result = {}; var parameters = Backbone.history.getFragment().split('?'); if (parameters.length > 1){