index: no longer using snippets
[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       $.support.transition && this.$element[dimension]('auto')
486     }
487
488   , hide: function () {
489       var dimension
490       if (this.transitioning) return
491       dimension = this.dimension()
492       this.reset(this.$element[dimension]())
493       this.transition('removeClass', $.Event('hide'), 'hidden')
494       this.$element[dimension](0)
495     }
496
497   , reset: function (size) {
498       var dimension = this.dimension()
499
500       this.$element
501         .removeClass('collapse')
502         [dimension](size || 'auto')
503         [0].offsetWidth
504
505       this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
506
507       return this
508     }
509
510   , transition: function (method, startEvent, completeEvent) {
511       var that = this
512         , complete = function () {
513             if (startEvent.type == 'show') that.reset()
514             that.transitioning = 0
515             that.$element.trigger(completeEvent)
516           }
517
518       this.$element.trigger(startEvent)
519
520       if (startEvent.isDefaultPrevented()) return
521
522       this.transitioning = 1
523
524       this.$element[method]('in')
525
526       $.support.transition && this.$element.hasClass('collapse') ?
527         this.$element.one($.support.transition.end, complete) :
528         complete()
529     }
530
531   , toggle: function () {
532       this[this.$element.hasClass('in') ? 'hide' : 'show']()
533     }
534
535   }
536
537
538  /* COLLAPSIBLE PLUGIN DEFINITION
539   * ============================== */
540
541   $.fn.collapse = function (option) {
542     return this.each(function () {
543       var $this = $(this)
544         , data = $this.data('collapse')
545         , options = typeof option == 'object' && option
546       if (!data) $this.data('collapse', (data = new Collapse(this, options)))
547       if (typeof option == 'string') data[option]()
548     })
549   }
550
551   $.fn.collapse.defaults = {
552     toggle: true
553   }
554
555   $.fn.collapse.Constructor = Collapse
556
557
558  /* COLLAPSIBLE DATA-API
559   * ==================== */
560
561   $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
562     var $this = $(this), href
563       , target = $this.attr('data-target')
564         || e.preventDefault()
565         || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
566       , option = $(target).data('collapse') ? 'toggle' : $this.data()
567     $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
568     $(target).collapse(option)
569   })
570
571 }(window.jQuery);/* ============================================================
572  * bootstrap-dropdown.js v2.2.1
573  * http://twitter.github.com/bootstrap/javascript.html#dropdowns
574  * ============================================================
575  * Copyright 2012 Twitter, Inc.
576  *
577  * Licensed under the Apache License, Version 2.0 (the "License");
578  * you may not use this file except in compliance with the License.
579  * You may obtain a copy of the License at
580  *
581  * http://www.apache.org/licenses/LICENSE-2.0
582  *
583  * Unless required by applicable law or agreed to in writing, software
584  * distributed under the License is distributed on an "AS IS" BASIS,
585  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
586  * See the License for the specific language governing permissions and
587  * limitations under the License.
588  * ============================================================ */
589
590
591 !function ($) {
592
593   "use strict"; // jshint ;_;
594
595
596  /* DROPDOWN CLASS DEFINITION
597   * ========================= */
598
599   var toggle = '[data-toggle=dropdown]'
600     , Dropdown = function (element) {
601         var $el = $(element).on('click.dropdown.data-api', this.toggle)
602         $('html').on('click.dropdown.data-api', function () {
603           $el.parent().removeClass('open')
604         })
605       }
606
607   Dropdown.prototype = {
608
609     constructor: Dropdown
610
611   , toggle: function (e) {
612       var $this = $(this)
613         , $parent
614         , isActive
615
616       if ($this.is('.disabled, :disabled')) return
617
618       $parent = getParent($this)
619
620       isActive = $parent.hasClass('open')
621
622       clearMenus()
623
624       if (!isActive) {
625         $parent.toggleClass('open')
626         $this.focus()
627       }
628
629       return false
630     }
631
632   , keydown: function (e) {
633       var $this
634         , $items
635         , $active
636         , $parent
637         , isActive
638         , index
639
640       if (!/(38|40|27)/.test(e.keyCode)) return
641
642       $this = $(this)
643
644       e.preventDefault()
645       e.stopPropagation()
646
647       if ($this.is('.disabled, :disabled')) return
648
649       $parent = getParent($this)
650
651       isActive = $parent.hasClass('open')
652
653       if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
654
655       $items = $('[role=menu] li:not(.divider) a', $parent)
656
657       if (!$items.length) return
658
659       index = $items.index($items.filter(':focus'))
660
661       if (e.keyCode == 38 && index > 0) index--                                        // up
662       if (e.keyCode == 40 && index < $items.length - 1) index++                        // down
663       if (!~index) index = 0
664
665       $items
666         .eq(index)
667         .focus()
668     }
669
670   }
671
672   function clearMenus() {
673     $(toggle).each(function () {
674       getParent($(this)).removeClass('open')
675     })
676   }
677
678   function getParent($this) {
679     var selector = $this.attr('data-target')
680       , $parent
681
682     if (!selector) {
683       selector = $this.attr('href')
684       selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
685     }
686
687     $parent = $(selector)
688     $parent.length || ($parent = $this.parent())
689
690     return $parent
691   }
692
693
694   /* DROPDOWN PLUGIN DEFINITION
695    * ========================== */
696
697   $.fn.dropdown = function (option) {
698     return this.each(function () {
699       var $this = $(this)
700         , data = $this.data('dropdown')
701       if (!data) $this.data('dropdown', (data = new Dropdown(this)))
702       if (typeof option == 'string') data[option].call($this)
703     })
704   }
705
706   $.fn.dropdown.Constructor = Dropdown
707
708
709   /* APPLY TO STANDARD DROPDOWN ELEMENTS
710    * =================================== */
711
712   $(document)
713   //   .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
714   //   .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
715   //   .on('click.dropdown.data-api touchstart.dropdown.data-api'  , toggle, Dropdown.prototype.toggle)
716   //   .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
717
718   .on('click.dropdown.data-api', clearMenus)
719   .on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() })
720   .on('click.dropdown.data-api'  , toggle, Dropdown.prototype.toggle)
721   .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
722
723 }(window.jQuery);/* =========================================================
724  * bootstrap-modal.js v2.2.1
725  * http://twitter.github.com/bootstrap/javascript.html#modals
726  * =========================================================
727  * Copyright 2012 Twitter, Inc.
728  *
729  * Licensed under the Apache License, Version 2.0 (the "License");
730  * you may not use this file except in compliance with the License.
731  * You may obtain a copy of the License at
732  *
733  * http://www.apache.org/licenses/LICENSE-2.0
734  *
735  * Unless required by applicable law or agreed to in writing, software
736  * distributed under the License is distributed on an "AS IS" BASIS,
737  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
738  * See the License for the specific language governing permissions and
739  * limitations under the License.
740  * ========================================================= */
741
742
743 !function ($) {
744
745   "use strict"; // jshint ;_;
746
747
748  /* MODAL CLASS DEFINITION
749   * ====================== */
750
751   var Modal = function (element, options) {
752     this.options = options
753     this.$element = $(element)
754       .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
755     this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
756   }
757
758   Modal.prototype = {
759
760       constructor: Modal
761
762     , toggle: function () {
763         return this[!this.isShown ? 'show' : 'hide']()
764       }
765
766     , show: function () {
767         var that = this
768           , e = $.Event('show')
769
770         this.$element.trigger(e)
771
772         if (this.isShown || e.isDefaultPrevented()) return
773
774         this.isShown = true
775
776         this.escape()
777
778         this.backdrop(function () {
779           var transition = $.support.transition && that.$element.hasClass('fade')
780
781           if (!that.$element.parent().length) {
782             that.$element.appendTo(document.body) //don't move modals dom position
783           }
784
785           that.$element
786             .show()
787
788           if (transition) {
789             that.$element[0].offsetWidth // force reflow
790           }
791
792           that.$element
793             .addClass('in')
794             .attr('aria-hidden', false)
795
796           that.enforceFocus()
797
798           transition ?
799             that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
800             that.$element.focus().trigger('shown')
801
802         })
803       }
804
805     , hide: function (e) {
806         e && e.preventDefault()
807
808         var that = this
809
810         e = $.Event('hide')
811
812         this.$element.trigger(e)
813
814         if (!this.isShown || e.isDefaultPrevented()) return
815
816         this.isShown = false
817
818         this.escape()
819
820         $(document).off('focusin.modal')
821
822         this.$element
823           .removeClass('in')
824           .attr('aria-hidden', true)
825
826         $.support.transition && this.$element.hasClass('fade') ?
827           this.hideWithTransition() :
828           this.hideModal()
829       }
830
831     , enforceFocus: function () {
832         var that = this
833         $(document).on('focusin.modal', function (e) {
834           if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
835             that.$element.focus()
836           }
837         })
838       }
839
840     , escape: function () {
841         var that = this
842         if (this.isShown && this.options.keyboard) {
843           this.$element.on('keyup.dismiss.modal', function ( e ) {
844             e.which == 27 && that.hide()
845           })
846         } else if (!this.isShown) {
847           this.$element.off('keyup.dismiss.modal')
848         }
849       }
850
851     , hideWithTransition: function () {
852         var that = this
853           , timeout = setTimeout(function () {
854               that.$element.off($.support.transition.end)
855               that.hideModal()
856             }, 500)
857
858         this.$element.one($.support.transition.end, function () {
859           clearTimeout(timeout)
860           that.hideModal()
861         })
862       }
863
864     , hideModal: function (that) {
865         this.$element
866           .hide()
867           .trigger('hidden')
868
869         this.backdrop()
870       }
871
872     , removeBackdrop: function () {
873         this.$backdrop.remove()
874         this.$backdrop = null
875       }
876
877     , backdrop: function (callback) {
878         var that = this
879           , animate = this.$element.hasClass('fade') ? 'fade' : ''
880
881         if (this.isShown && this.options.backdrop) {
882           var doAnimate = $.support.transition && animate
883
884           this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
885             .appendTo(document.body)
886
887           this.$backdrop.click(
888             this.options.backdrop == 'static' ?
889               $.proxy(this.$element[0].focus, this.$element[0])
890             : $.proxy(this.hide, this)
891           )
892
893           if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
894
895           this.$backdrop.addClass('in')
896
897           doAnimate ?
898             this.$backdrop.one($.support.transition.end, callback) :
899             callback()
900
901         } else if (!this.isShown && this.$backdrop) {
902           this.$backdrop.removeClass('in')
903
904           $.support.transition && this.$element.hasClass('fade')?
905             this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
906             this.removeBackdrop()
907
908         } else if (callback) {
909           callback()
910         }
911       }
912   }
913
914
915  /* MODAL PLUGIN DEFINITION
916   * ======================= */
917
918   $.fn.modal = function (option) {
919     return this.each(function () {
920       var $this = $(this)
921         , data = $this.data('modal')
922         , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
923       if (!data) $this.data('modal', (data = new Modal(this, options)))
924       if (typeof option == 'string') data[option]()
925       else if (options.show) data.show()
926     })
927   }
928
929   $.fn.modal.defaults = {
930       backdrop: true
931     , keyboard: true
932     , show: true
933   }
934
935   $.fn.modal.Constructor = Modal
936
937
938  /* MODAL DATA-API
939   * ============== */
940
941   $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
942     var $this = $(this)
943       , href = $this.attr('href')
944       , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
945       , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
946
947     e.preventDefault()
948
949     $target
950       .modal(option)
951       .one('hide', function () {
952         $this.focus()
953       })
954   })
955
956 }(window.jQuery);
957 /* ===========================================================
958  * bootstrap-tooltip.js v2.2.1
959  * http://twitter.github.com/bootstrap/javascript.html#tooltips
960  * Inspired by the original jQuery.tipsy by Jason Frame
961  * ===========================================================
962  * Copyright 2012 Twitter, Inc.
963  *
964  * Licensed under the Apache License, Version 2.0 (the "License");
965  * you may not use this file except in compliance with the License.
966  * You may obtain a copy of the License at
967  *
968  * http://www.apache.org/licenses/LICENSE-2.0
969  *
970  * Unless required by applicable law or agreed to in writing, software
971  * distributed under the License is distributed on an "AS IS" BASIS,
972  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
973  * See the License for the specific language governing permissions and
974  * limitations under the License.
975  * ========================================================== */
976
977
978 !function ($) {
979
980   "use strict"; // jshint ;_;
981
982
983  /* TOOLTIP PUBLIC CLASS DEFINITION
984   * =============================== */
985
986   var Tooltip = function (element, options) {
987     this.init('tooltip', element, options)
988   }
989
990   Tooltip.prototype = {
991
992     constructor: Tooltip
993
994   , init: function (type, element, options) {
995       var eventIn
996         , eventOut
997
998       this.type = type
999       this.$element = $(element)
1000       this.options = this.getOptions(options)
1001       this.enabled = true
1002
1003       if (this.options.trigger == 'click') {
1004         this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
1005       } else if (this.options.trigger != 'manual') {
1006         eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
1007         eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
1008         this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
1009         this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
1010       }
1011
1012       this.options.selector ?
1013         (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
1014         this.fixTitle()
1015     }
1016
1017   , getOptions: function (options) {
1018       options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
1019
1020       if (options.delay && typeof options.delay == 'number') {
1021         options.delay = {
1022           show: options.delay
1023         , hide: options.delay
1024         }
1025       }
1026
1027       return options
1028     }
1029
1030   , enter: function (e) {
1031       var self = $(e.currentTarget)[this.type](this._options).data(this.type)
1032
1033       if (!self.options.delay || !self.options.delay.show) return self.show()
1034
1035       clearTimeout(this.timeout)
1036       self.hoverState = 'in'
1037       this.timeout = setTimeout(function() {
1038         if (self.hoverState == 'in') self.show()
1039       }, self.options.delay.show)
1040     }
1041
1042   , leave: function (e) {
1043       var self = $(e.currentTarget)[this.type](this._options).data(this.type)
1044
1045       if (this.timeout) clearTimeout(this.timeout)
1046       if (!self.options.delay || !self.options.delay.hide) return self.hide()
1047
1048       self.hoverState = 'out'
1049       this.timeout = setTimeout(function() {
1050         if (self.hoverState == 'out') self.hide()
1051       }, self.options.delay.hide)
1052     }
1053
1054   , show: function () {
1055       var $tip
1056         , inside
1057         , pos
1058         , actualWidth
1059         , actualHeight
1060         , placement
1061         , tp
1062
1063       if (this.hasContent() && this.enabled) {
1064         $tip = this.tip()
1065         this.setContent()
1066
1067         if (this.options.animation) {
1068           $tip.addClass('fade')
1069         }
1070
1071         placement = typeof this.options.placement == 'function' ?
1072           this.options.placement.call(this, $tip[0], this.$element[0]) :
1073           this.options.placement
1074
1075         inside = /in/.test(placement)
1076
1077         $tip
1078           .detach()
1079           .css({ top: 0, left: 0, display: 'block' })
1080           .insertAfter(this.$element)
1081
1082         pos = this.getPosition(inside)
1083
1084         actualWidth = $tip[0].offsetWidth
1085         actualHeight = $tip[0].offsetHeight
1086
1087         switch (inside ? placement.split(' ')[1] : placement) {
1088           case 'bottom':
1089             tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
1090             break
1091           case 'top':
1092             tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
1093             break
1094           case 'left':
1095             tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
1096             break
1097           case 'right':
1098             tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
1099             break
1100         }
1101
1102         $tip
1103           .offset(tp)
1104           .addClass(placement)
1105           .addClass('in')
1106       }
1107     }
1108
1109   , setContent: function () {
1110       var $tip = this.tip()
1111         , title = this.getTitle()
1112
1113       $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
1114       $tip.removeClass('fade in top bottom left right')
1115     }
1116
1117   , hide: function () {
1118       var that = this
1119         , $tip = this.tip()
1120
1121       $tip.removeClass('in')
1122
1123       function removeWithAnimation() {
1124         var timeout = setTimeout(function () {
1125           $tip.off($.support.transition.end).detach()
1126         }, 500)
1127
1128         $tip.one($.support.transition.end, function () {
1129           clearTimeout(timeout)
1130           $tip.detach()
1131         })
1132       }
1133
1134       $.support.transition && this.$tip.hasClass('fade') ?
1135         removeWithAnimation() :
1136         $tip.detach()
1137
1138       return this
1139     }
1140
1141   , fixTitle: function () {
1142       var $e = this.$element
1143       if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
1144         $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
1145       }
1146     }
1147
1148   , hasContent: function () {
1149       return this.getTitle()
1150     }
1151
1152   , getPosition: function (inside) {
1153       return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
1154         width: this.$element[0].offsetWidth
1155       , height: this.$element[0].offsetHeight
1156       })
1157     }
1158
1159   , getTitle: function () {
1160       var title
1161         , $e = this.$element
1162         , o = this.options
1163
1164       title = $e.attr('data-original-title')
1165         || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)
1166
1167       return title
1168     }
1169
1170   , tip: function () {
1171       return this.$tip = this.$tip || $(this.options.template)
1172     }
1173
1174   , validate: function () {
1175       if (!this.$element[0].parentNode) {
1176         this.hide()
1177         this.$element = null
1178         this.options = null
1179       }
1180     }
1181
1182   , enable: function () {
1183       this.enabled = true
1184     }
1185
1186   , disable: function () {
1187       this.enabled = false
1188     }
1189
1190   , toggleEnabled: function () {
1191       this.enabled = !this.enabled
1192     }
1193
1194   , toggle: function (e) {
1195       var self = $(e.currentTarget)[this.type](this._options).data(this.type)
1196       self[self.tip().hasClass('in') ? 'hide' : 'show']()
1197     }
1198
1199   , destroy: function () {
1200       this.hide().$element.off('.' + this.type).removeData(this.type)
1201     }
1202
1203   }
1204
1205
1206  /* TOOLTIP PLUGIN DEFINITION
1207   * ========================= */
1208
1209   $.fn.tooltip = function ( option ) {
1210     return this.each(function () {
1211       var $this = $(this)
1212         , data = $this.data('tooltip')
1213         , options = typeof option == 'object' && option
1214       if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
1215       if (typeof option == 'string') data[option]()
1216     })
1217   }
1218
1219   $.fn.tooltip.Constructor = Tooltip
1220
1221   $.fn.tooltip.defaults = {
1222     animation: true
1223   , placement: 'top'
1224   , selector: false
1225   , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
1226   , trigger: 'hover'
1227   , title: ''
1228   , delay: 0
1229   , html: false
1230   }
1231
1232 }(window.jQuery);/* ===========================================================
1233  * bootstrap-popover.js v2.2.1
1234  * http://twitter.github.com/bootstrap/javascript.html#popovers
1235  * ===========================================================
1236  * Copyright 2012 Twitter, Inc.
1237  *
1238  * Licensed under the Apache License, Version 2.0 (the "License");
1239  * you may not use this file except in compliance with the License.
1240  * You may obtain a copy of the License at
1241  *
1242  * http://www.apache.org/licenses/LICENSE-2.0
1243  *
1244  * Unless required by applicable law or agreed to in writing, software
1245  * distributed under the License is distributed on an "AS IS" BASIS,
1246  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1247  * See the License for the specific language governing permissions and
1248  * limitations under the License.
1249  * =========================================================== */
1250
1251
1252 !function ($) {
1253
1254   "use strict"; // jshint ;_;
1255
1256
1257  /* POPOVER PUBLIC CLASS DEFINITION
1258   * =============================== */
1259
1260   var Popover = function (element, options) {
1261     this.init('popover', element, options)
1262   }
1263
1264
1265   /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
1266      ========================================== */
1267
1268   Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
1269
1270     constructor: Popover
1271
1272   , setContent: function () {
1273       var $tip = this.tip()
1274         , title = this.getTitle()
1275         , content = this.getContent()
1276
1277       $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
1278       $tip.find('.popover-content > *')[this.options.html ? 'html' : 'text'](content)
1279
1280       $tip.removeClass('fade top bottom left right in')
1281     }
1282
1283   , hasContent: function () {
1284       return this.getTitle() || this.getContent()
1285     }
1286
1287   , getContent: function () {
1288       var content
1289         , $e = this.$element
1290         , o = this.options
1291
1292       content = $e.attr('data-content')
1293         || (typeof o.content == 'function' ? o.content.call($e[0]) :  o.content)
1294
1295       return content
1296     }
1297
1298   , tip: function () {
1299       if (!this.$tip) {
1300         this.$tip = $(this.options.template)
1301       }
1302       return this.$tip
1303     }
1304
1305   , destroy: function () {
1306       this.hide().$element.off('.' + this.type).removeData(this.type)
1307     }
1308
1309   })
1310
1311
1312  /* POPOVER PLUGIN DEFINITION
1313   * ======================= */
1314
1315   $.fn.popover = function (option) {
1316     return this.each(function () {
1317       var $this = $(this)
1318         , data = $this.data('popover')
1319         , options = typeof option == 'object' && option
1320       if (!data) $this.data('popover', (data = new Popover(this, options)))
1321       if (typeof option == 'string') data[option]()
1322     })
1323   }
1324
1325   $.fn.popover.Constructor = Popover
1326
1327   $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
1328     placement: 'right'
1329   , trigger: 'click'
1330   , content: ''
1331   , 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>'
1332   })
1333
1334 }(window.jQuery);/* =============================================================
1335  * bootstrap-scrollspy.js v2.2.1
1336  * http://twitter.github.com/bootstrap/javascript.html#scrollspy
1337  * =============================================================
1338  * Copyright 2012 Twitter, Inc.
1339  *
1340  * Licensed under the Apache License, Version 2.0 (the "License");
1341  * you may not use this file except in compliance with the License.
1342  * You may obtain a copy of the License at
1343  *
1344  * http://www.apache.org/licenses/LICENSE-2.0
1345  *
1346  * Unless required by applicable law or agreed to in writing, software
1347  * distributed under the License is distributed on an "AS IS" BASIS,
1348  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1349  * See the License for the specific language governing permissions and
1350  * limitations under the License.
1351  * ============================================================== */
1352
1353
1354 !function ($) {
1355
1356   "use strict"; // jshint ;_;
1357
1358
1359  /* SCROLLSPY CLASS DEFINITION
1360   * ========================== */
1361
1362   function ScrollSpy(element, options) {
1363     var process = $.proxy(this.process, this)
1364       , $element = $(element).is('body') ? $(window) : $(element)
1365       , href
1366     this.options = $.extend({}, $.fn.scrollspy.defaults, options)
1367     this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
1368     this.selector = (this.options.target
1369       || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
1370       || '') + ' .nav li > a'
1371     this.$body = $('body')
1372     this.refresh()
1373     this.process()
1374   }
1375
1376   ScrollSpy.prototype = {
1377
1378       constructor: ScrollSpy
1379
1380     , refresh: function () {
1381         var self = this
1382           , $targets
1383
1384         this.offsets = $([])
1385         this.targets = $([])
1386
1387         $targets = this.$body
1388           .find(this.selector)
1389           .map(function () {
1390             var $el = $(this)
1391               , href = $el.data('target') || $el.attr('href')
1392               , $href = /^#\w/.test(href) && $(href)
1393             return ( $href
1394               && $href.length
1395               && [[ $href.position().top, href ]] ) || null
1396           })
1397           .sort(function (a, b) { return a[0] - b[0] })
1398           .each(function () {
1399             self.offsets.push(this[0])
1400             self.targets.push(this[1])
1401           })
1402       }
1403
1404     , process: function () {
1405         var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
1406           , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
1407           , maxScroll = scrollHeight - this.$scrollElement.height()
1408           , offsets = this.offsets
1409           , targets = this.targets
1410           , activeTarget = this.activeTarget
1411           , i
1412
1413         if (scrollTop >= maxScroll) {
1414           return activeTarget != (i = targets.last()[0])
1415             && this.activate ( i )
1416         }
1417
1418         for (i = offsets.length; i--;) {
1419           activeTarget != targets[i]
1420             && scrollTop >= offsets[i]
1421             && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
1422             && this.activate( targets[i] )
1423         }
1424       }
1425
1426     , activate: function (target) {
1427         var active
1428           , selector
1429
1430         this.activeTarget = target
1431
1432         $(this.selector)
1433           .parent('.active')
1434           .removeClass('active')
1435
1436         selector = this.selector
1437           + '[data-target="' + target + '"],'
1438           + this.selector + '[href="' + target + '"]'
1439
1440         active = $(selector)
1441           .parent('li')
1442           .addClass('active')
1443
1444         if (active.parent('.dropdown-menu').length)  {
1445           active = active.closest('li.dropdown').addClass('active')
1446         }
1447
1448         active.trigger('activate')
1449       }
1450
1451   }
1452
1453
1454  /* SCROLLSPY PLUGIN DEFINITION
1455   * =========================== */
1456
1457   $.fn.scrollspy = function (option) {
1458     return this.each(function () {
1459       var $this = $(this)
1460         , data = $this.data('scrollspy')
1461         , options = typeof option == 'object' && option
1462       if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
1463       if (typeof option == 'string') data[option]()
1464     })
1465   }
1466
1467   $.fn.scrollspy.Constructor = ScrollSpy
1468
1469   $.fn.scrollspy.defaults = {
1470     offset: 10
1471   }
1472
1473
1474  /* SCROLLSPY DATA-API
1475   * ================== */
1476
1477   $(window).on('load', function () {
1478     $('[data-spy="scroll"]').each(function () {
1479       var $spy = $(this)
1480       $spy.scrollspy($spy.data())
1481     })
1482   })
1483
1484 }(window.jQuery);/* ========================================================
1485  * bootstrap-tab.js v2.2.1
1486  * http://twitter.github.com/bootstrap/javascript.html#tabs
1487  * ========================================================
1488  * Copyright 2012 Twitter, Inc.
1489  *
1490  * Licensed under the Apache License, Version 2.0 (the "License");
1491  * you may not use this file except in compliance with the License.
1492  * You may obtain a copy of the License at
1493  *
1494  * http://www.apache.org/licenses/LICENSE-2.0
1495  *
1496  * Unless required by applicable law or agreed to in writing, software
1497  * distributed under the License is distributed on an "AS IS" BASIS,
1498  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1499  * See the License for the specific language governing permissions and
1500  * limitations under the License.
1501  * ======================================================== */
1502
1503
1504 !function ($) {
1505
1506   "use strict"; // jshint ;_;
1507
1508
1509  /* TAB CLASS DEFINITION
1510   * ==================== */
1511
1512   var Tab = function (element) {
1513     this.element = $(element)
1514   }
1515
1516   Tab.prototype = {
1517
1518     constructor: Tab
1519
1520   , show: function () {
1521       var $this = this.element
1522         , $ul = $this.closest('ul:not(.dropdown-menu)')
1523         , selector = $this.attr('data-target')
1524         , previous
1525         , $target
1526         , e
1527
1528       if (!selector) {
1529         selector = $this.attr('href')
1530         selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
1531       }
1532
1533       if ( $this.parent('li').hasClass('active') ) return
1534
1535       previous = $ul.find('.active:last a')[0]
1536
1537       e = $.Event('show', {
1538         relatedTarget: previous
1539       })
1540
1541       $this.trigger(e)
1542
1543       if (e.isDefaultPrevented()) return
1544
1545       $target = $(selector)
1546
1547       this.activate($this.parent('li'), $ul)
1548       this.activate($target, $target.parent(), function () {
1549         $this.trigger({
1550           type: 'shown'
1551         , relatedTarget: previous
1552         })
1553       })
1554     }
1555
1556   , activate: function ( element, container, callback) {
1557       var $active = container.find('> .active')
1558         , transition = callback
1559             && $.support.transition
1560             && $active.hasClass('fade')
1561
1562       function next() {
1563         $active
1564           .removeClass('active')
1565           .find('> .dropdown-menu > .active')
1566           .removeClass('active')
1567
1568         element.addClass('active')
1569
1570         if (transition) {
1571           element[0].offsetWidth // reflow for transition
1572           element.addClass('in')
1573         } else {
1574           element.removeClass('fade')
1575         }
1576
1577         if ( element.parent('.dropdown-menu') ) {
1578           element.closest('li.dropdown').addClass('active')
1579         }
1580
1581         callback && callback()
1582       }
1583
1584       transition ?
1585         $active.one($.support.transition.end, next) :
1586         next()
1587
1588       $active.removeClass('in')
1589     }
1590   }
1591
1592
1593  /* TAB PLUGIN DEFINITION
1594   * ===================== */
1595
1596   $.fn.tab = function ( option ) {
1597     return this.each(function () {
1598       var $this = $(this)
1599         , data = $this.data('tab')
1600       if (!data) $this.data('tab', (data = new Tab(this)))
1601       if (typeof option == 'string') data[option]()
1602     })
1603   }
1604
1605   $.fn.tab.Constructor = Tab
1606
1607
1608  /* TAB DATA-API
1609   * ============ */
1610
1611   $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
1612     e.preventDefault()
1613     $(this).tab('show')
1614   })
1615
1616 }(window.jQuery);/* =============================================================
1617  * bootstrap-typeahead.js v2.2.1
1618  * http://twitter.github.com/bootstrap/javascript.html#typeahead
1619  * =============================================================
1620  * Copyright 2012 Twitter, Inc.
1621  *
1622  * Licensed under the Apache License, Version 2.0 (the "License");
1623  * you may not use this file except in compliance with the License.
1624  * You may obtain a copy of the License at
1625  *
1626  * http://www.apache.org/licenses/LICENSE-2.0
1627  *
1628  * Unless required by applicable law or agreed to in writing, software
1629  * distributed under the License is distributed on an "AS IS" BASIS,
1630  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1631  * See the License for the specific language governing permissions and
1632  * limitations under the License.
1633  * ============================================================ */
1634
1635
1636 !function($){
1637
1638   "use strict"; // jshint ;_;
1639
1640
1641  /* TYPEAHEAD PUBLIC CLASS DEFINITION
1642   * ================================= */
1643
1644   var Typeahead = function (element, options) {
1645     this.$element = $(element)
1646     this.options = $.extend({}, $.fn.typeahead.defaults, options)
1647     this.matcher = this.options.matcher || this.matcher
1648     this.sorter = this.options.sorter || this.sorter
1649     this.highlighter = this.options.highlighter || this.highlighter
1650     this.updater = this.options.updater || this.updater
1651     this.$menu = $(this.options.menu).appendTo('body')
1652     this.source = this.options.source
1653     this.shown = false
1654     this.listen()
1655   }
1656
1657   Typeahead.prototype = {
1658
1659     constructor: Typeahead
1660
1661   , select: function () {
1662       var val = this.$menu.find('.active').attr('data-value')
1663       this.$element
1664         .val(this.updater(val))
1665         .change()
1666       return this.hide()
1667     }
1668
1669   , updater: function (item) {
1670       return item
1671     }
1672
1673   , show: function () {
1674       var pos = $.extend({}, this.$element.offset(), {
1675         height: this.$element[0].offsetHeight
1676       })
1677
1678       this.$menu.css({
1679         top: pos.top + pos.height
1680       , left: pos.left
1681       })
1682
1683       this.$menu.show()
1684       this.shown = true
1685       return this
1686     }
1687
1688   , hide: function () {
1689       this.$menu.hide()
1690       this.shown = false
1691       return this
1692     }
1693
1694   , lookup: function (event) {
1695       var items
1696
1697       this.query = this.$element.val()
1698
1699       if (!this.query || this.query.length < this.options.minLength) {
1700         return this.shown ? this.hide() : this
1701       }
1702
1703       items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
1704
1705       return items ? this.process(items) : this
1706     }
1707
1708   , process: function (items) {
1709       var that = this
1710
1711       items = $.grep(items, function (item) {
1712         return that.matcher(item)
1713       })
1714
1715       items = this.sorter(items)
1716
1717       if (!items.length) {
1718         return this.shown ? this.hide() : this
1719       }
1720
1721       return this.render(items.slice(0, this.options.items)).show()
1722     }
1723
1724   , matcher: function (item) {
1725       return ~item.toLowerCase().indexOf(this.query.toLowerCase())
1726     }
1727
1728   , sorter: function (items) {
1729       var beginswith = []
1730         , caseSensitive = []
1731         , caseInsensitive = []
1732         , item
1733
1734       while (item = items.shift()) {
1735         if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
1736         else if (~item.indexOf(this.query)) caseSensitive.push(item)
1737         else caseInsensitive.push(item)
1738       }
1739
1740       return beginswith.concat(caseSensitive, caseInsensitive)
1741     }
1742
1743   , highlighter: function (item) {
1744       var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
1745       return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
1746         return '<strong>' + match + '</strong>'
1747       })
1748     }
1749
1750   , render: function (items) {
1751       var that = this
1752
1753       items = $(items).map(function (i, item) {
1754         i = $(that.options.item).attr('data-value', item)
1755         i.find('a').html(that.highlighter(item))
1756         return i[0]
1757       })
1758
1759       items.first().addClass('active')
1760       this.$menu.html(items)
1761       return this
1762     }
1763
1764   , next: function (event) {
1765       var active = this.$menu.find('.active').removeClass('active')
1766         , next = active.next()
1767
1768       if (!next.length) {
1769         next = $(this.$menu.find('li')[0])
1770       }
1771
1772       next.addClass('active')
1773     }
1774
1775   , prev: function (event) {
1776       var active = this.$menu.find('.active').removeClass('active')
1777         , prev = active.prev()
1778
1779       if (!prev.length) {
1780         prev = this.$menu.find('li').last()
1781       }
1782
1783       prev.addClass('active')
1784     }
1785
1786   , listen: function () {
1787       this.$element
1788         .on('blur',     $.proxy(this.blur, this))
1789         .on('keypress', $.proxy(this.keypress, this))
1790         .on('keyup',    $.proxy(this.keyup, this))
1791
1792       if (this.eventSupported('keydown')) {
1793         this.$element.on('keydown', $.proxy(this.keydown, this))
1794       }
1795
1796       this.$menu
1797         .on('click', $.proxy(this.click, this))
1798         .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
1799     }
1800
1801   , eventSupported: function(eventName) {
1802       var isSupported = eventName in this.$element
1803       if (!isSupported) {
1804         this.$element.setAttribute(eventName, 'return;')
1805         isSupported = typeof this.$element[eventName] === 'function'
1806       }
1807       return isSupported
1808     }
1809
1810   , move: function (e) {
1811       if (!this.shown) return
1812
1813       switch(e.keyCode) {
1814         case 9: // tab
1815         case 13: // enter
1816         case 27: // escape
1817           e.preventDefault()
1818           break
1819
1820         case 38: // up arrow
1821           e.preventDefault()
1822           this.prev()
1823           break
1824
1825         case 40: // down arrow
1826           e.preventDefault()
1827           this.next()
1828           break
1829       }
1830
1831       e.stopPropagation()
1832     }
1833
1834   , keydown: function (e) {
1835       this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40,38,9,13,27])
1836       this.move(e)
1837     }
1838
1839   , keypress: function (e) {
1840       if (this.suppressKeyPressRepeat) return
1841       this.move(e)
1842     }
1843
1844   , keyup: function (e) {
1845       switch(e.keyCode) {
1846         case 40: // down arrow
1847         case 38: // up arrow
1848         case 16: // shift
1849         case 17: // ctrl
1850         case 18: // alt
1851           break
1852
1853         case 9: // tab
1854         case 13: // enter
1855           if (!this.shown) return
1856           this.select()
1857           break
1858
1859         case 27: // escape
1860           if (!this.shown) return
1861           this.hide()
1862           break
1863
1864         default:
1865           this.lookup()
1866       }
1867
1868       e.stopPropagation()
1869       e.preventDefault()
1870   }
1871
1872   , blur: function (e) {
1873       var that = this
1874       setTimeout(function () { that.hide() }, 150)
1875     }
1876
1877   , click: function (e) {
1878       e.stopPropagation()
1879       e.preventDefault()
1880       this.select()
1881     }
1882
1883   , mouseenter: function (e) {
1884       this.$menu.find('.active').removeClass('active')
1885       $(e.currentTarget).addClass('active')
1886     }
1887
1888   }
1889
1890
1891   /* TYPEAHEAD PLUGIN DEFINITION
1892    * =========================== */
1893
1894   $.fn.typeahead = function (option) {
1895     return this.each(function () {
1896       var $this = $(this)
1897         , data = $this.data('typeahead')
1898         , options = typeof option == 'object' && option
1899       if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
1900       if (typeof option == 'string') data[option]()
1901     })
1902   }
1903
1904   $.fn.typeahead.defaults = {
1905     source: []
1906   , items: 8
1907   , menu: '<ul class="typeahead dropdown-menu"></ul>'
1908   , item: '<li><a href="#"></a></li>'
1909   , minLength: 1
1910   }
1911
1912   $.fn.typeahead.Constructor = Typeahead
1913
1914
1915  /*   TYPEAHEAD DATA-API
1916   * ================== */
1917
1918   $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
1919     var $this = $(this)
1920     if ($this.data('typeahead')) return
1921     e.preventDefault()
1922     $this.typeahead($this.data())
1923   })
1924
1925 }(window.jQuery);
1926 /* ==========================================================
1927  * bootstrap-affix.js v2.2.1
1928  * http://twitter.github.com/bootstrap/javascript.html#affix
1929  * ==========================================================
1930  * Copyright 2012 Twitter, Inc.
1931  *
1932  * Licensed under the Apache License, Version 2.0 (the "License");
1933  * you may not use this file except in compliance with the License.
1934  * You may obtain a copy of the License at
1935  *
1936  * http://www.apache.org/licenses/LICENSE-2.0
1937  *
1938  * Unless required by applicable law or agreed to in writing, software
1939  * distributed under the License is distributed on an "AS IS" BASIS,
1940  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1941  * See the License for the specific language governing permissions and
1942  * limitations under the License.
1943  * ========================================================== */
1944
1945
1946 !function ($) {
1947
1948   "use strict"; // jshint ;_;
1949
1950
1951  /* AFFIX CLASS DEFINITION
1952   * ====================== */
1953
1954   var Affix = function (element, options) {
1955     this.options = $.extend({}, $.fn.affix.defaults, options)
1956     this.$window = $(window)
1957       .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
1958       .on('click.affix.data-api',  $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
1959     this.$element = $(element)
1960     this.checkPosition()
1961   }
1962
1963   Affix.prototype.checkPosition = function () {
1964     if (!this.$element.is(':visible')) return
1965
1966     var scrollHeight = $(document).height()
1967       , scrollTop = this.$window.scrollTop()
1968       , position = this.$element.offset()
1969       , offset = this.options.offset
1970       , offsetBottom = offset.bottom
1971       , offsetTop = offset.top
1972       , reset = 'affix affix-top affix-bottom'
1973       , affix
1974
1975     if (typeof offset != 'object') offsetBottom = offsetTop = offset
1976     if (typeof offsetTop == 'function') offsetTop = offset.top()
1977     if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
1978
1979     affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
1980       false    : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
1981       'bottom' : offsetTop != null && scrollTop <= offsetTop ?
1982       'top'    : false
1983
1984     if (this.affixed === affix) return
1985
1986     this.affixed = affix
1987     this.unpin = affix == 'bottom' ? position.top - scrollTop : null
1988
1989     this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
1990   }
1991
1992
1993  /* AFFIX PLUGIN DEFINITION
1994   * ======================= */
1995
1996   $.fn.affix = function (option) {
1997     return this.each(function () {
1998       var $this = $(this)
1999         , data = $this.data('affix')
2000         , options = typeof option == 'object' && option
2001       if (!data) $this.data('affix', (data = new Affix(this, options)))
2002       if (typeof option == 'string') data[option]()
2003     })
2004   }
2005
2006   $.fn.affix.Constructor = Affix
2007
2008   $.fn.affix.defaults = {
2009     offset: 0
2010   }
2011
2012
2013  /* AFFIX DATA-API
2014   * ============== */
2015
2016   $(window).on('load', function () {
2017     $('[data-spy="affix"]').each(function () {
2018       var $spy = $(this)
2019         , data = $spy.data()
2020
2021       data.offset = data.offset || {}
2022
2023       data.offsetBottom && (data.offset.bottom = data.offsetBottom)
2024       data.offsetTop && (data.offset.top = data.offsetTop)
2025
2026       $spy.affix(data)
2027     })
2028   })
2029
2030
2031 }(window.jQuery);