Skip to content

Commit

Permalink
JS update
Browse files Browse the repository at this point in the history
  • Loading branch information
Lesz committed Mar 8, 2022
1 parent 798e436 commit 3ec7cbf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var modal = null

function showModal(modalId) {
modal = (modalId)
$("#" + modal).show()
}

$("[data-modalopen]").click(function () {
showModal($(this).data("modalopen"))
return false;
})

$(window).click(function (event) {
if (modal != null && $(event.target).is("#" + modal)) {
$("#" + modal).hide()
modal = null
}
})

$("[data-modalclose]").click(function () {
$("#" + modal).hide()
modal = null
})
3 changes: 2 additions & 1 deletion src/components/dialog/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ intro: A dialog (also called a modal window or lightbox) is a web page element t
---
<h3>Button below will trigger a dialog</h3>
<a data-modalopen="alpha-modal" class="nsw-button nsw-button--dark">Open dialog</a>
<div id="alpha-modal" class="nsw-modal">

<div id="alpha-modal" class="nsw-modal" style="display: none;">
<div class="nsw-modal_dialog" role="dialog" aria-labelledby="alpha-modal_label" aria-modal="true">
<div class="nsw-modal_content">
<button class="nsw-icon-button nsw-modal_close" type="button" aria-expanded="true">
Expand Down

0 comments on commit 3ec7cbf

Please sign in to comment.