mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-22 23:42:54 +01:00
27 lines
814 B
JavaScript
27 lines
814 B
JavaScript
'use strict';
|
|
|
|
|
|
define('sort', ['components'], function (components) {
|
|
const module = {};
|
|
|
|
module.handleSort = function (field, gotoOnSave) {
|
|
const threadSort = components.get('thread/sort');
|
|
threadSort.find('i').removeClass('fa-check');
|
|
const currentSort = utils.params().sort || config[field];
|
|
const currentSetting = threadSort.find('a[data-sort="' + currentSort + '"]');
|
|
currentSetting.find('i').addClass('fa-check');
|
|
|
|
$('body')
|
|
.off('click', '[component="thread/sort"] a')
|
|
.on('click', '[component="thread/sort"] a', function () {
|
|
const newSetting = $(this).attr('data-sort');
|
|
const urlParams = utils.params();
|
|
urlParams.sort = newSetting;
|
|
const qs = decodeURIComponent($.param(urlParams));
|
|
ajaxify.go(gotoOnSave + (qs ? '?' + qs : ''));
|
|
});
|
|
};
|
|
|
|
return module;
|
|
});
|