Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bug described in mootools/mootools-more#1346 #1347

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Source/Interface/HtmlTable.Sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ script: HtmlTable.Sort.js

name: HtmlTable.Sort

description: Builds a stripy, sortable table with methods to add rows.
description: Builds a sortable table with methods to add rows.

license: MIT-style license

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.getSortSpan().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.injectSortSpan, this);
this.sortable = true;
return this;
},
Expand All @@ -275,6 +276,16 @@ HtmlTable = Class.refactor(HtmlTable, {
this.sortSpans.empty();
this.sortable = false;
return this;
},

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

injectSortSpan: function(parent){
return this.getSortSpan().inject(parent, 'top');
}

});
Expand Down Expand Up @@ -358,4 +369,3 @@ HtmlTable.defineParsers = function(parsers){
};

})();