From: Radek Czajka Date: Mon, 19 Apr 2021 11:19:00 +0000 (+0200) Subject: Fixes #4191: backward search. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/ab3c4f696564e0f8cad64ff3f3123d4f6fac4361?ds=sidebyside;hp=88e7597e91bb03364d7846b160ff0b38b97c1be6 Fixes #4191: backward search. --- diff --git a/src/redakcja/static/js/wiki/view_search.js b/src/redakcja/static/js/wiki/view_search.js index e8f9e1b4..09f64dab 100644 --- a/src/redakcja/static/js/wiki/view_search.js +++ b/src/redakcja/static/js/wiki/view_search.js @@ -16,6 +16,7 @@ this.$searchInput = $('#search-input', this.$element); this.$replaceInput = $('#replace-input', this.$element); this.$searchButton = $('#search-button', this.$element); + this.$searchPrevButton = $('#search-prev-button', this.$element); this.$replaceButton = $('#replace-button', this.$element); this.$replaceButton.attr("disabled","disabled"); @@ -41,6 +42,11 @@ alert('Brak wyników.'); }); + this.$searchPrevButton.click(function(){ + if (!self.search(false)) + alert('Brak wyników.'); + }); + this.$replaceButton.click(function(){ self.replace(); }); @@ -53,7 +59,7 @@ SearchPerspective.prototype = new $.wiki.SidebarPerspective(); - SearchPerspective.prototype.search = function(){ + SearchPerspective.prototype.search = function(forward=true){ var self = this; var query = self.$searchInput.val(); @@ -73,7 +79,7 @@ options ); } - if (self.searchCursor.findNext()) { + if (forward ? self.searchCursor.findNext() : self.searchCursor.findPrevious()) { self.editor.setSelection(self.searchCursor.from(), self.searchCursor.to()); self.editor.scrollIntoView({from: self.searchCursor.from(), to: self.searchCursor.to()}, 20); self.$replaceButton.removeAttr("disabled"); diff --git a/src/wiki/templates/wiki/tabs/search_view.html b/src/wiki/templates/wiki/tabs/search_view.html index e54b8799..23067b55 100644 --- a/src/wiki/templates/wiki/tabs/search_view.html +++ b/src/wiki/templates/wiki/tabs/search_view.html @@ -6,6 +6,7 @@
+