From 606f42701ccd545a04fdf0b2a6bea3bce2ee9dd0 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 17 Jun 2016 14:09:18 +0200 Subject: [PATCH] frio - event - some js and template refactoring + event view css styling --- mod/events.php | 6 +- view/theme/frio/css/style.css | 20 ++++ view/theme/frio/js/event.js | 124 +++++++++++++++++++++++ view/theme/frio/templates/event.tpl | 19 ++-- view/theme/frio/templates/event_form.tpl | 47 +++++---- view/theme/frio/templates/event_head.tpl | 119 ---------------------- view/theme/frio/templates/events-js.tpl | 2 +- 7 files changed, 187 insertions(+), 150 deletions(-) create mode 100644 view/theme/frio/js/event.js diff --git a/mod/events.php b/mod/events.php index 7786136097..e4526ac594 100644 --- a/mod/events.php +++ b/mod/events.php @@ -455,6 +455,7 @@ function events_content(&$a) { '$baseurl' => $a->get_baseurl(), '$tabs' => $tabs, '$title' => t('Events'), + '$view' => t('View'), '$new_event'=> array($a->get_baseurl().'/events/new',t('Create New Event'),'',''), '$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''), '$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''), @@ -462,7 +463,6 @@ function events_content(&$a) { '$events' => $events, - // eignene "today" => t("today"), "month" => t("month"), "week" => t("week"), @@ -582,7 +582,9 @@ function events_content(&$a) { '$adjust' => array('adjust', t('Adjust for viewer timezone'), $a_checked), '$preview' => t('Preview'), '$acl' => $acl, - '$submit' => t('Submit') + '$submit' => t('Submit'), + '$basic' => t("Basic"), + '$advanced' => t("Advanced") )); diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index 185888b718..deb3436ded 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -1954,15 +1954,35 @@ td.fc-day { .event-wrapper .event-owner { margin-bottom: 15px; } +.event-wrapper .event-owner img { + display: block; +} .event-owner img { margin-right: 5px; height: 48px; width: 48; border-radius: 3px; } +.event-wrapper .vevent { + margin-left: 0; + margin-right: 0; + box-shadow: 1.5px 0 0 0 rgba(0, 0, 0, .1) inset; +} .event-wrapper .event-buttons { margin-top: 15px; } +#event-form-wrapper { + padding-top: 5px; +} +#event-edit-form-wrapper { + padding-top: 15px; +} +#event-nav a { + color: #555; +} +#event-edit-form-wrapper #event-edit-time { + padding: 10px 0; +} /* * Overwriting for transparency and other colors */ diff --git a/view/theme/frio/js/event.js b/view/theme/frio/js/event.js new file mode 100644 index 0000000000..c6a3541f6c --- /dev/null +++ b/view/theme/frio/js/event.js @@ -0,0 +1,124 @@ +$(document).ready(function() { + // go to the permissions tab if the checkbox is checked + $('body').on("change", "#id_share", function() { + + if ($('#id_share').is(':checked') && !( $('#id_share').attr("disabled"))) { + $('#acl-wrapper').show(); + $("a#event-perms-lnk").parent("li").show(); + toggleEventNav("a#event-perms-lnk"); + eventAclActive(); + } + else { + $('#acl-wrapper').hide(); + $("a#event-perms-lnk").parent("li").hide(); + } + }).trigger('change'); + + // disable the finish time input if the user disable it + $('body').on("change", "#id_nofinish", function() { + enableDisableFinishDate() + }).trigger('change'); + + // js for the permission sextion + $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() { + var selstr; + $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() { + selstr = $(this).text(); + $('#jot-public').hide(); + }); + if(selstr == null) { + $('#jot-public').show(); + } + + }).trigger('change'); + + // Change the event nav menu.tabs on click + $("body").on("click", "#event-nav > li > a", function(e){ + e.preventDefault(); + toggleEventNav(this); + }); + + // this is experimental. We maybe can make use of it to inject + // some js code while the event modal opens + //$('body').on('show.bs.modal', function () { + // enableDisableFinishDate(); + //}); + + // clear some elements (e.g. the event-preview container) when + // selecting a event nav link so it don't appear more than once + $('body').on("click", "#event-nav a", function(e) { + $("#event-preview").empty(); + e.preventDefault(); + }); + +}); + +// Load the html of the actual event and incect the output to the +// event-edit section +function doEventPreview() { + $('#event-edit-preview').val(1); + $.post('events',$('#event-edit-form').serialize(), function(data) { + $("#event-preview").append(data); + }); + $('#event-edit-preview').val(0); +} + + +// this function load the content of the edit url into a modal +function eventEdit(url) { + var char = qOrAmp(url); + url = url + char + 'mode=none'; + + $.get(url, function(data) { + $("#modal-body").empty(); + $("#modal-body").append(data); + }).done(function() { + loadModalTitle(); + }); +} + +// the following functions show/hide the specific event-edit content +// in dependence of the selected nav +function eventAclActive() { + $("#event-edit-wrapper, #event-preview, #event-desc-wrapper").hide(); + $("#event-acl-wrapper").show(); +} + + +function eventPreviewActive() { + $("#event-acl-wrapper, #event-edit-wrapper, #event-desc-wrapper").hide(); + $("#event-preview").show(); + doEventPreview(); +} + +function eventEditActive() { + $("#event-acl-wrapper, #event-preview, #event-desc-wrapper").hide(); + $("#event-edit-wrapper").show(); + + //make sure jot text does have really the active class (we do this because there are some + // other events which trigger jot text + toggleEventNav($("#event-edit-lnk")); +} + +function eventDescActive() { + $("#event-edit-wrapper, #event-preview, #event-acl-wrapper").hide(); + $("#event-desc-wrapper").show(); +} + +// Give the active "event-nav" list element the class "active" +function toggleEventNav (elm) { + // select all li of #event-nav and remove the active class + $(elm).closest("#event-nav").children("li").removeClass("active"); + // add the active class to the parent of the link which was selected + $(elm).parent("li").addClass("active"); +} + + + +// disable the input for the finish date if it is not available +function enableDisableFinishDate() { + if( $('#id_nofinish').is(':checked')) + $('#id_finish_text').prop("disabled", true); + else + $('#id_finish_text').prop("disabled", false); +} diff --git a/view/theme/frio/templates/event.tpl b/view/theme/frio/templates/event.tpl index 27965bb590..32e740581a 100644 --- a/view/theme/frio/templates/event.tpl +++ b/view/theme/frio/templates/event.tpl @@ -1,16 +1,23 @@ + {{foreach $events as $event}}