Proyectos de Subversion Moodle

Rev

Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
198 ariadna 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
   Admin Header Link with Icon
19
}}
20
<div class="rui-blocks-wrapper wrapper--with-margin wrapper-xl">
21
    <div class="wrapper-page-withblocks">
22
        <div class="card text-center">
23
                <div class="card-header">
24
                    <div class="nav btn-group d-inline-flex mx-auto" id="blocks_buttons"></div>
25
                </div>
26
                <div class="card-body">
27
                    <section class="d-print-none" aria-label="Bloques">
28
                        <div id="static-blocks" class="block-region tab-content" data-droptarget="1">
29
                            <h2 class="sr-only">Bloques</h2>
30
                            {{{ blocks }}}
31
 
32
                        </div>
33
                    </section>
34
                </div>
35
        </div>
36
    </div>
37
</div>
38
{{#js}}
39
M.util.js_pending('theme_universe/loader');
40
require(['theme_universe/loader', 'jquery'], function(Loader, $) {
41
    M.util.js_complete('theme_universe/loader');
42
 
43
    function renderBlockButtons(){
44
        const buttonsContainer = $("#blocks_buttons");
45
        const blocksContainer = $(".block-region");
46
        const blocks = blocksContainer.find("section.block").toArray();
47
 
48
        $(blocksContainer).addClass("tab-content")
49
 
50
        const blocksObjs = []
51
 
52
        $(blocks).each((index, block) => {
53
            const blckId = $(block).attr("id").trim()
54
            const blckTitle = $(block).find(".card-title").text()
55
 
56
            $(block).addClass("tab-pane fade")
57
            if(index === 0) $(block).addClass("active show")
58
 
59
            const blckObj = { id: blckId, title: blckTitle }
60
 
61
            blocksObjs.push(blckObj)
62
        })
63
 
64
        blocksObjs.forEach(({ id, title }, index)=> {
65
            const blockBtn = `
66
                <button class="btn nav-link ${index === 0 ? 'active' : ''}" data-toggle="tab" data-target="#${id}" type="button" role="tab" aria-controls="nav-home" aria-selected="true">${title}</button>
67
            `
68
 
69
            buttonsContainer.append(blockBtn)
70
        })
71
    }
72
 
73
    renderBlockButtons()
74
});
75
{{/js}}