Änderungen von Dokument Calendar Macro
Zuletzt geändert von xwikiadmin am 2025/01/07 11:31
Von Version 1.1
bearbeitet von xwikiadmin
am 2022/03/14 15:14
am 2022/03/14 15:14
Änderungskommentar:
Install extension [org.xwiki.contrib:macro-fullcalendar-ui/2.2.5]
Auf Version 3.1
bearbeitet von xwikiadmin
am 2022/08/11 17:49
am 2022/08/11 17:49
Änderungskommentar:
Install extension [org.xwiki.contrib:macro-fullcalendar-ui/2.2.11]
Zusammenfassung
-
Objekte (1 geändert, 0 hinzugefügt, 0 gelöscht)
Details
- XWiki.WikiMacroClass[0]
-
- Makro-Code
-
... ... @@ -1,6 +1,5 @@ 1 1 {{velocity}} 2 2 #set($discard = $xwiki.ssx.use("Calendar.FullCalendar")) 3 -#set ($discard = $xwiki.jsx.use('Calendar.FullCalendar')) 4 4 ## 5 5 #if($calcounter) 6 6 #set($calcounter = $calcounter + 1) ... ... @@ -105,139 +105,164 @@ 105 105 /************************************ 106 106 * Configure RequireJS to use jQuery-UI 107 107 ************************************/ 108 -require(['jquery', 'jqueryui', 'fullcalendar', 'gcal'], function ($) { 109 - function updateEvent(page, isResize, delta, allDay, revertFunc) { 110 - // Initialize notification boxes 111 - var savingBox = new XWiki.widgets.Notification("$!services.localization.render('xwiki.calendar.notification.inprogress')", "inprogress", {inactive: true}); 112 - var savedBox = new XWiki.widgets.Notification("$!services.localization.render('xwiki.calendar.notification.done')", "done", {inactive: true}); 113 - var failedBox = new XWiki.widgets.Notification("$!services.localization.render('xwiki.calendar.notification.error')", "error", {inactive: true}); 107 +require.config({ 108 + paths: { 109 + 'fullcalendar-setup': new XWiki.Document('FullCalendar', 'Calendar').getURL('jsx', 'minify=$!services.debug.minify') 110 + } 111 +}); 112 +require(['fullcalendar-setup'], function() { 113 + require(['jquery', 'jquery-ui', 'fullcalendar', 'gcal'], function ($) { 114 + function updateEvent(page, isResize, delta, allDay, revertFunc) { 115 + // Initialize notification boxes 116 + var savingBox = new XWiki.widgets.Notification("$!services.localization.render('xwiki.calendar.notification.inprogress')", "inprogress", {inactive: true}); 117 + var savedBox = new XWiki.widgets.Notification("$!services.localization.render('xwiki.calendar.notification.done')", "done", {inactive: true}); 118 + var failedBox = new XWiki.widgets.Notification("$!services.localization.render('xwiki.calendar.notification.error')", "error", {inactive: true}); 114 114 115 - // Display loading notification 116 - savingBox.show(); 117 - savedBox.hide(); 118 - failedBox.hide(); 120 + // Display loading notification 121 + savingBox.show(); 122 + savedBox.hide(); 123 + failedBox.hide(); 119 119 120 - // Compute days and minutes in order to keep backwards compatibility 121 - var dayDelta = delta._data.days; 122 - var minuteDelta = delta._data.hours * 60 + delta._data.minutes; 125 + // Compute days and minutes in order to keep backwards compatibility 126 + var dayDelta = delta._data.days; 127 + var minuteDelta = delta._data.hours * 60 + delta._data.minutes; 123 123 124 - // Let's call the calendar update 125 - var url = '$updateurl'; 126 - url = url + "#if($stringtool.contains($updateurl, "?"))&#{else}?#{end}xpage=plain&outputSyntax=plain&classname=$!{xcontext.macro.params.classname}&startfield=$!{xcontext.macro.params.startfield}&endfield=$!{xcontext.macro.params.endfield}&durationfield=$!{xcontext.macro.params.durationfield}&page=" + page + "&isResize=" + (isResize ? "1" : "0") + "&dayDelta=" + dayDelta + "&minuteDelta=" + minuteDelta + ((allDay) ? "&allDay=1" : ""); 129 + // Let's call the calendar update 130 + var url = '$updateurl'; 131 + url = url + "#if($stringtool.contains($updateurl, "?"))&#{else}?#{end}xpage=plain&outputSyntax=plain&classname=$!{xcontext.macro.params.classname}&startfield=$!{xcontext.macro.params.startfield}&endfield=$!{xcontext.macro.params.endfield}&durationfield=$!{xcontext.macro.params.durationfield}&page=" + page + "&isResize=" + (isResize ? "1" : "0") + "&dayDelta=" + dayDelta + "&minuteDelta=" + minuteDelta + ((allDay) ? "&allDay=1" : ""); 127 127 128 - $.ajax({ url: url }).fail(function(data) { 129 - savingBox.hide(); 130 - failedBox.show(); 131 - revertFunc(); 132 - }).success(function(data) { 133 - if (data.indexOf("OK") == 0) { 133 + $.ajax({ url: url }).fail(function(data) { 134 134 savingBox.hide(); 135 - savedBox.show(); 136 - } else { 137 - savingBox.hide(); 138 138 failedBox.show(); 139 139 revertFunc(); 140 - } 141 - }); 142 - } 137 + }).success(function(data) { 138 + if (data.indexOf("OK") == 0) { 139 + savingBox.hide(); 140 + savedBox.show(); 141 + } else { 142 + savingBox.hide(); 143 + failedBox.show(); 144 + revertFunc(); 145 + } 146 + }); 147 + } 143 143 144 - var monthNames = $!services.localization.render('xwiki.calendar.monthNames') 145 - var monthNamesShort = $!services.localization.render('xwiki.calendar.monthNamesShort'); 146 - var dayNames = $!services.localization.render('xwiki.calendar.dayNames'); 147 - var dayNamesShort = $!services.localization.render('xwiki.calendar.dayNamesShort'); 149 + var monthNames = $!services.localization.render('xwiki.calendar.monthNames') 150 + var monthNamesShort = $!services.localization.render('xwiki.calendar.monthNamesShort'); 151 + var dayNames = $!services.localization.render('xwiki.calendar.dayNames'); 152 + var dayNamesShort = $!services.localization.render('xwiki.calendar.dayNamesShort'); 148 148 149 - $(document).ready(function() { 150 - // The page is now ready, initialize the calendar... 151 - var progressNotification; 152 - $('#calendar${calcounter}').fullCalendar({ 153 - views: { 154 - month : { 155 - columnFormat: "$!services.localization.render('xwiki.calendar.columnFormat.month')", 156 - titleFormat: "$!services.localization.render('xwiki.calendar.titleFormat.month')", 157 - buttonText: "$!services.localization.render('xwiki.calendar.button.month')" 154 + function init() { 155 + // The page is now ready, initialize the calendar... 156 + var progressNotification; 157 + $('#calendar${calcounter}').fullCalendar({ 158 + views: { 159 + month : { 160 + columnFormat: "$!services.localization.render('xwiki.calendar.columnFormat.month')", 161 + titleFormat: "$!services.localization.render('xwiki.calendar.titleFormat.month')", 162 + buttonText: "$!services.localization.render('xwiki.calendar.button.month')" 163 + }, 164 + week : { 165 + columnFormat: "$!services.localization.render('xwiki.calendar.columnFormat.week')", 166 + titleFormat: "$!services.localization.render('xwiki.calendar.titleFormat.week')", 167 + buttonText: "$!services.localization.render('xwiki.calendar.button.week')" 168 + }, 169 + day : { 170 + columnFormat: "$!services.localization.render('xwiki.calendar.columnFormat.day')", 171 + titleFormat: "$!services.localization.render('xwiki.calendar.titleFormat.day')", 172 + buttonText: "$!services.localization.render('xwiki.calendar.button.day')" 173 + }, 174 + today: { 175 + buttonText: "$!services.localization.render('xwiki.calendar.button.today')" 176 + } 158 158 }, 159 - week : { 160 - columnFormat: "$!services.localization.render('xwiki.calendar.columnFormat.week')", 161 - titleFormat: "$!services.localization.render('xwiki.calendar.titleFormat.week')", 162 - buttonText: "$!services.localization.render('xwiki.calendar.button.week')" 163 - }, 164 - day : { 165 - columnFormat: "$!services.localization.render('xwiki.calendar.columnFormat.day')", 166 - titleFormat: "$!services.localization.render('xwiki.calendar.titleFormat.day')", 167 - buttonText: "$!services.localization.render('xwiki.calendar.button.day')" 168 - }, 169 - today: { 170 - buttonText: "$!services.localization.render('xwiki.calendar.button.today')" 171 - } 172 - }, 173 - timeFormat : "$!services.localization.render('xwiki.calendar.timeFormat')", 174 - axisFormat : "$!services.localization.render('xwiki.calendar.axisFormat')", 175 - allDayText : "$!services.localization.render('xwiki.calendar.allDayText')", 176 - monthNames : monthNames, 177 - monthNamesShort : monthNamesShort, 178 - dayNames : dayNames, 179 - dayNamesShort : dayNamesShort, 180 - googleCalendarApiKey : "$gApiKey", 181 - eventSources: [ 182 - #if("$!xcontext.macro.params.classname" != '') 183 - "${json}#if($stringtool.contains($json, "?"))&#{else}?#{end}xpage=plain&outputSyntax=plain&classname=$!{xcontext.macro.params.classname}&startfield=$!{xcontext.macro.params.startfield}&endfield=$!{xcontext.macro.params.endfield}&durationfield=$!{xcontext.macro.params.durationfield}&extraFields=$!{extraFields}" 184 - #end 185 - #if($!gCal != '') 186 - , 187 - #set($calendars = $stringtool.split($gCal, ',')) 188 - #foreach($calendar in $calendars) 189 - { googleCalendarId: "$stringtool.strip($calendar)" } 190 - #if($velocityCount < $calendars.size()) 191 - , 192 - #end 178 + timeFormat : "$!services.localization.render('xwiki.calendar.timeFormat')", 179 + axisFormat : "$!services.localization.render('xwiki.calendar.axisFormat')", 180 + allDayText : "$!services.localization.render('xwiki.calendar.allDayText')", 181 + monthNames : monthNames, 182 + monthNamesShort : monthNamesShort, 183 + dayNames : dayNames, 184 + dayNamesShort : dayNamesShort, 185 + googleCalendarApiKey : "$gApiKey", 186 + eventSources: [ 187 + #if($json != $jsonService || "$!xcontext.macro.params.classname" != '') 188 + "${json}#if($stringtool.contains($json, "?"))&#{else}?#{end}xpage=plain&outputSyntax=plain&classname=$!{xcontext.macro.params.classname}&startfield=$!{xcontext.macro.params.startfield}&endfield=$!{xcontext.macro.params.endfield}&durationfield=$!{xcontext.macro.params.durationfield}&extraFields=$!{extraFields}" 193 193 #end 194 - #end 195 - ], 196 - header: { 197 - left : '$left', 198 - center : '$center', 199 - right : '$right' 200 - } 201 - #if($timeFormat != ""), timeFormat : '$timeFormat' #end 202 - #if($defaultView != ""), defaultView : '$defaultView' #end 203 - #if($firstDay != ""), firstDay : '$firstDay' #end 204 - #if($firstHour != ""), firstHour : '$firstHour' #end 205 - #if($minTime != ""), minTime : '$minTime' #end 206 - #if($maxTime != ""), maxTime : '$maxTime' #end 207 - ,defaultDate : '${year}-${month}-${date}' 208 - ,editable : $editable 209 - ,eventDrop : function(event, delta, revertFunc) { 210 - updateEvent(event.id, false, delta, event._allDay, revertFunc); 211 - } 212 - ,eventResize : function(event, delta, revertFunc) { 213 - updateEvent(event.id, true, delta, false, revertFunc); 214 - }, 215 - eventRender: function(event, element) { 216 - // Add tooltip on the calendar element. 217 - var tooltip = ''; 218 - if (event.status) { 219 - tooltip = tooltip + "$services.localization.render('xwiki.calendar.event.status') " + event.status + '\n'; 190 + #if($!gCal != '') 191 + , 192 + #set($calendars = $stringtool.split($gCal, ',')) 193 + #foreach($calendar in $calendars) 194 + { googleCalendarId: "$stringtool.strip($calendar)" } 195 + #if($velocityCount < $calendars.size()) 196 + , 197 + #end 198 + #end 199 + #end 200 + ], 201 + header: { 202 + left : '$left', 203 + center : '$center', 204 + right : '$right' 220 220 } 221 - if (event.location) { 222 - tooltip = tooltip + "$services.localization.render('xwiki.calendar.event.location') " + event.location + '\n'; 206 + #if($timeFormat != ""), timeFormat : '$timeFormat' #end 207 + #if($defaultView != ""), defaultView : '$defaultView' #end 208 + #if($firstDay != ""), firstDay : '$firstDay' #end 209 + #if($firstHour != ""), firstHour : '$firstHour' #end 210 + #if($minTime != ""), minTime : '$minTime' #end 211 + #if($maxTime != ""), maxTime : '$maxTime' #end 212 + ,defaultDate : '${year}-${month}-${date}' 213 + ,editable : $editable 214 + ,eventDrop : function(event, delta, revertFunc) { 215 + updateEvent(event.id, false, delta, event._allDay, revertFunc); 223 223 } 224 - if (event.description) { 225 - tooltip = tooltip + "$services.localization.render('xwiki.calendar.event.description') " + event.description; 217 + ,eventResize : function(event, delta, revertFunc) { 218 + updateEvent(event.id, true, delta, false, revertFunc); 219 + }, 220 + eventRender: function(event, element) { 221 + // Add tooltip on the calendar element. 222 + var tooltip = ''; 223 + if (event.status) { 224 + tooltip = tooltip + "$services.localization.render('xwiki.calendar.event.status') " + event.status + '\n'; 225 + } 226 + if (event.location) { 227 + tooltip = tooltip + "$services.localization.render('xwiki.calendar.event.location') " + event.location + '\n'; 228 + } 229 + if (event.description) { 230 + tooltip = tooltip + "$services.localization.render('xwiki.calendar.event.description') " + event.description; 231 + } 232 + element.attr('title', tooltip); 233 + }, 234 + loading: function( isLoading) { 235 + if (isLoading) { 236 + if (typeof progressNotification === 'undefined') { 237 + progressNotification = new XWiki.widgets.Notification( 238 + "$escapetool.javascript($services.localization.render('xwiki.calendar.notification.loading'))", 'inprogress'); 239 + } else { 240 + var oldNotification = progressNotification; 241 + progressNotification = new XWiki.widgets.Notification( 242 + "$escapetool.javascript($services.localization.render('xwiki.calendar.notification.loading'))", 'inprogress'); 243 + oldNotification.replace(progressNotification); 244 + } 245 + } else { 246 + var oldNotification = progressNotification; 247 + progressNotification = new XWiki.widgets.Notification( 248 + "$escapetool.javascript($services.localization.render('xwiki.calendar.notification.loaded'))", 'done'); 249 + oldNotification.replace(progressNotification); 250 + } 226 226 } 227 - element.attr('title', tooltip); 228 - }, 229 - loading: function( isLoading) { 230 - if (isLoading) { 231 - progressNotification = new XWiki.widgets.Notification( 232 - "$escapetool.javascript($services.localization.render('xwiki.calendar.notification.loading'))", 'inprogress') 233 - } else { 234 - progressNotification.replace(new XWiki.widgets.Notification( 235 - "$escapetool.javascript($services.localization.render('xwiki.calendar.notification.loaded'))", 'done')); 236 - } 237 - } 252 + }); 253 + } 254 + 255 + // Load the calendar in edit mode. 256 + $(window).on('xwiki:dom:updated', function() { 257 + init(); 238 238 }); 259 + // Load the calendar in view mode. 260 + $(document).ready(function() { 261 + init(); 262 + }); 239 239 }); 240 240 }); 241 241 </script> 242 242 {{/html}} 243 -{{velocity}} 267 +{{/velocity}}