Änderungen von Dokument Calendar Macro
Zuletzt geändert von xwikiadmin am 2025/01/07 11:31
Von 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]
Auf Version 2.1
bearbeitet von xwikiadmin
am 2022/08/11 16:36
am 2022/08/11 16:36
Änderungskommentar:
Migrated property [defaultCategories] from class [XWiki.WikiMacroClass]
Zusammenfassung
-
Objekte (1 geändert, 0 hinzugefügt, 0 gelöscht)
Details
- XWiki.WikiMacroClass[0]
-
- Makro-Code
-
... ... @@ -1,5 +1,6 @@ 1 1 {{velocity}} 2 2 #set($discard = $xwiki.ssx.use("Calendar.FullCalendar")) 3 +#set ($discard = $xwiki.jsx.use('Calendar.FullCalendar')) 3 3 ## 4 4 #if($calcounter) 5 5 #set($calcounter = $calcounter + 1) ... ... @@ -104,164 +104,139 @@ 104 104 /************************************ 105 105 * Configure RequireJS to use jQuery-UI 106 106 ************************************/ 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}); 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}); 119 119 120 - 121 - 122 - 123 - 115 + // Display loading notification 116 + savingBox.show(); 117 + savedBox.hide(); 118 + failedBox.hide(); 124 124 125 - 126 - 127 - 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; 128 128 129 - 130 - 131 - 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" : ""); 132 132 133 - $.ajax({ url: url }).fail(function(data) { 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) { 134 134 savingBox.hide(); 135 + savedBox.show(); 136 + } else { 137 + savingBox.hide(); 135 135 failedBox.show(); 136 136 revertFunc(); 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 - } 140 + } 141 + }); 142 + } 148 148 149 - 150 - 151 - 152 - 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'); 153 153 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 - } 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')" 177 177 }, 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}" 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 189 189 #end 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' 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'; 205 205 } 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); 221 + if (event.location) { 222 + tooltip = tooltip + "$services.localization.render('xwiki.calendar.event.location') " + event.location + '\n'; 216 216 } 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 - } 224 + if (event.description) { 225 + tooltip = tooltip + "$services.localization.render('xwiki.calendar.event.description') " + event.description; 251 251 } 252 - }); 253 - } 254 - 255 - // Load the calendar in edit mode. 256 - $(window).on('xwiki:dom:updated', function() { 257 - init(); 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 + } 258 258 }); 259 - // Load the calendar in view mode. 260 - $(document).ready(function() { 261 - init(); 262 - }); 263 263 }); 264 264 }); 265 265 </script> 266 266 {{/html}} 267 -{{ /velocity}}243 +{{velocity}}