1 // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
2 $(document).ready(function () {
3 // Go to the permissions tab if the checkbox is checked.
5 .on("click", "#id_share", function () {
6 if ($("#id_share").is(":checked") && !$("#id_share").attr("disabled")) {
7 $("#acl-wrapper").show();
8 $("a#event-perms-lnk").parent("li").show();
9 toggleEventNav("a#event-perms-lnk");
12 $("#acl-wrapper").hide();
13 $("a#event-perms-lnk").parent("li").hide();
18 // Disable the finish time input if the user disable it.
20 .on("change", "#id_nofinish", function () {
21 enableDisableFinishDate();
25 // JS for the permission section.
26 $("#contact_allow, #contact_deny, #group_allow, #group_deny")
30 "#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected",
32 selstr = $(this).html();
33 $("#jot-public").hide();
36 $("#jot-public").show();
41 // Change the event nav menu.tabs on click.
42 $("body").on("click", "#event-nav > li > a", function (e) {
47 // This is experimental. We maybe can make use of it to inject
48 // some js code while the event modal opens.
49 //$('body').on('show.bs.modal', function () {
50 // enableDisableFinishDate();
53 // Clear some elements (e.g. the event-preview container) when
54 // selecting a event nav link so it don't appear more than once.
55 $("body").on("click", "#event-nav a", function (e) {
56 $("#event-preview").empty();
61 // Load the html of the actual event and incect the output to the
62 // event-edit section.
63 function doEventPreview() {
64 $("#event-edit-preview").val(1);
65 $.post("events", $("#event-edit-form").serialize(), function (data) {
66 $("#event-preview").append(data);
68 $("#event-edit-preview").val(0);
71 // The following functions show/hide the specific event-edit content
72 // in dependence of the selected nav.
73 function eventAclActive() {
74 $("#event-edit-wrapper, #event-preview, #event-desc-wrapper").hide();
75 $("#event-acl-wrapper").show();
78 function eventPreviewActive() {
79 $("#event-acl-wrapper, #event-edit-wrapper, #event-desc-wrapper").hide();
80 $("#event-preview").show();
84 function eventEditActive() {
85 $("#event-acl-wrapper, #event-preview, #event-desc-wrapper").hide();
86 $("#event-edit-wrapper").show();
88 // Make sure jot text does have really the active class (we do this because there are some
89 // other events which trigger jot text.
90 toggleEventNav($("#event-edit-lnk"));
93 function eventDescActive() {
94 $("#event-edit-wrapper, #event-preview, #event-acl-wrapper").hide();
95 $("#event-desc-wrapper").show();
98 // Give the active "event-nav" list element the class "active".
99 function toggleEventNav(elm) {
100 // Select all li of #event-nav and remove the active class.
101 $(elm).closest("#event-nav").children("li").removeClass("active");
102 // Add the active class to the parent of the link which was selected.
103 $(elm).parent("li").addClass("active");
106 // Disable the input for the finish date if it is not available.
107 function enableDisableFinishDate() {
108 if ($("#id_nofinish").is(":checked")) $("#id_finish_text").prop("disabled", true);
109 else $("#id_finish_text").prop("disabled", false);