Mercurial > wikked
annotate static/bootstrap/js/bootstrap-carousel.js @ 88:a5a3d454eac9
Updated Bootstrap.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 05 Apr 2013 08:08:12 -0700 |
parents | 130eccd396d8 |
children |
rev | line source |
---|---|
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 /* ========================================================== |
88 | 2 * bootstrap-carousel.js v2.3.1 |
61
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) |
88 | 31 this.$indicators = this.$element.find('.carousel-indicators') |
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
32 this.options = options |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
33 this.options.pause == 'hover' && this.$element |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
34 .on('mouseenter', $.proxy(this.pause, this)) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
35 .on('mouseleave', $.proxy(this.cycle, this)) |
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 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
38 Carousel.prototype = { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
39 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
40 cycle: function (e) { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
41 if (!e) this.paused = false |
88 | 42 if (this.interval) clearInterval(this.interval); |
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
43 this.options.interval |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
44 && !this.paused |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
45 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
46 return this |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
47 } |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
48 |
88 | 49 , getActiveIndex: function () { |
50 this.$active = this.$element.find('.item.active') | |
51 this.$items = this.$active.parent().children() | |
52 return this.$items.index(this.$active) | |
53 } | |
54 | |
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
55 , to: function (pos) { |
88 | 56 var activeIndex = this.getActiveIndex() |
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
57 , that = this |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
58 |
88 | 59 if (pos > (this.$items.length - 1) || pos < 0) return |
61
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 (this.sliding) { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
62 return this.$element.one('slid', function () { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
63 that.to(pos) |
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 } |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
66 |
88 | 67 if (activeIndex == pos) { |
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
68 return this.pause().cycle() |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
69 } |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
70 |
88 | 71 return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) |
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
72 } |
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 , pause: function (e) { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
75 if (!e) this.paused = true |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
76 if (this.$element.find('.next, .prev').length && $.support.transition.end) { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
77 this.$element.trigger($.support.transition.end) |
88 | 78 this.cycle(true) |
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
79 } |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
80 clearInterval(this.interval) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
81 this.interval = null |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
82 return this |
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 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
85 , next: function () { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
86 if (this.sliding) return |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
87 return this.slide('next') |
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 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
90 , prev: function () { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
91 if (this.sliding) return |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
92 return this.slide('prev') |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
93 } |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
94 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
95 , slide: function (type, next) { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
96 var $active = this.$element.find('.item.active') |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
97 , $next = next || $active[type]() |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
98 , isCycling = this.interval |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
99 , direction = type == 'next' ? 'left' : 'right' |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
100 , fallback = type == 'next' ? 'first' : 'last' |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
101 , that = this |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
102 , e |
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 this.sliding = true |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
105 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
106 isCycling && this.pause() |
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 $next = $next.length ? $next : this.$element.find('.item')[fallback]() |
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 e = $.Event('slide', { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
111 relatedTarget: $next[0] |
88 | 112 , direction: direction |
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
113 }) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
114 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
115 if ($next.hasClass('active')) return |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
116 |
88 | 117 if (this.$indicators.length) { |
118 this.$indicators.find('.active').removeClass('active') | |
119 this.$element.one('slid', function () { | |
120 var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) | |
121 $nextIndicator && $nextIndicator.addClass('active') | |
122 }) | |
123 } | |
124 | |
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
125 if ($.support.transition && this.$element.hasClass('slide')) { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
126 this.$element.trigger(e) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
127 if (e.isDefaultPrevented()) return |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
128 $next.addClass(type) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
129 $next[0].offsetWidth // force reflow |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
130 $active.addClass(direction) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
131 $next.addClass(direction) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
132 this.$element.one($.support.transition.end, function () { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
133 $next.removeClass([type, direction].join(' ')).addClass('active') |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
134 $active.removeClass(['active', direction].join(' ')) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
135 that.sliding = false |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
136 setTimeout(function () { that.$element.trigger('slid') }, 0) |
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 } else { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
139 this.$element.trigger(e) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
140 if (e.isDefaultPrevented()) return |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
141 $active.removeClass('active') |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
142 $next.addClass('active') |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
143 this.sliding = false |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
144 this.$element.trigger('slid') |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
145 } |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
146 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
147 isCycling && this.cycle() |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
148 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
149 return this |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
150 } |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
151 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
152 } |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
153 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
154 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
155 /* CAROUSEL PLUGIN DEFINITION |
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 var old = $.fn.carousel |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
159 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
160 $.fn.carousel = function (option) { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
161 return this.each(function () { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
162 var $this = $(this) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
163 , data = $this.data('carousel') |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
164 , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
165 , action = typeof option == 'string' ? option : options.slide |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
166 if (!data) $this.data('carousel', (data = new Carousel(this, options))) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
167 if (typeof option == 'number') data.to(option) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
168 else if (action) data[action]() |
88 | 169 else if (options.interval) data.pause().cycle() |
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
170 }) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
171 } |
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 $.fn.carousel.defaults = { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
174 interval: 5000 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
175 , pause: 'hover' |
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 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
178 $.fn.carousel.Constructor = Carousel |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
179 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
180 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
181 /* CAROUSEL NO CONFLICT |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
182 * ==================== */ |
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 $.fn.carousel.noConflict = function () { |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
185 $.fn.carousel = old |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
186 return this |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
187 } |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
188 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
189 /* CAROUSEL DATA-API |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
190 * ================= */ |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
191 |
88 | 192 $(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { |
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
193 var $this = $(this), href |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
194 , $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
|
195 , options = $.extend({}, $target.data(), $this.data()) |
88 | 196 , slideIndex |
197 | |
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
198 $target.carousel(options) |
88 | 199 |
200 if (slideIndex = $this.attr('data-slide-to')) { | |
201 $target.data('carousel').pause().to(slideIndex).cycle() | |
202 } | |
203 | |
61
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
204 e.preventDefault() |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
205 }) |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
206 |
130eccd396d8
Now using Boostrap with LESS.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
207 }(window.jQuery); |