twitter_bootstrap_markup 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/lib/twitter_bootstrap_markup.rb +7 -0
  2. data/lib/twitter_bootstrap_markup/alert.rb +1 -1
  3. data/lib/twitter_bootstrap_markup/badge.rb +2 -1
  4. data/lib/twitter_bootstrap_markup/button.rb +2 -1
  5. data/lib/twitter_bootstrap_markup/button_base.rb +27 -23
  6. data/lib/twitter_bootstrap_markup/dropdown_link.rb +30 -0
  7. data/lib/twitter_bootstrap_markup/input.rb +3 -9
  8. data/lib/twitter_bootstrap_markup/input_size.rb +22 -0
  9. data/lib/twitter_bootstrap_markup/label.rb +2 -1
  10. data/lib/twitter_bootstrap_markup/label_base.rb +13 -9
  11. data/lib/twitter_bootstrap_markup/link_button.rb +2 -1
  12. data/lib/twitter_bootstrap_markup/nav_bar.rb +8 -6
  13. data/lib/twitter_bootstrap_markup/nav_list.rb +9 -4
  14. data/lib/twitter_bootstrap_markup/select.rb +2 -14
  15. data/lib/twitter_bootstrap_markup/tag.rb +12 -2
  16. data/lib/twitter_bootstrap_markup/tag_builder.rb +22 -0
  17. data/lib/twitter_bootstrap_markup/textarea.rb +15 -0
  18. data/lib/twitter_bootstrap_markup/ul_container.rb +9 -2
  19. data/lib/twitter_bootstrap_markup/version.rb +1 -1
  20. data/markup/alerts.html +1 -1
  21. data/markup/css/bootstrap.css +3451 -3520
  22. data/markup/css/bootstrap.min.css +719 -1
  23. data/markup/dropdown_links.html +112 -0
  24. data/markup/index.html +14 -12
  25. data/markup/js/bootstrap.js +856 -845
  26. data/markup/js/bootstrap.min.js +3 -2
  27. data/markup/textareas.html +90 -0
  28. data/spec/dropdown_link_spec.rb +48 -0
  29. data/spec/nav_bar_spec.rb +11 -0
  30. data/spec/nav_list_spec.rb +14 -1
  31. data/spec/select_spec.rb +2 -3
  32. data/spec/tag_builder_spec.rb +38 -0
  33. data/spec/tag_spec.rb +12 -0
  34. data/spec/text_area_spec.rb +43 -0
  35. data/spec/textbox_spec.rb +2 -2
  36. data/twitter_bootstrap_markup.gemspec +2 -0
  37. metadata +26 -6
@@ -0,0 +1,112 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Twitter Bootstrap Markup</title>
5
+ <!--[if lt IE 9]>
6
+ <script src='http://html5shim.googlecode/svn/trunk/html5.js' type='text/javascript'></script>
7
+ <![endif]-->
8
+ <link href="css/bootstrap.css" media="screen" rel="stylesheet" type="text/css" />
9
+ <meta content='width=device-width, initial-scale=1.0' name='viewport'>
10
+ </head>
11
+ <body>
12
+ <div class="container">
13
+ <h2>Dropdown Links</h2>
14
+ <table class="table table-bordered table-striped">
15
+ <thead>
16
+ <tr>
17
+ <th class="span2">Name</th>
18
+ <th>Component</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <tr>
23
+ <td>Default</td>
24
+ <td id="default">
25
+ <div class="dropdown">
26
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">
27
+ Select option
28
+ <span class="caret"></span>
29
+ </a>
30
+ <ul class="dropdown-menu">
31
+ <li>
32
+ <a href="#1">Option 1</a>
33
+ </li>
34
+ <li>
35
+ <a href="#2">Option 2</a>
36
+ </li>
37
+ </ul>
38
+ </div>
39
+ </td>
40
+ </tr>
41
+ <tr>
42
+ <td>Image</td>
43
+ <td id="image">
44
+ <div class="dropdown">
45
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">
46
+ Select option
47
+ <span class="caret"></span>
48
+ </a>
49
+ <ul class="dropdown-menu">
50
+ <li>
51
+ <a href="#1">
52
+ <i class="icon-search"></i>
53
+ Option 1
54
+ </a>
55
+ </li>
56
+ <li>
57
+ <a href="#2">
58
+ <i class="icon-star"></i>
59
+ Option 2
60
+ </a>
61
+ </li>
62
+ </ul>
63
+ </div>
64
+ </td>
65
+ </tr>
66
+ <tr>
67
+ <td>Divider</td>
68
+ <td id="divider">
69
+ <div class="dropdown">
70
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">
71
+ Select option
72
+ <span class="caret"></span>
73
+ </a>
74
+ <ul class="dropdown-menu">
75
+ <li>
76
+ <a href="#1">Option 1</a>
77
+ </li>
78
+ <li class="divider">
79
+ <li>
80
+ <a href="#2">Option 2</a>
81
+ </li>
82
+ </ul>
83
+ </div>
84
+ </td>
85
+ </tr>
86
+ <tr>
87
+ <td>Nav Item</td>
88
+ <td id="nav_item">
89
+ <li class="dropdown">
90
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">
91
+ Select option
92
+ <span class="caret"></span>
93
+ </a>
94
+ <ul class="dropdown-menu">
95
+ <li>
96
+ <a href="#1">Option 1</a>
97
+ </li>
98
+ <li>
99
+ <a href="#2">Option 2</a>
100
+ </li>
101
+ </ul>
102
+ </li>
103
+ </td>
104
+ </tr>
105
+ </tbody>
106
+ </table>
107
+ <a href="index.html">back to index</a>
108
+ </div>
109
+ <script src="js/jquery-1.7.2.js" type="text/javascript"></script>
110
+ <script src="js/bootstrap.js" type="text/javascript"></script>
111
+ </body>
112
+ </html>
data/markup/index.html CHANGED
@@ -11,26 +11,28 @@
11
11
  <body>
12
12
  <div class="container">
13
13
  <h2>Componentes</h2>
14
- <p><a href="grid_system.html">Grid system</a></p>
14
+ <p><a href="alerts.html">Alerts</a></p>
15
+ <p><a href="badges.html">Badges</a></p>
16
+ <p><a href="breadcrumbs.html">Breadcrumbs</a></p>
15
17
  <p><a href="buttons.html">Buttons</a></p>
16
- <p><a href="link_buttons.html">Link Buttons</a></p>
18
+ <p><a href="control_groups.html">Control group</a></p>
17
19
  <p><a href="dropdown_buttons.html">Dropdown Buttons</a></p>
18
- <p><a href="alerts.html">Alerts</a></p>
20
+ <p><a href="dropdown_links.html">Dropdown Links</a></p>
19
21
  <p><a href="forms.html">Forms</a></p>
20
- <p><a href="control_groups.html">Control group</a></p>
21
- <p><a href="selects.html">Selects</a></p>
22
- <p><a href="textboxes.html">Texboxes</a></p>
23
22
  <p><a href="form_fields.html">Form fields</a></p>
24
- <p><a href="nav_lists.html">Nav Lists</a></p>
25
- <p><a href="nav_bars.html">Nav Bars</a></p>
23
+ <p><a href="grid_system.html">Grid system</a></p>
26
24
  <p><a href="labels.html">Labels</a></p>
27
- <p><a href="badges.html">Badges</a></p>
28
- <p><a href="breadcrumbs.html">Breadcrumbs</a></p>
25
+ <p><a href="link_buttons.html">Link Buttons</a></p>
26
+ <p><a href="nav_bars.html">Nav Bars</a></p>
27
+ <p><a href="nav_lists.html">Nav Lists</a></p>
29
28
  <p><a href="paginations.html">Paginations</a></p>
30
- <p><a href="progress_bars.html">Progress bars</a></p>
31
- <p><a href="tooltips.html">Tooltips</a></p>
32
29
  <p><a href="popovers.html">Popovers</a></p>
30
+ <p><a href="progress_bars.html">Progress bars</a></p>
31
+ <p><a href="selects.html">Selects</a></p>
33
32
  <p><a href="tabs.html">Tabs</a></p>
33
+ <p><a href="textareas.html">Textareas</a></p>
34
+ <p><a href="textboxes.html">Textboxes</a></p>
35
+ <p><a href="tooltips.html">Tooltips</a></p>
34
36
  </div>
35
37
  <script src="js/bootstrap.js" type="text/javascript"></script>
36
38
  </body>
@@ -58,10 +58,11 @@
58
58
 
59
59
  })
60
60
 
61
- }(window.jQuery);/* ==========================================================
62
- * bootstrap-alert.js v2.0.4
63
- * http://twitter.github.com/bootstrap/javascript.html#alerts
64
- * ==========================================================
61
+ }(window.jQuery);
62
+ /* =========================================================
63
+ * bootstrap-modal.js v2.0.4
64
+ * http://twitter.github.com/bootstrap/javascript.html#modals
65
+ * =========================================================
65
66
  * Copyright 2012 Twitter, Inc.
66
67
  *
67
68
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -75,7 +76,7 @@
75
76
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76
77
  * See the License for the specific language governing permissions and
77
78
  * limitations under the License.
78
- * ========================================================== */
79
+ * ========================================================= */
79
80
 
80
81
 
81
82
  !function ($) {
@@ -83,73 +84,202 @@
83
84
  "use strict"; // jshint ;_;
84
85
 
85
86
 
86
- /* ALERT CLASS DEFINITION
87
+ /* MODAL CLASS DEFINITION
87
88
  * ====================== */
88
89
 
89
- var dismiss = '[data-dismiss="alert"]'
90
- , Alert = function (el) {
91
- $(el).on('click', dismiss, this.close)
90
+ var Modal = function (content, options) {
91
+ this.options = options
92
+ this.$element = $(content)
93
+ .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
94
+ }
95
+
96
+ Modal.prototype = {
97
+
98
+ constructor: Modal
99
+
100
+ , toggle: function () {
101
+ return this[!this.isShown ? 'show' : 'hide']()
92
102
  }
93
103
 
94
- Alert.prototype.close = function (e) {
95
- var $this = $(this)
96
- , selector = $this.attr('data-target')
97
- , $parent
104
+ , show: function () {
105
+ var that = this
106
+ , e = $.Event('show')
98
107
 
99
- if (!selector) {
100
- selector = $this.attr('href')
101
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
102
- }
108
+ this.$element.trigger(e)
103
109
 
104
- $parent = $(selector)
110
+ if (this.isShown || e.isDefaultPrevented()) return
105
111
 
106
- e && e.preventDefault()
112
+ $('body').addClass('modal-open')
107
113
 
108
- $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
114
+ this.isShown = true
109
115
 
110
- $parent.trigger(e = $.Event('close'))
116
+ escape.call(this)
117
+ backdrop.call(this, function () {
118
+ var transition = $.support.transition && that.$element.hasClass('fade')
111
119
 
112
- if (e.isDefaultPrevented()) return
120
+ if (!that.$element.parent().length) {
121
+ that.$element.appendTo(document.body) //don't move modals dom position
122
+ }
113
123
 
114
- $parent.removeClass('in')
124
+ that.$element
125
+ .show()
115
126
 
116
- function removeElement() {
117
- $parent
118
- .trigger('closed')
119
- .remove()
127
+ if (transition) {
128
+ that.$element[0].offsetWidth // force reflow
129
+ }
130
+
131
+ that.$element.addClass('in')
132
+
133
+ transition ?
134
+ that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
135
+ that.$element.trigger('shown')
136
+
137
+ })
138
+ }
139
+
140
+ , hide: function (e) {
141
+ e && e.preventDefault()
142
+
143
+ var that = this
144
+
145
+ e = $.Event('hide')
146
+
147
+ this.$element.trigger(e)
148
+
149
+ if (!this.isShown || e.isDefaultPrevented()) return
150
+
151
+ this.isShown = false
152
+
153
+ $('body').removeClass('modal-open')
154
+
155
+ escape.call(this)
156
+
157
+ this.$element.removeClass('in')
158
+
159
+ $.support.transition && this.$element.hasClass('fade') ?
160
+ hideWithTransition.call(this) :
161
+ hideModal.call(this)
162
+ }
163
+
164
+ }
165
+
166
+
167
+ /* MODAL PRIVATE METHODS
168
+ * ===================== */
169
+
170
+ function hideWithTransition() {
171
+ var that = this
172
+ , timeout = setTimeout(function () {
173
+ that.$element.off($.support.transition.end)
174
+ hideModal.call(that)
175
+ }, 500)
176
+
177
+ this.$element.one($.support.transition.end, function () {
178
+ clearTimeout(timeout)
179
+ hideModal.call(that)
180
+ })
181
+ }
182
+
183
+ function hideModal(that) {
184
+ this.$element
185
+ .hide()
186
+ .trigger('hidden')
187
+
188
+ backdrop.call(this)
189
+ }
190
+
191
+ function backdrop(callback) {
192
+ var that = this
193
+ , animate = this.$element.hasClass('fade') ? 'fade' : ''
194
+
195
+ if (this.isShown && this.options.backdrop) {
196
+ var doAnimate = $.support.transition && animate
197
+
198
+ this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
199
+ .appendTo(document.body)
200
+
201
+ if (this.options.backdrop != 'static') {
202
+ this.$backdrop.click($.proxy(this.hide, this))
203
+ }
204
+
205
+ if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
206
+
207
+ this.$backdrop.addClass('in')
208
+
209
+ doAnimate ?
210
+ this.$backdrop.one($.support.transition.end, callback) :
211
+ callback()
212
+
213
+ } else if (!this.isShown && this.$backdrop) {
214
+ this.$backdrop.removeClass('in')
215
+
216
+ $.support.transition && this.$element.hasClass('fade')?
217
+ this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
218
+ removeBackdrop.call(this)
219
+
220
+ } else if (callback) {
221
+ callback()
120
222
  }
223
+ }
121
224
 
122
- $.support.transition && $parent.hasClass('fade') ?
123
- $parent.on($.support.transition.end, removeElement) :
124
- removeElement()
225
+ function removeBackdrop() {
226
+ this.$backdrop.remove()
227
+ this.$backdrop = null
228
+ }
229
+
230
+ function escape() {
231
+ var that = this
232
+ if (this.isShown && this.options.keyboard) {
233
+ $(document).on('keyup.dismiss.modal', function ( e ) {
234
+ e.which == 27 && that.hide()
235
+ })
236
+ } else if (!this.isShown) {
237
+ $(document).off('keyup.dismiss.modal')
238
+ }
125
239
  }
126
240
 
127
241
 
128
- /* ALERT PLUGIN DEFINITION
242
+ /* MODAL PLUGIN DEFINITION
129
243
  * ======================= */
130
244
 
131
- $.fn.alert = function (option) {
245
+ $.fn.modal = function (option) {
132
246
  return this.each(function () {
133
247
  var $this = $(this)
134
- , data = $this.data('alert')
135
- if (!data) $this.data('alert', (data = new Alert(this)))
136
- if (typeof option == 'string') data[option].call($this)
248
+ , data = $this.data('modal')
249
+ , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
250
+ if (!data) $this.data('modal', (data = new Modal(this, options)))
251
+ if (typeof option == 'string') data[option]()
252
+ else if (options.show) data.show()
137
253
  })
138
254
  }
139
255
 
140
- $.fn.alert.Constructor = Alert
256
+ $.fn.modal.defaults = {
257
+ backdrop: true
258
+ , keyboard: true
259
+ , show: true
260
+ }
141
261
 
262
+ $.fn.modal.Constructor = Modal
142
263
 
143
- /* ALERT DATA-API
264
+
265
+ /* MODAL DATA-API
144
266
  * ============== */
145
267
 
146
268
  $(function () {
147
- $('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
269
+ $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
270
+ var $this = $(this), href
271
+ , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
272
+ , option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
273
+
274
+ e.preventDefault()
275
+ $target.modal(option)
276
+ })
148
277
  })
149
278
 
150
- }(window.jQuery);/* ============================================================
151
- * bootstrap-button.js v2.0.4
152
- * http://twitter.github.com/bootstrap/javascript.html#buttons
279
+ }(window.jQuery);
280
+ /* ============================================================
281
+ * bootstrap-dropdown.js v2.0.4
282
+ * http://twitter.github.com/bootstrap/javascript.html#dropdowns
153
283
  * ============================================================
154
284
  * Copyright 2012 Twitter, Inc.
155
285
  *
@@ -172,80 +302,85 @@
172
302
  "use strict"; // jshint ;_;
173
303
 
174
304
 
175
- /* BUTTON PUBLIC CLASS DEFINITION
176
- * ============================== */
305
+ /* DROPDOWN CLASS DEFINITION
306
+ * ========================= */
177
307
 
178
- var Button = function (element, options) {
179
- this.$element = $(element)
180
- this.options = $.extend({}, $.fn.button.defaults, options)
181
- }
308
+ var toggle = '[data-toggle="dropdown"]'
309
+ , Dropdown = function (element) {
310
+ var $el = $(element).on('click.dropdown.data-api', this.toggle)
311
+ $('html').on('click.dropdown.data-api', function () {
312
+ $el.parent().removeClass('open')
313
+ })
314
+ }
182
315
 
183
- Button.prototype.setState = function (state) {
184
- var d = 'disabled'
185
- , $el = this.$element
186
- , data = $el.data()
187
- , val = $el.is('input') ? 'val' : 'html'
316
+ Dropdown.prototype = {
188
317
 
189
- state = state + 'Text'
190
- data.resetText || $el.data('resetText', $el[val]())
318
+ constructor: Dropdown
191
319
 
192
- $el[val](data[state] || this.options[state])
320
+ , toggle: function (e) {
321
+ var $this = $(this)
322
+ , $parent
323
+ , selector
324
+ , isActive
193
325
 
194
- // push to event loop to allow forms to submit
195
- setTimeout(function () {
196
- state == 'loadingText' ?
197
- $el.addClass(d).attr(d, d) :
198
- $el.removeClass(d).removeAttr(d)
199
- }, 0)
200
- }
326
+ if ($this.is('.disabled, :disabled')) return
201
327
 
202
- Button.prototype.toggle = function () {
203
- var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
328
+ selector = $this.attr('data-target')
204
329
 
205
- $parent && $parent
206
- .find('.active')
207
- .removeClass('active')
330
+ if (!selector) {
331
+ selector = $this.attr('href')
332
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
333
+ }
208
334
 
209
- this.$element.toggleClass('active')
335
+ $parent = $(selector)
336
+ $parent.length || ($parent = $this.parent())
337
+
338
+ isActive = $parent.hasClass('open')
339
+
340
+ clearMenus()
341
+
342
+ if (!isActive) $parent.toggleClass('open')
343
+
344
+ return false
345
+ }
346
+
347
+ }
348
+
349
+ function clearMenus() {
350
+ $(toggle).parent().removeClass('open')
210
351
  }
211
352
 
212
353
 
213
- /* BUTTON PLUGIN DEFINITION
214
- * ======================== */
354
+ /* DROPDOWN PLUGIN DEFINITION
355
+ * ========================== */
215
356
 
216
- $.fn.button = function (option) {
357
+ $.fn.dropdown = function (option) {
217
358
  return this.each(function () {
218
359
  var $this = $(this)
219
- , data = $this.data('button')
220
- , options = typeof option == 'object' && option
221
- if (!data) $this.data('button', (data = new Button(this, options)))
222
- if (option == 'toggle') data.toggle()
223
- else if (option) data.setState(option)
360
+ , data = $this.data('dropdown')
361
+ if (!data) $this.data('dropdown', (data = new Dropdown(this)))
362
+ if (typeof option == 'string') data[option].call($this)
224
363
  })
225
364
  }
226
365
 
227
- $.fn.button.defaults = {
228
- loadingText: 'loading...'
229
- }
230
-
231
- $.fn.button.Constructor = Button
366
+ $.fn.dropdown.Constructor = Dropdown
232
367
 
233
368
 
234
- /* BUTTON DATA-API
235
- * =============== */
369
+ /* APPLY TO STANDARD DROPDOWN ELEMENTS
370
+ * =================================== */
236
371
 
237
372
  $(function () {
238
- $('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
239
- var $btn = $(e.target)
240
- if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
241
- $btn.button('toggle')
242
- })
373
+ $('html').on('click.dropdown.data-api', clearMenus)
374
+ $('body')
375
+ .on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() })
376
+ .on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
243
377
  })
244
378
 
245
- }(window.jQuery);/* ==========================================================
246
- * bootstrap-carousel.js v2.0.4
247
- * http://twitter.github.com/bootstrap/javascript.html#carousel
248
- * ==========================================================
379
+ }(window.jQuery);
380
+ /* =============================================================
381
+ * bootstrap-scrollspy.js v2.0.4
382
+ * http://twitter.github.com/bootstrap/javascript.html#scrollspy
383
+ * =============================================================
249
384
  * Copyright 2012 Twitter, Inc.
250
385
  *
251
386
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -259,7 +394,7 @@
259
394
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
260
395
  * See the License for the specific language governing permissions and
261
396
  * limitations under the License.
262
- * ========================================================== */
397
+ * ============================================================== */
263
398
 
264
399
 
265
400
  !function ($) {
@@ -267,153 +402,136 @@
267
402
  "use strict"; // jshint ;_;
268
403
 
269
404
 
270
- /* CAROUSEL CLASS DEFINITION
271
- * ========================= */
405
+ /* SCROLLSPY CLASS DEFINITION
406
+ * ========================== */
272
407
 
273
- var Carousel = function (element, options) {
274
- this.$element = $(element)
275
- this.options = options
276
- this.options.slide && this.slide(this.options.slide)
277
- this.options.pause == 'hover' && this.$element
278
- .on('mouseenter', $.proxy(this.pause, this))
279
- .on('mouseleave', $.proxy(this.cycle, this))
408
+ function ScrollSpy( element, options) {
409
+ var process = $.proxy(this.process, this)
410
+ , $element = $(element).is('body') ? $(window) : $(element)
411
+ , href
412
+ this.options = $.extend({}, $.fn.scrollspy.defaults, options)
413
+ this.$scrollElement = $element.on('scroll.scroll.data-api', process)
414
+ this.selector = (this.options.target
415
+ || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
416
+ || '') + ' .nav li > a'
417
+ this.$body = $('body')
418
+ this.refresh()
419
+ this.process()
280
420
  }
281
421
 
282
- Carousel.prototype = {
283
-
284
- cycle: function (e) {
285
- if (!e) this.paused = false
286
- this.options.interval
287
- && !this.paused
288
- && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
289
- return this
290
- }
422
+ ScrollSpy.prototype = {
291
423
 
292
- , to: function (pos) {
293
- var $active = this.$element.find('.active')
294
- , children = $active.parent().children()
295
- , activePos = children.index($active)
296
- , that = this
424
+ constructor: ScrollSpy
297
425
 
298
- if (pos > (children.length - 1) || pos < 0) return
426
+ , refresh: function () {
427
+ var self = this
428
+ , $targets
299
429
 
300
- if (this.sliding) {
301
- return this.$element.one('slid', function () {
302
- that.to(pos)
303
- })
304
- }
430
+ this.offsets = $([])
431
+ this.targets = $([])
305
432
 
306
- if (activePos == pos) {
307
- return this.pause().cycle()
433
+ $targets = this.$body
434
+ .find(this.selector)
435
+ .map(function () {
436
+ var $el = $(this)
437
+ , href = $el.data('target') || $el.attr('href')
438
+ , $href = /^#\w/.test(href) && $(href)
439
+ return ( $href
440
+ && href.length
441
+ && [[ $href.position().top, href ]] ) || null
442
+ })
443
+ .sort(function (a, b) { return a[0] - b[0] })
444
+ .each(function () {
445
+ self.offsets.push(this[0])
446
+ self.targets.push(this[1])
447
+ })
308
448
  }
309
449
 
310
- return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
311
- }
450
+ , process: function () {
451
+ var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
452
+ , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
453
+ , maxScroll = scrollHeight - this.$scrollElement.height()
454
+ , offsets = this.offsets
455
+ , targets = this.targets
456
+ , activeTarget = this.activeTarget
457
+ , i
312
458
 
313
- , pause: function (e) {
314
- if (!e) this.paused = true
315
- clearInterval(this.interval)
316
- this.interval = null
317
- return this
318
- }
459
+ if (scrollTop >= maxScroll) {
460
+ return activeTarget != (i = targets.last()[0])
461
+ && this.activate ( i )
462
+ }
319
463
 
320
- , next: function () {
321
- if (this.sliding) return
322
- return this.slide('next')
323
- }
464
+ for (i = offsets.length; i--;) {
465
+ activeTarget != targets[i]
466
+ && scrollTop >= offsets[i]
467
+ && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
468
+ && this.activate( targets[i] )
469
+ }
470
+ }
324
471
 
325
- , prev: function () {
326
- if (this.sliding) return
327
- return this.slide('prev')
328
- }
472
+ , activate: function (target) {
473
+ var active
474
+ , selector
329
475
 
330
- , slide: function (type, next) {
331
- var $active = this.$element.find('.active')
332
- , $next = next || $active[type]()
333
- , isCycling = this.interval
334
- , direction = type == 'next' ? 'left' : 'right'
335
- , fallback = type == 'next' ? 'first' : 'last'
336
- , that = this
337
- , e = $.Event('slide')
476
+ this.activeTarget = target
338
477
 
339
- this.sliding = true
478
+ $(this.selector)
479
+ .parent('.active')
480
+ .removeClass('active')
340
481
 
341
- isCycling && this.pause()
482
+ selector = this.selector
483
+ + '[data-target="' + target + '"],'
484
+ + this.selector + '[href="' + target + '"]'
342
485
 
343
- $next = $next.length ? $next : this.$element.find('.item')[fallback]()
486
+ active = $(selector)
487
+ .parent('li')
488
+ .addClass('active')
344
489
 
345
- if ($next.hasClass('active')) return
490
+ if (active.parent('.dropdown-menu')) {
491
+ active = active.closest('li.dropdown').addClass('active')
492
+ }
346
493
 
347
- if ($.support.transition && this.$element.hasClass('slide')) {
348
- this.$element.trigger(e)
349
- if (e.isDefaultPrevented()) return
350
- $next.addClass(type)
351
- $next[0].offsetWidth // force reflow
352
- $active.addClass(direction)
353
- $next.addClass(direction)
354
- this.$element.one($.support.transition.end, function () {
355
- $next.removeClass([type, direction].join(' ')).addClass('active')
356
- $active.removeClass(['active', direction].join(' '))
357
- that.sliding = false
358
- setTimeout(function () { that.$element.trigger('slid') }, 0)
359
- })
360
- } else {
361
- this.$element.trigger(e)
362
- if (e.isDefaultPrevented()) return
363
- $active.removeClass('active')
364
- $next.addClass('active')
365
- this.sliding = false
366
- this.$element.trigger('slid')
494
+ active.trigger('activate')
367
495
  }
368
496
 
369
- isCycling && this.cycle()
370
-
371
- return this
372
- }
373
-
374
497
  }
375
498
 
376
499
 
377
- /* CAROUSEL PLUGIN DEFINITION
378
- * ========================== */
500
+ /* SCROLLSPY PLUGIN DEFINITION
501
+ * =========================== */
379
502
 
380
- $.fn.carousel = function (option) {
503
+ $.fn.scrollspy = function ( option ) {
381
504
  return this.each(function () {
382
505
  var $this = $(this)
383
- , data = $this.data('carousel')
384
- , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
385
- if (!data) $this.data('carousel', (data = new Carousel(this, options)))
386
- if (typeof option == 'number') data.to(option)
387
- else if (typeof option == 'string' || (option = options.slide)) data[option]()
388
- else if (options.interval) data.cycle()
506
+ , data = $this.data('scrollspy')
507
+ , options = typeof option == 'object' && option
508
+ if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
509
+ if (typeof option == 'string') data[option]()
389
510
  })
390
511
  }
391
512
 
392
- $.fn.carousel.defaults = {
393
- interval: 5000
394
- , pause: 'hover'
395
- }
513
+ $.fn.scrollspy.Constructor = ScrollSpy
396
514
 
397
- $.fn.carousel.Constructor = Carousel
515
+ $.fn.scrollspy.defaults = {
516
+ offset: 10
517
+ }
398
518
 
399
519
 
400
- /* CAROUSEL DATA-API
401
- * ================= */
520
+ /* SCROLLSPY DATA-API
521
+ * ================== */
402
522
 
403
523
  $(function () {
404
- $('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
405
- var $this = $(this), href
406
- , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
407
- , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
408
- $target.carousel(options)
409
- e.preventDefault()
524
+ $('[data-spy="scroll"]').each(function () {
525
+ var $spy = $(this)
526
+ $spy.scrollspy($spy.data())
410
527
  })
411
528
  })
412
529
 
413
- }(window.jQuery);/* =============================================================
414
- * bootstrap-collapse.js v2.0.4
415
- * http://twitter.github.com/bootstrap/javascript.html#collapse
416
- * =============================================================
530
+ }(window.jQuery);
531
+ /* ========================================================
532
+ * bootstrap-tab.js v2.0.4
533
+ * http://twitter.github.com/bootstrap/javascript.html#tabs
534
+ * ========================================================
417
535
  * Copyright 2012 Twitter, Inc.
418
536
  *
419
537
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -427,7 +545,7 @@
427
545
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
428
546
  * See the License for the specific language governing permissions and
429
547
  * limitations under the License.
430
- * ============================================================ */
548
+ * ======================================================== */
431
549
 
432
550
 
433
551
  !function ($) {
@@ -435,454 +553,117 @@
435
553
  "use strict"; // jshint ;_;
436
554
 
437
555
 
438
- /* COLLAPSE PUBLIC CLASS DEFINITION
439
- * ================================ */
440
-
441
- var Collapse = function (element, options) {
442
- this.$element = $(element)
443
- this.options = $.extend({}, $.fn.collapse.defaults, options)
444
-
445
- if (this.options.parent) {
446
- this.$parent = $(this.options.parent)
447
- }
556
+ /* TAB CLASS DEFINITION
557
+ * ==================== */
448
558
 
449
- this.options.toggle && this.toggle()
559
+ var Tab = function ( element ) {
560
+ this.element = $(element)
450
561
  }
451
562
 
452
- Collapse.prototype = {
453
-
454
- constructor: Collapse
563
+ Tab.prototype = {
455
564
 
456
- , dimension: function () {
457
- var hasWidth = this.$element.hasClass('width')
458
- return hasWidth ? 'width' : 'height'
459
- }
565
+ constructor: Tab
460
566
 
461
567
  , show: function () {
462
- var dimension
463
- , scroll
464
- , actives
465
- , hasData
466
-
467
- if (this.transitioning) return
468
-
469
- dimension = this.dimension()
470
- scroll = $.camelCase(['scroll', dimension].join('-'))
471
- actives = this.$parent && this.$parent.find('> .accordion-group > .in')
472
-
473
- if (actives && actives.length) {
474
- hasData = actives.data('collapse')
475
- if (hasData && hasData.transitioning) return
476
- actives.collapse('hide')
477
- hasData || actives.data('collapse', null)
478
- }
479
-
480
- this.$element[dimension](0)
481
- this.transition('addClass', $.Event('show'), 'shown')
482
- this.$element[dimension](this.$element[0][scroll])
483
- }
484
-
485
- , hide: function () {
486
- var dimension
487
- if (this.transitioning) return
488
- dimension = this.dimension()
489
- this.reset(this.$element[dimension]())
490
- this.transition('removeClass', $.Event('hide'), 'hidden')
491
- this.$element[dimension](0)
492
- }
493
-
494
- , reset: function (size) {
495
- var dimension = this.dimension()
496
-
497
- this.$element
498
- .removeClass('collapse')
499
- [dimension](size || 'auto')
500
- [0].offsetWidth
501
-
502
- this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
503
-
504
- return this
505
- }
506
-
507
- , transition: function (method, startEvent, completeEvent) {
508
- var that = this
509
- , complete = function () {
510
- if (startEvent.type == 'show') that.reset()
511
- that.transitioning = 0
512
- that.$element.trigger(completeEvent)
513
- }
514
-
515
- this.$element.trigger(startEvent)
516
-
517
- if (startEvent.isDefaultPrevented()) return
518
-
519
- this.transitioning = 1
520
-
521
- this.$element[method]('in')
522
-
523
- $.support.transition && this.$element.hasClass('collapse') ?
524
- this.$element.one($.support.transition.end, complete) :
525
- complete()
526
- }
527
-
528
- , toggle: function () {
529
- this[this.$element.hasClass('in') ? 'hide' : 'show']()
530
- }
531
-
532
- }
533
-
534
-
535
- /* COLLAPSIBLE PLUGIN DEFINITION
536
- * ============================== */
537
-
538
- $.fn.collapse = function (option) {
539
- return this.each(function () {
540
- var $this = $(this)
541
- , data = $this.data('collapse')
542
- , options = typeof option == 'object' && option
543
- if (!data) $this.data('collapse', (data = new Collapse(this, options)))
544
- if (typeof option == 'string') data[option]()
545
- })
546
- }
547
-
548
- $.fn.collapse.defaults = {
549
- toggle: true
550
- }
551
-
552
- $.fn.collapse.Constructor = Collapse
553
-
554
-
555
- /* COLLAPSIBLE DATA-API
556
- * ==================== */
557
-
558
- $(function () {
559
- $('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) {
560
- var $this = $(this), href
561
- , target = $this.attr('data-target')
562
- || e.preventDefault()
563
- || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
564
- , option = $(target).data('collapse') ? 'toggle' : $this.data()
565
- $(target).collapse(option)
566
- })
567
- })
568
-
569
- }(window.jQuery);/* ============================================================
570
- * bootstrap-dropdown.js v2.0.4
571
- * http://twitter.github.com/bootstrap/javascript.html#dropdowns
572
- * ============================================================
573
- * Copyright 2012 Twitter, Inc.
574
- *
575
- * Licensed under the Apache License, Version 2.0 (the "License");
576
- * you may not use this file except in compliance with the License.
577
- * You may obtain a copy of the License at
578
- *
579
- * http://www.apache.org/licenses/LICENSE-2.0
580
- *
581
- * Unless required by applicable law or agreed to in writing, software
582
- * distributed under the License is distributed on an "AS IS" BASIS,
583
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
584
- * See the License for the specific language governing permissions and
585
- * limitations under the License.
586
- * ============================================================ */
587
-
588
-
589
- !function ($) {
590
-
591
- "use strict"; // jshint ;_;
592
-
593
-
594
- /* DROPDOWN CLASS DEFINITION
595
- * ========================= */
596
-
597
- var toggle = '[data-toggle="dropdown"]'
598
- , Dropdown = function (element) {
599
- var $el = $(element).on('click.dropdown.data-api', this.toggle)
600
- $('html').on('click.dropdown.data-api', function () {
601
- $el.parent().removeClass('open')
602
- })
603
- }
604
-
605
- Dropdown.prototype = {
606
-
607
- constructor: Dropdown
608
-
609
- , toggle: function (e) {
610
- var $this = $(this)
611
- , $parent
612
- , selector
613
- , isActive
614
-
615
- if ($this.is('.disabled, :disabled')) return
616
-
617
- selector = $this.attr('data-target')
568
+ var $this = this.element
569
+ , $ul = $this.closest('ul:not(.dropdown-menu)')
570
+ , selector = $this.attr('data-target')
571
+ , previous
572
+ , $target
573
+ , e
618
574
 
619
575
  if (!selector) {
620
576
  selector = $this.attr('href')
621
577
  selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
622
578
  }
623
579
 
624
- $parent = $(selector)
625
- $parent.length || ($parent = $this.parent())
626
-
627
- isActive = $parent.hasClass('open')
628
-
629
- clearMenus()
630
-
631
- if (!isActive) $parent.toggleClass('open')
632
-
633
- return false
634
- }
635
-
636
- }
637
-
638
- function clearMenus() {
639
- $(toggle).parent().removeClass('open')
640
- }
641
-
642
-
643
- /* DROPDOWN PLUGIN DEFINITION
644
- * ========================== */
645
-
646
- $.fn.dropdown = function (option) {
647
- return this.each(function () {
648
- var $this = $(this)
649
- , data = $this.data('dropdown')
650
- if (!data) $this.data('dropdown', (data = new Dropdown(this)))
651
- if (typeof option == 'string') data[option].call($this)
652
- })
653
- }
654
-
655
- $.fn.dropdown.Constructor = Dropdown
656
-
657
-
658
- /* APPLY TO STANDARD DROPDOWN ELEMENTS
659
- * =================================== */
660
-
661
- $(function () {
662
- $('html').on('click.dropdown.data-api', clearMenus)
663
- $('body')
664
- .on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() })
665
- .on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
666
- })
667
-
668
- }(window.jQuery);/* =========================================================
669
- * bootstrap-modal.js v2.0.4
670
- * http://twitter.github.com/bootstrap/javascript.html#modals
671
- * =========================================================
672
- * Copyright 2012 Twitter, Inc.
673
- *
674
- * Licensed under the Apache License, Version 2.0 (the "License");
675
- * you may not use this file except in compliance with the License.
676
- * You may obtain a copy of the License at
677
- *
678
- * http://www.apache.org/licenses/LICENSE-2.0
679
- *
680
- * Unless required by applicable law or agreed to in writing, software
681
- * distributed under the License is distributed on an "AS IS" BASIS,
682
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
683
- * See the License for the specific language governing permissions and
684
- * limitations under the License.
685
- * ========================================================= */
686
-
687
-
688
- !function ($) {
689
-
690
- "use strict"; // jshint ;_;
691
-
692
-
693
- /* MODAL CLASS DEFINITION
694
- * ====================== */
695
-
696
- var Modal = function (content, options) {
697
- this.options = options
698
- this.$element = $(content)
699
- .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
700
- }
701
-
702
- Modal.prototype = {
703
-
704
- constructor: Modal
705
-
706
- , toggle: function () {
707
- return this[!this.isShown ? 'show' : 'hide']()
708
- }
709
-
710
- , show: function () {
711
- var that = this
712
- , e = $.Event('show')
713
-
714
- this.$element.trigger(e)
715
-
716
- if (this.isShown || e.isDefaultPrevented()) return
717
-
718
- $('body').addClass('modal-open')
719
-
720
- this.isShown = true
721
-
722
- escape.call(this)
723
- backdrop.call(this, function () {
724
- var transition = $.support.transition && that.$element.hasClass('fade')
580
+ if ( $this.parent('li').hasClass('active') ) return
725
581
 
726
- if (!that.$element.parent().length) {
727
- that.$element.appendTo(document.body) //don't move modals dom position
728
- }
582
+ previous = $ul.find('.active a').last()[0]
729
583
 
730
- that.$element
731
- .show()
584
+ e = $.Event('show', {
585
+ relatedTarget: previous
586
+ })
732
587
 
733
- if (transition) {
734
- that.$element[0].offsetWidth // force reflow
735
- }
588
+ $this.trigger(e)
736
589
 
737
- that.$element.addClass('in')
590
+ if (e.isDefaultPrevented()) return
738
591
 
739
- transition ?
740
- that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
741
- that.$element.trigger('shown')
592
+ $target = $(selector)
742
593
 
594
+ this.activate($this.parent('li'), $ul)
595
+ this.activate($target, $target.parent(), function () {
596
+ $this.trigger({
597
+ type: 'shown'
598
+ , relatedTarget: previous
743
599
  })
744
- }
745
-
746
- , hide: function (e) {
747
- e && e.preventDefault()
748
-
749
- var that = this
750
-
751
- e = $.Event('hide')
752
-
753
- this.$element.trigger(e)
754
-
755
- if (!this.isShown || e.isDefaultPrevented()) return
756
-
757
- this.isShown = false
758
-
759
- $('body').removeClass('modal-open')
760
-
761
- escape.call(this)
762
-
763
- this.$element.removeClass('in')
764
-
765
- $.support.transition && this.$element.hasClass('fade') ?
766
- hideWithTransition.call(this) :
767
- hideModal.call(this)
768
- }
769
-
770
- }
771
-
772
-
773
- /* MODAL PRIVATE METHODS
774
- * ===================== */
775
-
776
- function hideWithTransition() {
777
- var that = this
778
- , timeout = setTimeout(function () {
779
- that.$element.off($.support.transition.end)
780
- hideModal.call(that)
781
- }, 500)
782
-
783
- this.$element.one($.support.transition.end, function () {
784
- clearTimeout(timeout)
785
- hideModal.call(that)
786
- })
787
- }
788
-
789
- function hideModal(that) {
790
- this.$element
791
- .hide()
792
- .trigger('hidden')
793
-
794
- backdrop.call(this)
795
- }
796
-
797
- function backdrop(callback) {
798
- var that = this
799
- , animate = this.$element.hasClass('fade') ? 'fade' : ''
800
-
801
- if (this.isShown && this.options.backdrop) {
802
- var doAnimate = $.support.transition && animate
803
-
804
- this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
805
- .appendTo(document.body)
806
-
807
- if (this.options.backdrop != 'static') {
808
- this.$backdrop.click($.proxy(this.hide, this))
809
- }
600
+ })
601
+ }
810
602
 
811
- if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
603
+ , activate: function ( element, container, callback) {
604
+ var $active = container.find('> .active')
605
+ , transition = callback
606
+ && $.support.transition
607
+ && $active.hasClass('fade')
812
608
 
813
- this.$backdrop.addClass('in')
609
+ function next() {
610
+ $active
611
+ .removeClass('active')
612
+ .find('> .dropdown-menu > .active')
613
+ .removeClass('active')
814
614
 
815
- doAnimate ?
816
- this.$backdrop.one($.support.transition.end, callback) :
817
- callback()
615
+ element.addClass('active')
818
616
 
819
- } else if (!this.isShown && this.$backdrop) {
820
- this.$backdrop.removeClass('in')
617
+ if (transition) {
618
+ element[0].offsetWidth // reflow for transition
619
+ element.addClass('in')
620
+ } else {
621
+ element.removeClass('fade')
622
+ }
821
623
 
822
- $.support.transition && this.$element.hasClass('fade')?
823
- this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
824
- removeBackdrop.call(this)
624
+ if ( element.parent('.dropdown-menu') ) {
625
+ element.closest('li.dropdown').addClass('active')
626
+ }
825
627
 
826
- } else if (callback) {
827
- callback()
828
- }
829
- }
628
+ callback && callback()
629
+ }
830
630
 
831
- function removeBackdrop() {
832
- this.$backdrop.remove()
833
- this.$backdrop = null
834
- }
631
+ transition ?
632
+ $active.one($.support.transition.end, next) :
633
+ next()
835
634
 
836
- function escape() {
837
- var that = this
838
- if (this.isShown && this.options.keyboard) {
839
- $(document).on('keyup.dismiss.modal', function ( e ) {
840
- e.which == 27 && that.hide()
841
- })
842
- } else if (!this.isShown) {
843
- $(document).off('keyup.dismiss.modal')
635
+ $active.removeClass('in')
844
636
  }
845
637
  }
846
638
 
847
639
 
848
- /* MODAL PLUGIN DEFINITION
849
- * ======================= */
640
+ /* TAB PLUGIN DEFINITION
641
+ * ===================== */
850
642
 
851
- $.fn.modal = function (option) {
643
+ $.fn.tab = function ( option ) {
852
644
  return this.each(function () {
853
645
  var $this = $(this)
854
- , data = $this.data('modal')
855
- , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
856
- if (!data) $this.data('modal', (data = new Modal(this, options)))
646
+ , data = $this.data('tab')
647
+ if (!data) $this.data('tab', (data = new Tab(this)))
857
648
  if (typeof option == 'string') data[option]()
858
- else if (options.show) data.show()
859
649
  })
860
650
  }
861
651
 
862
- $.fn.modal.defaults = {
863
- backdrop: true
864
- , keyboard: true
865
- , show: true
866
- }
867
-
868
- $.fn.modal.Constructor = Modal
652
+ $.fn.tab.Constructor = Tab
869
653
 
870
654
 
871
- /* MODAL DATA-API
872
- * ============== */
655
+ /* TAB DATA-API
656
+ * ============ */
873
657
 
874
658
  $(function () {
875
- $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
876
- var $this = $(this), href
877
- , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
878
- , option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
879
-
659
+ $('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
880
660
  e.preventDefault()
881
- $target.modal(option)
661
+ $(this).tab('show')
882
662
  })
883
663
  })
884
664
 
885
- }(window.jQuery);/* ===========================================================
665
+ }(window.jQuery);
666
+ /* ===========================================================
886
667
  * bootstrap-tooltip.js v2.0.4
887
668
  * http://twitter.github.com/bootstrap/javascript.html#tooltips
888
669
  * Inspired by the original jQuery.tipsy by Jason Frame
@@ -1131,36 +912,225 @@
1131
912
  }
1132
913
 
1133
914
 
1134
- /* TOOLTIP PLUGIN DEFINITION
1135
- * ========================= */
915
+ /* TOOLTIP PLUGIN DEFINITION
916
+ * ========================= */
917
+
918
+ $.fn.tooltip = function ( option ) {
919
+ return this.each(function () {
920
+ var $this = $(this)
921
+ , data = $this.data('tooltip')
922
+ , options = typeof option == 'object' && option
923
+ if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
924
+ if (typeof option == 'string') data[option]()
925
+ })
926
+ }
927
+
928
+ $.fn.tooltip.Constructor = Tooltip
929
+
930
+ $.fn.tooltip.defaults = {
931
+ animation: true
932
+ , placement: 'top'
933
+ , selector: false
934
+ , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
935
+ , trigger: 'hover'
936
+ , title: ''
937
+ , delay: 0
938
+ }
939
+
940
+ }(window.jQuery);
941
+
942
+ /* ===========================================================
943
+ * bootstrap-popover.js v2.0.4
944
+ * http://twitter.github.com/bootstrap/javascript.html#popovers
945
+ * ===========================================================
946
+ * Copyright 2012 Twitter, Inc.
947
+ *
948
+ * Licensed under the Apache License, Version 2.0 (the "License");
949
+ * you may not use this file except in compliance with the License.
950
+ * You may obtain a copy of the License at
951
+ *
952
+ * http://www.apache.org/licenses/LICENSE-2.0
953
+ *
954
+ * Unless required by applicable law or agreed to in writing, software
955
+ * distributed under the License is distributed on an "AS IS" BASIS,
956
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
957
+ * See the License for the specific language governing permissions and
958
+ * limitations under the License.
959
+ * =========================================================== */
960
+
961
+
962
+ !function ($) {
963
+
964
+ "use strict"; // jshint ;_;
965
+
966
+
967
+ /* POPOVER PUBLIC CLASS DEFINITION
968
+ * =============================== */
969
+
970
+ var Popover = function ( element, options ) {
971
+ this.init('popover', element, options)
972
+ }
973
+
974
+
975
+ /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
976
+ ========================================== */
977
+
978
+ Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
979
+
980
+ constructor: Popover
981
+
982
+ , setContent: function () {
983
+ var $tip = this.tip()
984
+ , title = this.getTitle()
985
+ , content = this.getContent()
986
+
987
+ $tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
988
+ $tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
989
+
990
+ $tip.removeClass('fade top bottom left right in')
991
+ }
992
+
993
+ , hasContent: function () {
994
+ return this.getTitle() || this.getContent()
995
+ }
996
+
997
+ , getContent: function () {
998
+ var content
999
+ , $e = this.$element
1000
+ , o = this.options
1001
+
1002
+ content = $e.attr('data-content')
1003
+ || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
1004
+
1005
+ return content
1006
+ }
1007
+
1008
+ , tip: function () {
1009
+ if (!this.$tip) {
1010
+ this.$tip = $(this.options.template)
1011
+ }
1012
+ return this.$tip
1013
+ }
1014
+
1015
+ })
1016
+
1017
+
1018
+ /* POPOVER PLUGIN DEFINITION
1019
+ * ======================= */
1020
+
1021
+ $.fn.popover = function (option) {
1022
+ return this.each(function () {
1023
+ var $this = $(this)
1024
+ , data = $this.data('popover')
1025
+ , options = typeof option == 'object' && option
1026
+ if (!data) $this.data('popover', (data = new Popover(this, options)))
1027
+ if (typeof option == 'string') data[option]()
1028
+ })
1029
+ }
1030
+
1031
+ $.fn.popover.Constructor = Popover
1032
+
1033
+ $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
1034
+ placement: 'right'
1035
+ , content: ''
1036
+ , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
1037
+ })
1038
+
1039
+ }(window.jQuery);
1040
+ /* ==========================================================
1041
+ * bootstrap-alert.js v2.0.4
1042
+ * http://twitter.github.com/bootstrap/javascript.html#alerts
1043
+ * ==========================================================
1044
+ * Copyright 2012 Twitter, Inc.
1045
+ *
1046
+ * Licensed under the Apache License, Version 2.0 (the "License");
1047
+ * you may not use this file except in compliance with the License.
1048
+ * You may obtain a copy of the License at
1049
+ *
1050
+ * http://www.apache.org/licenses/LICENSE-2.0
1051
+ *
1052
+ * Unless required by applicable law or agreed to in writing, software
1053
+ * distributed under the License is distributed on an "AS IS" BASIS,
1054
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1055
+ * See the License for the specific language governing permissions and
1056
+ * limitations under the License.
1057
+ * ========================================================== */
1058
+
1059
+
1060
+ !function ($) {
1061
+
1062
+ "use strict"; // jshint ;_;
1063
+
1064
+
1065
+ /* ALERT CLASS DEFINITION
1066
+ * ====================== */
1067
+
1068
+ var dismiss = '[data-dismiss="alert"]'
1069
+ , Alert = function (el) {
1070
+ $(el).on('click', dismiss, this.close)
1071
+ }
1072
+
1073
+ Alert.prototype.close = function (e) {
1074
+ var $this = $(this)
1075
+ , selector = $this.attr('data-target')
1076
+ , $parent
1077
+
1078
+ if (!selector) {
1079
+ selector = $this.attr('href')
1080
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
1081
+ }
1082
+
1083
+ $parent = $(selector)
1084
+
1085
+ e && e.preventDefault()
1086
+
1087
+ $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
1088
+
1089
+ $parent.trigger(e = $.Event('close'))
1090
+
1091
+ if (e.isDefaultPrevented()) return
1092
+
1093
+ $parent.removeClass('in')
1094
+
1095
+ function removeElement() {
1096
+ $parent
1097
+ .trigger('closed')
1098
+ .remove()
1099
+ }
1100
+
1101
+ $.support.transition && $parent.hasClass('fade') ?
1102
+ $parent.on($.support.transition.end, removeElement) :
1103
+ removeElement()
1104
+ }
1105
+
1106
+
1107
+ /* ALERT PLUGIN DEFINITION
1108
+ * ======================= */
1136
1109
 
1137
- $.fn.tooltip = function ( option ) {
1110
+ $.fn.alert = function (option) {
1138
1111
  return this.each(function () {
1139
1112
  var $this = $(this)
1140
- , data = $this.data('tooltip')
1141
- , options = typeof option == 'object' && option
1142
- if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
1143
- if (typeof option == 'string') data[option]()
1113
+ , data = $this.data('alert')
1114
+ if (!data) $this.data('alert', (data = new Alert(this)))
1115
+ if (typeof option == 'string') data[option].call($this)
1144
1116
  })
1145
1117
  }
1146
1118
 
1147
- $.fn.tooltip.Constructor = Tooltip
1119
+ $.fn.alert.Constructor = Alert
1148
1120
 
1149
- $.fn.tooltip.defaults = {
1150
- animation: true
1151
- , placement: 'top'
1152
- , selector: false
1153
- , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
1154
- , trigger: 'hover'
1155
- , title: ''
1156
- , delay: 0
1157
- }
1121
+
1122
+ /* ALERT DATA-API
1123
+ * ============== */
1124
+
1125
+ $(function () {
1126
+ $('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
1127
+ })
1158
1128
 
1159
1129
  }(window.jQuery);
1160
- /* ===========================================================
1161
- * bootstrap-popover.js v2.0.4
1162
- * http://twitter.github.com/bootstrap/javascript.html#popovers
1163
- * ===========================================================
1130
+ /* ============================================================
1131
+ * bootstrap-button.js v2.0.4
1132
+ * http://twitter.github.com/bootstrap/javascript.html#buttons
1133
+ * ============================================================
1164
1134
  * Copyright 2012 Twitter, Inc.
1165
1135
  *
1166
1136
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -1174,7 +1144,7 @@
1174
1144
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1175
1145
  * See the License for the specific language governing permissions and
1176
1146
  * limitations under the License.
1177
- * =========================================================== */
1147
+ * ============================================================ */
1178
1148
 
1179
1149
 
1180
1150
  !function ($) {
@@ -1182,81 +1152,80 @@
1182
1152
  "use strict"; // jshint ;_;
1183
1153
 
1184
1154
 
1185
- /* POPOVER PUBLIC CLASS DEFINITION
1186
- * =============================== */
1155
+ /* BUTTON PUBLIC CLASS DEFINITION
1156
+ * ============================== */
1187
1157
 
1188
- var Popover = function ( element, options ) {
1189
- this.init('popover', element, options)
1158
+ var Button = function (element, options) {
1159
+ this.$element = $(element)
1160
+ this.options = $.extend({}, $.fn.button.defaults, options)
1190
1161
  }
1191
1162
 
1163
+ Button.prototype.setState = function (state) {
1164
+ var d = 'disabled'
1165
+ , $el = this.$element
1166
+ , data = $el.data()
1167
+ , val = $el.is('input') ? 'val' : 'html'
1192
1168
 
1193
- /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
1194
- ========================================== */
1195
-
1196
- Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
1197
-
1198
- constructor: Popover
1199
-
1200
- , setContent: function () {
1201
- var $tip = this.tip()
1202
- , title = this.getTitle()
1203
- , content = this.getContent()
1204
-
1205
- $tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
1206
- $tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
1207
-
1208
- $tip.removeClass('fade top bottom left right in')
1209
- }
1210
-
1211
- , hasContent: function () {
1212
- return this.getTitle() || this.getContent()
1213
- }
1169
+ state = state + 'Text'
1170
+ data.resetText || $el.data('resetText', $el[val]())
1214
1171
 
1215
- , getContent: function () {
1216
- var content
1217
- , $e = this.$element
1218
- , o = this.options
1172
+ $el[val](data[state] || this.options[state])
1219
1173
 
1220
- content = $e.attr('data-content')
1221
- || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
1174
+ // push to event loop to allow forms to submit
1175
+ setTimeout(function () {
1176
+ state == 'loadingText' ?
1177
+ $el.addClass(d).attr(d, d) :
1178
+ $el.removeClass(d).removeAttr(d)
1179
+ }, 0)
1180
+ }
1222
1181
 
1223
- return content
1224
- }
1182
+ Button.prototype.toggle = function () {
1183
+ var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
1225
1184
 
1226
- , tip: function () {
1227
- if (!this.$tip) {
1228
- this.$tip = $(this.options.template)
1229
- }
1230
- return this.$tip
1231
- }
1185
+ $parent && $parent
1186
+ .find('.active')
1187
+ .removeClass('active')
1232
1188
 
1233
- })
1189
+ this.$element.toggleClass('active')
1190
+ }
1234
1191
 
1235
1192
 
1236
- /* POPOVER PLUGIN DEFINITION
1237
- * ======================= */
1193
+ /* BUTTON PLUGIN DEFINITION
1194
+ * ======================== */
1238
1195
 
1239
- $.fn.popover = function (option) {
1196
+ $.fn.button = function (option) {
1240
1197
  return this.each(function () {
1241
1198
  var $this = $(this)
1242
- , data = $this.data('popover')
1199
+ , data = $this.data('button')
1243
1200
  , options = typeof option == 'object' && option
1244
- if (!data) $this.data('popover', (data = new Popover(this, options)))
1245
- if (typeof option == 'string') data[option]()
1201
+ if (!data) $this.data('button', (data = new Button(this, options)))
1202
+ if (option == 'toggle') data.toggle()
1203
+ else if (option) data.setState(option)
1246
1204
  })
1247
1205
  }
1248
1206
 
1249
- $.fn.popover.Constructor = Popover
1207
+ $.fn.button.defaults = {
1208
+ loadingText: 'loading...'
1209
+ }
1250
1210
 
1251
- $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
1252
- placement: 'right'
1253
- , content: ''
1254
- , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
1211
+ $.fn.button.Constructor = Button
1212
+
1213
+
1214
+ /* BUTTON DATA-API
1215
+ * =============== */
1216
+
1217
+ $(function () {
1218
+ $('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
1219
+ var $btn = $(e.target)
1220
+ if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
1221
+ $btn.button('toggle')
1222
+ })
1255
1223
  })
1256
1224
 
1257
- }(window.jQuery);/* =============================================================
1258
- * bootstrap-scrollspy.js v2.0.4
1259
- * http://twitter.github.com/bootstrap/javascript.html#scrollspy
1225
+ }(window.jQuery);
1226
+ /* =============================================================
1227
+ * bootstrap-collapse.js v2.0.4
1228
+ * http://twitter.github.com/bootstrap/javascript.html#collapse
1260
1229
  * =============================================================
1261
1230
  * Copyright 2012 Twitter, Inc.
1262
1231
  *
@@ -1271,7 +1240,7 @@
1271
1240
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1272
1241
  * See the License for the specific language governing permissions and
1273
1242
  * limitations under the License.
1274
- * ============================================================== */
1243
+ * ============================================================ */
1275
1244
 
1276
1245
 
1277
1246
  !function ($) {
@@ -1279,135 +1248,142 @@
1279
1248
  "use strict"; // jshint ;_;
1280
1249
 
1281
1250
 
1282
- /* SCROLLSPY CLASS DEFINITION
1283
- * ========================== */
1251
+ /* COLLAPSE PUBLIC CLASS DEFINITION
1252
+ * ================================ */
1284
1253
 
1285
- function ScrollSpy( element, options) {
1286
- var process = $.proxy(this.process, this)
1287
- , $element = $(element).is('body') ? $(window) : $(element)
1288
- , href
1289
- this.options = $.extend({}, $.fn.scrollspy.defaults, options)
1290
- this.$scrollElement = $element.on('scroll.scroll.data-api', process)
1291
- this.selector = (this.options.target
1292
- || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
1293
- || '') + ' .nav li > a'
1294
- this.$body = $('body')
1295
- this.refresh()
1296
- this.process()
1254
+ var Collapse = function (element, options) {
1255
+ this.$element = $(element)
1256
+ this.options = $.extend({}, $.fn.collapse.defaults, options)
1257
+
1258
+ if (this.options.parent) {
1259
+ this.$parent = $(this.options.parent)
1260
+ }
1261
+
1262
+ this.options.toggle && this.toggle()
1297
1263
  }
1298
1264
 
1299
- ScrollSpy.prototype = {
1265
+ Collapse.prototype = {
1300
1266
 
1301
- constructor: ScrollSpy
1267
+ constructor: Collapse
1302
1268
 
1303
- , refresh: function () {
1304
- var self = this
1305
- , $targets
1269
+ , dimension: function () {
1270
+ var hasWidth = this.$element.hasClass('width')
1271
+ return hasWidth ? 'width' : 'height'
1272
+ }
1306
1273
 
1307
- this.offsets = $([])
1308
- this.targets = $([])
1274
+ , show: function () {
1275
+ var dimension
1276
+ , scroll
1277
+ , actives
1278
+ , hasData
1309
1279
 
1310
- $targets = this.$body
1311
- .find(this.selector)
1312
- .map(function () {
1313
- var $el = $(this)
1314
- , href = $el.data('target') || $el.attr('href')
1315
- , $href = /^#\w/.test(href) && $(href)
1316
- return ( $href
1317
- && href.length
1318
- && [[ $href.position().top, href ]] ) || null
1319
- })
1320
- .sort(function (a, b) { return a[0] - b[0] })
1321
- .each(function () {
1322
- self.offsets.push(this[0])
1323
- self.targets.push(this[1])
1324
- })
1280
+ if (this.transitioning) return
1281
+
1282
+ dimension = this.dimension()
1283
+ scroll = $.camelCase(['scroll', dimension].join('-'))
1284
+ actives = this.$parent && this.$parent.find('> .accordion-group > .in')
1285
+
1286
+ if (actives && actives.length) {
1287
+ hasData = actives.data('collapse')
1288
+ if (hasData && hasData.transitioning) return
1289
+ actives.collapse('hide')
1290
+ hasData || actives.data('collapse', null)
1325
1291
  }
1326
1292
 
1327
- , process: function () {
1328
- var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
1329
- , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
1330
- , maxScroll = scrollHeight - this.$scrollElement.height()
1331
- , offsets = this.offsets
1332
- , targets = this.targets
1333
- , activeTarget = this.activeTarget
1334
- , i
1293
+ this.$element[dimension](0)
1294
+ this.transition('addClass', $.Event('show'), 'shown')
1295
+ this.$element[dimension](this.$element[0][scroll])
1296
+ }
1335
1297
 
1336
- if (scrollTop >= maxScroll) {
1337
- return activeTarget != (i = targets.last()[0])
1338
- && this.activate ( i )
1339
- }
1298
+ , hide: function () {
1299
+ var dimension
1300
+ if (this.transitioning) return
1301
+ dimension = this.dimension()
1302
+ this.reset(this.$element[dimension]())
1303
+ this.transition('removeClass', $.Event('hide'), 'hidden')
1304
+ this.$element[dimension](0)
1305
+ }
1340
1306
 
1341
- for (i = offsets.length; i--;) {
1342
- activeTarget != targets[i]
1343
- && scrollTop >= offsets[i]
1344
- && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
1345
- && this.activate( targets[i] )
1346
- }
1347
- }
1307
+ , reset: function (size) {
1308
+ var dimension = this.dimension()
1309
+
1310
+ this.$element
1311
+ .removeClass('collapse')
1312
+ [dimension](size || 'auto')
1313
+ [0].offsetWidth
1348
1314
 
1349
- , activate: function (target) {
1350
- var active
1351
- , selector
1315
+ this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
1352
1316
 
1353
- this.activeTarget = target
1317
+ return this
1318
+ }
1354
1319
 
1355
- $(this.selector)
1356
- .parent('.active')
1357
- .removeClass('active')
1320
+ , transition: function (method, startEvent, completeEvent) {
1321
+ var that = this
1322
+ , complete = function () {
1323
+ if (startEvent.type == 'show') that.reset()
1324
+ that.transitioning = 0
1325
+ that.$element.trigger(completeEvent)
1326
+ }
1358
1327
 
1359
- selector = this.selector
1360
- + '[data-target="' + target + '"],'
1361
- + this.selector + '[href="' + target + '"]'
1328
+ this.$element.trigger(startEvent)
1362
1329
 
1363
- active = $(selector)
1364
- .parent('li')
1365
- .addClass('active')
1330
+ if (startEvent.isDefaultPrevented()) return
1366
1331
 
1367
- if (active.parent('.dropdown-menu')) {
1368
- active = active.closest('li.dropdown').addClass('active')
1369
- }
1332
+ this.transitioning = 1
1370
1333
 
1371
- active.trigger('activate')
1372
- }
1334
+ this.$element[method]('in')
1335
+
1336
+ $.support.transition && this.$element.hasClass('collapse') ?
1337
+ this.$element.one($.support.transition.end, complete) :
1338
+ complete()
1339
+ }
1340
+
1341
+ , toggle: function () {
1342
+ this[this.$element.hasClass('in') ? 'hide' : 'show']()
1343
+ }
1373
1344
 
1374
1345
  }
1375
1346
 
1376
1347
 
1377
- /* SCROLLSPY PLUGIN DEFINITION
1378
- * =========================== */
1348
+ /* COLLAPSIBLE PLUGIN DEFINITION
1349
+ * ============================== */
1379
1350
 
1380
- $.fn.scrollspy = function ( option ) {
1351
+ $.fn.collapse = function (option) {
1381
1352
  return this.each(function () {
1382
1353
  var $this = $(this)
1383
- , data = $this.data('scrollspy')
1354
+ , data = $this.data('collapse')
1384
1355
  , options = typeof option == 'object' && option
1385
- if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
1356
+ if (!data) $this.data('collapse', (data = new Collapse(this, options)))
1386
1357
  if (typeof option == 'string') data[option]()
1387
1358
  })
1388
1359
  }
1389
1360
 
1390
- $.fn.scrollspy.Constructor = ScrollSpy
1391
-
1392
- $.fn.scrollspy.defaults = {
1393
- offset: 10
1361
+ $.fn.collapse.defaults = {
1362
+ toggle: true
1394
1363
  }
1395
1364
 
1365
+ $.fn.collapse.Constructor = Collapse
1396
1366
 
1397
- /* SCROLLSPY DATA-API
1398
- * ================== */
1367
+
1368
+ /* COLLAPSIBLE DATA-API
1369
+ * ==================== */
1399
1370
 
1400
1371
  $(function () {
1401
- $('[data-spy="scroll"]').each(function () {
1402
- var $spy = $(this)
1403
- $spy.scrollspy($spy.data())
1372
+ $('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) {
1373
+ var $this = $(this), href
1374
+ , target = $this.attr('data-target')
1375
+ || e.preventDefault()
1376
+ || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
1377
+ , option = $(target).data('collapse') ? 'toggle' : $this.data()
1378
+ $(target).collapse(option)
1404
1379
  })
1405
1380
  })
1406
1381
 
1407
- }(window.jQuery);/* ========================================================
1408
- * bootstrap-tab.js v2.0.4
1409
- * http://twitter.github.com/bootstrap/javascript.html#tabs
1410
- * ========================================================
1382
+ }(window.jQuery);
1383
+ /* ==========================================================
1384
+ * bootstrap-carousel.js v2.0.4
1385
+ * http://twitter.github.com/bootstrap/javascript.html#carousel
1386
+ * ==========================================================
1411
1387
  * Copyright 2012 Twitter, Inc.
1412
1388
  *
1413
1389
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -1421,7 +1397,7 @@
1421
1397
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1422
1398
  * See the License for the specific language governing permissions and
1423
1399
  * limitations under the License.
1424
- * ======================================================== */
1400
+ * ========================================================== */
1425
1401
 
1426
1402
 
1427
1403
  !function ($) {
@@ -1429,116 +1405,151 @@
1429
1405
  "use strict"; // jshint ;_;
1430
1406
 
1431
1407
 
1432
- /* TAB CLASS DEFINITION
1433
- * ==================== */
1408
+ /* CAROUSEL CLASS DEFINITION
1409
+ * ========================= */
1434
1410
 
1435
- var Tab = function ( element ) {
1436
- this.element = $(element)
1411
+ var Carousel = function (element, options) {
1412
+ this.$element = $(element)
1413
+ this.options = options
1414
+ this.options.slide && this.slide(this.options.slide)
1415
+ this.options.pause == 'hover' && this.$element
1416
+ .on('mouseenter', $.proxy(this.pause, this))
1417
+ .on('mouseleave', $.proxy(this.cycle, this))
1437
1418
  }
1438
1419
 
1439
- Tab.prototype = {
1440
-
1441
- constructor: Tab
1420
+ Carousel.prototype = {
1442
1421
 
1443
- , show: function () {
1444
- var $this = this.element
1445
- , $ul = $this.closest('ul:not(.dropdown-menu)')
1446
- , selector = $this.attr('data-target')
1447
- , previous
1448
- , $target
1449
- , e
1422
+ cycle: function (e) {
1423
+ if (!e) this.paused = false
1424
+ this.options.interval
1425
+ && !this.paused
1426
+ && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
1427
+ return this
1428
+ }
1450
1429
 
1451
- if (!selector) {
1452
- selector = $this.attr('href')
1453
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
1454
- }
1430
+ , to: function (pos) {
1431
+ var $active = this.$element.find('.active')
1432
+ , children = $active.parent().children()
1433
+ , activePos = children.index($active)
1434
+ , that = this
1455
1435
 
1456
- if ( $this.parent('li').hasClass('active') ) return
1436
+ if (pos > (children.length - 1) || pos < 0) return
1457
1437
 
1458
- previous = $ul.find('.active a').last()[0]
1438
+ if (this.sliding) {
1439
+ return this.$element.one('slid', function () {
1440
+ that.to(pos)
1441
+ })
1442
+ }
1459
1443
 
1460
- e = $.Event('show', {
1461
- relatedTarget: previous
1462
- })
1444
+ if (activePos == pos) {
1445
+ return this.pause().cycle()
1446
+ }
1463
1447
 
1464
- $this.trigger(e)
1448
+ return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
1449
+ }
1465
1450
 
1466
- if (e.isDefaultPrevented()) return
1451
+ , pause: function (e) {
1452
+ if (!e) this.paused = true
1453
+ clearInterval(this.interval)
1454
+ this.interval = null
1455
+ return this
1456
+ }
1467
1457
 
1468
- $target = $(selector)
1458
+ , next: function () {
1459
+ if (this.sliding) return
1460
+ return this.slide('next')
1461
+ }
1469
1462
 
1470
- this.activate($this.parent('li'), $ul)
1471
- this.activate($target, $target.parent(), function () {
1472
- $this.trigger({
1473
- type: 'shown'
1474
- , relatedTarget: previous
1475
- })
1476
- })
1463
+ , prev: function () {
1464
+ if (this.sliding) return
1465
+ return this.slide('prev')
1477
1466
  }
1478
1467
 
1479
- , activate: function ( element, container, callback) {
1480
- var $active = container.find('> .active')
1481
- , transition = callback
1482
- && $.support.transition
1483
- && $active.hasClass('fade')
1468
+ , slide: function (type, next) {
1469
+ var $active = this.$element.find('.active')
1470
+ , $next = next || $active[type]()
1471
+ , isCycling = this.interval
1472
+ , direction = type == 'next' ? 'left' : 'right'
1473
+ , fallback = type == 'next' ? 'first' : 'last'
1474
+ , that = this
1475
+ , e = $.Event('slide')
1484
1476
 
1485
- function next() {
1486
- $active
1487
- .removeClass('active')
1488
- .find('> .dropdown-menu > .active')
1489
- .removeClass('active')
1477
+ this.sliding = true
1490
1478
 
1491
- element.addClass('active')
1479
+ isCycling && this.pause()
1492
1480
 
1493
- if (transition) {
1494
- element[0].offsetWidth // reflow for transition
1495
- element.addClass('in')
1496
- } else {
1497
- element.removeClass('fade')
1498
- }
1481
+ $next = $next.length ? $next : this.$element.find('.item')[fallback]()
1499
1482
 
1500
- if ( element.parent('.dropdown-menu') ) {
1501
- element.closest('li.dropdown').addClass('active')
1502
- }
1483
+ if ($next.hasClass('active')) return
1503
1484
 
1504
- callback && callback()
1485
+ if ($.support.transition && this.$element.hasClass('slide')) {
1486
+ this.$element.trigger(e)
1487
+ if (e.isDefaultPrevented()) return
1488
+ $next.addClass(type)
1489
+ $next[0].offsetWidth // force reflow
1490
+ $active.addClass(direction)
1491
+ $next.addClass(direction)
1492
+ this.$element.one($.support.transition.end, function () {
1493
+ $next.removeClass([type, direction].join(' ')).addClass('active')
1494
+ $active.removeClass(['active', direction].join(' '))
1495
+ that.sliding = false
1496
+ setTimeout(function () { that.$element.trigger('slid') }, 0)
1497
+ })
1498
+ } else {
1499
+ this.$element.trigger(e)
1500
+ if (e.isDefaultPrevented()) return
1501
+ $active.removeClass('active')
1502
+ $next.addClass('active')
1503
+ this.sliding = false
1504
+ this.$element.trigger('slid')
1505
1505
  }
1506
1506
 
1507
- transition ?
1508
- $active.one($.support.transition.end, next) :
1509
- next()
1507
+ isCycling && this.cycle()
1510
1508
 
1511
- $active.removeClass('in')
1509
+ return this
1512
1510
  }
1511
+
1513
1512
  }
1514
1513
 
1515
1514
 
1516
- /* TAB PLUGIN DEFINITION
1517
- * ===================== */
1515
+ /* CAROUSEL PLUGIN DEFINITION
1516
+ * ========================== */
1518
1517
 
1519
- $.fn.tab = function ( option ) {
1518
+ $.fn.carousel = function (option) {
1520
1519
  return this.each(function () {
1521
1520
  var $this = $(this)
1522
- , data = $this.data('tab')
1523
- if (!data) $this.data('tab', (data = new Tab(this)))
1524
- if (typeof option == 'string') data[option]()
1521
+ , data = $this.data('carousel')
1522
+ , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
1523
+ if (!data) $this.data('carousel', (data = new Carousel(this, options)))
1524
+ if (typeof option == 'number') data.to(option)
1525
+ else if (typeof option == 'string' || (option = options.slide)) data[option]()
1526
+ else if (options.interval) data.cycle()
1525
1527
  })
1526
1528
  }
1527
1529
 
1528
- $.fn.tab.Constructor = Tab
1530
+ $.fn.carousel.defaults = {
1531
+ interval: 5000
1532
+ , pause: 'hover'
1533
+ }
1529
1534
 
1535
+ $.fn.carousel.Constructor = Carousel
1530
1536
 
1531
- /* TAB DATA-API
1532
- * ============ */
1537
+
1538
+ /* CAROUSEL DATA-API
1539
+ * ================= */
1533
1540
 
1534
1541
  $(function () {
1535
- $('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
1542
+ $('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
1543
+ var $this = $(this), href
1544
+ , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
1545
+ , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
1546
+ $target.carousel(options)
1536
1547
  e.preventDefault()
1537
- $(this).tab('show')
1538
1548
  })
1539
1549
  })
1540
1550
 
1541
- }(window.jQuery);/* =============================================================
1551
+ }(window.jQuery);
1552
+ /* =============================================================
1542
1553
  * bootstrap-typeahead.js v2.0.4
1543
1554
  * http://twitter.github.com/bootstrap/javascript.html#typeahead
1544
1555
  * =============================================================