diff options
| author | Mark Otto <[email protected]> | 2014-11-30 20:17:45 -0800 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2014-11-30 20:17:45 -0800 |
| commit | b648a77ed36d2d3a38842a7ab5a19ba50c52bae6 (patch) | |
| tree | 5f2a1a3db3f9464f1803c1afef8946e07951ad5c /js | |
| parent | b53ad74d472d0dbe3669b61e79c89fd35da4aa1f (diff) | |
| parent | 0eb2c922d892bdcd4356b7212ab61c7d8a44c2dc (diff) | |
| download | bootstrap-b648a77ed36d2d3a38842a7ab5a19ba50c52bae6.tar.xz bootstrap-b648a77ed36d2d3a38842a7ab5a19ba50c52bae6.zip | |
Merge branch 'master' into v4
Conflicts:
Gruntfile.js
_config.yml
dist/css/bootstrap-theme.css
dist/css/bootstrap-theme.min.css
dist/css/bootstrap.css
dist/css/bootstrap.css.map
dist/css/bootstrap.min.css
dist/fonts/glyphicons-halflings-regular.eot
dist/fonts/glyphicons-halflings-regular.svg
dist/fonts/glyphicons-halflings-regular.ttf
dist/fonts/glyphicons-halflings-regular.woff
docs/_data/glyphicons.yml
docs/_includes/components/alerts.html
docs/_includes/components/badges.html
docs/_includes/components/button-dropdowns.html
docs/_includes/components/button-groups.html
docs/_includes/components/dropdowns.html
docs/_includes/components/glyphicons.html
docs/_includes/components/input-groups.html
docs/_includes/components/labels.html
docs/_includes/components/media.html
docs/_includes/components/navbar.html
docs/_includes/components/navs.html
docs/_includes/components/pagination.html
docs/_includes/components/panels.html
docs/_includes/components/progress-bars.html
docs/_includes/css/buttons.html
docs/_includes/css/forms.html
docs/_includes/css/grid.html
docs/_includes/css/helpers.html
docs/_includes/css/images.html
docs/_includes/css/less.html
docs/_includes/css/responsive-utilities.html
docs/_includes/css/sass.html
docs/_includes/css/tables.html
docs/_includes/css/type.html
docs/_includes/getting-started/accessibility.html
docs/_includes/getting-started/browser-device-support.html
docs/_includes/getting-started/community.html
docs/_includes/getting-started/download.html
docs/_includes/getting-started/examples.html
docs/_includes/getting-started/whats-included.html
docs/_includes/js/affix.html
docs/_includes/js/alerts.html
docs/_includes/js/buttons.html
docs/_includes/js/carousel.html
docs/_includes/js/collapse.html
docs/_includes/js/dropdowns.html
docs/_includes/js/modal.html
docs/_includes/js/overview.html
docs/_includes/js/tabs.html
docs/_includes/nav/components.html
docs/_includes/nav/css.html
docs/_includes/nav/javascript.html
docs/_includes/nav/main.html
docs/about.html
docs/assets/css/docs.min.css
docs/assets/js/customize.min.js
docs/assets/js/raw-files.min.js
docs/dist/css/bootstrap-theme.css
docs/dist/css/bootstrap-theme.min.css
docs/dist/css/bootstrap.css
docs/dist/css/bootstrap.css.map
docs/dist/css/bootstrap.min.css
docs/dist/fonts/glyphicons-halflings-regular.eot
docs/dist/fonts/glyphicons-halflings-regular.svg
docs/dist/fonts/glyphicons-halflings-regular.ttf
docs/dist/fonts/glyphicons-halflings-regular.woff
docs/examples/carousel/index.html
docs/examples/navbar-fixed-top/index.html
docs/examples/navbar-static-top/index.html
docs/examples/navbar/index.html
docs/examples/non-responsive/index.html
docs/examples/non-responsive/non-responsive.css
docs/examples/sticky-footer-navbar/index.html
docs/examples/theme/index.html
fonts/glyphicons-halflings-regular.eot
fonts/glyphicons-halflings-regular.svg
fonts/glyphicons-halflings-regular.ttf
fonts/glyphicons-halflings-regular.woff
less/_carousel.less
less/_forms.less
less/glyphicons.less
Diffstat (limited to 'js')
| -rw-r--r-- | js/affix.js | 6 | ||||
| -rw-r--r-- | js/alert.js | 4 | ||||
| -rw-r--r-- | js/button.js | 4 | ||||
| -rw-r--r-- | js/carousel.js | 15 | ||||
| -rw-r--r-- | js/collapse.js | 6 | ||||
| -rw-r--r-- | js/dropdown.js | 6 | ||||
| -rw-r--r-- | js/modal.js | 4 | ||||
| -rw-r--r-- | js/popover.js | 4 | ||||
| -rw-r--r-- | js/scrollspy.js | 4 | ||||
| -rw-r--r-- | js/tab.js | 4 | ||||
| -rw-r--r-- | js/tests/unit/affix.js | 30 | ||||
| -rw-r--r-- | js/tests/unit/carousel.js | 153 | ||||
| -rw-r--r-- | js/tests/unit/dropdown.js | 41 | ||||
| -rw-r--r-- | js/tests/unit/tooltip.js | 2 | ||||
| -rw-r--r-- | js/tooltip.js | 4 | ||||
| -rw-r--r-- | js/transition.js | 2 |
16 files changed, 255 insertions, 34 deletions
diff --git a/js/affix.js b/js/affix.js index e4efa20c6..04f389e2c 100644 --- a/js/affix.js +++ b/js/affix.js @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: affix.js v3.3.0 + * Bootstrap: affix.js v3.3.1 * http://getbootstrap.com/javascript/#affix * ======================================================================== * Copyright 2011-2014 Twitter, Inc. @@ -28,7 +28,7 @@ this.checkPosition() } - Affix.VERSION = '3.3.0' + Affix.VERSION = '3.3.1' Affix.RESET = 'affix affix-top affix-bottom' @@ -53,7 +53,7 @@ var colliderTop = initializing ? scrollTop : position.top var colliderHeight = initializing ? targetHeight : height - if (offsetTop != null && colliderTop <= offsetTop) return 'top' + if (offsetTop != null && scrollTop <= offsetTop) return 'top' if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom' return false diff --git a/js/alert.js b/js/alert.js index d47d85fc5..7b775dd0a 100644 --- a/js/alert.js +++ b/js/alert.js @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: alert.js v3.3.0 + * Bootstrap: alert.js v3.3.1 * http://getbootstrap.com/javascript/#alerts * ======================================================================== * Copyright 2011-2014 Twitter, Inc. @@ -18,7 +18,7 @@ $(el).on('click', dismiss, this.close) } - Alert.VERSION = '3.3.0' + Alert.VERSION = '3.3.1' Alert.TRANSITION_DURATION = 150 diff --git a/js/button.js b/js/button.js index 403829490..7b1e134b2 100644 --- a/js/button.js +++ b/js/button.js @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: button.js v3.3.0 + * Bootstrap: button.js v3.3.1 * http://getbootstrap.com/javascript/#buttons * ======================================================================== * Copyright 2011-2014 Twitter, Inc. @@ -19,7 +19,7 @@ this.isLoading = false } - Button.VERSION = '3.3.0' + Button.VERSION = '3.3.1' Button.DEFAULTS = { loadingText: 'loading...' diff --git a/js/carousel.js b/js/carousel.js index 82106d278..99a077c10 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: carousel.js v3.3.0 + * Bootstrap: carousel.js v3.3.1 * http://getbootstrap.com/javascript/#carousel * ======================================================================== * Copyright 2011-2014 Twitter, Inc. @@ -30,7 +30,7 @@ .on('mouseleave.bs.carousel', $.proxy(this.cycle, this)) } - Carousel.VERSION = '3.3.0' + Carousel.VERSION = '3.3.1' Carousel.TRANSITION_DURATION = 600 @@ -70,8 +70,11 @@ } Carousel.prototype.getItemForDirection = function (direction, active) { - var delta = direction == 'prev' ? -1 : 1 var activeIndex = this.getItemIndex(active) + var willWrap = (direction == 'prev' && activeIndex === 0) + || (direction == 'next' && activeIndex == (this.$items.length - 1)) + if (willWrap && !this.options.wrap) return active + var delta = direction == 'prev' ? -1 : 1 var itemIndex = (activeIndex + delta) % this.$items.length return this.$items.eq(itemIndex) } @@ -116,14 +119,8 @@ var $next = next || this.getItemForDirection(type, $active) var isCycling = this.interval var direction = type == 'next' ? 'left' : 'right' - var fallback = type == 'next' ? 'first' : 'last' var that = this - if (!$next.length) { - if (!this.options.wrap) return - $next = this.$element.find('.item')[fallback]() - } - if ($next.hasClass('active')) return (this.sliding = false) var relatedTarget = $next[0] diff --git a/js/collapse.js b/js/collapse.js index 4f8596444..a2ede5914 100644 --- a/js/collapse.js +++ b/js/collapse.js @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: collapse.js v3.3.0 + * Bootstrap: collapse.js v3.3.1 * http://getbootstrap.com/javascript/#collapse * ======================================================================== * Copyright 2011-2014 Twitter, Inc. @@ -28,7 +28,7 @@ if (this.options.toggle) this.toggle() } - Collapse.VERSION = '3.3.0' + Collapse.VERSION = '3.3.1' Collapse.TRANSITION_DURATION = 350 @@ -46,7 +46,7 @@ if (this.transitioning || this.$element.hasClass('in')) return var activesData - var actives = this.$parent && this.$parent.find('> .panel').children('.in, .collapsing') + var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing') if (actives && actives.length) { activesData = actives.data('bs.collapse') diff --git a/js/dropdown.js b/js/dropdown.js index ae192e570..69a40f681 100644 --- a/js/dropdown.js +++ b/js/dropdown.js @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: dropdown.js v3.3.0 + * Bootstrap: dropdown.js v3.3.1 * http://getbootstrap.com/javascript/#dropdowns * ======================================================================== * Copyright 2011-2014 Twitter, Inc. @@ -19,7 +19,7 @@ $(element).on('click.bs.dropdown', this.toggle) } - Dropdown.VERSION = '3.3.0' + Dropdown.VERSION = '3.3.1' Dropdown.prototype.toggle = function (e) { var $this = $(this) @@ -55,7 +55,7 @@ } Dropdown.prototype.keydown = function (e) { - if (!/(38|40|27|32)/.test(e.which)) return + if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return var $this = $(this) diff --git a/js/modal.js b/js/modal.js index ed3f0293f..93891aa4e 100644 --- a/js/modal.js +++ b/js/modal.js @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: modal.js v3.3.0 + * Bootstrap: modal.js v3.3.1 * http://getbootstrap.com/javascript/#modals * ======================================================================== * Copyright 2011-2014 Twitter, Inc. @@ -30,7 +30,7 @@ } } - Modal.VERSION = '3.3.0' + Modal.VERSION = '3.3.1' Modal.TRANSITION_DURATION = 300 Modal.BACKDROP_TRANSITION_DURATION = 150 diff --git a/js/popover.js b/js/popover.js index 354805917..db272bdee 100644 --- a/js/popover.js +++ b/js/popover.js @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: popover.js v3.3.0 + * Bootstrap: popover.js v3.3.1 * http://getbootstrap.com/javascript/#popovers * ======================================================================== * Copyright 2011-2014 Twitter, Inc. @@ -19,7 +19,7 @@ if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js') - Popover.VERSION = '3.3.0' + Popover.VERSION = '3.3.1' Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, { placement: 'right', diff --git a/js/scrollspy.js b/js/scrollspy.js index 973021a93..c468262f3 100644 --- a/js/scrollspy.js +++ b/js/scrollspy.js @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: scrollspy.js v3.3.0 + * Bootstrap: scrollspy.js v3.3.1 * http://getbootstrap.com/javascript/#scrollspy * ======================================================================== * Copyright 2011-2014 Twitter, Inc. @@ -30,7 +30,7 @@ this.process() } - ScrollSpy.VERSION = '3.3.0' + ScrollSpy.VERSION = '3.3.1' ScrollSpy.DEFAULTS = { offset: 10 @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: tab.js v3.3.0 + * Bootstrap: tab.js v3.3.1 * http://getbootstrap.com/javascript/#tabs * ======================================================================== * Copyright 2011-2014 Twitter, Inc. @@ -17,7 +17,7 @@ this.element = $(element) } - Tab.VERSION = '3.3.0' + Tab.VERSION = '3.3.1' Tab.TRANSITION_DURATION = 150 diff --git a/js/tests/unit/affix.js b/js/tests/unit/affix.js index ef6ef74b9..3152d8d2e 100644 --- a/js/tests/unit/affix.js +++ b/js/tests/unit/affix.js @@ -68,4 +68,34 @@ $(function () { }, 16) // for testing in a browser }, 0) }) + + test('should affix-top when scrolling up to offset when parent has padding', function () { + stop() + + var templateHTML = '<div id="padding-offset" style="padding-top: 20px;">' + + '<div id="affixTopTarget">' + + '<p>Testing affix-top class is added</p>' + + '</div>' + + '<div style="height: 1000px; display: block;"/>' + + '</div>' + $(templateHTML).appendTo(document.body) + + $('#affixTopTarget') + .bootstrapAffix({ + offset: { top: 120, bottom: 0 } + }) + .on('affixed-top.bs.affix', function () { + ok($('#affixTopTarget').hasClass('affix-top'), 'affix-top class applied') + $('#padding-offset').remove() + start() + }) + + setTimeout(function () { + window.scrollTo(0, document.body.scrollHeight) + + setTimeout(function () { + window.scroll(0, 119) + }, 250) + }, 250) + }) }) diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index 5998abe6a..008b72082 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -541,4 +541,157 @@ $(function () { strictEqual(type in $._data($template[0], 'events'), !isMobile, 'does' + (isMobile ? ' not' : '') + ' listen for ' + type + ' events') }) }) + + test('should wrap around from end to start when wrap option is true', function () { + var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="true">' + + '<ol class="carousel-indicators">' + + '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' + + '<li data-target="#carousel-example-generic" data-slide-to="1"/>' + + '<li data-target="#carousel-example-generic" data-slide-to="2"/>' + + '</ol>' + + '<div class="carousel-inner">' + + '<div class="item active" id="one">' + + '<div class="carousel-caption"/>' + + '</div>' + + '<div class="item" id="two">' + + '<div class="carousel-caption"/>' + + '</div>' + + '<div class="item" id="three">' + + '<div class="carousel-caption"/>' + + '</div>' + + '</div>' + + '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' + + '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' + + '</div>' + var $carousel = $(carouselHTML) + var getActiveId = function () { return $carousel.find('.item.active').attr('id') } + + stop() + + $carousel + .one('slid.bs.carousel', function () { + strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide') + $carousel + .one('slid.bs.carousel', function () { + strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide') + $carousel + .one('slid.bs.carousel', function () { + strictEqual(getActiveId(), 'one', 'carousel wrapped around and slid from 3rd to 1st slide') + start() + }) + .bootstrapCarousel('next') + }) + .bootstrapCarousel('next') + }) + .bootstrapCarousel('next') + }) + + test('should wrap around from start to end when wrap option is true', function () { + var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="true">' + + '<ol class="carousel-indicators">' + + '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' + + '<li data-target="#carousel-example-generic" data-slide-to="1"/>' + + '<li data-target="#carousel-example-generic" data-slide-to="2"/>' + + '</ol>' + + '<div class="carousel-inner">' + + '<div class="item active" id="one">' + + '<div class="carousel-caption"/>' + + '</div>' + + '<div class="item" id="two">' + + '<div class="carousel-caption"/>' + + '</div>' + + '<div class="item" id="three">' + + '<div class="carousel-caption"/>' + + '</div>' + + '</div>' + + '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' + + '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' + + '</div>' + var $carousel = $(carouselHTML) + + stop() + + $carousel + .on('slid.bs.carousel', function () { + strictEqual($carousel.find('.item.active').attr('id'), 'three', 'carousel wrapped around and slid from 1st to 3rd slide') + start() + }) + .bootstrapCarousel('prev') + }) + + test('should stay at the end when the next method is called and wrap is false', function () { + var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="false">' + + '<ol class="carousel-indicators">' + + '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' + + '<li data-target="#carousel-example-generic" data-slide-to="1"/>' + + '<li data-target="#carousel-example-generic" data-slide-to="2"/>' + + '</ol>' + + '<div class="carousel-inner">' + + '<div class="item active" id="one">' + + '<div class="carousel-caption"/>' + + '</div>' + + '<div class="item" id="two">' + + '<div class="carousel-caption"/>' + + '</div>' + + '<div class="item" id="three">' + + '<div class="carousel-caption"/>' + + '</div>' + + '</div>' + + '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' + + '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' + + '</div>' + var $carousel = $(carouselHTML) + var getActiveId = function () { return $carousel.find('.item.active').attr('id') } + + stop() + + $carousel + .one('slid.bs.carousel', function () { + strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide') + $carousel + .one('slid.bs.carousel', function () { + strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide') + $carousel + .one('slid.bs.carousel', function () { + ok(false, 'carousel slid when it should not have slid') + }) + .bootstrapCarousel('next') + strictEqual(getActiveId(), 'three', 'carousel did not wrap around and stayed on 3rd slide') + start() + }) + .bootstrapCarousel('next') + }) + .bootstrapCarousel('next') + }) + + test('should stay at the start when the prev method is called and wrap is false', function () { + var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="false">' + + '<ol class="carousel-indicators">' + + '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' + + '<li data-target="#carousel-example-generic" data-slide-to="1"/>' + + '<li data-target="#carousel-example-generic" data-slide-to="2"/>' + + '</ol>' + + '<div class="carousel-inner">' + + '<div class="item active" id="one">' + + '<div class="carousel-caption"/>' + + '</div>' + + '<div class="item" id="two">' + + '<div class="carousel-caption"/>' + + '</div>' + + '<div class="item" id="three">' + + '<div class="carousel-caption"/>' + + '</div>' + + '</div>' + + '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' + + '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' + + '</div>' + var $carousel = $(carouselHTML) + + $carousel + .on('slid.bs.carousel', function () { + ok(false, 'carousel slid when it should not have slid') + }) + .bootstrapCarousel('prev') + strictEqual($carousel.find('.item.active').attr('id'), 'one', 'carousel did not wrap around and stayed on 1st slide') + }) }) diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index 335795fde..3cdf637ee 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -224,4 +224,45 @@ $(function () { $(document.body).click() }) + test('should ignore keyboard events within <input>s and <textarea>s', function () { + stop() + + var dropdownHTML = '<ul class="tabs">' + + '<li class="dropdown">' + + '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>' + + '<ul class="dropdown-menu" role="menu">' + + '<li><a href="#">Secondary link</a></li>' + + '<li><a href="#">Something else here</a></li>' + + '<li class="divider"/>' + + '<li><a href="#">Another link</a></li>' + + '<li><input type="text" id="input"></li>' + + '<li><textarea id="textarea"/></li>' + + '</ul>' + + '</li>' + + '</ul>' + var $dropdown = $(dropdownHTML) + .appendTo('#qunit-fixture') + .find('[data-toggle="dropdown"]') + .bootstrapDropdown() + + var $input = $('#input') + var $textarea = $('#textarea') + + $dropdown + .parent('.dropdown') + .on('shown.bs.dropdown', function () { + ok(true, 'shown was fired') + + $input.focus().trigger($.Event('keydown', { which: 38 })) + ok($(document.activeElement).is($input), 'input still focused') + + $textarea.focus().trigger($.Event('keydown', { which: 38 })) + ok($(document.activeElement).is($textarea), 'textarea still focused') + + start() + }) + + $dropdown.click() + }) + }) diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 4fbd91dc3..eb578c22a 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -4,7 +4,7 @@ $(function () { module('tooltip plugin') test('should be defined on jquery object', function () { - ok($(document.body).tooltip, 'popover method is defined') + ok($(document.body).tooltip, 'tooltip method is defined') }) module('tooltip', { diff --git a/js/tooltip.js b/js/tooltip.js index 68163c17a..cda147d9c 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: tooltip.js v3.3.0 + * Bootstrap: tooltip.js v3.3.1 * http://getbootstrap.com/javascript/#tooltip * Inspired by the original jQuery.tipsy by Jason Frame * ======================================================================== @@ -25,7 +25,7 @@ this.init('tooltip', element, options) } - Tooltip.VERSION = '3.3.0' + Tooltip.VERSION = '3.3.1' Tooltip.TRANSITION_DURATION = 150 diff --git a/js/transition.js b/js/transition.js index 81993834a..68c2bd60b 100644 --- a/js/transition.js +++ b/js/transition.js @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: transition.js v3.3.0 + * Bootstrap: transition.js v3.3.1 * http://getbootstrap.com/javascript/#transitions * ======================================================================== * Copyright 2011-2014 Twitter, Inc. |
