mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-08 17:22:31 +03:00
#11464 - Fix JS noConflict mode - Refactor all plugins to use an internal reference to the jQuery plugin, because in noConflict mode you can never expect to be defined on the jQuery object
This commit is contained in:
+32
-23
@@ -1,26 +1,35 @@
|
||||
$(function () {
|
||||
|
||||
module('modal')
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
var modal = $.fn.modal.noConflict()
|
||||
ok(!$.fn.modal, 'modal was set back to undefined (org value)')
|
||||
$.fn.modal = modal
|
||||
})
|
||||
module('modal plugin')
|
||||
|
||||
test('should be defined on jquery object', function () {
|
||||
var div = $('<div id="modal-test"></div>')
|
||||
ok(div.modal, 'modal method is defined')
|
||||
})
|
||||
|
||||
module('modal', {
|
||||
setup: function() {
|
||||
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
|
||||
$.fn.bootstrapModal = $.fn.modal.noConflict()
|
||||
},
|
||||
teardown: function() {
|
||||
$.fn.modal = $.fn.bootstrapModal
|
||||
delete $.fn.bootstrapModal
|
||||
}
|
||||
})
|
||||
|
||||
test('should provide no conflict', function () {
|
||||
ok(!$.fn.modal, 'modal was set back to undefined (org value)')
|
||||
})
|
||||
|
||||
test('should return element', function () {
|
||||
var div = $('<div id="modal-test"></div>')
|
||||
ok(div.modal() == div, 'document.body returned')
|
||||
ok(div.bootstrapModal() == div, 'document.body returned')
|
||||
$('#modal-test').remove()
|
||||
})
|
||||
|
||||
test('should expose defaults var for settings', function () {
|
||||
ok($.fn.modal.Constructor.DEFAULTS, 'default object exposed')
|
||||
ok($.fn.bootstrapModal.Constructor.DEFAULTS, 'default object exposed')
|
||||
})
|
||||
|
||||
test('should insert into dom when show method is called', function () {
|
||||
@@ -32,7 +41,7 @@ $(function () {
|
||||
$(this).remove()
|
||||
start()
|
||||
})
|
||||
.modal('show')
|
||||
.bootstrapModal('show')
|
||||
})
|
||||
|
||||
test('should fire show event', function () {
|
||||
@@ -46,7 +55,7 @@ $(function () {
|
||||
$(this).remove()
|
||||
start()
|
||||
})
|
||||
.modal('show')
|
||||
.bootstrapModal('show')
|
||||
})
|
||||
|
||||
test('should not fire shown when default prevented', function () {
|
||||
@@ -61,7 +70,7 @@ $(function () {
|
||||
.on('shown.bs.modal', function () {
|
||||
ok(false, 'shown was called')
|
||||
})
|
||||
.modal('show')
|
||||
.bootstrapModal('show')
|
||||
})
|
||||
|
||||
test('should hide modal when hide is called', function () {
|
||||
@@ -72,14 +81,14 @@ $(function () {
|
||||
.on('shown.bs.modal', function () {
|
||||
ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
ok($('#modal-test').length, 'modal inserted into dom')
|
||||
$(this).modal('hide')
|
||||
$(this).bootstrapModal('hide')
|
||||
})
|
||||
.on('hidden.bs.modal', function () {
|
||||
ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
$('#modal-test').remove()
|
||||
start()
|
||||
})
|
||||
.modal('show')
|
||||
.bootstrapModal('show')
|
||||
})
|
||||
|
||||
test('should toggle when toggle is called', function () {
|
||||
@@ -90,14 +99,14 @@ $(function () {
|
||||
.on('shown.bs.modal', function () {
|
||||
ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
ok($('#modal-test').length, 'modal inserted into dom')
|
||||
div.modal('toggle')
|
||||
div.bootstrapModal('toggle')
|
||||
})
|
||||
.on('hidden.bs.modal', function () {
|
||||
ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
div.remove()
|
||||
start()
|
||||
})
|
||||
.modal('toggle')
|
||||
.bootstrapModal('toggle')
|
||||
})
|
||||
|
||||
test('should remove from dom when click [data-dismiss="modal"]', function () {
|
||||
@@ -115,7 +124,7 @@ $(function () {
|
||||
div.remove()
|
||||
start()
|
||||
})
|
||||
.modal('toggle')
|
||||
.bootstrapModal('toggle')
|
||||
})
|
||||
|
||||
test('should allow modal close with "backdrop:false"', function () {
|
||||
@@ -125,14 +134,14 @@ $(function () {
|
||||
div
|
||||
.on('shown.bs.modal', function () {
|
||||
ok($('#modal-test').is(':visible'), 'modal visible')
|
||||
div.modal('hide')
|
||||
div.bootstrapModal('hide')
|
||||
})
|
||||
.on('hidden.bs.modal', function () {
|
||||
ok(!$('#modal-test').is(':visible'), 'modal hidden')
|
||||
div.remove()
|
||||
start()
|
||||
})
|
||||
.modal('show')
|
||||
.bootstrapModal('show')
|
||||
})
|
||||
|
||||
test('should close modal when clicking outside of modal-content', function () {
|
||||
@@ -151,7 +160,7 @@ $(function () {
|
||||
div.remove()
|
||||
start()
|
||||
})
|
||||
.modal('show')
|
||||
.bootstrapModal('show')
|
||||
})
|
||||
|
||||
test('should trigger hide event once when clicking outside of modal-content', function () {
|
||||
@@ -171,7 +180,7 @@ $(function () {
|
||||
ok(triggered === 1, 'modal hide triggered once')
|
||||
start()
|
||||
})
|
||||
.modal('show')
|
||||
.bootstrapModal('show')
|
||||
})
|
||||
|
||||
test('should close reopened modal with [data-dismiss="modal"] click', function () {
|
||||
@@ -186,9 +195,9 @@ $(function () {
|
||||
.one('hidden.bs.modal', function () {
|
||||
div.one('hidden.bs.modal', function () {
|
||||
start()
|
||||
}).modal('show')
|
||||
}).bootstrapModal('show')
|
||||
})
|
||||
.modal('show')
|
||||
.bootstrapModal('show')
|
||||
|
||||
div.remove()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user