From 6b017b9bea37629d0ee9bcd99e8e34b91aa3b5c0 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 15 Oct 2012 15:17:59 +0200 Subject: fixed reference to this.tip() so it works in delegate events --- js/bootstrap-tooltip.js | 5 +++-- js/tests/unit/bootstrap-tooltip.js | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 14e48c856..d5c2def29 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -235,8 +235,9 @@ this.enabled = !this.enabled } - , toggle: function () { - this[this.tip().hasClass('in') ? 'hide' : 'show']() + , toggle: function (e) { + var self = $(e.currentTarget)[this.type](this._options).data(this.type) + self[self.tip().hasClass('in') ? 'hide' : 'show']() } , destroy: function () { diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js index 964ba1ef2..bbdf3ce80 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -142,4 +142,12 @@ $(function () { ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events') }) + test("should show tooltip with delegate selector on click", function () { + var div = $('
') + var tooltip = div.appendTo('#qunit-fixture') + .tooltip({ selector: 'a[rel=tooltip]', + trigger: 'click' }) + div.find('a').trigger('click') + ok($(".tooltip").is('.fade.in'), 'tooltip is faded in') + }) }) \ No newline at end of file -- cgit v1.2.3 From 432eaff29cc05f488fc0a1c87d1e28d86ef3641e Mon Sep 17 00:00:00 2001 From: dmitriybudnik Date: Mon, 15 Oct 2012 21:55:32 +0300 Subject: Fixed copy/paste caused typo --- js/bootstrap-carousel.js | 2 +- js/tests/unit/bootstrap-carousel.js | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js index 0d7167e1c..0852cf3f4 100644 --- a/js/bootstrap-carousel.js +++ b/js/bootstrap-carousel.js @@ -167,7 +167,7 @@ $('body').on('click.carousel.data-api', '[data-slide]', function ( e ) { var $this = $(this), href , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 - , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data()) + , options = !$target.data('carousel') && $.extend({}, $target.data(), $this.data()) $target.carousel(options) e.preventDefault() }) diff --git a/js/tests/unit/bootstrap-carousel.js b/js/tests/unit/bootstrap-carousel.js index 5ac9fb2d8..fbcbb5b17 100644 --- a/js/tests/unit/bootstrap-carousel.js +++ b/js/tests/unit/bootstrap-carousel.js @@ -37,6 +37,26 @@ $(function () { start(); }) .carousel('next') - }) + test("should set interval from data attribute", function () { + var template = $(''); + template.attr("data-interval", 1814); + + template.appendTo("body"); + $('[data-slide]').first().click(); + ok($('#myCarousel').data('carousel').options.interval == 1814); + $('#myCarousel').remove(); + + template.appendTo("body").attr("data-modal", "foobar"); + $('[data-slide]').first().click(); + ok($('#myCarousel').data('carousel').options.interval == 1814, "even if there is an data-modal attribute set"); + $('#myCarousel').remove(); + + template.appendTo("body"); + $('[data-slide]').first().click(); + $('#myCarousel').attr('data-interval', 1860); + $('[data-slide]').first().click(); + ok($('#myCarousel').data('carousel').options.interval == 1814, "attributes should be read only on intitialization"); + $('#myCarousel').remove(); + }) }) \ No newline at end of file -- cgit v1.2.3 From cd5596393049e5c22f17f7f99764be1bfbc43ecc Mon Sep 17 00:00:00 2001 From: Dmitriy Budnik Date: Tue, 16 Oct 2012 09:49:01 +0300 Subject: fixed test --- js/tests/unit/bootstrap-carousel.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/tests/unit/bootstrap-carousel.js b/js/tests/unit/bootstrap-carousel.js index fbcbb5b17..97ea942de 100644 --- a/js/tests/unit/bootstrap-carousel.js +++ b/js/tests/unit/bootstrap-carousel.js @@ -37,11 +37,12 @@ $(function () { start(); }) .carousel('next') + }) test("should set interval from data attribute", function () { var template = $(''); template.attr("data-interval", 1814); - + template.appendTo("body"); $('[data-slide]').first().click(); ok($('#myCarousel').data('carousel').options.interval == 1814); @@ -51,7 +52,7 @@ $(function () { $('[data-slide]').first().click(); ok($('#myCarousel').data('carousel').options.interval == 1814, "even if there is an data-modal attribute set"); $('#myCarousel').remove(); - + template.appendTo("body"); $('[data-slide]').first().click(); $('#myCarousel').attr('data-interval', 1860); -- cgit v1.2.3 From ae0ba0686efcbf73116a21eb9aff3f9bede4a489 Mon Sep 17 00:00:00 2001 From: Dmitriy Budnik Date: Tue, 16 Oct 2012 11:16:38 +0300 Subject: set spesific assertions count for test --- js/tests/unit/bootstrap-carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/tests/unit/bootstrap-carousel.js b/js/tests/unit/bootstrap-carousel.js index 97ea942de..8bd1b62ba 100644 --- a/js/tests/unit/bootstrap-carousel.js +++ b/js/tests/unit/bootstrap-carousel.js @@ -39,7 +39,7 @@ $(function () { .carousel('next') }) - test("should set interval from data attribute", function () { + test("should set interval from data attribute", 3,function () { var template = $(''); template.attr("data-interval", 1814); -- cgit v1.2.3 From e24b46b7f3fb9eab5f34fb6e199d24781204c745 Mon Sep 17 00:00:00 2001 From: mfansler Date: Tue, 16 Oct 2012 12:27:43 -0400 Subject: fixes #5336: reorder focus() call to avoid scrolling --- js/bootstrap-modal.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/bootstrap-modal.js b/js/bootstrap-modal.js index d53f13a00..d2a4878b3 100644 --- a/js/bootstrap-modal.js +++ b/js/bootstrap-modal.js @@ -70,13 +70,12 @@ that.$element .addClass('in') .attr('aria-hidden', false) - .focus() that.enforceFocus() transition ? - that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) : - that.$element.trigger('shown') + that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) : + that.$element.focus().trigger('shown') }) } @@ -232,4 +231,4 @@ }) }) -}(window.jQuery); \ No newline at end of file +}(window.jQuery); -- cgit v1.2.3