mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-13 17:14:04 +02:00
Merge remote-tracking branch 'bootstrap/3.0.0-wip' into 3.0.0-wip
Conflicts: js/bootstrap-collapse.js
This commit is contained in:
@@ -12,37 +12,36 @@
|
||||
<script src="vendor/qunit.js"></script>
|
||||
|
||||
<!-- phantomjs logging script-->
|
||||
<script src="unit/bootstrap-phantom.js"></script>
|
||||
<script src="unit/phantom.js"></script>
|
||||
|
||||
<!-- plugin sources -->
|
||||
<script src="../../js/bootstrap-transition.js"></script>
|
||||
<script src="../../js/bootstrap-alert.js"></script>
|
||||
<script src="../../js/bootstrap-button.js"></script>
|
||||
<script src="../../js/bootstrap-carousel.js"></script>
|
||||
<script src="../../js/bootstrap-collapse.js"></script>
|
||||
<script src="../../js/bootstrap-dropdown.js"></script>
|
||||
<script src="../../js/bootstrap-modal.js"></script>
|
||||
<script src="../../js/bootstrap-scrollspy.js"></script>
|
||||
<script src="../../js/bootstrap-tab.js"></script>
|
||||
<script src="../../js/bootstrap-tooltip.js"></script>
|
||||
<script src="../../js/bootstrap-popover.js"></script>
|
||||
<script src="../../js/bootstrap-typeahead.js"></script>
|
||||
<script src="../../js/bootstrap-affix.js"></script>
|
||||
<script src="../../js/transition.js"></script>
|
||||
<script src="../../js/alert.js"></script>
|
||||
<script src="../../js/button.js"></script>
|
||||
<script src="../../js/carousel.js"></script>
|
||||
<script src="../../js/collapse.js"></script>
|
||||
<script src="../../js/dropdown.js"></script>
|
||||
<script src="../../js/modal.js"></script>
|
||||
<script src="../../js/scrollspy.js"></script>
|
||||
<script src="../../js/tab.js"></script>
|
||||
<script src="../../js/tooltip.js"></script>
|
||||
<script src="../../js/popover.js"></script>
|
||||
<script src="../../js/affix.js"></script>
|
||||
|
||||
<!-- unit tests -->
|
||||
<script src="unit/bootstrap-transition.js"></script>
|
||||
<script src="unit/bootstrap-alert.js"></script>
|
||||
<script src="unit/bootstrap-button.js"></script>
|
||||
<script src="unit/bootstrap-carousel.js"></script>
|
||||
<script src="unit/bootstrap-collapse.js"></script>
|
||||
<script src="unit/bootstrap-dropdown.js"></script>
|
||||
<script src="unit/bootstrap-modal.js"></script>
|
||||
<script src="unit/bootstrap-scrollspy.js"></script>
|
||||
<script src="unit/bootstrap-tab.js"></script>
|
||||
<script src="unit/bootstrap-tooltip.js"></script>
|
||||
<script src="unit/bootstrap-popover.js"></script>
|
||||
<script src="unit/bootstrap-typeahead.js"></script>
|
||||
<script src="unit/bootstrap-affix.js"></script>
|
||||
<script src="unit/transition.js"></script>
|
||||
<script src="unit/alert.js"></script>
|
||||
<script src="unit/button.js"></script>
|
||||
<script src="unit/carousel.js"></script>
|
||||
<script src="unit/collapse.js"></script>
|
||||
<script src="unit/dropdown.js"></script>
|
||||
<script src="unit/modal.js"></script>
|
||||
<script src="unit/scrollspy.js"></script>
|
||||
<script src="unit/tab.js"></script>
|
||||
<script src="unit/tooltip.js"></script>
|
||||
<script src="unit/popover.js"></script>
|
||||
<script src="unit/affix.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-affix")
|
||||
module("affix")
|
||||
|
||||
test("should provide no conflict", function () {
|
||||
var affix = $.fn.affix.noConflict()
|
||||
@@ -18,7 +18,7 @@ $(function () {
|
||||
|
||||
test("should exit early if element is not visible", function () {
|
||||
var $affix = $('<div style="display: none"></div>').affix()
|
||||
$affix.data('affix').checkPosition()
|
||||
$affix.data('bs.affix').checkPosition()
|
||||
ok(!$affix.hasClass('affix'), 'affix class was not added')
|
||||
})
|
||||
|
@@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-alerts")
|
||||
module("alert")
|
||||
|
||||
test("should provide no conflict", function () {
|
||||
var alert = $.fn.alert.noConflict()
|
||||
@@ -48,12 +48,12 @@ $(function () {
|
||||
$.support.transition = false
|
||||
stop();
|
||||
$('<div class="alert"/>')
|
||||
.bind('close', function (e) {
|
||||
.on('close.bs.alert', function (e) {
|
||||
e.preventDefault();
|
||||
ok(true);
|
||||
start();
|
||||
})
|
||||
.bind('closed', function () {
|
||||
.on('closed.bs.alert', function () {
|
||||
ok(false);
|
||||
})
|
||||
.alert('close')
|
236
js/tests/unit/bootstrap-typeahead.js
vendored
236
js/tests/unit/bootstrap-typeahead.js
vendored
@@ -1,236 +0,0 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-typeahead")
|
||||
|
||||
test("should provide no conflict", function () {
|
||||
var typeahead = $.fn.typeahead.noConflict()
|
||||
ok(!$.fn.typeahead, 'typeahead was set back to undefined (org value)')
|
||||
$.fn.typeahead = typeahead
|
||||
})
|
||||
|
||||
test("should be defined on jquery object", function () {
|
||||
ok($(document.body).typeahead, 'alert method is defined')
|
||||
})
|
||||
|
||||
test("should return element", function () {
|
||||
ok($(document.body).typeahead()[0] == document.body, 'document.body returned')
|
||||
})
|
||||
|
||||
test("should listen to an input", function () {
|
||||
var $input = $('<input />')
|
||||
$input.typeahead()
|
||||
ok($._data($input[0], 'events').blur, 'has a blur event')
|
||||
ok($._data($input[0], 'events').keypress, 'has a keypress event')
|
||||
ok($._data($input[0], 'events').keyup, 'has a keyup event')
|
||||
})
|
||||
|
||||
test("should create a menu", function () {
|
||||
var $input = $('<input />')
|
||||
ok($input.typeahead().data('typeahead').$menu, 'has a menu')
|
||||
})
|
||||
|
||||
test("should listen to the menu", function () {
|
||||
var $input = $('<input />')
|
||||
, $menu = $input.typeahead().data('typeahead').$menu
|
||||
|
||||
ok($._data($menu[0], 'events').mouseover, 'has a mouseover(pseudo: mouseenter)')
|
||||
ok($._data($menu[0], 'events').click, 'has a click')
|
||||
})
|
||||
|
||||
test("should show menu when query entered", function () {
|
||||
var $input = $('<input />')
|
||||
.appendTo('body')
|
||||
.typeahead({
|
||||
source: ['aa', 'ab', 'ac']
|
||||
})
|
||||
, typeahead = $input.data('typeahead')
|
||||
|
||||
$input.val('a')
|
||||
typeahead.lookup()
|
||||
|
||||
ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
|
||||
equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
|
||||
equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
|
||||
|
||||
$input.remove()
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
|
||||
test("should accept data source via synchronous function", function () {
|
||||
var $input = $('<input />').typeahead({
|
||||
source: function () {
|
||||
return ['aa', 'ab', 'ac']
|
||||
}
|
||||
}).appendTo('body')
|
||||
, typeahead = $input.data('typeahead')
|
||||
|
||||
$input.val('a')
|
||||
typeahead.lookup()
|
||||
|
||||
ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
|
||||
equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
|
||||
equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
|
||||
|
||||
$input.remove()
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
|
||||
test("should accept data source via asynchronous function", function () {
|
||||
var $input = $('<input />').typeahead({
|
||||
source: function (query, process) {
|
||||
process(['aa', 'ab', 'ac'])
|
||||
}
|
||||
}).appendTo('body')
|
||||
, typeahead = $input.data('typeahead')
|
||||
|
||||
$input.val('a')
|
||||
typeahead.lookup()
|
||||
|
||||
ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
|
||||
equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
|
||||
equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
|
||||
|
||||
$input.remove()
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
|
||||
test("should not explode when regex chars are entered", function () {
|
||||
var $input = $('<input />').typeahead({
|
||||
source: ['aa', 'ab', 'ac', 'mdo*', 'fat+']
|
||||
}).appendTo('body')
|
||||
, typeahead = $input.data('typeahead')
|
||||
|
||||
$input.val('+')
|
||||
typeahead.lookup()
|
||||
|
||||
ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
|
||||
equals(typeahead.$menu.find('li').length, 1, 'has 1 item in menu')
|
||||
equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
|
||||
|
||||
$input.remove()
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
|
||||
test("should hide menu when query entered", function () {
|
||||
stop()
|
||||
var $input = $('<input />').typeahead({
|
||||
source: ['aa', 'ab', 'ac']
|
||||
}).appendTo('body')
|
||||
, typeahead = $input.data('typeahead')
|
||||
|
||||
$input.val('a')
|
||||
typeahead.lookup()
|
||||
|
||||
ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
|
||||
equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
|
||||
equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
|
||||
|
||||
$input.blur()
|
||||
|
||||
setTimeout(function () {
|
||||
ok(!typeahead.$menu.is(":visible"), "typeahead is no longer visible")
|
||||
start()
|
||||
}, 200)
|
||||
|
||||
$input.remove()
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
|
||||
test("should set next item when down arrow is pressed", function () {
|
||||
var $input = $('<input />').typeahead({
|
||||
source: ['aa', 'ab', 'ac']
|
||||
}).appendTo('body')
|
||||
, typeahead = $input.data('typeahead')
|
||||
|
||||
$input.val('a')
|
||||
typeahead.lookup()
|
||||
|
||||
ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
|
||||
equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
|
||||
equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
|
||||
ok(typeahead.$menu.find('li').first().hasClass('active'), "first item is active")
|
||||
|
||||
// simulate entire key pressing event
|
||||
$input.trigger({
|
||||
type: 'keydown'
|
||||
, keyCode: 40
|
||||
})
|
||||
.trigger({
|
||||
type: 'keypress'
|
||||
, keyCode: 40
|
||||
})
|
||||
.trigger({
|
||||
type: 'keyup'
|
||||
, keyCode: 40
|
||||
})
|
||||
|
||||
ok(typeahead.$menu.find('li').first().next().hasClass('active'), "second item is active")
|
||||
|
||||
$input.trigger({
|
||||
type: 'keydown'
|
||||
, keyCode: 38
|
||||
})
|
||||
.trigger({
|
||||
type: 'keypress'
|
||||
, keyCode: 38
|
||||
})
|
||||
.trigger({
|
||||
type: 'keyup'
|
||||
, keyCode: 38
|
||||
})
|
||||
|
||||
ok(typeahead.$menu.find('li').first().hasClass('active'), "first item is active")
|
||||
|
||||
$input.remove()
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
|
||||
|
||||
test("should set input value to selected item", function () {
|
||||
var $input = $('<input />').typeahead({
|
||||
source: ['aa', 'ab', 'ac']
|
||||
}).appendTo('body')
|
||||
, typeahead = $input.data('typeahead')
|
||||
, changed = false
|
||||
, focus = false
|
||||
, blur = false
|
||||
|
||||
$input.val('a')
|
||||
typeahead.lookup()
|
||||
|
||||
$input.change(function() { changed = true });
|
||||
$input.focus(function() { focus = true; blur = false });
|
||||
$input.blur(function() { blur = true; focus = false });
|
||||
|
||||
$(typeahead.$menu.find('li')[2]).mouseover().click()
|
||||
|
||||
equals($input.val(), 'ac', 'input value was correctly set')
|
||||
ok(!typeahead.$menu.is(':visible'), 'the menu was hidden')
|
||||
ok(changed, 'a change event was fired')
|
||||
ok(focus && !blur, 'focus is still set')
|
||||
|
||||
$input.remove()
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
|
||||
test("should start querying when minLength is met", function () {
|
||||
var $input = $('<input />').typeahead({
|
||||
source: ['aaaa', 'aaab', 'aaac'],
|
||||
minLength: 3
|
||||
}).appendTo('body')
|
||||
, typeahead = $input.data('typeahead')
|
||||
|
||||
$input.val('aa')
|
||||
typeahead.lookup()
|
||||
|
||||
equals(typeahead.$menu.find('li').length, 0, 'has 0 items in menu')
|
||||
|
||||
$input.val('aaa')
|
||||
typeahead.lookup()
|
||||
|
||||
equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
|
||||
|
||||
$input.remove()
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
})
|
@@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-buttons")
|
||||
module("button")
|
||||
|
||||
test("should provide no conflict", function () {
|
||||
var button = $.fn.button.noConflict()
|
@@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-carousel")
|
||||
module("carousel")
|
||||
|
||||
test("should provide no conflict", function () {
|
||||
var carousel = $.fn.carousel.noConflict()
|
||||
@@ -20,12 +20,12 @@ $(function () {
|
||||
$.support.transition = false
|
||||
stop()
|
||||
$('<div class="carousel"/>')
|
||||
.bind('slide', function (e) {
|
||||
.on('slide.bs.carousel', function (e) {
|
||||
e.preventDefault();
|
||||
ok(true);
|
||||
start();
|
||||
})
|
||||
.bind('slid', function () {
|
||||
.on('slid.bs.carousel', function () {
|
||||
ok(false);
|
||||
})
|
||||
.carousel('next')
|
||||
@@ -35,7 +35,7 @@ $(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">‹</a><a class="right carousel-control" href="#myCarousel" data-slide="next">›</a></div>'
|
||||
$.support.transition = false
|
||||
stop()
|
||||
$(template).on('slide', function (e) {
|
||||
$(template).on('slide.bs.carousel', function (e) {
|
||||
e.preventDefault()
|
||||
ok(e.direction)
|
||||
ok(e.direction === 'right' || e.direction === 'left')
|
||||
@@ -48,7 +48,7 @@ $(function () {
|
||||
$.support.transition = false
|
||||
stop()
|
||||
$(template)
|
||||
.on('slide', function (e) {
|
||||
.on('slide.bs.carousel', function (e) {
|
||||
e.preventDefault();
|
||||
ok(e.relatedTarget);
|
||||
ok($(e.relatedTarget).hasClass('item'));
|
||||
@@ -63,19 +63,19 @@ $(function () {
|
||||
|
||||
template.appendTo("body");
|
||||
$('[data-slide]').first().click();
|
||||
ok($('#myCarousel').data('carousel').options.interval == 1814);
|
||||
ok($('#myCarousel').data('bs.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");
|
||||
ok($('#myCarousel').data('bs.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");
|
||||
ok($('#myCarousel').data('bs.carousel').options.interval == 1814, "attributes should be read only on intitialization");
|
||||
$('#myCarousel').remove();
|
||||
})
|
||||
})
|
@@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-collapse")
|
||||
module("collapse")
|
||||
|
||||
test("should provide no conflict", function () {
|
||||
var collapse = $.fn.collapse.noConflict()
|
||||
@@ -32,12 +32,12 @@ $(function () {
|
||||
$.support.transition = false
|
||||
stop()
|
||||
$('<div class="collapse"/>')
|
||||
.bind('show', function (e) {
|
||||
.on('show.bs.collapse', function (e) {
|
||||
e.preventDefault();
|
||||
ok(true);
|
||||
start();
|
||||
})
|
||||
.bind('shown', function () {
|
||||
.on('shown.bs.collapse', function () {
|
||||
ok(false);
|
||||
})
|
||||
.collapse('show')
|
||||
@@ -47,10 +47,10 @@ $(function () {
|
||||
$.support.transition = false
|
||||
stop()
|
||||
$('<div class="collapse" style="height: 0px"/>')
|
||||
.bind('show', function () {
|
||||
.on('show.bs.collapse', function () {
|
||||
ok(this.style.height == '0px')
|
||||
})
|
||||
.bind('shown', function () {
|
||||
.on('shown.bs.collapse', function () {
|
||||
ok(this.style.height == 'auto')
|
||||
start()
|
||||
})
|
||||
@@ -66,7 +66,7 @@ $(function () {
|
||||
|
||||
var collapsible = $('<div id="test1"></div>')
|
||||
.appendTo($('#qunit-fixture'))
|
||||
.on('show', function () {
|
||||
.on('show.bs.collapse', function () {
|
||||
ok(!target.hasClass('collapsed'))
|
||||
start()
|
||||
})
|
||||
@@ -83,7 +83,7 @@ $(function () {
|
||||
|
||||
var collapsible = $('<div id="test1" class="in"></div>')
|
||||
.appendTo($('#qunit-fixture'))
|
||||
.on('hide', function () {
|
||||
.on('hide.bs.collapse', function () {
|
||||
ok(target.hasClass('collapsed'))
|
||||
start()
|
||||
})
|
||||
@@ -115,7 +115,7 @@ $(function () {
|
||||
|
||||
var collapsible3 = $('<div id="body3"></div>')
|
||||
.appendTo(accordion.find('.accordion-group').eq(2))
|
||||
.on('show', function () {
|
||||
.on('show.bs.collapse', function () {
|
||||
ok(target1.hasClass('collapsed'))
|
||||
ok(target2.hasClass('collapsed'))
|
||||
ok(!target3.hasClass('collapsed'))
|
||||
@@ -126,4 +126,4 @@ $(function () {
|
||||
target3.click()
|
||||
})
|
||||
|
||||
})
|
||||
})
|
@@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-dropdowns")
|
||||
module("dropdowns")
|
||||
|
||||
test("should provide no conflict", function () {
|
||||
var dropdown = $.fn.dropdown.noConflict()
|
||||
@@ -103,6 +103,7 @@ $(function () {
|
||||
.find('[data-toggle="dropdown"]')
|
||||
.dropdown()
|
||||
.click()
|
||||
|
||||
ok(dropdown.parent('.dropdown').hasClass('open'), 'open class added on click')
|
||||
$('body').click()
|
||||
ok(!dropdown.parent('.dropdown').hasClass('open'), 'open class removed')
|
||||
@@ -148,4 +149,71 @@ $(function () {
|
||||
$("#qunit-fixture").html("")
|
||||
})
|
||||
|
||||
test("should fire show and hide event", function () {
|
||||
var dropdownHTML = '<ul class="tabs">'
|
||||
+ '<li class="dropdown">'
|
||||
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
|
||||
+ '<ul class="dropdown-menu">'
|
||||
+ '<li><a href="#">Secondary link</a></li>'
|
||||
+ '<li><a href="#">Something else here</a></li>'
|
||||
+ '<li class="divider"></li>'
|
||||
+ '<li><a href="#">Another link</a></li>'
|
||||
+ '</ul>'
|
||||
+ '</li>'
|
||||
+ '</ul>'
|
||||
, dropdown = $(dropdownHTML)
|
||||
.appendTo('#qunit-fixture')
|
||||
.find('[data-toggle="dropdown"]')
|
||||
.dropdown()
|
||||
|
||||
stop()
|
||||
|
||||
dropdown
|
||||
.parent('.dropdown')
|
||||
.bind('show.bs.dropdown', function () {
|
||||
ok(true, 'show was called')
|
||||
})
|
||||
.bind('hide.bs.dropdown', function () {
|
||||
ok(true, 'hide was called')
|
||||
start()
|
||||
})
|
||||
|
||||
dropdown.click()
|
||||
$(document.body).click()
|
||||
})
|
||||
|
||||
|
||||
test("should fire shown and hiden event", function () {
|
||||
var dropdownHTML = '<ul class="tabs">'
|
||||
+ '<li class="dropdown">'
|
||||
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
|
||||
+ '<ul class="dropdown-menu">'
|
||||
+ '<li><a href="#">Secondary link</a></li>'
|
||||
+ '<li><a href="#">Something else here</a></li>'
|
||||
+ '<li class="divider"></li>'
|
||||
+ '<li><a href="#">Another link</a></li>'
|
||||
+ '</ul>'
|
||||
+ '</li>'
|
||||
+ '</ul>'
|
||||
, dropdown = $(dropdownHTML)
|
||||
.appendTo('#qunit-fixture')
|
||||
.find('[data-toggle="dropdown"]')
|
||||
.dropdown()
|
||||
|
||||
stop()
|
||||
|
||||
dropdown
|
||||
.parent('.dropdown')
|
||||
.bind('shown.bs.dropdown', function () {
|
||||
ok(true, 'show was called')
|
||||
})
|
||||
.bind('hidden.bs.dropdown', function () {
|
||||
ok(true, 'hide was called')
|
||||
start()
|
||||
})
|
||||
|
||||
dropdown.click()
|
||||
$(document.body).click()
|
||||
})
|
||||
|
||||
})
|
@@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-modal")
|
||||
module("modal")
|
||||
|
||||
test("should provide no conflict", function () {
|
||||
var modal = $.fn.modal.noConflict()
|
||||
@@ -20,15 +20,15 @@ $(function () {
|
||||
})
|
||||
|
||||
test("should expose defaults var for settings", function () {
|
||||
ok($.fn.modal.defaults, 'default object exposed')
|
||||
ok($.fn.modal.Constructor.DEFAULTS, 'default object exposed')
|
||||
})
|
||||
|
||||
test("should insert into dom when show method is called", function () {
|
||||
stop()
|
||||
$.support.transition = false
|
||||
$("<div id='modal-test'></div>")
|
||||
.bind("shown", function () {
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
.on("shown.bs.modal", function () {
|
||||
ok($('#modal-test').length, 'modal inserted into dom')
|
||||
$(this).remove()
|
||||
start()
|
||||
})
|
||||
@@ -39,10 +39,10 @@ $(function () {
|
||||
stop()
|
||||
$.support.transition = false
|
||||
$("<div id='modal-test'></div>")
|
||||
.bind("show", function () {
|
||||
.on("show.bs.modal", function () {
|
||||
ok(true, "show was called")
|
||||
})
|
||||
.bind("shown", function () {
|
||||
.on("shown.bs.modal", function () {
|
||||
$(this).remove()
|
||||
start()
|
||||
})
|
||||
@@ -53,12 +53,12 @@ $(function () {
|
||||
stop()
|
||||
$.support.transition = false
|
||||
$("<div id='modal-test'></div>")
|
||||
.bind("show", function (e) {
|
||||
.on("show.bs.modal", function (e) {
|
||||
e.preventDefault()
|
||||
ok(true, "show was called")
|
||||
start()
|
||||
})
|
||||
.bind("shown", function () {
|
||||
.on("shown.bs.modal", function () {
|
||||
ok(false, "shown was called")
|
||||
})
|
||||
.modal("show")
|
||||
@@ -69,12 +69,12 @@ $(function () {
|
||||
$.support.transition = false
|
||||
|
||||
$("<div id='modal-test'></div>")
|
||||
.bind("shown", function () {
|
||||
.on("shown.bs.modal", function () {
|
||||
ok($('#modal-test').is(":visible"), 'modal visible')
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
ok($('#modal-test').length, 'modal inserted into dom')
|
||||
$(this).modal("hide")
|
||||
})
|
||||
.bind("hidden", function() {
|
||||
.on("hidden.bs.modal", function() {
|
||||
ok(!$('#modal-test').is(":visible"), 'modal hidden')
|
||||
$('#modal-test').remove()
|
||||
start()
|
||||
@@ -87,12 +87,12 @@ $(function () {
|
||||
$.support.transition = false
|
||||
var div = $("<div id='modal-test'></div>")
|
||||
div
|
||||
.bind("shown", function () {
|
||||
.on("shown.bs.modal", function () {
|
||||
ok($('#modal-test').is(":visible"), 'modal visible')
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
ok($('#modal-test').length, 'modal inserted into dom')
|
||||
div.modal("toggle")
|
||||
})
|
||||
.bind("hidden", function() {
|
||||
.on("hidden.bs.modal", function() {
|
||||
ok(!$('#modal-test').is(":visible"), 'modal hidden')
|
||||
div.remove()
|
||||
start()
|
||||
@@ -105,12 +105,12 @@ $(function () {
|
||||
$.support.transition = false
|
||||
var div = $("<div id='modal-test'><span class='close' data-dismiss='modal'></span></div>")
|
||||
div
|
||||
.bind("shown", function () {
|
||||
.on("shown.bs.modal", function () {
|
||||
ok($('#modal-test').is(":visible"), 'modal visible')
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
ok($('#modal-test').length, 'modal inserted into dom')
|
||||
div.find('.close').click()
|
||||
})
|
||||
.bind("hidden", function() {
|
||||
.on("hidden.bs.modal", function() {
|
||||
ok(!$('#modal-test').is(":visible"), 'modal hidden')
|
||||
div.remove()
|
||||
start()
|
||||
@@ -123,11 +123,11 @@ $(function () {
|
||||
$.support.transition = false
|
||||
var div = $("<div>", { id: 'modal-test', "data-backdrop": false })
|
||||
div
|
||||
.bind("shown", function () {
|
||||
.on("shown.bs.modal", function () {
|
||||
ok($('#modal-test').is(":visible"), 'modal visible')
|
||||
div.modal("hide")
|
||||
})
|
||||
.bind("hidden", function() {
|
||||
.on("hidden.bs.modal", function() {
|
||||
ok(!$('#modal-test').is(":visible"), 'modal hidden')
|
||||
div.remove()
|
||||
start()
|
@@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-popover")
|
||||
module("popover")
|
||||
|
||||
test("should provide no conflict", function () {
|
||||
var popover = $.fn.popover.noConflict()
|
||||
@@ -34,7 +34,7 @@ $(function () {
|
||||
var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
|
||||
.popover()
|
||||
|
||||
ok(!!popover.data('popover'), 'popover instance exists')
|
||||
ok(!!popover.data('bs.popover'), 'popover instance exists')
|
||||
})
|
||||
|
||||
test("should get title and content from options", function () {
|
||||
@@ -99,7 +99,7 @@ $(function () {
|
||||
|
||||
test("should destroy popover", function () {
|
||||
var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function(){})
|
||||
ok(popover.data('popover'), 'popover has data')
|
||||
ok(popover.data('bs.popover'), 'popover has data')
|
||||
ok($._data(popover[0], 'events').mouseover && $._data(popover[0], 'events').mouseout, 'popover has hover event')
|
||||
ok($._data(popover[0], 'events').click[0].namespace == 'foo', 'popover has extra click.foo event')
|
||||
popover.popover('show')
|
@@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-scrollspy")
|
||||
module("scrollspy")
|
||||
|
||||
test("should provide no conflict", function () {
|
||||
var scrollspy = $.fn.scrollspy.noConflict()
|
@@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-tabs")
|
||||
module("tabs")
|
||||
|
||||
test("should provide no conflict", function () {
|
||||
var tab = $.fn.tab.noConflict()
|
||||
@@ -53,12 +53,12 @@ $(function () {
|
||||
$.support.transition = false
|
||||
stop();
|
||||
$('<div class="tab"/>')
|
||||
.bind('show', function (e) {
|
||||
.on('show.bs.tab', function (e) {
|
||||
e.preventDefault();
|
||||
ok(true);
|
||||
start();
|
||||
})
|
||||
.bind('shown', function () {
|
||||
.on('shown.bs.tab', function () {
|
||||
ok(false);
|
||||
})
|
||||
.tab('show')
|
@@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-tooltip")
|
||||
module("tooltip")
|
||||
|
||||
test("should provide no conflict", function () {
|
||||
var tooltip = $.fn.tooltip.noConflict()
|
||||
@@ -19,7 +19,7 @@ $(function () {
|
||||
})
|
||||
|
||||
test("should expose default settings", function () {
|
||||
ok(!!$.fn.tooltip.defaults, 'defaults is defined')
|
||||
ok(!!$.fn.tooltip.Constructor.DEFAULTS, 'defaults is defined')
|
||||
})
|
||||
|
||||
test("should empty title attribute", function () {
|
||||
@@ -69,7 +69,7 @@ $(function () {
|
||||
test("should fire show event", function () {
|
||||
stop()
|
||||
var tooltip = $('<div title="tooltip title"></div>')
|
||||
.bind("show", function() {
|
||||
.on("show.bs.tooltip", function() {
|
||||
ok(true, "show was called")
|
||||
start()
|
||||
})
|
||||
@@ -79,7 +79,7 @@ $(function () {
|
||||
test("should fire shown event", function () {
|
||||
stop()
|
||||
var tooltip = $('<div title="tooltip title"></div>')
|
||||
.bind("shown", function() {
|
||||
.on("shown.bs.tooltip", function() {
|
||||
ok(true, "shown was called")
|
||||
start()
|
||||
})
|
||||
@@ -89,12 +89,12 @@ $(function () {
|
||||
test("should not fire shown event when default prevented", function () {
|
||||
stop()
|
||||
var tooltip = $('<div title="tooltip title"></div>')
|
||||
.bind("show", function(e) {
|
||||
.on("show.bs.tooltip", function(e) {
|
||||
e.preventDefault()
|
||||
ok(true, "show was called")
|
||||
start()
|
||||
})
|
||||
.bind("shown", function() {
|
||||
.on("shown.bs.tooltip", function() {
|
||||
ok(false, "shown was called")
|
||||
})
|
||||
.tooltip('show')
|
||||
@@ -103,10 +103,10 @@ $(function () {
|
||||
test("should fire hide event", function () {
|
||||
stop()
|
||||
var tooltip = $('<div title="tooltip title"></div>')
|
||||
.bind("shown", function() {
|
||||
.on("shown.bs.tooltip", function() {
|
||||
$(this).tooltip('hide')
|
||||
})
|
||||
.bind("hide", function() {
|
||||
.on("hide.bs.tooltip", function() {
|
||||
ok(true, "hide was called")
|
||||
start()
|
||||
})
|
||||
@@ -116,10 +116,10 @@ $(function () {
|
||||
test("should fire hidden event", function () {
|
||||
stop()
|
||||
var tooltip = $('<div title="tooltip title"></div>')
|
||||
.bind("shown", function() {
|
||||
.on("shown.bs.tooltip", function() {
|
||||
$(this).tooltip('hide')
|
||||
})
|
||||
.bind("hidden", function() {
|
||||
.on("hidden.bs.tooltip", function() {
|
||||
ok(true, "hidden was called")
|
||||
start()
|
||||
})
|
||||
@@ -129,15 +129,15 @@ $(function () {
|
||||
test("should not fire hidden event when default prevented", function () {
|
||||
stop()
|
||||
var tooltip = $('<div title="tooltip title"></div>')
|
||||
.bind("shown", function() {
|
||||
.on("shown.bs.tooltip", function() {
|
||||
$(this).tooltip('hide')
|
||||
})
|
||||
.bind("hide", function(e) {
|
||||
.on("hide.bs.tooltip", function(e) {
|
||||
e.preventDefault()
|
||||
ok(true, "hide was called")
|
||||
start()
|
||||
})
|
||||
.bind("hidden", function() {
|
||||
.on("hidden.bs.tooltip", function() {
|
||||
ok(false, "hidden was called")
|
||||
})
|
||||
.tooltip('show')
|
||||
@@ -214,13 +214,13 @@ $(function () {
|
||||
|
||||
test("should destroy tooltip", function () {
|
||||
var tooltip = $('<div/>').tooltip().on('click.foo', function(){})
|
||||
ok(tooltip.data('tooltip'), 'tooltip has data')
|
||||
ok(tooltip.data('bs.tooltip'), 'tooltip has data')
|
||||
ok($._data(tooltip[0], 'events').mouseover && $._data(tooltip[0], 'events').mouseout, 'tooltip has hover event')
|
||||
ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip has extra click.foo event')
|
||||
tooltip.tooltip('show')
|
||||
tooltip.tooltip('destroy')
|
||||
ok(!tooltip.hasClass('in'), 'tooltip is hidden')
|
||||
ok(!$._data(tooltip[0], 'tooltip'), 'tooltip does not have data')
|
||||
ok(!$._data(tooltip[0], 'bs.tooltip'), 'tooltip does not have data')
|
||||
ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip still has click.foo')
|
||||
ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events')
|
||||
})
|
@@ -1,6 +1,6 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-transition")
|
||||
module("transition")
|
||||
|
||||
test("should be defined on jquery support object", function () {
|
||||
ok($.support.transition !== undefined, 'transition object is defined')
|
Reference in New Issue
Block a user