Skip to content

Commit

Permalink
Fix: CONTRIB-5511.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Dec 16, 2014
1 parent f18c8bb commit 6761c4c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 44 deletions.
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,12 @@ Known Issues

History
=============
12th December 2014 Version 2.7.2
16th December 2014 Version 2.7.2
1. Revamped the arrows such that they are always visible.
2. Arrow and close image size responsive to screen size.
3. Changed the arrow images to FontAwesome: http://fontawesome.io/license/ and extracted with: https://icomoon.io/app/#/select.
4. Added change in cursor for the arrow areas.
5. Fix CONTRIB-5511: Navigation arrows should be hidden when only one section.

14th November 2014 Version 2.7.1.5
1. Always show shadebox arrows on Tablets and Mobiles with the latter being half size.
Expand Down
31 changes: 4 additions & 27 deletions module.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ M.format_grid = M.format_grid || {
shadebox_shown_array: null,
// DOM reference to the #gridshadebox_content element.
shadebox_content: null,
// DOM reference to the #gridshadebox_left element.
shadebox_arrow_l: null,
// DOM reference to the #gridshadebox_right element.
shadebox_arrow_r: null
};

/**
Expand All @@ -67,6 +63,7 @@ M.format_grid.init = function(Y, the_editing_on, the_section_redirect, the_num_s
this.section_redirect = the_section_redirect;
this.selected_section = null;
this.num_sections = parseInt(the_num_sections);
//console.log("the_num_sections parameter: " + the_num_sections);
//console.log("SSA parameter: " + the_shadebox_shown_array);
//this.shadebox_shown_array = JSON.parse(the_shadebox_shown_array);
this.shadebox_shown_array = the_shadebox_shown_array;
Expand Down Expand Up @@ -97,6 +94,7 @@ M.format_grid.init = function(Y, the_editing_on, the_section_redirect, the_num_s
var shadeboxtoggletwo = Y.one("#gridshadebox_close");
if (shadeboxtoggletwo) {
shadeboxtoggletwo.on('click', this.icon_toggle, this);
document.getElementById("gridshadebox_close").style.display = "";
}
var shadeboxarrowleft = Y.one("#gridshadebox_left");
if (shadeboxarrowleft) {
Expand All @@ -111,19 +109,12 @@ M.format_grid.init = function(Y, the_editing_on, the_section_redirect, the_num_s
for(var i = 0; i < icon_links.length; i++) {
icon_links[i].href = "#";
}
document.getElementById("gridshadebox_close").style.display = "";
document.getElementById("gridshadebox_left").style.display = "";
document.getElementById("gridshadebox_right").style.display = "";

M.format_grid.shadebox.initialize_shadebox();
M.format_grid.shadebox.update_shadebox();
window.onresize = function() {
M.format_grid.shadebox.update_shadebox();
}

// Arrows.
this.shadebox_arrow_l = document.getElementById("gridshadebox_left");
this.shadebox_arrow_r = document.getElementById("gridshadebox_right");
}
this.shadebox_content = Y.one("#gridshadebox_content");
this.shadebox_content.removeClass('hide_content'); // Content 'flash' prevention.
Expand Down Expand Up @@ -165,7 +156,6 @@ M.format_grid.icon_toggle = function(e) {
//console.log("Shadebox was closed");
this.icon_change_shown();
this.shadebox.toggle_shadebox();
//this.update_arrows();
}
} //else {
//console.log("Grid format:icon_toggle() - no selected section to show.");
Expand Down Expand Up @@ -205,7 +195,6 @@ M.format_grid.change_selected_section = function(increase_section) {
//console.log("Selected section no is now: " + this.selected_section_no);
if (M.format_grid.shadebox.shadebox_open == true) {
this.icon_change_shown();
//this.update_arrows();
}
} //else {
//console.log("Grid format:change_selected_section() - no selected section to show.");
Expand All @@ -226,18 +215,6 @@ M.format_grid.icon_change_shown = function() {
this.selected_section.removeClass('hide_section');
};

/**
* Changes the position of the shade box arrows to be in the centre when the section changes.
*/
M.format_grid.update_arrows = function() {
"use strict";
var computed_height = ((this.shadebox_content.get('clientHeight') / 2) - 8);
//console.log(this.shadebox_content.getComputedStyle('height'));
//console.log(this.shadebox_content.get('clientHeight'));
this.shadebox_arrow_l.style.top = computed_height + "px";
this.shadebox_arrow_r.style.top = computed_height + "px";
};

/**
* Works out what the 'next' section should be given the starting point and direction. If called from
* init() then will ignore that there is no current section upon which to 'un-select' before we select
Expand Down Expand Up @@ -281,7 +258,7 @@ M.format_grid.find_next_shown_section = function(starting_point, increase_sectio
"use strict";
var found = false;
var current = starting_point;
var next = -1;
var next = starting_point;

while(found == false) {
if (increase_section == true) {
Expand All @@ -298,7 +275,7 @@ M.format_grid.find_next_shown_section = function(starting_point, increase_sectio

// Guard against repeated looping code...
if (current == starting_point) {
found = true; // Exit loop and 'next' will be '-1'.
found = true; // Exit loop and 'next' will be the starting point.
} else if (this.shadebox_shown_array[current] == 2) { // This section can be shown.
next = current;
found = true; // Exit loop and 'next' will be 'current'.
Expand Down
35 changes: 19 additions & 16 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,25 @@ public function print_multiple_section_page($course, $sections, $mods, $modnames
'src' => $this->output->pix_url('close', 'format_grid'),
'role' => 'link',
'aria-label' => get_string('closeshadebox', 'format_grid')));
echo html_writer::start_tag('div', array('id' => 'gridshadebox_left',
'class' => 'gridshadebox_left_area',
'role' => 'link',
'aria-label' => get_string('previoussection', 'format_grid')));
echo html_writer::tag('img', '', array('class' => 'gridshadebox_arrow gridshadebox_left'.$deviceextra,
'src' => $this->output->pix_url('fa-arrow-circle-left-w', 'format_grid')));
echo html_writer::end_tag('div');
echo html_writer::start_tag('div', array('id' => 'gridshadebox_right',
'class' => 'gridshadebox_right_area',
'role' => 'link',
'aria-label' => get_string('nextsection', 'format_grid')));
echo html_writer::tag('img', '', array('class' => 'gridshadebox_arrow gridshadebox_right'.$deviceextra,
'src' => $this->output->pix_url('fa-arrow-circle-right-w', 'format_grid')));
echo html_writer::end_tag('div');

// Only show the arrows if there is more than one box shown.
if (($course->numsections > 1) || (($course->numsections == 1) && (!$this->topic0_at_top))) {
echo html_writer::start_tag('div', array('id' => 'gridshadebox_left',
'class' => 'gridshadebox_left_area',
'role' => 'link',
'aria-label' => get_string('previoussection', 'format_grid')));
echo html_writer::tag('img', '', array('class' => 'gridshadebox_arrow gridshadebox_left'.$deviceextra,
'src' => $this->output->pix_url('fa-arrow-circle-left-w', 'format_grid')));
echo html_writer::end_tag('div');
echo html_writer::start_tag('div', array('id' => 'gridshadebox_right',
'class' => 'gridshadebox_right_area',
'role' => 'link',
'aria-label' => get_string('nextsection', 'format_grid')));
echo html_writer::tag('img', '', array('class' => 'gridshadebox_arrow gridshadebox_right'.$deviceextra,
'src' => $this->output->pix_url('fa-arrow-circle-right-w', 'format_grid')));
echo html_writer::end_tag('div');
}

echo $this->start_section_list();
// If currently moving a file then show the current clipboard.
$this->make_block_show_clipboard_if_file_moving($course);
Expand Down Expand Up @@ -268,8 +273,6 @@ private function make_block_topic0($course, $sections, $modinfo, $editing, $urlp
'aria-label' => $sectionname)
);

echo html_writer::tag('div', '&nbsp;', array('class' => 'right side'));

echo html_writer::start_tag('div', array('class' => 'content'));

if (!$onsectionpage) {
Expand Down

0 comments on commit 6761c4c

Please sign in to comment.