Skip to content

Commit

Permalink
filled in settext and gettext for notification class
Browse files Browse the repository at this point in the history
  • Loading branch information
FireLemons committed Sep 30, 2023
1 parent f39a333 commit cc5f3e5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/javascript/src/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Notification {
}

getText () {

return this.notificationElement.children('span').text()
}

isDismissable () {
Expand All @@ -28,8 +28,9 @@ class Notification {

}

setText () {

setText (newText) {
TypeChecker.checkString(newText)
return this.notificationElement.children('span').text(newText)
}

toggleDismissable () {
Expand Down Expand Up @@ -91,22 +92,23 @@ class Notifier {
}

const dismissButtonAsHTML = isDismissable ? `<button class="btn btn-${classSuffixDismissButton} btn-sm">×</button>` : ''
const newNotification =
const newNotificationAsJQuery =
$(
`<div class="${classPrefixMessage}-indicator">
<span>${escapedMessage}</span>
${dismissButtonAsHTML}
</div>`
)

this.notificationsElement.append(newNotification)
this.notificationsElement.append(newNotificationAsJQuery)

if (isDismissable) {
newNotification.children('button').on('click', function () {
newNotificationAsJQuery.children('button').on('click', function () {
$(this).parent().remove()
})
}

const newNotification = new Notification(newNotificationAsJQuery)
console.log(newNotification)
return newNotification
}
Expand Down

0 comments on commit cc5f3e5

Please sign in to comment.