Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions amd/build/collapse.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions amd/build/collapse.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions amd/src/collapse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// WWU Addon. Allows collapsing of topics in courses.
// Robin Tschudi

define(['jquery'], function ($) {

const collapsed_url = M.util.image_url("t/collapsed", "core");
const expanded_url = M.util.image_url("t/expanded", "core");

var hide = function (section) {
$("#section-" + section).find(".content").each(function (index, element) {
element.hidden = true;
});
let arrow = $("#collapseicon" + section);
arrow.attr("src", collapsed_url);
arrow.click(function () { arrow.unbind("click"); show(section); });
};

var show = function (section) {
$("#section-" + section).find(".content").each(function (index, element) {
element.hidden = false;
});
let arrow = $("#collapseicon" + section);
arrow.attr("src", expanded_url);
arrow.click(function () { arrow.unbind("click"); hide(section); });
};

var init = function (sectionindex) {
let arrow = $("#collapseicon" + sectionindex);
arrow.click(function () {arrow.unbind("click"); hide(sectionindex);});
};
return {
init: init,
};
});
5 changes: 5 additions & 0 deletions classes/output/wwu_format_trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public function wwu_section_header($section, $course, $onsectionpage) {
$leftcontent = $this->section_left_content($section, $course, $onsectionpage);
$o .= html_writer::tag('div', $leftcontent, array('class' => 'left side'));

global $OUTPUT;
$arrowurl = $OUTPUT->image_url("t/expanded", "core");
$o .= html_writer::img($arrowurl, "collapse", array("id" => "collapseicon" . $section->section));
$this->page->requires->js_call_amd('theme_wwu2019/collapse', 'init', array($section->section));

$sectionname = html_writer::tag('span', $this->section_title($section, $course));
$o .= $this->output->heading($sectionname, 3, 'sectionname');

Expand Down