1 $(document).ready(function() {
2 // go to the permissions tab if the checkbox is checked
3 $('body').on("change", "#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");
11 $('#acl-wrapper').hide();
12 $("a#event-perms-lnk").parent("li").hide();
16 // disable the finish time input if the user disable it
17 $('body').on("change", "#id_nofinish", function() {
18 enableDisableFinishDate()
21 // js for the permission sextion
22 $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
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();
29 $('#jot-public').show();
34 // Change the event nav menu.tabs on click
35 $("body").on("click", "#event-nav > li > a", function(e){
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();
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();
55 // Load the html of the actual event and incect the output to the
57 function doEventPreview() {
58 $('#event-edit-preview').val(1);
59 $.post('events',$('#event-edit-form').serialize(), function(data) {
60 $("#event-preview").append(data);
62 $('#event-edit-preview').val(0);
66 // this function load the content of the edit url into a modal
67 function eventEdit(url) {
68 var char = qOrAmp(url);
69 url = url + char + 'mode=none';
71 $.get(url, function(data) {
72 $("#modal-body").empty();
73 $("#modal-body").append(data);
79 // the following functions show/hide the specific event-edit content
80 // in dependence of the selected nav
81 function eventAclActive() {
82 $("#event-edit-wrapper, #event-preview, #event-desc-wrapper").hide();
83 $("#event-acl-wrapper").show();
87 function eventPreviewActive() {
88 $("#event-acl-wrapper, #event-edit-wrapper, #event-desc-wrapper").hide();
89 $("#event-preview").show();
93 function eventEditActive() {
94 $("#event-acl-wrapper, #event-preview, #event-desc-wrapper").hide();
95 $("#event-edit-wrapper").show();
97 //make sure jot text does have really the active class (we do this because there are some
98 // other events which trigger jot text
99 toggleEventNav($("#event-edit-lnk"));
102 function eventDescActive() {
103 $("#event-edit-wrapper, #event-preview, #event-acl-wrapper").hide();
104 $("#event-desc-wrapper").show();
107 // Give the active "event-nav" list element the class "active"
108 function toggleEventNav (elm) {
109 // select all li of #event-nav and remove the active class
110 $(elm).closest("#event-nav").children("li").removeClass("active");
111 // add the active class to the parent of the link which was selected
112 $(elm).parent("li").addClass("active");
117 // disable the input for the finish date if it is not available
118 function enableDisableFinishDate() {
119 if( $('#id_nofinish').is(':checked'))
120 $('#id_finish_text').prop("disabled", true);
122 $('#id_finish_text').prop("disabled", false);