diff -r 6fd067e988d7 -r 0ce3dcdf24f7 client/js/renderer/viewrepr.js --- a/client/js/renderer/viewrepr.js Tue Sep 22 15:35:43 2015 +0200 +++ b/client/js/renderer/viewrepr.js Thu Sep 24 13:31:13 2015 +0200 @@ -28,7 +28,7 @@ }; } - this.init(); + this.initWithParams(); var bindClick = function(selector, fname) { _this.$.find(selector).click(function(evt) { @@ -40,20 +40,7 @@ bindClick(".Rk-ZoomOut", "zoomOut"); bindClick(".Rk-ZoomIn", "zoomIn"); bindClick(".Rk-ZoomFit", "autoScale"); - - this.$.find(".Rk-ZoomSave").click( function() { - var offset = { - "x": _this.offset.x, - "y": _this.offset.y - }; - _this.model = _this.renkan.project.addView( { zoom_level:_this.scale, offset:offset, hidden_nodes: _this.hiddenNodes.concat() } ); - _this.params = { - "zoom_level": _this.model.get("zoom_level"), - "offset": _this.model.get("offset"), - "hidden_nodes": _this.model.get("hidden_nodes") - }; - _this.updateUrl(); - }); + 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); @@ -88,14 +75,36 @@ redraw: function(options) { //console.log("view : ", this.model.toJSON()); }, - init: function(){ + initWithParams: function(){ var _this = this; + _this.setScale(_this.params.zoom_level, new paper.Point(_this.params.offset)); if (_this.options.hide_nodes){ _this.hiddenNodes = (_this.params.hidden_nodes || []).concat(); _this.hideNodes(); } + + if (_this.renkan.project.get("views").length === 0){ + _this.saveView(); + } + }, + saveView: function(){ + var _this = this; + + var offset = { + "x": _this.offset.x, + "y": _this.offset.y + }; + + _this.model = _this.renkan.project.addView( { zoom_level:_this.scale, offset:offset, hidden_nodes: _this.hiddenNodes.concat() } ); + _this.params = { + "zoom_level": _this.model.get("zoom_level"), + "offset": _this.model.get("offset"), + "hidden_nodes": _this.model.get("hidden_nodes") + }; + + _this.updateUrl(); }, addHiddenNode: function(_model){ this.hideNode(_model);