Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-----------------------------------
- // Function - Expandable Icon Box
- //-----------------------------------
- function expandableIconBox(){
- ?>
- <script>
- jQuery(document).ready(function() {
- // Configuration
- var excerptLength = 140; // Excerpt text length
- var ellipses = "...";
- var moreTxt = "Show more >";
- var lessTxt = "Show less";
- var iconBox = jQuery(".iconbox_content_container");
- jQuery('.iconbox_content_container p').each(function(){
- var shortTxt = jQuery(this).text().substring(0, excerptLength);
- var hiddenTxt = jQuery(this).text().substring(excerptLength);
- var fullText = jQuery(this).text();
- if(fullText.length > excerptLength) {
- jQuery(this).html( shortTxt + '<span class="ellipses">' + ellipses + '</span>' + '<span class="hiddenTxt hideThis">' + hiddenTxt + '</span> </br> <span class="toggleTxt"> ' + moreTxt + '</span> ');
- }
- else {
- jQuery(this).text(shortTxt);
- }
- });
- jQuery('.toggleTxt').on('click', function(){
- jQuery(this).parentsUntil(iconBox).find('.hiddenTxt').toggleClass('hideThis');
- jQuery(this).parentsUntil(iconBox).find('.ellipses').toggleClass("hideThis");
- jQuery(this).text(function(i, text){
- return text === lessTxt ? moreTxt : lessTxt ;
- });
- });
- });
- </script>
- <?php
- }
- add_action('wp_footer', 'expandableIconBox');
Add Comment
Please, Sign In to add comment