client/js/renderer/noderepr.js
changeset 453 04b7d46e9d67
parent 450 88e8673aaeeb
child 461 48235ed6b07d
equal deleted inserted replaced
452:96f84344a70e 453:04b7d46e9d67
    31                 var Renderer = requtils.getRenderer();
    31                 var Renderer = requtils.getRenderer();
    32                 this.normal_buttons = [
    32                 this.normal_buttons = [
    33                                        new Renderer.NodeEditButton(this.renderer, null),
    33                                        new Renderer.NodeEditButton(this.renderer, null),
    34                                        new Renderer.NodeRemoveButton(this.renderer, null),
    34                                        new Renderer.NodeRemoveButton(this.renderer, null),
    35                                        new Renderer.NodeHideButton(this.renderer, null),
    35                                        new Renderer.NodeHideButton(this.renderer, null),
       
    36                                        new Renderer.NodeShowButton(this.renderer, null),
    36                                        new Renderer.NodeLinkButton(this.renderer, null),
    37                                        new Renderer.NodeLinkButton(this.renderer, null),
    37                                        new Renderer.NodeEnlargeButton(this.renderer, null),
    38                                        new Renderer.NodeEnlargeButton(this.renderer, null),
    38                                        new Renderer.NodeShrinkButton(this.renderer, null)
    39                                        new Renderer.NodeShrinkButton(this.renderer, null)
    39                                        ];
    40                                        ];
    40                 this.pending_delete_buttons = [
    41                 this.pending_delete_buttons = [
   365                 this.minimap_circle.strokeColor = this.options.minimap_highlight_color;
   366                 this.minimap_circle.strokeColor = this.options.minimap_highlight_color;
   366             }
   367             }
   367             //if the node is hidden and the mouse hover it, it appears as a ghost
   368             //if the node is hidden and the mouse hover it, it appears as a ghost
   368             if (this.hidden){
   369             if (this.hidden){
   369                 this.show(true);
   370                 this.show(true);
       
   371             }else{
       
   372                 this.showNeighbors(true);
   370             }
   373             }
   371             this._super("select");
   374             this._super("select");
   372         },
   375         },
   373         hideButtons: function() {
   376         hideButtons: function() {
   374             this.all_buttons.forEach(function(b) {
   377             this.all_buttons.forEach(function(b) {
   387                     this.minimap_circle.strokeColor = undefined;
   390                     this.minimap_circle.strokeColor = undefined;
   388                 }
   391                 }
   389                 //when the mouse don't hover the node anymore, we hide it
   392                 //when the mouse don't hover the node anymore, we hide it
   390                 if (this.hidden){
   393                 if (this.hidden){
   391                     this.hide();
   394                     this.hide();
       
   395                 }else{
       
   396                     this.hideNeighbors();
   392                 }
   397                 }
   393                 this._super("unselect");
   398                 this._super("unselect");
   394             }
   399             }
   395         },
   400         },
   396         hide: function(){
   401         hide: function(){
   417                         if (repr && typeof repr.from_representation !== "undefined" && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") {
   422                         if (repr && typeof repr.from_representation !== "undefined" && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") {
   418                             repr.hide();
   423                             repr.hide();
   419                         }
   424                         }
   420                     }
   425                     }
   421             );
   426             );
       
   427             this.hideNeighbors();
   422         },
   428         },
   423         show: function(ghost){
   429         show: function(ghost){
   424             var _this = this;
   430             var _this = this;
   425             this.ghost = ghost;
   431             this.ghost = ghost;
   426             if (this.ghost){
   432             if (this.ghost){
   446                         if (repr && typeof repr.from_representation !== "undefined" && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") {
   452                         if (repr && typeof repr.from_representation !== "undefined" && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") {
   447                             repr.show(_this.ghost);
   453                             repr.show(_this.ghost);
   448                         }
   454                         }
   449                     }
   455                     }
   450             );            
   456             );            
       
   457         },
       
   458         hideNeighbors: function(){
       
   459             var _this = this;
       
   460             _.each(
       
   461                     this.project.get("edges").filter(
       
   462                             function (ed) {
       
   463                                 return (ed.get("from") === _this.model);
       
   464                             }
       
   465                     ),
       
   466                     function(edge, index, list) {
       
   467                         var repr = _this.renderer.getRepresentationByModel(edge.get("to"));
       
   468                         if (repr && repr.ghost) {
       
   469                             repr.hide();
       
   470                         }
       
   471                     }
       
   472             );
       
   473         },
       
   474         showNeighbors: function(ghost){
       
   475             var _this = this;
       
   476             _.each(
       
   477                     this.project.get("edges").filter(
       
   478                             function (ed) {
       
   479                                 return (ed.get("from") === _this.model);
       
   480                             }
       
   481                     ),
       
   482                     function(edge, index, list) {
       
   483                         var repr = _this.renderer.getRepresentationByModel(edge.get("to"));
       
   484                         if (repr && repr.hidden) {
       
   485                             repr.show(ghost);
       
   486                             if (!ghost){
       
   487                                 var indexNode = _this.renderer.hiddenNodes.indexOf(repr.model.id);
       
   488                                 if (indexNode !== -1){
       
   489                                     _this.renderer.hiddenNodes.splice(indexNode, 1);
       
   490                                 }
       
   491                             }
       
   492                         }
       
   493                     }
       
   494             );
   451         },
   495         },
   452         highlight: function(textToReplace) {
   496         highlight: function(textToReplace) {
   453             var hlvalue = textToReplace || true;
   497             var hlvalue = textToReplace || true;
   454             if (this.highlighted === hlvalue) {
   498             if (this.highlighted === hlvalue) {
   455                 return;
   499                 return;