Improve the way we init the view. The data loader send a "loaded" event, hooked by the scene.py and initializing the backbone.history and the view.
We don't use redraw_active in save-once and full-json, because it was making the view initialization dependent of these file which are externals.
Small fix to hide the "set saved view" button when there is only one view.
--- a/client/js/dataloader.js Fri Sep 18 16:37:26 2015 +0200
+++ b/client/js/dataloader.js Tue Sep 22 15:14:10 2015 +0200
@@ -65,6 +65,7 @@
this.project.set(this.convert(data), {
validate: true
});
+ this.project.trigger('loaded', true);
};
})(window);
--- a/client/js/full-json.js Fri Sep 18 16:37:26 2015 +0200
+++ b/client/js/full-json.js Tue Sep 22 15:14:10 2015 +0200
@@ -6,19 +6,18 @@
_opts.http_method = 'PUT';
}
var _load = function() {
- _renkan.renderer.redrawActive = false;
_proj.set({
loadingStatus : true
});
Rkns.$.getJSON(_opts.url, function(_data) {
_renkan.dataloader.load(_data);
+
_proj.set({
loadingStatus : false
});
_proj.set({
saveStatus : 0
});
- _renkan.renderer.redrawActive = true;
});
};
var _save = function() {
--- a/client/js/renderer/scene.js Fri Sep 18 16:37:26 2015 +0200
+++ b/client/js/renderer/scene.js Tue Sep 22 15:14:10 2015 +0200
@@ -29,7 +29,7 @@
this.node_layer = new paper.Layer();
this.buttons_layer = new paper.Layer();
this.delete_list = [];
- this.redrawActive = true;
+ this.redrawActive = false;
if (_renkan.options.show_minimap) {
this.minimap = {
@@ -266,9 +266,9 @@
paper.view.onResize = function(_event) {
var _ratio,
- newWidth = _event.width,
- newHeight = _event.height;
-
+ newWidth = _event.size._width,
+ newHeight = _event.size._height;
+
if (_this.minimap) {
_this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size);
_this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4]));
@@ -282,7 +282,6 @@
} else {
_ratio = ratioW;
}
-
_this.view.resizeZoom(ratioW, ratioH, _ratio);
_this.redraw();
@@ -329,7 +328,13 @@
break;
}
});
-
+
+ this.renkan.project.on("loaded", function(){
+ Backbone.history.start();
+ _this.redrawActive = true;
+ _thRedraw();
+ });
+
this.renkan.project.on("change:loadingStatus", function(){
if (_this.renkan.project.get("loadingStatus")){
var animate = _this.$.find(".loader").addClass("run");
@@ -337,16 +342,12 @@
_this.$.find(".loader").hide(250);
}, 3000);
}
- else{
- Backbone.history.start();
- _thRedraw();
- }
});
this.renkan.project.on("add:users remove:users", _thRedrawUsers);
this.renkan.project.on("add:views remove:views", function(_node) {
- if(_this.renkan.project.get('views').length > 0) {
+ if(_this.renkan.project.get('views').length > 1) {
_this.$.find(".Rk-ZoomSetSaved").show();
}
else {
@@ -1285,7 +1286,6 @@
sizeAft = sizeBef+300;
foldBinsButton.html("»");
}
- _this.view.resizeZoom(1, 1, (sizeAft/sizeBef));
},
save: function() { },
open: function() { }
--- a/client/js/renderer/viewrepr.js Fri Sep 18 16:37:26 2015 +0200
+++ b/client/js/renderer/viewrepr.js Tue Sep 22 15:14:10 2015 +0200
@@ -81,7 +81,7 @@
_this.showNodes(false);
_this.$.find(".Rk-ShowHiddenNodes").off( "mouseleave" );
});
- if(this.renkan.project.get("views").length > 0 && this.renkan.options.save_view){
+ if(this.renkan.project.get("views").length > 1 && this.renkan.options.save_view){
this.$.find(".Rk-ZoomSetSaved").show();
}
},
--- a/client/js/save-once.js Fri Sep 18 16:37:26 2015 +0200
+++ b/client/js/save-once.js Tue Sep 22 15:14:10 2015 +0200
@@ -20,14 +20,12 @@
url: _opts.url,
data: getdata,
beforeSend: function(){
- _renkan.renderer.redrawActive = false;
_proj.set({loadingStatus:true});
},
success: function(_data) {
_renkan.dataloader.load(_data);
_proj.set({loadingStatus:false});
_proj.set({saveStatus:0});
- _renkan.renderer.redrawActive = true;
}
});
};