|
|
Line 55: |
Line 55: |
| }); | | }); |
| }]); | | }]); |
|
| |
| function orderByName(currentButton) {
| |
| var sortOrder = tdollSorterActiveButton(currentButton);
| |
|
| |
| var comparer = function (a, b) {
| |
| var nameA=$(a).data('name').toLowerCase();
| |
| var nameB=$(b).data('name').toLowerCase();
| |
| if (nameA < nameB) return -1 * sortOrder;
| |
| if (nameA > nameB) return 1 * sortOrder;
| |
| return 0;
| |
| };
| |
|
| |
| var grouper = function (parent, elements) {
| |
| var currentLetter = getFirstLetterGroup($(elements).first().data('name'));
| |
| var groupHeader = $("<h3><span class="mw-headline" id="Some_heading">").text(currentLetter.toUpperCase() + "...").addClass("addedbysorter");
| |
| groupHeader.insertBefore(elements.first());
| |
|
| |
| $.grep(elements, function(element, i) {
| |
| var currentLetter = getFirstLetterGroup($(element).data('name'));
| |
| var nextElementLetter = getFirstLetterGroup($(elements[i+1]).data('name'));
| |
| if (currentLetter !== nextElementLetter) {
| |
| var groupHeaderText = nextElementLetter.toUpperCase() + "...";
| |
| if (groupHeaderText.trim() != "...") {
| |
| var groupHeader = $("<h3 />").text(groupHeaderText).addClass("addedbysorter");
| |
| groupHeader.insertAfter(element);
| |
| }
| |
| }
| |
| return true;
| |
| });
| |
| };
| |
|
| |
| tdollSorter(comparer, grouper);
| |
| }
| |
|
| |
|
| function getFirstLetterGroup(element) { | | function getFirstLetterGroup(element) { |
Released on this server:
Some heading