Files
NodeBB/public/src/modules/sort.js
Barış Soner Uşaklı 3526c937cc fix: tag urls getting double escaped (#13306)
* fix: tag urls getting double escaped

get rid of weird decodeURIComponent($.param()) usage
$.param returns a string suitable for use in query param string

* add a new test
2025-04-07 13:23:22 -04:00

27 lines
816 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[data-sort]')
.on('click', '[component="thread/sort"] a[data-sort]', function () {
const newSetting = $(this).attr('data-sort');
const urlParams = utils.params();
urlParams.sort = newSetting;
const qs = $.param(urlParams);
ajaxify.go(gotoOnSave + (qs ? '?' + qs : ''));
});
};
return module;
});