| 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 */
|
| 736 |
ariadna |
26 |
define(["jquery", "core/aria", "core_user/repository"], function (
|
|
|
27 |
$,
|
|
|
28 |
setUserPreference,
|
|
|
29 |
UserRepository
|
|
|
30 |
) {
|
|
|
31 |
"use strict"; // ...jshint ;_; !!!
|
| 1 |
efrain |
32 |
|
| 736 |
ariadna |
33 |
return {
|
|
|
34 |
init: function () {
|
|
|
35 |
$(document).ready(function ($) {
|
|
|
36 |
var trigger = $(document.getElementById("darkModeBtn"));
|
|
|
37 |
var preference = trigger.attr("data-preference");
|
| 1 |
efrain |
38 |
|
| 736 |
ariadna |
39 |
$("#darkModeBtn").click(function () {
|
|
|
40 |
if ($("body").hasClass("theme-dark")) {
|
|
|
41 |
$("body").removeClass("theme-dark");
|
|
|
42 |
$("html").removeClass("dark-mode");
|
|
|
43 |
trigger.attr("aria-checked", "false");
|
|
|
44 |
UserRepository.setUserPreference(preference, false);
|
|
|
45 |
} else {
|
|
|
46 |
$("body").addClass("theme-dark");
|
|
|
47 |
$("html").addClass("dark-mode");
|
|
|
48 |
trigger.attr("aria-checked", "true");
|
|
|
49 |
UserRepository.setUserPreference(preference, true);
|
|
|
50 |
}
|
|
|
51 |
});
|
| 1 |
efrain |
52 |
|
| 736 |
ariadna |
53 |
$(".btn-drawer--left").click(function () {
|
|
|
54 |
if ($("body").hasClass("drawer-open-index--open")) {
|
|
|
55 |
$("body").removeClass("drawer-courseindex--open");
|
|
|
56 |
$("body").removeClass("drawer-open-index--open");
|
|
|
57 |
} else {
|
|
|
58 |
$("body").toggleClass("drawer-courseindex--open");
|
|
|
59 |
}
|
|
|
60 |
});
|
| 1 |
efrain |
61 |
|
| 736 |
ariadna |
62 |
$(".drawertoggle").click(function () {
|
|
|
63 |
if ($("body").hasClass("drawer-open-index--open")) {
|
|
|
64 |
$("body").removeClass("drawer-courseindex--open");
|
|
|
65 |
$("body").removeClass("drawer-open-index--open");
|
|
|
66 |
} else {
|
|
|
67 |
$("body").toggleClass("drawer-courseindex--open");
|
|
|
68 |
}
|
|
|
69 |
});
|
| 1 |
efrain |
70 |
|
| 736 |
ariadna |
71 |
$("#courseindexbtn, .bulkEnable").click(function () {
|
|
|
72 |
$(function () {
|
| 737 |
ariadna |
73 |
const coursetab = $("#course-tab2");
|
|
|
74 |
if (coursetab) {
|
|
|
75 |
coursetab.tab("show");
|
|
|
76 |
}
|
| 736 |
ariadna |
77 |
});
|
|
|
78 |
});
|
| 1 |
efrain |
79 |
|
| 736 |
ariadna |
80 |
$(document).ready(function () {
|
|
|
81 |
if (
|
|
|
82 |
$("body.drawer-open-index--open, body.drawer-courseindex--open")
|
|
|
83 |
.length
|
|
|
84 |
) {
|
| 737 |
ariadna |
85 |
const coursetab = $("#course-tab2");
|
|
|
86 |
if (coursetab) {
|
|
|
87 |
coursetab.tab("show");
|
|
|
88 |
}
|
| 736 |
ariadna |
89 |
}
|
|
|
90 |
});
|
| 1 |
efrain |
91 |
|
| 736 |
ariadna |
92 |
$("#mobileNav, .rui-mobile-nav-btn-close").click(function () {
|
|
|
93 |
$("#topBar").toggleClass("opened");
|
|
|
94 |
});
|
| 1 |
efrain |
95 |
|
| 736 |
ariadna |
96 |
$("#showBlockArea").on("click", function () {
|
|
|
97 |
$("body").toggleClass("rui-edit-areas");
|
|
|
98 |
$("#showBlockArea").toggleClass("active");
|
|
|
99 |
});
|
| 1 |
efrain |
100 |
|
| 736 |
ariadna |
101 |
$(".rui-nav--admin .nav-link").each(function () {
|
|
|
102 |
var text = $(this).html();
|
|
|
103 |
$(this).html(text.replace("(", '<span class="mt-1 small d-block">'));
|
|
|
104 |
});
|
|
|
105 |
$(".rui-nav--admin .nav-link").each(function () {
|
|
|
106 |
var text = $(this).html();
|
|
|
107 |
$(this).html(text.replace(")", "</span>"));
|
|
|
108 |
});
|
|
|
109 |
});
|
|
|
110 |
},
|
|
|
111 |
};
|
| 1 |
efrain |
112 |
});
|
|
|
113 |
/* jshint ignore:end */
|