Changes for page Home
Last modified by Benjamin Fischer on 2025/06/04 14:20
From version 72.12
edited by Benjamin Fischer
on 2024/11/06 11:47
on 2024/11/06 11:47
Change comment:
There is no comment for this version
To version 72.52
edited by Benjamin Fischer
on 2024/11/07 12:03
on 2024/11/07 12:03
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 1 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -19,11 +19,15 @@ 19 19 = ErUM-Data Calendar = 20 20 21 21 {{velocity output="false"}} 22 +$xwiki.ssx.use("Calendar.FullCalendar") 22 22 $xwiki.jsx.use("Calendar.FullCalendar", {'defer': false}) 23 -$xwiki.jsx.use("M occaCalendar.Code.Macro", {'defer': false})24 +$xwiki.jsx.use("Main.WebHome", {'defer': false, 'minify': false}) 24 24 {{/velocity}} 25 25 26 -{{calendar json="/bin/get/MoccaCalendar/Code/JSONService?xpage=plain&outputSyntax=plain&calendarDoc=Main.WebHome&filter=wiki&classname=MoccaCalendar.MoccaCalendarEventClass&startfield=startDate&endfield=endDate&durationfield=" right="month,plainList" editable="false"/}} 27 +(% id="calendarCustom" %) 28 +((( 29 + 30 +))) 27 27 28 28 {{velocity}} 29 29 #set ($showcomments = false)
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -1,1 +1,146 @@ 1 -/* CUSTOM CALENDAR STUFF GOES HERE */ 1 +require(["jquery", "fullcalendar"], function (jq) { 2 + const FC = jq.fullCalendar; 3 + const E = (tag, ...childs) => { 4 + const attrs = childs[0]?.constructor === Object ? childs.shift() : {}; 5 + const ret = Element(tag, attrs); 6 + ret.append(...childs.flat().filter(e => e)); 7 + return ret; 8 + }; 9 + const range = num => Array(num).fill().map((_, i) => i); 10 + FC.defineView('monthCols', { 11 + class: FC.View.extend({ 12 + render() { 13 + console.debug("render"); 14 + }, 15 + renderSkeleton() { 16 + console.debug("renderSkeleton"); 17 + }, 18 + renderEvents(events) { 19 + console.debug("renderEvents", events); 20 + debugger; 21 + try { 22 + this._renderFun(events); 23 + } catch (e) { 24 + console.exception(e); 25 + } 26 + }, 27 + _renderFun(events) { 28 + const cf = this.opt("columnFormat") ?? "MMM"; 29 + const rf = this.opt("rowFormat") ?? "dd"; 30 + const df = this.opt("cellFormat") ?? "ddd"; 31 + const wf = this.opt("weekFormat") ?? "w"; 32 + const colspan = (df || wf) ? (1 + !!df + !!wf) : null; 33 + 34 + const ys = this.start; 35 + const ye = this.end; 36 + const yv = events.slice().sort((a,b) => a.start.diff(b.start) || a.end.diff(b.end)); 37 + 38 + const head = []; 39 + const days = Array(31).fill().map(_ => []); 40 + 41 + if (rf) { 42 + head.push(E("th")); 43 + days.forEach((arr, day) => arr.push(E("th", {class: "fc-axis"}, ys.clone().add({day}).format(rf)))); 44 + } 45 + 46 + for (const month in Array(12).fill()) { 47 + const ms = ys.clone().add({month}) 48 + const me = ms.clone().add({month: 1}); 49 + const md = me.diff(ms, "days"); 50 + const mv = yv.filter(t => ms.isBefore(t.end) || t.start.isBefore(me)); 51 + 52 + head.push(E("th", {colspan}, ms.format(cf))); 53 + 54 + const bgc = new Array(md); 55 + 56 + for (let day = 0; day < 31; day++) { 57 + if (day < md) { 58 + const ds = ms.clone().add({day}); 59 + const de = ds.clone().add({day: 1}); 60 + 61 + const oc = []; 62 + while(mv[0]?.start.isBefore(de)) { 63 + const v = mv.shift(); 64 + const d = Math.ceil(v.end.min(me).diff(ds, "days", true)); 65 + if (t.rendering == "background") 66 + if (t.color) 67 + for (let i=0; i<d; i++) 68 + bgc[day + i] = t.color; 69 + else { 70 + const e = E("div", t.title); 71 + e.style.height = `${100 * d}%`; 72 + if (t.color) e.style.borderColor = e.style.backgroundColor = t.color; 73 + if (t.textColor) e.style.color = t.textColor; 74 + oc.push(e); 75 + // TODO: soft-columns 76 + } 77 + } 78 + 79 + const da = {class: this.getDayClasses(d).join(" ")}; 80 + if (df) days[day].push(E("td", da, ds.format(df))); 81 + if (bgc[day]) da.style = `background-color: ${bgc[day]};`; 82 + days[day].push(E("td", da, oc)); 83 + if (wf) days[day].oush(E("td", ds.weekday() ? "" : ds.format(wf))); 84 + } else 85 + days[day].push(E("td", {colspan})); 86 + } 87 + } 88 + 89 + 90 + this.el.addClass("fc-month-cols-view").html( 91 + E( 92 + "table", 93 + E("thead", {class: "fc-head"}, E("tr", head)), 94 + E("tbody", {class: "fc-body"}, days.map(d => E("tr", d))), 95 + ) 96 + ); 97 + } 98 + }), 99 + duration: { year: 1 }, 100 + }); 101 + 102 + const init = () => { 103 + jq("#calendarCustom").fullCalendar({ 104 + views: { 105 + month: { 106 + columnFormat: "ddd", 107 + titleFormat: "MMMM YYYY", 108 + buttonText: "month", 109 + }, 110 + monthCols: { 111 + columnFormat: "MMM", 112 + titleFormat: "YYYY", 113 + buttonText: "year", 114 + }, 115 + }, 116 + timeFormat: "h(:mm)t", 117 + axisFormat: "h(:mm)t", 118 + allDayText: "All day", 119 + eventSources: [ 120 + "/bin/get/MoccaCalendar/Code/JSONService?xpage=plain&outputSyntax=plain&calendarDoc=Main.WebHome&filter=wiki&classname=MoccaCalendar.MoccaCalendarEventClass&startfield=startDate&endfield=endDate&durationfield=&xpage=plain&outputSyntax=plain&classname=&startfield=datetime&endfield=&durationfield=&extraFields=", 121 + ], 122 + header: { 123 + left: "prev,next today", 124 + center: "title", 125 + right: "month,monthCols", 126 + }, 127 + timeFormat: "H:mm", 128 + defaultView: "month", 129 + firstDay: "1", 130 + minTime: "8:00", 131 + maxTime: "23:00", 132 + defaultDate: "2024-11-06", 133 + editable: false, 134 + eventDataTransform: event => { 135 + if (event.url.split("/")[4] === "Holidays") event.rendering = "background"; 136 + return event; 137 + }, 138 + eventRender: function (event, element) { 139 + // Render augmentation hook, use: event.html 140 + }, 141 + }); 142 + }; 143 + 144 + jq(document).ready(init); 145 +}); 146 + - Use this extension
-
... ... @@ -1,1 +1,1 @@ 1 - currentPage1 +onDemand
- XWiki.StyleSheetExtension[0]
-
- Caching policy
-
... ... @@ -1,0 +1,1 @@ 1 +default - Code
-
... ... @@ -1,0 +1,5 @@ 1 +#calendarCustom { 2 + td.fc-sat, td.fc-sun { 3 + background-color: #f5f5f5; 4 + } 5 +} - Content Type
-
... ... @@ -1,0 +1,1 @@ 1 +LESS - Parse content
-
... ... @@ -1,0 +1,1 @@ 1 +No - Use this extension
-
... ... @@ -1,0 +1,1 @@ 1 +currentPage