diff options
Diffstat (limited to 'js/dojo-1.6/dojox/gantt')
43 files changed, 9961 insertions, 0 deletions
diff --git a/js/dojo-1.6/dojox/gantt/GanttChart.js b/js/dojo-1.6/dojox/gantt/GanttChart.js new file mode 100644 index 0000000..95b26ef --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/GanttChart.js @@ -0,0 +1,1276 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.gantt.GanttChart"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.gantt.GanttChart"] = true;
+dojo.provide("dojox.gantt.GanttChart");
+
+dojo.require("dijit.Tooltip");
+dojo.require("dojox.gantt.GanttProjectItem");
+dojo.require("dojox.gantt.GanttResourceItem");
+dojo.require("dojox.gantt.TabMenu");
+dojo.require("dojo.date.locale");
+
+(function(){
+ dojo.declare("dojox.gantt.GanttChart", null, {
+ constructor: function(configuration, node){
+ this.resourceChartHeight = configuration.resourceChartHeight !== undefined ? configuration.resourceChartHeight : false;
+ this.withResource = configuration.withResource !== undefined ? configuration.withResource : true;
+ this.correctError = configuration.autoCorrectError !== undefined ? configuration.autoCorrectError : false;
+ this.isShowConMenu = this.isContentEditable = !configuration.readOnly;
+ this.withTaskId = configuration.withTaskId !== undefined ? configuration.withTaskId : !configuration.readOnly;
+ this.animation = configuration.animation !== undefined ? configuration.animation : true;
+ this.saveProgramPath = configuration.saveProgramPath || "saveGanttData.php";
+ this.dataFilePath = configuration.dataFilePath || "gantt_default.json";
+ this.contentHeight = configuration.height || 400;
+ this.contentWidth = configuration.width || 600;
+ this.content = dojo.byId(node);
+ this.scrollBarWidth = 18;
+ this.panelTimeHeight = 102;
+ this.maxWidthPanelNames = 150;
+ this.maxWidthTaskNames = 150;
+ this.minWorkLength = 8;
+ this.heightTaskItem = 12;
+ this.heightTaskItemExtra = 11;
+ this.pixelsPerDay = 24;//px
+ this.hsPerDay = 8;
+ this.pixelsPerWorkHour = this.pixelsPerDay / this.hsPerDay;//px
+ this.pixelsPerHour = this.pixelsPerDay / 24;//px
+ this.countDays = 0;
+ this.totalDays = 0;
+ this.startDate = null;
+ this.initialPos = 0;
+
+ this.contentDataHeight = 0;
+ this.panelTimeExpandDelta = 20;
+
+ this.divTimeInfo = null;
+ this.panelNames = null;
+ this.panelTime = null;
+ this.contentData = null;
+ this.tabMenu = null;
+
+ this.project = [];
+ this.arrProjects = [];
+
+ this.xmlLoader = null;
+ this.isMoving = false;
+ this.isResizing = false;
+ this.animationNodes = [];
+ this.scale = 1;
+ this.tempDayInPixels = 0;
+ this.resource = null;
+ this.months = dojo.date.locale.getNames("months", "wide");
+ this._events = [];
+ },
+ getProject: function(id){
+ return dojo.filter(this.arrProjects, function(proj){
+ return proj.project.id == id;
+ }, this)[0];
+ },
+ checkPosPreviousTask: function(predTask, task){
+ var widthPred = this.getWidthOnDuration(predTask.duration);
+ var posPred = this.getPosOnDate(predTask.startTime);
+ var posChild = this.getPosOnDate(task.startTime);
+ if((widthPred + posPred) > posChild){
+ return false;
+ }
+ return true;
+ },
+ correctPosPreviousTask: function(predTask, ctask, ctaskObj){
+ var newDate = new Date(predTask.startTime);
+ newDate.setHours(newDate.getHours() + (predTask.duration / this.hsPerDay * 24))
+ if(newDate.getHours() > 0){
+ newDate.setHours(0);
+ newDate.setDate(newDate.getDate() + 1);
+ }
+ ctaskObj ? (ctaskObj.setStartTime(newDate, true)) : (ctask.startTime = newDate);
+ if(ctask.parentTask){
+ if(!this.checkPosParentTask(ctask.parentTask, ctask)){
+ var newDate2 = new Date(ctask.parentTask.startTime);
+ newDate2.setHours(newDate2.getHours() + (ctask.parentTask.duration / this.hsPerDay * 24))
+ ctask.duration = parseInt((parseInt((newDate2 - ctask.startTime) / (1000 * 60 * 60))) * this.hsPerDay / 24);
+ }
+ }
+ },
+ correctPosParentTask: function(parentTask, ctask){
+ if(!ctask.previousTask){
+ if(parentTask.startTime > ctask.startTime){
+ ctask.startTime = new Date(parentTask.startTime);
+ }
+ if(!this.checkPosParentTask(parentTask, ctask)){
+ ctask.duration = parentTask.duration;
+ }
+ }else{
+ this.correctPosPreviousTask(ctask.previousTask, ctask);
+ }
+ },
+ checkPosParentTaskInTree: function(parentTask){
+ var exception = false;
+ for(var i = 0; i < parentTask.cldTasks.length; i++){
+ var pcTask = parentTask.cldTasks[i];
+ if(!this.checkPosParentTask(parentTask, pcTask)){
+ if(!this.correctError){
+ return true;
+ }else{
+ this.correctPosParentTask(parentTask, pcTask);
+ }
+ }
+ if(parentTask.startTime > pcTask.startTime){
+ if(!this.correctError){
+ return true;
+ }else{
+ this.correctPosParentTask(parentTask, pcTask);
+ }
+ }
+ if(pcTask.cldTasks.length > 0){
+ exception = this.checkPosParentTaskInTree(pcTask);
+ }
+ }
+ return exception;
+ },
+ setPreviousTask: function(project){
+ var exception = false;
+ for(var i = 0; i < project.parentTasks.length; i++){
+ var ppTask = project.parentTasks[i];
+ if(ppTask.previousTaskId){
+ ppTask.previousTask = project.getTaskById(ppTask.previousTaskId);
+ if(!ppTask.previousTask){
+ if(!this.correctError){
+ return true;
+ }
+ }
+ ppTask.previousTask.cldPreTasks.push(ppTask);
+ }
+ if(ppTask.previousTask){
+ if(!this.checkPosPreviousTask(ppTask.previousTask, ppTask)){
+ if(!this.correctError){
+ return true;
+ }else{
+ this.correctPosPreviousTask(ppTask.previousTask, ppTask);
+ }
+ }
+ }
+ exception = this.setPreviousTaskInTree(ppTask);
+ }
+ return exception;
+ },
+ setPreviousTaskInTree: function(parentTask){
+ var exception = false;
+ for(var i = 0; i < parentTask.cldTasks.length; i++){
+ var pcTask = parentTask.cldTasks[i];
+ if(pcTask.previousTaskId){
+ pcTask.previousTask = parentTask.project.getTaskById(pcTask.previousTaskId);
+ if(!pcTask.previousTask){
+ if(!this.correctError){
+ return true;
+ }
+ }
+ if(!this.checkPosPreviousTask(pcTask.previousTask, pcTask)){
+ if(!this.correctError){
+ return true;
+ }else{
+ this.correctPosPreviousTask(pcTask.previousTask, pcTask);
+ }
+ }
+ pcTask.previousTask.cldPreTasks.push(pcTask);
+ }
+
+ if(pcTask.cldTasks.length > 0){
+ exception = this.setPreviousTaskInTree(pcTask);
+ }
+ }
+ return exception;
+ },
+ checkPosParentTask: function(parentTask, task){
+ var widthParent = this.getWidthOnDuration(parentTask.duration);
+ var posParent = this.getPosOnDate(parentTask.startTime);
+ var posChild = this.getPosOnDate(task.startTime);
+ var widthChild = this.getWidthOnDuration(task.duration);
+ return (widthParent + posParent) >= (posChild + widthChild);
+ },
+ addProject: function(projectItem){
+ this.project.push(projectItem);
+ },
+ deleteProject: function(id){
+ var project = this.getProject(id);
+ if(project){
+ if(project.arrTasks.length > 0){
+ while(project.arrTasks.length > 0){
+ project.deleteChildTask(project.arrTasks[0]);
+ }
+ }
+ var rowHeight = this.heightTaskItemExtra + this.heightTaskItem;
+ project.nextProject && project.shiftNextProject(project, -rowHeight); //rowHeight: 23
+ this.project = dojo.filter(this.project, function(proj){
+ return proj.id != project.project.id;
+ }, this);
+ if((project.previousProject) && (project.nextProject)){
+ var previousProject = project.previousProject;
+ previousProject.nextProject = project.nextProject;
+ }
+ if((project.previousProject) && !(project.nextProject)){
+ var previousProject = project.previousProject;
+ previousProject.nextProject = null;
+ }
+ if(!(project.previousProject) && (project.nextProject)){
+ var nextProject = project.nextProject;
+ nextProject.previousProject = null;
+ }
+ for(var i = 0; i < this.arrProjects.length; i++){
+ if(this.arrProjects[i].project.id == id){
+ this.arrProjects.splice(i, 1);
+ }
+ }
+ project.projectItem[0].parentNode.removeChild(project.projectItem[0]);
+ project.descrProject.parentNode.removeChild(project.descrProject);
+ project.projectNameItem.parentNode.removeChild(project.projectNameItem);
+ this.contentDataHeight -= this.heightTaskItemExtra + this.heightTaskItem;
+ if(this.project.length == 0){
+ var d = new Date(this.startDate);
+ var t = new Date(d.setDate(d.getDate() + 1));
+ var pi = new dojox.gantt.GanttProjectItem({
+ id: 1,
+ name: "New Project",
+ startDate: t
+ });
+ this.project.push(pi);
+ var project = new dojox.gantt.GanttProjectControl(this, pi);
+ project.create();
+ this.arrProjects.push(project);
+ this.contentDataHeight += this.heightTaskItemExtra + this.heightTaskItem;
+ }
+ this.checkPosition();
+ }
+ },
+ insertProject: function(id, name, startDate){
+ if(this.startDate >= startDate){
+ return false;
+ }
+ if(this.getProject(id)){
+ return false;
+ }
+ this.checkHeighPanelTasks();
+ var project = new dojox.gantt.GanttProjectItem({
+ id: id,
+ name: name,
+ startDate: startDate
+ });
+ this.project.push(project);
+ var _project = new dojox.gantt.GanttProjectControl(this, project);
+ for(var i = 0; i < this.arrProjects.length; i++){
+ var curProject = this.arrProjects[i],
+ preProject = this.arrProjects[i-1],
+ nextProject = this.arrProjects[i+1];
+ if(startDate < curProject.project.startDate){
+ this.arrProjects.splice(i, 0, _project);
+ if(i > 0){
+ _project.previousProject = preProject;
+ preProject.nextProject = _project;
+ }
+ if(i + 1 <= this.arrProjects.length){
+ _project.nextProject = nextProject;
+ nextProject.previousProject = _project;
+ var rowHeight = this.heightTaskItem + this.heightTaskItemExtra;
+ _project.shiftNextProject(_project, rowHeight);
+ }
+ _project.create();
+ _project.hideDescrProject();
+ this.checkPosition();
+ return _project;
+ }
+ }
+ if(this.arrProjects.length > 0){
+ this.arrProjects[this.arrProjects.length - 1].nextProject = _project;
+ _project.previousProject = this.arrProjects[this.arrProjects.length - 1];
+ }
+ this.arrProjects.push(_project);
+ _project.create();
+ _project.hideDescrProject();
+ this.checkPosition();
+ return _project;
+ },
+ openTree: function(parentTask){
+ var lastParentTask = this.getLastCloseParent(parentTask);
+ this.openNode(lastParentTask);
+ parentTask.taskItem.id != lastParentTask.taskItem.id && this.openTree(parentTask);
+ },
+ openNode: function(parentTask){
+ if(!parentTask.isExpanded){
+ dojo.removeClass(parentTask.cTaskNameItem[2], "ganttImageTreeExpand");
+ dojo.addClass(parentTask.cTaskNameItem[2], "ganttImageTreeCollapse");
+ parentTask.isExpanded = true;
+ parentTask.shiftCurrentTasks(parentTask, parentTask.hideTasksHeight);
+ parentTask.showChildTasks(parentTask, parentTask.isExpanded);
+ parentTask.hideTasksHeight = 0;
+ }
+ },
+ getLastCloseParent: function(task){
+ if(task.parentTask){
+ if((!task.parentTask.isExpanded) ||
+ (task.parentTask.cTaskNameItem[2].style.display == "none")){
+ return this.getLastCloseParent(task.parentTask);
+ }else{
+ return task;
+ }
+ }else{
+ return task;
+ }
+ },
+ getProjectItemById: function(id){
+ return dojo.filter(this.project, function(proj){
+ return proj.id == id;
+ }, this)[0];
+ },
+ clearAll: function(){
+ this.contentDataHeight = 0;
+ this.startDate = null;
+ this.clearData();
+ this.clearItems();
+ this.clearEvents();
+ },
+ clearEvents: function(){
+ dojo.forEach(this._events, dojo.disconnect);
+ this._events = [];
+ },
+ clearData: function(){
+ this.project = [];
+ this.arrProjects = [];
+ },
+ clearItems: function(){
+ this.contentData.removeChild(this.contentData.firstChild);
+ this.contentData.appendChild(this.createPanelTasks());
+ this.panelNames.removeChild(this.panelNames.firstChild);
+ this.panelNames.appendChild(this.createPanelNamesTasks());
+ this.panelTime.removeChild(this.panelTime.firstChild);
+ },
+ buildUIContent: function(){
+ this.project.sort(this.sortProjStartDate);
+ this.startDate = this.getStartDate();
+ this.panelTime.appendChild(this.createPanelTime());
+ for(var i = 0; i < this.project.length; i++){
+ var proj = this.project[i];
+ for(var k = 0; k < proj.parentTasks.length; k++){
+ var ppTask = proj.parentTasks[k];
+ if(ppTask.startTime){
+ this.setStartTimeChild(ppTask);
+ }else{
+ return;
+ }
+ if(this.setPreviousTask(proj)){
+ return;
+ }
+ }
+ for(var k = 0; k < proj.parentTasks.length; k++){
+ var ppTask = proj.parentTasks[k];
+ if(ppTask.startTime < proj.startDate){
+ return;
+ }
+ if(this.checkPosParentTaskInTree(ppTask)) return;
+ }
+ this.sortTasksByStartTime(proj);
+ }
+
+ for(var i = 0; i < this.project.length; i++){
+ var proj = this.project[i];
+ var project = new dojox.gantt.GanttProjectControl(this, proj);
+ if(this.arrProjects.length > 0){
+ var previousProject = this.arrProjects[this.arrProjects.length - 1];
+ project.previousProject = previousProject;
+ previousProject.nextProject = project;
+ }
+ project.create();
+ this.checkHeighPanelTasks();
+ this.arrProjects.push(project);
+ this.createTasks(project);
+ }
+ this.resource && this.resource.reConstruct();
+ this.postLoadData();
+ this.postBindEvents();
+ },
+ loadJSONData: function(filename){
+ var _this = this;
+ _this.dataFilePath = filename || _this.dataFilePath;
+ dojo.xhrGet({
+ url: _this.dataFilePath,
+ sync: true,
+ load: function(text, ioArgs){
+ _this.loadJSONString(text);
+ _this.buildUIContent();
+ alert("Successfully! Loaded data from: " + _this.dataFilePath);
+ },
+ error: function(err, ioArgs){
+ alert("Failed! Load error: " + _this.dataFilePath);
+ }
+ });
+ },
+ loadJSONString: function(content){
+ //load data
+ if(!content){ return; }
+ this.clearAll();
+ var jsonObj = dojo.fromJson(content);
+
+ var items = jsonObj.items;
+ dojo.forEach(items, function(pItem){
+ var startDate = pItem.startdate.split("-");
+ var project = new dojox.gantt.GanttProjectItem({
+ id: pItem.id,
+ name: pItem.name,
+ startDate: new Date(startDate[0], (parseInt(startDate[1]) - 1), startDate[2])
+ });
+ var tItems = pItem.tasks;
+ dojo.forEach(tItems, function(tItem){
+ var id = tItem.id,
+ name = tItem.name,
+ starttime = tItem.starttime.split("-");
+ duration = tItem.duration,
+ percentage = tItem.percentage,
+ previousTaskId = tItem.previousTaskId,
+ taskOwner = tItem.taskOwner;
+
+ var task = new dojox.gantt.GanttTaskItem({
+ id: id,
+ name: name,
+ startTime: new Date(starttime[0], (parseInt(starttime[1]) - 1), starttime[2]),
+ duration: duration,
+ percentage: percentage,
+ previousTaskId: previousTaskId,
+ taskOwner: taskOwner
+ });
+ var ctItems = tItem.children;
+ if(ctItems.length != 0){
+ this.buildChildTasksData(task, ctItems);
+ }
+ project.addTask(task);
+ }, this);
+ this.addProject(project);
+ }, this);
+ },
+ buildChildTasksData: function(parentTask, childTaskItems){
+ childTaskItems && dojo.forEach(childTaskItems, function(ctItem){
+ var id = ctItem.id,
+ name = ctItem.name,
+ starttime = ctItem.starttime.split("-"),
+ duration = ctItem.duration,
+ percentage = ctItem.percentage,
+ previousTaskId = ctItem.previousTaskId,
+ taskOwner = ctItem.taskOwner;
+
+ var task = new dojox.gantt.GanttTaskItem({
+ id: id,
+ name: name,
+ startTime: new Date(starttime[0], (parseInt(starttime[1]) - 1), starttime[2]),
+ duration: duration,
+ percentage: percentage,
+ previousTaskId: previousTaskId,
+ taskOwner: taskOwner
+ });
+ task.parentTask = parentTask;
+ parentTask.addChildTask(task);
+
+ var ctItems = ctItem.children;
+ if(ctItems.length != 0){
+ this.buildChildTasksData(task, ctItems);
+ }
+ }, this);
+ },
+ getJSONData: function(){
+ var jsonObj = {identifier: 'id', items: []};
+ dojo.forEach(this.project, function(proj){
+ var project = {
+ id: proj.id,
+ name: proj.name,
+ startdate: proj.startDate.getFullYear() + '-' + (proj.startDate.getMonth() + 1) + '-' + proj.startDate.getDate(),
+ tasks: []
+ };
+ jsonObj.items.push(project);
+ dojo.forEach(proj.parentTasks, function(pTask){
+ var task = {
+ id: pTask.id,
+ name: pTask.name,
+ starttime: pTask.startTime.getFullYear() + '-' + (pTask.startTime.getMonth() + 1) + '-' + pTask.startTime.getDate(),
+ duration: pTask.duration,
+ percentage: pTask.percentage,
+ previousTaskId: (pTask.previousTaskId || ''),
+ taskOwner: (pTask.taskOwner || ''),
+ children: this.getChildTasksData(pTask.cldTasks)
+ };
+ project.tasks.push(task);
+ }, this);
+ }, this);
+ return jsonObj;
+ },
+ getChildTasksData: function(childTasks){
+ var cTaskObj = [];
+ childTasks && childTasks.length > 0 && dojo.forEach(childTasks, function(childTask){
+ var ctask = {
+ id: childTask.id,
+ name: childTask.name,
+ starttime: childTask.startTime.getFullYear() + '-' + (childTask.startTime.getMonth() + 1) + '-' + childTask.startTime.getDate(),
+ duration: childTask.duration,
+ percentage: childTask.percentage,
+ previousTaskId: (childTask.previousTaskId || ''),
+ taskOwner: (childTask.taskOwner || ''),
+ children: this.getChildTasksData(childTask.cldTasks)
+ };
+ cTaskObj.push(ctask);
+ }, this);
+ return cTaskObj;
+ },
+ saveJSONData: function(fileName){
+ var _this = this;
+ _this.dataFilePath = (fileName && dojo.trim(fileName).length > 0) ? fileName : this.dataFilePath;
+ try {
+ var td = dojo.xhrPost({
+ url: _this.saveProgramPath,
+ content: {filename: _this.dataFilePath, data: dojo.toJson(_this.getJSONData())},
+ handle: function(res, ioArgs){
+ if((dojo._isDocumentOk(ioArgs.xhr))||
+ (ioArgs.xhr.status == 405)
+ ){
+ alert("Successfully! Saved data to " + _this.dataFilePath);
+ }else{
+ alert("Failed! Saved error");
+ }
+ }
+ });
+ } catch (e){
+ alert("exception: " + e.message);
+ }
+ },
+ sortTaskStartTime: function(a, b){
+ return a.startTime < b.startTime ? -1 : (a.startTime > b.startTime ? 1 : 0);
+ },
+ sortProjStartDate: function(a, b){
+ return a.startDate < b.startDate ? -1 : (a.startDate > b.startDate ? 1 : 0);
+ },
+ setStartTimeChild: function(parentTask){
+ dojo.forEach(parentTask.cldTasks, function(pcTask){
+ if(!pcTask.startTime){
+ pcTask.startTime = parentTask.startTime;
+ }
+ if(pcTask.cldTasks.length != 0){
+ this.setStartTimeChild(pcTask);
+ }
+ }, this);
+ },
+ createPanelTasks: function(){
+ var panelTask = dojo.create("div", {
+ className: "ganttTaskPanel"
+ });
+ dojo.style(panelTask, {
+ height: (this.contentHeight - this.panelTimeHeight - this.scrollBarWidth) + "px"
+ });
+ return panelTask;
+ },
+ refreshParams: function(pixelsPerDay){
+ this.pixelsPerDay = pixelsPerDay;
+ this.pixelsPerWorkHour = this.pixelsPerDay / this.hsPerDay;
+ this.pixelsPerHour = this.pixelsPerDay / 24;
+ },
+ createPanelNamesTasksHeader: function(){
+ var _this = this;
+ var panelHeader = dojo.create("div", {className: "ganttPanelHeader"});
+ var tblHeader = dojo.create("table", {
+ cellPadding: "0px",
+ border: "0px",
+ cellSpacing: "0px",
+ bgColor: "#FFFFFF",
+ className: "ganttToolbar"
+ }, panelHeader);
+ var firstRow = tblHeader.insertRow(tblHeader.rows.length);
+ var secondRow = tblHeader.insertRow(tblHeader.rows.length);
+ var thirdRow = tblHeader.insertRow(tblHeader.rows.length);
+ var forthRow = tblHeader.insertRow(tblHeader.rows.length);
+ var zoomIn = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttToolbarZoomIn"
+ }, firstRow);
+ var zoomInFn = dojo.hitch(this, function(){
+ if(this.scale * 2 > 5){return;}
+ this.scale = this.scale * 2;
+ this.switchTeleMicroView(this.pixelsPerDay * this.scale);
+ });
+ dojo.disconnect(this.zoomInClickEvent);
+ this.zoomInClickEvent = dojo.connect(zoomIn, "onclick", this, zoomInFn);
+ //a11y support
+ dojo.disconnect(this.zoomInKeyEvent);
+ this.zoomInKeyEvent = dojo.connect(zoomIn, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ zoomInFn();
+ });
+ dojo.attr(zoomIn, "tabIndex", 0);
+ var zoomOut = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttToolbarZoomOut"
+ }, firstRow);
+ var zoomOutFn = dojo.hitch(this, function(){
+ if(this.scale * 0.5 < 0.2){return;}
+ this.scale = this.scale * 0.5;
+ this.switchTeleMicroView(this.pixelsPerDay * this.scale);
+ });
+ dojo.disconnect(this.zoomOutClickEvent);
+ this.zoomOutClickEvent = dojo.connect(zoomOut, "onclick", this, zoomOutFn);
+ //a11y support
+ dojo.disconnect(this.zoomOutKeyEvent);
+ this.zoomOutKeyEvent = dojo.connect(zoomOut, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ zoomOutFn();
+ });
+ dojo.attr(zoomOut, "tabIndex", 0);
+ var micro = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttToolbarMicro"
+ }, secondRow);
+ dojo.disconnect(this.microClickEvent);
+ this.microClickEvent = dojo.connect(micro, "onclick", this, dojo.hitch(this, this.refresh, this.animation?15:1, 0, 2));
+ //a11y support
+ dojo.disconnect(this.microKeyEvent);
+ this.microKeyEvent = dojo.connect(micro, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ micro.blur();
+ this.refresh(this.animation?15:1, 0, 2);
+ });
+ dojo.attr(micro, "tabIndex", 0);
+ var tele = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttToolbarTele"
+ }, secondRow);
+ dojo.disconnect(this.teleClickEvent);
+ this.teleClickEvent = dojo.connect(tele, "onclick", this, dojo.hitch(this, this.refresh, this.animation?15:1, 0, 0.5));
+ //a11y support
+ dojo.disconnect(this.teleKeyEvent);
+ this.teleKeyEvent = dojo.connect(tele, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ tele.blur();
+ this.refresh(this.animation?15:1, 0, 0.5);
+ });
+ dojo.attr(tele, "tabIndex", 0);
+ var save = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttToolbarSave"
+ }, thirdRow);
+ dojo.disconnect(this.saveClickEvent);
+ this.saveClickEvent = dojo.connect(save, "onclick", this, dojo.hitch(this, this.saveJSONData, ""));
+ //a11y support
+ dojo.disconnect(this.saveKeyEvent);
+ this.saveKeyEvent = dojo.connect(save, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ this.saveJSONData("");
+ });
+ dojo.attr(save, "tabIndex", 0);
+ var load = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttToolbarLoad"
+ }, thirdRow);
+ dojo.disconnect(this.loadClickEvent);
+ this.loadClickEvent = dojo.connect(load, "onclick", this, dojo.hitch(this, this.loadJSONData, ""));
+ //a11y support
+ dojo.disconnect(this.loadKeyEvent);
+ this.loadKeyEvent = dojo.connect(load, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ this.loadJSONData("");
+ });
+ dojo.attr(load, "tabIndex", 0);
+ //action popup description
+ var actions = [zoomIn, zoomOut, micro, tele, save, load],
+ titles = ["Enlarge timeline", "Shrink timeline", "Zoom in time zone(microscope view)", "Zoom out time zone(telescope view)",
+ "Save gantt data to json file", "Load gantt data from json file"];
+ dojo.forEach(actions, function(action, i){
+ var title = titles[i];
+ var tooltipShow = function(){
+ dojo.addClass(action, "ganttToolbarActionHover");
+ dijit.showTooltip(title, action, ["above", "below"]);
+ };
+ action.onmouseover = tooltipShow;
+ //a11y support
+ action.onfocus = tooltipShow;
+ var tooltipHide = function(){
+ dojo.removeClass(action, "ganttToolbarActionHover");
+ action && dijit.hideTooltip(action);
+ };
+ action.onmouseout = tooltipHide;
+ action.onblur = tooltipHide;
+ }, this);
+ return panelHeader;
+ },
+ createPanelNamesTasks: function(){
+ var panelNameTask = dojo.create("div", {
+ innerHTML: " ",
+ className: "ganttPanelNames"
+ });
+ dojo.style(panelNameTask, {
+ height: (this.contentHeight - this.panelTimeHeight - this.scrollBarWidth) + "px",
+ width: this.maxWidthPanelNames + "px"
+ });
+ return panelNameTask;
+ },
+ createPanelTime: function(){
+ var panelTime = dojo.create("div", {className: "ganttPanelTime"});
+ var tblTime = dojo.create("table", {
+ cellPadding: "0px",
+ border: "0px",
+ cellSpacing: "0px",
+ bgColor: "#FFFFFF",
+ className: "ganttTblTime"
+ }, panelTime);
+ this.totalDays = this.countDays;
+ //year
+ var newYearRow = tblTime.insertRow(tblTime.rows.length), newYear = oldYear = new Date(this.startDate).getFullYear(), ycount = 0;
+ for(var i = 0; i < this.countDays; i++, ycount++){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + i);
+ newYear = date.getFullYear();
+ if(newYear != oldYear){
+ this.addYearInPanelTime(newYearRow, ycount, oldYear);
+ ycount = 0;
+ oldYear = newYear;
+ }
+ }
+ this.addYearInPanelTime(newYearRow, ycount, newYear);
+ dojo.style(newYearRow, "display", "none");
+ //month
+ var newMonthRow = tblTime.insertRow(tblTime.rows.length), newMonth = oldMonth = new Date(this.startDate).getMonth(), mcount = 0, lastYear = 1970;
+ for(var i = 0; i < this.countDays; i++, mcount++){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + i);
+ newMonth = date.getMonth();
+ lastYear = date.getFullYear();
+ if(newMonth != oldMonth){
+ this.addMonthInPanelTime(newMonthRow, mcount, oldMonth, lastYear);
+ mcount = 0;
+ oldMonth = newMonth;
+ }
+ }
+ this.addMonthInPanelTime(newMonthRow, mcount, newMonth, lastYear);
+ //week
+ var newWeekRow = tblTime.insertRow(tblTime.rows.length), newWeek = oldWeek = dojo.date.locale._getWeekOfYear(new Date(this.startDate)), mcount = 0;
+ for(var i = 0; i < this.countDays; i++, mcount++){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + i);
+ newWeek = dojo.date.locale._getWeekOfYear(date);
+ if(newWeek != oldWeek){
+ this.addWeekInPanelTime(newWeekRow, mcount, oldWeek);
+ mcount = 0;
+ oldWeek = newWeek;
+ }
+ }
+ this.addWeekInPanelTime(newWeekRow, mcount, newWeek);
+ //day
+ var newDayRow = tblTime.insertRow(tblTime.rows.length);
+ for(var i = 0; i < this.countDays; i++){
+ this.addDayInPanelTime(newDayRow);
+ }
+ //hour
+ var newHourRow = tblTime.insertRow(tblTime.rows.length);
+ for(var i = 0; i < this.countDays; i++){
+ this.addHourInPanelTime(newHourRow);
+ }
+ dojo.style(newHourRow, "display", "none");
+ return panelTime;
+ },
+ adjustPanelTime: function(width){
+ var maxEndPos = dojo.map(this.arrProjects, function(project){
+ return (parseInt(project.projectItem[0].style.left) + parseInt(project.projectItem[0].firstChild.style.width)
+ + project.descrProject.offsetWidth + this.panelTimeExpandDelta);
+ }, this).sort(function(a,b){return b-a})[0];
+ if(this.maxTaskEndPos != maxEndPos){
+ //reset panel time
+ var prows = this.panelTime.firstChild.firstChild.rows;
+ for(var i = 0; i <= 4; i++){//prows.length
+ this.removeCell(prows[i]);
+ };
+ var countDays = Math.round((maxEndPos+this.panelTimeExpandDelta) / this.pixelsPerDay);
+ this.totalDays = countDays;
+ //year
+ var newYear = oldYear = new Date(this.startDate).getFullYear(), ycount = 0;
+ for(var i = 0; i < countDays; i++, ycount++){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + i);
+ newYear = date.getFullYear();
+ if(newYear != oldYear){
+ this.addYearInPanelTime(prows[0], ycount, oldYear);
+ ycount = 0;
+ oldYear = newYear;
+ }
+ }
+ this.addYearInPanelTime(prows[0], ycount, newYear);
+ //month
+ var newMonth = oldMonth = new Date(this.startDate).getMonth(), mcount = 0, lastYear = 1970;
+ for(var i = 0; i < countDays; i++, mcount++){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + i);
+ newMonth = date.getMonth();
+ lastYear = date.getFullYear();
+ if(newMonth != oldMonth){
+ this.addMonthInPanelTime(prows[1], mcount, oldMonth, lastYear);
+ mcount = 0;
+ oldMonth = newMonth;
+ }
+ }
+ this.addMonthInPanelTime(prows[1], mcount, newMonth, lastYear);
+ //week
+ var newWeek = oldWeek = dojo.date.locale._getWeekOfYear(new Date(this.startDate)), mcount = 0;
+ for(var i = 0; i < countDays; i++, mcount++){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + i);
+ newWeek = dojo.date.locale._getWeekOfYear(date);
+ if(newWeek != oldWeek){
+ this.addWeekInPanelTime(prows[2], mcount, oldWeek);
+ mcount = 0;
+ oldWeek = newWeek;
+ }
+ }
+ this.addWeekInPanelTime(prows[2], mcount, newWeek);
+ //day
+ for(var i = 0; i < countDays; i++){
+ this.addDayInPanelTime(prows[3]);
+ }
+ //hour
+ for(var i = 0; i < countDays; i++){
+ this.addHourInPanelTime(prows[4]);
+ }
+ this.panelTime.firstChild.firstChild.style.width = this.pixelsPerDay * (prows[3].cells.length) + "px";
+ this.contentData.firstChild.style.width = this.pixelsPerDay * (prows[3].cells.length) + "px";
+ this.maxTaskEndPos = maxEndPos;
+ }
+ },
+ addYearInPanelTime: function(row, count, year){
+ var data = "Year " + year;
+ var newCell = dojo.create("td", {
+ colSpan: count,
+ align: "center",
+ vAlign: "middle",
+ className: "ganttYearNumber",
+ innerHTML: this.pixelsPerDay * count > 20 ? data : "",
+ innerHTMLData: data
+ }, row);
+ dojo.style(newCell, "width", (this.pixelsPerDay * count) + "px");
+ },
+ addMonthInPanelTime: function(row, count, month, year){
+ var data = this.months[month] + (year ? " of " + year : "");
+ var newCell = dojo.create("td", {
+ colSpan: count,
+ align: "center",
+ vAlign: "middle",
+ className: "ganttMonthNumber",
+ innerHTML: this.pixelsPerDay * count > 30 ? data : "",
+ innerHTMLData: data
+ }, row);
+ dojo.style(newCell, "width", (this.pixelsPerDay * count) + "px");
+ },
+ addWeekInPanelTime: function(row, count, week){
+ var data = "Week " + week;
+ var newCell = dojo.create("td", {
+ colSpan: count,
+ align: "center",
+ vAlign: "middle",
+ className: "ganttWeekNumber",
+ innerHTML: this.pixelsPerDay * count > 20 ? data : "",
+ innerHTMLData: data
+ }, row);
+ dojo.style(newCell, "width", (this.pixelsPerDay * count) + "px");
+ },
+ addDayInPanelTime: function(row){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + parseInt(row.cells.length));
+ var newCell = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttDayNumber",
+ innerHTML: this.pixelsPerDay > 20 ? date.getDate() : "",
+ innerHTMLData: String(date.getDate()),
+ data: row.cells.length
+ }, row);
+ dojo.style(newCell, "width", this.pixelsPerDay + "px");
+ (date.getDay() >= 5) && dojo.addClass(newCell, "ganttDayNumberWeekend");
+ this._events.push(
+ dojo.connect(newCell, "onmouseover", this, function(event){
+ var dayTime = event.target || event.srcElement;
+ var date = new Date(this.startDate.getTime());
+ date.setDate(date.getDate() + parseInt(dojo.attr(dayTime, "data")));
+ dijit.showTooltip(date.getFullYear() + "." + (date.getMonth() + 1) + "." + date.getDate(), newCell, ["above", "below"]);
+ })
+ );
+ this._events.push(
+ dojo.connect(newCell, "onmouseout", this, function(event){
+ var dayTime = event.target || event.srcElement;
+ dayTime && dijit.hideTooltip(dayTime);
+ })
+ );
+ },
+ addHourInPanelTime: function(row){
+ var newCell = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttHourNumber",
+ data: row.cells.length
+ }, row);
+ dojo.style(newCell, "width", this.pixelsPerDay + "px");
+
+ var hourTable = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0"
+ }, newCell);
+ var newRow = hourTable.insertRow(hourTable.rows.length);
+ for(var i = 0; i < this.hsPerDay; i++){
+ var hourTD = dojo.create("td", {
+ className: "ganttHourClass"
+ }, newRow);
+ dojo.style(hourTD, "width", (this.pixelsPerDay / this.hsPerDay) + "px");
+ dojo.attr(hourTD, "innerHTMLData", String(9 + i));
+ if(this.pixelsPerDay / this.hsPerDay > 5){
+ dojo.attr(hourTD, "innerHTML", String(9 + i));
+ }
+ dojo.addClass(hourTD, i <= 3?"ganttHourNumberAM":"ganttHourNumberPM");
+ }
+ },
+ incHeightPanelTasks: function(height){
+ var containerTasks = this.contentData.firstChild;
+ containerTasks.style.height = parseInt(containerTasks.style.height) + height + "px";
+ },
+ incHeightPanelNames: function(height){
+ var containerNames = this.panelNames.firstChild;
+ containerNames.style.height = parseInt(containerNames.style.height) + height + "px";
+ },
+ checkPosition: function(){
+ dojo.forEach(this.arrProjects, function(project){
+ dojo.forEach(project.arrTasks, function(task){
+ task.checkPosition();
+ }, this);
+ }, this);
+ },
+ checkHeighPanelTasks: function(){
+ this.contentDataHeight += this.heightTaskItemExtra + this.heightTaskItem;
+ if((parseInt(this.contentData.firstChild.style.height) <= this.contentDataHeight)){
+ this.incHeightPanelTasks(this.heightTaskItem + this.heightTaskItemExtra);
+ this.incHeightPanelNames(this.heightTaskItem + this.heightTaskItemExtra);
+ }
+ },
+ sortTasksByStartTime: function(project){
+ project.parentTasks.sort(this.sortTaskStartTime);
+ for(var i = 0; i < project.parentTasks.length; i++){
+ project.parentTasks[i] = this.sortChildTasks(project.parentTasks[i]);
+ }
+ },
+ sortChildTasks: function(parenttask){
+ parenttask.cldTasks.sort(this.sortTaskStartTime);
+ for(var i = 0; i < parenttask.cldTasks.length; i++){
+ if(parenttask.cldTasks[i].cldTasks.length > 0) this.sortChildTasks(parenttask.cldTasks[i]);
+ }
+ return parenttask;
+ },
+ refresh: function(count, current, multi){
+ //return if no task items
+ if(this.arrProjects.length <= 0){return;}
+ if(this.arrProjects[0].arrTasks.length <= 0){return;}
+ //Show panel of names
+ if(!count || current > count){
+ this.refreshController();
+ if(this.resource){
+ this.resource.refresh();
+ }
+ this.tempDayInPixels = 0;
+ this.panelNameHeadersCover && dojo.style(this.panelNameHeadersCover, "display", "none");
+ return;
+ }
+ if(this.tempDayInPixels == 0){
+ this.tempDayInPixels = this.pixelsPerDay;
+ }
+ this.panelNameHeadersCover && dojo.style(this.panelNameHeadersCover, "display", "");
+ var dip = this.tempDayInPixels + this.tempDayInPixels * (multi - 1) * Math.pow((current / count), 2);
+ this.refreshParams(dip);
+ dojo.forEach(this.arrProjects, function(project){
+ dojo.forEach(project.arrTasks, function(task){
+ task.refresh();
+ }, this);
+ project.refresh();
+ }, this);
+ setTimeout(dojo.hitch(this, function(){
+ this.refresh(count, ++current, multi);
+ }), 15);
+ },
+ switchTeleMicroView: function(dip){
+ var plChild = this.panelTime.firstChild.firstChild;
+ for(var i = 0; i < 5; i++){//0:Y 1:M 2:W 3:D 4:H
+ if(dip > 40){
+ dojo.style(plChild.rows[i], "display", (i==0||i==1)?"none":"");
+ }else if(dip < 20){
+ dojo.style(plChild.rows[i], "display", (i==2||i==4)?"none":"");
+ }else{
+ dojo.style(plChild.rows[i], "display", (i==0||i==4)?"none":"");
+ }
+ }
+ },
+ refreshController: function(){
+ this.contentData.firstChild.style.width = Math.max(1200, this.pixelsPerDay * this.totalDays) + "px";
+ this.panelTime.firstChild.style.width = this.pixelsPerDay * this.totalDays + "px";
+ this.panelTime.firstChild.firstChild.style.width = this.pixelsPerDay * this.totalDays + "px";
+ this.switchTeleMicroView(this.pixelsPerDay);
+ dojo.forEach(this.panelTime.firstChild.firstChild.rows, function(row){
+ dojo.forEach(row.childNodes, function(td){
+ var cs = parseInt(dojo.attr(td, "colSpan") || 1);
+ var idata = dojo.trim(dojo.attr(td, "innerHTMLData")||"");
+ if(idata.length > 0){
+ dojo.attr(td, "innerHTML", this.pixelsPerDay * cs < 20 ? "" : idata);
+ }else{
+ dojo.forEach(td.firstChild.rows[0].childNodes, function(td){
+ var sdata = dojo.trim(dojo.attr(td, "innerHTMLData")||"");
+ dojo.attr(td, "innerHTML", this.pixelsPerDay / this.hsPerDay > 10 ? sdata : "");
+ }, this);
+ }
+ if(cs == 1){
+ dojo.style(td, "width", (this.pixelsPerDay*cs) + "px");
+ if(idata.length <= 0){
+ dojo.forEach(td.firstChild.rows[0].childNodes, function(td){
+ dojo.style(td, "width", (this.pixelsPerDay*cs / this.hsPerDay) + "px");
+ }, this);
+ }
+ }
+ }, this);
+ }, this);
+ },
+ init: function(){
+ this.startDate = this.getStartDate();
+ dojo.style(this.content, {
+ width: this.contentWidth + "px",
+ height: this.contentHeight + "px"
+ });
+ //create Table
+ this.tableControl = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0",
+ className: "ganttTabelControl"
+ });
+ var newRowTblControl = this.tableControl.insertRow(this.tableControl.rows.length);
+ //Add to content Table
+ this.content.appendChild(this.tableControl);
+ this.countDays = this.getCountDays();
+ //Creation panel of time
+ this.panelTime = dojo.create("div", {className: "ganttPanelTimeContainer"});
+ dojo.style(this.panelTime, "height", this.panelTimeHeight + "px");
+ this.panelTime.appendChild(this.createPanelTime());
+ //Creation panel contentData
+ this.contentData = dojo.create("div", {className: "ganttContentDataContainer"});
+ dojo.style(this.contentData, "height", (this.contentHeight - this.panelTimeHeight) + "px");
+ this.contentData.appendChild(this.createPanelTasks());
+ //Creation panel of names
+ var newCellTblControl = dojo.create("td", {
+ vAlign: "top"
+ });
+ //Creation panel of task header
+ this.panelNameHeaders = dojo.create("div", {className: "ganttPanelNameHeaders"}, newCellTblControl);
+ dojo.style(this.panelNameHeaders, {
+ height: this.panelTimeHeight + "px",
+ width: this.maxWidthPanelNames + "px"
+ });
+ this.panelNameHeaders.appendChild(this.createPanelNamesTasksHeader());
+ this.panelNames = dojo.create("div", {className: "ganttPanelNamesContainer"}, newCellTblControl);
+ this.panelNames.appendChild(this.createPanelNamesTasks());
+ newRowTblControl.appendChild(newCellTblControl);
+ //add to control contentData and dataTime
+ newCellTblControl = dojo.create("td", {
+ vAlign: "top"
+ });
+ var divCell = dojo.create("div", {className: "ganttDivCell"});
+ divCell.appendChild(this.panelTime);
+ divCell.appendChild(this.contentData);
+ newCellTblControl.appendChild(divCell);
+ newRowTblControl.appendChild(newCellTblControl);
+ //Show panel of names
+ dojo.style(this.panelNames, "height", (this.contentHeight - this.panelTimeHeight - this.scrollBarWidth) + "px");
+ dojo.style(this.panelNames, "width", this.maxWidthPanelNames + "px");
+ dojo.style(this.contentData, "width", (this.contentWidth - this.maxWidthPanelNames) + "px");
+ dojo.style(this.contentData.firstChild, "width", this.pixelsPerDay * this.countDays + "px");
+ dojo.style(this.panelTime, "width", (this.contentWidth - this.maxWidthPanelNames - this.scrollBarWidth) + "px");
+ dojo.style(this.panelTime.firstChild, "width", this.pixelsPerDay * this.countDays + "px");
+ if(this.isShowConMenu){
+ this.tabMenu = new dojox.gantt.TabMenu(this);
+ }
+ var _this = this;
+ this.contentData.onscroll = function(){
+ _this.panelTime.scrollLeft = this.scrollLeft;
+ if(_this.panelNames){
+ _this.panelNames.scrollTop = this.scrollTop;
+ if(_this.isShowConMenu){
+ _this.tabMenu.hide();
+ }
+ }
+ if(_this.resource){
+ _this.resource.contentData.scrollLeft = this.scrollLeft;
+ }
+ }
+ this.project.sort(this.sortProjStartDate);
+ for(var i = 0; i < this.project.length; i++){
+ var proj = this.project[i];
+ for(var k = 0; k < proj.parentTasks.length; k++){
+ var ppTask = proj.parentTasks[k];
+ if(!ppTask.startTime){
+ ppTask.startTime = proj.startDate;
+ }
+ this.setStartTimeChild(ppTask);
+ if(this.setPreviousTask(proj)){
+ return;
+ }
+ }
+ for(var k = 0; k < proj.parentTasks.length; k++){
+ var ppTask = proj.parentTasks[k];
+ if(ppTask.startTime < proj.startDate){
+ if(!this.correctError){
+ return;
+ }else{
+ ppTask.startTime = proj.startDate;
+ }
+ }
+ if(this.checkPosParentTaskInTree(ppTask)){
+ return;
+ }
+ }
+ this.sortTasksByStartTime(proj);
+ }
+ for(var i = 0; i < this.project.length; i++){
+ //creation project
+ var proj = this.project[i];
+ var project = new dojox.gantt.GanttProjectControl(this, proj);
+ if(this.arrProjects.length > 0){
+ var previousProject = this.arrProjects[this.arrProjects.length - 1];
+ project.previousProject = previousProject;
+ previousProject.nextProject = project;
+ }
+ project.create();
+ this.checkHeighPanelTasks();
+ this.arrProjects.push(project);
+ this.createTasks(project);
+ }
+ if(this.withResource){
+ this.resource = new dojox.gantt.GanttResourceItem(this);
+ this.resource.create();
+ }
+ this.postLoadData();
+ this.postBindEvents();
+ return this;
+ },
+ postLoadData: function(){
+ dojo.forEach(this.arrProjects, function(project){
+ dojo.forEach(project.arrTasks, function(task){
+ task.postLoadData();
+ }, this);
+ project.postLoadData();
+ }, this);
+ //toolbar cover div
+ var cpos = dojo.coords(this.panelNameHeaders);
+ if(!this.panelNameHeadersCover){
+ this.panelNameHeadersCover = dojo.create("div", {className: "ganttHeaderCover"}, this.panelNameHeaders.parentNode);
+ dojo.style(this.panelNameHeadersCover, {
+ left: cpos.l+"px",
+ top: cpos.t+"px",
+ height: cpos.h+"px",
+ width: cpos.w+"px",
+ display: "none"
+ });
+ }
+ },
+ postBindEvents: function(){
+ //highlight row
+ var pos = dojo.position(this.tableControl, true);
+ !dojo.isIE && this._events.push(
+ dojo.connect(this.tableControl, "onmousemove", this, function(event){
+ var elem = event.srcElement || event.target;
+ if(elem == this.panelNames.firstChild || elem == this.contentData.firstChild){
+ //23: this.heightTaskItem + this.heightTaskItemExtra
+ var rowHeight = this.heightTaskItem + this.heightTaskItemExtra;
+ var hlTop = parseInt(event.layerY / rowHeight) * rowHeight + this.panelTimeHeight - this.contentData.scrollTop;
+ if(hlTop != this.oldHLTop && hlTop < (pos.h - 50)){
+ if(this.highLightDiv){
+ dojo.style(this.highLightDiv, "top", (pos.y + hlTop) + "px");
+ }else{
+ this.highLightDiv = dojo.create("div", {
+ className: "ganttRowHighlight"
+ }, dojo.body());
+ dojo.style(this.highLightDiv, {
+ top: (pos.y + hlTop) + "px",
+ left: pos.x + "px",
+ width: (pos.w - 20) + "px",
+ height: rowHeight + "px"
+ });
+ }
+ }
+ this.oldHLTop = hlTop;
+ }
+ })
+ );
+ //TODO: other event bindings
+ },
+ getStartDate: function(){
+ dojo.forEach(this.project, function(proj){
+ if(this.startDate){
+ if(proj.startDate < this.startDate){
+ this.startDate = new Date(proj.startDate);
+ }
+ }else{
+ this.startDate = new Date(proj.startDate);
+ }
+ }, this);
+ this.initialPos = 24 * this.pixelsPerHour;
+ return this.startDate ? new Date(this.startDate.setHours(this.startDate.getHours() - 24)) : new Date();
+ },
+ getCountDays: function(){
+ return parseInt((this.contentWidth - this.maxWidthPanelNames) / (this.pixelsPerHour * 24));
+ },
+ createTasks: function(project){
+ dojo.forEach(project.project.parentTasks, function(pppTask, i){
+ if(i > 0){
+ project.project.parentTasks[i - 1].nextParentTask = pppTask;
+ pppTask.previousParentTask = project.project.parentTasks[i - 1];
+ }
+ var task = new dojox.gantt.GanttTaskControl(pppTask, project, this);
+ project.arrTasks.push(task);
+ task.create();
+ this.checkHeighPanelTasks();
+ if(pppTask.cldTasks.length > 0){
+ this.createChildItemControls(pppTask.cldTasks, project);
+ }
+ }, this);
+ },
+ createChildItemControls: function(arrChildTasks, project){
+ arrChildTasks && dojo.forEach(arrChildTasks, function(cTask, i){
+ if(i > 0){
+ cTask.previousChildTask = arrChildTasks[i - 1];
+ arrChildTasks[i - 1].nextChildTask = cTask;
+ }
+ var task = new dojox.gantt.GanttTaskControl(cTask, project, this);
+ task.create();
+ this.checkHeighPanelTasks();
+ if(cTask.cldTasks.length > 0){
+ this.createChildItemControls(cTask.cldTasks, project);
+ }
+ }, this);
+ },
+ getPosOnDate: function(startTime){
+ return (startTime - this.startDate) / (60 * 60 * 1000) * this.pixelsPerHour;
+ },
+ getWidthOnDuration: function(duration){
+ return Math.round(this.pixelsPerWorkHour * duration);
+ },
+ getLastChildTask: function(task){
+ return task.childTask.length > 0 ? this.getLastChildTask(task.childTask[task.childTask.length - 1]) : task;
+ },
+ removeCell: function(row){
+ while(row.cells[0]){
+ row.deleteCell(row.cells[0]);
+ }
+ }
+ });
+})();
+
+}
diff --git a/js/dojo-1.6/dojox/gantt/GanttChart.xd.js b/js/dojo-1.6/dojox/gantt/GanttChart.xd.js new file mode 100644 index 0000000..a53f715 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/GanttChart.xd.js @@ -0,0 +1,1285 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.gantt.GanttChart"],
+["require", "dijit.Tooltip"],
+["require", "dojox.gantt.GanttProjectItem"],
+["require", "dojox.gantt.GanttResourceItem"],
+["require", "dojox.gantt.TabMenu"],
+["require", "dojo.date.locale"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.gantt.GanttChart"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.gantt.GanttChart"] = true;
+dojo.provide("dojox.gantt.GanttChart");
+
+dojo.require("dijit.Tooltip");
+dojo.require("dojox.gantt.GanttProjectItem");
+dojo.require("dojox.gantt.GanttResourceItem");
+dojo.require("dojox.gantt.TabMenu");
+dojo.require("dojo.date.locale");
+
+(function(){
+ dojo.declare("dojox.gantt.GanttChart", null, {
+ constructor: function(configuration, node){
+ this.resourceChartHeight = configuration.resourceChartHeight !== undefined ? configuration.resourceChartHeight : false;
+ this.withResource = configuration.withResource !== undefined ? configuration.withResource : true;
+ this.correctError = configuration.autoCorrectError !== undefined ? configuration.autoCorrectError : false;
+ this.isShowConMenu = this.isContentEditable = !configuration.readOnly;
+ this.withTaskId = configuration.withTaskId !== undefined ? configuration.withTaskId : !configuration.readOnly;
+ this.animation = configuration.animation !== undefined ? configuration.animation : true;
+ this.saveProgramPath = configuration.saveProgramPath || "saveGanttData.php";
+ this.dataFilePath = configuration.dataFilePath || "gantt_default.json";
+ this.contentHeight = configuration.height || 400;
+ this.contentWidth = configuration.width || 600;
+ this.content = dojo.byId(node);
+ this.scrollBarWidth = 18;
+ this.panelTimeHeight = 102;
+ this.maxWidthPanelNames = 150;
+ this.maxWidthTaskNames = 150;
+ this.minWorkLength = 8;
+ this.heightTaskItem = 12;
+ this.heightTaskItemExtra = 11;
+ this.pixelsPerDay = 24;//px
+ this.hsPerDay = 8;
+ this.pixelsPerWorkHour = this.pixelsPerDay / this.hsPerDay;//px
+ this.pixelsPerHour = this.pixelsPerDay / 24;//px
+ this.countDays = 0;
+ this.totalDays = 0;
+ this.startDate = null;
+ this.initialPos = 0;
+
+ this.contentDataHeight = 0;
+ this.panelTimeExpandDelta = 20;
+
+ this.divTimeInfo = null;
+ this.panelNames = null;
+ this.panelTime = null;
+ this.contentData = null;
+ this.tabMenu = null;
+
+ this.project = [];
+ this.arrProjects = [];
+
+ this.xmlLoader = null;
+ this.isMoving = false;
+ this.isResizing = false;
+ this.animationNodes = [];
+ this.scale = 1;
+ this.tempDayInPixels = 0;
+ this.resource = null;
+ this.months = dojo.date.locale.getNames("months", "wide");
+ this._events = [];
+ },
+ getProject: function(id){
+ return dojo.filter(this.arrProjects, function(proj){
+ return proj.project.id == id;
+ }, this)[0];
+ },
+ checkPosPreviousTask: function(predTask, task){
+ var widthPred = this.getWidthOnDuration(predTask.duration);
+ var posPred = this.getPosOnDate(predTask.startTime);
+ var posChild = this.getPosOnDate(task.startTime);
+ if((widthPred + posPred) > posChild){
+ return false;
+ }
+ return true;
+ },
+ correctPosPreviousTask: function(predTask, ctask, ctaskObj){
+ var newDate = new Date(predTask.startTime);
+ newDate.setHours(newDate.getHours() + (predTask.duration / this.hsPerDay * 24))
+ if(newDate.getHours() > 0){
+ newDate.setHours(0);
+ newDate.setDate(newDate.getDate() + 1);
+ }
+ ctaskObj ? (ctaskObj.setStartTime(newDate, true)) : (ctask.startTime = newDate);
+ if(ctask.parentTask){
+ if(!this.checkPosParentTask(ctask.parentTask, ctask)){
+ var newDate2 = new Date(ctask.parentTask.startTime);
+ newDate2.setHours(newDate2.getHours() + (ctask.parentTask.duration / this.hsPerDay * 24))
+ ctask.duration = parseInt((parseInt((newDate2 - ctask.startTime) / (1000 * 60 * 60))) * this.hsPerDay / 24);
+ }
+ }
+ },
+ correctPosParentTask: function(parentTask, ctask){
+ if(!ctask.previousTask){
+ if(parentTask.startTime > ctask.startTime){
+ ctask.startTime = new Date(parentTask.startTime);
+ }
+ if(!this.checkPosParentTask(parentTask, ctask)){
+ ctask.duration = parentTask.duration;
+ }
+ }else{
+ this.correctPosPreviousTask(ctask.previousTask, ctask);
+ }
+ },
+ checkPosParentTaskInTree: function(parentTask){
+ var exception = false;
+ for(var i = 0; i < parentTask.cldTasks.length; i++){
+ var pcTask = parentTask.cldTasks[i];
+ if(!this.checkPosParentTask(parentTask, pcTask)){
+ if(!this.correctError){
+ return true;
+ }else{
+ this.correctPosParentTask(parentTask, pcTask);
+ }
+ }
+ if(parentTask.startTime > pcTask.startTime){
+ if(!this.correctError){
+ return true;
+ }else{
+ this.correctPosParentTask(parentTask, pcTask);
+ }
+ }
+ if(pcTask.cldTasks.length > 0){
+ exception = this.checkPosParentTaskInTree(pcTask);
+ }
+ }
+ return exception;
+ },
+ setPreviousTask: function(project){
+ var exception = false;
+ for(var i = 0; i < project.parentTasks.length; i++){
+ var ppTask = project.parentTasks[i];
+ if(ppTask.previousTaskId){
+ ppTask.previousTask = project.getTaskById(ppTask.previousTaskId);
+ if(!ppTask.previousTask){
+ if(!this.correctError){
+ return true;
+ }
+ }
+ ppTask.previousTask.cldPreTasks.push(ppTask);
+ }
+ if(ppTask.previousTask){
+ if(!this.checkPosPreviousTask(ppTask.previousTask, ppTask)){
+ if(!this.correctError){
+ return true;
+ }else{
+ this.correctPosPreviousTask(ppTask.previousTask, ppTask);
+ }
+ }
+ }
+ exception = this.setPreviousTaskInTree(ppTask);
+ }
+ return exception;
+ },
+ setPreviousTaskInTree: function(parentTask){
+ var exception = false;
+ for(var i = 0; i < parentTask.cldTasks.length; i++){
+ var pcTask = parentTask.cldTasks[i];
+ if(pcTask.previousTaskId){
+ pcTask.previousTask = parentTask.project.getTaskById(pcTask.previousTaskId);
+ if(!pcTask.previousTask){
+ if(!this.correctError){
+ return true;
+ }
+ }
+ if(!this.checkPosPreviousTask(pcTask.previousTask, pcTask)){
+ if(!this.correctError){
+ return true;
+ }else{
+ this.correctPosPreviousTask(pcTask.previousTask, pcTask);
+ }
+ }
+ pcTask.previousTask.cldPreTasks.push(pcTask);
+ }
+
+ if(pcTask.cldTasks.length > 0){
+ exception = this.setPreviousTaskInTree(pcTask);
+ }
+ }
+ return exception;
+ },
+ checkPosParentTask: function(parentTask, task){
+ var widthParent = this.getWidthOnDuration(parentTask.duration);
+ var posParent = this.getPosOnDate(parentTask.startTime);
+ var posChild = this.getPosOnDate(task.startTime);
+ var widthChild = this.getWidthOnDuration(task.duration);
+ return (widthParent + posParent) >= (posChild + widthChild);
+ },
+ addProject: function(projectItem){
+ this.project.push(projectItem);
+ },
+ deleteProject: function(id){
+ var project = this.getProject(id);
+ if(project){
+ if(project.arrTasks.length > 0){
+ while(project.arrTasks.length > 0){
+ project.deleteChildTask(project.arrTasks[0]);
+ }
+ }
+ var rowHeight = this.heightTaskItemExtra + this.heightTaskItem;
+ project.nextProject && project.shiftNextProject(project, -rowHeight); //rowHeight: 23
+ this.project = dojo.filter(this.project, function(proj){
+ return proj.id != project.project.id;
+ }, this);
+ if((project.previousProject) && (project.nextProject)){
+ var previousProject = project.previousProject;
+ previousProject.nextProject = project.nextProject;
+ }
+ if((project.previousProject) && !(project.nextProject)){
+ var previousProject = project.previousProject;
+ previousProject.nextProject = null;
+ }
+ if(!(project.previousProject) && (project.nextProject)){
+ var nextProject = project.nextProject;
+ nextProject.previousProject = null;
+ }
+ for(var i = 0; i < this.arrProjects.length; i++){
+ if(this.arrProjects[i].project.id == id){
+ this.arrProjects.splice(i, 1);
+ }
+ }
+ project.projectItem[0].parentNode.removeChild(project.projectItem[0]);
+ project.descrProject.parentNode.removeChild(project.descrProject);
+ project.projectNameItem.parentNode.removeChild(project.projectNameItem);
+ this.contentDataHeight -= this.heightTaskItemExtra + this.heightTaskItem;
+ if(this.project.length == 0){
+ var d = new Date(this.startDate);
+ var t = new Date(d.setDate(d.getDate() + 1));
+ var pi = new dojox.gantt.GanttProjectItem({
+ id: 1,
+ name: "New Project",
+ startDate: t
+ });
+ this.project.push(pi);
+ var project = new dojox.gantt.GanttProjectControl(this, pi);
+ project.create();
+ this.arrProjects.push(project);
+ this.contentDataHeight += this.heightTaskItemExtra + this.heightTaskItem;
+ }
+ this.checkPosition();
+ }
+ },
+ insertProject: function(id, name, startDate){
+ if(this.startDate >= startDate){
+ return false;
+ }
+ if(this.getProject(id)){
+ return false;
+ }
+ this.checkHeighPanelTasks();
+ var project = new dojox.gantt.GanttProjectItem({
+ id: id,
+ name: name,
+ startDate: startDate
+ });
+ this.project.push(project);
+ var _project = new dojox.gantt.GanttProjectControl(this, project);
+ for(var i = 0; i < this.arrProjects.length; i++){
+ var curProject = this.arrProjects[i],
+ preProject = this.arrProjects[i-1],
+ nextProject = this.arrProjects[i+1];
+ if(startDate < curProject.project.startDate){
+ this.arrProjects.splice(i, 0, _project);
+ if(i > 0){
+ _project.previousProject = preProject;
+ preProject.nextProject = _project;
+ }
+ if(i + 1 <= this.arrProjects.length){
+ _project.nextProject = nextProject;
+ nextProject.previousProject = _project;
+ var rowHeight = this.heightTaskItem + this.heightTaskItemExtra;
+ _project.shiftNextProject(_project, rowHeight);
+ }
+ _project.create();
+ _project.hideDescrProject();
+ this.checkPosition();
+ return _project;
+ }
+ }
+ if(this.arrProjects.length > 0){
+ this.arrProjects[this.arrProjects.length - 1].nextProject = _project;
+ _project.previousProject = this.arrProjects[this.arrProjects.length - 1];
+ }
+ this.arrProjects.push(_project);
+ _project.create();
+ _project.hideDescrProject();
+ this.checkPosition();
+ return _project;
+ },
+ openTree: function(parentTask){
+ var lastParentTask = this.getLastCloseParent(parentTask);
+ this.openNode(lastParentTask);
+ parentTask.taskItem.id != lastParentTask.taskItem.id && this.openTree(parentTask);
+ },
+ openNode: function(parentTask){
+ if(!parentTask.isExpanded){
+ dojo.removeClass(parentTask.cTaskNameItem[2], "ganttImageTreeExpand");
+ dojo.addClass(parentTask.cTaskNameItem[2], "ganttImageTreeCollapse");
+ parentTask.isExpanded = true;
+ parentTask.shiftCurrentTasks(parentTask, parentTask.hideTasksHeight);
+ parentTask.showChildTasks(parentTask, parentTask.isExpanded);
+ parentTask.hideTasksHeight = 0;
+ }
+ },
+ getLastCloseParent: function(task){
+ if(task.parentTask){
+ if((!task.parentTask.isExpanded) ||
+ (task.parentTask.cTaskNameItem[2].style.display == "none")){
+ return this.getLastCloseParent(task.parentTask);
+ }else{
+ return task;
+ }
+ }else{
+ return task;
+ }
+ },
+ getProjectItemById: function(id){
+ return dojo.filter(this.project, function(proj){
+ return proj.id == id;
+ }, this)[0];
+ },
+ clearAll: function(){
+ this.contentDataHeight = 0;
+ this.startDate = null;
+ this.clearData();
+ this.clearItems();
+ this.clearEvents();
+ },
+ clearEvents: function(){
+ dojo.forEach(this._events, dojo.disconnect);
+ this._events = [];
+ },
+ clearData: function(){
+ this.project = [];
+ this.arrProjects = [];
+ },
+ clearItems: function(){
+ this.contentData.removeChild(this.contentData.firstChild);
+ this.contentData.appendChild(this.createPanelTasks());
+ this.panelNames.removeChild(this.panelNames.firstChild);
+ this.panelNames.appendChild(this.createPanelNamesTasks());
+ this.panelTime.removeChild(this.panelTime.firstChild);
+ },
+ buildUIContent: function(){
+ this.project.sort(this.sortProjStartDate);
+ this.startDate = this.getStartDate();
+ this.panelTime.appendChild(this.createPanelTime());
+ for(var i = 0; i < this.project.length; i++){
+ var proj = this.project[i];
+ for(var k = 0; k < proj.parentTasks.length; k++){
+ var ppTask = proj.parentTasks[k];
+ if(ppTask.startTime){
+ this.setStartTimeChild(ppTask);
+ }else{
+ return;
+ }
+ if(this.setPreviousTask(proj)){
+ return;
+ }
+ }
+ for(var k = 0; k < proj.parentTasks.length; k++){
+ var ppTask = proj.parentTasks[k];
+ if(ppTask.startTime < proj.startDate){
+ return;
+ }
+ if(this.checkPosParentTaskInTree(ppTask)) return;
+ }
+ this.sortTasksByStartTime(proj);
+ }
+
+ for(var i = 0; i < this.project.length; i++){
+ var proj = this.project[i];
+ var project = new dojox.gantt.GanttProjectControl(this, proj);
+ if(this.arrProjects.length > 0){
+ var previousProject = this.arrProjects[this.arrProjects.length - 1];
+ project.previousProject = previousProject;
+ previousProject.nextProject = project;
+ }
+ project.create();
+ this.checkHeighPanelTasks();
+ this.arrProjects.push(project);
+ this.createTasks(project);
+ }
+ this.resource && this.resource.reConstruct();
+ this.postLoadData();
+ this.postBindEvents();
+ },
+ loadJSONData: function(filename){
+ var _this = this;
+ _this.dataFilePath = filename || _this.dataFilePath;
+ dojo.xhrGet({
+ url: _this.dataFilePath,
+ sync: true,
+ load: function(text, ioArgs){
+ _this.loadJSONString(text);
+ _this.buildUIContent();
+ alert("Successfully! Loaded data from: " + _this.dataFilePath);
+ },
+ error: function(err, ioArgs){
+ alert("Failed! Load error: " + _this.dataFilePath);
+ }
+ });
+ },
+ loadJSONString: function(content){
+ //load data
+ if(!content){ return; }
+ this.clearAll();
+ var jsonObj = dojo.fromJson(content);
+
+ var items = jsonObj.items;
+ dojo.forEach(items, function(pItem){
+ var startDate = pItem.startdate.split("-");
+ var project = new dojox.gantt.GanttProjectItem({
+ id: pItem.id,
+ name: pItem.name,
+ startDate: new Date(startDate[0], (parseInt(startDate[1]) - 1), startDate[2])
+ });
+ var tItems = pItem.tasks;
+ dojo.forEach(tItems, function(tItem){
+ var id = tItem.id,
+ name = tItem.name,
+ starttime = tItem.starttime.split("-");
+ duration = tItem.duration,
+ percentage = tItem.percentage,
+ previousTaskId = tItem.previousTaskId,
+ taskOwner = tItem.taskOwner;
+
+ var task = new dojox.gantt.GanttTaskItem({
+ id: id,
+ name: name,
+ startTime: new Date(starttime[0], (parseInt(starttime[1]) - 1), starttime[2]),
+ duration: duration,
+ percentage: percentage,
+ previousTaskId: previousTaskId,
+ taskOwner: taskOwner
+ });
+ var ctItems = tItem.children;
+ if(ctItems.length != 0){
+ this.buildChildTasksData(task, ctItems);
+ }
+ project.addTask(task);
+ }, this);
+ this.addProject(project);
+ }, this);
+ },
+ buildChildTasksData: function(parentTask, childTaskItems){
+ childTaskItems && dojo.forEach(childTaskItems, function(ctItem){
+ var id = ctItem.id,
+ name = ctItem.name,
+ starttime = ctItem.starttime.split("-"),
+ duration = ctItem.duration,
+ percentage = ctItem.percentage,
+ previousTaskId = ctItem.previousTaskId,
+ taskOwner = ctItem.taskOwner;
+
+ var task = new dojox.gantt.GanttTaskItem({
+ id: id,
+ name: name,
+ startTime: new Date(starttime[0], (parseInt(starttime[1]) - 1), starttime[2]),
+ duration: duration,
+ percentage: percentage,
+ previousTaskId: previousTaskId,
+ taskOwner: taskOwner
+ });
+ task.parentTask = parentTask;
+ parentTask.addChildTask(task);
+
+ var ctItems = ctItem.children;
+ if(ctItems.length != 0){
+ this.buildChildTasksData(task, ctItems);
+ }
+ }, this);
+ },
+ getJSONData: function(){
+ var jsonObj = {identifier: 'id', items: []};
+ dojo.forEach(this.project, function(proj){
+ var project = {
+ id: proj.id,
+ name: proj.name,
+ startdate: proj.startDate.getFullYear() + '-' + (proj.startDate.getMonth() + 1) + '-' + proj.startDate.getDate(),
+ tasks: []
+ };
+ jsonObj.items.push(project);
+ dojo.forEach(proj.parentTasks, function(pTask){
+ var task = {
+ id: pTask.id,
+ name: pTask.name,
+ starttime: pTask.startTime.getFullYear() + '-' + (pTask.startTime.getMonth() + 1) + '-' + pTask.startTime.getDate(),
+ duration: pTask.duration,
+ percentage: pTask.percentage,
+ previousTaskId: (pTask.previousTaskId || ''),
+ taskOwner: (pTask.taskOwner || ''),
+ children: this.getChildTasksData(pTask.cldTasks)
+ };
+ project.tasks.push(task);
+ }, this);
+ }, this);
+ return jsonObj;
+ },
+ getChildTasksData: function(childTasks){
+ var cTaskObj = [];
+ childTasks && childTasks.length > 0 && dojo.forEach(childTasks, function(childTask){
+ var ctask = {
+ id: childTask.id,
+ name: childTask.name,
+ starttime: childTask.startTime.getFullYear() + '-' + (childTask.startTime.getMonth() + 1) + '-' + childTask.startTime.getDate(),
+ duration: childTask.duration,
+ percentage: childTask.percentage,
+ previousTaskId: (childTask.previousTaskId || ''),
+ taskOwner: (childTask.taskOwner || ''),
+ children: this.getChildTasksData(childTask.cldTasks)
+ };
+ cTaskObj.push(ctask);
+ }, this);
+ return cTaskObj;
+ },
+ saveJSONData: function(fileName){
+ var _this = this;
+ _this.dataFilePath = (fileName && dojo.trim(fileName).length > 0) ? fileName : this.dataFilePath;
+ try {
+ var td = dojo.xhrPost({
+ url: _this.saveProgramPath,
+ content: {filename: _this.dataFilePath, data: dojo.toJson(_this.getJSONData())},
+ handle: function(res, ioArgs){
+ if((dojo._isDocumentOk(ioArgs.xhr))||
+ (ioArgs.xhr.status == 405)
+ ){
+ alert("Successfully! Saved data to " + _this.dataFilePath);
+ }else{
+ alert("Failed! Saved error");
+ }
+ }
+ });
+ } catch (e){
+ alert("exception: " + e.message);
+ }
+ },
+ sortTaskStartTime: function(a, b){
+ return a.startTime < b.startTime ? -1 : (a.startTime > b.startTime ? 1 : 0);
+ },
+ sortProjStartDate: function(a, b){
+ return a.startDate < b.startDate ? -1 : (a.startDate > b.startDate ? 1 : 0);
+ },
+ setStartTimeChild: function(parentTask){
+ dojo.forEach(parentTask.cldTasks, function(pcTask){
+ if(!pcTask.startTime){
+ pcTask.startTime = parentTask.startTime;
+ }
+ if(pcTask.cldTasks.length != 0){
+ this.setStartTimeChild(pcTask);
+ }
+ }, this);
+ },
+ createPanelTasks: function(){
+ var panelTask = dojo.create("div", {
+ className: "ganttTaskPanel"
+ });
+ dojo.style(panelTask, {
+ height: (this.contentHeight - this.panelTimeHeight - this.scrollBarWidth) + "px"
+ });
+ return panelTask;
+ },
+ refreshParams: function(pixelsPerDay){
+ this.pixelsPerDay = pixelsPerDay;
+ this.pixelsPerWorkHour = this.pixelsPerDay / this.hsPerDay;
+ this.pixelsPerHour = this.pixelsPerDay / 24;
+ },
+ createPanelNamesTasksHeader: function(){
+ var _this = this;
+ var panelHeader = dojo.create("div", {className: "ganttPanelHeader"});
+ var tblHeader = dojo.create("table", {
+ cellPadding: "0px",
+ border: "0px",
+ cellSpacing: "0px",
+ bgColor: "#FFFFFF",
+ className: "ganttToolbar"
+ }, panelHeader);
+ var firstRow = tblHeader.insertRow(tblHeader.rows.length);
+ var secondRow = tblHeader.insertRow(tblHeader.rows.length);
+ var thirdRow = tblHeader.insertRow(tblHeader.rows.length);
+ var forthRow = tblHeader.insertRow(tblHeader.rows.length);
+ var zoomIn = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttToolbarZoomIn"
+ }, firstRow);
+ var zoomInFn = dojo.hitch(this, function(){
+ if(this.scale * 2 > 5){return;}
+ this.scale = this.scale * 2;
+ this.switchTeleMicroView(this.pixelsPerDay * this.scale);
+ });
+ dojo.disconnect(this.zoomInClickEvent);
+ this.zoomInClickEvent = dojo.connect(zoomIn, "onclick", this, zoomInFn);
+ //a11y support
+ dojo.disconnect(this.zoomInKeyEvent);
+ this.zoomInKeyEvent = dojo.connect(zoomIn, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ zoomInFn();
+ });
+ dojo.attr(zoomIn, "tabIndex", 0);
+ var zoomOut = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttToolbarZoomOut"
+ }, firstRow);
+ var zoomOutFn = dojo.hitch(this, function(){
+ if(this.scale * 0.5 < 0.2){return;}
+ this.scale = this.scale * 0.5;
+ this.switchTeleMicroView(this.pixelsPerDay * this.scale);
+ });
+ dojo.disconnect(this.zoomOutClickEvent);
+ this.zoomOutClickEvent = dojo.connect(zoomOut, "onclick", this, zoomOutFn);
+ //a11y support
+ dojo.disconnect(this.zoomOutKeyEvent);
+ this.zoomOutKeyEvent = dojo.connect(zoomOut, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ zoomOutFn();
+ });
+ dojo.attr(zoomOut, "tabIndex", 0);
+ var micro = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttToolbarMicro"
+ }, secondRow);
+ dojo.disconnect(this.microClickEvent);
+ this.microClickEvent = dojo.connect(micro, "onclick", this, dojo.hitch(this, this.refresh, this.animation?15:1, 0, 2));
+ //a11y support
+ dojo.disconnect(this.microKeyEvent);
+ this.microKeyEvent = dojo.connect(micro, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ micro.blur();
+ this.refresh(this.animation?15:1, 0, 2);
+ });
+ dojo.attr(micro, "tabIndex", 0);
+ var tele = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttToolbarTele"
+ }, secondRow);
+ dojo.disconnect(this.teleClickEvent);
+ this.teleClickEvent = dojo.connect(tele, "onclick", this, dojo.hitch(this, this.refresh, this.animation?15:1, 0, 0.5));
+ //a11y support
+ dojo.disconnect(this.teleKeyEvent);
+ this.teleKeyEvent = dojo.connect(tele, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ tele.blur();
+ this.refresh(this.animation?15:1, 0, 0.5);
+ });
+ dojo.attr(tele, "tabIndex", 0);
+ var save = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttToolbarSave"
+ }, thirdRow);
+ dojo.disconnect(this.saveClickEvent);
+ this.saveClickEvent = dojo.connect(save, "onclick", this, dojo.hitch(this, this.saveJSONData, ""));
+ //a11y support
+ dojo.disconnect(this.saveKeyEvent);
+ this.saveKeyEvent = dojo.connect(save, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ this.saveJSONData("");
+ });
+ dojo.attr(save, "tabIndex", 0);
+ var load = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttToolbarLoad"
+ }, thirdRow);
+ dojo.disconnect(this.loadClickEvent);
+ this.loadClickEvent = dojo.connect(load, "onclick", this, dojo.hitch(this, this.loadJSONData, ""));
+ //a11y support
+ dojo.disconnect(this.loadKeyEvent);
+ this.loadKeyEvent = dojo.connect(load, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ this.loadJSONData("");
+ });
+ dojo.attr(load, "tabIndex", 0);
+ //action popup description
+ var actions = [zoomIn, zoomOut, micro, tele, save, load],
+ titles = ["Enlarge timeline", "Shrink timeline", "Zoom in time zone(microscope view)", "Zoom out time zone(telescope view)",
+ "Save gantt data to json file", "Load gantt data from json file"];
+ dojo.forEach(actions, function(action, i){
+ var title = titles[i];
+ var tooltipShow = function(){
+ dojo.addClass(action, "ganttToolbarActionHover");
+ dijit.showTooltip(title, action, ["above", "below"]);
+ };
+ action.onmouseover = tooltipShow;
+ //a11y support
+ action.onfocus = tooltipShow;
+ var tooltipHide = function(){
+ dojo.removeClass(action, "ganttToolbarActionHover");
+ action && dijit.hideTooltip(action);
+ };
+ action.onmouseout = tooltipHide;
+ action.onblur = tooltipHide;
+ }, this);
+ return panelHeader;
+ },
+ createPanelNamesTasks: function(){
+ var panelNameTask = dojo.create("div", {
+ innerHTML: " ",
+ className: "ganttPanelNames"
+ });
+ dojo.style(panelNameTask, {
+ height: (this.contentHeight - this.panelTimeHeight - this.scrollBarWidth) + "px",
+ width: this.maxWidthPanelNames + "px"
+ });
+ return panelNameTask;
+ },
+ createPanelTime: function(){
+ var panelTime = dojo.create("div", {className: "ganttPanelTime"});
+ var tblTime = dojo.create("table", {
+ cellPadding: "0px",
+ border: "0px",
+ cellSpacing: "0px",
+ bgColor: "#FFFFFF",
+ className: "ganttTblTime"
+ }, panelTime);
+ this.totalDays = this.countDays;
+ //year
+ var newYearRow = tblTime.insertRow(tblTime.rows.length), newYear = oldYear = new Date(this.startDate).getFullYear(), ycount = 0;
+ for(var i = 0; i < this.countDays; i++, ycount++){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + i);
+ newYear = date.getFullYear();
+ if(newYear != oldYear){
+ this.addYearInPanelTime(newYearRow, ycount, oldYear);
+ ycount = 0;
+ oldYear = newYear;
+ }
+ }
+ this.addYearInPanelTime(newYearRow, ycount, newYear);
+ dojo.style(newYearRow, "display", "none");
+ //month
+ var newMonthRow = tblTime.insertRow(tblTime.rows.length), newMonth = oldMonth = new Date(this.startDate).getMonth(), mcount = 0, lastYear = 1970;
+ for(var i = 0; i < this.countDays; i++, mcount++){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + i);
+ newMonth = date.getMonth();
+ lastYear = date.getFullYear();
+ if(newMonth != oldMonth){
+ this.addMonthInPanelTime(newMonthRow, mcount, oldMonth, lastYear);
+ mcount = 0;
+ oldMonth = newMonth;
+ }
+ }
+ this.addMonthInPanelTime(newMonthRow, mcount, newMonth, lastYear);
+ //week
+ var newWeekRow = tblTime.insertRow(tblTime.rows.length), newWeek = oldWeek = dojo.date.locale._getWeekOfYear(new Date(this.startDate)), mcount = 0;
+ for(var i = 0; i < this.countDays; i++, mcount++){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + i);
+ newWeek = dojo.date.locale._getWeekOfYear(date);
+ if(newWeek != oldWeek){
+ this.addWeekInPanelTime(newWeekRow, mcount, oldWeek);
+ mcount = 0;
+ oldWeek = newWeek;
+ }
+ }
+ this.addWeekInPanelTime(newWeekRow, mcount, newWeek);
+ //day
+ var newDayRow = tblTime.insertRow(tblTime.rows.length);
+ for(var i = 0; i < this.countDays; i++){
+ this.addDayInPanelTime(newDayRow);
+ }
+ //hour
+ var newHourRow = tblTime.insertRow(tblTime.rows.length);
+ for(var i = 0; i < this.countDays; i++){
+ this.addHourInPanelTime(newHourRow);
+ }
+ dojo.style(newHourRow, "display", "none");
+ return panelTime;
+ },
+ adjustPanelTime: function(width){
+ var maxEndPos = dojo.map(this.arrProjects, function(project){
+ return (parseInt(project.projectItem[0].style.left) + parseInt(project.projectItem[0].firstChild.style.width)
+ + project.descrProject.offsetWidth + this.panelTimeExpandDelta);
+ }, this).sort(function(a,b){return b-a})[0];
+ if(this.maxTaskEndPos != maxEndPos){
+ //reset panel time
+ var prows = this.panelTime.firstChild.firstChild.rows;
+ for(var i = 0; i <= 4; i++){//prows.length
+ this.removeCell(prows[i]);
+ };
+ var countDays = Math.round((maxEndPos+this.panelTimeExpandDelta) / this.pixelsPerDay);
+ this.totalDays = countDays;
+ //year
+ var newYear = oldYear = new Date(this.startDate).getFullYear(), ycount = 0;
+ for(var i = 0; i < countDays; i++, ycount++){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + i);
+ newYear = date.getFullYear();
+ if(newYear != oldYear){
+ this.addYearInPanelTime(prows[0], ycount, oldYear);
+ ycount = 0;
+ oldYear = newYear;
+ }
+ }
+ this.addYearInPanelTime(prows[0], ycount, newYear);
+ //month
+ var newMonth = oldMonth = new Date(this.startDate).getMonth(), mcount = 0, lastYear = 1970;
+ for(var i = 0; i < countDays; i++, mcount++){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + i);
+ newMonth = date.getMonth();
+ lastYear = date.getFullYear();
+ if(newMonth != oldMonth){
+ this.addMonthInPanelTime(prows[1], mcount, oldMonth, lastYear);
+ mcount = 0;
+ oldMonth = newMonth;
+ }
+ }
+ this.addMonthInPanelTime(prows[1], mcount, newMonth, lastYear);
+ //week
+ var newWeek = oldWeek = dojo.date.locale._getWeekOfYear(new Date(this.startDate)), mcount = 0;
+ for(var i = 0; i < countDays; i++, mcount++){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + i);
+ newWeek = dojo.date.locale._getWeekOfYear(date);
+ if(newWeek != oldWeek){
+ this.addWeekInPanelTime(prows[2], mcount, oldWeek);
+ mcount = 0;
+ oldWeek = newWeek;
+ }
+ }
+ this.addWeekInPanelTime(prows[2], mcount, newWeek);
+ //day
+ for(var i = 0; i < countDays; i++){
+ this.addDayInPanelTime(prows[3]);
+ }
+ //hour
+ for(var i = 0; i < countDays; i++){
+ this.addHourInPanelTime(prows[4]);
+ }
+ this.panelTime.firstChild.firstChild.style.width = this.pixelsPerDay * (prows[3].cells.length) + "px";
+ this.contentData.firstChild.style.width = this.pixelsPerDay * (prows[3].cells.length) + "px";
+ this.maxTaskEndPos = maxEndPos;
+ }
+ },
+ addYearInPanelTime: function(row, count, year){
+ var data = "Year " + year;
+ var newCell = dojo.create("td", {
+ colSpan: count,
+ align: "center",
+ vAlign: "middle",
+ className: "ganttYearNumber",
+ innerHTML: this.pixelsPerDay * count > 20 ? data : "",
+ innerHTMLData: data
+ }, row);
+ dojo.style(newCell, "width", (this.pixelsPerDay * count) + "px");
+ },
+ addMonthInPanelTime: function(row, count, month, year){
+ var data = this.months[month] + (year ? " of " + year : "");
+ var newCell = dojo.create("td", {
+ colSpan: count,
+ align: "center",
+ vAlign: "middle",
+ className: "ganttMonthNumber",
+ innerHTML: this.pixelsPerDay * count > 30 ? data : "",
+ innerHTMLData: data
+ }, row);
+ dojo.style(newCell, "width", (this.pixelsPerDay * count) + "px");
+ },
+ addWeekInPanelTime: function(row, count, week){
+ var data = "Week " + week;
+ var newCell = dojo.create("td", {
+ colSpan: count,
+ align: "center",
+ vAlign: "middle",
+ className: "ganttWeekNumber",
+ innerHTML: this.pixelsPerDay * count > 20 ? data : "",
+ innerHTMLData: data
+ }, row);
+ dojo.style(newCell, "width", (this.pixelsPerDay * count) + "px");
+ },
+ addDayInPanelTime: function(row){
+ var date = new Date(this.startDate);
+ date.setDate(date.getDate() + parseInt(row.cells.length));
+ var newCell = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttDayNumber",
+ innerHTML: this.pixelsPerDay > 20 ? date.getDate() : "",
+ innerHTMLData: String(date.getDate()),
+ data: row.cells.length
+ }, row);
+ dojo.style(newCell, "width", this.pixelsPerDay + "px");
+ (date.getDay() >= 5) && dojo.addClass(newCell, "ganttDayNumberWeekend");
+ this._events.push(
+ dojo.connect(newCell, "onmouseover", this, function(event){
+ var dayTime = event.target || event.srcElement;
+ var date = new Date(this.startDate.getTime());
+ date.setDate(date.getDate() + parseInt(dojo.attr(dayTime, "data")));
+ dijit.showTooltip(date.getFullYear() + "." + (date.getMonth() + 1) + "." + date.getDate(), newCell, ["above", "below"]);
+ })
+ );
+ this._events.push(
+ dojo.connect(newCell, "onmouseout", this, function(event){
+ var dayTime = event.target || event.srcElement;
+ dayTime && dijit.hideTooltip(dayTime);
+ })
+ );
+ },
+ addHourInPanelTime: function(row){
+ var newCell = dojo.create("td", {
+ align: "center",
+ vAlign: "middle",
+ className: "ganttHourNumber",
+ data: row.cells.length
+ }, row);
+ dojo.style(newCell, "width", this.pixelsPerDay + "px");
+
+ var hourTable = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0"
+ }, newCell);
+ var newRow = hourTable.insertRow(hourTable.rows.length);
+ for(var i = 0; i < this.hsPerDay; i++){
+ var hourTD = dojo.create("td", {
+ className: "ganttHourClass"
+ }, newRow);
+ dojo.style(hourTD, "width", (this.pixelsPerDay / this.hsPerDay) + "px");
+ dojo.attr(hourTD, "innerHTMLData", String(9 + i));
+ if(this.pixelsPerDay / this.hsPerDay > 5){
+ dojo.attr(hourTD, "innerHTML", String(9 + i));
+ }
+ dojo.addClass(hourTD, i <= 3?"ganttHourNumberAM":"ganttHourNumberPM");
+ }
+ },
+ incHeightPanelTasks: function(height){
+ var containerTasks = this.contentData.firstChild;
+ containerTasks.style.height = parseInt(containerTasks.style.height) + height + "px";
+ },
+ incHeightPanelNames: function(height){
+ var containerNames = this.panelNames.firstChild;
+ containerNames.style.height = parseInt(containerNames.style.height) + height + "px";
+ },
+ checkPosition: function(){
+ dojo.forEach(this.arrProjects, function(project){
+ dojo.forEach(project.arrTasks, function(task){
+ task.checkPosition();
+ }, this);
+ }, this);
+ },
+ checkHeighPanelTasks: function(){
+ this.contentDataHeight += this.heightTaskItemExtra + this.heightTaskItem;
+ if((parseInt(this.contentData.firstChild.style.height) <= this.contentDataHeight)){
+ this.incHeightPanelTasks(this.heightTaskItem + this.heightTaskItemExtra);
+ this.incHeightPanelNames(this.heightTaskItem + this.heightTaskItemExtra);
+ }
+ },
+ sortTasksByStartTime: function(project){
+ project.parentTasks.sort(this.sortTaskStartTime);
+ for(var i = 0; i < project.parentTasks.length; i++){
+ project.parentTasks[i] = this.sortChildTasks(project.parentTasks[i]);
+ }
+ },
+ sortChildTasks: function(parenttask){
+ parenttask.cldTasks.sort(this.sortTaskStartTime);
+ for(var i = 0; i < parenttask.cldTasks.length; i++){
+ if(parenttask.cldTasks[i].cldTasks.length > 0) this.sortChildTasks(parenttask.cldTasks[i]);
+ }
+ return parenttask;
+ },
+ refresh: function(count, current, multi){
+ //return if no task items
+ if(this.arrProjects.length <= 0){return;}
+ if(this.arrProjects[0].arrTasks.length <= 0){return;}
+ //Show panel of names
+ if(!count || current > count){
+ this.refreshController();
+ if(this.resource){
+ this.resource.refresh();
+ }
+ this.tempDayInPixels = 0;
+ this.panelNameHeadersCover && dojo.style(this.panelNameHeadersCover, "display", "none");
+ return;
+ }
+ if(this.tempDayInPixels == 0){
+ this.tempDayInPixels = this.pixelsPerDay;
+ }
+ this.panelNameHeadersCover && dojo.style(this.panelNameHeadersCover, "display", "");
+ var dip = this.tempDayInPixels + this.tempDayInPixels * (multi - 1) * Math.pow((current / count), 2);
+ this.refreshParams(dip);
+ dojo.forEach(this.arrProjects, function(project){
+ dojo.forEach(project.arrTasks, function(task){
+ task.refresh();
+ }, this);
+ project.refresh();
+ }, this);
+ setTimeout(dojo.hitch(this, function(){
+ this.refresh(count, ++current, multi);
+ }), 15);
+ },
+ switchTeleMicroView: function(dip){
+ var plChild = this.panelTime.firstChild.firstChild;
+ for(var i = 0; i < 5; i++){//0:Y 1:M 2:W 3:D 4:H
+ if(dip > 40){
+ dojo.style(plChild.rows[i], "display", (i==0||i==1)?"none":"");
+ }else if(dip < 20){
+ dojo.style(plChild.rows[i], "display", (i==2||i==4)?"none":"");
+ }else{
+ dojo.style(plChild.rows[i], "display", (i==0||i==4)?"none":"");
+ }
+ }
+ },
+ refreshController: function(){
+ this.contentData.firstChild.style.width = Math.max(1200, this.pixelsPerDay * this.totalDays) + "px";
+ this.panelTime.firstChild.style.width = this.pixelsPerDay * this.totalDays + "px";
+ this.panelTime.firstChild.firstChild.style.width = this.pixelsPerDay * this.totalDays + "px";
+ this.switchTeleMicroView(this.pixelsPerDay);
+ dojo.forEach(this.panelTime.firstChild.firstChild.rows, function(row){
+ dojo.forEach(row.childNodes, function(td){
+ var cs = parseInt(dojo.attr(td, "colSpan") || 1);
+ var idata = dojo.trim(dojo.attr(td, "innerHTMLData")||"");
+ if(idata.length > 0){
+ dojo.attr(td, "innerHTML", this.pixelsPerDay * cs < 20 ? "" : idata);
+ }else{
+ dojo.forEach(td.firstChild.rows[0].childNodes, function(td){
+ var sdata = dojo.trim(dojo.attr(td, "innerHTMLData")||"");
+ dojo.attr(td, "innerHTML", this.pixelsPerDay / this.hsPerDay > 10 ? sdata : "");
+ }, this);
+ }
+ if(cs == 1){
+ dojo.style(td, "width", (this.pixelsPerDay*cs) + "px");
+ if(idata.length <= 0){
+ dojo.forEach(td.firstChild.rows[0].childNodes, function(td){
+ dojo.style(td, "width", (this.pixelsPerDay*cs / this.hsPerDay) + "px");
+ }, this);
+ }
+ }
+ }, this);
+ }, this);
+ },
+ init: function(){
+ this.startDate = this.getStartDate();
+ dojo.style(this.content, {
+ width: this.contentWidth + "px",
+ height: this.contentHeight + "px"
+ });
+ //create Table
+ this.tableControl = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0",
+ className: "ganttTabelControl"
+ });
+ var newRowTblControl = this.tableControl.insertRow(this.tableControl.rows.length);
+ //Add to content Table
+ this.content.appendChild(this.tableControl);
+ this.countDays = this.getCountDays();
+ //Creation panel of time
+ this.panelTime = dojo.create("div", {className: "ganttPanelTimeContainer"});
+ dojo.style(this.panelTime, "height", this.panelTimeHeight + "px");
+ this.panelTime.appendChild(this.createPanelTime());
+ //Creation panel contentData
+ this.contentData = dojo.create("div", {className: "ganttContentDataContainer"});
+ dojo.style(this.contentData, "height", (this.contentHeight - this.panelTimeHeight) + "px");
+ this.contentData.appendChild(this.createPanelTasks());
+ //Creation panel of names
+ var newCellTblControl = dojo.create("td", {
+ vAlign: "top"
+ });
+ //Creation panel of task header
+ this.panelNameHeaders = dojo.create("div", {className: "ganttPanelNameHeaders"}, newCellTblControl);
+ dojo.style(this.panelNameHeaders, {
+ height: this.panelTimeHeight + "px",
+ width: this.maxWidthPanelNames + "px"
+ });
+ this.panelNameHeaders.appendChild(this.createPanelNamesTasksHeader());
+ this.panelNames = dojo.create("div", {className: "ganttPanelNamesContainer"}, newCellTblControl);
+ this.panelNames.appendChild(this.createPanelNamesTasks());
+ newRowTblControl.appendChild(newCellTblControl);
+ //add to control contentData and dataTime
+ newCellTblControl = dojo.create("td", {
+ vAlign: "top"
+ });
+ var divCell = dojo.create("div", {className: "ganttDivCell"});
+ divCell.appendChild(this.panelTime);
+ divCell.appendChild(this.contentData);
+ newCellTblControl.appendChild(divCell);
+ newRowTblControl.appendChild(newCellTblControl);
+ //Show panel of names
+ dojo.style(this.panelNames, "height", (this.contentHeight - this.panelTimeHeight - this.scrollBarWidth) + "px");
+ dojo.style(this.panelNames, "width", this.maxWidthPanelNames + "px");
+ dojo.style(this.contentData, "width", (this.contentWidth - this.maxWidthPanelNames) + "px");
+ dojo.style(this.contentData.firstChild, "width", this.pixelsPerDay * this.countDays + "px");
+ dojo.style(this.panelTime, "width", (this.contentWidth - this.maxWidthPanelNames - this.scrollBarWidth) + "px");
+ dojo.style(this.panelTime.firstChild, "width", this.pixelsPerDay * this.countDays + "px");
+ if(this.isShowConMenu){
+ this.tabMenu = new dojox.gantt.TabMenu(this);
+ }
+ var _this = this;
+ this.contentData.onscroll = function(){
+ _this.panelTime.scrollLeft = this.scrollLeft;
+ if(_this.panelNames){
+ _this.panelNames.scrollTop = this.scrollTop;
+ if(_this.isShowConMenu){
+ _this.tabMenu.hide();
+ }
+ }
+ if(_this.resource){
+ _this.resource.contentData.scrollLeft = this.scrollLeft;
+ }
+ }
+ this.project.sort(this.sortProjStartDate);
+ for(var i = 0; i < this.project.length; i++){
+ var proj = this.project[i];
+ for(var k = 0; k < proj.parentTasks.length; k++){
+ var ppTask = proj.parentTasks[k];
+ if(!ppTask.startTime){
+ ppTask.startTime = proj.startDate;
+ }
+ this.setStartTimeChild(ppTask);
+ if(this.setPreviousTask(proj)){
+ return;
+ }
+ }
+ for(var k = 0; k < proj.parentTasks.length; k++){
+ var ppTask = proj.parentTasks[k];
+ if(ppTask.startTime < proj.startDate){
+ if(!this.correctError){
+ return;
+ }else{
+ ppTask.startTime = proj.startDate;
+ }
+ }
+ if(this.checkPosParentTaskInTree(ppTask)){
+ return;
+ }
+ }
+ this.sortTasksByStartTime(proj);
+ }
+ for(var i = 0; i < this.project.length; i++){
+ //creation project
+ var proj = this.project[i];
+ var project = new dojox.gantt.GanttProjectControl(this, proj);
+ if(this.arrProjects.length > 0){
+ var previousProject = this.arrProjects[this.arrProjects.length - 1];
+ project.previousProject = previousProject;
+ previousProject.nextProject = project;
+ }
+ project.create();
+ this.checkHeighPanelTasks();
+ this.arrProjects.push(project);
+ this.createTasks(project);
+ }
+ if(this.withResource){
+ this.resource = new dojox.gantt.GanttResourceItem(this);
+ this.resource.create();
+ }
+ this.postLoadData();
+ this.postBindEvents();
+ return this;
+ },
+ postLoadData: function(){
+ dojo.forEach(this.arrProjects, function(project){
+ dojo.forEach(project.arrTasks, function(task){
+ task.postLoadData();
+ }, this);
+ project.postLoadData();
+ }, this);
+ //toolbar cover div
+ var cpos = dojo.coords(this.panelNameHeaders);
+ if(!this.panelNameHeadersCover){
+ this.panelNameHeadersCover = dojo.create("div", {className: "ganttHeaderCover"}, this.panelNameHeaders.parentNode);
+ dojo.style(this.panelNameHeadersCover, {
+ left: cpos.l+"px",
+ top: cpos.t+"px",
+ height: cpos.h+"px",
+ width: cpos.w+"px",
+ display: "none"
+ });
+ }
+ },
+ postBindEvents: function(){
+ //highlight row
+ var pos = dojo.position(this.tableControl, true);
+ !dojo.isIE && this._events.push(
+ dojo.connect(this.tableControl, "onmousemove", this, function(event){
+ var elem = event.srcElement || event.target;
+ if(elem == this.panelNames.firstChild || elem == this.contentData.firstChild){
+ //23: this.heightTaskItem + this.heightTaskItemExtra
+ var rowHeight = this.heightTaskItem + this.heightTaskItemExtra;
+ var hlTop = parseInt(event.layerY / rowHeight) * rowHeight + this.panelTimeHeight - this.contentData.scrollTop;
+ if(hlTop != this.oldHLTop && hlTop < (pos.h - 50)){
+ if(this.highLightDiv){
+ dojo.style(this.highLightDiv, "top", (pos.y + hlTop) + "px");
+ }else{
+ this.highLightDiv = dojo.create("div", {
+ className: "ganttRowHighlight"
+ }, dojo.body());
+ dojo.style(this.highLightDiv, {
+ top: (pos.y + hlTop) + "px",
+ left: pos.x + "px",
+ width: (pos.w - 20) + "px",
+ height: rowHeight + "px"
+ });
+ }
+ }
+ this.oldHLTop = hlTop;
+ }
+ })
+ );
+ //TODO: other event bindings
+ },
+ getStartDate: function(){
+ dojo.forEach(this.project, function(proj){
+ if(this.startDate){
+ if(proj.startDate < this.startDate){
+ this.startDate = new Date(proj.startDate);
+ }
+ }else{
+ this.startDate = new Date(proj.startDate);
+ }
+ }, this);
+ this.initialPos = 24 * this.pixelsPerHour;
+ return this.startDate ? new Date(this.startDate.setHours(this.startDate.getHours() - 24)) : new Date();
+ },
+ getCountDays: function(){
+ return parseInt((this.contentWidth - this.maxWidthPanelNames) / (this.pixelsPerHour * 24));
+ },
+ createTasks: function(project){
+ dojo.forEach(project.project.parentTasks, function(pppTask, i){
+ if(i > 0){
+ project.project.parentTasks[i - 1].nextParentTask = pppTask;
+ pppTask.previousParentTask = project.project.parentTasks[i - 1];
+ }
+ var task = new dojox.gantt.GanttTaskControl(pppTask, project, this);
+ project.arrTasks.push(task);
+ task.create();
+ this.checkHeighPanelTasks();
+ if(pppTask.cldTasks.length > 0){
+ this.createChildItemControls(pppTask.cldTasks, project);
+ }
+ }, this);
+ },
+ createChildItemControls: function(arrChildTasks, project){
+ arrChildTasks && dojo.forEach(arrChildTasks, function(cTask, i){
+ if(i > 0){
+ cTask.previousChildTask = arrChildTasks[i - 1];
+ arrChildTasks[i - 1].nextChildTask = cTask;
+ }
+ var task = new dojox.gantt.GanttTaskControl(cTask, project, this);
+ task.create();
+ this.checkHeighPanelTasks();
+ if(cTask.cldTasks.length > 0){
+ this.createChildItemControls(cTask.cldTasks, project);
+ }
+ }, this);
+ },
+ getPosOnDate: function(startTime){
+ return (startTime - this.startDate) / (60 * 60 * 1000) * this.pixelsPerHour;
+ },
+ getWidthOnDuration: function(duration){
+ return Math.round(this.pixelsPerWorkHour * duration);
+ },
+ getLastChildTask: function(task){
+ return task.childTask.length > 0 ? this.getLastChildTask(task.childTask[task.childTask.length - 1]) : task;
+ },
+ removeCell: function(row){
+ while(row.cells[0]){
+ row.deleteCell(row.cells[0]);
+ }
+ }
+ });
+})();
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/gantt/GanttProjectItem.js b/js/dojo-1.6/dojox/gantt/GanttProjectItem.js new file mode 100644 index 0000000..7c1a5d3 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/GanttProjectItem.js @@ -0,0 +1,978 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.gantt.GanttProjectItem"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.gantt.GanttProjectItem"] = true;
+dojo.provide("dojox.gantt.GanttProjectItem");
+
+dojo.require("dojox.gantt.GanttTaskItem");
+dojo.require("dojo.date.locale");
+
+dojo.declare("dojox.gantt.GanttProjectControl", null, {
+ constructor: function(ganttChart, projectItem){
+ this.project = projectItem;
+ this.ganttChart = ganttChart;
+ this.descrProject = null;
+ this.projectItem = null;
+ this.projectNameItem = null;
+ this.posY = 0;
+ this.posX = 0;
+ this.nextProject = null;
+ this.previousProject = null;
+ this.arrTasks = [];
+ this.percentage = 0;
+ this.duration = 0;
+ },
+ checkWidthProjectNameItem: function(){
+ if(this.projectNameItem.offsetWidth + this.projectNameItem.offsetLeft > this.ganttChart.maxWidthTaskNames){
+ var width = this.projectNameItem.offsetWidth + this.projectNameItem.offsetLeft - this.ganttChart.maxWidthTaskNames;
+ var countChar = Math.round(width / (this.projectNameItem.offsetWidth / this.projectNameItem.firstChild.length));
+ var pName = this.project.name.substring(0, this.projectNameItem.firstChild.length - countChar - 3);
+ pName += "...";
+ this.projectNameItem.innerHTML = pName;
+ }
+ },
+ refreshProjectItem: function(projectItem){
+ this.percentage = this.getPercentCompleted();
+ dojo.style(projectItem, {
+ "left": this.posX + "px",
+ "width": this.duration * this.ganttChart.pixelsPerWorkHour + "px"
+ });
+ var tblProjectItem = projectItem.firstChild;
+ var width = this.duration * this.ganttChart.pixelsPerWorkHour;
+ tblProjectItem.width = ((width == 0) ? 1 : width) + "px";
+ tblProjectItem.style.width = ((width == 0) ? 1 : width) + "px";
+ var rowprojectItem = tblProjectItem.rows[0];
+ if(this.percentage != -1){
+ if(this.percentage != 0){
+ var cellprojectItem = rowprojectItem.firstChild;
+ cellprojectItem.width = this.percentage + "%";
+ var imageProgress = cellprojectItem.firstChild;
+ dojo.style(imageProgress, {
+ width: (!this.duration ? 1 : (this.percentage * this.duration * this.ganttChart.pixelsPerWorkHour / 100)) + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ })
+ }
+ if(this.percentage != 100){
+ var cellprojectItem = rowprojectItem.lastChild;
+ cellprojectItem.width = (100 - this.percentage) + "%";
+ var imageProgress = cellprojectItem.firstChild;
+ dojo.style(imageProgress, {
+ width: (!this.duration ? 1 : ((100 - this.percentage) * this.duration * this.ganttChart.pixelsPerWorkHour / 100)) + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ })
+ }
+ }else{
+ var cellprojectItem = rowprojectItem.firstChild;
+ cellprojectItem.width = "1px";
+ var imageProgress = cellprojectItem.firstChild;
+ dojo.style(imageProgress, {
+ width: "1px",
+ height: this.ganttChart.heightTaskItem + "px"
+ })
+ }
+ var divTaskInfo = projectItem.lastChild;
+ var tblTaskInfo = divTaskInfo.firstChild;
+ dojo.style(tblTaskInfo, {
+ height: this.ganttChart.heightTaskItem + "px",
+ width: (!this.duration ? 1 : (this.duration * this.ganttChart.pixelsPerWorkHour)) + "px"
+ });
+ var rowTaskInfo = tblTaskInfo.rows[0];
+ var cellTaskInfo = rowTaskInfo.firstChild;
+ cellTaskInfo.height = this.ganttChart.heightTaskItem + "px";
+ if(this.project.parentTasks.length == 0){
+ projectItem.style.display = "none";
+ }
+ return projectItem;
+ },
+ refreshDescrProject: function(divDesc){
+ var posX = (this.posX + this.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ dojo.style(divDesc, {
+ "left": posX + "px"
+ });
+ if(this.project.parentTasks.length == 0){
+ this.descrProject.style.visibility = 'hidden';
+ }
+ return divDesc;
+ },
+ postLoadData: function(){
+ //TODO e.g. project relative info...
+ },
+ refresh: function(){
+ var containerTasks = this.ganttChart.contentData.firstChild;
+ this.posX = (this.project.startDate - this.ganttChart.startDate) / (60 * 60 * 1000) * this.ganttChart.pixelsPerHour;
+ this.refreshProjectItem(this.projectItem[0]);
+ this.refreshDescrProject(this.projectItem[0].nextSibling);
+ return this;
+ },
+ create: function(){
+ var containerTasks = this.ganttChart.contentData.firstChild;
+ this.posX = (this.project.startDate - this.ganttChart.startDate) / (60 * 60 * 1000) * this.ganttChart.pixelsPerHour;
+ if(this.previousProject){
+ if(this.previousProject.arrTasks.length > 0){
+ var lastChildTask = this.ganttChart.getLastChildTask(this.previousProject.arrTasks[this.previousProject.arrTasks.length - 1]);
+ this.posY = parseInt(lastChildTask.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;
+ }
+ var containerNames = this.ganttChart.panelNames.firstChild;
+ this.projectNameItem = this.createProjectNameItem();
+ containerNames.appendChild(this.projectNameItem);
+ this.checkWidthProjectNameItem();
+ this.projectItem = [this.createProjectItem(), []];
+ containerTasks.appendChild(this.projectItem[0]);
+ containerTasks.appendChild(this.createDescrProject());
+ this.adjustPanelTime();
+ },
+ getTaskById: function(id){
+ for(var i = 0; i < this.arrTasks.length; i++){
+ var aTask = this.arrTasks[i];
+ var task = this.searchTaskInTree(aTask, id);
+ if(task){
+ return task;
+ }
+ }
+ return null;
+ },
+ searchTaskInTree: function(task, id){
+ if(task.taskItem.id == id){
+ return task;
+ }else{
+ for(var i = 0; i < task.childTask.length; i++){
+ var cTask = task.childTask[i];
+ if(cTask.taskItem.id == id){
+ return cTask;
+ }else{
+ if(cTask.childTask.length > 0){
+ var cTask = this.searchTaskInTree(cTask, id);
+ if(cTask){
+ return cTask;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ },
+ shiftProjectItem: function(){
+ var posItemL = null;
+ var posItemR = null;
+ var posProjectItemL = parseInt(this.projectItem[0].style.left);
+ var posProjectItemR = parseInt(this.projectItem[0].firstChild.style.width) + parseInt(this.projectItem[0].style.left);
+ var widthProjectItem = parseInt(this.projectItem[0].firstChild.style.width);
+ for(var i = 0; i < this.arrTasks.length; i++){
+ var aTask = this.arrTasks[i];
+ var tmpPosItemL = parseInt(aTask.cTaskItem[0].style.left);
+ var tmpPosItemR = parseInt(aTask.cTaskItem[0].style.left) + parseInt(aTask.cTaskItem[0].firstChild.firstChild.width);
+ if(!posItemL){
+ posItemL = tmpPosItemL;
+ }
+ if(!posItemR){
+ posItemR = tmpPosItemR;
+ }
+ if(posItemL > tmpPosItemL){
+ posItemL = tmpPosItemL;
+ }
+ if(posItemR < tmpPosItemR){
+ posItemR = tmpPosItemR;
+ }
+ }
+ if(posItemL != posProjectItemL){
+ this.project.startDate = new Date(this.ganttChart.startDate);
+ this.project.startDate.setHours(this.project.startDate.getHours() + (posItemL / this.ganttChart.pixelsPerHour));
+ }
+ this.projectItem[0].style.left = posItemL + "px";
+ this.resizeProjectItem(posItemR - posItemL);
+ this.duration = Math.round(parseInt(this.projectItem[0].firstChild.width) / (this.ganttChart.pixelsPerWorkHour));
+ this.shiftDescrProject();
+ this.adjustPanelTime();
+ },
+ adjustPanelTime: function(){
+ var projectItem = this.projectItem[0];
+ var width = parseInt(projectItem.style.left) + parseInt(projectItem.firstChild.style.width) + this.ganttChart.panelTimeExpandDelta;
+ width += this.descrProject.offsetWidth;
+ this.ganttChart.adjustPanelTime(width);
+ },
+ resizeProjectItem: function(width){
+ var percentage = this.percentage,
+ pItem = this.projectItem[0];
+ if(percentage > 0 && percentage < 100){
+ pItem.firstChild.style.width = width + "px";
+ pItem.firstChild.width = width + "px";
+ pItem.style.width = width + "px";
+ var firstRow = pItem.firstChild.rows[0];
+ firstRow.cells[0].firstChild.style.width = Math.round(width * percentage / 100) + "px";
+ firstRow.cells[0].firstChild.style.height = this.ganttChart.heightTaskItem + "px";
+ firstRow.cells[1].firstChild.style.width = Math.round(width * (100 - percentage) / 100) + "px";
+ firstRow.cells[1].firstChild.style.height = this.ganttChart.heightTaskItem + "px";
+ pItem.lastChild.firstChild.width = width + "px";
+ }else if(percentage == 0 || percentage == 100){
+ pItem.firstChild.style.width = width + "px";
+ pItem.firstChild.width = width + "px";
+ pItem.style.width = width + "px";
+ var firstRow = pItem.firstChild.rows[0];
+ firstRow.cells[0].firstChild.style.width = width + "px";
+ firstRow.cells[0].firstChild.style.height = this.ganttChart.heightTaskItem + "px";
+ pItem.lastChild.firstChild.width = width + "px";
+ }
+ },
+ shiftDescrProject: function(){
+ var posX = (parseInt(this.projectItem[0].style.left) + this.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ this.descrProject.style.left = posX + "px";
+ this.descrProject.innerHTML = this.getDescStr();
+ },
+ showDescrProject: function(){
+ var posX = (parseInt(this.projectItem[0].style.left) + this.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ this.descrProject.style.left = posX + "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 posX = (this.posX + this.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ var divDesc = dojo.create("div", {
+ innerHTML: this.getDescStr(),
+ className: "ganttDescProject"
+ });
+ dojo.style(divDesc, {
+ left: posX + "px",
+ top: this.posY + "px"
+ });
+ this.descrProject = divDesc;
+ if(this.project.parentTasks.length == 0){
+ this.descrProject.style.visibility = 'hidden';
+ }
+ return divDesc;
+ },
+ createProjectItem: function(){
+ this.percentage = this.getPercentCompleted();
+ this.duration = this.getDuration();
+ var projectItem = dojo.create("div", {
+ id: this.project.id,
+ className: "ganttProjectItem"
+ });
+ dojo.style(projectItem, {
+ left: this.posX + "px",
+ top: this.posY + "px",
+ width: this.duration * this.ganttChart.pixelsPerWorkHour + "px"
+ });
+ var tblProjectItem = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0",
+ className: "ganttTblProjectItem"
+ }, projectItem);
+ var width = this.duration * this.ganttChart.pixelsPerWorkHour;
+ tblProjectItem.width = ((width == 0) ? 1 : width) + "px";
+ tblProjectItem.style.width = ((width == 0) ? 1 : width) + "px";
+
+ var rowprojectItem = tblProjectItem.insertRow(tblProjectItem.rows.length);
+ if(this.percentage != -1){
+ if(this.percentage != 0){
+ var cellprojectItem = dojo.create("td", {
+ width: this.percentage + "%"
+ }, rowprojectItem);
+ cellprojectItem.style.lineHeight = "1px";
+ var imageProgress = dojo.create("div", {
+ className: "ganttImageProgressFilled"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: (this.percentage * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ if(this.percentage != 100){
+ var cellprojectItem = dojo.create("td", {
+ width: (100 - this.percentage) + "%"
+ }, rowprojectItem);
+ cellprojectItem.style.lineHeight = "1px";
+ var imageProgress = dojo.create("div", {
+ className: "ganttImageProgressBg"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: ((100 - this.percentage) * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ }else{
+ var cellprojectItem = dojo.create("td", {
+ width: "1px"
+ }, rowprojectItem);
+ cellprojectItem.style.lineHeight = "1px";
+ var imageProgress = dojo.create("div", {
+ className: "ganttImageProgressBg"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: "1px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ var divTaskInfo = dojo.create("div", {className: "ganttDivTaskInfo"});
+ var tblTaskInfo = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0",
+ height: this.ganttChart.heightTaskItem + "px",
+ width: ((this.duration * this.ganttChart.pixelsPerWorkHour == 0) ? 1 : this.duration * this.ganttChart.pixelsPerWorkHour) + "px"
+ }, divTaskInfo);
+ var rowTaskInfo = tblTaskInfo.insertRow(0);
+ var cellTaskInfo = dojo.create("td", {
+ align: "center",
+ vAlign: "top",
+ height: this.ganttChart.heightTaskItem + "px",
+ className: "ganttMoveInfo"
+ }, rowTaskInfo);
+ projectItem.appendChild(divTaskInfo);
+ if(this.project.parentTasks.length == 0){
+ projectItem.style.display = "none";
+ }
+ return projectItem;
+ },
+ createProjectNameItem: function(){
+ var divName = dojo.create("div", {
+ className: "ganttProjectNameItem",
+ innerHTML: this.project.name,
+ title: this.project.name
+ });
+ dojo.style(divName, {
+ left: "5px",
+ top: this.posY + "px"
+ });
+ dojo.attr(divName, "tabIndex", 0);
+ if(this.ganttChart.isShowConMenu){
+ this.ganttChart._events.push(
+ dojo.connect(divName, "onmouseover", this, function(event){
+ dojo.addClass(divName, "ganttProjectNameItemHover");
+ clearTimeout(this.ganttChart.menuTimer);
+ this.ganttChart.tabMenu.clear();
+ this.ganttChart.tabMenu.show(event.target, this);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divName, "onkeydown", this, function(event){
+ if(event.keyCode == dojo.keys.ENTER){
+ this.ganttChart.tabMenu.clear();
+ this.ganttChart.tabMenu.show(event.target, this);
+ }
+ if(this.ganttChart.tabMenu.isShow && (event.keyCode == dojo.keys.LEFT_ARROW || event.keyCode == dojo.keys.RIGHT_ARROW)){
+ dijit.focus(this.ganttChart.tabMenu.menuPanel.firstChild.rows[0].cells[0]);
+ }
+ if(this.ganttChart.tabMenu.isShow && event.keyCode == dojo.keys.ESCAPE){
+ this.ganttChart.tabMenu.hide();
+ }
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divName, "onmouseout", this, function(){
+ dojo.removeClass(divName, "ganttProjectNameItemHover");
+ clearTimeout(this.ganttChart.menuTimer);
+ this.ganttChart.menuTimer = setTimeout(dojo.hitch(this, function(){
+ this.ganttChart.tabMenu.hide();
+ }), 200);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(this.ganttChart.tabMenu.menuPanel, "onmouseover", this, function(){
+ clearTimeout(this.ganttChart.menuTimer);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(this.ganttChart.tabMenu.menuPanel, "onkeydown", this, function(event){
+ if(this.ganttChart.tabMenu.isShow && event.keyCode == dojo.keys.ESCAPE){
+ this.ganttChart.tabMenu.hide();
+ }
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(this.ganttChart.tabMenu.menuPanel, "onmouseout", this, function(){
+ clearTimeout(this.ganttChart.menuTimer);
+ this.ganttChart.menuTimer = setTimeout(dojo.hitch(this, function(){
+ this.ganttChart.tabMenu.hide();
+ }), 200);
+ })
+ );
+ }
+ return divName;
+ },
+ getPercentCompleted: function(){
+ var sum = 0, percentage = 0;
+ dojo.forEach(this.project.parentTasks, function(ppTask){
+ sum += parseInt(ppTask.percentage);
+ }, this);
+ if(this.project.parentTasks.length != 0){
+ return percentage = Math.round(sum / this.project.parentTasks.length);
+ }else{
+ return percentage = -1;
+ }
+ },
+ getDuration: function(){
+ var duration = 0, tmpDuration = 0;
+ if(this.project.parentTasks.length > 0){
+ dojo.forEach(this.project.parentTasks, function(ppTask){
+ tmpDuration = ppTask.duration * 24 / this.ganttChart.hsPerDay + (ppTask.startTime - this.ganttChart.startDate) / (60 * 60 * 1000);
+ if(tmpDuration > duration){
+ duration = tmpDuration;
+ }
+ }, this);
+ return ((duration - this.posX) / 24) * this.ganttChart.hsPerDay;
+ }else{
+ return 0;
+ }
+ },
+ deleteTask: function(id){
+ var task = this.getTaskById(id);
+ if(task){
+ this.deleteChildTask(task);
+ this.ganttChart.checkPosition();
+ }
+ },
+ setName: function(name){
+ if(name){
+ this.project.name = name;
+ this.projectNameItem.innerHTML = name;
+ this.projectNameItem.title = name;
+ this.checkWidthProjectNameItem();
+
+ this.descrProject.innerHTML = this.getDescStr();
+ this.adjustPanelTime();
+ }
+ },
+ setPercentCompleted: function(percentage){
+ percentage = parseInt(percentage);
+ if(isNaN(percentage) || percentage > 100 || percentage < 0){
+ return false;
+ }
+ var prow = this.projectItem[0].firstChild.rows[0],
+ rc0 = prow.cells[0], rc1 = prow.cells[1];
+ if((percentage > 0) && (percentage < 100) && (this.percentage > 0) && (this.percentage < 100)){
+ rc0.width = parseInt(percentage) + "%";
+ rc0.firstChild.style.width = (percentage * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px";
+ rc1.width = (100 - parseInt(percentage)) + "%";
+ rc1.firstChild.style.width = ((100 - percentage) * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px";
+ }else if(((percentage == 0) || (percentage == 100)) && (this.percentage > 0) && (this.percentage < 100)){
+ if(percentage == 0){
+ rc0.parentNode.removeChild(rc0);
+ rc1.width = 100 + "%";
+ rc1.firstChild.style.width = this.duration * this.ganttChart.pixelsPerWorkHour + "px";
+ }else if(percentage == 100){
+ rc1.parentNode.removeChild(rc1);
+ rc0.width = 100 + "%";
+ rc0.firstChild.style.width = this.duration * this.ganttChart.pixelsPerWorkHour + "px";
+ }
+ }else if(((percentage == 0) || (percentage == 100)) && ((this.percentage == 0) || (this.percentage == 100))){
+ if((percentage == 0) && (this.percentage == 100)){
+ dojo.removeClass(rc0.firstChild, "ganttImageProgressFilled");
+ dojo.addClass(rc0.firstChild, "ganttImageProgressBg");
+ }else if((percentage == 100) && (this.percentage == 0)){
+ dojo.removeClass(rc0.firstChild, "ganttImageProgressBg");
+ dojo.addClass(rc0.firstChild, "ganttImageProgressFilled");
+ }
+ }else if(((percentage > 0) || (percentage < 100)) && ((this.percentage == 0) || (this.percentage == 100))){
+ rc0.parentNode.removeChild(rc0);
+ var cellprojectItem = dojo.create("td", {
+ width: percentage + "%"
+ }, prow);
+ cellprojectItem.style.lineHeight = "1px";
+ var imageProgress = dojo.create("div", {
+ className: "ganttImageProgressFilled"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: (percentage * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ cellprojectItem = dojo.create("td", {
+ width: (100 - percentage) + "%"
+ }, prow);
+ cellprojectItem.style.lineHeight = "1px";
+ imageProgress = dojo.create("div", {
+ className: "ganttImageProgressBg"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: ((100 - percentage) * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }else if(this.percentage == -1){
+ if(percentage == 100){
+ dojo.removeClass(rc0.firstChild, "ganttImageProgressBg");
+ dojo.addClass(rc0.firstChild, "ganttImageProgressFilled");
+ }else if(percentage < 100 && percentage > 0){
+ rc0.parentNode.removeChild(rc0);
+ var cellprojectItem = dojo.create("td", {
+ width: percentage + "%"
+ }, prow);
+ cellprojectItem.style.lineHeight = "1px";
+ imageProgress = dojo.create("div", {
+ className: "ganttImageProgressFilled"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: (percentage * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ cellprojectItem = dojo.create("td", {
+ width: (100 - percentage) + "%"
+ }, prow);
+ cellprojectItem.style.lineHeight = "1px";
+ imageProgress = dojo.create("div", {
+ className: "ganttImageProgressBg"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: ((100 - percentage) * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ }
+ this.percentage = percentage;
+ this.descrProject.innerHTML = this.getDescStr();
+ return true;
+ },
+ deleteChildTask: function(task){
+ if(task){
+ var tItem0 = task.cTaskItem[0], tNameItem0 = task.cTaskNameItem[0],
+ tItem1 = task.cTaskItem[1], tNameItem1 = task.cTaskNameItem[1],
+ tItem2 = task.cTaskItem[2], tNameItem2 = task.cTaskNameItem[2];
+ if(tItem0.style.display == "none"){
+ this.ganttChart.openTree(task.parentTask);
+ }
+ //delete of connecting lines
+ if(task.childPredTask.length > 0){
+ for(var i = 0; i < task.childPredTask.length; i++){
+ var cpTask = task.childPredTask[i];
+ for(var t = 0; t < cpTask.cTaskItem[1].length; t++){
+ cpTask.cTaskItem[1][t].parentNode.removeChild(cpTask.cTaskItem[1][t]);
+ }
+ cpTask.cTaskItem[1] = [];
+ cpTask.predTask = null;
+ }
+ }
+ //delete child task
+ if(task.childTask.length > 0){
+ while(task.childTask.length > 0){
+ this.deleteChildTask(task.childTask[0]);
+ }
+ }
+ //shift tasks
+ var rowHeight = this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ if(tItem0.style.display != "none"){
+ task.shiftCurrentTasks(task, -rowHeight);
+ }
+ //delete object task
+ this.project.deleteTask(task.taskItem.id);
+ //delete div and connecting lines from contentData
+ if(tItem0){
+ tItem0.parentNode.removeChild(tItem0);
+ }
+ task.descrTask.parentNode.removeChild(task.descrTask);
+ if(tItem1.length > 0){
+ for(var j = 0; j < tItem1.length; j++){
+ tItem1[j].parentNode.removeChild(tItem1[j]);
+ }
+ }
+ //delete div and connecting lines from panelName
+ if(tNameItem0){
+ tNameItem0.parentNode.removeChild(tNameItem0);
+ }
+ if(task.cTaskNameItem[1]){
+ for(var j = 0; j < tNameItem1.length; j++){
+ tNameItem1[j].parentNode.removeChild(tNameItem1[j]);
+ }
+ }
+ if(tNameItem2 && tNameItem2.parentNode){
+ tNameItem2.parentNode.removeChild(tNameItem2);
+ }
+ if(task.taskIdentifier){
+ task.taskIdentifier.parentNode.removeChild(task.taskIdentifier);
+ task.taskIdentifier = null;
+ }
+ //delete object task
+ if(task.parentTask){
+ if(task.previousChildTask){
+ if(task.nextChildTask){
+ task.previousChildTask.nextChildTask = task.nextChildTask;
+ }else{
+ task.previousChildTask.nextChildTask = null;
+ }
+ }
+ var parentTask = task.parentTask;
+ for(var i = 0; i < parentTask.childTask.length; i++){
+ if(parentTask.childTask[i].taskItem.id == task.taskItem.id){
+ parentTask.childTask[i] = null;
+ parentTask.childTask.splice(i, 1);
+ break;
+ }
+ }
+ if(parentTask.childTask.length == 0){
+ if(parentTask.cTaskNameItem[2]){
+ parentTask.cTaskNameItem[2].parentNode.removeChild(parentTask.cTaskNameItem[2]);
+ parentTask.cTaskNameItem[2] = null;
+ }
+ }
+ }else{
+ if(task.previousParentTask){
+ if(task.nextParentTask){
+ task.previousParentTask.nextParentTask = task.nextParentTask;
+ }else{
+ task.previousParentTask.nextParentTask = null;
+ }
+ }
+ var project = task.project;
+ for(var i = 0; i < project.arrTasks.length; i++){
+ if(project.arrTasks[i].taskItem.id == task.taskItem.id){
+ project.arrTasks.splice(i, 1);
+ }
+ }
+ }
+ if(task.predTask){
+ var predTask = task.predTask;
+ for(var i = 0; i < predTask.childPredTask.length; i++){
+ if(predTask.childPredTask[i].taskItem.id == task.taskItem.id){
+ predTask.childPredTask[i] = null;
+ predTask.childPredTask.splice(i, 1);
+ }
+ }
+ }
+ if(task.project.arrTasks.length != 0){
+ task.project.shiftProjectItem();
+ }else{
+ task.project.projectItem[0].style.display = "none";
+ this.hideDescrProject();
+ }
+ this.ganttChart.contentDataHeight -= this.ganttChart.heightTaskItemExtra + this.ganttChart.heightTaskItem;
+ }
+ },
+
+ insertTask: function(id, name, startTime, duration, percentage, previousTaskId, taskOwner, parentTaskId){
+ var task = null;
+ var _task = null;
+ if(this.project.getTaskById(id)){
+ return false;
+ }
+ if((!duration) || (duration < this.ganttChart.minWorkLength)){
+ duration = this.ganttChart.minWorkLength;
+ }
+ if((!name) || (name == "")){
+ name = id;
+ }
+ if((!percentage) || (percentage == "")){
+ percentage = 0;
+
+ }else{
+ percentage = parseInt(percentage);
+ if(percentage < 0 || percentage > 100){
+ return false;
+ }
+ }
+ var sortRequired = false;
+ if((parentTaskId) && (parentTaskId != "")){
+ var parentTask = this.project.getTaskById(parentTaskId);
+ if(!parentTask){
+ return false;
+ }
+ startTime = startTime || parentTask.startTime;
+ if(startTime < parentTask.startTime){
+ return false;
+ }
+ task = new dojox.gantt.GanttTaskItem({
+ id: id,
+ name: name,
+ startTime: startTime,
+ duration: duration,
+ percentage: percentage,
+ previousTaskId: previousTaskId,
+ taskOwner: taskOwner
+ });
+ if(!this.ganttChart.checkPosParentTask(parentTask, task)){
+ return false;
+ }
+ task.parentTask = parentTask;
+ var _parentTask = this.getTaskById(parentTask.id);
+ var isHide = false;
+ if(_parentTask.cTaskItem[0].style.display == "none"){
+ isHide = true;
+ }else if(_parentTask.cTaskNameItem[2]){
+ if(!_parentTask.isExpanded){
+ isHide = true;
+ }
+ }
+ if(isHide){
+ if(_parentTask.childTask.length == 0){
+ this.ganttChart.openTree(_parentTask.parentTask);
+ }else{
+ this.ganttChart.openTree(_parentTask);
+ }
+ }
+ if(previousTaskId != ""){
+ var predTask = this.project.getTaskById(previousTaskId);
+ if(!predTask){
+ return false;
+ }
+ if(predTask.parentTask){
+ if(predTask.parentTask.id != task.parentTask.id){
+ return false;
+ }
+ }else{
+ return false;
+ }
+ if(!this.ganttChart.checkPosPreviousTask(predTask, task)){
+ this.ganttChart.correctPosPreviousTask(predTask, task);
+ }
+ task.previousTask = predTask;
+ }
+ var isAdd = false;
+ if(sortRequired) for(var i = 0; i < parentTask.cldTasks.length; i++){
+ if(task.startTime < parentTask.cldTasks[i].startTime){
+ parentTask.cldTasks.splice(i, 0, task);
+ if(i > 0){
+ parentTask.cldTasks[i - 1].nextChildTask = parentTask.cldTasks[i];
+ parentTask.cldTasks[i].previousChildTask = parentTask.cldTasks[i - 1];
+ }
+ if(parentTask.cldTasks[i + 1]){
+ parentTask.cldTasks[i + 1].previousChildTask = parentTask.cldTasks[i];
+ parentTask.cldTasks[i].nextChildTask = parentTask.cldTasks[i + 1];
+ }
+ isAdd = true;
+ break;
+ }
+ }
+ if(!isAdd){
+ if(parentTask.cldTasks.length > 0){
+ parentTask.cldTasks[parentTask.cldTasks.length - 1].nextChildTask = task;
+ task.previousChildTask = parentTask.cldTasks[parentTask.cldTasks.length - 1];
+ }
+ parentTask.cldTasks.push(task);
+ }
+ if(parentTask.cldTasks.length == 1){
+ var treeImg = _parentTask.createTreeImg();
+ _parentTask.cTaskNameItem[2] = treeImg;
+ }
+ _task = new dojox.gantt.GanttTaskControl(task, this, this.ganttChart);
+ _task.create();
+ if(task.nextChildTask) _task.nextChildTask = _task.project.getTaskById(task.nextChildTask.id);
+ _task.adjustPanelTime();
+ var rowHeight = this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ _task.shiftCurrentTasks(_task, rowHeight);//23
+ }else{
+ startTime = startTime || this.project.startDate;
+ task = new dojox.gantt.GanttTaskItem({
+ id: id,
+ name: name,
+ startTime: startTime,
+ duration: duration,
+ percentage: percentage,
+ previousTaskId: previousTaskId,
+ taskOwner: taskOwner
+ });
+ if(task.startTime <= this.ganttChart.startDate){
+ return false;
+ }
+ if(previousTaskId != ""){
+ var predTask = this.project.getTaskById(previousTaskId);
+ if(!predTask){
+ return false;
+ }
+ if(!this.ganttChart.checkPosPreviousTask(predTask, task)){
+ this.ganttChart.correctPosPreviousTask(predTask, task);
+ }
+ if(predTask.parentTask){
+ return false;
+ }
+ task.previousTask = predTask;
+ }
+ var isAdd = false;
+ if(sortRequired){
+ for(var i = 0; i < this.project.parentTasks.length; i++){
+ var ppTask = this.project.parentTasks[i];
+ if(startTime < ppTask.startTime){
+ this.project.parentTasks.splice(i, 0, task);
+ if(i > 0){
+ this.project.parentTasks[i - 1].nextParentTask = task;
+ task.previousParentTask = this.project.parentTasks[i - 1];
+ }
+ if(this.project.parentTasks[i + 1]){
+ this.project.parentTasks[i + 1].previousParentTask = task;
+ task.nextParentTask = this.project.parentTasks[i + 1];
+ }
+ isAdd = true;
+ break;
+ }
+ }
+ }
+ if(!isAdd){
+ if(this.project.parentTasks.length > 0){
+ this.project.parentTasks[this.project.parentTasks.length - 1].nextParentTask = task;
+ task.previousParentTask = this.project.parentTasks[this.project.parentTasks.length - 1];
+ }
+ this.project.parentTasks.push(task);
+ }
+ _task = new dojox.gantt.GanttTaskControl(task, this, this.ganttChart);
+ _task.create();
+ if(task.nextParentTask) _task.nextParentTask = _task.project.getTaskById(task.nextParentTask.id);
+ _task.adjustPanelTime();
+ this.arrTasks.push(_task);
+ var rowHeight = this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ _task.shiftCurrentTasks(_task, rowHeight);
+ this.projectItem[0].style.display = "inline";
+ this.setPercentCompleted(this.getPercentCompleted());
+ this.shiftProjectItem();
+ this.showDescrProject();
+ }
+ this.ganttChart.checkHeighPanelTasks();
+ this.ganttChart.checkPosition();
+ return _task;
+ },
+ shiftNextProject: function(project, height){
+ if(project.nextProject){
+ project.nextProject.shiftProject(height);
+ this.shiftNextProject(project.nextProject, height);
+ }
+ },
+ shiftProject: function(height){
+ this.posY = this.posY + height;
+ this.projectItem[0].style.top = parseInt(this.projectItem[0].style.top) + height + "px";
+ this.descrProject.style.top = parseInt(this.descrProject.style.top) + height + "px";
+ this.projectNameItem.style.top = parseInt(this.projectNameItem.style.top) + height + "px";
+ if(this.arrTasks.length > 0){
+ this.shiftNextParentTask(this.arrTasks[0], height);
+ }
+ },
+ shiftTask: function(task, height){
+ task.posY = task.posY + height;
+ var tNameItem0 = task.cTaskNameItem[0], tNameItem1 = task.cTaskNameItem[1], tNameItem2 = task.cTaskNameItem[2],
+ tItem0 = task.cTaskItem[0], tItem1 = task.cTaskItem[1], tItem2 = task.cTaskItem[2];
+ tNameItem0.style.top = parseInt(tNameItem0.style.top) + height + "px";
+ if(tNameItem2){
+ tNameItem2.style.top = parseInt(tNameItem2.style.top) + height + "px";
+ }
+ if(task.parentTask){
+ tNameItem1[0].style.top = parseInt(tNameItem1[0].style.top) + height + "px";
+ tNameItem1[1].style.top = parseInt(tNameItem1[1].style.top) + height + "px";
+ }
+ task.cTaskItem[0].style.top = parseInt(task.cTaskItem[0].style.top) + height + "px";
+ task.descrTask.style.top = parseInt(task.descrTask.style.top) + height + "px";
+ if(tItem1[0]){
+ tItem1[0].style.top = parseInt(tItem1[0].style.top) + height + "px";
+ tItem1[1].style.top = parseInt(tItem1[1].style.top) + height + "px";
+ tItem1[2].style.top = parseInt(tItem1[2].style.top) + height + "px";
+ }
+ },
+ shiftNextParentTask: function(task, height){
+ this.shiftTask(task, height);
+ this.shiftChildTasks(task, height);
+ if(task.nextParentTask){
+ this.shiftNextParentTask(task.nextParentTask, height);
+ }
+ },
+ shiftChildTasks: function(task, height){
+ dojo.forEach(task.childTask, function(cTask){
+ this.shiftTask(cTask, height);
+ if(cTask.childTask.length > 0){
+ this.shiftChildTasks(cTask, height);
+ }
+ }, this);
+ }
+});
+
+
+dojo.declare("dojox.gantt.GanttProjectItem", null, {
+ constructor: function(configuration){
+ //id is required
+ this.id = configuration.id;
+ this.name = configuration.name || this.id;
+ this.startDate = configuration.startDate || new Date();
+ this.parentTasks = [];
+ },
+ getTaskById: function(id){
+ for(var i = 0; i < this.parentTasks.length; i++){
+ var pTask = this.parentTasks[i];
+ var task = this.getTaskByIdInTree(pTask, id);
+ if(task){
+ return task;
+ }
+ }
+ return null;
+ },
+ getTaskByIdInTree: function(parentTask, id){
+ if(parentTask.id == id){
+ return parentTask;
+ }else{
+ for(var i = 0; i < parentTask.cldTasks.length; i++){
+ var pcTask = parentTask.cldTasks[i];
+ if(pcTask.id == id){
+ return pcTask;
+ }
+ if(pcTask.cldTasks.length > 0){
+ if(pcTask.cldTasks.length > 0){
+ var cTask = this.getTaskByIdInTree(pcTask, id);
+ if(cTask){
+ return cTask;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ },
+ addTask: function(task){
+ this.parentTasks.push(task);
+ task.setProject(this);
+ },
+ deleteTask: function(id){
+ var task = this.getTaskById(id);
+ if(!task){return;}
+ if(!task.parentTask){
+ for(var i = 0; i < this.parentTasks.length; i++){
+ var pTask = this.parentTasks[i];
+ if(pTask.id == id){
+ if(pTask.nextParentTask){
+ if(pTask.previousParentTask){
+ pTask.previousParentTask.nextParentTask = pTask.nextParentTask;
+ pTask.nextParentTask.previousParentTask = pTask.previousParentTask;
+ }else{
+ pTask.nextParentTask.previousParentTask = null;
+ }
+ }else{
+ if(pTask.previousParentTask){
+ pTask.previousParentTask.nextParentTask = null;
+ }
+ }
+ pTask = null;
+ this.parentTasks.splice(i, 1);
+ break;
+ }
+ }
+ }else{
+ var parentTask = task.parentTask;
+ for(var i = 0; i < parentTask.cldTasks.length; i++){
+ var pcTask = parentTask.cldTasks[i];
+ if(pcTask.id == id){
+ if(pcTask.nextChildTask){
+ if(pcTask.previousChildTask){
+ pcTask.previousChildTask.nextChildTask = pcTask.nextChildTask;
+ pcTask.nextChildTask.previousChildTask = pcTask.previousChildTask;
+ }else{
+ pcTask.nextChildTask.previousChildTask = null;
+ }
+ }else{
+ if(pcTask.previousChildTask){
+ pcTask.previousChildTask.nextChildTask = null;
+ }
+ }
+ pcTask = null;
+ parentTask.cldTasks.splice(i, 1);
+ break;
+ }
+ }
+ }
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/gantt/GanttProjectItem.xd.js b/js/dojo-1.6/dojox/gantt/GanttProjectItem.xd.js new file mode 100644 index 0000000..9c90f2e --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/GanttProjectItem.xd.js @@ -0,0 +1,984 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.gantt.GanttProjectItem"],
+["require", "dojox.gantt.GanttTaskItem"],
+["require", "dojo.date.locale"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.gantt.GanttProjectItem"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.gantt.GanttProjectItem"] = true;
+dojo.provide("dojox.gantt.GanttProjectItem");
+
+dojo.require("dojox.gantt.GanttTaskItem");
+dojo.require("dojo.date.locale");
+
+dojo.declare("dojox.gantt.GanttProjectControl", null, {
+ constructor: function(ganttChart, projectItem){
+ this.project = projectItem;
+ this.ganttChart = ganttChart;
+ this.descrProject = null;
+ this.projectItem = null;
+ this.projectNameItem = null;
+ this.posY = 0;
+ this.posX = 0;
+ this.nextProject = null;
+ this.previousProject = null;
+ this.arrTasks = [];
+ this.percentage = 0;
+ this.duration = 0;
+ },
+ checkWidthProjectNameItem: function(){
+ if(this.projectNameItem.offsetWidth + this.projectNameItem.offsetLeft > this.ganttChart.maxWidthTaskNames){
+ var width = this.projectNameItem.offsetWidth + this.projectNameItem.offsetLeft - this.ganttChart.maxWidthTaskNames;
+ var countChar = Math.round(width / (this.projectNameItem.offsetWidth / this.projectNameItem.firstChild.length));
+ var pName = this.project.name.substring(0, this.projectNameItem.firstChild.length - countChar - 3);
+ pName += "...";
+ this.projectNameItem.innerHTML = pName;
+ }
+ },
+ refreshProjectItem: function(projectItem){
+ this.percentage = this.getPercentCompleted();
+ dojo.style(projectItem, {
+ "left": this.posX + "px",
+ "width": this.duration * this.ganttChart.pixelsPerWorkHour + "px"
+ });
+ var tblProjectItem = projectItem.firstChild;
+ var width = this.duration * this.ganttChart.pixelsPerWorkHour;
+ tblProjectItem.width = ((width == 0) ? 1 : width) + "px";
+ tblProjectItem.style.width = ((width == 0) ? 1 : width) + "px";
+ var rowprojectItem = tblProjectItem.rows[0];
+ if(this.percentage != -1){
+ if(this.percentage != 0){
+ var cellprojectItem = rowprojectItem.firstChild;
+ cellprojectItem.width = this.percentage + "%";
+ var imageProgress = cellprojectItem.firstChild;
+ dojo.style(imageProgress, {
+ width: (!this.duration ? 1 : (this.percentage * this.duration * this.ganttChart.pixelsPerWorkHour / 100)) + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ })
+ }
+ if(this.percentage != 100){
+ var cellprojectItem = rowprojectItem.lastChild;
+ cellprojectItem.width = (100 - this.percentage) + "%";
+ var imageProgress = cellprojectItem.firstChild;
+ dojo.style(imageProgress, {
+ width: (!this.duration ? 1 : ((100 - this.percentage) * this.duration * this.ganttChart.pixelsPerWorkHour / 100)) + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ })
+ }
+ }else{
+ var cellprojectItem = rowprojectItem.firstChild;
+ cellprojectItem.width = "1px";
+ var imageProgress = cellprojectItem.firstChild;
+ dojo.style(imageProgress, {
+ width: "1px",
+ height: this.ganttChart.heightTaskItem + "px"
+ })
+ }
+ var divTaskInfo = projectItem.lastChild;
+ var tblTaskInfo = divTaskInfo.firstChild;
+ dojo.style(tblTaskInfo, {
+ height: this.ganttChart.heightTaskItem + "px",
+ width: (!this.duration ? 1 : (this.duration * this.ganttChart.pixelsPerWorkHour)) + "px"
+ });
+ var rowTaskInfo = tblTaskInfo.rows[0];
+ var cellTaskInfo = rowTaskInfo.firstChild;
+ cellTaskInfo.height = this.ganttChart.heightTaskItem + "px";
+ if(this.project.parentTasks.length == 0){
+ projectItem.style.display = "none";
+ }
+ return projectItem;
+ },
+ refreshDescrProject: function(divDesc){
+ var posX = (this.posX + this.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ dojo.style(divDesc, {
+ "left": posX + "px"
+ });
+ if(this.project.parentTasks.length == 0){
+ this.descrProject.style.visibility = 'hidden';
+ }
+ return divDesc;
+ },
+ postLoadData: function(){
+ //TODO e.g. project relative info...
+ },
+ refresh: function(){
+ var containerTasks = this.ganttChart.contentData.firstChild;
+ this.posX = (this.project.startDate - this.ganttChart.startDate) / (60 * 60 * 1000) * this.ganttChart.pixelsPerHour;
+ this.refreshProjectItem(this.projectItem[0]);
+ this.refreshDescrProject(this.projectItem[0].nextSibling);
+ return this;
+ },
+ create: function(){
+ var containerTasks = this.ganttChart.contentData.firstChild;
+ this.posX = (this.project.startDate - this.ganttChart.startDate) / (60 * 60 * 1000) * this.ganttChart.pixelsPerHour;
+ if(this.previousProject){
+ if(this.previousProject.arrTasks.length > 0){
+ var lastChildTask = this.ganttChart.getLastChildTask(this.previousProject.arrTasks[this.previousProject.arrTasks.length - 1]);
+ this.posY = parseInt(lastChildTask.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;
+ }
+ var containerNames = this.ganttChart.panelNames.firstChild;
+ this.projectNameItem = this.createProjectNameItem();
+ containerNames.appendChild(this.projectNameItem);
+ this.checkWidthProjectNameItem();
+ this.projectItem = [this.createProjectItem(), []];
+ containerTasks.appendChild(this.projectItem[0]);
+ containerTasks.appendChild(this.createDescrProject());
+ this.adjustPanelTime();
+ },
+ getTaskById: function(id){
+ for(var i = 0; i < this.arrTasks.length; i++){
+ var aTask = this.arrTasks[i];
+ var task = this.searchTaskInTree(aTask, id);
+ if(task){
+ return task;
+ }
+ }
+ return null;
+ },
+ searchTaskInTree: function(task, id){
+ if(task.taskItem.id == id){
+ return task;
+ }else{
+ for(var i = 0; i < task.childTask.length; i++){
+ var cTask = task.childTask[i];
+ if(cTask.taskItem.id == id){
+ return cTask;
+ }else{
+ if(cTask.childTask.length > 0){
+ var cTask = this.searchTaskInTree(cTask, id);
+ if(cTask){
+ return cTask;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ },
+ shiftProjectItem: function(){
+ var posItemL = null;
+ var posItemR = null;
+ var posProjectItemL = parseInt(this.projectItem[0].style.left);
+ var posProjectItemR = parseInt(this.projectItem[0].firstChild.style.width) + parseInt(this.projectItem[0].style.left);
+ var widthProjectItem = parseInt(this.projectItem[0].firstChild.style.width);
+ for(var i = 0; i < this.arrTasks.length; i++){
+ var aTask = this.arrTasks[i];
+ var tmpPosItemL = parseInt(aTask.cTaskItem[0].style.left);
+ var tmpPosItemR = parseInt(aTask.cTaskItem[0].style.left) + parseInt(aTask.cTaskItem[0].firstChild.firstChild.width);
+ if(!posItemL){
+ posItemL = tmpPosItemL;
+ }
+ if(!posItemR){
+ posItemR = tmpPosItemR;
+ }
+ if(posItemL > tmpPosItemL){
+ posItemL = tmpPosItemL;
+ }
+ if(posItemR < tmpPosItemR){
+ posItemR = tmpPosItemR;
+ }
+ }
+ if(posItemL != posProjectItemL){
+ this.project.startDate = new Date(this.ganttChart.startDate);
+ this.project.startDate.setHours(this.project.startDate.getHours() + (posItemL / this.ganttChart.pixelsPerHour));
+ }
+ this.projectItem[0].style.left = posItemL + "px";
+ this.resizeProjectItem(posItemR - posItemL);
+ this.duration = Math.round(parseInt(this.projectItem[0].firstChild.width) / (this.ganttChart.pixelsPerWorkHour));
+ this.shiftDescrProject();
+ this.adjustPanelTime();
+ },
+ adjustPanelTime: function(){
+ var projectItem = this.projectItem[0];
+ var width = parseInt(projectItem.style.left) + parseInt(projectItem.firstChild.style.width) + this.ganttChart.panelTimeExpandDelta;
+ width += this.descrProject.offsetWidth;
+ this.ganttChart.adjustPanelTime(width);
+ },
+ resizeProjectItem: function(width){
+ var percentage = this.percentage,
+ pItem = this.projectItem[0];
+ if(percentage > 0 && percentage < 100){
+ pItem.firstChild.style.width = width + "px";
+ pItem.firstChild.width = width + "px";
+ pItem.style.width = width + "px";
+ var firstRow = pItem.firstChild.rows[0];
+ firstRow.cells[0].firstChild.style.width = Math.round(width * percentage / 100) + "px";
+ firstRow.cells[0].firstChild.style.height = this.ganttChart.heightTaskItem + "px";
+ firstRow.cells[1].firstChild.style.width = Math.round(width * (100 - percentage) / 100) + "px";
+ firstRow.cells[1].firstChild.style.height = this.ganttChart.heightTaskItem + "px";
+ pItem.lastChild.firstChild.width = width + "px";
+ }else if(percentage == 0 || percentage == 100){
+ pItem.firstChild.style.width = width + "px";
+ pItem.firstChild.width = width + "px";
+ pItem.style.width = width + "px";
+ var firstRow = pItem.firstChild.rows[0];
+ firstRow.cells[0].firstChild.style.width = width + "px";
+ firstRow.cells[0].firstChild.style.height = this.ganttChart.heightTaskItem + "px";
+ pItem.lastChild.firstChild.width = width + "px";
+ }
+ },
+ shiftDescrProject: function(){
+ var posX = (parseInt(this.projectItem[0].style.left) + this.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ this.descrProject.style.left = posX + "px";
+ this.descrProject.innerHTML = this.getDescStr();
+ },
+ showDescrProject: function(){
+ var posX = (parseInt(this.projectItem[0].style.left) + this.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ this.descrProject.style.left = posX + "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 posX = (this.posX + this.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ var divDesc = dojo.create("div", {
+ innerHTML: this.getDescStr(),
+ className: "ganttDescProject"
+ });
+ dojo.style(divDesc, {
+ left: posX + "px",
+ top: this.posY + "px"
+ });
+ this.descrProject = divDesc;
+ if(this.project.parentTasks.length == 0){
+ this.descrProject.style.visibility = 'hidden';
+ }
+ return divDesc;
+ },
+ createProjectItem: function(){
+ this.percentage = this.getPercentCompleted();
+ this.duration = this.getDuration();
+ var projectItem = dojo.create("div", {
+ id: this.project.id,
+ className: "ganttProjectItem"
+ });
+ dojo.style(projectItem, {
+ left: this.posX + "px",
+ top: this.posY + "px",
+ width: this.duration * this.ganttChart.pixelsPerWorkHour + "px"
+ });
+ var tblProjectItem = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0",
+ className: "ganttTblProjectItem"
+ }, projectItem);
+ var width = this.duration * this.ganttChart.pixelsPerWorkHour;
+ tblProjectItem.width = ((width == 0) ? 1 : width) + "px";
+ tblProjectItem.style.width = ((width == 0) ? 1 : width) + "px";
+
+ var rowprojectItem = tblProjectItem.insertRow(tblProjectItem.rows.length);
+ if(this.percentage != -1){
+ if(this.percentage != 0){
+ var cellprojectItem = dojo.create("td", {
+ width: this.percentage + "%"
+ }, rowprojectItem);
+ cellprojectItem.style.lineHeight = "1px";
+ var imageProgress = dojo.create("div", {
+ className: "ganttImageProgressFilled"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: (this.percentage * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ if(this.percentage != 100){
+ var cellprojectItem = dojo.create("td", {
+ width: (100 - this.percentage) + "%"
+ }, rowprojectItem);
+ cellprojectItem.style.lineHeight = "1px";
+ var imageProgress = dojo.create("div", {
+ className: "ganttImageProgressBg"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: ((100 - this.percentage) * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ }else{
+ var cellprojectItem = dojo.create("td", {
+ width: "1px"
+ }, rowprojectItem);
+ cellprojectItem.style.lineHeight = "1px";
+ var imageProgress = dojo.create("div", {
+ className: "ganttImageProgressBg"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: "1px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ var divTaskInfo = dojo.create("div", {className: "ganttDivTaskInfo"});
+ var tblTaskInfo = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0",
+ height: this.ganttChart.heightTaskItem + "px",
+ width: ((this.duration * this.ganttChart.pixelsPerWorkHour == 0) ? 1 : this.duration * this.ganttChart.pixelsPerWorkHour) + "px"
+ }, divTaskInfo);
+ var rowTaskInfo = tblTaskInfo.insertRow(0);
+ var cellTaskInfo = dojo.create("td", {
+ align: "center",
+ vAlign: "top",
+ height: this.ganttChart.heightTaskItem + "px",
+ className: "ganttMoveInfo"
+ }, rowTaskInfo);
+ projectItem.appendChild(divTaskInfo);
+ if(this.project.parentTasks.length == 0){
+ projectItem.style.display = "none";
+ }
+ return projectItem;
+ },
+ createProjectNameItem: function(){
+ var divName = dojo.create("div", {
+ className: "ganttProjectNameItem",
+ innerHTML: this.project.name,
+ title: this.project.name
+ });
+ dojo.style(divName, {
+ left: "5px",
+ top: this.posY + "px"
+ });
+ dojo.attr(divName, "tabIndex", 0);
+ if(this.ganttChart.isShowConMenu){
+ this.ganttChart._events.push(
+ dojo.connect(divName, "onmouseover", this, function(event){
+ dojo.addClass(divName, "ganttProjectNameItemHover");
+ clearTimeout(this.ganttChart.menuTimer);
+ this.ganttChart.tabMenu.clear();
+ this.ganttChart.tabMenu.show(event.target, this);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divName, "onkeydown", this, function(event){
+ if(event.keyCode == dojo.keys.ENTER){
+ this.ganttChart.tabMenu.clear();
+ this.ganttChart.tabMenu.show(event.target, this);
+ }
+ if(this.ganttChart.tabMenu.isShow && (event.keyCode == dojo.keys.LEFT_ARROW || event.keyCode == dojo.keys.RIGHT_ARROW)){
+ dijit.focus(this.ganttChart.tabMenu.menuPanel.firstChild.rows[0].cells[0]);
+ }
+ if(this.ganttChart.tabMenu.isShow && event.keyCode == dojo.keys.ESCAPE){
+ this.ganttChart.tabMenu.hide();
+ }
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divName, "onmouseout", this, function(){
+ dojo.removeClass(divName, "ganttProjectNameItemHover");
+ clearTimeout(this.ganttChart.menuTimer);
+ this.ganttChart.menuTimer = setTimeout(dojo.hitch(this, function(){
+ this.ganttChart.tabMenu.hide();
+ }), 200);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(this.ganttChart.tabMenu.menuPanel, "onmouseover", this, function(){
+ clearTimeout(this.ganttChart.menuTimer);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(this.ganttChart.tabMenu.menuPanel, "onkeydown", this, function(event){
+ if(this.ganttChart.tabMenu.isShow && event.keyCode == dojo.keys.ESCAPE){
+ this.ganttChart.tabMenu.hide();
+ }
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(this.ganttChart.tabMenu.menuPanel, "onmouseout", this, function(){
+ clearTimeout(this.ganttChart.menuTimer);
+ this.ganttChart.menuTimer = setTimeout(dojo.hitch(this, function(){
+ this.ganttChart.tabMenu.hide();
+ }), 200);
+ })
+ );
+ }
+ return divName;
+ },
+ getPercentCompleted: function(){
+ var sum = 0, percentage = 0;
+ dojo.forEach(this.project.parentTasks, function(ppTask){
+ sum += parseInt(ppTask.percentage);
+ }, this);
+ if(this.project.parentTasks.length != 0){
+ return percentage = Math.round(sum / this.project.parentTasks.length);
+ }else{
+ return percentage = -1;
+ }
+ },
+ getDuration: function(){
+ var duration = 0, tmpDuration = 0;
+ if(this.project.parentTasks.length > 0){
+ dojo.forEach(this.project.parentTasks, function(ppTask){
+ tmpDuration = ppTask.duration * 24 / this.ganttChart.hsPerDay + (ppTask.startTime - this.ganttChart.startDate) / (60 * 60 * 1000);
+ if(tmpDuration > duration){
+ duration = tmpDuration;
+ }
+ }, this);
+ return ((duration - this.posX) / 24) * this.ganttChart.hsPerDay;
+ }else{
+ return 0;
+ }
+ },
+ deleteTask: function(id){
+ var task = this.getTaskById(id);
+ if(task){
+ this.deleteChildTask(task);
+ this.ganttChart.checkPosition();
+ }
+ },
+ setName: function(name){
+ if(name){
+ this.project.name = name;
+ this.projectNameItem.innerHTML = name;
+ this.projectNameItem.title = name;
+ this.checkWidthProjectNameItem();
+
+ this.descrProject.innerHTML = this.getDescStr();
+ this.adjustPanelTime();
+ }
+ },
+ setPercentCompleted: function(percentage){
+ percentage = parseInt(percentage);
+ if(isNaN(percentage) || percentage > 100 || percentage < 0){
+ return false;
+ }
+ var prow = this.projectItem[0].firstChild.rows[0],
+ rc0 = prow.cells[0], rc1 = prow.cells[1];
+ if((percentage > 0) && (percentage < 100) && (this.percentage > 0) && (this.percentage < 100)){
+ rc0.width = parseInt(percentage) + "%";
+ rc0.firstChild.style.width = (percentage * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px";
+ rc1.width = (100 - parseInt(percentage)) + "%";
+ rc1.firstChild.style.width = ((100 - percentage) * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px";
+ }else if(((percentage == 0) || (percentage == 100)) && (this.percentage > 0) && (this.percentage < 100)){
+ if(percentage == 0){
+ rc0.parentNode.removeChild(rc0);
+ rc1.width = 100 + "%";
+ rc1.firstChild.style.width = this.duration * this.ganttChart.pixelsPerWorkHour + "px";
+ }else if(percentage == 100){
+ rc1.parentNode.removeChild(rc1);
+ rc0.width = 100 + "%";
+ rc0.firstChild.style.width = this.duration * this.ganttChart.pixelsPerWorkHour + "px";
+ }
+ }else if(((percentage == 0) || (percentage == 100)) && ((this.percentage == 0) || (this.percentage == 100))){
+ if((percentage == 0) && (this.percentage == 100)){
+ dojo.removeClass(rc0.firstChild, "ganttImageProgressFilled");
+ dojo.addClass(rc0.firstChild, "ganttImageProgressBg");
+ }else if((percentage == 100) && (this.percentage == 0)){
+ dojo.removeClass(rc0.firstChild, "ganttImageProgressBg");
+ dojo.addClass(rc0.firstChild, "ganttImageProgressFilled");
+ }
+ }else if(((percentage > 0) || (percentage < 100)) && ((this.percentage == 0) || (this.percentage == 100))){
+ rc0.parentNode.removeChild(rc0);
+ var cellprojectItem = dojo.create("td", {
+ width: percentage + "%"
+ }, prow);
+ cellprojectItem.style.lineHeight = "1px";
+ var imageProgress = dojo.create("div", {
+ className: "ganttImageProgressFilled"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: (percentage * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ cellprojectItem = dojo.create("td", {
+ width: (100 - percentage) + "%"
+ }, prow);
+ cellprojectItem.style.lineHeight = "1px";
+ imageProgress = dojo.create("div", {
+ className: "ganttImageProgressBg"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: ((100 - percentage) * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }else if(this.percentage == -1){
+ if(percentage == 100){
+ dojo.removeClass(rc0.firstChild, "ganttImageProgressBg");
+ dojo.addClass(rc0.firstChild, "ganttImageProgressFilled");
+ }else if(percentage < 100 && percentage > 0){
+ rc0.parentNode.removeChild(rc0);
+ var cellprojectItem = dojo.create("td", {
+ width: percentage + "%"
+ }, prow);
+ cellprojectItem.style.lineHeight = "1px";
+ imageProgress = dojo.create("div", {
+ className: "ganttImageProgressFilled"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: (percentage * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ cellprojectItem = dojo.create("td", {
+ width: (100 - percentage) + "%"
+ }, prow);
+ cellprojectItem.style.lineHeight = "1px";
+ imageProgress = dojo.create("div", {
+ className: "ganttImageProgressBg"
+ }, cellprojectItem);
+ dojo.style(imageProgress, {
+ width: ((100 - percentage) * this.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ }
+ this.percentage = percentage;
+ this.descrProject.innerHTML = this.getDescStr();
+ return true;
+ },
+ deleteChildTask: function(task){
+ if(task){
+ var tItem0 = task.cTaskItem[0], tNameItem0 = task.cTaskNameItem[0],
+ tItem1 = task.cTaskItem[1], tNameItem1 = task.cTaskNameItem[1],
+ tItem2 = task.cTaskItem[2], tNameItem2 = task.cTaskNameItem[2];
+ if(tItem0.style.display == "none"){
+ this.ganttChart.openTree(task.parentTask);
+ }
+ //delete of connecting lines
+ if(task.childPredTask.length > 0){
+ for(var i = 0; i < task.childPredTask.length; i++){
+ var cpTask = task.childPredTask[i];
+ for(var t = 0; t < cpTask.cTaskItem[1].length; t++){
+ cpTask.cTaskItem[1][t].parentNode.removeChild(cpTask.cTaskItem[1][t]);
+ }
+ cpTask.cTaskItem[1] = [];
+ cpTask.predTask = null;
+ }
+ }
+ //delete child task
+ if(task.childTask.length > 0){
+ while(task.childTask.length > 0){
+ this.deleteChildTask(task.childTask[0]);
+ }
+ }
+ //shift tasks
+ var rowHeight = this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ if(tItem0.style.display != "none"){
+ task.shiftCurrentTasks(task, -rowHeight);
+ }
+ //delete object task
+ this.project.deleteTask(task.taskItem.id);
+ //delete div and connecting lines from contentData
+ if(tItem0){
+ tItem0.parentNode.removeChild(tItem0);
+ }
+ task.descrTask.parentNode.removeChild(task.descrTask);
+ if(tItem1.length > 0){
+ for(var j = 0; j < tItem1.length; j++){
+ tItem1[j].parentNode.removeChild(tItem1[j]);
+ }
+ }
+ //delete div and connecting lines from panelName
+ if(tNameItem0){
+ tNameItem0.parentNode.removeChild(tNameItem0);
+ }
+ if(task.cTaskNameItem[1]){
+ for(var j = 0; j < tNameItem1.length; j++){
+ tNameItem1[j].parentNode.removeChild(tNameItem1[j]);
+ }
+ }
+ if(tNameItem2 && tNameItem2.parentNode){
+ tNameItem2.parentNode.removeChild(tNameItem2);
+ }
+ if(task.taskIdentifier){
+ task.taskIdentifier.parentNode.removeChild(task.taskIdentifier);
+ task.taskIdentifier = null;
+ }
+ //delete object task
+ if(task.parentTask){
+ if(task.previousChildTask){
+ if(task.nextChildTask){
+ task.previousChildTask.nextChildTask = task.nextChildTask;
+ }else{
+ task.previousChildTask.nextChildTask = null;
+ }
+ }
+ var parentTask = task.parentTask;
+ for(var i = 0; i < parentTask.childTask.length; i++){
+ if(parentTask.childTask[i].taskItem.id == task.taskItem.id){
+ parentTask.childTask[i] = null;
+ parentTask.childTask.splice(i, 1);
+ break;
+ }
+ }
+ if(parentTask.childTask.length == 0){
+ if(parentTask.cTaskNameItem[2]){
+ parentTask.cTaskNameItem[2].parentNode.removeChild(parentTask.cTaskNameItem[2]);
+ parentTask.cTaskNameItem[2] = null;
+ }
+ }
+ }else{
+ if(task.previousParentTask){
+ if(task.nextParentTask){
+ task.previousParentTask.nextParentTask = task.nextParentTask;
+ }else{
+ task.previousParentTask.nextParentTask = null;
+ }
+ }
+ var project = task.project;
+ for(var i = 0; i < project.arrTasks.length; i++){
+ if(project.arrTasks[i].taskItem.id == task.taskItem.id){
+ project.arrTasks.splice(i, 1);
+ }
+ }
+ }
+ if(task.predTask){
+ var predTask = task.predTask;
+ for(var i = 0; i < predTask.childPredTask.length; i++){
+ if(predTask.childPredTask[i].taskItem.id == task.taskItem.id){
+ predTask.childPredTask[i] = null;
+ predTask.childPredTask.splice(i, 1);
+ }
+ }
+ }
+ if(task.project.arrTasks.length != 0){
+ task.project.shiftProjectItem();
+ }else{
+ task.project.projectItem[0].style.display = "none";
+ this.hideDescrProject();
+ }
+ this.ganttChart.contentDataHeight -= this.ganttChart.heightTaskItemExtra + this.ganttChart.heightTaskItem;
+ }
+ },
+
+ insertTask: function(id, name, startTime, duration, percentage, previousTaskId, taskOwner, parentTaskId){
+ var task = null;
+ var _task = null;
+ if(this.project.getTaskById(id)){
+ return false;
+ }
+ if((!duration) || (duration < this.ganttChart.minWorkLength)){
+ duration = this.ganttChart.minWorkLength;
+ }
+ if((!name) || (name == "")){
+ name = id;
+ }
+ if((!percentage) || (percentage == "")){
+ percentage = 0;
+
+ }else{
+ percentage = parseInt(percentage);
+ if(percentage < 0 || percentage > 100){
+ return false;
+ }
+ }
+ var sortRequired = false;
+ if((parentTaskId) && (parentTaskId != "")){
+ var parentTask = this.project.getTaskById(parentTaskId);
+ if(!parentTask){
+ return false;
+ }
+ startTime = startTime || parentTask.startTime;
+ if(startTime < parentTask.startTime){
+ return false;
+ }
+ task = new dojox.gantt.GanttTaskItem({
+ id: id,
+ name: name,
+ startTime: startTime,
+ duration: duration,
+ percentage: percentage,
+ previousTaskId: previousTaskId,
+ taskOwner: taskOwner
+ });
+ if(!this.ganttChart.checkPosParentTask(parentTask, task)){
+ return false;
+ }
+ task.parentTask = parentTask;
+ var _parentTask = this.getTaskById(parentTask.id);
+ var isHide = false;
+ if(_parentTask.cTaskItem[0].style.display == "none"){
+ isHide = true;
+ }else if(_parentTask.cTaskNameItem[2]){
+ if(!_parentTask.isExpanded){
+ isHide = true;
+ }
+ }
+ if(isHide){
+ if(_parentTask.childTask.length == 0){
+ this.ganttChart.openTree(_parentTask.parentTask);
+ }else{
+ this.ganttChart.openTree(_parentTask);
+ }
+ }
+ if(previousTaskId != ""){
+ var predTask = this.project.getTaskById(previousTaskId);
+ if(!predTask){
+ return false;
+ }
+ if(predTask.parentTask){
+ if(predTask.parentTask.id != task.parentTask.id){
+ return false;
+ }
+ }else{
+ return false;
+ }
+ if(!this.ganttChart.checkPosPreviousTask(predTask, task)){
+ this.ganttChart.correctPosPreviousTask(predTask, task);
+ }
+ task.previousTask = predTask;
+ }
+ var isAdd = false;
+ if(sortRequired) for(var i = 0; i < parentTask.cldTasks.length; i++){
+ if(task.startTime < parentTask.cldTasks[i].startTime){
+ parentTask.cldTasks.splice(i, 0, task);
+ if(i > 0){
+ parentTask.cldTasks[i - 1].nextChildTask = parentTask.cldTasks[i];
+ parentTask.cldTasks[i].previousChildTask = parentTask.cldTasks[i - 1];
+ }
+ if(parentTask.cldTasks[i + 1]){
+ parentTask.cldTasks[i + 1].previousChildTask = parentTask.cldTasks[i];
+ parentTask.cldTasks[i].nextChildTask = parentTask.cldTasks[i + 1];
+ }
+ isAdd = true;
+ break;
+ }
+ }
+ if(!isAdd){
+ if(parentTask.cldTasks.length > 0){
+ parentTask.cldTasks[parentTask.cldTasks.length - 1].nextChildTask = task;
+ task.previousChildTask = parentTask.cldTasks[parentTask.cldTasks.length - 1];
+ }
+ parentTask.cldTasks.push(task);
+ }
+ if(parentTask.cldTasks.length == 1){
+ var treeImg = _parentTask.createTreeImg();
+ _parentTask.cTaskNameItem[2] = treeImg;
+ }
+ _task = new dojox.gantt.GanttTaskControl(task, this, this.ganttChart);
+ _task.create();
+ if(task.nextChildTask) _task.nextChildTask = _task.project.getTaskById(task.nextChildTask.id);
+ _task.adjustPanelTime();
+ var rowHeight = this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ _task.shiftCurrentTasks(_task, rowHeight);//23
+ }else{
+ startTime = startTime || this.project.startDate;
+ task = new dojox.gantt.GanttTaskItem({
+ id: id,
+ name: name,
+ startTime: startTime,
+ duration: duration,
+ percentage: percentage,
+ previousTaskId: previousTaskId,
+ taskOwner: taskOwner
+ });
+ if(task.startTime <= this.ganttChart.startDate){
+ return false;
+ }
+ if(previousTaskId != ""){
+ var predTask = this.project.getTaskById(previousTaskId);
+ if(!predTask){
+ return false;
+ }
+ if(!this.ganttChart.checkPosPreviousTask(predTask, task)){
+ this.ganttChart.correctPosPreviousTask(predTask, task);
+ }
+ if(predTask.parentTask){
+ return false;
+ }
+ task.previousTask = predTask;
+ }
+ var isAdd = false;
+ if(sortRequired){
+ for(var i = 0; i < this.project.parentTasks.length; i++){
+ var ppTask = this.project.parentTasks[i];
+ if(startTime < ppTask.startTime){
+ this.project.parentTasks.splice(i, 0, task);
+ if(i > 0){
+ this.project.parentTasks[i - 1].nextParentTask = task;
+ task.previousParentTask = this.project.parentTasks[i - 1];
+ }
+ if(this.project.parentTasks[i + 1]){
+ this.project.parentTasks[i + 1].previousParentTask = task;
+ task.nextParentTask = this.project.parentTasks[i + 1];
+ }
+ isAdd = true;
+ break;
+ }
+ }
+ }
+ if(!isAdd){
+ if(this.project.parentTasks.length > 0){
+ this.project.parentTasks[this.project.parentTasks.length - 1].nextParentTask = task;
+ task.previousParentTask = this.project.parentTasks[this.project.parentTasks.length - 1];
+ }
+ this.project.parentTasks.push(task);
+ }
+ _task = new dojox.gantt.GanttTaskControl(task, this, this.ganttChart);
+ _task.create();
+ if(task.nextParentTask) _task.nextParentTask = _task.project.getTaskById(task.nextParentTask.id);
+ _task.adjustPanelTime();
+ this.arrTasks.push(_task);
+ var rowHeight = this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ _task.shiftCurrentTasks(_task, rowHeight);
+ this.projectItem[0].style.display = "inline";
+ this.setPercentCompleted(this.getPercentCompleted());
+ this.shiftProjectItem();
+ this.showDescrProject();
+ }
+ this.ganttChart.checkHeighPanelTasks();
+ this.ganttChart.checkPosition();
+ return _task;
+ },
+ shiftNextProject: function(project, height){
+ if(project.nextProject){
+ project.nextProject.shiftProject(height);
+ this.shiftNextProject(project.nextProject, height);
+ }
+ },
+ shiftProject: function(height){
+ this.posY = this.posY + height;
+ this.projectItem[0].style.top = parseInt(this.projectItem[0].style.top) + height + "px";
+ this.descrProject.style.top = parseInt(this.descrProject.style.top) + height + "px";
+ this.projectNameItem.style.top = parseInt(this.projectNameItem.style.top) + height + "px";
+ if(this.arrTasks.length > 0){
+ this.shiftNextParentTask(this.arrTasks[0], height);
+ }
+ },
+ shiftTask: function(task, height){
+ task.posY = task.posY + height;
+ var tNameItem0 = task.cTaskNameItem[0], tNameItem1 = task.cTaskNameItem[1], tNameItem2 = task.cTaskNameItem[2],
+ tItem0 = task.cTaskItem[0], tItem1 = task.cTaskItem[1], tItem2 = task.cTaskItem[2];
+ tNameItem0.style.top = parseInt(tNameItem0.style.top) + height + "px";
+ if(tNameItem2){
+ tNameItem2.style.top = parseInt(tNameItem2.style.top) + height + "px";
+ }
+ if(task.parentTask){
+ tNameItem1[0].style.top = parseInt(tNameItem1[0].style.top) + height + "px";
+ tNameItem1[1].style.top = parseInt(tNameItem1[1].style.top) + height + "px";
+ }
+ task.cTaskItem[0].style.top = parseInt(task.cTaskItem[0].style.top) + height + "px";
+ task.descrTask.style.top = parseInt(task.descrTask.style.top) + height + "px";
+ if(tItem1[0]){
+ tItem1[0].style.top = parseInt(tItem1[0].style.top) + height + "px";
+ tItem1[1].style.top = parseInt(tItem1[1].style.top) + height + "px";
+ tItem1[2].style.top = parseInt(tItem1[2].style.top) + height + "px";
+ }
+ },
+ shiftNextParentTask: function(task, height){
+ this.shiftTask(task, height);
+ this.shiftChildTasks(task, height);
+ if(task.nextParentTask){
+ this.shiftNextParentTask(task.nextParentTask, height);
+ }
+ },
+ shiftChildTasks: function(task, height){
+ dojo.forEach(task.childTask, function(cTask){
+ this.shiftTask(cTask, height);
+ if(cTask.childTask.length > 0){
+ this.shiftChildTasks(cTask, height);
+ }
+ }, this);
+ }
+});
+
+
+dojo.declare("dojox.gantt.GanttProjectItem", null, {
+ constructor: function(configuration){
+ //id is required
+ this.id = configuration.id;
+ this.name = configuration.name || this.id;
+ this.startDate = configuration.startDate || new Date();
+ this.parentTasks = [];
+ },
+ getTaskById: function(id){
+ for(var i = 0; i < this.parentTasks.length; i++){
+ var pTask = this.parentTasks[i];
+ var task = this.getTaskByIdInTree(pTask, id);
+ if(task){
+ return task;
+ }
+ }
+ return null;
+ },
+ getTaskByIdInTree: function(parentTask, id){
+ if(parentTask.id == id){
+ return parentTask;
+ }else{
+ for(var i = 0; i < parentTask.cldTasks.length; i++){
+ var pcTask = parentTask.cldTasks[i];
+ if(pcTask.id == id){
+ return pcTask;
+ }
+ if(pcTask.cldTasks.length > 0){
+ if(pcTask.cldTasks.length > 0){
+ var cTask = this.getTaskByIdInTree(pcTask, id);
+ if(cTask){
+ return cTask;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ },
+ addTask: function(task){
+ this.parentTasks.push(task);
+ task.setProject(this);
+ },
+ deleteTask: function(id){
+ var task = this.getTaskById(id);
+ if(!task){return;}
+ if(!task.parentTask){
+ for(var i = 0; i < this.parentTasks.length; i++){
+ var pTask = this.parentTasks[i];
+ if(pTask.id == id){
+ if(pTask.nextParentTask){
+ if(pTask.previousParentTask){
+ pTask.previousParentTask.nextParentTask = pTask.nextParentTask;
+ pTask.nextParentTask.previousParentTask = pTask.previousParentTask;
+ }else{
+ pTask.nextParentTask.previousParentTask = null;
+ }
+ }else{
+ if(pTask.previousParentTask){
+ pTask.previousParentTask.nextParentTask = null;
+ }
+ }
+ pTask = null;
+ this.parentTasks.splice(i, 1);
+ break;
+ }
+ }
+ }else{
+ var parentTask = task.parentTask;
+ for(var i = 0; i < parentTask.cldTasks.length; i++){
+ var pcTask = parentTask.cldTasks[i];
+ if(pcTask.id == id){
+ if(pcTask.nextChildTask){
+ if(pcTask.previousChildTask){
+ pcTask.previousChildTask.nextChildTask = pcTask.nextChildTask;
+ pcTask.nextChildTask.previousChildTask = pcTask.previousChildTask;
+ }else{
+ pcTask.nextChildTask.previousChildTask = null;
+ }
+ }else{
+ if(pcTask.previousChildTask){
+ pcTask.previousChildTask.nextChildTask = null;
+ }
+ }
+ pcTask = null;
+ parentTask.cldTasks.splice(i, 1);
+ break;
+ }
+ }
+ }
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/gantt/GanttResourceItem.js b/js/dojo-1.6/dojox/gantt/GanttResourceItem.js new file mode 100644 index 0000000..64ab102 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/GanttResourceItem.js @@ -0,0 +1,467 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.gantt.GanttResourceItem"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.gantt.GanttResourceItem"] = true;
+dojo.provide("dojox.gantt.GanttResourceItem");
+
+dojo.require("dojo.date.locale");
+
+dojo.declare("dojox.gantt.GanttResourceItem", null, {
+ constructor: function(ganttchart){
+ this.ganttChart = ganttchart;
+ 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(){
+ dojo.destroy(this.content.firstChild);
+ },
+ buildResource: function(){
+ var resourceInfo = {};
+ dojo.forEach(this.ganttChart.arrProjects, function(project){
+ dojo.forEach(project.arrTasks, function(task){
+ task.buildResourceInfo(resourceInfo);
+ }, this);
+ }, this);
+ return resourceInfo;
+ },
+ buildOwnerTimeConsume: function(){
+ var ownerTimeConsume = {};
+ for(var owner in this.resourceInfo){
+ var tasks = this.resourceInfo[owner];
+ //combine time zone (startTime - this.startDate) / (60 * 60 * 1000) * this.pixelsPerHour;
+ var timeZoom = {};
+ for(var i = 0; i < tasks.length; i++){
+ var task = tasks[i];
+ var startTime = task.taskItem.startTime.getTime(), dur = task.taskItem.duration * 24 * 60 * 60 * 1000 / this.ganttChart.hsPerDay;
+ timeZoom.min = timeZoom.min ? Math.min(timeZoom.min, startTime) : startTime;
+ timeZoom.max = timeZoom.max ? Math.max(timeZoom.max, (startTime + dur)) : (startTime + dur);
+ }
+ timeZoom.dur = (timeZoom.max - timeZoom.min) * this.ganttChart.hsPerDay / (24 * 60 * 60 * 1000);
+ timeZoom.min = new Date(timeZoom.min);
+ timeZoom.max = new Date(timeZoom.max);
+ ownerTimeConsume[owner] = timeZoom;
+ }
+ return ownerTimeConsume;
+ },
+ refresh: function(){
+ this.ownerTimeConsume = this.buildOwnerTimeConsume();
+ //resize outer div
+ this.contentData.firstChild.style.width = Math.max(1200, this.ganttChart.pixelsPerDay * this.ganttChart.totalDays) + "px";
+ for(var owner in this.resourceInfo){
+ this.refreshOwnerEntry(owner);
+ }
+ },
+ reConstruct: function(){
+ this.clearAll();
+ this.resourceInfo = this.buildResource();
+ this.ownerTimeConsume = this.buildOwnerTimeConsume();
+ this.tableControl = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0",
+ className: "ganttResourceTableControl"
+ });
+ var newRowTblControl = this.tableControl.insertRow(this.tableControl.rows.length);
+ //Add to content Table
+ this.contentHeight = this.content.offsetHeight;
+ this.contentWidth = this.content.offsetWidth;
+ this.content.appendChild(this.tableControl);
+ //Creation panel contentData
+ this.contentData = dojo.create("div", {className: "ganttResourceContentDataContainer"});
+ this.contentData.appendChild(this.createPanelOwners());
+ dojo.style(this.contentData, "height", (this.contentHeight - this.ganttChart.panelTimeHeight) + "px");
+ //Creation panel of names
+ var newCellTblControl = dojo.create("td", {
+ vAlign: "top"
+ });
+ this.panelNames = dojo.create("div", {className: "ganttResourcePanelNames"});
+ this.panelNames.appendChild(this.createPanelNamesOwners());
+ newCellTblControl.appendChild(this.panelNames);
+ newRowTblControl.appendChild(newCellTblControl);
+ //add to control contentData and contentDataTime
+ newCellTblControl = dojo.create("td", {
+ vAlign: "top"
+ });
+ var divCell = dojo.create("div", {className: "ganttResourceDivCell"});
+ divCell.appendChild(this.contentData);
+ newCellTblControl.appendChild(divCell);
+ newRowTblControl.appendChild(newCellTblControl);
+ //Show panel of names
+ dojo.style(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 _this = this;
+ this.contentData.onscroll = function(){
+ if(_this.panelNames){
+ _this.panelNames.scrollTop = this.scrollTop;
+ }
+ }
+ this.contentData.scrollLeft = this.ganttChart.contentData.scrollLeft;
+ for(var owner in this.resourceInfo){
+ this.createOwnerEntry(owner);
+ }
+ this.postAdjustment();
+ },
+ create: function(){
+ var resourceHeader = dojo.create("div", {
+ innerHTML: "Resource Chart:",
+ className: "ganttResourceHeader"
+ }, this.ganttChart.content, "after");
+ dojo.style(resourceHeader, "width", this.ganttChart.contentWidth + "px");
+ var content = dojo.create("div", {className: "ganttResourceContent"}, resourceHeader, "after");
+ dojo.style(content, {
+ width: this.ganttChart.contentWidth + "px",
+ height: (this.ganttChart.resourceChartHeight || (this.ganttChart.contentHeight * 0.8)) + "px"
+ });
+ this.content = content || this.content;
+ //create Table
+ this.reConstruct();
+ },
+ postAdjustment: function(){
+ //contentData height
+ this.contentData.firstChild.style.height = (this.ownerItem.length * 23) + "px";
+ this.panelNames.firstChild.style.height = (this.ownerItem.length * 23) + "px";
+ },
+
+ refreshOwnerEntry: function(owner){
+ this.refreshOwnerItem(owner);
+ dojo.forEach(this.resourceInfo[owner], function(task, i){
+ var item = this.ownerTaskNodeMapping[owner].tasks[i][0];
+ this.refreshDetailedTaskEntry(owner, item, task);
+ }, this);
+ },
+ createOwnerEntry: function(owner){
+ var containerOwner = this.contentData.firstChild;
+ var previousOwner = this.ownerItem[this.ownerItem.length - 1];
+ this.ownerTaskNodeMapping[owner] = {};
+ this.ownerTaskNodeMapping[owner][owner] = [];
+ //create nodes
+ var pos = dojo.position(containerOwner);
+ //creation arrTasks
+ var posY = (previousOwner ? parseInt(previousOwner.style.top) : (6 - 23)) + this.ganttChart.heightTaskItem + 11;
+ //creation task item
+ var oItem = this.createOwnerItem(owner, posY);
+ containerOwner.appendChild(oItem);
+ this.ownerItem.push(oItem);
+ this.ownerTaskNodeMapping[owner][owner].push(oItem);
+ if(this.panelNames){
+ var oNameItem = this.createOwnerNameItem(owner, posY);
+ this.panelNames.firstChild.appendChild(oNameItem);
+ this.ownerNameItem.push(oNameItem);
+ this.ownerTaskNodeMapping[owner][owner].push(oNameItem);
+ }
+ var currentOwnerNode = this.ownerItem[this.ownerNameItem.length - 1];
+ var currentOwnerNameNode = this.ownerNameItem[this.ownerNameItem.length - 1];
+ //adjust nodes
+ if(this.panelNames){
+ this.checkWidthTaskNameItem(currentOwnerNameNode);
+ var treeImg = this.createTreeImg(currentOwnerNameNode);
+ this.panelNames.firstChild.appendChild(treeImg);
+ this.ownerTaskNodeMapping[owner][owner].push(treeImg);
+ }
+ this.ownerTaskNodeMapping[owner]["taskCount"] = this.resourceInfo[owner].length;
+ this.ownerTaskNodeMapping[owner]["isOpen"] = false;
+ this.ownerTaskNodeMapping[owner]["tasks"] = [];
+ dojo.forEach(this.resourceInfo[owner], function(task){
+ this.ownerTaskNodeMapping[owner]["tasks"].push(this.createDetailedTaskEntry(owner, currentOwnerNameNode, task));
+ }, this);
+ return this;
+ },
+ createOwnerNameItem: function(owner, posY){
+ var ownerName = dojo.create("div", {
+ id: owner,
+ title: owner,
+ innerHTML: owner,
+ className: "ganttOwnerNameItem"
+ });
+ dojo.style(ownerName, "top", posY + "px");
+ return ownerName;
+ },
+ refreshOwnerItem: function(owner){
+ var item = this.ownerTaskNodeMapping[owner][owner][0];
+ var start = this.ownerTimeConsume[owner].min, end = this.ownerTimeConsume[owner].max, dur = this.ownerTimeConsume[owner].dur;
+ var posX = this.ganttChart.getPosOnDate(start); // should be task start date
+ item.style.left = posX + "px";
+ item.style.width = dur * this.ganttChart.pixelsPerWorkHour + "px";
+ dojo.forEach(this.resourceInfo[owner], function(task, i){
+ var tposX = this.ganttChart.getPosOnDate(task.taskItem.startTime); // should be task start date
+ dojo.style(item.childNodes[i], {
+ left: (tposX - posX) + "px",
+ width: task.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px"
+ });
+ }, this);
+ },
+ createOwnerItem: function(owner, posY){
+ var start = this.ownerTimeConsume[owner].min, end = this.ownerTimeConsume[owner].max, dur = this.ownerTimeConsume[owner].dur;
+ var posX = this.ganttChart.getPosOnDate(start); // should be task start date
+ var ownerControl = dojo.create("div", {
+ id: owner,
+ owner: true,
+ className: "ganttOwnerBar"
+ });
+ dojo.style(ownerControl, {
+ left: posX + "px",
+ top: posY + "px",
+ width: dur * this.ganttChart.pixelsPerWorkHour + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ dojo.forEach(this.resourceInfo[owner], function(task){
+ var ownerTaskItem = dojo.create("div", {
+ id: owner,
+ className: "ganttOwnerTaskBar"
+ }, ownerControl);
+ var tposX = this.ganttChart.getPosOnDate(task.taskItem.startTime); // should be task start date
+ dojo.style(ownerTaskItem, {
+ left: (tposX - posX) + "px",
+ width: task.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px", // should be task duration
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }, this);
+ return ownerControl;
+ },
+ refreshDetailedTaskEntry: function(owner, item, task){
+ this.refreshTaskItem(item, task);
+ },
+ createDetailedTaskEntry: function(owner, parentNode, task){
+ var taskItems = [];
+ var containerTasks = this.contentData.firstChild;
+ var posY = parseInt(parentNode.style.top);
+
+ //creation task item
+ var taskItem = this.createTaskItem(task, posY);
+ taskItem.style.display = "none";
+ containerTasks.appendChild(taskItem);
+ this.ownerItem.push(taskItem);
+ taskItems.push(taskItem);
+ if(this.panelNames){
+ var taskNameItem = this.createTaskNameItem(task.taskItem.name, posY);
+ this.panelNames.firstChild.appendChild(taskNameItem);
+ taskNameItem.style.display = "none";
+ this.ownerNameItem.push(taskNameItem);
+ taskItems.push(taskNameItem);
+ }
+ if(this.panelNames){
+ this.ownerNameItem[this.ownerNameItem.length - 1].style.left = dojo.style(parentNode, "left") + 15 + "px";
+ var arrConnectingLinesNames = this.createConnectingLinesPN(parentNode, this.ownerNameItem[this.ownerNameItem.length - 1]);
+ dojo.forEach(arrConnectingLinesNames, function(lineName){
+ lineName.style.display = "none";
+ }, this);
+ taskItems.push({
+ "v": arrConnectingLinesNames[0],
+ "h": arrConnectingLinesNames[1]
+ });
+ this.checkWidthTaskNameItem(this.ownerNameItem[this.ownerNameItem.length - 1]);
+ }
+ return taskItems;
+ },
+ createTaskNameItem: function(owner, posY){
+ var taskNameItem = dojo.create("div", {
+ id: owner,
+ className: "ganttTaskNameItem",
+ title: owner,
+ innerHTML: owner
+ });
+ dojo.style(taskNameItem, "top", posY + "px");
+ return taskNameItem;
+ },
+ refreshTaskItem: function(item, task){
+ var posX = this.ganttChart.getPosOnDate(task.taskItem.startTime); // should be task start date
+ dojo.style(item, {
+ left: posX + "px",
+ width: task.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px"
+ });
+ },
+ createTaskItem: function(task, posY){
+ var posX = this.ganttChart.getPosOnDate(task.taskItem.startTime); // should be task start date
+ var itemControl = dojo.create("div", {
+ id: task.taskItem.name,
+ className: "ganttTaskBar"
+ });
+ dojo.style(itemControl, {
+ left: posX + "px",
+ top: posY + "px",
+ width: task.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ return itemControl;
+ },
+ createConnectingLinesPN: function(parentNode, currentNode){
+ var arrConnectingLinesNames = [];
+ var lineVerticalLeft = dojo.create("div", {
+ innerHTML: " ",
+ className: "ganttResourceLineVerticalLeft"
+ }, this.panelNames.firstChild);
+ lineVerticalLeft.cNode = currentNode;
+ lineVerticalLeft.pNode = parentNode;
+ var LineHorizontalLeft = dojo.create("div", {
+ noShade: true,
+ color: "#000000",
+ className: "ganttResourceLineHorizontalLeft"
+ }, this.panelNames.firstChild);
+ LineHorizontalLeft.cNode = currentNode;
+ LineHorizontalLeft.pNode = parentNode;
+ this.panelNames.firstChild.appendChild(LineHorizontalLeft);
+ arrConnectingLinesNames.push(lineVerticalLeft);
+ arrConnectingLinesNames.push(LineHorizontalLeft);
+ return arrConnectingLinesNames;
+ },
+ createTreeImg: function(ownerNameItem){
+ var treeImg = dojo.create("div", {
+ id: ownerNameItem.id,
+ className: "ganttImageTreeExpand"
+ });
+ dojo.attr(treeImg, "tabIndex", 0);
+ var currentItem = this.ownerTaskNodeMapping[ownerNameItem.id];
+ dojo.forEach(["onclick", "onkeydown"], function(e){
+ this.ganttChart._events.push(
+ dojo.connect(treeImg, e, this, function(evt){
+ if(e == "onkeydown" && evt.keyCode != dojo.keys.ENTER){ return; }
+ if(currentItem.isOpen){
+ dojo.removeClass(treeImg, "ganttImageTreeCollapse");
+ dojo.addClass(treeImg, "ganttImageTreeExpand");
+ currentItem.isOpen = false;
+ //collapse
+ var reachTarget = false;
+ for(var owner in this.ownerTaskNodeMapping){
+ var ownerItem = this.ownerTaskNodeMapping[owner];
+ if(reachTarget){
+ dojo.forEach(ownerItem[owner], function(tItem){
+ dojo.style(tItem, "top", dojo.style(tItem, "top") - currentItem.taskCount * 23 + "px");
+ }, this);
+ dojo.forEach(ownerItem.tasks, function(tItems){
+ dojo.forEach(tItems, function(tItem){
+ var item = !tItem.v && !tItem.h ? [tItem] : [tItem.v, tItem.h];
+ dojo.forEach(item, function(t){
+ dojo.style(t, "top", dojo.style(t, "top") - currentItem.taskCount * 23 + "px");
+ }, this);
+ }, this);
+ }, this);
+ }else{
+ if(owner == ownerNameItem.id){
+ reachTarget = true;
+ dojo.forEach(ownerItem.tasks, function(tItems, i){
+ dojo.forEach(tItems, function(tItem){
+ this.styleOwnerItem(tItem, ownerItem[owner][0], "none", 0);
+ }, this);
+ }, this);
+ }
+ }
+ }
+ }else{
+ dojo.removeClass(treeImg, "ganttImageTreeExpand");
+ dojo.addClass(treeImg, "ganttImageTreeCollapse");
+ currentItem.isOpen = true;
+ //expand
+ var reachTarget = false;
+ for(var owner in this.ownerTaskNodeMapping){
+ var ownerItem = this.ownerTaskNodeMapping[owner];
+ if(reachTarget){
+ dojo.forEach(ownerItem[owner], function(tItem){
+ dojo.style(tItem, "top", dojo.style(tItem, "top") + currentItem.taskCount * 23 + "px");
+ }, this);
+ dojo.forEach(ownerItem.tasks, function(tItems){
+ dojo.forEach(tItems, function(tItem){
+ var item = !tItem.v && !tItem.h ? [tItem] : [tItem.v, tItem.h];
+ dojo.forEach(item, function(t){
+ dojo.style(t, "top", dojo.style(t, "top") + currentItem.taskCount * 23 + "px");
+ }, this);
+ }, this);
+ }, this);
+ }else{
+ if(owner == ownerNameItem.id){
+ reachTarget = true;
+ dojo.forEach(ownerItem.tasks, function(tItems, i){
+ dojo.forEach(tItems, function(tItem){
+ this.styleOwnerItem(tItem, ownerItem[owner][0], "inline", (i + 1) * 23);
+ }, this);
+ }, this);
+ }
+ }
+ }
+ }
+ })
+ );
+ }, this);
+ dojo.addClass(treeImg, "ganttResourceTreeImage");
+ dojo.style(treeImg, {
+ left: (dojo.style(ownerNameItem, "left") - 12) + "px",
+ top: (dojo.style(ownerNameItem, "top") + 3) + "px"
+ });
+ return treeImg;
+ },
+ styleOwnerItem: function(tItem, owner, displayType, topOffset){
+ if(tItem.v || tItem.h){
+ dojo.style(tItem.v, {
+ height: Math.max(1, (tItem.v.cNode.offsetTop - tItem.v.pNode.offsetTop)) + "px",
+ top: (tItem.v.pNode.offsetTop + 5) + "px",
+ left: (tItem.v.pNode.offsetLeft - 9) + "px",
+ display: displayType
+ });
+ dojo.style(tItem.h, {
+ width: Math.max(1, (tItem.h.cNode.offsetLeft - tItem.h.pNode.offsetLeft + 4)) + "px",
+ top: (tItem.h.cNode.offsetTop + 5) + "px",
+ left: (tItem.h.pNode.offsetLeft - 9) + "px",
+ display: displayType
+ });
+ }else{
+ dojo.style(tItem, {
+ display: displayType,
+ top: parseInt(owner.style.top) + topOffset + "px"
+ });
+ }
+ },
+ checkWidthTaskNameItem: function(taskNameItem){
+ if(taskNameItem && taskNameItem.offsetWidth + taskNameItem.offsetLeft > this.ganttChart.maxWidthPanelNames){
+ var width = taskNameItem.offsetWidth + taskNameItem.offsetLeft - this.ganttChart.maxWidthPanelNames;
+ var countChar = Math.round(width / (taskNameItem.offsetWidth / taskNameItem.firstChild.length));
+ var tName = taskNameItem.id.substring(0, taskNameItem.firstChild.length - countChar - 3);
+ tName += "...";
+ taskNameItem.innerHTML = tName;
+ }
+ },
+ createPanelOwners: function(){
+ var panelOwner = dojo.create("div", {
+ className: "ganttOwnerPanel"
+ });
+ dojo.style(panelOwner, {
+ height: (this.contentHeight - this.ganttChart.panelTimeHeight - this.ganttChart.scrollBarWidth) + "px"
+ });
+ return panelOwner;
+ },
+ createPanelNamesOwners: function(){
+ var panelNameOwner = dojo.create("div", {
+ innerHTML: " ",
+ className: "ganttResourcePanelNamesOwners"
+ });
+ dojo.style(panelNameOwner, {
+ height: (this.contentHeight - this.ganttChart.panelTimeHeight - this.ganttChart.scrollBarWidth) + "px",
+ width: this.ganttChart.maxWidthPanelNames + "px"
+ });
+ return panelNameOwner;
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/gantt/GanttResourceItem.xd.js b/js/dojo-1.6/dojox/gantt/GanttResourceItem.xd.js new file mode 100644 index 0000000..9e3b368 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/GanttResourceItem.xd.js @@ -0,0 +1,472 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.gantt.GanttResourceItem"],
+["require", "dojo.date.locale"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.gantt.GanttResourceItem"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.gantt.GanttResourceItem"] = true;
+dojo.provide("dojox.gantt.GanttResourceItem");
+
+dojo.require("dojo.date.locale");
+
+dojo.declare("dojox.gantt.GanttResourceItem", null, {
+ constructor: function(ganttchart){
+ this.ganttChart = ganttchart;
+ 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(){
+ dojo.destroy(this.content.firstChild);
+ },
+ buildResource: function(){
+ var resourceInfo = {};
+ dojo.forEach(this.ganttChart.arrProjects, function(project){
+ dojo.forEach(project.arrTasks, function(task){
+ task.buildResourceInfo(resourceInfo);
+ }, this);
+ }, this);
+ return resourceInfo;
+ },
+ buildOwnerTimeConsume: function(){
+ var ownerTimeConsume = {};
+ for(var owner in this.resourceInfo){
+ var tasks = this.resourceInfo[owner];
+ //combine time zone (startTime - this.startDate) / (60 * 60 * 1000) * this.pixelsPerHour;
+ var timeZoom = {};
+ for(var i = 0; i < tasks.length; i++){
+ var task = tasks[i];
+ var startTime = task.taskItem.startTime.getTime(), dur = task.taskItem.duration * 24 * 60 * 60 * 1000 / this.ganttChart.hsPerDay;
+ timeZoom.min = timeZoom.min ? Math.min(timeZoom.min, startTime) : startTime;
+ timeZoom.max = timeZoom.max ? Math.max(timeZoom.max, (startTime + dur)) : (startTime + dur);
+ }
+ timeZoom.dur = (timeZoom.max - timeZoom.min) * this.ganttChart.hsPerDay / (24 * 60 * 60 * 1000);
+ timeZoom.min = new Date(timeZoom.min);
+ timeZoom.max = new Date(timeZoom.max);
+ ownerTimeConsume[owner] = timeZoom;
+ }
+ return ownerTimeConsume;
+ },
+ refresh: function(){
+ this.ownerTimeConsume = this.buildOwnerTimeConsume();
+ //resize outer div
+ this.contentData.firstChild.style.width = Math.max(1200, this.ganttChart.pixelsPerDay * this.ganttChart.totalDays) + "px";
+ for(var owner in this.resourceInfo){
+ this.refreshOwnerEntry(owner);
+ }
+ },
+ reConstruct: function(){
+ this.clearAll();
+ this.resourceInfo = this.buildResource();
+ this.ownerTimeConsume = this.buildOwnerTimeConsume();
+ this.tableControl = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0",
+ className: "ganttResourceTableControl"
+ });
+ var newRowTblControl = this.tableControl.insertRow(this.tableControl.rows.length);
+ //Add to content Table
+ this.contentHeight = this.content.offsetHeight;
+ this.contentWidth = this.content.offsetWidth;
+ this.content.appendChild(this.tableControl);
+ //Creation panel contentData
+ this.contentData = dojo.create("div", {className: "ganttResourceContentDataContainer"});
+ this.contentData.appendChild(this.createPanelOwners());
+ dojo.style(this.contentData, "height", (this.contentHeight - this.ganttChart.panelTimeHeight) + "px");
+ //Creation panel of names
+ var newCellTblControl = dojo.create("td", {
+ vAlign: "top"
+ });
+ this.panelNames = dojo.create("div", {className: "ganttResourcePanelNames"});
+ this.panelNames.appendChild(this.createPanelNamesOwners());
+ newCellTblControl.appendChild(this.panelNames);
+ newRowTblControl.appendChild(newCellTblControl);
+ //add to control contentData and contentDataTime
+ newCellTblControl = dojo.create("td", {
+ vAlign: "top"
+ });
+ var divCell = dojo.create("div", {className: "ganttResourceDivCell"});
+ divCell.appendChild(this.contentData);
+ newCellTblControl.appendChild(divCell);
+ newRowTblControl.appendChild(newCellTblControl);
+ //Show panel of names
+ dojo.style(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 _this = this;
+ this.contentData.onscroll = function(){
+ if(_this.panelNames){
+ _this.panelNames.scrollTop = this.scrollTop;
+ }
+ }
+ this.contentData.scrollLeft = this.ganttChart.contentData.scrollLeft;
+ for(var owner in this.resourceInfo){
+ this.createOwnerEntry(owner);
+ }
+ this.postAdjustment();
+ },
+ create: function(){
+ var resourceHeader = dojo.create("div", {
+ innerHTML: "Resource Chart:",
+ className: "ganttResourceHeader"
+ }, this.ganttChart.content, "after");
+ dojo.style(resourceHeader, "width", this.ganttChart.contentWidth + "px");
+ var content = dojo.create("div", {className: "ganttResourceContent"}, resourceHeader, "after");
+ dojo.style(content, {
+ width: this.ganttChart.contentWidth + "px",
+ height: (this.ganttChart.resourceChartHeight || (this.ganttChart.contentHeight * 0.8)) + "px"
+ });
+ this.content = content || this.content;
+ //create Table
+ this.reConstruct();
+ },
+ postAdjustment: function(){
+ //contentData height
+ this.contentData.firstChild.style.height = (this.ownerItem.length * 23) + "px";
+ this.panelNames.firstChild.style.height = (this.ownerItem.length * 23) + "px";
+ },
+
+ refreshOwnerEntry: function(owner){
+ this.refreshOwnerItem(owner);
+ dojo.forEach(this.resourceInfo[owner], function(task, i){
+ var item = this.ownerTaskNodeMapping[owner].tasks[i][0];
+ this.refreshDetailedTaskEntry(owner, item, task);
+ }, this);
+ },
+ createOwnerEntry: function(owner){
+ var containerOwner = this.contentData.firstChild;
+ var previousOwner = this.ownerItem[this.ownerItem.length - 1];
+ this.ownerTaskNodeMapping[owner] = {};
+ this.ownerTaskNodeMapping[owner][owner] = [];
+ //create nodes
+ var pos = dojo.position(containerOwner);
+ //creation arrTasks
+ var posY = (previousOwner ? parseInt(previousOwner.style.top) : (6 - 23)) + this.ganttChart.heightTaskItem + 11;
+ //creation task item
+ var oItem = this.createOwnerItem(owner, posY);
+ containerOwner.appendChild(oItem);
+ this.ownerItem.push(oItem);
+ this.ownerTaskNodeMapping[owner][owner].push(oItem);
+ if(this.panelNames){
+ var oNameItem = this.createOwnerNameItem(owner, posY);
+ this.panelNames.firstChild.appendChild(oNameItem);
+ this.ownerNameItem.push(oNameItem);
+ this.ownerTaskNodeMapping[owner][owner].push(oNameItem);
+ }
+ var currentOwnerNode = this.ownerItem[this.ownerNameItem.length - 1];
+ var currentOwnerNameNode = this.ownerNameItem[this.ownerNameItem.length - 1];
+ //adjust nodes
+ if(this.panelNames){
+ this.checkWidthTaskNameItem(currentOwnerNameNode);
+ var treeImg = this.createTreeImg(currentOwnerNameNode);
+ this.panelNames.firstChild.appendChild(treeImg);
+ this.ownerTaskNodeMapping[owner][owner].push(treeImg);
+ }
+ this.ownerTaskNodeMapping[owner]["taskCount"] = this.resourceInfo[owner].length;
+ this.ownerTaskNodeMapping[owner]["isOpen"] = false;
+ this.ownerTaskNodeMapping[owner]["tasks"] = [];
+ dojo.forEach(this.resourceInfo[owner], function(task){
+ this.ownerTaskNodeMapping[owner]["tasks"].push(this.createDetailedTaskEntry(owner, currentOwnerNameNode, task));
+ }, this);
+ return this;
+ },
+ createOwnerNameItem: function(owner, posY){
+ var ownerName = dojo.create("div", {
+ id: owner,
+ title: owner,
+ innerHTML: owner,
+ className: "ganttOwnerNameItem"
+ });
+ dojo.style(ownerName, "top", posY + "px");
+ return ownerName;
+ },
+ refreshOwnerItem: function(owner){
+ var item = this.ownerTaskNodeMapping[owner][owner][0];
+ var start = this.ownerTimeConsume[owner].min, end = this.ownerTimeConsume[owner].max, dur = this.ownerTimeConsume[owner].dur;
+ var posX = this.ganttChart.getPosOnDate(start); // should be task start date
+ item.style.left = posX + "px";
+ item.style.width = dur * this.ganttChart.pixelsPerWorkHour + "px";
+ dojo.forEach(this.resourceInfo[owner], function(task, i){
+ var tposX = this.ganttChart.getPosOnDate(task.taskItem.startTime); // should be task start date
+ dojo.style(item.childNodes[i], {
+ left: (tposX - posX) + "px",
+ width: task.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px"
+ });
+ }, this);
+ },
+ createOwnerItem: function(owner, posY){
+ var start = this.ownerTimeConsume[owner].min, end = this.ownerTimeConsume[owner].max, dur = this.ownerTimeConsume[owner].dur;
+ var posX = this.ganttChart.getPosOnDate(start); // should be task start date
+ var ownerControl = dojo.create("div", {
+ id: owner,
+ owner: true,
+ className: "ganttOwnerBar"
+ });
+ dojo.style(ownerControl, {
+ left: posX + "px",
+ top: posY + "px",
+ width: dur * this.ganttChart.pixelsPerWorkHour + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ dojo.forEach(this.resourceInfo[owner], function(task){
+ var ownerTaskItem = dojo.create("div", {
+ id: owner,
+ className: "ganttOwnerTaskBar"
+ }, ownerControl);
+ var tposX = this.ganttChart.getPosOnDate(task.taskItem.startTime); // should be task start date
+ dojo.style(ownerTaskItem, {
+ left: (tposX - posX) + "px",
+ width: task.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px", // should be task duration
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }, this);
+ return ownerControl;
+ },
+ refreshDetailedTaskEntry: function(owner, item, task){
+ this.refreshTaskItem(item, task);
+ },
+ createDetailedTaskEntry: function(owner, parentNode, task){
+ var taskItems = [];
+ var containerTasks = this.contentData.firstChild;
+ var posY = parseInt(parentNode.style.top);
+
+ //creation task item
+ var taskItem = this.createTaskItem(task, posY);
+ taskItem.style.display = "none";
+ containerTasks.appendChild(taskItem);
+ this.ownerItem.push(taskItem);
+ taskItems.push(taskItem);
+ if(this.panelNames){
+ var taskNameItem = this.createTaskNameItem(task.taskItem.name, posY);
+ this.panelNames.firstChild.appendChild(taskNameItem);
+ taskNameItem.style.display = "none";
+ this.ownerNameItem.push(taskNameItem);
+ taskItems.push(taskNameItem);
+ }
+ if(this.panelNames){
+ this.ownerNameItem[this.ownerNameItem.length - 1].style.left = dojo.style(parentNode, "left") + 15 + "px";
+ var arrConnectingLinesNames = this.createConnectingLinesPN(parentNode, this.ownerNameItem[this.ownerNameItem.length - 1]);
+ dojo.forEach(arrConnectingLinesNames, function(lineName){
+ lineName.style.display = "none";
+ }, this);
+ taskItems.push({
+ "v": arrConnectingLinesNames[0],
+ "h": arrConnectingLinesNames[1]
+ });
+ this.checkWidthTaskNameItem(this.ownerNameItem[this.ownerNameItem.length - 1]);
+ }
+ return taskItems;
+ },
+ createTaskNameItem: function(owner, posY){
+ var taskNameItem = dojo.create("div", {
+ id: owner,
+ className: "ganttTaskNameItem",
+ title: owner,
+ innerHTML: owner
+ });
+ dojo.style(taskNameItem, "top", posY + "px");
+ return taskNameItem;
+ },
+ refreshTaskItem: function(item, task){
+ var posX = this.ganttChart.getPosOnDate(task.taskItem.startTime); // should be task start date
+ dojo.style(item, {
+ left: posX + "px",
+ width: task.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px"
+ });
+ },
+ createTaskItem: function(task, posY){
+ var posX = this.ganttChart.getPosOnDate(task.taskItem.startTime); // should be task start date
+ var itemControl = dojo.create("div", {
+ id: task.taskItem.name,
+ className: "ganttTaskBar"
+ });
+ dojo.style(itemControl, {
+ left: posX + "px",
+ top: posY + "px",
+ width: task.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ return itemControl;
+ },
+ createConnectingLinesPN: function(parentNode, currentNode){
+ var arrConnectingLinesNames = [];
+ var lineVerticalLeft = dojo.create("div", {
+ innerHTML: " ",
+ className: "ganttResourceLineVerticalLeft"
+ }, this.panelNames.firstChild);
+ lineVerticalLeft.cNode = currentNode;
+ lineVerticalLeft.pNode = parentNode;
+ var LineHorizontalLeft = dojo.create("div", {
+ noShade: true,
+ color: "#000000",
+ className: "ganttResourceLineHorizontalLeft"
+ }, this.panelNames.firstChild);
+ LineHorizontalLeft.cNode = currentNode;
+ LineHorizontalLeft.pNode = parentNode;
+ this.panelNames.firstChild.appendChild(LineHorizontalLeft);
+ arrConnectingLinesNames.push(lineVerticalLeft);
+ arrConnectingLinesNames.push(LineHorizontalLeft);
+ return arrConnectingLinesNames;
+ },
+ createTreeImg: function(ownerNameItem){
+ var treeImg = dojo.create("div", {
+ id: ownerNameItem.id,
+ className: "ganttImageTreeExpand"
+ });
+ dojo.attr(treeImg, "tabIndex", 0);
+ var currentItem = this.ownerTaskNodeMapping[ownerNameItem.id];
+ dojo.forEach(["onclick", "onkeydown"], function(e){
+ this.ganttChart._events.push(
+ dojo.connect(treeImg, e, this, function(evt){
+ if(e == "onkeydown" && evt.keyCode != dojo.keys.ENTER){ return; }
+ if(currentItem.isOpen){
+ dojo.removeClass(treeImg, "ganttImageTreeCollapse");
+ dojo.addClass(treeImg, "ganttImageTreeExpand");
+ currentItem.isOpen = false;
+ //collapse
+ var reachTarget = false;
+ for(var owner in this.ownerTaskNodeMapping){
+ var ownerItem = this.ownerTaskNodeMapping[owner];
+ if(reachTarget){
+ dojo.forEach(ownerItem[owner], function(tItem){
+ dojo.style(tItem, "top", dojo.style(tItem, "top") - currentItem.taskCount * 23 + "px");
+ }, this);
+ dojo.forEach(ownerItem.tasks, function(tItems){
+ dojo.forEach(tItems, function(tItem){
+ var item = !tItem.v && !tItem.h ? [tItem] : [tItem.v, tItem.h];
+ dojo.forEach(item, function(t){
+ dojo.style(t, "top", dojo.style(t, "top") - currentItem.taskCount * 23 + "px");
+ }, this);
+ }, this);
+ }, this);
+ }else{
+ if(owner == ownerNameItem.id){
+ reachTarget = true;
+ dojo.forEach(ownerItem.tasks, function(tItems, i){
+ dojo.forEach(tItems, function(tItem){
+ this.styleOwnerItem(tItem, ownerItem[owner][0], "none", 0);
+ }, this);
+ }, this);
+ }
+ }
+ }
+ }else{
+ dojo.removeClass(treeImg, "ganttImageTreeExpand");
+ dojo.addClass(treeImg, "ganttImageTreeCollapse");
+ currentItem.isOpen = true;
+ //expand
+ var reachTarget = false;
+ for(var owner in this.ownerTaskNodeMapping){
+ var ownerItem = this.ownerTaskNodeMapping[owner];
+ if(reachTarget){
+ dojo.forEach(ownerItem[owner], function(tItem){
+ dojo.style(tItem, "top", dojo.style(tItem, "top") + currentItem.taskCount * 23 + "px");
+ }, this);
+ dojo.forEach(ownerItem.tasks, function(tItems){
+ dojo.forEach(tItems, function(tItem){
+ var item = !tItem.v && !tItem.h ? [tItem] : [tItem.v, tItem.h];
+ dojo.forEach(item, function(t){
+ dojo.style(t, "top", dojo.style(t, "top") + currentItem.taskCount * 23 + "px");
+ }, this);
+ }, this);
+ }, this);
+ }else{
+ if(owner == ownerNameItem.id){
+ reachTarget = true;
+ dojo.forEach(ownerItem.tasks, function(tItems, i){
+ dojo.forEach(tItems, function(tItem){
+ this.styleOwnerItem(tItem, ownerItem[owner][0], "inline", (i + 1) * 23);
+ }, this);
+ }, this);
+ }
+ }
+ }
+ }
+ })
+ );
+ }, this);
+ dojo.addClass(treeImg, "ganttResourceTreeImage");
+ dojo.style(treeImg, {
+ left: (dojo.style(ownerNameItem, "left") - 12) + "px",
+ top: (dojo.style(ownerNameItem, "top") + 3) + "px"
+ });
+ return treeImg;
+ },
+ styleOwnerItem: function(tItem, owner, displayType, topOffset){
+ if(tItem.v || tItem.h){
+ dojo.style(tItem.v, {
+ height: Math.max(1, (tItem.v.cNode.offsetTop - tItem.v.pNode.offsetTop)) + "px",
+ top: (tItem.v.pNode.offsetTop + 5) + "px",
+ left: (tItem.v.pNode.offsetLeft - 9) + "px",
+ display: displayType
+ });
+ dojo.style(tItem.h, {
+ width: Math.max(1, (tItem.h.cNode.offsetLeft - tItem.h.pNode.offsetLeft + 4)) + "px",
+ top: (tItem.h.cNode.offsetTop + 5) + "px",
+ left: (tItem.h.pNode.offsetLeft - 9) + "px",
+ display: displayType
+ });
+ }else{
+ dojo.style(tItem, {
+ display: displayType,
+ top: parseInt(owner.style.top) + topOffset + "px"
+ });
+ }
+ },
+ checkWidthTaskNameItem: function(taskNameItem){
+ if(taskNameItem && taskNameItem.offsetWidth + taskNameItem.offsetLeft > this.ganttChart.maxWidthPanelNames){
+ var width = taskNameItem.offsetWidth + taskNameItem.offsetLeft - this.ganttChart.maxWidthPanelNames;
+ var countChar = Math.round(width / (taskNameItem.offsetWidth / taskNameItem.firstChild.length));
+ var tName = taskNameItem.id.substring(0, taskNameItem.firstChild.length - countChar - 3);
+ tName += "...";
+ taskNameItem.innerHTML = tName;
+ }
+ },
+ createPanelOwners: function(){
+ var panelOwner = dojo.create("div", {
+ className: "ganttOwnerPanel"
+ });
+ dojo.style(panelOwner, {
+ height: (this.contentHeight - this.ganttChart.panelTimeHeight - this.ganttChart.scrollBarWidth) + "px"
+ });
+ return panelOwner;
+ },
+ createPanelNamesOwners: function(){
+ var panelNameOwner = dojo.create("div", {
+ innerHTML: " ",
+ className: "ganttResourcePanelNamesOwners"
+ });
+ dojo.style(panelNameOwner, {
+ height: (this.contentHeight - this.ganttChart.panelTimeHeight - this.ganttChart.scrollBarWidth) + "px",
+ width: this.ganttChart.maxWidthPanelNames + "px"
+ });
+ return panelNameOwner;
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/gantt/GanttTaskItem.js b/js/dojo-1.6/dojox/gantt/GanttTaskItem.js new file mode 100644 index 0000000..339a5b2 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/GanttTaskItem.js @@ -0,0 +1,1368 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.gantt.GanttTaskItem"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.gantt.GanttTaskItem"] = true;
+dojo.provide("dojox.gantt.GanttTaskItem");
+
+dojo.require("dojo.date.locale");
+
+dojo.declare("dojox.gantt.GanttTaskControl", null, {
+ constructor: function(taskInfo, project, chart){
+ this.ganttChart = chart;
+ this.project = project;
+ this.taskItem = taskInfo;
+ //control variables
+ this.checkMove = false;
+ this.checkResize = false;
+ this.moveChild = false;
+ this.maxPosXMove = -1;
+ this.minPosXMove = -1;
+ this.maxWidthResize = -1;
+ this.minWidthResize = -1;
+ this.posX = 0;
+ this.posY = 0;
+ this.mouseX = 0;
+ this.taskItemWidth = 0;
+ this.isHide = false;
+ this.hideTasksHeight = 0;
+ this.isExpanded = true;
+ this.descrTask = null;
+ this.cTaskItem = null;
+ this.cTaskNameItem = null;
+ this.parentTask = null;
+ this.predTask = null;
+ this.childTask = [];
+ this.childPredTask = [];
+ this.nextChildTask = null;
+ this.previousChildTask = null;
+ this.nextParentTask = null;
+ this.previousParentTask = null;
+ },
+ createConnectingLinesPN: function(){
+ var arrConnectingLinesNames = [];
+ var lineVerticalLeft = dojo.create("div", {
+ innerHTML: " ",
+ className: "ganttTaskLineVerticalLeft"
+ }, this.ganttChart.panelNames.firstChild);
+ var cTaskName = this.cTaskNameItem[0], pcTaskName = this.parentTask.cTaskNameItem[0];
+ dojo.style(lineVerticalLeft, {
+ height: (cTaskName.offsetTop - pcTaskName.offsetTop) + "px",
+ top: (pcTaskName.offsetTop + 5) + "px",
+ left: (pcTaskName.offsetLeft - 9) + "px"
+ });
+ var LineHorizontalLeft = dojo.create("div", {
+ noShade: true,
+ color: "#000000",
+ className: "ganttTaskLineHorizontalLeft"
+ }, this.ganttChart.panelNames.firstChild);
+ dojo.style(LineHorizontalLeft, {
+ left: (pcTaskName.offsetLeft - 9) + "px",
+ top: (cTaskName.offsetTop + 5) + "px",
+ height: "1px",
+ width: (cTaskName.offsetLeft - pcTaskName.offsetLeft + 4) + "px"
+ });
+ arrConnectingLinesNames.push(lineVerticalLeft);
+ arrConnectingLinesNames.push(LineHorizontalLeft);
+ return arrConnectingLinesNames;
+ },
+ createConnectingLinesDS: function(){
+ var contentData = this.ganttChart.contentData.firstChild;
+ var arrLines = [];
+ var arrowImg = new Image();
+ var arrowImg = dojo.create("div", {
+ className: "ganttImageArrow"
+ });
+ //vertical line
+ var lineVerticalRight = document.createElement("div");
+ //horizontal line
+ var lineHorizontal = document.createElement("div");
+ var posXPreviousTask = dojo.style(this.predTask.cTaskItem[0], "left");
+ var posYPreviousTask = dojo.style(this.predTask.cTaskItem[0], "top");
+ var posXChildTask = dojo.style(this.cTaskItem[0], "left");
+ var posYChildTask = this.posY + 2;
+ //width task item
+ var widthChildTask = parseInt(this.predTask.cTaskItem[0].firstChild.firstChild.width);
+ var widthPreviousTask = parseInt(this.predTask.cTaskItem[0].firstChild.firstChild.width);
+ if(posYPreviousTask < posYChildTask){
+ dojo.addClass(lineVerticalRight, "ganttTaskLineVerticalRight");
+ dojo.style(lineVerticalRight, {
+ height: (posYChildTask - this.ganttChart.heightTaskItem / 2 - posYPreviousTask - 3) + "px",
+ width: "1px",
+ left: (posXPreviousTask + widthPreviousTask - 20) + "px",
+ top: (posYPreviousTask + this.ganttChart.heightTaskItem) + "px"
+ });
+ dojo.addClass(lineHorizontal, "ganttTaskLineHorizontal");
+ dojo.style(lineHorizontal, {
+ width: (15 + (posXChildTask - (widthPreviousTask + posXPreviousTask))) + "px",
+ left: (posXPreviousTask + widthPreviousTask - 20) + "px",
+ top: (posYChildTask + 2) + "px"
+ });
+ dojo.addClass(arrowImg, "ganttTaskArrowImg");
+ dojo.style(arrowImg, {
+ left: (posXChildTask - 7) + "px",
+ top: (posYChildTask - 1) + "px"
+ });
+ }else{
+ dojo.addClass(lineVerticalRight, "ganttTaskLineVerticalRightPlus");
+ dojo.style(lineVerticalRight, {
+ height: (posYPreviousTask + 2 - posYChildTask) + "px",
+ width: "1px",
+ left: (posXPreviousTask + widthPreviousTask - 20) + "px",
+ top: (posYChildTask + 2) + "px"
+ });
+ dojo.addClass(lineHorizontal, "ganttTaskLineHorizontalPlus");
+ dojo.style(lineHorizontal, {
+ width: (15 + (posXChildTask - (widthPreviousTask + posXPreviousTask))) + "px",
+ left: (posXPreviousTask + widthPreviousTask - 20) + "px",
+ top: (posYChildTask + 2) + "px"
+ });
+ dojo.addClass(arrowImg, "ganttTaskArrowImgPlus");
+ dojo.style(arrowImg, {
+ left: (posXChildTask - 7) + "px",
+ top: (posYChildTask - 1) + "px"
+ });
+ }
+ contentData.appendChild(lineVerticalRight);
+ contentData.appendChild(lineHorizontal);
+ contentData.appendChild(arrowImg);
+ arrLines.push(lineVerticalRight);
+ arrLines.push(arrowImg);
+ arrLines.push(lineHorizontal);
+ return arrLines;
+ },
+ showChildTasks: function(task, isOpen){
+ if(isOpen){
+ for(var i = 0; i < task.childTask.length; i++){
+ var cTask = task.childTask[i],
+ cTaskItem0 = cTask.cTaskItem[0], cTaskName0 = cTask.cTaskNameItem[0],
+ cTaskItem1 = cTask.cTaskItem[1], cTaskName1 = cTask.cTaskNameItem[1],
+ cTaskItem2 = cTask.cTaskItem[2], cTaskName2 = cTask.cTaskNameItem[2];
+ if(cTaskItem0.style.display == "none"){
+ cTaskItem0.style.display = "inline";
+ cTaskName0.style.display = "inline";
+ cTask.showDescTask();
+ task.isHide = false;
+ if(cTaskName2){
+ cTaskName2.style.display = "inline";
+ isOpen = cTask.isExpanded;
+ }
+ for(var k = 0; k < cTaskItem1.length; k++){
+ cTaskItem1[k].style.display = "inline";
+ }
+ for(var k = 0; k < cTaskName1.length; k++){
+ cTaskName1[k].style.display = "inline";
+ }
+ (cTask.taskIdentifier) && (cTask.taskIdentifier.style.display = "inline");
+ this.hideTasksHeight += this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ if(cTask.childTask.length > 0){
+ this.showChildTasks(cTask, isOpen);
+ }
+ }
+ }
+ }
+ },
+ hideChildTasks: function(task){
+ for(var i = 0; i < task.childTask.length; i++){
+ var cTask = task.childTask[i],
+ cTaskItem0 = cTask.cTaskItem[0], cTaskName0 = cTask.cTaskNameItem[0],
+ cTaskItem1 = cTask.cTaskItem[1], cTaskName1 = cTask.cTaskNameItem[1],
+ cTaskItem2 = cTask.cTaskItem[2], cTaskName2 = cTask.cTaskNameItem[2];
+ if(cTaskItem0.style.display != "none"){
+ cTaskItem0.style.display = "none";
+ cTaskName0.style.display = "none";
+ cTask.hideDescTask();
+ task.isHide = true;
+ if(cTaskName2){
+ cTaskName2.style.display = "none";
+ }
+ for(var k = 0; k < cTaskItem1.length; k++){
+ cTaskItem1[k].style.display = "none";
+ }
+ for(var k = 0; k < cTaskName1.length; k++){
+ cTaskName1[k].style.display = "none";
+ }
+ (cTask.taskIdentifier) && (cTask.taskIdentifier.style.display = "none");
+ this.hideTasksHeight += (this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra);
+ if(cTask.childTask.length > 0){
+ this.hideChildTasks(cTask);
+ }
+ }
+ }
+ },
+ shiftCurrentTasks: function(task, height){
+ this.shiftNextTask(this, height);
+ task.project.shiftNextProject(task.project, height);
+ },
+ shiftTask: function(task, height){
+ task.posY = task.posY + height;
+ var taskItem0 = task.cTaskItem[0], taskName0 = task.cTaskNameItem[0],
+ taskItem1 = task.cTaskItem[1], taskName1 = task.cTaskNameItem[1],
+ taskItem2 = task.cTaskItem[2], taskName2 = task.cTaskNameItem[2];
+ taskName0.style.top = parseInt(taskName0.style.top) + height + "px";
+ if(taskName2){
+ taskName2.style.top = parseInt(taskName2.style.top) + height + "px";
+ }
+ if(task.parentTask){
+ if(parseInt(this.cTaskNameItem[0].style.top) > parseInt(task.parentTask.cTaskNameItem[0].style.top) &&
+ (taskName1[0].style.display != "none")){
+ taskName1[0].style.height = parseInt(taskName1[0].style.height) + height + "px";
+ }else{
+ taskName1[0].style.top = parseInt(taskName1[0].style.top) + height + "px";
+ }
+ taskName1[1].style.top = parseInt(taskName1[1].style.top) + height + "px";
+ }
+ taskItem0.style.top = parseInt(taskItem0.style.top) + height + "px";
+ task.descrTask.style.top = parseInt(task.descrTask.style.top) + height + "px";
+ if(task.predTask){
+ if(((parseInt(this.cTaskItem[0].style.top) > parseInt(task.predTask.cTaskItem[0].style.top)) ||
+ (this.cTaskItem[0].id == task.predTask.taskItem.id)) &&
+ taskItem1[0].style.display != "none"){
+ taskItem1[0].style.height = parseInt(taskItem1[0].style.height) + height + "px";
+ }else{
+ taskItem1[0].style.top = parseInt(taskItem1[0].style.top) + height + "px";
+ }
+ taskItem1[1].style.top = parseInt(taskItem1[1].style.top) + height + "px";
+ taskItem1[2].style.top = parseInt(taskItem1[2].style.top) + height + "px";
+ }
+ },
+ shiftNextTask: function(task, height){
+ if(task.nextChildTask){
+ this.shiftTask(task.nextChildTask, height);
+ this.shiftChildTask(task.nextChildTask, height);
+ this.shiftNextTask(task.nextChildTask, height);
+ }else if(task.parentTask){
+ this.shiftNextTask(task.parentTask, height);
+ }else if(task.nextParentTask){
+ this.shiftTask(task.nextParentTask, height);
+ this.shiftChildTask(task.nextParentTask, height);
+ this.shiftNextTask(task.nextParentTask, height);
+ }
+ },
+ shiftChildTask: function(task, height){
+ dojo.forEach(task.childTask, function(cTask){
+ this.shiftTask(cTask, height);
+ if(cTask.childTask.length > 0){
+ this.shiftChildTask(cTask, height);
+ }
+ }, this);
+ },
+ endMove: function(){
+ var cTask0 = this.cTaskItem[0];
+ var width = dojo.style(cTask0, "left") - this.posX;
+ var startTime = this.getDateOnPosition(dojo.style(cTask0, "left"));
+ startTime = this.checkPos(startTime);
+ if(this.checkMove){
+ width = this.ganttChart.getPosOnDate(startTime) - this.posX;
+ this.moveCurrentTaskItem(width, this.moveChild);
+ this.project.shiftProjectItem();
+ }
+ this.checkMove = false;
+ this.posX = 0;
+ this.maxPosXMove = -1;
+ this.minPosXMove = -1;
+ cTask0.childNodes[1].firstChild.rows[0].cells[0].innerHTML = "";
+ this.adjustPanelTime();
+ if(this.ganttChart.resource){
+ this.ganttChart.resource.refresh();
+ }
+ },
+ checkPos: function(startTime){
+ var cTask0 = this.cTaskItem[0];
+ var h = startTime.getHours();
+ if(h >= 12){
+ startTime.setDate(startTime.getDate() + 1);
+ startTime.setHours(0);
+ if((parseInt(cTask0.firstChild.firstChild.width) + this.ganttChart.getPosOnDate(startTime) > this.maxPosXMove) && (this.maxPosXMove != -1)){
+ startTime.setDate(startTime.getDate() - 1);
+ startTime.setHours(0);
+ }
+ }else if((h < 12) && (h != 0)){
+ startTime.setHours(0);
+ if((this.ganttChart.getPosOnDate(startTime) < this.minPosXMove)){
+ startTime.setDate(startTime.getDate() + 1);
+ }
+ }
+ cTask0.style.left = this.ganttChart.getPosOnDate(startTime) + "px";
+ return startTime;
+ },
+ getMaxPosPredChildTaskItem: function(){
+ var posPredChildTaskItem = 0;
+ var nextPosPredChildTaskItem = 0;
+ for(var i = 0; i < this.childPredTask.length; i++){
+ nextPosPredChildTaskItem = this.getMaxPosPredChildTaskItemInTree(this.childPredTask[i]);
+ if(nextPosPredChildTaskItem > posPredChildTaskItem){
+ posPredChildTaskItem = nextPosPredChildTaskItem;
+ }
+ }
+ return posPredChildTaskItem;
+ },
+ getMaxPosPredChildTaskItemInTree: function(task){
+ var cTask0 = task.cTaskItem[0];
+ var currentPos = parseInt(cTask0.firstChild.firstChild.width) + dojo.style(cTask0, "left");
+ var posPredChildTaskItem = 0;
+ var nextPosPredChildTaskItem = 0;
+ dojo.forEach(task.childPredTask, function(cpTask){
+ nextPosPredChildTaskItem = this.getMaxPosPredChildTaskItemInTree(cpTask);
+ if(nextPosPredChildTaskItem > posPredChildTaskItem){
+ posPredChildTaskItem = nextPosPredChildTaskItem;
+ }
+ }, this);
+ return posPredChildTaskItem > currentPos ? posPredChildTaskItem : currentPos;
+ },
+ moveCurrentTaskItem: function(width, moveChild){
+ var taskItem = this.cTaskItem[0];
+ this.taskItem.startTime = new Date(this.ganttChart.startDate);
+ this.taskItem.startTime.setHours(this.taskItem.startTime.getHours() + (parseInt(taskItem.style.left) / this.ganttChart.pixelsPerHour));
+ this.showDescTask();
+ var cTask1 = this.cTaskItem[1];
+ if(cTask1.length > 0){
+ cTask1[2].style.width = parseInt(cTask1[2].style.width) + width + "px";
+ cTask1[1].style.left = parseInt(cTask1[1].style.left) + width + "px";
+ }
+ dojo.forEach(this.childTask, function(cTask){
+ if(!cTask.predTask){
+ this.moveChildTaskItems(cTask, width, moveChild);
+ }
+ }, this);
+ dojo.forEach(this.childPredTask, function(cpTask){
+ this.moveChildTaskItems(cpTask, width, moveChild);
+ }, this);
+ },
+ moveChildTaskItems: function(task, width, moveChild){
+ var taskItem = task.cTaskItem[0];
+ if(moveChild){
+ taskItem.style.left = parseInt(taskItem.style.left) + width + "px";
+ task.adjustPanelTime();
+ task.taskItem.startTime = new Date(this.ganttChart.startDate);
+ task.taskItem.startTime.setHours(task.taskItem.startTime.getHours() + (parseInt(taskItem.style.left) / this.ganttChart.pixelsPerHour));
+ var ctItem = task.cTaskItem[1];
+ dojo.forEach(ctItem, function(item){
+ item.style.left = parseInt(item.style.left) + width + "px";
+ }, this);
+ dojo.forEach(task.childTask, function(cTask){
+ if(!cTask.predTask){
+ this.moveChildTaskItems(cTask, width, moveChild);
+ }
+ }, this);
+ dojo.forEach(task.childPredTask, function(cpTask){
+ this.moveChildTaskItems(cpTask, width, moveChild);
+ }, this);
+ }else{
+ var ctItem = task.cTaskItem[1];
+ if(ctItem.length > 0){
+ var item0 = ctItem[0], item2 = ctItem[2];
+ item2.style.left = parseInt(item2.style.left) + width + "px";
+ item2.style.width = parseInt(item2.style.width) - width + "px";
+ item0.style.left = parseInt(item0.style.left) + width + "px";
+ }
+ }
+ task.moveDescTask();
+ },
+ adjustPanelTime: function(){
+ var taskItem = this.cTaskItem[0];
+ var width = parseInt(taskItem.style.left) + parseInt(taskItem.firstChild.firstChild.width) + this.ganttChart.panelTimeExpandDelta;
+ width += this.descrTask.offsetWidth;
+ this.ganttChart.adjustPanelTime(width);
+ },
+ getDateOnPosition: function(position){
+ var date = new Date(this.ganttChart.startDate);
+ date.setHours(date.getHours() + (position / this.ganttChart.pixelsPerHour));
+ return date;
+ },
+ moveItem: function(event){
+ var pageX = event.screenX;
+ var posTaskItem = (this.posX + (pageX - this.mouseX));
+ var widthTaskItem = parseInt(this.cTaskItem[0].childNodes[0].firstChild.width);
+ var posTaskItemR = posTaskItem + widthTaskItem;
+ if(this.checkMove){
+ if(((this.minPosXMove <= posTaskItem)) &&
+ ((posTaskItemR <= this.maxPosXMove) || (this.maxPosXMove == -1))){
+ this.moveTaskItem(posTaskItem);
+ }
+ }
+ },
+ moveTaskItem: function(posX){
+ var cTask = this.cTaskItem[0];
+ cTask.style.left = posX + "px";
+ cTask.childNodes[1].firstChild.rows[0].cells[0].innerHTML = this.getDateOnPosition(posX).getDate() + '.' + (this.getDateOnPosition(posX).getMonth() + 1) + '.' + this.getDateOnPosition(posX).getUTCFullYear();
+ },
+ resizeItem: function(event){
+ if(this.checkResize){
+ var taskItem = this.cTaskItem[0];
+ var mouseX = event.screenX;
+ var width = (mouseX - this.mouseX);
+ var widthTaskItem = this.taskItemWidth + (mouseX - this.mouseX);
+ if(widthTaskItem >= this.taskItemWidth){
+ if((widthTaskItem <= this.maxWidthResize) || (this.maxWidthResize == -1)){
+ this.resizeTaskItem(widthTaskItem);
+ }else if((this.maxWidthResize != -1) && (widthTaskItem > this.maxWidthResize)){
+ this.resizeTaskItem(this.maxWidthResize);
+ }
+ }else if(widthTaskItem <= this.taskItemWidth){
+ if(widthTaskItem >= this.minWidthResize){
+ this.resizeTaskItem(widthTaskItem);
+ }else if(widthTaskItem < this.minWidthResize){
+ this.resizeTaskItem(this.minWidthResize);
+ }
+ }
+ }
+ },
+ resizeTaskItem: function(width){
+ var taskItem = this.cTaskItem[0];
+ var countHours = Math.round(width / this.ganttChart.pixelsPerWorkHour);
+ var trow = taskItem.childNodes[0].firstChild.rows[0],
+ rc0 = trow.cells[0], rc1 = trow.cells[1];
+ rc0 && (rc0.firstChild.style.width = parseInt(rc0.width) * width / 100 + "px");
+ rc1 && (rc1.firstChild.style.width = parseInt(rc1.width) * width / 100 + "px");
+ taskItem.childNodes[0].firstChild.width = width + "px";
+ taskItem.childNodes[1].firstChild.width = width + "px";
+ //resize info
+ this.cTaskItem[0].childNodes[1].firstChild.rows[0].cells[0].innerHTML = countHours;
+ var tcNode2 = taskItem.childNodes[2];
+ tcNode2.childNodes[0].style.width = width + "px";
+ tcNode2.childNodes[1].style.left = width - 10 + "px";
+ },
+ endResizeItem: function(){
+ var taskItem = this.cTaskItem[0];
+ if((this.taskItemWidth != parseInt(taskItem.childNodes[0].firstChild.width))){
+ var posXL = taskItem.offsetLeft;
+ var posXR = taskItem.offsetLeft + parseInt(taskItem.childNodes[0].firstChild.width);
+ var countHours = Math.round((posXR - posXL) / this.ganttChart.pixelsPerWorkHour);
+ this.taskItem.duration = countHours;
+ if(this.childPredTask.length > 0){
+ for(var j = 0; j < this.childPredTask.length; j++){
+ var cpctItem = this.childPredTask[j].cTaskItem[1],
+ item0 = cpctItem[0], item2 = cpctItem[2], tcNode0 = taskItem.childNodes[0];
+ item2.style.width = parseInt(item2.style.width) - (parseInt(tcNode0.firstChild.width) - this.taskItemWidth) + "px";
+ item2.style.left = parseInt(item2.style.left) + (parseInt(tcNode0.firstChild.width) - this.taskItemWidth) + "px";
+ item0.style.left = parseInt(item0.style.left) + (parseInt(tcNode0.firstChild.width) - this.taskItemWidth) + "px";
+ }
+ }
+ }
+ this.cTaskItem[0].childNodes[1].firstChild.rows[0].cells[0].innerHTML = "";
+ this.checkResize = false;
+ this.taskItemWidth = 0;
+ this.mouseX = 0;
+ this.showDescTask();
+ this.project.shiftProjectItem();
+ this.adjustPanelTime();
+ if(this.ganttChart.resource){
+ this.ganttChart.resource.refresh();
+ }
+ },
+ startMove: function(event){
+ this.moveChild = event.ctrlKey;
+ this.mouseX = event.screenX;
+ this.getMoveInfo();
+ this.checkMove = true;
+ this.hideDescTask();
+ },
+ showDescTask: function(){
+ var posX = (parseInt(this.cTaskItem[0].style.left) + this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ this.descrTask.style.left = posX + "px";
+ this.descrTask.innerHTML = this.objKeyToStr(this.getTaskOwner());
+ this.descrTask.style.visibility = 'visible';
+ },
+ hideDescTask: function(){
+ dojo.style(this.descrTask, "visibility", "hidden");
+ },
+ buildResourceInfo: function(resourceInfo){
+ if(this.childTask && this.childTask.length > 0){
+ for(var i = 0; i < this.childTask.length; i++){
+ var cTask = this.childTask[i];
+ cTask.buildResourceInfo(resourceInfo);
+ }
+ }
+ if(dojo.trim(this.taskItem.taskOwner).length > 0){
+ var owners = this.taskItem.taskOwner.split(";");
+ for(var i = 0; i < owners.length; i++){
+ var o = owners[i];
+ if(dojo.trim(o).length <= 0){
+ continue;
+ }
+ resourceInfo[o] ? (resourceInfo[o].push(this)) : (resourceInfo[o] = [this]);
+ }
+ }
+ },
+ objKeyToStr: function(obj, delm){
+ var returnStr = "";
+ delm = delm || " ";
+ if(obj){
+ for(var key in obj){
+ returnStr += delm + key;
+ }
+ }
+ return returnStr;
+ },
+ getTaskOwner: function(){
+ var tOwner = {};
+ if(dojo.trim(this.taskItem.taskOwner).length > 0){
+ var owners = this.taskItem.taskOwner.split(";");
+ for(var i = 0; i < owners.length; i++){
+ var o = owners[i];
+ tOwner[o] = 1;
+ }
+ }
+ dojo.forEach(this.childTask, function(ctask){
+ dojo.mixin(tOwner, ctask.getTaskOwner());
+ }, this);
+ return tOwner;
+ },
+ moveDescTask: function(){
+ var posX = (parseInt(this.cTaskItem[0].style.left) + this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ this.descrTask.style.left = posX + "px";
+ },
+ getMoveInfo: function(){
+ this.posX = parseInt(this.cTaskItem[0].style.left);
+ var widthTaskItem = parseInt(this.cTaskItem[0].childNodes[0].firstChild.width);
+ var posParentTaskItem = !this.parentTask ? 0 : parseInt(this.parentTask.cTaskItem[0].style.left);
+ var posPredTaskItem = !this.predTask ? 0 : parseInt(this.predTask.cTaskItem[0].style.left) + parseInt(this.predTask.cTaskItem[0].childNodes[0].firstChild.width);
+ var widthParentTaskItem = !this.parentTask ? 0 : parseInt(this.parentTask.cTaskItem[0].childNodes[0].firstChild.width);
+
+ var childPredPosX = 0;
+ var childParentPosX = 0;
+ var childParentPosXR = 0;
+ if(this.childPredTask.length > 0){
+ var posChildTaskItem = null;
+ dojo.forEach(this.childPredTask, function(cpTask){
+ if((!posChildTaskItem) || ((posChildTaskItem) && (posChildTaskItem > parseInt(cpTask.cTaskItem[0].style.left)))){
+ posChildTaskItem = parseInt(cpTask.cTaskItem[0].style.left);
+ }
+ }, this);
+ childPredPosX = posChildTaskItem;
+ }
+ if(this.childTask.length > 0){
+ var posChildTaskItemR = null;
+ dojo.forEach(this.childTask, function(cTask){
+ if((!posChildTaskItemR) || ((posChildTaskItemR) && (posChildTaskItemR > (parseInt(cTask.cTaskItem[0].style.left))))){
+ posChildTaskItemR = parseInt(cTask.cTaskItem[0].style.left);
+ }
+ }, this);
+ childParentPosXR = posChildTaskItemR;
+ var posChildTaskItem = null;
+ dojo.forEach(this.childTask, function(cTask){
+ if((!posChildTaskItem) || ((posChildTaskItem)
+ && (posChildTaskItem < (parseInt(cTask.cTaskItem[0].style.left) + parseInt(cTask.cTaskItem[0].firstChild.firstChild.width))))){
+ posChildTaskItem = parseInt(cTask.cTaskItem[0].style.left) + parseInt(cTask.cTaskItem[0].firstChild.firstChild.width);
+ }
+ }, this);
+ childParentPosX = posChildTaskItem;
+ }
+ if(!this.moveChild){
+ if(this.childPredTask.length > 0){
+ if(this.maxPosXMove < childPredPosX) this.maxPosXMove = childPredPosX;
+ }
+ if(this.childTask.length > 0){
+ if((this.childPredTask.length > 0) && (this.maxPosXMove - widthTaskItem) > childParentPosXR){
+ this.maxPosXMove = this.maxPosXMove - ((this.maxPosXMove - widthTaskItem) - childParentPosXR);
+ }
+ if(!(this.childPredTask.length > 0)){
+ this.maxPosXMove = childParentPosXR + widthTaskItem;
+ }
+ this.minPosXMove = (childParentPosX - widthTaskItem);
+ }
+ if(posParentTaskItem > 0){
+ if((!(this.childPredTask.length > 0)) && (this.childTask.length > 0)){
+ if(this.maxPosXMove > posParentTaskItem + widthParentTaskItem){
+ this.maxPosXMove = posParentTaskItem + widthParentTaskItem;
+ }
+ }
+ if(this.minPosXMove <= posParentTaskItem){
+ this.minPosXMove = posParentTaskItem;
+ }
+ if((!(this.childTask.length > 0)) && (!(this.childPredTask.length > 0))){
+ this.maxPosXMove = posParentTaskItem + widthParentTaskItem;
+ }else if((!(this.childTask.length > 0)) && (this.childPredTask.length > 0)){
+ if((posParentTaskItem + widthParentTaskItem) > posPredTaskItem){
+ this.maxPosXMove = childPredPosX;
+ }
+ }
+ }
+ if(posPredTaskItem > 0){
+ if(this.minPosXMove <= posPredTaskItem){
+ this.minPosXMove = posPredTaskItem;
+ }
+ }
+ if((posPredTaskItem == 0) && (posParentTaskItem == 0)){
+ if(this.minPosXMove <= this.ganttChart.initialPos){
+ this.minPosXMove = this.ganttChart.initialPos;
+ }
+ }
+ }else{
+ if((posParentTaskItem > 0) && (posPredTaskItem == 0)){
+ this.minPosXMove = posParentTaskItem;
+ this.maxPosXMove = posParentTaskItem + widthParentTaskItem;
+ }else if((posParentTaskItem == 0) && (posPredTaskItem == 0)){
+ this.minPosXMove = this.ganttChart.initialPos;
+ this.maxPosXMove = -1;
+ }else if((posParentTaskItem > 0) && (posPredTaskItem > 0)){
+ this.minPosXMove = posPredTaskItem;
+ this.maxPosXMove = posParentTaskItem + widthParentTaskItem;
+ }else if((posParentTaskItem == 0) && (posPredTaskItem > 0)){
+ this.minPosXMove = posPredTaskItem;
+ this.maxPosXMove = -1;
+ }
+ if((this.parentTask) && (this.childPredTask.length > 0)){
+ var posChildTaskItem = this.getMaxPosPredChildTaskItem(this);
+ var posParentTaskItem = parseInt(this.parentTask.cTaskItem[0].style.left) + parseInt(this.parentTask.cTaskItem[0].firstChild.firstChild.width);
+ this.maxPosXMove = this.posX + widthTaskItem + posParentTaskItem - posChildTaskItem;
+ }
+ }
+ },
+ startResize: function(event){
+ this.mouseX = event.screenX;
+ this.getResizeInfo();
+ this.hideDescTask();
+ this.checkResize = true;
+ this.taskItemWidth = parseInt(this.cTaskItem[0].firstChild.firstChild.width);
+ },
+ getResizeInfo: function(){
+ var cTask = this.cTaskItem[0];
+ var posParentTaskItem = !this.parentTask ? 0 : parseInt(this.parentTask.cTaskItem[0].style.left);
+ var widthParentTaskItem = !this.parentTask ? 0 : parseInt(this.parentTask.cTaskItem[0].childNodes[0].firstChild.width);
+ var posTaskItem = parseInt(cTask.style.left);
+ var childPredPosX = 0;
+ var childParentPosX = 0;
+ if(this.childPredTask.length > 0){
+ var posChildTaskItem = null;
+ dojo.forEach(this.childPredTask, function(cpTask){
+ if((!posChildTaskItem) || ((posChildTaskItem) && (posChildTaskItem > parseInt(cpTask.cTaskItem[0].style.left)))){
+ posChildTaskItem = parseInt(cpTask.cTaskItem[0].style.left);
+ }
+ }, this);
+ childPredPosX = posChildTaskItem;
+ }
+ if(this.childTask.length > 0){
+ var posChildTaskItem = null;
+ dojo.forEach(this.childTask, function(cTask){
+ if((!posChildTaskItem) || ((posChildTaskItem) && (posChildTaskItem < (parseInt(cTask.cTaskItem[0].style.left) + parseInt(cTask.cTaskItem[0].firstChild.firstChild.width))))){
+ posChildTaskItem = parseInt(cTask.cTaskItem[0].style.left) + parseInt(cTask.cTaskItem[0].firstChild.firstChild.width);
+ }
+ }, this);
+ childParentPosX = posChildTaskItem;
+ }
+ this.minWidthResize = this.ganttChart.pixelsPerDay;
+ if(this.childTask.length > 0){
+ this.minWidthResize = childParentPosX - posTaskItem;
+ }
+ if((this.childPredTask.length > 0) && (!this.parentTask)){
+ this.maxWidthResize = childPredPosX - posTaskItem;
+ }else if((this.childPredTask.length > 0) && (this.parentTask)){
+ var w1 = posParentTaskItem + widthParentTaskItem - posTaskItem;
+ var w2 = childPredPosX - posTaskItem;
+ this.maxWidthResize = Math.min(w1, w2);
+ }else if((this.childPredTask.length == 0) && (this.parentTask)){
+ this.maxWidthResize = posParentTaskItem + widthParentTaskItem - posTaskItem;
+ }
+ },
+ createTaskItem: function(){
+ this.posX = this.ganttChart.getPosOnDate(this.taskItem.startTime);
+ var itemControl = dojo.create("div", {
+ id: this.taskItem.id,
+ className: "ganttTaskItemControl"
+ });
+ dojo.style(itemControl, {
+ left: this.posX + "px",
+ top: this.posY + "px"
+ });
+ var divTaskItem = dojo.create("div", {className: "ganttTaskDivTaskItem"}, itemControl);
+ var tblTaskItem = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0",
+ width: this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px",
+ className: "ganttTaskTblTaskItem"
+ }, divTaskItem);
+ var rowTblTask = tblTaskItem.insertRow(tblTaskItem.rows.length);
+ if(this.taskItem.percentage != 0){
+ var cellTblTask = dojo.create("td", {
+ height: this.ganttChart.heightTaskItem + "px",
+ width: this.taskItem.percentage + "%"
+ }, rowTblTask);
+ cellTblTask.style.lineHeight = "1px";
+ var imageProgress = dojo.create("div", {
+ className: "ganttImageTaskProgressFilled"
+ }, cellTblTask);
+ dojo.style(imageProgress, {
+ width: (this.taskItem.percentage * this.taskItem.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ if(this.taskItem.percentage != 100){
+ var cellTblTask = dojo.create("td", {
+ height: this.ganttChart.heightTaskItem + "px",
+ width: (100 - this.taskItem.percentage) + "%"
+ }, rowTblTask);
+ cellTblTask.style.lineHeight = "1px";
+ var imageProgressFill = dojo.create("div", {
+ className: "ganttImageTaskProgressBg"
+ }, cellTblTask);
+ dojo.style(imageProgressFill, {
+ width: ((100 - this.taskItem.percentage) * this.taskItem.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ if(this.ganttChart.isContentEditable){
+ var divTaskInfo = dojo.create("div", {className: "ganttTaskDivTaskInfo"}, itemControl);
+ var tblTaskInfo = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0",
+ height: this.ganttChart.heightTaskItem + "px",
+ width: this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px"
+ }, divTaskInfo);
+ var rowTaskInfo = tblTaskInfo.insertRow(0);
+ var cellTaskInfo = dojo.create("td", {
+ align: "center",
+ vAlign: "top",
+ height: this.ganttChart.heightTaskItem + "px",
+ className: "ganttMoveInfo"
+ }, rowTaskInfo);
+ var divTaskName = dojo.create("div", {className: "ganttTaskDivTaskName"}, itemControl);
+ var divMove = dojo.create("div", {}, divTaskName);
+ dojo.create("input", {
+ className: "ganttTaskDivMoveInput",
+ type: "text"
+ }, divMove);
+ dojo.isIE && dojo.style(divMove, {
+ background: "#000000",
+ filter: "alpha(opacity=0)"
+ });
+ dojo.style(divMove, {
+ height: this.ganttChart.heightTaskItem + "px",
+ width: this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px"
+ });
+ //Creation resize area
+ var divResize = dojo.create("div", {className: "ganttTaskDivResize"}, divTaskName);
+ dojo.create("input", {
+ className: "ganttTaskDivResizeInput",
+ type: "text"
+ }, divResize);
+ dojo.style(divResize, {
+ left: (this.taskItem.duration * this.ganttChart.pixelsPerWorkHour - 10) + "px",
+ height: this.ganttChart.heightTaskItem + "px",
+ width: "10px"
+ });
+ this.ganttChart._events.push(
+ dojo.connect(divMove, "onmousedown", this, function(event){
+ //start move
+ this.moveMoveConn = dojo.connect(document, "onmousemove", this, function(e){
+ this.checkMove && this.moveItem(e);
+ });
+ this.moveUpConn = dojo.connect(document, "onmouseup", this, function(e){
+ if(this.checkMove){
+ this.endMove();
+ this.ganttChart.isMoving = false;
+ document.body.releaseCapture && document.body.releaseCapture();
+ dojo.disconnect(this.moveMoveConn);
+ dojo.disconnect(this.moveUpConn);
+ }
+ });
+ this.startMove(event);
+ this.ganttChart.isMoving = true;
+ document.body.setCapture && document.body.setCapture(false);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divMove, "onmouseover", this, function(event){
+ event.target && (event.target.style.cursor = "move");
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divMove, "onmouseout", this, function(event){
+ event.target.style.cursor = "";
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divResize, "onmousedown", this, function(event){
+ //start resize
+ this.resizeMoveConn = dojo.connect(document, "onmousemove", this, function(e){
+ this.checkResize && this.resizeItem(e);
+ });
+ this.resizeUpConn = dojo.connect(document, "onmouseup", this, function(e){
+ if(this.checkResize){
+ this.endResizeItem();
+ this.ganttChart.isResizing = false;
+ document.body.releaseCapture && document.body.releaseCapture();
+ dojo.disconnect(this.resizeMoveConn);
+ dojo.disconnect(this.resizeUpConn);
+ }
+ });
+ this.startResize(event);
+ this.ganttChart.isResizing = true;
+ document.body.setCapture && document.body.setCapture(false);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divResize, "onmouseover", this, function(event){
+ (!this.ganttChart.isMoving) && (!this.ganttChart.isResizing) && event.target && (event.target.style.cursor = "e-resize");
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divResize, "onmouseout", this, function(event){
+ !this.checkResize && event.target && (event.target.style.cursor = "");
+ })
+ );
+ }
+ return itemControl;
+ },
+ createTaskNameItem: function(){
+ var divName = dojo.create("div", {
+ id: this.taskItem.id,
+ className: "ganttTaskTaskNameItem",
+ title: this.taskItem.name + ", id: " + this.taskItem.id + " ",
+ innerHTML: this.taskItem.name
+ });
+ dojo.style(divName, "top", this.posY + "px");
+ dojo.attr(divName, "tabIndex", 0);
+ if(this.ganttChart.isShowConMenu){
+ this.ganttChart._events.push(
+ dojo.connect(divName, "onmouseover", this, function(event){
+ dojo.addClass(divName, "ganttTaskTaskNameItemHover");
+ clearTimeout(this.ganttChart.menuTimer);
+ this.ganttChart.tabMenu.clear();
+ this.ganttChart.tabMenu.show(event.target, this);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divName, "onkeydown", this, function(event){
+ if(event.keyCode == dojo.keys.ENTER){
+ this.ganttChart.tabMenu.clear();
+ this.ganttChart.tabMenu.show(event.target, this);
+ }
+ if(this.ganttChart.tabMenu.isShow && (event.keyCode == dojo.keys.LEFT_ARROW || event.keyCode == dojo.keys.RIGHT_ARROW)){
+ dijit.focus(this.ganttChart.tabMenu.menuPanel.firstChild.rows[0].cells[0]);
+ }
+ if(this.ganttChart.tabMenu.isShow && event.keyCode == dojo.keys.ESCAPE){
+ this.ganttChart.tabMenu.hide();
+ }
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divName, "onmouseout", this, function(){
+ dojo.removeClass(divName, "ganttTaskTaskNameItemHover");
+ clearTimeout(this.ganttChart.menuTimer);
+ this.ganttChart.menuTimer = setTimeout(dojo.hitch(this, function(){
+ this.ganttChart.tabMenu.hide();
+ }), 200);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(this.ganttChart.tabMenu.menuPanel, "onmouseover", this, function(){
+ clearTimeout(this.ganttChart.menuTimer);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(this.ganttChart.tabMenu.menuPanel, "onkeydown", this, function(event){
+ if(this.ganttChart.tabMenu.isShow && event.keyCode == dojo.keys.ESCAPE){
+ this.ganttChart.tabMenu.hide();
+ }
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(this.ganttChart.tabMenu.menuPanel, "onmouseout", this, function(){
+ clearTimeout(this.ganttChart.menuTimer);
+ this.ganttChart.menuTimer = setTimeout(dojo.hitch(this, function(){
+ this.ganttChart.tabMenu.hide();
+ }), 200);
+ })
+ );
+ }
+ return divName;
+ },
+ createTaskDescItem: function(){
+ var posX = (this.posX + this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ var divDesc = dojo.create("div", {
+ innerHTML: this.objKeyToStr(this.getTaskOwner()),
+ className: "ganttTaskDescTask"
+ });
+ dojo.style(divDesc, {
+ left: posX + "px",
+ top: this.posY + "px"
+ });
+ return this.descrTask = divDesc;
+ },
+ checkWidthTaskNameItem: function(){
+ if(this.cTaskNameItem[0].offsetWidth + this.cTaskNameItem[0].offsetLeft > this.ganttChart.maxWidthTaskNames){
+ var width = this.cTaskNameItem[0].offsetWidth + this.cTaskNameItem[0].offsetLeft - this.ganttChart.maxWidthTaskNames;
+ var countChar = Math.round(width / (this.cTaskNameItem[0].offsetWidth / this.cTaskNameItem[0].firstChild.length));
+ var tName = this.taskItem.name.substring(0, this.cTaskNameItem[0].firstChild.length - countChar - 3);
+ tName += "...";
+ this.cTaskNameItem[0].innerHTML = tName;
+ }
+ },
+ refreshTaskItem: function(itemControl){
+ this.posX = this.ganttChart.getPosOnDate(this.taskItem.startTime);
+ dojo.style(itemControl, {
+ "left": this.posX + "px"
+ });
+ var divTaskItem = itemControl.childNodes[0];
+ var tblTaskItem = divTaskItem.firstChild;
+ tblTaskItem.width = (!this.taskItem.duration ? 1 : this.taskItem.duration * this.ganttChart.pixelsPerWorkHour) + "px";
+ var rowTblTask = tblTaskItem.rows[0];
+ if(this.taskItem.percentage != 0){
+ var cellTblTask = rowTblTask.firstChild;
+ cellTblTask.height = this.ganttChart.heightTaskItem + "px";
+ cellTblTask.width = this.taskItem.percentage + "%";
+ cellTblTask.style.lineHeight = "1px";
+ var imageProgress = cellTblTask.firstChild;
+ dojo.style(imageProgress, {
+ width: (!this.taskItem.duration ? 1 : (this.taskItem.percentage * this.taskItem.duration * this.ganttChart.pixelsPerWorkHour / 100)) + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ if(this.taskItem.percentage != 100){
+ var cellTblTask = rowTblTask.lastChild;
+ cellTblTask.height = this.ganttChart.heightTaskItem + "px";
+ cellTblTask.width = (100 - this.taskItem.percentage) + "%";
+ cellTblTask.style.lineHeight = "1px";
+ var imageProgressFill = cellTblTask.firstChild;
+ dojo.style(imageProgressFill, {
+ width: (!this.taskItem.duration ? 1 : ((100 - this.taskItem.percentage) * this.taskItem.duration * this.ganttChart.pixelsPerWorkHour / 100)) + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ if(this.ganttChart.isContentEditable){
+ var divTaskInfo = itemControl.childNodes[1];
+ var tblTaskInfo = divTaskInfo.firstChild;
+ tblTaskInfo.height = this.ganttChart.heightTaskItem + "px";
+ tblTaskInfo.width = (!this.taskItem.duration ? 1 : (this.taskItem.duration * this.ganttChart.pixelsPerWorkHour)) + "px";
+ var rowTaskInfo = tblTaskInfo.rows[0];
+ var cellTaskInfo = rowTaskInfo.firstChild;
+ cellTaskInfo.height = this.ganttChart.heightTaskItem + "px";
+ var divTaskName = itemControl.childNodes[2];
+ var divMove = divTaskName.firstChild;
+ divMove.style.height = this.ganttChart.heightTaskItem + "px";
+ divMove.style.width = (!this.taskItem.duration ? 1 : (this.taskItem.duration * this.ganttChart.pixelsPerWorkHour)) + "px";
+ //Creation resize area
+ var divResize = divTaskName.lastChild;
+ dojo.style(divResize, {
+ "left": (this.taskItem.duration * this.ganttChart.pixelsPerWorkHour - 10) + "px"
+ });
+ divResize.style.height = this.ganttChart.heightTaskItem + "px";
+ divResize.style.width = "10px";
+ }
+ return itemControl;
+ },
+ refreshTaskDesc: function(divDesc){
+ var posX = (this.posX + this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ dojo.style(divDesc, {
+ "left": posX + "px"
+ });
+ return divDesc;
+ },
+ refreshConnectingLinesDS: function(arrLines){
+ var arrowImg = arrLines[1];
+ var lineVerticalRight = arrLines[0];
+ //horizontal line
+ var lineHorizontal = arrLines[2];
+ var posXPreviousTask = dojo.style(this.predTask.cTaskItem[0], "left");
+ var posYPreviousTask = dojo.style(this.predTask.cTaskItem[0], "top");
+ var posXChildTask = dojo.style(this.cTaskItem[0], "left");
+ var posYChildTask = this.posY + 2;
+ //width task item
+ var widthChildTask = parseInt(this.predTask.cTaskItem[0].firstChild.firstChild.width);
+ var widthPreviousTask = parseInt(this.predTask.cTaskItem[0].firstChild.firstChild.width);
+ if(posYPreviousTask < posYChildTask){
+ dojo.style(lineVerticalRight, {
+ "height": (posYChildTask - this.ganttChart.heightTaskItem / 2 - posYPreviousTask - 3) + "px",
+ "left": (posXPreviousTask + widthPreviousTask - 20) + "px"
+ });
+ dojo.style(lineHorizontal, {
+ "width": (15 + (posXChildTask - (widthPreviousTask + posXPreviousTask))) + "px",
+ "left": (posXPreviousTask + widthPreviousTask - 20) + "px"
+ });
+
+ dojo.style(arrowImg, {
+ "left": (posXChildTask - 7) + "px"
+ });
+ }else{
+ dojo.style(lineVerticalRight, {
+ "height": (posYPreviousTask + 2 - posYChildTask) + "px",
+ "left": (posXPreviousTask + widthPreviousTask - 20) + "px"
+ });
+ dojo.style(lineHorizontal, {
+ "width": (15 + (posXChildTask - (widthPreviousTask + posXPreviousTask))) + "px",
+ "left": (posXPreviousTask + widthPreviousTask - 20) + "px"
+ });
+ dojo.style(arrowImg, {
+ "left": (posXChildTask - 7) + "px"
+ });
+ }
+ return arrLines;
+ },
+ postLoadData: function(){
+ //TODO e.g. task relative info...
+ },
+ refresh: function(){
+ if(this.childTask && this.childTask.length > 0){
+ dojo.forEach(this.childTask, function(cTask){
+ cTask.refresh();
+ }, this);
+ }
+ //creation task item
+ this.refreshTaskItem(this.cTaskItem[0]);
+ this.refreshTaskDesc(this.cTaskItem[0].nextSibling);
+ //Create Connecting Lines
+ var arrConnectingLines = [];
+ if(this.taskItem.previousTask && this.predTask){
+ this.refreshConnectingLinesDS(this.cTaskItem[1]);
+ }
+ return this;
+ },
+ create: function(){
+ var containerTasks = this.ganttChart.contentData.firstChild;
+ var containerNames = this.ganttChart.panelNames.firstChild;
+ var previousTask = this.taskItem.previousTask;
+ var parentTask = this.taskItem.parentTask;
+ var isCParentTask = (this.taskItem.cldTasks.length > 0) ? true : false;
+ this.cTaskItem = [];
+ this.cTaskNameItem = [];
+ //creation arrTasks
+ if(!parentTask){
+ if(this.taskItem.previousParentTask){
+ this.previousParentTask = this.project.getTaskById(this.taskItem.previousParentTask.id);
+ var lastChildTask = this.ganttChart.getLastChildTask(this.previousParentTask);
+ this.posY = parseInt(lastChildTask.cTaskItem[0].style.top)
+ + this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ this.previousParentTask.nextParentTask = this;
+ }else{
+ this.posY = parseInt(this.project.projectItem[0].style.top)
+ + this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ }
+ }
+ if(parentTask){
+ var task = this.project.getTaskById(this.taskItem.parentTask.id);
+ this.parentTask = task;
+
+ if(this.taskItem.previousChildTask){
+ this.previousChildTask = this.project.getTaskById(this.taskItem.previousChildTask.id);
+ var lastChildTask = this.ganttChart.getLastChildTask(this.previousChildTask);
+ this.posY = dojo.style(lastChildTask.cTaskItem[0], "top")
+ + this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ this.previousChildTask.nextChildTask = this;
+ }else{
+ this.posY = dojo.style(task.cTaskItem[0], "top")
+ + this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ }
+ task.childTask.push(this);
+ }
+ if(previousTask){
+ var task = this.project.getTaskById(previousTask.id);
+ this.predTask = task;
+ task.childPredTask.push(this);
+ }
+ //creation task item
+ this.cTaskItem.push(this.createTaskItem());
+ containerTasks.appendChild(this.cTaskItem[0]);
+ if(this.ganttChart.panelNames){
+ this.cTaskNameItem.push(this.createTaskNameItem());
+ this.ganttChart.panelNames.firstChild.appendChild(this.cTaskNameItem[0]);
+ }
+ containerTasks.appendChild(this.createTaskDescItem());
+ //Create Connecting Lines
+ var arrConnectingLines = [];
+ if(previousTask){
+ arrConnectingLines = this.createConnectingLinesDS();
+ }
+ this.cTaskItem.push(arrConnectingLines);
+ if(this.ganttChart.panelNames){
+ //Create Connecting Lines
+ var arrConnectingLinesNames = [];
+ if(parentTask){
+ this.cTaskNameItem[0].style.left = dojo.style(this.parentTask.cTaskNameItem[0], "left") + 15 + "px";
+ arrConnectingLinesNames = this.createConnectingLinesPN();
+ }
+ this.checkWidthTaskNameItem();
+ //Identifier
+ this.checkPosition();
+ var treeImg = null;
+ if(isCParentTask){
+ treeImg = this.createTreeImg();
+ }
+ this.cTaskNameItem.push(arrConnectingLinesNames);
+ this.cTaskNameItem.push(treeImg);
+ }
+ this.adjustPanelTime();
+ return this;
+ },
+ checkPosition: function(){
+ //task name position: check Task Identifier
+ if(!this.ganttChart.withTaskId){
+ return;
+ }
+ var pos = dojo.coords(this.cTaskNameItem[0], true);
+ if(this.taskIdentifier){
+ if(this.childTask && this.childTask.length > 0){
+ dojo.forEach(this.childTask, function(cTask){
+ cTask.checkPosition();
+ }, this);
+ }
+ dojo.style(this.taskIdentifier, {
+ "left": (pos.l + pos.w + 4) + "px",
+ "top": (pos.t - 1) + "px"
+ });
+ }else{
+ this.taskIdentifier = dojo.create("div", {
+ id: "TaskId_" + this.taskItem.id,
+ className: "ganttTaskIdentifier",
+ title: this.taskItem.id,
+ innerHTML: this.taskItem.id
+ }, this.cTaskNameItem[0].parentNode);
+ dojo.style(this.taskIdentifier, {
+ left: (pos.l + pos.w + 4) + "px",
+ top: (pos.t - 1) + "px"
+ });
+ }
+ },
+ createTreeImg: function(){
+ var treeImg = dojo.create("div", {
+ id: this.taskItem.id,
+ className: "ganttImageTreeCollapse"
+ });
+ dojo.attr(treeImg, "tabIndex", 0);
+ dojo.forEach(["onclick", "onkeydown"], function(e){
+ this.ganttChart._events.push(
+ dojo.connect(treeImg, e, this, function(evt){
+ if(e == "onkeydown" && evt.keyCode != dojo.keys.ENTER){ return; }
+ if(this.isExpanded){
+ dojo.removeClass(treeImg, "ganttImageTreeCollapse");
+ dojo.addClass(treeImg, "ganttImageTreeExpand");
+ this.isExpanded = false;
+ this.hideChildTasks(this);
+ this.shiftCurrentTasks(this, -this.hideTasksHeight);
+ this.ganttChart.checkPosition();
+ }else{
+ dojo.removeClass(treeImg, "ganttImageTreeExpand");
+ dojo.addClass(treeImg, "ganttImageTreeCollapse");
+ this.isExpanded = true;
+ this.shiftCurrentTasks(this, this.hideTasksHeight);
+ this.showChildTasks(this, true);
+ this.hideTasksHeight = 0;
+ this.ganttChart.checkPosition();
+ }
+ })
+ );
+ }, this);
+ this.ganttChart.panelNames.firstChild.appendChild(treeImg);
+ dojo.addClass(treeImg, "ganttTaskTreeImage");
+ dojo.style(treeImg, {
+ left: (dojo.style(this.cTaskNameItem[0], "left") - 12) + "px",
+ top: (dojo.style(this.cTaskNameItem[0], "top") + 3) + "px"
+ });
+ return treeImg;
+ },
+ setPreviousTask: function(previousTaskId){
+ if(previousTaskId == ""){
+ this.clearPredTask();
+ }else{
+ var task = this.taskItem;
+ if(task.id == previousTaskId){
+ return false;
+ }
+ var predTaskObj = this.project.getTaskById(previousTaskId);
+ if(!predTaskObj){
+ return false;
+ }
+ var predTask = predTaskObj.taskItem;
+ var a1 = predTask.parentTask == null, a2 = task.parentTask == null;
+ if(a1 && !a2 || !a1 && a2 || !a1 && !a2 && (predTask.parentTask.id != task.parentTask.id)){
+ return false;
+ }
+ //check time
+ var startTime = task.startTime.getTime(),
+ pest = predTask.startTime.getTime(),
+ pdur = predTask.duration * 24 * 60 * 60 * 1000 / predTaskObj.ganttChart.hsPerDay;
+ if((pest+pdur) > startTime){
+ return false;
+ }
+ // remove current connection
+ this.clearPredTask();
+ if(!this.ganttChart.checkPosPreviousTask(predTask, task)){
+ this.ganttChart.correctPosPreviousTask(predTask, task, this);
+ }
+ task.previousTaskId = previousTaskId;
+ task.previousTask = predTask;
+ this.predTask = predTaskObj;
+ predTaskObj.childPredTask.push(this);
+ this.cTaskItem[1] = this.createConnectingLinesDS();
+ }
+ return true;
+ },
+ clearPredTask: function(){
+ if(this.predTask){
+ var ch = this.predTask.childPredTask;
+ for(var i = 0; i < ch.length; i++){
+ if(ch[i] == this){
+ ch.splice(i, 1);
+ break;
+ }
+ }
+ for(var i = 0; i < this.cTaskItem[1].length; i++){
+ this.cTaskItem[1][i].parentNode.removeChild(this.cTaskItem[1][i]);
+ }
+ this.cTaskItem[1] = [];
+ this.taskItem.previousTaskId = null;
+ this.taskItem.previousTask = null;
+ this.predTask = null;
+ }
+ },
+ setStartTime: function(startTime, shiftChild){
+ this.moveChild = shiftChild;
+ this.getMoveInfo();
+ var pos = this.ganttChart.getPosOnDate(startTime);
+ if((parseInt(this.cTaskItem[0].firstChild.firstChild.width) + pos > this.maxPosXMove) && (this.maxPosXMove != -1)){
+ this.maxPosXMove = -1;
+ this.minPosXMove = -1;
+ return false;
+ }
+ if(pos < this.minPosXMove){
+ this.maxPosXMove = -1;
+ this.minPosXMove = -1;
+ return false;
+ }
+ this.cTaskItem[0].style.left = pos;
+ var width = pos - this.posX;
+ this.moveCurrentTaskItem(width, shiftChild);
+ this.project.shiftProjectItem();
+ this.descrTask.innerHTML = this.objKeyToStr(this.getTaskOwner());
+ this.adjustPanelTime();
+ this.posX = 0;
+ this.maxPosXMove = -1;
+ this.minPosXMove = -1;
+ return true;
+ },
+ setDuration: function(duration){
+ this.getResizeInfo();
+ var width = this.ganttChart.getWidthOnDuration(duration);
+ if((width > this.maxWidthResize) && (this.maxWidthResize != -1)){
+ return false;
+ }else if(width < this.minWidthResize){
+ return false;
+ }else{
+ this.taskItemWidth = parseInt(this.cTaskItem[0].firstChild.firstChild.width);
+ this.resizeTaskItem(width);
+ this.endResizeItem();
+ this.descrTask.innerHTML = this.objKeyToStr(this.getTaskOwner());
+ return true;
+ }
+ },
+ setTaskOwner: function(owner){
+ owner = (owner == null || owner == undefined) ? "" : owner;
+ this.taskItem.taskOwner = owner;
+ this.descrTask.innerHTML = this.objKeyToStr(this.getTaskOwner());
+ return true;
+ },
+ setPercentCompleted: function(percentage){
+ percentage = parseInt(percentage);
+ if(isNaN(percentage) || percentage > 100 || percentage < 0){
+ return false;
+ }
+ var trow = this.cTaskItem[0].childNodes[0].firstChild.rows[0],
+ rc0 = trow.cells[0], rc1 = trow.cells[1];
+ if((percentage != 0) && (percentage != 100)){
+ if((this.taskItem.percentage != 0) && (this.taskItem.percentage != 100)){
+ rc0.width = percentage + "%";
+ rc1.width = 100 - percentage + "%";
+ }else if((this.taskItem.percentage == 0) || (this.taskItem.percentage == 100)){
+ rc0.parentNode.removeChild(rc0);
+ var cellTblTask = dojo.create("td", {
+ height: this.ganttChart.heightTaskItem + "px",
+ width: percentage + "%"
+ }, trow);
+ cellTblTask.style.lineHeight = "1px";
+ var imageProgressFill = dojo.create("div", {
+ className: "ganttImageTaskProgressFilled"
+ }, cellTblTask);
+ dojo.style(imageProgressFill, {
+ width: (percentage * this.taskItem.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+
+ cellTblTask = dojo.create("td", {
+ height: this.ganttChart.heightTaskItem + "px",
+ width: (100 - percentage) + "%"
+ }, trow);
+ cellTblTask.style.lineHeight = "1px";
+ imageProgressFill = dojo.create("div", {
+ className: "ganttImageTaskProgressBg"
+ }, cellTblTask);
+ dojo.style(imageProgressFill, {
+ width: ((100 - percentage) * this.taskItem.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ }else if(percentage == 0){
+ if((this.taskItem.percentage != 0) && (this.taskItem.percentage != 100)){
+ rc0.parentNode.removeChild(rc0);
+ rc1.width = 100 + "%";
+ }else{
+ dojo.removeClass(rc0.firstChild, "ganttImageTaskProgressFilled");
+ dojo.addClass(rc0.firstChild, "ganttImageTaskProgressBg");
+ }
+ }else if(percentage == 100){
+ if((this.taskItem.percentage != 0) && (this.taskItem.percentage != 100)){
+ rc1.parentNode.removeChild(rc1);
+ rc0.width = 100 + "%";
+ }else{
+ dojo.removeClass(rc0.firstChild, "ganttImageTaskProgressBg");
+ dojo.addClass(rc0.firstChild, "ganttImageTaskProgressFilled");
+ }
+ }
+ this.taskItem.percentage = percentage;
+ this.taskItemWidth = parseInt(this.cTaskItem[0].firstChild.firstChild.width);
+ this.resizeTaskItem(this.taskItemWidth);
+ this.endResizeItem();
+ this.descrTask.innerHTML = this.objKeyToStr(this.getTaskOwner());
+ return true;
+ },
+ setName: function(name){
+ if(name){
+ this.taskItem.name = name;
+ this.cTaskNameItem[0].innerHTML = name;
+ this.cTaskNameItem[0].title = name;
+ this.checkWidthTaskNameItem();
+ this.checkPosition();
+ this.descrTask.innerHTML = this.objKeyToStr(this.getTaskOwner());
+ this.adjustPanelTime();
+ }
+ }
+});
+
+dojo.declare("dojox.gantt.GanttTaskItem", null, {
+ constructor: function(configuration){
+ //id is required
+ this.id = configuration.id;
+ this.name = configuration.name || this.id;
+ this.startTime = configuration.startTime || new Date();
+ this.duration = configuration.duration || 8;
+ this.percentage = configuration.percentage || 0;
+ this.previousTaskId = configuration.previousTaskId || "";
+ this.taskOwner = configuration.taskOwner || "";
+ this.cldTasks = [];
+ this.cldPreTasks = [];
+ this.parentTask = null;
+ this.previousTask = null;
+ this.project = null;
+ this.nextChildTask = null;
+ this.previousChildTask = null;
+ this.nextParentTask = null;
+ this.previousParentTask = null;
+ },
+ addChildTask: function(task){
+ this.cldTasks.push(task);
+ task.parentTask = this;
+ },
+ setProject: function(project){
+ this.project = project;
+ for(var j = 0; j < this.cldTasks.length; j++){
+ this.cldTasks[j].setProject(project);
+ }
+ }
+});
+
+
+}
diff --git a/js/dojo-1.6/dojox/gantt/GanttTaskItem.xd.js b/js/dojo-1.6/dojox/gantt/GanttTaskItem.xd.js new file mode 100644 index 0000000..9740728 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/GanttTaskItem.xd.js @@ -0,0 +1,1373 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.gantt.GanttTaskItem"],
+["require", "dojo.date.locale"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.gantt.GanttTaskItem"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.gantt.GanttTaskItem"] = true;
+dojo.provide("dojox.gantt.GanttTaskItem");
+
+dojo.require("dojo.date.locale");
+
+dojo.declare("dojox.gantt.GanttTaskControl", null, {
+ constructor: function(taskInfo, project, chart){
+ this.ganttChart = chart;
+ this.project = project;
+ this.taskItem = taskInfo;
+ //control variables
+ this.checkMove = false;
+ this.checkResize = false;
+ this.moveChild = false;
+ this.maxPosXMove = -1;
+ this.minPosXMove = -1;
+ this.maxWidthResize = -1;
+ this.minWidthResize = -1;
+ this.posX = 0;
+ this.posY = 0;
+ this.mouseX = 0;
+ this.taskItemWidth = 0;
+ this.isHide = false;
+ this.hideTasksHeight = 0;
+ this.isExpanded = true;
+ this.descrTask = null;
+ this.cTaskItem = null;
+ this.cTaskNameItem = null;
+ this.parentTask = null;
+ this.predTask = null;
+ this.childTask = [];
+ this.childPredTask = [];
+ this.nextChildTask = null;
+ this.previousChildTask = null;
+ this.nextParentTask = null;
+ this.previousParentTask = null;
+ },
+ createConnectingLinesPN: function(){
+ var arrConnectingLinesNames = [];
+ var lineVerticalLeft = dojo.create("div", {
+ innerHTML: " ",
+ className: "ganttTaskLineVerticalLeft"
+ }, this.ganttChart.panelNames.firstChild);
+ var cTaskName = this.cTaskNameItem[0], pcTaskName = this.parentTask.cTaskNameItem[0];
+ dojo.style(lineVerticalLeft, {
+ height: (cTaskName.offsetTop - pcTaskName.offsetTop) + "px",
+ top: (pcTaskName.offsetTop + 5) + "px",
+ left: (pcTaskName.offsetLeft - 9) + "px"
+ });
+ var LineHorizontalLeft = dojo.create("div", {
+ noShade: true,
+ color: "#000000",
+ className: "ganttTaskLineHorizontalLeft"
+ }, this.ganttChart.panelNames.firstChild);
+ dojo.style(LineHorizontalLeft, {
+ left: (pcTaskName.offsetLeft - 9) + "px",
+ top: (cTaskName.offsetTop + 5) + "px",
+ height: "1px",
+ width: (cTaskName.offsetLeft - pcTaskName.offsetLeft + 4) + "px"
+ });
+ arrConnectingLinesNames.push(lineVerticalLeft);
+ arrConnectingLinesNames.push(LineHorizontalLeft);
+ return arrConnectingLinesNames;
+ },
+ createConnectingLinesDS: function(){
+ var contentData = this.ganttChart.contentData.firstChild;
+ var arrLines = [];
+ var arrowImg = new Image();
+ var arrowImg = dojo.create("div", {
+ className: "ganttImageArrow"
+ });
+ //vertical line
+ var lineVerticalRight = document.createElement("div");
+ //horizontal line
+ var lineHorizontal = document.createElement("div");
+ var posXPreviousTask = dojo.style(this.predTask.cTaskItem[0], "left");
+ var posYPreviousTask = dojo.style(this.predTask.cTaskItem[0], "top");
+ var posXChildTask = dojo.style(this.cTaskItem[0], "left");
+ var posYChildTask = this.posY + 2;
+ //width task item
+ var widthChildTask = parseInt(this.predTask.cTaskItem[0].firstChild.firstChild.width);
+ var widthPreviousTask = parseInt(this.predTask.cTaskItem[0].firstChild.firstChild.width);
+ if(posYPreviousTask < posYChildTask){
+ dojo.addClass(lineVerticalRight, "ganttTaskLineVerticalRight");
+ dojo.style(lineVerticalRight, {
+ height: (posYChildTask - this.ganttChart.heightTaskItem / 2 - posYPreviousTask - 3) + "px",
+ width: "1px",
+ left: (posXPreviousTask + widthPreviousTask - 20) + "px",
+ top: (posYPreviousTask + this.ganttChart.heightTaskItem) + "px"
+ });
+ dojo.addClass(lineHorizontal, "ganttTaskLineHorizontal");
+ dojo.style(lineHorizontal, {
+ width: (15 + (posXChildTask - (widthPreviousTask + posXPreviousTask))) + "px",
+ left: (posXPreviousTask + widthPreviousTask - 20) + "px",
+ top: (posYChildTask + 2) + "px"
+ });
+ dojo.addClass(arrowImg, "ganttTaskArrowImg");
+ dojo.style(arrowImg, {
+ left: (posXChildTask - 7) + "px",
+ top: (posYChildTask - 1) + "px"
+ });
+ }else{
+ dojo.addClass(lineVerticalRight, "ganttTaskLineVerticalRightPlus");
+ dojo.style(lineVerticalRight, {
+ height: (posYPreviousTask + 2 - posYChildTask) + "px",
+ width: "1px",
+ left: (posXPreviousTask + widthPreviousTask - 20) + "px",
+ top: (posYChildTask + 2) + "px"
+ });
+ dojo.addClass(lineHorizontal, "ganttTaskLineHorizontalPlus");
+ dojo.style(lineHorizontal, {
+ width: (15 + (posXChildTask - (widthPreviousTask + posXPreviousTask))) + "px",
+ left: (posXPreviousTask + widthPreviousTask - 20) + "px",
+ top: (posYChildTask + 2) + "px"
+ });
+ dojo.addClass(arrowImg, "ganttTaskArrowImgPlus");
+ dojo.style(arrowImg, {
+ left: (posXChildTask - 7) + "px",
+ top: (posYChildTask - 1) + "px"
+ });
+ }
+ contentData.appendChild(lineVerticalRight);
+ contentData.appendChild(lineHorizontal);
+ contentData.appendChild(arrowImg);
+ arrLines.push(lineVerticalRight);
+ arrLines.push(arrowImg);
+ arrLines.push(lineHorizontal);
+ return arrLines;
+ },
+ showChildTasks: function(task, isOpen){
+ if(isOpen){
+ for(var i = 0; i < task.childTask.length; i++){
+ var cTask = task.childTask[i],
+ cTaskItem0 = cTask.cTaskItem[0], cTaskName0 = cTask.cTaskNameItem[0],
+ cTaskItem1 = cTask.cTaskItem[1], cTaskName1 = cTask.cTaskNameItem[1],
+ cTaskItem2 = cTask.cTaskItem[2], cTaskName2 = cTask.cTaskNameItem[2];
+ if(cTaskItem0.style.display == "none"){
+ cTaskItem0.style.display = "inline";
+ cTaskName0.style.display = "inline";
+ cTask.showDescTask();
+ task.isHide = false;
+ if(cTaskName2){
+ cTaskName2.style.display = "inline";
+ isOpen = cTask.isExpanded;
+ }
+ for(var k = 0; k < cTaskItem1.length; k++){
+ cTaskItem1[k].style.display = "inline";
+ }
+ for(var k = 0; k < cTaskName1.length; k++){
+ cTaskName1[k].style.display = "inline";
+ }
+ (cTask.taskIdentifier) && (cTask.taskIdentifier.style.display = "inline");
+ this.hideTasksHeight += this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ if(cTask.childTask.length > 0){
+ this.showChildTasks(cTask, isOpen);
+ }
+ }
+ }
+ }
+ },
+ hideChildTasks: function(task){
+ for(var i = 0; i < task.childTask.length; i++){
+ var cTask = task.childTask[i],
+ cTaskItem0 = cTask.cTaskItem[0], cTaskName0 = cTask.cTaskNameItem[0],
+ cTaskItem1 = cTask.cTaskItem[1], cTaskName1 = cTask.cTaskNameItem[1],
+ cTaskItem2 = cTask.cTaskItem[2], cTaskName2 = cTask.cTaskNameItem[2];
+ if(cTaskItem0.style.display != "none"){
+ cTaskItem0.style.display = "none";
+ cTaskName0.style.display = "none";
+ cTask.hideDescTask();
+ task.isHide = true;
+ if(cTaskName2){
+ cTaskName2.style.display = "none";
+ }
+ for(var k = 0; k < cTaskItem1.length; k++){
+ cTaskItem1[k].style.display = "none";
+ }
+ for(var k = 0; k < cTaskName1.length; k++){
+ cTaskName1[k].style.display = "none";
+ }
+ (cTask.taskIdentifier) && (cTask.taskIdentifier.style.display = "none");
+ this.hideTasksHeight += (this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra);
+ if(cTask.childTask.length > 0){
+ this.hideChildTasks(cTask);
+ }
+ }
+ }
+ },
+ shiftCurrentTasks: function(task, height){
+ this.shiftNextTask(this, height);
+ task.project.shiftNextProject(task.project, height);
+ },
+ shiftTask: function(task, height){
+ task.posY = task.posY + height;
+ var taskItem0 = task.cTaskItem[0], taskName0 = task.cTaskNameItem[0],
+ taskItem1 = task.cTaskItem[1], taskName1 = task.cTaskNameItem[1],
+ taskItem2 = task.cTaskItem[2], taskName2 = task.cTaskNameItem[2];
+ taskName0.style.top = parseInt(taskName0.style.top) + height + "px";
+ if(taskName2){
+ taskName2.style.top = parseInt(taskName2.style.top) + height + "px";
+ }
+ if(task.parentTask){
+ if(parseInt(this.cTaskNameItem[0].style.top) > parseInt(task.parentTask.cTaskNameItem[0].style.top) &&
+ (taskName1[0].style.display != "none")){
+ taskName1[0].style.height = parseInt(taskName1[0].style.height) + height + "px";
+ }else{
+ taskName1[0].style.top = parseInt(taskName1[0].style.top) + height + "px";
+ }
+ taskName1[1].style.top = parseInt(taskName1[1].style.top) + height + "px";
+ }
+ taskItem0.style.top = parseInt(taskItem0.style.top) + height + "px";
+ task.descrTask.style.top = parseInt(task.descrTask.style.top) + height + "px";
+ if(task.predTask){
+ if(((parseInt(this.cTaskItem[0].style.top) > parseInt(task.predTask.cTaskItem[0].style.top)) ||
+ (this.cTaskItem[0].id == task.predTask.taskItem.id)) &&
+ taskItem1[0].style.display != "none"){
+ taskItem1[0].style.height = parseInt(taskItem1[0].style.height) + height + "px";
+ }else{
+ taskItem1[0].style.top = parseInt(taskItem1[0].style.top) + height + "px";
+ }
+ taskItem1[1].style.top = parseInt(taskItem1[1].style.top) + height + "px";
+ taskItem1[2].style.top = parseInt(taskItem1[2].style.top) + height + "px";
+ }
+ },
+ shiftNextTask: function(task, height){
+ if(task.nextChildTask){
+ this.shiftTask(task.nextChildTask, height);
+ this.shiftChildTask(task.nextChildTask, height);
+ this.shiftNextTask(task.nextChildTask, height);
+ }else if(task.parentTask){
+ this.shiftNextTask(task.parentTask, height);
+ }else if(task.nextParentTask){
+ this.shiftTask(task.nextParentTask, height);
+ this.shiftChildTask(task.nextParentTask, height);
+ this.shiftNextTask(task.nextParentTask, height);
+ }
+ },
+ shiftChildTask: function(task, height){
+ dojo.forEach(task.childTask, function(cTask){
+ this.shiftTask(cTask, height);
+ if(cTask.childTask.length > 0){
+ this.shiftChildTask(cTask, height);
+ }
+ }, this);
+ },
+ endMove: function(){
+ var cTask0 = this.cTaskItem[0];
+ var width = dojo.style(cTask0, "left") - this.posX;
+ var startTime = this.getDateOnPosition(dojo.style(cTask0, "left"));
+ startTime = this.checkPos(startTime);
+ if(this.checkMove){
+ width = this.ganttChart.getPosOnDate(startTime) - this.posX;
+ this.moveCurrentTaskItem(width, this.moveChild);
+ this.project.shiftProjectItem();
+ }
+ this.checkMove = false;
+ this.posX = 0;
+ this.maxPosXMove = -1;
+ this.minPosXMove = -1;
+ cTask0.childNodes[1].firstChild.rows[0].cells[0].innerHTML = "";
+ this.adjustPanelTime();
+ if(this.ganttChart.resource){
+ this.ganttChart.resource.refresh();
+ }
+ },
+ checkPos: function(startTime){
+ var cTask0 = this.cTaskItem[0];
+ var h = startTime.getHours();
+ if(h >= 12){
+ startTime.setDate(startTime.getDate() + 1);
+ startTime.setHours(0);
+ if((parseInt(cTask0.firstChild.firstChild.width) + this.ganttChart.getPosOnDate(startTime) > this.maxPosXMove) && (this.maxPosXMove != -1)){
+ startTime.setDate(startTime.getDate() - 1);
+ startTime.setHours(0);
+ }
+ }else if((h < 12) && (h != 0)){
+ startTime.setHours(0);
+ if((this.ganttChart.getPosOnDate(startTime) < this.minPosXMove)){
+ startTime.setDate(startTime.getDate() + 1);
+ }
+ }
+ cTask0.style.left = this.ganttChart.getPosOnDate(startTime) + "px";
+ return startTime;
+ },
+ getMaxPosPredChildTaskItem: function(){
+ var posPredChildTaskItem = 0;
+ var nextPosPredChildTaskItem = 0;
+ for(var i = 0; i < this.childPredTask.length; i++){
+ nextPosPredChildTaskItem = this.getMaxPosPredChildTaskItemInTree(this.childPredTask[i]);
+ if(nextPosPredChildTaskItem > posPredChildTaskItem){
+ posPredChildTaskItem = nextPosPredChildTaskItem;
+ }
+ }
+ return posPredChildTaskItem;
+ },
+ getMaxPosPredChildTaskItemInTree: function(task){
+ var cTask0 = task.cTaskItem[0];
+ var currentPos = parseInt(cTask0.firstChild.firstChild.width) + dojo.style(cTask0, "left");
+ var posPredChildTaskItem = 0;
+ var nextPosPredChildTaskItem = 0;
+ dojo.forEach(task.childPredTask, function(cpTask){
+ nextPosPredChildTaskItem = this.getMaxPosPredChildTaskItemInTree(cpTask);
+ if(nextPosPredChildTaskItem > posPredChildTaskItem){
+ posPredChildTaskItem = nextPosPredChildTaskItem;
+ }
+ }, this);
+ return posPredChildTaskItem > currentPos ? posPredChildTaskItem : currentPos;
+ },
+ moveCurrentTaskItem: function(width, moveChild){
+ var taskItem = this.cTaskItem[0];
+ this.taskItem.startTime = new Date(this.ganttChart.startDate);
+ this.taskItem.startTime.setHours(this.taskItem.startTime.getHours() + (parseInt(taskItem.style.left) / this.ganttChart.pixelsPerHour));
+ this.showDescTask();
+ var cTask1 = this.cTaskItem[1];
+ if(cTask1.length > 0){
+ cTask1[2].style.width = parseInt(cTask1[2].style.width) + width + "px";
+ cTask1[1].style.left = parseInt(cTask1[1].style.left) + width + "px";
+ }
+ dojo.forEach(this.childTask, function(cTask){
+ if(!cTask.predTask){
+ this.moveChildTaskItems(cTask, width, moveChild);
+ }
+ }, this);
+ dojo.forEach(this.childPredTask, function(cpTask){
+ this.moveChildTaskItems(cpTask, width, moveChild);
+ }, this);
+ },
+ moveChildTaskItems: function(task, width, moveChild){
+ var taskItem = task.cTaskItem[0];
+ if(moveChild){
+ taskItem.style.left = parseInt(taskItem.style.left) + width + "px";
+ task.adjustPanelTime();
+ task.taskItem.startTime = new Date(this.ganttChart.startDate);
+ task.taskItem.startTime.setHours(task.taskItem.startTime.getHours() + (parseInt(taskItem.style.left) / this.ganttChart.pixelsPerHour));
+ var ctItem = task.cTaskItem[1];
+ dojo.forEach(ctItem, function(item){
+ item.style.left = parseInt(item.style.left) + width + "px";
+ }, this);
+ dojo.forEach(task.childTask, function(cTask){
+ if(!cTask.predTask){
+ this.moveChildTaskItems(cTask, width, moveChild);
+ }
+ }, this);
+ dojo.forEach(task.childPredTask, function(cpTask){
+ this.moveChildTaskItems(cpTask, width, moveChild);
+ }, this);
+ }else{
+ var ctItem = task.cTaskItem[1];
+ if(ctItem.length > 0){
+ var item0 = ctItem[0], item2 = ctItem[2];
+ item2.style.left = parseInt(item2.style.left) + width + "px";
+ item2.style.width = parseInt(item2.style.width) - width + "px";
+ item0.style.left = parseInt(item0.style.left) + width + "px";
+ }
+ }
+ task.moveDescTask();
+ },
+ adjustPanelTime: function(){
+ var taskItem = this.cTaskItem[0];
+ var width = parseInt(taskItem.style.left) + parseInt(taskItem.firstChild.firstChild.width) + this.ganttChart.panelTimeExpandDelta;
+ width += this.descrTask.offsetWidth;
+ this.ganttChart.adjustPanelTime(width);
+ },
+ getDateOnPosition: function(position){
+ var date = new Date(this.ganttChart.startDate);
+ date.setHours(date.getHours() + (position / this.ganttChart.pixelsPerHour));
+ return date;
+ },
+ moveItem: function(event){
+ var pageX = event.screenX;
+ var posTaskItem = (this.posX + (pageX - this.mouseX));
+ var widthTaskItem = parseInt(this.cTaskItem[0].childNodes[0].firstChild.width);
+ var posTaskItemR = posTaskItem + widthTaskItem;
+ if(this.checkMove){
+ if(((this.minPosXMove <= posTaskItem)) &&
+ ((posTaskItemR <= this.maxPosXMove) || (this.maxPosXMove == -1))){
+ this.moveTaskItem(posTaskItem);
+ }
+ }
+ },
+ moveTaskItem: function(posX){
+ var cTask = this.cTaskItem[0];
+ cTask.style.left = posX + "px";
+ cTask.childNodes[1].firstChild.rows[0].cells[0].innerHTML = this.getDateOnPosition(posX).getDate() + '.' + (this.getDateOnPosition(posX).getMonth() + 1) + '.' + this.getDateOnPosition(posX).getUTCFullYear();
+ },
+ resizeItem: function(event){
+ if(this.checkResize){
+ var taskItem = this.cTaskItem[0];
+ var mouseX = event.screenX;
+ var width = (mouseX - this.mouseX);
+ var widthTaskItem = this.taskItemWidth + (mouseX - this.mouseX);
+ if(widthTaskItem >= this.taskItemWidth){
+ if((widthTaskItem <= this.maxWidthResize) || (this.maxWidthResize == -1)){
+ this.resizeTaskItem(widthTaskItem);
+ }else if((this.maxWidthResize != -1) && (widthTaskItem > this.maxWidthResize)){
+ this.resizeTaskItem(this.maxWidthResize);
+ }
+ }else if(widthTaskItem <= this.taskItemWidth){
+ if(widthTaskItem >= this.minWidthResize){
+ this.resizeTaskItem(widthTaskItem);
+ }else if(widthTaskItem < this.minWidthResize){
+ this.resizeTaskItem(this.minWidthResize);
+ }
+ }
+ }
+ },
+ resizeTaskItem: function(width){
+ var taskItem = this.cTaskItem[0];
+ var countHours = Math.round(width / this.ganttChart.pixelsPerWorkHour);
+ var trow = taskItem.childNodes[0].firstChild.rows[0],
+ rc0 = trow.cells[0], rc1 = trow.cells[1];
+ rc0 && (rc0.firstChild.style.width = parseInt(rc0.width) * width / 100 + "px");
+ rc1 && (rc1.firstChild.style.width = parseInt(rc1.width) * width / 100 + "px");
+ taskItem.childNodes[0].firstChild.width = width + "px";
+ taskItem.childNodes[1].firstChild.width = width + "px";
+ //resize info
+ this.cTaskItem[0].childNodes[1].firstChild.rows[0].cells[0].innerHTML = countHours;
+ var tcNode2 = taskItem.childNodes[2];
+ tcNode2.childNodes[0].style.width = width + "px";
+ tcNode2.childNodes[1].style.left = width - 10 + "px";
+ },
+ endResizeItem: function(){
+ var taskItem = this.cTaskItem[0];
+ if((this.taskItemWidth != parseInt(taskItem.childNodes[0].firstChild.width))){
+ var posXL = taskItem.offsetLeft;
+ var posXR = taskItem.offsetLeft + parseInt(taskItem.childNodes[0].firstChild.width);
+ var countHours = Math.round((posXR - posXL) / this.ganttChart.pixelsPerWorkHour);
+ this.taskItem.duration = countHours;
+ if(this.childPredTask.length > 0){
+ for(var j = 0; j < this.childPredTask.length; j++){
+ var cpctItem = this.childPredTask[j].cTaskItem[1],
+ item0 = cpctItem[0], item2 = cpctItem[2], tcNode0 = taskItem.childNodes[0];
+ item2.style.width = parseInt(item2.style.width) - (parseInt(tcNode0.firstChild.width) - this.taskItemWidth) + "px";
+ item2.style.left = parseInt(item2.style.left) + (parseInt(tcNode0.firstChild.width) - this.taskItemWidth) + "px";
+ item0.style.left = parseInt(item0.style.left) + (parseInt(tcNode0.firstChild.width) - this.taskItemWidth) + "px";
+ }
+ }
+ }
+ this.cTaskItem[0].childNodes[1].firstChild.rows[0].cells[0].innerHTML = "";
+ this.checkResize = false;
+ this.taskItemWidth = 0;
+ this.mouseX = 0;
+ this.showDescTask();
+ this.project.shiftProjectItem();
+ this.adjustPanelTime();
+ if(this.ganttChart.resource){
+ this.ganttChart.resource.refresh();
+ }
+ },
+ startMove: function(event){
+ this.moveChild = event.ctrlKey;
+ this.mouseX = event.screenX;
+ this.getMoveInfo();
+ this.checkMove = true;
+ this.hideDescTask();
+ },
+ showDescTask: function(){
+ var posX = (parseInt(this.cTaskItem[0].style.left) + this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ this.descrTask.style.left = posX + "px";
+ this.descrTask.innerHTML = this.objKeyToStr(this.getTaskOwner());
+ this.descrTask.style.visibility = 'visible';
+ },
+ hideDescTask: function(){
+ dojo.style(this.descrTask, "visibility", "hidden");
+ },
+ buildResourceInfo: function(resourceInfo){
+ if(this.childTask && this.childTask.length > 0){
+ for(var i = 0; i < this.childTask.length; i++){
+ var cTask = this.childTask[i];
+ cTask.buildResourceInfo(resourceInfo);
+ }
+ }
+ if(dojo.trim(this.taskItem.taskOwner).length > 0){
+ var owners = this.taskItem.taskOwner.split(";");
+ for(var i = 0; i < owners.length; i++){
+ var o = owners[i];
+ if(dojo.trim(o).length <= 0){
+ continue;
+ }
+ resourceInfo[o] ? (resourceInfo[o].push(this)) : (resourceInfo[o] = [this]);
+ }
+ }
+ },
+ objKeyToStr: function(obj, delm){
+ var returnStr = "";
+ delm = delm || " ";
+ if(obj){
+ for(var key in obj){
+ returnStr += delm + key;
+ }
+ }
+ return returnStr;
+ },
+ getTaskOwner: function(){
+ var tOwner = {};
+ if(dojo.trim(this.taskItem.taskOwner).length > 0){
+ var owners = this.taskItem.taskOwner.split(";");
+ for(var i = 0; i < owners.length; i++){
+ var o = owners[i];
+ tOwner[o] = 1;
+ }
+ }
+ dojo.forEach(this.childTask, function(ctask){
+ dojo.mixin(tOwner, ctask.getTaskOwner());
+ }, this);
+ return tOwner;
+ },
+ moveDescTask: function(){
+ var posX = (parseInt(this.cTaskItem[0].style.left) + this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ this.descrTask.style.left = posX + "px";
+ },
+ getMoveInfo: function(){
+ this.posX = parseInt(this.cTaskItem[0].style.left);
+ var widthTaskItem = parseInt(this.cTaskItem[0].childNodes[0].firstChild.width);
+ var posParentTaskItem = !this.parentTask ? 0 : parseInt(this.parentTask.cTaskItem[0].style.left);
+ var posPredTaskItem = !this.predTask ? 0 : parseInt(this.predTask.cTaskItem[0].style.left) + parseInt(this.predTask.cTaskItem[0].childNodes[0].firstChild.width);
+ var widthParentTaskItem = !this.parentTask ? 0 : parseInt(this.parentTask.cTaskItem[0].childNodes[0].firstChild.width);
+
+ var childPredPosX = 0;
+ var childParentPosX = 0;
+ var childParentPosXR = 0;
+ if(this.childPredTask.length > 0){
+ var posChildTaskItem = null;
+ dojo.forEach(this.childPredTask, function(cpTask){
+ if((!posChildTaskItem) || ((posChildTaskItem) && (posChildTaskItem > parseInt(cpTask.cTaskItem[0].style.left)))){
+ posChildTaskItem = parseInt(cpTask.cTaskItem[0].style.left);
+ }
+ }, this);
+ childPredPosX = posChildTaskItem;
+ }
+ if(this.childTask.length > 0){
+ var posChildTaskItemR = null;
+ dojo.forEach(this.childTask, function(cTask){
+ if((!posChildTaskItemR) || ((posChildTaskItemR) && (posChildTaskItemR > (parseInt(cTask.cTaskItem[0].style.left))))){
+ posChildTaskItemR = parseInt(cTask.cTaskItem[0].style.left);
+ }
+ }, this);
+ childParentPosXR = posChildTaskItemR;
+ var posChildTaskItem = null;
+ dojo.forEach(this.childTask, function(cTask){
+ if((!posChildTaskItem) || ((posChildTaskItem)
+ && (posChildTaskItem < (parseInt(cTask.cTaskItem[0].style.left) + parseInt(cTask.cTaskItem[0].firstChild.firstChild.width))))){
+ posChildTaskItem = parseInt(cTask.cTaskItem[0].style.left) + parseInt(cTask.cTaskItem[0].firstChild.firstChild.width);
+ }
+ }, this);
+ childParentPosX = posChildTaskItem;
+ }
+ if(!this.moveChild){
+ if(this.childPredTask.length > 0){
+ if(this.maxPosXMove < childPredPosX) this.maxPosXMove = childPredPosX;
+ }
+ if(this.childTask.length > 0){
+ if((this.childPredTask.length > 0) && (this.maxPosXMove - widthTaskItem) > childParentPosXR){
+ this.maxPosXMove = this.maxPosXMove - ((this.maxPosXMove - widthTaskItem) - childParentPosXR);
+ }
+ if(!(this.childPredTask.length > 0)){
+ this.maxPosXMove = childParentPosXR + widthTaskItem;
+ }
+ this.minPosXMove = (childParentPosX - widthTaskItem);
+ }
+ if(posParentTaskItem > 0){
+ if((!(this.childPredTask.length > 0)) && (this.childTask.length > 0)){
+ if(this.maxPosXMove > posParentTaskItem + widthParentTaskItem){
+ this.maxPosXMove = posParentTaskItem + widthParentTaskItem;
+ }
+ }
+ if(this.minPosXMove <= posParentTaskItem){
+ this.minPosXMove = posParentTaskItem;
+ }
+ if((!(this.childTask.length > 0)) && (!(this.childPredTask.length > 0))){
+ this.maxPosXMove = posParentTaskItem + widthParentTaskItem;
+ }else if((!(this.childTask.length > 0)) && (this.childPredTask.length > 0)){
+ if((posParentTaskItem + widthParentTaskItem) > posPredTaskItem){
+ this.maxPosXMove = childPredPosX;
+ }
+ }
+ }
+ if(posPredTaskItem > 0){
+ if(this.minPosXMove <= posPredTaskItem){
+ this.minPosXMove = posPredTaskItem;
+ }
+ }
+ if((posPredTaskItem == 0) && (posParentTaskItem == 0)){
+ if(this.minPosXMove <= this.ganttChart.initialPos){
+ this.minPosXMove = this.ganttChart.initialPos;
+ }
+ }
+ }else{
+ if((posParentTaskItem > 0) && (posPredTaskItem == 0)){
+ this.minPosXMove = posParentTaskItem;
+ this.maxPosXMove = posParentTaskItem + widthParentTaskItem;
+ }else if((posParentTaskItem == 0) && (posPredTaskItem == 0)){
+ this.minPosXMove = this.ganttChart.initialPos;
+ this.maxPosXMove = -1;
+ }else if((posParentTaskItem > 0) && (posPredTaskItem > 0)){
+ this.minPosXMove = posPredTaskItem;
+ this.maxPosXMove = posParentTaskItem + widthParentTaskItem;
+ }else if((posParentTaskItem == 0) && (posPredTaskItem > 0)){
+ this.minPosXMove = posPredTaskItem;
+ this.maxPosXMove = -1;
+ }
+ if((this.parentTask) && (this.childPredTask.length > 0)){
+ var posChildTaskItem = this.getMaxPosPredChildTaskItem(this);
+ var posParentTaskItem = parseInt(this.parentTask.cTaskItem[0].style.left) + parseInt(this.parentTask.cTaskItem[0].firstChild.firstChild.width);
+ this.maxPosXMove = this.posX + widthTaskItem + posParentTaskItem - posChildTaskItem;
+ }
+ }
+ },
+ startResize: function(event){
+ this.mouseX = event.screenX;
+ this.getResizeInfo();
+ this.hideDescTask();
+ this.checkResize = true;
+ this.taskItemWidth = parseInt(this.cTaskItem[0].firstChild.firstChild.width);
+ },
+ getResizeInfo: function(){
+ var cTask = this.cTaskItem[0];
+ var posParentTaskItem = !this.parentTask ? 0 : parseInt(this.parentTask.cTaskItem[0].style.left);
+ var widthParentTaskItem = !this.parentTask ? 0 : parseInt(this.parentTask.cTaskItem[0].childNodes[0].firstChild.width);
+ var posTaskItem = parseInt(cTask.style.left);
+ var childPredPosX = 0;
+ var childParentPosX = 0;
+ if(this.childPredTask.length > 0){
+ var posChildTaskItem = null;
+ dojo.forEach(this.childPredTask, function(cpTask){
+ if((!posChildTaskItem) || ((posChildTaskItem) && (posChildTaskItem > parseInt(cpTask.cTaskItem[0].style.left)))){
+ posChildTaskItem = parseInt(cpTask.cTaskItem[0].style.left);
+ }
+ }, this);
+ childPredPosX = posChildTaskItem;
+ }
+ if(this.childTask.length > 0){
+ var posChildTaskItem = null;
+ dojo.forEach(this.childTask, function(cTask){
+ if((!posChildTaskItem) || ((posChildTaskItem) && (posChildTaskItem < (parseInt(cTask.cTaskItem[0].style.left) + parseInt(cTask.cTaskItem[0].firstChild.firstChild.width))))){
+ posChildTaskItem = parseInt(cTask.cTaskItem[0].style.left) + parseInt(cTask.cTaskItem[0].firstChild.firstChild.width);
+ }
+ }, this);
+ childParentPosX = posChildTaskItem;
+ }
+ this.minWidthResize = this.ganttChart.pixelsPerDay;
+ if(this.childTask.length > 0){
+ this.minWidthResize = childParentPosX - posTaskItem;
+ }
+ if((this.childPredTask.length > 0) && (!this.parentTask)){
+ this.maxWidthResize = childPredPosX - posTaskItem;
+ }else if((this.childPredTask.length > 0) && (this.parentTask)){
+ var w1 = posParentTaskItem + widthParentTaskItem - posTaskItem;
+ var w2 = childPredPosX - posTaskItem;
+ this.maxWidthResize = Math.min(w1, w2);
+ }else if((this.childPredTask.length == 0) && (this.parentTask)){
+ this.maxWidthResize = posParentTaskItem + widthParentTaskItem - posTaskItem;
+ }
+ },
+ createTaskItem: function(){
+ this.posX = this.ganttChart.getPosOnDate(this.taskItem.startTime);
+ var itemControl = dojo.create("div", {
+ id: this.taskItem.id,
+ className: "ganttTaskItemControl"
+ });
+ dojo.style(itemControl, {
+ left: this.posX + "px",
+ top: this.posY + "px"
+ });
+ var divTaskItem = dojo.create("div", {className: "ganttTaskDivTaskItem"}, itemControl);
+ var tblTaskItem = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0",
+ width: this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px",
+ className: "ganttTaskTblTaskItem"
+ }, divTaskItem);
+ var rowTblTask = tblTaskItem.insertRow(tblTaskItem.rows.length);
+ if(this.taskItem.percentage != 0){
+ var cellTblTask = dojo.create("td", {
+ height: this.ganttChart.heightTaskItem + "px",
+ width: this.taskItem.percentage + "%"
+ }, rowTblTask);
+ cellTblTask.style.lineHeight = "1px";
+ var imageProgress = dojo.create("div", {
+ className: "ganttImageTaskProgressFilled"
+ }, cellTblTask);
+ dojo.style(imageProgress, {
+ width: (this.taskItem.percentage * this.taskItem.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ if(this.taskItem.percentage != 100){
+ var cellTblTask = dojo.create("td", {
+ height: this.ganttChart.heightTaskItem + "px",
+ width: (100 - this.taskItem.percentage) + "%"
+ }, rowTblTask);
+ cellTblTask.style.lineHeight = "1px";
+ var imageProgressFill = dojo.create("div", {
+ className: "ganttImageTaskProgressBg"
+ }, cellTblTask);
+ dojo.style(imageProgressFill, {
+ width: ((100 - this.taskItem.percentage) * this.taskItem.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ if(this.ganttChart.isContentEditable){
+ var divTaskInfo = dojo.create("div", {className: "ganttTaskDivTaskInfo"}, itemControl);
+ var tblTaskInfo = dojo.create("table", {
+ cellPadding: "0",
+ cellSpacing: "0",
+ height: this.ganttChart.heightTaskItem + "px",
+ width: this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px"
+ }, divTaskInfo);
+ var rowTaskInfo = tblTaskInfo.insertRow(0);
+ var cellTaskInfo = dojo.create("td", {
+ align: "center",
+ vAlign: "top",
+ height: this.ganttChart.heightTaskItem + "px",
+ className: "ganttMoveInfo"
+ }, rowTaskInfo);
+ var divTaskName = dojo.create("div", {className: "ganttTaskDivTaskName"}, itemControl);
+ var divMove = dojo.create("div", {}, divTaskName);
+ dojo.create("input", {
+ className: "ganttTaskDivMoveInput",
+ type: "text"
+ }, divMove);
+ dojo.isIE && dojo.style(divMove, {
+ background: "#000000",
+ filter: "alpha(opacity=0)"
+ });
+ dojo.style(divMove, {
+ height: this.ganttChart.heightTaskItem + "px",
+ width: this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + "px"
+ });
+ //Creation resize area
+ var divResize = dojo.create("div", {className: "ganttTaskDivResize"}, divTaskName);
+ dojo.create("input", {
+ className: "ganttTaskDivResizeInput",
+ type: "text"
+ }, divResize);
+ dojo.style(divResize, {
+ left: (this.taskItem.duration * this.ganttChart.pixelsPerWorkHour - 10) + "px",
+ height: this.ganttChart.heightTaskItem + "px",
+ width: "10px"
+ });
+ this.ganttChart._events.push(
+ dojo.connect(divMove, "onmousedown", this, function(event){
+ //start move
+ this.moveMoveConn = dojo.connect(document, "onmousemove", this, function(e){
+ this.checkMove && this.moveItem(e);
+ });
+ this.moveUpConn = dojo.connect(document, "onmouseup", this, function(e){
+ if(this.checkMove){
+ this.endMove();
+ this.ganttChart.isMoving = false;
+ document.body.releaseCapture && document.body.releaseCapture();
+ dojo.disconnect(this.moveMoveConn);
+ dojo.disconnect(this.moveUpConn);
+ }
+ });
+ this.startMove(event);
+ this.ganttChart.isMoving = true;
+ document.body.setCapture && document.body.setCapture(false);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divMove, "onmouseover", this, function(event){
+ event.target && (event.target.style.cursor = "move");
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divMove, "onmouseout", this, function(event){
+ event.target.style.cursor = "";
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divResize, "onmousedown", this, function(event){
+ //start resize
+ this.resizeMoveConn = dojo.connect(document, "onmousemove", this, function(e){
+ this.checkResize && this.resizeItem(e);
+ });
+ this.resizeUpConn = dojo.connect(document, "onmouseup", this, function(e){
+ if(this.checkResize){
+ this.endResizeItem();
+ this.ganttChart.isResizing = false;
+ document.body.releaseCapture && document.body.releaseCapture();
+ dojo.disconnect(this.resizeMoveConn);
+ dojo.disconnect(this.resizeUpConn);
+ }
+ });
+ this.startResize(event);
+ this.ganttChart.isResizing = true;
+ document.body.setCapture && document.body.setCapture(false);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divResize, "onmouseover", this, function(event){
+ (!this.ganttChart.isMoving) && (!this.ganttChart.isResizing) && event.target && (event.target.style.cursor = "e-resize");
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divResize, "onmouseout", this, function(event){
+ !this.checkResize && event.target && (event.target.style.cursor = "");
+ })
+ );
+ }
+ return itemControl;
+ },
+ createTaskNameItem: function(){
+ var divName = dojo.create("div", {
+ id: this.taskItem.id,
+ className: "ganttTaskTaskNameItem",
+ title: this.taskItem.name + ", id: " + this.taskItem.id + " ",
+ innerHTML: this.taskItem.name
+ });
+ dojo.style(divName, "top", this.posY + "px");
+ dojo.attr(divName, "tabIndex", 0);
+ if(this.ganttChart.isShowConMenu){
+ this.ganttChart._events.push(
+ dojo.connect(divName, "onmouseover", this, function(event){
+ dojo.addClass(divName, "ganttTaskTaskNameItemHover");
+ clearTimeout(this.ganttChart.menuTimer);
+ this.ganttChart.tabMenu.clear();
+ this.ganttChart.tabMenu.show(event.target, this);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divName, "onkeydown", this, function(event){
+ if(event.keyCode == dojo.keys.ENTER){
+ this.ganttChart.tabMenu.clear();
+ this.ganttChart.tabMenu.show(event.target, this);
+ }
+ if(this.ganttChart.tabMenu.isShow && (event.keyCode == dojo.keys.LEFT_ARROW || event.keyCode == dojo.keys.RIGHT_ARROW)){
+ dijit.focus(this.ganttChart.tabMenu.menuPanel.firstChild.rows[0].cells[0]);
+ }
+ if(this.ganttChart.tabMenu.isShow && event.keyCode == dojo.keys.ESCAPE){
+ this.ganttChart.tabMenu.hide();
+ }
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(divName, "onmouseout", this, function(){
+ dojo.removeClass(divName, "ganttTaskTaskNameItemHover");
+ clearTimeout(this.ganttChart.menuTimer);
+ this.ganttChart.menuTimer = setTimeout(dojo.hitch(this, function(){
+ this.ganttChart.tabMenu.hide();
+ }), 200);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(this.ganttChart.tabMenu.menuPanel, "onmouseover", this, function(){
+ clearTimeout(this.ganttChart.menuTimer);
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(this.ganttChart.tabMenu.menuPanel, "onkeydown", this, function(event){
+ if(this.ganttChart.tabMenu.isShow && event.keyCode == dojo.keys.ESCAPE){
+ this.ganttChart.tabMenu.hide();
+ }
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(this.ganttChart.tabMenu.menuPanel, "onmouseout", this, function(){
+ clearTimeout(this.ganttChart.menuTimer);
+ this.ganttChart.menuTimer = setTimeout(dojo.hitch(this, function(){
+ this.ganttChart.tabMenu.hide();
+ }), 200);
+ })
+ );
+ }
+ return divName;
+ },
+ createTaskDescItem: function(){
+ var posX = (this.posX + this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ var divDesc = dojo.create("div", {
+ innerHTML: this.objKeyToStr(this.getTaskOwner()),
+ className: "ganttTaskDescTask"
+ });
+ dojo.style(divDesc, {
+ left: posX + "px",
+ top: this.posY + "px"
+ });
+ return this.descrTask = divDesc;
+ },
+ checkWidthTaskNameItem: function(){
+ if(this.cTaskNameItem[0].offsetWidth + this.cTaskNameItem[0].offsetLeft > this.ganttChart.maxWidthTaskNames){
+ var width = this.cTaskNameItem[0].offsetWidth + this.cTaskNameItem[0].offsetLeft - this.ganttChart.maxWidthTaskNames;
+ var countChar = Math.round(width / (this.cTaskNameItem[0].offsetWidth / this.cTaskNameItem[0].firstChild.length));
+ var tName = this.taskItem.name.substring(0, this.cTaskNameItem[0].firstChild.length - countChar - 3);
+ tName += "...";
+ this.cTaskNameItem[0].innerHTML = tName;
+ }
+ },
+ refreshTaskItem: function(itemControl){
+ this.posX = this.ganttChart.getPosOnDate(this.taskItem.startTime);
+ dojo.style(itemControl, {
+ "left": this.posX + "px"
+ });
+ var divTaskItem = itemControl.childNodes[0];
+ var tblTaskItem = divTaskItem.firstChild;
+ tblTaskItem.width = (!this.taskItem.duration ? 1 : this.taskItem.duration * this.ganttChart.pixelsPerWorkHour) + "px";
+ var rowTblTask = tblTaskItem.rows[0];
+ if(this.taskItem.percentage != 0){
+ var cellTblTask = rowTblTask.firstChild;
+ cellTblTask.height = this.ganttChart.heightTaskItem + "px";
+ cellTblTask.width = this.taskItem.percentage + "%";
+ cellTblTask.style.lineHeight = "1px";
+ var imageProgress = cellTblTask.firstChild;
+ dojo.style(imageProgress, {
+ width: (!this.taskItem.duration ? 1 : (this.taskItem.percentage * this.taskItem.duration * this.ganttChart.pixelsPerWorkHour / 100)) + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ if(this.taskItem.percentage != 100){
+ var cellTblTask = rowTblTask.lastChild;
+ cellTblTask.height = this.ganttChart.heightTaskItem + "px";
+ cellTblTask.width = (100 - this.taskItem.percentage) + "%";
+ cellTblTask.style.lineHeight = "1px";
+ var imageProgressFill = cellTblTask.firstChild;
+ dojo.style(imageProgressFill, {
+ width: (!this.taskItem.duration ? 1 : ((100 - this.taskItem.percentage) * this.taskItem.duration * this.ganttChart.pixelsPerWorkHour / 100)) + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ if(this.ganttChart.isContentEditable){
+ var divTaskInfo = itemControl.childNodes[1];
+ var tblTaskInfo = divTaskInfo.firstChild;
+ tblTaskInfo.height = this.ganttChart.heightTaskItem + "px";
+ tblTaskInfo.width = (!this.taskItem.duration ? 1 : (this.taskItem.duration * this.ganttChart.pixelsPerWorkHour)) + "px";
+ var rowTaskInfo = tblTaskInfo.rows[0];
+ var cellTaskInfo = rowTaskInfo.firstChild;
+ cellTaskInfo.height = this.ganttChart.heightTaskItem + "px";
+ var divTaskName = itemControl.childNodes[2];
+ var divMove = divTaskName.firstChild;
+ divMove.style.height = this.ganttChart.heightTaskItem + "px";
+ divMove.style.width = (!this.taskItem.duration ? 1 : (this.taskItem.duration * this.ganttChart.pixelsPerWorkHour)) + "px";
+ //Creation resize area
+ var divResize = divTaskName.lastChild;
+ dojo.style(divResize, {
+ "left": (this.taskItem.duration * this.ganttChart.pixelsPerWorkHour - 10) + "px"
+ });
+ divResize.style.height = this.ganttChart.heightTaskItem + "px";
+ divResize.style.width = "10px";
+ }
+ return itemControl;
+ },
+ refreshTaskDesc: function(divDesc){
+ var posX = (this.posX + this.taskItem.duration * this.ganttChart.pixelsPerWorkHour + 10);
+ dojo.style(divDesc, {
+ "left": posX + "px"
+ });
+ return divDesc;
+ },
+ refreshConnectingLinesDS: function(arrLines){
+ var arrowImg = arrLines[1];
+ var lineVerticalRight = arrLines[0];
+ //horizontal line
+ var lineHorizontal = arrLines[2];
+ var posXPreviousTask = dojo.style(this.predTask.cTaskItem[0], "left");
+ var posYPreviousTask = dojo.style(this.predTask.cTaskItem[0], "top");
+ var posXChildTask = dojo.style(this.cTaskItem[0], "left");
+ var posYChildTask = this.posY + 2;
+ //width task item
+ var widthChildTask = parseInt(this.predTask.cTaskItem[0].firstChild.firstChild.width);
+ var widthPreviousTask = parseInt(this.predTask.cTaskItem[0].firstChild.firstChild.width);
+ if(posYPreviousTask < posYChildTask){
+ dojo.style(lineVerticalRight, {
+ "height": (posYChildTask - this.ganttChart.heightTaskItem / 2 - posYPreviousTask - 3) + "px",
+ "left": (posXPreviousTask + widthPreviousTask - 20) + "px"
+ });
+ dojo.style(lineHorizontal, {
+ "width": (15 + (posXChildTask - (widthPreviousTask + posXPreviousTask))) + "px",
+ "left": (posXPreviousTask + widthPreviousTask - 20) + "px"
+ });
+
+ dojo.style(arrowImg, {
+ "left": (posXChildTask - 7) + "px"
+ });
+ }else{
+ dojo.style(lineVerticalRight, {
+ "height": (posYPreviousTask + 2 - posYChildTask) + "px",
+ "left": (posXPreviousTask + widthPreviousTask - 20) + "px"
+ });
+ dojo.style(lineHorizontal, {
+ "width": (15 + (posXChildTask - (widthPreviousTask + posXPreviousTask))) + "px",
+ "left": (posXPreviousTask + widthPreviousTask - 20) + "px"
+ });
+ dojo.style(arrowImg, {
+ "left": (posXChildTask - 7) + "px"
+ });
+ }
+ return arrLines;
+ },
+ postLoadData: function(){
+ //TODO e.g. task relative info...
+ },
+ refresh: function(){
+ if(this.childTask && this.childTask.length > 0){
+ dojo.forEach(this.childTask, function(cTask){
+ cTask.refresh();
+ }, this);
+ }
+ //creation task item
+ this.refreshTaskItem(this.cTaskItem[0]);
+ this.refreshTaskDesc(this.cTaskItem[0].nextSibling);
+ //Create Connecting Lines
+ var arrConnectingLines = [];
+ if(this.taskItem.previousTask && this.predTask){
+ this.refreshConnectingLinesDS(this.cTaskItem[1]);
+ }
+ return this;
+ },
+ create: function(){
+ var containerTasks = this.ganttChart.contentData.firstChild;
+ var containerNames = this.ganttChart.panelNames.firstChild;
+ var previousTask = this.taskItem.previousTask;
+ var parentTask = this.taskItem.parentTask;
+ var isCParentTask = (this.taskItem.cldTasks.length > 0) ? true : false;
+ this.cTaskItem = [];
+ this.cTaskNameItem = [];
+ //creation arrTasks
+ if(!parentTask){
+ if(this.taskItem.previousParentTask){
+ this.previousParentTask = this.project.getTaskById(this.taskItem.previousParentTask.id);
+ var lastChildTask = this.ganttChart.getLastChildTask(this.previousParentTask);
+ this.posY = parseInt(lastChildTask.cTaskItem[0].style.top)
+ + this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ this.previousParentTask.nextParentTask = this;
+ }else{
+ this.posY = parseInt(this.project.projectItem[0].style.top)
+ + this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ }
+ }
+ if(parentTask){
+ var task = this.project.getTaskById(this.taskItem.parentTask.id);
+ this.parentTask = task;
+
+ if(this.taskItem.previousChildTask){
+ this.previousChildTask = this.project.getTaskById(this.taskItem.previousChildTask.id);
+ var lastChildTask = this.ganttChart.getLastChildTask(this.previousChildTask);
+ this.posY = dojo.style(lastChildTask.cTaskItem[0], "top")
+ + this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ this.previousChildTask.nextChildTask = this;
+ }else{
+ this.posY = dojo.style(task.cTaskItem[0], "top")
+ + this.ganttChart.heightTaskItem + this.ganttChart.heightTaskItemExtra;
+ }
+ task.childTask.push(this);
+ }
+ if(previousTask){
+ var task = this.project.getTaskById(previousTask.id);
+ this.predTask = task;
+ task.childPredTask.push(this);
+ }
+ //creation task item
+ this.cTaskItem.push(this.createTaskItem());
+ containerTasks.appendChild(this.cTaskItem[0]);
+ if(this.ganttChart.panelNames){
+ this.cTaskNameItem.push(this.createTaskNameItem());
+ this.ganttChart.panelNames.firstChild.appendChild(this.cTaskNameItem[0]);
+ }
+ containerTasks.appendChild(this.createTaskDescItem());
+ //Create Connecting Lines
+ var arrConnectingLines = [];
+ if(previousTask){
+ arrConnectingLines = this.createConnectingLinesDS();
+ }
+ this.cTaskItem.push(arrConnectingLines);
+ if(this.ganttChart.panelNames){
+ //Create Connecting Lines
+ var arrConnectingLinesNames = [];
+ if(parentTask){
+ this.cTaskNameItem[0].style.left = dojo.style(this.parentTask.cTaskNameItem[0], "left") + 15 + "px";
+ arrConnectingLinesNames = this.createConnectingLinesPN();
+ }
+ this.checkWidthTaskNameItem();
+ //Identifier
+ this.checkPosition();
+ var treeImg = null;
+ if(isCParentTask){
+ treeImg = this.createTreeImg();
+ }
+ this.cTaskNameItem.push(arrConnectingLinesNames);
+ this.cTaskNameItem.push(treeImg);
+ }
+ this.adjustPanelTime();
+ return this;
+ },
+ checkPosition: function(){
+ //task name position: check Task Identifier
+ if(!this.ganttChart.withTaskId){
+ return;
+ }
+ var pos = dojo.coords(this.cTaskNameItem[0], true);
+ if(this.taskIdentifier){
+ if(this.childTask && this.childTask.length > 0){
+ dojo.forEach(this.childTask, function(cTask){
+ cTask.checkPosition();
+ }, this);
+ }
+ dojo.style(this.taskIdentifier, {
+ "left": (pos.l + pos.w + 4) + "px",
+ "top": (pos.t - 1) + "px"
+ });
+ }else{
+ this.taskIdentifier = dojo.create("div", {
+ id: "TaskId_" + this.taskItem.id,
+ className: "ganttTaskIdentifier",
+ title: this.taskItem.id,
+ innerHTML: this.taskItem.id
+ }, this.cTaskNameItem[0].parentNode);
+ dojo.style(this.taskIdentifier, {
+ left: (pos.l + pos.w + 4) + "px",
+ top: (pos.t - 1) + "px"
+ });
+ }
+ },
+ createTreeImg: function(){
+ var treeImg = dojo.create("div", {
+ id: this.taskItem.id,
+ className: "ganttImageTreeCollapse"
+ });
+ dojo.attr(treeImg, "tabIndex", 0);
+ dojo.forEach(["onclick", "onkeydown"], function(e){
+ this.ganttChart._events.push(
+ dojo.connect(treeImg, e, this, function(evt){
+ if(e == "onkeydown" && evt.keyCode != dojo.keys.ENTER){ return; }
+ if(this.isExpanded){
+ dojo.removeClass(treeImg, "ganttImageTreeCollapse");
+ dojo.addClass(treeImg, "ganttImageTreeExpand");
+ this.isExpanded = false;
+ this.hideChildTasks(this);
+ this.shiftCurrentTasks(this, -this.hideTasksHeight);
+ this.ganttChart.checkPosition();
+ }else{
+ dojo.removeClass(treeImg, "ganttImageTreeExpand");
+ dojo.addClass(treeImg, "ganttImageTreeCollapse");
+ this.isExpanded = true;
+ this.shiftCurrentTasks(this, this.hideTasksHeight);
+ this.showChildTasks(this, true);
+ this.hideTasksHeight = 0;
+ this.ganttChart.checkPosition();
+ }
+ })
+ );
+ }, this);
+ this.ganttChart.panelNames.firstChild.appendChild(treeImg);
+ dojo.addClass(treeImg, "ganttTaskTreeImage");
+ dojo.style(treeImg, {
+ left: (dojo.style(this.cTaskNameItem[0], "left") - 12) + "px",
+ top: (dojo.style(this.cTaskNameItem[0], "top") + 3) + "px"
+ });
+ return treeImg;
+ },
+ setPreviousTask: function(previousTaskId){
+ if(previousTaskId == ""){
+ this.clearPredTask();
+ }else{
+ var task = this.taskItem;
+ if(task.id == previousTaskId){
+ return false;
+ }
+ var predTaskObj = this.project.getTaskById(previousTaskId);
+ if(!predTaskObj){
+ return false;
+ }
+ var predTask = predTaskObj.taskItem;
+ var a1 = predTask.parentTask == null, a2 = task.parentTask == null;
+ if(a1 && !a2 || !a1 && a2 || !a1 && !a2 && (predTask.parentTask.id != task.parentTask.id)){
+ return false;
+ }
+ //check time
+ var startTime = task.startTime.getTime(),
+ pest = predTask.startTime.getTime(),
+ pdur = predTask.duration * 24 * 60 * 60 * 1000 / predTaskObj.ganttChart.hsPerDay;
+ if((pest+pdur) > startTime){
+ return false;
+ }
+ // remove current connection
+ this.clearPredTask();
+ if(!this.ganttChart.checkPosPreviousTask(predTask, task)){
+ this.ganttChart.correctPosPreviousTask(predTask, task, this);
+ }
+ task.previousTaskId = previousTaskId;
+ task.previousTask = predTask;
+ this.predTask = predTaskObj;
+ predTaskObj.childPredTask.push(this);
+ this.cTaskItem[1] = this.createConnectingLinesDS();
+ }
+ return true;
+ },
+ clearPredTask: function(){
+ if(this.predTask){
+ var ch = this.predTask.childPredTask;
+ for(var i = 0; i < ch.length; i++){
+ if(ch[i] == this){
+ ch.splice(i, 1);
+ break;
+ }
+ }
+ for(var i = 0; i < this.cTaskItem[1].length; i++){
+ this.cTaskItem[1][i].parentNode.removeChild(this.cTaskItem[1][i]);
+ }
+ this.cTaskItem[1] = [];
+ this.taskItem.previousTaskId = null;
+ this.taskItem.previousTask = null;
+ this.predTask = null;
+ }
+ },
+ setStartTime: function(startTime, shiftChild){
+ this.moveChild = shiftChild;
+ this.getMoveInfo();
+ var pos = this.ganttChart.getPosOnDate(startTime);
+ if((parseInt(this.cTaskItem[0].firstChild.firstChild.width) + pos > this.maxPosXMove) && (this.maxPosXMove != -1)){
+ this.maxPosXMove = -1;
+ this.minPosXMove = -1;
+ return false;
+ }
+ if(pos < this.minPosXMove){
+ this.maxPosXMove = -1;
+ this.minPosXMove = -1;
+ return false;
+ }
+ this.cTaskItem[0].style.left = pos;
+ var width = pos - this.posX;
+ this.moveCurrentTaskItem(width, shiftChild);
+ this.project.shiftProjectItem();
+ this.descrTask.innerHTML = this.objKeyToStr(this.getTaskOwner());
+ this.adjustPanelTime();
+ this.posX = 0;
+ this.maxPosXMove = -1;
+ this.minPosXMove = -1;
+ return true;
+ },
+ setDuration: function(duration){
+ this.getResizeInfo();
+ var width = this.ganttChart.getWidthOnDuration(duration);
+ if((width > this.maxWidthResize) && (this.maxWidthResize != -1)){
+ return false;
+ }else if(width < this.minWidthResize){
+ return false;
+ }else{
+ this.taskItemWidth = parseInt(this.cTaskItem[0].firstChild.firstChild.width);
+ this.resizeTaskItem(width);
+ this.endResizeItem();
+ this.descrTask.innerHTML = this.objKeyToStr(this.getTaskOwner());
+ return true;
+ }
+ },
+ setTaskOwner: function(owner){
+ owner = (owner == null || owner == undefined) ? "" : owner;
+ this.taskItem.taskOwner = owner;
+ this.descrTask.innerHTML = this.objKeyToStr(this.getTaskOwner());
+ return true;
+ },
+ setPercentCompleted: function(percentage){
+ percentage = parseInt(percentage);
+ if(isNaN(percentage) || percentage > 100 || percentage < 0){
+ return false;
+ }
+ var trow = this.cTaskItem[0].childNodes[0].firstChild.rows[0],
+ rc0 = trow.cells[0], rc1 = trow.cells[1];
+ if((percentage != 0) && (percentage != 100)){
+ if((this.taskItem.percentage != 0) && (this.taskItem.percentage != 100)){
+ rc0.width = percentage + "%";
+ rc1.width = 100 - percentage + "%";
+ }else if((this.taskItem.percentage == 0) || (this.taskItem.percentage == 100)){
+ rc0.parentNode.removeChild(rc0);
+ var cellTblTask = dojo.create("td", {
+ height: this.ganttChart.heightTaskItem + "px",
+ width: percentage + "%"
+ }, trow);
+ cellTblTask.style.lineHeight = "1px";
+ var imageProgressFill = dojo.create("div", {
+ className: "ganttImageTaskProgressFilled"
+ }, cellTblTask);
+ dojo.style(imageProgressFill, {
+ width: (percentage * this.taskItem.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+
+ cellTblTask = dojo.create("td", {
+ height: this.ganttChart.heightTaskItem + "px",
+ width: (100 - percentage) + "%"
+ }, trow);
+ cellTblTask.style.lineHeight = "1px";
+ imageProgressFill = dojo.create("div", {
+ className: "ganttImageTaskProgressBg"
+ }, cellTblTask);
+ dojo.style(imageProgressFill, {
+ width: ((100 - percentage) * this.taskItem.duration * this.ganttChart.pixelsPerWorkHour) / 100 + "px",
+ height: this.ganttChart.heightTaskItem + "px"
+ });
+ }
+ }else if(percentage == 0){
+ if((this.taskItem.percentage != 0) && (this.taskItem.percentage != 100)){
+ rc0.parentNode.removeChild(rc0);
+ rc1.width = 100 + "%";
+ }else{
+ dojo.removeClass(rc0.firstChild, "ganttImageTaskProgressFilled");
+ dojo.addClass(rc0.firstChild, "ganttImageTaskProgressBg");
+ }
+ }else if(percentage == 100){
+ if((this.taskItem.percentage != 0) && (this.taskItem.percentage != 100)){
+ rc1.parentNode.removeChild(rc1);
+ rc0.width = 100 + "%";
+ }else{
+ dojo.removeClass(rc0.firstChild, "ganttImageTaskProgressBg");
+ dojo.addClass(rc0.firstChild, "ganttImageTaskProgressFilled");
+ }
+ }
+ this.taskItem.percentage = percentage;
+ this.taskItemWidth = parseInt(this.cTaskItem[0].firstChild.firstChild.width);
+ this.resizeTaskItem(this.taskItemWidth);
+ this.endResizeItem();
+ this.descrTask.innerHTML = this.objKeyToStr(this.getTaskOwner());
+ return true;
+ },
+ setName: function(name){
+ if(name){
+ this.taskItem.name = name;
+ this.cTaskNameItem[0].innerHTML = name;
+ this.cTaskNameItem[0].title = name;
+ this.checkWidthTaskNameItem();
+ this.checkPosition();
+ this.descrTask.innerHTML = this.objKeyToStr(this.getTaskOwner());
+ this.adjustPanelTime();
+ }
+ }
+});
+
+dojo.declare("dojox.gantt.GanttTaskItem", null, {
+ constructor: function(configuration){
+ //id is required
+ this.id = configuration.id;
+ this.name = configuration.name || this.id;
+ this.startTime = configuration.startTime || new Date();
+ this.duration = configuration.duration || 8;
+ this.percentage = configuration.percentage || 0;
+ this.previousTaskId = configuration.previousTaskId || "";
+ this.taskOwner = configuration.taskOwner || "";
+ this.cldTasks = [];
+ this.cldPreTasks = [];
+ this.parentTask = null;
+ this.previousTask = null;
+ this.project = null;
+ this.nextChildTask = null;
+ this.previousChildTask = null;
+ this.nextParentTask = null;
+ this.previousParentTask = null;
+ },
+ addChildTask: function(task){
+ this.cldTasks.push(task);
+ task.parentTask = this;
+ },
+ setProject: function(project){
+ this.project = project;
+ for(var j = 0; j < this.cldTasks.length; j++){
+ this.cldTasks[j].setProject(project);
+ }
+ }
+});
+
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/gantt/TabMenu.js b/js/dojo-1.6/dojox/gantt/TabMenu.js new file mode 100644 index 0000000..9baf08d --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/TabMenu.js @@ -0,0 +1,584 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.gantt.TabMenu"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.gantt.TabMenu"] = true;
+dojo.provide("dojox.gantt.TabMenu");
+
+dojo.require("dijit.dijit");
+dojo.require("dijit.Menu");
+dojo.require("dijit.Dialog");
+dojo.require("dijit.form.NumberSpinner");
+dojo.require("dijit.form.Button");
+dojo.require("dijit.form.CheckBox");
+dojo.require("dijit.form.DateTextBox");
+dojo.require("dijit.form.TimeTextBox");
+dojo.require("dojo.date.locale");
+
+dojo.require("dijit.form.Form");
+dojo.require("dojo.parser");
+
+(function(){
+ dojo.declare("dojox.gantt.TabMenu", null, {
+ constructor: function(chart){
+ this.ganttChart = chart;
+ this.menuPanel = null;
+ this.paneContentArea = null;
+ this.paneActionBar = null;
+ this.tabPanelDlg = null;
+ this.tabPanelDlgId = null;
+ this.arrTabs = [];
+ this.isShow = false;
+ this.buildContent();
+ },
+ buildContent: function(){
+ this.createMenuPanel();
+ this.createTabPanel();
+
+ //tasks customization
+ var taskSucAdd = this.createTab(11, "Add Successor Task", "t", true, this);
+ taskSucAdd.addItem(1, "Id", "id", true);
+ taskSucAdd.addItem(2, "Name", "name");
+ taskSucAdd.addItem(3, "Start Time", "startTime");
+ taskSucAdd.addItem(4, "Duration (hours)", "duration");
+ taskSucAdd.addItem(5, "Percent Complete (%)", "percentage");
+ taskSucAdd.addItem(6, "Task Assignee", "taskOwner");
+ taskSucAdd.addAction("addSuccessorTaskAction");
+
+ var taskChildAdd = this.createTab(10, "Add Child Task", "t", true, this);
+ taskChildAdd.addItem(1, "Id", "id", true);
+ taskChildAdd.addItem(2, "Name", "name");
+ taskChildAdd.addItem(3, "Start Time", "startTime");
+ taskChildAdd.addItem(4, "Duration (hours)", "duration");
+ taskChildAdd.addItem(5, "Percent Complete (%)", "percentage");
+ taskChildAdd.addItem(6, "Task Assignee", "taskOwner");
+ taskChildAdd.addAction("addChildTaskAction");
+
+ var taskDuration = this.createTab(4, "Set Duration(hours)", "t", true, this, true);
+ taskDuration.addItem(1, "Duration (hours)", "duration", true);
+ taskDuration.addAction("durationUpdateAction");
+
+ var taskCP = this.createTab(5, "Set Complete Percentage (%)", "t", true, this, true);
+ taskCP.addItem(1, "Percent Complete (%)", "percentage", true);
+ taskCP.addAction("cpUpdateAction");
+
+ var taskOwner = this.createTab(20, "Set Owner", "t", true, this, true);
+ taskOwner.addItem(1, "Task Assignee", "taskOwner", true);
+ taskOwner.addAction("ownerUpdateAction");
+
+ var taskPrevious = this.createTab(13, "Set Previous Task", "t", true, this);
+ taskPrevious.addItem(1, "Previous Task Id", "previousTaskId", true);
+ taskPrevious.addAction("ptUpdateAction");
+
+ var taskRename = this.createTab(1, "Rename Task", "t", true, this, true);
+ taskRename.addItem(1, "New Name", "name", true);
+ taskRename.addAction("renameTaskAction");
+
+ var taskDelete = this.createTab(2, "Delete Task", "t", true, this);
+ taskDelete.addAction("deleteAction");
+
+ //projects customization
+ var projectAdd = this.createTab(12, "Add New Project", "p", false, this);
+ projectAdd.addItem(1, "Id", "id", true);
+ projectAdd.addItem(2, "Name", "name", true);
+ projectAdd.addItem(3, "Start Date", "startDate", true);
+ projectAdd.addAction("addProjectAction");
+
+ var projectCP = this.createTab(8, "Set Complete Percentage (%)", "p", true, this, true);
+ projectCP.addItem(1, "Percent Complete (%)", "percentage", true);
+ projectCP.addAction("cpProjectAction");
+
+ var projectRename = this.createTab(6, "Rename Project", "p", true, this, true);
+ projectRename.addItem(1, "New Name", "name", true);
+ projectRename.addAction("renameProjectAction");
+
+ var projectDelete = this.createTab(7, "Delete Project", "p", true, this);
+ projectDelete.addAction("deleteProjectAction");
+
+ //task relative
+ var projectTaskAdd = this.createTab(9, "Add New Task", "p", true, this);
+ projectTaskAdd.addItem(1, "Id", "id", true);
+ projectTaskAdd.addItem(2, "Name", "name");
+ projectTaskAdd.addItem(3, "Start Time", "startTime");
+ projectTaskAdd.addItem(4, "Duration (hours)", "duration");
+ projectTaskAdd.addItem(5, "Percent Complete (%)", "percentage");
+ projectTaskAdd.addItem(6, "Task Assignee", "taskOwner");
+ projectTaskAdd.addItem(7, "Parent Task Id", "parentTaskId");
+ projectTaskAdd.addItem(8, "Previous Task Id", "previousTaskId");
+ projectTaskAdd.addAction("addTaskAction");
+ },
+ createMenuPanel: function(){
+ this.menuPanel = dojo.create("div", {
+ innerHTML: "<table></table>",
+ className: "ganttMenuPanel"
+ }, this.ganttChart.content);
+ dojo.addClass(this.menuPanel.firstChild, "ganttContextMenu");
+ this.menuPanel.firstChild.cellPadding = 0;
+ this.menuPanel.firstChild.cellSpacing = 0;
+ },
+ createTabPanel: function(){
+ this.tabPanelDlg = dijit.byId(this.tabPanelDlgId) ||
+ new dijit.Dialog({
+ title: "Settings"
+ });
+ this.tabPanelDlgId = this.tabPanelDlg.id;
+ this.tabPanelDlg.closeButtonNode.style.display = "none";
+ var tabPanel = this.tabPanelDlg.containerNode;
+ this.paneContentArea = dojo.create("div", {className: "dijitDialogPaneContentArea"}, tabPanel);
+ this.paneActionBar = dojo.create("div", {className: "dijitDialogPaneActionBar"}, tabPanel);
+ this.paneContentArea.innerHTML = "<table cellpadding=0 cellspacing=0><tr><th></th></tr><tr><td></td></tr></table>";
+ var headerCell = this.paneContentArea.firstChild.rows[0].cells[0];
+ headerCell.colSpan = 2;
+ headerCell.innerHTML = "Description: ";
+ dojo.addClass(headerCell, "ganttDialogContentHeader");
+ var contentCell = this.paneContentArea.firstChild.rows[1].cells[0];
+ contentCell.innerHTML = "<table></table>";
+ dojo.addClass(contentCell.firstChild, "ganttDialogContentCell");
+ contentCell.align = "center";
+ this.ok = new dijit.form.Button({label: "OK"});
+ this.cancel = new dijit.form.Button({label: "Cancel"});
+ this.paneActionBar.appendChild(this.ok.domNode);
+ this.paneActionBar.appendChild(this.cancel.domNode);
+ },
+ addItemMenuPanel: function(tab){
+ var row = this.menuPanel.firstChild.insertRow(this.menuPanel.firstChild.rows.length);
+ var cell = dojo.create("td", {
+ className: "ganttContextMenuItem",
+ innerHTML: tab.Description
+ });
+ dojo.attr(cell, "tabIndex", 0);
+ this.ganttChart._events.push(
+ dojo.connect(cell, "onclick", this, function(){
+ try{
+ this.hide();
+ tab.show();
+ }catch(e){
+ console.log("dialog open exception: " + e.message);
+ }
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(cell, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ try{
+ this.hide();
+ tab.show();
+ }catch(e){
+ console.log("dialog open exception: " + e.message);
+ }
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(cell, "onmouseover", this, function(){
+ dojo.addClass(cell, "ganttContextMenuItemHover");
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(cell, "onmouseout", this, function(){
+ dojo.removeClass(cell, "ganttContextMenuItemHover");
+ })
+ );
+ row.appendChild(cell);
+ },
+ show: function(elem, object){
+ if(object.constructor == dojox.gantt.GanttTaskControl){
+ dojo.forEach(this.arrTabs, function(tab){
+ if(tab.type == "t"){
+ tab.object = object;
+ this.addItemMenuPanel(tab);
+ }
+ }, this);
+ }else if(object.constructor == dojox.gantt.GanttProjectControl){
+ dojo.forEach(this.arrTabs, function(tab){
+ if(tab.type == "p"){
+ tab.object = object;
+ this.addItemMenuPanel(tab);
+ }
+ }, this);
+ }
+ this.isShow = true;
+ dojo.style(this.menuPanel, {
+ zIndex: 15,
+ visibility: "visible"
+ });
+ //make sure menu box inside gantt's bounding box
+ var menuBox = dojo.position(this.menuPanel, true),
+ bBox = dojo.position(this.ganttChart.content, true),
+ pos = dojo.coords(elem, true);
+ if((pos.y + menuBox.h) > (bBox.y + bBox.h + 50)){
+ this.menuPanel.style.top = pos.y - menuBox.h + pos.h + "px";
+ }else{
+ this.menuPanel.style.top = pos.y + "px";
+ }
+ if(dojo._isBodyLtr()){
+ this.menuPanel.style.left = pos.x + pos.w + 5 + "px";
+ }else{
+ this.menuPanel.style.left = pos.x - menuBox.w - 5 + "px";
+ }
+ },
+ hide: function(){
+ this.isShow = false;
+ this.menuPanel.style.visibility = "hidden";
+ },
+ clear: function(){
+ this.menuPanel.removeChild(this.menuPanel.firstChild);
+ this.menuPanel.innerHTML = "<table></table>";
+ dojo.addClass(this.menuPanel.firstChild, "ganttContextMenu");
+ this.menuPanel.firstChild.cellPadding = 0;
+ this.menuPanel.firstChild.cellSpacing = 0;
+ },
+ createTab: function(id, desc, type, showOInfo, menu, withDefaultValue){
+ var tab = new dojox.gantt.contextMenuTab(id, desc, type, showOInfo, menu, withDefaultValue);
+ this.arrTabs.push(tab);
+ return tab;
+ }
+ });
+
+ dojo.declare("dojox.gantt.contextMenuTab", null, {
+ constructor: function(id, description, type, showOInfo, tabMenu, withDefaultValue){
+ this.id = id;
+ this.arrItems = [];
+ this.TabItemContainer = null;
+ this.Description = description;
+ this.tabMenu = tabMenu;
+ this.type = type;
+ this.object = null;
+ this.showObjectInfo = showOInfo;
+ this.withDefaultValue = withDefaultValue;
+ },
+ preValueValidation: function(items){
+ for(var i = 0; i < items.length; i++){
+ var item = items[i];
+ //TODO add more validation for Id, Name, .....
+ if(item.required && !item.control.textbox.value){
+ return false;
+ }
+ }
+ return true;
+ },
+ encodeDate: function(date){
+ return date.getFullYear() + "." + (date.getMonth() + 1) + "." + date.getDate();
+ },
+ decodeDate: function(dateStr){
+ var arr = dateStr.split(".");
+ return (arr.length < 3) ? "" : (new Date(arr[0], parseInt(arr[1]) - 1, arr[2]));
+ },
+ renameTaskAction: function(){
+ var name = this.arrItems[0].control.textbox.value;
+ if(dojo.trim(name).length <= 0){
+ return;
+ }
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ this.object.setName(name);
+ this.hide();
+ },
+ deleteAction: function(){
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ this.object.project.deleteTask(this.object.taskItem.id);
+ this.hide();
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+ durationUpdateAction: function(){
+ var d = this.arrItems[0].control.textbox.value;
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ if(this.object.setDuration(d)){
+ this.hide();
+ }else{
+ alert("Duration out of Range");
+ return;
+ }
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.refresh();
+ },
+ cpUpdateAction: function(){
+ var p = this.arrItems[0].control.textbox.value;
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ if(this.object.setPercentCompleted(p)){
+ this.hide();
+ }else{
+ alert("Complete Percentage out of Range");
+ return;
+ }
+ },
+ ownerUpdateAction: function(){
+ var to = this.arrItems[0].control.textbox.value;
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ if(this.object.setTaskOwner(to)){
+ this.hide();
+ }else{
+ alert("Task owner not Valid");
+ return;
+ }
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+ ptUpdateAction: function(){
+ var p = this.arrItems[0].control.textbox.value;
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ if(this.object.setPreviousTask(p)){
+ this.hide();
+ }else{
+ alert("Please verify the Previous Task (" + p + ") and adjust its Time Range");
+ return;
+ }
+ },
+ renameProjectAction: function(){
+ var name = this.arrItems[0].control.textbox.value;
+ if(dojo.trim(name).length <= 0){
+ return;
+ }
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ this.object.setName(name);
+ this.hide();
+ },
+ deleteProjectAction: function(){
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ this.object.ganttChart.deleteProject(this.object.project.id);
+ this.hide();
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+ cpProjectAction: function(){
+ var p = this.arrItems[0].control.textbox.value;
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ if(this.object.setPercentCompleted(p)){
+ this.hide();
+ }else{
+ alert("Percentage not Acceptable");
+ return;
+ }
+ },
+ addTaskAction: function(){
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ var id = this.arrItems[0].control.textbox.value,
+ name = this.arrItems[1].control.textbox.value,
+ startTime = this.decodeDate(this.arrItems[2].control.textbox.value),
+ duration = this.arrItems[3].control.textbox.value,
+ pc = this.arrItems[4].control.textbox.value,
+ owner = this.arrItems[5].control.textbox.value,
+ parentTaskId = this.arrItems[6].control.textbox.value,
+ predTaskId = this.arrItems[7].control.textbox.value;
+ if(dojo.trim(id).length <= 0){
+ return;
+ }
+ if(this.object.insertTask(id, name, startTime, duration, pc, predTaskId, owner, parentTaskId)){
+ this.hide();
+ }else{
+ alert("Please adjust your Customization");
+ return;
+ }
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+ addSuccessorTaskAction: function(){
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ var pr = this.object.project,
+ id = this.arrItems[0].control.textbox.value,
+ name = this.arrItems[1].control.textbox.value,
+ startTime = this.decodeDate(this.arrItems[2].control.textbox.value),
+ duration = this.arrItems[3].control.textbox.value,
+ pc = this.arrItems[4].control.textbox.value,
+ owner = this.arrItems[5].control.textbox.value;
+ if(dojo.trim(id).length <= 0){
+ return;
+ }
+ var parentTaskId = !this.object.parentTask ? "" : this.object.parentTask.taskItem.id;
+ var predTaskId = this.object.taskItem.id;
+ if(pr.insertTask(id, name, startTime, duration, pc, predTaskId, owner, parentTaskId)){
+ this.hide();
+ }else{
+ alert("Please adjust your Customization");
+ return;
+ }
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+ addChildTaskAction: function(){
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ var pr = this.object.project,
+ id = this.arrItems[0].control.textbox.value,
+ name = this.arrItems[1].control.textbox.value,
+ startTime = this.decodeDate(this.arrItems[2].control.textbox.value),
+ duration = this.arrItems[3].control.textbox.value,
+ pc = this.arrItems[4].control.textbox.value,
+ owner = this.arrItems[5].control.textbox.value,
+ parentTaskId = this.object.taskItem.id,
+ predTaskId = "";
+ if(dojo.trim(id).length <= 0){
+ return;
+ }
+ if(pr.insertTask(id, name, startTime, duration, pc, predTaskId, owner, parentTaskId)){
+ this.hide();
+ }else{
+ alert("Please adjust your Customization");
+ return;
+ }
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+ addProjectAction: function(){
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ var id = this.arrItems[0].control.textbox.value,
+ namePr = this.arrItems[1].control.textbox.value,
+ startDatePr = this.decodeDate(this.arrItems[2].control.textbox.value);
+ if(dojo.trim(id).length <= 0 || dojo.trim(namePr).length <= 0){
+ return;
+ }
+ if(this.tabMenu.ganttChart.insertProject(id, namePr, startDatePr)){
+ this.hide();
+ }else{
+ alert("Please adjust your Customization");
+ return;
+ }
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+
+ addAction: function(handler){
+ this.actionFunc = this[handler];
+ },
+ addItem: function(id, name, key, required){
+ var inputControl;
+ if(key == "startTime" || key == "startDate"){
+ inputControl = new dijit.form.DateTextBox({type:"text", constraints:{datePattern:"yyyy.M.d", strict:true}});
+ }else if(key == "percentage"){
+ inputControl = new dijit.form.NumberSpinner({ constraints:{ max:100, min:0 }});
+ }else if(key == "duration"){
+ inputControl = new dijit.form.NumberSpinner({ constraints:{ min:0 }});
+ }else{
+ inputControl = new dijit.form.TextBox();
+ }
+ this.arrItems.push({
+ id: id,
+ name: name,
+ control: inputControl,
+ tab: this,
+ key: key,
+ required: required
+ });
+ },
+ show: function(){
+ this.tabMenu.tabPanelDlg = this.tabMenu.tabPanelDlg || dijit.byId(this.tabMenu.tabPanelDlgId) ||
+ new dijit.Dialog({
+ title: "Settings"
+ });
+ try{
+ this.tabMenu.tabPanelDlg.show();
+ }catch(e){
+ console.log("dialog show exception: " + e.message);
+ return;
+ }
+ this.tabMenu.tabPanelDlg.titleNode.innerHTML = this.Description;
+ var content = this.tabMenu.paneContentArea.firstChild.rows[1].cells[0].firstChild,
+ action = this.tabMenu.paneActionBar;
+ var cell, cellValue, row = null;
+
+ if(this.showObjectInfo){
+ if(this.object){
+ if(this.object.constructor == dojox.gantt.GanttTaskControl){
+ this.insertData(content, "Id", this.object.taskItem.id);
+ this.insertData(content, "Name", this.object.taskItem.name);
+ this.insertData(content, "Start Time", this.encodeDate(this.object.taskItem.startTime));
+ this.insertData(content, "Duration (hours)", this.object.taskItem.duration + " hours");
+ this.insertData(content, "Percent Complete (%)", this.object.taskItem.percentage + "%");
+ this.insertData(content, "Task Assignee", this.object.taskItem.taskOwner);
+ this.insertData(content, "Previous Task Id", this.object.taskItem.previousTaskId);
+ }else{
+ this.insertData(content, "Id", this.object.project.id);
+ this.insertData(content, "Name", this.object.project.name);
+ this.insertData(content, "Start date", this.encodeDate(this.object.project.startDate));
+ }
+ }
+ }
+ //separator
+ row = content.insertRow(content.rows.length);
+ cell = row.insertCell(row.cells.length);
+ cell.colSpan = 2;
+ cell.innerHTML = "<hr/>";
+ //input section header
+ row = content.insertRow(content.rows.length);
+ cell = row.insertCell(row.cells.length);
+ cell.colSpan = 2;
+ dojo.addClass(cell, "ganttMenuDialogInputCellHeader");
+ cell.innerHTML = "Customization: " + this.Description;
+ //input details
+ dojo.forEach(this.arrItems, function(item){
+ row = content.insertRow(content.rows.length);
+ cell = row.insertCell(row.cells.length);
+ dojo.addClass(cell, "ganttMenuDialogInputCell");
+ cellValue = row.insertCell(row.cells.length);
+ dojo.addClass(cellValue, "ganttMenuDialogInputCellValue");
+ cell.innerHTML = item.name;
+ cellValue.appendChild(item.control.domNode);
+ //initialize default value
+ if(this.withDefaultValue && this.object){
+ if(this.object.constructor == dojox.gantt.GanttTaskControl){
+ if(item.key == "startTime"){
+ item.control.textbox.value = this.encodeDate(this.object.taskItem.startTime);
+ }else{
+ item.control.textbox.value = item.key ? this.object.taskItem[item.key] : "";
+ }
+ }else{
+ if(item.key == "startDate"){
+ item.control.textbox.value = this.encodeDate(this.object.project.startDate);
+ }else{
+ item.control.textbox.value = item.key ? (this.object.project[item.key] || this.object[item.key] || "") : "";
+ }
+ }
+ }else{
+ //HTML5 placeholder property
+ item.control.textbox.placeholder = item.required ? "---required---" : "---optional---";
+ }
+ }, this);
+ this.tabMenu.ok.onClick = dojo.hitch(this, this.actionFunc);
+ this.tabMenu.cancel.onClick = dojo.hitch(this, this.hide);
+ },
+ hide: function(){
+ try{
+ this.tabMenu.tabPanelDlg.hide();
+ }catch(e){
+ console.log("dialog show exception: " + e.message);
+ this.tabMenu.tabPanelDlg.destroy();
+ }
+ var cell = this.tabMenu.paneContentArea.firstChild.rows[1].cells[0];
+ cell.firstChild.parentNode.removeChild(cell.firstChild);
+ cell.innerHTML = "<table></table>";
+ dojo.addClass(cell.firstChild, "ganttDialogContentCell");
+ },
+ insertData: function(content, name, value){
+ var cell, cellValue, row = null;
+ row = content.insertRow(content.rows.length);
+ cell = row.insertCell(row.cells.length);
+ dojo.addClass(cell, "ganttMenuDialogDescCell");
+ cell.innerHTML = name;
+ cellValue = row.insertCell(row.cells.length);
+ dojo.addClass(cellValue, "ganttMenuDialogDescCellValue");
+ cellValue.innerHTML = value;
+ }
+ });
+})();
+
+}
diff --git a/js/dojo-1.6/dojox/gantt/TabMenu.xd.js b/js/dojo-1.6/dojox/gantt/TabMenu.xd.js new file mode 100644 index 0000000..c053d80 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/TabMenu.xd.js @@ -0,0 +1,599 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.gantt.TabMenu"],
+["require", "dijit.dijit"],
+["require", "dijit.Menu"],
+["require", "dijit.Dialog"],
+["require", "dijit.form.NumberSpinner"],
+["require", "dijit.form.Button"],
+["require", "dijit.form.CheckBox"],
+["require", "dijit.form.DateTextBox"],
+["require", "dijit.form.TimeTextBox"],
+["require", "dojo.date.locale"],
+["require", "dijit.form.Form"],
+["require", "dojo.parser"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.gantt.TabMenu"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.gantt.TabMenu"] = true;
+dojo.provide("dojox.gantt.TabMenu");
+
+dojo.require("dijit.dijit");
+dojo.require("dijit.Menu");
+dojo.require("dijit.Dialog");
+dojo.require("dijit.form.NumberSpinner");
+dojo.require("dijit.form.Button");
+dojo.require("dijit.form.CheckBox");
+dojo.require("dijit.form.DateTextBox");
+dojo.require("dijit.form.TimeTextBox");
+dojo.require("dojo.date.locale");
+
+dojo.require("dijit.form.Form");
+dojo.require("dojo.parser");
+
+(function(){
+ dojo.declare("dojox.gantt.TabMenu", null, {
+ constructor: function(chart){
+ this.ganttChart = chart;
+ this.menuPanel = null;
+ this.paneContentArea = null;
+ this.paneActionBar = null;
+ this.tabPanelDlg = null;
+ this.tabPanelDlgId = null;
+ this.arrTabs = [];
+ this.isShow = false;
+ this.buildContent();
+ },
+ buildContent: function(){
+ this.createMenuPanel();
+ this.createTabPanel();
+
+ //tasks customization
+ var taskSucAdd = this.createTab(11, "Add Successor Task", "t", true, this);
+ taskSucAdd.addItem(1, "Id", "id", true);
+ taskSucAdd.addItem(2, "Name", "name");
+ taskSucAdd.addItem(3, "Start Time", "startTime");
+ taskSucAdd.addItem(4, "Duration (hours)", "duration");
+ taskSucAdd.addItem(5, "Percent Complete (%)", "percentage");
+ taskSucAdd.addItem(6, "Task Assignee", "taskOwner");
+ taskSucAdd.addAction("addSuccessorTaskAction");
+
+ var taskChildAdd = this.createTab(10, "Add Child Task", "t", true, this);
+ taskChildAdd.addItem(1, "Id", "id", true);
+ taskChildAdd.addItem(2, "Name", "name");
+ taskChildAdd.addItem(3, "Start Time", "startTime");
+ taskChildAdd.addItem(4, "Duration (hours)", "duration");
+ taskChildAdd.addItem(5, "Percent Complete (%)", "percentage");
+ taskChildAdd.addItem(6, "Task Assignee", "taskOwner");
+ taskChildAdd.addAction("addChildTaskAction");
+
+ var taskDuration = this.createTab(4, "Set Duration(hours)", "t", true, this, true);
+ taskDuration.addItem(1, "Duration (hours)", "duration", true);
+ taskDuration.addAction("durationUpdateAction");
+
+ var taskCP = this.createTab(5, "Set Complete Percentage (%)", "t", true, this, true);
+ taskCP.addItem(1, "Percent Complete (%)", "percentage", true);
+ taskCP.addAction("cpUpdateAction");
+
+ var taskOwner = this.createTab(20, "Set Owner", "t", true, this, true);
+ taskOwner.addItem(1, "Task Assignee", "taskOwner", true);
+ taskOwner.addAction("ownerUpdateAction");
+
+ var taskPrevious = this.createTab(13, "Set Previous Task", "t", true, this);
+ taskPrevious.addItem(1, "Previous Task Id", "previousTaskId", true);
+ taskPrevious.addAction("ptUpdateAction");
+
+ var taskRename = this.createTab(1, "Rename Task", "t", true, this, true);
+ taskRename.addItem(1, "New Name", "name", true);
+ taskRename.addAction("renameTaskAction");
+
+ var taskDelete = this.createTab(2, "Delete Task", "t", true, this);
+ taskDelete.addAction("deleteAction");
+
+ //projects customization
+ var projectAdd = this.createTab(12, "Add New Project", "p", false, this);
+ projectAdd.addItem(1, "Id", "id", true);
+ projectAdd.addItem(2, "Name", "name", true);
+ projectAdd.addItem(3, "Start Date", "startDate", true);
+ projectAdd.addAction("addProjectAction");
+
+ var projectCP = this.createTab(8, "Set Complete Percentage (%)", "p", true, this, true);
+ projectCP.addItem(1, "Percent Complete (%)", "percentage", true);
+ projectCP.addAction("cpProjectAction");
+
+ var projectRename = this.createTab(6, "Rename Project", "p", true, this, true);
+ projectRename.addItem(1, "New Name", "name", true);
+ projectRename.addAction("renameProjectAction");
+
+ var projectDelete = this.createTab(7, "Delete Project", "p", true, this);
+ projectDelete.addAction("deleteProjectAction");
+
+ //task relative
+ var projectTaskAdd = this.createTab(9, "Add New Task", "p", true, this);
+ projectTaskAdd.addItem(1, "Id", "id", true);
+ projectTaskAdd.addItem(2, "Name", "name");
+ projectTaskAdd.addItem(3, "Start Time", "startTime");
+ projectTaskAdd.addItem(4, "Duration (hours)", "duration");
+ projectTaskAdd.addItem(5, "Percent Complete (%)", "percentage");
+ projectTaskAdd.addItem(6, "Task Assignee", "taskOwner");
+ projectTaskAdd.addItem(7, "Parent Task Id", "parentTaskId");
+ projectTaskAdd.addItem(8, "Previous Task Id", "previousTaskId");
+ projectTaskAdd.addAction("addTaskAction");
+ },
+ createMenuPanel: function(){
+ this.menuPanel = dojo.create("div", {
+ innerHTML: "<table></table>",
+ className: "ganttMenuPanel"
+ }, this.ganttChart.content);
+ dojo.addClass(this.menuPanel.firstChild, "ganttContextMenu");
+ this.menuPanel.firstChild.cellPadding = 0;
+ this.menuPanel.firstChild.cellSpacing = 0;
+ },
+ createTabPanel: function(){
+ this.tabPanelDlg = dijit.byId(this.tabPanelDlgId) ||
+ new dijit.Dialog({
+ title: "Settings"
+ });
+ this.tabPanelDlgId = this.tabPanelDlg.id;
+ this.tabPanelDlg.closeButtonNode.style.display = "none";
+ var tabPanel = this.tabPanelDlg.containerNode;
+ this.paneContentArea = dojo.create("div", {className: "dijitDialogPaneContentArea"}, tabPanel);
+ this.paneActionBar = dojo.create("div", {className: "dijitDialogPaneActionBar"}, tabPanel);
+ this.paneContentArea.innerHTML = "<table cellpadding=0 cellspacing=0><tr><th></th></tr><tr><td></td></tr></table>";
+ var headerCell = this.paneContentArea.firstChild.rows[0].cells[0];
+ headerCell.colSpan = 2;
+ headerCell.innerHTML = "Description: ";
+ dojo.addClass(headerCell, "ganttDialogContentHeader");
+ var contentCell = this.paneContentArea.firstChild.rows[1].cells[0];
+ contentCell.innerHTML = "<table></table>";
+ dojo.addClass(contentCell.firstChild, "ganttDialogContentCell");
+ contentCell.align = "center";
+ this.ok = new dijit.form.Button({label: "OK"});
+ this.cancel = new dijit.form.Button({label: "Cancel"});
+ this.paneActionBar.appendChild(this.ok.domNode);
+ this.paneActionBar.appendChild(this.cancel.domNode);
+ },
+ addItemMenuPanel: function(tab){
+ var row = this.menuPanel.firstChild.insertRow(this.menuPanel.firstChild.rows.length);
+ var cell = dojo.create("td", {
+ className: "ganttContextMenuItem",
+ innerHTML: tab.Description
+ });
+ dojo.attr(cell, "tabIndex", 0);
+ this.ganttChart._events.push(
+ dojo.connect(cell, "onclick", this, function(){
+ try{
+ this.hide();
+ tab.show();
+ }catch(e){
+ console.log("dialog open exception: " + e.message);
+ }
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(cell, "onkeydown", this, function(e){
+ if(e.keyCode != dojo.keys.ENTER){return;}
+ try{
+ this.hide();
+ tab.show();
+ }catch(e){
+ console.log("dialog open exception: " + e.message);
+ }
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(cell, "onmouseover", this, function(){
+ dojo.addClass(cell, "ganttContextMenuItemHover");
+ })
+ );
+ this.ganttChart._events.push(
+ dojo.connect(cell, "onmouseout", this, function(){
+ dojo.removeClass(cell, "ganttContextMenuItemHover");
+ })
+ );
+ row.appendChild(cell);
+ },
+ show: function(elem, object){
+ if(object.constructor == dojox.gantt.GanttTaskControl){
+ dojo.forEach(this.arrTabs, function(tab){
+ if(tab.type == "t"){
+ tab.object = object;
+ this.addItemMenuPanel(tab);
+ }
+ }, this);
+ }else if(object.constructor == dojox.gantt.GanttProjectControl){
+ dojo.forEach(this.arrTabs, function(tab){
+ if(tab.type == "p"){
+ tab.object = object;
+ this.addItemMenuPanel(tab);
+ }
+ }, this);
+ }
+ this.isShow = true;
+ dojo.style(this.menuPanel, {
+ zIndex: 15,
+ visibility: "visible"
+ });
+ //make sure menu box inside gantt's bounding box
+ var menuBox = dojo.position(this.menuPanel, true),
+ bBox = dojo.position(this.ganttChart.content, true),
+ pos = dojo.coords(elem, true);
+ if((pos.y + menuBox.h) > (bBox.y + bBox.h + 50)){
+ this.menuPanel.style.top = pos.y - menuBox.h + pos.h + "px";
+ }else{
+ this.menuPanel.style.top = pos.y + "px";
+ }
+ if(dojo._isBodyLtr()){
+ this.menuPanel.style.left = pos.x + pos.w + 5 + "px";
+ }else{
+ this.menuPanel.style.left = pos.x - menuBox.w - 5 + "px";
+ }
+ },
+ hide: function(){
+ this.isShow = false;
+ this.menuPanel.style.visibility = "hidden";
+ },
+ clear: function(){
+ this.menuPanel.removeChild(this.menuPanel.firstChild);
+ this.menuPanel.innerHTML = "<table></table>";
+ dojo.addClass(this.menuPanel.firstChild, "ganttContextMenu");
+ this.menuPanel.firstChild.cellPadding = 0;
+ this.menuPanel.firstChild.cellSpacing = 0;
+ },
+ createTab: function(id, desc, type, showOInfo, menu, withDefaultValue){
+ var tab = new dojox.gantt.contextMenuTab(id, desc, type, showOInfo, menu, withDefaultValue);
+ this.arrTabs.push(tab);
+ return tab;
+ }
+ });
+
+ dojo.declare("dojox.gantt.contextMenuTab", null, {
+ constructor: function(id, description, type, showOInfo, tabMenu, withDefaultValue){
+ this.id = id;
+ this.arrItems = [];
+ this.TabItemContainer = null;
+ this.Description = description;
+ this.tabMenu = tabMenu;
+ this.type = type;
+ this.object = null;
+ this.showObjectInfo = showOInfo;
+ this.withDefaultValue = withDefaultValue;
+ },
+ preValueValidation: function(items){
+ for(var i = 0; i < items.length; i++){
+ var item = items[i];
+ //TODO add more validation for Id, Name, .....
+ if(item.required && !item.control.textbox.value){
+ return false;
+ }
+ }
+ return true;
+ },
+ encodeDate: function(date){
+ return date.getFullYear() + "." + (date.getMonth() + 1) + "." + date.getDate();
+ },
+ decodeDate: function(dateStr){
+ var arr = dateStr.split(".");
+ return (arr.length < 3) ? "" : (new Date(arr[0], parseInt(arr[1]) - 1, arr[2]));
+ },
+ renameTaskAction: function(){
+ var name = this.arrItems[0].control.textbox.value;
+ if(dojo.trim(name).length <= 0){
+ return;
+ }
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ this.object.setName(name);
+ this.hide();
+ },
+ deleteAction: function(){
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ this.object.project.deleteTask(this.object.taskItem.id);
+ this.hide();
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+ durationUpdateAction: function(){
+ var d = this.arrItems[0].control.textbox.value;
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ if(this.object.setDuration(d)){
+ this.hide();
+ }else{
+ alert("Duration out of Range");
+ return;
+ }
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.refresh();
+ },
+ cpUpdateAction: function(){
+ var p = this.arrItems[0].control.textbox.value;
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ if(this.object.setPercentCompleted(p)){
+ this.hide();
+ }else{
+ alert("Complete Percentage out of Range");
+ return;
+ }
+ },
+ ownerUpdateAction: function(){
+ var to = this.arrItems[0].control.textbox.value;
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ if(this.object.setTaskOwner(to)){
+ this.hide();
+ }else{
+ alert("Task owner not Valid");
+ return;
+ }
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+ ptUpdateAction: function(){
+ var p = this.arrItems[0].control.textbox.value;
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ if(this.object.setPreviousTask(p)){
+ this.hide();
+ }else{
+ alert("Please verify the Previous Task (" + p + ") and adjust its Time Range");
+ return;
+ }
+ },
+ renameProjectAction: function(){
+ var name = this.arrItems[0].control.textbox.value;
+ if(dojo.trim(name).length <= 0){
+ return;
+ }
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ this.object.setName(name);
+ this.hide();
+ },
+ deleteProjectAction: function(){
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ this.object.ganttChart.deleteProject(this.object.project.id);
+ this.hide();
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+ cpProjectAction: function(){
+ var p = this.arrItems[0].control.textbox.value;
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ if(this.object.setPercentCompleted(p)){
+ this.hide();
+ }else{
+ alert("Percentage not Acceptable");
+ return;
+ }
+ },
+ addTaskAction: function(){
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ var id = this.arrItems[0].control.textbox.value,
+ name = this.arrItems[1].control.textbox.value,
+ startTime = this.decodeDate(this.arrItems[2].control.textbox.value),
+ duration = this.arrItems[3].control.textbox.value,
+ pc = this.arrItems[4].control.textbox.value,
+ owner = this.arrItems[5].control.textbox.value,
+ parentTaskId = this.arrItems[6].control.textbox.value,
+ predTaskId = this.arrItems[7].control.textbox.value;
+ if(dojo.trim(id).length <= 0){
+ return;
+ }
+ if(this.object.insertTask(id, name, startTime, duration, pc, predTaskId, owner, parentTaskId)){
+ this.hide();
+ }else{
+ alert("Please adjust your Customization");
+ return;
+ }
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+ addSuccessorTaskAction: function(){
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ var pr = this.object.project,
+ id = this.arrItems[0].control.textbox.value,
+ name = this.arrItems[1].control.textbox.value,
+ startTime = this.decodeDate(this.arrItems[2].control.textbox.value),
+ duration = this.arrItems[3].control.textbox.value,
+ pc = this.arrItems[4].control.textbox.value,
+ owner = this.arrItems[5].control.textbox.value;
+ if(dojo.trim(id).length <= 0){
+ return;
+ }
+ var parentTaskId = !this.object.parentTask ? "" : this.object.parentTask.taskItem.id;
+ var predTaskId = this.object.taskItem.id;
+ if(pr.insertTask(id, name, startTime, duration, pc, predTaskId, owner, parentTaskId)){
+ this.hide();
+ }else{
+ alert("Please adjust your Customization");
+ return;
+ }
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+ addChildTaskAction: function(){
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ var pr = this.object.project,
+ id = this.arrItems[0].control.textbox.value,
+ name = this.arrItems[1].control.textbox.value,
+ startTime = this.decodeDate(this.arrItems[2].control.textbox.value),
+ duration = this.arrItems[3].control.textbox.value,
+ pc = this.arrItems[4].control.textbox.value,
+ owner = this.arrItems[5].control.textbox.value,
+ parentTaskId = this.object.taskItem.id,
+ predTaskId = "";
+ if(dojo.trim(id).length <= 0){
+ return;
+ }
+ if(pr.insertTask(id, name, startTime, duration, pc, predTaskId, owner, parentTaskId)){
+ this.hide();
+ }else{
+ alert("Please adjust your Customization");
+ return;
+ }
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+ addProjectAction: function(){
+ if(!this.preValueValidation(this.arrItems)){
+ return;
+ }
+ var id = this.arrItems[0].control.textbox.value,
+ namePr = this.arrItems[1].control.textbox.value,
+ startDatePr = this.decodeDate(this.arrItems[2].control.textbox.value);
+ if(dojo.trim(id).length <= 0 || dojo.trim(namePr).length <= 0){
+ return;
+ }
+ if(this.tabMenu.ganttChart.insertProject(id, namePr, startDatePr)){
+ this.hide();
+ }else{
+ alert("Please adjust your Customization");
+ return;
+ }
+ this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct();
+ },
+
+ addAction: function(handler){
+ this.actionFunc = this[handler];
+ },
+ addItem: function(id, name, key, required){
+ var inputControl;
+ if(key == "startTime" || key == "startDate"){
+ inputControl = new dijit.form.DateTextBox({type:"text", constraints:{datePattern:"yyyy.M.d", strict:true}});
+ }else if(key == "percentage"){
+ inputControl = new dijit.form.NumberSpinner({ constraints:{ max:100, min:0 }});
+ }else if(key == "duration"){
+ inputControl = new dijit.form.NumberSpinner({ constraints:{ min:0 }});
+ }else{
+ inputControl = new dijit.form.TextBox();
+ }
+ this.arrItems.push({
+ id: id,
+ name: name,
+ control: inputControl,
+ tab: this,
+ key: key,
+ required: required
+ });
+ },
+ show: function(){
+ this.tabMenu.tabPanelDlg = this.tabMenu.tabPanelDlg || dijit.byId(this.tabMenu.tabPanelDlgId) ||
+ new dijit.Dialog({
+ title: "Settings"
+ });
+ try{
+ this.tabMenu.tabPanelDlg.show();
+ }catch(e){
+ console.log("dialog show exception: " + e.message);
+ return;
+ }
+ this.tabMenu.tabPanelDlg.titleNode.innerHTML = this.Description;
+ var content = this.tabMenu.paneContentArea.firstChild.rows[1].cells[0].firstChild,
+ action = this.tabMenu.paneActionBar;
+ var cell, cellValue, row = null;
+
+ if(this.showObjectInfo){
+ if(this.object){
+ if(this.object.constructor == dojox.gantt.GanttTaskControl){
+ this.insertData(content, "Id", this.object.taskItem.id);
+ this.insertData(content, "Name", this.object.taskItem.name);
+ this.insertData(content, "Start Time", this.encodeDate(this.object.taskItem.startTime));
+ this.insertData(content, "Duration (hours)", this.object.taskItem.duration + " hours");
+ this.insertData(content, "Percent Complete (%)", this.object.taskItem.percentage + "%");
+ this.insertData(content, "Task Assignee", this.object.taskItem.taskOwner);
+ this.insertData(content, "Previous Task Id", this.object.taskItem.previousTaskId);
+ }else{
+ this.insertData(content, "Id", this.object.project.id);
+ this.insertData(content, "Name", this.object.project.name);
+ this.insertData(content, "Start date", this.encodeDate(this.object.project.startDate));
+ }
+ }
+ }
+ //separator
+ row = content.insertRow(content.rows.length);
+ cell = row.insertCell(row.cells.length);
+ cell.colSpan = 2;
+ cell.innerHTML = "<hr/>";
+ //input section header
+ row = content.insertRow(content.rows.length);
+ cell = row.insertCell(row.cells.length);
+ cell.colSpan = 2;
+ dojo.addClass(cell, "ganttMenuDialogInputCellHeader");
+ cell.innerHTML = "Customization: " + this.Description;
+ //input details
+ dojo.forEach(this.arrItems, function(item){
+ row = content.insertRow(content.rows.length);
+ cell = row.insertCell(row.cells.length);
+ dojo.addClass(cell, "ganttMenuDialogInputCell");
+ cellValue = row.insertCell(row.cells.length);
+ dojo.addClass(cellValue, "ganttMenuDialogInputCellValue");
+ cell.innerHTML = item.name;
+ cellValue.appendChild(item.control.domNode);
+ //initialize default value
+ if(this.withDefaultValue && this.object){
+ if(this.object.constructor == dojox.gantt.GanttTaskControl){
+ if(item.key == "startTime"){
+ item.control.textbox.value = this.encodeDate(this.object.taskItem.startTime);
+ }else{
+ item.control.textbox.value = item.key ? this.object.taskItem[item.key] : "";
+ }
+ }else{
+ if(item.key == "startDate"){
+ item.control.textbox.value = this.encodeDate(this.object.project.startDate);
+ }else{
+ item.control.textbox.value = item.key ? (this.object.project[item.key] || this.object[item.key] || "") : "";
+ }
+ }
+ }else{
+ //HTML5 placeholder property
+ item.control.textbox.placeholder = item.required ? "---required---" : "---optional---";
+ }
+ }, this);
+ this.tabMenu.ok.onClick = dojo.hitch(this, this.actionFunc);
+ this.tabMenu.cancel.onClick = dojo.hitch(this, this.hide);
+ },
+ hide: function(){
+ try{
+ this.tabMenu.tabPanelDlg.hide();
+ }catch(e){
+ console.log("dialog show exception: " + e.message);
+ this.tabMenu.tabPanelDlg.destroy();
+ }
+ var cell = this.tabMenu.paneContentArea.firstChild.rows[1].cells[0];
+ cell.firstChild.parentNode.removeChild(cell.firstChild);
+ cell.innerHTML = "<table></table>";
+ dojo.addClass(cell.firstChild, "ganttDialogContentCell");
+ },
+ insertData: function(content, name, value){
+ var cell, cellValue, row = null;
+ row = content.insertRow(content.rows.length);
+ cell = row.insertCell(row.cells.length);
+ dojo.addClass(cell, "ganttMenuDialogDescCell");
+ cell.innerHTML = name;
+ cellValue = row.insertCell(row.cells.length);
+ dojo.addClass(cellValue, "ganttMenuDialogDescCellValue");
+ cellValue.innerHTML = value;
+ }
+ });
+})();
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/gantt/resources/gantt.css b/js/dojo-1.6/dojox/gantt/resources/gantt.css new file mode 100644 index 0000000..0f17a2a --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/gantt.css @@ -0,0 +1,575 @@ +.ganttToolbarZoomIn { + background-image: url("images/zoomIn.png"); + background-repeat: no-repeat; + height: 30px; + width: 30px; + padding: 2px; +} +.ganttToolbarZoomOut { + background-image: url("images/zoomOut.png"); + background-repeat: no-repeat; + height: 30px; + width: 30px; + padding: 2px; +} +.ganttToolbarMicro { + background-image: url("images/zoomInTime.png"); + background-repeat: no-repeat; + height: 30px; + width: 30px; + padding: 2px; +} +.ganttToolbarTele { + background-image: url("images/zoomOutTime.png"); + background-repeat: no-repeat; + height: 30px; + width: 30px; + padding: 2px; +} +.ganttToolbarSave { + background-image: url("images/save.png"); + background-repeat: no-repeat; + height: 30px; + width: 30px; + padding: 2px; +} +.ganttToolbarLoad { + background-image: url("images/load.png"); + background-repeat: no-repeat; + height: 30px; + width: 30px; + padding: 2px; +} +.ganttToolbarActionHover{ + border: 2px solid blue; + padding: 0px; +} +.ganttToolbar { + cursor: pointer; +} +.ganttPanelHeader{ + position: relative; +} +.ganttPanelNameHeaders{ + position: relative; + overflow: hidden; +} +.ganttPanelNamesContainer{ + position: relative; + overflow: hidden; + border-left: #f1f3f1 1px solid; + border-bottom: #f1f3f1 1px solid; +} +.ganttPanelNames{ + position: relative; + overflow: hidden; + border-left: #f1f3f1 1px solid; + border-bottom: #f1f3f1 1px solid; + background: url("images/bg.png") repeat scroll 0 0 transparent; +} +.ganttPanelTime{ + position: relative; +} +.ganttPanelTimeContainer{ + position: relative; + overflow: hidden; + direction: ltr; +} +.ganttContentDataContainer{ + position: relative; + overflow: scroll; + border-left: #f1f3f1 1px solid; + direction: ltr; +} +.ganttDivCell{ + position: relative; +} +.ganttMoveInfo { + font-family: Tahoma, Arial; + font-size: 10px; + color: #006600; + white-space: nowrap; +} +.ganttDescProject { + font-family: Tahoma, Arial; + font-size: 10px; + color: #3B3B3B; + cursor: default; + white-space: nowrap; + z-index: 6; + position: absolute; +} +.ganttProjectNameItem{ + cursor:pointer; + color: #003366; + font-weight: bold; + font-size: 12px; + font-family: Tahoma, Arial; + white-space:nowrap; + height:15px; + z-index:6; + position: absolute; +} +.ganttProjectNameItemHover{ + border-top: 1px solid black; + border-bottom: 1px solid black; +} +.ganttProjectItem{ + z-index: 6; + position: absolute; +} +.ganttTblProjectItem{ + border: solid 1px #555555; +} +.ganttDivTaskInfo{ + text-align: center; + z-index: 7; + position: absolute; + left: 0px; + top: 0px; +} +.ganttTblTime { + background-color: transparent; + cursor: pointer; + margin-top: 0px; +} +.ganttHourNumber { + font-size: 7px; + color: #858585; + border: 1px solid transparent; + border-top: 1px solid #DBECFF; + height: 30px; +} +.ganttHourClass { + text-align: center; + padding: 5px 2px; + height: 20px; +} +.ganttHourNumberAM { + background: url("images/am.png") repeat scroll 0 0 transparent; +} +.ganttHourNumberPM { + background: url("images/pm.png") repeat scroll 0 0 transparent; +} +.ganttDayNumber { + font-family: Tahoma, Arial; + font-weight: bold; + font-size: 9px; + color: #858585; + border: 1px solid transparent; + border-top: 1px solid #DBECFF; + height: 30px; +} +.ganttDayNumberWeekend { + background: url("images/bg.png") repeat scroll 0 0 transparent; +} +.ganttWeekNumber { + font-family: Tahoma, Arial; + font-weight: bold; + font-size: 9px; + color: #858585; + border: 1px solid transparent; + border-top: 1px solid #DBECFF; + border-right: 1px solid #DBECFF; + height:30px; +} +.ganttMonthNumber { + font-family: Tahoma, Arial; + font-weight: bold; + font-size: 9px; + color: #858585; + border: 1px solid transparent; + border-top: 1px solid #DBECFF; + border-right: 1px solid #DBECFF; + height: 30px; +} +.ganttYearNumber { + font-family: Tahoma, Arial; + font-weight: bold; + font-size: 9px; + color: #858585; + border: 1px solid transparent; + border-top: 1px solid #DBECFF; + border-right: 1px solid #DBECFF; + height: 30px; +} +.ganttTabelControl{ + width: 100%; + position: relative; +} +.ganttContextMenu { + z-index: 10; + width: 200px; + cursor: pointer; + font-family: Tahoma, Arial; + font-size: 12px; + border: 1px solid #b5bcc7; + margin: 0px; + padding: 0px; + background-color: #fff; + background-repeat: repeat-x; + border-collapse: separate; + border-spacing: 0 0; +} +.ganttContextMenuItem { + background-image: url("images/menuHighlight.png"); + background-position:0px -40px; + background-repeat:repeat-x; + padding: 3px 10px 4px; + height:18px; +} +.ganttContextMenuItemHover { + border:solid 1px #769dc0; + padding: 2px 9px 3px; + background-color: #9dcfff; + background-position:0px 0px; + color:#000; +} +.ganttMenuDialogDescCell{ + width:150px; + padding: 3px; + border-bottom: 1px solid gray; + text-align: center; +} +.ganttMenuDialogDescCellValue{ + width:150px; + padding: 3px; + border-bottom: 1px solid gray; + text-align: center; +} +.ganttMenuDialogInputCellHeader{ + font-size:12px; + font-family:Tahoma,Arial; + font-weight: bold; + padding: 10px 3px 5px; +} +.ganttMenuDialogInputCell{ + padding: 3px; +} +.ganttMenuDialogInputCellValue{ + padding: 3px; +} +.ganttHeaderCover { + z-index: 999; + position: absolute; +} +.ganttResourceHeader { + font-family: Tahoma, Arial; + background: url("images/resourceHeader.png") repeat scroll 0 0 transparent; + color: black; + padding: 3px 0px 0px 6px; + height: 25px; + font-weight: bold; + position:relative; +} +.ganttResourceContent{ + position:relative; +} +.ganttTaskNameItem { + font-family: Tahoma, Arial; + font-size: 11px; + font-weight: bold; + color: #7D7D7D; + white-space:nowrap; + height:15px; + z-index:1; + position: absolute; + left:20px; +} +.ganttMenuPanel{ + visibility:hidden; + z-index:10; + position:absolute; +} +.ganttDialogContentCell{ + width:300px; + font-size:11px; + font-family:Tahoma,Arial; +} +.ganttDialogContentHeader{ + font-size:12px; + font-family:Tahoma,Arial; + font-weight: bold; +} +.ganttOwnerNameItem { + font-family: Tahoma, Arial; + font-size: 11px; + font-weight: bold; + color: black; + cursor:pointer; + white-space:nowrap; + height:15px; + z-index:1; + position: absolute; + left:20px; +} +.ganttTaskBar { + background: url("images/taskBar.png") repeat scroll 0 0 transparent; + -moz-border-radius: 10px; + z-index:1; + position:absolute; +} +.ganttOwnerBar { + z-index:1; + position:absolute; +} +.ganttOwnerTaskBar { + background: url("images/ownerBar.png") repeat scroll 0 0 transparent; + border-top: solid 1px black; + border-bottom: solid 1px black; + position:absolute; + top:0px; +} +.ganttRowHighlight { + background: url("images/rowHighlight.png") repeat scroll 0 0 transparent; + position: absolute; + z-index: 1; +} +.ganttTaskPanel { + background: url("images/bg.png") repeat scroll 0 0 transparent; + overflow: hidden; + position:relative; +} +.ganttOwnerPanel { + overflow: hidden; + position:relative; + background: url("images/resourceBg.png") repeat scroll 0 0 transparent; +} +.ganttContent { + margin: 15px 63px 0; +} +.ganttTaskLineVerticalLeft{ + border-width: 0px 0px 0px 1px; + border-style: dotted; + border-color: #86A3BE; + margin: 0px; + padding: 0px; + z-index:10; + position: absolute; +} +.ganttTaskLineHorizontalLeft{ + position: absolute; + border-width: 1px 0px 0px 0px; + font-size: 1px; + border-style: dotted; + border-color: #86A3BE; + margin: 0px; + padding: 0px; + z-index:10; +} +.ganttTaskLineVerticalRight{ + border-width: 0px 0px 0px 1px; + border-style: solid; + border-color: #4A8F43; + margin: 0px; + padding: 0px; + z-index:6; + font-size: 1px; + position: absolute; +} +.ganttTaskLineHorizontal{ + height:1px; + border-color: #4A8F43; + border-style: solid; + border-width: 1px 0px 0px 0px; + margin: 0px; + padding: 0px; + z-index:6; + position: absolute; +} +.ganttTaskArrowImg{ + z-index:6; + margin: 0px; + padding: 0px; + width:7px; + height:14px; + position: absolute; +} +.ganttTaskLineVerticalRightPlus{ + border-width: 0px 0px 0px 1px; + border-style: solid; + border-color: #519145; + margin: 0px; + padding: 0px; + z-index:6; + font-size: 1px; + position: absolute; +} +.ganttTaskLineHorizontalPlus{ + height:1px; + border-color: #519145; + border-style: solid; + border-width: 1px 0px 0px 0px; + margin: 0px; + padding: 0px; + z-index:6; + position: absolute; +} +.ganttTaskArrowImgPlus{ + z-index:6; + margin: 0px; + padding: 0px; + width:7px; + height:14px; + position: absolute; +} +.ganttTaskItemControl{ + z-index:6; + position:absolute; +} +.ganttTaskDivTaskItem{ + z-index:6; + position: absolute; + left:0px; + top:0px; +} +.ganttTaskTblTaskItem{ + border: solid 1px #5FF55F; +} +.ganttTaskDivTaskInfo{ + text-align:center; + font-size:9px; + z-index:7; + position: absolute; + left:0px; + top:0px; +} +.ganttTaskDivTaskName{ + z-index:7; + position: absolute; + left:0px; + top:0px; +} +.ganttTaskDivMoveInput{ + visibility:hidden; + width:1px; + height:1px; +} +.ganttTaskDivResizeInput{ + visibility:hidden; + width:1px; + height:1px; +} +.ganttTaskDivResize{ + z-index:10; + position: absolute; + top:0px; +} +.ganttTaskTaskNameItem{ + font-family: Tahoma, Arial; + cursor:pointer; + white-space:nowrap; + height:15px; + z-index:6; + position: absolute; + left:20px; +} +.ganttTaskTaskNameItemHover{ + border-top: 1px solid black; + border-bottom: 1px solid black; +} +.ganttTaskDescTask { + font-family: Tahoma, Arial; + font-size: 10px; + color: #008000; + cursor: default; + white-space: nowrap; + z-index:6; + position:absolute; +} +.ganttTaskIdentifier{ + color:#7D7D7D; + font-family:Tahoma,Arial; + font-size:11px; + font-weight:bold; + border: solid 1px #7D7D7D; + -moz-border-radius: 20px; + -khtml-border-radius: 20px; + -webkit-border-radius: 20px; + border-radius: 20px; + padding: 0px 3px; + cursor:pointer; + white-space:nowrap; + height:14px; + z-index:6; + position:absolute; +} +.ganttTaskTreeImage{ + cursor: pointer; + z-index:12; + position: absolute; +} + +.ganttResourceTableControl{ + width: 100%; + position: relative; +} +.ganttResourceContentDataContainer{ + position:relative; + overflow:scroll; + border-left:#f1f3f1 1px solid; + direction: ltr; +} +.ganttResourcePanelNames{ + position:relative; + overflow:hidden; + border-left:#f1f3f1 1px solid; + border-bottom:#f1f3f1 1px solid; +} +.ganttResourceDivCell{ + position: relative; +} +.ganttResourceLineVerticalLeft{ + border-width: 0px 0px 0px 1px; + border-style: dotted; + border-color: #86A3BE; + margin: 0px; + padding: 0px; + z-index:10; + position: absolute; +} +.ganttResourceLineHorizontalLeft{ + z-index:10; + height:1px; + position: absolute; + border-width: 1px 0px 0px 0px; + font-size: 1px; + border-style: dotted; + border-color: #86A3BE; + margin: 0px; + padding: 0px; +} +.ganttResourceTreeImage{ + cursor: pointer; + z-index:12; + position: absolute; +} +.ganttResourcePanelNamesOwners{ + position:relative; + background: url("images/resourceBg.png") repeat scroll 0 0 transparent; +} +.ganttImageProgressFilled{ + background: url("images/projProgressFilled.png") repeat scroll 0 0 transparent; +} +.ganttImageProgressBg{ + background: url("images/projProgressBg.png") repeat scroll 0 0 transparent; +} +.ganttImageTaskProgressFilled{ + background: url("images/taskProgressFilled.png") repeat scroll 0 0 transparent; +} +.ganttImageTaskProgressBg{ + background: url("images/taskProgressBg.png") repeat scroll 0 0 transparent; +} +.ganttImageTreeCollapse{ + background: url("images/collapse.png") no-repeat scroll 0 0 transparent; + height: 9px; + width: 9px; +} +.ganttImageTreeExpand{ + background: url("images/expand.png") no-repeat scroll 0 0 transparent; + height: 9px; + width: 9px; +} +.ganttImageArrow{ + background: url("images/taskArrow.gif") no-repeat scroll 0 0 transparent; +} diff --git a/js/dojo-1.6/dojox/gantt/resources/images/Thumbs.db b/js/dojo-1.6/dojox/gantt/resources/images/Thumbs.db Binary files differnew file mode 100644 index 0000000..d28cf12 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/Thumbs.db diff --git a/js/dojo-1.6/dojox/gantt/resources/images/am.png b/js/dojo-1.6/dojox/gantt/resources/images/am.png Binary files differnew file mode 100644 index 0000000..94b127e --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/am.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/arrow.gif b/js/dojo-1.6/dojox/gantt/resources/images/arrow.gif Binary files differnew file mode 100644 index 0000000..3bd0863 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/arrow.gif diff --git a/js/dojo-1.6/dojox/gantt/resources/images/bg.png b/js/dojo-1.6/dojox/gantt/resources/images/bg.png Binary files differnew file mode 100644 index 0000000..a6cd044 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/bg.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/collapse.png b/js/dojo-1.6/dojox/gantt/resources/images/collapse.png Binary files differnew file mode 100644 index 0000000..1ae0697 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/collapse.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/expand.png b/js/dojo-1.6/dojox/gantt/resources/images/expand.png Binary files differnew file mode 100644 index 0000000..14a4f6d --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/expand.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/load.png b/js/dojo-1.6/dojox/gantt/resources/images/load.png Binary files differnew file mode 100644 index 0000000..df33667 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/load.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/menuHighlight.png b/js/dojo-1.6/dojox/gantt/resources/images/menuHighlight.png Binary files differnew file mode 100644 index 0000000..22328a7 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/menuHighlight.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/minus.gif b/js/dojo-1.6/dojox/gantt/resources/images/minus.gif Binary files differnew file mode 100644 index 0000000..470c673 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/minus.gif diff --git a/js/dojo-1.6/dojox/gantt/resources/images/ownerBar.png b/js/dojo-1.6/dojox/gantt/resources/images/ownerBar.png Binary files differnew file mode 100644 index 0000000..da9aa60 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/ownerBar.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/parentnode_bg.png b/js/dojo-1.6/dojox/gantt/resources/images/parentnode_bg.png Binary files differnew file mode 100644 index 0000000..e58367b --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/parentnode_bg.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/parentnode_filled.png b/js/dojo-1.6/dojox/gantt/resources/images/parentnode_filled.png Binary files differnew file mode 100644 index 0000000..d2bba7b --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/parentnode_filled.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/plus.gif b/js/dojo-1.6/dojox/gantt/resources/images/plus.gif Binary files differnew file mode 100644 index 0000000..ff22238 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/plus.gif diff --git a/js/dojo-1.6/dojox/gantt/resources/images/pm.png b/js/dojo-1.6/dojox/gantt/resources/images/pm.png Binary files differnew file mode 100644 index 0000000..0e01327 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/pm.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/progress_bg.png b/js/dojo-1.6/dojox/gantt/resources/images/progress_bg.png Binary files differnew file mode 100644 index 0000000..69205da --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/progress_bg.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/progress_filled.png b/js/dojo-1.6/dojox/gantt/resources/images/progress_filled.png Binary files differnew file mode 100644 index 0000000..6f2c1c7 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/progress_filled.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/projProgressBg.png b/js/dojo-1.6/dojox/gantt/resources/images/projProgressBg.png Binary files differnew file mode 100644 index 0000000..e58367b --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/projProgressBg.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/projProgressFilled.png b/js/dojo-1.6/dojox/gantt/resources/images/projProgressFilled.png Binary files differnew file mode 100644 index 0000000..d2bba7b --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/projProgressFilled.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/rbg.png b/js/dojo-1.6/dojox/gantt/resources/images/rbg.png Binary files differnew file mode 100644 index 0000000..71f7daa --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/rbg.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/resourceBg.png b/js/dojo-1.6/dojox/gantt/resources/images/resourceBg.png Binary files differnew file mode 100644 index 0000000..71f7daa --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/resourceBg.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/resourceHeader.png b/js/dojo-1.6/dojox/gantt/resources/images/resourceHeader.png Binary files differnew file mode 100644 index 0000000..b6f7c6a --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/resourceHeader.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/rheader.png b/js/dojo-1.6/dojox/gantt/resources/images/rheader.png Binary files differnew file mode 100644 index 0000000..b6f7c6a --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/rheader.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/rowHighlight.png b/js/dojo-1.6/dojox/gantt/resources/images/rowHighlight.png Binary files differnew file mode 100644 index 0000000..3dd4e94 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/rowHighlight.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/save.png b/js/dojo-1.6/dojox/gantt/resources/images/save.png Binary files differnew file mode 100644 index 0000000..0527fc5 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/save.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/taskArrow.gif b/js/dojo-1.6/dojox/gantt/resources/images/taskArrow.gif Binary files differnew file mode 100644 index 0000000..3bd0863 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/taskArrow.gif diff --git a/js/dojo-1.6/dojox/gantt/resources/images/taskBar.png b/js/dojo-1.6/dojox/gantt/resources/images/taskBar.png Binary files differnew file mode 100644 index 0000000..e5245d2 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/taskBar.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/taskProgressBg.png b/js/dojo-1.6/dojox/gantt/resources/images/taskProgressBg.png Binary files differnew file mode 100644 index 0000000..69205da --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/taskProgressBg.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/taskProgressFilled.png b/js/dojo-1.6/dojox/gantt/resources/images/taskProgressFilled.png Binary files differnew file mode 100644 index 0000000..6f2c1c7 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/taskProgressFilled.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/zoomin.png b/js/dojo-1.6/dojox/gantt/resources/images/zoomin.png Binary files differnew file mode 100644 index 0000000..254c5cb --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/zoomin.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/zoomintime.png b/js/dojo-1.6/dojox/gantt/resources/images/zoomintime.png Binary files differnew file mode 100644 index 0000000..459346a --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/zoomintime.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/zoomout.png b/js/dojo-1.6/dojox/gantt/resources/images/zoomout.png Binary files differnew file mode 100644 index 0000000..dfc2dc0 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/zoomout.png diff --git a/js/dojo-1.6/dojox/gantt/resources/images/zoomouttime.png b/js/dojo-1.6/dojox/gantt/resources/images/zoomouttime.png Binary files differnew file mode 100644 index 0000000..beea687 --- /dev/null +++ b/js/dojo-1.6/dojox/gantt/resources/images/zoomouttime.png |
