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