]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/js/event.js
Merge branch 'master' into develop
[friendica.git] / view / theme / frio / js / event.js
1 $(document).ready(function() { 
2         // go to the permissions tab if the checkbox is checked
3         $('body').on("change", "#id_share", function() {
4
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 sextion
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
56 // Load the html of the actual event and incect the output to the
57 // event-edit section
58 function doEventPreview() {
59         $('#event-edit-preview').val(1);
60         $.post('events',$('#event-edit-form').serialize(), function(data) {
61                 $("#event-preview").append(data);
62         });
63         $('#event-edit-preview').val(0);
64 }
65
66
67 // this function load the content of the edit url into a modal
68 function eventEdit(url) {
69         var char = qOrAmp(url);
70         url = url + char + 'mode=none';
71
72         $.get(url, function(data) {
73                 $("#modal-body").empty();
74                 $("#modal-body").append(data);
75         }).done(function() {
76                 loadModalTitle();
77         });
78 }
79
80 // the following functions show/hide the specific event-edit content 
81 // in dependence of the selected nav
82 function eventAclActive() {
83         $("#event-edit-wrapper, #event-preview, #event-desc-wrapper").hide();
84         $("#event-acl-wrapper").show();
85 }
86
87
88 function eventPreviewActive() {
89         $("#event-acl-wrapper, #event-edit-wrapper, #event-desc-wrapper").hide();
90         $("#event-preview").show();
91         doEventPreview();
92 }
93
94 function eventEditActive() {
95         $("#event-acl-wrapper, #event-preview, #event-desc-wrapper").hide();
96         $("#event-edit-wrapper").show();
97
98         //make sure jot text does have really the active class (we do this because there are some
99         // other events which trigger jot text
100         toggleEventNav($("#event-edit-lnk"));
101 }
102
103 function eventDescActive() {
104         $("#event-edit-wrapper, #event-preview, #event-acl-wrapper").hide();
105         $("#event-desc-wrapper").show();
106 }
107
108 // Give the active "event-nav" list element the class "active"
109 function toggleEventNav (elm) {
110         // select all li of #event-nav and remove the active class
111         $(elm).closest("#event-nav").children("li").removeClass("active");
112         // add the active class to the parent of the link which was selected
113         $(elm).parent("li").addClass("active");
114 }
115
116
117
118 // disable the input for the finish date if it is not available
119 function enableDisableFinishDate() {
120         if( $('#id_nofinish').is(':checked'))
121                 $('#id_finish_text').prop("disabled", true);
122         else
123                 $('#id_finish_text').prop("disabled", false);
124 }