update Bootstrap, Font Awesome to current versions
[mygpo.git] / htdocs / media / js / bootstrap.js
bloba8ca2a8913352a4cfe6b8c69cdcab06fbd6c5fbb
1 /* ===================================================
2  * bootstrap-transition.js v2.3.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  * ========================================================== */
21 !function ($) {
23   "use strict"; // jshint ;_;
26   /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
27    * ======================================================= */
29   $(function () {
31     $.support.transition = (function () {
33       var transitionEnd = (function () {
35         var el = document.createElement('bootstrap')
36           , transEndEventNames = {
37                'WebkitTransition' : 'webkitTransitionEnd'
38             ,  'MozTransition'    : 'transitionend'
39             ,  'OTransition'      : 'oTransitionEnd otransitionend'
40             ,  'transition'       : 'transitionend'
41             }
42           , name
44         for (name in transEndEventNames){
45           if (el.style[name] !== undefined) {
46             return transEndEventNames[name]
47           }
48         }
50       }())
52       return transitionEnd && {
53         end: transitionEnd
54       }
56     })()
58   })
60 }(window.jQuery);
61 /* =========================================================
62  * bootstrap-modal.js v2.3.1
63  * http://twitter.github.com/bootstrap/javascript.html#modals
64  * =========================================================
65  * Copyright 2012 Twitter, Inc.
66  *
67  * Licensed under the Apache License, Version 2.0 (the "License");
68  * you may not use this file except in compliance with the License.
69  * You may obtain a copy of the License at
70  *
71  * http://www.apache.org/licenses/LICENSE-2.0
72  *
73  * Unless required by applicable law or agreed to in writing, software
74  * distributed under the License is distributed on an "AS IS" BASIS,
75  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76  * See the License for the specific language governing permissions and
77  * limitations under the License.
78  * ========================================================= */
81 !function ($) {
83   "use strict"; // jshint ;_;
86  /* MODAL CLASS DEFINITION
87   * ====================== */
89   var Modal = function (element, options) {
90     this.options = options
91     this.$element = $(element)
92       .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
93     this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
94   }
96   Modal.prototype = {
98       constructor: Modal
100     , toggle: function () {
101         return this[!this.isShown ? 'show' : 'hide']()
102       }
104     , show: function () {
105         var that = this
106           , e = $.Event('show')
108         this.$element.trigger(e)
110         if (this.isShown || e.isDefaultPrevented()) return
112         this.isShown = true
114         this.escape()
116         this.backdrop(function () {
117           var transition = $.support.transition && that.$element.hasClass('fade')
119           if (!that.$element.parent().length) {
120             that.$element.appendTo(document.body) //don't move modals dom position
121           }
123           that.$element.show()
125           if (transition) {
126             that.$element[0].offsetWidth // force reflow
127           }
129           that.$element
130             .addClass('in')
131             .attr('aria-hidden', false)
133           that.enforceFocus()
135           transition ?
136             that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
137             that.$element.focus().trigger('shown')
139         })
140       }
142     , hide: function (e) {
143         e && e.preventDefault()
145         var that = this
147         e = $.Event('hide')
149         this.$element.trigger(e)
151         if (!this.isShown || e.isDefaultPrevented()) return
153         this.isShown = false
155         this.escape()
157         $(document).off('focusin.modal')
159         this.$element
160           .removeClass('in')
161           .attr('aria-hidden', true)
163         $.support.transition && this.$element.hasClass('fade') ?
164           this.hideWithTransition() :
165           this.hideModal()
166       }
168     , enforceFocus: function () {
169         var that = this
170         $(document).on('focusin.modal', function (e) {
171           if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
172             that.$element.focus()
173           }
174         })
175       }
177     , escape: function () {
178         var that = this
179         if (this.isShown && this.options.keyboard) {
180           this.$element.on('keyup.dismiss.modal', function ( e ) {
181             e.which == 27 && that.hide()
182           })
183         } else if (!this.isShown) {
184           this.$element.off('keyup.dismiss.modal')
185         }
186       }
188     , hideWithTransition: function () {
189         var that = this
190           , timeout = setTimeout(function () {
191               that.$element.off($.support.transition.end)
192               that.hideModal()
193             }, 500)
195         this.$element.one($.support.transition.end, function () {
196           clearTimeout(timeout)
197           that.hideModal()
198         })
199       }
201     , hideModal: function () {
202         var that = this
203         this.$element.hide()
204         this.backdrop(function () {
205           that.removeBackdrop()
206           that.$element.trigger('hidden')
207         })
208       }
210     , removeBackdrop: function () {
211         this.$backdrop && this.$backdrop.remove()
212         this.$backdrop = null
213       }
215     , backdrop: function (callback) {
216         var that = this
217           , animate = this.$element.hasClass('fade') ? 'fade' : ''
219         if (this.isShown && this.options.backdrop) {
220           var doAnimate = $.support.transition && animate
222           this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
223             .appendTo(document.body)
225           this.$backdrop.click(
226             this.options.backdrop == 'static' ?
227               $.proxy(this.$element[0].focus, this.$element[0])
228             : $.proxy(this.hide, this)
229           )
231           if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
233           this.$backdrop.addClass('in')
235           if (!callback) return
237           doAnimate ?
238             this.$backdrop.one($.support.transition.end, callback) :
239             callback()
241         } else if (!this.isShown && this.$backdrop) {
242           this.$backdrop.removeClass('in')
244           $.support.transition && this.$element.hasClass('fade')?
245             this.$backdrop.one($.support.transition.end, callback) :
246             callback()
248         } else if (callback) {
249           callback()
250         }
251       }
252   }
255  /* MODAL PLUGIN DEFINITION
256   * ======================= */
258   var old = $.fn.modal
260   $.fn.modal = function (option) {
261     return this.each(function () {
262       var $this = $(this)
263         , data = $this.data('modal')
264         , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
265       if (!data) $this.data('modal', (data = new Modal(this, options)))
266       if (typeof option == 'string') data[option]()
267       else if (options.show) data.show()
268     })
269   }
271   $.fn.modal.defaults = {
272       backdrop: true
273     , keyboard: true
274     , show: true
275   }
277   $.fn.modal.Constructor = Modal
280  /* MODAL NO CONFLICT
281   * ================= */
283   $.fn.modal.noConflict = function () {
284     $.fn.modal = old
285     return this
286   }
289  /* MODAL DATA-API
290   * ============== */
292   $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
293     var $this = $(this)
294       , href = $this.attr('href')
295       , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
296       , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
298     e.preventDefault()
300     $target
301       .modal(option)
302       .one('hide', function () {
303         $this.focus()
304       })
305   })
307 }(window.jQuery);
309 /* ============================================================
310  * bootstrap-dropdown.js v2.3.1
311  * http://twitter.github.com/bootstrap/javascript.html#dropdowns
312  * ============================================================
313  * Copyright 2012 Twitter, Inc.
315  * Licensed under the Apache License, Version 2.0 (the "License");
316  * you may not use this file except in compliance with the License.
317  * You may obtain a copy of the License at
319  * http://www.apache.org/licenses/LICENSE-2.0
321  * Unless required by applicable law or agreed to in writing, software
322  * distributed under the License is distributed on an "AS IS" BASIS,
323  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
324  * See the License for the specific language governing permissions and
325  * limitations under the License.
326  * ============================================================ */
329 !function ($) {
331   "use strict"; // jshint ;_;
334  /* DROPDOWN CLASS DEFINITION
335   * ========================= */
337   var toggle = '[data-toggle=dropdown]'
338     , Dropdown = function (element) {
339         var $el = $(element).on('click.dropdown.data-api', this.toggle)
340         $('html').on('click.dropdown.data-api', function () {
341           $el.parent().removeClass('open')
342         })
343       }
345   Dropdown.prototype = {
347     constructor: Dropdown
349   , toggle: function (e) {
350       var $this = $(this)
351         , $parent
352         , isActive
354       if ($this.is('.disabled, :disabled')) return
356       $parent = getParent($this)
358       isActive = $parent.hasClass('open')
360       clearMenus()
362       if (!isActive) {
363         $parent.toggleClass('open')
364       }
366       $this.focus()
368       return false
369     }
371   , keydown: function (e) {
372       var $this
373         , $items
374         , $active
375         , $parent
376         , isActive
377         , index
379       if (!/(38|40|27)/.test(e.keyCode)) return
381       $this = $(this)
383       e.preventDefault()
384       e.stopPropagation()
386       if ($this.is('.disabled, :disabled')) return
388       $parent = getParent($this)
390       isActive = $parent.hasClass('open')
392       if (!isActive || (isActive && e.keyCode == 27)) {
393         if (e.which == 27) $parent.find(toggle).focus()
394         return $this.click()
395       }
397       $items = $('[role=menu] li:not(.divider):visible a', $parent)
399       if (!$items.length) return
401       index = $items.index($items.filter(':focus'))
403       if (e.keyCode == 38 && index > 0) index--                                        // up
404       if (e.keyCode == 40 && index < $items.length - 1) index++                        // down
405       if (!~index) index = 0
407       $items
408         .eq(index)
409         .focus()
410     }
412   }
414   function clearMenus() {
415     $(toggle).each(function () {
416       getParent($(this)).removeClass('open')
417     })
418   }
420   function getParent($this) {
421     var selector = $this.attr('data-target')
422       , $parent
424     if (!selector) {
425       selector = $this.attr('href')
426       selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
427     }
429     $parent = selector && $(selector)
431     if (!$parent || !$parent.length) $parent = $this.parent()
433     return $parent
434   }
437   /* DROPDOWN PLUGIN DEFINITION
438    * ========================== */
440   var old = $.fn.dropdown
442   $.fn.dropdown = function (option) {
443     return this.each(function () {
444       var $this = $(this)
445         , data = $this.data('dropdown')
446       if (!data) $this.data('dropdown', (data = new Dropdown(this)))
447       if (typeof option == 'string') data[option].call($this)
448     })
449   }
451   $.fn.dropdown.Constructor = Dropdown
454  /* DROPDOWN NO CONFLICT
455   * ==================== */
457   $.fn.dropdown.noConflict = function () {
458     $.fn.dropdown = old
459     return this
460   }
463   /* APPLY TO STANDARD DROPDOWN ELEMENTS
464    * =================================== */
466   $(document)
467     .on('click.dropdown.data-api', clearMenus)
468     .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
469     .on('click.dropdown-menu', function (e) { e.stopPropagation() })
470     .on('click.dropdown.data-api'  , toggle, Dropdown.prototype.toggle)
471     .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
473 }(window.jQuery);
475 /* =============================================================
476  * bootstrap-scrollspy.js v2.3.1
477  * http://twitter.github.com/bootstrap/javascript.html#scrollspy
478  * =============================================================
479  * Copyright 2012 Twitter, Inc.
481  * Licensed under the Apache License, Version 2.0 (the "License");
482  * you may not use this file except in compliance with the License.
483  * You may obtain a copy of the License at
485  * http://www.apache.org/licenses/LICENSE-2.0
487  * Unless required by applicable law or agreed to in writing, software
488  * distributed under the License is distributed on an "AS IS" BASIS,
489  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
490  * See the License for the specific language governing permissions and
491  * limitations under the License.
492  * ============================================================== */
495 !function ($) {
497   "use strict"; // jshint ;_;
500  /* SCROLLSPY CLASS DEFINITION
501   * ========================== */
503   function ScrollSpy(element, options) {
504     var process = $.proxy(this.process, this)
505       , $element = $(element).is('body') ? $(window) : $(element)
506       , href
507     this.options = $.extend({}, $.fn.scrollspy.defaults, options)
508     this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
509     this.selector = (this.options.target
510       || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
511       || '') + ' .nav li > a'
512     this.$body = $('body')
513     this.refresh()
514     this.process()
515   }
517   ScrollSpy.prototype = {
519       constructor: ScrollSpy
521     , refresh: function () {
522         var self = this
523           , $targets
525         this.offsets = $([])
526         this.targets = $([])
528         $targets = this.$body
529           .find(this.selector)
530           .map(function () {
531             var $el = $(this)
532               , href = $el.data('target') || $el.attr('href')
533               , $href = /^#\w/.test(href) && $(href)
534             return ( $href
535               && $href.length
536               && [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]] ) || null
537           })
538           .sort(function (a, b) { return a[0] - b[0] })
539           .each(function () {
540             self.offsets.push(this[0])
541             self.targets.push(this[1])
542           })
543       }
545     , process: function () {
546         var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
547           , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
548           , maxScroll = scrollHeight - this.$scrollElement.height()
549           , offsets = this.offsets
550           , targets = this.targets
551           , activeTarget = this.activeTarget
552           , i
554         if (scrollTop >= maxScroll) {
555           return activeTarget != (i = targets.last()[0])
556             && this.activate ( i )
557         }
559         for (i = offsets.length; i--;) {
560           activeTarget != targets[i]
561             && scrollTop >= offsets[i]
562             && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
563             && this.activate( targets[i] )
564         }
565       }
567     , activate: function (target) {
568         var active
569           , selector
571         this.activeTarget = target
573         $(this.selector)
574           .parent('.active')
575           .removeClass('active')
577         selector = this.selector
578           + '[data-target="' + target + '"],'
579           + this.selector + '[href="' + target + '"]'
581         active = $(selector)
582           .parent('li')
583           .addClass('active')
585         if (active.parent('.dropdown-menu').length)  {
586           active = active.closest('li.dropdown').addClass('active')
587         }
589         active.trigger('activate')
590       }
592   }
595  /* SCROLLSPY PLUGIN DEFINITION
596   * =========================== */
598   var old = $.fn.scrollspy
600   $.fn.scrollspy = function (option) {
601     return this.each(function () {
602       var $this = $(this)
603         , data = $this.data('scrollspy')
604         , options = typeof option == 'object' && option
605       if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
606       if (typeof option == 'string') data[option]()
607     })
608   }
610   $.fn.scrollspy.Constructor = ScrollSpy
612   $.fn.scrollspy.defaults = {
613     offset: 10
614   }
617  /* SCROLLSPY NO CONFLICT
618   * ===================== */
620   $.fn.scrollspy.noConflict = function () {
621     $.fn.scrollspy = old
622     return this
623   }
626  /* SCROLLSPY DATA-API
627   * ================== */
629   $(window).on('load', function () {
630     $('[data-spy="scroll"]').each(function () {
631       var $spy = $(this)
632       $spy.scrollspy($spy.data())
633     })
634   })
636 }(window.jQuery);
637 /* ========================================================
638  * bootstrap-tab.js v2.3.1
639  * http://twitter.github.com/bootstrap/javascript.html#tabs
640  * ========================================================
641  * Copyright 2012 Twitter, Inc.
643  * Licensed under the Apache License, Version 2.0 (the "License");
644  * you may not use this file except in compliance with the License.
645  * You may obtain a copy of the License at
647  * http://www.apache.org/licenses/LICENSE-2.0
649  * Unless required by applicable law or agreed to in writing, software
650  * distributed under the License is distributed on an "AS IS" BASIS,
651  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
652  * See the License for the specific language governing permissions and
653  * limitations under the License.
654  * ======================================================== */
657 !function ($) {
659   "use strict"; // jshint ;_;
662  /* TAB CLASS DEFINITION
663   * ==================== */
665   var Tab = function (element) {
666     this.element = $(element)
667   }
669   Tab.prototype = {
671     constructor: Tab
673   , show: function () {
674       var $this = this.element
675         , $ul = $this.closest('ul:not(.dropdown-menu)')
676         , selector = $this.attr('data-target')
677         , previous
678         , $target
679         , e
681       if (!selector) {
682         selector = $this.attr('href')
683         selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
684       }
686       if ( $this.parent('li').hasClass('active') ) return
688       previous = $ul.find('.active:last a')[0]
690       e = $.Event('show', {
691         relatedTarget: previous
692       })
694       $this.trigger(e)
696       if (e.isDefaultPrevented()) return
698       $target = $(selector)
700       this.activate($this.parent('li'), $ul)
701       this.activate($target, $target.parent(), function () {
702         $this.trigger({
703           type: 'shown'
704         , relatedTarget: previous
705         })
706       })
707     }
709   , activate: function ( element, container, callback) {
710       var $active = container.find('> .active')
711         , transition = callback
712             && $.support.transition
713             && $active.hasClass('fade')
715       function next() {
716         $active
717           .removeClass('active')
718           .find('> .dropdown-menu > .active')
719           .removeClass('active')
721         element.addClass('active')
723         if (transition) {
724           element[0].offsetWidth // reflow for transition
725           element.addClass('in')
726         } else {
727           element.removeClass('fade')
728         }
730         if ( element.parent('.dropdown-menu') ) {
731           element.closest('li.dropdown').addClass('active')
732         }
734         callback && callback()
735       }
737       transition ?
738         $active.one($.support.transition.end, next) :
739         next()
741       $active.removeClass('in')
742     }
743   }
746  /* TAB PLUGIN DEFINITION
747   * ===================== */
749   var old = $.fn.tab
751   $.fn.tab = function ( option ) {
752     return this.each(function () {
753       var $this = $(this)
754         , data = $this.data('tab')
755       if (!data) $this.data('tab', (data = new Tab(this)))
756       if (typeof option == 'string') data[option]()
757     })
758   }
760   $.fn.tab.Constructor = Tab
763  /* TAB NO CONFLICT
764   * =============== */
766   $.fn.tab.noConflict = function () {
767     $.fn.tab = old
768     return this
769   }
772  /* TAB DATA-API
773   * ============ */
775   $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
776     e.preventDefault()
777     $(this).tab('show')
778   })
780 }(window.jQuery);
781 /* ===========================================================
782  * bootstrap-tooltip.js v2.3.1
783  * http://twitter.github.com/bootstrap/javascript.html#tooltips
784  * Inspired by the original jQuery.tipsy by Jason Frame
785  * ===========================================================
786  * Copyright 2012 Twitter, Inc.
788  * Licensed under the Apache License, Version 2.0 (the "License");
789  * you may not use this file except in compliance with the License.
790  * You may obtain a copy of the License at
792  * http://www.apache.org/licenses/LICENSE-2.0
794  * Unless required by applicable law or agreed to in writing, software
795  * distributed under the License is distributed on an "AS IS" BASIS,
796  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
797  * See the License for the specific language governing permissions and
798  * limitations under the License.
799  * ========================================================== */
802 !function ($) {
804   "use strict"; // jshint ;_;
807  /* TOOLTIP PUBLIC CLASS DEFINITION
808   * =============================== */
810   var Tooltip = function (element, options) {
811     this.init('tooltip', element, options)
812   }
814   Tooltip.prototype = {
816     constructor: Tooltip
818   , init: function (type, element, options) {
819       var eventIn
820         , eventOut
821         , triggers
822         , trigger
823         , i
825       this.type = type
826       this.$element = $(element)
827       this.options = this.getOptions(options)
828       this.enabled = true
830       triggers = this.options.trigger.split(' ')
832       for (i = triggers.length; i--;) {
833         trigger = triggers[i]
834         if (trigger == 'click') {
835           this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
836         } else if (trigger != 'manual') {
837           eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
838           eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
839           this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
840           this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
841         }
842       }
844       this.options.selector ?
845         (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
846         this.fixTitle()
847     }
849   , getOptions: function (options) {
850       options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
852       if (options.delay && typeof options.delay == 'number') {
853         options.delay = {
854           show: options.delay
855         , hide: options.delay
856         }
857       }
859       return options
860     }
862   , enter: function (e) {
863       var defaults = $.fn[this.type].defaults
864         , options = {}
865         , self
867       this._options && $.each(this._options, function (key, value) {
868         if (defaults[key] != value) options[key] = value
869       }, this)
871       self = $(e.currentTarget)[this.type](options).data(this.type)
873       if (!self.options.delay || !self.options.delay.show) return self.show()
875       clearTimeout(this.timeout)
876       self.hoverState = 'in'
877       this.timeout = setTimeout(function() {
878         if (self.hoverState == 'in') self.show()
879       }, self.options.delay.show)
880     }
882   , leave: function (e) {
883       var self = $(e.currentTarget)[this.type](this._options).data(this.type)
885       if (this.timeout) clearTimeout(this.timeout)
886       if (!self.options.delay || !self.options.delay.hide) return self.hide()
888       self.hoverState = 'out'
889       this.timeout = setTimeout(function() {
890         if (self.hoverState == 'out') self.hide()
891       }, self.options.delay.hide)
892     }
894   , show: function () {
895       var $tip
896         , pos
897         , actualWidth
898         , actualHeight
899         , placement
900         , tp
901         , e = $.Event('show')
903       if (this.hasContent() && this.enabled) {
904         this.$element.trigger(e)
905         if (e.isDefaultPrevented()) return
906         $tip = this.tip()
907         this.setContent()
909         if (this.options.animation) {
910           $tip.addClass('fade')
911         }
913         placement = typeof this.options.placement == 'function' ?
914           this.options.placement.call(this, $tip[0], this.$element[0]) :
915           this.options.placement
917         $tip
918           .detach()
919           .css({ top: 0, left: 0, display: 'block' })
921         this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
923         pos = this.getPosition()
925         actualWidth = $tip[0].offsetWidth
926         actualHeight = $tip[0].offsetHeight
928         switch (placement) {
929           case 'bottom':
930             tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
931             break
932           case 'top':
933             tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
934             break
935           case 'left':
936             tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
937             break
938           case 'right':
939             tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
940             break
941         }
943         this.applyPlacement(tp, placement)
944         this.$element.trigger('shown')
945       }
946     }
948   , applyPlacement: function(offset, placement){
949       var $tip = this.tip()
950         , width = $tip[0].offsetWidth
951         , height = $tip[0].offsetHeight
952         , actualWidth
953         , actualHeight
954         , delta
955         , replace
957       $tip
958         .offset(offset)
959         .addClass(placement)
960         .addClass('in')
962       actualWidth = $tip[0].offsetWidth
963       actualHeight = $tip[0].offsetHeight
965       if (placement == 'top' && actualHeight != height) {
966         offset.top = offset.top + height - actualHeight
967         replace = true
968       }
970       if (placement == 'bottom' || placement == 'top') {
971         delta = 0
973         if (offset.left < 0){
974           delta = offset.left * -2
975           offset.left = 0
976           $tip.offset(offset)
977           actualWidth = $tip[0].offsetWidth
978           actualHeight = $tip[0].offsetHeight
979         }
981         this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
982       } else {
983         this.replaceArrow(actualHeight - height, actualHeight, 'top')
984       }
986       if (replace) $tip.offset(offset)
987     }
989   , replaceArrow: function(delta, dimension, position){
990       this
991         .arrow()
992         .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
993     }
995   , setContent: function () {
996       var $tip = this.tip()
997         , title = this.getTitle()
999       $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
1000       $tip.removeClass('fade in top bottom left right')
1001     }
1003   , hide: function () {
1004       var that = this
1005         , $tip = this.tip()
1006         , e = $.Event('hide')
1008       this.$element.trigger(e)
1009       if (e.isDefaultPrevented()) return
1011       $tip.removeClass('in')
1013       function removeWithAnimation() {
1014         var timeout = setTimeout(function () {
1015           $tip.off($.support.transition.end).detach()
1016         }, 500)
1018         $tip.one($.support.transition.end, function () {
1019           clearTimeout(timeout)
1020           $tip.detach()
1021         })
1022       }
1024       $.support.transition && this.$tip.hasClass('fade') ?
1025         removeWithAnimation() :
1026         $tip.detach()
1028       this.$element.trigger('hidden')
1030       return this
1031     }
1033   , fixTitle: function () {
1034       var $e = this.$element
1035       if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
1036         $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
1037       }
1038     }
1040   , hasContent: function () {
1041       return this.getTitle()
1042     }
1044   , getPosition: function () {
1045       var el = this.$element[0]
1046       return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
1047         width: el.offsetWidth
1048       , height: el.offsetHeight
1049       }, this.$element.offset())
1050     }
1052   , getTitle: function () {
1053       var title
1054         , $e = this.$element
1055         , o = this.options
1057       title = $e.attr('data-original-title')
1058         || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)
1060       return title
1061     }
1063   , tip: function () {
1064       return this.$tip = this.$tip || $(this.options.template)
1065     }
1067   , arrow: function(){
1068       return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
1069     }
1071   , validate: function () {
1072       if (!this.$element[0].parentNode) {
1073         this.hide()
1074         this.$element = null
1075         this.options = null
1076       }
1077     }
1079   , enable: function () {
1080       this.enabled = true
1081     }
1083   , disable: function () {
1084       this.enabled = false
1085     }
1087   , toggleEnabled: function () {
1088       this.enabled = !this.enabled
1089     }
1091   , toggle: function (e) {
1092       var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
1093       self.tip().hasClass('in') ? self.hide() : self.show()
1094     }
1096   , destroy: function () {
1097       this.hide().$element.off('.' + this.type).removeData(this.type)
1098     }
1100   }
1103  /* TOOLTIP PLUGIN DEFINITION
1104   * ========================= */
1106   var old = $.fn.tooltip
1108   $.fn.tooltip = function ( option ) {
1109     return this.each(function () {
1110       var $this = $(this)
1111         , data = $this.data('tooltip')
1112         , options = typeof option == 'object' && option
1113       if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
1114       if (typeof option == 'string') data[option]()
1115     })
1116   }
1118   $.fn.tooltip.Constructor = Tooltip
1120   $.fn.tooltip.defaults = {
1121     animation: true
1122   , placement: 'top'
1123   , selector: false
1124   , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
1125   , trigger: 'hover focus'
1126   , title: ''
1127   , delay: 0
1128   , html: false
1129   , container: false
1130   }
1133  /* TOOLTIP NO CONFLICT
1134   * =================== */
1136   $.fn.tooltip.noConflict = function () {
1137     $.fn.tooltip = old
1138     return this
1139   }
1141 }(window.jQuery);
1143 /* ===========================================================
1144  * bootstrap-popover.js v2.3.1
1145  * http://twitter.github.com/bootstrap/javascript.html#popovers
1146  * ===========================================================
1147  * Copyright 2012 Twitter, Inc.
1149  * Licensed under the Apache License, Version 2.0 (the "License");
1150  * you may not use this file except in compliance with the License.
1151  * You may obtain a copy of the License at
1153  * http://www.apache.org/licenses/LICENSE-2.0
1155  * Unless required by applicable law or agreed to in writing, software
1156  * distributed under the License is distributed on an "AS IS" BASIS,
1157  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1158  * See the License for the specific language governing permissions and
1159  * limitations under the License.
1160  * =========================================================== */
1163 !function ($) {
1165   "use strict"; // jshint ;_;
1168  /* POPOVER PUBLIC CLASS DEFINITION
1169   * =============================== */
1171   var Popover = function (element, options) {
1172     this.init('popover', element, options)
1173   }
1176   /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
1177      ========================================== */
1179   Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
1181     constructor: Popover
1183   , setContent: function () {
1184       var $tip = this.tip()
1185         , title = this.getTitle()
1186         , content = this.getContent()
1188       $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
1189       $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
1191       $tip.removeClass('fade top bottom left right in')
1192     }
1194   , hasContent: function () {
1195       return this.getTitle() || this.getContent()
1196     }
1198   , getContent: function () {
1199       var content
1200         , $e = this.$element
1201         , o = this.options
1203       content = (typeof o.content == 'function' ? o.content.call($e[0]) :  o.content)
1204         || $e.attr('data-content')
1206       return content
1207     }
1209   , tip: function () {
1210       if (!this.$tip) {
1211         this.$tip = $(this.options.template)
1212       }
1213       return this.$tip
1214     }
1216   , destroy: function () {
1217       this.hide().$element.off('.' + this.type).removeData(this.type)
1218     }
1220   })
1223  /* POPOVER PLUGIN DEFINITION
1224   * ======================= */
1226   var old = $.fn.popover
1228   $.fn.popover = function (option) {
1229     return this.each(function () {
1230       var $this = $(this)
1231         , data = $this.data('popover')
1232         , options = typeof option == 'object' && option
1233       if (!data) $this.data('popover', (data = new Popover(this, options)))
1234       if (typeof option == 'string') data[option]()
1235     })
1236   }
1238   $.fn.popover.Constructor = Popover
1240   $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
1241     placement: 'right'
1242   , trigger: 'click'
1243   , content: ''
1244   , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
1245   })
1248  /* POPOVER NO CONFLICT
1249   * =================== */
1251   $.fn.popover.noConflict = function () {
1252     $.fn.popover = old
1253     return this
1254   }
1256 }(window.jQuery);
1258 /* ==========================================================
1259  * bootstrap-affix.js v2.3.1
1260  * http://twitter.github.com/bootstrap/javascript.html#affix
1261  * ==========================================================
1262  * Copyright 2012 Twitter, Inc.
1264  * Licensed under the Apache License, Version 2.0 (the "License");
1265  * you may not use this file except in compliance with the License.
1266  * You may obtain a copy of the License at
1268  * http://www.apache.org/licenses/LICENSE-2.0
1270  * Unless required by applicable law or agreed to in writing, software
1271  * distributed under the License is distributed on an "AS IS" BASIS,
1272  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1273  * See the License for the specific language governing permissions and
1274  * limitations under the License.
1275  * ========================================================== */
1278 !function ($) {
1280   "use strict"; // jshint ;_;
1283  /* AFFIX CLASS DEFINITION
1284   * ====================== */
1286   var Affix = function (element, options) {
1287     this.options = $.extend({}, $.fn.affix.defaults, options)
1288     this.$window = $(window)
1289       .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
1290       .on('click.affix.data-api',  $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
1291     this.$element = $(element)
1292     this.checkPosition()
1293   }
1295   Affix.prototype.checkPosition = function () {
1296     if (!this.$element.is(':visible')) return
1298     var scrollHeight = $(document).height()
1299       , scrollTop = this.$window.scrollTop()
1300       , position = this.$element.offset()
1301       , offset = this.options.offset
1302       , offsetBottom = offset.bottom
1303       , offsetTop = offset.top
1304       , reset = 'affix affix-top affix-bottom'
1305       , affix
1307     if (typeof offset != 'object') offsetBottom = offsetTop = offset
1308     if (typeof offsetTop == 'function') offsetTop = offset.top()
1309     if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
1311     affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
1312       false    : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
1313       'bottom' : offsetTop != null && scrollTop <= offsetTop ?
1314       'top'    : false
1316     if (this.affixed === affix) return
1318     this.affixed = affix
1319     this.unpin = affix == 'bottom' ? position.top - scrollTop : null
1321     this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
1322   }
1325  /* AFFIX PLUGIN DEFINITION
1326   * ======================= */
1328   var old = $.fn.affix
1330   $.fn.affix = function (option) {
1331     return this.each(function () {
1332       var $this = $(this)
1333         , data = $this.data('affix')
1334         , options = typeof option == 'object' && option
1335       if (!data) $this.data('affix', (data = new Affix(this, options)))
1336       if (typeof option == 'string') data[option]()
1337     })
1338   }
1340   $.fn.affix.Constructor = Affix
1342   $.fn.affix.defaults = {
1343     offset: 0
1344   }
1347  /* AFFIX NO CONFLICT
1348   * ================= */
1350   $.fn.affix.noConflict = function () {
1351     $.fn.affix = old
1352     return this
1353   }
1356  /* AFFIX DATA-API
1357   * ============== */
1359   $(window).on('load', function () {
1360     $('[data-spy="affix"]').each(function () {
1361       var $spy = $(this)
1362         , data = $spy.data()
1364       data.offset = data.offset || {}
1366       data.offsetBottom && (data.offset.bottom = data.offsetBottom)
1367       data.offsetTop && (data.offset.top = data.offsetTop)
1369       $spy.affix(data)
1370     })
1371   })
1374 }(window.jQuery);
1375 /* ==========================================================
1376  * bootstrap-alert.js v2.3.1
1377  * http://twitter.github.com/bootstrap/javascript.html#alerts
1378  * ==========================================================
1379  * Copyright 2012 Twitter, Inc.
1381  * Licensed under the Apache License, Version 2.0 (the "License");
1382  * you may not use this file except in compliance with the License.
1383  * You may obtain a copy of the License at
1385  * http://www.apache.org/licenses/LICENSE-2.0
1387  * Unless required by applicable law or agreed to in writing, software
1388  * distributed under the License is distributed on an "AS IS" BASIS,
1389  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1390  * See the License for the specific language governing permissions and
1391  * limitations under the License.
1392  * ========================================================== */
1395 !function ($) {
1397   "use strict"; // jshint ;_;
1400  /* ALERT CLASS DEFINITION
1401   * ====================== */
1403   var dismiss = '[data-dismiss="alert"]'
1404     , Alert = function (el) {
1405         $(el).on('click', dismiss, this.close)
1406       }
1408   Alert.prototype.close = function (e) {
1409     var $this = $(this)
1410       , selector = $this.attr('data-target')
1411       , $parent
1413     if (!selector) {
1414       selector = $this.attr('href')
1415       selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
1416     }
1418     $parent = $(selector)
1420     e && e.preventDefault()
1422     $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
1424     $parent.trigger(e = $.Event('close'))
1426     if (e.isDefaultPrevented()) return
1428     $parent.removeClass('in')
1430     function removeElement() {
1431       $parent
1432         .trigger('closed')
1433         .remove()
1434     }
1436     $.support.transition && $parent.hasClass('fade') ?
1437       $parent.on($.support.transition.end, removeElement) :
1438       removeElement()
1439   }
1442  /* ALERT PLUGIN DEFINITION
1443   * ======================= */
1445   var old = $.fn.alert
1447   $.fn.alert = function (option) {
1448     return this.each(function () {
1449       var $this = $(this)
1450         , data = $this.data('alert')
1451       if (!data) $this.data('alert', (data = new Alert(this)))
1452       if (typeof option == 'string') data[option].call($this)
1453     })
1454   }
1456   $.fn.alert.Constructor = Alert
1459  /* ALERT NO CONFLICT
1460   * ================= */
1462   $.fn.alert.noConflict = function () {
1463     $.fn.alert = old
1464     return this
1465   }
1468  /* ALERT DATA-API
1469   * ============== */
1471   $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
1473 }(window.jQuery);
1474 /* ============================================================
1475  * bootstrap-button.js v2.3.1
1476  * http://twitter.github.com/bootstrap/javascript.html#buttons
1477  * ============================================================
1478  * Copyright 2012 Twitter, Inc.
1480  * Licensed under the Apache License, Version 2.0 (the "License");
1481  * you may not use this file except in compliance with the License.
1482  * You may obtain a copy of the License at
1484  * http://www.apache.org/licenses/LICENSE-2.0
1486  * Unless required by applicable law or agreed to in writing, software
1487  * distributed under the License is distributed on an "AS IS" BASIS,
1488  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1489  * See the License for the specific language governing permissions and
1490  * limitations under the License.
1491  * ============================================================ */
1494 !function ($) {
1496   "use strict"; // jshint ;_;
1499  /* BUTTON PUBLIC CLASS DEFINITION
1500   * ============================== */
1502   var Button = function (element, options) {
1503     this.$element = $(element)
1504     this.options = $.extend({}, $.fn.button.defaults, options)
1505   }
1507   Button.prototype.setState = function (state) {
1508     var d = 'disabled'
1509       , $el = this.$element
1510       , data = $el.data()
1511       , val = $el.is('input') ? 'val' : 'html'
1513     state = state + 'Text'
1514     data.resetText || $el.data('resetText', $el[val]())
1516     $el[val](data[state] || this.options[state])
1518     // push to event loop to allow forms to submit
1519     setTimeout(function () {
1520       state == 'loadingText' ?
1521         $el.addClass(d).attr(d, d) :
1522         $el.removeClass(d).removeAttr(d)
1523     }, 0)
1524   }
1526   Button.prototype.toggle = function () {
1527     var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
1529     $parent && $parent
1530       .find('.active')
1531       .removeClass('active')
1533     this.$element.toggleClass('active')
1534   }
1537  /* BUTTON PLUGIN DEFINITION
1538   * ======================== */
1540   var old = $.fn.button
1542   $.fn.button = function (option) {
1543     return this.each(function () {
1544       var $this = $(this)
1545         , data = $this.data('button')
1546         , options = typeof option == 'object' && option
1547       if (!data) $this.data('button', (data = new Button(this, options)))
1548       if (option == 'toggle') data.toggle()
1549       else if (option) data.setState(option)
1550     })
1551   }
1553   $.fn.button.defaults = {
1554     loadingText: 'loading...'
1555   }
1557   $.fn.button.Constructor = Button
1560  /* BUTTON NO CONFLICT
1561   * ================== */
1563   $.fn.button.noConflict = function () {
1564     $.fn.button = old
1565     return this
1566   }
1569  /* BUTTON DATA-API
1570   * =============== */
1572   $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
1573     var $btn = $(e.target)
1574     if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
1575     $btn.button('toggle')
1576   })
1578 }(window.jQuery);
1579 /* =============================================================
1580  * bootstrap-collapse.js v2.3.1
1581  * http://twitter.github.com/bootstrap/javascript.html#collapse
1582  * =============================================================
1583  * Copyright 2012 Twitter, Inc.
1585  * Licensed under the Apache License, Version 2.0 (the "License");
1586  * you may not use this file except in compliance with the License.
1587  * You may obtain a copy of the License at
1589  * http://www.apache.org/licenses/LICENSE-2.0
1591  * Unless required by applicable law or agreed to in writing, software
1592  * distributed under the License is distributed on an "AS IS" BASIS,
1593  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1594  * See the License for the specific language governing permissions and
1595  * limitations under the License.
1596  * ============================================================ */
1599 !function ($) {
1601   "use strict"; // jshint ;_;
1604  /* COLLAPSE PUBLIC CLASS DEFINITION
1605   * ================================ */
1607   var Collapse = function (element, options) {
1608     this.$element = $(element)
1609     this.options = $.extend({}, $.fn.collapse.defaults, options)
1611     if (this.options.parent) {
1612       this.$parent = $(this.options.parent)
1613     }
1615     this.options.toggle && this.toggle()
1616   }
1618   Collapse.prototype = {
1620     constructor: Collapse
1622   , dimension: function () {
1623       var hasWidth = this.$element.hasClass('width')
1624       return hasWidth ? 'width' : 'height'
1625     }
1627   , show: function () {
1628       var dimension
1629         , scroll
1630         , actives
1631         , hasData
1633       if (this.transitioning || this.$element.hasClass('in')) return
1635       dimension = this.dimension()
1636       scroll = $.camelCase(['scroll', dimension].join('-'))
1637       actives = this.$parent && this.$parent.find('> .accordion-group > .in')
1639       if (actives && actives.length) {
1640         hasData = actives.data('collapse')
1641         if (hasData && hasData.transitioning) return
1642         actives.collapse('hide')
1643         hasData || actives.data('collapse', null)
1644       }
1646       this.$element[dimension](0)
1647       this.transition('addClass', $.Event('show'), 'shown')
1648       $.support.transition && this.$element[dimension](this.$element[0][scroll])
1649     }
1651   , hide: function () {
1652       var dimension
1653       if (this.transitioning || !this.$element.hasClass('in')) return
1654       dimension = this.dimension()
1655       this.reset(this.$element[dimension]())
1656       this.transition('removeClass', $.Event('hide'), 'hidden')
1657       this.$element[dimension](0)
1658     }
1660   , reset: function (size) {
1661       var dimension = this.dimension()
1663       this.$element
1664         .removeClass('collapse')
1665         [dimension](size || 'auto')
1666         [0].offsetWidth
1668       this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
1670       return this
1671     }
1673   , transition: function (method, startEvent, completeEvent) {
1674       var that = this
1675         , complete = function () {
1676             if (startEvent.type == 'show') that.reset()
1677             that.transitioning = 0
1678             that.$element.trigger(completeEvent)
1679           }
1681       this.$element.trigger(startEvent)
1683       if (startEvent.isDefaultPrevented()) return
1685       this.transitioning = 1
1687       this.$element[method]('in')
1689       $.support.transition && this.$element.hasClass('collapse') ?
1690         this.$element.one($.support.transition.end, complete) :
1691         complete()
1692     }
1694   , toggle: function () {
1695       this[this.$element.hasClass('in') ? 'hide' : 'show']()
1696     }
1698   }
1701  /* COLLAPSE PLUGIN DEFINITION
1702   * ========================== */
1704   var old = $.fn.collapse
1706   $.fn.collapse = function (option) {
1707     return this.each(function () {
1708       var $this = $(this)
1709         , data = $this.data('collapse')
1710         , options = $.extend({}, $.fn.collapse.defaults, $this.data(), typeof option == 'object' && option)
1711       if (!data) $this.data('collapse', (data = new Collapse(this, options)))
1712       if (typeof option == 'string') data[option]()
1713     })
1714   }
1716   $.fn.collapse.defaults = {
1717     toggle: true
1718   }
1720   $.fn.collapse.Constructor = Collapse
1723  /* COLLAPSE NO CONFLICT
1724   * ==================== */
1726   $.fn.collapse.noConflict = function () {
1727     $.fn.collapse = old
1728     return this
1729   }
1732  /* COLLAPSE DATA-API
1733   * ================= */
1735   $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
1736     var $this = $(this), href
1737       , target = $this.attr('data-target')
1738         || e.preventDefault()
1739         || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
1740       , option = $(target).data('collapse') ? 'toggle' : $this.data()
1741     $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
1742     $(target).collapse(option)
1743   })
1745 }(window.jQuery);
1746 /* ==========================================================
1747  * bootstrap-carousel.js v2.3.1
1748  * http://twitter.github.com/bootstrap/javascript.html#carousel
1749  * ==========================================================
1750  * Copyright 2012 Twitter, Inc.
1752  * Licensed under the Apache License, Version 2.0 (the "License");
1753  * you may not use this file except in compliance with the License.
1754  * You may obtain a copy of the License at
1756  * http://www.apache.org/licenses/LICENSE-2.0
1758  * Unless required by applicable law or agreed to in writing, software
1759  * distributed under the License is distributed on an "AS IS" BASIS,
1760  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1761  * See the License for the specific language governing permissions and
1762  * limitations under the License.
1763  * ========================================================== */
1766 !function ($) {
1768   "use strict"; // jshint ;_;
1771  /* CAROUSEL CLASS DEFINITION
1772   * ========================= */
1774   var Carousel = function (element, options) {
1775     this.$element = $(element)
1776     this.$indicators = this.$element.find('.carousel-indicators')
1777     this.options = options
1778     this.options.pause == 'hover' && this.$element
1779       .on('mouseenter', $.proxy(this.pause, this))
1780       .on('mouseleave', $.proxy(this.cycle, this))
1781   }
1783   Carousel.prototype = {
1785     cycle: function (e) {
1786       if (!e) this.paused = false
1787       if (this.interval) clearInterval(this.interval);
1788       this.options.interval
1789         && !this.paused
1790         && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
1791       return this
1792     }
1794   , getActiveIndex: function () {
1795       this.$active = this.$element.find('.item.active')
1796       this.$items = this.$active.parent().children()
1797       return this.$items.index(this.$active)
1798     }
1800   , to: function (pos) {
1801       var activeIndex = this.getActiveIndex()
1802         , that = this
1804       if (pos > (this.$items.length - 1) || pos < 0) return
1806       if (this.sliding) {
1807         return this.$element.one('slid', function () {
1808           that.to(pos)
1809         })
1810       }
1812       if (activeIndex == pos) {
1813         return this.pause().cycle()
1814       }
1816       return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
1817     }
1819   , pause: function (e) {
1820       if (!e) this.paused = true
1821       if (this.$element.find('.next, .prev').length && $.support.transition.end) {
1822         this.$element.trigger($.support.transition.end)
1823         this.cycle(true)
1824       }
1825       clearInterval(this.interval)
1826       this.interval = null
1827       return this
1828     }
1830   , next: function () {
1831       if (this.sliding) return
1832       return this.slide('next')
1833     }
1835   , prev: function () {
1836       if (this.sliding) return
1837       return this.slide('prev')
1838     }
1840   , slide: function (type, next) {
1841       var $active = this.$element.find('.item.active')
1842         , $next = next || $active[type]()
1843         , isCycling = this.interval
1844         , direction = type == 'next' ? 'left' : 'right'
1845         , fallback  = type == 'next' ? 'first' : 'last'
1846         , that = this
1847         , e
1849       this.sliding = true
1851       isCycling && this.pause()
1853       $next = $next.length ? $next : this.$element.find('.item')[fallback]()
1855       e = $.Event('slide', {
1856         relatedTarget: $next[0]
1857       , direction: direction
1858       })
1860       if ($next.hasClass('active')) return
1862       if (this.$indicators.length) {
1863         this.$indicators.find('.active').removeClass('active')
1864         this.$element.one('slid', function () {
1865           var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
1866           $nextIndicator && $nextIndicator.addClass('active')
1867         })
1868       }
1870       if ($.support.transition && this.$element.hasClass('slide')) {
1871         this.$element.trigger(e)
1872         if (e.isDefaultPrevented()) return
1873         $next.addClass(type)
1874         $next[0].offsetWidth // force reflow
1875         $active.addClass(direction)
1876         $next.addClass(direction)
1877         this.$element.one($.support.transition.end, function () {
1878           $next.removeClass([type, direction].join(' ')).addClass('active')
1879           $active.removeClass(['active', direction].join(' '))
1880           that.sliding = false
1881           setTimeout(function () { that.$element.trigger('slid') }, 0)
1882         })
1883       } else {
1884         this.$element.trigger(e)
1885         if (e.isDefaultPrevented()) return
1886         $active.removeClass('active')
1887         $next.addClass('active')
1888         this.sliding = false
1889         this.$element.trigger('slid')
1890       }
1892       isCycling && this.cycle()
1894       return this
1895     }
1897   }
1900  /* CAROUSEL PLUGIN DEFINITION
1901   * ========================== */
1903   var old = $.fn.carousel
1905   $.fn.carousel = function (option) {
1906     return this.each(function () {
1907       var $this = $(this)
1908         , data = $this.data('carousel')
1909         , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
1910         , action = typeof option == 'string' ? option : options.slide
1911       if (!data) $this.data('carousel', (data = new Carousel(this, options)))
1912       if (typeof option == 'number') data.to(option)
1913       else if (action) data[action]()
1914       else if (options.interval) data.pause().cycle()
1915     })
1916   }
1918   $.fn.carousel.defaults = {
1919     interval: 5000
1920   , pause: 'hover'
1921   }
1923   $.fn.carousel.Constructor = Carousel
1926  /* CAROUSEL NO CONFLICT
1927   * ==================== */
1929   $.fn.carousel.noConflict = function () {
1930     $.fn.carousel = old
1931     return this
1932   }
1934  /* CAROUSEL DATA-API
1935   * ================= */
1937   $(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
1938     var $this = $(this), href
1939       , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
1940       , options = $.extend({}, $target.data(), $this.data())
1941       , slideIndex
1943     $target.carousel(options)
1945     if (slideIndex = $this.attr('data-slide-to')) {
1946       $target.data('carousel').pause().to(slideIndex).cycle()
1947     }
1949     e.preventDefault()
1950   })
1952 }(window.jQuery);
1953 /* =============================================================
1954  * bootstrap-typeahead.js v2.3.1
1955  * http://twitter.github.com/bootstrap/javascript.html#typeahead
1956  * =============================================================
1957  * Copyright 2012 Twitter, Inc.
1959  * Licensed under the Apache License, Version 2.0 (the "License");
1960  * you may not use this file except in compliance with the License.
1961  * You may obtain a copy of the License at
1963  * http://www.apache.org/licenses/LICENSE-2.0
1965  * Unless required by applicable law or agreed to in writing, software
1966  * distributed under the License is distributed on an "AS IS" BASIS,
1967  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1968  * See the License for the specific language governing permissions and
1969  * limitations under the License.
1970  * ============================================================ */
1973 !function($){
1975   "use strict"; // jshint ;_;
1978  /* TYPEAHEAD PUBLIC CLASS DEFINITION
1979   * ================================= */
1981   var Typeahead = function (element, options) {
1982     this.$element = $(element)
1983     this.options = $.extend({}, $.fn.typeahead.defaults, options)
1984     this.matcher = this.options.matcher || this.matcher
1985     this.sorter = this.options.sorter || this.sorter
1986     this.highlighter = this.options.highlighter || this.highlighter
1987     this.updater = this.options.updater || this.updater
1988     this.source = this.options.source
1989     this.$menu = $(this.options.menu)
1990     this.shown = false
1991     this.listen()
1992   }
1994   Typeahead.prototype = {
1996     constructor: Typeahead
1998   , select: function () {
1999       var val = this.$menu.find('.active').attr('data-value')
2000       this.$element
2001         .val(this.updater(val))
2002         .change()
2003       return this.hide()
2004     }
2006   , updater: function (item) {
2007       return item
2008     }
2010   , show: function () {
2011       var pos = $.extend({}, this.$element.position(), {
2012         height: this.$element[0].offsetHeight
2013       })
2015       this.$menu
2016         .insertAfter(this.$element)
2017         .css({
2018           top: pos.top + pos.height
2019         , left: pos.left
2020         })
2021         .show()
2023       this.shown = true
2024       return this
2025     }
2027   , hide: function () {
2028       this.$menu.hide()
2029       this.shown = false
2030       return this
2031     }
2033   , lookup: function (event) {
2034       var items
2036       this.query = this.$element.val()
2038       if (!this.query || this.query.length < this.options.minLength) {
2039         return this.shown ? this.hide() : this
2040       }
2042       items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
2044       return items ? this.process(items) : this
2045     }
2047   , process: function (items) {
2048       var that = this
2050       items = $.grep(items, function (item) {
2051         return that.matcher(item)
2052       })
2054       items = this.sorter(items)
2056       if (!items.length) {
2057         return this.shown ? this.hide() : this
2058       }
2060       return this.render(items.slice(0, this.options.items)).show()
2061     }
2063   , matcher: function (item) {
2064       return ~item.toLowerCase().indexOf(this.query.toLowerCase())
2065     }
2067   , sorter: function (items) {
2068       var beginswith = []
2069         , caseSensitive = []
2070         , caseInsensitive = []
2071         , item
2073       while (item = items.shift()) {
2074         if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
2075         else if (~item.indexOf(this.query)) caseSensitive.push(item)
2076         else caseInsensitive.push(item)
2077       }
2079       return beginswith.concat(caseSensitive, caseInsensitive)
2080     }
2082   , highlighter: function (item) {
2083       var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
2084       return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
2085         return '<strong>' + match + '</strong>'
2086       })
2087     }
2089   , render: function (items) {
2090       var that = this
2092       items = $(items).map(function (i, item) {
2093         i = $(that.options.item).attr('data-value', item)
2094         i.find('a').html(that.highlighter(item))
2095         return i[0]
2096       })
2098       items.first().addClass('active')
2099       this.$menu.html(items)
2100       return this
2101     }
2103   , next: function (event) {
2104       var active = this.$menu.find('.active').removeClass('active')
2105         , next = active.next()
2107       if (!next.length) {
2108         next = $(this.$menu.find('li')[0])
2109       }
2111       next.addClass('active')
2112     }
2114   , prev: function (event) {
2115       var active = this.$menu.find('.active').removeClass('active')
2116         , prev = active.prev()
2118       if (!prev.length) {
2119         prev = this.$menu.find('li').last()
2120       }
2122       prev.addClass('active')
2123     }
2125   , listen: function () {
2126       this.$element
2127         .on('focus',    $.proxy(this.focus, this))
2128         .on('blur',     $.proxy(this.blur, this))
2129         .on('keypress', $.proxy(this.keypress, this))
2130         .on('keyup',    $.proxy(this.keyup, this))
2132       if (this.eventSupported('keydown')) {
2133         this.$element.on('keydown', $.proxy(this.keydown, this))
2134       }
2136       this.$menu
2137         .on('click', $.proxy(this.click, this))
2138         .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
2139         .on('mouseleave', 'li', $.proxy(this.mouseleave, this))
2140     }
2142   , eventSupported: function(eventName) {
2143       var isSupported = eventName in this.$element
2144       if (!isSupported) {
2145         this.$element.setAttribute(eventName, 'return;')
2146         isSupported = typeof this.$element[eventName] === 'function'
2147       }
2148       return isSupported
2149     }
2151   , move: function (e) {
2152       if (!this.shown) return
2154       switch(e.keyCode) {
2155         case 9: // tab
2156         case 13: // enter
2157         case 27: // escape
2158           e.preventDefault()
2159           break
2161         case 38: // up arrow
2162           e.preventDefault()
2163           this.prev()
2164           break
2166         case 40: // down arrow
2167           e.preventDefault()
2168           this.next()
2169           break
2170       }
2172       e.stopPropagation()
2173     }
2175   , keydown: function (e) {
2176       this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
2177       this.move(e)
2178     }
2180   , keypress: function (e) {
2181       if (this.suppressKeyPressRepeat) return
2182       this.move(e)
2183     }
2185   , keyup: function (e) {
2186       switch(e.keyCode) {
2187         case 40: // down arrow
2188         case 38: // up arrow
2189         case 16: // shift
2190         case 17: // ctrl
2191         case 18: // alt
2192           break
2194         case 9: // tab
2195         case 13: // enter
2196           if (!this.shown) return
2197           this.select()
2198           break
2200         case 27: // escape
2201           if (!this.shown) return
2202           this.hide()
2203           break
2205         default:
2206           this.lookup()
2207       }
2209       e.stopPropagation()
2210       e.preventDefault()
2211   }
2213   , focus: function (e) {
2214       this.focused = true
2215     }
2217   , blur: function (e) {
2218       this.focused = false
2219       if (!this.mousedover && this.shown) this.hide()
2220     }
2222   , click: function (e) {
2223       e.stopPropagation()
2224       e.preventDefault()
2225       this.select()
2226       this.$element.focus()
2227     }
2229   , mouseenter: function (e) {
2230       this.mousedover = true
2231       this.$menu.find('.active').removeClass('active')
2232       $(e.currentTarget).addClass('active')
2233     }
2235   , mouseleave: function (e) {
2236       this.mousedover = false
2237       if (!this.focused && this.shown) this.hide()
2238     }
2240   }
2243   /* TYPEAHEAD PLUGIN DEFINITION
2244    * =========================== */
2246   var old = $.fn.typeahead
2248   $.fn.typeahead = function (option) {
2249     return this.each(function () {
2250       var $this = $(this)
2251         , data = $this.data('typeahead')
2252         , options = typeof option == 'object' && option
2253       if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
2254       if (typeof option == 'string') data[option]()
2255     })
2256   }
2258   $.fn.typeahead.defaults = {
2259     source: []
2260   , items: 8
2261   , menu: '<ul class="typeahead dropdown-menu"></ul>'
2262   , item: '<li><a href="#"></a></li>'
2263   , minLength: 1
2264   }
2266   $.fn.typeahead.Constructor = Typeahead
2269  /* TYPEAHEAD NO CONFLICT
2270   * =================== */
2272   $.fn.typeahead.noConflict = function () {
2273     $.fn.typeahead = old
2274     return this
2275   }
2278  /* TYPEAHEAD DATA-API
2279   * ================== */
2281   $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
2282     var $this = $(this)
2283     if ($this.data('typeahead')) return
2284     $this.typeahead($this.data())
2285   })
2287 }(window.jQuery);