From 0fde26c86c0e9f7f6738f68b29d6e61a8d8c2ac6 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 16 Sep 2011 14:02:21 +0200 Subject: [PATCH] Close event new/edit dialog when clicking outside the dialog --- apps/calendar/css/style.css | 6 ++ apps/calendar/js/calendar.js | 79 +++++++++++++++------- apps/calendar/templates/calendar.php | 12 ++-- apps/calendar/templates/part.editevent.php | 34 +--------- apps/calendar/templates/part.eventform.php | 12 +++- apps/calendar/templates/part.newevent.php | 34 +--------- 6 files changed, 77 insertions(+), 100 deletions(-) diff --git a/apps/calendar/css/style.css b/apps/calendar/css/style.css index d01bd65bc3e..06892e896b1 100644 --- a/apps/calendar/css/style.css +++ b/apps/calendar/css/style.css @@ -62,3 +62,9 @@ .event_popup {width: 280px; height: 40px; padding: 10px;} input[type="button"].active {color: #0098E4} +#fromtime, #totime { +color:#333; +} +#fromtime.disabled, #totime.disabled { +color:#A9A9A9; +} diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index ad44c5d4bc0..31277b716be 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -274,18 +274,52 @@ Calendar={ .data('event_info', event) .hover(this.createEventPopup, this.hideEventPopup) - .click(this.editEventPopup); + .click(this.editEvent); eventcontainer.append(event_holder); }, - editEventPopup:function(event){ + newEvent:function(selector, time){ + var date_info = $(selector).data('date_info'); + var dayofmonth = date_info.getDate(); + var month = date_info.getMonth(); + var year = date_info.getFullYear(); + if(dayofmonth <= 9){ + dayofmonth = '0' + dayofmonth; + } + month++; + if(month <= 9){ + month = '0' + month; + } + var date = String(dayofmonth) + String(month) + String(year); + if($('#event').dialog('isOpen') == true){ + // TODO: save event + $('#event').dialog('destroy').remove(); + }else{ + $('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/neweventform.php?d=' + date + '&t=' + time, function(){ + $('#event').dialog({ + width : 500, + close : function(event, ui) { + $(this).dialog('destroy').remove(); + } + }); + }); + } + }, + editEvent:function(event){ event.stopPropagation(); var event_data = $(this).data('event_info'); var id = event_data.id; - if(oc_cal_opendialog == 0){ - $("#dialog_holder").load(oc_webroot + "/apps/calendar/ajax/editeventform.php?id="+id); - oc_cal_opendialog = 1; + if($('#event').dialog('isOpen') == true){ + // TODO: save event + $('#event').dialog('destroy').remove(); }else{ - alert(t("calendar", "You can't open more than one dialog per site!")); + $('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/editeventform.php?id=' + id, function(){ + $('#event').dialog({ + width : 500, + close : function(event, ui) { + $(this).dialog('destroy').remove(); + } + }); + }); } }, createEventPopup:function(e){ @@ -334,6 +368,19 @@ Calendar={ Calendar.Date.current = new Date(); Calendar.UI.updateView(); }, + lockTime:function(){ + if($('#allday_checkbox').is(':checked')) { + $("#fromtime").attr('disabled', true) + .addClass('disabled'); + $("#totime").attr('disabled', true) + .addClass('disabled'); + } else { + $("#fromtime").attr('disabled', false) + .removeClass('disabled'); + $("#totime").attr('disabled', false) + .removeClass('disabled'); + } + }, Calendar:{ overview:function(){ if(oc_cal_opendialog == 0){ @@ -756,26 +803,6 @@ $(document).ready(function(){ Calendar.UI.loadEvents(); var oc_cal_opendialog = 0; -function oc_cal_newevent(selector, time){ - var date_info = $(selector).data('date_info'); - var dayofmonth = date_info.getDate(); - var month = date_info.getMonth(); - var year = date_info.getFullYear(); - if(dayofmonth <= 9){ - dayofmonth = "0" + dayofmonth; - } - month++; - if(month <= 9){ - month = "0" + month; - } - var date = String(dayofmonth) + String(month) + String(year); - if(oc_cal_opendialog == 0){ - $("#dialog_holder").load(oc_webroot + "/apps/calendar/ajax/neweventform.php?d=" + date + "&t=" + time); - oc_cal_opendialog = 1; - }else{ - alert(t("calendar", "You can't open more than one dialog per site!")); - } -} function validate_event_form(url){ var post = $( "#event_form" ).serialize(); diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index aedfeda9cb4..c5717640fb5 100644 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -71,14 +71,14 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur t("Time");?> - + $time_label): ?> - + @@ -90,7 +90,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur t("Time");?> $weekday): ?> - + @@ -99,7 +99,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur $weekday): ?> - + @@ -121,7 +121,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur $weekday): ?> - +
@@ -144,7 +144,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur $weekday): ?> - +
diff --git a/apps/calendar/templates/part.editevent.php b/apps/calendar/templates/part.editevent.php index 7fbb75756cd..8c6053dc88a 100644 --- a/apps/calendar/templates/part.editevent.php +++ b/apps/calendar/templates/part.editevent.php @@ -1,4 +1,4 @@ -
"> +
">
inc("part.eventform"); ?> @@ -8,35 +8,3 @@
- diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index 4c3024e1deb..f80854177d6 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -39,8 +39,7 @@ - id="allday_checkbox" name="allday"> - document.getElementById("fromtime").disabled = true;document.getElementById("totime").disabled = true;document.getElementById("fromtime").style.color = "#A9A9A9";document.getElementById("totime").style.color = "#A9A9A9";';}?> + id="allday_checkbox" name="allday"> @@ -86,3 +85,12 @@ + diff --git a/apps/calendar/templates/part.newevent.php b/apps/calendar/templates/part.newevent.php index cff8d4412b2..2c8ba7b907d 100644 --- a/apps/calendar/templates/part.newevent.php +++ b/apps/calendar/templates/part.newevent.php @@ -1,4 +1,4 @@ -
"> +
">
inc("part.eventform"); ?>
@@ -7,35 +7,3 @@
- -- 2.39.5