Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var DynamicInvoiceLinesBehavior = Behavior.create({
- initialize: function(){
- this.disableClick = false;
- this.disableHover = false;
- this.contentShowed = false;
- this.element.behavior = this;
- },
- onclick: function(event){
- if(this.disableClick){
- alert("Another line is active.\nClose it first to view another line");
- return;
- }
- if(this.contentShowed){
- this.enableOnhoverElement();
- this.element.up("tbody").select("tr.invoice-line").each(function( e ){
- e.behavior.enableOnclickElement();
- e.removeClassName("disable");
- });
- this.contentShowed = false;
- this.element.next().down("td.line_details").remove();
- }
- else{
- this.disableOnhoverElement();
- this.disableElement("tr.invoice-line");
- this.element.down("a.show-line").onclick();
- this.contentShowed = true;
- }
- },
- disableElement: function(stringElement){
- this.element.up("tbody").select(stringElement).each(function( e ){
- if( e.id != this.element.id ){
- e.behavior.disableOnclickElement();
- e.addClassName("disable");
- }
- }.bind(this));
- },
- disableOnhoverElement: function(){
- this.disableHover = true;
- },
- enableOnhoverElement: function(){
- this.disableHover = false;
- },
- disableOnclickElement: function(){
- this.disableClick = true;
- },
- enableOnclickElement: function(){
- this.disableClick = false;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement