605 Commits

Author SHA1 Message Date
Ferran Recio
804e138cb2 MDL-71209 core: reactive parent registration and updates
Now a reactive component could inherit the reactive instance from the
parent DOM element. This way components are more reusable. Apart, some
new state updates have been added. To the previous create, update and
delete, now the update message could provide also put and override,
making the state update message more REST alike and simplifying the
backend returns processing.
2021-08-20 16:49:06 +02:00
Andrew Nicols
530322e2ce MDL-69918 core: Update uses of legacy form change checker 2021-08-10 23:54:01 +08:00
Víctor Déniz
73a868c38d Merge branch 'MDL-72108-master' of git://github.com/andrewnicols/moodle 2021-07-21 19:25:54 +01:00
Andrew Nicols
36f21508fb MDL-72108 js: Fix incorrect jsdoc examples for core/ajax 2021-07-08 10:39:13 +08:00
Jun Pataleta
341578bfde MDL-61460 core: Create a copy to clipboard JS module
This works by adding event listeners for elements that contain
the 'copytoclipboard' "data-action" attribute through event delegation.
These trigger elements must also define a "data-clipboard-target"
attribute which contains the query selector for the target element
where text will be copied.

On success, a toast message is shown to the user that the text has
been copied to the clipboard. This success message can be customised
by passing a message string to the "data-clipboard-success-message"
attribute in the trigger element.

When the element's value or innerText cannot be found, a toast message
indicating that the text cannot be copied to the clipboard is shown.

The copy to clipboard functionality is primarily using the Clipboard API
but in the event that this is not available, e.g. the site is not
running on HTTPS, this falls back to the document.execCommand('copy')
approach of copying the text in the target container.

Special thanks to Andrew for improving this module with the event
delegation approach and improved fallback handling.

Co-authored-by: Andrew Lyons <andrew@nicols.co.uk>
2021-07-08 09:50:34 +08:00
Tim Hunt
0bb2d16337 MDL-68003 session timeout warning: don't show in iframes 2021-06-29 16:58:06 +01:00
Andrew Nicols
4f422785c6 MDL-71113 javascript: Improve basic JS Documentation 2021-06-18 09:38:05 +08:00
Andrew Nicols
92179b7057 MDL-71113 js: Fix all jsdoc warnings 2021-06-18 09:38:05 +08:00
Andrew Nicols
a9b0f4dafe Merge branch 'MDL-71134-master-v03' of git://github.com/ferranrecio/moodle 2021-06-14 11:52:35 +08:00
Ferran Recio
b85cba317e MDL-71134 core: add new reactive modules
The new course creation for Moodle 4.0 requires to add
some leavel of reactivity to the frontend. Instead of
building a specific solution only for the course editor,
in this commit there's a generic solution that can be
used in other places in Moodle to implement single
state reactive components.
2021-06-07 12:27:06 +02:00
Dongsheng Cai
e3690a392d MDL-70846 accessibility: update tree attributes to pass a11y check
- Move aria-* atrributes from <p> to <li>
- Move "role" attribute from <p> to <li>
- Update behat tests

Based on reference implementation from:
- https://www.w3.org/TR/wai-aria-practices-1.1/examples/treeview/treeview-2/treeview-2a.html
- https://www.w3.org/WAI/GL/wiki/Using_ARIA_trees
2021-06-03 13:52:04 +10:00
Andrew Nicols
743d17ff58 MDL-70990 core: Deprecate core/events::getLegacyEvents() 2021-05-26 10:49:01 +08:00
Andrew Nicols
d4c6ac20c7 MDL-70990 core_filter: Add new native filterContentUpdated event
The legacy M.core.event.FILTER_CONTENT_UPDATED event has been replaced with a
new core_filter/events::filterContentUpdated native DOM event.

The new event can be triggered using the `notifyFilterContentUpdated`
function, and by providing with an Array containing the HTMLElements
that were updated, for example:

```
import {notifyFilterContentUpdated} from 'core_filter/events';

const someHandler = e => {
    // ...
    const nodeList = Array.from(document.querySelectorAll('div'));
    notifyFilterContentUpdated(nodeList);
};
```

The new event can be listened to at any point in the DOM using the
following syntax:

```
import {eventTypes} from 'core_filter/events';

const handler = e => {
    // The list of HTMLElements in an Array.
    e.detail.nodes;
};

document.addEventListener(eventTypes.filterContentUpdated, handler);
```

A backward-compatabibility layer is included to ensure that any legacy
YUI event listener, or jQuery event listener are still called with the
same arguments.

This legacy bridges will be removed after Moodle 4.3.
2021-05-26 10:47:15 +08:00
Andrew Nicols
a44cee78f1 MDL-70990 core_editor: Replace EDITOR_CONTENT_RESTORED event
The legacy M.core.event.EDITOR_CONTENT_RESTORED event has been replaced
with a new core_editor/events::editorContentRestored native DOM event.

The new event can be listened to at any point in the DOM using the
following syntax:

```
import {eventTypes} from 'core_editor/events';

document.addEventListener(eventTypes.editorContentRestored, handler);
```

A backward-compatabibility layer is included to ensure that any legacy
jQuery event is still called with the same arguments.

This legacy bridge will be removed after Moodle 4.3.
2021-05-26 10:47:03 +08:00
Andrew Nicols
acd9d9823b MDL-70990 core_form: Replace FORM_SUBMIT_AJAX event
The legacy M.core.event.FORM_SUBMIT_AJAX ecent has been replaced with a
new core_form/events::formSubmittedByJavascript native DOM event.

The new event can be listened to at any point in the DOM using the
following syntax:

```
import {eventTypes} from 'core_form/events';

document.addEventListener(eventTypes.formSubmittedByJavascript, handler);
```

A backward-compatabibility layer is included to ensure that any
legacy YUI event triggered on a form is still respected and the new
native event is also fired.

A similar handler is also included to ensure that any legacy YUI event
listener is still called with the same arguments.

These legacy bridges will be removed after Moodle 4.3.
2021-05-26 10:46:49 +08:00
Andrew Nicols
da8658e49a MDL-70990 core: Rewrite core/event as ES6 2021-05-26 10:45:21 +08:00
Jun Pataleta
97429f82b4 Merge branch 'MDL-71157-master' of git://github.com/sarjona/moodle 2021-05-20 12:30:15 +08:00
Andrew Nicols
dfaa450621 MDL-71157 core: Pending JS in paged content bars 2021-05-19 09:30:15 +02:00
Dongsheng Cai
ee58790e46 MDL-65203 template: tab should be quoted to produce valid json 2021-05-18 20:40:32 +10:00
Mikel Martín
5fade7fcc6 MDL-71089 core: Add different Toast notification styling 'types' 2021-04-13 16:28:35 +02:00
Eloy Lafuente (stronk7)
c06ed30430 Merge branch 'MDL-70802-master' of git://github.com/andrewnicols/moodle 2021-04-08 18:30:13 +02:00
Paul Holden
11099c15bb MDL-70962 forms: catch modal exceptions when getting body content.
They are thrown in the following circumstances:

 * The dynamic form class doesn't exist;
 * It does exist but it's `check_access` method throws exception

Co-Authored-By: Andrew Nicols <andrew@nicols.co.uk>
2021-03-25 17:26:36 +00:00
Andrew Nicols
1b7ce2dd0d MDL-70802 javascript: Normalise component consistently in templates 2021-03-24 11:18:33 +08:00
Ilya Tregubov
eaf40e050e MDL-69680 lib: Replace deprecated jQuery functions 2021-03-04 12:48:26 +08:00
Marina Glancy
72be49c473 MDL-64554 core_form: new API for modal forms 2021-02-17 18:06:49 +01:00
Andrew Nicols
6995888454 Merge branch 'MDL-69748-master' of git://github.com/rezaies/moodle 2021-02-04 11:51:57 +08:00
Shamim Rezaie
a321181fe6 MDL-69748 core: Fix hideif issue with array elements
Changed the element selector to get all array elements,
whether named or unnamed. The previus selector was only
working for elements that thir names were like name="something[]".
It was not working for name="something[a]" elements.
2021-02-04 14:37:40 +11:00
Sara Arjona
1e5a862c93 Merge branch 'MDL-70316-master' of git://github.com/mihailges/moodle 2021-02-03 15:29:23 +01:00
Ilya Tregubov
e174f19db6 MDL-70304 core: updated adapter.js to 7.4.0 2021-02-02 08:58:30 +02:00
Mihail Geshoski
517069bc8e MDL-70316 core: Upgrade emoji-data to 6.0.0 2021-01-27 13:35:44 +08:00
Sara Arjona
fea8fb3e92 Merge branch 'MDL-70305-master' of git://github.com/peterRd/moodle 2021-01-18 09:20:21 +01:00
Peter Dias
a0573603e6 MDL-70305 lib: Update thirdpartylibs chartjs version 2021-01-14 07:54:19 +08:00
Peter Dias
79ee30c6ca MDL-70305 lib: Upgrade chartjs to 2.9.4 2021-01-14 07:36:35 +08:00
Sara Arjona
b3164b3253 Merge branch 'MDL-70299' of git://github.com/paulholden/moodle 2021-01-13 17:19:50 +01:00
Jun Pataleta
81cb8b9f09 Merge branch 'MDL-70580' of git://github.com/paulholden/moodle 2021-01-13 10:20:20 +08:00
Paul Holden
be48efc9b7 MDL-70580 core: retrieve closest tree node in click handler. 2021-01-12 20:11:25 +00:00
Jun Pataleta
495f45ef3b Merge branch 'MDL-70580' of git://github.com/paulholden/moodle 2021-01-12 13:16:00 +08:00
Andrew Nicols
d0bc893972 MDL-70580 core: Tree nodes should check if they were clicked directly 2021-01-11 23:42:03 +00:00
Paul Holden
67f137832d MDL-70299 libraries: upgrade to version 1.7.1 of loglevel. 2021-01-08 09:55:03 +00:00
Dmitrii Metelkin
21789c7168 MDL-70352 core: attach modal to a specific element 2020-12-31 14:02:20 +11:00
Andrew Nicols
eed01bbc94 Merge branch 'MDL-65856' of https://github.com/hdagheda/moodle 2020-12-22 09:38:01 +08:00
Heena Agheda
9c5dc8fc7d MDL-65856 session: UX review of session timeout
Add new setting 'sessiontimeoutwarning', gives logged in user ability to extend session when there is no activity.
2020-12-21 08:43:21 +11:00
Sara Arjona
8099deda48 Merge branch 'MDL-69107-master-2' of git://github.com/andrewnicols/moodle 2020-12-18 15:22:09 +01:00
Andrew Nicols
f07d3b71d2 MDL-69107 form_autocomplete: Rewrite item selection
The form_autocomplete is essentially a custom element. Unfortunately the
`setValue()` function in Mink has undesired actions so it is necessary
to write our own handling for it.

The standard Mink `setValue()` function focuses the element, sets a
value, and then blurs the element. In the case of the autocomplete this
can cause the autocomplete suggestions list to be closed in some
situations. Instead of using the setValue we click, and type the value,
but do not immediately blur.
2020-12-15 09:08:05 +08:00
Tom Dickman
c00fc9707f MDL-67623 block overview: fix pagination regression
Fixed a regression caused by MDL-64194 resulting in Dashboard - Course
overview pagination not working from second page of courses onwards.

Course overview block should now do the following:
- Display no pagination controls when user has no courses
- Display no pagination controls when less than 12 courses to display
- Only display pagination controls up to the number of courses user is
enrolled in
- Work correctly when on a page greater than the second page.
2020-12-14 13:15:26 +11:00
Andrew Nicols
cd3809653c Merge branch 'MDL-70320' of https://github.com/timhunt/moodle 2020-12-09 11:56:05 +08:00
Mihail Geshoski
16b72504b3 MDL-57614 core: Fetch blocks through a webservice in add block modal 2020-12-02 13:43:15 +08:00
Tim Hunt
374d3e7700 MDL-70320 permission overrides: role names were double-escaped 2020-11-25 21:19:57 +00:00
Eloy Lafuente (stronk7)
de317c2cd4 Merge branch 'MDL-67513-master-fix' of https://github.com/andrewnicols/moodle into master 2020-11-16 09:17:31 +01:00
Andrew Nicols
78962293ef MDL-67513 core: Only move modal to body if currently attached
A previous change as part of this commitset was intended to move the
modal to the document.body, but where the modal had been destroyed it
was instead added back to the body.
2020-11-16 15:19:32 +08:00