1 $(document).ready(function() {
2 // go to the permissions tab if the checkbox is checked
3 $('body').on("change", "#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");
12 $('#acl-wrapper').hide();
13 $("a#event-perms-lnk").parent("li").hide();
17 // disable the finish time input if the user disable it
18 $('body').on("change", "#id_nofinish", function() {
19 enableDisableFinishDate()
22 // js for the permission sextion
23 $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
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();
30 $('#jot-public').show();
35 // Change the event nav menu.tabs on click
36 $("body").on("click", "#event-nav > li > a", function(e){
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();
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();
56 // Load the html of the actual event and incect the output to the
58 function doEventPreview() {
59 $('#event-edit-preview').val(1);
60 $.post('events',$('#event-edit-form').serialize(), function(data) {
61 $("#event-preview").append(data);
63 $('#event-edit-preview').val(0);
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';
72 $.get(url, function(data) {
73 $("#modal-body").empty();
74 $("#modal-body").append(data);
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();
88 function eventPreviewActive() {
89 $("#event-acl-wrapper, #event-edit-wrapper, #event-desc-wrapper").hide();
90 $("#event-preview").show();
94 function eventEditActive() {
95 $("#event-acl-wrapper, #event-preview, #event-desc-wrapper").hide();
96 $("#event-edit-wrapper").show();
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"));
103 function eventDescActive() {
104 $("#event-edit-wrapper, #event-preview, #event-acl-wrapper").hide();
105 $("#event-desc-wrapper").show();
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");
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);
123 $('#id_finish_text').prop("disabled", false);