diff --git a/lang/en/lang.php b/lang/en/lang.php
--- a/lang/en/lang.php
+++ b/lang/en/lang.php
@@ -1,33 +1,34 @@
');
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_davcal',
id: JSINFO.id,
action: 'saveSettings',
params: postArray
},
function(data)
{
var result = data['result'];
var html = data['html'];
jQuery('#dw_davcal__ajaxsettings').html(html);
if(result === true)
{
location.reload();
}
}
);
};
dialogButtons[LANG.plugins.davcal['cancel']] = function () {
dw_davcal__modals.hideSettingsDialog();
};
dw_davcal__modals.$settingsDialog = jQuery(document.createElement('div'))
.dialog({
autoOpen: false,
draggable: true,
title: LANG.plugins.davcal['settings'],
resizable: true,
buttons: dialogButtons,
})
.html(
'
' +
''
)
.parent()
.attr('id','dw_davcal__settings')
.show()
.appendTo('.dokuwiki:first');
// attach event handlers
jQuery('#dw_davcal__settings .ui-dialog-titlebar-close').click(function(){
dw_davcal__modals.hideSettingsDialog();
});
var $tzdropdown = jQuery('#dw_davcal__settings_timezone');
jQuery('#fullCalendarTimezoneList option').each(function() {
jQuery('', {value: jQuery(this).val(),
text: jQuery(this).text()}).appendTo($tzdropdown);
});
if(dw_davcal__modals.settings)
{
if(dw_davcal__modals.settings['timezone'] !== '')
jQuery('#dw_davcal__settings_timezone').val(dw_davcal__modals.settings['timezone']);
if(dw_davcal__modals.settings['weeknumbers'] == 1)
jQuery('#dw_davcal__settings_weeknumbers').prop('checked', true);
else
jQuery('#dw_davcal__settings_weeknumbers').prop('checked', false);
if(dw_davcal__modals.settings['workweek'] == 1)
jQuery('#dw_davcal__settings_workweek').prop('checked', true);
else
jQuery('#dw_davcal__settings_workweek').prop('checked', false);
}
},
- showEditEventDialog : function(calEvent) {
+ showEditEventDialog : function(event, edit) {
if(dw_davcal__modals.$editEventDialog)
return;
-
+
+ var title = '';
var dialogButtons = {};
- dialogButtons[LANG.plugins.davcal['edit']] = function() {
- var postArray = { };
- jQuery("input.dw_davcal__editevent").each(function() {
- if(jQuery(this).attr('type') == 'checkbox')
- {
- postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0;
- }
- else
- {
- postArray[jQuery(this).prop('name')] = jQuery(this).val();
- }
- });
- jQuery('#dw_davcal__ajaxedit').html('');
- jQuery.post(
- DOKU_BASE + 'lib/exe/ajax.php',
- {
- call: 'plugin_davcal',
- id: JSINFO.id,
- action: 'editEvent',
- params: postArray
- },
- function(data)
- {
- var result = data['result'];
- var html = data['html'];
- jQuery('#dw_davcal__ajaxedit').html(html);
- if(result === true)
+ var calEvent = [];
+ if(edit)
+ {
+ calEvent = event;
+ title = LANG.plugins.davcal['edit_event'];
+ dialogButtons[LANG.plugins.davcal['edit']] = function() {
+ if(!dw_davcal__modals.checkEvents())
+ return;
+ var postArray = { };
+ jQuery("input.dw_davcal__editevent").each(function() {
+ if(jQuery(this).attr('type') == 'checkbox')
+ {
+ postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0;
+ }
+ else
+ {
+ postArray[jQuery(this).prop('name')] = jQuery(this).val();
+ }
+ });
+ jQuery('#dw_davcal__ajaxedit').html('');
+ jQuery.post(
+ DOKU_BASE + 'lib/exe/ajax.php',
+ {
+ call: 'plugin_davcal',
+ id: JSINFO.id,
+ action: 'editEvent',
+ params: postArray
+ },
+ function(data)
+ {
+ var result = data['result'];
+ var html = data['html'];
+ jQuery('#dw_davcal__ajaxedit').html(html);
+ if(result === true)
+ {
+ jQuery('#fullCalendar').fullCalendar('refetchEvents');
+ dw_davcal__modals.hideEditEventDialog();
+ }
+ }
+ );
+ };
+ dialogButtons[LANG.plugins.davcal['delete']] = function() {
+ dw_davcal__modals.action = 'deleteEvent';
+ dw_davcal__modals.msg = LANG.plugins.davcal['really_delete_this_event'];
+ dw_davcal__modals.completeCb = function(data) {
+ if(data.result == false)
+ {
+ dw_davcal__modals.msg = data.errmsg;
+ dw_davcal__modals.showDialog(false);
+ }
+ else
{
jQuery('#fullCalendar').fullCalendar('refetchEvents');
dw_davcal__modals.hideEditEventDialog();
}
- }
- );
- };
+ };
+ dw_davcal__modals.showDialog(true);
+ };
+ }
+ else
+ {
+ calEvent.start = event;
+ calEvent.end = moment(event);
+ calEvent.start.hour(12);
+ calEvent.start.minute(0);
+ calEvent.end.hour(13);
+ calEvent.end.minute(0);
+ calEvent.allDay = false;
+ calEvent.title = '';
+ calEvent.id = '0';
+ title = LANG.plugins.davcal['create_new_event'];
+ dialogButtons[LANG.plugins.davcal['create']] = function() {
+ if(!dw_davcal__modals.checkEvents())
+ return;
+
+ var postArray = { };
+ jQuery("input.dw_davcal__editevent").each(function() {
+ if(jQuery(this).attr('type') == 'checkbox')
+ {
+ postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0;
+ }
+ else
+ {
+ postArray[jQuery(this).prop('name')] = jQuery(this).val();
+ }
+ });
+ jQuery('#dw_davcal__ajaxnew').html('');
+ jQuery.post(
+ DOKU_BASE + 'lib/exe/ajax.php',
+ {
+ call: 'plugin_davcal',
+ id: JSINFO.id,
+ action: 'newEvent',
+ params: postArray
+ },
+ function(data)
+ {
+ var result = data['result'];
+ var html = data['html'];
+ jQuery('#dw_davcal__ajaxedit').html(html);
+ if(result === true)
+ {
+ jQuery('#fullCalendar').fullCalendar('refetchEvents');
+ dw_davcal__modals.hideEditEventDialog();
+ }
+ }
+ );
+ };
+ }
dialogButtons[LANG.plugins.davcal['cancel']] = function() {
dw_davcal__modals.hideEditEventDialog();
};
- dialogButtons[LANG.plugins.davcal['delete']] = function() {
- dw_davcal__modals.action = 'deleteEvent';
- dw_davcal__modals.msg = LANG.plugins.davcal['really_delete_this_event'];
- dw_davcal__modals.completeCb = function(data) {
- if(data.result == false)
- {
- dw_davcal__modals.msg = data.errmsg;
- dw_davcal__modals.showInfoDialog();
- }
- else
- {
- jQuery('#fullCalendar').fullCalendar('refetchEvents');
- dw_davcal__modals.hideEditEventDialog();
- }
- };
- dw_davcal__modals.showConfirmDialog();
- };
dw_davcal__modals.uid = calEvent.id;
dw_davcal__modals.$editEventDialog = jQuery(document.createElement('div'))
.dialog({
autoOpen: false,
draggable: true,
- title: LANG.plugins.davcal['edit_event'],
+ title: title,
resizable: true,
buttons: dialogButtons,
})
.html(
'' +
''
)
.parent()
.attr('id','dw_davcal__edit')
.show()
.appendTo('.dokuwiki:first');
jQuery('#dw_davcal__uid_edit').val(calEvent.id);
jQuery('#dw_davcal__eventname_edit').val(calEvent.title);
jQuery('#dw_davcal__eventfrom_edit').val(calEvent.start.format('YYYY-MM-DD'));
jQuery('#dw_davcal__eventfromtime_edit').val(calEvent.start.format('HH:mm'));
if(calEvent.allDay && (calEvent.end === null))
{
jQuery('#dw_davcal__eventto_edit').val(calEvent.start.format('YYYY-MM-DD'));
jQuery('#dw_davcal__eventtotime_edit').val(calEvent.start.format('HH:mm'));
}
else if(calEvent.allDay)
{
endEvent = moment(calEvent.end);
endEvent.subtract(1, 'days');
jQuery('#dw_davcal__eventto_edit').val(endEvent.format('YYYY-MM-DD'));
jQuery('#dw_davcal__eventotime_edit').val(endEvent.format('HH:mm'));
}
else
{
jQuery('#dw_davcal__eventto_edit').val(calEvent.end.format('YYYY-MM-DD'));
jQuery('#dw_davcal__eventtotime_edit').val(calEvent.end.format('HH:mm'));
}
jQuery('#dw_davcal__allday_edit').prop('checked', calEvent.allDay);
// attach event handlers
jQuery('#dw_davcal__edit .ui-dialog-titlebar-close').click(function(){
dw_davcal__modals.hideEditEventDialog();
});
jQuery('#dw_davcal__eventfrom_edit').datetimepicker({format:'YYYY-MM-DD',
formatDate:'YYYY-MM-DD',
datepicker: true,
timepicker: false,
});
jQuery('#dw_davcal__eventfromtime_edit').datetimepicker({format:'HH:mm',
formatTime:'HH:mm',
datepicker: false,
timepicker: true,
step: 15});
jQuery('#dw_davcal__eventto_edit').datetimepicker({format:'YYYY-MM-DD',
formatDate:'YYYY-MM-DD',
datepicker: true,
timepicker: false,
});
jQuery('#dw_davcal__eventtotime_edit').datetimepicker({format:'HH:mm',
formatTime:'HH:mm',
datepicker: false,
timepicker: true,
step:15});
jQuery('#dw_davcal__allday_edit').change(function() {
if(jQuery(this).is(":checked"))
{
jQuery('#dw_davcal__eventfromtime_edit').prop('readonly', true);
jQuery('#dw_davcal__eventtotime_edit').prop('readonly', true);
}
else
{
jQuery('#dw_davcal__eventfromtime_edit').prop('readonly', false);
jQuery('#dw_davcal__eventtotime_edit').prop('readonly', false);
}
});
jQuery('#dw_davcal__allday_edit').change();
},
- showNewEventDialog : function(date) {
- if(dw_davcal__modals.$newEventDialog)
- return;
- var dialogButtons = {};
- dialogButtons[LANG.plugins.davcal['create']] = function() {
- var postArray = { };
- jQuery("input.dw_davcal__newevent").each(function() {
- if(jQuery(this).attr('type') == 'checkbox')
- {
- postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0;
- }
- else
- {
- postArray[jQuery(this).prop('name')] = jQuery(this).val();
- }
- });
- jQuery('#dw_davcal__ajaxnew').html('');
- jQuery.post(
- DOKU_BASE + 'lib/exe/ajax.php',
- {
- call: 'plugin_davcal',
- id: JSINFO.id,
- action: 'newEvent',
- params: postArray
- },
- function(data)
- {
- var result = data['result'];
- var html = data['html'];
- jQuery('#dw_davcal__ajaxnew').html(html);
- if(result === true)
- {
- jQuery('#fullCalendar').fullCalendar('refetchEvents');
- dw_davcal__modals.hideNewEventDialog();
- }
- }
- );
- };
- dialogButtons[LANG.plugins.davcal['cancel']] = function() {
- dw_davcal__modals.hideNewEventDialog();
- };
- dw_davcal__modals.$newEventDialog = jQuery(document.createElement('div'))
- .dialog({
- autoOpen: false,
- draggable: true,
- title: LANG.plugins.davcal['create_new_event'],
- resizable: true,
- buttons: dialogButtons,
- })
- .html(
- '' +
- ''
- )
- .parent()
- .attr('id','dw_davcal__createnew')
- .show()
- .appendTo('.dokuwiki:first');
-
- // attach event handlers
- jQuery('#dw_davcal__createnew .ui-dialog-titlebar-close').click(function(){
- dw_davcal__modals.hideNewEventDialog();
- });
- jQuery('#dw_davcal__eventfrom').datetimepicker({format:'YYYY-MM-DD',
- formatDate:'YYYY-MM-DD',
- datepicker: true,
- timepicker: false,
- });
- jQuery('#dw_davcal__eventfromtime').datetimepicker({format:'HH:mm',
- formatTime:'HH:mm',
- datepicker: false,
- timepicker: true,
- step: 15});
- jQuery('#dw_davcal__eventto').datetimepicker({format:'YYYY-MM-DD',
- formatDate:'YYYY-MM-DD',
- datepicker: true,
- timepicker: false,
- });
- jQuery('#dw_davcal__eventtotime').datetimepicker({format:'HH:mm',
- formatTime:'HH:mm',
- datepicker: false,
- timepicker: true,
- step:15});
- jQuery('#dw_davcal__allday').change(function() {
- if(jQuery(this).is(":checked"))
- {
- jQuery('#dw_davcal__eventfromtime').prop('readonly', true);
- jQuery('#dw_davcal__eventtotime').prop('readonly', true);
- }
- else
- {
- jQuery('#dw_davcal__eventfromtime').prop('readonly', false);
- jQuery('#dw_davcal__eventtotime').prop('readonly', false);
- }
- });
- },
-
- showConfirmDialog : function()
+ showDialog : function(confirm)
{
if(dw_davcal__modals.$confirmDialog)
return;
var dialogButtons = {};
- dialogButtons[LANG.plugins.davcal['yes']] = function() {
- jQuery.post(
- DOKU_BASE + 'lib/exe/ajax.php',
- {
- call: 'plugin_davcal',
- id: JSINFO.id,
- action: dw_davcal__modals.action,
- params: {
- uid: dw_davcal__modals.uid
+ var title = '';
+ if(confirm)
+ {
+ title = LANG.plugins.davcal['confirmation'];
+ dialogButtons[LANG.plugins.davcal['yes']] = function() {
+ jQuery.post(
+ DOKU_BASE + 'lib/exe/ajax.php',
+ {
+ call: 'plugin_davcal',
+ id: JSINFO.id,
+ action: dw_davcal__modals.action,
+ params: {
+ uid: dw_davcal__modals.uid
+ }
+ },
+ function(data)
+ {
+ dw_davcal__modals.completeCb(data);
}
- },
- function(data)
- {
- dw_davcal__modals.completeCb(data);
- }
- );
- dw_davcal__modals.hideConfirmDialog();
- };
- dialogButtons[LANG.plugins.tagrevisions['cancel']] = function() {
- dw_davcal__modals.hideConfirmDialog();
- };
- dw_davcal__modals.$confirmDialog = jQuery(document.createElement('div'))
+ );
+ dw_davcal__modals.hideDialog();
+ };
+ dialogButtons[LANG.plugins.tagrevisions['cancel']] = function() {
+ dw_davcal__modals.hideDialog();
+ };
+ }
+ else
+ {
+ title = LANG.plugins.davcal['info'];
+ dialogButtons[LANG.plugins.davcal['ok']] = function() {
+ dw_davcal__modals.hideDialog();
+ };
+ }
+ dw_davcal__modals.$dialog = jQuery(document.createElement('div'))
.dialog({
autoOpen: false,
draggable: true,
- title: LANG.plugins.tagrevisions['confirmation'],
+ title: title,
resizable: true,
buttons: dialogButtons,
})
.html(
'' + dw_davcal__modals.msg + '
'
)
.parent()
.attr('id','dw_davcal__confirm')
.show()
.appendTo('.dokuwiki:first');
// attach event handlers
jQuery('#dw_davcal__confirm .ui-dialog-titlebar-close').click(function(){
- dw_davcal__modals.hideConfirmDialog();
+ dw_davcal__modals.hideDialog();
});
},
- showInfoDialog : function() {
- if(dw_davcal__modal.$infoDialog)
- return;
- var dialogButtons = {};
- dialogButtons[LANG.plugins.davcal['ok']] = function() {
- dw_davcal__modals.hideInfoDialog();
- };
- dw_davcal__modals.$infoDialog = jQuery(document.createElement('div'))
- .dialog({
- autoOpen: false,
- draggable: true,
- title: LANG.plugins.davcal['info'],
- resizable: true,
- buttons: dialogButtons,
- })
- .html(
- '' + dw_davcal__modals.msg + '
'
- )
- .parent()
- .attr('id','dw_davcal__info')
- .show()
- .appendTo('.dokuwiki:first');
-
- // attach event handlers
- jQuery('#dw_davcal__info .ui-dialog-titlebar-close').click(function(){
- dw_davcal__modals.hideInfoDialog();
- });
- },
-
- hideNewEventDialog : function() {
- dw_davcal__modals.$newEventDialog.empty();
- dw_davcal__modals.$newEventDialog.remove();
- dw_davcal__modals.$newEventDialog = null;
- },
-
hideEditEventDialog : function() {
dw_davcal__modals.$editEventDialog.empty();
dw_davcal__modals.$editEventDialog.remove();
dw_davcal__modals.$editEventDialog = null;
},
- hideInfoDialog : function() {
- dw_davcal__modals.$infoDialog.empty();
- dw_davcal__modals.$infoDialog.remove();
- dw_davcal__modals.$infoDialog = null;
- },
-
- hideConfirmDialog: function() {
- dw_davcal__modals.$confirmDialog.empty();
- dw_davcal__modals.$confirmDialog.remove();
- dw_davcal__modals.$confirmDialog = null;
+ hideDialog: function() {
+ dw_davcal__modals.$dialog.empty();
+ dw_davcal__modals.$dialog.remove();
+ dw_davcal__modals.$dialog = null;
},
hideSettingsDialog: function() {
dw_davcal__modals.$settingsDialog.empty();
dw_davcal__modals.$settingsDialog.remove();
dw_davcal__modals.$settingsDialog = null;
}
};
diff --git a/style.css b/style.css
--- a/style.css
+++ b/style.css
@@ -1,54 +1,48 @@
@import "fullcalendar-2.4.0/fullcalendar.less";
@import "datetimepicker-2.4.5/jquery.datetimepicker.less";
/* modal windows */
-#dw_davcal__createnew,
#dw_davcal__edit,
-#dw_davcal__info,
#dw_davcal__settings,
#dw_davcal__confirm {
position: absolute;
background-color: #fff;
color: #000;
z-index: 20;
overflow: hidden;
}
#dw_davcal__edit .ui-dialog-content,
-#dw_davcal__info .ui-dialog-content,
#dw_davcal__confirm .ui-dialog-content,
-#dw_davcal__settings .ui-dialog-content,
-#dw_davcal__createnew .ui-dialog-content {
+#dw_davcal__settings .ui-dialog-content, {
padding-left: 0;
padding-right: 0;
}
#dw_davcal__confirm,
-#dw_davcal__info,
-#dw_davcal__edit,
-#dw_davcal__createnew {
+#dw_davcal__edit, {
position: absolute;
top: 50%;
left: 50%;
width: 300px;
height: 260px;
margin:-130px 0 0 -150px;
}
#dw_davcal__settings {
position: absolute;
top: 50%;
left: 50%;
width: 350px;
height: 320px;
margin:-160px 0 0 -175px;
}
.dw_davcal__date {
width: 90px;
}
.dw_davcal__time {
width: 50px;
}