Skip to content

Instantly share code, notes, and snippets.

@lsmith
Last active December 17, 2015 02:29
Show Gist options
  • Save lsmith/5536394 to your computer and use it in GitHub Desktop.
Save lsmith/5536394 to your computer and use it in GitHub Desktop.

Revisions

  1. lsmith revised this gist May 7, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,8 @@ _toggleStripes: function (index) {
    var task = this._toggleStripesTask,
    self;

    index |= 0; // force int
    // index|0 to force int, avoid NaN. Math.max() to avoid neg indexes.
    index = Math.max((index|0), 0);

    if (!task) {
    self = this;
  2. lsmith created this gist May 7, 2013.
    29 changes: 29 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    _toggleStripes: function (index) {
    var task = this._toggleStripesTask,
    self;

    index |= 0; // force int

    if (!task) {
    self = this;

    this._toggleStripesTask = {
    timer: setTimeout(function () {
    var odd = [this.CLASS_ODD, this.CLASS_EVEN],
    even = [this.CLASS_EVEN, this.CLASS_ODD];

    self.tbodyNode.get('childNodes')
    .slice(self._toggleStripeTask.index)
    .each(function (row, i) {
    row.replaceClass.apply(row, (index + i) % 2 ? odd : even);
    });

    this._toggleStripesTask = null;
    }, 0),

    index: index
    }
    } else {
    task.index = Math.min(task.index, index);
    }
    }