FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
roadmap/app/javascript/src/utils/requiredField.js at api-patch · DMPRoadmap/roadmap · GitHub
DMPRoadmap
roadmap
Repository navigation
Code
Issues
300
(300)
Pull requests
49
(49)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
roadmap
/
app
/
javascript
/
src
/
utils
/
requiredField.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (31 loc) · 1.14 KB
Breadcrumbs
roadmap
/
app
/
javascript
/
src
/
utils
/
requiredField.js
Copy path
File metadata and controls
37 lines (31 loc) · 1.14 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import
getConstant
from
'./constants'
;
import
{
isObject
}
from
'./isType'
;
var
asterisk
;
export
const
addAsterisk
=
(
el
)
=>
{
const
target
=
$
(
el
)
;
if
(
isObject
(
target
)
)
{
// If the element is part of a Fieldset then place the asterisk before the <fieldset><legend>
if
(
target
.
closest
(
'fieldset'
)
.
length
>
0
&&
target
.
closest
(
'fieldset'
)
.
find
(
'legend'
)
.
length
>
0
)
{
const
legend
=
target
.
closest
(
'fieldset'
)
.
find
(
'legend'
)
;
legend
.
html
(
`
${
asterisk
}
${
legend
.
html
(
)
}
`
)
;
// If the element is a radio button or checkbox place the asterisk after the label
}
else
if
(
target
.
is
(
'[input="checkbox"]'
)
||
target
.
is
(
'[input="radio"]'
)
)
{
target
.
after
(
asterisk
)
;
// Else place the asterisk before the corresponding label
}
else
{
const
label
=
target
.
prev
(
)
;
if
(
isObject
(
label
)
)
{
$
(
label
[
0
]
)
.
before
(
asterisk
)
;
}
}
}
}
;
export
const
addAsterisks
=
(
el
)
=>
{
$
(
el
)
.
find
(
'[aria-required=true]'
)
.
each
(
(
idx
,
jqObject
)
=>
{
addAsterisk
(
jqObject
)
;
}
)
;
}
;
$
(
(
)
=>
{
asterisk
=
`<span class="red" title="
${
getConstant
(
'REQUIRED_FIELD_TEXT'
)
}
">* </span>`
;
addAsterisks
(
'body'
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL