Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * Load the settings block tree javscript
18
 *
19
 * @module     block_settings/settingsblock
20
 * @copyright  2015 John Okely <john@moodle.com>
21
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
23
import {notifyBlockContentUpdated} from 'core_block/events';
24
import Tree from 'core/tree';
25
 
26
export const init = (instanceId, siteAdminNodeId) => {
27
    const adminTree = new Tree(".block_settings .block_tree");
28
    const blockNode = document.querySelector(`[data-instance-id="${instanceId}"]`);
29
 
30
    if (siteAdminNodeId) {
31
        const siteAdminLink = adminTree.treeRoot.get(0).querySelector(`#${siteAdminNodeId} a`);
32
        const newContainer = document.createElement('span');
33
        newContainer.setAttribute('tabindex', '0');
34
        siteAdminLink.childNodes.forEach(node => newContainer.appendChild(node));
35
        siteAdminLink.replaceWith(newContainer);
36
    }
37
 
38
    /**
39
     * The method to call when then the navtree finishes expanding a group.
40
     *
41
     * @method finishExpandingGroup
42
     * @param {Object} item
43
     * @fires event:blockContentUpdated
44
     */
45
    adminTree.finishExpandingGroup = function(item) {
46
        Tree.prototype.finishExpandingGroup.call(adminTree, item);
47
        notifyBlockContentUpdated(blockNode);
48
    };
49
 
50
    /**
51
     * The method to call whe then the navtree collapses a group
52
     *
53
     * @method collapseGroup
54
     * @param {Object} item
55
     * @fires event:blockContentUpdated
56
     */
57
    adminTree.collapseGroup = function(item) {
58
        Tree.prototype.collapseGroup.call(adminTree, item);
59
        notifyBlockContentUpdated(blockNode);
60
    };
61
};