Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

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