0 Votes

Changes for page Solr Search

Last modified by Сергей Коршунов on 2025/01/12 00:53

From version 1.1
edited by admins admins
on 2021/12/11 17:12
Change comment: Install extension [org.xwiki.platform:xwiki-platform-search-solr-ui/13.10]
To version 2.1
edited by Сергей Коршунов
on 2022/03/08 17:00
Change comment: Install extension [org.xwiki.platform:xwiki-platform-search-solr-ui/14.1]

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.admins
1 +XWiki.skorshunov
XWiki.JavaScriptExtension[0]
Code
... ... @@ -26,8 +26,8 @@
26 26   };
27 27  
28 28   var updateExpandCollapseAllFacetsState = function(facetsContainer) {
29 - var facetCount = facetsContainer.find('.search-facet').size();
30 - var expandedFacetCount = facetsContainer.find('.search-facet.expanded').size();
29 + var facetCount = facetsContainer.find('.search-facet').length;
30 + var expandedFacetCount = facetsContainer.find('.search-facet.expanded').length;
31 31   if (expandedFacetCount > facetCount / 2) {
32 32   facetsContainer.find('.search-facets-action-collapseAll').show()
33 33   .parent().children('.search-facets-action-expandAll').hide();
... ... @@ -42,7 +42,7 @@
42 42   checkBox.prop('checked', $(this).hasClass('selected'));
43 43   // Add the 'checked' attribute so that it can be easily located with CSS.
44 44   checkBox.prop('checked') && checkBox.attr('checked', 'checked');
45 - checkBox.click($.proxy(this, 'click'));
45 + checkBox.on('click', this.click.bind(this));
46 46   // Remove the 'selected' class because the selected state is marked using the check box.
47 47   $(this).removeClass('selected').before(checkBox);
48 48   };
... ... @@ -51,17 +51,17 @@
51 51   var facetsContainer = $(this);
52 52  
53 53   // Add the ability to collapse the facets pane on extra small screens (phones).
54 - facetsContainer.find('.search-facets-header').click(function() {
54 + facetsContainer.find('.search-facets-header').on('click', function() {
55 55   facetsContainer.toggleClass('collapsed-xs');
56 56   });
57 57  
58 58   // Global Expand/Collapse toggle.
59 - facetsContainer.find('.search-facets-action-collapseAll').removeClass('hidden').click(collapseAllFacets);
60 - facetsContainer.find('.search-facets-action-expandAll').removeClass('hidden').click(expandAllFacets);
59 + facetsContainer.find('.search-facets-action-collapseAll').removeClass('hidden').on('click', collapseAllFacets);
60 + facetsContainer.find('.search-facets-action-expandAll').removeClass('hidden').on('click', expandAllFacets);
61 61   updateExpandCollapseAllFacetsState(facetsContainer);
62 62  
63 63   // Expand/Collapse toggle for each facet.
64 - facetsContainer.find('.search-facet-header').click(function(event) {
64 + facetsContainer.find('.search-facet-header').on('click', function(event) {
65 65   $(event.target).parent('.search-facet').toggleClass('expanded');
66 66   updateExpandCollapseAllFacetsState(facetsContainer);
67 67   });
... ... @@ -110,7 +110,8 @@
110 110   searchRequest && searchRequest.abort();
111 111   $('.search-ui').attr('aria-busy', true);
112 112   var getURL = XWiki.currentDocument.getURL('get', getQueryString(viewURL));
113 - searchRequest = $.get(getURL).done(function(html) {
113 + searchRequest = $.get(getURL);
114 + searchRequest.then(html => {
114 114   var state = getSearchUIState();
115 115   updateSearchUI(html);
116 116   setSearchUIState(state);
... ... @@ -123,7 +123,7 @@
123 123   var reloadSearchUI = function(event) {
124 124   event.preventDefault();
125 125   var anchor = $(event.target).closest('a');
126 - anchor.size() > 0 && $(document).trigger('xwiki:search:update', anchor.attr('href'));
127 + anchor.length && $(document).trigger('xwiki:search:update', anchor.attr('href'));
127 127   };
128 128  
129 129   // Others (e.g. a custom facet) can trigger a search UI update by firing this event.
... ... @@ -137,7 +137,8 @@
137 137   $('.search-ui').attr('aria-busy', true);
138 138   var state = event.originalEvent.state;
139 139   var getURL = XWiki.currentDocument.getURL('get', window.location.search.substr(1));
140 - searchRequest = $.get(getURL).done(function(html) {
141 + searchRequest = $.get(getURL);
142 + searchRequest.then(html => {
141 141   updateSearchUI(html);
142 142   setSearchUIState(state);
143 143   });
... ... @@ -178,7 +178,7 @@
178 178   '.search-facet a.itemName',
179 179   '.search-facet-body a.more',
180 180   '.search-facet-body .selectedLocation a'
181 - ].join(',')).click(reloadSearchUI);
183 + ].join(',')).on('click', reloadSearchUI);
182 182   };
183 183  
184 184   enhanceSearchUI();