mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-25 05:02:57 +01:00
window.history.pushState → replaceState.
No longer floods the history.
This commit is contained in:
parent
bffd5a2c45
commit
5f465276a1
@ -55,6 +55,7 @@ Changelog
|
||||
* Fix: Using RGBA images no longer crashes with Pillow >= 4.2.0 (Karl Hobley)
|
||||
* Fix: Copying a page with PostgreSQL search enabled no longer crashes (Bertrand Bordage)
|
||||
* Fix: Style of the page unlock button was broken (Bertrand Bordage)
|
||||
* Fix: Admin search no longer floods browser history (Bertrand Bordage)
|
||||
|
||||
|
||||
1.13.1 (17.11.2017)
|
||||
|
@ -73,6 +73,7 @@ Bug fixes
|
||||
* Using RGBA images no longer crashes with Pillow >= 4.2.0 (Karl Hobley)
|
||||
* Copying a page with PostgreSQL search enabled no longer crashes (Bertrand Bordage)
|
||||
* Style of the page unlock button was broken (Bertrand Bordage)
|
||||
* Admin search no longer floods browser history (Bertrand Bordage)
|
||||
|
||||
|
||||
Upgrade considerations
|
||||
|
@ -218,25 +218,26 @@ $(function() {
|
||||
if (window.headerSearch) {
|
||||
var searchCurrentIndex = 0;
|
||||
var searchNextIndex = 0;
|
||||
var $input = $(window.headerSearch.termInput);
|
||||
var $inputContainer = $input.parent();
|
||||
|
||||
$(window.headerSearch.termInput).on('keyup cut paste change', function() {
|
||||
clearTimeout($.data(this, 'timer'));
|
||||
var wait = setTimeout(search, 200);
|
||||
$(this).data('timer', wait);
|
||||
$input.on('keyup cut paste change', function() {
|
||||
clearTimeout($input.data('timer'));
|
||||
$input.data('timer', setTimeout(search, 200));
|
||||
});
|
||||
|
||||
// auto focus on search box
|
||||
$(window.headerSearch.termInput).trigger('focus');
|
||||
$input.trigger('focus');
|
||||
|
||||
function search() {
|
||||
var workingClasses = 'icon-spinner';
|
||||
|
||||
var newQuery = $(window.headerSearch.termInput).val();
|
||||
var newQuery = $input.val();
|
||||
var currentQuery = getURLParam('q');
|
||||
// only do the query if it has changed for trimmed queries
|
||||
// eg. " " === "" and "firstword " ==== "firstword"
|
||||
if (currentQuery.trim() !== newQuery.trim()) {
|
||||
$(window.headerSearch.termInput).parent().addClass(workingClasses);
|
||||
$inputContainer.addClass(workingClasses);
|
||||
searchNextIndex++;
|
||||
var index = searchNextIndex;
|
||||
$.ajax({
|
||||
@ -246,17 +247,17 @@ $(function() {
|
||||
if (index > searchCurrentIndex) {
|
||||
searchCurrentIndex = index;
|
||||
$(window.headerSearch.targetOutput).html(data).slideDown(800);
|
||||
window.history.pushState(null, 'Search results', '?q=' + newQuery);
|
||||
window.history.replaceState(null, null, '?q=' + newQuery);
|
||||
}
|
||||
},
|
||||
complete: function() {
|
||||
$(window.headerSearch.termInput).parent().removeClass(workingClasses);
|
||||
$inputContainer.removeClass(workingClasses);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
getURLParam = function(name) {
|
||||
function getURLParam(name) {
|
||||
var results = new RegExp('[\?&]' + name + '=([^]*)').exec(window.location.search);
|
||||
if (results) {
|
||||
return results[1];
|
||||
|
Loading…
Reference in New Issue
Block a user