Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fc-pregmod
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
macaronideath
fc-pregmod
Commits
1a643e91
Commit
1a643e91
authored
6 years ago
by
Skriv
Browse files
Options
Downloads
Patches
Plain Diff
rbuttonJS
parent
270e81ab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/js/rbuttonJS.js
+39
-39
39 additions, 39 deletions
src/js/rbuttonJS.js
with
39 additions
and
39 deletions
src/js/rbuttonJS.js
+
39
−
39
View file @
1a643e91
...
@@ -12,22 +12,22 @@ Group of radiobutton will be created based on variable name. Checked state will
...
@@ -12,22 +12,22 @@ Group of radiobutton will be created based on variable name. Checked state will
Macro
.
add
(
'
rbutton
'
,
{
Macro
.
add
(
'
rbutton
'
,
{
handler
()
{
handler
()
{
if
(
this
.
args
.
length
<
2
)
{
if
(
this
.
args
.
length
<
2
)
{
const
errors
=
[];
const
errors
=
[];
if
(
this
.
args
.
length
<
1
)
{
errors
.
push
(
'
variable name
'
);
}
if
(
this
.
args
.
length
<
1
)
{
errors
.
push
(
'
variable name
'
);
}
if
(
this
.
args
.
length
<
2
)
{
errors
.
push
(
'
checked value
'
);
}
if
(
this
.
args
.
length
<
2
)
{
errors
.
push
(
'
checked value
'
);
}
return
this
.
error
(
`no
${
errors
.
join
(
'
or
'
)}
specified`
);
return
this
.
error
(
`no
${
errors
.
join
(
'
or
'
)}
specified`
);
}
}
// Ensure that the variable name argument is a string.
// Ensure that the variable name argument is a string.
if
(
typeof
this
.
args
[
0
]
!==
'
string
'
)
{
if
(
typeof
this
.
args
[
0
]
!==
'
string
'
)
{
return
this
.
error
(
'
variable name argument is not a string
'
);
return
this
.
error
(
'
variable name argument is not a string
'
);
}
}
const
varName
=
this
.
args
[
0
].
trim
();
const
varName
=
this
.
args
[
0
].
trim
();
// Try to ensure that we receive the variable's name (incl. sigil), not its value.
// Try to ensure that we receive the variable's name (incl. sigil), not its value.
if
(
varName
[
0
]
!==
'
$
'
&&
varName
[
0
]
!==
'
_
'
)
{
if
(
varName
[
0
]
!==
'
$
'
&&
varName
[
0
]
!==
'
_
'
)
{
return
this
.
error
(
`variable name "
${
this
.
args
[
0
]}
" is missing its sigil ($ or _)`
);
return
this
.
error
(
`variable name "
${
this
.
args
[
0
]}
" is missing its sigil ($ or _)`
);
}
}
const
initValue
=
Wikifier
.
getValue
(
this
.
args
[
0
]);
const
initValue
=
Wikifier
.
getValue
(
this
.
args
[
0
]);
...
@@ -48,59 +48,59 @@ Macro.add('rbutton', {
...
@@ -48,59 +48,59 @@ Macro.add('rbutton', {
Setup and initialize the group counter.
Setup and initialize the group counter.
*/
*/
if
(
!
TempState
.
hasOwnProperty
(
this
.
name
))
{
if
(
!
TempState
.
hasOwnProperty
(
this
.
name
))
{
TempState
[
this
.
name
]
=
{};
TempState
[
this
.
name
]
=
{};
}
}
if
(
!
TempState
[
this
.
name
].
hasOwnProperty
(
varId
))
{
if
(
!
TempState
[
this
.
name
].
hasOwnProperty
(
varId
))
{
TempState
[
this
.
name
][
varId
]
=
0
;
TempState
[
this
.
name
][
varId
]
=
0
;
}
}
/*
/*
Setup and append the input element to the output buffer.
Setup and append the input element to the output buffer.
*/
*/
jQuery
(
el
)
jQuery
(
el
)
.
attr
({
.
attr
({
id
:
`
${
this
.
name
}
-
${
varId
}
-
${
TempState
[
this
.
name
][
varId
]
++
}
`
,
id
:
`
${
this
.
name
}
-
${
varId
}
-
${
TempState
[
this
.
name
][
varId
]
++
}
`
,
name
:
`
${
this
.
name
}
-
${
varId
}
`
,
name
:
`
${
this
.
name
}
-
${
varId
}
`
,
type
:
'
radio
'
,
type
:
'
radio
'
,
tabindex
:
0
// for accessibility
tabindex
:
0
// for accessibility
})
})
.
addClass
(
`macro-
${
this
.
name
}
`
)
.
addClass
(
`macro-
${
this
.
name
}
`
)
.
on
(
'
change
'
,
function
()
{
.
on
(
'
change
'
,
function
()
{
if
(
this
.
checked
)
{
if
(
this
.
checked
)
{
Wikifier
.
setValue
(
varName
,
checkValue
);
Wikifier
.
setValue
(
varName
,
checkValue
);
if
(
replaceID
.
length
>
0
&&
replaceText
.
length
>
0
){
if
(
replaceID
.
length
>
0
&&
replaceText
.
length
>
0
){
var
replaceEl
=
document
.
getElementById
(
replaceID
);
//alert (replaceEl);
if
(
replaceEl
!==
null
)
{
replaceEl
.
innerHTML
=
replaceText
;
}
var
replaceEl
=
document
.
getElementById
(
replaceID
);
//alert (replaceEl);
if
(
replaceEl
!==
null
)
{
replaceEl
.
innerHTML
=
replaceText
;
}
}
}
}
}
})
})
.
ready
(
function
()
{
.
ready
(
function
()
{
//alert ("DOM finished");
//alert ("DOM finished");
if
(
el
.
checked
&&
replaceID
.
length
>
0
&&
replaceText
.
length
>
0
){
if
(
el
.
checked
&&
replaceID
.
length
>
0
&&
replaceText
.
length
>
0
){
var
replaceEl
=
document
.
getElementById
(
replaceID
);
var
replaceEl
=
document
.
getElementById
(
replaceID
);
//alert (replaceEl);
//alert (replaceEl);
if
(
replaceEl
!==
null
)
{
if
(
replaceEl
!==
null
)
{
replaceEl
.
innerHTML
=
replaceText
;
replaceEl
.
innerHTML
=
replaceText
;
}
}
}
}
})
})
.
appendTo
(
this
.
output
);
.
appendTo
(
this
.
output
);
/*
/*
Set the story variable to the checked value and the input element to checked, if requested.
Set the story variable to the checked value and the input element to checked, if requested.
*/
*/
if
(
initValue
===
checkValue
)
{
if
(
initValue
===
checkValue
)
{
el
.
checked
=
true
;
el
.
checked
=
true
;
Wikifier
.
setValue
(
varName
,
checkValue
);
Wikifier
.
setValue
(
varName
,
checkValue
);
}
}
}
}
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment