indvd00m@0: /* ========================================================== indvd00m@0: * bootstrap-carousel.js v2.3.1 indvd00m@0: * http://twitter.github.com/bootstrap/javascript.html#carousel indvd00m@0: * ========================================================== indvd00m@0: * Copyright 2012 Twitter, Inc. indvd00m@0: * indvd00m@0: * Licensed under the Apache License, Version 2.0 (the "License"); indvd00m@0: * you may not use this file except in compliance with the License. indvd00m@0: * You may obtain a copy of the License at indvd00m@0: * indvd00m@0: * http://www.apache.org/licenses/LICENSE-2.0 indvd00m@0: * indvd00m@0: * Unless required by applicable law or agreed to in writing, software indvd00m@0: * distributed under the License is distributed on an "AS IS" BASIS, indvd00m@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. indvd00m@0: * See the License for the specific language governing permissions and indvd00m@0: * limitations under the License. indvd00m@0: * ========================================================== */ indvd00m@0: indvd00m@0: indvd00m@0: !function ($) { indvd00m@0: indvd00m@0: "use strict"; // jshint ;_; indvd00m@0: indvd00m@0: indvd00m@0: /* CAROUSEL CLASS DEFINITION indvd00m@0: * ========================= */ indvd00m@0: indvd00m@0: var Carousel = function (element, options) { indvd00m@0: this.$element = $(element) indvd00m@0: this.$indicators = this.$element.find('.carousel-indicators') indvd00m@0: this.options = options indvd00m@0: this.options.pause == 'hover' && this.$element indvd00m@0: .on('mouseenter', $.proxy(this.pause, this)) indvd00m@0: .on('mouseleave', $.proxy(this.cycle, this)) indvd00m@0: } indvd00m@0: indvd00m@0: Carousel.prototype = { indvd00m@0: indvd00m@0: cycle: function (e) { indvd00m@0: if (!e) this.paused = false indvd00m@0: if (this.interval) clearInterval(this.interval); indvd00m@0: this.options.interval indvd00m@0: && !this.paused indvd00m@0: && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) indvd00m@0: return this indvd00m@0: } indvd00m@0: indvd00m@0: , getActiveIndex: function () { indvd00m@0: this.$active = this.$element.find('.item.active') indvd00m@0: this.$items = this.$active.parent().children() indvd00m@0: return this.$items.index(this.$active) indvd00m@0: } indvd00m@0: indvd00m@0: , to: function (pos) { indvd00m@0: var activeIndex = this.getActiveIndex() indvd00m@0: , that = this indvd00m@0: indvd00m@0: if (pos > (this.$items.length - 1) || pos < 0) return indvd00m@0: indvd00m@0: if (this.sliding) { indvd00m@0: return this.$element.one('slid', function () { indvd00m@0: that.to(pos) indvd00m@0: }) indvd00m@0: } indvd00m@0: indvd00m@0: if (activeIndex == pos) { indvd00m@0: return this.pause().cycle() indvd00m@0: } indvd00m@0: indvd00m@0: return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) indvd00m@0: } indvd00m@0: indvd00m@0: , pause: function (e) { indvd00m@0: if (!e) this.paused = true indvd00m@0: if (this.$element.find('.next, .prev').length && $.support.transition.end) { indvd00m@0: this.$element.trigger($.support.transition.end) indvd00m@0: this.cycle(true) indvd00m@0: } indvd00m@0: clearInterval(this.interval) indvd00m@0: this.interval = null indvd00m@0: return this indvd00m@0: } indvd00m@0: indvd00m@0: , next: function () { indvd00m@0: if (this.sliding) return indvd00m@0: return this.slide('next') indvd00m@0: } indvd00m@0: indvd00m@0: , prev: function () { indvd00m@0: if (this.sliding) return indvd00m@0: return this.slide('prev') indvd00m@0: } indvd00m@0: indvd00m@0: , slide: function (type, next) { indvd00m@0: var $active = this.$element.find('.item.active') indvd00m@0: , $next = next || $active[type]() indvd00m@0: , isCycling = this.interval indvd00m@0: , direction = type == 'next' ? 'left' : 'right' indvd00m@0: , fallback = type == 'next' ? 'first' : 'last' indvd00m@0: , that = this indvd00m@0: , e indvd00m@0: indvd00m@0: this.sliding = true indvd00m@0: indvd00m@0: isCycling && this.pause() indvd00m@0: indvd00m@0: $next = $next.length ? $next : this.$element.find('.item')[fallback]() indvd00m@0: indvd00m@0: e = $.Event('slide', { indvd00m@0: relatedTarget: $next[0] indvd00m@0: , direction: direction indvd00m@0: }) indvd00m@0: indvd00m@0: if ($next.hasClass('active')) return indvd00m@0: indvd00m@0: if (this.$indicators.length) { indvd00m@0: this.$indicators.find('.active').removeClass('active') indvd00m@0: this.$element.one('slid', function () { indvd00m@0: var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) indvd00m@0: $nextIndicator && $nextIndicator.addClass('active') indvd00m@0: }) indvd00m@0: } indvd00m@0: indvd00m@0: if ($.support.transition && this.$element.hasClass('slide')) { indvd00m@0: this.$element.trigger(e) indvd00m@0: if (e.isDefaultPrevented()) return indvd00m@0: $next.addClass(type) indvd00m@0: $next[0].offsetWidth // force reflow indvd00m@0: $active.addClass(direction) indvd00m@0: $next.addClass(direction) indvd00m@0: this.$element.one($.support.transition.end, function () { indvd00m@0: $next.removeClass([type, direction].join(' ')).addClass('active') indvd00m@0: $active.removeClass(['active', direction].join(' ')) indvd00m@0: that.sliding = false indvd00m@0: setTimeout(function () { that.$element.trigger('slid') }, 0) indvd00m@0: }) indvd00m@0: } else { indvd00m@0: this.$element.trigger(e) indvd00m@0: if (e.isDefaultPrevented()) return indvd00m@0: $active.removeClass('active') indvd00m@0: $next.addClass('active') indvd00m@0: this.sliding = false indvd00m@0: this.$element.trigger('slid') indvd00m@0: } indvd00m@0: indvd00m@0: isCycling && this.cycle() indvd00m@0: indvd00m@0: return this indvd00m@0: } indvd00m@0: indvd00m@0: } indvd00m@0: indvd00m@0: indvd00m@0: /* CAROUSEL PLUGIN DEFINITION indvd00m@0: * ========================== */ indvd00m@0: indvd00m@0: var old = $.fn.carousel indvd00m@0: indvd00m@0: $.fn.carousel = function (option) { indvd00m@0: return this.each(function () { indvd00m@0: var $this = $(this) indvd00m@0: , data = $this.data('carousel') indvd00m@0: , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option) indvd00m@0: , action = typeof option == 'string' ? option : options.slide indvd00m@0: if (!data) $this.data('carousel', (data = new Carousel(this, options))) indvd00m@0: if (typeof option == 'number') data.to(option) indvd00m@0: else if (action) data[action]() indvd00m@0: else if (options.interval) data.pause().cycle() indvd00m@0: }) indvd00m@0: } indvd00m@0: indvd00m@0: $.fn.carousel.defaults = { indvd00m@0: interval: 5000 indvd00m@0: , pause: 'hover' indvd00m@0: } indvd00m@0: indvd00m@0: $.fn.carousel.Constructor = Carousel indvd00m@0: indvd00m@0: indvd00m@0: /* CAROUSEL NO CONFLICT indvd00m@0: * ==================== */ indvd00m@0: indvd00m@0: $.fn.carousel.noConflict = function () { indvd00m@0: $.fn.carousel = old indvd00m@0: return this indvd00m@0: } indvd00m@0: indvd00m@0: /* CAROUSEL DATA-API indvd00m@0: * ================= */ indvd00m@0: indvd00m@0: $(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { indvd00m@0: var $this = $(this), href indvd00m@0: , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 indvd00m@0: , options = $.extend({}, $target.data(), $this.data()) indvd00m@0: , slideIndex indvd00m@0: indvd00m@0: $target.carousel(options) indvd00m@0: indvd00m@0: if (slideIndex = $this.attr('data-slide-to')) { indvd00m@0: $target.data('carousel').pause().to(slideIndex).cycle() indvd00m@0: } indvd00m@0: indvd00m@0: e.preventDefault() indvd00m@0: }) indvd00m@0: indvd00m@0: }(window.jQuery);