]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/js/event_edit.js
Merge pull request #8131 from nupplaphil/task/cleanup_lock
[friendica.git] / view / theme / frio / js / event_edit.js
1 $(document).ready(function() {
2         // Go to the permissions tab if the checkbox is checked.
3         $('body').on("click", "#id_share", function() {
4                 if ($('#id_share').is(':checked') && !( $('#id_share').attr("disabled"))) {
5                         $('#acl-wrapper').show();
6                         $("a#event-perms-lnk").parent("li").show();
7                         toggleEventNav("a#event-perms-lnk");
8                         eventAclActive();
9                 }
10                 else {
11                         $('#acl-wrapper').hide();
12                         $("a#event-perms-lnk").parent("li").hide();
13                 }
14         }).trigger('change');
15
16         // Disable the finish time input if the user disable it.
17         $('body').on("change", "#id_nofinish", function() {
18                 enableDisableFinishDate()
19         }).trigger('change');
20
21         // JS for the permission section.
22         $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
23                 var selstr;
24                 $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
25                         selstr = $(this).text();
26                         $('#jot-public').hide();
27                 });
28                 if (selstr == null) {
29                         $('#jot-public').show();
30                 }
31
32         }).trigger('change');
33
34         // Change the event nav menu.tabs on click.
35         $("body").on("click", "#event-nav > li > a", function(e){
36                 e.preventDefault();
37                 toggleEventNav(this);
38         });
39
40         // This is experimental. We maybe can make use of it to inject
41         // some js code while the event modal opens.
42         //$('body').on('show.bs.modal', function () {
43         //      enableDisableFinishDate();
44         //});
45
46         // Clear some elements (e.g. the event-preview container) when
47         // selecting a event nav link so it don't appear more than once.
48         $('body').on("click", "#event-nav a", function(e) {
49                 $("#event-preview").empty();
50                 e.preventDefault();
51         });
52 });
53
54 // Load the html of the actual event and incect the output to the
55 // event-edit section.
56 function doEventPreview() {
57         $('#event-edit-preview').val(1);
58         $.post('events',$('#event-edit-form').serialize(), function(data) {
59                 $("#event-preview").append(data);
60         });
61         $('#event-edit-preview').val(0);
62 }
63
64
65 // The following functions show/hide the specific event-edit content
66 // in dependence of the selected nav.
67 function eventAclActive() {
68         $("#event-edit-wrapper, #event-preview, #event-desc-wrapper").hide();
69         $("#event-acl-wrapper").show();
70 }
71
72
73 function eventPreviewActive() {
74         $("#event-acl-wrapper, #event-edit-wrapper, #event-desc-wrapper").hide();
75         $("#event-preview").show();
76         doEventPreview();
77 }
78
79 function eventEditActive() {
80         $("#event-acl-wrapper, #event-preview, #event-desc-wrapper").hide();
81         $("#event-edit-wrapper").show();
82
83         // Make sure jot text does have really the active class (we do this because there are some
84         // other events which trigger jot text.
85         toggleEventNav($("#event-edit-lnk"));
86 }
87
88 function eventDescActive() {
89         $("#event-edit-wrapper, #event-preview, #event-acl-wrapper").hide();
90         $("#event-desc-wrapper").show();
91 }
92
93 // Give the active "event-nav" list element the class "active".
94 function toggleEventNav (elm) {
95         // Select all li of #event-nav and remove the active class.
96         $(elm).closest("#event-nav").children("li").removeClass("active");
97         // Add the active class to the parent of the link which was selected.
98         $(elm).parent("li").addClass("active");
99 }
100
101
102
103 // Disable the input for the finish date if it is not available.
104 function enableDisableFinishDate() {
105         if( $('#id_nofinish').is(':checked'))
106                 $('#id_finish_text').prop("disabled", true);
107         else
108                 $('#id_finish_text').prop("disabled", false);
109 }