Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
alt_text_validation
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
alt_text_validation
Merge requests
!6
Issue
#3497460
: Removes client side cruft.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3497460
: Removes client side cruft.
3497460-removes-clientside-cruft
into
1.0.x
Overview
1
Commits
1
Pipelines
1
Changes
6
Merged
Tony Taylor
requested to merge
3497460-removes-clientside-cruft
into
1.0.x
3 months ago
Overview
1
Commits
1
Pipelines
1
Changes
6
Expand
Closes
#3497460
0
0
Merge request reports
Compare
1.0.x
1.0.x (base)
and
latest version
latest version
1bc21826
1 commit,
3 months ago
6 files
+
0
−
223
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
js/alt_text_validation.es6.js deleted
100644 → 0
+
0
−
78
Options
/**
* @file
* Attaches behaviors VA GOv Media module.
*/
((
$
,
Drupal
,
once
,
drupalSettings
)
=>
{
if
(
typeof
drupalSettings
.
cvJqueryValidateOptions
===
"
undefined
"
)
{
drupalSettings
.
cvJqueryValidateOptions
=
{};
}
if
(
drupalSettings
.
clientside_validation_jquery
.
force_validate_on_blur
)
{
drupalSettings
.
cvJqueryValidateOptions
.
onfocusout
=
(
element
)
=>
{
// "eager" validation
this
.
element
(
element
);
};
}
drupalSettings
.
cvJqueryValidateOptions
.
rules
=
{
"
image[0][alt]
"
:
{
remote
:
{
url
:
`
${
drupalSettings
.
path
.
baseUrl
}
media/validate`
,
type
:
"
post
"
,
data
:
{
value
()
{
return
$
(
"
textarea[data-drupal-selector='edit-image-0-alt']
"
).
val
();
},
},
dataType
:
"
json
"
,
},
},
"
media[0][fields][image][0][alt]
"
:
{
remote
:
{
url
:
`
${
drupalSettings
.
path
.
baseUrl
}
media/validate`
,
type
:
"
post
"
,
data
:
{
value
()
{
return
$
(
"
textarea[data-drupal-selector='edit-media-0-fields-image-0-alt']
"
).
val
();
},
},
dataType
:
"
json
"
,
},
},
};
// Add messages with translations from backend.
$
.
extend
(
$
.
validator
.
messages
,
drupalSettings
.
clientside_validation_jquery
.
messages
);
/**
* Attaches jQuery validate behavior to forms.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches the outline behavior to the right context.
*/
Drupal
.
behaviors
.
altTextValidate
=
{
// eslint-disable-next-line no-unused-vars
attach
(
context
)
{
// Allow all modules to update the validate options.
// Example of how to do this is shown below.
$
(
document
).
trigger
(
"
cv-jquery-validate-options-update
"
,
drupalSettings
.
cvJqueryValidateOptions
);
// Process for all the forms on the page everytime,
// we already use once so we should be good.
once
(
"
altTextValidate
"
,
"
body form
"
).
forEach
((
element
)
=>
{
$
(
element
).
validate
(
drupalSettings
.
cvJqueryValidateOptions
);
});
},
};
// eslint-disable-next-line no-undef
})(
jQuery
,
Drupal
,
once
,
drupalSettings
);
Loading