Skip to content

Instantly share code, notes, and snippets.

@mreidsma
Last active February 22, 2017 19:10
Show Gist options
  • Save mreidsma/11df2c12cccc66e7574332bf6d3c1c9a to your computer and use it in GitHub Desktop.
Save mreidsma/11df2c12cccc66e7574332bf6d3c1c9a to your computer and use it in GitHub Desktop.
Force single linked parents to take user directly to LibGuide on home page
// Make sure you are on the homepage
if($('#s-lg-index-list').length > 0) {
// Loop through all the subjects
$('#s-lg-index-cols').find('div.panel.panel-default').each(function() {
// Get the number of guides in this subject
var guides = $(this).find('.badge').text();
// console.log('Number of guides: ' + guides);
// If there is only one guide, change the link
if(guides == 1) {
// Get the link to the guide
var newLink = $(this).find('.panel-collapse').find('ul.s-lg-guide-list').find('li').find('a').attr('href');
// Remove the action elements in the heading
$(this).find('.panel-heading').find('a').removeAttr('data-toggle');
// Switch out the href
$(this).find('.panel-heading').find('a').attr('href', newLink);
}
});
}
@phette23
Copy link

phette23 commented Oct 6, 2016

Ha, we suffer from this same problem, borrowing the solution.

@arschlegel
Copy link

Thank you for coding/sharing this! Our librarians have been asking for this functionality for a while now, and I'm so glad to see there's already a solution for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment