1 /* ===================================================
2 * bootstrap-transition.js v2.1.0
3 * http://twitter.github.com/bootstrap/javascript.html#transitions
4 * ===================================================
5 * Copyright 2012 Twitter, Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ========================================================== */
25 "use strict"; // jshint ;_;
28 /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
29 * ======================================================= */
31 $.support.transition = (function () {
33 var transitionEnd = (function () {
35 var el = document.createElement('bootstrap')
36 , transEndEventNames = {
37 'WebkitTransition' : 'webkitTransitionEnd'
38 , 'MozTransition' : 'transitionend'
39 , 'OTransition' : 'oTransitionEnd otransitionend'
40 , 'transition' : 'transitionend'
44 for (name in transEndEventNames){
45 if (el.style[name] !== undefined) {
46 return transEndEventNames[name]
52 return transitionEnd && {
61 /* =========================================================
62 * bootstrap-modal.js v2.1.0
63 * http://twitter.github.com/bootstrap/javascript.html#modals
64 * =========================================================
65 * Copyright 2012 Twitter, Inc.
67 * Licensed under the Apache License, Version 2.0 (the "License");
68 * you may not use this file except in compliance with the License.
69 * You may obtain a copy of the License at
71 * http://www.apache.org/licenses/LICENSE-2.0
73 * Unless required by applicable law or agreed to in writing, software
74 * distributed under the License is distributed on an "AS IS" BASIS,
75 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76 * See the License for the specific language governing permissions and
77 * limitations under the License.
78 * ========================================================= */
83 "use strict"; // jshint ;_;
86 /* MODAL CLASS DEFINITION
87 * ====================== */
89 var Modal = function (element, options) {
90 this.options = options
91 this.$element = $(element)
92 .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
93 this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
100 , toggle: function () {
101 return this[!this.isShown ? 'show' : 'hide']()
104 , show: function () {
106 , e = $.Event('show')
108 this.$element.trigger(e)
110 if (this.isShown || e.isDefaultPrevented()) return
112 $('body').addClass('modal-open')
118 this.backdrop(function () {
119 var transition = $.support.transition && that.$element.hasClass('fade')
121 if (!that.$element.parent().length) {
122 that.$element.appendTo(document.body) //don't move modals dom position
129 that.$element[0].offsetWidth // force reflow
134 .attr('aria-hidden', false)
140 that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
141 that.$element.trigger('shown')
146 , hide: function (e) {
147 e && e.preventDefault()
153 this.$element.trigger(e)
155 if (!this.isShown || e.isDefaultPrevented()) return
159 $('body').removeClass('modal-open')
163 $(document).off('focusin.modal')
167 .attr('aria-hidden', true)
169 $.support.transition && this.$element.hasClass('fade') ?
170 this.hideWithTransition() :
174 , enforceFocus: function () {
176 $(document).on('focusin.modal', function (e) {
177 if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
178 that.$element.focus()
183 , escape: function () {
185 if (this.isShown && this.options.keyboard) {
186 this.$element.on('keyup.dismiss.modal', function ( e ) {
187 e.which == 27 && that.hide()
189 } else if (!this.isShown) {
190 this.$element.off('keyup.dismiss.modal')
194 , hideWithTransition: function () {
196 , timeout = setTimeout(function () {
197 that.$element.off($.support.transition.end)
201 this.$element.one($.support.transition.end, function () {
202 clearTimeout(timeout)
207 , hideModal: function (that) {
215 , removeBackdrop: function () {
216 this.$backdrop.remove()
217 this.$backdrop = null
220 , backdrop: function (callback) {
222 , animate = this.$element.hasClass('fade') ? 'fade' : ''
224 if (this.isShown && this.options.backdrop) {
225 var doAnimate = $.support.transition && animate
227 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
228 .appendTo(document.body)
230 if (this.options.backdrop != 'static') {
231 this.$backdrop.click($.proxy(this.hide, this))
234 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
236 this.$backdrop.addClass('in')
239 this.$backdrop.one($.support.transition.end, callback) :
242 } else if (!this.isShown && this.$backdrop) {
243 this.$backdrop.removeClass('in')
245 $.support.transition && this.$element.hasClass('fade')?
246 this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
247 this.removeBackdrop()
249 } else if (callback) {
256 /* MODAL PLUGIN DEFINITION
257 * ======================= */
259 $.fn.modal = function (option) {
260 return this.each(function () {
262 , data = $this.data('modal')
263 , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
264 if (!data) $this.data('modal', (data = new Modal(this, options)))
265 if (typeof option == 'string') data[option]()
266 else if (options.show) data.show()
270 $.fn.modal.defaults = {
276 $.fn.modal.Constructor = Modal
283 $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
285 , href = $this.attr('href')
286 , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
287 , option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
293 .one('hide', function () {
300 /* ============================================================
301 * bootstrap-dropdown.js v2.1.0
302 * http://twitter.github.com/bootstrap/javascript.html#dropdowns
303 * ============================================================
304 * Copyright 2012 Twitter, Inc.
306 * Licensed under the Apache License, Version 2.0 (the "License");
307 * you may not use this file except in compliance with the License.
308 * You may obtain a copy of the License at
310 * http://www.apache.org/licenses/LICENSE-2.0
312 * Unless required by applicable law or agreed to in writing, software
313 * distributed under the License is distributed on an "AS IS" BASIS,
314 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
315 * See the License for the specific language governing permissions and
316 * limitations under the License.
317 * ============================================================ */
322 "use strict"; // jshint ;_;
325 /* DROPDOWN CLASS DEFINITION
326 * ========================= */
328 var toggle = '[data-toggle=dropdown]'
329 , Dropdown = function (element) {
330 var $el = $(element).on('click.dropdown.data-api', this.toggle)
331 $('html').on('click.dropdown.data-api', function () {
332 $el.parent().removeClass('open')
336 Dropdown.prototype = {
338 constructor: Dropdown
340 , toggle: function (e) {
345 if ($this.is('.disabled, :disabled')) return
347 $parent = getParent($this)
349 isActive = $parent.hasClass('open')
354 $parent.toggleClass('open')
361 , keydown: function (e) {
369 if (!/(38|40|27)/.test(e.keyCode)) return
376 if ($this.is('.disabled, :disabled')) return
378 $parent = getParent($this)
380 isActive = $parent.hasClass('open')
382 if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
384 $items = $('[role=menu] li:not(.divider) a', $parent)
386 if (!$items.length) return
388 index = $items.index($items.filter(':focus'))
390 if (e.keyCode == 38 && index > 0) index-- // up
391 if (e.keyCode == 40 && index < $items.length - 1) index++ // down
392 if (!~index) index = 0
401 function clearMenus() {
406 function getParent($this) {
407 var selector = $this.attr('data-target')
411 selector = $this.attr('href')
412 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
415 $parent = $(selector)
416 $parent.length || ($parent = $this.parent())
422 /* DROPDOWN PLUGIN DEFINITION
423 * ========================== */
425 $.fn.dropdown = function (option) {
426 return this.each(function () {
428 , data = $this.data('dropdown')
429 if (!data) $this.data('dropdown', (data = new Dropdown(this)))
430 if (typeof option == 'string') data[option].call($this)
434 $.fn.dropdown.Constructor = Dropdown
437 /* APPLY TO STANDARD DROPDOWN ELEMENTS
438 * =================================== */
442 .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
444 .on('click.dropdown touchstart.dropdown.data-api', '.dropdown', function (e) { e.stopPropagation() })
445 .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
446 .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
450 /* =============================================================
451 * bootstrap-scrollspy.js v2.1.0
452 * http://twitter.github.com/bootstrap/javascript.html#scrollspy
453 * =============================================================
454 * Copyright 2012 Twitter, Inc.
456 * Licensed under the Apache License, Version 2.0 (the "License");
457 * you may not use this file except in compliance with the License.
458 * You may obtain a copy of the License at
460 * http://www.apache.org/licenses/LICENSE-2.0
462 * Unless required by applicable law or agreed to in writing, software
463 * distributed under the License is distributed on an "AS IS" BASIS,
464 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
465 * See the License for the specific language governing permissions and
466 * limitations under the License.
467 * ============================================================== */
472 "use strict"; // jshint ;_;
475 /* SCROLLSPY CLASS DEFINITION
476 * ========================== */
478 function ScrollSpy(element, options) {
479 var process = $.proxy(this.process, this)
480 , $element = $(element).is('body') ? $(window) : $(element)
482 this.options = $.extend({}, $.fn.scrollspy.defaults, options)
483 this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
484 this.selector = (this.options.target
485 || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
486 || '') + ' .nav li > a'
487 this.$body = $('body')
492 ScrollSpy.prototype = {
494 constructor: ScrollSpy
496 , refresh: function () {
503 $targets = this.$body
507 , href = $el.data('target') || $el.attr('href')
508 , $href = /^#\w/.test(href) && $(href)
511 && [[ $href.position().top, href ]] ) || null
513 .sort(function (a, b) { return a[0] - b[0] })
515 self.offsets.push(this[0])
516 self.targets.push(this[1])
520 , process: function () {
521 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
522 , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
523 , maxScroll = scrollHeight - this.$scrollElement.height()
524 , offsets = this.offsets
525 , targets = this.targets
526 , activeTarget = this.activeTarget
529 if (scrollTop >= maxScroll) {
530 return activeTarget != (i = targets.last()[0])
531 && this.activate ( i )
534 for (i = offsets.length; i--;) {
535 activeTarget != targets[i]
536 && scrollTop >= offsets[i]
537 && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
538 && this.activate( targets[i] )
542 , activate: function (target) {
546 this.activeTarget = target
550 .removeClass('active')
552 selector = this.selector
553 + '[data-target="' + target + '"],'
554 + this.selector + '[href="' + target + '"]'
560 if (active.parent('.dropdown-menu').length) {
561 active = active.closest('li.dropdown').addClass('active')
564 active.trigger('activate')
570 /* SCROLLSPY PLUGIN DEFINITION
571 * =========================== */
573 $.fn.scrollspy = function (option) {
574 return this.each(function () {
576 , data = $this.data('scrollspy')
577 , options = typeof option == 'object' && option
578 if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
579 if (typeof option == 'string') data[option]()
583 $.fn.scrollspy.Constructor = ScrollSpy
585 $.fn.scrollspy.defaults = {
590 /* SCROLLSPY DATA-API
591 * ================== */
593 $(window).on('load', function () {
594 $('[data-spy="scroll"]').each(function () {
596 $spy.scrollspy($spy.data())
601 /* ========================================================
602 * bootstrap-tab.js v2.1.0
603 * http://twitter.github.com/bootstrap/javascript.html#tabs
604 * ========================================================
605 * Copyright 2012 Twitter, Inc.
607 * Licensed under the Apache License, Version 2.0 (the "License");
608 * you may not use this file except in compliance with the License.
609 * You may obtain a copy of the License at
611 * http://www.apache.org/licenses/LICENSE-2.0
613 * Unless required by applicable law or agreed to in writing, software
614 * distributed under the License is distributed on an "AS IS" BASIS,
615 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
616 * See the License for the specific language governing permissions and
617 * limitations under the License.
618 * ======================================================== */
623 "use strict"; // jshint ;_;
626 /* TAB CLASS DEFINITION
627 * ==================== */
629 var Tab = function (element) {
630 this.element = $(element)
637 , show: function () {
638 var $this = this.element
639 , $ul = $this.closest('ul:not(.dropdown-menu)')
640 , selector = $this.attr('data-target')
646 selector = $this.attr('href')
647 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
650 if ( $this.parent('li').hasClass('active') ) return
652 previous = $ul.find('.active a').last()[0]
654 e = $.Event('show', {
655 relatedTarget: previous
660 if (e.isDefaultPrevented()) return
662 $target = $(selector)
664 this.activate($this.parent('li'), $ul)
665 this.activate($target, $target.parent(), function () {
668 , relatedTarget: previous
673 , activate: function ( element, container, callback) {
674 var $active = container.find('> .active')
675 , transition = callback
676 && $.support.transition
677 && $active.hasClass('fade')
681 .removeClass('active')
682 .find('> .dropdown-menu > .active')
683 .removeClass('active')
685 element.addClass('active')
688 element[0].offsetWidth // reflow for transition
689 element.addClass('in')
691 element.removeClass('fade')
694 if ( element.parent('.dropdown-menu') ) {
695 element.closest('li.dropdown').addClass('active')
698 callback && callback()
702 $active.one($.support.transition.end, next) :
705 $active.removeClass('in')
710 /* TAB PLUGIN DEFINITION
711 * ===================== */
713 $.fn.tab = function ( option ) {
714 return this.each(function () {
716 , data = $this.data('tab')
717 if (!data) $this.data('tab', (data = new Tab(this)))
718 if (typeof option == 'string') data[option]()
722 $.fn.tab.Constructor = Tab
729 $('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
736 /* ===========================================================
737 * bootstrap-tooltip.js v2.1.0
738 * http://twitter.github.com/bootstrap/javascript.html#tooltips
739 * Inspired by the original jQuery.tipsy by Jason Frame
740 * ===========================================================
741 * Copyright 2012 Twitter, Inc.
743 * Licensed under the Apache License, Version 2.0 (the "License");
744 * you may not use this file except in compliance with the License.
745 * You may obtain a copy of the License at
747 * http://www.apache.org/licenses/LICENSE-2.0
749 * Unless required by applicable law or agreed to in writing, software
750 * distributed under the License is distributed on an "AS IS" BASIS,
751 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
752 * See the License for the specific language governing permissions and
753 * limitations under the License.
754 * ========================================================== */
759 "use strict"; // jshint ;_;
762 /* TOOLTIP PUBLIC CLASS DEFINITION
763 * =============================== */
765 var Tooltip = function (element, options) {
766 this.init('tooltip', element, options)
769 Tooltip.prototype = {
773 , init: function (type, element, options) {
778 this.$element = $(element)
779 this.options = this.getOptions(options)
782 if (this.options.trigger == 'click') {
783 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
784 } else if (this.options.trigger != 'manual') {
785 eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
786 eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
787 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
788 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
791 this.options.selector ?
792 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
796 , getOptions: function (options) {
797 options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
799 if (options.delay && typeof options.delay == 'number') {
802 , hide: options.delay
809 , enter: function (e) {
810 var self = $(e.currentTarget)[this.type](this._options).data(this.type)
812 if (!self.options.delay || !self.options.delay.show) return self.show()
814 clearTimeout(this.timeout)
815 self.hoverState = 'in'
816 this.timeout = setTimeout(function() {
817 if (self.hoverState == 'in') self.show()
818 }, self.options.delay.show)
821 , leave: function (e) {
822 var self = $(e.currentTarget)[this.type](this._options).data(this.type)
824 if (this.timeout) clearTimeout(this.timeout)
825 if (!self.options.delay || !self.options.delay.hide) return self.hide()
827 self.hoverState = 'out'
828 this.timeout = setTimeout(function() {
829 if (self.hoverState == 'out') self.hide()
830 }, self.options.delay.hide)
833 , show: function () {
842 if (this.hasContent() && this.enabled) {
846 if (this.options.animation) {
847 $tip.addClass('fade')
850 placement = typeof this.options.placement == 'function' ?
851 this.options.placement.call(this, $tip[0], this.$element[0]) :
852 this.options.placement
854 inside = /in/.test(placement)
858 .css({ top: 0, left: 0, display: 'block' })
859 .appendTo(inside ? this.$element : document.body)
861 pos = this.getPosition(inside)
863 actualWidth = $tip[0].offsetWidth
864 actualHeight = $tip[0].offsetHeight
866 switch (inside ? placement.split(' ')[1] : placement) {
868 tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
871 tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
874 tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
877 tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
888 , setContent: function () {
889 var $tip = this.tip()
890 , title = this.getTitle()
892 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
893 $tip.removeClass('fade in top bottom left right')
896 , hide: function () {
900 $tip.removeClass('in')
902 function removeWithAnimation() {
903 var timeout = setTimeout(function () {
904 $tip.off($.support.transition.end).remove()
907 $tip.one($.support.transition.end, function () {
908 clearTimeout(timeout)
913 $.support.transition && this.$tip.hasClass('fade') ?
914 removeWithAnimation() :
920 , fixTitle: function () {
921 var $e = this.$element
922 if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
923 $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
927 , hasContent: function () {
928 return this.getTitle()
931 , getPosition: function (inside) {
932 return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
933 width: this.$element[0].offsetWidth
934 , height: this.$element[0].offsetHeight
938 , getTitle: function () {
943 title = $e.attr('data-original-title')
944 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
950 return this.$tip = this.$tip || $(this.options.template)
953 , validate: function () {
954 if (!this.$element[0].parentNode) {
961 , enable: function () {
965 , disable: function () {
969 , toggleEnabled: function () {
970 this.enabled = !this.enabled
973 , toggle: function () {
974 this[this.tip().hasClass('in') ? 'hide' : 'show']()
977 , destroy: function () {
978 this.hide().$element.off('.' + this.type).removeData(this.type)
984 /* TOOLTIP PLUGIN DEFINITION
985 * ========================= */
987 $.fn.tooltip = function ( option ) {
988 return this.each(function () {
990 , data = $this.data('tooltip')
991 , options = typeof option == 'object' && option
992 if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
993 if (typeof option == 'string') data[option]()
997 $.fn.tooltip.Constructor = Tooltip
999 $.fn.tooltip.defaults = {
1003 , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
1012 /* ===========================================================
1013 * bootstrap-popover.js v2.1.0
1014 * http://twitter.github.com/bootstrap/javascript.html#popovers
1015 * ===========================================================
1016 * Copyright 2012 Twitter, Inc.
1018 * Licensed under the Apache License, Version 2.0 (the "License");
1019 * you may not use this file except in compliance with the License.
1020 * You may obtain a copy of the License at
1022 * http://www.apache.org/licenses/LICENSE-2.0
1024 * Unless required by applicable law or agreed to in writing, software
1025 * distributed under the License is distributed on an "AS IS" BASIS,
1026 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1027 * See the License for the specific language governing permissions and
1028 * limitations under the License.
1029 * =========================================================== */
1034 "use strict"; // jshint ;_;
1037 /* POPOVER PUBLIC CLASS DEFINITION
1038 * =============================== */
1040 var Popover = function (element, options) {
1041 this.init('popover', element, options)
1045 /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
1046 ========================================== */
1048 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
1050 constructor: Popover
1052 , setContent: function () {
1053 var $tip = this.tip()
1054 , title = this.getTitle()
1055 , content = this.getContent()
1057 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
1058 $tip.find('.popover-content > *')[this.options.html ? 'html' : 'text'](content)
1060 $tip.removeClass('fade top bottom left right in')
1063 , hasContent: function () {
1064 return this.getTitle() || this.getContent()
1067 , getContent: function () {
1069 , $e = this.$element
1072 content = $e.attr('data-content')
1073 || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
1078 , tip: function () {
1080 this.$tip = $(this.options.template)
1085 , destroy: function () {
1086 this.hide().$element.off('.' + this.type).removeData(this.type)
1092 /* POPOVER PLUGIN DEFINITION
1093 * ======================= */
1095 $.fn.popover = function (option) {
1096 return this.each(function () {
1098 , data = $this.data('popover')
1099 , options = typeof option == 'object' && option
1100 if (!data) $this.data('popover', (data = new Popover(this, options)))
1101 if (typeof option == 'string') data[option]()
1105 $.fn.popover.Constructor = Popover
1107 $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
1111 , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
1115 /* ==========================================================
1116 * bootstrap-affix.js v2.1.0
1117 * http://twitter.github.com/bootstrap/javascript.html#affix
1118 * ==========================================================
1119 * Copyright 2012 Twitter, Inc.
1121 * Licensed under the Apache License, Version 2.0 (the "License");
1122 * you may not use this file except in compliance with the License.
1123 * You may obtain a copy of the License at
1125 * http://www.apache.org/licenses/LICENSE-2.0
1127 * Unless required by applicable law or agreed to in writing, software
1128 * distributed under the License is distributed on an "AS IS" BASIS,
1129 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1130 * See the License for the specific language governing permissions and
1131 * limitations under the License.
1132 * ========================================================== */
1137 "use strict"; // jshint ;_;
1140 /* AFFIX CLASS DEFINITION
1141 * ====================== */
1143 var Affix = function (element, options) {
1144 this.options = $.extend({}, $.fn.affix.defaults, options)
1145 this.$window = $(window).on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
1146 this.$element = $(element)
1147 this.checkPosition()
1150 Affix.prototype.checkPosition = function () {
1151 if (!this.$element.is(':visible')) return
1153 var scrollHeight = $(document).height()
1154 , scrollTop = this.$window.scrollTop()
1155 , position = this.$element.offset()
1156 , offset = this.options.offset
1157 , offsetBottom = offset.bottom
1158 , offsetTop = offset.top
1159 , reset = 'affix affix-top affix-bottom'
1162 if (typeof offset != 'object') offsetBottom = offsetTop = offset
1163 if (typeof offsetTop == 'function') offsetTop = offset.top()
1164 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
1166 affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
1167 false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
1168 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
1171 if (this.affixed === affix) return
1173 this.affixed = affix
1174 this.unpin = affix == 'bottom' ? position.top - scrollTop : null
1176 this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
1180 /* AFFIX PLUGIN DEFINITION
1181 * ======================= */
1183 $.fn.affix = function (option) {
1184 return this.each(function () {
1186 , data = $this.data('affix')
1187 , options = typeof option == 'object' && option
1188 if (!data) $this.data('affix', (data = new Affix(this, options)))
1189 if (typeof option == 'string') data[option]()
1193 $.fn.affix.Constructor = Affix
1195 $.fn.affix.defaults = {
1203 $(window).on('load', function () {
1204 $('[data-spy="affix"]').each(function () {
1206 , data = $spy.data()
1208 data.offset = data.offset || {}
1210 data.offsetBottom && (data.offset.bottom = data.offsetBottom)
1211 data.offsetTop && (data.offset.top = data.offsetTop)
1219 /* ==========================================================
1220 * bootstrap-alert.js v2.1.0
1221 * http://twitter.github.com/bootstrap/javascript.html#alerts
1222 * ==========================================================
1223 * Copyright 2012 Twitter, Inc.
1225 * Licensed under the Apache License, Version 2.0 (the "License");
1226 * you may not use this file except in compliance with the License.
1227 * You may obtain a copy of the License at
1229 * http://www.apache.org/licenses/LICENSE-2.0
1231 * Unless required by applicable law or agreed to in writing, software
1232 * distributed under the License is distributed on an "AS IS" BASIS,
1233 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1234 * See the License for the specific language governing permissions and
1235 * limitations under the License.
1236 * ========================================================== */
1241 "use strict"; // jshint ;_;
1244 /* ALERT CLASS DEFINITION
1245 * ====================== */
1247 var dismiss = '[data-dismiss="alert"]'
1248 , Alert = function (el) {
1249 $(el).on('click', dismiss, this.close)
1252 Alert.prototype.close = function (e) {
1254 , selector = $this.attr('data-target')
1258 selector = $this.attr('href')
1259 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
1262 $parent = $(selector)
1264 e && e.preventDefault()
1266 $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
1268 $parent.trigger(e = $.Event('close'))
1270 if (e.isDefaultPrevented()) return
1272 $parent.removeClass('in')
1274 function removeElement() {
1280 $.support.transition && $parent.hasClass('fade') ?
1281 $parent.on($.support.transition.end, removeElement) :
1286 /* ALERT PLUGIN DEFINITION
1287 * ======================= */
1289 $.fn.alert = function (option) {
1290 return this.each(function () {
1292 , data = $this.data('alert')
1293 if (!data) $this.data('alert', (data = new Alert(this)))
1294 if (typeof option == 'string') data[option].call($this)
1298 $.fn.alert.Constructor = Alert
1305 $('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
1309 /* ============================================================
1310 * bootstrap-button.js v2.1.0
1311 * http://twitter.github.com/bootstrap/javascript.html#buttons
1312 * ============================================================
1313 * Copyright 2012 Twitter, Inc.
1315 * Licensed under the Apache License, Version 2.0 (the "License");
1316 * you may not use this file except in compliance with the License.
1317 * You may obtain a copy of the License at
1319 * http://www.apache.org/licenses/LICENSE-2.0
1321 * Unless required by applicable law or agreed to in writing, software
1322 * distributed under the License is distributed on an "AS IS" BASIS,
1323 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1324 * See the License for the specific language governing permissions and
1325 * limitations under the License.
1326 * ============================================================ */
1331 "use strict"; // jshint ;_;
1334 /* BUTTON PUBLIC CLASS DEFINITION
1335 * ============================== */
1337 var Button = function (element, options) {
1338 this.$element = $(element)
1339 this.options = $.extend({}, $.fn.button.defaults, options)
1342 Button.prototype.setState = function (state) {
1344 , $el = this.$element
1346 , val = $el.is('input') ? 'val' : 'html'
1348 state = state + 'Text'
1349 data.resetText || $el.data('resetText', $el[val]())
1351 $el[val](data[state] || this.options[state])
1353 // push to event loop to allow forms to submit
1354 setTimeout(function () {
1355 state == 'loadingText' ?
1356 $el.addClass(d).attr(d, d) :
1357 $el.removeClass(d).removeAttr(d)
1361 Button.prototype.toggle = function () {
1362 var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
1366 .removeClass('active')
1368 this.$element.toggleClass('active')
1372 /* BUTTON PLUGIN DEFINITION
1373 * ======================== */
1375 $.fn.button = function (option) {
1376 return this.each(function () {
1378 , data = $this.data('button')
1379 , options = typeof option == 'object' && option
1380 if (!data) $this.data('button', (data = new Button(this, options)))
1381 if (option == 'toggle') data.toggle()
1382 else if (option) data.setState(option)
1386 $.fn.button.defaults = {
1387 loadingText: 'loading...'
1390 $.fn.button.Constructor = Button
1394 * =============== */
1397 $('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
1398 var $btn = $(e.target)
1399 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
1400 $btn.button('toggle')
1405 /* =============================================================
1406 * bootstrap-collapse.js v2.1.0
1407 * http://twitter.github.com/bootstrap/javascript.html#collapse
1408 * =============================================================
1409 * Copyright 2012 Twitter, Inc.
1411 * Licensed under the Apache License, Version 2.0 (the "License");
1412 * you may not use this file except in compliance with the License.
1413 * You may obtain a copy of the License at
1415 * http://www.apache.org/licenses/LICENSE-2.0
1417 * Unless required by applicable law or agreed to in writing, software
1418 * distributed under the License is distributed on an "AS IS" BASIS,
1419 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1420 * See the License for the specific language governing permissions and
1421 * limitations under the License.
1422 * ============================================================ */
1427 "use strict"; // jshint ;_;
1430 /* COLLAPSE PUBLIC CLASS DEFINITION
1431 * ================================ */
1433 var Collapse = function (element, options) {
1434 this.$element = $(element)
1435 this.options = $.extend({}, $.fn.collapse.defaults, options)
1437 if (this.options.parent) {
1438 this.$parent = $(this.options.parent)
1441 this.options.toggle && this.toggle()
1444 Collapse.prototype = {
1446 constructor: Collapse
1448 , dimension: function () {
1449 var hasWidth = this.$element.hasClass('width')
1450 return hasWidth ? 'width' : 'height'
1453 , show: function () {
1459 if (this.transitioning) return
1461 dimension = this.dimension()
1462 scroll = $.camelCase(['scroll', dimension].join('-'))
1463 actives = this.$parent && this.$parent.find('> .accordion-group > .in')
1465 if (actives && actives.length) {
1466 hasData = actives.data('collapse')
1467 if (hasData && hasData.transitioning) return
1468 actives.collapse('hide')
1469 hasData || actives.data('collapse', null)
1472 this.$element[dimension](0)
1473 this.transition('addClass', $.Event('show'), 'shown')
1474 $.support.transition && this.$element[dimension](this.$element[0][scroll])
1477 , hide: function () {
1479 if (this.transitioning) return
1480 dimension = this.dimension()
1481 this.reset(this.$element[dimension]())
1482 this.transition('removeClass', $.Event('hide'), 'hidden')
1483 this.$element[dimension](0)
1486 , reset: function (size) {
1487 var dimension = this.dimension()
1490 .removeClass('collapse')
1491 [dimension](size || 'auto')
1494 this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
1499 , transition: function (method, startEvent, completeEvent) {
1501 , complete = function () {
1502 if (startEvent.type == 'show') that.reset()
1503 that.transitioning = 0
1504 that.$element.trigger(completeEvent)
1507 this.$element.trigger(startEvent)
1509 if (startEvent.isDefaultPrevented()) return
1511 this.transitioning = 1
1513 this.$element[method]('in')
1515 $.support.transition && this.$element.hasClass('collapse') ?
1516 this.$element.one($.support.transition.end, complete) :
1520 , toggle: function () {
1521 this[this.$element.hasClass('in') ? 'hide' : 'show']()
1527 /* COLLAPSIBLE PLUGIN DEFINITION
1528 * ============================== */
1530 $.fn.collapse = function (option) {
1531 return this.each(function () {
1533 , data = $this.data('collapse')
1534 , options = typeof option == 'object' && option
1535 if (!data) $this.data('collapse', (data = new Collapse(this, options)))
1536 if (typeof option == 'string') data[option]()
1540 $.fn.collapse.defaults = {
1544 $.fn.collapse.Constructor = Collapse
1547 /* COLLAPSIBLE DATA-API
1548 * ==================== */
1551 $('body').on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
1552 var $this = $(this), href
1553 , target = $this.attr('data-target')
1554 || e.preventDefault()
1555 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
1556 , option = $(target).data('collapse') ? 'toggle' : $this.data()
1557 $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
1558 $(target).collapse(option)
1563 /* ==========================================================
1564 * bootstrap-carousel.js v2.1.0
1565 * http://twitter.github.com/bootstrap/javascript.html#carousel
1566 * ==========================================================
1567 * Copyright 2012 Twitter, Inc.
1569 * Licensed under the Apache License, Version 2.0 (the "License");
1570 * you may not use this file except in compliance with the License.
1571 * You may obtain a copy of the License at
1573 * http://www.apache.org/licenses/LICENSE-2.0
1575 * Unless required by applicable law or agreed to in writing, software
1576 * distributed under the License is distributed on an "AS IS" BASIS,
1577 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1578 * See the License for the specific language governing permissions and
1579 * limitations under the License.
1580 * ========================================================== */
1585 "use strict"; // jshint ;_;
1588 /* CAROUSEL CLASS DEFINITION
1589 * ========================= */
1591 var Carousel = function (element, options) {
1592 this.$element = $(element)
1593 this.options = options
1594 this.options.slide && this.slide(this.options.slide)
1595 this.options.pause == 'hover' && this.$element
1596 .on('mouseenter', $.proxy(this.pause, this))
1597 .on('mouseleave', $.proxy(this.cycle, this))
1600 Carousel.prototype = {
1602 cycle: function (e) {
1603 if (!e) this.paused = false
1604 this.options.interval
1606 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
1610 , to: function (pos) {
1611 var $active = this.$element.find('.item.active')
1612 , children = $active.parent().children()
1613 , activePos = children.index($active)
1616 if (pos > (children.length - 1) || pos < 0) return
1619 return this.$element.one('slid', function () {
1624 if (activePos == pos) {
1625 return this.pause().cycle()
1628 return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
1631 , pause: function (e) {
1632 if (!e) this.paused = true
1633 if (this.$element.find('.next, .prev').length && $.support.transition.end) {
1634 this.$element.trigger($.support.transition.end)
1637 clearInterval(this.interval)
1638 this.interval = null
1642 , next: function () {
1643 if (this.sliding) return
1644 return this.slide('next')
1647 , prev: function () {
1648 if (this.sliding) return
1649 return this.slide('prev')
1652 , slide: function (type, next) {
1653 var $active = this.$element.find('.item.active')
1654 , $next = next || $active[type]()
1655 , isCycling = this.interval
1656 , direction = type == 'next' ? 'left' : 'right'
1657 , fallback = type == 'next' ? 'first' : 'last'
1659 , e = $.Event('slide', {
1660 relatedTarget: $next[0]
1665 isCycling && this.pause()
1667 $next = $next.length ? $next : this.$element.find('.item')[fallback]()
1669 if ($next.hasClass('active')) return
1671 if ($.support.transition && this.$element.hasClass('slide')) {
1672 this.$element.trigger(e)
1673 if (e.isDefaultPrevented()) return
1674 $next.addClass(type)
1675 $next[0].offsetWidth // force reflow
1676 $active.addClass(direction)
1677 $next.addClass(direction)
1678 this.$element.one($.support.transition.end, function () {
1679 $next.removeClass([type, direction].join(' ')).addClass('active')
1680 $active.removeClass(['active', direction].join(' '))
1681 that.sliding = false
1682 setTimeout(function () { that.$element.trigger('slid') }, 0)
1685 this.$element.trigger(e)
1686 if (e.isDefaultPrevented()) return
1687 $active.removeClass('active')
1688 $next.addClass('active')
1689 this.sliding = false
1690 this.$element.trigger('slid')
1693 isCycling && this.cycle()
1701 /* CAROUSEL PLUGIN DEFINITION
1702 * ========================== */
1704 $.fn.carousel = function (option) {
1705 return this.each(function () {
1707 , data = $this.data('carousel')
1708 , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
1709 , action = typeof option == 'string' ? option : options.slide
1710 if (!data) $this.data('carousel', (data = new Carousel(this, options)))
1711 if (typeof option == 'number') data.to(option)
1712 else if (action) data[action]()
1713 else if (options.interval) data.cycle()
1717 $.fn.carousel.defaults = {
1722 $.fn.carousel.Constructor = Carousel
1725 /* CAROUSEL DATA-API
1726 * ================= */
1729 $('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
1730 var $this = $(this), href
1731 , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
1732 , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
1733 $target.carousel(options)
1739 /* =============================================================
1740 * bootstrap-typeahead.js v2.1.0
1741 * http://twitter.github.com/bootstrap/javascript.html#typeahead
1742 * =============================================================
1743 * Copyright 2012 Twitter, Inc.
1745 * Licensed under the Apache License, Version 2.0 (the "License");
1746 * you may not use this file except in compliance with the License.
1747 * You may obtain a copy of the License at
1749 * http://www.apache.org/licenses/LICENSE-2.0
1751 * Unless required by applicable law or agreed to in writing, software
1752 * distributed under the License is distributed on an "AS IS" BASIS,
1753 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1754 * See the License for the specific language governing permissions and
1755 * limitations under the License.
1756 * ============================================================ */
1761 "use strict"; // jshint ;_;
1764 /* TYPEAHEAD PUBLIC CLASS DEFINITION
1765 * ================================= */
1767 var Typeahead = function (element, options) {
1768 this.$element = $(element)
1769 this.options = $.extend({}, $.fn.typeahead.defaults, options)
1770 this.matcher = this.options.matcher || this.matcher
1771 this.sorter = this.options.sorter || this.sorter
1772 this.highlighter = this.options.highlighter || this.highlighter
1773 this.updater = this.options.updater || this.updater
1774 this.$menu = $(this.options.menu).appendTo('body')
1775 this.source = this.options.source
1780 Typeahead.prototype = {
1782 constructor: Typeahead
1784 , select: function () {
1785 var val = this.$menu.find('.active').attr('data-value')
1787 .val(this.updater(val))
1792 , updater: function (item) {
1796 , show: function () {
1797 var pos = $.extend({}, this.$element.offset(), {
1798 height: this.$element[0].offsetHeight
1802 top: pos.top + pos.height
1811 , hide: function () {
1817 , lookup: function (event) {
1820 this.query = this.$element.val()
1822 if (!this.query || this.query.length < this.options.minLength) {
1823 return this.shown ? this.hide() : this
1826 items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
1828 return items ? this.process(items) : this
1831 , process: function (items) {
1834 items = $.grep(items, function (item) {
1835 return that.matcher(item)
1838 items = this.sorter(items)
1840 if (!items.length) {
1841 return this.shown ? this.hide() : this
1844 return this.render(items.slice(0, this.options.items)).show()
1847 , matcher: function (item) {
1848 return ~item.toLowerCase().indexOf(this.query.toLowerCase())
1851 , sorter: function (items) {
1853 , caseSensitive = []
1854 , caseInsensitive = []
1857 while (item = items.shift()) {
1858 if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
1859 else if (~item.indexOf(this.query)) caseSensitive.push(item)
1860 else caseInsensitive.push(item)
1863 return beginswith.concat(caseSensitive, caseInsensitive)
1866 , highlighter: function (item) {
1867 var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
1868 return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
1869 return '<strong>' + match + '</strong>'
1873 , render: function (items) {
1876 items = $(items).map(function (i, item) {
1877 i = $(that.options.item).attr('data-value', item)
1878 i.find('a').html(that.highlighter(item))
1882 items.first().addClass('active')
1883 this.$menu.html(items)
1887 , next: function (event) {
1888 var active = this.$menu.find('.active').removeClass('active')
1889 , next = active.next()
1892 next = $(this.$menu.find('li')[0])
1895 next.addClass('active')
1898 , prev: function (event) {
1899 var active = this.$menu.find('.active').removeClass('active')
1900 , prev = active.prev()
1903 prev = this.$menu.find('li').last()
1906 prev.addClass('active')
1909 , listen: function () {
1911 .on('blur', $.proxy(this.blur, this))
1912 .on('keypress', $.proxy(this.keypress, this))
1913 .on('keyup', $.proxy(this.keyup, this))
1915 if ($.browser.webkit || $.browser.msie) {
1916 this.$element.on('keydown', $.proxy(this.keydown, this))
1920 .on('click', $.proxy(this.click, this))
1921 .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
1924 , move: function (e) {
1925 if (!this.shown) return
1934 case 38: // up arrow
1939 case 40: // down arrow
1948 , keydown: function (e) {
1949 this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40,38,9,13,27])
1953 , keypress: function (e) {
1954 if (this.suppressKeyPressRepeat) return
1958 , keyup: function (e) {
1960 case 40: // down arrow
1961 case 38: // up arrow
1966 if (!this.shown) return
1971 if (!this.shown) return
1983 , blur: function (e) {
1985 setTimeout(function () { that.hide() }, 150)
1988 , click: function (e) {
1994 , mouseenter: function (e) {
1995 this.$menu.find('.active').removeClass('active')
1996 $(e.currentTarget).addClass('active')
2002 /* TYPEAHEAD PLUGIN DEFINITION
2003 * =========================== */
2005 $.fn.typeahead = function (option) {
2006 return this.each(function () {
2008 , data = $this.data('typeahead')
2009 , options = typeof option == 'object' && option
2010 if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
2011 if (typeof option == 'string') data[option]()
2015 $.fn.typeahead.defaults = {
2018 , menu: '<ul class="typeahead dropdown-menu"></ul>'
2019 , item: '<li><a href="#"></a></li>'
2023 $.fn.typeahead.Constructor = Typeahead
2026 /* TYPEAHEAD DATA-API
2027 * ================== */
2030 $('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
2032 if ($this.data('typeahead')) return
2034 $this.typeahead($this.data())