1 |
efrain |
1 |
{{!
|
|
|
2 |
This file is part of Moodle - http://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 mod_unilabel/colourpicker
|
|
|
19 |
Template to show a colour picker in the content settings form to choose the background colour.
|
|
|
20 |
|
|
|
21 |
Example context (json):
|
|
|
22 |
{
|
|
|
23 |
"iconurl": "https://example.com/theme/image.php/svg_bootstrap4/core/1544826417/i/colourpicker",
|
|
|
24 |
"inputname": "unilabeltype_carousel_background",
|
|
|
25 |
"inputid": "id_unilabeltype_carousel_background_colourpicker",
|
|
|
26 |
"hiddeninputid": "id_unilabeltype_carousel_background_colourpicker_hidden",
|
|
|
27 |
"label": "Background",
|
|
|
28 |
"defaultvalue": "#A0E2FD",
|
|
|
29 |
"testing": true
|
|
|
30 |
}
|
|
|
31 |
}}
|
|
|
32 |
|
|
|
33 |
<div class="form-group row fitem ">
|
|
|
34 |
<div class="col-md-3">
|
|
|
35 |
<span class="float-sm-right text-nowrap"> </span>
|
|
|
36 |
<label class="col-form-label d-inline " for="{{inputid}}">
|
|
|
37 |
{{label}}
|
|
|
38 |
</label>
|
|
|
39 |
</div>
|
|
|
40 |
|
|
|
41 |
<div class="col-md-9 form-inline felement" data-fieldtype="text">
|
|
|
42 |
<div class="form-colourpicker defaultsnext">
|
|
|
43 |
<div id="imgclicker_{{uniqid}}" class="admin_colourpicker clearfix">
|
|
|
44 |
<img alt="" class="colourdialogue" src="{{{iconurl}}}">
|
|
|
45 |
<div class="previewcolour" style="width: 50px; height: 50px; background-color: rgb(137, 27, 0);"></div>
|
|
|
46 |
<div class="currentcolour" style="width: 50px; height: 49px; background-color: rgb(58, 69, 75);"></div>
|
|
|
47 |
</div>
|
|
|
48 |
<input type="hidden" name="{{inputname}}" id="{{hiddeninputid}}" value="{{{defaultvalue}}}" class="form-control text-ltr">{{!
|
|
|
49 |
The next input field is only for parsing mustache. A visible input field is expected but not available here
|
|
|
50 |
because it is defined in a moodle form where this mustache is called.
|
|
|
51 |
}}{{#testing}}<input type="text" id="{{inputid}}">{{/testing}}
|
|
|
52 |
</div>
|
|
|
53 |
</div>
|
|
|
54 |
</div>
|
|
|
55 |
{{#js}}
|
|
|
56 |
require(['mod_unilabel/colourpicker'], function(colourpicker) {
|
|
|
57 |
colourpicker.init(
|
|
|
58 |
"imgclicker_{{uniqid}} img",
|
|
|
59 |
"{{hiddeninputid}}",
|
|
|
60 |
"{{inputid}}"
|
|
|
61 |
);
|
|
|
62 |
});
|
|
|
63 |
{{/js}}
|