From 76667562971626f1764465fa4122084852c8e9a5 Mon Sep 17 00:00:00 2001 From: NinaHerrmann Date: Thu, 6 Jun 2024 13:50:40 +0200 Subject: [PATCH 01/19] function not longer required. --- classes/output/core_renderer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/classes/output/core_renderer.php b/classes/output/core_renderer.php index 0c1c61c..7de1f6c 100644 --- a/classes/output/core_renderer.php +++ b/classes/output/core_renderer.php @@ -1372,7 +1372,6 @@ public function standard_head_html() { public function htmlattributes() { if (get_config('theme_wwu2019', 'darktheme_enabled') == '1') { - user_preference_allow_ajax_update('theme_wwu2019_theme', PARAM_INT); $themepreference = get_user_preferences('theme_wwu2019_theme'); if ($themepreference == 1) { return parent::htmlattributes() . 'class="light"'; From e0e0d2e0058d68112f670dbfc8bbe3d084e87c7d Mon Sep 17 00:00:00 2001 From: NinaHerrmann Date: Wed, 26 Jun 2024 10:54:39 +0200 Subject: [PATCH 02/19] let cbf run over the file --- classes/alerts.php | 2 +- classes/output/core_renderer.php | 166 ++++++++++++--------- classes/output/icon_system_fontawesome.php | 6 +- config.php | 134 ++++++++--------- db/caches.php | 10 +- lang/de/theme_wwu2019.php | 124 ++++++++------- lang/en/theme_wwu2019.php | 115 ++++++-------- layout/contentonly.php | 2 +- layout/frontpage.php | 2 +- lib.php | 8 +- scss/wwu2019/forms.scss | 2 +- settings.php | 4 +- version.php | 4 +- 13 files changed, 288 insertions(+), 291 deletions(-) diff --git a/classes/alerts.php b/classes/alerts.php index fc11c13..4cec849 100644 --- a/classes/alerts.php +++ b/classes/alerts.php @@ -130,4 +130,4 @@ public static function get_alerts() { return $alertstring; } -} \ No newline at end of file +} diff --git a/classes/output/core_renderer.php b/classes/output/core_renderer.php index 7de1f6c..c61536e 100644 --- a/classes/output/core_renderer.php +++ b/classes/output/core_renderer.php @@ -72,11 +72,15 @@ public static function get_secondary_color(): string { } } + /** + * @var null + */ private static $isexamweb = null; /** * Returns whether this is the examweb. * @return bool + * @throws \dml_exception */ public static function is_examweb(): bool { if (!self::$isexamweb) { @@ -100,12 +104,13 @@ public function __construct(moodle_page $page, $target) { /** * Renders logo heading. * @return string HTML string. + * @throws \moodle_exception */ public function logo_header() { global $CFG; $templatecontext = [ - 'wwwroot' => $CFG->wwwroot + 'wwwroot' => $CFG->wwwroot, ]; return $this->render_from_template('theme_wwu2019/logo_header', $templatecontext); } @@ -126,7 +131,7 @@ public function main_menu() { 'hasmenu' => true, 'isexpanded' => false, 'menu' => $this->add_breakers($courses), - 'icon' => (new pix_icon('i/graduation-cap', ''))->export_for_pix() + 'icon' => (new pix_icon('i/graduation-cap', ''))->export_for_pix(), ]; } @@ -137,7 +142,7 @@ public function main_menu() { 'hasmenu' => true, 'isexpanded' => false, 'menu' => $this->add_breakers($thiscourse), - 'icon' => (new pix_icon('i/book', ''))->export_for_pix() + 'icon' => (new pix_icon('i/book', ''))->export_for_pix(), ]; } @@ -148,7 +153,7 @@ public function main_menu() { 'hasmenu' => true, 'isexpanded' => false, 'menu' => $this->add_breakers($settings), - 'icon' => (new pix_icon('i/cogs', ''))->export_for_pix() + 'icon' => (new pix_icon('i/cogs', ''))->export_for_pix(), ]; } @@ -208,6 +213,7 @@ public function navbar_plugin_output() { * @param moodle_url $url The URL + params to send through when clicking the button * @param string $method * @return string HTML the button + * @throws \coding_exception */ public function edit_button(moodle_url $url, string $method = 'post'): string { $url->param('sesskey', sesskey()); @@ -221,7 +227,7 @@ public function edit_button(moodle_url $url, string $method = 'post'): string { $editstring = get_string('turneditingon'); } - return $this->single_button($url, $editstring, $method, array('class' => 'singlebutton ' . $class)); + return $this->single_button($url, $editstring, $method, ['class' => 'singlebutton ' . $class]); } /** @@ -261,6 +267,7 @@ private function add_edit_button() { * TODO: n_herr03 Not all cases of the switch statement are tested. Moreover, there might exist pages that are currently ... * TODO cont. ... handeled by the default case but would require other url parameters. * @return object url with the required edit parameter + * @throws \coding_exception */ private function get_edit_button_url_by_pagetype() { $pagetype = $this->page->pagetype; @@ -379,10 +386,10 @@ private function settingsnav_for_template(\navigation_node_collection $nodecolle foreach ($nodecollection as $node) { if ($node->display) { - $templateformat = array( + $templateformat = [ 'name' => $node->get_content(), - 'class' => '' - ); + 'class' => '', + ]; if ($node->icon && !$node->hideicon) { if ($node->icon->pix == 'i/navigationitem' && $node->has_children()) { @@ -405,7 +412,8 @@ private function settingsnav_for_template(\navigation_node_collection $nodecolle $children = $node->children; } else { // Create artificial first element in submenu that duplicates the parent's action. - // We have to rewrite the entire collection because generally there is no way to prepend an item to the collection. + // We have to rewrite the entire collection because generally there is no way ... + // ... to prepend an item to the collection. // That is, unless we know the first child's key, which does not always exist in any submenu. $children = new navigation_node_collection(); $duplicatedaction = new navigation_node([ @@ -445,7 +453,7 @@ private function settingsnav_for_template(\navigation_node_collection $nodecolle */ private function add_breakers(array $menuitems) { if (count($menuitems) == 0) { - return array(); + return []; } $columntwo = intval(ceil(count($menuitems) / 2.0) - 1); $columnthree1 = intval(ceil(count($menuitems) / 3.0) - 1); @@ -476,7 +484,7 @@ private function get_courses() { $terms = []; // Create an array where the key points to the string representation of the customfield value. - if (($field = $DB->get_record('customfield_field', array('name' => 'Semester', 'type' => 'semester'))) + if (($field = $DB->get_record('customfield_field', ['name' => 'Semester', 'type' => 'semester'])) && class_exists('customfield_semester\data_controller')) { $currenttermid = \customfield_semester\data_controller::get_semester_for_datetime(new \DateTime('now')); @@ -505,11 +513,11 @@ private function get_courses() { 'name' => $course->visible ? $course->shortname : '' . htmlentities($course->shortname) . '', 'dontescape' => !$course->visible, 'description' => $fullname, - 'href' => (new moodle_url('/course/view.php', array('id' => $course->id)))->out(false), + 'href' => (new moodle_url('/course/view.php', ['id' => $course->id]))->out(false), 'icon' => $course->visible ? $courseicon : $hiddencourseicon, 'class' => $course->visible ? '' : 'dimmed_text', 'hasmenu' => false, - 'menu' => null + 'menu' => null, ]; } } else { @@ -523,11 +531,11 @@ private function get_courses() { 'name' => $course->visible ? $course->shortname : '' . htmlentities($course->shortname) . '', 'dontescape' => !$course->visible, 'description' => $fullname, - 'href' => (new moodle_url('/course/view.php', array('id' => $course->id)))->out(false), + 'href' => (new moodle_url('/course/view.php', ['id' => $course->id]))->out(false), 'icon' => $course->visible ? $courseicon : $hiddencourseicon, 'class' => $course->visible ? '' : 'dimmed_text', 'hasmenu' => false, - 'menu' => null + 'menu' => null, ]; } } @@ -548,7 +556,7 @@ private function create_term($termid) { 'icon' => $calendaricon, 'hasmenu' => true, 'isexpanded' => false, - 'menu' => [] + 'menu' => [], ]; } @@ -588,7 +596,7 @@ private function get_courses_with_semester($fieldid) { private function get_activity_menu() { $activities = []; if (!isguestuser()) { - if (in_array($this->page->pagelayout, array('course', 'incourse', 'report', 'admin', 'standard')) && + if (in_array($this->page->pagelayout, ['course', 'incourse', 'report', 'admin', 'standard']) && (!empty($this->page->course->id) && $this->page->course->id > 1)) { $activities[] = [ @@ -596,7 +604,7 @@ private function get_activity_menu() { 'icon' => (new pix_icon('i/users', ''))->export_for_pix(), 'hasmenu' => false, 'menu' => null, - 'href' => (new moodle_url('/user/index.php', array('id' => $this->page->course->id)))->out(false) + 'href' => (new moodle_url('/user/index.php', ['id' => $this->page->course->id]))->out(false), ]; $context = context_course::instance($this->page->course->id); @@ -608,7 +616,7 @@ private function get_activity_menu() { 'icon' => (new pix_icon('i/grades', ''))->export_for_pix(), 'hasmenu' => false, 'menu' => null, - 'href' => (new moodle_url('/grade/report/index.php', array('id' => $this->page->course->id)))->out(false) + 'href' => (new moodle_url('/grade/report/index.php', ['id' => $this->page->course->id]))->out(false), ]; } $activities[] = [ @@ -616,7 +624,7 @@ private function get_activity_menu() { 'icon' => (new pix_icon('i/trophy', ''))->export_for_pix(), 'hasmenu' => false, 'menu' => null, - 'href' => (new moodle_url('/badges/view.php', array('id' => $this->page->course->id, 'type' => 2)))->out(false) + 'href' => (new moodle_url('/badges/view.php', ['id' => $this->page->course->id, 'type' => 2]))->out(false), ]; $data = $this->get_course_activities(); @@ -627,7 +635,7 @@ private function get_activity_menu() { 'icon' => (new pix_icon('monologo', '', 'mod_page'))->export_for_pix(), 'hasmenu' => false, 'menu' => null, - 'href' => (new moodle_url('/course/resources.php', array('id' => $this->page->course->id)))->out(false) + 'href' => (new moodle_url('/course/resources.php', ['id' => $this->page->course->id]))->out(false), ]; } else { $activities[] = [ @@ -635,7 +643,8 @@ private function get_activity_menu() { 'icon' => (new pix_icon('monologo', '', $modname))->export_for_pix(), 'hasmenu' => false, 'menu' => null, - 'href' => (new moodle_url("/mod/$modname/index.php", array('id' => $this->page->course->id)))->out(false) + 'href' => (new moodle_url("/mod/$modname/index.php", + ['id' => $this->page->course->id]))->out(false), ]; } } @@ -653,18 +662,18 @@ private function get_course_activities() { $course = $this->page->course; $modinfo = get_fast_modinfo($course); $course = \course_get_format($course)->get_course(); - $modfullnames = array(); - $archetypes = array(); + $modfullnames = []; + $archetypes = []; foreach ($modinfo->get_section_info_all() as $section => $thissection) { - if (((!empty($course->numsections)) and ($section > $course->numsections)) or (empty($modinfo->sections[$section]))) { + if (((!empty($course->numsections)) && ($section > $course->numsections)) || (empty($modinfo->sections[$section]))) { // This is a stealth section or is empty. continue; } foreach ($modinfo->sections[$thissection->section] as $modnumber) { $cm = $modinfo->cms[$modnumber]; // Exclude activities which are not visible or have no link (=label). - if (!$cm->uservisible or !$cm->has_view()) { + if (!$cm->uservisible || !$cm->has_view()) { continue; } if (array_key_exists($cm->modname, $modfullnames)) { @@ -709,14 +718,14 @@ private function get_user_menu() { $rolemenuitem = null; $rolename = null; if (\is_role_switched($course->id)) { // Has switched roles. - if ($role = $DB->get_record('role', array('id' => $USER->access['rsw'][$context->path]))) { + if ($role = $DB->get_record('role', ['id' => $USER->access['rsw'][$context->path]])) { $rolemenuitem = [ 'name' => get_string('switchrolereturn'), 'hasmenu' => false, 'menu' => null, - 'href' => (new moodle_url('/course/switchrole.php', array('id' => $course->id, 'sesskey' => sesskey(), - 'switchrole' => 0, 'returnurl' => $this->page->url->out_as_local_url(false))))->out(false), - 'icon' => (new pix_icon('i/user', ''))->export_for_pix() + 'href' => (new moodle_url('/course/switchrole.php', ['id' => $course->id, 'sesskey' => sesskey(), + 'switchrole' => 0, 'returnurl' => $this->page->url->out_as_local_url(false)]))->out(false), + 'icon' => (new pix_icon('i/user', ''))->export_for_pix(), ]; $rolename = ' - '.role_get_name($role, $context); } @@ -727,9 +736,9 @@ private function get_user_menu() { 'name' => get_string('switchroleto'), 'hasmenu' => false, 'menu' => null, - 'href' => (new moodle_url('/course/switchrole.php', array('id' => $course->id, - 'switchrole' => -1, 'returnurl' => $this->page->url->out_as_local_url(false))))->out(false), - 'icon' => (new pix_icon('i/users', ''))->export_for_pix() + 'href' => (new moodle_url('/course/switchrole.php', ['id' => $course->id, + 'switchrole' => -1, 'returnurl' => $this->page->url->out_as_local_url(false)]))->out(false), + 'icon' => (new pix_icon('i/users', ''))->export_for_pix(), ]; } } @@ -739,20 +748,20 @@ private function get_user_menu() { $realuser = \core\session\manager::get_realuser(); $menucontent[] = [ 'name' => get_string('loggedinas', 'theme_wwu2019', - array('real' => fullname($realuser, true), 'fake' => fullname($USER, true))) . + ['real' => fullname($realuser, true), 'fake' => fullname($USER, true)]) . ($rolename ? $rolename : ''), 'hasmenu' => false, 'menu' => null, - 'href' => (new moodle_url('/user/profile.php', array('id' => $USER->id)))->out(false), - 'icon' => (new pix_icon('i/key', ''))->export_for_pix() + 'href' => (new moodle_url('/user/profile.php', ['id' => $USER->id]))->out(false), + 'icon' => (new pix_icon('i/key', ''))->export_for_pix(), ]; } else { $menucontent[] = [ 'name' => fullname($USER, true) . ($rolename ? $rolename : ''), 'hasmenu' => false, 'menu' => null, - 'href' => (new moodle_url('/user/profile.php', array('id' => $USER->id)))->out(false), - 'icon' => (new pix_icon('i/user', ''))->export_for_pix() + 'href' => (new moodle_url('/user/profile.php', ['id' => $USER->id]))->out(false), + 'icon' => (new pix_icon('i/user', ''))->export_for_pix(), ]; } @@ -768,25 +777,26 @@ private function get_user_menu() { 'icon' => (new pix_icon('i/sun', ''))->export_for_pix(), 'href' => null, 'hasmenu' => false, - 'class' => 'wwu-uselighttheme' + 'class' => 'wwu-uselighttheme', ], [ - 'name' => \html_writer::tag('abbr', get_string('ostheme', 'theme_wwu2019'), ['title' => get_string('ostheme_help', 'theme_wwu2019')]), + 'name' => \html_writer::tag('abbr', get_string('ostheme', 'theme_wwu2019'), + ['title' => get_string('ostheme_help', 'theme_wwu2019')]), 'icon' => (new pix_icon('i/magic', ''))->export_for_pix(), 'href' => null, 'hasmenu' => false, 'class' => 'wwu-useostheme', - 'dontescape' => true + 'dontescape' => true, ], [ 'name' => get_string('dark', 'theme_wwu2019'), 'icon' => (new pix_icon('i/moon', ''))->export_for_pix(), 'href' => null, 'hasmenu' => false, - 'class' => 'wwu-usedarktheme' + 'class' => 'wwu-usedarktheme', ], ], - 'icon' => (new pix_icon('i/theme', ''))->export_for_pix() + 'icon' => (new pix_icon('i/theme', ''))->export_for_pix(), ]; } @@ -800,7 +810,7 @@ private function get_user_menu() { 'hasmenu' => true, 'isexpanded' => false, 'menu' => $this->get_user_settings_submenu($context), - 'icon' => (new pix_icon('i/cogs', ''))->export_for_pix() + 'icon' => (new pix_icon('i/cogs', ''))->export_for_pix(), ]; $menucontent[count($menucontent) - 1]['class'] = 'divider'; @@ -813,7 +823,7 @@ private function get_user_menu() { 'hasmenu' => false, 'menu' => null, 'icon' => (new pix_icon('i/calendar', ''))->export_for_pix(), - 'href' => (new moodle_url('/calendar/view.php'))->out(false) + 'href' => (new moodle_url('/calendar/view.php'))->out(false), ]; } } @@ -825,7 +835,7 @@ private function get_user_menu() { 'hasmenu' => false, 'menu' => null, 'icon' => (new pix_icon('i/comment', ''))->export_for_pix(), - 'href' => (new moodle_url('/message/index.php'))->out(false) + 'href' => (new moodle_url('/message/index.php'))->out(false), ]; } @@ -837,7 +847,7 @@ private function get_user_menu() { 'hasmenu' => false, 'menu' => null, 'icon' => (new pix_icon('i/files', ''))->export_for_pix(), - 'href' => (new moodle_url('/user/files.php'))->out(false) + 'href' => (new moodle_url('/user/files.php'))->out(false), ]; } @@ -847,7 +857,7 @@ private function get_user_menu() { 'hasmenu' => false, 'menu' => null, 'icon' => (new pix_icon('i/log', ''))->export_for_pix(), - 'href' => (new moodle_url('/mod/forum/user.php', array('id' => $USER->id)))->out(false), + 'href' => (new moodle_url('/mod/forum/user.php', ['id' => $USER->id]))->out(false), ]; if (has_capability('mod/forum:viewdiscussion', $context)) { @@ -857,7 +867,7 @@ private function get_user_menu() { 'menu' => null, 'icon' => (new pix_icon('i/list', ''))->export_for_pix(), 'href' => (new moodle_url('/mod/forum/user.php', - array('id' => $USER->id, 'mode' => 'discussions')))->out(false) + ['id' => $USER->id, 'mode' => 'discussions']))->out(false), ]; } @@ -870,7 +880,7 @@ private function get_user_menu() { 'menu' => null, 'icon' => (new pix_icon('i/grades', ''))->export_for_pix(), 'href' => (new moodle_url('/grade/report/overview/index.php', - array('userid' => $USER->id)))->out(false) + ['userid' => $USER->id]))->out(false), ]; // Badges. @@ -880,7 +890,7 @@ private function get_user_menu() { 'hasmenu' => false, 'menu' => null, 'icon' => (new pix_icon('i/badge', ''))->export_for_pix(), - 'href' => (new moodle_url('/badges/mybadges.php'))->out(false) + 'href' => (new moodle_url('/badges/mybadges.php'))->out(false), ]; } } @@ -889,16 +899,16 @@ private function get_user_menu() { // Logout. if (\core\session\manager::is_loggedinas()) { - $branchurl = new moodle_url('/course/loginas.php', array('id' => $course->id, 'sesskey' => sesskey())); + $branchurl = new moodle_url('/course/loginas.php', ['id' => $course->id, 'sesskey' => sesskey()]); } else { - $branchurl = new moodle_url('/login/logout.php', array('sesskey' => sesskey())); + $branchurl = new moodle_url('/login/logout.php', ['sesskey' => sesskey()]); } $menucontent[] = [ 'name' => get_string('logout'), 'hasmenu' => false, 'menu' => null, 'icon' => (new pix_icon('i/logout', ''))->export_for_pix(), - 'href' => $branchurl->out(false) + 'href' => $branchurl->out(false), ]; // Help link. @@ -908,7 +918,7 @@ private function get_user_menu() { 'hasmenu' => false, 'menu' => null, 'icon' => (new pix_icon('i/help', ''))->export_for_pix(), - 'href' => $url + 'href' => $url, ]; } @@ -917,7 +927,7 @@ private function get_user_menu() { $usermenu = [ 'name' => sprintf('%.1s. %s', $USER->firstname, $USER->lastname), 'pic' => $userpic->get_url($this->page)->out(true), - 'menu' => $this->add_breakers($menucontent) + 'menu' => $this->add_breakers($menucontent), ]; return $usermenu; @@ -939,7 +949,7 @@ private function get_user_settings_submenu($context) { $menu[] = [ 'name' => get_string('user'), 'icon' => (new pix_icon('i/user', ''))->export_for_pix(), - 'href' => (new moodle_url('/user/preferences.php', array('userid' => $USER->id)))->out(false), + 'href' => (new moodle_url('/user/preferences.php', ['userid' => $USER->id]))->out(false), 'hasmenu' => false, ]; @@ -947,7 +957,7 @@ private function get_user_settings_submenu($context) { $menu[] = [ 'name' => get_string('editmyprofile'), 'icon' => (new pix_icon('i/edit', ''))->export_for_pix(), - 'href' => (new moodle_url('/user/edit.php', array('id' => $USER->id)))->out(false), + 'href' => (new moodle_url('/user/edit.php', ['id' => $USER->id]))->out(false), 'hasmenu' => false, ]; } @@ -964,7 +974,7 @@ private function get_user_settings_submenu($context) { $menu[] = [ 'name' => get_string('message', 'message'), 'icon' => (new pix_icon('i/comment', ''))->export_for_pix(), - 'href' => (new moodle_url('/message/edit.php', array('id' => $USER->id)))->out(false), + 'href' => (new moodle_url('/message/edit.php', ['id' => $USER->id]))->out(false), 'hasmenu' => false, ]; } @@ -1006,7 +1016,7 @@ private function get_languages() { $templateobj[] = [ 'short' => $langtype, 'full' => $langname, - 'href' => (new moodle_url($this->page->url, array('lang' => $langtype)))->out(false) + 'href' => (new moodle_url($this->page->url, ['lang' => $langtype]))->out(false), ]; } return $templateobj; @@ -1158,9 +1168,9 @@ public function render_login(\core_auth\output\login $form) { // $wantsurl can contain parameters e.g. user/view.php?id=5&course=10 // form method needs to be 'get', because an xsso forward would drop post values. // within the get action of a form query string values are dropped as well. - $params = array(); + $params = []; parse_str(parse_url($wantsurl, PHP_URL_QUERY), $params); - $paramsmustache = array(); + $paramsmustache = []; foreach ($params as $key => $val) { $paramsmustache[] = ["key" => $key, "value" => $val]; } @@ -1184,10 +1194,10 @@ private function matomo_trackurl() { if ((isset($pageinfo[1]->category)) || (isset($pageinfo[1]->fullname)) || (isset($pageinfo[2]->name))) { // Adds course category name. if (isset($pageinfo[1]->category)) { - if ($category = $DB->get_record('course_categories', array('id' => $pageinfo[1]->category))) { + if ($category = $DB->get_record('course_categories', ['id' => $pageinfo[1]->category])) { $cats = explode("/", $category->path); foreach (array_filter($cats) as $cat) { - if ($categorydepth = $DB->get_record("course_categories", array("id" => $cat))) { + if ($categorydepth = $DB->get_record("course_categories", ["id" => $cat])) { $trackurl .= $categorydepth->name . '/'; } } @@ -1298,7 +1308,7 @@ public function slideshow() { ) { require_once($CFG->dirroot . '/local/marketing/locallib.php'); $allslides = \local_marketing\slide_manager::get_slides_for(); - $slides = array(); + $slides = []; $index = 0; foreach ($allslides as $slide) { // Add slide index for slide navigation in the mustache template. @@ -1312,14 +1322,14 @@ public function slideshow() { 'slidesfilearea', $slide->id, '/', $slideimage); $slideimage = preg_replace('|^https?://|i', '//', $slideimage->out(false)); } else { - $slideimage = self::pix_url('default_slide', 'theme'); + $slideimage = self::image_url('default_slide', 'theme'); } $slide->slideimage = $slideimage; // Attach tracking params for matomo. $concatenate = strpos($slide->link, '?') !== false ? '&' : '?'; $titleslug = strtolower(trim(preg_replace('/[^A-Za-z0-9]+/', '-', $slide->title))); - if(strpos($slide->link, "#")!==false){ + if (strpos($slide->link, "#") !== false) { $pos = strpos($slide->link, "#"); $slide->link = substr($slide->link, 0, $pos) . $concatenate . 'pk_medium=local_marketing&pk_campaign=' . $slide->id . '--' . $titleslug . substr($slide->link, $pos); @@ -1341,16 +1351,20 @@ public function slideshow() { if ($slides) { $this->page->requires->js_call_amd('theme_wwu2019/slideshow', 'init'); - $output .= $this->render_from_template('theme_wwu2019/slideshow', array('slides' => $slides)); + $output .= $this->render_from_template('theme_wwu2019/slideshow', ['slides' => $slides]); } } return $output; } + /** + * Show debugging Information for site administrators. + * @return string + */ public function debug_footer_html() { if (is_siteadmin()) { return \html_writer::tag('div', sprintf("Hostname: %s", gethostname()), - array('class' => 'hostname pt-2')) . + ['class' => 'hostname pt-2']) . parent::debug_footer_html(); } else { return ''; @@ -1370,6 +1384,12 @@ public function standard_head_html() { return $output; } + /** + * Returns the primary color of the theme. + * @return string + * @throws \coding_exception + * @throws \dml_exception + */ public function htmlattributes() { if (get_config('theme_wwu2019', 'darktheme_enabled') == '1') { $themepreference = get_user_preferences('theme_wwu2019_theme'); @@ -1411,18 +1431,17 @@ protected function render_image_icon(image_icon $icon) { } /** + * Check for the suitable logo. * @param pix_icon $icon */ private function check_monologo(pix_icon $icon) { - global $PAGE; - if ($icon->pix === 'monologo' || $icon->pix === 'icon') { if (!in_array($icon->component, ['moodle', 'core', 'theme', null]) && ( substr_compare($icon->component, 'mod_', 0, 4) === 0 || strpos($icon->component, '_') === false ) ) { - if ($location = $PAGE->theme->resolve_image_location($icon->pix, $icon->component, null)) { + if ($location = $this->page->theme->resolve_image_location($icon->pix, $icon->component, null)) { if (substr_compare($location, 'monologo.svg', -12) === 0) { if (isset($icon->attributes['class'])) { $icon->attributes['class'] .= ' wwu-monologo '; @@ -1436,9 +1455,10 @@ private function check_monologo(pix_icon $icon) { } /** + * Check if doctype is necessay. * @return string Doctype string, if not already printed. */ - public function doctype_if_necessary() : string { + public function doctype_if_necessary(): string { if (empty($this->contenttype)) { return $this->doctype(); } else { diff --git a/classes/output/icon_system_fontawesome.php b/classes/output/icon_system_fontawesome.php index 953d80e..3ff23c0 100644 --- a/classes/output/icon_system_fontawesome.php +++ b/classes/output/icon_system_fontawesome.php @@ -46,7 +46,7 @@ class icon_system_fontawesome extends \core\output\icon_system_fontawesome { public function get_core_icon_map() { $iconmap = parent::get_core_icon_map(); - $override = array( + $override = [ 'core:i/briefcase' => 'fa-briefcase', 'core:i/cogs' => 'fa-cogs', 'core:i/graduation-cap' => 'fa-graduation-cap', @@ -65,8 +65,8 @@ public function get_core_icon_map() { 'core:i/sun' => 'fa-sun-o', 'core:i/moon' => 'fa-moon-o', 'core:i/magic' => 'fa-magic', - 'core:i/theme' => 'fa-paint-brush' - ); + 'core:i/theme' => 'fa-paint-brush', + ]; return array_merge($iconmap, $override); } diff --git a/config.php b/config.php index b262d0f..b244c44 100644 --- a/config.php +++ b/config.php @@ -53,7 +53,7 @@ // This is an old setting used to load specific CSS for some YUI JS. We don't need it in Classic based themes because Classic // provides default styling for the YUI modules that we use. It is not recommended to use this setting anymore. -$THEME->yuicssmodules = array(); +$THEME->yuicssmodules = []; // Most themes will use this rendererfactory as this is the one that allows the theme to override any other renderer. $THEME->rendererfactory = 'theme_overridden_renderer_factory'; @@ -64,139 +64,139 @@ // multiple column layouts. $THEME->layouts = [ // Most backwards compatible layout without the blocks - this is the layout used by default. - 'base' => array( + 'base' => [ 'theme' => 'wwu2019', 'file' => 'columns.php', - 'regions' => array(), - ), + 'regions' => [], + ], // Standard layout with blocks, this is recommended for most pages with general information. - 'standard' => array( + 'standard' => [ 'theme' => 'wwu2019', 'file' => 'columns.php', - 'regions' => array('side-post'), + 'regions' => ['side-post'], 'defaultregion' => 'side-post', - ), + ], // Main course page. - 'course' => array( + 'course' => [ 'theme' => 'wwu2019', 'file' => 'columns.php', - 'regions' => array('side-post'), + 'regions' => ['side-post'], 'defaultregion' => 'side-post', - 'options' => array('langmenu' => true), - ), - 'coursecategory' => array( + 'options' => ['langmenu' => true], + ], + 'coursecategory' => [ 'theme' => 'wwu2019', 'file' => 'columns.php', - 'regions' => array('side-post'), + 'regions' => ['side-post'], 'defaultregion' => 'side-post', - ), + ], // Part of course, typical for modules - default page layout if $cm specified in require_login(). - 'incourse' => array( + 'incourse' => [ 'theme' => 'wwu2019', 'file' => 'columns.php', - 'regions' => array('side-post'), + 'regions' => ['side-post'], 'defaultregion' => 'side-post', - ), + ], // The site home page. - 'frontpage' => array( + 'frontpage' => [ 'theme' => 'wwu2019', 'file' => 'frontpage.php', - 'regions' => array('side-post'), + 'regions' => ['side-post'], 'defaultregion' => 'side-post', - 'options' => array('nonavbar' => true), - ), + 'options' => ['nonavbar' => true], + ], // Server administration scripts. - 'admin' => array( + 'admin' => [ 'theme' => 'wwu2019', 'file' => 'columns.php', - 'regions' => array('side-post'), + 'regions' => ['side-post'], 'defaultregion' => 'side-post', - ), + ], // My dashboard page. - 'mydashboard' => array( + 'mydashboard' => [ 'theme' => 'wwu2019', 'file' => 'columns.php', - 'regions' => array('side-post'), + 'regions' => ['side-post'], 'defaultregion' => 'side-post', - 'options' => array('nonavbar' => true, 'langmenu' => true, 'nocontextheader' => true), - ), + 'options' => ['nonavbar' => true, 'langmenu' => true, 'nocontextheader' => true], + ], // My courses page. - 'mycourses' => array( + 'mycourses' => [ 'theme' => 'wwu2019', 'file' => 'columns.php', - 'regions' => array('side-post'), + 'regions' => ['side-post'], 'defaultregion' => 'side-post', - 'options' => array('nonavbar' => true, 'nocontextheader' => true), - ), + 'options' => ['nonavbar' => true, 'nocontextheader' => true], + ], // My public page. - 'mypublic' => array( + 'mypublic' => [ 'theme' => 'wwu2019', 'file' => 'columns.php', - 'regions' => array('side-post'), + 'regions' => ['side-post'], 'defaultregion' => 'side-post', - ), - 'login' => array( + ], + 'login' => [ 'theme' => 'wwu2019', 'file' => 'columns.php', - 'regions' => array(), - 'options' => array('langmenu' => true), - ), + 'regions' => [], + 'options' => ['langmenu' => true], + ], // Pages that appear in pop-up windows - no navigation, no blocks, no header. - 'popup' => array( + 'popup' => [ 'theme' => 'wwu2019', 'file' => 'contentonly.php', - 'regions' => array(), - 'options' => array('nofooter' => true, 'nonavbar' => true), - ), + 'regions' => [], + 'options' => ['nofooter' => true, 'nonavbar' => true], + ], // No blocks and minimal footer - used for legacy frame layouts only! - 'frametop' => array( + 'frametop' => [ 'theme' => 'wwu2019', 'file' => 'contentonly.php', - 'regions' => array(), - 'options' => array('nofooter' => true, 'nocoursefooter' => true), - ), + 'regions' => [], + 'options' => ['nofooter' => true, 'nocoursefooter' => true], + ], // Embeded pages, like iframe/object embeded in moodleform - it needs as much space as possible. - 'embedded' => array( + 'embedded' => [ 'theme' => 'boost', 'file' => 'embedded.php', - 'regions' => array() - ), + 'regions' => [], + ], // Used during upgrade and install, and for the 'This site is undergoing maintenance' message. // This must not have any blocks, links, or API calls that would lead to database or cache interaction. // Please be extremely careful if you are modifying this layout. - 'maintenance' => array( + 'maintenance' => [ 'theme' => 'boost', 'file' => 'maintenance.php', - 'regions' => array(), - ), + 'regions' => [], + ], // Should display the content and basic headers only. - 'print' => array( + 'print' => [ 'theme' => 'wwu2019', 'file' => 'contentonly.php', - 'regions' => array(), - 'options' => array('nofooter' => true, 'nonavbar' => false), - ), + 'regions' => [], + 'options' => ['nofooter' => true, 'nonavbar' => false], + ], // The pagelayout used when a redirection is occuring. - 'redirect' => array( + 'redirect' => [ 'theme' => 'boost', 'file' => 'embedded.php', - 'regions' => array(), - ), + 'regions' => [], + ], // The pagelayout used for reports. - 'report' => array( + 'report' => [ 'theme' => 'wwu2019', 'file' => 'columns.php', - 'regions' => array('side-post'), + 'regions' => ['side-post'], 'defaultregion' => 'side-post', - ), + ], // The pagelayout used for safebrowser and securewindow. - 'secure' => array( + 'secure' => [ 'theme' => 'wwu2019', 'file' => 'secure.php', - 'regions' => array('side-post'), - 'defaultregion' => 'side-post' - ) + 'regions' => ['side-post'], + 'defaultregion' => 'side-post', + ], ]; // This is the function that returns the SCSS source for the main file in our theme. diff --git a/db/caches.php b/db/caches.php index c39dd9e..0ce6098 100644 --- a/db/caches.php +++ b/db/caches.php @@ -24,15 +24,15 @@ defined('MOODLE_INTERNAL') || die(); -$definitions = array( +$definitions = [ // Caches font awesome icons. - 'fontawesomeiconmapping' => array( + 'fontawesomeiconmapping' => [ 'mode' => cache_store::MODE_APPLICATION, 'simplekeys' => true, 'simpledata' => true, 'staticacceleration' => true, - 'staticaccelerationsize' => 1 - ), + 'staticaccelerationsize' => 1, + ], -); \ No newline at end of file +]; diff --git a/lang/de/theme_wwu2019.php b/lang/de/theme_wwu2019.php index b2030bf..4edbc0f 100644 --- a/lang/de/theme_wwu2019.php +++ b/lang/de/theme_wwu2019.php @@ -24,88 +24,82 @@ defined('MOODLE_INTERNAL') || die(); -$string['pluginname'] = 'WWU 2019'; +$string['alert1text'] = 'Alert-Text (Alert 1)'; +$string['alert1title'] = 'Alert-Titel (Alert 1)'; +$string['alert1type'] = 'Alert-Typ (Alert 1)'; +$string['alert2text'] = 'Alert-Text (Alert 2)'; +$string['alert2title'] = 'Alert-Titel (Alert 2)'; +$string['alert2type'] = 'Alert-Typ (Alert 2)'; +$string['alert3text'] = 'Alert-Text (Alert 3)'; +$string['alert3title'] = 'Alert-Titel (Alert 3)'; +$string['alert3type'] = 'Alert-Typ (Alert 3)'; +$string['alert_general'] = 'Ankündigung'; +$string['alert_info'] = 'Info'; +$string['alert_warning'] = 'Warnung'; +$string['alerttext_desc'] = 'Zweiter Teil der Meldung.'; +$string['alerttitle_desc'] = 'Erster Teil der Meldung (wird fettgedruckt).'; +$string['alerttype_desc'] = 'Typ des Alerts (vgl. debug levels).'; +$string['badgepreferences'] = 'Badge'; $string['choosereadme'] = 'Dieses Theme basiert auf dem Classic-Theme von Moodle und ist hinsichtlich des Corporate Design der WWU Münster angepasst.'; - -/* Main menu */ -$string['mycourses'] = 'Meine Kurse'; -$string['termindependent'] = 'Semesterunabhängig'; +$string['choosetheme'] = 'Theme auswählen'; +$string['dark'] = 'Dunkel'; $string['dashboard'] = 'Dashboard'; - -$string['thiscourse'] = 'Dieser Kurs'; -$string['searchadmin'] = 'Administrationssuche'; - -$string['openmainmenu'] = 'Hauptmenü öffnen'; -$string['mainmenu'] = 'Hauptmenü'; - -/* User menu */ -$string['loggedinas'] = '{$a->real}, als {$a->fake}'; -$string['badgepreferences'] = 'Badge'; -$string['mygrades'] = 'Meine Noten'; - -$string['openusermenu'] = 'Nutzermenü öffnen'; -$string['usermenu'] = 'Nutzermenü'; - -/* Settings */ -$string['helpurl'] = 'Hilfe-URL'; -$string['helpurl_desc'] = 'URL zu einer Hilfeseite, die im Usermenü verlinkt ist.'; -$string['matomo_siteurl'] = 'Analytics-URL'; -$string['matomo_siteurl_desc'] = 'Ihre "Matomo Analytics"-URL, aber ohne http(s) oder Slash am Ende. Beispiel: "mysite.com/analytics".'; -$string['matomo_siteid'] = 'Analytics-Site-ID'; -$string['matomo_siteid_desc'] = 'Ihre "Matomo Analytics" Site-ID.'; $string['enable1alert'] = 'Alert 1 zeigen'; $string['enable2alert'] = 'Alert 2 zeigen'; $string['enable3alert'] = 'Alert 3 zeigen'; $string['enablealert_desc'] = 'Ob der jeweilige Alert angezeigt wird.'; -$string['alert1type'] = 'Alert-Typ (Alert 1)'; -$string['alert1title'] = 'Alert-Titel (Alert 1)'; -$string['alert1text'] = 'Alert-Text (Alert 1)'; -$string['alert2type'] = 'Alert-Typ (Alert 2)'; -$string['alert2title'] = 'Alert-Titel (Alert 2)'; -$string['alert2text'] = 'Alert-Text (Alert 2)'; -$string['alert3type'] = 'Alert-Typ (Alert 3)'; -$string['alert3title'] = 'Alert-Titel (Alert 3)'; -$string['alert3text'] = 'Alert-Text (Alert 3)'; -$string['alerttype_desc'] = 'Typ des Alerts (vgl. debug levels).'; -$string['alerttitle_desc'] = 'Erster Teil der Meldung (wird fettgedruckt).'; -$string['alerttext_desc'] = 'Zweiter Teil der Meldung.'; - - -$string['alert_info'] = 'Info'; -$string['alert_warning'] = 'Warnung'; -$string['alert_general'] = 'Ankündigung'; - -// Marketing Spots. -$string['marketingheading'] = 'Marketing spots'; -$string['marketinginfodesc'] = 'Enter the settings for your marketing spot.'; -$string['marketingdesc'] = 'This theme provides the option of enabling three "marketing" or "ad" spots just under the slide show. These allow you to easily identify core information to your users and provide direct links.'; +$string['exam:begin'] = 'Klausurbeginn:'; +$string['exam:end'] = 'Klausurende:'; +$string['examweb_description'] = 'Online-Prüfungssystem der WWU Münster'; +$string['helpurl'] = 'Hilfe-URL'; +$string['helpurl_desc'] = 'URL zu einer Hilfeseite, die im Usermenü verlinkt ist.'; +$string['light'] = 'Hell'; +$string['loggedinas'] = '{$a->real}, als {$a->fake}'; +$string['mainmenu'] = 'Hauptmenü'; $string['marketing1'] = 'Marketing spot one'; $string['marketing2'] = 'Marketing spot two'; $string['marketing3'] = 'Marketing spot three'; - -$string['marketingtitle'] = 'Titel'; -$string['marketingtitledesc'] = 'Title to show in this marketing spot'; $string['marketingcontent'] = 'Beschreibung'; $string['marketingcontentdesc'] = 'Content to display in the marketing box. Keep it short and sweet.'; - -$string['viewfullsection'] = 'Kompletten Abschnitt anschauen'; - -// Theme switcher. -$string['choosetheme'] = 'Theme auswählen'; -$string['light'] = 'Hell'; -$string['dark'] = 'Dunkel'; +$string['marketingdesc'] = 'This theme provides the option of enabling three "marketing" or "ad" spots just under the slide show. These allow you to easily identify core information to your users and provide direct links.'; +$string['marketingheading'] = 'Marketing spots'; +$string['marketinginfodesc'] = 'Enter the settings for your marketing spot.'; +$string['marketingtitle'] = 'Titel'; +$string['marketingtitledesc'] = 'Title to show in this marketing spot'; +$string['matomo_siteid'] = 'Analytics-Site-ID'; +$string['matomo_siteid_desc'] = 'Ihre "Matomo Analytics" Site-ID.'; +$string['matomo_siteurl'] = 'Analytics-URL'; +$string['matomo_siteurl_desc'] = 'Ihre "Matomo Analytics"-URL, aber ohne http(s) oder Slash am Ende. Beispiel: "mysite.com/analytics".'; +$string['mycourses'] = 'Meine Kurse'; +$string['mygrades'] = 'Meine Noten'; +$string['openmainmenu'] = 'Hauptmenü öffnen'; +$string['openusermenu'] = 'Nutzermenü öffnen'; $string['ostheme'] = 'Systemfarben'; $string['ostheme_help'] = 'Wechselt zwischen hellem und dunklem Theme basierend auf den Systemeinstellungen.'; +$string['pluginname'] = 'WWU 2019'; +$string['searchadmin'] = 'Administrationssuche'; +$string['settings:darkthemeenabled'] = 'Sollte der Darktheme auswählbar sein?'; $string['settings:isexamweb'] = 'Ist dies das Examweb?'; $string['settings:isexamweb_desc'] = 'Bestimmt über das Seitenlogo, als auch verschiedene Dinge in Templates (z.B. keine Slideshow, ...)'; +$string['settings:prescss'] = 'Zusätzlicher Pre-SCSS Code'; $string['settings:primarycolor'] = 'Primäre Themefarbe'; $string['settings:secondarycolor'] = 'Sekundäre Themefarbe'; -$string['settings:prescss'] = 'Zusätzlicher Pre-SCSS Code'; -$string['settings:darkthemeenabled'] = 'Sollte der Darktheme auswählbar sein?'; +$string['termindependent'] = 'Semesterunabhängig'; + +$string['thiscourse'] = 'Dieser Kurs'; + + + +$string['usermenu'] = 'Nutzermenü'; + + + + + + +$string['viewfullsection'] = 'Kompletten Abschnitt anschauen'; + + -// Examweb. -$string['exam:begin'] = 'Klausurbeginn:'; -$string['exam:end'] = 'Klausurende:'; -$string['examweb_description'] = 'Online-Prüfungssystem der WWU Münster'; diff --git a/lang/en/theme_wwu2019.php b/lang/en/theme_wwu2019.php index 4c5fcd3..3fed2ad 100644 --- a/lang/en/theme_wwu2019.php +++ b/lang/en/theme_wwu2019.php @@ -24,88 +24,67 @@ defined('MOODLE_INTERNAL') || die(); -$string['pluginname'] = 'WWU 2019'; +$string['alert1text'] = 'Alert text (alert 1)'; +$string['alert1title'] = 'Alert title (alert 1)'; +$string['alert1type'] = 'Alert type (alert 1)'; +$string['alert2text'] = 'Alert text (alert 2)'; +$string['alert2title'] = 'Alert title (alert 2)'; +$string['alert2type'] = 'Alert type (alert 2)'; +$string['alert3text'] = 'Alert text (alert 3)'; +$string['alert3title'] = 'Alert title (alert 3)'; +$string['alert3type'] = 'Alert type (alert 3)'; +$string['alert_general'] = 'General'; +$string['alert_info'] = 'Info'; +$string['alert_warning'] = 'Warning'; +$string['alerttext_desc'] = 'Second part of the alert.'; +$string['alerttitle_desc'] = 'First part of the alert (printed in bold).'; +$string['alerttype_desc'] = 'Type of alert (similar to debug levels).'; +$string['badgepreferences'] = 'Badge'; $string['choosereadme'] = 'This theme is based on moodle\'s classic theme and aligned with the corporate design of the University of Münster'; - -/* Main menu */ -$string['mycourses'] = 'My courses'; -$string['termindependent'] = 'Semester independent'; +$string['choosetheme'] = 'Choose theme'; +$string['dark'] = 'Dark'; $string['dashboard'] = 'Dashboard'; - -$string['thiscourse'] = 'This Course'; -$string['searchadmin'] = 'Admin search'; - -$string['openmainmenu'] = 'Open main menu'; -$string['mainmenu'] = 'Main menu'; - -/* User menu */ -$string['loggedinas'] = '{$a->real} logged in as {$a->fake}'; -$string['badgepreferences'] = 'Badge'; -$string['mygrades'] = 'My grades'; - -$string['openusermenu'] = 'Open user menu'; -$string['usermenu'] = 'User menu'; - -/* Settings */ -$string['helpurl'] = 'Help URL'; -$string['helpurl_desc'] = 'URL to helppage that will be linked to in the usermenu'; -$string['matomo_siteurl'] = 'Analytics URL'; -$string['matomo_siteurl_desc'] = 'Enter your "Matomo Analytics" URL without http(s) or a trailing slash. For example "mysite.com/analytics".'; -$string['matomo_siteid'] = 'Analytics Site ID'; -$string['matomo_siteid_desc'] = 'Enter your "Matomo Analytics" site id.'; $string['enable1alert'] = 'Show alert 1'; $string['enable2alert'] = 'Show alert 2'; $string['enable3alert'] = 'Show alert 3'; $string['enablealert_desc'] = 'Show/hide a specific alert.'; -$string['alert1type'] = 'Alert type (alert 1)'; -$string['alert1title'] = 'Alert title (alert 1)'; -$string['alert1text'] = 'Alert text (alert 1)'; -$string['alert2type'] = 'Alert type (alert 2)'; -$string['alert2title'] = 'Alert title (alert 2)'; -$string['alert2text'] = 'Alert text (alert 2)'; -$string['alert3type'] = 'Alert type (alert 3)'; -$string['alert3title'] = 'Alert title (alert 3)'; -$string['alert3text'] = 'Alert text (alert 3)'; -$string['alerttype_desc'] = 'Type of alert (similar to debug levels).'; -$string['alerttitle_desc'] = 'First part of the alert (printed in bold).'; -$string['alerttext_desc'] = 'Second part of the alert.'; - - -$string['alert_info'] = 'Info'; -$string['alert_warning'] = 'Warning'; -$string['alert_general'] = 'General'; - -// Marketing Spots. -$string['marketingheading'] = 'Marketing spots'; -$string['marketinginfodesc'] = 'Enter the settings for your marketing spot.'; -$string['marketingdesc'] = 'This theme provides the option of enabling three "marketing" or "ad" spots just under the slide show. These allow you to easily identify core information to your users and provide direct links.'; +$string['exam:begin'] = 'Start of exam:'; +$string['exam:end'] = 'End of exam:'; +$string['examweb_description'] = 'Online examination system of the University of Münster'; +$string['helpurl'] = 'Help URL'; +$string['helpurl_desc'] = 'URL to helppage that will be linked to in the usermenu'; +$string['light'] = 'Light'; +$string['loggedinas'] = '{$a->real} logged in as {$a->fake}'; +$string['mainmenu'] = 'Main menu'; $string['marketing1'] = 'Marketing spot one'; $string['marketing2'] = 'Marketing spot two'; $string['marketing3'] = 'Marketing spot three'; - -$string['marketingtitle'] = 'Title'; -$string['marketingtitledesc'] = 'Title to show in this marketing spot'; $string['marketingcontent'] = 'Content'; $string['marketingcontentdesc'] = 'Content to display in the marketing box. Keep it short and sweet.'; - -$string['viewfullsection'] = 'View full section'; - -// Theme switcher. -$string['choosetheme'] = 'Choose theme'; -$string['light'] = 'Light'; -$string['dark'] = 'Dark'; +$string['marketingdesc'] = 'This theme provides the option of enabling three "marketing" or "ad" spots just under the slide show. These allow you to easily identify core information to your users and provide direct links.'; +$string['marketingheading'] = 'Marketing spots'; +$string['marketinginfodesc'] = 'Enter the settings for your marketing spot.'; +$string['marketingtitle'] = 'Title'; +$string['marketingtitledesc'] = 'Title to show in this marketing spot'; +$string['matomo_siteid'] = 'Analytics Site ID'; +$string['matomo_siteid_desc'] = 'Enter your "Matomo Analytics" site id.'; +$string['matomo_siteurl'] = 'Analytics URL'; +$string['matomo_siteurl_desc'] = 'Enter your "Matomo Analytics" URL without http(s) or a trailing slash. For example "mysite.com/analytics".'; +$string['mycourses'] = 'My courses'; +$string['mygrades'] = 'My grades'; +$string['openmainmenu'] = 'Open main menu'; +$string['openusermenu'] = 'Open user menu'; $string['ostheme'] = 'System colors'; $string['ostheme_help'] = 'Switches between light and dark theme depending on the OS settings.'; - +$string['pluginname'] = 'WWU 2019'; +$string['searchadmin'] = 'Admin search'; +$string['settings:darkthemeenabled'] = 'Should the dark theme be choosable?'; $string['settings:isexamweb'] = 'Is this the Examweb?'; $string['settings:isexamweb_desc'] = 'This decides the page logo, as well as various things in templates (for example no slideshow, ...)'; +$string['settings:prescss'] = 'Additional Pre-SCSS Code'; $string['settings:primarycolor'] = 'Primary theme color'; $string['settings:secondarycolor'] = 'Secondary theme color'; -$string['settings:prescss'] = 'Additional Pre-SCSS Code'; -$string['settings:darkthemeenabled'] = 'Should the dark theme be choosable?'; - -// Examweb. -$string['exam:begin'] = 'Start of exam:'; -$string['exam:end'] = 'End of exam:'; - -$string['examweb_description'] = 'Online examination system of the University of Münster'; +$string['termindependent'] = 'Semester independent'; +$string['thiscourse'] = 'This Course'; +$string['usermenu'] = 'User menu'; +$string['viewfullsection'] = 'View full section'; diff --git a/layout/contentonly.php b/layout/contentonly.php index 08c92a8..eefe3e1 100644 --- a/layout/contentonly.php +++ b/layout/contentonly.php @@ -30,7 +30,7 @@ $templatecontext = [ 'bodyattributes' => $OUTPUT->body_attributes(), - 'output' => $OUTPUT + 'output' => $OUTPUT, ]; echo $OUTPUT->doctype_if_necessary(); diff --git a/layout/frontpage.php b/layout/frontpage.php index 223d256..0766072 100644 --- a/layout/frontpage.php +++ b/layout/frontpage.php @@ -37,7 +37,7 @@ $marketingboxes[$i]->index = $i; $marketingboxes[$i]->title = get_config('theme_wwu2019', 'marketing' . $marketingspot); $marketingboxes[$i]->content = format_text(get_config('theme_wwu2019', 'marketing' . $marketingspot . 'content'), FORMAT_HTML, - array('trusted' => true, 'noclean' => true)); + ['trusted' => true, 'noclean' => true]); } $templatecontext['marketingboxes'] = $marketingboxes; diff --git a/lib.php b/lib.php index 1c5c18b..fcabcf2 100644 --- a/lib.php +++ b/lib.php @@ -62,18 +62,22 @@ function theme_wwu2019_get_main_scss_content($theme) { return $pre . "\n" . $scss . "\n" . $post; } +/** + * Save preferences for the snow. + * @return array + */ function theme_wwu2019_user_preferences() { $preferences['theme_wwu2019_theme'] = [ 'null' => NULL_NOT_ALLOWED, 'default' => 0, 'type' => PARAM_INT, - 'choices' => [0, 1, 2,] + 'choices' => [0, 1, 2], ]; $preferences['theme_wwu2019_snow'] = [ 'null' => NULL_NOT_ALLOWED, 'default' => 1, 'type' => PARAM_INT, - 'choices' => [0, 1] + 'choices' => [0, 1], ]; return $preferences; } diff --git a/scss/wwu2019/forms.scss b/scss/wwu2019/forms.scss index ff90851..96e8b85 100644 --- a/scss/wwu2019/forms.scss +++ b/scss/wwu2019/forms.scss @@ -23,7 +23,7 @@ /* Buttons */ -.btn { +.btn, .btn.btn-icon { border-radius: 0; color: var(--wwu-fg); } diff --git a/settings.php b/settings.php index 9409e3d..29f9676 100644 --- a/settings.php +++ b/settings.php @@ -76,7 +76,7 @@ $alertwarning = get_string('alert_warning', 'theme_wwu2019'); $alertgeneral = get_string('alert_general', 'theme_wwu2019'); $alerttypedefault = 'info'; - $alerttypechoices = array('info' => $alertinfo, 'error' => $alertwarning, 'success' => $alertgeneral); + $alerttypechoices = ['info' => $alertinfo, 'error' => $alertwarning, 'success' => $alertgeneral]; $setting = new admin_setting_configselect('theme_wwu2019/alert1type', get_string('alert1type', 'theme_wwu2019'), get_string('alerttype_desc', 'theme_wwu2019'), @@ -173,7 +173,7 @@ 0, [ 0 => 'Disable snow', 1 => 'Enable snow', - 2 => 'Enable snow within timelimits' + 2 => 'Enable snow within timelimits', ])); $gimmickpage->add(new admin_setting_configtext('theme_wwu2019/snow_start', 'Start snow', 'Of course a unixtimestamp. Because it is very convenient.', 0)); diff --git a/version.php b/version.php index 0316359..d04d025 100644 --- a/version.php +++ b/version.php @@ -38,11 +38,11 @@ // This is a list of plugins, this plugin depends on (and their versions). $plugin->dependencies = [ - 'theme_classic' => 2019111800 + 'theme_classic' => 2019111800, ]; // This is a stable release. $plugin->maturity = MATURITY_ALPHA; // This is the named version. -$plugin->release = 0.1; \ No newline at end of file +$plugin->release = 0.1; From 41b67a2b0a0c8ba1253c2658a74f4ae64cd0df1e Mon Sep 17 00:00:00 2001 From: NinaHerrmann Date: Thu, 27 Jun 2024 10:53:10 +0200 Subject: [PATCH 03/19] first adjustments, taking rounded corners --- classes/output/core_renderer.php | 8 ++- scss/wwu2019/blocks.scss | 5 +- scss/wwu2019/courselayout.scss | 31 +++++++-- scss/wwu2019/forms.scss | 2 +- scss/wwu2019/general.scss | 11 +++- .../local/content/cm/cmname.mustache | 66 ------------------- 6 files changed, 43 insertions(+), 80 deletions(-) delete mode 100644 templates/core_courseformat/local/content/cm/cmname.mustache diff --git a/classes/output/core_renderer.php b/classes/output/core_renderer.php index c61536e..6f8d8db 100644 --- a/classes/output/core_renderer.php +++ b/classes/output/core_renderer.php @@ -26,6 +26,7 @@ use action_link; use context_course; +use core\output\icon_system; use image_icon; use moodle_page; use moodle_url; @@ -1414,7 +1415,7 @@ public function htmlattributes() { */ protected function render_pix_icon(pix_icon $icon) { $this->check_monologo($icon); - $system = \core\output\icon_system::instance(); + $system = icon_system::instance(); return $system->render_pix_icon($this, $icon); } @@ -1426,7 +1427,10 @@ protected function render_pix_icon(pix_icon $icon) { */ protected function render_image_icon(image_icon $icon) { $this->check_monologo($icon); - $system = \core\output\icon_system::instance(\core\output\icon_system::STANDARD); + $system = icon_system::instance(icon_system::STANDARD); + if (str_contains($icon->attributes['class'], 'activityicon')) { + var_dump($icon->attributes['class']); + } return $system->render_pix_icon($this, $icon); } diff --git a/scss/wwu2019/blocks.scss b/scss/wwu2019/blocks.scss index 08f1ab0..4d91f2d 100644 --- a/scss/wwu2019/blocks.scss +++ b/scss/wwu2019/blocks.scss @@ -26,15 +26,14 @@ } .block.card { - border: none; - border-radius: 0; background: var(--wwu-bg); word-break: break-word; > .card-body { - border: 2px solid var(--wwu-outlinegrey); + //border: 2px solid var(--wwu-outlinegrey); > .block-header { + border-radius: 0.5rem 0.5rem 0 0; background-color: $learnwebblue; color: white; padding: 0 12px; diff --git a/scss/wwu2019/courselayout.scss b/scss/wwu2019/courselayout.scss index 1574122..455605c 100644 --- a/scss/wwu2019/courselayout.scss +++ b/scss/wwu2019/courselayout.scss @@ -23,7 +23,7 @@ #region-main { border: 2px solid $outlinegrey; - border-radius: 0; + border-radius: 0.5rem; background: var(--wwu-bg); padding: 1em; } @@ -60,10 +60,17 @@ body.pagelayout-course { .course-content ul li.section.main { border-radius: 0; padding: 0; - border: 2px solid $outlinegrey; - margin-bottom: 0.5rem; + margin-top: 0; + + .topics { + margin-top: 0; + } .header, .course-section-header { + padding-left: 0; + padding-right: 0; + border-radius: 0.5rem 0.5rem 0 0; + box-sizing: border-box; background-color: $learnwebblue; color: white; display: flex; @@ -100,11 +107,11 @@ body.pagelayout-course { &> .content { margin: 0; - padding: 0 0.5rem 0.5rem; // overflow-x: auto; .section { margin: 0; + padding: 0 0.5rem 0.5rem; } .summary-view-full { @@ -128,6 +135,14 @@ body.pagelayout-course { } } + .course-section .section-item { + padding: 0 0 1rem 0; + .course-content-item-content.content{ + padding-left: 0.5rem; + padding-right: 0.5rem; + } + } + .course-content ul li.section.hidden .sectionname > span { /* !important is needed in order to overwrite .text-muted */ color: #ddd !important; /* stylelint-disable-line */ @@ -171,9 +186,13 @@ body.pagelayout-course { } } +.btn.btn-icon.icons-collapse-expand { + background-color: inherit; +} + .activity-item:not(.activityinline) { - border: none; padding: 0.5rem; + border: 2px solid var(--wwu-bg-1); @media (min-width: 768px) { padding: 0.5rem; @@ -369,4 +388,4 @@ body.path-grade #region-main-body { .activity-item.hiddenactivity .description .course-description-item, .activity-item.hiddenactivity .activityiconcontainer, .activity-item.hiddenactivity .badge { mix-blend-mode: normal; -} \ No newline at end of file +} diff --git a/scss/wwu2019/forms.scss b/scss/wwu2019/forms.scss index 96e8b85..d8eb1a4 100644 --- a/scss/wwu2019/forms.scss +++ b/scss/wwu2019/forms.scss @@ -24,7 +24,7 @@ /* Buttons */ .btn, .btn.btn-icon { - border-radius: 0; + border-radius: 0.5rem; color: var(--wwu-fg); } diff --git a/scss/wwu2019/general.scss b/scss/wwu2019/general.scss index 94a6433..a9abaf4 100644 --- a/scss/wwu2019/general.scss +++ b/scss/wwu2019/general.scss @@ -274,7 +274,7 @@ footer#wwu-footer + div > div.container { .nav-tabs { .nav-link { - border-radius: 0; + border-radius: 0.5rem; border: 2px solid transparent; } & > li { @@ -386,7 +386,7 @@ a:not([class]):focus, } .nav-tabs > .nav-item > .nav-link { - border: 2px solid var(--wwu-outlinegrey); + border: 1px solid var(--wwu-outlinegrey); background-color: var(--wwu-tab-bg-inactive); color: var(--wwu-tab-fg-inactive); @@ -401,14 +401,21 @@ a:not([class]):focus, background-color: var(--wwu-bg); border-bottom-color: var(--wwu-bg); box-shadow: none; + border-radius: 0.5rem 0.5rem 0 0; } } +.secondary-navigation .navigation .nav-tabs .nav-item .nav-link { + border-radius: 0.5rem 0.5rem 0 0; +} .nav-tabs .nav-link { &:focus, &:hover { background-color: var(--wwu-bg-1); } + &:active { + border-radius: 0.5rem 0.5rem 0 0; + } } .nav-tabs { diff --git a/templates/core_courseformat/local/content/cm/cmname.mustache b/templates/core_courseformat/local/content/cm/cmname.mustache deleted file mode 100644 index a02ba1e..0000000 --- a/templates/core_courseformat/local/content/cm/cmname.mustache +++ /dev/null @@ -1,66 +0,0 @@ -{{! - This file is part of Moodle - http://moodle.org/ - - Moodle is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Moodle is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Moodle. If not, see . -}} -{{! - @template core_courseformat/local/content/cm/cmname - - Convenience mustache to displays a course module inplcae editable from the format renderer. - - Format plugins are free to implement an alternative inplace editable for activities. - - Example context (json): - { - "url": "#", - "icon": "../../../pix/help.svg", - "pluginname": "File", - "textclasses": "", - "purpose": "content", - "modname": "resource", - "activityname": { - "displayvalue" : "Moodle", - "value" : "Moodle", - "itemid" : "1", - "component" : "core_unknown", - "itemtype" : "unknown", - "edithint" : "Edit this", - "editlabel" : "New name for this", - "type" : "text", - "options" : "", - "linkeverything": 0 - } - } -}} -{{#url}} -
-
-
- -
-
- -
- {{#activityname}} - {{$ core/inplace_editable }} - {{> core/inplace_editable }} - {{/ core/inplace_editable }} - {{/activityname}} -
-
-
-
-{{/url}} From 71fe2a9371652a8cadb6902a42aa5bfa55b81781 Mon Sep 17 00:00:00 2001 From: NinaHerrmann Date: Wed, 10 Jul 2024 13:22:15 +0200 Subject: [PATCH 04/19] WIP make corners sharper and add marketing rules --- classes/output/core/course_renderer.php | 5 ----- classes/output/core_renderer.php | 27 ++++++++++--------------- scss/wwu2019/blocks.scss | 2 +- scss/wwu2019/courselayout.scss | 8 ++++---- scss/wwu2019/general.scss | 4 ++-- scss/wwu2019/marketingboxes.scss | 19 +++++++++++++++++ scss/wwu2019/menu.scss | 2 +- scss/wwu2019/slideshow.scss | 2 +- 8 files changed, 39 insertions(+), 30 deletions(-) diff --git a/classes/output/core/course_renderer.php b/classes/output/core/course_renderer.php index 03692fc..a21375e 100644 --- a/classes/output/core/course_renderer.php +++ b/classes/output/core/course_renderer.php @@ -75,11 +75,6 @@ public function course_search_form($value = '', $format = 'plain') { $data->value = $value; $data->globalsearch = (new \moodle_url('/search/index.php'))->out(false); - if ($format != 'navbar') { - $helpicon = new \help_icon('coursesearch', 'core'); - $data->helpicon = $helpicon->export_for_template($this); - } - $output = $this->render_from_template('theme_wwu2019/course_search_form', $data); return $output; } diff --git a/classes/output/core_renderer.php b/classes/output/core_renderer.php index 6f8d8db..1127315 100644 --- a/classes/output/core_renderer.php +++ b/classes/output/core_renderer.php @@ -1428,9 +1428,6 @@ protected function render_pix_icon(pix_icon $icon) { protected function render_image_icon(image_icon $icon) { $this->check_monologo($icon); $system = icon_system::instance(icon_system::STANDARD); - if (str_contains($icon->attributes['class'], 'activityicon')) { - var_dump($icon->attributes['class']); - } return $system->render_pix_icon($this, $icon); } @@ -1439,19 +1436,17 @@ protected function render_image_icon(image_icon $icon) { * @param pix_icon $icon */ private function check_monologo(pix_icon $icon) { - if ($icon->pix === 'monologo' || $icon->pix === 'icon') { - if (!in_array($icon->component, ['moodle', 'core', 'theme', null]) && ( - substr_compare($icon->component, 'mod_', 0, 4) === 0 || - strpos($icon->component, '_') === false - ) - ) { - if ($location = $this->page->theme->resolve_image_location($icon->pix, $icon->component, null)) { - if (substr_compare($location, 'monologo.svg', -12) === 0) { - if (isset($icon->attributes['class'])) { - $icon->attributes['class'] .= ' wwu-monologo '; - } else { - $icon->attributes['class'] = ' wwu-monologo '; - } + if (!in_array($icon->component, ['moodle', 'core', 'theme', null]) && ( + substr_compare($icon->component, 'mod_', 0, 4) === 0 || + !str_contains($icon->component, '_') + ) + ) { + if ($location = $this->page->theme->resolve_image_location($icon->pix, $icon->component, null)) { + if (substr_compare($location, 'monologo.svg', -12) === 0) { + if (isset($icon->attributes['class'])) { + $icon->attributes['class'] .= ' wwu-monologo '; + } else { + $icon->attributes['class'] = ' wwu-monologo '; } } } diff --git a/scss/wwu2019/blocks.scss b/scss/wwu2019/blocks.scss index 4d91f2d..76f16d9 100644 --- a/scss/wwu2019/blocks.scss +++ b/scss/wwu2019/blocks.scss @@ -33,7 +33,7 @@ //border: 2px solid var(--wwu-outlinegrey); > .block-header { - border-radius: 0.5rem 0.5rem 0 0; + border-radius: 0.25rem 0.25rem 0 0; background-color: $learnwebblue; color: white; padding: 0 12px; diff --git a/scss/wwu2019/courselayout.scss b/scss/wwu2019/courselayout.scss index 455605c..97d0a8e 100644 --- a/scss/wwu2019/courselayout.scss +++ b/scss/wwu2019/courselayout.scss @@ -22,7 +22,7 @@ */ #region-main { - border: 2px solid $outlinegrey; + border: 1px solid $outlinegrey; border-radius: 0.5rem; background: var(--wwu-bg); padding: 1em; @@ -33,7 +33,7 @@ color: white; // Should be white both in light and dark theme. background: $learnwebblue; padding: 16px 16px 14px 16px; - border: 2px solid $outlinegrey; + border: 1px solid $outlinegrey; font-size: 26px; text-transform: uppercase; } @@ -192,7 +192,7 @@ body.pagelayout-course { .activity-item:not(.activityinline) { padding: 0.5rem; - border: 2px solid var(--wwu-bg-1); + border: 1px solid var(--wwu-bg-1); @media (min-width: 768px) { padding: 0.5rem; @@ -300,7 +300,7 @@ body.format-topcoll { } .course-content ul.ctopics li.section.main { - border-bottom: 2px solid $outlinegrey; + border-bottom: 1px solid $outlinegrey; margin-bottom: 16px; .header { diff --git a/scss/wwu2019/general.scss b/scss/wwu2019/general.scss index a9abaf4..97bb94f 100644 --- a/scss/wwu2019/general.scss +++ b/scss/wwu2019/general.scss @@ -275,7 +275,7 @@ footer#wwu-footer + div > div.container { .nav-link { border-radius: 0.5rem; - border: 2px solid transparent; + border: 1px solid transparent; } & > li { margin-left: 10px; @@ -450,7 +450,7 @@ a:not([class]):focus, .nav-tabs:not(.more-nav) .nav-link.active:not(:disabled):not(.disabled):active, .nav-tabs:not(.more-nav) .nav-link.active:not(:disabled):not(.disabled).active, .show > .nav-tabs:not(.more-nav) .nav-link.active.dropdown-toggle, .nav-pills .nav-link.active:not(:disabled):not(.disabled):active, .nav-pills .nav-link.active:not(:disabled):not(.disabled).active, .show > .nav-pills .nav-link.active.dropdown-toggle { color: var(--wwu-fg); background: var(--wwu-bg); - border: 2px solid var(--wwu-bg-5); + border: 1px solid var(--wwu-bg-5); } .nav-tabs:not(.more-nav) .nav-link.active:not(:disabled):not(.disabled):active:focus, .nav-tabs:not(.more-nav) .nav-link.active:not(:disabled):not(.disabled).active:focus, .show > .nav-tabs:not(.more-nav) .nav-link.active.dropdown-toggle:focus, .nav-pills .nav-link.active:not(:disabled):not(.disabled):active:focus, .nav-pills .nav-link.active:not(:disabled):not(.disabled).active:focus, .show > .nav-pills .nav-link.active.dropdown-toggle:focus { box-shadow: 0 0 0 0.2rem rgba(104, 111, 117, 0.5); diff --git a/scss/wwu2019/marketingboxes.scss b/scss/wwu2019/marketingboxes.scss index 4660ef3..7e15e52 100644 --- a/scss/wwu2019/marketingboxes.scss +++ b/scss/wwu2019/marketingboxes.scss @@ -23,6 +23,25 @@ #region-marketing .block.card .card-body .card-text { height: calc(100% - #{$block-header-height}); + padding: 0; +} + +#region-marketing .block.card { + padding: 0; +} + +#region-marketing .block.card { + padding: 0; + margin-left: 5px; + margin-right: 5px; + flex: 1 1 calc(33.333% - 40px); + &:first-child { + margin-left: 0; + } + + &:last-child { + margin-right: 0; + } } @media (max-width: $onecolumn-break-point) { diff --git a/scss/wwu2019/menu.scss b/scss/wwu2019/menu.scss index 0ef6369..26c34ad 100644 --- a/scss/wwu2019/menu.scss +++ b/scss/wwu2019/menu.scss @@ -316,7 +316,7 @@ ul.main-menubar { margin-left: 4px; .sub-menu-scroll-wrapper { - border: 2px solid var(--wwu-dividergrey); + border: 1px solid var(--wwu-dividergrey); border-top: 0; right: 0; left: auto; diff --git a/scss/wwu2019/slideshow.scss b/scss/wwu2019/slideshow.scss index ae8597b..1da7382 100644 --- a/scss/wwu2019/slideshow.scss +++ b/scss/wwu2019/slideshow.scss @@ -24,7 +24,7 @@ /* Slideshow */ #wwuCarousel.carousel { - border: 2px solid var(--wwu-outlinegrey); + border: 1px solid var(--wwu-outlinegrey); .carousel-inner { margin-bottom: 26px; From 27592843a7edd7d39c6776701336c7ca5b510e5b Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Wed, 10 Jul 2024 15:23:55 +0200 Subject: [PATCH 05/19] Fix corners and spacing --- scss/wwu2019/blocks.scss | 7 ++++++- scss/wwu2019/courselayout.scss | 28 ++++++++-------------------- templates/full_header.mustache | 8 +++++--- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/scss/wwu2019/blocks.scss b/scss/wwu2019/blocks.scss index 76f16d9..a8decfb 100644 --- a/scss/wwu2019/blocks.scss +++ b/scss/wwu2019/blocks.scss @@ -28,12 +28,13 @@ .block.card { background: var(--wwu-bg); word-break: break-word; + border-radius: 0.75rem; + overflow: clip; > .card-body { //border: 2px solid var(--wwu-outlinegrey); > .block-header { - border-radius: 0.25rem 0.25rem 0 0; background-color: $learnwebblue; color: white; padding: 0 12px; @@ -45,6 +46,10 @@ margin: 4px 0; font-size: 1em; } + + .menubar { + margin-top: 2px; + } } } diff --git a/scss/wwu2019/courselayout.scss b/scss/wwu2019/courselayout.scss index 97d0a8e..40f4b6b 100644 --- a/scss/wwu2019/courselayout.scss +++ b/scss/wwu2019/courselayout.scss @@ -33,7 +33,7 @@ color: white; // Should be white both in light and dark theme. background: $learnwebblue; padding: 16px 16px 14px 16px; - border: 1px solid $outlinegrey; + border-radius: 0.75rem; font-size: 26px; text-transform: uppercase; } @@ -58,18 +58,16 @@ body.pagelayout-report { body.pagelayout-course { .course-content ul li.section.main { - border-radius: 0; - padding: 0; - margin-top: 0; + + &:first-child { + margin-top: 0; + } .topics { margin-top: 0; } .header, .course-section-header { - padding-left: 0; - padding-right: 0; - border-radius: 0.5rem 0.5rem 0 0; box-sizing: border-box; background-color: $learnwebblue; color: white; @@ -137,6 +135,9 @@ body.pagelayout-course { .course-section .section-item { padding: 0 0 1rem 0; + border-radius: 0.75rem; + overflow: clip; + .course-content-item-content.content{ padding-left: 0.5rem; padding-right: 0.5rem; @@ -190,19 +191,6 @@ body.pagelayout-course { background-color: inherit; } -.activity-item:not(.activityinline) { - padding: 0.5rem; - border: 1px solid var(--wwu-bg-1); - - @media (min-width: 768px) { - padding: 0.5rem; - } -} - -.activity-item.activityinline { - padding: 0.5rem; -} - .editing .activity-item:hover { background-color: var(--wwu-bg-1); color: unset; diff --git a/templates/full_header.mustache b/templates/full_header.mustache index babce39..f94c5ce 100644 --- a/templates/full_header.mustache +++ b/templates/full_header.mustache @@ -40,9 +40,11 @@ {{/pageheadingbutton}}
-
- {{{contextheader}}} -
+ {{#contextheader}} +
+ {{{contextheader}}} +
+ {{/contextheader}}
{{#headeractions}}
{{{.}}}
From ddf933dce92583d4ffe97917363256ceba554a61 Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Wed, 10 Jul 2024 15:46:24 +0200 Subject: [PATCH 06/19] Add courselayout and tables in darkmode --- scss/wwu2019/courselayout.scss | 13 +++++-------- scss/wwu2019/theming.scss | 5 +++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scss/wwu2019/courselayout.scss b/scss/wwu2019/courselayout.scss index 40f4b6b..eee61df 100644 --- a/scss/wwu2019/courselayout.scss +++ b/scss/wwu2019/courselayout.scss @@ -137,6 +137,7 @@ body.pagelayout-course { padding: 0 0 1rem 0; border-radius: 0.75rem; overflow: clip; + border-color: var(--wwu-muted-bg); .course-content-item-content.content{ padding-left: 0.5rem; @@ -362,16 +363,12 @@ body.path-grade #region-main-body { display: inline-block; } -.section li.activity:not(:last-child) { - border-bottom: 1px solid var(--wwu-muted-bg); +.activity { + border-color: var(--wwu-muted-bg); } -.activity-item.hiddenactivity { - background-color: var(--wwu-bg-1); -} - -.activity-item.hiddenactivity:hover { - background-color: var(--wwu-bg-2); +.activity-item { + background-color: var(--wwu-bg); } .activity-item.hiddenactivity .description .course-description-item, .activity-item.hiddenactivity .activityiconcontainer, .activity-item.hiddenactivity .badge { diff --git a/scss/wwu2019/theming.scss b/scss/wwu2019/theming.scss index 760cc20..53c5407 100644 --- a/scss/wwu2019/theming.scss +++ b/scss/wwu2019/theming.scss @@ -194,6 +194,11 @@ table.mod-data-default-template { color: var(--wwu-fg); + thead .sticky-column, + tbody tr:nth-of-type(2n) { + background-color: var(--wwu-bg); + } + thead th, th, td { From 46ed5661b1eaed9d10f2ea20cead610b8b9693b0 Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Wed, 10 Jul 2024 16:27:46 +0200 Subject: [PATCH 07/19] Darktheme & local_marketing fixes --- scss/wwu2019/courselayout.scss | 7 ++++++- scss/wwu2019/theming.scss | 23 +++++++++++++++++++++++ templates/frontpage.mustache | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/scss/wwu2019/courselayout.scss b/scss/wwu2019/courselayout.scss index eee61df..b59cb41 100644 --- a/scss/wwu2019/courselayout.scss +++ b/scss/wwu2019/courselayout.scss @@ -363,7 +363,8 @@ body.path-grade #region-main-body { display: inline-block; } -.activity { +.activity, +.activity-item .activity-afterlink { border-color: var(--wwu-muted-bg); } @@ -374,3 +375,7 @@ body.path-grade #region-main-body { .activity-item.hiddenactivity .description .course-description-item, .activity-item.hiddenactivity .activityiconcontainer, .activity-item.hiddenactivity .badge { mix-blend-mode: normal; } + +.divider .divider-content { + background: linear-gradient(transparent 40%, var(--wwu-bg) 40%, var(--wwu-bg) 60%, transparent 60%); +} diff --git a/scss/wwu2019/theming.scss b/scss/wwu2019/theming.scss index 53c5407..40041da 100644 --- a/scss/wwu2019/theming.scss +++ b/scss/wwu2019/theming.scss @@ -916,6 +916,29 @@ canvas.snow { opacity: 0.3 !important; } + + .btn.add-content { + color: #5b8f9d; + background-color: #283133; + + &:hover, &:focus { + color: #fff; + background-color: #006784; + } + } + + .btn.add-section { + border-color: var(--wwu-muted-bg); + + &:hover, &:focus { + background-color: var(--wwu-muted-bg); + color: var(--wwu-learnwebblue); + } + } + + .activity-item .activity-groupmode-info { + filter: invert(1); + } } diff --git a/templates/frontpage.mustache b/templates/frontpage.mustache index 19956e4..a1a3f71 100644 --- a/templates/frontpage.mustache +++ b/templates/frontpage.mustache @@ -81,7 +81,7 @@ {{/isexamweb}}
-
+
{{#marketingboxes}}
From 9397e1bd29e5f419237e1107a7a031a924ed24bd Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Wed, 10 Jul 2024 16:44:17 +0200 Subject: [PATCH 08/19] More theme fixes --- scss/wwu2019/courselayout.scss | 8 ++++++++ scss/wwu2019/theming.scss | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/scss/wwu2019/courselayout.scss b/scss/wwu2019/courselayout.scss index b59cb41..f56d172 100644 --- a/scss/wwu2019/courselayout.scss +++ b/scss/wwu2019/courselayout.scss @@ -372,10 +372,18 @@ body.path-grade #region-main-body { background-color: var(--wwu-bg); } +.activity-item.hiddenactivity { + background-color: var(--wwu-bg-1); +} + .activity-item.hiddenactivity .description .course-description-item, .activity-item.hiddenactivity .activityiconcontainer, .activity-item.hiddenactivity .badge { mix-blend-mode: normal; } +.course-section .availabilityinfo { + background-color: var(--wwu-bg-3); +} + .divider .divider-content { background: linear-gradient(transparent 40%, var(--wwu-bg) 40%, var(--wwu-bg) 60%, transparent 60%); } diff --git a/scss/wwu2019/theming.scss b/scss/wwu2019/theming.scss index 40041da..ad37d83 100644 --- a/scss/wwu2019/theming.scss +++ b/scss/wwu2019/theming.scss @@ -144,7 +144,11 @@ } .text-dark { - color: var(--wwu-fg-1); + color: var(--wwu-fg-1) !important; + } + + a.text-dark:hover, a.text-dark:focus { + color: var(--wwu-fg) !important; } .icon.wwu-monologo { @@ -967,6 +971,14 @@ } +.action-menu .dropdown-subpanel.content-displayed { + background-color: var(--wwu-bg-2); +} + +.text-primary { + color: var(--wwu-learnwebblue) !important; +} + :root { @include light-colors; color-scheme: light dark; From bbaf5f27b46b9fb2cd3146a4577a7122ea72f6ab Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Fri, 9 Aug 2024 13:05:04 +0200 Subject: [PATCH 09/19] Remove overflow: clip from blocks and various dark theme fixes --- scss/wwu2019/blocks.scss | 4 ++-- scss/wwu2019/courselayout.scss | 2 +- scss/wwu2019/general.scss | 2 +- scss/wwu2019/theming.scss | 28 ++++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/scss/wwu2019/blocks.scss b/scss/wwu2019/blocks.scss index a8decfb..58e4419 100644 --- a/scss/wwu2019/blocks.scss +++ b/scss/wwu2019/blocks.scss @@ -29,10 +29,9 @@ background: var(--wwu-bg); word-break: break-word; border-radius: 0.75rem; - overflow: clip; + border-color: var(--wwu-muted-bg); > .card-body { - //border: 2px solid var(--wwu-outlinegrey); > .block-header { background-color: $learnwebblue; @@ -41,6 +40,7 @@ font-size: 18px; display: flex; justify-content: space-between; + border-radius: 0.7rem 0.7rem 0 0; > .card-title { margin: 4px 0; diff --git a/scss/wwu2019/courselayout.scss b/scss/wwu2019/courselayout.scss index f56d172..fa2933f 100644 --- a/scss/wwu2019/courselayout.scss +++ b/scss/wwu2019/courselayout.scss @@ -73,6 +73,7 @@ body.pagelayout-course { color: white; display: flex; width: 100%; + border-radius: 0.7rem 0.7rem 0 0; a, .btn-link { @@ -136,7 +137,6 @@ body.pagelayout-course { .course-section .section-item { padding: 0 0 1rem 0; border-radius: 0.75rem; - overflow: clip; border-color: var(--wwu-muted-bg); .course-content-item-content.content{ diff --git a/scss/wwu2019/general.scss b/scss/wwu2019/general.scss index 97bb94f..748f616 100644 --- a/scss/wwu2019/general.scss +++ b/scss/wwu2019/general.scss @@ -369,7 +369,7 @@ a:not([class]):focus, .secondary-navigation { padding: 0; - margin-bottom: -2px; + margin-bottom: -0.7px; margin-left: 0; z-index: 3; diff --git a/scss/wwu2019/theming.scss b/scss/wwu2019/theming.scss index ad37d83..60631ab 100644 --- a/scss/wwu2019/theming.scss +++ b/scss/wwu2019/theming.scss @@ -280,6 +280,18 @@ &:focus { color: var(--wwu-fg); } + + &> img.icon { + filter: invert(1); + } + } + + .dropdown-subpanel-content .bg-primary-light { + background-color: var(--wwu-bg-1); + } + + .dropdown-subpanel-content .option-icon img { + filter: invert(1); } .activity-item .activityname a { @@ -733,6 +745,22 @@ border-color: var(--wwu-bg-3); } + .bg-info { + background-color: var(--wwu-info-bg) !important; + } + + .bg-warning { + background-color: var(--wwu-warn-bg) !important; + } + + .bg-error { + background-color: var(--wwu-error-bg) !important; + } + + .bg-success { + background-color: var(--wwu-success-bg) !important; + } + /** 3rd party plugin theme fixes **/ .qn-question, .qn-info { From 89b48ec558cc2a9cc1033bd2f68e4838cc978d6b Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Wed, 14 Aug 2024 16:22:09 +0200 Subject: [PATCH 10/19] Dark theme: fix block_xp and mod_questionnaire --- scss/wwu2019/3rd-party-fixes.scss | 31 ++++++--- scss/wwu2019/courselayout.scss | 21 +++--- scss/wwu2019/general.scss | 5 +- scss/wwu2019/theming.scss | 106 ++++++++++++++++++++++++------ 4 files changed, 120 insertions(+), 43 deletions(-) diff --git a/scss/wwu2019/3rd-party-fixes.scss b/scss/wwu2019/3rd-party-fixes.scss index 198d9a5..26dd070 100644 --- a/scss/wwu2019/3rd-party-fixes.scss +++ b/scss/wwu2019/3rd-party-fixes.scss @@ -54,16 +54,6 @@ body.path-mod-cas table.generaltable table[border]{ border-color: var(--wwu-bg-3); } -/* block_xp */ -.block_xp nav .nav-button, -.block_xp .xp-test-gray900 { - color: var(--wwu-fg-1); -} - -.block_xp nav .nav-button:hover { - background: var(--wwu-bg-1); -} - .block_xp-table tr.highlight-row > td { background-color: var(--wwu-info-bg); } @@ -94,3 +84,24 @@ body.path-mod-cas table.generaltable table[border]{ border-bottom-color: var(--wwu-muted-bg); } } + +/* mod_questionnaire */ +#page-mod-questionnaire-complete, +#page-mod-questionnaire-preview, +#page-mod-questionnaire-print, +#page-mod-questionnaire-report .individual, +#page-mod-questionnaire-myreport .individual { + .raterow { + background: var(--wwu-bg); + } +} + +#page-mod-questionnaire-complete td.raterow:hover, +#page-mod-questionnaire-preview td.raterow:hover { + background: var(--wwu-bg-1); + border-color: var(--wwu-bg-3); +} + +#page-mod-questionnaire-complete .raterow:hover, #page-mod-questionnaire-preview .raterow:hover { + background-color: var(--wu-bg-1); +} diff --git a/scss/wwu2019/courselayout.scss b/scss/wwu2019/courselayout.scss index fa2933f..a330f49 100644 --- a/scss/wwu2019/courselayout.scss +++ b/scss/wwu2019/courselayout.scss @@ -134,17 +134,6 @@ body.pagelayout-course { } } - .course-section .section-item { - padding: 0 0 1rem 0; - border-radius: 0.75rem; - border-color: var(--wwu-muted-bg); - - .course-content-item-content.content{ - padding-left: 0.5rem; - padding-right: 0.5rem; - } - } - .course-content ul li.section.hidden .sectionname > span { /* !important is needed in order to overwrite .text-muted */ color: #ddd !important; /* stylelint-disable-line */ @@ -178,7 +167,17 @@ body.pagelayout-course { &:not(.editing) .course-content ul.weeks li.section .right { display: inherit; } +} +.course-section .section-item { + padding: 0 0 1rem 0; + border-radius: 0.75rem; + border-color: var(--wwu-muted-bg); + + .course-content-item-content.content{ + padding-left: 0.5rem; + padding-right: 0.5rem; + } } .btn.btn-icon { diff --git a/scss/wwu2019/general.scss b/scss/wwu2019/general.scss index 748f616..b30338b 100644 --- a/scss/wwu2019/general.scss +++ b/scss/wwu2019/general.scss @@ -409,13 +409,12 @@ a:not([class]):focus, } .nav-tabs .nav-link { + border-radius: 0.5rem 0.5rem 0 0; + &:focus, &:hover { background-color: var(--wwu-bg-1); } - &:active { - border-radius: 0.5rem 0.5rem 0 0; - } } .nav-tabs { diff --git a/scss/wwu2019/theming.scss b/scss/wwu2019/theming.scss index 60631ab..046ae8f 100644 --- a/scss/wwu2019/theming.scss +++ b/scss/wwu2019/theming.scss @@ -286,12 +286,15 @@ } } - .dropdown-subpanel-content .bg-primary-light { - background-color: var(--wwu-bg-1); - } + .dropdown-menu, + .dropdown-subpanel-content { + .bg-primary-light { + background-color: var(--wwu-bg-1); + } - .dropdown-subpanel-content .option-icon img { - filter: invert(1); + .option-icon img { + filter: invert(1); + } } .activity-item .activityname a { @@ -310,7 +313,8 @@ background-color: var(--wwu-bg-1); } - .form-autocomplete-suggestions li { + .form-autocomplete-suggestions li, + .activity-item .activity-completion .completion-dialog { color: var(--wwu-fg-1); } @@ -841,24 +845,80 @@ background-color:var(--wwu-info-bg); } - /** block_xp */ + /* block_xp */ + .block.block_xp, + .block_xp { + nav { + border-color: var(--wwu-bg-3); + } - .block_xp .react-numeric-input > b { - filter: invert(1); - } + nav .nav-button { + color: var(--wwu-fg-2); + } - .block_xp .xp-bg-gray-100, - .block_xp-level-grid .block_xp-level-no, - .block_xp-level-grid .block_xp-level-box { - color: black; - } + .xp-text-gray-50 { + color: var(--wwu-bg-1); + } - .block_xp .xp-bg-gray-200 { - color: var(--wwu-bg-5); + .xp-text-gray-900, + .xp-text-gray-600, + .xp-text-gray-500 { + color: var(--wwu-fg); + } + + .xp-bg-gray-200 { + background-color: var(--wwu-bg-2); + } + + :is(.hover\:xp-bg-gray-100:hover) { + background-color: var(--wwu-bg-2); + } + + .xp-bg-gray-100 { + background-color: var(--wwu-bg-1); + } + + :is(.hover\:xp-bg-gray-50:hover) { + background-color: var(--wwu-bg-1); + } + + .xp-border-gray-200 { + border-color: var(--wwu-bg-2); + } + + .xp-border-gray-300 { + border-color: var(--wwu-bg-3); + } + + .xp-bg-white { + background-color: var(--wwu-bg); + } + + .nav-button:hover { + background: var(--wwu-bg-1); + } + + .block_xp-heading { + border-color: var(--wwu-bg-3); + color: var(--wwu-fg-1); + } + + .react-numeric-input > b { + filter: invert(1); + } + + .block_xp-level-grid .block_xp-level-no, + .block_xp-level-grid .block_xp-level-box { + background-color: var(--wwu-bg-1); + } + + .block_xp-level-grid .block_xp-level-no { + color: black; + } } - .block_xp .xp-text-gray-600 { - color: var(--wwu-fg); + .block_xp-table tr.highlight-row > td { + background-color: var(--wwu-warn-bg) !important; } /** mod_margic */ @@ -971,6 +1031,10 @@ .activity-item .activity-groupmode-info { filter: invert(1); } + + .bg-secondary.text-dark { + color: white !important; + } } @@ -1007,6 +1071,10 @@ color: var(--wwu-learnwebblue) !important; } +.bg-secondary.text-dark { + color: white !important; +} + :root { @include light-colors; color-scheme: light dark; From b6331a27ec46702b93aa76e4b5877019130465cf Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Wed, 14 Aug 2024 16:27:13 +0200 Subject: [PATCH 11/19] Different dark theme fixes in course --- scss/wwu2019/theming.scss | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scss/wwu2019/theming.scss b/scss/wwu2019/theming.scss index 046ae8f..b49d643 100644 --- a/scss/wwu2019/theming.scss +++ b/scss/wwu2019/theming.scss @@ -828,6 +828,10 @@ } } + .opencast-vlist { + border-color: var(--wwu-muted-bg); + } + #page-mod-quiz-view table.quizattemptsummary tr.bestrow td, body.path-mod-quiz .gradedattempt, body.path-mod-quiz table tbody tr.gradedattempt > td { background-color: var(--wwu-info-bg); @@ -952,6 +956,17 @@ border-color: var(--wwu-bg-4); } + .activity-item .activity-altcontent.activity-description { + border-color: var(--wwu-muted-bg); + } + + .activity-item .activity-completion button.btn, + .activity-item .activity-completion a[role="button"].btn { + color: var(--wwu-fg); + background-color: var(--wwu-bg); + border-color: var(--wwu-bg-4); + } + // File manager. .filemanager .yui3-datatable-header { background: var(--wwu-bg) !important; From 26eedc95f42a057663e281258a986af4b9daf098 Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Wed, 14 Aug 2024 16:35:51 +0200 Subject: [PATCH 12/19] Dark theme: more block_xp fixes --- scss/wwu2019/theming.scss | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/scss/wwu2019/theming.scss b/scss/wwu2019/theming.scss index b49d643..87f2c9f 100644 --- a/scss/wwu2019/theming.scss +++ b/scss/wwu2019/theming.scss @@ -350,6 +350,15 @@ border: 1px solid var(--wwu-bg); } + .filemanager-container, .filepicker-filelist { + border-color: var(--wwu-muted-bg); + } + + .filepicker-filelist .filepicker-container, + .filemanager.fm-noitems .fm-empty-container { + border-color: var(--wwu-bg-5); + } + .file-picker .fp-content, .fp-iconview .fp-filename-field .fp-filename, .filepicker-filelist .dndupload-target, @@ -886,6 +895,10 @@ background-color: var(--wwu-bg-1); } + .xp-border-gray-100 { + border-color: var(--wwu-bg-1); + } + .xp-border-gray-200 { border-color: var(--wwu-bg-2); } @@ -911,14 +924,22 @@ filter: invert(1); } - .block_xp-level-grid .block_xp-level-no, - .block_xp-level-grid .block_xp-level-box { - background-color: var(--wwu-bg-1); - } - .block_xp-level-grid .block_xp-level-no { color: black; } + + .block-xp-filters-wrapper .filter, + .block_xp-rulepicker-content .rule { + border-color: var(--wwu-muted-bg); + } + + .block_xp-level-grid .block_xp-level-no, + .block_xp-level-grid .block_xp-level-box, + .block-xp-filters-wrapper .rule-type-ruleset > .rule-definition, + .block_xp-rulepicker-content .rule:focus, + .block_xp-rulepicker-content .rule:hover { + background-color: var(--wwu-bg-1); + } } .block_xp-table tr.highlight-row > td { From c8c19bca80c5efc66c4fe05355af0f226fd595dd Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Mon, 19 Aug 2024 14:26:22 +0200 Subject: [PATCH 13/19] Add back small padding to course sections --- scss/wwu2019/courselayout.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/scss/wwu2019/courselayout.scss b/scss/wwu2019/courselayout.scss index a330f49..a75c493 100644 --- a/scss/wwu2019/courselayout.scss +++ b/scss/wwu2019/courselayout.scss @@ -106,6 +106,7 @@ body.pagelayout-course { &> .content { margin: 0; + padding: 0 .5rem .5rem; // overflow-x: auto; .section { From 1f25be161766ca39e9d82a435a377e347b7ad9fb Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Mon, 19 Aug 2024 14:26:30 +0200 Subject: [PATCH 14/19] Make blocks a bit bigger --- scss/wwu2019/general.scss | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/scss/wwu2019/general.scss b/scss/wwu2019/general.scss index b30338b..5135660 100644 --- a/scss/wwu2019/general.scss +++ b/scss/wwu2019/general.scss @@ -100,6 +100,41 @@ $page-padding: 1rem; margin-right: auto; } +#page-content.blocks-post { + @media (min-width: 768px) { + .region-main { + flex: 0 0 65%; + max-width: 65%; + } + .columnright { + flex: 0 0 35%; + max-width: 35%; + } + } + + @media (min-width: 992px) { + .region-main { + flex: 0 0 71%; + max-width: 71%; + } + .columnright { + flex: 0 0 29%; + max-width: 29%; + } + } + + @media (min-width: 1200px) { + .region-main { + flex: 0 0 74%; + max-width: 74%; + } + .columnright { + flex: 0 0 26%; + max-width: 26%; + } + } +} + .pagelayout-embedded #page { padding: 0; } From 55d91d62535a827ece29f81b1a589eaf4fac7197 Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Wed, 21 Aug 2024 18:47:16 +0200 Subject: [PATCH 15/19] Fix padding and borders in course --- scss/wwu2019/courselayout.scss | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/scss/wwu2019/courselayout.scss b/scss/wwu2019/courselayout.scss index a75c493..323475e 100644 --- a/scss/wwu2019/courselayout.scss +++ b/scss/wwu2019/courselayout.scss @@ -104,22 +104,21 @@ body.pagelayout-course { } } - &> .content { + .content { margin: 0; - padding: 0 .5rem .5rem; + padding: 0 1rem; // overflow-x: auto; - .section { - margin: 0; - padding: 0 0.5rem 0.5rem; - } - .summary-view-full { font-size: .8203125rem; display: block; color: $learnwebblue; text-decoration: underline; } + + .section li:first-child { + border: none; + } } // Highlighted section From 75e02619c6e0df15a123e49e6d3923fb388b56df Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Tue, 27 Aug 2024 18:42:47 +0200 Subject: [PATCH 16/19] Rename .dark to .dark-theme because of conflict with mootimeter. Use light-colors in mootimeter --- amd/build/menu.min.js | 2 +- amd/build/menu.min.js.map | 2 +- amd/build/snow.min.js | 4 +-- amd/build/snow.min.js.map | 2 +- amd/src/menu.js | 18 ++++++++------ amd/src/snow.js | 1 + classes/output/core_renderer.php | 6 ++--- scss/wwu2019/theming.scss | 42 +++++++++++++++++++++++--------- 8 files changed, 49 insertions(+), 28 deletions(-) diff --git a/amd/build/menu.min.js b/amd/build/menu.min.js index 3bd048f..27631b8 100644 --- a/amd/build/menu.min.js +++ b/amd/build/menu.min.js @@ -5,6 +5,6 @@ define("theme_wwu2019/menu",["exports","jquery","core/ajax","core/notification"] * @module theme_wwu2019/menu * @copyright 2019 Justus Dieckmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */function updateThemePreferenceAjax(theme){var request={methodname:"core_user_update_user_preferences",args:{preferences:[{type:"theme_wwu2019_theme",value:theme}]}};_ajax.default.call([request])[0].fail(_notification.default.exception)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){(function(){const openDelay=100,closeDelay=300,closeCooldown=300;let openMenu=null,openCandidate=null,openTimeoutId=null,closeTimeoutId=null,openTime=null;function open(menuItem){openMenu&&close(openMenu),abortClose(),(0,_jquery.default)(menuItem).addClass("open"),(0,_jquery.default)(menuItem).children("a").attr("aria-expanded","true"),openMenu=menuItem,openCandidate=null,openTimeoutId=null}function openWithDelay(menuItem){openCandidate=menuItem,openTimeoutId=setTimeout((()=>{open(menuItem),openTime=new Date}),openDelay)}function close(menuItem){(0,_jquery.default)(menuItem).removeClass("open"),(0,_jquery.default)(menuItem).children("a").attr("aria-expanded","false"),openMenu=null,abortClose(),openTime=null}function closeWithDelay(menuItem){closeTimeoutId=setTimeout(close,closeDelay,menuItem)}function abortClose(){closeTimeoutId&&(clearTimeout(closeTimeoutId),closeTimeoutId=null)}function abortOpen(){openCandidate=null,openTimeoutId&&(clearTimeout(openTimeoutId),openTimeoutId=null)}function reset(){abortClose(),abortOpen(),openMenu&&close(openMenu)}(0,_jquery.default)('li.main-menu-item > a[aria-haspopup="true"], li#user-menu > a[aria-haspopup="true"]').click((ev=>{ev.currentTarget.parentNode===openMenu?new Date-openTime>closeCooldown&&close(openMenu):open(ev.currentTarget.parentNode)}));let menuitems=(0,_jquery.default)('li.main-menu-item > a[aria-haspopup="true"], li#user-menu > a[aria-haspopup="true"]').parent();menuitems.mouseenter((ev=>{(window.innerWidth>0?window.innerWidth:screen.width)>767&&(ev.currentTarget===openMenu?abortClose():openWithDelay(ev.currentTarget))})),menuitems.mouseleave((ev=>{(window.innerWidth>0?window.innerWidth:screen.width)>767&&(openCandidate&&ev.currentTarget===openCandidate&&abortOpen(),openMenu&&ev.currentTarget===openMenu&&closeWithDelay(ev.currentTarget))})),(0,_jquery.default)('li.sub-menu-item > a[aria-haspopup="true"], li.sub-sub-menu-item > a[aria-haspopup="true"]').click((ev=>{let link=(0,_jquery.default)(ev.currentTarget),item=link.parent();item.toggleClass("open"),link.attr("aria-expanded",item.hasClass("open"))}));let hamburgertoggle=(0,_jquery.default)("#main-menu-hamburger > a"),hamburgerparent=hamburgertoggle.parent();hamburgertoggle.click((()=>{hamburgerparent.toggleClass("open"),hamburgertoggle.attr("aria-expanded",hamburgerparent.hasClass("open"))}));let oneColLayoutBefore=!1,hamburgerLayoutBefore=!1;function updateMaxMenuHeight(){let botPos=(0,_jquery.default)("#menu-bottom").offset().top+16,width=window.innerWidth>0?window.innerWidth:screen.width,oneColLayout=width<=767;oneColLayout?((0,_jquery.default)(".sub-menu-scroll-container").css("max-height",""),(0,_jquery.default)("#main-menu-left").css("max-height",(0,_jquery.default)(window).height()-botPos+"px")):(width<=1080&&(botPos+=50),(0,_jquery.default)(".sub-menu-scroll-container").css("max-height",(0,_jquery.default)(window).height()-botPos+"px"),(0,_jquery.default)("#main-menu-left").css("max-height","")),oneColLayout!==oneColLayoutBefore&&(reset(),oneColLayoutBefore=oneColLayout);let hamburgerLayout=width<=1080;hamburgerLayout!==hamburgerLayoutBefore&&(hamburgertoggle.attr("role",hamburgerLayout?"button":"none"),hamburgerLayoutBefore=hamburgerLayout)}updateMaxMenuHeight(),(0,_jquery.default)(window).resize(updateMaxMenuHeight)})(),function(){const html=(0,_jquery.default)("html"),uselighttheme=(0,_jquery.default)("#user-menu .wwu-uselighttheme"),useostheme=(0,_jquery.default)("#user-menu .wwu-useostheme"),usedarktheme=(0,_jquery.default)("#user-menu .wwu-usedarktheme");let selected;selected=html.hasClass("dark")?usedarktheme:html.hasClass("light")?uselighttheme:useostheme;selected.addClass("selectedtheme"),uselighttheme.click((function(){selected.removeClass("selectedtheme"),html.removeClass("dark"),html.addClass("light"),updateThemePreferenceAjax(1),selected=uselighttheme,selected.addClass("selectedtheme")})),useostheme.click((function(){selected.removeClass("selectedtheme"),html.removeClass("dark"),html.removeClass("light"),updateThemePreferenceAjax(null),selected=useostheme,selected.addClass("selectedtheme")})),usedarktheme.click((function(){selected.removeClass("selectedtheme"),html.addClass("dark"),html.removeClass("light"),updateThemePreferenceAjax(2),selected=usedarktheme,selected.addClass("selectedtheme")}))}()},_jquery=_interopRequireDefault(_jquery),_ajax=_interopRequireDefault(_ajax),_notification=_interopRequireDefault(_notification)})); + */function updateThemePreferenceAjax(theme){var request={methodname:"core_user_update_user_preferences",args:{preferences:[{type:"theme_wwu2019_theme",value:theme}]}};_ajax.default.call([request])[0].fail(_notification.default.exception)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){(function(){const openDelay=100,closeDelay=300,closeCooldown=300;let openMenu=null,openCandidate=null,openTimeoutId=null,closeTimeoutId=null,openTime=null;function open(menuItem){openMenu&&close(openMenu),abortClose(),(0,_jquery.default)(menuItem).addClass("open"),(0,_jquery.default)(menuItem).children("a").attr("aria-expanded","true"),openMenu=menuItem,openCandidate=null,openTimeoutId=null}function openWithDelay(menuItem){openCandidate=menuItem,openTimeoutId=setTimeout((()=>{open(menuItem),openTime=new Date}),openDelay)}function close(menuItem){(0,_jquery.default)(menuItem).removeClass("open"),(0,_jquery.default)(menuItem).children("a").attr("aria-expanded","false"),openMenu=null,abortClose(),openTime=null}function closeWithDelay(menuItem){closeTimeoutId=setTimeout(close,closeDelay,menuItem)}function abortClose(){closeTimeoutId&&(clearTimeout(closeTimeoutId),closeTimeoutId=null)}function abortOpen(){openCandidate=null,openTimeoutId&&(clearTimeout(openTimeoutId),openTimeoutId=null)}function reset(){abortClose(),abortOpen(),openMenu&&close(openMenu)}(0,_jquery.default)('li.main-menu-item > a[aria-haspopup="true"], li#user-menu > a[aria-haspopup="true"]').click((ev=>{ev.currentTarget.parentNode===openMenu?new Date-openTime>closeCooldown&&close(openMenu):open(ev.currentTarget.parentNode)}));let menuitems=(0,_jquery.default)('li.main-menu-item > a[aria-haspopup="true"], li#user-menu > a[aria-haspopup="true"]').parent();menuitems.mouseenter((ev=>{(window.innerWidth>0?window.innerWidth:screen.width)>767&&(ev.currentTarget===openMenu?abortClose():openWithDelay(ev.currentTarget))})),menuitems.mouseleave((ev=>{(window.innerWidth>0?window.innerWidth:screen.width)>767&&(openCandidate&&ev.currentTarget===openCandidate&&abortOpen(),openMenu&&ev.currentTarget===openMenu&&closeWithDelay(ev.currentTarget))})),(0,_jquery.default)('li.sub-menu-item > a[aria-haspopup="true"], li.sub-sub-menu-item > a[aria-haspopup="true"]').click((ev=>{let link=(0,_jquery.default)(ev.currentTarget),item=link.parent();item.toggleClass("open"),link.attr("aria-expanded",item.hasClass("open"))}));let hamburgertoggle=(0,_jquery.default)("#main-menu-hamburger > a"),hamburgerparent=hamburgertoggle.parent();hamburgertoggle.click((()=>{hamburgerparent.toggleClass("open"),hamburgertoggle.attr("aria-expanded",hamburgerparent.hasClass("open"))}));let oneColLayoutBefore=!1,hamburgerLayoutBefore=!1;function updateMaxMenuHeight(){let botPos=(0,_jquery.default)("#menu-bottom").offset().top+16,width=window.innerWidth>0?window.innerWidth:screen.width,oneColLayout=width<=767;oneColLayout?((0,_jquery.default)(".sub-menu-scroll-container").css("max-height",""),(0,_jquery.default)("#main-menu-left").css("max-height",(0,_jquery.default)(window).height()-botPos+"px")):(width<=1080&&(botPos+=50),(0,_jquery.default)(".sub-menu-scroll-container").css("max-height",(0,_jquery.default)(window).height()-botPos+"px"),(0,_jquery.default)("#main-menu-left").css("max-height","")),oneColLayout!==oneColLayoutBefore&&(reset(),oneColLayoutBefore=oneColLayout);let hamburgerLayout=width<=1080;hamburgerLayout!==hamburgerLayoutBefore&&(hamburgertoggle.attr("role",hamburgerLayout?"button":"none"),hamburgerLayoutBefore=hamburgerLayout)}updateMaxMenuHeight(),(0,_jquery.default)(window).resize(updateMaxMenuHeight)})(),function(){const html=(0,_jquery.default)("html"),uselighttheme=(0,_jquery.default)("#user-menu .wwu-uselighttheme"),useostheme=(0,_jquery.default)("#user-menu .wwu-useostheme"),usedarktheme=(0,_jquery.default)("#user-menu .wwu-usedarktheme"),darkThemeClass="dark-theme",lightThemeClass="light-theme";let selected;selected=html.hasClass(darkThemeClass)?usedarktheme:html.hasClass(lightThemeClass)?uselighttheme:useostheme;selected.addClass("selectedtheme"),uselighttheme.click((function(){selected.removeClass("selectedtheme"),html.removeClass(darkThemeClass),html.addClass(lightThemeClass),updateThemePreferenceAjax(1),selected=uselighttheme,selected.addClass("selectedtheme")})),useostheme.click((function(){selected.removeClass("selectedtheme"),html.removeClass(darkThemeClass),html.removeClass(lightThemeClass),updateThemePreferenceAjax(null),selected=useostheme,selected.addClass("selectedtheme")})),usedarktheme.click((function(){selected.removeClass("selectedtheme"),html.addClass(darkThemeClass),html.removeClass(lightThemeClass),updateThemePreferenceAjax(2),selected=usedarktheme,selected.addClass("selectedtheme")}))}()},_jquery=_interopRequireDefault(_jquery),_ajax=_interopRequireDefault(_ajax),_notification=_interopRequireDefault(_notification)})); //# sourceMappingURL=menu.min.js.map \ No newline at end of file diff --git a/amd/build/menu.min.js.map b/amd/build/menu.min.js.map index 55494ff..7168dc2 100644 --- a/amd/build/menu.min.js.map +++ b/amd/build/menu.min.js.map @@ -1 +1 @@ -{"version":3,"file":"menu.min.js","sources":["../src/menu.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Manage the user menu.\n *\n * @module theme_wwu2019/menu\n * @copyright 2019 Justus Dieckmann WWU\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\n\n/**\n * Init function\n */\nexport function init() {\n openMenu();\n initThemeChooser();\n}\n\n\n/**\n * Initializes the theme chooser.\n */\nfunction initThemeChooser() {\n const html = $('html');\n const uselighttheme = $('#user-menu .wwu-uselighttheme');\n const useostheme = $('#user-menu .wwu-useostheme');\n const usedarktheme = $('#user-menu .wwu-usedarktheme');\n\n let selected;\n if (html.hasClass('dark')) {\n selected = usedarktheme;\n } else if (html.hasClass('light')) {\n selected = uselighttheme;\n } else {\n selected = useostheme;\n }\n selected.addClass('selectedtheme');\n\n uselighttheme.click(function() {\n selected.removeClass('selectedtheme');\n html.removeClass('dark');\n html.addClass('light');\n updateThemePreferenceAjax(1);\n selected = uselighttheme;\n selected.addClass('selectedtheme');\n });\n useostheme.click(function() {\n selected.removeClass('selectedtheme');\n html.removeClass('dark');\n html.removeClass('light');\n updateThemePreferenceAjax(null);\n selected = useostheme;\n selected.addClass('selectedtheme');\n });\n usedarktheme.click(function() {\n selected.removeClass('selectedtheme');\n html.addClass('dark');\n html.removeClass('light');\n updateThemePreferenceAjax(2);\n selected = usedarktheme;\n selected.addClass('selectedtheme');\n });\n}\n\n/**\n * Updates the theme preference.\n * @param {int} theme\n */\nfunction updateThemePreferenceAjax(theme) {\n var request = {\n methodname: 'core_user_update_user_preferences',\n args: {\n preferences: [{\n type: 'theme_wwu2019_theme',\n value: theme\n }]\n }\n };\n\n Ajax.call([request])[0]\n .fail(Notification.exception);\n}\n\nconst onecolumnbreakpoint = 767;\nconst hamburgerbreakpoint = 1080;\n\n\n/**\n * Opens submenu when hovering\n */\nfunction openMenu() {\n const openDelay = 100;\n const closeDelay = 300;\n const closeCooldown = 300;\n\n let openMenu = null;\n let openCandidate = null;\n let openTimeoutId = null;\n let closeTimeoutId = null;\n /** @type {null|Date} Date when menu was opened by hovering, to prevent immediately closing it by clicking again. */\n let openTime = null;\n\n /**\n * Opens a menu.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function open(menuItem) {\n if (openMenu) {\n close(openMenu);\n }\n abortClose();\n $(menuItem).addClass('open');\n $(menuItem).children('a').attr('aria-expanded', 'true');\n openMenu = menuItem;\n openCandidate = null;\n openTimeoutId = null;\n }\n\n /**\n * Opens a menu with delay.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function openWithDelay(menuItem) {\n openCandidate = menuItem;\n openTimeoutId = setTimeout(() => {\n open(menuItem);\n openTime = new Date();\n }, openDelay);\n }\n\n /**\n * Closes a menu.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function close(menuItem) {\n $(menuItem).removeClass('open');\n $(menuItem).children('a').attr('aria-expanded', 'false');\n openMenu = null;\n abortClose();\n openTime = null;\n }\n\n /**\n * Closes a menu with delay.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function closeWithDelay(menuItem) {\n closeTimeoutId = setTimeout(close, closeDelay, menuItem);\n }\n\n /**\n * Aborts the delayed closing of {@link openMenu}\n */\n function abortClose() {\n if (closeTimeoutId) {\n clearTimeout(closeTimeoutId);\n closeTimeoutId = null;\n }\n }\n\n /**\n * Aborts the delayed opening of {@link openCandidate}\n */\n function abortOpen() {\n openCandidate = null;\n if (openTimeoutId) {\n clearTimeout(openTimeoutId);\n openTimeoutId = null;\n }\n }\n\n /**\n * Closes the open menu and resets timeouts;\n */\n function reset() {\n abortClose();\n abortOpen();\n if (openMenu) {\n close(openMenu);\n }\n }\n\n $('li.main-menu-item > a[aria-haspopup=\"true\"], li#user-menu > a[aria-haspopup=\"true\"]').click((ev) => {\n if (ev.currentTarget.parentNode === openMenu) {\n if (new Date() - openTime > closeCooldown) {\n close(openMenu);\n }\n } else {\n open(ev.currentTarget.parentNode);\n }\n });\n\n let menuitems = $('li.main-menu-item > a[aria-haspopup=\"true\"], li#user-menu > a[aria-haspopup=\"true\"]').parent();\n menuitems.mouseenter((ev) => {\n let width = (window.innerWidth > 0) ? window.innerWidth : screen.width;\n if (width > onecolumnbreakpoint) {\n if (ev.currentTarget === openMenu) {\n abortClose();\n } else {\n openWithDelay(ev.currentTarget);\n }\n }\n });\n menuitems.mouseleave((ev) => {\n let width = (window.innerWidth > 0) ? window.innerWidth : screen.width;\n if (width > onecolumnbreakpoint) {\n if (openCandidate && ev.currentTarget === openCandidate) {\n abortOpen();\n }\n if (openMenu && ev.currentTarget === openMenu) {\n closeWithDelay(ev.currentTarget);\n }\n }\n });\n\n $('li.sub-menu-item > a[aria-haspopup=\"true\"], li.sub-sub-menu-item > a[aria-haspopup=\"true\"]').click((ev) => {\n let link = $(ev.currentTarget);\n let item = link.parent();\n item.toggleClass('open');\n link.attr('aria-expanded', item.hasClass('open'));\n });\n\n let hamburgertoggle = $('#main-menu-hamburger > a');\n let hamburgerparent = hamburgertoggle.parent();\n hamburgertoggle.click(() => {\n hamburgerparent.toggleClass('open');\n hamburgertoggle.attr('aria-expanded', hamburgerparent.hasClass('open'));\n });\n\n let oneColLayoutBefore = false;\n let hamburgerLayoutBefore = false;\n\n /**\n * Updates max-height of submenus on page-init and window resize.\n */\n function updateMaxMenuHeight() {\n const menuButtom = $('#menu-bottom');\n let botPos = menuButtom.offset().top + 16;\n let width = (window.innerWidth > 0) ? window.innerWidth : screen.width;\n let oneColLayout = width <= onecolumnbreakpoint;\n if (oneColLayout) {\n $('.sub-menu-scroll-container').css('max-height', '');\n $('#main-menu-left').css('max-height', ($(window).height() - botPos) + 'px');\n } else {\n // If Menu is expanded down, add the height of the #main-menu-left container\n if (width <= hamburgerbreakpoint) {\n botPos += 50;\n }\n $('.sub-menu-scroll-container').css('max-height', ($(window).height() - botPos) + 'px');\n $('#main-menu-left').css('max-height', '');\n }\n if (oneColLayout !== oneColLayoutBefore) {\n reset();\n oneColLayoutBefore = oneColLayout;\n }\n\n // Switch hamburger toggle role between button and none, based on whether it is hidden.\n let hamburgerLayout = width <= hamburgerbreakpoint;\n if (hamburgerLayout !== hamburgerLayoutBefore) {\n hamburgertoggle.attr('role', hamburgerLayout ? 'button' : 'none');\n hamburgerLayoutBefore = hamburgerLayout;\n }\n }\n\n updateMaxMenuHeight();\n $(window).resize(updateMaxMenuHeight);\n}\n"],"names":["updateThemePreferenceAjax","theme","request","methodname","args","preferences","type","value","call","fail","Notification","exception","openDelay","closeDelay","closeCooldown","openMenu","openCandidate","openTimeoutId","closeTimeoutId","openTime","open","menuItem","close","abortClose","addClass","children","attr","openWithDelay","setTimeout","Date","removeClass","closeWithDelay","clearTimeout","abortOpen","reset","click","ev","currentTarget","parentNode","menuitems","parent","mouseenter","window","innerWidth","screen","width","mouseleave","link","item","toggleClass","hasClass","hamburgertoggle","hamburgerparent","oneColLayoutBefore","hamburgerLayoutBefore","updateMaxMenuHeight","botPos","offset","top","oneColLayout","css","height","hamburgerLayout","resize","html","uselighttheme","useostheme","usedarktheme","selected","initThemeChooser"],"mappings":";;;;;;;cAqFSA,0BAA0BC,WAC3BC,QAAU,CACVC,WAAY,oCACZC,KAAM,CACFC,YAAa,CAAC,CACVC,KAAM,sBACNC,MAAON,wBAKdO,KAAK,CAACN,UAAU,GAChBO,KAAKC,sBAAaC,8GAWjBC,UAAY,IACZC,WAAa,IACbC,cAAgB,QAElBC,SAAW,KACXC,cAAgB,KAChBC,cAAgB,KAChBC,eAAiB,KAEjBC,SAAW,cAMNC,KAAKC,UACNN,UACAO,MAAMP,UAEVQ,iCACEF,UAAUG,SAAS,4BACnBH,UAAUI,SAAS,KAAKC,KAAK,gBAAiB,QAChDX,SAAWM,SACXL,cAAgB,KAChBC,cAAgB,cAOXU,cAAcN,UACnBL,cAAgBK,SAChBJ,cAAgBW,YAAW,KACvBR,KAAKC,UACLF,SAAW,IAAIU,OAChBjB,oBAOEU,MAAMD,8BACTA,UAAUS,YAAY,4BACtBT,UAAUI,SAAS,KAAKC,KAAK,gBAAiB,SAChDX,SAAW,KACXQ,aACAJ,SAAW,cAONY,eAAeV,UACpBH,eAAiBU,WAAWN,MAAOT,WAAYQ,mBAM1CE,aACDL,iBACAc,aAAad,gBACbA,eAAiB,eAOhBe,YACLjB,cAAgB,KACZC,gBACAe,aAAaf,eACbA,cAAgB,eAOfiB,QACLX,aACAU,YACIlB,UACAO,MAAMP,8BAIZ,uFAAuFoB,OAAOC,KACxFA,GAAGC,cAAcC,aAAevB,SAC5B,IAAIc,KAAS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wBQ,iBAIhCP,0CACEb,QAAQqB,OAAOR,sBA3PjBxC,oBASMiD,MAAO,mBAAE,QACTC,eAAgB,mBAAE,iCAClBC,YAAa,mBAAE,8BACfC,cAAe,mBAAE,oCAEnBC,SAEAA,SADAJ,KAAKd,SAAS,QACHiB,aACJH,KAAKd,SAAS,SACVe,cAEAC,WAEfE,SAAS5C,SAAS,iBAElByC,cAAc9B,OAAM,WAChBiC,SAAStC,YAAY,iBACrBkC,KAAKlC,YAAY,QACjBkC,KAAKxC,SAAS,SACdxB,0BAA0B,GAC1BoE,SAAWH,cACXG,SAAS5C,SAAS,oBAEtB0C,WAAW/B,OAAM,WACbiC,SAAStC,YAAY,iBACrBkC,KAAKlC,YAAY,QACjBkC,KAAKlC,YAAY,SACjB9B,0BAA0B,MAC1BoE,SAAWF,WACXE,SAAS5C,SAAS,oBAEtB2C,aAAahC,OAAM,WACfiC,SAAStC,YAAY,iBACrBkC,KAAKxC,SAAS,QACdwC,KAAKlC,YAAY,SACjB9B,0BAA0B,GAC1BoE,SAAWD,aACXC,SAAS5C,SAAS,oBA7CtB6C"} \ No newline at end of file +{"version":3,"file":"menu.min.js","sources":["../src/menu.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Manage the user menu.\n *\n * @module theme_wwu2019/menu\n * @copyright 2019 Justus Dieckmann WWU\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\n\n/**\n * Init function\n */\nexport function init() {\n openMenu();\n initThemeChooser();\n}\n\n\n/**\n * Initializes the theme chooser.\n */\nfunction initThemeChooser() {\n const html = $('html');\n const uselighttheme = $('#user-menu .wwu-uselighttheme');\n const useostheme = $('#user-menu .wwu-useostheme');\n const usedarktheme = $('#user-menu .wwu-usedarktheme');\n const darkThemeClass = 'dark-theme';\n const lightThemeClass = 'light-theme';\n\n let selected;\n if (html.hasClass(darkThemeClass)) {\n selected = usedarktheme;\n } else if (html.hasClass(lightThemeClass)) {\n selected = uselighttheme;\n } else {\n selected = useostheme;\n }\n selected.addClass('selectedtheme');\n\n uselighttheme.click(function() {\n selected.removeClass('selectedtheme');\n html.removeClass(darkThemeClass);\n html.addClass(lightThemeClass);\n updateThemePreferenceAjax(1);\n selected = uselighttheme;\n selected.addClass('selectedtheme');\n });\n useostheme.click(function() {\n selected.removeClass('selectedtheme');\n html.removeClass(darkThemeClass);\n html.removeClass(lightThemeClass);\n updateThemePreferenceAjax(null);\n selected = useostheme;\n selected.addClass('selectedtheme');\n });\n usedarktheme.click(function() {\n selected.removeClass('selectedtheme');\n html.addClass(darkThemeClass);\n html.removeClass(lightThemeClass);\n updateThemePreferenceAjax(2);\n selected = usedarktheme;\n selected.addClass('selectedtheme');\n });\n}\n\n/**\n * Updates the theme preference.\n * @param {int} theme\n */\nfunction updateThemePreferenceAjax(theme) {\n var request = {\n methodname: 'core_user_update_user_preferences',\n args: {\n preferences: [{\n type: 'theme_wwu2019_theme',\n value: theme\n }]\n }\n };\n\n Ajax.call([request])[0]\n .fail(Notification.exception);\n}\n\nconst onecolumnbreakpoint = 767;\nconst hamburgerbreakpoint = 1080;\n\n\n/**\n * Opens submenu when hovering\n */\nfunction openMenu() {\n const openDelay = 100;\n const closeDelay = 300;\n const closeCooldown = 300;\n\n let openMenu = null;\n let openCandidate = null;\n let openTimeoutId = null;\n let closeTimeoutId = null;\n /** @type {null|Date} Date when menu was opened by hovering, to prevent immediately closing it by clicking again. */\n let openTime = null;\n\n /**\n * Opens a menu.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function open(menuItem) {\n if (openMenu) {\n close(openMenu);\n }\n abortClose();\n $(menuItem).addClass('open');\n $(menuItem).children('a').attr('aria-expanded', 'true');\n openMenu = menuItem;\n openCandidate = null;\n openTimeoutId = null;\n }\n\n /**\n * Opens a menu with delay.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function openWithDelay(menuItem) {\n openCandidate = menuItem;\n openTimeoutId = setTimeout(() => {\n open(menuItem);\n openTime = new Date();\n }, openDelay);\n }\n\n /**\n * Closes a menu.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function close(menuItem) {\n $(menuItem).removeClass('open');\n $(menuItem).children('a').attr('aria-expanded', 'false');\n openMenu = null;\n abortClose();\n openTime = null;\n }\n\n /**\n * Closes a menu with delay.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function closeWithDelay(menuItem) {\n closeTimeoutId = setTimeout(close, closeDelay, menuItem);\n }\n\n /**\n * Aborts the delayed closing of {@link openMenu}\n */\n function abortClose() {\n if (closeTimeoutId) {\n clearTimeout(closeTimeoutId);\n closeTimeoutId = null;\n }\n }\n\n /**\n * Aborts the delayed opening of {@link openCandidate}\n */\n function abortOpen() {\n openCandidate = null;\n if (openTimeoutId) {\n clearTimeout(openTimeoutId);\n openTimeoutId = null;\n }\n }\n\n /**\n * Closes the open menu and resets timeouts;\n */\n function reset() {\n abortClose();\n abortOpen();\n if (openMenu) {\n close(openMenu);\n }\n }\n\n $('li.main-menu-item > a[aria-haspopup=\"true\"], li#user-menu > a[aria-haspopup=\"true\"]').click((ev) => {\n if (ev.currentTarget.parentNode === openMenu) {\n if (new Date() - openTime > closeCooldown) {\n close(openMenu);\n }\n } else {\n open(ev.currentTarget.parentNode);\n }\n });\n\n let menuitems = $('li.main-menu-item > a[aria-haspopup=\"true\"], li#user-menu > a[aria-haspopup=\"true\"]').parent();\n menuitems.mouseenter((ev) => {\n let width = (window.innerWidth > 0) ? window.innerWidth : screen.width;\n if (width > onecolumnbreakpoint) {\n if (ev.currentTarget === openMenu) {\n abortClose();\n } else {\n openWithDelay(ev.currentTarget);\n }\n }\n });\n menuitems.mouseleave((ev) => {\n let width = (window.innerWidth > 0) ? window.innerWidth : screen.width;\n if (width > onecolumnbreakpoint) {\n if (openCandidate && ev.currentTarget === openCandidate) {\n abortOpen();\n }\n if (openMenu && ev.currentTarget === openMenu) {\n closeWithDelay(ev.currentTarget);\n }\n }\n });\n\n $('li.sub-menu-item > a[aria-haspopup=\"true\"], li.sub-sub-menu-item > a[aria-haspopup=\"true\"]').click((ev) => {\n let link = $(ev.currentTarget);\n let item = link.parent();\n item.toggleClass('open');\n link.attr('aria-expanded', item.hasClass('open'));\n });\n\n let hamburgertoggle = $('#main-menu-hamburger > a');\n let hamburgerparent = hamburgertoggle.parent();\n hamburgertoggle.click(() => {\n hamburgerparent.toggleClass('open');\n hamburgertoggle.attr('aria-expanded', hamburgerparent.hasClass('open'));\n });\n\n let oneColLayoutBefore = false;\n let hamburgerLayoutBefore = false;\n\n /**\n * Updates max-height of submenus on page-init and window resize.\n */\n function updateMaxMenuHeight() {\n const menuButtom = $('#menu-bottom');\n let botPos = menuButtom.offset().top + 16;\n let width = (window.innerWidth > 0) ? window.innerWidth : screen.width;\n let oneColLayout = width <= onecolumnbreakpoint;\n if (oneColLayout) {\n $('.sub-menu-scroll-container').css('max-height', '');\n $('#main-menu-left').css('max-height', ($(window).height() - botPos) + 'px');\n } else {\n // If Menu is expanded down, add the height of the #main-menu-left container\n if (width <= hamburgerbreakpoint) {\n botPos += 50;\n }\n $('.sub-menu-scroll-container').css('max-height', ($(window).height() - botPos) + 'px');\n $('#main-menu-left').css('max-height', '');\n }\n if (oneColLayout !== oneColLayoutBefore) {\n reset();\n oneColLayoutBefore = oneColLayout;\n }\n\n // Switch hamburger toggle role between button and none, based on whether it is hidden.\n let hamburgerLayout = width <= hamburgerbreakpoint;\n if (hamburgerLayout !== hamburgerLayoutBefore) {\n hamburgertoggle.attr('role', hamburgerLayout ? 'button' : 'none');\n hamburgerLayoutBefore = hamburgerLayout;\n }\n }\n\n updateMaxMenuHeight();\n $(window).resize(updateMaxMenuHeight);\n}\n"],"names":["updateThemePreferenceAjax","theme","request","methodname","args","preferences","type","value","call","fail","Notification","exception","openDelay","closeDelay","closeCooldown","openMenu","openCandidate","openTimeoutId","closeTimeoutId","openTime","open","menuItem","close","abortClose","addClass","children","attr","openWithDelay","setTimeout","Date","removeClass","closeWithDelay","clearTimeout","abortOpen","reset","click","ev","currentTarget","parentNode","menuitems","parent","mouseenter","window","innerWidth","screen","width","mouseleave","link","item","toggleClass","hasClass","hamburgertoggle","hamburgerparent","oneColLayoutBefore","hamburgerLayoutBefore","updateMaxMenuHeight","botPos","offset","top","oneColLayout","css","height","hamburgerLayout","resize","html","uselighttheme","useostheme","usedarktheme","darkThemeClass","lightThemeClass","selected","initThemeChooser"],"mappings":";;;;;;;cAuFSA,0BAA0BC,WAC3BC,QAAU,CACVC,WAAY,oCACZC,KAAM,CACFC,YAAa,CAAC,CACVC,KAAM,sBACNC,MAAON,wBAKdO,KAAK,CAACN,UAAU,GAChBO,KAAKC,sBAAaC,8GAWjBC,UAAY,IACZC,WAAa,IACbC,cAAgB,QAElBC,SAAW,KACXC,cAAgB,KAChBC,cAAgB,KAChBC,eAAiB,KAEjBC,SAAW,cAMNC,KAAKC,UACNN,UACAO,MAAMP,UAEVQ,iCACEF,UAAUG,SAAS,4BACnBH,UAAUI,SAAS,KAAKC,KAAK,gBAAiB,QAChDX,SAAWM,SACXL,cAAgB,KAChBC,cAAgB,cAOXU,cAAcN,UACnBL,cAAgBK,SAChBJ,cAAgBW,YAAW,KACvBR,KAAKC,UACLF,SAAW,IAAIU,OAChBjB,oBAOEU,MAAMD,8BACTA,UAAUS,YAAY,4BACtBT,UAAUI,SAAS,KAAKC,KAAK,gBAAiB,SAChDX,SAAW,KACXQ,aACAJ,SAAW,cAONY,eAAeV,UACpBH,eAAiBU,WAAWN,MAAOT,WAAYQ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Ae,mBAAElB,QAAQmB,SAAWL,OAAU,0BAChF,mBAAmBI,IAAI,aAAc,KAEvCD,eAAiBN,qBACjBnB,QACAmB,mBAAqBM,kBAIrBG,gBAAkBjB,OA7KF,KA8KhBiB,kBAAoBR,wBACpBH,gBAAgBzB,KAAK,OAAQoC,gBAAkB,SAAW,QAC1DR,sBAAwBQ,iBAIhCP,0CACEb,QAAQqB,OAAOR,sBA7PjBxC,oBASMiD,MAAO,mBAAE,QACTC,eAAgB,mBAAE,iCAClBC,YAAa,mBAAE,8BACfC,cAAe,mBAAE,gCACjBC,eAAiB,aACjBC,gBAAkB,kBAEpBC,SAEAA,SADAN,KAAKd,SAASkB,gBACHD,aACJH,KAAKd,SAASmB,iBACVJ,cAEAC,WAEfI,SAAS9C,SAAS,iBAElByC,cAAc9B,OAAM,WAChBmC,SAASxC,YAAY,iBACrBkC,KAAKlC,YAAYsC,gBACjBJ,KAAKxC,SAAS6C,iBACdrE,0BAA0B,GAC1BsE,SAAWL,cACXK,SAAS9C,SAAS,oBAEtB0C,WAAW/B,OAAM,WACbmC,SAASxC,YAAY,iBACrBkC,KAAKlC,YAAYsC,gBACjBJ,KAAKlC,YAAYuC,iBACjBrE,0BAA0B,MAC1BsE,SAAWJ,WACXI,SAAS9C,SAAS,oBAEtB2C,aAAahC,OAAM,WACfmC,SAASxC,YAAY,iBACrBkC,KAAKxC,SAAS4C,gBACdJ,KAAKlC,YAAYuC,iBACjBrE,0BAA0B,GAC1BsE,SAAWH,aACXG,SAAS9C,SAAS,oBA/CtB+C"} \ No newline at end of file diff --git a/amd/build/snow.min.js b/amd/build/snow.min.js index 6a7bcca..6be565c 100644 --- a/amd/build/snow.min.js +++ b/amd/build/snow.min.js @@ -1,10 +1,10 @@ -define("theme_wwu2019/snow",["exports","jquery","core/ajax"],(function(_exports,_jquery,_ajax){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} +define("theme_wwu2019/snow",["exports","jquery","core/ajax","core/notification"],(function(_exports,_jquery,_ajax,_notification){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} /** * Manages the very important snow. * * @module theme_wwu2019/snow * @copyright 2020 Justus Dieckmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */let canvas;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(snowValue){let enableSnow=!!snowValue;null!==localStorage.getItem("theme_wwu2019/enable-snow")&&(enableSnow="false"!==localStorage.getItem("theme_wwu2019/enable-snow"),updateSnowPreferenceAjax(enableSnow),localStorage.removeItem("theme_wwu2019/enable-snow"));(0,_jquery.default)('
').insertAfter("#main-menu-right .main-menu-additions-item"),canvas=document.createElement("canvas"),canvas.height=window.innerHeight,canvas.width=window.innerWidth,canvas.classList.add("snow"),canvas.style.position="fixed",canvas.style.top="0",canvas.style.left="0",canvas.style.zIndex="1010",canvas.style.opacity="0.8",canvas.style.pointerEvents="none",(0,_jquery.default)(window).resize((()=>{canvas.height=window.innerHeight,canvas.width=window.innerWidth,desiredFlakes=50+canvas.height*canvas.width*1e-4})),desiredFlakes=50+canvas.height*canvas.width*1e-4;for(let i=0;i img");enableSnow?(intervalId=setInterval(redraw,25,ctx),snowicon.attr("src",pixurl+"snow-disable.svg")):(canvas.hidden=!0,snowicon.attr("src",pixurl+"snow-enable.svg"));(0,_jquery.default)("#snow-toggle").click((()=>{intervalId?(clearInterval(intervalId),intervalId=null,snowicon.attr("src",pixurl+"snow-enable.svg")):(intervalId=setInterval(redraw,25,ctx),snowicon.attr("src",pixurl+"snow-disable.svg")),canvas.hidden=null===intervalId,updateSnowPreferenceAjax(null!==intervalId)})),(0,_jquery.default)("body").append(canvas),noise.seed(Math.random())},_jquery=_interopRequireDefault(_jquery),_ajax=_interopRequireDefault(_ajax);let desiredFlakes=150,flakes=[],intervalId=null;const pixurl=M.cfg.wwwroot+"/theme/wwu2019/pix/";let noise=function(){var module={};function Grad(x,y,z){this.x=x,this.y=y,this.z=z}Grad.prototype.dot2=function(x,y){return this.x*x+this.y*y},Grad.prototype.dot3=function(x,y,z){return this.x*x+this.y*y+this.z*z};var grad3=[new Grad(1,1,0),new Grad(-1,1,0),new Grad(1,-1,0),new Grad(-1,-1,0),new Grad(1,0,1),new Grad(-1,0,1),new Grad(1,0,-1),new Grad(-1,0,-1),new Grad(0,1,1),new Grad(0,-1,1),new Grad(0,1,-1),new Grad(0,-1,-1)],p=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],perm=new Array(512),gradP=new Array(512);module.seed=function(seed){seed>0&&seed<1&&(seed*=65536),(seed=Math.floor(seed))<256&&(seed|=seed<<8);for(var i=0;i<256;i++){var v;v=1&i?p[i]^255&seed:p[i]^seed>>8&255,perm[i]=perm[i+256]=v,gradP[i]=gradP[i+256]=grad3[v%12]}},module.seed(0);var F2=.5*(Math.sqrt(3)-1),G2=(3-Math.sqrt(3))/6;function fade(t){return t*t*t*(t*(6*t-15)+10)}function lerp(a,b,t){return(1-t)*a+t*b}return module.simplex2=function(xin,yin){var i1,j1,s=(xin+yin)*F2,i=Math.floor(xin+s),j=Math.floor(yin+s),t=(i+j)*G2,x0=xin-i+t,y0=yin-j+t;x0>y0?(i1=1,j1=0):(i1=0,j1=1);var x1=x0-i1+G2,y1=y0-j1+G2,x2=x0-1+2*G2,y2=y0-1+2*G2,gi0=gradP[(i&=255)+perm[j&=255]],gi1=gradP[i+i1+perm[j+j1]],gi2=gradP[i+1+perm[j+1]],t0=.5-x0*x0-y0*y0,t1=.5-x1*x1-y1*y1,t2=.5-x2*x2-y2*y2;return 70*((t0<0?0:(t0*=t0)*t0*gi0.dot2(x0,y0))+(t1<0?0:(t1*=t1)*t1*gi1.dot2(x1,y1))+(t2<0?0:(t2*=t2)*t2*gi2.dot2(x2,y2)))},module.perlin2=function(x,y){var X=Math.floor(x),Y=Math.floor(y);x-=X,y-=Y;var n00=gradP[(X&=255)+perm[Y&=255]].dot2(x,y),n01=gradP[X+perm[Y+1]].dot2(x,y-1),n10=gradP[X+1+perm[Y]].dot2(x-1,y),n11=gradP[X+1+perm[Y+1]].dot2(x-1,y-1),u=fade(x);return lerp(lerp(n00,n10,u),lerp(n01,n11,u),fade(y))},module}();function updateSnowPreferenceAjax(snow){var request={methodname:"core_user_update_user_preferences",args:{preferences:[{type:"theme_wwu2019_snow",value:snow?1:0}]}};_ajax.default.call([request])[0].fail(Notification.exception)}let angle=0;function generateXCoord(){return Math.random()*(canvas.width+400)-200}function redraw(ctx){ctx.clearRect(0,0,canvas.width,canvas.height),ctx.fillStyle="#cbebfa",ctx.beginPath();for(let f of flakes)ctx.moveTo(f.x,f.y),ctx.arc(f.x,f.y,f.r,0,2*Math.PI,!0);ctx.fill(),function(){angle+=.01;let basemovement=2.5*noise.simplex2(.1*angle,0);for(let i=0;icanvas.height+10&&(flakes.length>desiredFlakes&&(flakes.splice(i,1),i--),f.x=generateXCoord(),f.y=-10)}desiredFlakes>flakes.length&&Math.random()<.2&&flakes.push({x:generateXCoord(),y:-10,r:5*Math.random()+2,d:Math.random()+1})}()}})); + */let canvas;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(snowValue){let enableSnow=!!snowValue;null!==localStorage.getItem("theme_wwu2019/enable-snow")&&(enableSnow="false"!==localStorage.getItem("theme_wwu2019/enable-snow"),updateSnowPreferenceAjax(enableSnow),localStorage.removeItem("theme_wwu2019/enable-snow"));(0,_jquery.default)('
').insertAfter("#main-menu-right .main-menu-additions-item"),canvas=document.createElement("canvas"),canvas.height=window.innerHeight,canvas.width=window.innerWidth,canvas.classList.add("snow"),canvas.style.position="fixed",canvas.style.top="0",canvas.style.left="0",canvas.style.zIndex="1010",canvas.style.opacity="0.8",canvas.style.pointerEvents="none",(0,_jquery.default)(window).resize((()=>{canvas.height=window.innerHeight,canvas.width=window.innerWidth,desiredFlakes=50+canvas.height*canvas.width*1e-4})),desiredFlakes=50+canvas.height*canvas.width*1e-4;for(let i=0;i img");enableSnow?(intervalId=setInterval(redraw,25,ctx),snowicon.attr("src",pixurl+"snow-disable.svg")):(canvas.hidden=!0,snowicon.attr("src",pixurl+"snow-enable.svg"));(0,_jquery.default)("#snow-toggle").click((()=>{intervalId?(clearInterval(intervalId),intervalId=null,snowicon.attr("src",pixurl+"snow-enable.svg")):(intervalId=setInterval(redraw,25,ctx),snowicon.attr("src",pixurl+"snow-disable.svg")),canvas.hidden=null===intervalId,updateSnowPreferenceAjax(null!==intervalId)})),(0,_jquery.default)("body").append(canvas),noise.seed(Math.random())},_jquery=_interopRequireDefault(_jquery),_ajax=_interopRequireDefault(_ajax),_notification=_interopRequireDefault(_notification);let desiredFlakes=150,flakes=[],intervalId=null;const pixurl=M.cfg.wwwroot+"/theme/wwu2019/pix/";let noise=function(){var module={};function Grad(x,y,z){this.x=x,this.y=y,this.z=z}Grad.prototype.dot2=function(x,y){return this.x*x+this.y*y},Grad.prototype.dot3=function(x,y,z){return this.x*x+this.y*y+this.z*z};var grad3=[new Grad(1,1,0),new Grad(-1,1,0),new Grad(1,-1,0),new Grad(-1,-1,0),new Grad(1,0,1),new Grad(-1,0,1),new Grad(1,0,-1),new Grad(-1,0,-1),new Grad(0,1,1),new Grad(0,-1,1),new Grad(0,1,-1),new Grad(0,-1,-1)],p=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],perm=new Array(512),gradP=new Array(512);module.seed=function(seed){seed>0&&seed<1&&(seed*=65536),(seed=Math.floor(seed))<256&&(seed|=seed<<8);for(var i=0;i<256;i++){var v;v=1&i?p[i]^255&seed:p[i]^seed>>8&255,perm[i]=perm[i+256]=v,gradP[i]=gradP[i+256]=grad3[v%12]}},module.seed(0);var F2=.5*(Math.sqrt(3)-1),G2=(3-Math.sqrt(3))/6;function fade(t){return t*t*t*(t*(6*t-15)+10)}function lerp(a,b,t){return(1-t)*a+t*b}return module.simplex2=function(xin,yin){var i1,j1,s=(xin+yin)*F2,i=Math.floor(xin+s),j=Math.floor(yin+s),t=(i+j)*G2,x0=xin-i+t,y0=yin-j+t;x0>y0?(i1=1,j1=0):(i1=0,j1=1);var x1=x0-i1+G2,y1=y0-j1+G2,x2=x0-1+2*G2,y2=y0-1+2*G2,gi0=gradP[(i&=255)+perm[j&=255]],gi1=gradP[i+i1+perm[j+j1]],gi2=gradP[i+1+perm[j+1]],t0=.5-x0*x0-y0*y0,t1=.5-x1*x1-y1*y1,t2=.5-x2*x2-y2*y2;return 70*((t0<0?0:(t0*=t0)*t0*gi0.dot2(x0,y0))+(t1<0?0:(t1*=t1)*t1*gi1.dot2(x1,y1))+(t2<0?0:(t2*=t2)*t2*gi2.dot2(x2,y2)))},module.perlin2=function(x,y){var X=Math.floor(x),Y=Math.floor(y);x-=X,y-=Y;var n00=gradP[(X&=255)+perm[Y&=255]].dot2(x,y),n01=gradP[X+perm[Y+1]].dot2(x,y-1),n10=gradP[X+1+perm[Y]].dot2(x-1,y),n11=gradP[X+1+perm[Y+1]].dot2(x-1,y-1),u=fade(x);return lerp(lerp(n00,n10,u),lerp(n01,n11,u),fade(y))},module}();function updateSnowPreferenceAjax(snow){var request={methodname:"core_user_update_user_preferences",args:{preferences:[{type:"theme_wwu2019_snow",value:snow?1:0}]}};_ajax.default.call([request])[0].fail(_notification.default.exception)}let angle=0;function generateXCoord(){return Math.random()*(canvas.width+400)-200}function redraw(ctx){ctx.clearRect(0,0,canvas.width,canvas.height),ctx.fillStyle="#cbebfa",ctx.beginPath();for(let f of flakes)ctx.moveTo(f.x,f.y),ctx.arc(f.x,f.y,f.r,0,2*Math.PI,!0);ctx.fill(),function(){angle+=.01;let basemovement=2.5*noise.simplex2(.1*angle,0);for(let i=0;icanvas.height+10&&(flakes.length>desiredFlakes&&(flakes.splice(i,1),i--),f.x=generateXCoord(),f.y=-10)}desiredFlakes>flakes.length&&Math.random()<.2&&flakes.push({x:generateXCoord(),y:-10,r:5*Math.random()+2,d:Math.random()+1})}()}})); //# sourceMappingURL=snow.min.js.map \ No newline at end of file diff --git a/amd/build/snow.min.js.map b/amd/build/snow.min.js.map index e081ea1..bd66e0d 100644 --- a/amd/build/snow.min.js.map +++ b/amd/build/snow.min.js.map @@ -1 +1 @@ -{"version":3,"file":"snow.min.js","sources":["../src/snow.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Manages the very important snow.\n *\n * @module theme_wwu2019/snow\n * @copyright 2020 Justus Dieckmann WWU\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Ajax from 'core/ajax';\n\nlet canvas;\n\nlet desiredFlakes = 150;\n\n/**\n * @type {[{x: number, y: number, r: number, d: number}]}\n */\nlet flakes = [];\n\nlet intervalId = null;\n\nconst pixurl = M.cfg.wwwroot + '/theme/wwu2019/pix/';\n\nlet noise = exportNoise();\n\n/**\n * Updates the snow preference.\n * @param {boolean} snow\n */\nfunction updateSnowPreferenceAjax(snow) {\n var request = {\n methodname: 'core_user_update_user_preferences',\n args: {\n preferences: [{\n type: 'theme_wwu2019_snow',\n value: snow ? 1 : 0\n }]\n }\n };\n\n Ajax.call([request])[0]\n .fail(Notification.exception);\n}\n\n/**\n * Init function\n * @param {int} snowValue\n */\nexport function init(snowValue) {\n let enableSnow = !!snowValue;\n if (localStorage.getItem('theme_wwu2019/enable-snow') !== null) {\n enableSnow = localStorage.getItem('theme_wwu2019/enable-snow') !== 'false';\n updateSnowPreferenceAjax(enableSnow);\n localStorage.removeItem('theme_wwu2019/enable-snow');\n }\n\n $('
' +\n '' +\n '
').insertAfter('#main-menu-right .main-menu-additions-item');\n\n canvas = document.createElement('canvas');\n canvas.height = window.innerHeight;\n canvas.width = window.innerWidth;\n canvas.classList.add('snow');\n canvas.style.position = 'fixed';\n canvas.style.top = '0';\n canvas.style.left = '0';\n canvas.style.zIndex = '1010';\n canvas.style.opacity = '0.8';\n canvas.style.pointerEvents = 'none';\n $(window).resize(() => {\n canvas.height = window.innerHeight;\n canvas.width = window.innerWidth;\n desiredFlakes = 50 + canvas.height * canvas.width * 0.0001;\n });\n\n desiredFlakes = 50 + canvas.height * canvas.width * 0.0001;\n\n // Loop throught the empty flakes and apply attributes\n for (let i = 0; i < desiredFlakes; i++) {\n flakes.push({\n x: generateXCoord(), // Also spawn left and right of window.\n y: Math.random() * canvas.height,\n r: Math.random() * 5 + 2, // Min of 2px and max of 7px\n d: Math.random() + 1 // Density of the flake\n });\n }\n let ctx = canvas.getContext(\"2d\");\n\n let snowicon = $('#snow-toggle > img');\n\n if (enableSnow) {\n intervalId = setInterval(redraw, 25, ctx);\n snowicon.attr('src', pixurl + 'snow-disable.svg');\n } else {\n canvas.hidden = true;\n snowicon.attr('src', pixurl + 'snow-enable.svg');\n }\n\n $('#snow-toggle').click(() => {\n if (intervalId) {\n clearInterval(intervalId);\n intervalId = null;\n snowicon.attr('src', pixurl + 'snow-enable.svg');\n } else {\n intervalId = setInterval(redraw, 25, ctx);\n snowicon.attr('src', pixurl + 'snow-disable.svg');\n }\n canvas.hidden = intervalId === null;\n updateSnowPreferenceAjax(intervalId !== null);\n });\n\n $('body').append(canvas);\n\n noise.seed(Math.random());\n}\n\n// Animate the flakes\nlet angle = 0;\n\n/**\n * Move the flakes.\n */\nfunction moveFlakes() {\n angle += 0.01;\n let basemovement = noise.simplex2(angle * 0.1, 0) * 2.5;\n for (let i = 0; i < flakes.length; i++) {\n // Store current flake\n let f = flakes[i];\n // Update X and Y coordinates of each snowflakes\n f.y += Math.pow(f.d, 2) + 1;\n f.x += basemovement + Math.sin(f.d * 8 + angle) * 0.5;\n\n // If the snowflake reaches the bottom, send a new one to the top\n if (f.y > canvas.height + 10) {\n if (flakes.length > desiredFlakes) {\n flakes.splice(i, 1);\n i--;\n }\n f.x = generateXCoord();\n f.y = -10;\n }\n }\n if (desiredFlakes > flakes.length && Math.random() < 0.2) {\n flakes.push({\n x: generateXCoord(), // Also spawn left and right of window.\n y: -10,\n r: Math.random() * 5 + 2, // Min of 2px and max of 7px\n d: Math.random() + 1 // Density of the flake\n });\n }\n}\n\n/**\n * Generate X Coordinate\n * @returns {number} the x coordinate\n */\nfunction generateXCoord() {\n return Math.random() * (canvas.width + 400) - 200;\n}\n\n/**\n * Redraw everything\n * @param {CanvasRenderingContext2D} ctx\n */\nfunction redraw(ctx) {\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.fillStyle = \"#cbebfa\";\n ctx.beginPath();\n for (let f of flakes) {\n ctx.moveTo(f.x, f.y);\n ctx.arc(f.x, f.y, f.r, 0, Math.PI * 2, true);\n }\n ctx.fill();\n moveFlakes();\n}\n\n/*\n * A speed-improved perlin and simplex noise algorithms for 2D.\n *\n * Based on example code by Stefan Gustavson (stegu@itn.liu.se).\n * Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).\n * Better rank ordering method by Stefan Gustavson in 2012.\n * Converted to Javascript by Joseph Gentle.\n *\n * Version 2012-03-09\n *\n * This code was placed in the public domain by its original author,\n * Stefan Gustavson. You may use it as you see fit, but\n * attribution is appreciated.\n *\n */\n// eslint-disable-next-line\nfunction exportNoise() {\n /* eslint-disable */\n var module = {};\n\n function Grad(x, y, z) {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n\n Grad.prototype.dot2 = function (x, y) {\n return this.x * x + this.y * y;\n };\n\n Grad.prototype.dot3 = function (x, y, z) {\n return this.x * x + this.y * y + this.z * z;\n };\n\n var grad3 = [new Grad(1, 1, 0), new Grad(-1, 1, 0), new Grad(1, -1, 0), new Grad(-1, -1, 0),\n new Grad(1, 0, 1), new Grad(-1, 0, 1), new Grad(1, 0, -1), new Grad(-1, 0, -1),\n new Grad(0, 1, 1), new Grad(0, -1, 1), new Grad(0, 1, -1), new Grad(0, -1, -1)];\n\n var p = [151, 160, 137, 91, 90, 15,\n 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23,\n 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33,\n 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166,\n 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244,\n 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196,\n 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123,\n 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42,\n 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9,\n 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228,\n 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107,\n 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254,\n 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180];\n // To remove the need for index wrapping, double the permutation table length\n var perm = new Array(512);\n var gradP = new Array(512);\n\n // This isn't a very good seeding function, but it works ok. It supports 2^16\n // different seed values. Write something better if you need more seeds.\n module.seed = function (seed) {\n if (seed > 0 && seed < 1) {\n // Scale the seed out\n seed *= 65536;\n }\n\n seed = Math.floor(seed);\n if (seed < 256) {\n seed |= seed << 8;\n }\n\n for (var i = 0; i < 256; i++) {\n var v;\n if (i & 1) {\n v = p[i] ^ (seed & 255);\n } else {\n v = p[i] ^ ((seed >> 8) & 255);\n }\n\n perm[i] = perm[i + 256] = v;\n gradP[i] = gradP[i + 256] = grad3[v % 12];\n }\n };\n\n module.seed(0);\n\n // Skewing and unskewing factors for 2, 3, and 4 dimensions\n var F2 = 0.5 * (Math.sqrt(3) - 1);\n var G2 = (3 - Math.sqrt(3)) / 6;\n\n // 2D simplex noise\n module.simplex2 = function(xin, yin) {\n var n0, n1, n2; // Noise contributions from the three corners\n // Skew the input space to determine which simplex cell we're in\n var s = (xin + yin) * F2; // Hairy factor for 2D\n var i = Math.floor(xin + s);\n var j = Math.floor(yin + s);\n var t = (i + j) * G2;\n var x0 = xin - i + t; // The x,y distances from the cell origin, unskewed.\n var y0 = yin - j + t;\n // For the 2D case, the simplex shape is an equilateral triangle.\n // Determine which simplex we are in.\n var i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords\n if (x0 > y0) { // Lower triangle, XY order: (0,0)->(1,0)->(1,1)\n i1 = 1;\n j1 = 0;\n } else { // Upper triangle, YX order: (0,0)->(0,1)->(1,1)\n i1 = 0;\n j1 = 1;\n }\n // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and\n // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where\n // c = (3-sqrt(3))/6\n var x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords\n var y1 = y0 - j1 + G2;\n var x2 = x0 - 1 + 2 * G2; // Offsets for last corner in (x,y) unskewed coords\n var y2 = y0 - 1 + 2 * G2;\n // Work out the hashed gradient indices of the three simplex corners\n i &= 255;\n j &= 255;\n var gi0 = gradP[i + perm[j]];\n var gi1 = gradP[i + i1 + perm[j + j1]];\n var gi2 = gradP[i + 1 + perm[j + 1]];\n // Calculate the contribution from the three corners\n var t0 = 0.5 - x0 * x0 - y0 * y0;\n if (t0 < 0) {\n n0 = 0;\n } else {\n t0 *= t0;\n n0 = t0 * t0 * gi0.dot2(x0, y0); // (x,y) of grad3 used for 2D gradient\n }\n var t1 = 0.5 - x1 * x1 - y1 * y1;\n if (t1 < 0) {\n n1 = 0;\n } else {\n t1 *= t1;\n n1 = t1 * t1 * gi1.dot2(x1, y1);\n }\n var t2 = 0.5 - x2 * x2 - y2 * y2;\n if (t2 < 0) {\n n2 = 0;\n } else {\n t2 *= t2;\n n2 = t2 * t2 * gi2.dot2(x2, y2);\n }\n // Add contributions from each corner to get the final noise value.\n // The result is scaled to return values in the interval [-1,1].\n return 70 * (n0 + n1 + n2);\n };\n\n // ##### Perlin noise stuff\n\n function fade(t) {\n return t * t * t * (t * (t * 6 - 15) + 10);\n }\n\n function lerp(a, b, t) {\n return (1 - t) * a + t * b;\n }\n\n // 2D Perlin Noise\n module.perlin2 = function (x, y) {\n // Find unit grid cell containing point\n var X = Math.floor(x), Y = Math.floor(y);\n // Get relative xy coordinates of point within that cell\n x = x - X;\n y = y - Y;\n // Wrap the integer cells at 255 (smaller integer period can be introduced here)\n X = X & 255;\n Y = Y & 255;\n\n // Calculate noise contributions from each of the four corners\n var n00 = gradP[X + perm[Y]].dot2(x, y);\n var n01 = gradP[X + perm[Y + 1]].dot2(x, y - 1);\n var n10 = gradP[X + 1 + perm[Y]].dot2(x - 1, y);\n var n11 = gradP[X + 1 + perm[Y + 1]].dot2(x - 1, y - 1);\n\n // Compute the fade curve value for x\n var u = fade(x);\n\n // Interpolate the four results\n return lerp(\n lerp(n00, n10, u),\n lerp(n01, n11, u),\n fade(y));\n };\n\n return module;\n}"],"names":["canvas","snowValue","enableSnow","localStorage","getItem","updateSnowPreferenceAjax","removeItem","insertAfter","document","createElement","height","window","innerHeight","width","innerWidth","classList","add","style","position","top","left","zIndex","opacity","pointerEvents","resize","desiredFlakes","i","flakes","push","x","generateXCoord","y","Math","random","r","d","ctx","getContext","snowicon","intervalId","setInterval","redraw","attr","pixurl","hidden","click","clearInterval","append","noise","seed","M","cfg","wwwroot","module","Grad","z","prototype","dot2","this","dot3","grad3","p","perm","Array","gradP","floor","v","F2","sqrt","G2","fade","t","lerp","a","b","simplex2","xin","yin","i1","j1","s","j","x0","y0","x1","y1","x2","y2","gi0","gi1","gi2","t0","t1","t2","perlin2","X","Y","n00","n01","n10","n11","u","exportNoise","snow","request","methodname","args","preferences","type","value","call","fail","Notification","exception","angle","clearRect","fillStyle","beginPath","f","moveTo","arc","PI","fill","basemovement","length","pow","sin","splice","moveFlakes"],"mappings":";;;;;;;SA0BIA,sFAsCiBC,eACbC,aAAeD,UACuC,OAAtDE,aAAaC,QAAQ,+BACrBF,WAAmE,UAAtDC,aAAaC,QAAQ,6BAClCC,yBAAyBH,YACzBC,aAAaG,WAAW,kDAG1B,uGAEYC,YAAY,8CAE1BP,OAASQ,SAASC,cAAc,UAChCT,OAAOU,OAASC,OAAOC,YACvBZ,OAAOa,MAAQF,OAAOG,WACtBd,OAAOe,UAAUC,IAAI,QACrBhB,OAAOiB,MAAMC,SAAW,QACxBlB,OAAOiB,MAAME,IAAM,IACnBnB,OAAOiB,MAAMG,KAAO,IACpBpB,OAAOiB,MAAMI,OAAS,OACtBrB,OAAOiB,MAAMK,QAAU,MACvBtB,OAAOiB,MAAMM,cAAgB,2BAC3BZ,QAAQa,QAAO,KACbxB,OAAOU,OAASC,OAAOC,YACvBZ,OAAOa,MAAQF,OAAOG,WACtBW,cAAgB,GAAKzB,OAAOU,OAASV,OAAOa,MAAQ,QAGxDY,cAAgB,GAAKzB,OAAOU,OAASV,OAAOa,MAAQ,SAG/C,IAAIa,EAAI,EAAGA,EAAID,cAAeC,IAC/BC,OAAOC,KAAK,CACRC,EAAGC,iBACHC,EAAGC,KAAKC,SAAWjC,OAAOU,OAC1BwB,EAAmB,EAAhBF,KAAKC,SAAe,EACvBE,EAAGH,KAAKC,SAAW,QAGvBG,IAAMpC,OAAOqC,WAAW,MAExBC,UAAW,mBAAE,sBAEbpC,YACAqC,WAAaC,YAAYC,OAAQ,GAAIL,KACrCE,SAASI,KAAK,MAAOC,OAAS,sBAE9B3C,OAAO4C,QAAS,EAChBN,SAASI,KAAK,MAAOC,OAAS,wCAGhC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CACVC,KAAM,qBACNC,MAAON,KAAO,EAAI,oBAKzBO,KAAK,CAACN,UAAU,GAChBO,KAAKC,aAAaC,eA6EvBC,MAAQ,WAuCHpF,wBACEE,KAAKC,UAAYjC,OAAOa,MAAQ,KAAO,aAOzC4B,OAAOL,KACZA,IAAI+E,UAAU,EAAG,EAAGnH,OAAOa,MAAOb,OAAOU,QACzC0B,IAAIgF,UAAY,UAChBhF,IAAIiF,gBACC,IAAIC,KAAK3F,OACVS,IAAImF,OAAOD,EAAEzF,EAAGyF,EAAEvF,GAClBK,IAAIoF,IAAIF,EAAEzF,EAAGyF,EAAEvF,EAAGuF,EAAEpF,EAAG,EAAa,EAAVF,KAAKyF,IAAQ,GAE3CrF,IAAIsF,kBAjDJR,OAAS,QACLS,aAAgD,IAAjC3E,MAAM2B,SAAiB,GAARuC,MAAa,OAC1C,IAAIxF,EAAI,EAAGA,EAAIC,OAAOiG,OAAQlG,IAAK,KAEhC4F,EAAI3F,OAAOD,GAEf4F,EAAEvF,GAAKC,KAAK6F,IAAIP,EAAEnF,EAAG,GAAK,EAC1BmF,EAAEzF,GAAK8F,aAA2C,GAA5B3F,KAAK8F,IAAU,EAANR,EAAEnF,EAAQ+E,OAGrCI,EAAEvF,EAAI/B,OAAOU,OAAS,KAClBiB,OAAOiG,OAASnG,gBAChBE,OAAOoG,OAAOrG,EAAG,GACjBA,KAEJ4F,EAAEzF,EAAIC,iBACNwF,EAAEvF,GAAK,IAGXN,cAAgBE,OAAOiG,QAAU5F,KAAKC,SAAW,IACjDN,OAAOC,KAAK,CACRC,EAAGC,iBACHC,GAAI,GACJG,EAAmB,EAAhBF,KAAKC,SAAe,EACvBE,EAAGH,KAAKC,SAAW,IA0B3B+F"} \ No newline at end of file +{"version":3,"file":"snow.min.js","sources":["../src/snow.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Manages the very important snow.\n *\n * @module theme_wwu2019/snow\n * @copyright 2020 Justus Dieckmann WWU\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\n\nlet canvas;\n\nlet desiredFlakes = 150;\n\n/**\n * @type {[{x: number, y: number, r: number, d: number}]}\n */\nlet flakes = [];\n\nlet intervalId = null;\n\nconst pixurl = M.cfg.wwwroot + '/theme/wwu2019/pix/';\n\nlet noise = exportNoise();\n\n/**\n * Updates the snow preference.\n * @param {boolean} snow\n */\nfunction updateSnowPreferenceAjax(snow) {\n var request = {\n methodname: 'core_user_update_user_preferences',\n args: {\n preferences: [{\n type: 'theme_wwu2019_snow',\n value: snow ? 1 : 0\n }]\n }\n };\n\n Ajax.call([request])[0]\n .fail(Notification.exception);\n}\n\n/**\n * Init function\n * @param {int} snowValue\n */\nexport function init(snowValue) {\n let enableSnow = !!snowValue;\n if (localStorage.getItem('theme_wwu2019/enable-snow') !== null) {\n enableSnow = localStorage.getItem('theme_wwu2019/enable-snow') !== 'false';\n updateSnowPreferenceAjax(enableSnow);\n localStorage.removeItem('theme_wwu2019/enable-snow');\n }\n\n $('
' +\n '' +\n '
').insertAfter('#main-menu-right .main-menu-additions-item');\n\n canvas = document.createElement('canvas');\n canvas.height = window.innerHeight;\n canvas.width = window.innerWidth;\n canvas.classList.add('snow');\n canvas.style.position = 'fixed';\n canvas.style.top = '0';\n canvas.style.left = '0';\n canvas.style.zIndex = '1010';\n canvas.style.opacity = '0.8';\n canvas.style.pointerEvents = 'none';\n $(window).resize(() => {\n canvas.height = window.innerHeight;\n canvas.width = window.innerWidth;\n desiredFlakes = 50 + canvas.height * canvas.width * 0.0001;\n });\n\n desiredFlakes = 50 + canvas.height * canvas.width * 0.0001;\n\n // Loop throught the empty flakes and apply attributes\n for (let i = 0; i < desiredFlakes; i++) {\n flakes.push({\n x: generateXCoord(), // Also spawn left and right of window.\n y: Math.random() * canvas.height,\n r: Math.random() * 5 + 2, // Min of 2px and max of 7px\n d: Math.random() + 1 // Density of the flake\n });\n }\n let ctx = canvas.getContext(\"2d\");\n\n let snowicon = $('#snow-toggle > img');\n\n if (enableSnow) {\n intervalId = setInterval(redraw, 25, ctx);\n snowicon.attr('src', pixurl + 'snow-disable.svg');\n } else {\n canvas.hidden = true;\n snowicon.attr('src', pixurl + 'snow-enable.svg');\n }\n\n $('#snow-toggle').click(() => {\n if (intervalId) {\n clearInterval(intervalId);\n intervalId = null;\n snowicon.attr('src', pixurl + 'snow-enable.svg');\n } else {\n intervalId = setInterval(redraw, 25, ctx);\n snowicon.attr('src', pixurl + 'snow-disable.svg');\n }\n canvas.hidden = intervalId === null;\n updateSnowPreferenceAjax(intervalId !== null);\n });\n\n $('body').append(canvas);\n\n noise.seed(Math.random());\n}\n\n// Animate the flakes\nlet angle = 0;\n\n/**\n * Move the flakes.\n */\nfunction moveFlakes() {\n angle += 0.01;\n let basemovement = noise.simplex2(angle * 0.1, 0) * 2.5;\n for (let i = 0; i < flakes.length; i++) {\n // Store current flake\n let f = flakes[i];\n // Update X and Y coordinates of each snowflakes\n f.y += Math.pow(f.d, 2) + 1;\n f.x += basemovement + Math.sin(f.d * 8 + angle) * 0.5;\n\n // If the snowflake reaches the bottom, send a new one to the top\n if (f.y > canvas.height + 10) {\n if (flakes.length > desiredFlakes) {\n flakes.splice(i, 1);\n i--;\n }\n f.x = generateXCoord();\n f.y = -10;\n }\n }\n if (desiredFlakes > flakes.length && Math.random() < 0.2) {\n flakes.push({\n x: generateXCoord(), // Also spawn left and right of window.\n y: -10,\n r: Math.random() * 5 + 2, // Min of 2px and max of 7px\n d: Math.random() + 1 // Density of the flake\n });\n }\n}\n\n/**\n * Generate X Coordinate\n * @returns {number} the x coordinate\n */\nfunction generateXCoord() {\n return Math.random() * (canvas.width + 400) - 200;\n}\n\n/**\n * Redraw everything\n * @param {CanvasRenderingContext2D} ctx\n */\nfunction redraw(ctx) {\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.fillStyle = \"#cbebfa\";\n ctx.beginPath();\n for (let f of flakes) {\n ctx.moveTo(f.x, f.y);\n ctx.arc(f.x, f.y, f.r, 0, Math.PI * 2, true);\n }\n ctx.fill();\n moveFlakes();\n}\n\n/*\n * A speed-improved perlin and simplex noise algorithms for 2D.\n *\n * Based on example code by Stefan Gustavson (stegu@itn.liu.se).\n * Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).\n * Better rank ordering method by Stefan Gustavson in 2012.\n * Converted to Javascript by Joseph Gentle.\n *\n * Version 2012-03-09\n *\n * This code was placed in the public domain by its original author,\n * Stefan Gustavson. You may use it as you see fit, but\n * attribution is appreciated.\n *\n */\n// eslint-disable-next-line\nfunction exportNoise() {\n /* eslint-disable */\n var module = {};\n\n function Grad(x, y, z) {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n\n Grad.prototype.dot2 = function (x, y) {\n return this.x * x + this.y * y;\n };\n\n Grad.prototype.dot3 = function (x, y, z) {\n return this.x * x + this.y * y + this.z * z;\n };\n\n var grad3 = [new Grad(1, 1, 0), new Grad(-1, 1, 0), new Grad(1, -1, 0), new Grad(-1, -1, 0),\n new Grad(1, 0, 1), new Grad(-1, 0, 1), new Grad(1, 0, -1), new Grad(-1, 0, -1),\n new Grad(0, 1, 1), new Grad(0, -1, 1), new Grad(0, 1, -1), new Grad(0, -1, -1)];\n\n var p = [151, 160, 137, 91, 90, 15,\n 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23,\n 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33,\n 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166,\n 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244,\n 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196,\n 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123,\n 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42,\n 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9,\n 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228,\n 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107,\n 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254,\n 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180];\n // To remove the need for index wrapping, double the permutation table length\n var perm = new Array(512);\n var gradP = new Array(512);\n\n // This isn't a very good seeding function, but it works ok. It supports 2^16\n // different seed values. Write something better if you need more seeds.\n module.seed = function (seed) {\n if (seed > 0 && seed < 1) {\n // Scale the seed out\n seed *= 65536;\n }\n\n seed = Math.floor(seed);\n if (seed < 256) {\n seed |= seed << 8;\n }\n\n for (var i = 0; i < 256; i++) {\n var v;\n if (i & 1) {\n v = p[i] ^ (seed & 255);\n } else {\n v = p[i] ^ ((seed >> 8) & 255);\n }\n\n perm[i] = perm[i + 256] = v;\n gradP[i] = gradP[i + 256] = grad3[v % 12];\n }\n };\n\n module.seed(0);\n\n // Skewing and unskewing factors for 2, 3, and 4 dimensions\n var F2 = 0.5 * (Math.sqrt(3) - 1);\n var G2 = (3 - Math.sqrt(3)) / 6;\n\n // 2D simplex noise\n module.simplex2 = function(xin, yin) {\n var n0, n1, n2; // Noise contributions from the three corners\n // Skew the input space to determine which simplex cell we're in\n var s = (xin + yin) * F2; // Hairy factor for 2D\n var i = Math.floor(xin + s);\n var j = Math.floor(yin + s);\n var t = (i + j) * G2;\n var x0 = xin - i + t; // The x,y distances from the cell origin, unskewed.\n var y0 = yin - j + t;\n // For the 2D case, the simplex shape is an equilateral triangle.\n // Determine which simplex we are in.\n var i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords\n if (x0 > y0) { // Lower triangle, XY order: (0,0)->(1,0)->(1,1)\n i1 = 1;\n j1 = 0;\n } else { // Upper triangle, YX order: (0,0)->(0,1)->(1,1)\n i1 = 0;\n j1 = 1;\n }\n // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and\n // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where\n // c = (3-sqrt(3))/6\n var x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords\n var y1 = y0 - j1 + G2;\n var x2 = x0 - 1 + 2 * G2; // Offsets for last corner in (x,y) unskewed coords\n var y2 = y0 - 1 + 2 * G2;\n // Work out the hashed gradient indices of the three simplex corners\n i &= 255;\n j &= 255;\n var gi0 = gradP[i + perm[j]];\n var gi1 = gradP[i + i1 + perm[j + j1]];\n var gi2 = gradP[i + 1 + perm[j + 1]];\n // Calculate the contribution from the three corners\n var t0 = 0.5 - x0 * x0 - y0 * y0;\n if (t0 < 0) {\n n0 = 0;\n } else {\n t0 *= t0;\n n0 = t0 * t0 * gi0.dot2(x0, y0); // (x,y) of grad3 used for 2D gradient\n }\n var t1 = 0.5 - x1 * x1 - y1 * y1;\n if (t1 < 0) {\n n1 = 0;\n } else {\n t1 *= t1;\n n1 = t1 * t1 * gi1.dot2(x1, y1);\n }\n var t2 = 0.5 - x2 * x2 - y2 * y2;\n if (t2 < 0) {\n n2 = 0;\n } else {\n t2 *= t2;\n n2 = t2 * t2 * gi2.dot2(x2, y2);\n }\n // Add contributions from each corner to get the final noise value.\n // The result is scaled to return values in the interval [-1,1].\n return 70 * (n0 + n1 + n2);\n };\n\n // ##### Perlin noise stuff\n\n function fade(t) {\n return t * t * t * (t * (t * 6 - 15) + 10);\n }\n\n function lerp(a, b, t) {\n return (1 - t) * a + t * b;\n }\n\n // 2D Perlin Noise\n module.perlin2 = function (x, y) {\n // Find unit grid cell containing point\n var X = Math.floor(x), Y = Math.floor(y);\n // Get relative xy coordinates of point within that cell\n x = x - X;\n y = y - Y;\n // Wrap the integer cells at 255 (smaller integer period can be introduced here)\n X = X & 255;\n Y = Y & 255;\n\n // Calculate noise contributions from each of the four corners\n var n00 = gradP[X + perm[Y]].dot2(x, y);\n var n01 = gradP[X + perm[Y + 1]].dot2(x, y - 1);\n var n10 = gradP[X + 1 + perm[Y]].dot2(x - 1, y);\n var n11 = gradP[X + 1 + perm[Y + 1]].dot2(x - 1, y - 1);\n\n // Compute the fade curve value for x\n var u = fade(x);\n\n // Interpolate the four results\n return lerp(\n lerp(n00, n10, u),\n lerp(n01, n11, u),\n fade(y));\n };\n\n return module;\n}"],"names":["canvas","snowValue","enableSnow","localStorage","getItem","updateSnowPreferenceAjax","removeItem","insertAfter","document","createElement","height","window","innerHeight","width","innerWidth","classList","add","style","position","top","left","zIndex","opacity","pointerEvents","resize","desiredFlakes","i","flakes","push","x","generateXCoord","y","Math","random","r","d","ctx","getContext","snowicon","intervalId","setInterval","redraw","attr","pixurl","hidden","click","clearInterval","append","noise","seed","M","cfg","wwwroot","module","Grad","z","prototype","dot2","this","dot3","grad3","p","perm","Array","gradP","floor","v","F2","sqrt","G2","fade","t","lerp","a","b","simplex2","xin","yin","i1","j1","s","j","x0","y0","x1","y1","x2","y2","gi0","gi1","gi2","t0","t1","t2","perlin2","X","Y","n00","n01","n10","n11","u","exportNoise","snow","request","methodname","args","preferences","type","value","call","fail","Notification","exception","angle","clearRect","fillStyle","beginPath","f","moveTo","arc","PI","fill","basemovement","length","pow","sin","splice","moveFlakes"],"mappings":";;;;;;;SA2BIA,sFAsCiBC,eACbC,aAAeD,UACuC,OAAtDE,aAAaC,QAAQ,+BACrBF,WAAmE,UAAtDC,aAAaC,QAAQ,6BAClCC,yBAAyBH,YACzBC,aAAaG,WAAW,kDAG1B,uGAEYC,YAAY,8CAE1BP,OAASQ,SAASC,cAAc,UAChCT,OAAOU,OAASC,OAAOC,YACvBZ,OAAOa,MAAQF,OAAOG,WACtBd,OAAOe,UAAUC,IAAI,QACrBhB,OAAOiB,MAAMC,SAAW,QACxBlB,OAAOiB,MAAME,IAAM,IACnBnB,OAAOiB,MAAMG,KAAO,IACpBpB,OAAOiB,MAAMI,OAAS,OACtBrB,OAAOiB,MAAMK,QAAU,MACvBtB,OAAOiB,MAAMM,cAAgB,2BAC3BZ,QAAQa,QAAO,KACbxB,OAAOU,OAASC,OAAOC,YACvBZ,OAAOa,MAAQF,OAAOG,WACtBW,cAAgB,GAAKzB,OAAOU,OAASV,OAAOa,MAAQ,QAGxDY,cAAgB,GAAKzB,OAAOU,OAASV,OAAOa,MAAQ,SAG/C,IAAIa,EAAI,EAAGA,EAAID,cAAeC,IAC/BC,OAAOC,KAAK,CACRC,EAAGC,iBACHC,EAAGC,KAAKC,SAAWjC,OAAOU,OAC1BwB,EAAmB,EAAhBF,KAAKC,SAAe,EACvBE,EAAGH,KAAKC,SAAW,QAGvBG,IAAMpC,OAAOqC,WAAW,MAExBC,UAAW,mBAAE,sBAEbpC,YACAqC,WAAaC,YAAYC,OAAQ,GAAIL,KACrCE,SAASI,KAAK,MAAOC,OAAS,sBAE9B3C,OAAO4C,QAAS,EAChBN,SAASI,KAAK,MAAOC,OAAS,wCAGhC,gBAAgBE,OAAM,KAChBN,YACAO,cAAcP,YACdA,WAAa,KACbD,SAASI,KAAK,MAAOC,OAAS,qBAE9BJ,WAAaC,YAAYC,OAAQ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F,wBACEE,KAAKC,UAAYjC,OAAOa,MAAQ,KAAO,aAOzC4B,OAAOL,KACZA,IAAI+E,UAAU,EAAG,EAAGnH,OAAOa,MAAOb,OAAOU,QACzC0B,IAAIgF,UAAY,UAChBhF,IAAIiF,gBACC,IAAIC,KAAK3F,OACVS,IAAImF,OAAOD,EAAEzF,EAAGyF,EAAEvF,GAClBK,IAAIoF,IAAIF,EAAEzF,EAAGyF,EAAEvF,EAAGuF,EAAEpF,EAAG,EAAa,EAAVF,KAAKyF,IAAQ,GAE3CrF,IAAIsF,kBAjDJR,OAAS,QACLS,aAAgD,IAAjC3E,MAAM2B,SAAiB,GAARuC,MAAa,OAC1C,IAAIxF,EAAI,EAAGA,EAAIC,OAAOiG,OAAQlG,IAAK,KAEhC4F,EAAI3F,OAAOD,GAEf4F,EAAEvF,GAAKC,KAAK6F,IAAIP,EAAEnF,EAAG,GAAK,EAC1BmF,EAAEzF,GAAK8F,aAA2C,GAA5B3F,KAAK8F,IAAU,EAANR,EAAEnF,EAAQ+E,OAGrCI,EAAEvF,EAAI/B,OAAOU,OAAS,KAClBiB,OAAOiG,OAASnG,gBAChBE,OAAOoG,OAAOrG,EAAG,GACjBA,KAEJ4F,EAAEzF,EAAIC,iBACNwF,EAAEvF,GAAK,IAGXN,cAAgBE,OAAOiG,QAAU5F,KAAKC,SAAW,IACjDN,OAAOC,KAAK,CACRC,EAAGC,iBACHC,GAAI,GACJG,EAAmB,EAAhBF,KAAKC,SAAe,EACvBE,EAAGH,KAAKC,SAAW,IA0B3B+F"} \ No newline at end of file diff --git a/amd/src/menu.js b/amd/src/menu.js index 02c94d8..2782f23 100644 --- a/amd/src/menu.js +++ b/amd/src/menu.js @@ -42,11 +42,13 @@ function initThemeChooser() { const uselighttheme = $('#user-menu .wwu-uselighttheme'); const useostheme = $('#user-menu .wwu-useostheme'); const usedarktheme = $('#user-menu .wwu-usedarktheme'); + const darkThemeClass = 'dark-theme'; + const lightThemeClass = 'light-theme'; let selected; - if (html.hasClass('dark')) { + if (html.hasClass(darkThemeClass)) { selected = usedarktheme; - } else if (html.hasClass('light')) { + } else if (html.hasClass(lightThemeClass)) { selected = uselighttheme; } else { selected = useostheme; @@ -55,24 +57,24 @@ function initThemeChooser() { uselighttheme.click(function() { selected.removeClass('selectedtheme'); - html.removeClass('dark'); - html.addClass('light'); + html.removeClass(darkThemeClass); + html.addClass(lightThemeClass); updateThemePreferenceAjax(1); selected = uselighttheme; selected.addClass('selectedtheme'); }); useostheme.click(function() { selected.removeClass('selectedtheme'); - html.removeClass('dark'); - html.removeClass('light'); + html.removeClass(darkThemeClass); + html.removeClass(lightThemeClass); updateThemePreferenceAjax(null); selected = useostheme; selected.addClass('selectedtheme'); }); usedarktheme.click(function() { selected.removeClass('selectedtheme'); - html.addClass('dark'); - html.removeClass('light'); + html.addClass(darkThemeClass); + html.removeClass(lightThemeClass); updateThemePreferenceAjax(2); selected = usedarktheme; selected.addClass('selectedtheme'); diff --git a/amd/src/snow.js b/amd/src/snow.js index d4a46b5..0a41ae3 100644 --- a/amd/src/snow.js +++ b/amd/src/snow.js @@ -23,6 +23,7 @@ import $ from 'jquery'; import Ajax from 'core/ajax'; +import Notification from 'core/notification'; let canvas; diff --git a/classes/output/core_renderer.php b/classes/output/core_renderer.php index 1127315..a9d1c83 100644 --- a/classes/output/core_renderer.php +++ b/classes/output/core_renderer.php @@ -1395,15 +1395,15 @@ public function htmlattributes() { if (get_config('theme_wwu2019', 'darktheme_enabled') == '1') { $themepreference = get_user_preferences('theme_wwu2019_theme'); if ($themepreference == 1) { - return parent::htmlattributes() . 'class="light"'; + return parent::htmlattributes() . 'class="light-theme"'; } else if ($themepreference == 2) { - return parent::htmlattributes() . 'class="dark"'; + return parent::htmlattributes() . 'class="dark-theme"'; } else { // Use system setting. return parent::htmlattributes(); } } else { - return parent::htmlattributes() . 'class="light"'; + return parent::htmlattributes() . 'class="light-theme"'; } } diff --git a/scss/wwu2019/theming.scss b/scss/wwu2019/theming.scss index 87f2c9f..c4b1143 100644 --- a/scss/wwu2019/theming.scss +++ b/scss/wwu2019/theming.scss @@ -234,7 +234,7 @@ thead th, th, - td{ + td { border-color: var(--wwu-bg-3); } } @@ -281,7 +281,7 @@ color: var(--wwu-fg); } - &> img.icon { + & > img.icon { filter: invert(1); } } @@ -491,7 +491,6 @@ } - .path-grade-report-singleview div.reporttable, .path-grade-report-user .user-report-container, .grade-report-user .user-report-container, @@ -646,7 +645,7 @@ #page-question-type-match div[id^="fitem_id_"] { &[id*="subquestions_"], - &[id*="subanswers_"]{ + &[id*="subanswers_"] { background-color: var(--wwu-bg-1); border-color: var(--wwu-bg-5); } @@ -672,7 +671,7 @@ #page-question-type-match div[id^="fitem_id_"] { &[id*="subanswers_"], - &[id*="subquestions_"]{ + &[id*="subquestions_"] { background-color: var(--wwu-bg-1); border-color: var(--wwu-bg-5); } @@ -736,21 +735,21 @@ .block_accessreview_success, .block_accessreview.block_accessreview_success.hasinfo { color: var(--wwu-success-fg); - background:var(--wwu-success-bg); + background: var(--wwu-success-bg); border-color: var(--wwu-success-border); } .block_accessreview_danger, .block_accessreview.block_accessreview_danger.hasinfo { color: var(--wwu-error-fg); - background:var(--wwu-error-bg); + background: var(--wwu-error-bg); border-color: var(--wwu-error-border); } .block_accessreview_warning, .block_accessreview.block_accessreview_warning.hasinfo { color: var(--wwu-warn-fg); - background:var(--wwu-warn-bg); + background: var(--wwu-warn-bg); border-color: var(--wwu-warn-border); } @@ -855,7 +854,7 @@ #plugins-check-page .pluginupdateinfo, #plugins-control-panel .pluginupdateinfo { - background-color:var(--wwu-info-bg); + background-color: var(--wwu-info-bg); } /* block_xp */ @@ -1015,6 +1014,7 @@ .yui3-skin-sam .yui3-datatable-even .yui3-datatable-cell { background: var(--wwu-bg); + &.yui3-datatable-sorted { background: var(--wwu-bg-1); } @@ -1022,6 +1022,7 @@ .yui3-skin-sam .yui3-datatable-odd .yui3-datatable-cell { background: var(--wwu-bg-1); + &.yui3-datatable-sorted { background: var(--wwu-bg-2); } @@ -1071,6 +1072,18 @@ .bg-secondary.text-dark { color: white !important; } + + // mod_margic + .margic_entry .ratingform { + background-color: var(--wwu-bg-3) !important; + } + + // mod_mootimeter + .mootimetercontainer .mootimetercolpages { + background-color: #00091e; + } + + } @@ -1115,18 +1128,23 @@ @include light-colors; color-scheme: light dark; - &.dark { + &.dark-theme { @include dark-colors; color-scheme: dark; } - &.light { + &.light-theme { color-scheme: light; } } @media (prefers-color-scheme: dark) { - :root:not(.light) { + :root:not(.light-theme) { @include dark-colors; } } + +.mootimetercontainer { + @include light-colors; + color: var(--wwu-fg); +} From 8d1969fc6d8f758e8600d894eb51589c253e31d4 Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Thu, 5 Sep 2024 15:16:40 +0200 Subject: [PATCH 17/19] Make hamburger toggle right size in 4.4 --- scss/wwu2019/menu.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scss/wwu2019/menu.scss b/scss/wwu2019/menu.scss index 26c34ad..1712a05 100644 --- a/scss/wwu2019/menu.scss +++ b/scss/wwu2019/menu.scss @@ -396,6 +396,8 @@ ul.main-menubar { color: white; background: $learnwebblue; cursor: pointer; + max-width: unset; + max-height: unset; } #main-menu-left { From cadb5e2416b20580534e0173fa12a94bdb64f1eb Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Thu, 5 Sep 2024 15:24:44 +0200 Subject: [PATCH 18/19] Fix wrapping of marketing boxes on mobile --- scss/wwu2019/marketingboxes.scss | 13 ++++--------- templates/frontpage.mustache | 6 +++--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/scss/wwu2019/marketingboxes.scss b/scss/wwu2019/marketingboxes.scss index 7e15e52..d0a5fac 100644 --- a/scss/wwu2019/marketingboxes.scss +++ b/scss/wwu2019/marketingboxes.scss @@ -26,22 +26,17 @@ padding: 0; } +#region-marketing > div { + gap: 10px; +} + #region-marketing .block.card { padding: 0; } #region-marketing .block.card { padding: 0; - margin-left: 5px; - margin-right: 5px; flex: 1 1 calc(33.333% - 40px); - &:first-child { - margin-left: 0; - } - - &:last-child { - margin-right: 0; - } } @media (max-width: $onecolumn-break-point) { diff --git a/templates/frontpage.mustache b/templates/frontpage.mustache index a1a3f71..aa32313 100644 --- a/templates/frontpage.mustache +++ b/templates/frontpage.mustache @@ -80,10 +80,10 @@
{{/isexamweb}} -
-
+
+
{{#marketingboxes}} -
+
{{! Block header }}
From 10b5a442b826c1895aa7052b158d86a177f94566 Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Thu, 12 Sep 2024 12:12:03 +0200 Subject: [PATCH 19/19] Use new core_user/repository for user preference ajax --- amd/build/menu.min.js | 4 ++-- amd/build/menu.min.js.map | 2 +- amd/build/snow.min.js | 4 ++-- amd/build/snow.min.js.map | 2 +- amd/src/menu.js | 16 +++------------- amd/src/snow.js | 18 ++++-------------- classes/layout.php | 1 - 7 files changed, 13 insertions(+), 34 deletions(-) diff --git a/amd/build/menu.min.js b/amd/build/menu.min.js index 27631b8..4ff8a5c 100644 --- a/amd/build/menu.min.js +++ b/amd/build/menu.min.js @@ -1,10 +1,10 @@ -define("theme_wwu2019/menu",["exports","jquery","core/ajax","core/notification"],(function(_exports,_jquery,_ajax,_notification){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} +define("theme_wwu2019/menu",["exports","jquery","core/notification","../../../../user/amd/src/repository"],(function(_exports,_jquery,_notification,_repository){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} /** * Manage the user menu. * * @module theme_wwu2019/menu * @copyright 2019 Justus Dieckmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */function updateThemePreferenceAjax(theme){var request={methodname:"core_user_update_user_preferences",args:{preferences:[{type:"theme_wwu2019_theme",value:theme}]}};_ajax.default.call([request])[0].fail(_notification.default.exception)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){(function(){const openDelay=100,closeDelay=300,closeCooldown=300;let openMenu=null,openCandidate=null,openTimeoutId=null,closeTimeoutId=null,openTime=null;function open(menuItem){openMenu&&close(openMenu),abortClose(),(0,_jquery.default)(menuItem).addClass("open"),(0,_jquery.default)(menuItem).children("a").attr("aria-expanded","true"),openMenu=menuItem,openCandidate=null,openTimeoutId=null}function openWithDelay(menuItem){openCandidate=menuItem,openTimeoutId=setTimeout((()=>{open(menuItem),openTime=new Date}),openDelay)}function close(menuItem){(0,_jquery.default)(menuItem).removeClass("open"),(0,_jquery.default)(menuItem).children("a").attr("aria-expanded","false"),openMenu=null,abortClose(),openTime=null}function closeWithDelay(menuItem){closeTimeoutId=setTimeout(close,closeDelay,menuItem)}function abortClose(){closeTimeoutId&&(clearTimeout(closeTimeoutId),closeTimeoutId=null)}function abortOpen(){openCandidate=null,openTimeoutId&&(clearTimeout(openTimeoutId),openTimeoutId=null)}function reset(){abortClose(),abortOpen(),openMenu&&close(openMenu)}(0,_jquery.default)('li.main-menu-item > a[aria-haspopup="true"], li#user-menu > a[aria-haspopup="true"]').click((ev=>{ev.currentTarget.parentNode===openMenu?new Date-openTime>closeCooldown&&close(openMenu):open(ev.currentTarget.parentNode)}));let menuitems=(0,_jquery.default)('li.main-menu-item > a[aria-haspopup="true"], li#user-menu > a[aria-haspopup="true"]').parent();menuitems.mouseenter((ev=>{(window.innerWidth>0?window.innerWidth:screen.width)>767&&(ev.currentTarget===openMenu?abortClose():openWithDelay(ev.currentTarget))})),menuitems.mouseleave((ev=>{(window.innerWidth>0?window.innerWidth:screen.width)>767&&(openCandidate&&ev.currentTarget===openCandidate&&abortOpen(),openMenu&&ev.currentTarget===openMenu&&closeWithDelay(ev.currentTarget))})),(0,_jquery.default)('li.sub-menu-item > a[aria-haspopup="true"], li.sub-sub-menu-item > a[aria-haspopup="true"]').click((ev=>{let link=(0,_jquery.default)(ev.currentTarget),item=link.parent();item.toggleClass("open"),link.attr("aria-expanded",item.hasClass("open"))}));let hamburgertoggle=(0,_jquery.default)("#main-menu-hamburger > a"),hamburgerparent=hamburgertoggle.parent();hamburgertoggle.click((()=>{hamburgerparent.toggleClass("open"),hamburgertoggle.attr("aria-expanded",hamburgerparent.hasClass("open"))}));let oneColLayoutBefore=!1,hamburgerLayoutBefore=!1;function updateMaxMenuHeight(){let botPos=(0,_jquery.default)("#menu-bottom").offset().top+16,width=window.innerWidth>0?window.innerWidth:screen.width,oneColLayout=width<=767;oneColLayout?((0,_jquery.default)(".sub-menu-scroll-container").css("max-height",""),(0,_jquery.default)("#main-menu-left").css("max-height",(0,_jquery.default)(window).height()-botPos+"px")):(width<=1080&&(botPos+=50),(0,_jquery.default)(".sub-menu-scroll-container").css("max-height",(0,_jquery.default)(window).height()-botPos+"px"),(0,_jquery.default)("#main-menu-left").css("max-height","")),oneColLayout!==oneColLayoutBefore&&(reset(),oneColLayoutBefore=oneColLayout);let hamburgerLayout=width<=1080;hamburgerLayout!==hamburgerLayoutBefore&&(hamburgertoggle.attr("role",hamburgerLayout?"button":"none"),hamburgerLayoutBefore=hamburgerLayout)}updateMaxMenuHeight(),(0,_jquery.default)(window).resize(updateMaxMenuHeight)})(),function(){const html=(0,_jquery.default)("html"),uselighttheme=(0,_jquery.default)("#user-menu .wwu-uselighttheme"),useostheme=(0,_jquery.default)("#user-menu .wwu-useostheme"),usedarktheme=(0,_jquery.default)("#user-menu .wwu-usedarktheme"),darkThemeClass="dark-theme",lightThemeClass="light-theme";let selected;selected=html.hasClass(darkThemeClass)?usedarktheme:html.hasClass(lightThemeClass)?uselighttheme:useostheme;selected.addClass("selectedtheme"),uselighttheme.click((function(){selected.removeClass("selectedtheme"),html.removeClass(darkThemeClass),html.addClass(lightThemeClass),updateThemePreferenceAjax(1),selected=uselighttheme,selected.addClass("selectedtheme")})),useostheme.click((function(){selected.removeClass("selectedtheme"),html.removeClass(darkThemeClass),html.removeClass(lightThemeClass),updateThemePreferenceAjax(null),selected=useostheme,selected.addClass("selectedtheme")})),usedarktheme.click((function(){selected.removeClass("selectedtheme"),html.addClass(darkThemeClass),html.removeClass(lightThemeClass),updateThemePreferenceAjax(2),selected=usedarktheme,selected.addClass("selectedtheme")}))}()},_jquery=_interopRequireDefault(_jquery),_ajax=_interopRequireDefault(_ajax),_notification=_interopRequireDefault(_notification)})); + */function updateThemePreferenceAjax(theme){(0,_repository.setUserPreference)("theme_wwu2019_theme",theme).catch(_notification.default.exception)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){(function(){const openDelay=100,closeDelay=300,closeCooldown=300;let openMenu=null,openCandidate=null,openTimeoutId=null,closeTimeoutId=null,openTime=null;function open(menuItem){openMenu&&close(openMenu),abortClose(),(0,_jquery.default)(menuItem).addClass("open"),(0,_jquery.default)(menuItem).children("a").attr("aria-expanded","true"),openMenu=menuItem,openCandidate=null,openTimeoutId=null}function openWithDelay(menuItem){openCandidate=menuItem,openTimeoutId=setTimeout((()=>{open(menuItem),openTime=new Date}),openDelay)}function close(menuItem){(0,_jquery.default)(menuItem).removeClass("open"),(0,_jquery.default)(menuItem).children("a").attr("aria-expanded","false"),openMenu=null,abortClose(),openTime=null}function closeWithDelay(menuItem){closeTimeoutId=setTimeout(close,closeDelay,menuItem)}function abortClose(){closeTimeoutId&&(clearTimeout(closeTimeoutId),closeTimeoutId=null)}function abortOpen(){openCandidate=null,openTimeoutId&&(clearTimeout(openTimeoutId),openTimeoutId=null)}function reset(){abortClose(),abortOpen(),openMenu&&close(openMenu)}(0,_jquery.default)('li.main-menu-item > a[aria-haspopup="true"], li#user-menu > a[aria-haspopup="true"]').click((ev=>{ev.currentTarget.parentNode===openMenu?new Date-openTime>closeCooldown&&close(openMenu):open(ev.currentTarget.parentNode)}));let menuitems=(0,_jquery.default)('li.main-menu-item > a[aria-haspopup="true"], li#user-menu > a[aria-haspopup="true"]').parent();menuitems.mouseenter((ev=>{(window.innerWidth>0?window.innerWidth:screen.width)>767&&(ev.currentTarget===openMenu?abortClose():openWithDelay(ev.currentTarget))})),menuitems.mouseleave((ev=>{(window.innerWidth>0?window.innerWidth:screen.width)>767&&(openCandidate&&ev.currentTarget===openCandidate&&abortOpen(),openMenu&&ev.currentTarget===openMenu&&closeWithDelay(ev.currentTarget))})),(0,_jquery.default)('li.sub-menu-item > a[aria-haspopup="true"], li.sub-sub-menu-item > a[aria-haspopup="true"]').click((ev=>{let link=(0,_jquery.default)(ev.currentTarget),item=link.parent();item.toggleClass("open"),link.attr("aria-expanded",item.hasClass("open"))}));let hamburgertoggle=(0,_jquery.default)("#main-menu-hamburger > a"),hamburgerparent=hamburgertoggle.parent();hamburgertoggle.click((()=>{hamburgerparent.toggleClass("open"),hamburgertoggle.attr("aria-expanded",hamburgerparent.hasClass("open"))}));let oneColLayoutBefore=!1,hamburgerLayoutBefore=!1;function updateMaxMenuHeight(){let botPos=(0,_jquery.default)("#menu-bottom").offset().top+16,width=window.innerWidth>0?window.innerWidth:screen.width,oneColLayout=width<=767;oneColLayout?((0,_jquery.default)(".sub-menu-scroll-container").css("max-height",""),(0,_jquery.default)("#main-menu-left").css("max-height",(0,_jquery.default)(window).height()-botPos+"px")):(width<=1080&&(botPos+=50),(0,_jquery.default)(".sub-menu-scroll-container").css("max-height",(0,_jquery.default)(window).height()-botPos+"px"),(0,_jquery.default)("#main-menu-left").css("max-height","")),oneColLayout!==oneColLayoutBefore&&(reset(),oneColLayoutBefore=oneColLayout);let hamburgerLayout=width<=1080;hamburgerLayout!==hamburgerLayoutBefore&&(hamburgertoggle.attr("role",hamburgerLayout?"button":"none"),hamburgerLayoutBefore=hamburgerLayout)}updateMaxMenuHeight(),(0,_jquery.default)(window).resize(updateMaxMenuHeight)})(),function(){const html=(0,_jquery.default)("html"),uselighttheme=(0,_jquery.default)("#user-menu .wwu-uselighttheme"),useostheme=(0,_jquery.default)("#user-menu .wwu-useostheme"),usedarktheme=(0,_jquery.default)("#user-menu .wwu-usedarktheme"),darkThemeClass="dark-theme",lightThemeClass="light-theme";let selected;selected=html.hasClass(darkThemeClass)?usedarktheme:html.hasClass(lightThemeClass)?uselighttheme:useostheme;selected.addClass("selectedtheme"),uselighttheme.click((function(){selected.removeClass("selectedtheme"),html.removeClass(darkThemeClass),html.addClass(lightThemeClass),updateThemePreferenceAjax(1),selected=uselighttheme,selected.addClass("selectedtheme")})),useostheme.click((function(){selected.removeClass("selectedtheme"),html.removeClass(darkThemeClass),html.removeClass(lightThemeClass),updateThemePreferenceAjax(null),selected=useostheme,selected.addClass("selectedtheme")})),usedarktheme.click((function(){selected.removeClass("selectedtheme"),html.addClass(darkThemeClass),html.removeClass(lightThemeClass),updateThemePreferenceAjax(2),selected=usedarktheme,selected.addClass("selectedtheme")}))}()},_jquery=_interopRequireDefault(_jquery),_notification=_interopRequireDefault(_notification)})); //# sourceMappingURL=menu.min.js.map \ No newline at end of file diff --git a/amd/build/menu.min.js.map b/amd/build/menu.min.js.map index 7168dc2..b7c79ea 100644 --- a/amd/build/menu.min.js.map +++ b/amd/build/menu.min.js.map @@ -1 +1 @@ -{"version":3,"file":"menu.min.js","sources":["../src/menu.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Manage the user menu.\n *\n * @module theme_wwu2019/menu\n * @copyright 2019 Justus Dieckmann WWU\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\n\n/**\n * Init function\n */\nexport function init() {\n openMenu();\n initThemeChooser();\n}\n\n\n/**\n * Initializes the theme chooser.\n */\nfunction initThemeChooser() {\n const html = $('html');\n const uselighttheme = $('#user-menu .wwu-uselighttheme');\n const useostheme = $('#user-menu .wwu-useostheme');\n const usedarktheme = $('#user-menu .wwu-usedarktheme');\n const darkThemeClass = 'dark-theme';\n const lightThemeClass = 'light-theme';\n\n let selected;\n if (html.hasClass(darkThemeClass)) {\n selected = usedarktheme;\n } else if (html.hasClass(lightThemeClass)) {\n selected = uselighttheme;\n } else {\n selected = useostheme;\n }\n selected.addClass('selectedtheme');\n\n uselighttheme.click(function() {\n selected.removeClass('selectedtheme');\n html.removeClass(darkThemeClass);\n html.addClass(lightThemeClass);\n updateThemePreferenceAjax(1);\n selected = uselighttheme;\n selected.addClass('selectedtheme');\n });\n useostheme.click(function() {\n selected.removeClass('selectedtheme');\n html.removeClass(darkThemeClass);\n html.removeClass(lightThemeClass);\n updateThemePreferenceAjax(null);\n selected = useostheme;\n selected.addClass('selectedtheme');\n });\n usedarktheme.click(function() {\n selected.removeClass('selectedtheme');\n html.addClass(darkThemeClass);\n html.removeClass(lightThemeClass);\n updateThemePreferenceAjax(2);\n selected = usedarktheme;\n selected.addClass('selectedtheme');\n });\n}\n\n/**\n * Updates the theme preference.\n * @param {int} theme\n */\nfunction updateThemePreferenceAjax(theme) {\n var request = {\n methodname: 'core_user_update_user_preferences',\n args: {\n preferences: [{\n type: 'theme_wwu2019_theme',\n value: theme\n }]\n }\n };\n\n Ajax.call([request])[0]\n .fail(Notification.exception);\n}\n\nconst onecolumnbreakpoint = 767;\nconst hamburgerbreakpoint = 1080;\n\n\n/**\n * Opens submenu when hovering\n */\nfunction openMenu() {\n const openDelay = 100;\n const closeDelay = 300;\n const closeCooldown = 300;\n\n let openMenu = null;\n let openCandidate = null;\n let openTimeoutId = null;\n let closeTimeoutId = null;\n /** @type {null|Date} Date when menu was opened by hovering, to prevent immediately closing it by clicking again. */\n let openTime = null;\n\n /**\n * Opens a menu.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function open(menuItem) {\n if (openMenu) {\n close(openMenu);\n }\n abortClose();\n $(menuItem).addClass('open');\n $(menuItem).children('a').attr('aria-expanded', 'true');\n openMenu = menuItem;\n openCandidate = null;\n openTimeoutId = null;\n }\n\n /**\n * Opens a menu with delay.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function openWithDelay(menuItem) {\n openCandidate = menuItem;\n openTimeoutId = setTimeout(() => {\n open(menuItem);\n openTime = new Date();\n }, openDelay);\n }\n\n /**\n * Closes a menu.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function close(menuItem) {\n $(menuItem).removeClass('open');\n $(menuItem).children('a').attr('aria-expanded', 'false');\n openMenu = null;\n abortClose();\n openTime = null;\n }\n\n /**\n * Closes a menu with delay.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function closeWithDelay(menuItem) {\n closeTimeoutId = setTimeout(close, closeDelay, menuItem);\n }\n\n /**\n * Aborts the delayed closing of {@link openMenu}\n */\n function abortClose() {\n if (closeTimeoutId) {\n clearTimeout(closeTimeoutId);\n closeTimeoutId = null;\n }\n }\n\n /**\n * Aborts the delayed opening of {@link openCandidate}\n */\n function abortOpen() {\n openCandidate = null;\n if (openTimeoutId) {\n clearTimeout(openTimeoutId);\n openTimeoutId = null;\n }\n }\n\n /**\n * Closes the open menu and resets timeouts;\n */\n function reset() {\n abortClose();\n abortOpen();\n if (openMenu) {\n close(openMenu);\n }\n }\n\n $('li.main-menu-item > a[aria-haspopup=\"true\"], li#user-menu > a[aria-haspopup=\"true\"]').click((ev) => {\n if (ev.currentTarget.parentNode === openMenu) {\n if (new Date() - openTime > closeCooldown) {\n close(openMenu);\n }\n } else {\n open(ev.currentTarget.parentNode);\n }\n });\n\n let menuitems = $('li.main-menu-item > a[aria-haspopup=\"true\"], li#user-menu > a[aria-haspopup=\"true\"]').parent();\n menuitems.mouseenter((ev) => {\n let width = (window.innerWidth > 0) ? window.innerWidth : screen.width;\n if (width > onecolumnbreakpoint) {\n if (ev.currentTarget === openMenu) {\n abortClose();\n } else {\n openWithDelay(ev.currentTarget);\n }\n }\n });\n menuitems.mouseleave((ev) => {\n let width = (window.innerWidth > 0) ? window.innerWidth : screen.width;\n if (width > onecolumnbreakpoint) {\n if (openCandidate && ev.currentTarget === openCandidate) {\n abortOpen();\n }\n if (openMenu && ev.currentTarget === openMenu) {\n closeWithDelay(ev.currentTarget);\n }\n }\n });\n\n $('li.sub-menu-item > a[aria-haspopup=\"true\"], li.sub-sub-menu-item > a[aria-haspopup=\"true\"]').click((ev) => {\n let link = $(ev.currentTarget);\n let item = link.parent();\n item.toggleClass('open');\n link.attr('aria-expanded', item.hasClass('open'));\n });\n\n let hamburgertoggle = $('#main-menu-hamburger > a');\n let hamburgerparent = hamburgertoggle.parent();\n hamburgertoggle.click(() => {\n hamburgerparent.toggleClass('open');\n hamburgertoggle.attr('aria-expanded', hamburgerparent.hasClass('open'));\n });\n\n let oneColLayoutBefore = false;\n let hamburgerLayoutBefore = false;\n\n /**\n * Updates max-height of submenus on page-init and window resize.\n */\n function updateMaxMenuHeight() {\n const menuButtom = $('#menu-bottom');\n let botPos = menuButtom.offset().top + 16;\n let width = (window.innerWidth > 0) ? window.innerWidth : screen.width;\n let oneColLayout = width <= onecolumnbreakpoint;\n if (oneColLayout) {\n $('.sub-menu-scroll-container').css('max-height', '');\n $('#main-menu-left').css('max-height', ($(window).height() - botPos) + 'px');\n } else {\n // If Menu is expanded down, add the height of the #main-menu-left container\n if (width <= hamburgerbreakpoint) {\n botPos += 50;\n }\n $('.sub-menu-scroll-container').css('max-height', ($(window).height() - botPos) + 'px');\n $('#main-menu-left').css('max-height', '');\n }\n if (oneColLayout !== oneColLayoutBefore) {\n reset();\n oneColLayoutBefore = oneColLayout;\n }\n\n // Switch hamburger toggle role between button and none, based on whether it is hidden.\n let hamburgerLayout = width <= hamburgerbreakpoint;\n if (hamburgerLayout !== hamburgerLayoutBefore) {\n hamburgertoggle.attr('role', hamburgerLayout ? 'button' : 'none');\n hamburgerLayoutBefore = hamburgerLayout;\n }\n }\n\n updateMaxMenuHeight();\n $(window).resize(updateMaxMenuHeight);\n}\n"],"names":["updateThemePreferenceAjax","theme","request","methodname","args","preferences","type","value","call","fail","Notification","exception","openDelay","closeDelay","closeCooldown","openMenu","openCandidate","openTimeoutId","closeTimeoutId","openTime","open","menuItem","close","abortClose","addClass","children","attr","openWithDelay","setTimeout","Date","removeClass","closeWithDelay","clearTimeout","abortOpen","reset","click","ev","currentTarget","parentNode","menuitems","parent","mouseenter","window","innerWidth","screen","width","mouseleave","link","item","toggleClass","hasClass","hamburgertoggle","hamburgerparent","oneColLayoutBefore","hamburgerLayoutBefore","updateMaxMenuHeight","botPos","offset","top","oneColLayout","css","height","hamburgerLayout","resize","html","uselighttheme","useostheme","usedarktheme","darkThemeClass","lightThemeClass","selected","initThemeChooser"],"mappings":";;;;;;;cAuFSA,0BAA0BC,WAC3BC,QAAU,CACVC,WAAY,oCACZC,KAAM,CACFC,YAAa,CAAC,CACVC,KAAM,sBACNC,MAAON,wBAKdO,KAAK,CAACN,UAAU,GAChBO,KAAKC,sBAAaC,8GAWjBC,UAAY,IACZC,WAAa,IACbC,cAAgB,QAElBC,SAAW,KACXC,cAAgB,KAChBC,cAAgB,KAChBC,eAAiB,KAEjBC,SAAW,cAMNC,KAAKC,UACNN,UACAO,MAAMP,UAEVQ,iCACEF,UAAUG,SAAS,4BACnBH,UAAUI,SAAS,KAAKC,KAAK,gBAAiB,QAChDX,SAAWM,SACXL,cAAgB,KAChBC,cAAgB,cAOXU,cAAcN,UACnBL,cAAgBK,SAChBJ,cAAgBW,YAAW,KACvBR,KAAKC,UACLF,SAAW,IAAIU,OAChBjB,oBAOEU,MAAMD,8BACTA,UAAUS,YAAY,4BACtBT,UAAUI,SAAS,KAAKC,KAAK,gBAAiB,SAChDX,SAAW,KACXQ,aACAJ,SAAW,cAONY,eAAeV,UACpBH,eAAiBU,WAAWN,MAAOT,WAAYQ,mBAM1CE,aACDL,iBACAc,aAAad,gBACbA,eAAiB,eAOhBe,YACLjB,cAAgB,KACZC,gBACAe,aAAaf,eACbA,cAAgB,eAOfiB,QACLX,aACAU,YACIlB,UACAO,MAAMP,8BAI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AAoBR,wBACpBH,gBAAgBzB,KAAK,OAAQoC,gBAAkB,SAAW,QAC1DR,sBAAwBQ,iBAIhCP,0CACEb,QAAQqB,OAAOR,sBA7PjBxC,oBASMiD,MAAO,mBAAE,QACTC,eAAgB,mBAAE,iCAClBC,YAAa,mBAAE,8BACfC,cAAe,mBAAE,gCACjBC,eAAiB,aACjBC,gBAAkB,kBAEpBC,SAEAA,SADAN,KAAKd,SAASkB,gBACHD,aACJH,KAAKd,SAASmB,iBACVJ,cAEAC,WAEfI,SAAS9C,SAAS,iBAElByC,cAAc9B,OAAM,WAChBmC,SAASxC,YAAY,iBACrBkC,KAAKlC,YAAYsC,gBACjBJ,KAAKxC,SAAS6C,iBACdrE,0BAA0B,GAC1BsE,SAAWL,cACXK,SAAS9C,SAAS,oBAEtB0C,WAAW/B,OAAM,WACbmC,SAASxC,YAAY,iBACrBkC,KAAKlC,YAAYsC,gBACjBJ,KAAKlC,YAAYuC,iBACjBrE,0BAA0B,MAC1BsE,SAAWJ,WACXI,SAAS9C,SAAS,oBAEtB2C,aAAahC,OAAM,WACfmC,SAASxC,YAAY,iBACrBkC,KAAKxC,SAAS4C,gBACdJ,KAAKlC,YAAYuC,iBACjBrE,0BAA0B,GAC1BsE,SAAWH,aACXG,SAAS9C,SAAS,oBA/CtB+C"} \ No newline at end of file +{"version":3,"file":"menu.min.js","sources":["../src/menu.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Manage the user menu.\n *\n * @module theme_wwu2019/menu\n * @copyright 2019 Justus Dieckmann WWU\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Notification from 'core/notification';\nimport {setUserPreference} from \"../../../../user/amd/src/repository\";\n\n/**\n * Init function\n */\nexport function init() {\n openMenu();\n initThemeChooser();\n}\n\n\n/**\n * Initializes the theme chooser.\n */\nfunction initThemeChooser() {\n const html = $('html');\n const uselighttheme = $('#user-menu .wwu-uselighttheme');\n const useostheme = $('#user-menu .wwu-useostheme');\n const usedarktheme = $('#user-menu .wwu-usedarktheme');\n const darkThemeClass = 'dark-theme';\n const lightThemeClass = 'light-theme';\n\n let selected;\n if (html.hasClass(darkThemeClass)) {\n selected = usedarktheme;\n } else if (html.hasClass(lightThemeClass)) {\n selected = uselighttheme;\n } else {\n selected = useostheme;\n }\n selected.addClass('selectedtheme');\n\n uselighttheme.click(function() {\n selected.removeClass('selectedtheme');\n html.removeClass(darkThemeClass);\n html.addClass(lightThemeClass);\n updateThemePreferenceAjax(1);\n selected = uselighttheme;\n selected.addClass('selectedtheme');\n });\n useostheme.click(function() {\n selected.removeClass('selectedtheme');\n html.removeClass(darkThemeClass);\n html.removeClass(lightThemeClass);\n updateThemePreferenceAjax(null);\n selected = useostheme;\n selected.addClass('selectedtheme');\n });\n usedarktheme.click(function() {\n selected.removeClass('selectedtheme');\n html.addClass(darkThemeClass);\n html.removeClass(lightThemeClass);\n updateThemePreferenceAjax(2);\n selected = usedarktheme;\n selected.addClass('selectedtheme');\n });\n}\n\n/**\n * Updates the theme preference.\n * @param {int} theme\n */\nfunction updateThemePreferenceAjax(theme) {\n setUserPreference('theme_wwu2019_theme', theme)\n .catch(Notification.exception);\n}\n\nconst onecolumnbreakpoint = 767;\nconst hamburgerbreakpoint = 1080;\n\n\n/**\n * Opens submenu when hovering\n */\nfunction openMenu() {\n const openDelay = 100;\n const closeDelay = 300;\n const closeCooldown = 300;\n\n let openMenu = null;\n let openCandidate = null;\n let openTimeoutId = null;\n let closeTimeoutId = null;\n /** @type {null|Date} Date when menu was opened by hovering, to prevent immediately closing it by clicking again. */\n let openTime = null;\n\n /**\n * Opens a menu.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function open(menuItem) {\n if (openMenu) {\n close(openMenu);\n }\n abortClose();\n $(menuItem).addClass('open');\n $(menuItem).children('a').attr('aria-expanded', 'true');\n openMenu = menuItem;\n openCandidate = null;\n openTimeoutId = null;\n }\n\n /**\n * Opens a menu with delay.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function openWithDelay(menuItem) {\n openCandidate = menuItem;\n openTimeoutId = setTimeout(() => {\n open(menuItem);\n openTime = new Date();\n }, openDelay);\n }\n\n /**\n * Closes a menu.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function close(menuItem) {\n $(menuItem).removeClass('open');\n $(menuItem).children('a').attr('aria-expanded', 'false');\n openMenu = null;\n abortClose();\n openTime = null;\n }\n\n /**\n * Closes a menu with delay.\n * @param {Node} menuItem the menuItem DOM-Element\n */\n function closeWithDelay(menuItem) {\n closeTimeoutId = setTimeout(close, closeDelay, menuItem);\n }\n\n /**\n * Aborts the delayed closing of {@link openMenu}\n */\n function abortClose() {\n if (closeTimeoutId) {\n clearTimeout(closeTimeoutId);\n closeTimeoutId = null;\n }\n }\n\n /**\n * Aborts the delayed opening of {@link openCandidate}\n */\n function abortOpen() {\n openCandidate = null;\n if (openTimeoutId) {\n clearTimeout(openTimeoutId);\n openTimeoutId = null;\n }\n }\n\n /**\n * Closes the open menu and resets timeouts;\n */\n function reset() {\n abortClose();\n abortOpen();\n if (openMenu) {\n close(openMenu);\n }\n }\n\n $('li.main-menu-item > a[aria-haspopup=\"true\"], li#user-menu > a[aria-haspopup=\"true\"]').click((ev) => {\n if (ev.currentTarget.parentNode === openMenu) {\n if (new Date() - openTime > closeCooldown) {\n close(openMenu);\n }\n } else {\n open(ev.currentTarget.parentNode);\n }\n });\n\n let menuitems = $('li.main-menu-item > a[aria-haspopup=\"true\"], li#user-menu > a[aria-haspopup=\"true\"]').parent();\n menuitems.mouseenter((ev) => {\n let width = (window.innerWidth > 0) ? window.innerWidth : screen.width;\n if (width > onecolumnbreakpoint) {\n if (ev.currentTarget === openMenu) {\n abortClose();\n } else {\n openWithDelay(ev.currentTarget);\n }\n }\n });\n menuitems.mouseleave((ev) => {\n let width = (window.innerWidth > 0) ? window.innerWidth : screen.width;\n if (width > onecolumnbreakpoint) {\n if (openCandidate && ev.currentTarget === openCandidate) {\n abortOpen();\n }\n if (openMenu && ev.currentTarget === openMenu) {\n closeWithDelay(ev.currentTarget);\n }\n }\n });\n\n $('li.sub-menu-item > a[aria-haspopup=\"true\"], li.sub-sub-menu-item > a[aria-haspopup=\"true\"]').click((ev) => {\n let link = $(ev.currentTarget);\n let item = link.parent();\n item.toggleClass('open');\n link.attr('aria-expanded', item.hasClass('open'));\n });\n\n let hamburgertoggle = $('#main-menu-hamburger > a');\n let hamburgerparent = hamburgertoggle.parent();\n hamburgertoggle.click(() => {\n hamburgerparent.toggleClass('open');\n hamburgertoggle.attr('aria-expanded', hamburgerparent.hasClass('open'));\n });\n\n let oneColLayoutBefore = false;\n let hamburgerLayoutBefore = false;\n\n /**\n * Updates max-height of submenus on page-init and window resize.\n */\n function updateMaxMenuHeight() {\n const menuButtom = $('#menu-bottom');\n let botPos = menuButtom.offset().top + 16;\n let width = (window.innerWidth > 0) ? window.innerWidth : screen.width;\n let oneColLayout = width <= onecolumnbreakpoint;\n if (oneColLayout) {\n $('.sub-menu-scroll-container').css('max-height', '');\n $('#main-menu-left').css('max-height', ($(window).height() - botPos) + 'px');\n } else {\n // If Menu is expanded down, add the height of the #main-menu-left container\n if (width <= hamburgerbreakpoint) {\n botPos += 50;\n }\n $('.sub-menu-scroll-container').css('max-height', ($(window).height() - botPos) + 'px');\n $('#main-menu-left').css('max-height', '');\n }\n if (oneColLayout !== oneColLayoutBefore) {\n reset();\n oneColLayoutBefore = oneColLayout;\n }\n\n // Switch hamburger toggle role between button and none, based on whether it is hidden.\n let hamburgerLayout = width <= hamburgerbreakpoint;\n if (hamburgerLayout !== hamburgerLayoutBefore) {\n hamburgertoggle.attr('role', hamburgerLayout ? 'button' : 'none');\n hamburgerLayoutBefore = hamburgerLayout;\n }\n }\n\n updateMaxMenuHeight();\n $(window).resize(updateMaxMenuHeight);\n}\n"],"names":["updateThemePreferenceAjax","theme","catch","Notification","exception","openDelay","closeDelay","closeCooldown","openMenu","openCandidate","openTimeoutId","closeTimeoutId","openTime","open","menuItem","close","abortClose","addClass","children","attr","openWithDelay","setTimeout","Date","removeClass","closeWithDelay","clearTimeout","abortOpen","reset","click","ev","currentTarget","parentNode","menuitems","parent","mouseenter","window","innerWidth","screen","width","mouseleave","link","item","toggleClass","hasClass","hamburgertoggle","hamburgerparent","oneColLayoutBefore","hamburgerLayoutBefore","updateMaxMenuHeight","botPos","offset","top","oneColLayout","css","height","hamburgerLayout","resize","html","uselighttheme","useostheme","usedarktheme","darkThemeClass","lightThemeClass","selected","initThemeChooser"],"mappings":";;;;;;;cAuFSA,0BAA0BC,yCACb,sBAAuBA,OACpCC,MAAMC,sBAAaC,8GAWlBC,UAAY,IACZC,WAAa,IACbC,cAAgB,QAElBC,SAAW,KACXC,cAAgB,KAChBC,cAAgB,KAChBC,eAAiB,KAEjBC,SAAW,cAMNC,KAAKC,UACNN,UACAO,MAAMP,UAEVQ,iCACEF,UAAUG,SAAS,4BACnBH,UAAUI,SAAS,KAAKC,KAAK,gBAAiB,QAChDX,SAAWM,SACXL,cAAgB,KAChBC,cAAgB,cAOXU,cAAcN,UACnBL,cAAgBK,SAChBJ,cAAgBW,YAAW,KACvBR,KAAKC,UACLF,SAAW,IAAIU,OAChBjB,oBAOEU,MAAMD,8BACTA,UAAUS,YAAY,4BACtBT,UAAUI,SAAS,KAAKC,KAAK,gBAAiB,SAChDX,SAAW,KACXQ,aACAJ,SAAW,cAONY,eAAeV,UACpBH,eAAiBU,WAAWN,MAAOT,WAAYQ,mBAM1CE,aACDL,iBACAc,aAAad,gBACbA,eAAiB,eAOhBe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AAI,aAAc,KAEvCD,eAAiBN,qBACjBnB,QACAmB,mBAAqBM,kBAIrBG,gBAAkBjB,OA7KF,KA8KhBiB,kBAAoBR,wBACpBH,gBAAgBzB,KAAK,OAAQoC,gBAAkB,SAAW,QAC1DR,sBAAwBQ,iBAIhCP,0CACEb,QAAQqB,OAAOR,sBAnPjBxC,oBASMiD,MAAO,mBAAE,QACTC,eAAgB,mBAAE,iCAClBC,YAAa,mBAAE,8BACfC,cAAe,mBAAE,gCACjBC,eAAiB,aACjBC,gBAAkB,kBAEpBC,SAEAA,SADAN,KAAKd,SAASkB,gBACHD,aACJH,KAAKd,SAASmB,iBACVJ,cAEAC,WAEfI,SAAS9C,SAAS,iBAElByC,cAAc9B,OAAM,WAChBmC,SAASxC,YAAY,iBACrBkC,KAAKlC,YAAYsC,gBACjBJ,KAAKxC,SAAS6C,iBACd9D,0BAA0B,GAC1B+D,SAAWL,cACXK,SAAS9C,SAAS,oBAEtB0C,WAAW/B,OAAM,WACbmC,SAASxC,YAAY,iBACrBkC,KAAKlC,YAAYsC,gBACjBJ,KAAKlC,YAAYuC,iBACjB9D,0BAA0B,MAC1B+D,SAAWJ,WACXI,SAAS9C,SAAS,oBAEtB2C,aAAahC,OAAM,WACfmC,SAASxC,YAAY,iBACrBkC,KAAKxC,SAAS4C,gBACdJ,KAAKlC,YAAYuC,iBACjB9D,0BAA0B,GAC1B+D,SAAWH,aACXG,SAAS9C,SAAS,oBA/CtB+C"} \ No newline at end of file diff --git a/amd/build/snow.min.js b/amd/build/snow.min.js index 6be565c..8678a85 100644 --- a/amd/build/snow.min.js +++ b/amd/build/snow.min.js @@ -1,10 +1,10 @@ -define("theme_wwu2019/snow",["exports","jquery","core/ajax","core/notification"],(function(_exports,_jquery,_ajax,_notification){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} +define("theme_wwu2019/snow",["exports","jquery","core/notification","core_user/repository"],(function(_exports,_jquery,_notification,_repository){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} /** * Manages the very important snow. * * @module theme_wwu2019/snow * @copyright 2020 Justus Dieckmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */let canvas;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(snowValue){let enableSnow=!!snowValue;null!==localStorage.getItem("theme_wwu2019/enable-snow")&&(enableSnow="false"!==localStorage.getItem("theme_wwu2019/enable-snow"),updateSnowPreferenceAjax(enableSnow),localStorage.removeItem("theme_wwu2019/enable-snow"));(0,_jquery.default)('
').insertAfter("#main-menu-right .main-menu-additions-item"),canvas=document.createElement("canvas"),canvas.height=window.innerHeight,canvas.width=window.innerWidth,canvas.classList.add("snow"),canvas.style.position="fixed",canvas.style.top="0",canvas.style.left="0",canvas.style.zIndex="1010",canvas.style.opacity="0.8",canvas.style.pointerEvents="none",(0,_jquery.default)(window).resize((()=>{canvas.height=window.innerHeight,canvas.width=window.innerWidth,desiredFlakes=50+canvas.height*canvas.width*1e-4})),desiredFlakes=50+canvas.height*canvas.width*1e-4;for(let i=0;i img");enableSnow?(intervalId=setInterval(redraw,25,ctx),snowicon.attr("src",pixurl+"snow-disable.svg")):(canvas.hidden=!0,snowicon.attr("src",pixurl+"snow-enable.svg"));(0,_jquery.default)("#snow-toggle").click((()=>{intervalId?(clearInterval(intervalId),intervalId=null,snowicon.attr("src",pixurl+"snow-enable.svg")):(intervalId=setInterval(redraw,25,ctx),snowicon.attr("src",pixurl+"snow-disable.svg")),canvas.hidden=null===intervalId,updateSnowPreferenceAjax(null!==intervalId)})),(0,_jquery.default)("body").append(canvas),noise.seed(Math.random())},_jquery=_interopRequireDefault(_jquery),_ajax=_interopRequireDefault(_ajax),_notification=_interopRequireDefault(_notification);let desiredFlakes=150,flakes=[],intervalId=null;const pixurl=M.cfg.wwwroot+"/theme/wwu2019/pix/";let noise=function(){var module={};function Grad(x,y,z){this.x=x,this.y=y,this.z=z}Grad.prototype.dot2=function(x,y){return this.x*x+this.y*y},Grad.prototype.dot3=function(x,y,z){return this.x*x+this.y*y+this.z*z};var grad3=[new Grad(1,1,0),new Grad(-1,1,0),new Grad(1,-1,0),new Grad(-1,-1,0),new Grad(1,0,1),new Grad(-1,0,1),new Grad(1,0,-1),new Grad(-1,0,-1),new Grad(0,1,1),new Grad(0,-1,1),new Grad(0,1,-1),new Grad(0,-1,-1)],p=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],perm=new Array(512),gradP=new Array(512);module.seed=function(seed){seed>0&&seed<1&&(seed*=65536),(seed=Math.floor(seed))<256&&(seed|=seed<<8);for(var i=0;i<256;i++){var v;v=1&i?p[i]^255&seed:p[i]^seed>>8&255,perm[i]=perm[i+256]=v,gradP[i]=gradP[i+256]=grad3[v%12]}},module.seed(0);var F2=.5*(Math.sqrt(3)-1),G2=(3-Math.sqrt(3))/6;function fade(t){return t*t*t*(t*(6*t-15)+10)}function lerp(a,b,t){return(1-t)*a+t*b}return module.simplex2=function(xin,yin){var i1,j1,s=(xin+yin)*F2,i=Math.floor(xin+s),j=Math.floor(yin+s),t=(i+j)*G2,x0=xin-i+t,y0=yin-j+t;x0>y0?(i1=1,j1=0):(i1=0,j1=1);var x1=x0-i1+G2,y1=y0-j1+G2,x2=x0-1+2*G2,y2=y0-1+2*G2,gi0=gradP[(i&=255)+perm[j&=255]],gi1=gradP[i+i1+perm[j+j1]],gi2=gradP[i+1+perm[j+1]],t0=.5-x0*x0-y0*y0,t1=.5-x1*x1-y1*y1,t2=.5-x2*x2-y2*y2;return 70*((t0<0?0:(t0*=t0)*t0*gi0.dot2(x0,y0))+(t1<0?0:(t1*=t1)*t1*gi1.dot2(x1,y1))+(t2<0?0:(t2*=t2)*t2*gi2.dot2(x2,y2)))},module.perlin2=function(x,y){var X=Math.floor(x),Y=Math.floor(y);x-=X,y-=Y;var n00=gradP[(X&=255)+perm[Y&=255]].dot2(x,y),n01=gradP[X+perm[Y+1]].dot2(x,y-1),n10=gradP[X+1+perm[Y]].dot2(x-1,y),n11=gradP[X+1+perm[Y+1]].dot2(x-1,y-1),u=fade(x);return lerp(lerp(n00,n10,u),lerp(n01,n11,u),fade(y))},module}();function updateSnowPreferenceAjax(snow){var request={methodname:"core_user_update_user_preferences",args:{preferences:[{type:"theme_wwu2019_snow",value:snow?1:0}]}};_ajax.default.call([request])[0].fail(_notification.default.exception)}let angle=0;function generateXCoord(){return Math.random()*(canvas.width+400)-200}function redraw(ctx){ctx.clearRect(0,0,canvas.width,canvas.height),ctx.fillStyle="#cbebfa",ctx.beginPath();for(let f of flakes)ctx.moveTo(f.x,f.y),ctx.arc(f.x,f.y,f.r,0,2*Math.PI,!0);ctx.fill(),function(){angle+=.01;let basemovement=2.5*noise.simplex2(.1*angle,0);for(let i=0;icanvas.height+10&&(flakes.length>desiredFlakes&&(flakes.splice(i,1),i--),f.x=generateXCoord(),f.y=-10)}desiredFlakes>flakes.length&&Math.random()<.2&&flakes.push({x:generateXCoord(),y:-10,r:5*Math.random()+2,d:Math.random()+1})}()}})); + */let canvas;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(snowValue){let enableSnow=!!snowValue;null!==localStorage.getItem("theme_wwu2019/enable-snow")&&(enableSnow="false"!==localStorage.getItem("theme_wwu2019/enable-snow"),updateSnowPreferenceAjax(enableSnow),localStorage.removeItem("theme_wwu2019/enable-snow"));(0,_jquery.default)('
').insertAfter("#main-menu-right .main-menu-additions-item"),canvas=document.createElement("canvas"),canvas.height=window.innerHeight,canvas.width=window.innerWidth,canvas.classList.add("snow"),canvas.style.position="fixed",canvas.style.top="0",canvas.style.left="0",canvas.style.zIndex="1010",canvas.style.opacity="0.8",canvas.style.pointerEvents="none",(0,_jquery.default)(window).resize((()=>{canvas.height=window.innerHeight,canvas.width=window.innerWidth,desiredFlakes=50+canvas.height*canvas.width*1e-4})),desiredFlakes=50+canvas.height*canvas.width*1e-4;for(let i=0;i img");enableSnow?(intervalId=setInterval(redraw,25,ctx),snowicon.attr("src",pixurl+"snow-disable.svg")):(canvas.hidden=!0,snowicon.attr("src",pixurl+"snow-enable.svg"));(0,_jquery.default)("#snow-toggle").click((()=>{intervalId?(clearInterval(intervalId),intervalId=null,snowicon.attr("src",pixurl+"snow-enable.svg")):(intervalId=setInterval(redraw,25,ctx),snowicon.attr("src",pixurl+"snow-disable.svg")),canvas.hidden=null===intervalId,updateSnowPreferenceAjax(null!==intervalId)})),(0,_jquery.default)("body").append(canvas),noise.seed(Math.random())},_jquery=_interopRequireDefault(_jquery),_notification=_interopRequireDefault(_notification);let desiredFlakes=150,flakes=[],intervalId=null;const pixurl=M.cfg.wwwroot+"/theme/wwu2019/pix/";let noise=function(){var module={};function Grad(x,y,z){this.x=x,this.y=y,this.z=z}Grad.prototype.dot2=function(x,y){return this.x*x+this.y*y},Grad.prototype.dot3=function(x,y,z){return this.x*x+this.y*y+this.z*z};var grad3=[new Grad(1,1,0),new Grad(-1,1,0),new Grad(1,-1,0),new Grad(-1,-1,0),new Grad(1,0,1),new Grad(-1,0,1),new Grad(1,0,-1),new Grad(-1,0,-1),new Grad(0,1,1),new Grad(0,-1,1),new Grad(0,1,-1),new Grad(0,-1,-1)],p=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],perm=new Array(512),gradP=new Array(512);module.seed=function(seed){seed>0&&seed<1&&(seed*=65536),(seed=Math.floor(seed))<256&&(seed|=seed<<8);for(var i=0;i<256;i++){var v;v=1&i?p[i]^255&seed:p[i]^seed>>8&255,perm[i]=perm[i+256]=v,gradP[i]=gradP[i+256]=grad3[v%12]}},module.seed(0);var F2=.5*(Math.sqrt(3)-1),G2=(3-Math.sqrt(3))/6;function fade(t){return t*t*t*(t*(6*t-15)+10)}function lerp(a,b,t){return(1-t)*a+t*b}return module.simplex2=function(xin,yin){var i1,j1,s=(xin+yin)*F2,i=Math.floor(xin+s),j=Math.floor(yin+s),t=(i+j)*G2,x0=xin-i+t,y0=yin-j+t;x0>y0?(i1=1,j1=0):(i1=0,j1=1);var x1=x0-i1+G2,y1=y0-j1+G2,x2=x0-1+2*G2,y2=y0-1+2*G2,gi0=gradP[(i&=255)+perm[j&=255]],gi1=gradP[i+i1+perm[j+j1]],gi2=gradP[i+1+perm[j+1]],t0=.5-x0*x0-y0*y0,t1=.5-x1*x1-y1*y1,t2=.5-x2*x2-y2*y2;return 70*((t0<0?0:(t0*=t0)*t0*gi0.dot2(x0,y0))+(t1<0?0:(t1*=t1)*t1*gi1.dot2(x1,y1))+(t2<0?0:(t2*=t2)*t2*gi2.dot2(x2,y2)))},module.perlin2=function(x,y){var X=Math.floor(x),Y=Math.floor(y);x-=X,y-=Y;var n00=gradP[(X&=255)+perm[Y&=255]].dot2(x,y),n01=gradP[X+perm[Y+1]].dot2(x,y-1),n10=gradP[X+1+perm[Y]].dot2(x-1,y),n11=gradP[X+1+perm[Y+1]].dot2(x-1,y-1),u=fade(x);return lerp(lerp(n00,n10,u),lerp(n01,n11,u),fade(y))},module}();function updateSnowPreferenceAjax(snow){(0,_repository.setUserPreference)("theme_wwu2019_snow",snow?1:0).catch(_notification.default.exception)}let angle=0;function generateXCoord(){return Math.random()*(canvas.width+400)-200}function redraw(ctx){ctx.clearRect(0,0,canvas.width,canvas.height),ctx.fillStyle="#cbebfa",ctx.beginPath();for(let f of flakes)ctx.moveTo(f.x,f.y),ctx.arc(f.x,f.y,f.r,0,2*Math.PI,!0);ctx.fill(),function(){angle+=.01;let basemovement=2.5*noise.simplex2(.1*angle,0);for(let i=0;icanvas.height+10&&(flakes.length>desiredFlakes&&(flakes.splice(i,1),i--),f.x=generateXCoord(),f.y=-10)}desiredFlakes>flakes.length&&Math.random()<.2&&flakes.push({x:generateXCoord(),y:-10,r:5*Math.random()+2,d:Math.random()+1})}()}})); //# sourceMappingURL=snow.min.js.map \ No newline at end of file diff --git a/amd/build/snow.min.js.map b/amd/build/snow.min.js.map index bd66e0d..5b5b253 100644 --- a/amd/build/snow.min.js.map +++ b/amd/build/snow.min.js.map @@ -1 +1 @@ -{"version":3,"file":"snow.min.js","sources":["../src/snow.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Manages the very important snow.\n *\n * @module theme_wwu2019/snow\n * @copyright 2020 Justus Dieckmann WWU\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\n\nlet canvas;\n\nlet desiredFlakes = 150;\n\n/**\n * @type {[{x: number, y: number, r: number, d: number}]}\n */\nlet flakes = [];\n\nlet intervalId = null;\n\nconst pixurl = M.cfg.wwwroot + '/theme/wwu2019/pix/';\n\nlet noise = exportNoise();\n\n/**\n * Updates the snow preference.\n * @param {boolean} snow\n */\nfunction updateSnowPreferenceAjax(snow) {\n var request = {\n methodname: 'core_user_update_user_preferences',\n args: {\n preferences: [{\n type: 'theme_wwu2019_snow',\n value: snow ? 1 : 0\n }]\n }\n };\n\n Ajax.call([request])[0]\n .fail(Notification.exception);\n}\n\n/**\n * Init function\n * @param {int} snowValue\n */\nexport function init(snowValue) {\n let enableSnow = !!snowValue;\n if (localStorage.getItem('theme_wwu2019/enable-snow') !== null) {\n enableSnow = localStorage.getItem('theme_wwu2019/enable-snow') !== 'false';\n updateSnowPreferenceAjax(enableSnow);\n localStorage.removeItem('theme_wwu2019/enable-snow');\n }\n\n $('
' +\n '' +\n '
').insertAfter('#main-menu-right .main-menu-additions-item');\n\n canvas = document.createElement('canvas');\n canvas.height = window.innerHeight;\n canvas.width = window.innerWidth;\n canvas.classList.add('snow');\n canvas.style.position = 'fixed';\n canvas.style.top = '0';\n canvas.style.left = '0';\n canvas.style.zIndex = '1010';\n canvas.style.opacity = '0.8';\n canvas.style.pointerEvents = 'none';\n $(window).resize(() => {\n canvas.height = window.innerHeight;\n canvas.width = window.innerWidth;\n desiredFlakes = 50 + canvas.height * canvas.width * 0.0001;\n });\n\n desiredFlakes = 50 + canvas.height * canvas.width * 0.0001;\n\n // Loop throught the empty flakes and apply attributes\n for (let i = 0; i < desiredFlakes; i++) {\n flakes.push({\n x: generateXCoord(), // Also spawn left and right of window.\n y: Math.random() * canvas.height,\n r: Math.random() * 5 + 2, // Min of 2px and max of 7px\n d: Math.random() + 1 // Density of the flake\n });\n }\n let ctx = canvas.getContext(\"2d\");\n\n let snowicon = $('#snow-toggle > img');\n\n if (enableSnow) {\n intervalId = setInterval(redraw, 25, ctx);\n snowicon.attr('src', pixurl + 'snow-disable.svg');\n } else {\n canvas.hidden = true;\n snowicon.attr('src', pixurl + 'snow-enable.svg');\n }\n\n $('#snow-toggle').click(() => {\n if (intervalId) {\n clearInterval(intervalId);\n intervalId = null;\n snowicon.attr('src', pixurl + 'snow-enable.svg');\n } else {\n intervalId = setInterval(redraw, 25, ctx);\n snowicon.attr('src', pixurl + 'snow-disable.svg');\n }\n canvas.hidden = intervalId === null;\n updateSnowPreferenceAjax(intervalId !== null);\n });\n\n $('body').append(canvas);\n\n noise.seed(Math.random());\n}\n\n// Animate the flakes\nlet angle = 0;\n\n/**\n * Move the flakes.\n */\nfunction moveFlakes() {\n angle += 0.01;\n let basemovement = noise.simplex2(angle * 0.1, 0) * 2.5;\n for (let i = 0; i < flakes.length; i++) {\n // Store current flake\n let f = flakes[i];\n // Update X and Y coordinates of each snowflakes\n f.y += Math.pow(f.d, 2) + 1;\n f.x += basemovement + Math.sin(f.d * 8 + angle) * 0.5;\n\n // If the snowflake reaches the bottom, send a new one to the top\n if (f.y > canvas.height + 10) {\n if (flakes.length > desiredFlakes) {\n flakes.splice(i, 1);\n i--;\n }\n f.x = generateXCoord();\n f.y = -10;\n }\n }\n if (desiredFlakes > flakes.length && Math.random() < 0.2) {\n flakes.push({\n x: generateXCoord(), // Also spawn left and right of window.\n y: -10,\n r: Math.random() * 5 + 2, // Min of 2px and max of 7px\n d: Math.random() + 1 // Density of the flake\n });\n }\n}\n\n/**\n * Generate X Coordinate\n * @returns {number} the x coordinate\n */\nfunction generateXCoord() {\n return Math.random() * (canvas.width + 400) - 200;\n}\n\n/**\n * Redraw everything\n * @param {CanvasRenderingContext2D} ctx\n */\nfunction redraw(ctx) {\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.fillStyle = \"#cbebfa\";\n ctx.beginPath();\n for (let f of flakes) {\n ctx.moveTo(f.x, f.y);\n ctx.arc(f.x, f.y, f.r, 0, Math.PI * 2, true);\n }\n ctx.fill();\n moveFlakes();\n}\n\n/*\n * A speed-improved perlin and simplex noise algorithms for 2D.\n *\n * Based on example code by Stefan Gustavson (stegu@itn.liu.se).\n * Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).\n * Better rank ordering method by Stefan Gustavson in 2012.\n * Converted to Javascript by Joseph Gentle.\n *\n * Version 2012-03-09\n *\n * This code was placed in the public domain by its original author,\n * Stefan Gustavson. You may use it as you see fit, but\n * attribution is appreciated.\n *\n */\n// eslint-disable-next-line\nfunction exportNoise() {\n /* eslint-disable */\n var module = {};\n\n function Grad(x, y, z) {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n\n Grad.prototype.dot2 = function (x, y) {\n return this.x * x + this.y * y;\n };\n\n Grad.prototype.dot3 = function (x, y, z) {\n return this.x * x + this.y * y + this.z * z;\n };\n\n var grad3 = [new Grad(1, 1, 0), new Grad(-1, 1, 0), new Grad(1, -1, 0), new Grad(-1, -1, 0),\n new Grad(1, 0, 1), new Grad(-1, 0, 1), new Grad(1, 0, -1), new Grad(-1, 0, -1),\n new Grad(0, 1, 1), new Grad(0, -1, 1), new Grad(0, 1, -1), new Grad(0, -1, -1)];\n\n var p = [151, 160, 137, 91, 90, 15,\n 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23,\n 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33,\n 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166,\n 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244,\n 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196,\n 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123,\n 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42,\n 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9,\n 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228,\n 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107,\n 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254,\n 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180];\n // To remove the need for index wrapping, double the permutation table length\n var perm = new Array(512);\n var gradP = new Array(512);\n\n // This isn't a very good seeding function, but it works ok. It supports 2^16\n // different seed values. Write something better if you need more seeds.\n module.seed = function (seed) {\n if (seed > 0 && seed < 1) {\n // Scale the seed out\n seed *= 65536;\n }\n\n seed = Math.floor(seed);\n if (seed < 256) {\n seed |= seed << 8;\n }\n\n for (var i = 0; i < 256; i++) {\n var v;\n if (i & 1) {\n v = p[i] ^ (seed & 255);\n } else {\n v = p[i] ^ ((seed >> 8) & 255);\n }\n\n perm[i] = perm[i + 256] = v;\n gradP[i] = gradP[i + 256] = grad3[v % 12];\n }\n };\n\n module.seed(0);\n\n // Skewing and unskewing factors for 2, 3, and 4 dimensions\n var F2 = 0.5 * (Math.sqrt(3) - 1);\n var G2 = (3 - Math.sqrt(3)) / 6;\n\n // 2D simplex noise\n module.simplex2 = function(xin, yin) {\n var n0, n1, n2; // Noise contributions from the three corners\n // Skew the input space to determine which simplex cell we're in\n var s = (xin + yin) * F2; // Hairy factor for 2D\n var i = Math.floor(xin + s);\n var j = Math.floor(yin + s);\n var t = (i + j) * G2;\n var x0 = xin - i + t; // The x,y distances from the cell origin, unskewed.\n var y0 = yin - j + t;\n // For the 2D case, the simplex shape is an equilateral triangle.\n // Determine which simplex we are in.\n var i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords\n if (x0 > y0) { // Lower triangle, XY order: (0,0)->(1,0)->(1,1)\n i1 = 1;\n j1 = 0;\n } else { // Upper triangle, YX order: (0,0)->(0,1)->(1,1)\n i1 = 0;\n j1 = 1;\n }\n // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and\n // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where\n // c = (3-sqrt(3))/6\n var x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords\n var y1 = y0 - j1 + G2;\n var x2 = x0 - 1 + 2 * G2; // Offsets for last corner in (x,y) unskewed coords\n var y2 = y0 - 1 + 2 * G2;\n // Work out the hashed gradient indices of the three simplex corners\n i &= 255;\n j &= 255;\n var gi0 = gradP[i + perm[j]];\n var gi1 = gradP[i + i1 + perm[j + j1]];\n var gi2 = gradP[i + 1 + perm[j + 1]];\n // Calculate the contribution from the three corners\n var t0 = 0.5 - x0 * x0 - y0 * y0;\n if (t0 < 0) {\n n0 = 0;\n } else {\n t0 *= t0;\n n0 = t0 * t0 * gi0.dot2(x0, y0); // (x,y) of grad3 used for 2D gradient\n }\n var t1 = 0.5 - x1 * x1 - y1 * y1;\n if (t1 < 0) {\n n1 = 0;\n } else {\n t1 *= t1;\n n1 = t1 * t1 * gi1.dot2(x1, y1);\n }\n var t2 = 0.5 - x2 * x2 - y2 * y2;\n if (t2 < 0) {\n n2 = 0;\n } else {\n t2 *= t2;\n n2 = t2 * t2 * gi2.dot2(x2, y2);\n }\n // Add contributions from each corner to get the final noise value.\n // The result is scaled to return values in the interval [-1,1].\n return 70 * (n0 + n1 + n2);\n };\n\n // ##### Perlin noise stuff\n\n function fade(t) {\n return t * t * t * (t * (t * 6 - 15) + 10);\n }\n\n function lerp(a, b, t) {\n return (1 - t) * a + t * b;\n }\n\n // 2D Perlin Noise\n module.perlin2 = function (x, y) {\n // Find unit grid cell containing point\n var X = Math.floor(x), Y = Math.floor(y);\n // Get relative xy coordinates of point within that cell\n x = x - X;\n y = y - Y;\n // Wrap the integer cells at 255 (smaller integer period can be introduced here)\n X = X & 255;\n Y = Y & 255;\n\n // Calculate noise contributions from each of the four corners\n var n00 = gradP[X + perm[Y]].dot2(x, y);\n var n01 = gradP[X + perm[Y + 1]].dot2(x, y - 1);\n var n10 = gradP[X + 1 + perm[Y]].dot2(x - 1, y);\n var n11 = gradP[X + 1 + perm[Y + 1]].dot2(x - 1, y - 1);\n\n // Compute the fade curve value for x\n var u = fade(x);\n\n // Interpolate the four results\n return lerp(\n lerp(n00, n10, u),\n lerp(n01, n11, u),\n fade(y));\n };\n\n return module;\n}"],"names":["canvas","snowValue","enableSnow","localStorage","getItem","updateSnowPreferenceAjax","removeItem","insertAfter","document","createElement","height","window","innerHeight","width","innerWidth","classList","add","style","position","top","left","zIndex","opacity","pointerEvents","resize","desiredFlakes","i","flakes","push","x","generateXCoord","y","Math","random","r","d","ctx","getContext","snowicon","intervalId","setInterval","redraw","attr","pixurl","hidden","click","clearInterval","append","noise","seed","M","cfg","wwwroot","module","Grad","z","prototype","dot2","this","dot3","grad3","p","perm","Array","gradP","floor","v","F2","sqrt","G2","fade","t","lerp","a","b","simplex2","xin","yin","i1","j1","s","j","x0","y0","x1","y1","x2","y2","gi0","gi1","gi2","t0","t1","t2","perlin2","X","Y","n00","n01","n10","n11","u","exportNoise","snow","request","methodname","args","preferences","type","value","call","fail","Notification","exception","angle","clearRect","fillStyle","beginPath","f","moveTo","arc","PI","fill","basemovement","length","pow","sin","splice","moveFlakes"],"mappings":";;;;;;;SA2BIA,sFAsCiBC,eACbC,aAAeD,UACuC,OAAtDE,aAAaC,QAAQ,+BACrBF,WAAmE,UAAtDC,aAAaC,QAAQ,6BAClCC,yBAAyBH,YACzBC,aAAaG,WAAW,kDAG1B,uGAEYC,YAAY,8CAE1BP,OAASQ,SAASC,cAAc,UAChCT,OAAOU,OAASC,OAAOC,YACvBZ,OAAOa,MAAQF,OAAOG,WACtBd,OAAOe,UAAUC,IAAI,QACrBhB,OAAOiB,MAAMC,SAAW,QACxBlB,OAAOiB,MAAME,IAAM,IACnBnB,OAAOiB,MAAMG,KAAO,IACpBpB,OAAOiB,MAAMI,OAAS,OACtBrB,OAAOiB,MAAMK,QAAU,MACvBtB,OAAOiB,MAAMM,cAAgB,2BAC3BZ,QAAQa,QAAO,KACbxB,OAAOU,OAASC,OAAOC,YACvBZ,OAAOa,MAAQF,OAAOG,WACtBW,cAAgB,GAAKzB,OAAOU,OAASV,OAAOa,MAAQ,QAGxDY,cAAgB,GAAKzB,OAAOU,OAASV,OAAOa,MAAQ,SAG/C,IAAIa,EAAI,EAAGA,EAAID,cAAeC,IAC/BC,OAAOC,KAAK,CACRC,EAAGC,iBACHC,EAAGC,KAAKC,SAAWjC,OAAOU,OAC1BwB,EAAmB,EAAhBF,KAAKC,SAAe,EACvBE,EAAGH,KAAKC,SAAW,QAGvBG,IAAMpC,OAAOqC,WAAW,MAExBC,UAAW,mBAAE,sBAEbpC,YACAqC,WAAaC,YAAYC,OAAQ,GAAIL,KACrCE,SAASI,KAAK,MAAOC,OAAS,sBAE9B3C,OAAO4C,QAAS,EAChBN,SAASI,KAAK,MAAOC,OAAS,wCAGhC,gBAAgBE,OAAM,KAChBN,YACAO,cAAcP,YACdA,WAAa,KACbD,SAASI,KAAK,M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BO,KAAKC,sBAAaC,eA6EvBC,MAAQ,WAuCHpF,wBACEE,KAAKC,UAAYjC,OAAOa,MAAQ,KAAO,aAOzC4B,OAAOL,KACZA,IAAI+E,UAAU,EAAG,EAAGnH,OAAOa,MAAOb,OAAOU,QACzC0B,IAAIgF,UAAY,UAChBhF,IAAIiF,gBACC,IAAIC,KAAK3F,OACVS,IAAImF,OAAOD,EAAEzF,EAAGyF,EAAEvF,GAClBK,IAAIoF,IAAIF,EAAEzF,EAAGyF,EAAEvF,EAAGuF,EAAEpF,EAAG,EAAa,EAAVF,KAAKyF,IAAQ,GAE3CrF,IAAIsF,kBAjDJR,OAAS,QACLS,aAAgD,IAAjC3E,MAAM2B,SAAiB,GAARuC,MAAa,OAC1C,IAAIxF,EAAI,EAAGA,EAAIC,OAAOiG,OAAQlG,IAAK,KAEhC4F,EAAI3F,OAAOD,GAEf4F,EAAEvF,GAAKC,KAAK6F,IAAIP,EAAEnF,EAAG,GAAK,EAC1BmF,EAAEzF,GAAK8F,aAA2C,GAA5B3F,KAAK8F,IAAU,EAANR,EAAEnF,EAAQ+E,OAGrCI,EAAEvF,EAAI/B,OAAOU,OAAS,KAClBiB,OAAOiG,OAASnG,gBAChBE,OAAOoG,OAAOrG,EAAG,GACjBA,KAEJ4F,EAAEzF,EAAIC,iBACNwF,EAAEvF,GAAK,IAGXN,cAAgBE,OAAOiG,QAAU5F,KAAKC,SAAW,IACjDN,OAAOC,KAAK,CACRC,EAAGC,iBACHC,GAAI,GACJG,EAAmB,EAAhBF,KAAKC,SAAe,EACvBE,EAAGH,KAAKC,SAAW,IA0B3B+F"} \ No newline at end of file +{"version":3,"file":"snow.min.js","sources":["../src/snow.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Manages the very important snow.\n *\n * @module theme_wwu2019/snow\n * @copyright 2020 Justus Dieckmann WWU\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\nimport Notification from 'core/notification';\nimport {setUserPreference} from 'core_user/repository';\n\nlet canvas;\n\nlet desiredFlakes = 150;\n\n/**\n * @type {[{x: number, y: number, r: number, d: number}]}\n */\nlet flakes = [];\n\nlet intervalId = null;\n\nconst pixurl = M.cfg.wwwroot + '/theme/wwu2019/pix/';\n\nlet noise = exportNoise();\n\n/**\n * Updates the snow preference.\n * @param {boolean} snow\n */\nfunction updateSnowPreferenceAjax(snow) {\n setUserPreference('theme_wwu2019_snow', snow ? 1 : 0)\n .catch(Notification.exception);\n}\n\n/**\n * Init function\n * @param {int} snowValue\n */\nexport function init(snowValue) {\n let enableSnow = !!snowValue;\n if (localStorage.getItem('theme_wwu2019/enable-snow') !== null) {\n enableSnow = localStorage.getItem('theme_wwu2019/enable-snow') !== 'false';\n updateSnowPreferenceAjax(enableSnow);\n localStorage.removeItem('theme_wwu2019/enable-snow');\n }\n\n $('
' +\n '' +\n '
').insertAfter('#main-menu-right .main-menu-additions-item');\n\n canvas = document.createElement('canvas');\n canvas.height = window.innerHeight;\n canvas.width = window.innerWidth;\n canvas.classList.add('snow');\n canvas.style.position = 'fixed';\n canvas.style.top = '0';\n canvas.style.left = '0';\n canvas.style.zIndex = '1010';\n canvas.style.opacity = '0.8';\n canvas.style.pointerEvents = 'none';\n $(window).resize(() => {\n canvas.height = window.innerHeight;\n canvas.width = window.innerWidth;\n desiredFlakes = 50 + canvas.height * canvas.width * 0.0001;\n });\n\n desiredFlakes = 50 + canvas.height * canvas.width * 0.0001;\n\n // Loop throught the empty flakes and apply attributes\n for (let i = 0; i < desiredFlakes; i++) {\n flakes.push({\n x: generateXCoord(), // Also spawn left and right of window.\n y: Math.random() * canvas.height,\n r: Math.random() * 5 + 2, // Min of 2px and max of 7px\n d: Math.random() + 1 // Density of the flake\n });\n }\n let ctx = canvas.getContext(\"2d\");\n\n let snowicon = $('#snow-toggle > img');\n\n if (enableSnow) {\n intervalId = setInterval(redraw, 25, ctx);\n snowicon.attr('src', pixurl + 'snow-disable.svg');\n } else {\n canvas.hidden = true;\n snowicon.attr('src', pixurl + 'snow-enable.svg');\n }\n\n $('#snow-toggle').click(() => {\n if (intervalId) {\n clearInterval(intervalId);\n intervalId = null;\n snowicon.attr('src', pixurl + 'snow-enable.svg');\n } else {\n intervalId = setInterval(redraw, 25, ctx);\n snowicon.attr('src', pixurl + 'snow-disable.svg');\n }\n canvas.hidden = intervalId === null;\n updateSnowPreferenceAjax(intervalId !== null);\n });\n\n $('body').append(canvas);\n\n noise.seed(Math.random());\n}\n\n// Animate the flakes\nlet angle = 0;\n\n/**\n * Move the flakes.\n */\nfunction moveFlakes() {\n angle += 0.01;\n let basemovement = noise.simplex2(angle * 0.1, 0) * 2.5;\n for (let i = 0; i < flakes.length; i++) {\n // Store current flake\n let f = flakes[i];\n // Update X and Y coordinates of each snowflakes\n f.y += Math.pow(f.d, 2) + 1;\n f.x += basemovement + Math.sin(f.d * 8 + angle) * 0.5;\n\n // If the snowflake reaches the bottom, send a new one to the top\n if (f.y > canvas.height + 10) {\n if (flakes.length > desiredFlakes) {\n flakes.splice(i, 1);\n i--;\n }\n f.x = generateXCoord();\n f.y = -10;\n }\n }\n if (desiredFlakes > flakes.length && Math.random() < 0.2) {\n flakes.push({\n x: generateXCoord(), // Also spawn left and right of window.\n y: -10,\n r: Math.random() * 5 + 2, // Min of 2px and max of 7px\n d: Math.random() + 1 // Density of the flake\n });\n }\n}\n\n/**\n * Generate X Coordinate\n * @returns {number} the x coordinate\n */\nfunction generateXCoord() {\n return Math.random() * (canvas.width + 400) - 200;\n}\n\n/**\n * Redraw everything\n * @param {CanvasRenderingContext2D} ctx\n */\nfunction redraw(ctx) {\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.fillStyle = \"#cbebfa\";\n ctx.beginPath();\n for (let f of flakes) {\n ctx.moveTo(f.x, f.y);\n ctx.arc(f.x, f.y, f.r, 0, Math.PI * 2, true);\n }\n ctx.fill();\n moveFlakes();\n}\n\n/*\n * A speed-improved perlin and simplex noise algorithms for 2D.\n *\n * Based on example code by Stefan Gustavson (stegu@itn.liu.se).\n * Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).\n * Better rank ordering method by Stefan Gustavson in 2012.\n * Converted to Javascript by Joseph Gentle.\n *\n * Version 2012-03-09\n *\n * This code was placed in the public domain by its original author,\n * Stefan Gustavson. You may use it as you see fit, but\n * attribution is appreciated.\n *\n */\n// eslint-disable-next-line\nfunction exportNoise() {\n /* eslint-disable */\n var module = {};\n\n function Grad(x, y, z) {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n\n Grad.prototype.dot2 = function (x, y) {\n return this.x * x + this.y * y;\n };\n\n Grad.prototype.dot3 = function (x, y, z) {\n return this.x * x + this.y * y + this.z * z;\n };\n\n var grad3 = [new Grad(1, 1, 0), new Grad(-1, 1, 0), new Grad(1, -1, 0), new Grad(-1, -1, 0),\n new Grad(1, 0, 1), new Grad(-1, 0, 1), new Grad(1, 0, -1), new Grad(-1, 0, -1),\n new Grad(0, 1, 1), new Grad(0, -1, 1), new Grad(0, 1, -1), new Grad(0, -1, -1)];\n\n var p = [151, 160, 137, 91, 90, 15,\n 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23,\n 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33,\n 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166,\n 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244,\n 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196,\n 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123,\n 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42,\n 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9,\n 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228,\n 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107,\n 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254,\n 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180];\n // To remove the need for index wrapping, double the permutation table length\n var perm = new Array(512);\n var gradP = new Array(512);\n\n // This isn't a very good seeding function, but it works ok. It supports 2^16\n // different seed values. Write something better if you need more seeds.\n module.seed = function (seed) {\n if (seed > 0 && seed < 1) {\n // Scale the seed out\n seed *= 65536;\n }\n\n seed = Math.floor(seed);\n if (seed < 256) {\n seed |= seed << 8;\n }\n\n for (var i = 0; i < 256; i++) {\n var v;\n if (i & 1) {\n v = p[i] ^ (seed & 255);\n } else {\n v = p[i] ^ ((seed >> 8) & 255);\n }\n\n perm[i] = perm[i + 256] = v;\n gradP[i] = gradP[i + 256] = grad3[v % 12];\n }\n };\n\n module.seed(0);\n\n // Skewing and unskewing factors for 2, 3, and 4 dimensions\n var F2 = 0.5 * (Math.sqrt(3) - 1);\n var G2 = (3 - Math.sqrt(3)) / 6;\n\n // 2D simplex noise\n module.simplex2 = function(xin, yin) {\n var n0, n1, n2; // Noise contributions from the three corners\n // Skew the input space to determine which simplex cell we're in\n var s = (xin + yin) * F2; // Hairy factor for 2D\n var i = Math.floor(xin + s);\n var j = Math.floor(yin + s);\n var t = (i + j) * G2;\n var x0 = xin - i + t; // The x,y distances from the cell origin, unskewed.\n var y0 = yin - j + t;\n // For the 2D case, the simplex shape is an equilateral triangle.\n // Determine which simplex we are in.\n var i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords\n if (x0 > y0) { // Lower triangle, XY order: (0,0)->(1,0)->(1,1)\n i1 = 1;\n j1 = 0;\n } else { // Upper triangle, YX order: (0,0)->(0,1)->(1,1)\n i1 = 0;\n j1 = 1;\n }\n // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and\n // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where\n // c = (3-sqrt(3))/6\n var x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords\n var y1 = y0 - j1 + G2;\n var x2 = x0 - 1 + 2 * G2; // Offsets for last corner in (x,y) unskewed coords\n var y2 = y0 - 1 + 2 * G2;\n // Work out the hashed gradient indices of the three simplex corners\n i &= 255;\n j &= 255;\n var gi0 = gradP[i + perm[j]];\n var gi1 = gradP[i + i1 + perm[j + j1]];\n var gi2 = gradP[i + 1 + perm[j + 1]];\n // Calculate the contribution from the three corners\n var t0 = 0.5 - x0 * x0 - y0 * y0;\n if (t0 < 0) {\n n0 = 0;\n } else {\n t0 *= t0;\n n0 = t0 * t0 * gi0.dot2(x0, y0); // (x,y) of grad3 used for 2D gradient\n }\n var t1 = 0.5 - x1 * x1 - y1 * y1;\n if (t1 < 0) {\n n1 = 0;\n } else {\n t1 *= t1;\n n1 = t1 * t1 * gi1.dot2(x1, y1);\n }\n var t2 = 0.5 - x2 * x2 - y2 * y2;\n if (t2 < 0) {\n n2 = 0;\n } else {\n t2 *= t2;\n n2 = t2 * t2 * gi2.dot2(x2, y2);\n }\n // Add contributions from each corner to get the final noise value.\n // The result is scaled to return values in the interval [-1,1].\n return 70 * (n0 + n1 + n2);\n };\n\n // ##### Perlin noise stuff\n\n function fade(t) {\n return t * t * t * (t * (t * 6 - 15) + 10);\n }\n\n function lerp(a, b, t) {\n return (1 - t) * a + t * b;\n }\n\n // 2D Perlin Noise\n module.perlin2 = function (x, y) {\n // Find unit grid cell containing point\n var X = Math.floor(x), Y = Math.floor(y);\n // Get relative xy coordinates of point within that cell\n x = x - X;\n y = y - Y;\n // Wrap the integer cells at 255 (smaller integer period can be introduced here)\n X = X & 255;\n Y = Y & 255;\n\n // Calculate noise contributions from each of the four corners\n var n00 = gradP[X + perm[Y]].dot2(x, y);\n var n01 = gradP[X + perm[Y + 1]].dot2(x, y - 1);\n var n10 = gradP[X + 1 + perm[Y]].dot2(x - 1, y);\n var n11 = gradP[X + 1 + perm[Y + 1]].dot2(x - 1, y - 1);\n\n // Compute the fade curve value for x\n var u = fade(x);\n\n // Interpolate the four results\n return lerp(\n lerp(n00, n10, u),\n lerp(n01, n11, u),\n fade(y));\n };\n\n return module;\n}\n"],"names":["canvas","snowValue","enableSnow","localStorage","getItem","updateSnowPreferenceAjax","removeItem","insertAfter","document","createElement","height","window","innerHeight","width","innerWidth","classList","add","style","position","top","left","zIndex","opacity","pointerEvents","resize","desiredFlakes","i","flakes","push","x","generateXCoord","y","Math","random","r","d","ctx","getContext","snowicon","intervalId","setInterval","redraw","attr","pixurl","hidden","click","clearInterval","append","noise","seed","M","cfg","wwwroot","module","Grad","z","prototype","dot2","this","dot3","grad3","p","perm","Array","gradP","floor","v","F2","sqrt","G2","fade","t","lerp","a","b","simplex2","xin","yin","i1","j1","s","j","x0","y0","x1","y1","x2","y2","gi0","gi1","gi2","t0","t1","t2","perlin2","X","Y","n00","n01","n10","n11","u","exportNoise","snow","catch","Notification","exception","angle","clearRect","fillStyle","beginPath","f","moveTo","arc","PI","fill","basemovement","length","pow","sin","splice","moveFlakes"],"mappings":";;;;;;;SA2BIA,sFA4BiBC,eACbC,aAAeD,UACuC,OAAtDE,aAAaC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AElF,EAAGkF,EAAEhF,EAAGgF,EAAE7E,EAAG,EAAa,EAAVF,KAAKkF,IAAQ,GAE3C9E,IAAI+E,kBAjDJR,OAAS,QACLS,aAAgD,IAAjCpE,MAAM2B,SAAiB,GAARgC,MAAa,OAC1C,IAAIjF,EAAI,EAAGA,EAAIC,OAAO0F,OAAQ3F,IAAK,KAEhCqF,EAAIpF,OAAOD,GAEfqF,EAAEhF,GAAKC,KAAKsF,IAAIP,EAAE5E,EAAG,GAAK,EAC1B4E,EAAElF,GAAKuF,aAA2C,GAA5BpF,KAAKuF,IAAU,EAANR,EAAE5E,EAAQwE,OAGrCI,EAAEhF,EAAI/B,OAAOU,OAAS,KAClBiB,OAAO0F,OAAS5F,gBAChBE,OAAO6F,OAAO9F,EAAG,GACjBA,KAEJqF,EAAElF,EAAIC,iBACNiF,EAAEhF,GAAK,IAGXN,cAAgBE,OAAO0F,QAAUrF,KAAKC,SAAW,IACjDN,OAAOC,KAAK,CACRC,EAAGC,iBACHC,GAAI,GACJG,EAAmB,EAAhBF,KAAKC,SAAe,EACvBE,EAAGH,KAAKC,SAAW,IA0B3BwF"} \ No newline at end of file diff --git a/amd/src/menu.js b/amd/src/menu.js index 2782f23..579bff1 100644 --- a/amd/src/menu.js +++ b/amd/src/menu.js @@ -22,8 +22,8 @@ */ import $ from 'jquery'; -import Ajax from 'core/ajax'; import Notification from 'core/notification'; +import {setUserPreference} from "../../../../user/amd/src/repository"; /** * Init function @@ -86,18 +86,8 @@ function initThemeChooser() { * @param {int} theme */ function updateThemePreferenceAjax(theme) { - var request = { - methodname: 'core_user_update_user_preferences', - args: { - preferences: [{ - type: 'theme_wwu2019_theme', - value: theme - }] - } - }; - - Ajax.call([request])[0] - .fail(Notification.exception); + setUserPreference('theme_wwu2019_theme', theme) + .catch(Notification.exception); } const onecolumnbreakpoint = 767; diff --git a/amd/src/snow.js b/amd/src/snow.js index 0a41ae3..bccb8f7 100644 --- a/amd/src/snow.js +++ b/amd/src/snow.js @@ -22,8 +22,8 @@ */ import $ from 'jquery'; -import Ajax from 'core/ajax'; import Notification from 'core/notification'; +import {setUserPreference} from 'core_user/repository'; let canvas; @@ -45,18 +45,8 @@ let noise = exportNoise(); * @param {boolean} snow */ function updateSnowPreferenceAjax(snow) { - var request = { - methodname: 'core_user_update_user_preferences', - args: { - preferences: [{ - type: 'theme_wwu2019_snow', - value: snow ? 1 : 0 - }] - } - }; - - Ajax.call([request])[0] - .fail(Notification.exception); + setUserPreference('theme_wwu2019_snow', snow ? 1 : 0) + .catch(Notification.exception); } /** @@ -377,4 +367,4 @@ function exportNoise() { }; return module; -} \ No newline at end of file +} diff --git a/classes/layout.php b/classes/layout.php index 4980cae..f7e4cfd 100644 --- a/classes/layout.php +++ b/classes/layout.php @@ -113,7 +113,6 @@ public static function handle_snow() { if ($snowenable == 1 || $snowenable == 2 && ( get_config('theme_wwu2019', 'snow_start') < time() && get_config('theme_wwu2019', 'snow_end') > time())) { - user_preference_allow_ajax_update('theme_wwu2019_snow', PARAM_INT); $snowpreference = get_user_preferences('theme_wwu2019_snow', '1'); $PAGE->requires->js_call_amd('theme_wwu2019/snow', 'init', [intval($snowpreference)]); }