diff --git a/Readme.md b/Readme.md index 8d299873..e5f52330 100644 --- a/Readme.md +++ b/Readme.md @@ -249,6 +249,10 @@ can be really useful in visualising the issue along with any files you consider Version Information =================== +20th September 2014 Version 2.6.1.7 + 1. Fixed issue where a debug message was being written to the PHP error log. + 2. When toggle persistence is off then the state of the toggles on page load will depend on the default user preference setting. + 18th August 2014 Version 2.6.1.6 1. Fixed CONTRIB-5211: Section 5 does not remain expanded when browsing away and back. @@ -1103,6 +1107,6 @@ Desired Enhancements Me == -G J Barnard MSc. BSc(Hons)(Sndw). MBCS. CEng. CITP. PGCE. - 17th April 2014. +G J Barnard MSc. BSc(Hons)(Sndw). MBCS. CEng. CITP. PGCE. - 20th September 2014. Moodle profile: http://moodle.org/user/profile.php?id=442195. Web profile : http://about.me/gjbarnard diff --git a/format.php b/format.php index fbaa004d..93853b15 100644 --- a/format.php +++ b/format.php @@ -85,8 +85,14 @@ if (!empty($displaysection)) { $renderer->print_single_section_page($course, null, null, null, null, $displaysection); } else { - user_preference_allow_ajax_update('topcoll_toggle_' . $course->id, PARAM_TOPCOLL); - $userpreference = get_user_preferences('topcoll_toggle_' . $course->id); + $defaulttogglepersistence = clean_param(get_config('format_topcoll', 'defaulttogglepersistence'), PARAM_INT); + + if ($defaulttogglepersistence == 1) { + user_preference_allow_ajax_update('topcoll_toggle_' . $course->id, PARAM_TOPCOLL); + $userpreference = get_user_preferences('topcoll_toggle_' . $course->id); + } else { + $userpreference = null; + } $renderer->set_user_preference($userpreference); $defaultuserpreference = clean_param(get_config('format_topcoll', 'defaultuserpreference'), PARAM_INT); @@ -96,7 +102,7 @@ $course->id, $userpreference, $course->numsections, - clean_param(get_config('format_topcoll', 'defaulttogglepersistence'), PARAM_INT), + $defaulttogglepersistence, $defaultuserpreference)); $tcsettings = $courseformat->get_settings(); diff --git a/lang/en/format_topcoll.php b/lang/en/format_topcoll.php index 0ac63386..8004e352 100644 --- a/lang/en/format_topcoll.php +++ b/lang/en/format_topcoll.php @@ -129,7 +129,7 @@ 'Weeks' - where each section is presented as a week in ascending week order from the start date of the course. -'Current Week First' - which is the same as weeks but the current week is shown at the top and preceding weeks in decending order are displayed below except in editing mode where the structure is the same as 'Weeks'. +'Current Week First' - which is the same as weeks but the current week is shown at the top and preceding weeks in descending order are displayed below except in editing mode where the structure is the same as 'Weeks'. 'Current Topic First' - which is the same as 'Topics' except that the current topic is shown at the top if it has been set. @@ -265,11 +265,11 @@ $string['defaulttgbghvrcolour_desc'] = "Toggle background hover colour in hexidecimal RGB."; $string['defaulttogglepersistence'] = 'Toggle persistence'; -$string['defaulttogglepersistence_desc'] = "'On' or 'Off'. You may wish to turn off for an AJAX performance increase but user toggle selections will not be recalled on page refresh or revisit. +$string['defaulttogglepersistence_desc'] = "'On' or 'Off'. Turn off for an AJAX performance increase but user toggle selections will not be remembered on page refresh or revisit. -Note: If turning persistence off remove any rows containing 'topcoll_toggle_x' in the 'name' field +Note: When turning persistence off, please remove any rows containing 'topcoll_toggle_x' in the 'name' field of the 'user_preferences' table in the database. Where the 'x' in 'topcoll_toggle_x' will be - a course id."; + a course id. This is to save space if you do not intend to turn it back on."; $string['defaulttogglealignment'] = 'Default toggle text alignment'; $string['defaulttogglealignment_desc'] = "'Left', 'Centre' or 'Right'."; diff --git a/module.js b/module.js index a1e19d45..ffab3ab3 100644 --- a/module.js +++ b/module.js @@ -41,6 +41,7 @@ M.format_topcoll.courseid; M.format_topcoll.togglePersistence = 1; // Toggle persistence - 1 = on, 0 = off. M.format_topcoll.ourYUI; M.format_topcoll.numSections; +M.format_topcoll.ie8; // Namespace constants: M.format_topcoll.TOGGLE_6 = 1; @@ -68,7 +69,10 @@ M.format_topcoll.init = function(Y, theCourseId, theToggleState, theNumSections, this.numSections = parseInt(theNumSections); this.togglePersistence = theTogglePersistence; - if (this.togglestate !== null) { + // IE8 - humm! + var bodyNode = Y.one(document.body); + M.format_topcoll.ie8 = bodyNode.hasClass('ie8'); + if ((this.togglestate !== null) && (this.togglePersistence == 1)) { // Toggle persistence - 1 = on, 0 = off. if (this.is_old_preference(this.togglestate) == true) { // Old preference, so convert to new. this.convert_to_new_preference(); @@ -160,6 +164,12 @@ M.format_topcoll.toggle_topic = function(targetNode, toggleNum) { targetNode.next('.toggledsection').removeClass('sectionopen'); state = false; } + //IE 8 Hack/workaround to force IE8 to repaint everything + if (M.format_topcoll.ie8) { + M.format_topcoll.ourYUI.all(".toggle a").addClass('ie8_hackclass_donotuseincss').removeClass('ie8_hackclass_donotuseincss'); + console.log('IE8 repaint.'); + } + this.set_toggle_state(toggleNum, state); this.save_toggles(); }; @@ -219,8 +229,8 @@ M.format_topcoll.convert_to_new_preference = function() { this.togglestate = ""; var logbintext = ""; - for (var i = 1; i <= 43; i = i+6) { - bin = toggleBinary.substring(i, i+6); + for (var i = 1; i <= 43; i = i + 6) { + bin = toggleBinary.substring(i, i + 6); value = parseInt(bin, 2); this.togglestate += this.encode_value_to_character(value); logbintext += bin + ' '; @@ -242,14 +252,14 @@ M.format_topcoll.set_toggle_state = function(togglenum, state) { "use strict"; var togglecharpos = this.get_toggle_pos(togglenum); var toggleflag = this.get_toggle_flag(togglenum, togglecharpos); - var value = this.decode_character_to_value(this.togglestate.charAt(togglecharpos-1)); + var value = this.decode_character_to_value(this.togglestate.charAt(togglecharpos - 1)); if (state == true) { value |= toggleflag; } else { value &= ~toggleflag; } var newchar = this.encode_value_to_character(value); - var start = this.togglestate.substring(0,togglecharpos-1); + var start = this.togglestate.substring(0,togglecharpos - 1); var end = this.togglestate.substring(togglecharpos); this.togglestate = start + newchar + end; }; @@ -276,7 +286,7 @@ M.format_topcoll.get_max_digit = function() { M.format_topcoll.get_toggle_flag = function(togglenum, togglecharpos) { "use strict"; - var toggleflagpos = togglenum - ((togglecharpos-1)*6); + var toggleflagpos = togglenum - ((togglecharpos - 1) * 6); var flag; switch (toggleflagpos) { case 1: diff --git a/renderer.php b/renderer.php index 7958ead0..0b957718 100644 --- a/renderer.php +++ b/renderer.php @@ -382,7 +382,7 @@ protected function section_header($section, $course, $onsectionpage, $sectionret $title = $this->courseformat->get_topcoll_section_name($course, $section, true); if (($this->mobiletheme === false) && ($this->tablettheme === false)) { - $o .= $this->output->heading($title, 3, 'sectionname'); + $o .= $this->output->heading($title, 3, 'section-title'); } else { $o .= html_writer::tag('h3', $title); // Moodle H3's look bad on mobile / tablet with CT so use plain. } @@ -410,7 +410,7 @@ protected function section_header($section, $course, $onsectionpage, $sectionret $hasnamesecpg = ($section->section == 0 && (string) $section->name !== ''); if ($hasnamesecpg) { - $o .= $this->output->heading($this->section_title($section, $course), 3, 'sectionname'); + $o .= $this->output->heading($this->section_title($section, $course), 3, 'section-title'); } $o .= html_writer::start_tag('div', array('class' => 'summary')); $o .= $this->format_summary_text($section); @@ -474,7 +474,7 @@ protected function section_hidden($section) { $title = get_string('notavailable'); if (($this->mobiletheme === false) && ($this->tablettheme === false)) { - $o .= $this->output->heading($title, 3, 'sectionname'); + $o .= $this->output->heading($title, 3, 'section-title'); } else { $o .= html_writer::tag('h3', $title); // Moodle H3's look bad on mobile / tablet with CT so use plain. } diff --git a/settopcollpref.php b/settopcollpref.php index 4eeb9b31..d4d668eb 100644 --- a/settopcollpref.php +++ b/settopcollpref.php @@ -45,7 +45,6 @@ // Get and set the value. $value = required_topcoll_param('value', $USER->ajax_updatable_user_prefs[$name]); -error_log($name.' is before: '.$USER->ajax_updatable_user_prefs[$name].' after: '.$value); // Update if (!set_user_preference($name, $value)) { print_error('errorsettinguserpref'); diff --git a/styles.css b/styles.css index 4d06e91a..31d379dc 100644 --- a/styles.css +++ b/styles.css @@ -93,8 +93,8 @@ body.tablettheme .course-content ul.ctopics li.tcsection .content, body.tabletth word-break: break-all; } -.course-content ul.ctopics li.section .content .toggle a h3.sectionname, -.course-content ul.ctopics li.section .content.sectionhidden h3.sectionname { +.course-content ul.ctopics li.section .content .toggle a h3.section-title, +.course-content ul.ctopics li.section .content.sectionhidden h3.section-title { margin: 4px; } diff --git a/version.php b/version.php index 87f6cc61..1fbf39d6 100644 --- a/version.php +++ b/version.php @@ -33,8 +33,8 @@ */ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2014041801; +$plugin->version = 2014041802; $plugin->maturity = MATURITY_STABLE; $plugin->requires = 2013111800.00; // 2.6 (Build: 20131118). $plugin->component = 'format_topcoll'; -$plugin->release = '2.6.1.6'; +$plugin->release = '2.6.1.7';