1/* DOKUWIKI:include_once script/jscalendar-1.0/calendar.js */ 2/* DOKUWIKI:include_once script/jscalendar-1.0/calendar-setup.js */ 3/* DOKUWIKI:include_once script/jscalendar-1.0/lang/calendar-en.js */ 4/* DOKUWIKI:include_once script/jscalendar-1.0/lang/calendar-de.js */ 5/** 6 * DokuWiki Plugin datepicker (JavaScript Component) 7 * 8 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 9 * @author lisps 10 */ 11var EMPTYSTRINGWEEK; 12var EMPTYSTRINGDATE; 13function datepickerInit(id,emptyString) 14{ 15 Calendar.setup({ 16 ifFormat : "%Y-%m-%d", // format of the input field (even if hidden, this format will be honored) 17 displayArea : "datepicker__show__"+id, // ID of the span where the date is to be shown 18 daFormat : "%Y-%m-%d",// format of the displayed date 19 button : "datepicker__button__"+id, // trigger button (well, IMG in our case) 20 align : "Br", // alignment (defaults to "Bl") 21 singleClick : true, 22 onUpdate : datepickeronUpdate, 23 electric : false, 24 firstDay : 1 25 }); 26 EMPTYSTRINGDATE = emptyString; 27} 28 29function weekpickerInit(id,emptyString) 30{ 31 Calendar.setup({ 32 ifFormat : "%W/%y", // format of the input field (even if hidden, this format will be honored) 33 displayArea : "weekpicker__show__"+id, // ID of the span where the date is to be shown 34 daFormat : "%W/%y",// format of the displayed date 35 button : "weekpicker__button__"+id, // trigger button (well, IMG in our case) 36 align : "Br", // alignment (defaults to "Bl") 37 singleClick : true, 38 onUpdate : weekpickeronUpdate, 39 firstDay : 1, 40 electric : false 41 }); 42 EMPTYSTRINGWEEK = emptyString; 43} 44 45function datepickeronUpdate(calendar) 46{ 47 mode = 'datepicker'; 48 par = calendar.params; 49 50 if(par.displayArea.innerHTML == ''){ 51 par.displayArea.innerHTML = EMPTYSTRINGDATE; 52 datestr = ''; 53 } 54 else { 55 datestr = calendar.date.print(par.daFormat); 56 } 57 var idx = null; 58 if(jQuery("#"+par.displayArea.id).parents('div.sortable').length != 0) { 59 idx = jQuery("#"+par.displayArea.id).data("plugin-datepicker-idx"); 60 } else { 61 idx = ajaxedit_getIdxByIdClass(par.displayArea.id, //DOM-id 62 'datepicker'); //DOM-class 63 } 64 ajaxedit_send2( 65 'datepicker', //pluginname 66 idx, 67 datepickerdone, //success-function 68 { 69 datestr:datestr, 70 mode:mode, 71 //id, 72 } 73 ); 74} 75 76function weekpickeronUpdate(calendar) 77{ 78 mode = 'weekpicker'; 79 par = calendar.params; 80 if(par.displayArea.innerHTML == ''){ 81 par.displayArea.innerHTML = EMPTYSTRINGWEEK; 82 datestr = ''; 83 } 84 else { 85 datestr = calendar.date.print(par.daFormat); 86 } 87 88 ajaxedit_send2( 89 'datepicker', //pluginname 90 ajaxedit_getIdxByIdClass( 91 par.displayArea.id, //DOM-id 92 'weekpicker'), //DOM-class 93 datepickerdone, //success-function 94 { 95 datestr:datestr, 96 mode:mode, 97 //id, 98 } 99 ); 100} 101 102function datepickerdone(data) 103{ 104 ret = ajaxedit_parse(data); 105 ajaxedit_checkResponse(ret); 106} 107