Skip to content
This repository has been archived by the owner on Aug 8, 2019. It is now read-only.

Commit

Permalink
Fixes bug described in mootools#1346
Browse files Browse the repository at this point in the history
Sources out the creation of the sort-span tag in order to re-inject them
on re-enable sorting.
  • Loading branch information
Henning Bopp committed Feb 5, 2017
1 parent f872370 commit 390175b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Source/Interface/HtmlTable.Sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ authors:
- Harald Kirschner
- Aaron Newton
- Jacob Thornton
- Henning Bopp <[email protected]>
requires:
- Core/Hash
Expand Down Expand Up @@ -95,8 +96,7 @@ HtmlTable = Class.refactor(HtmlTable, {
if (cell.hasClass(this.options.classNoSort) || cell.retrieve('htmltable-parser')) return cell.retrieve('htmltable-parser');
var thDiv = new Element('div');
thDiv.adopt(cell.childNodes).inject(cell);
var sortSpan = new Element('span', {'class': this.options.classSortSpan}).inject(thDiv, 'top');
this.sortSpans.push(sortSpan);
this.getHeadSpan().inject(thDiv, 'top');
var parser = this.options.parsers[index],
rows = this.body.rows,
cancel;
Expand Down Expand Up @@ -262,6 +262,7 @@ HtmlTable = Class.refactor(HtmlTable, {
this.element.addClass(this.options.classSortable);
this.attachSorts(true);
this.setParsers();
this.head && this.head.getElements(this.options.thSelector).flatten().map(this.injectHeadSpan, this);
this.sortable = true;
return this;
},
Expand All @@ -275,8 +276,17 @@ HtmlTable = Class.refactor(HtmlTable, {
this.sortSpans.empty();
this.sortable = false;
return this;
}
},

getHeadSpan: function(parent){
var sortSpan = new Element('span', {'class': this.options.classSortSpan});
this.sortSpans.push(sortSpan);
return sortSpan;
},

injectHeadSpan: function(parent){
return this.getHeadSpan().inject(parent);
}
});

HtmlTable.ParserPriority = ['date', 'input-checked', 'input-value', 'float', 'number'];
Expand Down Expand Up @@ -358,4 +368,3 @@ HtmlTable.defineParsers = function(parsers){
};

})();

0 comments on commit 390175b

Please sign in to comment.