2 * Bootstrap v3.0.2 by @fat and @mdo
3 * Copyright 2013 Twitter, Inc.
4 * Licensed under http://www.apache.org/licenses/LICENSE-2.0
6 * Designed and built with all the love in the world by @mdo and @fat.
9 if (typeof jQuery === "undefined") { throw new Error("Bootstrap requires jQuery") }
11 /* ========================================================================
12 * Bootstrap: transition.js v3.0.2
13 * http://getbootstrap.com/javascript/#transitions
14 * ========================================================================
15 * Copyright 2013 Twitter, Inc.
17 * Licensed under the Apache License, Version 2.0 (the "License");
18 * you may not use this file except in compliance with the License.
19 * You may obtain a copy of the License at
21 * http://www.apache.org/licenses/LICENSE-2.0
23 * Unless required by applicable law or agreed to in writing, software
24 * distributed under the License is distributed on an "AS IS" BASIS,
25 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26 * See the License for the specific language governing permissions and
27 * limitations under the License.
28 * ======================================================================== */
31 +function ($) { "use strict";
33 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
34 // ============================================================
36 function transitionEnd() {
37 var el = document.createElement('bootstrap')
39 var transEndEventNames = {
40 'WebkitTransition' : 'webkitTransitionEnd'
41 , 'MozTransition' : 'transitionend'
42 , 'OTransition' : 'oTransitionEnd otransitionend'
43 , 'transition' : 'transitionend'
46 for (var name in transEndEventNames) {
47 if (el.style[name] !== undefined) {
48 return { end: transEndEventNames[name] }
53 // http://blog.alexmaccaw.com/css-transitions
54 $.fn.emulateTransitionEnd = function (duration) {
55 var called = false, $el = this
56 $(this).one($.support.transition.end, function () { called = true })
57 var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
58 setTimeout(callback, duration)
63 $.support.transition = transitionEnd()
68 /* ========================================================================
69 * Bootstrap: alert.js v3.0.2
70 * http://getbootstrap.com/javascript/#alerts
71 * ========================================================================
72 * Copyright 2013 Twitter, Inc.
74 * Licensed under the Apache License, Version 2.0 (the "License");
75 * you may not use this file except in compliance with the License.
76 * You may obtain a copy of the License at
78 * http://www.apache.org/licenses/LICENSE-2.0
80 * Unless required by applicable law or agreed to in writing, software
81 * distributed under the License is distributed on an "AS IS" BASIS,
82 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
83 * See the License for the specific language governing permissions and
84 * limitations under the License.
85 * ======================================================================== */
88 +function ($) { "use strict";
90 // ALERT CLASS DEFINITION
91 // ======================
93 var dismiss = '[data-dismiss="alert"]'
94 var Alert = function (el) {
95 $(el).on('click', dismiss, this.close)
98 Alert.prototype.close = function (e) {
100 var selector = $this.attr('data-target')
103 selector = $this.attr('href')
104 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
107 var $parent = $(selector)
109 if (e) e.preventDefault()
111 if (!$parent.length) {
112 $parent = $this.hasClass('alert') ? $this : $this.parent()
115 $parent.trigger(e = $.Event('close.bs.alert'))
117 if (e.isDefaultPrevented()) return
119 $parent.removeClass('in')
121 function removeElement() {
122 $parent.trigger('closed.bs.alert').remove()
125 $.support.transition && $parent.hasClass('fade') ?
127 .one($.support.transition.end, removeElement)
128 .emulateTransitionEnd(150) :
133 // ALERT PLUGIN DEFINITION
134 // =======================
138 $.fn.alert = function (option) {
139 return this.each(function () {
141 var data = $this.data('bs.alert')
143 if (!data) $this.data('bs.alert', (data = new Alert(this)))
144 if (typeof option == 'string') data[option].call($this)
148 $.fn.alert.Constructor = Alert
154 $.fn.alert.noConflict = function () {
163 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
167 /* ========================================================================
168 * Bootstrap: button.js v3.0.2
169 * http://getbootstrap.com/javascript/#buttons
170 * ========================================================================
171 * Copyright 2013 Twitter, Inc.
173 * Licensed under the Apache License, Version 2.0 (the "License");
174 * you may not use this file except in compliance with the License.
175 * You may obtain a copy of the License at
177 * http://www.apache.org/licenses/LICENSE-2.0
179 * Unless required by applicable law or agreed to in writing, software
180 * distributed under the License is distributed on an "AS IS" BASIS,
181 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
182 * See the License for the specific language governing permissions and
183 * limitations under the License.
184 * ======================================================================== */
187 +function ($) { "use strict";
189 // BUTTON PUBLIC CLASS DEFINITION
190 // ==============================
192 var Button = function (element, options) {
193 this.$element = $(element)
194 this.options = $.extend({}, Button.DEFAULTS, options)
198 loadingText: 'loading...'
201 Button.prototype.setState = function (state) {
203 var $el = this.$element
204 var val = $el.is('input') ? 'val' : 'html'
205 var data = $el.data()
207 state = state + 'Text'
209 if (!data.resetText) $el.data('resetText', $el[val]())
211 $el[val](data[state] || this.options[state])
213 // push to event loop to allow forms to submit
214 setTimeout(function () {
215 state == 'loadingText' ?
216 $el.addClass(d).attr(d, d) :
217 $el.removeClass(d).removeAttr(d);
221 Button.prototype.toggle = function () {
222 var $parent = this.$element.closest('[data-toggle="buttons"]')
224 if ($parent.length) {
225 var $input = this.$element.find('input')
226 .prop('checked', !this.$element.hasClass('active'))
228 if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active')
231 this.$element.toggleClass('active')
235 // BUTTON PLUGIN DEFINITION
236 // ========================
238 var old = $.fn.button
240 $.fn.button = function (option) {
241 return this.each(function () {
243 var data = $this.data('bs.button')
244 var options = typeof option == 'object' && option
246 if (!data) $this.data('bs.button', (data = new Button(this, options)))
248 if (option == 'toggle') data.toggle()
249 else if (option) data.setState(option)
253 $.fn.button.Constructor = Button
256 // BUTTON NO CONFLICT
257 // ==================
259 $.fn.button.noConflict = function () {
268 $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
269 var $btn = $(e.target)
270 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
271 $btn.button('toggle')
277 /* ========================================================================
278 * Bootstrap: carousel.js v3.0.2
279 * http://getbootstrap.com/javascript/#carousel
280 * ========================================================================
281 * Copyright 2013 Twitter, Inc.
283 * Licensed under the Apache License, Version 2.0 (the "License");
284 * you may not use this file except in compliance with the License.
285 * You may obtain a copy of the License at
287 * http://www.apache.org/licenses/LICENSE-2.0
289 * Unless required by applicable law or agreed to in writing, software
290 * distributed under the License is distributed on an "AS IS" BASIS,
291 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
292 * See the License for the specific language governing permissions and
293 * limitations under the License.
294 * ======================================================================== */
297 +function ($) { "use strict";
299 // CAROUSEL CLASS DEFINITION
300 // =========================
302 var Carousel = function (element, options) {
303 this.$element = $(element)
304 this.$indicators = this.$element.find('.carousel-indicators')
305 this.options = options
312 this.options.pause == 'hover' && this.$element
313 .on('mouseenter', $.proxy(this.pause, this))
314 .on('mouseleave', $.proxy(this.cycle, this))
317 Carousel.DEFAULTS = {
323 Carousel.prototype.cycle = function (e) {
324 e || (this.paused = false)
326 this.interval && clearInterval(this.interval)
328 this.options.interval
330 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
335 Carousel.prototype.getActiveIndex = function () {
336 this.$active = this.$element.find('.item.active')
337 this.$items = this.$active.parent().children()
339 return this.$items.index(this.$active)
342 Carousel.prototype.to = function (pos) {
344 var activeIndex = this.getActiveIndex()
346 if (pos > (this.$items.length - 1) || pos < 0) return
348 if (this.sliding) return this.$element.one('slid', function () { that.to(pos) })
349 if (activeIndex == pos) return this.pause().cycle()
351 return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
354 Carousel.prototype.pause = function (e) {
355 e || (this.paused = true)
357 if (this.$element.find('.next, .prev').length && $.support.transition.end) {
358 this.$element.trigger($.support.transition.end)
362 this.interval = clearInterval(this.interval)
367 Carousel.prototype.next = function () {
368 if (this.sliding) return
369 return this.slide('next')
372 Carousel.prototype.prev = function () {
373 if (this.sliding) return
374 return this.slide('prev')
377 Carousel.prototype.slide = function (type, next) {
378 var $active = this.$element.find('.item.active')
379 var $next = next || $active[type]()
380 var isCycling = this.interval
381 var direction = type == 'next' ? 'left' : 'right'
382 var fallback = type == 'next' ? 'first' : 'last'
386 if (!this.options.wrap) return
387 $next = this.$element.find('.item')[fallback]()
392 isCycling && this.pause()
394 var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction })
396 if ($next.hasClass('active')) return
398 if (this.$indicators.length) {
399 this.$indicators.find('.active').removeClass('active')
400 this.$element.one('slid', function () {
401 var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
402 $nextIndicator && $nextIndicator.addClass('active')
406 if ($.support.transition && this.$element.hasClass('slide')) {
407 this.$element.trigger(e)
408 if (e.isDefaultPrevented()) return
410 $next[0].offsetWidth // force reflow
411 $active.addClass(direction)
412 $next.addClass(direction)
414 .one($.support.transition.end, function () {
415 $next.removeClass([type, direction].join(' ')).addClass('active')
416 $active.removeClass(['active', direction].join(' '))
418 setTimeout(function () { that.$element.trigger('slid') }, 0)
420 .emulateTransitionEnd(600)
422 this.$element.trigger(e)
423 if (e.isDefaultPrevented()) return
424 $active.removeClass('active')
425 $next.addClass('active')
427 this.$element.trigger('slid')
430 isCycling && this.cycle()
436 // CAROUSEL PLUGIN DEFINITION
437 // ==========================
439 var old = $.fn.carousel
441 $.fn.carousel = function (option) {
442 return this.each(function () {
444 var data = $this.data('bs.carousel')
445 var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
446 var action = typeof option == 'string' ? option : options.slide
448 if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
449 if (typeof option == 'number') data.to(option)
450 else if (action) data[action]()
451 else if (options.interval) data.pause().cycle()
455 $.fn.carousel.Constructor = Carousel
458 // CAROUSEL NO CONFLICT
459 // ====================
461 $.fn.carousel.noConflict = function () {
470 $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
471 var $this = $(this), href
472 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
473 var options = $.extend({}, $target.data(), $this.data())
474 var slideIndex = $this.attr('data-slide-to')
475 if (slideIndex) options.interval = false
477 $target.carousel(options)
479 if (slideIndex = $this.attr('data-slide-to')) {
480 $target.data('bs.carousel').to(slideIndex)
486 $(window).on('load', function () {
487 $('[data-ride="carousel"]').each(function () {
488 var $carousel = $(this)
489 $carousel.carousel($carousel.data())
495 /* ========================================================================
496 * Bootstrap: collapse.js v3.0.2
497 * http://getbootstrap.com/javascript/#collapse
498 * ========================================================================
499 * Copyright 2013 Twitter, Inc.
501 * Licensed under the Apache License, Version 2.0 (the "License");
502 * you may not use this file except in compliance with the License.
503 * You may obtain a copy of the License at
505 * http://www.apache.org/licenses/LICENSE-2.0
507 * Unless required by applicable law or agreed to in writing, software
508 * distributed under the License is distributed on an "AS IS" BASIS,
509 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
510 * See the License for the specific language governing permissions and
511 * limitations under the License.
512 * ======================================================================== */
515 +function ($) { "use strict";
517 // COLLAPSE PUBLIC CLASS DEFINITION
518 // ================================
520 var Collapse = function (element, options) {
521 this.$element = $(element)
522 this.options = $.extend({}, Collapse.DEFAULTS, options)
523 this.transitioning = null
525 if (this.options.parent) this.$parent = $(this.options.parent)
526 if (this.options.toggle) this.toggle()
529 Collapse.DEFAULTS = {
533 Collapse.prototype.dimension = function () {
534 var hasWidth = this.$element.hasClass('width')
535 return hasWidth ? 'width' : 'height'
538 Collapse.prototype.show = function () {
539 if (this.transitioning || this.$element.hasClass('in')) return
541 var startEvent = $.Event('show.bs.collapse')
542 this.$element.trigger(startEvent)
543 if (startEvent.isDefaultPrevented()) return
545 var actives = this.$parent && this.$parent.find('> .panel > .in')
547 if (actives && actives.length) {
548 var hasData = actives.data('bs.collapse')
549 if (hasData && hasData.transitioning) return
550 actives.collapse('hide')
551 hasData || actives.data('bs.collapse', null)
554 var dimension = this.dimension()
557 .removeClass('collapse')
558 .addClass('collapsing')
561 this.transitioning = 1
563 var complete = function () {
565 .removeClass('collapsing')
568 this.transitioning = 0
569 this.$element.trigger('shown.bs.collapse')
572 if (!$.support.transition) return complete.call(this)
574 var scrollSize = $.camelCase(['scroll', dimension].join('-'))
577 .one($.support.transition.end, $.proxy(complete, this))
578 .emulateTransitionEnd(350)
579 [dimension](this.$element[0][scrollSize])
582 Collapse.prototype.hide = function () {
583 if (this.transitioning || !this.$element.hasClass('in')) return
585 var startEvent = $.Event('hide.bs.collapse')
586 this.$element.trigger(startEvent)
587 if (startEvent.isDefaultPrevented()) return
589 var dimension = this.dimension()
592 [dimension](this.$element[dimension]())
596 .addClass('collapsing')
597 .removeClass('collapse')
600 this.transitioning = 1
602 var complete = function () {
603 this.transitioning = 0
605 .trigger('hidden.bs.collapse')
606 .removeClass('collapsing')
607 .addClass('collapse')
610 if (!$.support.transition) return complete.call(this)
614 .one($.support.transition.end, $.proxy(complete, this))
615 .emulateTransitionEnd(350)
618 Collapse.prototype.toggle = function () {
619 this[this.$element.hasClass('in') ? 'hide' : 'show']()
623 // COLLAPSE PLUGIN DEFINITION
624 // ==========================
626 var old = $.fn.collapse
628 $.fn.collapse = function (option) {
629 return this.each(function () {
631 var data = $this.data('bs.collapse')
632 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
634 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
635 if (typeof option == 'string') data[option]()
639 $.fn.collapse.Constructor = Collapse
642 // COLLAPSE NO CONFLICT
643 // ====================
645 $.fn.collapse.noConflict = function () {
654 $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
655 var $this = $(this), href
656 var target = $this.attr('data-target')
657 || e.preventDefault()
658 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
659 var $target = $(target)
660 var data = $target.data('bs.collapse')
661 var option = data ? 'toggle' : $this.data()
662 var parent = $this.attr('data-parent')
663 var $parent = parent && $(parent)
665 if (!data || !data.transitioning) {
666 if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed')
667 $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
670 $target.collapse(option)
675 /* ========================================================================
676 * Bootstrap: dropdown.js v3.0.2
677 * http://getbootstrap.com/javascript/#dropdowns
678 * ========================================================================
679 * Copyright 2013 Twitter, Inc.
681 * Licensed under the Apache License, Version 2.0 (the "License");
682 * you may not use this file except in compliance with the License.
683 * You may obtain a copy of the License at
685 * http://www.apache.org/licenses/LICENSE-2.0
687 * Unless required by applicable law or agreed to in writing, software
688 * distributed under the License is distributed on an "AS IS" BASIS,
689 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
690 * See the License for the specific language governing permissions and
691 * limitations under the License.
692 * ======================================================================== */
695 +function ($) { "use strict";
697 // DROPDOWN CLASS DEFINITION
698 // =========================
700 var backdrop = '.dropdown-backdrop'
701 var toggle = '[data-toggle=dropdown]'
702 var Dropdown = function (element) {
703 var $el = $(element).on('click.bs.dropdown', this.toggle)
706 Dropdown.prototype.toggle = function (e) {
709 if ($this.is('.disabled, :disabled')) return
711 var $parent = getParent($this)
712 var isActive = $parent.hasClass('open')
717 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
718 // if mobile we we use a backdrop because click events don't delegate
719 $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
722 $parent.trigger(e = $.Event('show.bs.dropdown'))
724 if (e.isDefaultPrevented()) return
728 .trigger('shown.bs.dropdown')
736 Dropdown.prototype.keydown = function (e) {
737 if (!/(38|40|27)/.test(e.keyCode)) return
744 if ($this.is('.disabled, :disabled')) return
746 var $parent = getParent($this)
747 var isActive = $parent.hasClass('open')
749 if (!isActive || (isActive && e.keyCode == 27)) {
750 if (e.which == 27) $parent.find(toggle).focus()
754 var $items = $('[role=menu] li:not(.divider):visible a', $parent)
756 if (!$items.length) return
758 var index = $items.index($items.filter(':focus'))
760 if (e.keyCode == 38 && index > 0) index-- // up
761 if (e.keyCode == 40 && index < $items.length - 1) index++ // down
764 $items.eq(index).focus()
767 function clearMenus() {
769 $(toggle).each(function (e) {
770 var $parent = getParent($(this))
771 if (!$parent.hasClass('open')) return
772 $parent.trigger(e = $.Event('hide.bs.dropdown'))
773 if (e.isDefaultPrevented()) return
774 $parent.removeClass('open').trigger('hidden.bs.dropdown')
778 function getParent($this) {
779 var selector = $this.attr('data-target')
782 selector = $this.attr('href')
783 selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
786 var $parent = selector && $(selector)
788 return $parent && $parent.length ? $parent : $this.parent()
792 // DROPDOWN PLUGIN DEFINITION
793 // ==========================
795 var old = $.fn.dropdown
797 $.fn.dropdown = function (option) {
798 return this.each(function () {
800 var data = $this.data('dropdown')
802 if (!data) $this.data('dropdown', (data = new Dropdown(this)))
803 if (typeof option == 'string') data[option].call($this)
807 $.fn.dropdown.Constructor = Dropdown
810 // DROPDOWN NO CONFLICT
811 // ====================
813 $.fn.dropdown.noConflict = function () {
819 // APPLY TO STANDARD DROPDOWN ELEMENTS
820 // ===================================
823 .on('click.bs.dropdown.data-api', clearMenus)
824 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
825 .on('click.bs.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
826 .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
830 /* ========================================================================
831 * Bootstrap: modal.js v3.0.2
832 * http://getbootstrap.com/javascript/#modals
833 * ========================================================================
834 * Copyright 2013 Twitter, Inc.
836 * Licensed under the Apache License, Version 2.0 (the "License");
837 * you may not use this file except in compliance with the License.
838 * You may obtain a copy of the License at
840 * http://www.apache.org/licenses/LICENSE-2.0
842 * Unless required by applicable law or agreed to in writing, software
843 * distributed under the License is distributed on an "AS IS" BASIS,
844 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
845 * See the License for the specific language governing permissions and
846 * limitations under the License.
847 * ======================================================================== */
850 +function ($) { "use strict";
852 // MODAL CLASS DEFINITION
853 // ======================
855 var Modal = function (element, options) {
856 this.options = options
857 this.$element = $(element)
861 if (this.options.remote) this.$element.load(this.options.remote)
870 Modal.prototype.toggle = function (_relatedTarget) {
871 return this[!this.isShown ? 'show' : 'hide'](_relatedTarget)
874 Modal.prototype.show = function (_relatedTarget) {
876 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
878 this.$element.trigger(e)
880 if (this.isShown || e.isDefaultPrevented()) return
886 this.$element.on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
888 this.backdrop(function () {
889 var transition = $.support.transition && that.$element.hasClass('fade')
891 if (!that.$element.parent().length) {
892 that.$element.appendTo(document.body) // don't move modals dom position
898 that.$element[0].offsetWidth // force reflow
903 .attr('aria-hidden', false)
907 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
910 that.$element.find('.modal-dialog') // wait for modal to slide in
911 .one($.support.transition.end, function () {
912 that.$element.focus().trigger(e)
914 .emulateTransitionEnd(300) :
915 that.$element.focus().trigger(e)
919 Modal.prototype.hide = function (e) {
920 if (e) e.preventDefault()
922 e = $.Event('hide.bs.modal')
924 this.$element.trigger(e)
926 if (!this.isShown || e.isDefaultPrevented()) return
932 $(document).off('focusin.bs.modal')
936 .attr('aria-hidden', true)
937 .off('click.dismiss.modal')
939 $.support.transition && this.$element.hasClass('fade') ?
941 .one($.support.transition.end, $.proxy(this.hideModal, this))
942 .emulateTransitionEnd(300) :
946 Modal.prototype.enforceFocus = function () {
948 .off('focusin.bs.modal') // guard against infinite focus loop
949 .on('focusin.bs.modal', $.proxy(function (e) {
950 if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
951 this.$element.focus()
956 Modal.prototype.escape = function () {
957 if (this.isShown && this.options.keyboard) {
958 this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
959 e.which == 27 && this.hide()
961 } else if (!this.isShown) {
962 this.$element.off('keyup.dismiss.bs.modal')
966 Modal.prototype.hideModal = function () {
969 this.backdrop(function () {
970 that.removeBackdrop()
971 that.$element.trigger('hidden.bs.modal')
975 Modal.prototype.removeBackdrop = function () {
976 this.$backdrop && this.$backdrop.remove()
977 this.$backdrop = null
980 Modal.prototype.backdrop = function (callback) {
982 var animate = this.$element.hasClass('fade') ? 'fade' : ''
984 if (this.isShown && this.options.backdrop) {
985 var doAnimate = $.support.transition && animate
987 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
988 .appendTo(document.body)
990 this.$element.on('click.dismiss.modal', $.proxy(function (e) {
991 if (e.target !== e.currentTarget) return
992 this.options.backdrop == 'static'
993 ? this.$element[0].focus.call(this.$element[0])
994 : this.hide.call(this)
997 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
999 this.$backdrop.addClass('in')
1001 if (!callback) return
1005 .one($.support.transition.end, callback)
1006 .emulateTransitionEnd(150) :
1009 } else if (!this.isShown && this.$backdrop) {
1010 this.$backdrop.removeClass('in')
1012 $.support.transition && this.$element.hasClass('fade')?
1014 .one($.support.transition.end, callback)
1015 .emulateTransitionEnd(150) :
1018 } else if (callback) {
1024 // MODAL PLUGIN DEFINITION
1025 // =======================
1027 var old = $.fn.modal
1029 $.fn.modal = function (option, _relatedTarget) {
1030 return this.each(function () {
1032 var data = $this.data('bs.modal')
1033 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
1035 if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
1036 if (typeof option == 'string') data[option](_relatedTarget)
1037 else if (options.show) data.show(_relatedTarget)
1041 $.fn.modal.Constructor = Modal
1044 // MODAL NO CONFLICT
1045 // =================
1047 $.fn.modal.noConflict = function () {
1056 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
1058 var href = $this.attr('href')
1059 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
1060 var option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
1065 .modal(option, this)
1066 .one('hide', function () {
1067 $this.is(':visible') && $this.focus()
1072 .on('show.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') })
1073 .on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') })
1077 /* ========================================================================
1078 * Bootstrap: tooltip.js v3.0.2
1079 * http://getbootstrap.com/javascript/#tooltip
1080 * Inspired by the original jQuery.tipsy by Jason Frame
1081 * ========================================================================
1082 * Copyright 2013 Twitter, Inc.
1084 * Licensed under the Apache License, Version 2.0 (the "License");
1085 * you may not use this file except in compliance with the License.
1086 * You may obtain a copy of the License at
1088 * http://www.apache.org/licenses/LICENSE-2.0
1090 * Unless required by applicable law or agreed to in writing, software
1091 * distributed under the License is distributed on an "AS IS" BASIS,
1092 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1093 * See the License for the specific language governing permissions and
1094 * limitations under the License.
1095 * ======================================================================== */
1098 +function ($) { "use strict";
1100 // TOOLTIP PUBLIC CLASS DEFINITION
1101 // ===============================
1103 var Tooltip = function (element, options) {
1109 this.$element = null
1111 this.init('tooltip', element, options)
1114 Tooltip.DEFAULTS = {
1118 , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
1119 , trigger: 'hover focus'
1126 Tooltip.prototype.init = function (type, element, options) {
1129 this.$element = $(element)
1130 this.options = this.getOptions(options)
1132 var triggers = this.options.trigger.split(' ')
1134 for (var i = triggers.length; i--;) {
1135 var trigger = triggers[i]
1137 if (trigger == 'click') {
1138 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
1139 } else if (trigger != 'manual') {
1140 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
1141 var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
1143 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
1144 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
1148 this.options.selector ?
1149 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
1153 Tooltip.prototype.getDefaults = function () {
1154 return Tooltip.DEFAULTS
1157 Tooltip.prototype.getOptions = function (options) {
1158 options = $.extend({}, this.getDefaults(), this.$element.data(), options)
1160 if (options.delay && typeof options.delay == 'number') {
1163 , hide: options.delay
1170 Tooltip.prototype.getDelegateOptions = function () {
1172 var defaults = this.getDefaults()
1174 this._options && $.each(this._options, function (key, value) {
1175 if (defaults[key] != value) options[key] = value
1181 Tooltip.prototype.enter = function (obj) {
1182 var self = obj instanceof this.constructor ?
1183 obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
1185 clearTimeout(self.timeout)
1187 self.hoverState = 'in'
1189 if (!self.options.delay || !self.options.delay.show) return self.show()
1191 self.timeout = setTimeout(function () {
1192 if (self.hoverState == 'in') self.show()
1193 }, self.options.delay.show)
1196 Tooltip.prototype.leave = function (obj) {
1197 var self = obj instanceof this.constructor ?
1198 obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
1200 clearTimeout(self.timeout)
1202 self.hoverState = 'out'
1204 if (!self.options.delay || !self.options.delay.hide) return self.hide()
1206 self.timeout = setTimeout(function () {
1207 if (self.hoverState == 'out') self.hide()
1208 }, self.options.delay.hide)
1211 Tooltip.prototype.show = function () {
1212 var e = $.Event('show.bs.'+ this.type)
1214 if (this.hasContent() && this.enabled) {
1215 this.$element.trigger(e)
1217 if (e.isDefaultPrevented()) return
1219 var $tip = this.tip()
1223 if (this.options.animation) $tip.addClass('fade')
1225 var placement = typeof this.options.placement == 'function' ?
1226 this.options.placement.call(this, $tip[0], this.$element[0]) :
1227 this.options.placement
1229 var autoToken = /\s?auto?\s?/i
1230 var autoPlace = autoToken.test(placement)
1231 if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
1235 .css({ top: 0, left: 0, display: 'block' })
1236 .addClass(placement)
1238 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
1240 var pos = this.getPosition()
1241 var actualWidth = $tip[0].offsetWidth
1242 var actualHeight = $tip[0].offsetHeight
1245 var $parent = this.$element.parent()
1247 var orgPlacement = placement
1248 var docScroll = document.documentElement.scrollTop || document.body.scrollTop
1249 var parentWidth = this.options.container == 'body' ? window.innerWidth : $parent.outerWidth()
1250 var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
1251 var parentLeft = this.options.container == 'body' ? 0 : $parent.offset().left
1253 placement = placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight ? 'top' :
1254 placement == 'top' && pos.top - docScroll - actualHeight < 0 ? 'bottom' :
1255 placement == 'right' && pos.right + actualWidth > parentWidth ? 'left' :
1256 placement == 'left' && pos.left - actualWidth < parentLeft ? 'right' :
1260 .removeClass(orgPlacement)
1261 .addClass(placement)
1264 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
1266 this.applyPlacement(calculatedOffset, placement)
1267 this.$element.trigger('shown.bs.' + this.type)
1271 Tooltip.prototype.applyPlacement = function(offset, placement) {
1273 var $tip = this.tip()
1274 var width = $tip[0].offsetWidth
1275 var height = $tip[0].offsetHeight
1277 // manually read margins because getBoundingClientRect includes difference
1278 var marginTop = parseInt($tip.css('margin-top'), 10)
1279 var marginLeft = parseInt($tip.css('margin-left'), 10)
1281 // we must check for NaN for ie 8/9
1282 if (isNaN(marginTop)) marginTop = 0
1283 if (isNaN(marginLeft)) marginLeft = 0
1285 offset.top = offset.top + marginTop
1286 offset.left = offset.left + marginLeft
1292 // check to see if placing tip in new offset caused the tip to resize itself
1293 var actualWidth = $tip[0].offsetWidth
1294 var actualHeight = $tip[0].offsetHeight
1296 if (placement == 'top' && actualHeight != height) {
1298 offset.top = offset.top + height - actualHeight
1301 if (/bottom|top/.test(placement)) {
1304 if (offset.left < 0) {
1305 delta = offset.left * -2
1310 actualWidth = $tip[0].offsetWidth
1311 actualHeight = $tip[0].offsetHeight
1314 this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
1316 this.replaceArrow(actualHeight - height, actualHeight, 'top')
1319 if (replace) $tip.offset(offset)
1322 Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
1323 this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
1326 Tooltip.prototype.setContent = function () {
1327 var $tip = this.tip()
1328 var title = this.getTitle()
1330 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
1331 $tip.removeClass('fade in top bottom left right')
1334 Tooltip.prototype.hide = function () {
1336 var $tip = this.tip()
1337 var e = $.Event('hide.bs.' + this.type)
1339 function complete() {
1340 if (that.hoverState != 'in') $tip.detach()
1343 this.$element.trigger(e)
1345 if (e.isDefaultPrevented()) return
1347 $tip.removeClass('in')
1349 $.support.transition && this.$tip.hasClass('fade') ?
1351 .one($.support.transition.end, complete)
1352 .emulateTransitionEnd(150) :
1355 this.$element.trigger('hidden.bs.' + this.type)
1360 Tooltip.prototype.fixTitle = function () {
1361 var $e = this.$element
1362 if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
1363 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
1367 Tooltip.prototype.hasContent = function () {
1368 return this.getTitle()
1371 Tooltip.prototype.getPosition = function () {
1372 var el = this.$element[0]
1373 return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
1374 width: el.offsetWidth
1375 , height: el.offsetHeight
1376 }, this.$element.offset())
1379 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
1380 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
1381 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
1382 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
1383 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
1386 Tooltip.prototype.getTitle = function () {
1388 var $e = this.$element
1389 var o = this.options
1391 title = $e.attr('data-original-title')
1392 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
1397 Tooltip.prototype.tip = function () {
1398 return this.$tip = this.$tip || $(this.options.template)
1401 Tooltip.prototype.arrow = function () {
1402 return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
1405 Tooltip.prototype.validate = function () {
1406 if (!this.$element[0].parentNode) {
1408 this.$element = null
1413 Tooltip.prototype.enable = function () {
1417 Tooltip.prototype.disable = function () {
1418 this.enabled = false
1421 Tooltip.prototype.toggleEnabled = function () {
1422 this.enabled = !this.enabled
1425 Tooltip.prototype.toggle = function (e) {
1426 var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this
1427 self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
1430 Tooltip.prototype.destroy = function () {
1431 this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
1435 // TOOLTIP PLUGIN DEFINITION
1436 // =========================
1438 var old = $.fn.tooltip
1440 $.fn.tooltip = function (option) {
1441 return this.each(function () {
1443 var data = $this.data('bs.tooltip')
1444 var options = typeof option == 'object' && option
1446 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
1447 if (typeof option == 'string') data[option]()
1451 $.fn.tooltip.Constructor = Tooltip
1454 // TOOLTIP NO CONFLICT
1455 // ===================
1457 $.fn.tooltip.noConflict = function () {
1464 /* ========================================================================
1465 * Bootstrap: popover.js v3.0.2
1466 * http://getbootstrap.com/javascript/#popovers
1467 * ========================================================================
1468 * Copyright 2013 Twitter, Inc.
1470 * Licensed under the Apache License, Version 2.0 (the "License");
1471 * you may not use this file except in compliance with the License.
1472 * You may obtain a copy of the License at
1474 * http://www.apache.org/licenses/LICENSE-2.0
1476 * Unless required by applicable law or agreed to in writing, software
1477 * distributed under the License is distributed on an "AS IS" BASIS,
1478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1479 * See the License for the specific language governing permissions and
1480 * limitations under the License.
1481 * ======================================================================== */
1484 +function ($) { "use strict";
1486 // POPOVER PUBLIC CLASS DEFINITION
1487 // ===============================
1489 var Popover = function (element, options) {
1490 this.init('popover', element, options)
1493 if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
1495 Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
1499 , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
1503 // NOTE: POPOVER EXTENDS tooltip.js
1504 // ================================
1506 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
1508 Popover.prototype.constructor = Popover
1510 Popover.prototype.getDefaults = function () {
1511 return Popover.DEFAULTS
1514 Popover.prototype.setContent = function () {
1515 var $tip = this.tip()
1516 var title = this.getTitle()
1517 var content = this.getContent()
1519 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
1520 $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
1522 $tip.removeClass('fade top bottom left right in')
1524 // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
1525 // this manually by checking the contents.
1526 if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
1529 Popover.prototype.hasContent = function () {
1530 return this.getTitle() || this.getContent()
1533 Popover.prototype.getContent = function () {
1534 var $e = this.$element
1535 var o = this.options
1537 return $e.attr('data-content')
1538 || (typeof o.content == 'function' ?
1539 o.content.call($e[0]) :
1543 Popover.prototype.arrow = function () {
1544 return this.$arrow = this.$arrow || this.tip().find('.arrow')
1547 Popover.prototype.tip = function () {
1548 if (!this.$tip) this.$tip = $(this.options.template)
1553 // POPOVER PLUGIN DEFINITION
1554 // =========================
1556 var old = $.fn.popover
1558 $.fn.popover = function (option) {
1559 return this.each(function () {
1561 var data = $this.data('bs.popover')
1562 var options = typeof option == 'object' && option
1564 if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
1565 if (typeof option == 'string') data[option]()
1569 $.fn.popover.Constructor = Popover
1572 // POPOVER NO CONFLICT
1573 // ===================
1575 $.fn.popover.noConflict = function () {
1582 /* ========================================================================
1583 * Bootstrap: scrollspy.js v3.0.2
1584 * http://getbootstrap.com/javascript/#scrollspy
1585 * ========================================================================
1586 * Copyright 2013 Twitter, Inc.
1588 * Licensed under the Apache License, Version 2.0 (the "License");
1589 * you may not use this file except in compliance with the License.
1590 * You may obtain a copy of the License at
1592 * http://www.apache.org/licenses/LICENSE-2.0
1594 * Unless required by applicable law or agreed to in writing, software
1595 * distributed under the License is distributed on an "AS IS" BASIS,
1596 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1597 * See the License for the specific language governing permissions and
1598 * limitations under the License.
1599 * ======================================================================== */
1602 +function ($) { "use strict";
1604 // SCROLLSPY CLASS DEFINITION
1605 // ==========================
1607 function ScrollSpy(element, options) {
1609 var process = $.proxy(this.process, this)
1611 this.$element = $(element).is('body') ? $(window) : $(element)
1612 this.$body = $('body')
1613 this.$scrollElement = this.$element.on('scroll.bs.scroll-spy.data-api', process)
1614 this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
1615 this.selector = (this.options.target
1616 || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
1617 || '') + ' .nav li > a'
1618 this.offsets = $([])
1619 this.targets = $([])
1620 this.activeTarget = null
1626 ScrollSpy.DEFAULTS = {
1630 ScrollSpy.prototype.refresh = function () {
1631 var offsetMethod = this.$element[0] == window ? 'offset' : 'position'
1633 this.offsets = $([])
1634 this.targets = $([])
1637 var $targets = this.$body
1638 .find(this.selector)
1641 var href = $el.data('target') || $el.attr('href')
1642 var $href = /^#\w/.test(href) && $(href)
1646 && [[ $href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null
1648 .sort(function (a, b) { return a[0] - b[0] })
1650 self.offsets.push(this[0])
1651 self.targets.push(this[1])
1655 ScrollSpy.prototype.process = function () {
1656 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
1657 var scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
1658 var maxScroll = scrollHeight - this.$scrollElement.height()
1659 var offsets = this.offsets
1660 var targets = this.targets
1661 var activeTarget = this.activeTarget
1664 if (scrollTop >= maxScroll) {
1665 return activeTarget != (i = targets.last()[0]) && this.activate(i)
1668 for (i = offsets.length; i--;) {
1669 activeTarget != targets[i]
1670 && scrollTop >= offsets[i]
1671 && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
1672 && this.activate( targets[i] )
1676 ScrollSpy.prototype.activate = function (target) {
1677 this.activeTarget = target
1681 .removeClass('active')
1683 var selector = this.selector
1684 + '[data-target="' + target + '"],'
1685 + this.selector + '[href="' + target + '"]'
1687 var active = $(selector)
1691 if (active.parent('.dropdown-menu').length) {
1693 .closest('li.dropdown')
1697 active.trigger('activate')
1701 // SCROLLSPY PLUGIN DEFINITION
1702 // ===========================
1704 var old = $.fn.scrollspy
1706 $.fn.scrollspy = function (option) {
1707 return this.each(function () {
1709 var data = $this.data('bs.scrollspy')
1710 var options = typeof option == 'object' && option
1712 if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
1713 if (typeof option == 'string') data[option]()
1717 $.fn.scrollspy.Constructor = ScrollSpy
1720 // SCROLLSPY NO CONFLICT
1721 // =====================
1723 $.fn.scrollspy.noConflict = function () {
1724 $.fn.scrollspy = old
1729 // SCROLLSPY DATA-API
1730 // ==================
1732 $(window).on('load', function () {
1733 $('[data-spy="scroll"]').each(function () {
1735 $spy.scrollspy($spy.data())
1741 /* ========================================================================
1742 * Bootstrap: tab.js v3.0.2
1743 * http://getbootstrap.com/javascript/#tabs
1744 * ========================================================================
1745 * Copyright 2013 Twitter, Inc.
1747 * Licensed under the Apache License, Version 2.0 (the "License");
1748 * you may not use this file except in compliance with the License.
1749 * You may obtain a copy of the License at
1751 * http://www.apache.org/licenses/LICENSE-2.0
1753 * Unless required by applicable law or agreed to in writing, software
1754 * distributed under the License is distributed on an "AS IS" BASIS,
1755 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1756 * See the License for the specific language governing permissions and
1757 * limitations under the License.
1758 * ======================================================================== */
1761 +function ($) { "use strict";
1763 // TAB CLASS DEFINITION
1764 // ====================
1766 var Tab = function (element) {
1767 this.element = $(element)
1770 Tab.prototype.show = function () {
1771 var $this = this.element
1772 var $ul = $this.closest('ul:not(.dropdown-menu)')
1773 var selector = $this.data('target')
1776 selector = $this.attr('href')
1777 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
1780 if ($this.parent('li').hasClass('active')) return
1782 var previous = $ul.find('.active:last a')[0]
1783 var e = $.Event('show.bs.tab', {
1784 relatedTarget: previous
1789 if (e.isDefaultPrevented()) return
1791 var $target = $(selector)
1793 this.activate($this.parent('li'), $ul)
1794 this.activate($target, $target.parent(), function () {
1796 type: 'shown.bs.tab'
1797 , relatedTarget: previous
1802 Tab.prototype.activate = function (element, container, callback) {
1803 var $active = container.find('> .active')
1804 var transition = callback
1805 && $.support.transition
1806 && $active.hasClass('fade')
1810 .removeClass('active')
1811 .find('> .dropdown-menu > .active')
1812 .removeClass('active')
1814 element.addClass('active')
1817 element[0].offsetWidth // reflow for transition
1818 element.addClass('in')
1820 element.removeClass('fade')
1823 if (element.parent('.dropdown-menu')) {
1824 element.closest('li.dropdown').addClass('active')
1827 callback && callback()
1832 .one($.support.transition.end, next)
1833 .emulateTransitionEnd(150) :
1836 $active.removeClass('in')
1840 // TAB PLUGIN DEFINITION
1841 // =====================
1845 $.fn.tab = function ( option ) {
1846 return this.each(function () {
1848 var data = $this.data('bs.tab')
1850 if (!data) $this.data('bs.tab', (data = new Tab(this)))
1851 if (typeof option == 'string') data[option]()
1855 $.fn.tab.Constructor = Tab
1861 $.fn.tab.noConflict = function () {
1870 $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
1877 /* ========================================================================
1878 * Bootstrap: affix.js v3.0.2
1879 * http://getbootstrap.com/javascript/#affix
1880 * ========================================================================
1881 * Copyright 2013 Twitter, Inc.
1883 * Licensed under the Apache License, Version 2.0 (the "License");
1884 * you may not use this file except in compliance with the License.
1885 * You may obtain a copy of the License at
1887 * http://www.apache.org/licenses/LICENSE-2.0
1889 * Unless required by applicable law or agreed to in writing, software
1890 * distributed under the License is distributed on an "AS IS" BASIS,
1891 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1892 * See the License for the specific language governing permissions and
1893 * limitations under the License.
1894 * ======================================================================== */
1897 +function ($) { "use strict";
1899 // AFFIX CLASS DEFINITION
1900 // ======================
1902 var Affix = function (element, options) {
1903 this.options = $.extend({}, Affix.DEFAULTS, options)
1904 this.$window = $(window)
1905 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
1906 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
1908 this.$element = $(element)
1912 this.checkPosition()
1915 Affix.RESET = 'affix affix-top affix-bottom'
1921 Affix.prototype.checkPositionWithEventLoop = function () {
1922 setTimeout($.proxy(this.checkPosition, this), 1)
1925 Affix.prototype.checkPosition = function () {
1926 if (!this.$element.is(':visible')) return
1928 var scrollHeight = $(document).height()
1929 var scrollTop = this.$window.scrollTop()
1930 var position = this.$element.offset()
1931 var offset = this.options.offset
1932 var offsetTop = offset.top
1933 var offsetBottom = offset.bottom
1935 if (typeof offset != 'object') offsetBottom = offsetTop = offset
1936 if (typeof offsetTop == 'function') offsetTop = offset.top()
1937 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
1939 var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
1940 offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
1941 offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
1943 if (this.affixed === affix) return
1944 if (this.unpin) this.$element.css('top', '')
1946 this.affixed = affix
1947 this.unpin = affix == 'bottom' ? position.top - scrollTop : null
1949 this.$element.removeClass(Affix.RESET).addClass('affix' + (affix ? '-' + affix : ''))
1951 if (affix == 'bottom') {
1952 this.$element.offset({ top: document.body.offsetHeight - offsetBottom - this.$element.height() })
1957 // AFFIX PLUGIN DEFINITION
1958 // =======================
1960 var old = $.fn.affix
1962 $.fn.affix = function (option) {
1963 return this.each(function () {
1965 var data = $this.data('bs.affix')
1966 var options = typeof option == 'object' && option
1968 if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
1969 if (typeof option == 'string') data[option]()
1973 $.fn.affix.Constructor = Affix
1976 // AFFIX NO CONFLICT
1977 // =================
1979 $.fn.affix.noConflict = function () {
1988 $(window).on('load', function () {
1989 $('[data-spy="affix"]').each(function () {
1991 var data = $spy.data()
1993 data.offset = data.offset || {}
1995 if (data.offsetBottom) data.offset.bottom = data.offsetBottom
1996 if (data.offsetTop) data.offset.top = data.offsetTop