PageSourceSearch

https://professionalqa.com/assets/javascripts/carousel.js

js professionalqa.com collected 2026-10-02 17:53:27 UTC 5,251 bytes, 100 lines download raw bytes

vendor: 4,769 bytes, lines 1-92
1+function($){'use strict';var Carousel=function(element,options){this.$element=$(element)
2this.$indicators=this.$element.find('.carousel-indicators')
3this.options=options
4this.paused=null
5this.sliding=null
6this.interval=null
7this.$active=null
8this.$items=null
9this.options.keyboard&&this.$element.on('keydown.bs.carousel',$.proxy(this.keydown,this))
10this.options.pause=='hover'&&!('ontouchstart'in document.documentElement)&&this.$element.on('mouseenter.bs.carousel',$.proxy(this.pause,this)).on('mouseleave.bs.carousel',$.proxy(this.cycle,this))}
11Carousel.VERSION='3.3.6'
12Carousel.TRANSITION_DURATION=600
13Carousel.DEFAULTS={interval:5000,pause:'hover',wrap:true,keyboard:true}
14Carousel.prototype.keydown=function(e){if(/input|textarea/i.test(e.target.tagName))return
15switch(e.which){case 37:this.prev();break
16case 39:this.next();break
17default:return}
18e.preventDefault()}
19Carousel.prototype.cycle=function(e){e||(this.paused=false)
20this.interval&&clearInterval(this.interval)
21this.options.interval&&!this.paused&&(this.interval=setInterval($.proxy(this.next,this),this.options.interval))
22return this}
23Carousel.prototype.getItemIndex=function(item){this.$items=item.parent().children('.item')
24return this.$items.index(item||this.$active)}
25Carousel.prototype.getItemForDirection=function(direction,active){var activeIndex=this.getItemIndex(active)
26var willWrap=(direction=='prev'&&activeIndex===0)||(direction=='next'&&activeIndex==(this.$items.length-1))
27if(willWrap&&!this.options.wrap)return active
28var delta=direction=='prev'?-1:1
29var itemIndex=(activeIndex+delta)%this.$items.length
30return this.$items.eq(itemIndex)}
31Carousel.prototype.to=function(pos){var that=this
32var activeIndex=this.getItemIndex(this.$active=this.$element.find('.item.active'))
33if(pos>(this.$items.length-1)||pos<0)return
34if(this.sliding)return this.$element.one('slid.bs.carousel',function(){that.to(pos)})
35if(activeIndex==pos)return this.pause().cycle()
36return this.slide(pos>activeIndex?'next':'prev',this.$items.eq(pos))}
37Carousel.prototype.pause=function(e){e||(this.paused=true)
38if(this.$element.find('.next, .prev').length&&$.support.transition){this.$element.trigger($.support.transition.end)
39this.cycle(true)}
40this.interval=clearInterval(this.interval)
41return this}
42Carousel.prototype.next=function(){if(this.sliding)return
43return this.slide('next')}
44Carousel.prototype.prev=function(){if(this.sliding)return
45return this.slide('prev')}
46Carousel.prototype.slide=function(type,next){var $active=this.$element.find('.item.active')
47var $next=next||this.getItemForDirection(type,$active)
48var isCycling=this.interval
49var direction=type=='next'?'left':'right'
50var that=this
51if($next.hasClass('active'))return(this.sliding=false)
52var relatedTarget=$next[0]
53var slideEvent=$.Event('slide.bs.carousel',{relatedTarget:relatedTarget,direction:direction})
54this.$element.trigger(slideEvent)
55if(slideEvent.isDefaultPrevented())return
56this.sliding=true
57isCycling&&this.pause()
58if(this.$indicators.length){this.$indicators.find('.active').removeClass('active')
59var $nextIndicator=$(this.$indicators.children()[this.getItemIndex($next)])
60$nextIndicator&&$nextIndicator.addClass('active')}
61var slidEvent=$.Event('slid.bs.carousel',{relatedTarget:relatedTarget,direction:direction})
62if($.support.transition&&this.$element.hasClass('slide')){$next.addClass(type)
63$next[0].offsetWidth
64$active.addClass(direction)
65$next.addClass(direction)
66$active.one('bsTransitionEnd',function(){$next.removeClass([type,direction].join(' ')).addClass('active')
67$active.removeClass(['active',direction].join(' '))
68that.sliding=false
69setTimeout(function(){that.$element.trigger(slidEvent)},0)}).emulateTransitionEnd(Carousel.TRANSITION_DURATION)}else{$active.removeClass('active')
70$next.addClass('active')
71this.sliding=false
72this.$element.trigger(slidEvent)}
73isCycling&&this.cycle()
74return this}
75function Plugin(option){return this.each(function(){var $this=$(this)
76var data=$this.data('bs.carousel')
77var options=$.extend({},Carousel.DEFAULTS,$this.data(),typeof option=='object'&&option)
78var action=typeof option=='string'?option:options.slide
79if(!data)$this.data('bs.carousel',(data=new Carousel(this,options)))
80if(typeof option=='number')data.to(option)
81else if(action)data[action]()
82else if(options.interval)data.pause().cycle()})}
83var old=$.fn.carousel
84$.fn.carousel=Plugin
85$.fn.carousel.Constructor=Carousel
86$.fn.carousel.noConflict=function(){$.fn.carousel=old
87return this}
88var clickHandler=function(e){var href
89var $this=$(this)
90var $target=$($this.attr('data-target')||(href=$this.attr('href'))&&href.replace(/.*(?=#[^\s]+$)/,''))
91if(!$target.hasClass('carousel'))return
92var options=$.extend({},$target.data(),$this.data())
vendor: 482 bytes, lines 93-100
93var slideIndex=$this.attr('data-slide-to')
94if(slideIndex)options.interval=false
95Plugin.call($target,options)
96if(slideIndex){$target.data('bs.carousel').to(slideIndex)}
97e.preventDefault()}
98$(document).on('click.bs.carousel.data-api','[data-slide]',clickHandler).on('click.bs.carousel.data-api','[data-slide-to]',clickHandler)
99$(window).on('load',function(){$('[data-ride="carousel"]').each(function(){var $carousel=$(this)
100Plugin.call($carousel,$carousel.data())})})}(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.