Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
smart_date-3406232
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
smart_date-3406232
Commits
a96e817b
Commit
a96e817b
authored
3 years ago
by
Martin Anderson-Clutz
Browse files
Options
Downloads
Patches
Plain Diff
Fixed validation and code standards issues.
parent
f47afb4a
No related branches found
Tags
7.x-1.3
7x-1.3
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
js/smart_date.js
+19
-21
19 additions, 21 deletions
js/smart_date.js
with
19 additions
and
21 deletions
js/smart_date.js
+
19
−
21
View file @
a96e817b
...
...
@@ -6,10 +6,13 @@
once
(
'
smartDateDuration
'
,
'
.smartdate--widget select.field-duration
'
,
context
).
forEach
(
function
(
element
)
{
setInitialDuration
(
element
);
augmentInputs
(
element
);
element
.
addEventListener
(
"
change
"
,
function
()
{
durationChanged
(
element
);
},
false
);
});
once
(
'
smartDateAllDay
'
,
'
.allday
'
,
context
).
forEach
(
function
(
element
)
{
setAllDay
(
element
);
element
.
addEventListener
(
"
change
"
,
function
(
event
)
{
element
.
addEventListener
(
"
change
"
,
function
()
{
checkAllDay
(
element
);
},
false
);
});
...
...
@@ -17,20 +20,15 @@
element
.
step
=
60
;
});
once
(
'
smartDateStartChange
'
,
'
.smartdate--widget .time-start input
'
,
context
).
forEach
(
function
(
element
)
{
element
.
addEventListener
(
"
change
"
,
function
(
event
)
{
element
.
addEventListener
(
"
change
"
,
function
()
{
setEndDate
(
element
);
},
false
);
});
once
(
'
smartDateEndChange
'
,
'
.smartdate--widget .time-end
'
,
context
).
forEach
(
function
(
element
)
{
element
.
addEventListener
(
"
change
"
,
function
(
event
)
{
element
.
addEventListener
(
"
change
"
,
function
()
{
setDuration
(
element
);
},
false
);
});
once
(
'
smartDateDurationChange
'
,
'
.smartdate--widget select.field-duration
'
,
context
).
forEach
(
function
(
element
)
{
element
.
addEventListener
(
"
change
"
,
function
(
event
)
{
durationChanged
(
element
);
},
false
);
});
function
setEndDate
(
element
)
{
let
wrapper
=
element
.
closest
(
'
.smartdate--widget
'
);
...
...
@@ -52,7 +50,7 @@
if
(
!
start_time
&&
start_date
)
{
// If only the start date has been specified update only the end date.
wrapper
.
querySelector
(
'
.time-end.form-date
'
).
value
=
start_date
;
return
return
;
}
let
start_array
=
start_time
.
split
(
'
:
'
);
...
...
@@ -129,32 +127,32 @@
duration
=
calcDuration
(
wrapper
);
}
else
if
(
duration
==
0
)
{
//
c
all this to hide the end date and time
//
C
all this to hide the end date and time
.
durationChanged
(
element
);
}
// Store the numeric value in a property so it can be used programmatically
// Store the numeric value in a property so it can be used programmatically
.
element
.
dataset
.
duration
=
duration
;
}
// Add/change inputs based on initial config
// Add/change inputs based on initial config
.
function
augmentInputs
(
element
)
{
// Add "All day checkbox" if config permits
// Add "All day checkbox" if config permits
.
if
(
element
.
querySelectorAll
(
'
select [value="custom"]
'
).
length
>
0
||
element
.
querySelectorAll
(
'
select [value="1439"]
'
).
length
>
0
)
{
// Create the input element
// Create the input element
.
let
checkbox
=
document
.
createElement
(
'
input
'
);
checkbox
.
type
=
'
checkbox
'
;
checkbox
.
classList
.
add
(
'
allday
'
);
// Create the label element
let
label
=
document
.
createElement
(
'
label
'
)
// Create the label element
.
let
label
=
document
.
createElement
(
'
label
'
)
;
label
.
classList
.
add
(
'
allday-label
'
);
// Insert the input into the label
// Insert the input into the label
.
label
.
appendChild
(
checkbox
);
label
.
appendChild
(
document
.
createTextNode
(
Drupal
.
t
(
'
All day
'
)));
element
.
parentElement
.
insertAdjacentElement
(
'
beforebegin
'
,
label
);
}
//
i
f a forced duration, make end date and time read only
//
I
f a forced duration, make end date and time read only
.
if
(
element
.
querySelectorAll
(
'
select [value="custom"]
'
).
length
==
0
)
{
let
wrapper
=
element
.
closest
(
'
fieldset
'
);
let
end_time_input
=
wrapper
.
querySelector
(
'
.time-end.form-time
'
);
...
...
@@ -174,9 +172,9 @@
return
;
}
let
duration_select
=
wrapper
.
querySelector
(
'
select.field-duration
'
);
// Store the numeric value in a property so it can be used programmatically
// Store the numeric value in a property so it can be used programmatically
.
duration_select
.
dataset
.
duration
=
duration
;
// Update the select to show the appropriate value
// Update the select to show the appropriate value
.
if
(
duration_select
.
querySelectorAll
(
'
option[value="
'
+
duration
+
'
"]
'
).
length
!=
0
){
duration_select
.
value
=
duration
;
}
else
{
...
...
@@ -298,7 +296,7 @@
duration_wrapper
.
style
.
visibility
=
'
visible
'
;
hideLabels
(
wrapper
,
false
);
if
(
duration
.
value
==
0
)
{
//
c
all this to hide the end date and time
//
C
all this to hide the end date and time
.
durationChanged
(
duration
);
}
checkEndDate
(
wrapper
);
...
...
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