Skip to content

Commit

Permalink
Merge pull request #297 from gtt-project/dkastl/issue296
Browse files Browse the repository at this point in the history
Supports activeTab access for plugin settings
  • Loading branch information
dkastl authored Jun 2, 2024
2 parents 368c0e0 + f4cea75 commit 9fc8707
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion app/views/settings/gtt/_settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,33 @@
{ :name => :geocoder, :partial => 'settings/gtt/geocoder', :label => :gtt_settings_label_geocoder }
] %>
<%= render_tabs plugin_tabs %>
<%= javascript_tag do %>
// Read query parameter
function getQueryParam(param) {
var urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param);
}

// Activate tab by name
function activateTab(tabName) {
var tabLinks = document.querySelectorAll('.tabs a');
tabLinks.forEach(function(link) {
if (link.href.includes('tab=' + tabName)) {
link.click();
}
});
}

// Activate tab if it is specified in the URL
document.addEventListener('DOMContentLoaded', function() {
var tab = getQueryParam('tab');
if (tab) {
activateTab(tab);
}
});

// Apply settings
window.gtt_setting()
<% end %>

0 comments on commit 9fc8707

Please sign in to comment.