PageSourceSearch

https://www.stefan-suender-band.de/wp-content/themes/toranj/assets…jquery.owwwlab-DoubleCarousel.js?ver=1.18.0

js stefan-suender-band.de collected 2026-10-08 09:14:36 UTC 12,742 bytes, 471 lines download raw bytes

1/*!
2 *  Double Carousel Plugin for JQuery
3 *  Version   : 1.2.1
4 *  Date      : 2016-06-23
5 *  Licence   : All rights reserved 
6 *  Author    : owwwlab (Ehsan Dalvand & Alireza Jahandideh)
7 *  Contact   : [email protected]
8 *  Web site  : http://themeforest.net/user/owwwlab
9 *  Dependencies: tweenmx, imagesLoaded
10 */
11
12// Utility
13if ( typeof Object.create !== 'function'  ){ // browser dose not support Object.create
14    Object.create = function (obj){
15        function F(){};
16        F.prototype = obj;
17        return new F();
18    };
19};
20
21(function($, window, document, undefined) {
22    
23    var dcs,inAnimation=false;
24
25    var DoubleCarousel = {
26      init: function( options , elem ){
27          var self = this; //store a reference to this
28
29          self.elem = elem;
30          self.$elem = $(elem);
31          self.options = $.extend( {}, $.fn.DoubleCarousel.options, options);
32
33          dcs=self.options;
34          dcs.allItems=self.$elem.find('.item');
35          
36          dcs.leftItems=dcs.leftSide.find('.item');
37          dcs.rightItems=dcs.rightSide.find('.item');
38
39
40          self.prepare();
41          //self.handleBgColors();
42
43          self.bindUIActions();
44      },
45      prepare : function(){
46
47        var self=this;
48
49        //slides count
50        dcs.slideCount = dcs.leftSide.find('.item').length; 
51        
52        dcs.currentSlideIndex = 0;
53        
54        dcs.counterTotal.html(dcs.slideCount);
55        dcs.counterCurrent.html(1);
56
57        //Show/hide Controllers
58        dcs.nextButton.fadeIn();
59        dcs.prevButton.fadeOut();
60
61
62        dcs.rightDirectionSign=(dcs.rightSideDir=='down')?-1:1;
63        dcs.leftDirectionSign=(dcs.leftSideDir=='down')?-1:1;
64
65        self.update();
66
67        var leftFillMode=dcs.leftSide.attr('data-fill'),
68            rightFillMode=dcs.rightSide.attr('data-fill');
69       
70        if (leftFillMode){
71          self.fillCore(leftFillMode,'left');
72        }
73
74        if (rightFillMode){
75          self.fillCore(rightFillMode,'right');
76        }
77
78        self.triggerInit();
79       
80      },
81      update:function(){
82
83        var self=this;
84
85        dcs.carouselHeight=self.$elem.height();
86
87        var cHeight=dcs.carouselHeight;
88
89        //Arrange slides based on sides direction
90        dcs.rightItems.each(function(){
91          var $this=$(this),
92              index=$this.index();
93
94          TweenMax.to($this,0,{y:dcs.rightDirectionSign*index*cHeight});
95
96        });
97
98         dcs.leftItems.each(function(){
99          var $this=$(this),
100              index=$this.index();
101
102          TweenMax.to($this,0,{y:dcs.leftDirectionSign*index*cHeight});
103
104        });
105
106         (new TimelineLite())
107          .to(dcs.rightWrapper,0,{y:-dcs.rightDirectionSign*dcs.currentSlideIndex*cHeight})
108          .to(dcs.leftWrapper,0,{y:-dcs.leftDirectionSign*dcs.currentSlideIndex*cHeight});  
109
110          dcs.leftSide.removeAttr('style');
111
112          var leftWidth=Math.floor(dcs.leftSide.width());
113          
114          dcs.leftSide.width(leftWidth);
115
116          dcs.rightSide.removeAttr('style');
117          var rightWidth=Math.floor(dcs.rightSide.width())+1;
118
119          dcs.rightSide.css({
120            'left':leftWidth,
121            'width':rightWidth
122          });
123
124      },
125      nextSlide : function(){
126        if (dcs.currentSlideIndex>=dcs.slideCount-1 || inAnimation){
127          return false
128        }
129
130        var self=this;
131
132        self.gotoSlide(dcs.currentSlideIndex+1);
133        if (dcs.autoplay){
134          self.clearAutoplay();  
135        }
136        
137      },
138
139      prevSlide : function(){
140        if (dcs.currentSlideIndex<=0 || inAnimation){
141          return false
142        }
143
144        var self=this;
145
146        self.gotoSlide(dcs.currentSlideIndex-1);
147        if (dcs.autoplay){
148          self.clearAutoplay();  
149        }
150      
151      },
152      gotoSlide:function(sIndex){
153        var self=this,
154            cHeight=dcs.carouselHeight;
155        
156        if (sIndex==dcs.currentSlideIndex || inAnimation){
157          return false;
158        }
159
160        dcs.currentSlideIndex=sIndex;
161        inAnimation=true;
162
163
164        
165        self.changeSlide(sIndex);
166           
167      },
168      changeSlide:function(sIndex){
169        var self=this,
170            cHeight=dcs.carouselHeight;
171
172        self.$elem.trigger('start-change');
173        self.updateCounter(dcs.currentSlideIndex);
174        (new TimelineLite({onComplete:function(){
175          inAnimation=false;
176          self.$elem.trigger('end-change');
177        }
178        }))
179          .to(dcs.rightWrapper,dcs.rightSideDuration,{y:-dcs.rightDirectionSign*sIndex*cHeight,ease:Power4.easeOut})
180          .to(dcs.leftWrapper,dcs.leftSideDuration,{y:-dcs.leftDirectionSign*sIndex*cHeight,ease:Power4.easeOut},'-='+dcs.rightSideDuration);  
181      },
182      updateCounter : function(currentSlideIndex){
183        dcs.counterCurrent.html(currentSlideIndex+1);
184      },
185      bindUIActions: function(){
186          var self = this;
187
188          dcs.nextButton.on('click',function(){
189            self.nextSlide();
190          })
191          dcs.prevButton.on('click',function(){
192            self.prevSlide();
193          })
194
195          $(window).on('resize',function(){
196            self.update();
197            clearInterval(self.dcsInterval);
198            self.autoPlayHandler();
199          });
200
201          if (dcs.mouse){
202             self.scrollControll();
203          }
204
205          if (dcs.keyboard){
206             self.keyboardControll();
207          }
208
209          if (dcs.touchSwipe){
210            self.touchControll();
211          }
212          if (dcs.bulletControll){
213             self.bulletControll();
214          }
215
216          self.$elem.on('DCSInit',function(){
217
218            if (dcs.autoplay){
219              self.autoPlayHandler();
220            }
221          });
222
223          self.$elem.on('start-change',function(){
224            if (dcs.currentSlideIndex+1==dcs.slideCount){
225                dcs.nextButton.fadeOut();
226                dcs.prevButton.fadeIn();  
227            }else if (dcs.currentSlideIndex==0){
228                dcs.prevButton.fadeOut();
229                dcs.nextButton.fadeIn();
230            }else{
231              dcs.prevButton.fadeIn();
232              dcs.nextButton.fadeIn();
233            }
234
235          });
236         
237      },
238      scrollControll:function(){
239        var self=this,
240            magicFlg=false,
241            debounceTime=Math.max(self.options.leftSideDuration,self.options.rightSideDuration)*1.8*1000;
242        self.$elem.on('DOMMouseScroll mousewheel', function (e) { 
243
244          e.preventDefault();
245          
246          if (magicFlg) return;
247
248          magicFlg=true;
249
250          if(e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0) {
251              self.nextSlide();
252
253          } else {
254              self.prevSlide();
255            
256          }
257
258          setTimeout(function(){
259            magicFlg=false;
260          },debounceTime);
261
262        });
263      },
264      keyboardControll:function(){
265        var self=this;
266        
267        $(document).keydown(function(e) {
268          switch(e.which) {
269              case 38: // up
270                self.prevSlide();
271              break;
272
273              case 40: // down
274              self.nextSlide();
275              break;
276
277              default: return; 
278          }
279          e.preventDefault(); 
280        });
281      },
282      touchControll:function(){
283        var self=this;
284        self.$elem.swipe({
285          
286          swipe:function(event, direction, distance) {
287            if (direction=='down'){
288              self.prevSlide();
289            }else if (direction=='up'){
290              self.nextSlide();
291            }
292          }
293
294        });
295        self.$elem.on('touchmove',function(e){
296          e.preventDefault();
297        });
298      },
299      bulletControll:function(){
300        var self=this;
301       
302        var $bWrapper=$('<ul></ul>').addClass('vc-bullets');
303
304        if (dcs.bulletNumber){
305          $bWrapper.addClass('bullet-numbers');
306        }
307
308        var lis='',j,liContent;
309
310        for (var i = 0; i <= dcs.slideCount - 1; i++) {
311          
312          j=(i<10)?('0'+(i+1)):(i+1);
313
314          liContent=(dcs.bulletNumber==true)?'<span>'+j+'</span>':'';
315
316          lis+='<li><span>'+liContent+'</span></li>';  
317        };
318
319
320        $bWrapper.append(lis).appendTo(self.$elem);
321
322        dcs.bullets=$bWrapper.children();
323
324
325        //Set the position of bullets
326        if (dcs.bulletCenter=='vertical'){
327          $bWrapper.css('margin-top',-($bWrapper.height()/2)).addClass('vertical-bullets');
328        }else if (dcs.bulletCenter=='horizontal'){
329          $bWrapper.css('margin-left',-($bWrapper.width()/2)).addClass('horizontal-bullets');
330        }
331
332        dcs.bullets.eq(dcs.currentSlideIndex).addClass('active');
333
334        dcs.bullets.on('click',function(){
335          var $this=$(this),
336              index=$(this).index();
337
338          if (index==dcs.currentSlideIndex){
339            return false;
340          }
341
342          self.gotoSlide(index);
343
344        });
345        self.$elem.on('start-change',function(){
346          dcs.bullets.removeClass('active');
347          dcs.bullets.eq(dcs.currentSlideIndex).addClass('active');
348        });
349      },
350      //cover images in a container
351      fillCore:function(mode,side){
352          var self=this;
353
354          var items=(side=='left')?dcs.leftItems:dcs.rightItems;
355
356          var state=(mode=='side-fill')?'manual':'auto';
357
358          runFill();
359
360          function runFill(){
361            items.each(function(){
362              fillIt($(this),state,self.$elem.width(),mode,side);
363            });
364          }
365
366          function fillIt($container,state,cWidth,mode,side){
367
368            $container.imagesLoaded(function(){
369              
370                var containerWidth=(state=='manual')?cWidth:$container.width(),
371                    containerHeight=$container.height(),
372                    containerRatio=containerWidth/containerHeight,
373                    imgRatio;
374
375                $container.find('img').each(function(){
376                  var img=$(this);
377                    imgRatio=img.width()/img.height();
378
379                  if (containerRatio < imgRatio) {
380                    // taller
381                    img.css({
382                      width: 'auto',
383                      height: containerHeight,
384                      marginTop:0,
385                      marginLeft:-(containerHeight*imgRatio-containerWidth)/2
386                    });
387                  } else {
388                    // wider
389                    img.css({
390                        width: containerWidth,
391                        height: 'auto',
392                        marginTop:-(containerWidth/imgRatio-containerHeight)/2,
393                        marginLeft:0
394                      });
395                    }
396
397                    if (mode=='side-fill'){
398                      img.addClass('fill-'+side);
399                    }
400                    
401
402                });
403            });
404          }
405
406          $(window).on('resize',function(){
407            runFill();
408          });
409      },
410      triggerInit:function(){
411        var self=this;
412
413        dcs.allItems.imagesLoaded(function(){
414          self.$elem.trigger('DCSInit');
415        });
416      },
417      autoPlayHandler:function(){
418        var self=this;
419        self.dcsInterval=setInterval(function(){
420
421          var nextSlideIndex=(dcs.currentSlideIndex==dcs.slideCount-1)?0:dcs.currentSlideIndex+1;
422          if(dcs.autoplay){
423            self.gotoSlide(nextSlideIndex);
424          }
425        },dcs.duration*1000);
426      },
427      clearAutoplay:function(){
428        var self=this;
429        window.clearInterval(self.dcsInterval);
430
431        self.$elem.one('end-change',function(){
432          self.autoPlayHandler();
433        });
434      }
435
436    }
437
438    
439    $.fn.DoubleCarousel = function( options ) {
440        return this.each(function(){
441            var dCar = Object.create( DoubleCarousel ); 
442            dCar.init( options, this );
443        }); 
444    };
445
446    $.fn.DoubleCarousel.options = {
447      rightSide       : $('.right-side'), 
448      leftSide        : $('.left-side'),
449      leftWrapper     : $('.left-side-wrapper'),
450      rightWrapper    : $('.right-side-wrapper'),
451      nextButton      : $('.vcarousel-next'),
452      prevButton      : $('.vcarousel-prev'),
453      counterTotal    : $(".vcarousel-counter .counter-total"),
454      counterCurrent  : $(".vcarousel-counter .counter-current"),
455      rightSideDir    :'up',
456      leftSideDir     :'down',
457      leftSideDuration : 1,
458      rightSideDuration :1,
459      mouse :true,
460      keyboard   :true,
461      touchSwipe :true,  
462      bulletControll:true,
463      bulletNumber:false,
464      bulletCenter:'vertical',//vertical, horizontal or none,
465      autoplay:false,//Added since v1.1,
466      duration:5//Added since v1.1-- delay time for autoplay option
467    };
468
469
470
471})(jQuery, window, document);

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.