From 934d1bcae588a278900018abb648242eb05328b3 Mon Sep 17 00:00:00 2001 From: Nathan Muir Date: Tue, 3 Sep 2013 12:23:51 +1000 Subject: Add unit test for #9920 Merges #10385 --- js/tests/unit/button.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'js') diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index 16284e0ce..115edefaf 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -111,6 +111,12 @@ $(function () { ok(!btn1.find('input').prop('checked'), 'btn1 is checked') ok(btn2.hasClass('active'), 'btn2 has active class') ok(btn2.find('input').prop('checked'), 'btn2 is checked') + + btn2.find('input').click() /* clicking an already checked radio should not un-check it */ + ok(!btn1.hasClass('active'), 'btn1 does not have active class') + ok(!btn1.find('input').prop('checked'), 'btn1 is checked') + ok(btn2.hasClass('active'), 'btn2 has active class') + ok(btn2.find('input').prop('checked'), 'btn2 is checked') }) }) -- cgit v1.2.3 From 5d6e9212a642430719702ead322103e19c6aa782 Mon Sep 17 00:00:00 2001 From: Brian Leonard Date: Sun, 1 Sep 2013 22:23:31 -0700 Subject: Don't deselect radio buttons in data-toggle; fixes #9920 Merges #10787 --- js/button.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/button.js b/js/button.js index 0145689dd..3c1613506 100644 --- a/js/button.js +++ b/js/button.js @@ -54,15 +54,21 @@ Button.prototype.toggle = function () { var $parent = this.$element.closest('[data-toggle="buttons"]') + var changed = true 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') { + // see if clicking on current one + 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') } -- cgit v1.2.3 From 7545da2e3c5488b1bcc9c70fecac759232466756 Mon Sep 17 00:00:00 2001 From: fat Date: Thu, 14 Nov 2013 23:58:29 -0800 Subject: fixes #11477 and updates slid event in carousel with namespace --- js/carousel.js | 8 ++++---- js/scrollspy.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/carousel.js b/js/carousel.js index 902d4d781..a31bb071f 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -69,7 +69,7 @@ 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])) @@ -121,7 +121,7 @@ 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') }) @@ -139,7 +139,7 @@ $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) } else { @@ -148,7 +148,7 @@ $active.removeClass('active') $next.addClass('active') this.sliding = false - this.$element.trigger('slid') + this.$element.trigger('slid.bs.carousel') } isCycling && this.cycle() diff --git a/js/scrollspy.js b/js/scrollspy.js index 1d2fc7859..b11ecdf29 100644 --- a/js/scrollspy.js +++ b/js/scrollspy.js @@ -113,7 +113,7 @@ .addClass('active') } - active.trigger('activate') + active.trigger('activate.bs.scrollspy') } -- cgit v1.2.3 From 56f6847ed60b5a8a15861a5db31676fe9901ff41 Mon Sep 17 00:00:00 2001 From: "Cina S." Date: Sat, 16 Nov 2013 09:43:47 -0600 Subject: Add missing data namespace for dropdown --- js/dropdown.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/dropdown.js b/js/dropdown.js index d5da638de..2bf65e5df 100644 --- a/js/dropdown.js +++ b/js/dropdown.js @@ -123,9 +123,9 @@ $.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) }) } -- cgit v1.2.3 From ad86d9a51bca001a52969d6cae65957023e30e9c Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Mon, 18 Nov 2013 11:55:33 +0200 Subject: Update dropdown.js --- js/dropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/dropdown.js b/js/dropdown.js index d5da638de..ecce5af78 100644 --- a/js/dropdown.js +++ b/js/dropdown.js @@ -41,7 +41,7 @@ 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 $('