//>>built
define("dojox/gantt/GanttResourceItem","dojo/_base/declare dojo/_base/array dojo/_base/lang dojo/date/locale dojo/request dojo/on dojo/dom dojo/dom-class dojo/dom-construct dojo/dom-style dojo/dom-attr dojo/dom-geometry dojo/keys dojo/domReady!".split(" "),function(t,k,u,y,z,v,A,r,l,e,w,B,x){return t("dojox.gantt.GanttResourceItem",[],{constructor:function(a){this.ganttChart=a;this.ownerItem=[];this.ownerNameItem=[];this.ownerTaskNodeMapping={};this.ownerTaskNodeMapping_time={};this.resourceInfo=
{};this.ownerTimeConsume={}},clearAll:function(){this.clearData();this.clearItems()},clearData:function(){this.ownerItem=[];this.ownerNameItem=[];this.ownerTaskNodeMapping={};this.ownerTaskNodeMapping_time={};this.resourceInfo={};this.ownerTimeConsume={}},clearItems:function(){this.content.firstChild&&l.destroy(this.content.firstChild)},buildResource:function(){var a={};k.forEach(this.ganttChart.arrProjects,function(b){k.forEach(b.arrTasks,function(c){c.buildResourceInfo(a)},this)},this);return a},
buildOwnerTimeConsume:function(){var a={},b;for(b in this.resourceInfo){for(var c=this.resourceInfo[b],d={},f=0;f<c.length;f++){var g=c[f],h=g.taskItem.startTime.getTime();g=864E5*g.taskItem.duration/this.ganttChart.hsPerDay;d.min=d.min?Math.min(d.min,h):h;d.max=d.max?Math.max(d.max,h+g):h+g}d.dur=(d.max-d.min)*this.ganttChart.hsPerDay/864E5;d.min=new Date(d.min);d.max=new Date(d.max);a[b]=d}return a},refresh:function(){this.ownerTimeConsume=this.buildOwnerTimeConsume();this.contentData.firstChild.style.width=
Math.max(1200,this.ganttChart.pixelsPerDay*this.ganttChart.totalDays)+"px";for(var a in this.resourceInfo)this.refreshOwnerEntry(a)},reConstruct:function(){this.clearAll();this.resourceInfo=this.buildResource();this.ownerTimeConsume=this.buildOwnerTimeConsume();this.tableControl=l.create("table",{cellPadding:"0",cellSpacing:"0",className:"ganttResourceTableControl"});var a=this.tableControl.insertRow(this.tableControl.rows.length);this.contentHeight=this.content.offsetHeight;this.contentWidth=this.content.offsetWidth;
this.content.appendChild(this.tableControl);this.contentData=l.create("div",{className:"ganttResourceContentDataContainer"});this.contentData.appendChild(this.createPanelOwners());e.set(this.contentData,"height",this.contentHeight-this.ganttChart.panelTimeHeight+"px");var b=l.create("td",{vAlign:"top"});this.panelNames=l.create("div",{className:"ganttResourcePanelNames"});this.panelNames.appendChild(this.createPanelNamesOwners());b.appendChild(this.panelNames);a.appendChild(b);b=l.create("td",{vAlign:"top"});
var c=l.create("div",{className:"ganttResourceDivCell"});c.appendChild(this.contentData);b.appendChild(c);a.appendChild(b);e.set(this.panelNames,{height:this.contentHeight-this.ganttChart.panelTimeHeight-this.ganttChart.scrollBarWidth+"px",width:this.ganttChart.maxWidthPanelNames+"px"});this.contentData.style.width=this.contentWidth-this.ganttChart.maxWidthPanelNames+"px";this.contentData.firstChild.style.width=this.ganttChart.pixelsPerDay*this.ganttChart.panelTime.firstChild.firstChild.rows[3].cells.length+
"px";var d=this;this.contentData.onscroll=function(){d.panelNames&&(d.panelNames.scrollTop=this.scrollTop)};this.contentData.scrollLeft=this.ganttChart.contentData.scrollLeft;for(var f in this.resourceInfo)this.createOwnerEntry(f);this.postAdjustment()},create:function(){var a=l.create("div",{innerHTML:"Resource Chart:",className:"ganttResourceHeader"},this.ganttChart.content,"after");e.set(a,"width",this.ganttChart.contentWidth+"px");a=l.create("div",{className:"ganttResourceContent"},a,"after");
e.set(a,{width:this.ganttChart.contentWidth+"px",height:(this.ganttChart.resourceChartHeight||.8*this.ganttChart.contentHeight)+"px"});this.content=a||this.content;this.reConstruct()},postAdjustment:function(){this.contentData.firstChild.style.height=23*this.ownerItem.length+"px";this.panelNames.firstChild.style.height=23*this.ownerItem.length+"px"},refreshOwnerEntry:function(a){this.refreshOwnerItem(a);k.forEach(this.resourceInfo[a],function(b,c){this.refreshDetailedTaskEntry(a,this.ownerTaskNodeMapping[a].tasks[c][0],
b)},this)},createOwnerEntry:function(a){var b=this.contentData.firstChild,c=this.ownerItem[this.ownerItem.length-1];this.ownerTaskNodeMapping[a]={};this.ownerTaskNodeMapping[a][a]=[];c=(c?parseInt(c.style.top):-17)+this.ganttChart.heightTaskItem+11;var d=this.createOwnerItem(a,c);b.appendChild(d);this.ownerItem.push(d);this.ownerTaskNodeMapping[a][a].push(d);this.panelNames&&(b=this.createOwnerNameItem(a,c),this.panelNames.firstChild.appendChild(b),this.ownerNameItem.push(b),this.ownerTaskNodeMapping[a][a].push(b));
var f=this.ownerNameItem[this.ownerNameItem.length-1];this.panelNames&&(this.checkWidthTaskNameItem(f),b=this.createTreeImg(f),this.panelNames.firstChild.appendChild(b),this.ownerTaskNodeMapping[a][a].push(b));this.ownerTaskNodeMapping[a].taskCount=this.resourceInfo[a].length;this.ownerTaskNodeMapping[a].isOpen=!1;this.ownerTaskNodeMapping[a].tasks=[];k.forEach(this.resourceInfo[a],function(g){this.ownerTaskNodeMapping[a].tasks.push(this.createDetailedTaskEntry(a,f,g))},this);return this},createOwnerNameItem:function(a,
b){var c=l.create("div",{id:a,title:a,innerHTML:a,className:"ganttOwnerNameItem"});e.set(c,"top",b+"px");return c},refreshOwnerItem:function(a){var b=this.ownerTaskNodeMapping[a][a][0],c=this.ownerTimeConsume[a].dur,d=this.ganttChart.getPosOnDate(this.ownerTimeConsume[a].min);b.style.left=d+"px";b.style.width=c*this.ganttChart.pixelsPerWorkHour+"px";k.forEach(this.resourceInfo[a],function(f,g){var h=this.ganttChart.getPosOnDate(f.taskItem.startTime);e.set(b.childNodes[g],{left:h-d+"px",width:f.taskItem.duration*
this.ganttChart.pixelsPerWorkHour+"px"})},this)},createOwnerItem:function(a,b){var c=this.ownerTimeConsume[a].dur,d=this.ganttChart.getPosOnDate(this.ownerTimeConsume[a].min),f=l.create("div",{id:a,owner:!0,className:"ganttOwnerBar"});e.set(f,{left:d+"px",top:b+"px",width:c*this.ganttChart.pixelsPerWorkHour+"px",height:this.ganttChart.heightTaskItem+"px"});k.forEach(this.resourceInfo[a],function(g){var h=l.create("div",{id:a,className:"ganttOwnerTaskBar"},f),p=this.ganttChart.getPosOnDate(g.taskItem.startTime);
e.set(h,{left:p-d+"px",width:g.taskItem.duration*this.ganttChart.pixelsPerWorkHour+"px",height:this.ganttChart.heightTaskItem+"px"})},this);return f},refreshDetailedTaskEntry:function(a,b,c){this.refreshTaskItem(b,c)},createDetailedTaskEntry:function(a,b,c){a=[];var d=this.contentData.firstChild,f=parseInt(b.style.top),g=this.createTaskItem(c,f);g.style.display="none";d.appendChild(g);this.ownerItem.push(g);a.push(g);this.panelNames&&(c=this.createTaskNameItem(c.taskItem.name,f),this.panelNames.firstChild.appendChild(c),
c.style.display="none",this.ownerNameItem.push(c),a.push(c));this.panelNames&&(this.ownerNameItem[this.ownerNameItem.length-1].style.left=e.get(b,"left")+15+"px",b=this.createConnectingLinesPN(b,this.ownerNameItem[this.ownerNameItem.length-1]),k.forEach(b,function(h){h.style.display="none"},this),a.push({v:b[0],h:b[1]}),this.checkWidthTaskNameItem(this.ownerNameItem[this.ownerNameItem.length-1]));return a},createTaskNameItem:function(a,b){var c=l.create("div",{id:a,className:"ganttTaskNameItem",title:a,
innerHTML:a});e.set(c,"top",b+"px");return c},refreshTaskItem:function(a,b){var c=this.ganttChart.getPosOnDate(b.taskItem.startTime);e.set(a,{left:c+"px",width:b.taskItem.duration*this.ganttChart.pixelsPerWorkHour+"px"})},createTaskItem:function(a,b){var c=this.ganttChart.getPosOnDate(a.taskItem.startTime),d=l.create("div",{id:a.taskItem.name,className:"ganttTaskBar"});e.set(d,{left:c+"px",top:b+"px",width:a.taskItem.duration*this.ganttChart.pixelsPerWorkHour+"px",height:this.ganttChart.heightTaskItem+
"px"});return d},createConnectingLinesPN:function(a,b){var c=[],d=l.create("div",{innerHTML:"\x26nbsp;",className:"ganttResourceLineVerticalLeft"},this.panelNames.firstChild);d.cNode=b;d.pNode=a;var f=l.create("div",{noShade:!0,color:"#000",className:"ganttResourceLineHorizontalLeft"},this.panelNames.firstChild);f.cNode=b;f.pNode=a;this.panelNames.firstChild.appendChild(f);c.push(d);c.push(f);return c},createTreeImg:function(a){var b=l.create("div",{id:a.id,className:"ganttImageTreeExpand"});w.set(b,
"tabIndex",0);var c=this.ownerTaskNodeMapping[a.id];k.forEach(["click","keydown"],function(d){this.ganttChart._events.push(v(b,d,u.hitch(this,function(f){var g=!1,h;if("keydown"!=d||f.keyCode==x.ENTER)if(c.isOpen)for(h in r.remove(b,"ganttImageTreeCollapse"),r.add(b,"ganttImageTreeExpand"),c.isOpen=!1,this.ownerTaskNodeMapping){var p=this.ownerTaskNodeMapping[h];g?(k.forEach(p[h],function(n){e.set(n,"top",e.get(n,"top")-23*c.taskCount+"px")}),k.forEach(p.tasks,function(n){k.forEach(n,function(m){k.forEach(m.v||
m.h?[m.v,m.h]:[m],function(q){e.set(q,"top",e.get(q,"top")-23*c.taskCount+"px")})})})):h==a.id&&(g=!0,k.forEach(p.tasks,function(n){k.forEach(n,function(m){this.styleOwnerItem(m,p[h][0],"none",0)},this)},this))}else for(h in r.remove(b,"ganttImageTreeExpand"),r.add(b,"ganttImageTreeCollapse"),c.isOpen=!0,this.ownerTaskNodeMapping)p=this.ownerTaskNodeMapping[h],g?(k.forEach(p[h],function(n){e.set(n,"top",e.get(n,"top")+23*c.taskCount+"px")}),k.forEach(p.tasks,function(n){k.forEach(n,function(m){k.forEach(m.v||
m.h?[m.v,m.h]:[m],function(q){e.set(q,"top",e.get(q,"top")+23*c.taskCount+"px")})})})):h==a.id&&(g=!0,k.forEach(p.tasks,function(n,m){k.forEach(n,function(q){this.styleOwnerItem(q,p[h][0],"inline",23*(m+1))},this)},this))})))},this);r.add(b,"ganttResourceTreeImage");e.set(b,{left:e.get(a,"left")-12+"px",top:e.get(a,"top")+3+"px"});return b},styleOwnerItem:function(a,b,c,d){a.v||a.h?(e.set(a.v,{height:Math.max(1,a.v.cNode.offsetTop-a.v.pNode.offsetTop)+"px",top:a.v.pNode.offsetTop+5+"px",left:a.v.pNode.offsetLeft-
9+"px",display:c}),e.set(a.h,{width:Math.max(1,a.h.cNode.offsetLeft-a.h.pNode.offsetLeft+4)+"px",top:a.h.cNode.offsetTop+5+"px",left:a.h.pNode.offsetLeft-9+"px",display:c})):e.set(a,{display:c,top:parseInt(b.style.top)+d+"px"})},checkWidthTaskNameItem:function(a){if(a&&a.offsetWidth+a.offsetLeft>this.ganttChart.maxWidthPanelNames){var b=a.id.substring(0,a.firstChild.length-Math.round((a.offsetWidth+a.offsetLeft-this.ganttChart.maxWidthPanelNames)/(a.offsetWidth/a.firstChild.length))-3);a.innerHTML=
b+"..."}},createPanelOwners:function(){var a=l.create("div",{className:"ganttOwnerPanel"});e.set(a,{height:this.contentHeight-this.ganttChart.panelTimeHeight-this.ganttChart.scrollBarWidth+"px"});return a},createPanelNamesOwners:function(){var a=l.create("div",{innerHTML:"\x26nbsp;",className:"ganttResourcePanelNamesOwners"});e.set(a,{height:this.contentHeight-this.ganttChart.panelTimeHeight-this.ganttChart.scrollBarWidth+"px",width:this.ganttChart.maxWidthPanelNames+"px"});return a}})});