diff --git a/css/style.css b/css/style.css index 0756dfe..fcf3f34 100644 --- a/css/style.css +++ b/css/style.css @@ -323,7 +323,7 @@ width: 20px; height: 20px; font-size: 0px; - background: #595959 url(../img/icon_sprite.png) !important; + background: #595959 url(../img/icon_sprite.png); border: 1px solid #454546; cursor: pointer; vertical-align: top; @@ -343,6 +343,16 @@ box-shadow: 0 1px 1px rgba(0,0,0,0.25) inset, 0 1px 0 #FFF; } +.fn-gantt .nav-link:disabled { + border: 1px solid #C4C4C4; + background-color: #dddddd; + -webkit-box-shadow: 0 0px 0px rgba(0,0,0,0); + -moz-box-shadow: 0 0px 0px rgba(0,0,0,0); + box-shadow: 0 0px 0px rgba(0,0,0,0); + + cursor: not-allowed; +} + .fn-gantt .navigate .nav-page-back { background-position: 1px 0 !important; margin: 0; diff --git a/index.html b/index.html index dd193db..610fabb 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ - + jQuery.Gantt @@ -185,7 +185,7 @@

"days" - string ("months", "weeks", "days", "hours") + string ("months", "weeks", "days", "hours12", "hours6", "hours3", "hours") @@ -196,7 +196,7 @@

"months" - string ("months", "weeks", "days", "hours") + string ("months", "weeks", "days", "hours12", "hours6", "hours3", "hours") @@ -207,7 +207,7 @@

"hours" - string ("months", "weeks", "days", "hours") + string ("months", "weeks", "days", "hours12", "hours6", "hours3", "hours") @@ -487,16 +487,16 @@

name: "Sprint 0", desc: "Analysis", values: [{ - from: "/Date(1320192000000)/", - to: "/Date(1322401600000)/", + from: "/Date(1446336000000)/", + to: "/Date(1448545600000)/", label: "Requirement Gathering", customClass: "ganttRed" }] },{ desc: "Scoping", values: [{ - from: "/Date(1322611200000)/", - to: "/Date(1323302400000)/", + from: "/Date(1448755200000)/", + to: "/Date(1449446400000)/", label: "Scoping", customClass: "ganttRed" }] @@ -504,8 +504,8 @@

name: "Sprint 1", desc: "Development", values: [{ - from: "/Date(1323802400000)/", - to: "/Date(1325685200000)/", + from: "/Date(1449946400000)/", + to: "/Date(1451829200000)/", label: "Development", customClass: "ganttGreen" }] @@ -513,8 +513,8 @@

name: " ", desc: "Showcasing", values: [{ - from: "/Date(1325685200000)/", - to: "/Date(1325695200000)/", + from: "/Date(1451829200000)/", + to: "/Date(1451839200000)/", label: "Showcasing", customClass: "ganttBlue" }] @@ -522,16 +522,16 @@

name: "Sprint 2", desc: "Development", values: [{ - from: "/Date(1326785200000)/", - to: "/Date(1325785200000)/", + from: "/Date(1452929200000)/", + to: "/Date(1451929200000)/", label: "Development", customClass: "ganttGreen" }] },{ desc: "Showcasing", values: [{ - from: "/Date(1328785200000)/", - to: "/Date(1328905200000)/", + from: "/Date(1454929200000)/", + to: "/Date(1455049200000)/", label: "Showcasing", customClass: "ganttBlue" }] @@ -539,24 +539,24 @@

name: "Release Stage", desc: "Training", values: [{ - from: "/Date(1330011200000)/", - to: "/Date(1336611200000)/", + from: "/Date(1456155200000)/", + to: "/Date(1462755200000)/", label: "Training", customClass: "ganttOrange" }] },{ desc: "Deployment", values: [{ - from: "/Date(1336611200000)/", - to: "/Date(1338711200000)/", + from: "/Date(1462755200000)/", + to: "/Date(1464855200000)/", label: "Deployment", customClass: "ganttOrange" }] },{ desc: "Warranty Period", values: [{ - from: "/Date(1336611200000)/", - to: "/Date(1349711200000)/", + from: "/Date(1462755200000)/", + to: "/Date(1475855200000)/", label: "Warranty Period", customClass: "ganttOrange" }] diff --git a/js/jquery.fn.gantt.js b/js/jquery.fn.gantt.js index 564f419..e06088a 100644 --- a/js/jquery.fn.gantt.js +++ b/js/jquery.fn.gantt.js @@ -100,14 +100,14 @@ // `getRepDate` returns the milliseconds since the epoch for a given date // depending on the active scale - Date.prototype.getRepDate = function (scale) { - switch (scale) { - case "hours": - return this.getTime(); + Date.prototype.getRepDate = function (scaleGroup) { + switch (scaleGroup) { case "weeks": return this.getDayForWeek().getTime(); case "months": return new Date(this.getFullYear(), this.getMonth(), 1).getTime(); + case "hours": + /* falls through */ case "days": /* falls through */ default: @@ -169,7 +169,24 @@ $.fn.gantt = function (options) { - var scales = ["hours", "days", "weeks", "months"]; + var scales = ["hours", "hours3", "hours6", "hours12", "days", "weeks", "months"]; + var scaleSettings = { + "hours": {scaleGroup: "hours", scaleStep: 1}, + "hours3": {scaleGroup: "hours", scaleStep: 3}, + "hours6": {scaleGroup: "hours", scaleStep: 6}, + "hours12": {scaleGroup: "hours", scaleStep: 12}, + "days": {scaleGroup: "days"}, + "weeks": {scaleGroup: "weeks"}, + "months": {scaleGroup: "months"}, + }; + + var scaleGroupSttings = { + "hours": {headerRows: 5}, + "days": {headerRows: 4}, + "weeks": {headerRows: 3}, + "months": {headerRows: 2}, + }; + //Default settings var settings = { source: [], @@ -199,6 +216,13 @@ // read options $.extend(settings, options); + settings.scale = ($.inArray(settings.scale, scales) >= 0) ? settings.scale : "days"; + settings.maxScale = ($.inArray(settings.maxScale, scales) >= 0) ? settings.maxScale : scales[scales.length - 1]; + settings.minScale = ($.inArray(settings.minScale, scales) >= 0) ? settings.minScale : scales[0]; + + settings.maxScale = ($.inArray(settings.scale, scales) <= $.inArray(settings.maxScale, scales) ? settings.maxScale : settings.scale); + settings.minScale = ($.inArray(settings.scale, scales) >= $.inArray(settings.minScale, scales) ? settings.minScale : settings.scale); + // can't use cookie if don't have `$.cookie` settings.useCookie = settings.useCookie && $.isFunction($.cookie); @@ -276,9 +300,7 @@ $(element).empty().append(element.gantt); - element.scrollNavigation.panelMargin = parseInt($dataPanel.css("margin-left").replace("px", ""), 10); - element.scrollNavigation.panelMaxPos = ($dataPanel.width() - $rightPanel.width()); - + element.scrollNavigation.panelMaxPos = ($dataPanel.width() - $rightPanel.width()) * -1; element.scrollNavigation.canScroll = ($dataPanel.width() > $rightPanel.width()); core.markNow(element); @@ -306,11 +328,13 @@ element.scaleOldWidth = null; } $dataPanel.css({ "margin-left": element.hPosition }); - element.scrollNavigation.panelMargin = element.hPosition; } core.repositionLabel(element); } + core.switchScrollButton(element); + + $dataPanel.css({ height: $leftPanel.height() }); core.waitToggle(element); settings.onRender(); @@ -319,9 +343,10 @@ // Create and return the left panel with labels leftPanel: function (element) { /* Left panel */ + var headerRows = scaleGroupSttings[element.scaleGroup].headerRows; var ganttLeftPanel = $('
') .append($('
') - .css("height", tools.getCellSize() * element.headerRows) + .css("height", tools.getCellSize() * headerRows) .css("width", "100%")); var entries = []; @@ -373,21 +398,8 @@ var corrX/* <- never used? */, corrY; var leftpanel = $(element).find(".fn-gantt .leftPanel"); var datapanel = $(element).find(".fn-gantt .dataPanel"); - switch (settings.scale) { - case "months": - corrY = tools.getCellSize(); - break; - case "hours": - corrY = tools.getCellSize() * 4; - break; - case "days": - corrY = tools.getCellSize() * 3; - break; - case "weeks": - /* falls through */ - default: - corrY = tools.getCellSize() * 2; - } + + corrY = tools.getCellSize() * (scaleGroupSttings[element.scaleGroup].headerRows -1); /* Adjust, so get middle of elm corrY -= Math.floor(tools.getCellSize() / 2); @@ -451,11 +463,12 @@ var rday, dayClass; var dataPanel; - // Setup the headings based on the chosen `settings.scale` - switch (settings.scale) { + // Setup the headings based on scaleGroup + switch (element.scaleGroup) { // **Hours** case "hours": - range = tools.parseTimeRange(element.dateStart, element.dateEnd, element.scaleStep); + var scaleStep = scaleSettings[settings.scale].scaleStep; + range = tools.parseTimeRange(element.dateStart, element.dateEnd, scaleStep); year = range[0].getFullYear(); month = range[0].getMonth(); @@ -526,7 +539,7 @@ '" id="dh-' + rday.getTime() + '" data-offset="' + i * tools.getCellSize() + - '" data-repdate="' + rday.getRepDate(settings.scale) + + '" data-repdate="' + rday.getRepDate(element.scaleGroup) + '">
' + rday.getHours() + '
'); @@ -626,7 +639,7 @@ '
' + + '" data-repdate="' + rday.getRepDate(element.scaleGroup) + '">' + '
' + week + '
'); } @@ -679,7 +692,7 @@ monthArr.push( '
' + + '" data-repdate="' + rday.getRepDate(element.scaleGroup) + '">' + (1 + rday.getMonth()) + '
'); } @@ -756,12 +769,12 @@ '
' + + '" data-repdate="' + rday.getRepDate(element.scaleGroup) + '">' + '
' + rday.getDate() + '
'); dowArr.push( '
' + + '" data-repdate="' + rday.getRepDate(element.scaleGroup) + '">' + '
' + settings.dow[day] + '
'); } //for @@ -803,6 +816,7 @@ .append($('