Skip to content

Commit

Permalink
also merges day-long events showing at the top of the week mode display
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienjoly committed May 24, 2014
1 parent 4d23ded commit 7d55ec5
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion events.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ EventMerger.prototype = {
});

keep.css('background-image', this.makeStripes(colors));
this.cleanUp(keep);
this.cleanUp && this.cleanUp(keep);
}
},
mergeSets: function ($events) {
Expand Down Expand Up @@ -69,3 +69,50 @@ var merger = new EventMerger(eventKey, cleanUp);
$(document).on("DOMNodeInserted", ".tg-mainwrapper", function () {
merger.mergeSets($('dl'));
});

/*****************************************************************************/

// merge day-long events, on top of week mode display

// http://stackoverflow.com/questions/10966687/how-can-i-find-each-table-cells-visual-location-using-jquery/10967488#10967488
function getCellLocation(cell) {
var cols = cell.closest("tr").children("td").index(cell);
var rows = cell.closest("tbody").children("tr").index(cell.closest("tr"));
var coltemp = cols;
var rowtemp = rows;
cell.prevAll("td").each(function() {
cols += ($(this).attr("colspan")) ? parseInt($(this).attr("colspan")) - 1 : 0;
});
cell.parent("tr").prevAll("tr").each(function() {
var rowindex = cell.closest("tbody").children("tr").index($(this));
var row = $(this);
row.children("td").each(function() {
var colindex = row.children("td").index($(this));
if (cell.offset().left > $(this).offset().left) {
var colspn = parseInt($(this).attr("colspan"));
var rowspn = parseInt($(this).attr("rowspan"));
if (colspn && rowspn) {
if(rowindex + rowspn > rows)
cols += colspn;
}
if(rowspn && rowindex + rowspn > rows) cols +=1;
}
});
});
return {
rows: rows,
cols: cols
};
}

var dayLongMerger = new EventMerger(function ($event) {
var event_name = $event.find('span').text(),
$td = $event.parents('td'),
span = $td.attr("colspan") || 1,
col = getCellLocation($td).cols - 2;
return event_name + "_" + col + "_" + span;
});

$(document).on("DOMNodeInserted", "#topcontainerwk", function () {
dayLongMerger.mergeSets($(".rb-n"));
});

0 comments on commit 7d55ec5

Please sign in to comment.