Skip to content

Commit

Permalink
Revert "Remove functions used once."
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Dec 9, 2021
1 parent 9d6c47f commit fb65af9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
15 changes: 9 additions & 6 deletions js/src/offcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,7 @@ class Offcanvas extends BaseComponent {
this._isShown = false
this._backdrop = this._initializeBackDrop()
this._focustrap = this._initializeFocusTrap()

EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
if (this._config.keyboard && event.key === ESCAPE_KEY) {
this.hide()
}
})
this._addEventListeners()
}

// Getters
Expand Down Expand Up @@ -193,6 +188,14 @@ class Offcanvas extends BaseComponent {
})
}

_addEventListeners() {
EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
if (this._config.keyboard && event.key === ESCAPE_KEY) {
this.hide()
}
})
}

// Static
static jQueryInterface(config) {
return this.each(function () {
Expand Down
13 changes: 8 additions & 5 deletions js/src/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ class Toast extends BaseComponent {
this._timeout = null
this._hasMouseInteraction = false
this._hasKeyboardInteraction = false

EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true))
EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false))
EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true))
EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false))
this._setListeners()
}

// Getters
Expand Down Expand Up @@ -193,6 +189,13 @@ class Toast extends BaseComponent {
this._maybeScheduleHide()
}

_setListeners() {
EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true))
EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false))
EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true))
EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false))
}

_clearTimeout() {
clearTimeout(this._timeout)
this._timeout = null
Expand Down

0 comments on commit fb65af9

Please sign in to comment.