Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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 core/local/toast/message
19
 
20
    Template to render a Toast notification.
21
 
22
    Classes required for JS:
23
    * none
24
 
25
    Data attributes required for JS:
26
    * none
27
 
28
    Example context (json):
29
    {
30
        "data": 200,
31
        "autohide": true,
32
        "Message": "Cubing negative numbers is tough",
33
        "title": "Negative numbers",
34
        "subtitle": "Cubing",
35
        "type": "info",
36
        "closebutton": true
37
    }
38
}}
1441 ariadna 39
<div id="toast-{{uniqid}}" class="toast mx-auto {{#type}}toast-{{type}}{{/type}}" data-bs-delay="{{delay}}" {{^autohide}}data-bs-autohide="false"{{/autohide}}>
1 efrain 40
    {{#title}}
41
    <div class="toast-header">
42
        <span class="toast-title">{{{title}}}</span>
1441 ariadna 43
        {{#subtitle}}<span class="toast-subtitle ms-auto small">{{{subtitle}}}</span>{{/subtitle}}
1 efrain 44
    </div>
45
    {{/title}}
46
    <div class="toast-body d-flex">
47
        <div class="toast-message px-1">{{{message}}}</div>
48
        {{#closeButton}}
1441 ariadna 49
        <button type="button" class="ms-auto align-self-baseline btn-close" data-bs-dismiss="toast" aria-label="{{#str}}dismissnotification, core{{/str}}"></button>
1 efrain 50
        {{/closeButton}}
51
    </div>
52
</div>
53
{{#js}}
1441 ariadna 54
require(['theme_boost/bootstrap/toast'], function(Toast) {
1 efrain 55
    // Show the toast.
1441 ariadna 56
    const toastTrigger = document.getElementById('toast-{{uniqid}}');
57
    new Toast(toastTrigger).show();
1 efrain 58
 
1441 ariadna 59
    // Remove the toast from the DOM when it is hidden.
60
    toastTrigger.addEventListener('hidden.bs.toast', function() {
61
        toastTrigger.remove();
1 efrain 62
    });
63
});
64
{{/js}}