Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Issue forks
fullcalendar_view-3183913
Commits
f88537b4
Commit
f88537b4
authored
Mar 18, 2020
by
Mingsong Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pop-up modal bug
parent
0fdf5ac3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
70 deletions
+66
-70
js/fullcalendar_view.js
js/fullcalendar_view.js
+66
-70
No files found.
js/fullcalendar_view.js
View file @
f88537b4
...
...
@@ -11,81 +11,77 @@
var
localeSelectorEl
=
document
.
getElementById
(
'
locale-selector
'
);
// Date entry clicked.
var
slotDate
;
// Create all calendars.
$
(
'
.js-drupal-fullcalendar
'
,
context
)
.
once
(
"
fullcalendarCustomBehavior
"
)
.
each
(
function
()
{
var
calendarEl
=
document
.
getElementsByClassName
(
"
js-drupal-fullcalendar
"
);
let
calendarOptions
=
JSON
.
parse
(
drupalSettings
.
calendar_options
);
// Bind the render event handler.
calendarOptions
.
eventRender
=
eventRender
;
// Bind the resize event handler.
calendarOptions
.
eventResize
=
eventResize
;
// Bind the day click handler.
calendarOptions
.
dateClick
=
dayClickCallback
;
// Bind the event click handler.
calendarOptions
.
eventClick
=
eventClick
;
// Bind the drop event handler.
calendarOptions
.
eventDrop
=
eventDrop
;
// Define calendar elemetns.
if
(
calendarEl
)
{
for
(
let
i
=
0
;
i
<
calendarEl
.
length
;
i
++
)
{
var
calendar
=
new
FullCalendar
.
Calendar
(
calendarEl
[
i
],
calendarOptions
);
// Render the calendar.
calendar
.
render
();
// Language dropdown box.
if
(
drupalSettings
.
languageSelector
)
{
// build the locale selector's options
calendar
.
getAvailableLocaleCodes
().
forEach
(
function
(
localeCode
)
{
var
optionEl
=
document
.
createElement
(
'
option
'
);
optionEl
.
value
=
localeCode
;
optionEl
.
selected
=
localeCode
==
calendarOptions
.
locale
;
optionEl
.
innerText
=
localeCode
;
localeSelectorEl
.
appendChild
(
optionEl
);
});
// when the selected option changes, dynamically change the calendar option
localeSelectorEl
.
addEventListener
(
'
change
'
,
function
()
{
if
(
this
.
value
)
{
calendar
.
setOption
(
'
locale
'
,
this
.
value
);
}
});
}
else
{
$
(
"
.locale-selector
"
).
hide
();
var
calendarEl
=
document
.
getElementsByClassName
(
"
js-drupal-fullcalendar
"
);
let
calendarOptions
=
JSON
.
parse
(
drupalSettings
.
calendar_options
);
// Bind the render event handler.
calendarOptions
.
eventRender
=
eventRender
;
// Bind the resize event handler.
calendarOptions
.
eventResize
=
eventResize
;
// Bind the day click handler.
calendarOptions
.
dateClick
=
dayClickCallback
;
// Bind the event click handler.
calendarOptions
.
eventClick
=
eventClick
;
// Bind the drop event handler.
calendarOptions
.
eventDrop
=
eventDrop
;
// Define calendar elemetns.
if
(
calendarEl
)
{
for
(
let
i
=
0
;
i
<
calendarEl
.
length
;
i
++
)
{
var
calendar
=
new
FullCalendar
.
Calendar
(
calendarEl
[
i
],
calendarOptions
);
// Render the calendar.
calendar
.
render
();
// Language dropdown box.
if
(
drupalSettings
.
languageSelector
)
{
// build the locale selector's options
calendar
.
getAvailableLocaleCodes
().
forEach
(
function
(
localeCode
)
{
var
optionEl
=
document
.
createElement
(
'
option
'
);
optionEl
.
value
=
localeCode
;
optionEl
.
selected
=
localeCode
==
calendarOptions
.
locale
;
optionEl
.
innerText
=
localeCode
;
localeSelectorEl
.
appendChild
(
optionEl
);
});
// when the selected option changes, dynamically change the calendar option
localeSelectorEl
.
addEventListener
(
'
change
'
,
function
()
{
if
(
this
.
value
)
{
calendar
.
setOption
(
'
locale
'
,
this
.
value
);
}
// Put into the calendar array.
calendarObjs
[
i
]
=
calendar
;
}
// Double click event.
$
(
"
.js-drupal-fullcalendar
"
).
dblclick
(
function
()
{
console
.
log
(
slotDate
);
if
(
slotDate
&&
drupalSettings
.
eventBundleType
&&
drupalSettings
.
dblClickToCreate
&&
drupalSettings
.
addForm
!==
""
)
{
// Open a new window to create a new event (content).
window
.
open
(
drupalSettings
.
path
.
baseUrl
+
drupalSettings
.
addForm
+
"
?start=
"
+
slotDate
+
"
&start_field=
"
+
drupalSettings
.
startField
,
"
_blank
"
);
}
});
}
else
{
$
(
"
.locale-selector
"
).
hide
();
}
// Put into the calendar array.
calendarObjs
[
i
]
=
calendar
;
}
// Double click event.
$
(
"
.js-drupal-fullcalendar
"
).
dblclick
(
function
()
{
// New event window can be open if following conditions match.
// * The new event content type are specified.
// * Allow to create a new event by double click.
// * User has the permission to create a new event.
// * The add form for the new event type is known.
if
(
slotDate
&&
drupalSettings
.
eventBundleType
&&
drupalSettings
.
dblClickToCreate
&&
drupalSettings
.
addForm
!==
""
)
{
// Open a new window to create a new event (content).
window
.
open
(
drupalSettings
.
path
.
baseUrl
+
drupalSettings
.
addForm
+
"
?start=
"
+
slotDate
+
"
&start_field=
"
+
drupalSettings
.
startField
,
"
_blank
"
);
}
});
}
/**
* Event render handler
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment