PageSourceSearch

https://peacehdforphd.com/wp-content/themes/bridge/js/plugins/bootstrap.carousel.js?ver=5.5.22

js peacehdforphd.com collected 2026-09-24 14:51:11 UTC 7,469 bytes, 224 lines download raw bytes

1/* ========================================================================
2 * Bootstrap: carousel.js v3.0.0
3 * http://twbs.github.com/bootstrap/javascript.html#carousel
4 * ========================================================================
5 * Copyright 2012 Twitter, Inc.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ======================================================================== */
19
20
21+function ($) { "use strict";
22
23    // CAROUSEL CLASS DEFINITION
24    // =========================
25    var Carousel = function (element, options) {
26        this.$element    = $(element)
27        this.$indicators = this.$element.find('.carousel-indicators')
28        this.options     = options
29        this.paused      =
30            this.sliding     =
31                this.interval    =
32                    this.$active     =
33                        this.$items      = null
34
35        this.options.pause == 'hover' && this.$element
36            .on('mouseenter', $.proxy(this.pause, this))
37            .on('mouseleave', $.proxy(this.cycle, this))
38    }
39
40    Carousel.DEFAULTS = {
41        interval: 5000
42        , pause: 'hover'
43        , wrap: true
44    }
45
46    Carousel.prototype.cycle =  function (e) {
47        e || (this.paused = false)
48
49        this.interval && clearInterval(this.interval)
50
51        this.options.interval
52        && !this.paused
53        && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
54
55        return this
56    }
57
58    Carousel.prototype.getActiveIndex = function () {
59        this.$active = this.$element.find('.item.active')
60        this.$items  = this.$active.parent().children()
61
62        return this.$items.index(this.$active)
63    }
64
65    Carousel.prototype.to = function (pos) {
66        var that        = this
67        var activeIndex = this.getActiveIndex()
68
69        if (pos > (this.$items.length - 1) || pos < 0) return
70
71        if (this.sliding)       return this.$element.one('slid', function () { that.to(pos) })
72        if (activeIndex == pos) return this.pause().cycle()
73
74        return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
75    }
76
77    Carousel.prototype.pause = function (e) {
78        e || (this.paused = true)
79
80        //if (this.$element.find('.next, .prev').length && $.support.transition.end) {
81        //this.$element.trigger($.support.transition.end)
82        this.cycle(true)
83        //}
84
85        this.interval = clearInterval(this.interval)
86
87        return this
88    }
89
90    Carousel.prototype.next = function () {
91        if (this.sliding) return
92        return this.slide('next')
93    }
94
95    Carousel.prototype.prev = function () {
96        if (this.sliding) return
97        return this.slide('prev')
98    }
99
100    Carousel.prototype.slide = function (type, next) {
101        var $active   = this.$element.find('.item.active')
102        var $next     = next || $active[type]()
103        var isCycling = this.interval
104        var direction = type == 'next' ? 'left' : 'right'
105        var fallback  = type == 'next' ? 'first' : 'last'
106        var that      = this
107
108        if (!$next.length) {
109            if (!this.options.wrap) return
110            $next = this.$element.find('.item')[fallback]()
111        }
112
113        this.sliding = true
114
115        isCycling && this.pause()
116
117        var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction })
118
119        if ($next.hasClass('active')) return
120
121        if (this.$indicators.length) {
122            this.$indicators.find('.active').removeClass('active')
123            this.$element.one('slid', function () {
124                var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
125                $nextIndicator && $nextIndicator.addClass('active')
126            })
127        }
128
129        var $this = this.$element.hasClass('header_effect');
130        if ($.support.transition && this.$element.hasClass('slide')) {
131            this.$element.trigger(e)
132            if (e.isDefaultPrevented()) return
133            var timer;
134
135
136            timer = setTimeout(function(){
137                checkSliderForHeaderStyle($next, $this);
138                $next.addClass(type)
139                $next[0].offsetWidth // force reflow
140                $active.addClass(direction)
141                $next.addClass(direction)
142                $active
143                    .one($.support.transition.end, function () {
144                        $next.removeClass([type, direction].join(' ')).removeClass('inactive').addClass('active')
145                        $active.removeClass(['active', direction].join(' ')).addClass('inactive')
146                        that.sliding = false
147                        setTimeout(function () { that.$element.trigger('slid') }, 0)
148                    })
149                    .emulateTransitionEnd(600)
150                clearTimeout(timer);
151            }, 1000);
152        } else {
153            this.$element.trigger(e)
154            if (e.isDefaultPrevented()) return
155            $active.removeClass('active')
156            $next.addClass('active')
157            this.sliding = false
158            this.$element.trigger('slid')
159        }
160
161        isCycling && this.cycle()
162
163        return this
164    }
165
166
167    // CAROUSEL PLUGIN DEFINITION
168    // ==========================
169
170    var old = $.fn.carousel
171
172    $.fn.carousel = function (option) {
173        return this.each(function () {
174            var $this   = $(this)
175            var data    = $this.data('bs.carousel')
176            var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
177            var action  = typeof option == 'string' ? option : options.slide
178
179            if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
180            if (typeof option == 'number') data.to(option)
181            else if (action) data[action]()
182            else if (options.interval) data.pause().cycle()
183        })
184    }
185
186    $.fn.carousel.Constructor = Carousel
187
188
189    // CAROUSEL NO CONFLICT
190    // ====================
191
192    $.fn.carousel.noConflict = function () {
193        $.fn.carousel = old
194        return this
195    }
196
197
198    // CAROUSEL DATA-API
199    // =================
200
201    $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
202        var $this   = $(this), href
203        var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
204        var options = $.extend({}, $target.data(), $this.data())
205        var slideIndex = $this.attr('data-slide-to')
206        if (slideIndex) options.interval = false
207
208        $target.carousel(options)
209
210        if (slideIndex = $this.attr('data-slide-to')) {
211            $target.data('bs.carousel').to(slideIndex)
212        }
213
214        e.preventDefault()
215    })
216
217    $(window).on('load', function () {
218        $('[data-ride="carousel"]').each(function () {
219            var $carousel = $(this)
220            $carousel.carousel($carousel.data())
221        })
222    })
223
224}(window.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.