antoniop
committed
on 25 Jan 24
Move custom calendar widget javascript implementation out of the core.js and into a separate file

In core/maintained packages, this widget … Show more
Move custom calendar widget javascript implementation out of the core.js and into a separate file

In core/maintained packages, this widget is used only by template::widget::textdate (which in turn is used nowhere). For this widget, we can include the relevant code on-demand.

Direct usages found in unsupported packages have been adapted by adding the extra requirement on the fly.

It is unclear if we should keep maintaining a calendar widget in our codebase, however, as the current one still works (kudos to the original author), we do not deprecate it for the time being.

It is also true that a custom widget provides a way to customize the look and feel of date fields, which is otherwise completely delegated to the browser.

Various packages, including the core, provide custom css styling for the current widget.

Show less

openacs-4/.../www/resources/core.js (+1 -1)
39 39     if (!form) {
40 40         return;
41 41     }
42 42
43 43     //
44 44     // Sometimes is convenient to have a single page serving the
45 45     // purpose of multiple bulk-actions, for instance
46 46     // "do-bulk-stuff?action=1" and "do-bulk-stuff?action=2".
47 47     //
48 48     // To do so, we parse the URL searching for query parameters. If
49 49     // there are, we inject them into the bulk-actions form together
50 50     // with the rest of the request.
51 51     //
52 52     // Note that the variables specified this way have total
53 53     // precedence and will override those specified differently.
54 54     //
55 55
56 56     //
57 57     // Parse the URL
58 58     //
59       const queryString = url.split('?')[1];
  59     const queryString = url.slice(url.indexOf('?') + 1);
60 60     const searchParams = new window.URLSearchParams(queryString);
61 61
62 62     //
63 63     // Cleanup pre-existing variable conflicting with the URL ones
64 64     //
65 65     for (const [name, value] of searchParams) {
66 66         for (const e of form.querySelectorAll(`[name='${name}']`)) {
67 67             //
68 68             // "e" may not be a direct child of the form
69 69             //
70 70             e.remove();
71 71         }
72 72     }
73 73
74 74     //
75 75     // Inject the variables in the form.
76 76     //
77 77     // Note that most browsers now support the "formdata" event, that
78 78     // can be use to manipulate the FormData object directly on the
79 79     // form before this is submitted. However, Safari only introduced