Skip to content
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){
};

})();