Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve createProgressBar, update homepage, fix css bug #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,6 @@
text-align: center;
}

.fn-gantt .holiday {
background-color: #ffd263;
height: 23px;
margin: 0 0 -1px -1px;
}

.fn-gantt .today {
background-color: #fff8da;
height: 23px;
margin: 0 0 -1px -1px;
font-weight: bold;
text-align: center;
}

.fn-gantt .sa, .fn-gantt .sn, .fn-gantt .wd {
height: 23px;
margin: 0 0 0 -1px;
Expand All @@ -153,6 +139,20 @@
text-align: center;
}

.fn-gantt .holiday {
background-color: #ffd263;
height: 23px;
margin: 0 0 -1px -1px;
}

.fn-gantt .today {
background-color: #999894;
color: white;
height: 23px;
margin: 0 0 -1px -1px;
text-align: center;
}

.fn-gantt .rightPanel .month, .fn-gantt .rightPanel .year {
float: left;
overflow: hidden;
Expand Down
70 changes: 39 additions & 31 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1">
<link href="css/style.css" type="text/css" rel="stylesheet">
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="http://taitems.github.com/UX-Lab/core/css/prettify.css" rel="stylesheet" type="text/css">
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="//taitems.github.com/UX-Lab/core/css/prettify.css" rel="stylesheet" type="text/css">
<style type="text/css">
body {
font-family: Helvetica, Arial, sans-serif;
Expand Down Expand Up @@ -435,102 +435,111 @@ <h2>

</div>

<script src="js/jquery.min.js"></script>
<script src="js/jquery.fn.gantt.min2.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="http://taitems.github.com/UX-Lab/core/js/prettify.js"></script>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="js/jquery.fn.gantt.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="//taitems.github.com/UX-Lab/core/js/prettify.js"></script>
<script>
$(function() {

"use strict";

var today = new Date();

$(".gantt").gantt({
source: [{
name: "Sprint 0",
desc: "Analysis",
values: [{
id: "t01",
from: "/Date(1320192000000)/",
to: "/Date(1322401600000)/",
from: today.getTime() - 1000*60*60*24*120,
to: today.getTime() - 1000*60*60*24*60,
label: "Requirement Gathering",
customClass: "ganttRed"
customClass: "ganttRed",
}]
},{
name: " ",
desc: "Scoping",
values: [{
id: "t02",
from: "/Date(1322611200000)/",
to: "/Date(1323302400000)/",
from: today.getTime() - 1000*60*60*24*90,
to: today.getTime() - 1000*60*60*24*50,
label: "Scoping",
customClass: "ganttRed"
customClass: "ganttRed",
}]
},{
name: "Sprint 1",
desc: "Development",
values: [{
from: "/Date(1323802400000)/",
to: "/Date(1325685200000)/",
from: today.getTime() - 1000*60*60*24*50,
to: today.getTime() - 1000*60*60*24*30,
label: "Development",
customClass: "ganttGreen"
customClass: "ganttGreen",
dataObj: {
"title": "Sprint 1",
"content": "worker: Bob<br />Cras mattis consectetur purus sit amet fermentum.",
"html": "true",
}
}]
},{
name: " ",
desc: "Showcasing",
values: [{
from: "/Date(1325685200000)/",
to: "/Date(1325695200000)/",
from: today.getTime() - 1000*60*60*24*20,
to: today.getTime() + 1000*60*60*24*50,
label: "Showcasing",
customClass: "ganttBlue"
}]
},{
name: "Sprint 2",
desc: "Development",
values: [{
from: "/Date(1326785200000)/",
to: "/Date(1325785200000)/",
from: today.getTime() - 1000*60*60*24*10,
to: today.getTime() + 1000*60*60*24*40,
label: "Development",
customClass: "ganttGreen"
}]
},{
name: " ",
desc: "Showcasing",
values: [{
from: "/Date(1328785200000)/",
to: "/Date(1328905200000)/",
from: today.getTime() + 1000*60*60*24*50,
to: today.getTime() + 1000*60*60*24*80,
label: "Showcasing",
customClass: "ganttBlue"
}]
},{
name: "Release Stage",
desc: "Training",
values: [{
from: "/Date(1330011200000)/",
to: "/Date(1336611200000)/",
from: today.getTime() + 1000*60*60*24*80,
to: today.getTime() + 1000*60*60*24*120,
label: "Training",
customClass: "ganttOrange"
}]
},{
name: " ",
desc: "Deployment",
values: [{
from: "/Date(1336611200000)/",
to: "/Date(1338711200000)/",
from: today.getTime() + 1000*60*60*24*80,
to: today.getTime() + 1000*60*60*24*90,
label: "Deployment",
customClass: "ganttOrange"
}]
},{
name: " ",
desc: "Warranty Period",
values: [{
from: "/Date(1336611200000)/",
to: "/Date(1349711200000)/",
from: today.getTime() + 1000*60*60*24*90,
to: today.getTime() + 1000*60*60*24*150,
label: "Warranty Period",
customClass: "ganttOrange"
}]
}],
navigate: "scroll",
maxScale: "hours",
scale: "weeks",
maxScale: "months",
minScale: "days",
itemsPerPage: 10,
onItemClick: function(data) {
alert("Item clicked - show some details");
Expand All @@ -550,9 +559,8 @@ <h2>

$(".gantt").popover({
selector: ".bar",
title: "I'm a popover",
content: "And I'm the content of said popover.",
trigger: "hover"
trigger: "hover",
placement: "auto"
});

prettyPrint();
Expand Down
89 changes: 35 additions & 54 deletions js/jquery.fn.gantt.js
Original file line number Diff line number Diff line change
Expand Up @@ -940,15 +940,23 @@
// **Progress Bar**
// Return an element representing a progress of position within
// the entire chart
createProgressBar: function (days, cls, desc, label, dataObj) {
createProgressBar: function (day) {

var days = ("dl" in day) ? day.dl : "";
var id = ("id" in day) ? day.id : "";
var cls = ("customClass" in day) ? day.customClass : "";
var desc = ("desc" in day) ? day.desc : "";
var label = ("label" in day) ? day.label : "";
var dataObj = ("dataObj" in day) ? day.dataObj : null;

var cellWidth = tools.getCellSize();
var barMarg = tools.getProgressBarMargin() || 0;
var bar = $('<div class="bar"><div class="fn-label">' + label + '</div></div>')
.addClass(cls)
.css({
width: ((cellWidth * days) - barMarg) + 2
})
.data("dataObj", dataObj);
.data(dataObj);

if (desc) {
bar
Expand Down Expand Up @@ -1010,21 +1018,21 @@
return "";
}
};
var darkerColor = function(colStr) {
try {
colStr = colStr.replace('rgb(','').replace(')','');
var rgbArr = colStr.split(',');
var R = parseInt(rgbArr[0]);
var G = parseInt(rgbArr[1]);
var B = parseInt(rgbArr[2]);
R = R-Math.round(parseInt(R)/7);
G = G-Math.round(parseInt(G)/7);
B = B-Math.round(parseInt(B)/7);
return 'rgb('+R+', '+G+', '+B+')';
} catch (err) {
return '';
}
};
var darkerColor = function(colStr) {
try {
colStr = colStr.replace('rgb(','').replace(')','');
var rgbArr = colStr.split(',');
var R = parseInt(rgbArr[0]);
var G = parseInt(rgbArr[1]);
var B = parseInt(rgbArr[2]);
R = R-Math.round(parseInt(R)/7);
G = G-Math.round(parseInt(G)/7);
B = B-Math.round(parseInt(B)/7);
return 'rgb('+R+', '+G+', '+B+')';
} catch (err) {
return '';
}
};
$.each(element.data, function (i, entry) {
if (i >= element.pageNum * settings.itemsPerPage && i < (element.pageNum * settings.itemsPerPage + settings.itemsPerPage)) {

Expand All @@ -1045,15 +1053,9 @@
var cFrom = from.attr("offset");
var cTo = to.attr("offset");
var dl = Math.floor((cTo - cFrom) / tools.getCellSize()) + 1;
day.dl = dl;

_bar = core.createProgressBar(
dl,
day.id ? day.id : "",
day.customClass ? day.customClass : "",
day.desc ? day.desc : "",
day.label ? day.label : "",
day.dataObj ? day.dataObj : null
);
_bar = core.createProgressBar(day);

// find row
var topEl = $(element).find("#rowheader" + i);
Expand Down Expand Up @@ -1082,22 +1084,13 @@
}

var from = $(element).find("#" + dtFrom.getWeekId());

var cFrom = from.attr("offset");

var to = $(element).find("#" + dtTo.getWeekId());
var cTo = to.attr("offset");

var dl = Math.round((cTo - cFrom) / tools.getCellSize()) + 1;
day.dl = dl;

_bar = core.createProgressBar(
dl,
day.id ? day.id : "",
day.customClass ? day.customClass : "",
day.desc ? day.desc : "",
day.label ? day.label : "",
day.dataObj ? day.dataObj : null
);
_bar = core.createProgressBar(day);

// find row
var topEl = $(element).find("#rowheader" + i);
Expand Down Expand Up @@ -1130,15 +1123,9 @@
var to = $(element).find("#dh-" + tools.genId(dtTo.getTime()));
var cTo = to.attr("offset");
var dl = Math.round((cTo - cFrom) / tools.getCellSize()) + 1;
day.dl = dl;

_bar = core.createProgressBar(
dl,
day.id ? day.id : "",
day.customClass ? day.customClass : "",
day.desc ? day.desc : "",
day.label ? day.label : "",
day.dataObj ? day.dataObj : null
);
_bar = core.createProgressBar(day);

// find row
var topEl = $(element).find("#rowheader" + i);
Expand All @@ -1156,16 +1143,10 @@

var from = $(element).find("#dh-" + dFrom);
var cFrom = from.attr("offset");

var dl = Math.floor(((dTo / 1000) - (dFrom / 1000)) / 86400) + 1;
_bar = core.createProgressBar(
dl,
day.id ? day.id : "",
day.customClass ? day.customClass : "",
day.desc ? day.desc : "",
day.label ? day.label : "",
day.dataObj ? day.dataObj : null
);
day.dl = dl;

_bar = core.createProgressBar(day);

// find row
var topEl = $(element).find("#rowheader" + i);
Expand Down Expand Up @@ -1333,7 +1314,7 @@

// Move chart via mousewheel
wheelScroll: function (element, e) {
e.preventDefault(); // e is a jQuery Event
e.preventDefault(); // e is a jQuery Event
var delta = e.detail ? e.detail * (-50) : e.wheelDelta / 120 * 50;

core.scrollPanel(element, delta);
Expand Down
61 changes: 57 additions & 4 deletions js/jquery.fn.gantt.min.js

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions js/jquery.min.js

This file was deleted.