Add accessors for search history #32781

This commit is contained in:
Nicolas Demonte 2020-04-07 17:50:09 +02:00
parent 6b84fcd84d
commit 7479ee5c29
1 changed files with 22 additions and 3 deletions

View File

@ -1,4 +1,25 @@
function store_history_parameter(name, value) {
var next_state = history.state || {};
next_state[name] = value;
history.replaceState(next_state, document.title);
}
function get_history_parameter(name, default_value) {
var history_state = history.state;
if (history_state !== null) {
if (history_state[name] !== undefined) {
return history_state[name];
} else {
return default_value;
}
} else {
return default_value;
}
}
(function ($) {
$.querywidget.updateSearch = function (stay_on_page) {
var context_url = (function() {
var baseUrl, pieces;
@ -445,9 +466,7 @@ function select_metatype(elem)
/* install callbacks */
$('.metatypes input').change(function() {
var state = history.state || {};
state.metatype = $(this).attr("value");
history.replaceState(state, document.title);
store_history_parameter('metatype', $(this).attr("value"));
select_metatype($(this));
update_portaltypes();
return false;