Proyectos de Subversion Moodle

Rev

Rev 738 | | 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 universe theme for moodle
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
// universe main JS file
19
//
20
// @package    theme_universe
21
// @copyright  Copyright © 2021 onwards Marcin Czaja Rosea Themes
22
//
23
// @license    Commercial
24
 
25
/* jshint ignore:start */
1441 ariadna 26
define(['jquery', 'core/aria', 'core_user/repository'], function ($, setUserPreference, UserRepository) {
27
    "use strict"; // ...jshint ;_; !!!
1 efrain 28
 
1441 ariadna 29
    return {
30
        init: function () {
31
            $(document).ready(function ($) {
32
 
33
                var trigger = $(document.getElementById("darkModeBtn"));
34
                var preference = trigger.attr('data-preference');
1 efrain 35
 
1441 ariadna 36
                $('#darkModeBtn').click(function () {
37
                    if ($('body').hasClass('theme-dark')) {
38
                        $('body').removeClass('theme-dark');
39
                        $('html').removeClass('dark-mode');
40
                        trigger.attr('aria-checked', 'false');
41
                        UserRepository.setUserPreference(preference, false);
42
                    } else {
43
                        $('body').addClass('theme-dark');
44
                        $('html').addClass('dark-mode');
45
                        trigger.attr('aria-checked', 'true');
46
                        UserRepository.setUserPreference(preference, true);
47
                    }
48
                });
1 efrain 49
 
1441 ariadna 50
                $('#courseIndexBtn').click(function () {
51
                    if ($('body').hasClass('drawer-open-index--open')) {
52
                        $('body').removeClass('drawer-courseindex--open');
53
                        $('body').removeClass('drawer-open-index--open');
54
                    } else {
55
                        $('body').toggleClass('drawer-courseindex--open');
56
                    }
57
                });
1 efrain 58
 
1441 ariadna 59
                $('.drawertoggle').click(function () {
60
                    if ($('body').hasClass('drawer-open-index--open')) {
61
                        $('body').removeClass('drawer-courseindex--open');
62
                        $('body').removeClass('drawer-open-index--open');
63
                    } else {
64
                        $('body').toggleClass('drawer-courseindex--open');
65
                    }
66
                });
1 efrain 67
 
1441 ariadna 68
                $('#courseindexbtn, .bulkEnable').click(function () {
69
                    $(function () {
70
                        $('#course-tab2').tab('show');
71
                    });
72
                });
1 efrain 73
 
1441 ariadna 74
                $( document ).ready(function() {
75
                    if ($("body.drawer-open-index--open, body.drawer-courseindex--open").length) {
76
                        $('#course-tab2').tab('show');
77
                    }
78
                });
1 efrain 79
 
1441 ariadna 80
                $('#mobileNav, .rui-mobile-nav-btn-close').click(function () {
81
                    $('#topBar').toggleClass('opened');
82
                });
1 efrain 83
 
1441 ariadna 84
                $("#showBlockArea").on("click", function () {
85
                    $('body').toggleClass('rui-edit-areas');
86
                    $('#showBlockArea').toggleClass('active');
87
                });
1 efrain 88
 
1441 ariadna 89
                $('.rui-nav--admin .nav-link').each(function () {
90
                    var text = $(this).html();
91
                    $(this).html(text.replace('(', '<span class="mt-1 small d-block">'));
92
                });
93
                $('.rui-nav--admin .nav-link').each(function () {
94
                    var text = $(this).html();
95
                    $(this).html(text.replace(')', '</span>'));
96
                });
97
            });
98
 
99
        }
100
    };
1 efrain 101
});
102
/* jshint ignore:end */