PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / 3.3.2
Strong Testimonials v3.3.2
3.3.2 3.3.1 trunk 1.0.1 2.30.9 2.31.10 2.32 2.32.1 2.32.2 2.32.3 2.32.4 2.33 2.34 2.35 2.36 2.37 2.38 2.38.1 2.39 2.39.1 2.39.2 2.39.3 2.40.0 2.40.1 2.40.2 2.40.3 2.40.4 2.40.5 2.40.6 2.40.7 2.41.0 2.41.1 2.50.0 2.50.1 2.50.2 2.50.3 2.50.4 2.51.0 2.51.1 2.51.2 2.51.3 2.51.4 2.51.5 2.51.6 2.51.7 2.51.8 2.51.9 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.17 3.2.18 3.2.19 3.2.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0
strong-testimonials / assets / public / js / lib / readmore / readmore.js
strong-testimonials / assets / public / js / lib / readmore Last commit date
readmore.js 1 year ago readmore.min.js 1 year ago
readmore.js
137 lines
1 /**
2 * readmore.js
3 *
4 * @param toggleButtonText
5 * @param toggleButtonText.dataset
6 * @param toggleButtonText.dataset.moreText
7 * @param toggleButtonText.dataset.lessText
8 */
9
10 (function () {
11
12 /*
13 * Do stuff at the end of animation.
14 */
15 var onAnimationEnd = function (event) {
16 if (event.type === 'animationend' && event.animationName === 'fadeOutUp') {
17
18 // Add `hidden` attribute
19 event.target.setAttribute('hidden', 'true');
20 event.target.style.display = 'none';
21
22 // Show read-more link
23 event.target.parentElement.parentElement.querySelector('.readmore-toggle').style.display = 'inline';
24
25 // Show ellipsis
26 var ellipsis = event.target.parentElement.querySelector('.ellipsis');
27 if (ellipsis) {
28 ellipsis.style.display = 'inline';
29 }
30
31 fireCustomEvent();
32 }
33 };
34
35 var fireCustomEvent = function () {
36 window.dispatchEvent(new Event('toggleFullContent'));
37 };
38
39 // Only in modern browsers.
40 if ('querySelector' in document && 'addEventListener' in window) {
41
42 // Listen for an animation.
43 document.addEventListener('transitionend', function (event) {
44 if (event.target.matches('.readmore-content')) {
45 onAnimationEnd(event);
46 }
47 }, false);
48
49 document.addEventListener('animationend', function (event) {
50 if (event.target.matches('.readmore-content')) {
51 onAnimationEnd(event);
52 }
53 }, false);
54
55 // Listen to each readmore link.
56 document.addEventListener('click', function (event) {
57
58
59 if (!event.target.matches('.readmore-text')) {
60 return;
61 }
62
63 var toggleButtonText = event.target;
64 var theContainer = jQuery( event.target ).parents( '.wpmtst-testimonial-content' );
65 var toggleButton = toggleButtonText.parentElement;
66 var excerptWrapper = jQuery( theContainer ).find( '.readmore-excerpt' );
67
68 var fullTextWrapper = jQuery( theContainer ).find( '.readmore-content' )[0];
69 var ellipsis = jQuery( theContainer ).find( '.ellipsis' )[0];
70 var allHtml = false;
71
72 if ( excerptWrapper.hasClass( 'all-html' ) ) {
73 allHtml = true;
74 }
75
76 if ( !fullTextWrapper ) {
77 return;
78 }
79
80 // change attributes and text if full text is shown/hidden
81 if (fullTextWrapper.hasAttribute('hidden')) {
82 // show
83 // 1. remove hidden attribute so we can animate it
84 fullTextWrapper.removeAttribute('hidden');
85 fullTextWrapper.style.display = 'inline';
86
87 // 2. update toggle link
88 // change text (may be blank)
89 toggleButtonText.innerText = toggleButtonText.dataset.lessText;
90 toggleButton.setAttribute('aria-expanded', true);
91 if (ellipsis) {
92 ellipsis.style.display = 'none';
93 }
94
95 // 3. animate it
96 fullTextWrapper.classList.add( 'fadeInDown' );
97 fullTextWrapper.classList.remove( 'fadeOutUp' );
98 fullTextWrapper.classList.remove( 'faster' );
99
100 excerptWrapper.hide();
101
102 fireCustomEvent();
103
104 } else {
105 // hide
106 // 1. update toggle link
107
108 fullTextWrapper.style.display = 'none';
109 fullTextWrapper.setAttribute('hidden', true);
110
111 toggleButton.setAttribute( 'aria-expanded', false );
112 // change link text (may be blank)
113 toggleButtonText.innerText = toggleButtonText.dataset.moreText;
114
115 // 2. animate it
116 fullTextWrapper.classList.add( 'fadeOutUp' );
117 fullTextWrapper.classList.add( 'faster' );
118 fullTextWrapper.classList.remove( 'fadeInDown' );
119
120 excerptWrapper.show();
121 // 3. Add back the elipsis if needed.
122 if (ellipsis) {
123 ellipsis.style.display = 'inline';
124 }
125
126 // 4. do stuff at end of animation (the event listener above)
127 fireCustomEvent();
128 }
129
130 }, false);
131
132
133
134 }
135
136 })();
137