PageSourceSearch

https://omnicommedia.com/wp-content/plugins/salient-core/js/nectar-testimonial-slider.js?ver=2.1.1

js omnicommedia.com collected 2026-10-03 21:51:08 UTC 16,233 bytes, 444 lines download raw bytes

1/**
2 * Salient "Testimonial Slider" script file.
3 *
4 * @package Salient
5 * @author ThemeNectar
6 */
7
8(function( $ ) {
9	
10	"use strict";
11
12  function NectarTestimonialSlider(el,type,resizeVideoToCover,fullWidthContentColumns) {
13		
14    this.el = el;
15    this.type = type;
16		this.resizeVideoToCover = resizeVideoToCover;
17		this.fullWidthContentColumns = fullWidthContentColumns;
18    this.flickityEl = null;
19    
20    this.createTestimonialControls();
21  }
22
23
24  // create controls
25  NectarTestimonialSlider.prototype.createTestimonialControls = function() {
26    
27    var $frontEndEditorTestimonialDiv =  ($('body.vc_editor').length > 0) ? '> div': 'blockquote';
28    var $that, slide_interval, objectStore;
29    
30    if( this.type != 'multiple_visible' && this.type != 'multiple_visible_minimal' ) {
31      
32      // fadeIn
33      this.el.animate({'opacity':'1'},800);
34      
35
36      if(this.el.find('blockquote').length > 1) {
37        this.el.find('.controls, .testimonial-next-prev').remove();
38        this.el.append('<div class="controls"><ul></ul></div>');
39        
40        var slideNum = this.el.find('blockquote').length;
41        $that = this.el;
42        
43        for(var i=0;i<slideNum;i++) {
44          
45          if( !this.el.is('[data-style="minimal"]') ) {
46            $that.find('.controls ul').append('<li><span class="pagination-switch"></span></li>');
47          } else {
48            $that.find('.controls ul').append('<li>'+(i+1)+'</li>');
49          }
50        }
51        
52        // minimal
53        if( this.el.is('[data-style="minimal"]') ) {
54          
55          // add next/prev
56          this.el.append('<div class="testimonial-next-prev"><a href="#" class="prev fa fa-angle-left"></a><a href="#" class="next fa fa-angle-right"></a></div>');
57          
58          // bind controls
59          this.el.find('.testimonial-next-prev a').on('click',this.minimalNextPrevSelect);
60          
61          // start on first
62          if(this.el.find('.active').length == 0) {
63            this.el.find('.slides '+$frontEndEditorTestimonialDiv +':first-child').addClass('active').css({'opacity':'1', 'transform': 'translateX(0px)'}).css('z-index','20');
64            if(	!this.el.hasClass('disable-height-animation') ) {
65              this.el.find('.slides').css({'height' : this.el.find('.slides '+$frontEndEditorTestimonialDiv +':first-child').height() + 40 + 'px' });
66            }
67          }
68          
69          // autorotate
70          if(this.el.attr('data-autorotate').length > 0) {
71            $that = this.el;
72            slide_interval = (parseInt(this.el.attr('data-autorotate')) < 100) ? 4000 : parseInt(this.el.attr('data-autorotate'));
73            objectStore = this;
74            var $rotate = setInterval(function(){ objectStore.testimonialRotate($that); },slide_interval);
75          }
76          this.el.find('.testimonial-next-prev a').on('click',function(e){
77            if(typeof e.clientX != 'undefined') {
78							clearInterval($rotate);
79						}
80          });
81          
82          // wrap bullets
83          this.el.find('.controls ul').wrap('<div class="control-wrap" />');
84          this.el.find('.controls ul').css('width', ((this.el.find('.controls ul li').length * 20) +1) + 'px');
85          this.el.find('.controls').append('<span class="out-of">/</span><span class="total">'+ this.el.find('blockquote').length+'</span>');
86          
87          //// swipe for testimonials
88          this.el.swipe({
89            
90            swipeLeft : function(e) {
91              $that.find('.testimonial-next-prev .next').trigger('click');
92              e.stopImmediatePropagation();
93              clearInterval($rotate);
94              return false;
95            },
96            swipeRight : function(e) {
97              $that.find('.testimonial-next-prev .prev').trigger('click');
98              e.stopImmediatePropagation();
99              clearInterval($rotate);
100              return false;
101            }    
102          });
103          
104          
105        }
106        
107        // non minimal
108        if( !this.el.is('[data-style="minimal"]') ) {
109          
110          // bind controls
111          this.el.find('.controls ul li').on('click',this.defaultPaginationSelect);
112          
113          // activate first slide
114          this.el.find('.controls ul li').first().trigger('click');
115          
116          // autorotate
117          if(this.el.attr('data-autorotate').length > 0) {
118            slide_interval = (parseInt(this.el.attr('data-autorotate')) < 100) ? 4000 : parseInt(this.el.attr('data-autorotate'));
119            $that = this.el;
120            objectStore = this;
121            var $rotate = setInterval(function(){ objectStore.testimonialRotate($that); },slide_interval);
122          }
123          
124          this.el.find('.controls li').on('click',function(e){
125            if(typeof e.clientX != 'undefined') clearInterval($rotate);
126          });
127          
128          //// swipe for testimonials
129          this.el.swipe({
130            
131            swipeLeft : function(e) {
132              $that.find('.controls ul li span.active').parent().next('li').find('span').trigger('click');
133              e.stopImmediatePropagation();
134              clearInterval($rotate);
135              return false;
136            },
137            swipeRight : function(e) {
138              $that.find('.controls ul li span.active').parent().prev('li').find('span').trigger('click');
139              e.stopImmediatePropagation();
140              clearInterval($rotate);
141              return false;
142            }    
143          });
144          
145        }
146      } 
147      
148      // only one testimonial
149      else if(this.el.find('.controls').length == 0) {
150        
151        var currentHeight = this.el.find('.slides blockquote').height();
152        
153        this.el.find('.slides blockquote')
154          .css({'opacity':'0', 'transform': 'translateX(-25px)', 'z-index': '1'});
155          
156        this.el.find('.slides blockquote')
157          .css({'opacity':'1', 'transform': 'translateX(0px)'})
158          .css('z-index','20');
159          
160        this.el.find('.slides')
161          .stop(true,true)
162          .animate({'height' : currentHeight + 20 + 'px' },450,'easeOutCubic');
163      }
164      
165      
166    } //non multiple vis
167    
168    
169    
170    if( this.type == 'multiple_visible' || this.type == 'multiple_visible_minimal' ) {
171      
172      objectStore = this;
173      $that = this.el; 
174      var $element = $that;
175      var $autoplay = ($that.attr('data-autorotate').length > 1 && parseInt($that.attr('data-autorotate')) > 100) ? parseInt($that.attr('data-autorotate')) : false;
176      if($that.find('img').length == 0) { $element = $('body'); }
177      
178      // move img pos
179      if( this.el.attr('data-style') != 'multiple_visible_minimal') {
180        this.el.find('blockquote').each(function(){
181          $(this).find('.image-icon').insertAfter($(this).find('p'));
182        });
183      } else {
184        // has alf class
185        if(this.el.find('blockquote').length > 4) {
186          this.el.addClass('has-alf');
187        }
188      }
189      
190      var $testimonialGroupCells = (this.el.attr('data-style') == 'multiple_visible_minimal') ? true : false;
191      var $frontEndEditorDrag =  ($('body.vc_editor').length > 0) ? false: true;
192      var $frontEndEditorPause =  ($('body.vc_editor').length > 0) ? true: false;
193      
194      this.flickityEl = $that.find('.slides').flickity({
195        contain: true,
196        draggable: $frontEndEditorDrag,
197        groupCells: $testimonialGroupCells,
198        lazyLoad: false,
199        imagesLoaded: true,
200        percentPosition: true,
201        prevNextButtons: false,
202        pageDots: true,
203        resize: true,
204        setGallerySize: true,
205        wrapAround: true,
206        autoPlay: $autoplay,
207        pauseAutoPlayOnHover: $frontEndEditorPause,
208        accessibility: false
209      });
210      
211      if(this.flickityEl.find('.vc_element.is-selected > blockquote').length > 0) {
212        
213        // starting
214        this.flickityEl.find('.vc_element.is-selected > blockquote').addClass('is-selected');
215        
216        // changed
217        this.flickityEl.on( 'select.flickity', function() {
218          objectStore.flickityEl.find('.vc_element > blockquote').removeClass('is-selected');
219          objectStore.flickityEl.find('.vc_element.is-selected > blockquote').addClass('is-selected');
220        });
221      }
222      
223      
224      $that.css('opacity','1');
225      
226      
227    }
228		
229		var testimonialObj = this;
230		$('body').on('click', '.testimonial_slider:not([data-style*="multiple_visible"]):not([data-style="minimal"]) .controls li, .testimonial_slider[data-style="minimal"] .testimonial-next-prev a', function () {
231			testimonialObj.resizeVideoToCover();
232			return false;
233		});
234    
235    
236  };
237
238
239  NectarTestimonialSlider.prototype.defaultPaginationSelect = function(clicked) {
240    
241    var $target = $(clicked.currentTarget);
242    
243    if($target.find('span').hasClass('active')) { 
244      return false; 
245    }
246    
247    var $frontEndEditorTestimonialDiv = ($('body.vc_editor').length > 0) ? '> div': 'blockquote';
248    var $index = $target.index();
249    var currentHeight = $target.parents('.testimonial_slider').find('.slides blockquote').eq($index).height();
250    
251    $target.parents('.testimonial_slider').find('li span').removeClass('active');
252    $target.find('span').addClass('active');
253    
254    $target.parents('.testimonial_slider').find('.slides '+$frontEndEditorTestimonialDiv).addClass('no-trans');
255    $target.parents('.testimonial_slider').find('.slides '+$frontEndEditorTestimonialDiv).css({'opacity':'0', 'transform': 'translateX(-25px)', 'z-index': '1'});
256    
257    $target.parents('.testimonial_slider').find('.slides '+$frontEndEditorTestimonialDiv)
258      .eq($index)
259      .removeClass('no-trans')
260      .css({'opacity':'1', 'transform': 'translateX(0px)'})
261      .css('z-index','20');
262      
263    $target.parents('.testimonial_slider:not(.disable-height-animation)').find('.slides')
264      .stop(true,true)
265      .animate({'height' : currentHeight + 40 + 'px' },450,'easeOutCubic');
266    
267  };
268
269  NectarTestimonialSlider.prototype.minimalNextPrevSelect = function(clicked) {
270    
271    var $target = $(clicked.currentTarget);
272    
273    var $frontEndEditorTestimonialDiv =  ($('body.vc_editor').length > 0) ? '> div': 'blockquote';
274    var $index = $target.parents('.testimonial_slider').find('.slides '+$frontEndEditorTestimonialDiv+'.active').index();
275    var $actualIndex = $index;
276    var currentHeight;
277    
278    $target.parents('.testimonial_slider').find('.slides '+$frontEndEditorTestimonialDiv).addClass('no-trans');
279    $target.parents('.testimonial_slider').find('.slides '+$frontEndEditorTestimonialDiv).css({'opacity':'0', 'transform': 'translateX(-25px)', 'z-index': '1'});
280    
281    
282    $target.parents('.testimonial_slider').find('.slides '+$frontEndEditorTestimonialDiv).eq($index).removeClass('active');
283    
284    if($target.hasClass('next')) {
285      if($index+1 >= $target.parents('.testimonial_slider').find('.slides '+$frontEndEditorTestimonialDiv).length) { 
286        $actualIndex = 0; 
287      } else {
288        $actualIndex = $index+1; 
289      }
290      currentHeight = $target.parents('.testimonial_slider').find('.slides '+$frontEndEditorTestimonialDiv).eq($actualIndex).height();
291      
292      // show slide
293      $target.parents('.testimonial_slider').find('.slides '+$frontEndEditorTestimonialDiv).eq($actualIndex)
294        .addClass('active')
295        .removeClass('no-trans')
296        .css({'opacity':'1', 'transform': 'translateX(0px)'})
297        .css('z-index','20');
298      
299      // change pag #
300      $target.parents('.testimonial_slider').find('.control-wrap ul').css({'transform':'translateX(-'+(20*$actualIndex)+'px)'});
301      
302    } else {
303      if($index-1 == -1) { 
304        $actualIndex = $target.parents('.testimonial_slider').find('.slides '+$frontEndEditorTestimonialDiv).length-1; 
305      } else {
306        $actualIndex = $index-1; 
307      }
308      currentHeight = $target.parents('.testimonial_slider').find('.slides '+$frontEndEditorTestimonialDiv).eq($index-1).height();
309      
310      // show slide
311      $target.parents('.testimonial_slider').find('.slides '+$frontEndEditorTestimonialDiv)
312        .eq($index-1)
313        .addClass('active')
314        .removeClass('no-trans')
315        .css({'opacity':'1', 'transform': 'translateX(0px)'})
316        .css('z-index','20');
317        
318      // change pag #
319      $target.parents('.testimonial_slider')
320        .find('.control-wrap ul')
321        .css({'transform':'translateX(-'+(20*$actualIndex)+'px)'});
322        
323    }
324    
325    
326    $target.parents('.testimonial_slider:not(.disable-height-animation)')
327      .find('.slides')
328      .stop(true,true)
329      .animate({'height' : currentHeight + 40 + 'px' },450,'easeOutCubic');
330			
331		return false;
332    
333  };
334
335
336  NectarTestimonialSlider.prototype.testimonialRotate = function(){
337    
338    var $testimonialLength = this.el.find('li').length;
339    var $currentTestimonial = this.el.find('.pagination-switch.active').parent().index();
340    
341    // stop the rotation when toggles are closed
342    if( this.el.parents('.toggle').length > 0 && this.el.parents('.toggle').hasClass('open') ) {
343      
344      if( !this.el.is('[data-style="minimal"]') ) {
345        if( $currentTestimonial+1 == $testimonialLength) {
346          this.el.find('ul li:first-child').trigger('click');
347        } else {
348          this.el.find('.pagination-switch.active').parent().next('li').trigger('click');
349        }
350      } else {
351        this.el.find('.testimonial-next-prev .next').trigger('click');
352      }
353      
354    } else {
355      
356      if( !this.el.is('[data-style="minimal"]') ) {
357        if( $currentTestimonial+1 == $testimonialLength) {
358          this.el.find('ul li:first-child').trigger('click');
359        } else {
360          this.el.find('.pagination-switch.active').parent().next('li').trigger('click');
361        }
362      } else {
363        this.el.find('.testimonial-next-prev .next').trigger('click');
364      }
365      
366    }
367    
368  };
369
370
371  NectarTestimonialSlider.prototype.testimonialHeightResize = function() {
372    
373    if(!this.el.is('.disable-height-animation') && !this.el.is('[data-style*="multiple_visible"]') ) {
374      
375      var $frontEndEditorTestimonialDiv = ($('body.vc_editor').length > 0) ? '.slides > div': '.slides blockquote';
376      var $index;
377      
378      if( this.el.is('[data-style="minimal"]') ) {
379        $index = this.el.find($frontEndEditorTestimonialDiv + '.active').index();
380      } else {
381        $index = this.el.find('.controls ul li span.active').parent().index();
382      }
383      
384      var currentHeight = this.el.find($frontEndEditorTestimonialDiv).eq($index).height();
385      this.el.find('.slides').stop(true,true).css({'height' : currentHeight + 40 + 'px' });
386      
387    }
388    
389  };
390
391
392  NectarTestimonialSlider.prototype.testimonialSliderHeight = function() {
393    
394    if( this.el.is('.disable-height-animation') && !this.el.is('[data-style*="multiple_visible"]') ) {
395      
396      var $tallestQuote = 0;
397      
398      this.el.find('blockquote').each(function(){
399        ($(this).height() > $tallestQuote) ? $tallestQuote = $(this).height() : $tallestQuote = $tallestQuote;
400      });	
401      
402      // safety net incase height couldn't be determined
403      if($tallestQuote == 0) {
404				$tallestQuote = 100;
405			}
406      
407      // set even height
408      this.el.find('.slides').css('height',$tallestQuote+40+'px');
409      
410      // show the slider once height is set
411      this.el.animate({'opacity':'1'});
412      
413      this.fullWidthContentColumns();
414      
415    }	
416    
417  };
418
419  NectarTestimonialSlider.prototype.testimonialSliderHeightMinimalMult = function() {
420    
421    if( this.type == 'multiple_visible_minimal') {
422      
423      var $tallestQuote = 0;
424      
425      this.el.find('blockquote > .inner p').css('height','auto');
426      
427      this.el.find('blockquote > .inner p').each(function(){
428        ($(this).height() > $tallestQuote) ? $tallestQuote = $(this).height() : $tallestQuote = $tallestQuote;
429      });	
430      
431      // safety net incase height couldn't be determined
432      if($tallestQuote == 0) { $tallestQuote = 200; }
433      
434      // set even height
435      this.el.find('blockquote > .inner p').css('height',$tallestQuote+'px');
436      
437    }
438    
439    
440  };
441  
442  window.NectarTestimonialSlider = NectarTestimonialSlider;
443
444}( jQuery ));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.