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