Created
May 15, 2017 07:47
-
-
Save nakamuraagatha/d4b1642f88afd9fe60f193d46734831f to your computer and use it in GitHub Desktop.
wp expand collapse
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
function bgExpandCollapsedContent() { | |
var bgCollapseExpandItems = document.querySelectorAll('input[bg_collapse_expand]'); | |
for ( i=0; i<bgCollapseExpandItems.length; i++) { | |
var showHideButton = document.getElementById('bg-showmore-action-'+bgCollapseExpandItems[i].value); | |
var hiddenContent = document.getElementById('bg-showmore-hidden-'+bgCollapseExpandItems[i].value); | |
if (showHideButton && hiddenContent) { | |
showHideButton.addEventListener('click', function(event) {bgExpandCollapsedContentAction(event, this);} ); | |
} | |
} | |
} | |
function bgExpandCollapsedContentAction(event, thisObj) { | |
event.preventDefault(); | |
var bgUniqId = thisObj.id.replace('bg-showmore-action-', ''); | |
var showHideButton = document.getElementById('bg-showmore-action-'+bgUniqId); | |
var hiddenContent = document.getElementById('bg-showmore-hidden-'+bgUniqId); | |
var showLessText = document.getElementById('bg-show-less-text-'+bgUniqId).value; | |
var showMoreText = document.getElementById('bg-show-more-text-'+bgUniqId).value; | |
var text = jQuery(showHideButton).text(); | |
jQuery( hiddenContent ).toggle(); | |
if (showLessText === '') { | |
jQuery( showHideButton ).toggle(); | |
if (jQuery( showHideButton ).parent().prop("tagName") === 'LI') { | |
jQuery( showHideButton ).parent().toggle(); | |
} | |
} | |
else { | |
jQuery(showHideButton).text( | |
text == showMoreText ? showLessText : showMoreText | |
); | |
jQuery(showHideButton).toggleClass("close"); | |
} | |
if ('undefined' !== typeof gmspAllMaps) { | |
gmspResizeMaps(); | |
} | |
} | |
jQuery(document).ready(function() { | |
bgExpandCollapsedContent(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment