Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var DynamicInvoiceLinesBehavior = 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.       this.enableOnhoverElement();
  17.       this.element.up("tbody").select("tr.invoice-line").each(function( e ){
  18.         e.behavior.enableOnclickElement();
  19.         e.removeClassName("disable");
  20.       });
  21.       this.contentShowed = false;
  22.       this.element.next().down("td.line_details").remove();
  23.     }
  24.     else{
  25.       this.disableOnhoverElement();
  26.       this.disableElement("tr.invoice-line");
  27.       this.element.down("a.show-line").onclick();
  28.       this.contentShowed = true;
  29.     }
  30.   },
  31.  
  32.   disableElement: function(stringElement){
  33.     this.element.up("tbody").select(stringElement).each(function( e ){
  34.       if( e.id != this.element.id ){
  35.         e.behavior.disableOnclickElement();
  36.         e.addClassName("disable");
  37.       }
  38.     }.bind(this));
  39.   },
  40.  
  41.   disableOnhoverElement: function(){
  42.     this.disableHover = true;
  43.   },
  44.    
  45.   enableOnhoverElement: function(){
  46.     this.disableHover = false;
  47.   },
  48.  
  49.   disableOnclickElement: function(){
  50.     this.disableClick = true;
  51.   },  
  52.   enableOnclickElement: function(){
  53.     this.disableClick = false;
  54.   }
  55.    
  56. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement