--- a/client/js/renderer/scene.js Thu Jun 18 17:17:11 2015 +0200
+++ b/client/js/renderer/scene.js Thu Jun 18 17:18:00 2015 +0200
@@ -25,7 +25,6 @@
this.initialScale = 1;
this.offset = paper.view.center;
this.totalScroll = 0;
- this.hiddenNodes = [];
this.mouse_down = false;
this.click_target = null;
this.selected_target = null;
@@ -239,29 +238,14 @@
bindClick(".Rk-ZoomFit", "autoScale");
this.$.find(".Rk-ZoomSave").click( function() {
// Save scale and offset point
- _this.renkan.project.addView( { zoom_level:_this.scale, offset:_this.offset, hidden_nodes: _this.hiddenNodes } );
+ _this.renkan.project.addView( { zoom_level:_this.scale, offset:_this.offset, hidden_nodes: _this.view.hiddenNodes } );
});
this.$.find(".Rk-ZoomSetSaved").click( function() {
var view = _this.renkan.project.get("views").last();
if(view){
- _this.showNodes(false);
_this.setScale(view.get("zoom_level"), new paper.Point(view.get("offset")));
- if (_this.renkan.options.hide_nodes){
- _this.hiddenNodes = (view.get("hidden_nodes") || []).concat();
- _this.hideNodes();
- }
}
});
- this.$.find(".Rk-ShowHiddenNodes").mouseenter( function() {
- _this.showNodes(true);
- _this.$.find(".Rk-ShowHiddenNodes").mouseleave( function() {
- _this.hideNodes();
- });
- });
- this.$.find(".Rk-ShowHiddenNodes").click( function() {
- _this.showNodes(false);
- _this.$.find(".Rk-ShowHiddenNodes").off( "mouseleave" );
- });
if(this.renkan.project.get("views").length > 0 && this.renkan.options.save_view){
this.$.find(".Rk-ZoomSetSaved").show();
}
@@ -323,7 +307,7 @@
var _thRedraw = _.throttle(function() {
_this.redraw();
},50);
-
+
this.addRepresentations("Node", this.renkan.project.get("nodes"));
this.addRepresentations("Edge", this.renkan.project.get("edges"));
this.renkan.project.on("change:title", function() {
@@ -396,6 +380,14 @@
_thRedraw();
}
});
+ this.renkan.project.on("add:views", function(_view) {
+ if (!_this.view){
+ _this.view = _this.addRepresentation("View", _view);
+ }
+ if (!_this.renkan.project.get("loadingStatus")){
+ _thRedraw();
+ }
+ });
this.renkan.project.on("change:title", function(_model, _title) {
var el = _this.$.find(".Rk-PadTitle");
if (el.is("input")) {
@@ -876,40 +868,6 @@
_tmpEdge.redraw();
this.click_target = _tmpEdge;
},
- addHiddenNode: function(_model){
- this.hideNode(_model);
- this.hiddenNodes.push(_model.id);
- },
- hideNode: function(_model){
- var _this = this;
- if (typeof _this.getRepresentationByModel(_model) !== 'undefined'){
- _this.getRepresentationByModel(_model).hide();
- }
- },
- hideNodes: function(){
- var _this = this;
- this.hiddenNodes.forEach(function(_id, index){
- var node = _this.renkan.project.get("nodes").get(_id);
- if (typeof node !== 'undefined'){
- return _this.hideNode(_this.renkan.project.get("nodes").get(_id));
- }else{
- _this.hiddenNodes.splice(index, 1);
- }
- });
- paper.view.draw();
- },
- showNodes: function(ghost){
- var _this = this;
- var i = 0;
- this.hiddenNodes.forEach(function(_id){
- i++;
- _this.getRepresentationByModel(_this.renkan.project.get("nodes").get(_id)).show(ghost);
- });
- if (!ghost){
- this.hiddenNodes = [];
- }
- paper.view.draw();
- },
findTarget: function(_hitResult) {
if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
var _newTarget = _hitResult.item.__representation;