Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var DynamicCellBehavior = Behavior.create({
  2.  
  3.   initialize: function(){
  4.     this.disableClick = false;
  5.     this.disableHover = false;
  6.     this.contentShowed = false;
  7.     this.element.behavior = this;
  8.   },
  9.  
  10.   onclick: function(event){
  11.     if(this.disableClick){
  12.       alert("Another line is active.\nClose it first to view another line");
  13.       return;
  14.     }
  15.     if(this.contentShowed){
  16.       var current_row = this.element.up('tr');
  17.       alert(current_row.id);
  18.       var details_row = $(current_row.id + '_details');
  19.       details_row.replace('');
  20.       this.element.up("tbody").select("tr.dynamic-line").each(function(line){
  21.         line.removeClassName("disable");
  22.         line.descendants().each(function(cell){
  23.           cell.enableOnclickElement();
  24.           cell.contentShowed = false;
  25.         });
  26.       });
  27.     }
  28.     else{
  29.       var current_row = this.element.up('tr');
  30.       alert(current_row.id);
  31.       current_row.descendants().each(function(cell){
  32.         alert(cell.behavior);
  33.         cell.behavior.contentShowed = true;
  34.       });
  35.       this.element.up("tbody").select("tr.dynamic-line").each(function(line){
  36.         line.addClassName("disable");
  37.         line.descendants().each(function(cell){
  38.           cell.disableOnclickElement();
  39.         });
  40.       });
  41.       current_row.element.down("a.show-line").onclick();
  42.     }
  43.   },
  44.  
  45.   disableOnhoverElement: function(){
  46.     this.disableHover = true;
  47.   },
  48.    
  49.   enableOnhoverElement: function(){
  50.     this.disableHover = false;
  51.   },
  52.  
  53.   disableOnclickElement: function(){
  54.     this.disableClick = true;
  55.   },  
  56.   enableOnclickElement: function(){
  57.     this.disableClick = false;
  58.   }
  59.    
  60. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement