-
Notifications
You must be signed in to change notification settings - Fork 46
Voiceover announcement and programmatic association to field #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
5616f44
930b2f4
c7e9425
5907c92
d1f8844
91080eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,14 @@ | |
base.init = function() { | ||
base.options = $.extend({}, $.textcounter.defaultOptions, options); | ||
|
||
var counterElementId = base.options.counterId ?? base.el.id + '_counter'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My only concern with setting it this way is if there are multiple instances on a page, with an empty ID, then this would create duplicate IDs. Perhaps something like jQuery UIs |
||
|
||
// append the count element | ||
var counterText = base.options.countDown ? base.options.countDownText : base.options.counterText, | ||
counterNum = base.options.countDown ? base.options.max : 0, | ||
$formatted_counter_text = $('<div/>').addClass(base.options.textCountMessageClass) | ||
.attr('aria-live', 'polite').attr('aria-atomic', 'true') | ||
.html(counterText.replace('%d', '<span class="' + base.options.textCountClass + '">' + counterNum + '</span>')), | ||
.attr('aria-live', 'polite').attr('aria-atomic', 'true').attr('id', counterElementId) | ||
.html(counterText.replace('%d', '<span class="' + base.options.textCountClass + '" role="text">' + counterNum + '</span>')), | ||
$count_overflow_text = $('<div/>').addClass(base.options.countOverflowContainerClass); | ||
|
||
base.hideMessage($count_overflow_text); | ||
|
@@ -39,6 +41,10 @@ | |
base.$text_counter = base.$container.find('span'); | ||
base.$el.after(base.$container); | ||
|
||
var curDescribedBy = base.$el.attr('aria-describedby') ?? ''; | ||
var describedByWithCount = (curDescribedBy + ' ' + counterElementId).trim(); | ||
base.$el.attr('aria-describedby', describedByWithCount); | ||
|
||
// bind input events | ||
base.$el.bind('keyup.textcounter click.textcounter blur.textcounter focus.textcounter change.textcounter paste.textcounter', base.checkLimits).trigger('click.textcounter'); | ||
|
||
|
@@ -340,6 +346,7 @@ | |
'countOverflowContainerClass' : "text-count-overflow-wrapper", // class applied to the count overflow wrapper | ||
'minDisplayCutoff' : -1, // maximum number of characters/words above the minimum to display a count | ||
'maxDisplayCutoff' : -1, // maximum number of characters/words below the maximum to display a count | ||
'counterId' : null, // custom ID for the counter element (e.g. to prevent conflicts). If one is not provided, a default ID will be assigned based on the ID of the element. | ||
|
||
// Callback API | ||
'maxunder' : function(el){}, // Callback: function(element) - Fires when counter under max limit | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.