Last active
February 22, 2017 19:10
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} | |
}); | |
} |
Ha, we suffer from this same problem, borrowing the solution.
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
You'd think this would be like default behavior! Thanks for this.