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