mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-22 13:13:03 +02:00
rewrite toast plugin without jquery
This commit is contained in:
@@ -146,11 +146,11 @@ $(function () {
|
||||
.bootstrapToast()
|
||||
.appendTo($('#qunit-fixture'))
|
||||
|
||||
assert.ok(typeof $toast.data('bs.toast') !== 'undefined')
|
||||
assert.ok(typeof Toast._getInstance($toast[0]) !== 'undefined')
|
||||
|
||||
$toast.bootstrapToast('dispose')
|
||||
|
||||
assert.ok(typeof $toast.data('bs.toast') === 'undefined')
|
||||
assert.ok(Toast._getInstance($toast[0]) === null)
|
||||
})
|
||||
|
||||
QUnit.test('should allow to destroy toast and hide it before that', function (assert) {
|
||||
@@ -171,11 +171,11 @@ $(function () {
|
||||
$toast.one('shown.bs.toast', function () {
|
||||
setTimeout(function () {
|
||||
assert.ok($toast.hasClass('show'))
|
||||
assert.ok(typeof $toast.data('bs.toast') !== 'undefined')
|
||||
assert.ok(typeof Toast._getInstance($toast[0]) !== 'undefined')
|
||||
|
||||
$toast.bootstrapToast('dispose')
|
||||
|
||||
assert.ok(typeof $toast.data('bs.toast') === 'undefined')
|
||||
assert.ok(Toast._getInstance($toast[0]) === null)
|
||||
assert.ok($toast.hasClass('show') === false)
|
||||
|
||||
done()
|
||||
|
@@ -52,19 +52,34 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="../../dist/dom/polyfill.js"></script>
|
||||
<script src="../../dist/util.js"></script>
|
||||
<script src="../../dist/dom/manipulator.js"></script>
|
||||
<script src="../../dist/dom/data.js"></script>
|
||||
<script src="../../dist/dom/eventHandler.js"></script>
|
||||
<script src="../../dist/toast.js"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
$('.toast').toast()
|
||||
window.addEventListener('load', function () {
|
||||
Util.makeArray(document.querySelectorAll('.toast'))
|
||||
.forEach(function (toastNode) {
|
||||
new Toast(toastNode)
|
||||
})
|
||||
|
||||
$('#btnShowToast').on('click', function () {
|
||||
$('.toast').toast('show')
|
||||
})
|
||||
document.getElementById('btnShowToast').addEventListener('click', function () {
|
||||
Util.makeArray(document.querySelectorAll('.toast'))
|
||||
.forEach(function (toastNode) {
|
||||
var toast = Toast._getInstance(toastNode)
|
||||
toast.show()
|
||||
})
|
||||
})
|
||||
|
||||
$('#btnHideToast').on('click', function () {
|
||||
$('.toast').toast('hide')
|
||||
})
|
||||
document.getElementById('btnHideToast').addEventListener('click', function () {
|
||||
Util.makeArray(document.querySelectorAll('.toast'))
|
||||
.forEach(function (toastNode) {
|
||||
var toast = Toast._getInstance(toastNode)
|
||||
toast.hide()
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
Reference in New Issue
Block a user