Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/bootstrap-carousel.js10
-rw-r--r--js/bootstrap-modal.js7
-rw-r--r--js/bootstrap-tooltip.js13
-rw-r--r--js/tests/unit/bootstrap-carousel.js21
-rw-r--r--js/tests/unit/bootstrap-tooltip.js8
5 files changed, 45 insertions, 14 deletions
diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js
index 0d7167e1c2..b533156526 100644
--- a/js/bootstrap-carousel.js
+++ b/js/bootstrap-carousel.js
@@ -94,9 +94,7 @@
, direction = type == 'next' ? 'left' : 'right'
, fallback = type == 'next' ? 'first' : 'last'
, that = this
- , e = $.Event('slide', {
- relatedTarget: $next[0]
- })
+ , e
this.sliding = true
@@ -104,6 +102,10 @@
$next = $next.length ? $next : this.$element.find('.item')[fallback]()
+ e = $.Event('slide', {
+ relatedTarget: $next[0]
+ })
+
if ($next.hasClass('active')) return
if ($.support.transition && this.$element.hasClass('slide')) {
@@ -167,7 +169,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/bootstrap-modal.js b/js/bootstrap-modal.js
index d53f13a00c..d2a4878b3d 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);
diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js
index 14e48c856b..a547b8a30e 100644
--- a/js/bootstrap-tooltip.js
+++ b/js/bootstrap-tooltip.js
@@ -119,7 +119,7 @@
inside = /in/.test(placement)
$tip
- .remove()
+ .detach()
.css({ top: 0, left: 0, display: 'block' })
.insertAfter(this.$element)
@@ -166,18 +166,18 @@
function removeWithAnimation() {
var timeout = setTimeout(function () {
- $tip.off($.support.transition.end).remove()
+ $tip.off($.support.transition.end).detach()
}, 500)
$tip.one($.support.transition.end, function () {
clearTimeout(timeout)
- $tip.remove()
+ $tip.detach()
})
}
$.support.transition && this.$tip.hasClass('fade') ?
removeWithAnimation() :
- $tip.remove()
+ $tip.detach()
return this
}
@@ -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-carousel.js b/js/tests/unit/bootstrap-carousel.js
index 5ac9fb2d81..8bd1b62ba0 100644
--- a/js/tests/unit/bootstrap-carousel.js
+++ b/js/tests/unit/bootstrap-carousel.js
@@ -39,4 +39,25 @@ $(function () {
.carousel('next')
})
+ test("should set interval from data attribute", 3,function () {
+ var template = $('<div id="myCarousel" class="carousel slide"> <div class="carousel-inner"> <div class="item active"> <img alt=""> <div class="carousel-caption"> <h4>{{_i}}First Thumbnail label{{/i}}</h4> <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p> </div> </div> <div class="item"> <img alt=""> <div class="carousel-caption"> <h4>{{_i}}Second Thumbnail label{{/i}}</h4> <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p> </div> </div> <div class="item"> <img alt=""> <div class="carousel-caption"> <h4>{{_i}}Third Thumbnail label{{/i}}</h4> <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p> </div> </div> </div> <a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a> <a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a> </div>');
+ 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
diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js
index 964ba1ef26..bbdf3ce80f 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 = $('<div><a href="#" rel="tooltip" title="Another tooltip"></a></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