aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/calendar/ajax/activation.php7
-rw-r--r--apps/calendar/ajax/createcalendar.php5
-rw-r--r--apps/calendar/ajax/updatecalendar.php5
-rw-r--r--apps/calendar/index.php7
-rw-r--r--apps/calendar/js/calendar.js89
-rw-r--r--apps/calendar/lib/calendar.php8
-rw-r--r--apps/calendar/templates/part.choosecalendar.rowfields.php2
7 files changed, 72 insertions, 51 deletions
diff --git a/apps/calendar/ajax/activation.php b/apps/calendar/ajax/activation.php
index 89239f21759..72882496ab6 100644
--- a/apps/calendar/ajax/activation.php
+++ b/apps/calendar/ajax/activation.php
@@ -13,5 +13,8 @@ if(!OC_USER::isLoggedIn()) {
OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['calendarid'];
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
-$cal = OC_Calendar_Calendar::findCalendar($calendarid);
-echo $cal['active'];
+$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
+OC_JSON::success(array(
+ 'active' => $calendar['active'],
+ 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar),
+));
diff --git a/apps/calendar/ajax/createcalendar.php b/apps/calendar/ajax/createcalendar.php
index 3fb2e8398a3..325a5ec35bc 100644
--- a/apps/calendar/ajax/createcalendar.php
+++ b/apps/calendar/ajax/createcalendar.php
@@ -20,4 +20,7 @@ OC_Calendar_Calendar::setCalendarActive($calendarid, 1);
$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields');
$tmpl->assign('calendar', $calendar);
-OC_JSON::success(array('data' => $tmpl->fetchPage()));
+OC_JSON::success(array(
+ 'page' => $tmpl->fetchPage(),
+ 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar),
+));
diff --git a/apps/calendar/ajax/updatecalendar.php b/apps/calendar/ajax/updatecalendar.php
index a81644ded17..e99ca16e22a 100644
--- a/apps/calendar/ajax/updatecalendar.php
+++ b/apps/calendar/ajax/updatecalendar.php
@@ -20,4 +20,7 @@ OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields');
$tmpl->assign('calendar', $calendar);
-OC_JSON::success(array('data' => $tmpl->fetchPage()));
+OC_JSON::success(array(
+ 'page' => $tmpl->fetchPage(),
+ 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar),
+));
diff --git a/apps/calendar/index.php b/apps/calendar/index.php
index c01410e3718..eba04100ce6 100644
--- a/apps/calendar/index.php
+++ b/apps/calendar/index.php
@@ -17,12 +17,7 @@ if( count($calendars) == 0){
}
$eventSources = array();
foreach($calendars as $calendar){
- $eventSources[] = array(
- 'url' => 'ajax/events.php?calendar_id='.$calendar['id'],
- 'backgroundColor' => '#'.$calendar['calendarcolor'],
- 'borderColor' => '#888',
- 'textColor' => 'black',
- );
+ $eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar);
}
OC_Util::addScript('calendar', 'calendar');
OC_Util::addStyle('calendar', 'style');
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index 5251dbaa2b4..c17ecb2479c 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -259,19 +259,6 @@ Calendar={
$('#caldav_url').show();
$("#caldav_url_close").show();
},
- deleteCalendar:function(calid){
- var check = confirm("Do you really want to delete this calendar?");
- if(check == false){
- return false;
- }else{
- $.post(OC.filePath('calendar', 'ajax', 'deletecalendar.php'), { calendarid: calid},
- function(data) {
- Calendar.UI.refetchEvents();
- $('#choosecalendar_dialog').dialog('destroy').remove();
- Calendar.UI.Calendar.overview();
- });
- }
- },
initscroll:function(){
if(window.addEventListener)
document.addEventListener('DOMMouseScroll', Calendar.UI.scrollcalendar);
@@ -328,8 +315,14 @@ Calendar={
{
$.post(OC.filePath('calendar', 'ajax', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 },
function(data) {
- checkbox.checked = data == 1;
- Calendar.UI.refetchEvents();
+ if (data.status == 'success'){
+ checkbox.checked = data.active == 1;
+ if (data.active == 1){
+ $('#calendar_holder').fullCalendar('addEventSource', data.eventSource);
+ }else{
+ $('#calendar_holder').fullCalendar('removeEventSource', data.eventSource.url);
+ }
+ }
});
},
newCalendar:function(object){
@@ -344,6 +337,46 @@ Calendar={
function(){Calendar.UI.Calendar.colorPicker(this)});
$(object).closest('tr').after(tr).hide();
},
+ deleteCalendar:function(calid){
+ var check = confirm("Do you really want to delete this calendar?");
+ if(check == false){
+ return false;
+ }else{
+ $.post(OC.filePath('calendar', 'ajax', 'deletecalendar.php'), { calendarid: calid},
+ function(data) {
+ if (data.status == 'success'){
+ var url = 'ajax/events.php?calendar_id='+calid;
+ $('#calendar_holder').fullCalendar('removeEventSource', url);
+ $('#choosecalendar_dialog').dialog('destroy').remove();
+ Calendar.UI.Calendar.overview();
+ }
+ });
+ }
+ },
+ submit:function(button, calendarid){
+ var displayname = $("#displayname_"+calendarid).val();
+ var active = $("#edit_active_"+calendarid+":checked").length;
+ var description = $("#description_"+calendarid).val();
+ var calendarcolor = $("#calendarcolor_"+calendarid).val();
+
+ var url;
+ if (calendarid == 'new'){
+ url = "ajax/createcalendar.php";
+ }else{
+ url = "ajax/updatecalendar.php";
+ }
+ $.post(url, { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor },
+ function(data){
+ if(data.status == 'success'){
+ $(button).closest('tr').prev().html(data.page).show().next().remove();
+ $('#calendar_holder').fullCalendar('removeEventSource', data.eventSource.url);
+ $('#calendar_holder').fullCalendar('addEventSource', data.eventSource);
+ }
+ }, 'json');
+ },
+ cancel:function(button, calendarid){
+ $(button).closest('tr').prev().show().next().remove();
+ },
colorPicker:function(container){
// based on jquery-colorpicker at jquery.webspirited.com
var obj = $('.colorpicker', container);
@@ -369,31 +402,7 @@ Calendar={
position: 'absolute',
left: -10000
});
- },
- submit:function(button, calendarid){
- var displayname = $("#displayname_"+calendarid).val();
- var active = $("#edit_active_"+calendarid+":checked").length;
- var description = $("#description_"+calendarid).val();
- var calendarcolor = $("#calendarcolor_"+calendarid).val();
-
- var url;
- if (calendarid == 'new'){
- url = "ajax/createcalendar.php";
- }else{
- url = "ajax/updatecalendar.php";
- }
- $.post(url, { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor },
- function(data){
- if(data.error == "true"){
- }else{
- $(button).closest('tr').prev().html(data.data).show().next().remove();
- Calendar.UI.refetchEvents();
- }
- }, 'json');
- },
- cancel:function(button, calendarid){
- $(button).closest('tr').prev().show().next().remove();
- },
+ }
},
List:{
removeEvents:function(){
diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php
index c19c0e73c08..252ea66555c 100644
--- a/apps/calendar/lib/calendar.php
+++ b/apps/calendar/lib/calendar.php
@@ -240,4 +240,12 @@ class OC_Calendar_Calendar{
'ecc255', // dark yellow
);
}
+ public static function getEventSourceInfo($calendar){
+ return array(
+ 'url' => 'ajax/events.php?calendar_id='.$calendar['id'],
+ 'backgroundColor' => '#'.$calendar['calendarcolor'],
+ 'borderColor' => '#888',
+ 'textColor' => 'black',
+ );
+ }
}
diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.php b/apps/calendar/templates/part.choosecalendar.rowfields.php
index db0c71252bb..a789be45a43 100644
--- a/apps/calendar/templates/part.choosecalendar.rowfields.php
+++ b/apps/calendar/templates/part.choosecalendar.rowfields.php
@@ -1,4 +1,4 @@
<?php
echo "<td width=\"20px\"><input id=\"active_" . $_['calendar']["id"] . "\" type=\"checkbox\" onClick=\"Calendar.UI.Calendar.activation(this, " . $_['calendar']["id"] . ")\"" . ($_['calendar']["active"] ? ' checked="checked"' : '') . "></td>";
echo "<td><label for=\"active_" . $_['calendar']["id"] . "\">" . $_['calendar']["displayname"] . "</label></td>";
- echo "<td width=\"20px\"><a href=\"#\" onclick=\"Calendar.UI.showCalDAVUrl('" . OC_User::getUser() . "', '" . $_['calendar']["uri"] . "');\" title=\"" . $l->t("CalDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?calid=" . $_['calendar']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Calendar.UI.Calendar.edit(this, " . $_['calendar']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td><td width=\"20px\"><a href=\"#\" onclick=\"Calendar.UI.deleteCalendar('" . $_['calendar']["id"] . "');\" title=\"" . $l->t("Delete") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/delete.svg\"></a></td>";
+ echo "<td width=\"20px\"><a href=\"#\" onclick=\"Calendar.UI.showCalDAVUrl('" . OC_User::getUser() . "', '" . $_['calendar']["uri"] . "');\" title=\"" . $l->t("CalDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?calid=" . $_['calendar']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Calendar.UI.Calendar.edit(this, " . $_['calendar']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td><td width=\"20px\"><a href=\"#\" onclick=\"Calendar.UI.Calendar.deleteCalendar('" . $_['calendar']["id"] . "');\" title=\"" . $l->t("Delete") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/delete.svg\"></a></td>";