Skip to content

Commit

Permalink
sbstjn#17 - Support ongoing items, improve range typography.
Browse files Browse the repository at this point in the history
If the end date is 'present', the bubble will extend to the end of the last year and the label will display an open range (with the correct em-dash). Also changed the closed range (e.g. 2001-2004) to use the correct dash (en).
  • Loading branch information
jpgcc committed Sep 21, 2014
1 parent 45d485c commit 7834cf3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/timesheet.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions source/javascripts/timesheet.bubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
/**
* Timesheet Bubble
*/
var Bubble = function(wMonth, min, start, end) {
var Bubble = function(wMonth, min, start, end, endless) {
this.min = min;
this.start = start;
this.end = end;
this.endless = endless;
this.widthMonth = wMonth;
};

Expand Down Expand Up @@ -70,7 +71,9 @@
Bubble.prototype.getDateLabel = function() {
return [
(this.start.hasMonth ? this.formatMonth(this.start.getMonth() + 1) + '/' : '' ) + this.start.getFullYear(),
(this.end ? '-' + ((this.end.hasMonth ? this.formatMonth(this.end.getMonth() + 1) + '/' : '' ) + this.end.getFullYear()) : '')
(this.endless ? '—' :
(this.end ? '–' + ((this.end.hasMonth ? this.formatMonth(this.end.getMonth() + 1) + '/' : '' ) + this.end.getFullYear()) : '')
)
].join('');
};

Expand Down
5 changes: 4 additions & 1 deletion source/javascripts/timesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

for (var n = 0, m = this.data.length; n < m; n++) {
var cur = this.data[n];
var bubble = new TimesheetBubble(widthMonth, this.year.min, cur.start, cur.end);
var bubble = new TimesheetBubble(widthMonth, this.year.min, cur.start, cur.end ? cur.end : new Date(this.year.max+1, 0, 1), cur.end ? false : true);

var line = [
'<span style="margin-left: ' + bubble.getStartOffset() + 'px; width: ' + bubble.getWidth() + 'px;" class="bubble bubble-' + (cur.type || 'default') + '" data-duration="' + (cur.end ? Math.round((cur.end-cur.start)/1000/60/60/24/39) : '') + '"></span>',
Expand Down Expand Up @@ -65,6 +65,9 @@
* Parse data string
*/
Timesheet.prototype.parseDate = function(date) {
if (date === 'present') {
return null;
}
if (date.indexOf('/') === -1) {
date = new Date(parseInt(date, 10), 0, 1);
date.hasMonth = false;
Expand Down

0 comments on commit 7834cf3

Please sign in to comment.