-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12386 from craftcms/a11y/login-announcement
Announce "signing in" state on login screen
- Loading branch information
Showing
31 changed files
with
171 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/web/assets/craftsupport/dist/css/CraftSupportWidget.css.map
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import Garnish from './Garnish.js'; | ||
import Base from './Base.js'; | ||
import $ from 'jquery'; | ||
|
||
/** | ||
* Multi-Function Button | ||
*/ | ||
export default Base.extend( | ||
{ | ||
$btn: null, | ||
$btnLabel: null, | ||
$liveRegion: null, | ||
|
||
defaultMessage: null, | ||
busyMessage: null, | ||
failureMessage: null, | ||
retryMessage: null, | ||
successMessage: null, | ||
|
||
init: function (button, settings) { | ||
this.setSettings(settings, Garnish.MultiFunctionBtn.defaults); | ||
this.$btn = $(button); | ||
|
||
// Is this already a multi-function button? | ||
if (this.$btn.data('multifunction-btn')) { | ||
console.warn( | ||
'Double-instantiating a multi-function button on an element' | ||
); | ||
this.$btn.data('multifunction-btn').destroy(); | ||
} | ||
|
||
this.$btnLabel = this.$btn.find('.label'); | ||
this.defaultMessage = this.$btnLabel.text(); | ||
|
||
if (this.$btn.prev().attr('role') === 'status') { | ||
this.$liveRegion = this.$btn.prev(); | ||
} | ||
|
||
this.busyMessage = this.$btn.data('busy-message'); | ||
this.failureMessage = this.$btn.data('failure-message'); | ||
this.retryMessage = this.$btn.data('retry-message'); | ||
this.successMessage = this.$btn.data('success-message'); | ||
}, | ||
|
||
busyEvent: function () { | ||
this.$btn.addClass(this.settings.busyClass); | ||
|
||
if (this.busyMessage) { | ||
this.updateMessages(this.busyMessage, false); | ||
} | ||
}, | ||
|
||
failureEvent: function () { | ||
this.endBusyState(); | ||
|
||
if (!this.failureMessage && !this.retryMessage) return; | ||
|
||
if (this.failureMessage) { | ||
this.updateMessages(this.failureMessage); | ||
} | ||
|
||
if (this.retryMessage) { | ||
// If there was a failure message, ensure there's a delay before showing retry message | ||
if (this.failureMessage) { | ||
setTimeout(() => { | ||
this.updateMessages(this.retryMessage); | ||
}, this.settings.failureMessageDuration); | ||
} else { | ||
this.updateMessages(this.retryMessage); | ||
} | ||
} | ||
}, | ||
|
||
successEvent: function () { | ||
this.endBusyState(); | ||
|
||
if (this.successMessage) { | ||
this.updateMessages(this.successMessage); | ||
} | ||
}, | ||
|
||
updateMessages: function (message, updateLabel = true) { | ||
this.$liveRegion.text(message); | ||
|
||
if (updateLabel) { | ||
this.$btnLabel.text(message); | ||
} | ||
|
||
// Empty live region so a SR user navigating with virtual cursor doesn't find outdated message | ||
setTimeout(() => { | ||
// Bail out if there's now a different message in the live region | ||
if (this.$liveRegion.text() !== message) return; | ||
|
||
this.$liveRegion.empty(); | ||
}, this.settings.clearLiveRegionTimeout); | ||
}, | ||
|
||
endBusyState: function () { | ||
this.$btn.removeClass(this.settings.busyClass); | ||
}, | ||
|
||
destroy: function () { | ||
this.$btn.removeData('multifunction-btn'); | ||
this.base(); | ||
}, | ||
}, | ||
{ | ||
defaults: { | ||
busyClass: 'loading', | ||
clearLiveRegionTimeout: 2500, | ||
failureMessageDuration: 3000, | ||
}, | ||
} | ||
); |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.