diff options
| author | Johann-S <[email protected]> | 2018-06-17 23:09:04 +0200 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2019-02-20 22:05:45 +0200 |
| commit | 5dcca44fcfe3e4ae2820f4b8b115f006374985b3 (patch) | |
| tree | 5dcab9edb06fc7933c4cd9b8e7af62c5ba412126 /js/tests/visual/modal.html | |
| parent | 0b726de94e6a30612dcd227222afd3b61516dae0 (diff) | |
| download | bootstrap-5dcca44fcfe3e4ae2820f4b8b115f006374985b3.tar.xz bootstrap-5dcca44fcfe3e4ae2820f4b8b115f006374985b3.zip | |
fix(visual-test): remove jquery in them
Diffstat (limited to 'js/tests/visual/modal.html')
| -rw-r--r-- | js/tests/visual/modal.html | 88 |
1 files changed, 60 insertions, 28 deletions
diff --git a/js/tests/visual/modal.html b/js/tests/visual/modal.html index 2062a195b..1f0eb0d63 100644 --- a/js/tests/visual/modal.html +++ b/js/tests/visual/modal.html @@ -205,8 +205,8 @@ </button> </div> - <script src="../../../node_modules/jquery/dist/jquery.slim.min.js"></script> <script src="../../../node_modules/popper.js/dist/umd/popper.min.js"></script> + <script src="../../dist/dom/polyfill.js"></script> <script src="../../dist/dom/data.js"></script> <script src="../../dist/dom/eventHandler.js"></script> <script src="../../dist/dom/manipulator.js"></script> @@ -218,53 +218,85 @@ <script src="../../dist/popover.js"></script> <script> var firefoxTestDone = false - function reportFirefoxTestResult(result) { - if (!firefoxTestDone) { - $('#ff-bug-test-result') - .addClass(result ? 'text-success' : 'text-danger') - .text(result ? 'PASS' : 'FAIL') + document.addEventListener('DOMContentLoaded', function () { + var ffBugTestResult = document.getElementById('ff-bug-test-result') + + function reportFirefoxTestResult(result) { + if (!firefoxTestDone) { + ffBugTestResult.classList + .add(result ? 'text-success' : 'text-danger') + + ffBugTestResult.innerHTML = result ? 'PASS' : 'FAIL' + } } - } - $(function () { - $('[data-toggle="popover"]').popover() - $('[data-toggle="tooltip"]').tooltip() + document.querySelectorAll('[data-toggle="popover"]') + .forEach(function (popover) { + new Popover(popover) + }) - $('#tall-toggle').click(function () { - $('#tall').toggle() - }) + document.querySelectorAll('[data-toggle="tooltip"]') + .forEach(function (tooltip) { + new Tooltip(tooltip) + }) - $('#ff-bug-input').one('focus', function () { - $('#firefoxModal').on('focus', reportFirefoxTestResult.bind(false)) - $('#ff-bug-input').on('focus', reportFirefoxTestResult.bind(true)) + var tallToggle = document.getElementById('tall-toggle') + var tall = document.getElementById('tall') + tallToggle.addEventListener('click', function () { + if (tall.style.display === 'none') { + tall.style.display = 'block' + } else { + tall.style.display = 'none' + } }) - $('#btnPreventModal').on('click', function () { - $('#firefoxModal').one('shown.bs.modal', function () { - $(this).modal('hide') - }) - .one('hide.bs.modal', function (event) { + var ffBugInput = document.getElementById('ff-bug-input') + var firefoxModal = document.getElementById('firefoxModal') + function handlerClickFfBugInput() { + firefoxModal.addEventListener('focus', reportFirefoxTestResult.bind(false)) + ffBugInput.addEventListener('focus', reportFirefoxTestResult.bind(true)) + ffBugInput.removeEventListener('focus', handlerClickFfBugInput) + } + ffBugInput.addEventListener('focus', handlerClickFfBugInput) + + var btnPreventModal = document.getElementById('btnPreventModal') + var modalFf = new Modal(firefoxModal) + + btnPreventModal.addEventListener('click', function () { + function shownFirefoxModal() { + modalFf.hide() + firefoxModal.removeEventListener('shown.bs.modal', hideFirefoxModal) + } + + function hideFirefoxModal(event) { event.preventDefault() - if ($(this).data('bs.modal')._isTransitioning) { + firefoxModal.removeEventListener('hide.bs.modal', hideFirefoxModal) + + if (modalFf._isTransitioning) { console.error('Modal plugin should not set _isTransitioning when hide event is prevented') } else { console.log('Test passed') - $(this).modal('hide') // work as expected + modalFf.hide() // work as expected } - }) - .modal('show') + } + + firefoxModal.addEventListener('shown.bs.modal', shownFirefoxModal) + firefoxModal.addEventListener('hide.bs.modal', hideFirefoxModal) + modalFf.show() }) // Test transition duration var t0, t1; + var slowModal = document.getElementById('slowModal') - $('#slowModal').on('shown.bs.modal', function(){ + slowModal.addEventListener('shown.bs.modal', function () { t1 = performance.now() console.log('transition-duration took ' + (t1 - t0) + 'ms.') - }).on('show.bs.modal', function(){ - t0 = performance.now() }) + slowModal.addEventListener('show.bs.modal', function () { + t0 = performance.now() + }) }) </script> </body> |
