1/* ========================================================== 2 * bootstrap-carousel.js v2.0.0 3 * http://twitter.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( $ ){ 22 23 "use strict" 24 25 /* CAROUSEL CLASS DEFINITION 26 * ========================= */ 27 28 var Carousel = function (element, options) { 29 this.$element = $(element) 30 this.options = $.extend({}, $.fn.carousel.defaults, options) 31 this.options.slide && this.slide(this.options.slide) 32 } 33 34 Carousel.prototype = { 35 36 cycle: function () { 37 this.interval = setInterval($.proxy(this.next, this), this.options.interval) 38 return this 39 } 40 41 , to: function (pos) { 42 var $active = this.$element.find('.active') 43 , children = $active.parent().children() 44 , activePos = children.index($active) 45 , that = this 46 47 if (pos > (children.length - 1) || pos < 0) return 48 49 if (this.sliding) { 50 return this.$element.one('slid', function () { 51 that.to(pos) 52 }) 53 } 54 55 if (activePos == pos) { 56 return this.pause().cycle() 57 } 58 59 return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos])) 60 } 61 62 , pause: function () { 63 clearInterval(this.interval) 64 return this 65 } 66 67 , next: function () { 68 if (this.sliding) return 69 return this.slide('next') 70 } 71 72 , prev: function () { 73 if (this.sliding) return 74 return this.slide('prev') 75 } 76 77 , slide: function (type, next) { 78 var $active = this.$element.find('.active') 79 , $next = next || $active[type]() 80 , isCycling = this.interval 81 , direction = type == 'next' ? 'left' : 'right' 82 , fallback = type == 'next' ? 'first' : 'last' 83 , that = this 84 85 this.sliding = true 86 87 isCycling && this.pause() 88 89 $next = $next.length ? $next : this.$element.find('.item')[fallback]() 90 91 if (!$.support.transition && this.$element.hasClass('slide')) { 92 this.$element.trigger('slide') 93 $active.removeClass('active') 94 $next.addClass('active') 95 this.sliding = false 96 this.$element.trigger('slid') 97 } else { 98 $next.addClass(type) 99 $next[0].offsetWidth // force reflow 100 $active.addClass(direction) 101 $next.addClass(direction) 102 this.$element.trigger('slide') 103 this.$element.one($.support.transition.end, function () { 104 $next.removeClass([type, direction].join(' ')).addClass('active') 105 $active.removeClass(['active', direction].join(' ')) 106 that.sliding = false 107 setTimeout(function () { that.$element.trigger('slid') }, 0) 108 }) 109 } 110 111 isCycling && this.cycle() 112 113 return this 114 } 115 116 } 117 118 119 /* CAROUSEL PLUGIN DEFINITION 120 * ========================== */ 121 122 $.fn.carousel = function ( option ) { 123 return this.each(function () { 124 var $this = $(this) 125 , data = $this.data('carousel') 126 , options = typeof option == 'object' && option 127 if (!data) $this.data('carousel', (data = new Carousel(this, options))) 128 if (typeof option == 'number') data.to(option) 129 else if (typeof option == 'string' || (option = options.slide)) data[option]() 130 else data.cycle() 131 }) 132 } 133 134 $.fn.carousel.defaults = { 135 interval: 5000 136 } 137 138 $.fn.carousel.Constructor = Carousel 139 140 141 /* CAROUSEL DATA-API 142 * ================= */ 143 144 $(function () {
145 $('body').on('click.carousel.data-api', '[data-slide]', function ( e ) { 146 var $this = $(this), href 147 , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 148 , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data()) 149 $target.carousel(options) 150 e.preventDefault() 151 }) 152 }) 153 154}( 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.