dojo.provide("parus.gridExtraRow");dojo.require("dojox.grid.cells.dijit");dojo.require("dojox.grid.enhanced._Plugin");dojo.require("dojox.grid.EnhancedGrid");dojo.declare("dojox.grid.enhanced.plugins.extraRow",dojox.grid.enhanced._Plugin,{name:"extraRow",visible:true,rowCount:1,_oldCreateView:null,_afterRowConnect:null,_table:null,_barRows:null,values:null,constructor:function(e,d){this.inherited(arguments);dojo.mixin(this,d);this._barRows=[];var c=this;var b=this.grid;var a=this._oldCreateView=dojo.hitch(this.grid,this.grid.createView);this.grid.createView=function(){c._cleanUp();var f=a.apply(b,arguments);c._afterRowConnect=dojo.connect(f,"onAfterRow",c,"_afterRow");return f};dojo.mixin(b,{showExtraRowBar:dojo.hitch(c,this.show),hideExtraRowBar:dojo.hitch(c,this.hide),getExtraRowVisible:dojo.hitch(c,function(){return this.visible}),extraRowObject:c,onExtraRowValue:function(g,f){return""}})},show:function(){this.visible=true;this._render();this.grid.setQuery(this.grid.query||{})},hide:function(){this.visible=false;this._cleanUpBar();this.grid.setQuery(this.grid.query||{})},_afterRow:function(b,a,c){if(b==-1){dojo.query("table",c).forEach(dojo.hitch(this,function(d){this._cleanUpBar();this._table=d;if(this.visible){this._render()}}))}},_cleanUpEvent:function(){this._table=null;if(this._afterRowConnect){dojo.disconnect(this._afterRowConnect);this._afterRowConnect=null}},_cleanUpBar:function(){if(this._barRows){dojo.forEach(this._barRows,function(a){if(a.parentNode){a.parentNode.removeChild(a)}})}this._barRows=[]},_cleanUp:function(){this._cleanUpEvent();this._cleanUpBar()},_render:function(){if(!this._table){return}for(var c=0;c<this.rowCount;c++){var b=this._table.insertRow(-1);this._barRows.push(b);dojo.addClass(b,"dojoxGridStatusBarRow");dojo.forEach(this._table.rows[0].cells,dojo.hitch(this,function(d){var e=b.insertCell(-1);e.style.padding="2px 5px 2px 0px";e.style.textAlign=d.style.textAlign;dojo.addClass(e,"dojoxGridCell")}));var a=-1;dojo.forEach(this.grid.views.views[0].structure.cells[0],dojo.hitch(this,function(e){if(e.field&&!e.hidden){if(a==-1){a=e.index}else{a++}var d=b.cells[a];d.innerHTML=this.grid.onExtraRowValue(e,c)}}))}},destroy:function(){this._cleanUp();this.grid.createView=this._oldCreateView;this.inherited(arguments)}});dojox.grid.EnhancedGrid.registerPlugin(dojox.grid.enhanced.plugins.extraRow);