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 |
log.debug('monocolor AMD opt in functions');
|
|
|
30 |
|
|
|
31 |
return {
|
|
|
32 |
init: function () {
|
|
|
33 |
$(document).ready(function ($) {
|
|
|
34 |
var trigger = $(document.getElementById("darkModeBtn"));
|
|
|
35 |
var preference = trigger.attr('data-preference');
|
|
|
36 |
|
|
|
37 |
$('#darkModeBtn').click(function () {
|
|
|
38 |
if ($('body').hasClass('theme-dark')) {
|
|
|
39 |
$('body').removeClass('theme-dark');
|
|
|
40 |
$('html').removeClass('dark-mode');
|
|
|
41 |
trigger.attr('aria-checked', 'false');
|
|
|
42 |
UserRepository.setUserPreference(preference, false);
|
|
|
43 |
} else {
|
|
|
44 |
$('body').addClass('theme-dark');
|
|
|
45 |
$('html').addClass('dark-mode');
|
|
|
46 |
trigger.attr('aria-checked', 'true');
|
|
|
47 |
UserRepository.setUserPreference(preference, true);
|
|
|
48 |
}
|
|
|
49 |
});
|
|
|
50 |
|
|
|
51 |
$('.btn-drawer--left').click(function () {
|
|
|
52 |
if ($('body').hasClass('drawer-open-index--open')) {
|
|
|
53 |
$('body').removeClass('drawer-courseindex--open');
|
|
|
54 |
$('body').removeClass('drawer-open-index--open');
|
|
|
55 |
} else {
|
|
|
56 |
$('body').toggleClass('drawer-courseindex--open');
|
|
|
57 |
}
|
|
|
58 |
});
|
|
|
59 |
|
|
|
60 |
$('.drawertoggle').click(function () {
|
|
|
61 |
if ($('body').hasClass('drawer-open-index--open')) {
|
|
|
62 |
$('body').removeClass('drawer-courseindex--open');
|
|
|
63 |
$('body').removeClass('drawer-open-index--open');
|
|
|
64 |
} else {
|
|
|
65 |
$('body').toggleClass('drawer-courseindex--open');
|
|
|
66 |
}
|
|
|
67 |
});
|
|
|
68 |
|
|
|
69 |
$('#courseindexbtn, .bulkEnable').click(function () {
|
|
|
70 |
$(function () {
|
|
|
71 |
$('#course-tab2').tab('show');
|
|
|
72 |
});
|
|
|
73 |
});
|
|
|
74 |
|
|
|
75 |
$( document ).ready(function() {
|
|
|
76 |
if ($("body.drawer-open-index--open, body.drawer-courseindex--open").length) {
|
|
|
77 |
$('#course-tab2').tab('show');
|
|
|
78 |
}
|
|
|
79 |
});
|
|
|
80 |
|
|
|
81 |
$('#mobileNav, .rui-mobile-nav-btn-close').click(function () {
|
|
|
82 |
$('#topBar').toggleClass('opened');
|
|
|
83 |
});
|
|
|
84 |
|
|
|
85 |
// $( ".editing .editmode-switch-form" ).on( "mouseover", function() {
|
|
|
86 |
// $('body').addClass('rui-edit-areas');
|
|
|
87 |
// });
|
|
|
88 |
|
|
|
89 |
// $( ".editing .editmode-switch-form" ).on( "mouseout", function() {
|
|
|
90 |
// $('body').removeClass('rui-edit-areas');
|
|
|
91 |
// });
|
|
|
92 |
|
|
|
93 |
$("#showBlockArea").on("click", function () {
|
|
|
94 |
$('body').toggleClass('rui-edit-areas');
|
|
|
95 |
$('#showBlockArea').toggleClass('active');
|
|
|
96 |
});
|
|
|
97 |
|
|
|
98 |
// Remove unnecessary string "..." from default moodle blocks
|
|
|
99 |
// $('.block .footer').each(function () {
|
|
|
100 |
// var text = $(this).html();
|
|
|
101 |
// $(this).html(text.replace('...', ''));
|
|
|
102 |
// });
|
|
|
103 |
|
|
|
104 |
$('.rui-nav--admin .nav-link').each(function () {
|
|
|
105 |
var text = $(this).html();
|
|
|
106 |
$(this).html(text.replace('(', '<span class="mt-1 small d-block">'));
|
|
|
107 |
});
|
|
|
108 |
$('.rui-nav--admin .nav-link').each(function () {
|
|
|
109 |
var text = $(this).html();
|
|
|
110 |
$(this).html(text.replace(')', '</span>'));
|
|
|
111 |
});
|
|
|
112 |
});
|
|
|
113 |
|
|
|
114 |
}
|
|
|
115 |
};
|
|
|
116 |
});
|
|
|
117 |
/* jshint ignore:end */
|