-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LOYALIST-20 Search results: add required feature w/ BS5+ally validity
- Loading branch information
Showing
4 changed files
with
36 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @file | ||
* Add required attribute on input elements of type 'search'. | ||
* Use built-in HTML5 form validation reporting and apply BS4 failure style on failure. | ||
*/ | ||
(function ($) { | ||
// Ensure required attribute present input of type 'search'. | ||
const search_input = 'input[type="search"]'; | ||
const required = $(search_input).attr('required'); | ||
if (typeof required === 'undefined' && required !== true) { | ||
$(search_input).attr('required', true); | ||
$(search_input).attr('required', true); | ||
} | ||
|
||
// If form validity check fails then apply BS5 invalid class. | ||
document.getElementById("edit-fulltext").addEventListener("invalid", | ||
function () { | ||
$(this).addClass('is-invalid').attr('aria-invalid', 'true'); | ||
} | ||
); | ||
|
||
})(jQuery); |
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,5 @@ | ||
search_input_required: | ||
js: | ||
js/search_input_required.js: {} | ||
dependencies: | ||
- core/jquery |
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