Proyectos de Subversion Moodle

Rev

Rev 737 | | 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 */
738 ariadna 26
define(["jquery", "core_user/repository"], function ($, UserRepository) {
27
  "use strict";
1 efrain 28
 
736 ariadna 29
  return {
30
    init: function () {
738 ariadna 31
      $(document).ready(function () {
32
        var trigger = $("#darkModeBtn");
33
        if (trigger.length) {
34
          var preference = trigger.attr("data-preference");
1 efrain 35
 
738 ariadna 36
          trigger.click(function () {
37
            $("body").toggleClass("theme-dark");
38
            $("html").toggleClass("dark-mode");
39
            var isDarkMode = $("body").hasClass("theme-dark");
40
            trigger.attr("aria-checked", isDarkMode.toString());
41
            UserRepository.setUserPreference(preference, isDarkMode);
42
          });
43
        }
1 efrain 44
 
738 ariadna 45
        function toggleDrawer() {
46
          $("body").toggleClass(
47
            "drawer-courseindex--open drawer-open-index--open"
48
          );
49
        }
1 efrain 50
 
738 ariadna 51
        $(".btn-drawer--left, .drawertoggle").click(toggleDrawer);
1 efrain 52
 
736 ariadna 53
        $("#courseindexbtn, .bulkEnable").click(function () {
738 ariadna 54
          $("#course-tab2").tab("show");
736 ariadna 55
        });
1 efrain 56
 
738 ariadna 57
        if ($("body").hasClass("drawer-courseindex--open")) {
58
          $("#course-tab2").tab("show");
59
        }
1 efrain 60
 
736 ariadna 61
        $("#mobileNav, .rui-mobile-nav-btn-close").click(function () {
62
          $("#topBar").toggleClass("opened");
63
        });
1 efrain 64
 
738 ariadna 65
        $("#showBlockArea").click(function () {
736 ariadna 66
          $("body").toggleClass("rui-edit-areas");
738 ariadna 67
          $(this).toggleClass("active");
736 ariadna 68
        });
1 efrain 69
 
736 ariadna 70
        $(".rui-nav--admin .nav-link").each(function () {
71
          var text = $(this).html();
738 ariadna 72
          $(this).html(
73
            text
74
              .replace("(", '<span class="mt-1 small d-block">')
75
              .replace(")", "</span>")
76
          );
736 ariadna 77
        });
78
      });
79
    },
80
  };
1 efrain 81
});
738 ariadna 82
 
1 efrain 83
/* jshint ignore:end */