1 |
efrain |
1 |
{{!
|
|
|
2 |
This file is part of Moodle - https://moodle.org/
|
|
|
3 |
|
|
|
4 |
Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
it under the terms of the GNU General Public License as published by
|
|
|
6 |
the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
(at your option) any later version.
|
|
|
8 |
|
|
|
9 |
Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
GNU General Public License for more details.
|
|
|
13 |
|
|
|
14 |
You should have received a copy of the GNU General Public License
|
|
|
15 |
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
}}
|
|
|
17 |
{{!
|
|
|
18 |
@template question_ordering/proxyhtml
|
|
|
19 |
|
|
|
20 |
The user actually drags a proxy object, which is constructed from this template.
|
|
|
21 |
The proxy node is then added directly as a child of <body>. Your CSS also needs to ensure
|
|
|
22 |
that this proxy has position: absolute.
|
|
|
23 |
|
|
|
24 |
Classes required for JS:
|
|
|
25 |
* none
|
|
|
26 |
|
|
|
27 |
Data attributes required for JS:
|
|
|
28 |
* none
|
|
|
29 |
|
|
|
30 |
Context variables required for this template:
|
|
|
31 |
* listClassName The token is replaced with the class attribute of the list being dragged.
|
|
|
32 |
* itemClassName The token is replaced with the class attribute of the item being dragged.
|
|
|
33 |
Because of this, the styling of the contents of your list item needs to work for the proxy,
|
|
|
34 |
as well as for items in place in the context of the list
|
|
|
35 |
* itemHtml The token is replaced with the innerHtml of the item being dragged.
|
|
|
36 |
* proxyStyles Passed in styles detailing the size of the proxy, and its position relative to the mouse.
|
|
|
37 |
|
|
|
38 |
Example context (json):
|
|
|
39 |
{
|
|
|
40 |
"listClassName": "osep-list",
|
|
|
41 |
"itemClassName": "osep-item osep-itemmoving",
|
|
|
42 |
"itemHtml": "Item 1",
|
|
|
43 |
"proxyStyles": "left: 0px; top: 0px; width: 100px; height: 100px;"
|
|
|
44 |
}
|
|
|
45 |
}}
|
|
|
46 |
<div class="que ordering dragproxy" style="position: absolute; {{proxyStyles}}">
|
|
|
47 |
<ul class="{{listClassName}}">
|
|
|
48 |
<li class="{{itemClassName}} item-moving">{{{itemHtml}}}</li>
|
|
|
49 |
</ul>
|
|
|
50 |
</div>
|