annotate static/bootstrap/js/bootstrap-carousel.js @ 61:130eccd396d8

Now using Boostrap with LESS.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 06 Feb 2013 08:22:31 -0800
parents
children a5a3d454eac9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
61
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
1 /* ==========================================================
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
2 * bootstrap-carousel.js v2.2.2
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
3 * http://twitter.github.com/bootstrap/javascript.html#carousel
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4 * ==========================================================
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
5 * Copyright 2012 Twitter, Inc.
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
6 *
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
7 * Licensed under the Apache License, Version 2.0 (the "License");
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
8 * you may not use this file except in compliance with the License.
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9 * You may obtain a copy of the License at
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
10 *
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
11 * http://www.apache.org/licenses/LICENSE-2.0
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
12 *
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
13 * Unless required by applicable law or agreed to in writing, software
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
14 * distributed under the License is distributed on an "AS IS" BASIS,
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16 * See the License for the specific language governing permissions and
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17 * limitations under the License.
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
18 * ========================================================== */
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
19
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
20
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
21 !function ($) {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
22
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
23 "use strict"; // jshint ;_;
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
25
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
26 /* CAROUSEL CLASS DEFINITION
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
27 * ========================= */
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
28
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
29 var Carousel = function (element, options) {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
30 this.$element = $(element)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
31 this.options = options
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
32 this.options.pause == 'hover' && this.$element
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
33 .on('mouseenter', $.proxy(this.pause, this))
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
34 .on('mouseleave', $.proxy(this.cycle, this))
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
35 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
36
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
37 Carousel.prototype = {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
38
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
39 cycle: function (e) {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
40 if (!e) this.paused = false
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
41 this.options.interval
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
42 && !this.paused
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
43 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
44 return this
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
45 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
46
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
47 , to: function (pos) {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
48 var $active = this.$element.find('.item.active')
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
49 , children = $active.parent().children()
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
50 , activePos = children.index($active)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
51 , that = this
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
52
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
53 if (pos > (children.length - 1) || pos < 0) return
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
54
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
55 if (this.sliding) {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
56 return this.$element.one('slid', function () {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
57 that.to(pos)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
58 })
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
59 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
60
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
61 if (activePos == pos) {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
62 return this.pause().cycle()
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
63 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
64
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
65 return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
66 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
67
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
68 , pause: function (e) {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
69 if (!e) this.paused = true
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
70 if (this.$element.find('.next, .prev').length && $.support.transition.end) {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
71 this.$element.trigger($.support.transition.end)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
72 this.cycle()
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
73 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
74 clearInterval(this.interval)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
75 this.interval = null
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
76 return this
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
77 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
78
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
79 , next: function () {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
80 if (this.sliding) return
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
81 return this.slide('next')
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
82 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
83
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
84 , prev: function () {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
85 if (this.sliding) return
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
86 return this.slide('prev')
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
87 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
88
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
89 , slide: function (type, next) {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
90 var $active = this.$element.find('.item.active')
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
91 , $next = next || $active[type]()
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
92 , isCycling = this.interval
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
93 , direction = type == 'next' ? 'left' : 'right'
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
94 , fallback = type == 'next' ? 'first' : 'last'
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
95 , that = this
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
96 , e
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
97
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
98 this.sliding = true
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
99
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
100 isCycling && this.pause()
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
101
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
102 $next = $next.length ? $next : this.$element.find('.item')[fallback]()
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
103
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
104 e = $.Event('slide', {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
105 relatedTarget: $next[0]
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
106 })
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
107
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
108 if ($next.hasClass('active')) return
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
109
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
110 if ($.support.transition && this.$element.hasClass('slide')) {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
111 this.$element.trigger(e)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
112 if (e.isDefaultPrevented()) return
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
113 $next.addClass(type)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
114 $next[0].offsetWidth // force reflow
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
115 $active.addClass(direction)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
116 $next.addClass(direction)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
117 this.$element.one($.support.transition.end, function () {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
118 $next.removeClass([type, direction].join(' ')).addClass('active')
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
119 $active.removeClass(['active', direction].join(' '))
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
120 that.sliding = false
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
121 setTimeout(function () { that.$element.trigger('slid') }, 0)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
122 })
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
123 } else {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
124 this.$element.trigger(e)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
125 if (e.isDefaultPrevented()) return
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
126 $active.removeClass('active')
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
127 $next.addClass('active')
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
128 this.sliding = false
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
129 this.$element.trigger('slid')
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
130 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
131
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
132 isCycling && this.cycle()
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
133
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
134 return this
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
135 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
136
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
137 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
138
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
139
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
140 /* CAROUSEL PLUGIN DEFINITION
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
141 * ========================== */
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
142
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
143 var old = $.fn.carousel
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
144
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
145 $.fn.carousel = function (option) {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
146 return this.each(function () {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
147 var $this = $(this)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
148 , data = $this.data('carousel')
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
149 , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
150 , action = typeof option == 'string' ? option : options.slide
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
151 if (!data) $this.data('carousel', (data = new Carousel(this, options)))
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
152 if (typeof option == 'number') data.to(option)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
153 else if (action) data[action]()
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
154 else if (options.interval) data.cycle()
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
155 })
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
156 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
157
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
158 $.fn.carousel.defaults = {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
159 interval: 5000
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
160 , pause: 'hover'
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
161 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
162
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
163 $.fn.carousel.Constructor = Carousel
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
164
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
165
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
166 /* CAROUSEL NO CONFLICT
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
167 * ==================== */
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
168
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
169 $.fn.carousel.noConflict = function () {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
170 $.fn.carousel = old
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
171 return this
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
172 }
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
173
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
174 /* CAROUSEL DATA-API
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
175 * ================= */
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
176
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
177 $(document).on('click.carousel.data-api', '[data-slide]', function (e) {
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
178 var $this = $(this), href
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
179 , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
180 , options = $.extend({}, $target.data(), $this.data())
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
181 $target.carousel(options)
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
182 e.preventDefault()
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
183 })
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
184
130eccd396d8 Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
185 }(window.jQuery);