| Server IP : 52.25.153.185 / Your IP : 216.73.217.131 Web Server : Apache System : Linux ip-172-26-6-158 5.10.0-35-cloud-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64 User : daemon ( 1) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /bitnami/wordpress/wp-content/plugins/testify/js/src/ |
Upload File : |
;(function ( $, window, document ) {
'use strict';
var globalText = '';
$.fn.testifyReadmore = function() {
this.each(function() {
var pThis = $(this)
, limit = pThis.data('readmore-limit')
, $body = pThis.find('.testimonial-body');
if ( $body.text().length <= limit ) {
pThis.removeClass('testify-body-hide');
return;
}
var bodyOriginal = $body.html()
, bodyTruncated = pThis.testifyTruncate( pThis.find('.testimonial-body'), limit ).text;
bodyTruncated = pThis.testifyPreventCutWords( bodyTruncated );
pThis.find('.testimonial-body').empty();
pThis.find('.testimonial-body').prepend( '<div class="testify-body-full">' + bodyOriginal + '</div>' );
pThis.find('.testimonial-body').prepend( '<div class="testify-body-truncated testify-body-show">' + bodyTruncated + '</div>' );
setTimeout(function() {
applyReadmore( pThis );
}, 250);
});
};
function applyReadmore( obj ) {
var id = obj.attr('id')
, morelink = obj.data('readmore-morelink')
, lesslink = obj.data('readmore-lesslink')
, font = obj.data('readmore-font')
, fontSize = obj.data('readmore-font-size')
, color = obj.data('readmore-color')
, letterSpacing = obj.data('readmore-letter-spacing')
, useIcon = obj.data('readmore-use-icon')
, readmoreIcon = obj.data('readmore-icon')
, readmoreIconColor = obj.data('readmore-icon-color')
, readmoreIconPlacement = obj.data('readmore-icon-placement')
, readlessIcon = obj.data('readmore-less-icon')
, readlessIconColor = obj.data('readmore-less-icon-color')
, readlessIconPlacement = obj.data('readmore-less-icon-placement')
, limit = obj.data('readmore-limit')
, blockCSS = '<style id="' + id + '-readmore-style">';
useIcon = 'off' === useIcon ? false : true;
if (font) {
blockCSS += '#' + id + ' .testify-link { ' +
font +
fontSize +
color +
letterSpacing +
' } ';
}
if ( useIcon ) {
blockCSS += '#' + id + ' .testify-link-readmore' + readmoreIconPlacement + ' { ' +
readmoreIcon +
readmoreIconColor +
' }';
blockCSS += '#' + id + ' .testify-link-readless' + readlessIconPlacement + ' { ' +
readlessIcon +
readlessIconColor +
' }';
}
blockCSS += '</style>';
$('#' + id + '-readmore-style').remove();
if (font || useIcon) {
$( blockCSS ).appendTo( "head" );
}
obj.removeClass('testify-body-hide');
obj.find('.testify-body-full').readmore({
speed: 100,
collapsedHeight: 1,
selector: ".testify-body-full",
moreLink: '<a href="#" class="testify-link testify-link-readmore"><span class="testify-link-readmore-text">' + morelink + '</span> </a>',
lessLink: '<a href="#" class="testify-link testify-link-readless"><span class="testify-link-readless-text">' + lesslink + '</span> </a>',
beforeToggle: function( trigger, elem, expanded ) {
if ( ! expanded ) {
elem.toggleClass('testify-body-hidden testify-body-show');
}
elem.parent().find('.testify-body-truncated').toggleClass('testify-body-hide testify-body-show');
},
afterToggle: function( trigger, elem, expanded ) {
if ( ! expanded ) {
elem.toggleClass('testify-body-hidden testify-body-show');
}
}
});
obj.find('.testify-body-full').addClass('testify-body-hidden');
}
$.fn.testifyTruncate = function( $text, reqCount ) {
var grabText = '',
readyString = '',
missCount = reqCount,
bodyContent = $text.contents(),
preventCutWords = 0;
bodyContent.each( function( index ) {
switch ( this.nodeType ) {
case Node.TEXT_NODE:
var str = this.data;
var readyString = $.trim( str.substr(0, missCount) );
grabText += readyString;
// Don't count spaces
str = str.replace(/\s+/g, '');
if ( str !== '' ) {
missCount -= Math.min(this.data.length, missCount);
}
break;
case Node.ELEMENT_NODE:
// Explore current child:
var $child = $(this);
var childPart = $child.testifyTruncate($child, missCount);
grabText += childPart.text;
missCount -= childPart.count;
break;
}
if ( missCount === 0 ) {
// We got text enough, stop looping.
return false;
}
});
return {
text:
// Wrap text using current elem tag.
$text[0].outerHTML.match(/^<[^>]+>/m)[0] + grabText + '</' + $text[0].localName + '>',
count: reqCount - missCount
};
};
$.fn.testifyPreventCutWords = function( elem ) {
var bodyContent = $( elem ).contents()
, contentLength = bodyContent.length
, preventCutWords = 0
, elemContent
, elemContentHtml
, bodyParsed = ''
, cuttedWordsRemoved;
bodyContent.each( function( index ) {
elemContent = $(this);
if ( elemContent.is(':last-child') ) {
elemContentHtml = elemContent.html();
preventCutWords = Math.min( elemContentHtml.length, elemContentHtml.lastIndexOf(" ") );
if ( preventCutWords > 1 ) {
cuttedWordsRemoved = elemContentHtml.substr( 0, preventCutWords );
elemContent.html( cuttedWordsRemoved );
}
elemContent.append( '…' );
}
bodyParsed += elemContent[0].textContent;
});
return bodyParsed;
};
/*$(window).load(function() {
if ( $('.testify-readmore').length ) {
$(this).testifyReadmore();
};
});*/
})(jQuery, window, document);