Skip to content
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
8 changes: 8 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@
color: #714715 !important;
}

.fn-gantt .highlight {
background-color: rgba(222, 238, 239, 0.6);
z-index: 1;
position: absolute;
height: 24px;
width : 100%;
}


/* === BOTTOM NAVIGATION === */

Expand Down
13 changes: 11 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>jQuery.Gantt</title>
Expand Down Expand Up @@ -271,6 +271,14 @@ <h2 id="config">
<td>
Boolean</td>
</tr>
<tr>
<td>
<code>highlightRow</code></td>
<td>
<code>true</code></td>
<td>
Boolean</td>
</tr>
</tbody>
</table>

Expand Down Expand Up @@ -577,7 +585,8 @@ <h2 id="values">
if (window.console && typeof console.log === "function") {
console.log("chart rendered");
}
}
},
highlightRow : false
});

$(".gantt").popover({
Expand Down
82 changes: 60 additions & 22 deletions js/jquery.fn.gantt.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@
// callbacks
onItemClick: function (data) { return; },
onAddClick: function (dt, rowId) { return; },
onRender: $.noop
onRender: $.noop,
// extensions
highlightRow : true
};

// read options
Expand Down Expand Up @@ -284,6 +286,10 @@
core.markNow(element);
core.fillData(element, $dataPanel, $leftPanel);

if (element.highlightedRow !== null) {
core.highlightRow(element, element.highlightedRow);
}

// Set a cookie to record current position in the view
if (settings.useCookie) {
var sc = $.cookie(settings.cookieKey + "ScrollPos");
Expand Down Expand Up @@ -324,36 +330,33 @@
.css("height", tools.getCellSize() * element.headerRows)
.css("width", "100%"));

var entries = [];
$.each(element.data, function (i, entry) {
if (i >= element.pageNum * settings.itemsPerPage &&
i < (element.pageNum * settings.itemsPerPage + settings.itemsPerPage)) {
var dataId = ('id' in entry) ? '" data-id="' + entry.id : '';
entries.push(
'<div class="row name row' + i +
(entry.desc ? '' : (' fn-wide '+dataId)) +
'" id="rowheader' + i +
'" data-offset="' + i % settings.itemsPerPage * tools.getCellSize() + '">' +
'<span class="fn-label' +
(entry.cssClass ? ' ' + entry.cssClass : '') + '">' +
(entry.name || '') +
'</span>' +
'</div>');

var nameRow = $('<div>').addClass('row name').addClass('row' + i).addClass(entry.desc ? '' : 'fn-wide')
.attr('id', 'rowheader' + i).data('offset', i % settings.itemsPerPage * tools.getCellSize()).data('id', entry.id)
.append(
$('<span>').addClass('fn-label').addClass(entry.cssClass ? entry.cssClass : '').text(entry.name || '')
);

core.setRowClick(element, nameRow, i);

ganttLeftPanel.append(nameRow);

if (entry.desc) {
entries.push(
'<div class="row desc row' + i +
' " id="RowdId_' + i + dataId + '">' +
'<span class="fn-label' +
(entry.cssClass ? ' ' + entry.cssClass : '') + '">' +
entry.desc +
'</span>' +
'</div>');
var descRow = $('<div>').addClass('row desc').addClass('row' + i).attr('id', 'RowdId_' + i).data('id', entry.id)
.append(
$('<span>').addClass('fn-label').addClass(entry.cssClass ? entry.cssClass : '').text(entry.desc)
);
core.setRowClick(element, descRow, i);

ganttLeftPanel.append(descRow);
}

}
});
return ganttLeftPanel.append(entries.join(""));
return ganttLeftPanel;
},

// Create and return the data panel element
Expand Down Expand Up @@ -1158,6 +1161,40 @@
}
});
},

setRowClick: function(element, row, rowNum) {
row.click(function() {
if (settings.highlightRow) {
// remove highlight
$(element).find(".fn-gantt .rightPanel .dataPanel .highlight").remove();

if(element.highlightedRow === rowNum) {
// currently highlighted
element.highlightedRow = null;
return false;
}

// currently no highlight or highlight another line
core.highlightRow(element, rowNum);
}

});
},

highlightRow: function(element, rowNum) {
var $dataPanel = $(element).find(".fn-gantt .rightPanel .dataPanel");

var topEl = $(element).find("#rowheader" + rowNum);
if (topEl.length > 0) {
var top = tools.getCellSize() * element.headerRows + topEl.data("offset");

var highlight = $('<div>').addClass('highlight').css('top', top);
$dataPanel.append(highlight);

element.highlightedRow = rowNum;
}
},

// **Navigation**
navigateTo: function (element, val) {
var $rightPanel = $(element).find(".fn-gantt .rightPanel");
Expand Down Expand Up @@ -1705,6 +1742,7 @@
this.pageCount = 0; // Available pages count
this.rowsOnLastPage = 0; // How many rows on last page
this.rowsNum = 0; // Number of total rows
this.highlightedRow = null; // Currnt highlighted row number
this.hPosition = 0; // Current position on diagram (Horizontal)
this.dateStart = null;
this.dateEnd = null;
Expand Down