Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/helpers/search_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def link_to_tab(target, label = nil)
clean_target = target.downcase.gsub(' ', '_').downcase
tab_label = label || target
if @active_tab == clean_target
link_to tab_label, results_path(params.permit(:q, :per_page, :booleanType, :tab).merge(tab: clean_target)),
link_to tab_label, results_path(params.permit(:q, :per_page, :booleanType, :tab, :mtmPreviewMode).merge(tab: clean_target)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [130/120] [rubocop:Layout/LineLength]

aria: { current: 'page' },
class: 'active tab-link',
data: { turbo_frame: 'search-results', turbo_action: 'advance' }
else
link_to tab_label, results_path(params.permit(:q, :per_page, :booleanType, :tab).merge(tab: clean_target)),
link_to tab_label, results_path(params.permit(:q, :per_page, :booleanType, :tab, :mtmPreviewMode).merge(tab: clean_target)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [130/120] [rubocop:Layout/LineLength]

class: 'tab-link',
data: { turbo_frame: 'search-results', turbo_action: 'advance' }
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method has too many lines. [12/10] [rubocop:Metrics/MethodLength]

Expand Down
6 changes: 6 additions & 0 deletions app/javascript/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ function initFilterToggle() {
var filter_toggle = document.getElementById('filter-toggle');
var filter_panel = document.getElementById('filter-container');
var filter_categories = document.getElementsByClassName('filter-category');

// No need for event listeners if filters aren't present.
if (!filter_toggle || !filter_panel) {
return;
}

filter_toggle.addEventListener('click', event => {
filter_panel.classList.toggle('hidden-md');
filter_toggle.classList.toggle('expanded');
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/search_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ if (Array.from(allPanels).includes(geoboxPanel && geodistancePanel)) {
togglePanelState(geodistancePanel);
});

document.getElementById('advanced-summary').addEventListener('click', () => {
document.getElementById('advanced-summary')?.addEventListener('click', () => {
togglePanelState(advancedPanel);
});
} else {
document.getElementById('advanced-summary').addEventListener('click', () => {
document.getElementById('advanced-summary')?.addEventListener('click', () => {
togglePanelState(advancedPanel);
});
}
Expand Down
11 changes: 9 additions & 2 deletions app/views/layouts/_head.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,22 @@

<%= yield :additional_js %>

<% if (ENV['MATOMO_CONTAINER_URL'].present?) %>
<% if (ENV['MATOMO_URL'].present? && ENV['MATOMO_CONTAINER_ID'].present?) %>
<!-- Matomo Tag Manager -->
<script type="text/javascript">
var _mtm = window._mtm = window._mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
(function() {
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='<%= ENV['MATOMO_CONTAINER_URL'] %>'; s.parentNode.insertBefore(g,s);
g.async=true; g.src='<%= ENV['MATOMO_URL'] %>js/container_<%= ENV['MATOMO_CONTAINER_ID'] %>.js'; s.parentNode.insertBefore(g,s);
})();
if ((document.cookie.indexOf('mtmPreview13_<%= ENV['MATOMO_CONTAINER_ID'] %>%3D1') !== -1 && window.location.href.indexOf('&mtmPreviewMode=0') === -1 && window.location.href.indexOf('?mtmPreviewMode=0') === -1) || window.location.href.indexOf('&mtmPreviewMode=<%= ENV['MATOMO_CONTAINER_ID'] %>') !== -1 || window.location.href.indexOf('?mtmPreviewMode=<%= ENV['MATOMO_CONTAINER_ID'] %>') !== -1) {
console.log('Loading preview container');
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=false; g.defer=false; g.src='<%= ENV['MATOMO_URL'] %>js/container_<%= ENV['MATOMO_CONTAINER_ID'] %>_preview.js'; s.parentNode.insertBefore(g,s);
} else {
console.log('Skipping preview container');
}
</script>
<!-- End Matomo Tag Manager -->
<% elsif (ENV['MATOMO_URL'].present? && ENV['MATOMO_SITE_ID'].present?) %>
Expand Down