Skip to content

Commit 97bbdb9

Browse files
committed
Update utils.js
1 parent 2602c4f commit 97bbdb9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

utils.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ const body = document.body,
6060
learnClose = learnWrapper.querySelector('.close'),
6161

6262
branchMenu = document.querySelector('.branch-menu'),
63+
64+
dialog = document.querySelector('.dialog'),
65+
dialogHeader = dialog.querySelector('.header'),
66+
dialogCancel = dialog.querySelector('.cancel'),
67+
dialogConfirm = dialog.querySelector('.confirm'),
6368

6469
messageEl = document.querySelector('.message'),
6570

@@ -142,7 +147,9 @@ function showMessage(message, duration) {
142147
}
143148

144149

150+
145151
// show dialog
152+
146153
function showDialog(confirmHandler, headerText, confirmText) {
147154

148155
// add dialog text to HTML
@@ -152,11 +159,19 @@ function showDialog(confirmHandler, headerText, confirmText) {
152159
// show dialog
153160
dialogWrapper.classList.add('visible');
154161

155-
// add confirm button click listener
162+
// add confirm button listener
156163
dialogConfirm.onclick = confirmHandler;
157164

158165
}
159166

167+
// add cancel button listener
168+
dialogCancel.addEventListener('click', () => {
169+
170+
// hide dialog
171+
dialogWrapper.classList.remove('visible');
172+
173+
});
174+
160175

161176

162177
// device and platform queries

0 commit comments

Comments
 (0)