text: //>>built
  define("dojox/grid/enhanced/plugins/CellMerge","dojo/_base/declare dojo/_base/array dojo/_base/lang dojo/_base/html ../_Plugin ../../EnhancedGrid".split(" "),function(p,m,k,l,w,x){p=p("dojox.grid.enhanced.plugins.CellMerge",w,{name:"cellMerge",constructor:function(a,b){this.grid=a;this._records=[];this._merged={};b&&k.isObject(b)&&this._setupConfig(b.mergedCells);this._initEvents();this._mixinGrid()},mergeCells:function(a,b,c,f){(a=this._createRecord({row:a,start:b,end:c,major:f}))&&this._updateRows(a);
  return a},unmergeCells:function(a){var b;a&&0<=(b=m.indexOf(this._records,a))&&(this._records.splice(b,1),this._updateRows(a))},getMergedCells:function(){var a=[],b;for(b in this._merged)a=a.concat(this._merged[b]);return a},getMergedCellsByRow:function(a){return this._merged[a]||[]},_setupConfig:function(a){m.forEach(a,this._createRecord,this)},_initEvents:function(){m.forEach(this.grid.views.views,function(a){this.connect(a,"onAfterRow",k.hitch(this,"_onAfterRow",a.index))},this)},_mixinGrid:function(){var a=
  this.grid;a.mergeCells=k.hitch(this,"mergeCells");a.unmergeCells=k.hitch(this,"unmergeCells");a.getMergedCells=k.hitch(this,"getMergedCells");a.getMergedCellsByRow=k.hitch(this,"getMergedCellsByRow")},_getWidth:function(a){a=this.grid.layout.cells[a].getHeaderNode();return l.position(a).w},_onAfterRow:function(a,b,c){try{if(!(0>b)){var f=[],h,d,r=this._records.length,t=this.grid.layout.cells;for(h=0;h<r;++h){var g=this._records[h],u=this.grid._by_idx[b];if(g.view==a&&g.row(b,u&&u.item,this.grid.store)){var n=
  {record:g,hiddenCells:[],totalWidth:0,majorNode:t[g.major].getNode(b),majorHeaderNode:t[g.major].getHeaderNode()};for(d=g.start;d<=g.end;++d){var y=this._getWidth(d,b);n.totalWidth+=y;d!=g.major&&n.hiddenCells.push(t[d].getNode(b))}if(1!=c.length||0<n.totalWidth){for(d=f.length-1;0<=d;--d){var q=f[d].record;(q.start>=g.start&&q.start<=g.end||q.end>=g.start&&q.end<=g.end)&&f.splice(d,1)}f.push(n)}}}this._merged[b]=[];m.forEach(f,function(e){m.forEach(e.hiddenCells,function(z){l.style(z,"display","none")});
  var A=l.marginBox(e.majorHeaderNode).w-l.contentBox(e.majorHeaderNode).w,v=e.totalWidth;l.isWebKit||(v-=A);l.style(e.majorNode,"width",v+"px");e.majorNode.setAttribute("colspan",e.hiddenCells.length+1);this._merged[b].push({row:b,start:e.record.start,end:e.record.end,major:e.record.major,handle:e.record})},this)}}catch(e){console.warn("CellMerge._onAfterRow() error: ",b,e)}},_createRecord:function(a){if(this._isValid(a)){a={row:a.row,start:a.start,end:a.end,major:a.major};a.view=this.grid.layout.cells[a.start].view.index;
  a.major="number"!=typeof a.major||isNaN(a.major)?a.start:a.major;if("number"==typeof a.row){var b=a.row;a.row=function(f){return f===b}}else if("string"==typeof a.row){var c=a.row;a.row=function(f,h,d){try{if(d&&h&&d.getFeatures()["dojo.data.api.Identity"])return d.getIdentity(h)==c}catch(r){console.error(r)}return!1}}if(k.isFunction(a.row))return this._records.push(a),a}return null},_isValid:function(a){var b=this.grid.layout.cells,c=b.length;return k.isObject(a)&&"row"in a&&"start"in a&&"end"in
  a&&0<=a.start&&a.start<c&&a.end>a.start&&a.end<c&&b[a.start].view.index==b[a.end].view.index&&b[a.start].subrow==b[a.end].subrow&&!("number"==typeof a.major&&(a.major<a.start||a.major>a.end))},_updateRows:function(a){for(var b=null,c=0,f=this.grid.rowCount;c<f;++c){var h=this.grid._by_idx[c];h&&a.row(c,h&&h.item,this.grid.store)&&(this.grid.views.updateRow(c),null===b&&(b=c))}0<=b&&this.grid.scroller.rowHeightChanged(b)}});x.registerPlugin(p);return p});