Widget:indexSorterGrouper: Difference between revisions
Jump to navigation
Jump to search
Fixed Index grouping |
Added reverse sorting and some name bugfix |
||
Line 25: | Line 25: | ||
function orderByName(currentButton) { | function orderByName(currentButton) { | ||
tdollSorterActiveButton(currentButton); | var sortOrder = tdollSorterActiveButton(currentButton); | ||
var comparer = function (a, b) { | var comparer = function (a, b) { | ||
var nameA=$(a).data('name').toLowerCase(); | var nameA=$(a).data('name').toLowerCase(); | ||
var nameB=$(b).data('name').toLowerCase(); | var nameB=$(b).data('name').toLowerCase(); | ||
if (nameA < nameB) return -1; | if (nameA < nameB) return -1 * sortOrder; | ||
if (nameA > nameB) return 1; | if (nameA > nameB) return 1 * sortOrder; | ||
return 0; | return 0; | ||
}; | }; | ||
var grouper = function (parent, elements) { | var grouper = function (parent, elements) { | ||
var currentLetter = getFirstLetterGroup($(elements).first().data('name')); | |||
var groupHeader = $("<h3 />").text(currentLetter.toUpperCase() + "...").addClass("addedbysorter"); | |||
var groupHeader = $("<h3 />").text(" | |||
groupHeader.insertBefore(elements.first()); | groupHeader.insertBefore(elements.first()); | ||
Line 75: | Line 72: | ||
function orderByRarityClassName(currentButton) { | function orderByRarityClassName(currentButton) { | ||
tdollSorterActiveButton(currentButton); | var sortOrder = tdollSorterActiveButton(currentButton); | ||
var comparer = function (a, b) { | var comparer = function (a, b) { | ||
var contentA = getSortKeyForRarityClassName($(a)); | var contentA = getSortKeyForRarityClassName($(a)); | ||
var contentB = getSortKeyForRarityClassName($(b)); | var contentB = getSortKeyForRarityClassName($(b)); | ||
var comp = (contentA < contentB) ? -1 : (contentA > contentB) ? 1 : 0; | |||
return comp * sortOrder; | |||
}; | }; | ||
Line 89: | Line 87: | ||
function orderByClassRarityName(currentButton) { | function orderByClassRarityName(currentButton) { | ||
tdollSorterActiveButton(currentButton); | var sortOrder = tdollSorterActiveButton(currentButton); | ||
var comparer = function (a, b) { | var comparer = function (a, b) { | ||
var contentA = getSortKeyForClassRarityName($(a)); | var contentA = getSortKeyForClassRarityName($(a)); | ||
var contentB = getSortKeyForClassRarityName($(b)); | var contentB = getSortKeyForClassRarityName($(b)); | ||
var comp = (contentA < contentB) ? -1 : (contentA > contentB) ? 1 : 0; | |||
return comp * sortOrder; | |||
}; | }; | ||
Line 182: | Line 181: | ||
function orderByIndex(currentButton) { | function orderByIndex(currentButton) { | ||
tdollSorterActiveButton(currentButton); | var sortOrder = tdollSorterActiveButton(currentButton); | ||
var comparer = function (a, b) { | var comparer = function (a, b) { | ||
var contentA = parseInt($(a).data('index')); | var contentA = parseInt($(a).data('index')); | ||
var contentB = parseInt($(b).data('index')); | var contentB = parseInt($(b).data('index')); | ||
var comp = (contentA < contentB) ? -1 : (contentA > contentB) ? 1 : 0; | |||
return comp * sortOrder; | |||
}; | }; | ||
Line 236: | Line 236: | ||
$('[data-tdollsortbutton="true"]').removeClass("enabled"); | $('[data-tdollsortbutton="true"]').removeClass("enabled"); | ||
$(butt).addClass("enabled"); | $(butt).addClass("enabled"); | ||
if ($(butt).is('.ascending')) { | |||
$(butt).removeClass('ascending'); | |||
return 1; | |||
} else { | |||
$(butt).addClass('ascending'); | |||
return -1; | |||
} | |||
} | } | ||
Revision as of 18:18, 1 May 2018
Released on this server: