Changes for page Calendar Macro
Last modified by Benjamin Fischer on 2025/07/01 00:06
From version 3.1
edited by Benjamin Fischer
on 2025/04/29 00:08
on 2025/04/29 00:08
Change comment:
Migrated property [executionIsolated] from class [XWiki.WikiMacroClass]
To version 1.1
edited by Benjamin Fischer
on 2024/07/26 12:42
on 2024/07/26 12:42
Change comment:
Install extension [org.xwiki.contrib:macro-fullcalendar/2.0.3]
Summary
-
Objects (1 modified, 0 added, 2 removed)
Details
- XWiki.WikiMacroClass[0]
-
- Macro code
-
... ... @@ -1,4 +1,8 @@ 1 1 {{velocity}} 2 +#set($discard = $xwiki.jsx.use("Calendar.JQuery", {'defer': false, 'minify': false})) 3 +#set($discard = $xwiki.jsx.use("Calendar.JQueryUI", {'defer': false, 'minify': false})) 4 +#set($discard = $xwiki.jsx.use("Calendar.Moment", {'defer': false, 'minify': false})) 5 +#set($discard = $xwiki.jsx.use("Calendar.FullCalendar", {'defer': false, 'minify': false})) 2 2 #set($discard = $xwiki.ssx.use("Calendar.FullCalendar")) 3 3 ## 4 4 #if($calcounter) ... ... @@ -80,16 +80,10 @@ 80 80 #if(!$editable) 81 81 #set($editable = "false") 82 82 #end 83 -#set($extraFields = $xcontext.macro.params.extraFields) 84 -#set($json = $xwiki.getDocument('Calendar.JSONService').getURL('get')) 85 -#if ($xcontext.macro.params.json) 86 - #set($json = $xcontext.macro.params.json) 87 +#set($json = $xcontext.macro.params.json) 88 +#if(!$json) 89 + #set($json = $xwiki.getDocument("Calendar.JSONService").getURL("get")) 87 87 #end 88 -#set($iCal = $xcontext.macro.params.iCal) 89 -#if ($iCal) 90 - ## The iCal format is serialized as JSON and should be used only when the JSON parameter is not specified. 91 - #set($json = $xwiki.getDocument('Calendar.ICalToJSON').getURL('get', "iCal=$escapetool.url($iCal)")) 92 -#end 93 93 #set($updateurl = $xcontext.macro.params.updateurl) 94 94 #if(!$updateurl) 95 95 #set($updateurl = $xwiki.getDocument("Calendar.UpdateService").getURL("get")) ... ... @@ -101,167 +101,111 @@ 101 101 #set($gCal = $xcontext.macro.params.gCal) 102 102 {{html clean="false"}} 103 103 <script> 104 -/************************************ 105 - * Configure RequireJS to use jQuery-UI 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}); 102 +require(['fullcalendar', 'gcal'], function ($) { 103 + function updateEvent(page, isResize, delta, allDay, revertFunc) { 104 + // Initialize notification boxes 105 + var savingBox = new XWiki.widgets.Notification("$!services.localization.render('xwiki.calendar.notification.inprogress')", "inprogress", {inactive: true}); 106 + var savedBox = new XWiki.widgets.Notification("$!services.localization.render('xwiki.calendar.notification.done')", "done", {inactive: true}); 107 + var failedBox = new XWiki.widgets.Notification("$!services.localization.render('xwiki.calendar.notification.error')", "error", {inactive: true}); 119 119 120 - 121 - 122 - 123 - 109 + // Display loading notification 110 + savingBox.show(); 111 + savedBox.hide(); 112 + failedBox.hide(); 124 124 125 - 126 - 127 - 114 + // Compute days and minutes in order to keep backwards compatibility 115 + var dayDelta = delta._data.days; 116 + var minuteDelta = delta._data.hours * 60 + delta._data.minutes; 128 128 129 - 130 - 131 - 118 + // Let's call the calendar update 119 + var url = '$updateurl'; 120 + 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) { 122 + jQuery.ajax({ url: url }).fail(function(data) { 123 + savingBox.hide(); 124 + failedBox.show(); 125 + revertFunc(); 126 + }).success(function(data) { 127 + if (data.indexOf("OK") == 0) { 134 134 savingBox.hide(); 129 + savedBox.show(); 130 + } else { 131 + 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 - } 134 + } 135 + }); 136 + } 148 148 149 - 150 - 151 - 152 - 138 + var monthNames = $!services.localization.render('xwiki.calendar.monthNames') 139 + var monthNamesShort = $!services.localization.render('xwiki.calendar.monthNamesShort'); 140 + var dayNames = $!services.localization.render('xwiki.calendar.dayNames'); 141 + 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 - } 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}" 143 + jQuery(document).ready(function() { 144 + // The page is now ready, initialize the calendar... 145 + jQuery('#calendar${calcounter}').fullCalendar({ 146 + columnFormat: { 147 + month : "$!services.localization.render('xwiki.calendar.columnFormat.month')", 148 + week : "$!services.localization.render('xwiki.calendar.columnFormat.week')", 149 + day : "$!services.localization.render('xwiki.calendar.columnFormat.day')" 150 + }, 151 + titleFormat: { 152 + month : "$!services.localization.render('xwiki.calendar.titleFormat.month')", 153 + week : "$!services.localization.render('xwiki.calendar.titleFormat.week')", 154 + day : "$!services.localization.render('xwiki.calendar.titleFormat.day')" 155 + }, 156 + buttonText: { 157 + today : "$!services.localization.render('xwiki.calendar.button.today')", 158 + day : "$!services.localization.render('xwiki.calendar.button.day')", 159 + week : "$!services.localization.render('xwiki.calendar.button.week')", 160 + month : "$!services.localization.render('xwiki.calendar.button.month')" 161 + }, 162 + timeFormat : "$!services.localization.render('xwiki.calendar.timeFormat')", 163 + axisFormat : "$!services.localization.render('xwiki.calendar.axisFormat')", 164 + allDayText : "$!services.localization.render('xwiki.calendar.allDayText')", 165 + monthNames : monthNames, 166 + monthNamesShort : monthNamesShort, 167 + dayNames : dayNames, 168 + dayNamesShort : dayNamesShort, 169 + googleCalendarApiKey : "$gApiKey", 170 + eventSources: [ 171 + #if($json != $jsonService || $!{xcontext.macro.params.classname} != '') 172 + "${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}" 173 + #end 174 + #if($!gCal != '') 175 + , 176 + #set($calendars = $stringtool.split($gCal, ',')) 177 + #foreach($calendar in $calendars) 178 + { googleCalendarId: "$stringtool.strip($calendar)" } 179 + #if($velocityCount < $calendars.size()) 180 + , 181 + #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($foreach.count < $calendars.size()) 196 - , 197 - #end 198 - #end 199 - #end 200 - ], 201 - header: { 202 - left : '$left', 203 - center : '$center', 204 - right : '$right' 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); 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 - } 251 - } 252 - }); 253 - } 254 - 255 - // Load the calendar in edit mode. 256 - $(window).on('xwiki:dom:updated', function() { 257 - init(); 258 - }); 259 - // Load the calendar in view mode. 260 - $(document).ready(function() { 261 - init(); 262 - }); 183 + #end 184 + ], 185 + header: { 186 + left : '$left', 187 + center : '$center', 188 + right : '$right' 189 + } 190 + #if($timeFormat != ""), timeFormat : '$timeFormat' #end 191 + #if($defaultView != ""), defaultView : '$defaultView' #end 192 + #if($firstDay != ""), firstDay : '$firstDay' #end 193 + #if($firstHour != ""), firstHour : '$firstHour' #end 194 + #if($minTime != ""), minTime : '$minTime' #end 195 + #if($maxTime != ""), maxTime : '$maxTime' #end 196 + ,defaultDate : '${year}-${month}-${date}' 197 + ,editable : $editable 198 + ,eventDrop : function(event, delta, revertFunc) { 199 + updateEvent(event.id, false, delta, event._allDay, revertFunc); 200 + } 201 + ,eventResize : function(event, delta, revertFunc) { 202 + updateEvent(event.id, true, delta, false, revertFunc); 203 + } 204 + }) 263 263 }); 264 264 }); 265 265 </script> 266 266 {{/html}} 267 -{{ /velocity}}209 +{{velocity}}
- XWiki.WikiMacroParameterClass[17]
-
- Parameter description
-
... ... @@ -1,1 +1,0 @@ 1 -The URL to access a calendar in iCal format (.ics file). If this parameter is used, the JSON one should be empty. - Parameter mandatory
-
... ... @@ -1,1 +1,0 @@ 1 -No - Parameter name
-
... ... @@ -1,1 +1,0 @@ 1 -iCal
- XWiki.WikiMacroParameterClass[18]
-
- Parameter description
-
... ... @@ -1,1 +1,0 @@ 1 -Provide extra fields to be displayed in the event tooltip. An empty list or a list of exactly 3 values that represent event description, event location and event status, in this order, is expected. - Parameter mandatory
-
... ... @@ -1,1 +1,0 @@ 1 -No - Parameter name
-
... ... @@ -1,1 +1,0 @@ 1 -extraFields