diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-01-30 20:27:19 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-01-30 20:27:19 +0100 |
commit | 7197ea1facc58cbbb5a858aa20172fde2c523027 (patch) | |
tree | 7ac714b60c65ce937c841bcb35345064f2cc440a /pyaggr3g470r/static/js/bootstrap.js | |
parent | Released version 4.5. Installation in one step. Misc improvements to the Jinj... (diff) | |
download | newspipe-7197ea1facc58cbbb5a858aa20172fde2c523027.tar.gz newspipe-7197ea1facc58cbbb5a858aa20172fde2c523027.tar.bz2 newspipe-7197ea1facc58cbbb5a858aa20172fde2c523027.zip |
Upgraded to Bootstrap 3.1.0.
Diffstat (limited to 'pyaggr3g470r/static/js/bootstrap.js')
-rw-r--r-- | pyaggr3g470r/static/js/bootstrap.js | 590 |
1 files changed, 271 insertions, 319 deletions
diff --git a/pyaggr3g470r/static/js/bootstrap.js b/pyaggr3g470r/static/js/bootstrap.js index 2c642571..39ec4710 100644 --- a/pyaggr3g470r/static/js/bootstrap.js +++ b/pyaggr3g470r/static/js/bootstrap.js @@ -1,31 +1,22 @@ -/** -* bootstrap.js v3.0.0 by @fat and @mdo -* Copyright 2013 Twitter Inc. -* http://www.apache.org/licenses/LICENSE-2.0 -*/ -if (!jQuery) { throw new Error("Bootstrap requires jQuery") } +/*! + * Bootstrap v3.1.0 (http://getbootstrap.com) + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + +if (typeof jQuery === 'undefined') { throw new Error('Bootstrap requires jQuery') } /* ======================================================================== - * Bootstrap: transition.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#transitions + * Bootstrap: transition.js v3.1.0 + * http://getbootstrap.com/javascript/#transitions * ======================================================================== - * Copyright 2013 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) // ============================================================ @@ -34,10 +25,10 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } var el = document.createElement('bootstrap') var transEndEventNames = { - 'WebkitTransition' : 'webkitTransitionEnd' - , 'MozTransition' : 'transitionend' - , 'OTransition' : 'oTransitionEnd otransitionend' - , 'transition' : 'transitionend' + 'WebkitTransition' : 'webkitTransitionEnd', + 'MozTransition' : 'transitionend', + 'OTransition' : 'oTransitionEnd otransitionend', + 'transition' : 'transitionend' } for (var name in transEndEventNames) { @@ -45,6 +36,8 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } return { end: transEndEventNames[name] } } } + + return false // explicit for ie8 ( ._.) } // http://blog.alexmaccaw.com/css-transitions @@ -60,29 +53,19 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } $.support.transition = transitionEnd() }) -}(window.jQuery); +}(jQuery); /* ======================================================================== - * Bootstrap: alert.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#alerts + * Bootstrap: alert.js v3.1.0 + * http://getbootstrap.com/javascript/#alerts * ======================================================================== - * Copyright 2013 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // ALERT CLASS DEFINITION // ====================== @@ -159,36 +142,27 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) -}(window.jQuery); +}(jQuery); /* ======================================================================== - * Bootstrap: button.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#buttons + * Bootstrap: button.js v3.1.0 + * http://getbootstrap.com/javascript/#buttons * ======================================================================== - * Copyright 2013 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // BUTTON PUBLIC CLASS DEFINITION // ============================== var Button = function (element, options) { - this.$element = $(element) - this.options = $.extend({}, Button.DEFAULTS, options) + this.$element = $(element) + this.options = $.extend({}, Button.DEFAULTS, options) + this.isLoading = false } Button.DEFAULTS = { @@ -208,24 +182,31 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } $el[val](data[state] || this.options[state]) // push to event loop to allow forms to submit - setTimeout(function () { - state == 'loadingText' ? - $el.addClass(d).attr(d, d) : - $el.removeClass(d).removeAttr(d); - }, 0) + setTimeout($.proxy(function () { + if (state == 'loadingText') { + this.isLoading = true + $el.addClass(d).attr(d, d) + } else if (this.isLoading) { + this.isLoading = false + $el.removeClass(d).removeAttr(d) + } + }, this), 0) } Button.prototype.toggle = function () { + var changed = true var $parent = this.$element.closest('[data-toggle="buttons"]') if ($parent.length) { var $input = this.$element.find('input') - .prop('checked', !this.$element.hasClass('active')) - .trigger('change') - if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') + if ($input.prop('type') == 'radio') { + if ($input.prop('checked') && this.$element.hasClass('active')) changed = false + else $parent.find('.active').removeClass('active') + } + if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') } - this.$element.toggleClass('active') + if (changed) this.$element.toggleClass('active') } @@ -269,29 +250,19 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } e.preventDefault() }) -}(window.jQuery); +}(jQuery); /* ======================================================================== - * Bootstrap: carousel.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#carousel + * Bootstrap: carousel.js v3.1.0 + * http://getbootstrap.com/javascript/#carousel * ======================================================================== - * Copyright 2012 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // CAROUSEL CLASS DEFINITION // ========================= @@ -312,9 +283,9 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } } Carousel.DEFAULTS = { - interval: 5000 - , pause: 'hover' - , wrap: true + interval: 5000, + pause: 'hover', + wrap: true } Carousel.prototype.cycle = function (e) { @@ -342,7 +313,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } if (pos > (this.$items.length - 1) || pos < 0) return - if (this.sliding) return this.$element.one('slid', function () { that.to(pos) }) + if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) if (activeIndex == pos) return this.pause().cycle() return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) @@ -351,7 +322,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } Carousel.prototype.pause = function (e) { e || (this.paused = true) - if (this.$element.find('.next, .prev').length && $.support.transition.end) { + if (this.$element.find('.next, .prev').length && $.support.transition) { this.$element.trigger($.support.transition.end) this.cycle(true) } @@ -384,25 +355,25 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } $next = this.$element.find('.item')[fallback]() } - this.sliding = true - - isCycling && this.pause() + if ($next.hasClass('active')) return this.sliding = false var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction }) + this.$element.trigger(e) + if (e.isDefaultPrevented()) return - if ($next.hasClass('active')) return + this.sliding = true + + isCycling && this.pause() if (this.$indicators.length) { this.$indicators.find('.active').removeClass('active') - this.$element.one('slid', function () { + this.$element.one('slid.bs.carousel', function () { var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) $nextIndicator && $nextIndicator.addClass('active') }) } if ($.support.transition && this.$element.hasClass('slide')) { - this.$element.trigger(e) - if (e.isDefaultPrevented()) return $next.addClass(type) $next[0].offsetWidth // force reflow $active.addClass(direction) @@ -412,16 +383,14 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } $next.removeClass([type, direction].join(' ')).addClass('active') $active.removeClass(['active', direction].join(' ')) that.sliding = false - setTimeout(function () { that.$element.trigger('slid') }, 0) + setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0) }) - .emulateTransitionEnd(600) + .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000) } else { - this.$element.trigger(e) - if (e.isDefaultPrevented()) return $active.removeClass('active') $next.addClass('active') this.sliding = false - this.$element.trigger('slid') + this.$element.trigger('slid.bs.carousel') } isCycling && this.cycle() @@ -487,29 +456,19 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } }) }) -}(window.jQuery); +}(jQuery); /* ======================================================================== - * Bootstrap: collapse.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#collapse + * Bootstrap: collapse.js v3.1.0 + * http://getbootstrap.com/javascript/#collapse * ======================================================================== - * Copyright 2012 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // COLLAPSE PUBLIC CLASS DEFINITION // ================================ @@ -560,7 +519,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } var complete = function () { this.$element .removeClass('collapsing') - .addClass('in') + .addClass('collapse in') [dimension]('auto') this.transitioning = 0 this.$element.trigger('shown.bs.collapse') @@ -628,6 +587,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } var data = $this.data('bs.collapse') var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) + if (!data && options.toggle && option == 'show') option = !option if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) if (typeof option == 'string') data[option]() }) @@ -667,29 +627,19 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } $target.collapse(option) }) -}(window.jQuery); +}(jQuery); /* ======================================================================== - * Bootstrap: dropdown.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#dropdowns + * Bootstrap: dropdown.js v3.1.0 + * http://getbootstrap.com/javascript/#dropdowns * ======================================================================== - * Copyright 2012 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // DROPDOWN CLASS DEFINITION // ========================= @@ -697,7 +647,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } var backdrop = '.dropdown-backdrop' var toggle = '[data-toggle=dropdown]' var Dropdown = function (element) { - var $el = $(element).on('click.bs.dropdown', this.toggle) + $(element).on('click.bs.dropdown', this.toggle) } Dropdown.prototype.toggle = function (e) { @@ -712,17 +662,18 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } if (!isActive) { if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { - // if mobile we we use a backdrop because click events don't delegate + // if mobile we use a backdrop because click events don't delegate $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus) } - $parent.trigger(e = $.Event('show.bs.dropdown')) + var relatedTarget = { relatedTarget: this } + $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget)) if (e.isDefaultPrevented()) return $parent .toggleClass('open') - .trigger('shown.bs.dropdown') + .trigger('shown.bs.dropdown', relatedTarget) $this.focus() } @@ -748,7 +699,8 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } return $this.click() } - var $items = $('[role=menu] li:not(.divider):visible a', $parent) + var desc = ' li:not(.divider):visible a' + var $items = $parent.find('[role=menu]' + desc + ', [role=listbox]' + desc) if (!$items.length) return @@ -756,19 +708,20 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } if (e.keyCode == 38 && index > 0) index-- // up if (e.keyCode == 40 && index < $items.length - 1) index++ // down - if (!~index) index=0 + if (!~index) index = 0 $items.eq(index).focus() } - function clearMenus() { + function clearMenus(e) { $(backdrop).remove() - $(toggle).each(function (e) { + $(toggle).each(function () { var $parent = getParent($(this)) + var relatedTarget = { relatedTarget: this } if (!$parent.hasClass('open')) return - $parent.trigger(e = $.Event('hide.bs.dropdown')) + $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget)) if (e.isDefaultPrevented()) return - $parent.removeClass('open').trigger('hidden.bs.dropdown') + $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget) }) } @@ -777,7 +730,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } if (!selector) { selector = $this.attr('href') - selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 + selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 } var $parent = selector && $(selector) @@ -794,9 +747,9 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } $.fn.dropdown = function (option) { return this.each(function () { var $this = $(this) - var data = $this.data('dropdown') + var data = $this.data('bs.dropdown') - if (!data) $this.data('dropdown', (data = new Dropdown(this))) + if (!data) $this.data('bs.dropdown', (data = new Dropdown(this))) if (typeof option == 'string') data[option].call($this) }) } @@ -819,32 +772,22 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } $(document) .on('click.bs.dropdown.data-api', clearMenus) .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) - .on('click.bs.dropdown.data-api' , toggle, Dropdown.prototype.toggle) - .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) + .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle) + .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu], [role=listbox]', Dropdown.prototype.keydown) -}(window.jQuery); +}(jQuery); /* ======================================================================== - * Bootstrap: modal.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#modals + * Bootstrap: modal.js v3.1.0 + * http://getbootstrap.com/javascript/#modals * ======================================================================== - * Copyright 2012 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // MODAL CLASS DEFINITION // ====================== @@ -855,13 +798,19 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } this.$backdrop = this.isShown = null - if (this.options.remote) this.$element.load(this.options.remote) + if (this.options.remote) { + this.$element + .find('.modal-content') + .load(this.options.remote, $.proxy(function () { + this.$element.trigger('loaded.bs.modal') + }, this)) + } } Modal.DEFAULTS = { - backdrop: true - , keyboard: true - , show: true + backdrop: true, + keyboard: true, + show: true } Modal.prototype.toggle = function (_relatedTarget) { @@ -880,7 +829,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } this.escape() - this.$element.on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) + this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) this.backdrop(function () { var transition = $.support.transition && that.$element.hasClass('fade') @@ -889,7 +838,9 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } that.$element.appendTo(document.body) // don't move modals dom position } - that.$element.show() + that.$element + .show() + .scrollTop(0) if (transition) { that.$element[0].offsetWidth // force reflow @@ -931,7 +882,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } this.$element .removeClass('in') .attr('aria-hidden', true) - .off('click.dismiss.modal') + .off('click.dismiss.bs.modal') $.support.transition && this.$element.hasClass('fade') ? this.$element @@ -975,7 +926,6 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } } Modal.prototype.backdrop = function (callback) { - var that = this var animate = this.$element.hasClass('fade') ? 'fade' : '' if (this.isShown && this.options.backdrop) { @@ -984,7 +934,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />') .appendTo(document.body) - this.$element.on('click.dismiss.modal', $.proxy(function (e) { + this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) { if (e.target !== e.currentTarget) return this.options.backdrop == 'static' ? this.$element[0].focus.call(this.$element[0]) @@ -1006,7 +956,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } } else if (!this.isShown && this.$backdrop) { this.$backdrop.removeClass('in') - $.support.transition && this.$element.hasClass('fade')? + $.support.transition && this.$element.hasClass('fade') ? this.$backdrop .one($.support.transition.end, callback) .emulateTransitionEnd(150) : @@ -1054,9 +1004,9 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } var $this = $(this) var href = $this.attr('href') var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 - var option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) + var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) - e.preventDefault() + if ($this.is('a')) e.preventDefault() $target .modal(option, this) @@ -1066,33 +1016,23 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } }) $(document) - .on('show.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') }) + .on('show.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') }) .on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') }) -}(window.jQuery); +}(jQuery); /* ======================================================================== - * Bootstrap: tooltip.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#tooltip + * Bootstrap: tooltip.js v3.1.0 + * http://getbootstrap.com/javascript/#tooltip * Inspired by the original jQuery.tipsy by Jason Frame * ======================================================================== - * Copyright 2012 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // TOOLTIP PUBLIC CLASS DEFINITION // =============================== @@ -1109,15 +1049,15 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } } Tooltip.DEFAULTS = { - animation: true - , placement: 'top' - , selector: false - , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' - , trigger: 'hover focus' - , title: '' - , delay: 0 - , html: false - , container: false + animation: true, + placement: 'top', + selector: false, + template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>', + trigger: 'hover focus', + title: '', + delay: 0, + html: false, + container: false } Tooltip.prototype.init = function (type, element, options) { @@ -1134,8 +1074,8 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } if (trigger == 'click') { this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) } else if (trigger != 'manual') { - var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus' - var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur' + var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin' + var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout' this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) @@ -1156,8 +1096,8 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } if (options.delay && typeof options.delay == 'number') { options.delay = { - show: options.delay - , hide: options.delay + show: options.delay, + hide: options.delay } } @@ -1206,12 +1146,13 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } } Tooltip.prototype.show = function () { - var e = $.Event('show.bs.'+ this.type) + var e = $.Event('show.bs.' + this.type) if (this.hasContent() && this.enabled) { this.$element.trigger(e) if (e.isDefaultPrevented()) return + var that = this; var $tip = this.tip() @@ -1261,11 +1202,21 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight) this.applyPlacement(calculatedOffset, placement) - this.$element.trigger('shown.bs.' + this.type) + this.hoverState = null + + var complete = function() { + that.$element.trigger('shown.bs.' + that.type) + } + + $.support.transition && this.$tip.hasClass('fade') ? + $tip + .one($.support.transition.end, complete) + .emulateTransitionEnd(150) : + complete() } } - Tooltip.prototype.applyPlacement = function(offset, placement) { + Tooltip.prototype.applyPlacement = function (offset, placement) { var replace var $tip = this.tip() var width = $tip[0].offsetWidth @@ -1282,9 +1233,18 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } offset.top = offset.top + marginTop offset.left = offset.left + marginLeft - $tip - .offset(offset) - .addClass('in') + // $.fn.offset doesn't round pixel values + // so we use setOffset directly with our own function B-0 + $.offset.setOffset($tip[0], $.extend({ + using: function (props) { + $tip.css({ + top: Math.round(props.top), + left: Math.round(props.left) + }) + } + }, offset), 0) + + $tip.addClass('in') // check to see if placing tip in new offset caused the tip to resize itself var actualWidth = $tip[0].offsetWidth @@ -1316,8 +1276,8 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } if (replace) $tip.offset(offset) } - Tooltip.prototype.replaceArrow = function(delta, dimension, position) { - this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '') + Tooltip.prototype.replaceArrow = function (delta, dimension, position) { + this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '') } Tooltip.prototype.setContent = function () { @@ -1335,6 +1295,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } function complete() { if (that.hoverState != 'in') $tip.detach() + that.$element.trigger('hidden.bs.' + that.type) } this.$element.trigger(e) @@ -1349,7 +1310,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } .emulateTransitionEnd(150) : complete() - this.$element.trigger('hidden.bs.' + this.type) + this.hoverState = null return this } @@ -1368,8 +1329,8 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } Tooltip.prototype.getPosition = function () { var el = this.$element[0] return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : { - width: el.offsetWidth - , height: el.offsetHeight + width: el.offsetWidth, + height: el.offsetHeight }, this.$element.offset()) } @@ -1425,6 +1386,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } } Tooltip.prototype.destroy = function () { + clearTimeout(this.timeout) this.hide().$element.off('.' + this.type).removeData('bs.' + this.type) } @@ -1440,6 +1402,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } var data = $this.data('bs.tooltip') var options = typeof option == 'object' && option + if (!data && option == 'destroy') return if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options))) if (typeof option == 'string') data[option]() }) @@ -1456,29 +1419,19 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } return this } -}(window.jQuery); +}(jQuery); /* ======================================================================== - * Bootstrap: popover.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#popovers + * Bootstrap: popover.js v3.1.0 + * http://getbootstrap.com/javascript/#popovers * ======================================================================== - * Copyright 2012 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // POPOVER PUBLIC CLASS DEFINITION // =============================== @@ -1489,11 +1442,11 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js') - Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, { - placement: 'right' - , trigger: 'click' - , content: '' - , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' + Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, { + placement: 'right', + trigger: 'click', + content: '', + template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' }) @@ -1514,7 +1467,9 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } var content = this.getContent() $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title) - $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content) + $tip.find('.popover-content')[ // we use append for html objects to maintain js events + this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text' + ](content) $tip.removeClass('fade top bottom left right in') @@ -1558,6 +1513,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } var data = $this.data('bs.popover') var options = typeof option == 'object' && option + if (!data && option == 'destroy') return if (!data) $this.data('bs.popover', (data = new Popover(this, options))) if (typeof option == 'string') data[option]() }) @@ -1574,29 +1530,19 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } return this } -}(window.jQuery); +}(jQuery); /* ======================================================================== - * Bootstrap: scrollspy.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#scrollspy + * Bootstrap: scrollspy.js v3.1.0 + * http://getbootstrap.com/javascript/#scrollspy * ======================================================================== - * Copyright 2012 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // SCROLLSPY CLASS DEFINITION // ========================== @@ -1636,10 +1582,11 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } .map(function () { var $el = $(this) var href = $el.data('target') || $el.attr('href') - var $href = /^#\w/.test(href) && $(href) + var $href = /^#./.test(href) && $(href) return ($href && $href.length + && $href.is(':visible') && [[ $href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null }) .sort(function (a, b) { return a[0] - b[0] }) @@ -1662,6 +1609,10 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } return activeTarget != (i = targets.last()[0]) && this.activate(i) } + if (activeTarget && scrollTop <= offsets[0]) { + return activeTarget != (i = targets[0]) && this.activate(i) + } + for (i = offsets.length; i--;) { activeTarget != targets[i] && scrollTop >= offsets[i] @@ -1674,24 +1625,24 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } this.activeTarget = target $(this.selector) - .parents('.active') + .parentsUntil(this.options.target, '.active') .removeClass('active') - var selector = this.selector - + '[data-target="' + target + '"],' - + this.selector + '[href="' + target + '"]' + var selector = this.selector + + '[data-target="' + target + '"],' + + this.selector + '[href="' + target + '"]' var active = $(selector) .parents('li') .addClass('active') - if (active.parent('.dropdown-menu').length) { + if (active.parent('.dropdown-menu').length) { active = active .closest('li.dropdown') .addClass('active') } - active.trigger('activate') + active.trigger('activate.bs.scrollspy') } @@ -1733,29 +1684,19 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } }) }) -}(window.jQuery); +}(jQuery); /* ======================================================================== - * Bootstrap: tab.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#tabs + * Bootstrap: tab.js v3.1.0 + * http://getbootstrap.com/javascript/#tabs * ======================================================================== - * Copyright 2012 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // TAB CLASS DEFINITION // ==================== @@ -1767,7 +1708,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } Tab.prototype.show = function () { var $this = this.element var $ul = $this.closest('ul:not(.dropdown-menu)') - var selector = $this.attr('data-target') + var selector = $this.data('target') if (!selector) { selector = $this.attr('href') @@ -1790,8 +1731,8 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } this.activate($this.parent('li'), $ul) this.activate($target, $target.parent(), function () { $this.trigger({ - type: 'shown.bs.tab' - , relatedTarget: previous + type: 'shown.bs.tab', + relatedTarget: previous }) }) } @@ -1869,29 +1810,19 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } $(this).tab('show') }) -}(window.jQuery); +}(jQuery); /* ======================================================================== - * Bootstrap: affix.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#affix + * Bootstrap: affix.js v3.1.0 + * http://getbootstrap.com/javascript/#affix * ======================================================================== - * Copyright 2012 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // AFFIX CLASS DEFINITION // ====================== @@ -1902,9 +1833,10 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this)) .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this)) - this.$element = $(element) - this.affixed = - this.unpin = null + this.$element = $(element) + this.affixed = + this.unpin = + this.pinnedOffset = null this.checkPosition() } @@ -1915,6 +1847,14 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } offset: 0 } + Affix.prototype.getPinnedOffset = function () { + if (this.pinnedOffset) return this.pinnedOffset + this.$element.removeClass(Affix.RESET).addClass('affix') + var scrollTop = this.$window.scrollTop() + var position = this.$element.offset() + return (this.pinnedOffset = position.top - scrollTop) + } + Affix.prototype.checkPositionWithEventLoop = function () { setTimeout($.proxy(this.checkPosition, this), 1) } @@ -1929,9 +1869,11 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } var offsetTop = offset.top var offsetBottom = offset.bottom + if (this.affixed == 'top') position.top += scrollTop + if (typeof offset != 'object') offsetBottom = offsetTop = offset - if (typeof offsetTop == 'function') offsetTop = offset.top() - if (typeof offsetBottom == 'function') offsetBottom = offset.bottom() + if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element) + if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element) var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' : @@ -1940,13 +1882,23 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } if (this.affixed === affix) return if (this.unpin) this.$element.css('top', '') + var affixType = 'affix' + (affix ? '-' + affix : '') + var e = $.Event(affixType + '.bs.affix') + + this.$element.trigger(e) + + if (e.isDefaultPrevented()) return + this.affixed = affix - this.unpin = affix == 'bottom' ? position.top - scrollTop : null + this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null - this.$element.removeClass(Affix.RESET).addClass('affix' + (affix ? '-' + affix : '')) + this.$element + .removeClass(Affix.RESET) + .addClass(affixType) + .trigger($.Event(affixType.replace('affix', 'affixed'))) if (affix == 'bottom') { - this.$element.offset({ top: document.body.offsetHeight - offsetBottom - this.$element.height() }) + this.$element.offset({ top: scrollHeight - offsetBottom - this.$element.height() }) } } @@ -1996,4 +1948,4 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } }) }) -}(window.jQuery); +}(jQuery); |