Skip to content

Commit 45d485c

Browse files
committed
Merge branch 'olivierrr-master'
2 parents eb7fe56 + 0525e01 commit 45d485c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

dist/timesheet.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/javascripts/timesheet.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* Initialize a Timesheet
1010
*/
1111
var Timesheet = function(container, min, max, data) {
12-
this.container = '#' + container;
1312
this.data = [];
1413
this.year = {
1514
min: min,
@@ -19,6 +18,7 @@
1918
this.parse(data || []);
2019

2120
if (typeof document !== 'undefined') {
21+
this.container = (typeof container === 'string') ? document.querySelector('#'+container) : container;
2222
this.drawSections();
2323
this.insertData();
2424
}
@@ -29,7 +29,7 @@
2929
*/
3030
Timesheet.prototype.insertData = function() {
3131
var html = [];
32-
var widthMonth = document.querySelector(this.container + ' .scale section').offsetWidth;
32+
var widthMonth = this.container.querySelector('.scale section').offsetWidth;
3333

3434
for (var n = 0, m = this.data.length; n < m; n++) {
3535
var cur = this.data[n];
@@ -44,7 +44,7 @@
4444
html.push('<li>' + line + '</li>');
4545
}
4646

47-
document.querySelector(this.container).innerHTML += '<ul class="data">' + html.join('') + '</ul>';
47+
this.container.innerHTML += '<ul class="data">' + html.join('') + '</ul>';
4848
};
4949

5050
/**
@@ -57,8 +57,8 @@
5757
html.push('<section>' + c + '</section>');
5858
}
5959

60-
document.querySelector(this.container).className = 'timesheet color-scheme-default';
61-
document.querySelector(this.container).innerHTML = '<div class="scale">' + html.join('') + '</div>';
60+
this.container.className = 'timesheet color-scheme-default';
61+
this.container.innerHTML = '<div class="scale">' + html.join('') + '</div>';
6262
};
6363

6464
/**

0 commit comments

Comments
 (0)