1/* DOKUWIKI:include_once fullcalendar-2.4.0/moment.js */ 2/* DOKUWIKI:include_once fullcalendar-2.4.0/fullcalendar.js */ 3/* DOKUWIKI:include_once fullcalendar-2.4.0/lang/de.js */ 4/* DOKUWIKI:include_once fullcalendar-2.4.0/lang/en.js */ 5/* DOKUWIKI:include_once datetimepicker-2.4.5/jquery.datetimepicker.js */ 6/* DOKUWIKI:include_once jstz.js */ 7 8/** 9 * Initialize the DAVCal script, attaching some event handlers and triggering 10 * the initial load of the fullcalendar JS 11 */ 12jQuery(function() { 13 // Redefine functions for using moment.js with datetimepicker 14 15 Date.parseDate = function( input, format ){ 16 return moment(input,format).toDate(); 17 }; 18 Date.prototype.dateFormat = function( format ){ 19 return moment(this).format(format); 20 }; 21 22 // Attach to event links 23 var calendarpage = jQuery('#fullCalendar').data('calendarpage'); 24 if(!calendarpage) return; 25 dw_davcal__modals.page = calendarpage; 26 27 jQuery('div.fullCalendarSettings a').each(function() { 28 var $link = jQuery(this); 29 var href = $link.attr('href'); 30 if (!href) return; 31 32 $link.click( 33 function(e) { 34 dw_davcal__modals.showSettingsDialog(); 35 e.preventDefault(); 36 return ''; 37 } 38 ); 39 } 40 ); 41 42 // First, retrieve the current settings. 43 // Upon success, initialize fullcalendar. 44 var postArray = { }; 45 jQuery.post( 46 DOKU_BASE + 'lib/exe/ajax.php', 47 { 48 call: 'plugin_davcal', 49 id: dw_davcal__modals.page, 50 action: 'getSettings', 51 params: postArray 52 }, 53 function(data) 54 { 55 var result = data['result']; 56 if(result === true) 57 { 58 dw_davcal__modals.settings = data['settings']; 59 var wknum = false; 60 var tz = false; 61 var we = true; 62 var ro = false; 63 var firstday = 0; 64 var detectedTz = jstz.determine().name(); 65 dw_davcal__modals.detectedTz = detectedTz; 66 if(data['settings']['weeknumbers'] == 1) 67 wknum = true; 68 if(data['settings']['timezone'] !== '') 69 tz = data['settings']['timezone']; 70 if(data['settings']['workweek'] == 1) 71 we = false; 72 if(data['settings']['monday'] == 1) 73 firstday = 1; 74 // Initialize the davcal popup 75 var res = jQuery('#fullCalendar').fullCalendar({ 76 dayClick: function(date, jsEvent, view) { 77 dw_davcal__modals.showEditEventDialog(date, false); 78 }, 79 eventClick: function(calEvent, jsEvent, view) { 80 dw_davcal__modals.showEditEventDialog(calEvent, true); 81 }, 82 events: { 83 url: DOKU_BASE + 'lib/exe/ajax.php', 84 type: 'POST', 85 data: { 86 call: 'plugin_davcal', 87 action: 'getEvents', 88 id: dw_davcal__modals.page 89 }, 90 error: function() { 91 dw_davcal__modals.msg = LANG.plugins.davcal['error_retrieving_data']; 92 dw_davcal__modals.showDialog(false); 93 } 94 }, 95 header: { 96 left: 'title', 97 center: 'today prev,next', 98 right: 'month,agendaWeek,agendaDay' 99 }, 100 lang: JSINFO.plugin.davcal['language'], 101 weekNumbers: wknum, 102 timezone: tz, 103 weekends: we, 104 firstDay: firstday 105 }); 106 } 107 } 108 ); 109}); 110 111/** 112 * This holds all modal windows that DAVCal uses. 113 */ 114var dw_davcal__modals = { 115 $editEventDialog: null, 116 $dialog: null, 117 $settingsDialog: null, 118 msg: null, 119 completeCb: null, 120 action: null, 121 uid: null, 122 settings: null, 123 page: null, 124 detectedTz: null, 125 126 /** 127 * Show the settings dialog 128 */ 129 // FIXME: Hide URLs for multi-calendar 130 showSettingsDialog : function() { 131 if(dw_davcal__modals.$settingsDialog) 132 return; 133 134 // Dialog buttons are language-dependent and defined here. 135 // Attach event handlers for save and cancel. 136 var dialogButtons = {}; 137 dialogButtons[LANG.plugins.davcal['save']] = function() { 138 var postArray = { }; 139 jQuery("input[class=dw_davcal__settings], select[class=dw_davcal__settings]").each(function() { 140 if(jQuery(this).attr('type') == 'checkbox') 141 { 142 postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0; 143 } 144 else 145 { 146 postArray[jQuery(this).prop('name')] = jQuery(this).val(); 147 } 148 }); 149 jQuery('#dw_davcal__ajaxsettings').html('<img src="'+DOKU_BASE+'lib/images/throbber.gif" alt="" width="16" height="16" />'); 150 jQuery.post( 151 DOKU_BASE + 'lib/exe/ajax.php', 152 { 153 call: 'plugin_davcal', 154 id: dw_davcal__modals.page, 155 action: 'saveSettings', 156 params: postArray 157 }, 158 function(data) 159 { 160 var result = data['result']; 161 var html = data['html']; 162 jQuery('#dw_davcal__ajaxsettings').html(html); 163 if(result === true) 164 { 165 location.reload(); 166 } 167 } 168 ); 169 }; 170 dialogButtons[LANG.plugins.davcal['cancel']] = function () { 171 dw_davcal__modals.hideSettingsDialog(); 172 }; 173 174 dw_davcal__modals.$settingsDialog = jQuery(document.createElement('div')) 175 .dialog({ 176 autoOpen: false, 177 draggable: true, 178 title: LANG.plugins.davcal['settings'], 179 resizable: true, 180 buttons: dialogButtons, 181 }) 182 .html( 183 '<div><table>' + 184 //'<tr><td>' + LANG.plugins.davcal['use_lang_tz'] + '</td><td><input type="checkbox" name="use_lang_tz" id="dw_davcal__settings_use_lang_tz" class="dw_davcal__settings"></td></tr>' + 185 '<tr><td>' + LANG.plugins.davcal['timezone'] + '</td><td><select name="timezone" id="dw_davcal__settings_timezone" class="dw_davcal__settings"></select></td></tr>' + 186 '<tr><td>' + LANG.plugins.davcal['weeknumbers'] + '</td><td><input type="checkbox" name="weeknumbers" id="dw_davcal__settings_weeknumbers" class="dw_davcal__settings"></td></tr>' + 187 '<tr><td>' + LANG.plugins.davcal['only_workweek'] + '</td><td><input type="checkbox" name="workweek" id="dw_davcal__settings_workweek" class="dw_davcal__settings"></td></tr>' + 188 '<tr><td>' + LANG.plugins.davcal['start_monday'] + '</td><td><input type="checkbox" name="monday" id="dw_davcal__settings_monday" class="dw_davcal__settings"></td></tr>' + 189 '<tr id="dw_davcal__settings_syncurl"><td>' + LANG.plugins.davcal['sync_url'] + '</td><td><input type="text" name="syncurl" readonly="readonly" id="dw_davcal__settings_syncurl" class="dw_davcal__text" value="' + dw_davcal__modals.settings['syncurl'] + '"></td></tr>' + 190 '<tr id="dw_davcal__settings_privateurl"><td>' + LANG.plugins.davcal['private_url'] + '</td><td><input type="text" name="privateurl" readonly="readonly" id="dw_davcal__settings_privateurl" class="dw_davcal__text" value="' + dw_davcal__modals.settings['privateurl'] + '"></td></tr>' + 191 '</table>' + 192 '</div>' + 193 '<div id="dw_davcal__ajaxsettings"></div>' 194 ) 195 .parent() 196 .attr('id','dw_davcal__settings') 197 .show() 198 .appendTo('.dokuwiki:first'); 199 200 jQuery('#dw_davcal__settings').position({ 201 my: "center", 202 at: "center", 203 of: window 204 }); 205 206 // Initialize current settings 207 jQuery('#dw_davcal__settings_syncurl').on('click', function() { 208 jQuery(this).select(); 209 }); 210 211 jQuery('#dw_davcal__settings_privateurl').on('click', function() { 212 jQuery(this).select(); 213 }); 214 215 var $tzdropdown = jQuery('#dw_davcal__settings_timezone'); 216 jQuery('#fullCalendarTimezoneList option').each(function() { 217 jQuery('<option />', {value: jQuery(this).val(), 218 text: jQuery(this).text()}).appendTo($tzdropdown); 219 }); 220 221 if(dw_davcal__modals.settings) 222 { 223 if(dw_davcal__modals.settings['timezone'] !== '') 224 jQuery('#dw_davcal__settings_timezone').val(dw_davcal__modals.settings['timezone']); 225 if(dw_davcal__modals.settings['weeknumbers'] == 1) 226 jQuery('#dw_davcal__settings_weeknumbers').prop('checked', true); 227 else 228 jQuery('#dw_davcal__settings_weeknumbers').prop('checked', false); 229 230 if(dw_davcal__modals.settings['workweek'] == 1) 231 jQuery('#dw_davcal__settings_workweek').prop('checked', true); 232 else 233 jQuery('#dw_davcal__settings_workweek').prop('checked', false); 234 235 if(dw_davcal__modals.settings['monday'] == 1) 236 jQuery('#dw_davcal__settings_monday').prop('checked', true); 237 else 238 jQuery('#dw_davcal__settings_monday').prop('checked', false); 239 } 240 241 if(JSINFO.plugin.davcal['disable_sync']) 242 { 243 jQuery('#dw_davcal__settings_syncurl').remove(); 244 } 245 246 if(JSINFO.plugin.davcal['disable_ics']) 247 { 248 jQuery('#dw_davcal__settings_privateurl').remove(); 249 } 250 251 // attach event handlers 252 jQuery('#dw_davcal__settings .ui-dialog-titlebar-close').click(function(){ 253 dw_davcal__modals.hideSettingsDialog(); 254 }); 255 }, 256 257 /** 258 * Sanity-check our events. 259 * 260 * @return boolean false on failure, otherwise true 261 */ 262 checkEvents : function() { 263 // Retrieve dates 264 var allDay = jQuery('#dw_davcal__allday_edit').prop('checked'); 265 var startDate = moment(jQuery('#dw_davcal__eventfrom_edit').val(), 'YYYY-MM-DD'); 266 var endDate = moment(jQuery('#dw_davcal__eventto_edit').val(), 'YYYY-MM-DD'); 267 268 // Do the checking 269 if(!allDay) 270 { 271 var startTime = moment.duration(jQuery('#dw_davcal__eventfromtime_edit').val()); 272 var endTime = moment.duration(jQuery('#dw_davcal__eventtotime_edit').val()); 273 startDate.add(startTime); 274 endDate.add(endTime); 275 } 276 if(!startDate.isValid()) 277 { 278 dw_davcal__modals.msg = LANG.plugins.davcal['start_date_invalid']; 279 dw_davcal__modals.showDialog(false); 280 return false; 281 } 282 if(!endDate.isValid()) 283 { 284 dw_davcal__modals.msg = LANG.plugins.davcal['end_date_invalid']; 285 dw_davcal__modals.showDialog(false); 286 return false; 287 } 288 if(endDate.isBefore(startDate)) 289 { 290 dw_davcal__modals.msg = LANG.plugins.davcal['end_date_before_start_date']; 291 dw_davcal__modals.showDialog(false); 292 return false; 293 } 294 if(!allDay && endDate.isSame(startDate)) 295 { 296 dw_davcal__modals.msg = LANG.plugins.davcal['end_date_is_same_as_start_date']; 297 dw_davcal__modals.showDialog(false); 298 return false; 299 } 300 return true; 301 }, 302 303 /** 304 * Show the edit event dialog, which is also used to create new events 305 * @param {Object} event The event to create, that is the date or the calEvent 306 * @param {Object} edit Whether we edit (true) or create a new event (false) 307 */ 308 showEditEventDialog : function(event, edit) { 309 if(dw_davcal__modals.$editEventDialog) 310 return; 311 312 var readonly = dw_davcal__modals.settings['readonly']; 313 var title = ''; 314 var dialogButtons = {}; 315 var calEvent = []; 316 var recurringWarning = ''; 317 // Buttons are dependent on edit or create 318 // Several possibilities: 319 // 320 // 1) Somebody tries to edit, it is not recurring and not readonly -> show 321 // 2) Somebody tries to edit, it is recurring and not readonly -> message 322 // 3) Somebody tries to edit, it is readonly -> message 323 // 4) Somebody tries to create and it is readonly -> message 324 // 5) Somebody tries to create -> show 325 if(edit && (event.recurring != true) && (readonly === false)) 326 { 327 calEvent = event; 328 title = LANG.plugins.davcal['edit_event']; 329 dialogButtons[LANG.plugins.davcal['edit']] = function() { 330 if(!dw_davcal__modals.checkEvents()) 331 return; 332 var postArray = { }; 333 var pageid = dw_davcal__modals.page; 334 if(dw_davcal__modals.settings['multi']) 335 { 336 pageid = jQuery("#dw_davcal__editevent_calendar option:selected").val(); 337 } 338 jQuery("input.dw_davcal__editevent, textarea.dw_davcal__editevent").each(function() { 339 if(jQuery(this).attr('type') == 'checkbox') 340 { 341 postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0; 342 } 343 else 344 { 345 postArray[jQuery(this).prop('name')] = jQuery(this).val(); 346 } 347 }); 348 jQuery('#dw_davcal__ajaxedit').html('<img src="'+DOKU_BASE+'lib/images/throbber.gif" alt="" width="16" height="16" />'); 349 jQuery.post( 350 DOKU_BASE + 'lib/exe/ajax.php', 351 { 352 call: 'plugin_davcal', 353 id: pageid, 354 action: 'editEvent', 355 params: postArray 356 }, 357 function(data) 358 { 359 var result = data['result']; 360 var html = data['html']; 361 jQuery('#dw_davcal__ajaxedit').html(html); 362 if(result === true) 363 { 364 jQuery('#fullCalendar').fullCalendar('refetchEvents'); 365 dw_davcal__modals.hideEditEventDialog(); 366 } 367 } 368 ); 369 }; 370 dialogButtons[LANG.plugins.davcal['delete']] = function() { 371 dw_davcal__modals.action = 'deleteEvent'; 372 dw_davcal__modals.msg = LANG.plugins.davcal['really_delete_this_event']; 373 dw_davcal__modals.completeCb = function(data) { 374 var result = data['result']; 375 var html = data['html']; 376 jQuery('#dw_davcal__ajaxedit').html(html); 377 if(result === true) 378 { 379 jQuery('#fullCalendar').fullCalendar('refetchEvents'); 380 dw_davcal__modals.hideEditEventDialog(); 381 } 382 }; 383 dw_davcal__modals.showDialog(true); 384 }; 385 } 386 else if(edit && (event.recurring == true) && (readonly === false)) 387 { 388 calEvent = event; 389 title = LANG.plugins.davcal['edit_event']; 390 recurringWarning = LANG.plugins.davcal['recurring_cant_edit']; 391 } 392 else if(edit && (readonly === true)) 393 { 394 calEvent = event; 395 title = LANG.plugins.davcal['edit_event']; 396 recurringWarning = LANG.plugins.davcal['no_permission']; 397 } 398 else if(readonly === true) 399 { 400 calEvent.start = event; 401 calEvent.end = moment(event); 402 calEvent.start.hour(12); 403 calEvent.start.minute(0); 404 calEvent.end.hour(13); 405 calEvent.end.minute(0); 406 calEvent.allDay = false; 407 calEvent.recurring = false; 408 calEvent.title = ''; 409 calEvent.description = ''; 410 calEvent.id = '0'; 411 calEvent.page = dw_davcal__modals.page; 412 title = LANG.plugins.davcal['create_new_event']; 413 recurringWarning = LANG.plugins.davcal['no_permission']; 414 } 415 else 416 { 417 calEvent.start = event; 418 calEvent.end = moment(event); 419 calEvent.start.hour(12); 420 calEvent.start.minute(0); 421 calEvent.end.hour(13); 422 calEvent.end.minute(0); 423 calEvent.allDay = false; 424 calEvent.recurring = false; 425 calEvent.title = ''; 426 calEvent.description = ''; 427 calEvent.id = '0'; 428 calEvent.page = dw_davcal__modals.settings['calids'][0]['page']; 429 title = LANG.plugins.davcal['create_new_event']; 430 dialogButtons[LANG.plugins.davcal['create']] = function() { 431 if(!dw_davcal__modals.checkEvents()) 432 return; 433 434 var postArray = { }; 435 var pageid = dw_davcal__modals.page; 436 if(dw_davcal__modals.settings['multi']) 437 { 438 pageid = jQuery("#dw_davcal__editevent_calendar option:selected").val(); 439 } 440 jQuery("input.dw_davcal__editevent, textarea.dw_davcal__editevent").each(function() { 441 if(jQuery(this).attr('type') == 'checkbox') 442 { 443 postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0; 444 } 445 else 446 { 447 postArray[jQuery(this).prop('name')] = jQuery(this).val(); 448 } 449 }); 450 jQuery('#dw_davcal__ajaxedit').html('<img src="'+DOKU_BASE+'lib/images/throbber.gif" alt="" width="16" height="16" />'); 451 jQuery.post( 452 DOKU_BASE + 'lib/exe/ajax.php', 453 { 454 call: 'plugin_davcal', 455 id: pageid, 456 action: 'newEvent', 457 params: postArray 458 }, 459 function(data) 460 { 461 var result = data['result']; 462 var html = data['html']; 463 jQuery('#dw_davcal__ajaxedit').html(html); 464 if(result === true) 465 { 466 jQuery('#fullCalendar').fullCalendar('refetchEvents'); 467 dw_davcal__modals.hideEditEventDialog(); 468 } 469 } 470 ); 471 }; 472 } 473 dialogButtons[LANG.plugins.davcal['cancel']] = function() { 474 dw_davcal__modals.hideEditEventDialog(); 475 }; 476 dw_davcal__modals.uid = calEvent.id; 477 dw_davcal__modals.$editEventDialog = jQuery(document.createElement('div')) 478 .dialog({ 479 autoOpen: false, 480 draggable: true, 481 title: title, 482 resizable: true, 483 buttons: dialogButtons, 484 }) 485 .html( 486 '<div><table>' + 487 '<tr><td>' + LANG.plugins.davcal['calendar'] + '</td><td><select id="dw_davcal__editevent_calendar"></select></td></tr>' + 488 '<tr><td>' + LANG.plugins.davcal['title'] + '</td><td><input type="text" id="dw_davcal__eventname_edit" name="eventname" class="dw_davcal__editevent"></td></tr>' + 489 '<tr><td>' + LANG.plugins.davcal['description'] + '</td><td><textarea name="eventdescription" id="dw_davcal__eventdescription_edit" class="dw_davcal__editevent dw_davcal__text"></textarea></td></tr>' + 490 '<tr><td>' + LANG.plugins.davcal['from'] + '</td><td><input type="text" name="eventfrom" id="dw_davcal__eventfrom_edit" class="dw_davcal__editevent dw_davcal__date"><input type="text" name="eventfromtime" id="dw_davcal__eventfromtime_edit" class="dw_davcal__editevent dw_davcal__time"></td></tr>' + 491 '<tr><td>' + LANG.plugins.davcal['to'] + '</td><td><input type="text" name="eventto" id="dw_davcal__eventto_edit" class="dw_davcal__editevent dw_davcal__date"><input type="text" name="eventtotime" id="dw_davcal__eventtotime_edit" class="dw_davcal__editevent dw_davcal__time"></td></tr>' + 492 '<tr><td colspan="2"><input type="checkbox" name="allday" id="dw_davcal__allday_edit" class="dw_davcal__editevent">' + LANG.plugins.davcal['allday'] + '</td></tr>' + 493 '</table>' + 494 recurringWarning + 495 '<input type="hidden" name="uid" id="dw_davcal__uid_edit" class="dw_davcal__editevent">' + 496 '<input type="hidden" name="detectedtz" id="dw_davcal__tz_edit" class="dw_davcal__editevent">' + 497 '</div>' + 498 '<div id="dw_davcal__ajaxedit"></div>' 499 ) 500 .parent() 501 .attr('id','dw_davcal__edit') 502 .show() 503 .appendTo('.dokuwiki:first'); 504 505 jQuery('#dw_davcal__edit').position({ 506 my: "center", 507 at: "center", 508 of: window 509 }); 510 511 // Populate calendar dropdown 512 var $dropdown = jQuery("#dw_davcal__editevent_calendar"); 513 for(var i=0; i<dw_davcal__modals.settings['calids'].length; i++) 514 { 515 var sel = ''; 516 if(calEvent.page == dw_davcal__modals.settings['calids'][i]['page']) 517 sel = ' selected="selected"'; 518 $dropdown.append('<option value="' + dw_davcal__modals.settings['calids'][i]['page'] + '"' + sel + '>' + dw_davcal__modals.settings['calids'][i]['name'] + '</option>'); 519 } 520 if(edit || (dw_davcal__modals.settings['calids'].length < 1)) 521 { 522 $dropdown.prop('disabled', true); 523 } 524 525 // Set up existing/predefined values 526 jQuery('#dw_davcal__tz_edit').val(dw_davcal__modals.detectedTz); 527 jQuery('#dw_davcal__uid_edit').val(calEvent.id); 528 jQuery('#dw_davcal__eventname_edit').val(calEvent.title); 529 jQuery('#dw_davcal__eventfrom_edit').val(calEvent.start.format('YYYY-MM-DD')); 530 jQuery('#dw_davcal__eventfromtime_edit').val(calEvent.start.format('HH:mm')); 531 jQuery('#dw_davcal__eventdescription_edit').val(calEvent.description); 532 if(calEvent.allDay && (calEvent.end === null)) 533 { 534 jQuery('#dw_davcal__eventto_edit').val(calEvent.start.format('YYYY-MM-DD')); 535 jQuery('#dw_davcal__eventtotime_edit').val(calEvent.start.format('HH:mm')); 536 } 537 else if(calEvent.allDay) 538 { 539 endEvent = moment(calEvent.end); 540 endEvent.subtract(1, 'days'); 541 jQuery('#dw_davcal__eventto_edit').val(endEvent.format('YYYY-MM-DD')); 542 jQuery('#dw_davcal__eventotime_edit').val(endEvent.format('HH:mm')); 543 } 544 else 545 { 546 jQuery('#dw_davcal__eventto_edit').val(calEvent.end.format('YYYY-MM-DD')); 547 jQuery('#dw_davcal__eventtotime_edit').val(calEvent.end.format('HH:mm')); 548 } 549 jQuery('#dw_davcal__allday_edit').prop('checked', calEvent.allDay); 550 551 // attach event handlers 552 jQuery('#dw_davcal__edit .ui-dialog-titlebar-close').click(function(){ 553 dw_davcal__modals.hideEditEventDialog(); 554 }); 555 jQuery('#dw_davcal__eventfrom_edit').datetimepicker({format:'YYYY-MM-DD', 556 formatDate:'YYYY-MM-DD', 557 datepicker: true, 558 timepicker: false, 559 }); 560 jQuery('#dw_davcal__eventfromtime_edit').datetimepicker({format:'HH:mm', 561 formatTime:'HH:mm', 562 datepicker: false, 563 timepicker: true, 564 step: 15}); 565 jQuery('#dw_davcal__eventto_edit').datetimepicker({format:'YYYY-MM-DD', 566 formatDate:'YYYY-MM-DD', 567 datepicker: true, 568 timepicker: false, 569 }); 570 jQuery('#dw_davcal__eventtotime_edit').datetimepicker({format:'HH:mm', 571 formatTime:'HH:mm', 572 datepicker: false, 573 timepicker: true, 574 step:15}); 575 jQuery('#dw_davcal__allday_edit').change(function() { 576 if(jQuery(this).is(":checked")) 577 { 578 jQuery('#dw_davcal__eventfromtime_edit').prop('readonly', true); 579 jQuery('#dw_davcal__eventtotime_edit').prop('readonly', true); 580 } 581 else 582 { 583 jQuery('#dw_davcal__eventfromtime_edit').prop('readonly', false); 584 jQuery('#dw_davcal__eventtotime_edit').prop('readonly', false); 585 } 586 }); 587 jQuery('#dw_davcal__allday_edit').change(); 588 }, 589 590 /** 591 * Show an info/confirmation dialog 592 * @param {Object} confirm Whether a confirmation dialog (true) or an info dialog (false) is requested 593 */ 594 showDialog : function(confirm) 595 { 596 if(dw_davcal__modals.$confirmDialog) 597 return; 598 var dialogButtons = {}; 599 var title = ''; 600 if(confirm) 601 { 602 title = LANG.plugins.davcal['confirmation']; 603 var pageid = dw_davcal__modals.page; 604 if(dw_davcal__modals.settings['multi']) 605 { 606 pageid = jQuery("#dw_davcal__editevent_calendar option:selected").val(); 607 } 608 dialogButtons[LANG.plugins.davcal['yes']] = function() { 609 jQuery.post( 610 DOKU_BASE + 'lib/exe/ajax.php', 611 { 612 call: 'plugin_davcal', 613 id: pageid, 614 action: dw_davcal__modals.action, 615 params: { 616 uid: dw_davcal__modals.uid 617 } 618 }, 619 function(data) 620 { 621 dw_davcal__modals.completeCb(data); 622 } 623 ); 624 dw_davcal__modals.hideDialog(); 625 }; 626 dialogButtons[LANG.plugins.davcal['cancel']] = function() { 627 dw_davcal__modals.hideDialog(); 628 }; 629 } 630 else 631 { 632 title = LANG.plugins.davcal['info']; 633 dialogButtons[LANG.plugins.davcal['ok']] = function() { 634 dw_davcal__modals.hideDialog(); 635 }; 636 } 637 dw_davcal__modals.$dialog = jQuery(document.createElement('div')) 638 .dialog({ 639 autoOpen: false, 640 draggable: true, 641 title: title, 642 resizable: true, 643 buttons: dialogButtons, 644 }) 645 .html( 646 '<div>' + dw_davcal__modals.msg + '</div>' 647 ) 648 .parent() 649 .attr('id','dw_davcal__confirm') 650 .show() 651 .appendTo('.dokuwiki:first'); 652 653 jQuery('#dw_davcal__confirm').position({ 654 my: "center", 655 at: "center", 656 of: window 657 }); 658 // attach event handlers 659 jQuery('#dw_davcal__confirm .ui-dialog-titlebar-close').click(function(){ 660 dw_davcal__modals.hideDialog(); 661 }); 662 }, 663 664 /** 665 * Hide the edit event dialog 666 */ 667 hideEditEventDialog : function() { 668 dw_davcal__modals.$editEventDialog.empty(); 669 dw_davcal__modals.$editEventDialog.remove(); 670 dw_davcal__modals.$editEventDialog = null; 671 }, 672 673 /** 674 * Hide the confirm/info dialog 675 */ 676 hideDialog: function() { 677 dw_davcal__modals.$dialog.empty(); 678 dw_davcal__modals.$dialog.remove(); 679 dw_davcal__modals.$dialog = null; 680 }, 681 682 /** 683 * Hide the settings dialog 684 */ 685 hideSettingsDialog: function() { 686 dw_davcal__modals.$settingsDialog.empty(); 687 dw_davcal__modals.$settingsDialog.remove(); 688 dw_davcal__modals.$settingsDialog = null; 689 } 690}; 691