Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
910 ariadna 1
// This file is part of Moodle - http://moodle.org/
2
//
3
// Moodle is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
7
//
8
// Moodle is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
 
16
/**
17
 * Add Pending JS checks to stock Bootstrap transitions.
18
 *
19
 * @module     theme_universe/pending
20
 * @copyright  2019 Andrew Nicols <andrew@nicols.co.uk>
21
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
23
 
24
import jQuery from 'jquery';
25
const moduleTransitions = {
26
    alert: [
27
        // Alert.
28
        {
29
            start: 'close',
30
            end: 'closed',
31
        },
32
    ],
33
 
34
    carousel: [
35
        {
36
            start: 'slide',
37
            end: 'slid',
38
        },
39
    ],
40
 
41
    collapse: [
42
        {
43
            start: 'hide',
44
            end: 'hidden',
45
        },
46
        {
47
            start: 'show',
48
            end: 'shown',
49
        },
50
    ],
51
 
52
    dropdown: [
53
        {
54
            start: 'hide',
55
            end: 'hidden',
56
        },
57
        {
58
            start: 'show',
59
            end: 'shown',
60
        },
61
    ],
62
 
63
    modal: [
64
        {
65
            start: 'hide',
66
            end: 'hidden',
67
        },
68
        {
69
            start: 'show',
70
            end: 'shown',
71
        },
72
    ],
73
 
74
    popover: [
75
        {
76
            start: 'hide',
77
            end: 'hidden',
78
        },
79
        {
80
            start: 'show',
81
            end: 'shown',
82
        },
83
    ],
84
 
85
    tab: [
86
        {
87
            start: 'hide',
88
            end: 'hidden',
89
        },
90
        {
91
            start: 'show',
92
            end: 'shown',
93
        },
94
    ],
95
 
96
    toast: [
97
        {
98
            start: 'hide',
99
            end: 'hidden',
100
        },
101
        {
102
            start: 'show',
103
            end: 'shown',
104
        },
105
    ],
106
 
107
    tooltip: [
108
        {
109
            start: 'hide',
110
            end: 'hidden',
111
        },
112
        {
113
            start: 'show',
114
            end: 'shown',
115
        },
116
    ],
117
};
118
 
119
export default () => {
120
    Object.entries(moduleTransitions).forEach(([key, pairs]) => {
121
        pairs.forEach(pair => {
122
            const eventStart = `${pair.start}.bs.${key}`;
123
            const eventEnd = `${pair.end}.bs.${key}`;
124
            jQuery(document.body).on(eventStart, e => {
125
                M.util.js_pending(eventEnd);
126
                jQuery(e.target).one(eventEnd, () => {
127
                    M.util.js_complete(eventEnd);
128
                });
129
            });
130
 
131
        });
132
    });
133
};