| 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">
 | 
        
           | 233 | ariadna | 28 |                         <div id="static-blocks" class="block-region tab-content d-none" data-droptarget="1">
 | 
        
           | 198 | ariadna | 29 |                             <h2 class="sr-only">Bloques</h2>
 | 
        
           |  |  | 30 |                             {{{ blocks }}}
 | 
        
           |  |  | 31 |                         </div>
 | 
        
           |  |  | 32 |                     </section>
 | 
        
           |  |  | 33 |                 </div>
 | 
        
           |  |  | 34 |         </div>
 | 
        
           |  |  | 35 |     </div>
 | 
        
           |  |  | 36 | </div>
 | 
        
           |  |  | 37 | {{#js}}
 | 
        
           |  |  | 38 | M.util.js_pending('theme_universe/loader');
 | 
        
           |  |  | 39 | require(['theme_universe/loader', 'jquery'], function(Loader, $) {
 | 
        
           |  |  | 40 |     M.util.js_complete('theme_universe/loader');
 | 
        
           |  |  | 41 |   | 
        
           |  |  | 42 |     function renderBlockButtons(){
 | 
        
           |  |  | 43 |         const buttonsContainer = $("#blocks_buttons");
 | 
        
           |  |  | 44 |         const blocksContainer = $(".block-region");
 | 
        
           |  |  | 45 |         const blocks = blocksContainer.find("section.block").toArray();
 | 
        
           |  |  | 46 |   | 
        
           |  |  | 47 |         const blocksObjs = []
 | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 |         $(blocks).each((index, block) => {
 | 
        
           |  |  | 50 |             const blckId = $(block).attr("id").trim()
 | 
        
           |  |  | 51 |             const blckTitle = $(block).find(".card-title").text()
 | 
        
           |  |  | 52 |   | 
        
           |  |  | 53 |             $(block).addClass("tab-pane fade")
 | 
        
           |  |  | 54 |             if(index === 0) $(block).addClass("active show")
 | 
        
           |  |  | 55 |   | 
        
           |  |  | 56 |             const blckObj = { id: blckId, title: blckTitle }
 | 
        
           |  |  | 57 |   | 
        
           |  |  | 58 |             blocksObjs.push(blckObj)
 | 
        
           |  |  | 59 |         })
 | 
        
           |  |  | 60 |   | 
        
           |  |  | 61 |         blocksObjs.forEach(({ id, title }, index)=> {
 | 
        
           |  |  | 62 |             const blockBtn = `
 | 
        
           |  |  | 63 |                 <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>
 | 
        
           |  |  | 64 |             `
 | 
        
           |  |  | 65 |   | 
        
           |  |  | 66 |             buttonsContainer.append(blockBtn)
 | 
        
           | 233 | ariadna | 67 |             $(blocksContainer).removeClass("d-none")
 | 
        
           | 198 | ariadna | 68 |         })
 | 
        
           |  |  | 69 |     }
 | 
        
           |  |  | 70 |   | 
        
           |  |  | 71 |     renderBlockButtons()
 | 
        
           |  |  | 72 | });
 | 
        
           |  |  | 73 | {{/js}}
 |