Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
72
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.childElements().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.childElements().each(function(cell){
  32.         //alert(cell + ' '+ cell.id);
  33.         if (cell.id != '')
  34.           //alert(cell + ' '+ cell.id + ' ' + cell.classNames());
  35.           cell.element.behavior.showedContent();
  36.       });
  37.       this.element.up("tbody").select("tr.dynamic-line").each(function(line){
  38.         line.addClassName("disable");
  39.         line.childElements().each(function(cell){
  40.           //cell.element.behavior.disableOnclickElement();
  41.         });
  42.       });
  43.       alert(current_row.element.down("a.show-line"));
  44.       //current_row.element.down("a.show-line").onclick();
  45.     }
  46.   },
  47.  
  48.   disableOnhoverElement: function(){
  49.     this.disableHover = true;
  50.   },
  51.    
  52.   enableOnhoverElement: function(){
  53.     this.disableHover = false;
  54.   },
  55.  
  56.   disableOnclickElement: function(){
  57.     this.disableClick = true;
  58.   },
  59.  
  60.   enableOnclickElement: function(){
  61.     this.disableClick = false;
  62.   },
  63.  
  64.   showedContent: function(){
  65.     this.contentShowed = true;
  66.   },
  67.  
  68.   hidedContent: function(){
  69.     this.contentShowed = false;
  70.   },
  71. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement