update bootstrap to 3.0.0-rc2
[bootswatch] / bower_components / bootstrap / dist / js / bootstrap.js
1 /**
2 * bootstrap.js v3.0.0 by @fat and @mdo
3 * Copyright 2013 Twitter Inc.
4 * http://www.apache.org/licenses/LICENSE-2.0
5 */
6 if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
7
8 /* ========================================================================
9  * Bootstrap: transition.js v3.0.0
10  * http://twbs.github.com/bootstrap/javascript.html#transitions
11  * ========================================================================
12  * Copyright 2013 Twitter, Inc.
13  *
14  * Licensed under the Apache License, Version 2.0 (the "License");
15  * you may not use this file except in compliance with the License.
16  * You may obtain a copy of the License at
17  *
18  * http://www.apache.org/licenses/LICENSE-2.0
19  *
20  * Unless required by applicable law or agreed to in writing, software
21  * distributed under the License is distributed on an "AS IS" BASIS,
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  * See the License for the specific language governing permissions and
24  * limitations under the License.
25  * ======================================================================== */
26
27
28 +function ($) { "use strict";
29
30   // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
31   // ============================================================
32
33   function transitionEnd() {
34     var el = document.createElement('bootstrap')
35
36     var transEndEventNames = {
37       'WebkitTransition' : 'webkitTransitionEnd'
38     , 'MozTransition'    : 'transitionend'
39     , 'OTransition'      : 'oTransitionEnd otransitionend'
40     , 'transition'       : 'transitionend'
41     }
42
43     for (var name in transEndEventNames) {
44       if (el.style[name] !== undefined) {
45         return { end: transEndEventNames[name] }
46       }
47     }
48   }
49
50   // http://blog.alexmaccaw.com/css-transitions
51   $.fn.emulateTransitionEnd = function (duration) {
52     var called = false, $el    = this
53     $(this).one($.support.transition.end, function () { called = true })
54     var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
55     setTimeout(callback, duration)
56     return this
57   }
58
59   $(function () {
60     $.support.transition = transitionEnd()
61   })
62
63 }(window.jQuery);
64
65 /* ========================================================================
66  * Bootstrap: alert.js v3.0.0
67  * http://twbs.github.com/bootstrap/javascript.html#alerts
68  * ========================================================================
69  * Copyright 2013 Twitter, Inc.
70  *
71  * Licensed under the Apache License, Version 2.0 (the "License");
72  * you may not use this file except in compliance with the License.
73  * You may obtain a copy of the License at
74  *
75  * http://www.apache.org/licenses/LICENSE-2.0
76  *
77  * Unless required by applicable law or agreed to in writing, software
78  * distributed under the License is distributed on an "AS IS" BASIS,
79  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
80  * See the License for the specific language governing permissions and
81  * limitations under the License.
82  * ======================================================================== */
83
84
85 +function ($) { "use strict";
86
87   // ALERT CLASS DEFINITION
88   // ======================
89
90   var dismiss = '[data-dismiss="alert"]'
91   var Alert   = function (el) {
92     $(el).on('click', dismiss, this.close)
93   }
94
95   Alert.prototype.close = function (e) {
96     var $this    = $(this)
97     var selector = $this.attr('data-target')
98
99     if (!selector) {
100       selector = $this.attr('href')
101       selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
102     }
103
104     var $parent = $(selector)
105
106     if (e) e.preventDefault()
107
108     if (!$parent.length) {
109       $parent = $this.hasClass('alert') ? $this : $this.parent()
110     }
111
112     $parent.trigger(e = $.Event('close.bs.alert'))
113
114     if (e.isDefaultPrevented()) return
115
116     $parent.removeClass('in')
117
118     function removeElement() {
119       $parent.trigger('closed.bs.alert').remove()
120     }
121
122     $.support.transition && $parent.hasClass('fade') ?
123       $parent
124         .one($.support.transition.end, removeElement)
125         .emulateTransitionEnd(150) :
126       removeElement()
127   }
128
129
130   // ALERT PLUGIN DEFINITION
131   // =======================
132
133   var old = $.fn.alert
134
135   $.fn.alert = function (option) {
136     return this.each(function () {
137       var $this = $(this)
138       var data  = $this.data('bs.alert')
139
140       if (!data) $this.data('bs.alert', (data = new Alert(this)))
141       if (typeof option == 'string') data[option].call($this)
142     })
143   }
144
145   $.fn.alert.Constructor = Alert
146
147
148   // ALERT NO CONFLICT
149   // =================
150
151   $.fn.alert.noConflict = function () {
152     $.fn.alert = old
153     return this
154   }
155
156
157   // ALERT DATA-API
158   // ==============
159
160   $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
161
162 }(window.jQuery);
163
164 /* ========================================================================
165  * Bootstrap: button.js v3.0.0
166  * http://twbs.github.com/bootstrap/javascript.html#buttons
167  * ========================================================================
168  * Copyright 2013 Twitter, Inc.
169  *
170  * Licensed under the Apache License, Version 2.0 (the "License");
171  * you may not use this file except in compliance with the License.
172  * You may obtain a copy of the License at
173  *
174  * http://www.apache.org/licenses/LICENSE-2.0
175  *
176  * Unless required by applicable law or agreed to in writing, software
177  * distributed under the License is distributed on an "AS IS" BASIS,
178  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179  * See the License for the specific language governing permissions and
180  * limitations under the License.
181  * ======================================================================== */
182
183
184 +function ($) { "use strict";
185
186   // BUTTON PUBLIC CLASS DEFINITION
187   // ==============================
188
189   var Button = function (element, options) {
190     this.$element = $(element)
191     this.options  = $.extend({}, Button.DEFAULTS, options)
192   }
193
194   Button.DEFAULTS = {
195     loadingText: 'loading...'
196   }
197
198   Button.prototype.setState = function (state) {
199     var d    = 'disabled'
200     var $el  = this.$element
201     var val  = $el.is('input') ? 'val' : 'html'
202     var data = $el.data()
203
204     state = state + 'Text'
205
206     if (!data.resetText) $el.data('resetText', $el[val]())
207
208     $el[val](data[state] || this.options[state])
209
210     // push to event loop to allow forms to submit
211     setTimeout(function () {
212       state == 'loadingText' ?
213         $el.addClass(d).attr(d, d) :
214         $el.removeClass(d).removeAttr(d);
215     }, 0)
216   }
217
218   Button.prototype.toggle = function () {
219     var $parent = this.$element.closest('[data-toggle="buttons"]')
220
221     if ($parent.length) {
222       var $input = this.$element.find('input')
223         .prop('checked', !this.$element.hasClass('active'))
224         .trigger('change')
225       if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active')
226     }
227
228     this.$element.toggleClass('active')
229   }
230
231
232   // BUTTON PLUGIN DEFINITION
233   // ========================
234
235   var old = $.fn.button
236
237   $.fn.button = function (option) {
238     return this.each(function () {
239       var $this   = $(this)
240       var data    = $this.data('bs.button')
241       var options = typeof option == 'object' && option
242
243       if (!data) $this.data('bs.button', (data = new Button(this, options)))
244
245       if (option == 'toggle') data.toggle()
246       else if (option) data.setState(option)
247     })
248   }
249
250   $.fn.button.Constructor = Button
251
252
253   // BUTTON NO CONFLICT
254   // ==================
255
256   $.fn.button.noConflict = function () {
257     $.fn.button = old
258     return this
259   }
260
261
262   // BUTTON DATA-API
263   // ===============
264
265   $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
266     var $btn = $(e.target)
267     if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
268     $btn.button('toggle')
269     e.preventDefault()
270   })
271
272 }(window.jQuery);
273
274 /* ========================================================================
275  * Bootstrap: carousel.js v3.0.0
276  * http://twbs.github.com/bootstrap/javascript.html#carousel
277  * ========================================================================
278  * Copyright 2012 Twitter, Inc.
279  *
280  * Licensed under the Apache License, Version 2.0 (the "License");
281  * you may not use this file except in compliance with the License.
282  * You may obtain a copy of the License at
283  *
284  * http://www.apache.org/licenses/LICENSE-2.0
285  *
286  * Unless required by applicable law or agreed to in writing, software
287  * distributed under the License is distributed on an "AS IS" BASIS,
288  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
289  * See the License for the specific language governing permissions and
290  * limitations under the License.
291  * ======================================================================== */
292
293
294 +function ($) { "use strict";
295
296   // CAROUSEL CLASS DEFINITION
297   // =========================
298
299   var Carousel = function (element, options) {
300     this.$element    = $(element)
301     this.$indicators = this.$element.find('.carousel-indicators')
302     this.options     = options
303     this.paused      =
304     this.sliding     =
305     this.interval    =
306     this.$active     =
307     this.$items      = null
308
309     this.options.pause == 'hover' && this.$element
310       .on('mouseenter', $.proxy(this.pause, this))
311       .on('mouseleave', $.proxy(this.cycle, this))
312   }
313
314   Carousel.DEFAULTS = {
315     interval: 5000
316   , pause: 'hover'
317   , wrap: true
318   }
319
320   Carousel.prototype.cycle =  function (e) {
321     e || (this.paused = false)
322
323     this.interval && clearInterval(this.interval)
324
325     this.options.interval
326       && !this.paused
327       && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
328
329     return this
330   }
331
332   Carousel.prototype.getActiveIndex = function () {
333     this.$active = this.$element.find('.item.active')
334     this.$items  = this.$active.parent().children()
335
336     return this.$items.index(this.$active)
337   }
338
339   Carousel.prototype.to = function (pos) {
340     var that        = this
341     var activeIndex = this.getActiveIndex()
342
343     if (pos > (this.$items.length - 1) || pos < 0) return
344
345     if (this.sliding)       return this.$element.one('slid', function () { that.to(pos) })
346     if (activeIndex == pos) return this.pause().cycle()
347
348     return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
349   }
350
351   Carousel.prototype.pause = function (e) {
352     e || (this.paused = true)
353
354     if (this.$element.find('.next, .prev').length && $.support.transition.end) {
355       this.$element.trigger($.support.transition.end)
356       this.cycle(true)
357     }
358
359     this.interval = clearInterval(this.interval)
360
361     return this
362   }
363
364   Carousel.prototype.next = function () {
365     if (this.sliding) return
366     return this.slide('next')
367   }
368
369   Carousel.prototype.prev = function () {
370     if (this.sliding) return
371     return this.slide('prev')
372   }
373
374   Carousel.prototype.slide = function (type, next) {
375     var $active   = this.$element.find('.item.active')
376     var $next     = next || $active[type]()
377     var isCycling = this.interval
378     var direction = type == 'next' ? 'left' : 'right'
379     var fallback  = type == 'next' ? 'first' : 'last'
380     var that      = this
381
382     if (!$next.length) {
383       if (!this.options.wrap) return
384       $next = this.$element.find('.item')[fallback]()
385     }
386
387     this.sliding = true
388
389     isCycling && this.pause()
390
391     var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction })
392
393     if ($next.hasClass('active')) return
394
395     if (this.$indicators.length) {
396       this.$indicators.find('.active').removeClass('active')
397       this.$element.one('slid', function () {
398         var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
399         $nextIndicator && $nextIndicator.addClass('active')
400       })
401     }
402
403     if ($.support.transition && this.$element.hasClass('slide')) {
404       this.$element.trigger(e)
405       if (e.isDefaultPrevented()) return
406       $next.addClass(type)
407       $next[0].offsetWidth // force reflow
408       $active.addClass(direction)
409       $next.addClass(direction)
410       $active
411         .one($.support.transition.end, function () {
412           $next.removeClass([type, direction].join(' ')).addClass('active')
413           $active.removeClass(['active', direction].join(' '))
414           that.sliding = false
415           setTimeout(function () { that.$element.trigger('slid') }, 0)
416         })
417         .emulateTransitionEnd(600)
418     } else {
419       this.$element.trigger(e)
420       if (e.isDefaultPrevented()) return
421       $active.removeClass('active')
422       $next.addClass('active')
423       this.sliding = false
424       this.$element.trigger('slid')
425     }
426
427     isCycling && this.cycle()
428
429     return this
430   }
431
432
433   // CAROUSEL PLUGIN DEFINITION
434   // ==========================
435
436   var old = $.fn.carousel
437
438   $.fn.carousel = function (option) {
439     return this.each(function () {
440       var $this   = $(this)
441       var data    = $this.data('bs.carousel')
442       var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
443       var action  = typeof option == 'string' ? option : options.slide
444
445       if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
446       if (typeof option == 'number') data.to(option)
447       else if (action) data[action]()
448       else if (options.interval) data.pause().cycle()
449     })
450   }
451
452   $.fn.carousel.Constructor = Carousel
453
454
455   // CAROUSEL NO CONFLICT
456   // ====================
457
458   $.fn.carousel.noConflict = function () {
459     $.fn.carousel = old
460     return this
461   }
462
463
464   // CAROUSEL DATA-API
465   // =================
466
467   $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
468     var $this   = $(this), href
469     var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
470     var options = $.extend({}, $target.data(), $this.data())
471     var slideIndex = $this.attr('data-slide-to')
472     if (slideIndex) options.interval = false
473
474     $target.carousel(options)
475
476     if (slideIndex = $this.attr('data-slide-to')) {
477       $target.data('bs.carousel').to(slideIndex)
478     }
479
480     e.preventDefault()
481   })
482
483   $(window).on('load', function () {
484     $('[data-ride="carousel"]').each(function () {
485       var $carousel = $(this)
486       $carousel.carousel($carousel.data())
487     })
488   })
489
490 }(window.jQuery);
491
492 /* ========================================================================
493  * Bootstrap: collapse.js v3.0.0
494  * http://twbs.github.com/bootstrap/javascript.html#collapse
495  * ========================================================================
496  * Copyright 2012 Twitter, Inc.
497  *
498  * Licensed under the Apache License, Version 2.0 (the "License");
499  * you may not use this file except in compliance with the License.
500  * You may obtain a copy of the License at
501  *
502  * http://www.apache.org/licenses/LICENSE-2.0
503  *
504  * Unless required by applicable law or agreed to in writing, software
505  * distributed under the License is distributed on an "AS IS" BASIS,
506  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
507  * See the License for the specific language governing permissions and
508  * limitations under the License.
509  * ======================================================================== */
510
511
512 +function ($) { "use strict";
513
514   // COLLAPSE PUBLIC CLASS DEFINITION
515   // ================================
516
517   var Collapse = function (element, options) {
518     this.$element      = $(element)
519     this.options       = $.extend({}, Collapse.DEFAULTS, options)
520     this.transitioning = null
521
522     if (this.options.parent) this.$parent = $(this.options.parent)
523     if (this.options.toggle) this.toggle()
524   }
525
526   Collapse.DEFAULTS = {
527     toggle: true
528   }
529
530   Collapse.prototype.dimension = function () {
531     var hasWidth = this.$element.hasClass('width')
532     return hasWidth ? 'width' : 'height'
533   }
534
535   Collapse.prototype.show = function () {
536     if (this.transitioning || this.$element.hasClass('in')) return
537
538     var startEvent = $.Event('show.bs.collapse')
539     this.$element.trigger(startEvent)
540     if (startEvent.isDefaultPrevented()) return
541
542     var actives = this.$parent && this.$parent.find('> .panel > .in')
543
544     if (actives && actives.length) {
545       var hasData = actives.data('bs.collapse')
546       if (hasData && hasData.transitioning) return
547       actives.collapse('hide')
548       hasData || actives.data('bs.collapse', null)
549     }
550
551     var dimension = this.dimension()
552
553     this.$element
554       .removeClass('collapse')
555       .addClass('collapsing')
556       [dimension](0)
557
558     this.transitioning = 1
559
560     var complete = function () {
561       this.$element
562         .removeClass('collapsing')
563         .addClass('in')
564         [dimension]('auto')
565       this.transitioning = 0
566       this.$element.trigger('shown.bs.collapse')
567     }
568
569     if (!$.support.transition) return complete.call(this)
570
571     var scrollSize = $.camelCase(['scroll', dimension].join('-'))
572
573     this.$element
574       .one($.support.transition.end, $.proxy(complete, this))
575       .emulateTransitionEnd(350)
576       [dimension](this.$element[0][scrollSize])
577   }
578
579   Collapse.prototype.hide = function () {
580     if (this.transitioning || !this.$element.hasClass('in')) return
581
582     var startEvent = $.Event('hide.bs.collapse')
583     this.$element.trigger(startEvent)
584     if (startEvent.isDefaultPrevented()) return
585
586     var dimension = this.dimension()
587
588     this.$element
589       [dimension](this.$element[dimension]())
590       [0].offsetHeight
591
592     this.$element
593       .addClass('collapsing')
594       .removeClass('collapse')
595       .removeClass('in')
596
597     this.transitioning = 1
598
599     var complete = function () {
600       this.transitioning = 0
601       this.$element
602         .trigger('hidden.bs.collapse')
603         .removeClass('collapsing')
604         .addClass('collapse')
605     }
606
607     if (!$.support.transition) return complete.call(this)
608
609     this.$element
610       [dimension](0)
611       .one($.support.transition.end, $.proxy(complete, this))
612       .emulateTransitionEnd(350)
613   }
614
615   Collapse.prototype.toggle = function () {
616     this[this.$element.hasClass('in') ? 'hide' : 'show']()
617   }
618
619
620   // COLLAPSE PLUGIN DEFINITION
621   // ==========================
622
623   var old = $.fn.collapse
624
625   $.fn.collapse = function (option) {
626     return this.each(function () {
627       var $this   = $(this)
628       var data    = $this.data('bs.collapse')
629       var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
630
631       if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
632       if (typeof option == 'string') data[option]()
633     })
634   }
635
636   $.fn.collapse.Constructor = Collapse
637
638
639   // COLLAPSE NO CONFLICT
640   // ====================
641
642   $.fn.collapse.noConflict = function () {
643     $.fn.collapse = old
644     return this
645   }
646
647
648   // COLLAPSE DATA-API
649   // =================
650
651   $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
652     var $this   = $(this), href
653     var target  = $this.attr('data-target')
654         || e.preventDefault()
655         || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
656     var $target = $(target)
657     var data    = $target.data('bs.collapse')
658     var option  = data ? 'toggle' : $this.data()
659     var parent  = $this.attr('data-parent')
660     var $parent = parent && $(parent)
661
662     if (!data || !data.transitioning) {
663       if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed')
664       $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
665     }
666
667     $target.collapse(option)
668   })
669
670 }(window.jQuery);
671
672 /* ========================================================================
673  * Bootstrap: dropdown.js v3.0.0
674  * http://twbs.github.com/bootstrap/javascript.html#dropdowns
675  * ========================================================================
676  * Copyright 2012 Twitter, Inc.
677  *
678  * Licensed under the Apache License, Version 2.0 (the "License");
679  * you may not use this file except in compliance with the License.
680  * You may obtain a copy of the License at
681  *
682  * http://www.apache.org/licenses/LICENSE-2.0
683  *
684  * Unless required by applicable law or agreed to in writing, software
685  * distributed under the License is distributed on an "AS IS" BASIS,
686  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
687  * See the License for the specific language governing permissions and
688  * limitations under the License.
689  * ======================================================================== */
690
691
692 +function ($) { "use strict";
693
694   // DROPDOWN CLASS DEFINITION
695   // =========================
696
697   var backdrop = '.dropdown-backdrop'
698   var toggle   = '[data-toggle=dropdown]'
699   var Dropdown = function (element) {
700     var $el = $(element).on('click.bs.dropdown', this.toggle)
701   }
702
703   Dropdown.prototype.toggle = function (e) {
704     var $this = $(this)
705
706     if ($this.is('.disabled, :disabled')) return
707
708     var $parent  = getParent($this)
709     var isActive = $parent.hasClass('open')
710
711     clearMenus()
712
713     if (!isActive) {
714       if ('ontouchstart' in document.documentElement) {
715         // if mobile we we use a backdrop because click events don't delegate
716         $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
717       }
718
719       $parent.trigger(e = $.Event('show.bs.dropdown'))
720
721       if (e.isDefaultPrevented()) return
722
723       $parent
724         .toggleClass('open')
725         .trigger('shown.bs.dropdown')
726     }
727
728     $this.focus()
729
730     return false
731   }
732
733   Dropdown.prototype.keydown = function (e) {
734     if (!/(38|40|27)/.test(e.keyCode)) return
735
736     var $this = $(this)
737
738     e.preventDefault()
739     e.stopPropagation()
740
741     if ($this.is('.disabled, :disabled')) return
742
743     var $parent  = getParent($this)
744     var isActive = $parent.hasClass('open')
745
746     if (!isActive || (isActive && e.keyCode == 27)) {
747       if (e.which == 27) $parent.find(toggle).focus()
748       return $this.click()
749     }
750
751     var $items = $('[role=menu] li:not(.divider):visible a', $parent)
752
753     if (!$items.length) return
754
755     var index = $items.index($items.filter(':focus'))
756
757     if (e.keyCode == 38 && index > 0)                 index--                        // up
758     if (e.keyCode == 40 && index < $items.length - 1) index++                        // down
759     if (!~index)                                      index=0
760
761     $items.eq(index).focus()
762   }
763
764   function clearMenus() {
765     $(backdrop).remove()
766     $(toggle).each(function (e) {
767       var $parent = getParent($(this))
768       if (!$parent.hasClass('open')) return
769       $parent.trigger(e = $.Event('hide.bs.dropdown'))
770       if (e.isDefaultPrevented()) return
771       $parent.removeClass('open').trigger('hidden.bs.dropdown')
772     })
773   }
774
775   function getParent($this) {
776     var selector = $this.attr('data-target')
777
778     if (!selector) {
779       selector = $this.attr('href')
780       selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
781     }
782
783     var $parent = selector && $(selector)
784
785     return $parent && $parent.length ? $parent : $this.parent()
786   }
787
788
789   // DROPDOWN PLUGIN DEFINITION
790   // ==========================
791
792   var old = $.fn.dropdown
793
794   $.fn.dropdown = function (option) {
795     return this.each(function () {
796       var $this = $(this)
797       var data  = $this.data('dropdown')
798
799       if (!data) $this.data('dropdown', (data = new Dropdown(this)))
800       if (typeof option == 'string') data[option].call($this)
801     })
802   }
803
804   $.fn.dropdown.Constructor = Dropdown
805
806
807   // DROPDOWN NO CONFLICT
808   // ====================
809
810   $.fn.dropdown.noConflict = function () {
811     $.fn.dropdown = old
812     return this
813   }
814
815
816   // APPLY TO STANDARD DROPDOWN ELEMENTS
817   // ===================================
818
819   $(document)
820     .on('click.bs.dropdown.data-api', clearMenus)
821     .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
822     .on('click.bs.dropdown.data-api'  , toggle, Dropdown.prototype.toggle)
823     .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
824
825 }(window.jQuery);
826
827 /* ========================================================================
828  * Bootstrap: modal.js v3.0.0
829  * http://twbs.github.com/bootstrap/javascript.html#modals
830  * ========================================================================
831  * Copyright 2012 Twitter, Inc.
832  *
833  * Licensed under the Apache License, Version 2.0 (the "License");
834  * you may not use this file except in compliance with the License.
835  * You may obtain a copy of the License at
836  *
837  * http://www.apache.org/licenses/LICENSE-2.0
838  *
839  * Unless required by applicable law or agreed to in writing, software
840  * distributed under the License is distributed on an "AS IS" BASIS,
841  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
842  * See the License for the specific language governing permissions and
843  * limitations under the License.
844  * ======================================================================== */
845
846
847 +function ($) { "use strict";
848
849   // MODAL CLASS DEFINITION
850   // ======================
851
852   var Modal = function (element, options) {
853     this.options   = options
854     this.$element  = $(element).on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
855     this.$backdrop =
856     this.isShown   = null
857
858     if (this.options.remote) this.$element.load(this.options.remote)
859   }
860
861   Modal.DEFAULTS = {
862       backdrop: true
863     , keyboard: true
864     , show: true
865   }
866
867   Modal.prototype.toggle = function (_relatedTarget) {
868     return this[!this.isShown ? 'show' : 'hide'](_relatedTarget)
869   }
870
871   Modal.prototype.show = function (_relatedTarget) {
872     var that = this
873     var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
874
875     this.$element.trigger(e)
876
877     if (this.isShown || e.isDefaultPrevented()) return
878
879     this.isShown = true
880
881     this.escape()
882
883     this.backdrop(function () {
884       var transition = $.support.transition && that.$element.hasClass('fade')
885
886       if (!that.$element.parent().length) {
887         that.$element.appendTo(document.body) // don't move modals dom position
888       }
889
890       that.$element.show()
891
892       if (transition) {
893         that.$element[0].offsetWidth // force reflow
894       }
895
896       that.$element
897         .addClass('in')
898         .attr('aria-hidden', false)
899
900       that.enforceFocus()
901
902       var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
903
904       transition ?
905         that.$element
906           .one($.support.transition.end, function () {
907             that.$element.focus().trigger(e)
908           })
909           .emulateTransitionEnd(300) :
910         that.$element.focus().trigger(e)
911     })
912   }
913
914   Modal.prototype.hide = function (e) {
915     if (e) e.preventDefault()
916
917     e = $.Event('hide.bs.modal')
918
919     this.$element.trigger(e)
920
921     if (!this.isShown || e.isDefaultPrevented()) return
922
923     this.isShown = false
924
925     this.escape()
926
927     $(document).off('focusin.bs.modal')
928
929     this.$element
930       .removeClass('in')
931       .attr('aria-hidden', true)
932       .off('click.dismiss.modal')
933
934     $.support.transition && this.$element.hasClass('fade') ?
935       this.$element
936         .one($.support.transition.end, $.proxy(this.hideModal, this))
937         .emulateTransitionEnd(300) :
938       this.hideModal()
939   }
940
941   Modal.prototype.enforceFocus = function () {
942     $(document)
943       .off('focusin.bs.modal') // guard against infinite focus loop
944       .on('focusin.bs.modal', $.proxy(function (e) {
945         if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
946           this.$element.focus()
947         }
948       }, this))
949   }
950
951   Modal.prototype.escape = function () {
952     if (this.isShown && this.options.keyboard) {
953       this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
954         e.which == 27 && this.hide()
955       }, this))
956     } else if (!this.isShown) {
957       this.$element.off('keyup.dismiss.bs.modal')
958     }
959   }
960
961   Modal.prototype.hideModal = function () {
962     var that = this
963     this.$element.hide()
964     this.backdrop(function () {
965       that.removeBackdrop()
966       that.$element.trigger('hidden.bs.modal')
967     })
968   }
969
970   Modal.prototype.removeBackdrop = function () {
971     this.$backdrop && this.$backdrop.remove()
972     this.$backdrop = null
973   }
974
975   Modal.prototype.backdrop = function (callback) {
976     var that    = this
977     var animate = this.$element.hasClass('fade') ? 'fade' : ''
978
979     if (this.isShown && this.options.backdrop) {
980       var doAnimate = $.support.transition && animate
981
982       this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
983         .appendTo(document.body)
984
985       this.$element.on('click.dismiss.modal', $.proxy(function (e) {
986         if (e.target !== e.currentTarget) return
987         this.options.backdrop == 'static'
988           ? this.$element[0].focus.call(this.$element[0])
989           : this.hide.call(this)
990       }, this))
991
992       if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
993
994       this.$backdrop.addClass('in')
995
996       if (!callback) return
997
998       doAnimate ?
999         this.$backdrop
1000           .one($.support.transition.end, callback)
1001           .emulateTransitionEnd(150) :
1002         callback()
1003
1004     } else if (!this.isShown && this.$backdrop) {
1005       this.$backdrop.removeClass('in')
1006
1007       $.support.transition && this.$element.hasClass('fade')?
1008         this.$backdrop
1009           .one($.support.transition.end, callback)
1010           .emulateTransitionEnd(150) :
1011         callback()
1012
1013     } else if (callback) {
1014       callback()
1015     }
1016   }
1017
1018
1019   // MODAL PLUGIN DEFINITION
1020   // =======================
1021
1022   var old = $.fn.modal
1023
1024   $.fn.modal = function (option, _relatedTarget) {
1025     return this.each(function () {
1026       var $this   = $(this)
1027       var data    = $this.data('bs.modal')
1028       var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
1029
1030       if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
1031       if (typeof option == 'string') data[option](_relatedTarget)
1032       else if (options.show) data.show(_relatedTarget)
1033     })
1034   }
1035
1036   $.fn.modal.Constructor = Modal
1037
1038
1039   // MODAL NO CONFLICT
1040   // =================
1041
1042   $.fn.modal.noConflict = function () {
1043     $.fn.modal = old
1044     return this
1045   }
1046
1047
1048   // MODAL DATA-API
1049   // ==============
1050
1051   $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
1052     var $this   = $(this)
1053     var href    = $this.attr('href')
1054     var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
1055     var option  = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
1056
1057     e.preventDefault()
1058
1059     $target
1060       .modal(option, this)
1061       .one('hide', function () {
1062         $this.is(':visible') && $this.focus()
1063       })
1064   })
1065
1066   $(document)
1067     .on('shown.bs.modal',  '.modal', function () { $(document.body).addClass('modal-open') })
1068     .on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') })
1069
1070 }(window.jQuery);
1071
1072 /* ========================================================================
1073  * Bootstrap: tooltip.js v3.0.0
1074  * http://twbs.github.com/bootstrap/javascript.html#tooltip
1075  * Inspired by the original jQuery.tipsy by Jason Frame
1076  * ========================================================================
1077  * Copyright 2012 Twitter, Inc.
1078  *
1079  * Licensed under the Apache License, Version 2.0 (the "License");
1080  * you may not use this file except in compliance with the License.
1081  * You may obtain a copy of the License at
1082  *
1083  * http://www.apache.org/licenses/LICENSE-2.0
1084  *
1085  * Unless required by applicable law or agreed to in writing, software
1086  * distributed under the License is distributed on an "AS IS" BASIS,
1087  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1088  * See the License for the specific language governing permissions and
1089  * limitations under the License.
1090  * ======================================================================== */
1091
1092
1093 +function ($) { "use strict";
1094
1095   // TOOLTIP PUBLIC CLASS DEFINITION
1096   // ===============================
1097
1098   var Tooltip = function (element, options) {
1099     this.type       =
1100     this.options    =
1101     this.enabled    =
1102     this.timeout    =
1103     this.hoverState =
1104     this.$element   = null
1105
1106     this.init('tooltip', element, options)
1107   }
1108
1109   Tooltip.DEFAULTS = {
1110     animation: true
1111   , placement: 'top'
1112   , selector: false
1113   , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
1114   , trigger: 'hover focus'
1115   , title: ''
1116   , delay: 0
1117   , html: false
1118   , container: false
1119   }
1120
1121   Tooltip.prototype.init = function (type, element, options) {
1122     this.enabled  = true
1123     this.type     = type
1124     this.$element = $(element)
1125     this.options  = this.getOptions(options)
1126
1127     var triggers = this.options.trigger.split(' ')
1128
1129     for (var i = triggers.length; i--;) {
1130       var trigger = triggers[i]
1131
1132       if (trigger == 'click') {
1133         this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
1134       } else if (trigger != 'manual') {
1135         var eventIn  = trigger == 'hover' ? 'mouseenter' : 'focus'
1136         var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
1137
1138         this.$element.on(eventIn  + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
1139         this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
1140       }
1141     }
1142
1143     this.options.selector ?
1144       (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
1145       this.fixTitle()
1146   }
1147
1148   Tooltip.prototype.getDefaults = function () {
1149     return Tooltip.DEFAULTS
1150   }
1151
1152   Tooltip.prototype.getOptions = function (options) {
1153     options = $.extend({}, this.getDefaults(), this.$element.data(), options)
1154
1155     if (options.delay && typeof options.delay == 'number') {
1156       options.delay = {
1157         show: options.delay
1158       , hide: options.delay
1159       }
1160     }
1161
1162     return options
1163   }
1164
1165   Tooltip.prototype.getDelegateOptions = function () {
1166     var options  = {}
1167     var defaults = this.getDefaults()
1168
1169     this._options && $.each(this._options, function (key, value) {
1170       if (defaults[key] != value) options[key] = value
1171     })
1172
1173     return options
1174   }
1175
1176   Tooltip.prototype.enter = function (obj) {
1177     var self = obj instanceof this.constructor ?
1178       obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
1179
1180     clearTimeout(self.timeout)
1181
1182     if (!self.options.delay || !self.options.delay.show) return self.show()
1183
1184     self.hoverState = 'in'
1185     self.timeout    = setTimeout(function () {
1186       if (self.hoverState == 'in') self.show()
1187     }, self.options.delay.show)
1188   }
1189
1190   Tooltip.prototype.leave = function (obj) {
1191     var self = obj instanceof this.constructor ?
1192       obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
1193
1194     clearTimeout(self.timeout)
1195
1196     if (!self.options.delay || !self.options.delay.hide) return self.hide()
1197
1198     self.hoverState = 'out'
1199     self.timeout    = setTimeout(function () {
1200       if (self.hoverState == 'out') self.hide()
1201     }, self.options.delay.hide)
1202   }
1203
1204   Tooltip.prototype.show = function () {
1205     var e = $.Event('show.bs.'+ this.type)
1206
1207     if (this.hasContent() && this.enabled) {
1208       this.$element.trigger(e)
1209
1210       if (e.isDefaultPrevented()) return
1211
1212       var $tip = this.tip()
1213
1214       this.setContent()
1215
1216       if (this.options.animation) $tip.addClass('fade')
1217
1218       var placement = typeof this.options.placement == 'function' ?
1219         this.options.placement.call(this, $tip[0], this.$element[0]) :
1220         this.options.placement
1221
1222       var autoToken = /\s?auto?\s?/i
1223       var autoPlace = autoToken.test(placement)
1224       if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
1225
1226       $tip
1227         .detach()
1228         .css({ top: 0, left: 0, display: 'block' })
1229         .addClass(placement)
1230
1231       this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
1232
1233       var pos          = this.getPosition()
1234       var actualWidth  = $tip[0].offsetWidth
1235       var actualHeight = $tip[0].offsetHeight
1236
1237       if (autoPlace) {
1238         var $parent = this.$element.parent()
1239
1240         var orgPlacement = placement
1241         var docScroll    = document.documentElement.scrollTop || document.body.scrollTop
1242         var parentWidth  = this.options.container == 'body' ? window.innerWidth  : $parent.outerWidth()
1243         var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
1244         var parentLeft   = this.options.container == 'body' ? 0 : $parent.offset().left
1245
1246         placement = placement == 'bottom' && pos.top   + pos.height  + actualHeight - docScroll > parentHeight  ? 'top'    :
1247                     placement == 'top'    && pos.top   - docScroll   - actualHeight < 0                         ? 'bottom' :
1248                     placement == 'right'  && pos.right + actualWidth > parentWidth                              ? 'left'   :
1249                     placement == 'left'   && pos.left  - actualWidth < parentLeft                               ? 'right'  :
1250                     placement
1251
1252         $tip
1253           .removeClass(orgPlacement)
1254           .addClass(placement)
1255       }
1256
1257       var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
1258
1259       this.applyPlacement(calculatedOffset, placement)
1260       this.$element.trigger('shown.bs.' + this.type)
1261     }
1262   }
1263
1264   Tooltip.prototype.applyPlacement = function(offset, placement) {
1265     var replace
1266     var $tip   = this.tip()
1267     var width  = $tip[0].offsetWidth
1268     var height = $tip[0].offsetHeight
1269
1270     // manually read margins because getBoundingClientRect includes difference
1271     var marginTop = parseInt($tip.css('margin-top'), 10)
1272     var marginLeft = parseInt($tip.css('margin-left'), 10)
1273
1274     // we must check for NaN for ie 8/9
1275     if (isNaN(marginTop))  marginTop  = 0
1276     if (isNaN(marginLeft)) marginLeft = 0
1277
1278     offset.top  = offset.top  + marginTop
1279     offset.left = offset.left + marginLeft
1280
1281     $tip
1282       .offset(offset)
1283       .addClass('in')
1284
1285     // check to see if placing tip in new offset caused the tip to resize itself
1286     var actualWidth  = $tip[0].offsetWidth
1287     var actualHeight = $tip[0].offsetHeight
1288
1289     if (placement == 'top' && actualHeight != height) {
1290       replace = true
1291       offset.top = offset.top + height - actualHeight
1292     }
1293
1294     if (/bottom|top/.test(placement)) {
1295       var delta = 0
1296
1297       if (offset.left < 0) {
1298         delta       = offset.left * -2
1299         offset.left = 0
1300
1301         $tip.offset(offset)
1302
1303         actualWidth  = $tip[0].offsetWidth
1304         actualHeight = $tip[0].offsetHeight
1305       }
1306
1307       this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
1308     } else {
1309       this.replaceArrow(actualHeight - height, actualHeight, 'top')
1310     }
1311
1312     if (replace) $tip.offset(offset)
1313   }
1314
1315   Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
1316     this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
1317   }
1318
1319   Tooltip.prototype.setContent = function () {
1320     var $tip  = this.tip()
1321     var title = this.getTitle()
1322
1323     $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
1324     $tip.removeClass('fade in top bottom left right')
1325   }
1326
1327   Tooltip.prototype.hide = function () {
1328     var that = this
1329     var $tip = this.tip()
1330     var e    = $.Event('hide.bs.' + this.type)
1331
1332     function complete() { $tip.detach() }
1333
1334     this.$element.trigger(e)
1335
1336     if (e.isDefaultPrevented()) return
1337
1338     $tip.removeClass('in')
1339
1340     $.support.transition && this.$tip.hasClass('fade') ?
1341       $tip
1342         .one($.support.transition.end, complete)
1343         .emulateTransitionEnd(150) :
1344       complete()
1345
1346     this.$element.trigger('hidden.bs.' + this.type)
1347
1348     return this
1349   }
1350
1351   Tooltip.prototype.fixTitle = function () {
1352     var $e = this.$element
1353     if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
1354       $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
1355     }
1356   }
1357
1358   Tooltip.prototype.hasContent = function () {
1359     return this.getTitle()
1360   }
1361
1362   Tooltip.prototype.getPosition = function () {
1363     var el = this.$element[0]
1364     return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
1365       width: el.offsetWidth
1366     , height: el.offsetHeight
1367     }, this.$element.offset())
1368   }
1369
1370   Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
1371     return placement == 'bottom' ? { top: pos.top + pos.height,   left: pos.left + pos.width / 2 - actualWidth / 2  } :
1372            placement == 'top'    ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2  } :
1373            placement == 'left'   ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
1374         /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width   }
1375   }
1376
1377   Tooltip.prototype.getTitle = function () {
1378     var title
1379     var $e = this.$element
1380     var o  = this.options
1381
1382     title = $e.attr('data-original-title')
1383       || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)
1384
1385     return title
1386   }
1387
1388   Tooltip.prototype.tip = function () {
1389     return this.$tip = this.$tip || $(this.options.template)
1390   }
1391
1392   Tooltip.prototype.arrow = function () {
1393     return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
1394   }
1395
1396   Tooltip.prototype.validate = function () {
1397     if (!this.$element[0].parentNode) {
1398       this.hide()
1399       this.$element = null
1400       this.options  = null
1401     }
1402   }
1403
1404   Tooltip.prototype.enable = function () {
1405     this.enabled = true
1406   }
1407
1408   Tooltip.prototype.disable = function () {
1409     this.enabled = false
1410   }
1411
1412   Tooltip.prototype.toggleEnabled = function () {
1413     this.enabled = !this.enabled
1414   }
1415
1416   Tooltip.prototype.toggle = function (e) {
1417     var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this
1418     self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
1419   }
1420
1421   Tooltip.prototype.destroy = function () {
1422     this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
1423   }
1424
1425
1426   // TOOLTIP PLUGIN DEFINITION
1427   // =========================
1428
1429   var old = $.fn.tooltip
1430
1431   $.fn.tooltip = function (option) {
1432     return this.each(function () {
1433       var $this   = $(this)
1434       var data    = $this.data('bs.tooltip')
1435       var options = typeof option == 'object' && option
1436
1437       if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
1438       if (typeof option == 'string') data[option]()
1439     })
1440   }
1441
1442   $.fn.tooltip.Constructor = Tooltip
1443
1444
1445   // TOOLTIP NO CONFLICT
1446   // ===================
1447
1448   $.fn.tooltip.noConflict = function () {
1449     $.fn.tooltip = old
1450     return this
1451   }
1452
1453 }(window.jQuery);
1454
1455 /* ========================================================================
1456  * Bootstrap: popover.js v3.0.0
1457  * http://twbs.github.com/bootstrap/javascript.html#popovers
1458  * ========================================================================
1459  * Copyright 2012 Twitter, Inc.
1460  *
1461  * Licensed under the Apache License, Version 2.0 (the "License");
1462  * you may not use this file except in compliance with the License.
1463  * You may obtain a copy of the License at
1464  *
1465  * http://www.apache.org/licenses/LICENSE-2.0
1466  *
1467  * Unless required by applicable law or agreed to in writing, software
1468  * distributed under the License is distributed on an "AS IS" BASIS,
1469  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1470  * See the License for the specific language governing permissions and
1471  * limitations under the License.
1472  * ======================================================================== */
1473
1474
1475 +function ($) { "use strict";
1476
1477   // POPOVER PUBLIC CLASS DEFINITION
1478   // ===============================
1479
1480   var Popover = function (element, options) {
1481     this.init('popover', element, options)
1482   }
1483
1484   if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
1485
1486   Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
1487     placement: 'right'
1488   , trigger: 'click'
1489   , content: ''
1490   , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
1491   })
1492
1493
1494   // NOTE: POPOVER EXTENDS tooltip.js
1495   // ================================
1496
1497   Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
1498
1499   Popover.prototype.constructor = Popover
1500
1501   Popover.prototype.getDefaults = function () {
1502     return Popover.DEFAULTS
1503   }
1504
1505   Popover.prototype.setContent = function () {
1506     var $tip    = this.tip()
1507     var title   = this.getTitle()
1508     var content = this.getContent()
1509
1510     $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
1511     $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
1512
1513     $tip.removeClass('fade top bottom left right in')
1514
1515     // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
1516     // this manually by checking the contents.
1517     if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
1518   }
1519
1520   Popover.prototype.hasContent = function () {
1521     return this.getTitle() || this.getContent()
1522   }
1523
1524   Popover.prototype.getContent = function () {
1525     var $e = this.$element
1526     var o  = this.options
1527
1528     return $e.attr('data-content')
1529       || (typeof o.content == 'function' ?
1530             o.content.call($e[0]) :
1531             o.content)
1532   }
1533
1534   Popover.prototype.arrow = function () {
1535     return this.$arrow = this.$arrow || this.tip().find('.arrow')
1536   }
1537
1538   Popover.prototype.tip = function () {
1539     if (!this.$tip) this.$tip = $(this.options.template)
1540     return this.$tip
1541   }
1542
1543
1544   // POPOVER PLUGIN DEFINITION
1545   // =========================
1546
1547   var old = $.fn.popover
1548
1549   $.fn.popover = function (option) {
1550     return this.each(function () {
1551       var $this   = $(this)
1552       var data    = $this.data('bs.popover')
1553       var options = typeof option == 'object' && option
1554
1555       if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
1556       if (typeof option == 'string') data[option]()
1557     })
1558   }
1559
1560   $.fn.popover.Constructor = Popover
1561
1562
1563   // POPOVER NO CONFLICT
1564   // ===================
1565
1566   $.fn.popover.noConflict = function () {
1567     $.fn.popover = old
1568     return this
1569   }
1570
1571 }(window.jQuery);
1572
1573 /* ========================================================================
1574  * Bootstrap: scrollspy.js v3.0.0
1575  * http://twbs.github.com/bootstrap/javascript.html#scrollspy
1576  * ========================================================================
1577  * Copyright 2012 Twitter, Inc.
1578  *
1579  * Licensed under the Apache License, Version 2.0 (the "License");
1580  * you may not use this file except in compliance with the License.
1581  * You may obtain a copy of the License at
1582  *
1583  * http://www.apache.org/licenses/LICENSE-2.0
1584  *
1585  * Unless required by applicable law or agreed to in writing, software
1586  * distributed under the License is distributed on an "AS IS" BASIS,
1587  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1588  * See the License for the specific language governing permissions and
1589  * limitations under the License.
1590  * ======================================================================== */
1591
1592
1593 +function ($) { "use strict";
1594
1595   // SCROLLSPY CLASS DEFINITION
1596   // ==========================
1597
1598   function ScrollSpy(element, options) {
1599     var href
1600     var process  = $.proxy(this.process, this)
1601
1602     this.$element       = $(element).is('body') ? $(window) : $(element)
1603     this.$body          = $('body')
1604     this.$scrollElement = this.$element.on('scroll.bs.scroll-spy.data-api', process)
1605     this.options        = $.extend({}, ScrollSpy.DEFAULTS, options)
1606     this.selector       = (this.options.target
1607       || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
1608       || '') + ' .nav li > a'
1609     this.offsets        = $([])
1610     this.targets        = $([])
1611     this.activeTarget   = null
1612
1613     this.refresh()
1614     this.process()
1615   }
1616
1617   ScrollSpy.DEFAULTS = {
1618     offset: 10
1619   }
1620
1621   ScrollSpy.prototype.refresh = function () {
1622     var offsetMethod = this.$element[0] == window ? 'offset' : 'position'
1623
1624     this.offsets = $([])
1625     this.targets = $([])
1626
1627     var self     = this
1628     var $targets = this.$body
1629       .find(this.selector)
1630       .map(function () {
1631         var $el   = $(this)
1632         var href  = $el.data('target') || $el.attr('href')
1633         var $href = /^#\w/.test(href) && $(href)
1634
1635         return ($href
1636           && $href.length
1637           && [[ $href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null
1638       })
1639       .sort(function (a, b) { return a[0] - b[0] })
1640       .each(function () {
1641         self.offsets.push(this[0])
1642         self.targets.push(this[1])
1643       })
1644   }
1645
1646   ScrollSpy.prototype.process = function () {
1647     var scrollTop    = this.$scrollElement.scrollTop() + this.options.offset
1648     var scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
1649     var maxScroll    = scrollHeight - this.$scrollElement.height()
1650     var offsets      = this.offsets
1651     var targets      = this.targets
1652     var activeTarget = this.activeTarget
1653     var i
1654
1655     if (scrollTop >= maxScroll) {
1656       return activeTarget != (i = targets.last()[0]) && this.activate(i)
1657     }
1658
1659     for (i = offsets.length; i--;) {
1660       activeTarget != targets[i]
1661         && scrollTop >= offsets[i]
1662         && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
1663         && this.activate( targets[i] )
1664     }
1665   }
1666
1667   ScrollSpy.prototype.activate = function (target) {
1668     this.activeTarget = target
1669
1670     $(this.selector)
1671       .parents('.active')
1672       .removeClass('active')
1673
1674     var selector = this.selector
1675       + '[data-target="' + target + '"],'
1676       + this.selector + '[href="' + target + '"]'
1677
1678     var active = $(selector)
1679       .parents('li')
1680       .addClass('active')
1681
1682     if (active.parent('.dropdown-menu').length)  {
1683       active = active
1684         .closest('li.dropdown')
1685         .addClass('active')
1686     }
1687
1688     active.trigger('activate')
1689   }
1690
1691
1692   // SCROLLSPY PLUGIN DEFINITION
1693   // ===========================
1694
1695   var old = $.fn.scrollspy
1696
1697   $.fn.scrollspy = function (option) {
1698     return this.each(function () {
1699       var $this   = $(this)
1700       var data    = $this.data('bs.scrollspy')
1701       var options = typeof option == 'object' && option
1702
1703       if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
1704       if (typeof option == 'string') data[option]()
1705     })
1706   }
1707
1708   $.fn.scrollspy.Constructor = ScrollSpy
1709
1710
1711   // SCROLLSPY NO CONFLICT
1712   // =====================
1713
1714   $.fn.scrollspy.noConflict = function () {
1715     $.fn.scrollspy = old
1716     return this
1717   }
1718
1719
1720   // SCROLLSPY DATA-API
1721   // ==================
1722
1723   $(window).on('load', function () {
1724     $('[data-spy="scroll"]').each(function () {
1725       var $spy = $(this)
1726       $spy.scrollspy($spy.data())
1727     })
1728   })
1729
1730 }(window.jQuery);
1731
1732 /* ========================================================================
1733  * Bootstrap: tab.js v3.0.0
1734  * http://twbs.github.com/bootstrap/javascript.html#tabs
1735  * ========================================================================
1736  * Copyright 2012 Twitter, Inc.
1737  *
1738  * Licensed under the Apache License, Version 2.0 (the "License");
1739  * you may not use this file except in compliance with the License.
1740  * You may obtain a copy of the License at
1741  *
1742  * http://www.apache.org/licenses/LICENSE-2.0
1743  *
1744  * Unless required by applicable law or agreed to in writing, software
1745  * distributed under the License is distributed on an "AS IS" BASIS,
1746  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1747  * See the License for the specific language governing permissions and
1748  * limitations under the License.
1749  * ======================================================================== */
1750
1751
1752 +function ($) { "use strict";
1753
1754   // TAB CLASS DEFINITION
1755   // ====================
1756
1757   var Tab = function (element) {
1758     this.element = $(element)
1759   }
1760
1761   Tab.prototype.show = function () {
1762     var $this    = this.element
1763     var $ul      = $this.closest('ul:not(.dropdown-menu)')
1764     var selector = $this.attr('data-target')
1765
1766     if (!selector) {
1767       selector = $this.attr('href')
1768       selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
1769     }
1770
1771     if ($this.parent('li').hasClass('active')) return
1772
1773     var previous = $ul.find('.active:last a')[0]
1774     var e        = $.Event('show.bs.tab', {
1775       relatedTarget: previous
1776     })
1777
1778     $this.trigger(e)
1779
1780     if (e.isDefaultPrevented()) return
1781
1782     var $target = $(selector)
1783
1784     this.activate($this.parent('li'), $ul)
1785     this.activate($target, $target.parent(), function () {
1786       $this.trigger({
1787         type: 'shown.bs.tab'
1788       , relatedTarget: previous
1789       })
1790     })
1791   }
1792
1793   Tab.prototype.activate = function (element, container, callback) {
1794     var $active    = container.find('> .active')
1795     var transition = callback
1796       && $.support.transition
1797       && $active.hasClass('fade')
1798
1799     function next() {
1800       $active
1801         .removeClass('active')
1802         .find('> .dropdown-menu > .active')
1803         .removeClass('active')
1804
1805       element.addClass('active')
1806
1807       if (transition) {
1808         element[0].offsetWidth // reflow for transition
1809         element.addClass('in')
1810       } else {
1811         element.removeClass('fade')
1812       }
1813
1814       if (element.parent('.dropdown-menu')) {
1815         element.closest('li.dropdown').addClass('active')
1816       }
1817
1818       callback && callback()
1819     }
1820
1821     transition ?
1822       $active
1823         .one($.support.transition.end, next)
1824         .emulateTransitionEnd(150) :
1825       next()
1826
1827     $active.removeClass('in')
1828   }
1829
1830
1831   // TAB PLUGIN DEFINITION
1832   // =====================
1833
1834   var old = $.fn.tab
1835
1836   $.fn.tab = function ( option ) {
1837     return this.each(function () {
1838       var $this = $(this)
1839       var data  = $this.data('bs.tab')
1840
1841       if (!data) $this.data('bs.tab', (data = new Tab(this)))
1842       if (typeof option == 'string') data[option]()
1843     })
1844   }
1845
1846   $.fn.tab.Constructor = Tab
1847
1848
1849   // TAB NO CONFLICT
1850   // ===============
1851
1852   $.fn.tab.noConflict = function () {
1853     $.fn.tab = old
1854     return this
1855   }
1856
1857
1858   // TAB DATA-API
1859   // ============
1860
1861   $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
1862     e.preventDefault()
1863     $(this).tab('show')
1864   })
1865
1866 }(window.jQuery);
1867
1868 /* ========================================================================
1869  * Bootstrap: affix.js v3.0.0
1870  * http://twbs.github.com/bootstrap/javascript.html#affix
1871  * ========================================================================
1872  * Copyright 2012 Twitter, Inc.
1873  *
1874  * Licensed under the Apache License, Version 2.0 (the "License");
1875  * you may not use this file except in compliance with the License.
1876  * You may obtain a copy of the License at
1877  *
1878  * http://www.apache.org/licenses/LICENSE-2.0
1879  *
1880  * Unless required by applicable law or agreed to in writing, software
1881  * distributed under the License is distributed on an "AS IS" BASIS,
1882  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1883  * See the License for the specific language governing permissions and
1884  * limitations under the License.
1885  * ======================================================================== */
1886
1887
1888 +function ($) { "use strict";
1889
1890   // AFFIX CLASS DEFINITION
1891   // ======================
1892
1893   var Affix = function (element, options) {
1894     this.options = $.extend({}, Affix.DEFAULTS, options)
1895     this.$window = $(window)
1896       .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
1897       .on('click.bs.affix.data-api',  $.proxy(this.checkPositionWithEventLoop, this))
1898
1899     this.$element = $(element)
1900     this.affixed  =
1901     this.unpin    = null
1902
1903     this.checkPosition()
1904   }
1905
1906   Affix.RESET = 'affix affix-top affix-bottom'
1907
1908   Affix.DEFAULTS = {
1909     offset: 0
1910   }
1911
1912   Affix.prototype.checkPositionWithEventLoop = function () {
1913     setTimeout($.proxy(this.checkPosition, this), 1)
1914   }
1915
1916   Affix.prototype.checkPosition = function () {
1917     if (!this.$element.is(':visible')) return
1918
1919     var scrollHeight = $(document).height()
1920     var scrollTop    = this.$window.scrollTop()
1921     var position     = this.$element.offset()
1922     var offset       = this.options.offset
1923     var offsetTop    = offset.top
1924     var offsetBottom = offset.bottom
1925
1926     if (typeof offset != 'object')         offsetBottom = offsetTop = offset
1927     if (typeof offsetTop == 'function')    offsetTop    = offset.top()
1928     if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
1929
1930     var affix = this.unpin   != null && (scrollTop + this.unpin <= position.top) ? false :
1931                 offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
1932                 offsetTop    != null && (scrollTop <= offsetTop) ? 'top' : false
1933
1934     if (this.affixed === affix) return
1935     if (this.unpin) this.$element.css('top', '')
1936
1937     this.affixed = affix
1938     this.unpin   = affix == 'bottom' ? position.top - scrollTop : null
1939
1940     this.$element.removeClass(Affix.RESET).addClass('affix' + (affix ? '-' + affix : ''))
1941
1942     if (affix == 'bottom') {
1943       this.$element.offset({ top: document.body.offsetHeight - offsetBottom - this.$element.height() })
1944     }
1945   }
1946
1947
1948   // AFFIX PLUGIN DEFINITION
1949   // =======================
1950
1951   var old = $.fn.affix
1952
1953   $.fn.affix = function (option) {
1954     return this.each(function () {
1955       var $this   = $(this)
1956       var data    = $this.data('bs.affix')
1957       var options = typeof option == 'object' && option
1958
1959       if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
1960       if (typeof option == 'string') data[option]()
1961     })
1962   }
1963
1964   $.fn.affix.Constructor = Affix
1965
1966
1967   // AFFIX NO CONFLICT
1968   // =================
1969
1970   $.fn.affix.noConflict = function () {
1971     $.fn.affix = old
1972     return this
1973   }
1974
1975
1976   // AFFIX DATA-API
1977   // ==============
1978
1979   $(window).on('load', function () {
1980     $('[data-spy="affix"]').each(function () {
1981       var $spy = $(this)
1982       var data = $spy.data()
1983
1984       data.offset = data.offset || {}
1985
1986       if (data.offsetBottom) data.offset.bottom = data.offsetBottom
1987       if (data.offsetTop)    data.offset.top    = data.offsetTop
1988
1989       $spy.affix(data)
1990     })
1991   })
1992
1993 }(window.jQuery);