//>>built
define("dojox/gantt/GanttProjectControl","./GanttTaskItem ./GanttTaskControl dijit/focus 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(v,w,x,y,u,p,A,B,r,C,q,l,m,z,D,t){return y("dojox.gantt.GanttProjectControl",[],{constructor:function(a,c){this.project=c;this.ganttChart=a;this.projectNameItem=this.projectItem=this.descrProject=
null;this.posX=this.posY=0;this.previousProject=this.nextProject=null;this.arrTasks=[];this.duration=this.percentage=0},checkWidthProjectNameItem:function(){if(this.projectNameItem.offsetWidth+this.projectNameItem.offsetLeft>this.ganttChart.maxWidthTaskNames){var a=this.project.name.substring(0,this.projectNameItem.firstChild.length-Math.round((this.projectNameItem.offsetWidth+this.projectNameItem.offsetLeft-this.ganttChart.maxWidthTaskNames)/(this.projectNameItem.offsetWidth/this.projectNameItem.firstChild.length))-
3);this.projectNameItem.innerHTML=a+"..."}},refreshProjectItem:function(a){this.percentage=this.getPercentCompleted();m.set(a,{left:this.posX+"px",width:this.duration*this.ganttChart.pixelsPerWorkHour+"px"});var c=a.firstChild,b=this.duration*this.ganttChart.pixelsPerWorkHour;c.width=(0==b?1:b)+"px";c.style.width=(0==b?1:b)+"px";c=c.rows[0];-1!=this.percentage?(0!=this.percentage&&(b=c.firstChild,b.width=this.percentage+"%",b=b.firstChild,m.set(b,{width:(this.duration?this.percentage*this.duration*
this.ganttChart.pixelsPerWorkHour/100:1)+"px",height:this.ganttChart.heightTaskItem+"px"})),100!=this.percentage&&(b=c.lastChild,b.width=100-this.percentage+"%",b=b.firstChild,m.set(b,{width:(this.duration?(100-this.percentage)*this.duration*this.ganttChart.pixelsPerWorkHour/100:1)+"px",height:this.ganttChart.heightTaskItem+"px"}))):(b=c.firstChild,b.width="1px",b=b.firstChild,m.set(b,{width:"1px",height:this.ganttChart.heightTaskItem+"px"}));c=a.lastChild.firstChild;m.set(c,{height:this.ganttChart.heightTaskItem+
"px",width:(this.duration?this.duration*this.ganttChart.pixelsPerWorkHour:1)+"px"});c.rows[0].firstChild.height=this.ganttChart.heightTaskItem+"px";0==this.project.parentTasks.length&&(a.style.display="none");return a},refreshDescrProject:function(a){m.set(a,{left:this.posX+this.duration*this.ganttChart.pixelsPerWorkHour+10+"px"});0==this.project.parentTasks.length&&(this.descrProject.style.visibility="hidden");return a},postLoadData:function(){},refresh:function(){this.posX=(this.project.startDate-
this.ganttChart.startDate)/36E5*this.ganttChart.pixelsPerHour;this.refreshProjectItem(this.projectItem[0]);this.refreshDescrProject(this.projectItem[0].nextSibling);return this},create:function(){var a=this.ganttChart.contentData.firstChild;this.posX=(this.project.startDate-this.ganttChart.startDate)/36E5*this.ganttChart.pixelsPerHour;if(this.previousProject)if(0<this.previousProject.arrTasks.length){var c=this.ganttChart.getLastChildTask(this.previousProject.arrTasks[this.previousProject.arrTasks.length-
1]);this.posY=parseInt(c.cTaskItem[0].style.top)+this.ganttChart.heightTaskItem+this.ganttChart.heightTaskItemExtra}else this.posY=parseInt(this.previousProject.projectItem[0].style.top)+this.ganttChart.heightTaskItem+this.ganttChart.heightTaskItemExtra;else this.posY=6;c=this.ganttChart.panelNames.firstChild;this.projectNameItem=this.createProjectNameItem();c.appendChild(this.projectNameItem);this.checkWidthProjectNameItem();this.projectItem=[this.createProjectItem(),[]];a.appendChild(this.projectItem[0]);
a.appendChild(this.createDescrProject());this.adjustPanelTime()},getTaskById:function(a){for(var c=0;c<this.arrTasks.length;c++){var b=this.searchTaskInTree(this.arrTasks[c],a);if(b)return b}return null},searchTaskInTree:function(a,c){if(a.taskItem.id==c)return a;for(var b=0;b<a.childTask.length;b++){var d=a.childTask[b];if(d.taskItem.id==c||0<d.childTask.length&&(d=this.searchTaskInTree(d,c)))return d}return null},shiftProjectItem:function(){for(var a=null,c=null,b=parseInt(this.projectItem[0].style.left),
d=0;d<this.arrTasks.length;d++){var k=this.arrTasks[d],e=parseInt(k.cTaskItem[0].style.left);k=parseInt(k.cTaskItem[0].style.left)+parseInt(k.cTaskItem[0].firstChild.firstChild.width);a||(a=e);c||(c=k);a>e&&(a=e);c<k&&(c=k)}a!=b&&(this.project.startDate=new Date(this.ganttChart.startDate),this.project.startDate.setHours(this.project.startDate.getHours()+a/this.ganttChart.pixelsPerHour));this.projectItem[0].style.left=a+"px";this.resizeProjectItem(c-a);this.duration=Math.round(parseInt(this.projectItem[0].firstChild.width)/
this.ganttChart.pixelsPerWorkHour);this.shiftDescrProject();this.adjustPanelTime()},adjustPanelTime:function(){var a=this.projectItem[0];a=parseInt(a.style.left)+parseInt(a.firstChild.style.width)+this.ganttChart.panelTimeExpandDelta;a+=this.descrProject.offsetWidth;this.ganttChart.adjustPanelTime(a)},resizeProjectItem:function(a){var c=this.percentage,b=this.projectItem[0];if(0<c&&100>c){b.firstChild.style.width=a+"px";b.firstChild.width=a+"px";b.style.width=a+"px";var d=b.firstChild.rows[0];d.cells[0].firstChild.style.width=
Math.round(a*c/100)+"px";d.cells[0].firstChild.style.height=this.ganttChart.heightTaskItem+"px";d.cells[1].firstChild.style.width=Math.round(a*(100-c)/100)+"px";d.cells[1].firstChild.style.height=this.ganttChart.heightTaskItem+"px";b.lastChild.firstChild.width=a+"px"}else if(0==c||100==c)b.firstChild.style.width=a+"px",b.firstChild.width=a+"px",b.style.width=a+"px",d=b.firstChild.rows[0],d.cells[0].firstChild.style.width=a+"px",d.cells[0].firstChild.style.height=this.ganttChart.heightTaskItem+"px",
b.lastChild.firstChild.width=a+"px"},shiftDescrProject:function(){var a=parseInt(this.projectItem[0].style.left)+this.duration*this.ganttChart.pixelsPerWorkHour+10;this.descrProject.style.left=a+"px";this.descrProject.innerHTML=this.getDescStr()},showDescrProject:function(){var a=parseInt(this.projectItem[0].style.left)+this.duration*this.ganttChart.pixelsPerWorkHour+10;this.descrProject.style.left=a+"px";this.descrProject.style.visibility="visible";this.descrProject.innerHTML=this.getDescStr()},
hideDescrProject:function(){this.descrProject.style.visibility="hidden"},getDescStr:function(){return this.duration/this.ganttChart.hsPerDay+" days,  "+this.duration+" hours"},createDescrProject:function(){var a=this.posX+this.duration*this.ganttChart.pixelsPerWorkHour+10,c=l.create("div",{innerHTML:this.getDescStr(),className:"ganttDescProject"});m.set(c,{left:a+"px",top:this.posY+"px"});this.descrProject=c;0==this.project.parentTasks.length&&(this.descrProject.style.visibility="hidden");return c},
createProjectItem:function(){this.percentage=this.getPercentCompleted();this.duration=this.getDuration();var a=l.create("div",{id:this.project.id,className:"ganttProjectItem"});m.set(a,{left:this.posX+"px",top:this.posY+"px",width:this.duration*this.ganttChart.pixelsPerWorkHour+"px"});var c=l.create("table",{cellPadding:"0",cellSpacing:"0",className:"ganttTblProjectItem"},a),b=this.duration*this.ganttChart.pixelsPerWorkHour;c.width=(0==b?1:b)+"px";c.style.width=(0==b?1:b)+"px";c=c.insertRow(c.rows.length);
-1!=this.percentage?(0!=this.percentage&&(b=l.create("td",{width:this.percentage+"%"},c),b.style.lineHeight="1px",b=l.create("div",{className:"ganttImageProgressFilled"},b),m.set(b,{width:this.percentage*this.duration*this.ganttChart.pixelsPerWorkHour/100+"px",height:this.ganttChart.heightTaskItem+"px"})),100!=this.percentage&&(b=l.create("td",{width:100-this.percentage+"%"},c),b.style.lineHeight="1px",b=l.create("div",{className:"ganttImageProgressBg"},b),m.set(b,{width:(100-this.percentage)*this.duration*
this.ganttChart.pixelsPerWorkHour/100+"px",height:this.ganttChart.heightTaskItem+"px"}))):(b=l.create("td",{width:"1px"},c),b.style.lineHeight="1px",b=l.create("div",{className:"ganttImageProgressBg"},b),m.set(b,{width:"1px",height:this.ganttChart.heightTaskItem+"px"}));c=l.create("div",{className:"ganttDivTaskInfo"});b=l.create("table",{cellPadding:"0",cellSpacing:"0",height:this.ganttChart.heightTaskItem+"px",width:(0==this.duration*this.ganttChart.pixelsPerWorkHour?1:this.duration*this.ganttChart.pixelsPerWorkHour)+
"px"},c).insertRow(0);l.create("td",{align:"center",vAlign:"top",height:this.ganttChart.heightTaskItem+"px",className:"ganttMoveInfo"},b);a.appendChild(c);0==this.project.parentTasks.length&&(a.style.display="none");return a},createProjectNameItem:function(){var a=l.create("div",{className:"ganttProjectNameItem",innerHTML:this.project.name,title:this.project.name});m.set(a,{left:"5px",top:this.posY+"px"});z.set(a,"tabIndex",0);this.ganttChart.isShowConMenu&&(this.ganttChart._events.push(r(a,"mouseover",
p.hitch(this,function(c){q.add(a,"ganttProjectNameItemHover");clearTimeout(this.ganttChart.menuTimer);this.ganttChart.tabMenu.clear();this.ganttChart.tabMenu.show(c.target,this)}))),this.ganttChart._events.push(r(a,"keydown",p.hitch(this,function(c){c.keyCode==t.ENTER&&(this.ganttChart.tabMenu.clear(),this.ganttChart.tabMenu.show(c.target,this));!this.ganttChart.tabMenu.isShow||c.keyCode!=t.LEFT_ARROW&&c.keyCode!=t.RIGHT_ARROW||x(this.ganttChart.tabMenu.menuPanel.firstChild.rows[0].cells[0]);this.ganttChart.tabMenu.isShow&&
c.keyCode==t.ESCAPE&&this.ganttChart.tabMenu.hide()}))),this.ganttChart._events.push(r(a,"mouseout",p.hitch(this,function(){q.remove(a,"ganttProjectNameItemHover");clearTimeout(this.ganttChart.menuTimer);this.ganttChart.menuTimer=setTimeout(p.hitch(this,function(){this.ganttChart.tabMenu.hide()}),200)}))),this.ganttChart._events.push(r(this.ganttChart.tabMenu.menuPanel,"mouseover",p.hitch(this,function(){clearTimeout(this.ganttChart.menuTimer)}))),this.ganttChart._events.push(r(this.ganttChart.tabMenu.menuPanel,
"keydown",p.hitch(this,function(){this.ganttChart.tabMenu.isShow&&event.keyCode==t.ESCAPE&&this.ganttChart.tabMenu.hide()}))),this.ganttChart._events.push(r(this.ganttChart.tabMenu.menuPanel,"mouseout",p.hitch(this,function(){clearTimeout(this.ganttChart.menuTimer);this.ganttChart.menuTimer=setTimeout(p.hitch(this,function(){this.ganttChart.tabMenu.hide()}),200)}))));return a},getPercentCompleted:function(){var a=0;u.forEach(this.project.parentTasks,function(c){a+=parseInt(c.percentage)},this);return 0!=
this.project.parentTasks.length?Math.round(a/this.project.parentTasks.length):-1},getDuration:function(){var a=0,c=0;return 0<this.project.parentTasks.length?(u.forEach(this.project.parentTasks,function(b){c=24*b.duration/this.ganttChart.hsPerDay+(b.startTime-this.ganttChart.startDate)/36E5;c>a&&(a=c)},this),(a-this.posX)/24*this.ganttChart.hsPerDay):0},deleteTask:function(a){if(a=this.getTaskById(a))this.deleteChildTask(a),this.ganttChart.checkPosition()},setName:function(a){a&&(this.project.name=
a,this.projectNameItem.innerHTML=a,this.projectNameItem.title=a,this.checkWidthProjectNameItem(),this.descrProject.innerHTML=this.getDescStr(),this.adjustPanelTime())},setPercentCompleted:function(a){a=parseInt(a);if(isNaN(a)||100<a||0>a)return!1;var c=this.projectItem[0].firstChild.rows[0],b=c.cells[0],d=c.cells[1];0<a&&100>a&&0<this.percentage&&100>this.percentage?(b.width=parseInt(a)+"%",b.firstChild.style.width=a*this.duration*this.ganttChart.pixelsPerWorkHour/100+"px",d.width=100-parseInt(a)+
"%",d.firstChild.style.width=(100-a)*this.duration*this.ganttChart.pixelsPerWorkHour/100+"px"):(0==a||100==a)&&0<this.percentage&&100>this.percentage?0==a?(b.parentNode.removeChild(b),d.width="100%",d.firstChild.style.width=this.duration*this.ganttChart.pixelsPerWorkHour+"px"):100==a&&(d.parentNode.removeChild(d),b.width="100%",b.firstChild.style.width=this.duration*this.ganttChart.pixelsPerWorkHour+"px"):0!=a&&100!=a||0!=this.percentage&&100!=this.percentage?!(0<a||100>a)||0!=this.percentage&&100!=
this.percentage?-1==this.percentage&&(100==a?(q.remove(b.firstChild,"ganttImageProgressBg"),q.add(b.firstChild,"ganttImageProgressFilled")):100>a&&0<a&&(b.parentNode.removeChild(b),b=l.create("td",{width:a+"%"},c),b.style.lineHeight="1px",b=l.create("div",{className:"ganttImageProgressFilled"},b),m.set(b,{width:a*this.duration*this.ganttChart.pixelsPerWorkHour/100+"px",height:this.ganttChart.heightTaskItem+"px"}),b=l.create("td",{width:100-a+"%"},c),b.style.lineHeight="1px",b=l.create("div",{className:"ganttImageProgressBg"},
b),m.set(b,{width:(100-a)*this.duration*this.ganttChart.pixelsPerWorkHour/100+"px",height:this.ganttChart.heightTaskItem+"px"}))):(b.parentNode.removeChild(b),b=l.create("td",{width:a+"%"},c),b.style.lineHeight="1px",b=l.create("div",{className:"ganttImageProgressFilled"},b),m.set(b,{width:a*this.duration*this.ganttChart.pixelsPerWorkHour/100+"px",height:this.ganttChart.heightTaskItem+"px"}),b=l.create("td",{width:100-a+"%"},c),b.style.lineHeight="1px",b=l.create("div",{className:"ganttImageProgressBg"},
b),m.set(b,{width:(100-a)*this.duration*this.ganttChart.pixelsPerWorkHour/100+"px",height:this.ganttChart.heightTaskItem+"px"})):0==a&&100==this.percentage?(q.remove(b.firstChild,"ganttImageProgressFilled"),q.add(b.firstChild,"ganttImageProgressBg")):100==a&&0==this.percentage&&(q.remove(b.firstChild,"ganttImageProgressBg"),q.add(b.firstChild,"ganttImageProgressFilled"));this.percentage=a;this.descrProject.innerHTML=this.getDescStr();return!0},deleteChildTask:function(a){if(a){var c=a.cTaskItem[0],
b=a.cTaskNameItem[0],d=a.cTaskItem[1],k=a.cTaskNameItem[1],e=a.cTaskNameItem[2];"none"==c.style.display&&this.ganttChart.openTree(a.parentTask);if(0<a.childPredTask.length)for(var f=0;f<a.childPredTask.length;f++){for(var n=a.childPredTask[f],g=0;g<n.cTaskItem[1].length;g++)n.cTaskItem[1][g].parentNode.removeChild(n.cTaskItem[1][g]);n.cTaskItem[1]=[];n.predTask=null}if(0<a.childTask.length)for(;0<a.childTask.length;)this.deleteChildTask(a.childTask[0]);f=this.ganttChart.heightTaskItem+this.ganttChart.heightTaskItemExtra;
"none"!=c.style.display&&a.shiftCurrentTasks(a,-f);this.project.deleteTask(a.taskItem.id);c&&c.parentNode.removeChild(c);a.descrTask.parentNode.removeChild(a.descrTask);if(0<d.length)for(f=0;f<d.length;f++)d[f].parentNode.removeChild(d[f]);b&&b.parentNode.removeChild(b);if(a.cTaskNameItem[1])for(f=0;f<k.length;f++)k[f].parentNode.removeChild(k[f]);e&&e.parentNode&&e.parentNode.removeChild(e);a.taskIdentifier&&(a.taskIdentifier.parentNode.removeChild(a.taskIdentifier),a.taskIdentifier=null);if(a.parentTask){a.previousChildTask&&
(a.previousChildTask.nextChildTask=a.nextChildTask?a.nextChildTask:null);b=a.parentTask;for(f=0;f<b.childTask.length;f++)if(b.childTask[f].taskItem.id==a.taskItem.id){b.childTask[f]=null;b.childTask.splice(f,1);break}0==b.childTask.length&&b.cTaskNameItem[2]&&(b.cTaskNameItem[2].parentNode.removeChild(b.cTaskNameItem[2]),b.cTaskNameItem[2]=null)}else for(a.previousParentTask&&(a.previousParentTask.nextParentTask=a.nextParentTask?a.nextParentTask:null),b=a.project,f=0;f<b.arrTasks.length;f++)b.arrTasks[f].taskItem.id==
a.taskItem.id&&b.arrTasks.splice(f,1);if(a.predTask)for(b=a.predTask,f=0;f<b.childPredTask.length;f++)b.childPredTask[f].taskItem.id==a.taskItem.id&&(b.childPredTask[f]=null,b.childPredTask.splice(f,1));0!=a.project.arrTasks.length?a.project.shiftProjectItem():(a.project.projectItem[0].style.display="none",this.hideDescrProject());this.ganttChart.contentDataHeight-=this.ganttChart.heightTaskItemExtra+this.ganttChart.heightTaskItem}},insertTask:function(a,c,b,d,k,e,f,n){var g=null,h=null;if(this.project.getTaskById(a))return!1;
if(!d||d<this.ganttChart.minWorkLength)d=this.ganttChart.minWorkLength;c&&""!=c||(c=a);if(k&&""!=k){if(k=parseInt(k),0>k||100<k)return!1}else k=0;if(n&&""!=n){h=this.project.getTaskById(n);if(!h)return!1;b=b||h.startTime;if(b<h.startTime)return!1;g=new v({id:a,name:c,startTime:b,duration:d,percentage:k,previousTaskId:e,taskOwner:f});if(!this.ganttChart.checkPosParentTask(h,g))return!1;g.parentTask=h;a=this.getTaskById(h.id);c=!1;"none"==a.cTaskItem[0].style.display?c=!0:a.cTaskNameItem[2]&&(a.isExpanded||
(c=!0));c&&(0==a.childTask.length?this.ganttChart.openTree(a.parentTask):this.ganttChart.openTree(a));if(""!=e){if((e=this.project.getTaskById(e))&&e.parentTask){if(e.parentTask.id!=g.parentTask.id)return!1}else return!1;this.ganttChart.checkPosPreviousTask(e,g)||this.ganttChart.correctPosPreviousTask(e,g);g.previousTask=e}0<h.cldTasks.length&&(h.cldTasks[h.cldTasks.length-1].nextChildTask=g,g.previousChildTask=h.cldTasks[h.cldTasks.length-1]);h.cldTasks.push(g);1==h.cldTasks.length&&(a.cTaskNameItem[2]=
a.createTreeImg());h=new w(g,this,this.ganttChart);h.create();g.nextChildTask&&(h.nextChildTask=h.project.getTaskById(g.nextChildTask.id));h.adjustPanelTime();g=this.ganttChart.heightTaskItem+this.ganttChart.heightTaskItemExtra;h.shiftCurrentTasks(h,g)}else{b=b||this.project.startDate;g=new v({id:a,name:c,startTime:b,duration:d,percentage:k,previousTaskId:e,taskOwner:f});if(g.startTime<=this.ganttChart.startDate)return!1;if(""!=e){e=this.project.getTaskById(e);if(!e)return!1;this.ganttChart.checkPosPreviousTask(e,
g)||this.ganttChart.correctPosPreviousTask(e,g);if(e.parentTask)return!1;g.previousTask=e}0<this.project.parentTasks.length&&(this.project.parentTasks[this.project.parentTasks.length-1].nextParentTask=g,g.previousParentTask=this.project.parentTasks[this.project.parentTasks.length-1]);this.project.parentTasks.push(g);h=new w(g,this,this.ganttChart);h.create();g.nextParentTask&&(h.nextParentTask=h.project.getTaskById(g.nextParentTask.id));h.adjustPanelTime();this.arrTasks.push(h);g=this.ganttChart.heightTaskItem+
this.ganttChart.heightTaskItemExtra;h.shiftCurrentTasks(h,g);this.projectItem[0].style.display="inline";this.setPercentCompleted(this.getPercentCompleted());this.shiftProjectItem();this.showDescrProject()}this.ganttChart.checkHeighPanelTasks();this.ganttChart.checkPosition();return h},shiftNextProject:function(a,c){a.nextProject&&(a.nextProject.shiftProject(c),this.shiftNextProject(a.nextProject,c))},shiftProject:function(a){this.posY+=a;this.projectItem[0].style.top=parseInt(this.projectItem[0].style.top)+
a+"px";this.descrProject.style.top=parseInt(this.descrProject.style.top)+a+"px";this.projectNameItem.style.top=parseInt(this.projectNameItem.style.top)+a+"px";0<this.arrTasks.length&&this.shiftNextParentTask(this.arrTasks[0],a)},shiftTask:function(a,c){a.posY+=c;var b=a.cTaskNameItem[0],d=a.cTaskNameItem[1],k=a.cTaskNameItem[2],e=a.cTaskItem[1];b.style.top=parseInt(b.style.top)+c+"px";k&&(k.style.top=parseInt(k.style.top)+c+"px");a.parentTask&&(d[0].style.top=parseInt(d[0].style.top)+c+"px",d[1].style.top=
parseInt(d[1].style.top)+c+"px");a.cTaskItem[0].style.top=parseInt(a.cTaskItem[0].style.top)+c+"px";a.descrTask.style.top=parseInt(a.descrTask.style.top)+c+"px";e[0]&&(e[0].style.top=parseInt(e[0].style.top)+c+"px",e[1].style.top=parseInt(e[1].style.top)+c+"px",e[2].style.top=parseInt(e[2].style.top)+c+"px")},shiftNextParentTask:function(a,c){this.shiftTask(a,c);this.shiftChildTasks(a,c);a.nextParentTask&&this.shiftNextParentTask(a.nextParentTask,c)},shiftChildTasks:function(a,c){u.forEach(a.childTask,
function(b){this.shiftTask(b,c);0<b.childTask.length&&this.shiftChildTasks(b,c)},this)}})});