2 * bootstrap.js v3.0.0 by @fat and @mdo
3 * Copyright 2013 Twitter Inc.
4 * http://www.apache.org/licenses/LICENSE-2.0
6 if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
8 /* ========================================================================
9 * Bootstrap: transition.js v3.0.0
10 * http://twbs.github.com/bootstrap/javascript.html#transitions
11 * ========================================================================
12 * Copyright 2013 Twitter, Inc.
14 * Licensed under the Apache License, Version 2.0 (the "License");
15 * you may not use this file except in compliance with the License.
16 * You may obtain a copy of the License at
18 * http://www.apache.org/licenses/LICENSE-2.0
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS,
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
25 * ======================================================================== */
28 +function ($) { "use strict";
30 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
31 // ============================================================
33 function transitionEnd() {
34 var el = document.createElement('bootstrap')
36 var transEndEventNames = {
37 'WebkitTransition' : 'webkitTransitionEnd'
38 , 'MozTransition' : 'transitionend'
39 , 'OTransition' : 'oTransitionEnd otransitionend'
40 , 'transition' : 'transitionend'
43 for (var name in transEndEventNames) {
44 if (el.style[name] !== undefined) {
45 return { end: transEndEventNames[name] }
50 // http://blog.alexmaccaw.com/css-transitions
51 $.fn.emulateTransitionEnd = function (duration) {
52 var called = false, $el = this
53 $(this).one('webkitTransitionEnd', function () { called = true })
54 var callback = function () { if (!called) $($el).trigger('webkitTransitionEnd') }
55 setTimeout(callback, duration)
60 $.support.transition = transitionEnd()
65 /* ========================================================================
66 * Bootstrap: alert.js v3.0.0
67 * http://twbs.github.com/bootstrap/javascript.html#alerts
68 * ========================================================================
69 * Copyright 2013 Twitter, Inc.
71 * Licensed under the Apache License, Version 2.0 (the "License");
72 * you may not use this file except in compliance with the License.
73 * You may obtain a copy of the License at
75 * http://www.apache.org/licenses/LICENSE-2.0
77 * Unless required by applicable law or agreed to in writing, software
78 * distributed under the License is distributed on an "AS IS" BASIS,
79 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
80 * See the License for the specific language governing permissions and
81 * limitations under the License.
82 * ======================================================================== */
85 +function ($) { "use strict";
87 // ALERT CLASS DEFINITION
88 // ======================
90 var dismiss = '[data-dismiss="alert"]'
91 var Alert = function (el) {
92 $(el).on('click', dismiss, this.close)
95 Alert.prototype.close = function (e) {
97 var selector = $this.attr('data-target')
100 selector = $this.attr('href')
101 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
104 var $parent = $(selector)
106 if (e) e.preventDefault()
108 if (!$parent.length) {
109 $parent = $this.hasClass('alert') ? $this : $this.parent()
112 $parent.trigger(e = $.Event('close.bs.alert'))
114 if (e.isDefaultPrevented()) return
116 $parent.removeClass('in')
118 function removeElement() {
119 $parent.trigger('closed.bs.alert').remove()
122 $.support.transition && $parent.hasClass('fade') ?
124 .one($.support.transition.end, removeElement)
125 .emulateTransitionEnd(150) :
130 // ALERT PLUGIN DEFINITION
131 // =======================
135 $.fn.alert = function (option) {
136 return this.each(function () {
138 var data = $this.data('bs.alert')
140 if (!data) $this.data('bs.alert', (data = new Alert(this)))
141 if (typeof option == 'string') data[option].call($this)
145 $.fn.alert.Constructor = Alert
151 $.fn.alert.noConflict = function () {
160 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
164 /* ========================================================================
165 * Bootstrap: button.js v3.0.0
166 * http://twbs.github.com/bootstrap/javascript.html#buttons
167 * ========================================================================
168 * Copyright 2013 Twitter, Inc.
170 * Licensed under the Apache License, Version 2.0 (the "License");
171 * you may not use this file except in compliance with the License.
172 * You may obtain a copy of the License at
174 * http://www.apache.org/licenses/LICENSE-2.0
176 * Unless required by applicable law or agreed to in writing, software
177 * distributed under the License is distributed on an "AS IS" BASIS,
178 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179 * See the License for the specific language governing permissions and
180 * limitations under the License.
181 * ======================================================================== */
184 +function ($) { "use strict";
186 // BUTTON PUBLIC CLASS DEFINITION
187 // ==============================
189 var Button = function (element, options) {
190 this.$element = $(element)
191 this.options = $.extend({}, Button.DEFAULTS, options)
195 loadingText: 'loading...'
198 Button.prototype.setState = function (state) {
200 var $el = this.$element
201 var val = $el.is('input') ? 'val' : 'html'
202 var data = $el.data()
204 state = state + 'Text'
206 if (!data.resetText) $el.data('resetText', $el[val]())
208 $el[val](data[state] || this.options[state])
210 // push to event loop to allow forms to submit
211 setTimeout(function () {
212 state == 'loadingText' ?
213 $el.addClass(d).attr(d, d) :
214 $el.removeClass(d).removeAttr(d);
218 Button.prototype.toggle = function () {
219 var $parent = this.$element.closest('[data-toggle="buttons"]')
221 if ($parent.length) {
222 var $input = this.$element.find('input').prop('checked', !this.$element.hasClass('active'))
223 if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active')
226 this.$element.toggleClass('active')
230 // BUTTON PLUGIN DEFINITION
231 // ========================
233 var old = $.fn.button
235 $.fn.button = function (option) {
236 return this.each(function () {
238 var data = $this.data('button')
239 var options = typeof option == 'object' && option
241 if (!data) $this.data('bs.button', (data = new Button(this, options)))
243 if (option == 'toggle') data.toggle()
244 else if (option) data.setState(option)
248 $.fn.button.Constructor = Button
251 // BUTTON NO CONFLICT
252 // ==================
254 $.fn.button.noConflict = function () {
263 $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
264 var $btn = $(e.target)
265 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
266 $btn.button('toggle')
272 /* ========================================================================
273 * Bootstrap: carousel.js v3.0.0
274 * http://twbs.github.com/bootstrap/javascript.html#carousel
275 * ========================================================================
276 * Copyright 2012 Twitter, Inc.
278 * Licensed under the Apache License, Version 2.0 (the "License");
279 * you may not use this file except in compliance with the License.
280 * You may obtain a copy of the License at
282 * http://www.apache.org/licenses/LICENSE-2.0
284 * Unless required by applicable law or agreed to in writing, software
285 * distributed under the License is distributed on an "AS IS" BASIS,
286 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
287 * See the License for the specific language governing permissions and
288 * limitations under the License.
289 * ======================================================================== */
292 +function ($) { "use strict";
294 // CAROUSEL CLASS DEFINITION
295 // =========================
297 var Carousel = function (element, options) {
298 this.$element = $(element)
299 this.$indicators = this.$element.find('.carousel-indicators')
300 this.options = options
307 this.options.pause == 'hover' && this.$element
308 .on('mouseenter', $.proxy(this.pause, this))
309 .on('mouseleave', $.proxy(this.cycle, this))
312 Carousel.DEFAULTS = {
317 Carousel.prototype.cycle = function (e) {
318 e || (this.paused = false)
320 this.interval && clearInterval(this.interval)
322 this.options.interval
324 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
329 Carousel.prototype.getActiveIndex = function () {
330 this.$active = this.$element.find('.item.active')
331 this.$items = this.$active.parent().children()
333 return this.$items.index(this.$active)
336 Carousel.prototype.to = function (pos) {
338 var activeIndex = this.getActiveIndex()
340 if (pos > (this.$items.length - 1) || pos < 0) return
342 if (this.sliding) return this.$element.one('slid', function () { that.to(pos) })
343 if (activeIndex == pos) return this.pause().cycle()
345 return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
348 Carousel.prototype.pause = function (e) {
349 e || (this.paused = true)
351 if (this.$element.find('.next, .prev').length && $.support.transition.end) {
352 this.$element.trigger($.support.transition.end)
356 this.interval = clearInterval(this.interval)
361 Carousel.prototype.next = function () {
362 if (this.sliding) return
363 return this.slide('next')
366 Carousel.prototype.prev = function () {
367 if (this.sliding) return
368 return this.slide('prev')
371 Carousel.prototype.slide = function (type, next) {
372 var $active = this.$element.find('.item.active')
373 var $next = next || $active[type]()
374 var isCycling = this.interval
375 var direction = type == 'next' ? 'left' : 'right'
376 var fallback = type == 'next' ? 'first' : 'last'
381 isCycling && this.pause()
383 $next = $next.length ? $next : this.$element.find('.item')[fallback]()
385 var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction })
387 if ($next.hasClass('active')) return
389 if (this.$indicators.length) {
390 this.$indicators.find('.active').removeClass('active')
391 this.$element.one('slid', function () {
392 var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
393 $nextIndicator && $nextIndicator.addClass('active')
397 if ($.support.transition && this.$element.hasClass('slide')) {
398 this.$element.trigger(e)
399 if (e.isDefaultPrevented()) return
401 $next[0].offsetWidth // force reflow
402 $active.addClass(direction)
403 $next.addClass(direction)
405 .one($.support.transition.end, function () {
406 $next.removeClass([type, direction].join(' ')).addClass('active')
407 $active.removeClass(['active', direction].join(' '))
409 setTimeout(function () { that.$element.trigger('slid') }, 0)
411 .emulateTransitionEnd(600)
413 this.$element.trigger(e)
414 if (e.isDefaultPrevented()) return
415 $active.removeClass('active')
416 $next.addClass('active')
418 this.$element.trigger('slid')
421 isCycling && this.cycle()
427 // CAROUSEL PLUGIN DEFINITION
428 // ==========================
430 var old = $.fn.carousel
432 $.fn.carousel = function (option) {
433 return this.each(function () {
435 var data = $this.data('bs.carousel')
436 var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
437 var action = typeof option == 'string' ? option : options.slide
439 if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
440 if (typeof option == 'number') data.to(option)
441 else if (action) data[action]()
442 else if (options.interval) data.pause().cycle()
446 $.fn.carousel.Constructor = Carousel
449 // CAROUSEL NO CONFLICT
450 // ====================
452 $.fn.carousel.noConflict = function () {
461 $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
462 var $this = $(this), href
463 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
464 var options = $.extend({}, $target.data(), $this.data())
465 var slideIndex = $this.attr('data-slide-to')
466 if (slideIndex) options.interval = false
468 $target.carousel(options)
470 if (slideIndex = $this.attr('data-slide-to')) {
471 $target.data('bs.carousel').to(slideIndex)
477 $(window).on('load', function () {
478 $('[data-ride="carousel"]').each(function () {
479 var $carousel = $(this)
480 $carousel.carousel($carousel.data())
486 /* ========================================================================
487 * Bootstrap: collapse.js v3.0.0
488 * http://twbs.github.com/bootstrap/javascript.html#collapse
489 * ========================================================================
490 * Copyright 2012 Twitter, Inc.
492 * Licensed under the Apache License, Version 2.0 (the "License");
493 * you may not use this file except in compliance with the License.
494 * You may obtain a copy of the License at
496 * http://www.apache.org/licenses/LICENSE-2.0
498 * Unless required by applicable law or agreed to in writing, software
499 * distributed under the License is distributed on an "AS IS" BASIS,
500 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
501 * See the License for the specific language governing permissions and
502 * limitations under the License.
503 * ======================================================================== */
506 +function ($) { "use strict";
508 // COLLAPSE PUBLIC CLASS DEFINITION
509 // ================================
511 var Collapse = function (element, options) {
512 this.$element = $(element)
513 this.options = $.extend({}, Collapse.DEFAULTS, options)
514 this.transitioning = null
516 if (this.options.parent) this.$parent = $(this.options.parent)
517 if (this.options.toggle) this.toggle()
520 Collapse.DEFAULTS = {
524 Collapse.prototype.dimension = function () {
525 var hasWidth = this.$element.hasClass('width')
526 return hasWidth ? 'width' : 'height'
529 Collapse.prototype.show = function () {
530 if (this.transitioning || this.$element.hasClass('in')) return
532 var startEvent = $.Event('show.bs.collapse')
533 this.$element.trigger(startEvent)
534 if (startEvent.isDefaultPrevented()) return
536 var actives = this.$parent && this.$parent.find('> .accordion-group > .in')
538 if (actives && actives.length) {
539 var hasData = actives.data('bs.collapse')
540 if (hasData && hasData.transitioning) return
541 actives.collapse('hide')
542 hasData || actives.data('bs.collapse', null)
545 var dimension = this.dimension()
548 .removeClass('collapse')
549 .addClass('collapsing')
552 this.transitioning = 1
554 var complete = function () {
556 .removeClass('collapsing')
559 this.transitioning = 0
560 this.$element.trigger('shown.bs.collapse')
563 if (!$.support.transition) return complete.call(this)
565 var scrollSize = $.camelCase(['scroll', dimension].join('-'))
568 .one($.support.transition.end, $.proxy(complete, this))
569 .emulateTransitionEnd(350)
570 [dimension](this.$element[0][scrollSize])
573 Collapse.prototype.hide = function () {
574 if (this.transitioning || !this.$element.hasClass('in')) return
576 var startEvent = $.Event('hide.bs.collapse')
577 this.$element.trigger(startEvent)
578 if (startEvent.isDefaultPrevented()) return
580 var dimension = this.dimension()
583 [dimension](this.$element[dimension]())
587 .addClass('collapsing')
588 .removeClass('collapse')
591 this.transitioning = 1
593 var complete = function () {
594 this.transitioning = 0
596 .trigger('hidden.bs.collapse')
597 .removeClass('collapsing')
598 .addClass('collapse')
601 if (!$.support.transition) return complete.call(this)
605 .one($.support.transition.end, $.proxy(complete, this))
606 .emulateTransitionEnd(350)
609 Collapse.prototype.toggle = function () {
610 this[this.$element.hasClass('in') ? 'hide' : 'show']()
614 // COLLAPSE PLUGIN DEFINITION
615 // ==========================
617 var old = $.fn.collapse
619 $.fn.collapse = function (option) {
620 return this.each(function () {
622 var data = $this.data('bs.collapse')
623 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
625 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
626 if (typeof option == 'string') data[option]()
630 $.fn.collapse.Constructor = Collapse
633 // COLLAPSE NO CONFLICT
634 // ====================
636 $.fn.collapse.noConflict = function () {
645 $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
646 var $this = $(this), href
647 var target = $this.attr('data-target')
648 || e.preventDefault()
649 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
650 var $target = $(target)
651 var data = $target.data('bs.collapse')
652 var option = data ? 'toggle' : $this.data()
653 var parent = $this.attr('data-parent')
654 var $parent = parent && $(parent)
656 if (!data || !data.transitioning) {
657 if ($parent) $parent.find('[data-toggle=collapse][data-parent=' + parent + ']').not($this).addClass('collapsed')
658 $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
661 $target.collapse(option)
666 /* ========================================================================
667 * Bootstrap: dropdown.js v3.0.0
668 * http://twbs.github.com/bootstrap/javascript.html#dropdowns
669 * ========================================================================
670 * Copyright 2012 Twitter, Inc.
672 * Licensed under the Apache License, Version 2.0 (the "License");
673 * you may not use this file except in compliance with the License.
674 * You may obtain a copy of the License at
676 * http://www.apache.org/licenses/LICENSE-2.0
678 * Unless required by applicable law or agreed to in writing, software
679 * distributed under the License is distributed on an "AS IS" BASIS,
680 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
681 * See the License for the specific language governing permissions and
682 * limitations under the License.
683 * ======================================================================== */
686 +function ($) { "use strict";
688 // DROPDOWN CLASS DEFINITION
689 // =========================
691 var backdrop = '.dropdown-backdrop'
692 var toggle = '[data-toggle=dropdown]'
693 var Dropdown = function (element) {
694 var $el = $(element).on('click.bs.dropdown', this.toggle)
697 Dropdown.prototype.toggle = function (e) {
700 if ($this.is('.disabled, :disabled')) return
702 var $parent = getParent($this)
703 var isActive = $parent.hasClass('open')
708 if ('ontouchstart' in document.documentElement) {
709 // if mobile we we use a backdrop because click events don't delegate
710 $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
713 $parent.trigger(e = $.Event('show.bs.dropdown'))
715 if (e.isDefaultPrevented()) return
719 .trigger('shown.bs.dropdown')
727 Dropdown.prototype.keydown = function (e) {
728 if (!/(38|40|27)/.test(e.keyCode)) return
735 if ($this.is('.disabled, :disabled')) return
737 var $parent = getParent($this)
738 var isActive = $parent.hasClass('open')
740 if (!isActive || (isActive && e.keyCode == 27)) {
741 if (e.which == 27) $parent.find(toggle).focus()
745 var $items = $('[role=menu] li:not(.divider):visible a', $parent)
747 if (!$items.length) return
749 var index = $items.index($items.filter(':focus'))
751 if (e.keyCode == 38 && index > 0) index-- // up
752 if (e.keyCode == 40 && index < $items.length - 1) index++ // down
755 $items.eq(index).focus()
758 function clearMenus() {
760 $(toggle).each(function (e) {
761 var $parent = getParent($(this))
762 if (!$parent.hasClass('open')) return
763 $parent.trigger(e = $.Event('hide.bs.dropdown'))
764 if (e.isDefaultPrevented()) return
765 $parent.removeClass('open').trigger('hidden.bs.dropdown')
769 function getParent($this) {
770 var selector = $this.attr('data-target')
773 selector = $this.attr('href')
774 selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
777 var $parent = selector && $(selector)
779 return $parent && $parent.length ? $parent : $this.parent()
783 // DROPDOWN PLUGIN DEFINITION
784 // ==========================
786 var old = $.fn.dropdown
788 $.fn.dropdown = function (option) {
789 return this.each(function () {
791 var data = $this.data('dropdown')
793 if (!data) $this.data('dropdown', (data = new Dropdown(this)))
794 if (typeof option == 'string') data[option].call($this)
798 $.fn.dropdown.Constructor = Dropdown
801 // DROPDOWN NO CONFLICT
802 // ====================
804 $.fn.dropdown.noConflict = function () {
810 // APPLY TO STANDARD DROPDOWN ELEMENTS
811 // ===================================
814 .on('click.bs.dropdown.data-api', clearMenus)
815 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
816 .on('click.bs.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
817 .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
821 /* ========================================================================
822 * Bootstrap: modal.js v3.0.0
823 * http://twbs.github.com/bootstrap/javascript.html#modals
824 * ========================================================================
825 * Copyright 2012 Twitter, Inc.
827 * Licensed under the Apache License, Version 2.0 (the "License");
828 * you may not use this file except in compliance with the License.
829 * You may obtain a copy of the License at
831 * http://www.apache.org/licenses/LICENSE-2.0
833 * Unless required by applicable law or agreed to in writing, software
834 * distributed under the License is distributed on an "AS IS" BASIS,
835 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
836 * See the License for the specific language governing permissions and
837 * limitations under the License.
838 * ======================================================================== */
841 +function ($) { "use strict";
843 // MODAL CLASS DEFINITION
844 // ======================
846 var Modal = function (element, options) {
847 this.options = options
848 this.$element = $(element).on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
852 if (this.options.remote) this.$element.find('.modal-body').load(this.options.remote)
861 Modal.prototype.toggle = function () {
862 return this[!this.isShown ? 'show' : 'hide']()
865 Modal.prototype.show = function () {
867 var e = $.Event('show.bs.modal')
869 this.$element.trigger(e)
871 if (this.isShown || e.isDefaultPrevented()) return
877 this.backdrop(function () {
878 var transition = $.support.transition && that.$element.hasClass('fade')
880 if (!that.$element.parent().length) {
881 that.$element.appendTo(document.body) // don't move modals dom position
887 that.$element[0].offsetWidth // force reflow
892 .attr('aria-hidden', false)
898 .one($.support.transition.end, function () {
899 that.$element.focus().trigger('shown.bs.modal')
901 .emulateTransitionEnd(300) :
902 that.$element.focus().trigger('shown.bs.modal')
906 Modal.prototype.hide = function (e) {
907 if (e) e.preventDefault()
909 e = $.Event('hide.bs.modal')
911 this.$element.trigger(e)
913 if (!this.isShown || e.isDefaultPrevented()) return
919 $(document).off('focusin.bs.modal')
923 .attr('aria-hidden', true)
925 $.support.transition && this.$element.hasClass('fade') ?
927 .one($.support.transition.end, $.proxy(this.hideModal, this))
928 .emulateTransitionEnd(300) :
932 Modal.prototype.enforceFocus = function () {
934 .off('focusin.bs.modal') // guard against infinite focus loop
935 .on('focusin.bs.modal', $.proxy(function (e) {
936 if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
937 this.$element.focus()
942 Modal.prototype.escape = function () {
943 if (this.isShown && this.options.keyboard) {
944 this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
945 e.which == 27 && this.hide()
947 } else if (!this.isShown) {
948 this.$element.off('keyup.dismiss.bs.modal')
952 Modal.prototype.hideModal = function () {
955 this.backdrop(function () {
956 that.removeBackdrop()
957 that.$element.trigger('hidden.bs.modal')
961 Modal.prototype.removeBackdrop = function () {
962 this.$backdrop && this.$backdrop.remove()
963 this.$backdrop = null
966 Modal.prototype.backdrop = function (callback) {
968 var animate = this.$element.hasClass('fade') ? 'fade' : ''
970 if (this.isShown && this.options.backdrop) {
971 var doAnimate = $.support.transition && animate
973 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
974 .appendTo(document.body)
976 this.$element.on('click', $.proxy(function (e) {
977 if (e.target !== e.currentTarget) return
978 this.options.backdrop == 'static'
979 ? this.$element[0].focus.call(this.$element[0])
980 : this.hide.call(this)
983 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
985 this.$backdrop.addClass('in')
987 if (!callback) return
991 .one($.support.transition.end, callback)
992 .emulateTransitionEnd(150) :
995 } else if (!this.isShown && this.$backdrop) {
996 this.$backdrop.removeClass('in')
998 $.support.transition && this.$element.hasClass('fade')?
1000 .one($.support.transition.end, callback)
1001 .emulateTransitionEnd(150) :
1004 } else if (callback) {
1010 // MODAL PLUGIN DEFINITION
1011 // =======================
1013 var old = $.fn.modal
1015 $.fn.modal = function (option) {
1016 return this.each(function () {
1018 var data = $this.data('bs.modal')
1019 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
1021 if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
1022 if (typeof option == 'string') data[option]()
1023 else if (options.show) data.show()
1027 $.fn.modal.Constructor = Modal
1030 // MODAL NO CONFLICT
1031 // =================
1033 $.fn.modal.noConflict = function () {
1042 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
1044 var href = $this.attr('href')
1045 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
1046 var option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
1052 .one('hide', function () {
1053 $this.is(':visible') && $this.focus()
1057 var $body = $(document.body)
1058 .on('shown.bs.modal', '.modal', function () { $body.addClass('modal-open') })
1059 .on('hidden.bs.modal', '.modal', function () { $body.removeClass('modal-open') })
1063 /* ========================================================================
1064 * Bootstrap: tooltip.js v3.0.0
1065 * http://twbs.github.com/bootstrap/javascript.html#affix
1066 * Inspired by the original jQuery.tipsy by Jason Frame
1067 * ========================================================================
1068 * Copyright 2012 Twitter, Inc.
1070 * Licensed under the Apache License, Version 2.0 (the "License");
1071 * you may not use this file except in compliance with the License.
1072 * You may obtain a copy of the License at
1074 * http://www.apache.org/licenses/LICENSE-2.0
1076 * Unless required by applicable law or agreed to in writing, software
1077 * distributed under the License is distributed on an "AS IS" BASIS,
1078 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1079 * See the License for the specific language governing permissions and
1080 * limitations under the License.
1081 * ======================================================================== */
1084 +function ($) { "use strict";
1086 // TOOLTIP PUBLIC CLASS DEFINITION
1087 // ===============================
1089 var Tooltip = function (element, options) {
1095 this.$element = null
1097 this.init('tooltip', element, options)
1100 Tooltip.DEFAULTS = {
1104 , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
1105 , trigger: 'hover focus'
1112 Tooltip.prototype.init = function (type, element, options) {
1115 this.$element = $(element)
1116 this.options = this.getOptions(options)
1118 var triggers = this.options.trigger.split(' ')
1120 for (var i = triggers.length; i--;) {
1121 var trigger = triggers[i]
1123 if (trigger == 'click') {
1124 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
1125 } else if (trigger != 'manual') {
1126 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
1127 var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
1129 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
1130 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
1134 this.options.selector ?
1135 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
1139 Tooltip.prototype.getDefaults = function () {
1140 return Tooltip.DEFAULTS
1143 Tooltip.prototype.getOptions = function (options) {
1144 options = $.extend({}, this.getDefaults(), this.$element.data(), options)
1146 if (options.delay && typeof options.delay == 'number') {
1149 , hide: options.delay
1156 Tooltip.prototype.enter = function (obj) {
1157 var defaults = this.getDefaults()
1160 this._options && $.each(this._options, function (key, value) {
1161 if (defaults[key] != value) options[key] = value
1164 var self = obj instanceof this.constructor ?
1165 obj : $(obj.currentTarget)[this.type](options).data('bs.' + this.type)
1167 clearTimeout(self.timeout)
1169 if (!self.options.delay || !self.options.delay.show) return self.show()
1171 self.hoverState = 'in'
1172 self.timeout = setTimeout(function () {
1173 if (self.hoverState == 'in') self.show()
1174 }, self.options.delay.show)
1177 Tooltip.prototype.leave = function (obj) {
1178 var self = obj instanceof this.constructor ?
1179 obj : $(obj.currentTarget)[this.type](this._options).data('bs.' + this.type)
1181 clearTimeout(self.timeout)
1183 if (!self.options.delay || !self.options.delay.hide) return self.hide()
1185 self.hoverState = 'out'
1186 self.timeout = setTimeout(function () {
1187 if (self.hoverState == 'out') self.hide()
1188 }, self.options.delay.hide)
1191 Tooltip.prototype.show = function () {
1192 var e = $.Event('show.bs.'+ this.type)
1194 if (this.hasContent() && this.enabled) {
1195 this.$element.trigger(e)
1197 if (e.isDefaultPrevented()) return
1199 var $tip = this.tip()
1203 if (this.options.animation) $tip.addClass('fade')
1205 var placement = typeof this.options.placement == 'function' ?
1206 this.options.placement.call(this, $tip[0], this.$element[0]) :
1207 this.options.placement
1209 var autoToken = /\s?auto?\s?/i
1210 var autoPlace = autoToken.test(placement)
1211 if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
1215 .css({ top: 0, left: 0, display: 'block' })
1216 .addClass(placement)
1218 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
1220 var pos = this.getPosition()
1221 var actualWidth = $tip[0].offsetWidth
1222 var actualHeight = $tip[0].offsetHeight
1225 var $parent = this.$element.parent()
1227 var orgPlacement = placement
1228 var docScroll = document.documentElement.scrollTop || document.body.scrollTop
1229 var parentWidth = this.options.container == 'body' ? window.innerWidth : $parent.outerWidth()
1230 var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
1231 var parentLeft = this.options.container == 'body' ? 0 : $parent.offset().left
1233 placement = placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight ? 'top' :
1234 placement == 'top' && pos.top - docScroll - actualHeight < 0 ? 'bottom' :
1235 placement == 'right' && pos.right + actualWidth > parentWidth ? 'left' :
1236 placement == 'left' && pos.left - actualWidth < parentLeft ? 'right' :
1240 .removeClass(orgPlacement)
1241 .addClass(placement)
1244 var tp = placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
1245 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
1246 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
1247 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
1249 this.applyPlacement(tp, placement)
1250 this.$element.trigger('shown.bs.' + this.type)
1254 Tooltip.prototype.applyPlacement = function(offset, placement) {
1256 var $tip = this.tip()
1257 var width = $tip[0].offsetWidth
1258 var height = $tip[0].offsetHeight
1260 // manually read margins because getBoundingClientRect includes difference
1261 offset.top = offset.top + parseInt($tip.css('margin-top'), 10)
1262 offset.left = offset.left + parseInt($tip.css('margin-left'), 10)
1268 var actualWidth = $tip[0].offsetWidth
1269 var actualHeight = $tip[0].offsetHeight
1271 if (placement == 'top' && actualHeight != height) {
1273 offset.top = offset.top + height - actualHeight
1276 if (placement == 'bottom' || placement == 'top') {
1279 if (offset.left < 0){
1280 delta = offset.left * -2
1285 actualWidth = $tip[0].offsetWidth
1286 actualHeight = $tip[0].offsetHeight
1289 this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
1291 this.replaceArrow(actualHeight - height, actualHeight, 'top')
1294 if (replace) $tip.offset(offset)
1297 Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
1298 this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
1301 Tooltip.prototype.setContent = function () {
1302 var $tip = this.tip()
1303 var title = this.getTitle()
1305 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
1306 $tip.removeClass('fade in top bottom left right')
1309 Tooltip.prototype.hide = function () {
1311 var $tip = this.tip()
1312 var e = $.Event('hide.bs.' + this.type)
1314 this.$element.trigger(e)
1316 if (e.isDefaultPrevented()) return
1318 $tip.removeClass('in')
1320 $.support.transition && this.$tip.hasClass('fade') ?
1322 .one($.support.transition.end, $tip.detach)
1323 .emulateTransitionEnd(150) :
1326 this.$element.trigger('hidden.bs.' + this.type)
1331 Tooltip.prototype.fixTitle = function () {
1332 var $e = this.$element
1333 if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
1334 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
1338 Tooltip.prototype.hasContent = function () {
1339 return this.getTitle()
1342 Tooltip.prototype.getPosition = function () {
1343 var el = this.$element[0]
1344 return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
1345 width: el.offsetWidth
1346 , height: el.offsetHeight
1347 }, this.$element.offset())
1350 Tooltip.prototype.getTitle = function () {
1352 var $e = this.$element
1353 var o = this.options
1355 title = $e.attr('data-original-title')
1356 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
1361 Tooltip.prototype.tip = function () {
1362 return this.$tip = this.$tip || $(this.options.template)
1365 Tooltip.prototype.arrow =function(){
1366 return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
1369 Tooltip.prototype.validate = function () {
1370 if (!this.$element[0].parentNode) {
1372 this.$element = null
1377 Tooltip.prototype.enable = function () {
1381 Tooltip.prototype.disable = function () {
1382 this.enabled = false
1385 Tooltip.prototype.toggleEnabled = function () {
1386 this.enabled = !this.enabled
1389 Tooltip.prototype.toggle = function (e) {
1390 var self = e ? $(e.currentTarget)[this.type](this._options).data('bs.' + this.type) : this
1391 self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
1394 Tooltip.prototype.destroy = function () {
1395 this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
1399 // TOOLTIP PLUGIN DEFINITION
1400 // =========================
1402 var old = $.fn.tooltip
1404 $.fn.tooltip = function (option) {
1405 return this.each(function () {
1407 var data = $this.data('bs.tooltip')
1408 var options = typeof option == 'object' && option
1410 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
1411 if (typeof option == 'string') data[option]()
1415 $.fn.tooltip.Constructor = Tooltip
1418 // TOOLTIP NO CONFLICT
1419 // ===================
1421 $.fn.tooltip.noConflict = function () {
1428 /* ========================================================================
1429 * Bootstrap: popover.js v3.0.0
1430 * http://twbs.github.com/bootstrap/javascript.html#popovers
1431 * ========================================================================
1432 * Copyright 2012 Twitter, Inc.
1434 * Licensed under the Apache License, Version 2.0 (the "License");
1435 * you may not use this file except in compliance with the License.
1436 * You may obtain a copy of the License at
1438 * http://www.apache.org/licenses/LICENSE-2.0
1440 * Unless required by applicable law or agreed to in writing, software
1441 * distributed under the License is distributed on an "AS IS" BASIS,
1442 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1443 * See the License for the specific language governing permissions and
1444 * limitations under the License.
1445 * ======================================================================== */
1448 +function ($) { "use strict";
1450 // POPOVER PUBLIC CLASS DEFINITION
1451 // ===============================
1453 var Popover = function (element, options) {
1454 this.init('popover', element, options)
1457 if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
1459 Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
1463 , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
1467 // NOTE: POPOVER EXTENDS tooltip.js
1468 // ================================
1470 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
1472 Popover.prototype.constructor = Popover
1474 Popover.prototype.getDefaults = function () {
1475 return Popover.DEFAULTS
1478 Popover.prototype.setContent = function () {
1479 var $tip = this.tip()
1480 var title = this.getTitle()
1481 var content = this.getContent()
1483 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
1484 $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
1486 $tip.removeClass('fade top bottom left right in')
1488 $tip.find('.popover-title:empty').hide()
1491 Popover.prototype.hasContent = function () {
1492 return this.getTitle() || this.getContent()
1495 Popover.prototype.getContent = function () {
1496 var $e = this.$element
1497 var o = this.options
1499 return $e.attr('data-content')
1500 || (typeof o.content == 'function' ?
1501 o.content.call($e[0]) :
1505 Popover.prototype.tip = function () {
1506 if (!this.$tip) this.$tip = $(this.options.template)
1510 Popover.prototype.destroy = function () {
1511 this.hide().$element.off('.' + this.type).removeData(this.type)
1515 // POPOVER PLUGIN DEFINITION
1516 // =========================
1518 var old = $.fn.popover
1520 $.fn.popover = function (option) {
1521 return this.each(function () {
1523 var data = $this.data('bs.popover')
1524 var options = typeof option == 'object' && option
1526 if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
1527 if (typeof option == 'string') data[option]()
1531 $.fn.popover.Constructor = Popover
1534 // POPOVER NO CONFLICT
1535 // ===================
1537 $.fn.popover.noConflict = function () {
1544 /* ========================================================================
1545 * Bootstrap: scrollspy.js v3.0.0
1546 * http://twbs.github.com/bootstrap/javascript.html#scrollspy
1547 * ========================================================================
1548 * Copyright 2012 Twitter, Inc.
1550 * Licensed under the Apache License, Version 2.0 (the "License");
1551 * you may not use this file except in compliance with the License.
1552 * You may obtain a copy of the License at
1554 * http://www.apache.org/licenses/LICENSE-2.0
1556 * Unless required by applicable law or agreed to in writing, software
1557 * distributed under the License is distributed on an "AS IS" BASIS,
1558 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1559 * See the License for the specific language governing permissions and
1560 * limitations under the License.
1561 * ======================================================================== */
1564 +function ($) { "use strict";
1566 // SCROLLSPY CLASS DEFINITION
1567 // ==========================
1569 function ScrollSpy(element, options) {
1571 var process = $.proxy(this.process, this)
1573 this.$element = $(element).is('body') ? $(window) : $(element)
1574 this.$body = $('body')
1575 this.$scrollElement = this.$element.on('scroll.bs.scroll-spy.data-api', process)
1576 this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
1577 this.selector = (this.options.target
1578 || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
1579 || '') + ' .nav li > a'
1580 this.offsets = $([])
1581 this.targets = $([])
1582 this.activeTarget = null
1588 ScrollSpy.DEFAULTS = {
1592 ScrollSpy.prototype.refresh = function () {
1593 var offsetMethod = this.$element[0] == window ? 'offset' : 'position'
1595 this.offsets = $([])
1596 this.targets = $([])
1599 var $targets = this.$body
1600 .find(this.selector)
1603 var href = $el.data('target') || $el.attr('href')
1604 var $href = /^#\w/.test(href) && $(href)
1608 && [[ $href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null
1610 .sort(function (a, b) { return a[0] - b[0] })
1612 self.offsets.push(this[0])
1613 self.targets.push(this[1])
1617 ScrollSpy.prototype.process = function () {
1618 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
1619 var scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
1620 var maxScroll = scrollHeight - this.$scrollElement.height()
1621 var offsets = this.offsets
1622 var targets = this.targets
1623 var activeTarget = this.activeTarget
1626 if (scrollTop >= maxScroll) {
1627 return activeTarget != (i = targets.last()[0]) && this.activate(i)
1630 for (i = offsets.length; i--;) {
1631 activeTarget != targets[i]
1632 && scrollTop >= offsets[i]
1633 && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
1634 && this.activate( targets[i] )
1638 ScrollSpy.prototype.activate = function (target) {
1639 this.activeTarget = target
1643 .removeClass('active')
1645 var selector = this.selector
1646 + '[data-target="' + target + '"],'
1647 + this.selector + '[href="' + target + '"]'
1649 var active = $(selector)
1653 if (active.parent('.dropdown-menu').length) {
1655 .closest('li.dropdown')
1659 active.trigger('activate')
1663 // SCROLLSPY PLUGIN DEFINITION
1664 // ===========================
1666 var old = $.fn.scrollspy
1668 $.fn.scrollspy = function (option) {
1669 return this.each(function () {
1671 var data = $this.data('bs.scrollspy')
1672 var options = typeof option == 'object' && option
1674 if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
1675 if (typeof option == 'string') data[option]()
1679 $.fn.scrollspy.Constructor = ScrollSpy
1682 // SCROLLSPY NO CONFLICT
1683 // =====================
1685 $.fn.scrollspy.noConflict = function () {
1686 $.fn.scrollspy = old
1691 // SCROLLSPY DATA-API
1692 // ==================
1694 $(window).on('load', function () {
1695 $('[data-spy="scroll"]').each(function () {
1697 $spy.scrollspy($spy.data())
1703 /* ========================================================================
1704 * Bootstrap: tab.js v3.0.0
1705 * http://twbs.github.com/bootstrap/javascript.html#tabs
1706 * ========================================================================
1707 * Copyright 2012 Twitter, Inc.
1709 * Licensed under the Apache License, Version 2.0 (the "License");
1710 * you may not use this file except in compliance with the License.
1711 * You may obtain a copy of the License at
1713 * http://www.apache.org/licenses/LICENSE-2.0
1715 * Unless required by applicable law or agreed to in writing, software
1716 * distributed under the License is distributed on an "AS IS" BASIS,
1717 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1718 * See the License for the specific language governing permissions and
1719 * limitations under the License.
1720 * ======================================================================== */
1723 +function ($) { "use strict";
1725 // TAB CLASS DEFINITION
1726 // ====================
1728 var Tab = function (element) {
1729 this.element = $(element)
1732 Tab.prototype.show = function () {
1733 var $this = this.element
1734 var $ul = $this.closest('ul:not(.dropdown-menu)')
1735 var selector = $this.attr('data-target')
1738 selector = $this.attr('href')
1739 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
1742 if ($this.parent('li').hasClass('active')) return
1744 var previous = $ul.find('.active:last a')[0]
1745 var e = $.Event('show.bs.tab', {
1746 relatedTarget: previous
1751 if (e.isDefaultPrevented()) return
1753 var $target = $(selector)
1755 this.activate($this.parent('li'), $ul)
1756 this.activate($target, $target.parent(), function () {
1758 type: 'shown.bs.tab'
1759 , relatedTarget: previous
1764 Tab.prototype.activate = function (element, container, callback) {
1765 var $active = container.find('> .active')
1766 var transition = callback
1767 && $.support.transition
1768 && $active.hasClass('fade')
1772 .removeClass('active')
1773 .find('> .dropdown-menu > .active')
1774 .removeClass('active')
1776 element.addClass('active')
1779 element[0].offsetWidth // reflow for transition
1780 element.addClass('in')
1782 element.removeClass('fade')
1785 if (element.parent('.dropdown-menu')) {
1786 element.closest('li.dropdown').addClass('active')
1789 callback && callback()
1794 .one($.support.transition.end, next)
1795 .emulateTransitionEnd(150) :
1798 $active.removeClass('in')
1802 // TAB PLUGIN DEFINITION
1803 // =====================
1807 $.fn.tab = function ( option ) {
1808 return this.each(function () {
1810 var data = $this.data('bs.tab')
1812 if (!data) $this.data('bs.tab', (data = new Tab(this)))
1813 if (typeof option == 'string') data[option]()
1817 $.fn.tab.Constructor = Tab
1823 $.fn.tab.noConflict = function () {
1832 $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
1839 /* ========================================================================
1840 * Bootstrap: affix.js v3.0.0
1841 * http://twbs.github.com/bootstrap/javascript.html#affix
1842 * ========================================================================
1843 * Copyright 2012 Twitter, Inc.
1845 * Licensed under the Apache License, Version 2.0 (the "License");
1846 * you may not use this file except in compliance with the License.
1847 * You may obtain a copy of the License at
1849 * http://www.apache.org/licenses/LICENSE-2.0
1851 * Unless required by applicable law or agreed to in writing, software
1852 * distributed under the License is distributed on an "AS IS" BASIS,
1853 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1854 * See the License for the specific language governing permissions and
1855 * limitations under the License.
1856 * ======================================================================== */
1859 +function ($) { "use strict";
1861 // AFFIX CLASS DEFINITION
1862 // ======================
1864 var Affix = function (element, options) {
1865 this.options = $.extend({}, Affix.DEFAULTS, options)
1866 this.$window = $(window)
1867 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
1868 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
1870 this.$element = $(element)
1874 this.checkPosition()
1877 Affix.RESET = 'affix affix-top affix-bottom'
1883 Affix.prototype.checkPositionWithEventLoop = function () {
1884 setTimeout($.proxy(this.checkPosition, this), 1)
1887 Affix.prototype.checkPosition = function () {
1888 if (!this.$element.is(':visible')) return
1890 var scrollHeight = $(document).height()
1891 var scrollTop = this.$window.scrollTop()
1892 var position = this.$element.offset()
1893 var offset = this.options.offset
1894 var offsetTop = offset.top
1895 var offsetBottom = offset.bottom
1897 if (typeof offset != 'object') offsetBottom = offsetTop = offset
1898 if (typeof offsetTop == 'function') offsetTop = offset.top()
1899 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
1901 var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
1902 offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
1903 offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
1905 if (this.affixed === affix) return
1906 if (this.unpin) this.$element.css('top', '')
1908 this.affixed = affix
1909 this.unpin = affix == 'bottom' ? position.top - scrollTop : null
1911 this.$element.removeClass(Affix.RESET).addClass('affix' + (affix ? '-' + affix : ''))
1913 if (affix == 'bottom') {
1914 this.$element.offset({ top: document.body.offsetHeight - offsetBottom - this.$element.height() })
1919 // AFFIX PLUGIN DEFINITION
1920 // =======================
1922 var old = $.fn.affix
1924 $.fn.affix = function (option) {
1925 return this.each(function () {
1927 var data = $this.data('bs.affix')
1928 var options = typeof option == 'object' && option
1930 if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
1931 if (typeof option == 'string') data[option]()
1935 $.fn.affix.Constructor = Affix
1938 // AFFIX NO CONFLICT
1939 // =================
1941 $.fn.affix.noConflict = function () {
1950 $(window).on('load', function () {
1951 $('[data-spy="affix"]').each(function () {
1953 var data = $spy.data()
1955 data.offset = data.offset || {}
1957 if (data.offsetBottom) data.offset.bottom = data.offsetBottom
1958 if (data.offsetTop) data.offset.top = data.offsetTop