Skip to content

Commit

Permalink
issue-51: Resolved IE10 table insertion issue (yabwe#52)
Browse files Browse the repository at this point in the history
* issue-51: Resolved IE10 table insertion issue
* issue-51: Fixed Travis comments
* issue-51: added 'classlist' in el
* issue-51: Removed dataset line
  • Loading branch information
vikasrj authored and j0k3r committed Jun 1, 2017
1 parent c06592e commit cf23596
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/js/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,25 @@ Grid.prototype = {
markCells: function () {
[].forEach.call(this._cellsElements, function (el) {
var cell = {
column: parseInt(el.dataset.column, 10),
row: parseInt(el.dataset.row, 10)
column: parseInt(el.getAttribute('data-column'), 10),
row: parseInt(el.getAttribute('data-row'), 10)
},
active = this._currentCell &&
cell.row <= this._currentCell.row &&
cell.column <= this._currentCell.column;

if (active === true) {
el.classList.add('active');
if ('classList' in el) {
el.classList.add('active');
} else {
el.className += ' ' + 'active';
}
} else {
el.classList.remove('active');
if ('classList' in el) {
el.classList.remove('active');
} else {
el.className = (' ' + el.className).replace(' ' + 'active' + ' ', '');
}
}
}.bind(this));
},
Expand Down Expand Up @@ -92,15 +100,13 @@ Grid.prototype = {
var self = this,
timer;

el.addEventListener('mouseenter', function () {
el.addEventListener('mouseenter', function (e) {
clearTimeout(timer);

var dataset = this.dataset;

timer = setTimeout(function () {
self._currentCell = {
column: parseInt(dataset.column, 10),
row: parseInt(dataset.row, 10)
column: parseInt(e.target.getAttribute('data-column'), 10),
row: parseInt(e.target.getAttribute('data-row'), 10)
};
self.markCells();
}, 50);
Expand All @@ -111,7 +117,7 @@ Grid.prototype = {
var self = this;
el.addEventListener('click', function (e) {
e.preventDefault();
self._callback(this.dataset.row, this.dataset.column);
self._callback(e.target.getAttribute('data-row'), e.target.getAttribute('data-column'));
});
}
};

0 comments on commit cf23596

Please sign in to comment.