From c076f4beeff099035e580ddc760d596bad3001a2 Mon Sep 17 00:00:00 2001 From: nfreear <nfreear> Date: Tue, 18 Dec 2007 17:18:19 +0000 Subject: [PATCH] Fixes reopened MDL-7493 "Make sure standard themes are visible under "Windows High Contrast Black" mode" - foreground show/hide block icon/ALT text switched with Javscript. --- blocks/moodleblock.class.php | 20 ++++++++++---------- lang/en_utf8/access.php | 3 ++- lib/javascript-static.js | 24 +++++++++++++++++------- lib/weblib.php | 14 ++++++++------ pix/t/switch_minus.gif | Bin 119 -> 108 bytes pix/t/switch_plus.gif | Bin 124 -> 111 bytes theme/standard/styles_color.css | 15 +-------------- theme/standard/styles_layout.css | 7 ++----- 8 files changed, 40 insertions(+), 43 deletions(-) diff --git a/blocks/moodleblock.class.php b/blocks/moodleblock.class.php index c6d2b44b26..dd3b406071 100644 --- a/blocks/moodleblock.class.php +++ b/blocks/moodleblock.class.php @@ -332,16 +332,16 @@ class block_base { $title = '<div class="title">'; if (!empty($CFG->allowuserblockhiding)) { - //Accessibility: added static 'alt' text for the +- icon. - //TODO (nfreear): language string 'hide OR show block' - $title .= '<div class="hide-show">'. - '<a title="'.get_string('showhideblock','access'). - '" href="#" onclick="elementToggleHide(this, true, function(el) {'. - 'return findParentNode(el, \'DIV\', \'sideblock\'); '. - '}, \''.$CFG->pixpath.'\' ); return false;">'. - '<img src="'.$CFG->pixpath.'/spacer.gif" '. - 'id = "togglehide_inst'.$this->instance->id.'" '. - 'alt="'.get_string('showhideblock','access').'" class="hide-show-image" /></a></div>'; + //Accessibility: added 'alt' text for the +- icon. + //Theme the buttons using, Admin - Miscellaneous - smartpix. + $strshow = addslashes_js(get_string('showblocka', 'access', $this->title)); + $strhide = addslashes_js(get_string('hideblocka', 'access', $this->title)); + $title .= '<input type="image" src="'.$CFG->pixpath.'/t/switch_minus.gif" '. + 'id="togglehide_inst'.$this->instance->id.'" '. + 'onclick="elementToggleHide(this, true, function(el) {'. + 'return findParentNode(el, \'DIV\', \'sideblock\'); },'. + ' \''.$strshow.'\', \''.$strhide.'\'); return false;" '. + 'alt="'.$strhide.'" title="'.$strhide.'" class="hide-show-image" />'; } //Accesssibility: added H2 (was in, weblib.php: print_side_block) diff --git a/lang/en_utf8/access.php b/lang/en_utf8/access.php index 2f6b613e26..27bbdfa0d1 100644 --- a/lang/en_utf8/access.php +++ b/lang/en_utf8/access.php @@ -14,7 +14,8 @@ $string['currentweek'] = 'This week '; $string['currenttopic'] = 'This topic '; $string['monthnext'] = 'Next month'; $string['monthprev'] = 'Previous month'; -$string['showhideblock'] = 'Show or hide block'; +$string['showblocka'] = 'Show $a block'; +$string['hideblocka'] = 'Hide $a block'; $string['sitemap'] = 'Site map'; $string['skipa'] = 'Skip $a'; $string['skipblock'] = 'Skip block'; diff --git a/lib/javascript-static.js b/lib/javascript-static.js index 219a368f99..cdc283a245 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -347,19 +347,30 @@ function unmaskPassword(id) { If persistent == true, also sets a cookie for this. */ -function elementToggleHide(el, persistent, elementFinder) { +function elementToggleHide(el, persistent, elementFinder, strShow, strHide) { if(!elementFinder) { - var obj = el; + var obj = el; //el:container + el = document.getElementById('togglehide_'+obj.id); } else { - var obj = elementFinder(el); + var obj = elementFinder(el); //el:button. } if(obj.className.indexOf('hidden') == -1) { obj.className += ' hidden'; + if (el.src) { + el.src = el.src.replace('switch_minus', 'switch_plus'); + el.alt = strShow; + el.title = strShow; + } var shown = 0; } else { - obj.className = obj.className.replace(new RegExp(' ?hidden'), '') + obj.className = obj.className.replace(new RegExp(' ?hidden'), ''); + if (el.src) { + el.src = el.src.replace('switch_plus', 'switch_minus'); + el.alt = strHide; + el.title = strHide; + } var shown = 1; } @@ -368,12 +379,11 @@ function elementToggleHide(el, persistent, elementFinder) { } } - -function elementCookieHide(id) { +function elementCookieHide(id, strShow, strHide) { var obj = document.getElementById(id); var cook = new cookie('hide:' + id).read(); if(cook != null) { - elementToggleHide(obj, false); + elementToggleHide(obj, false, null, strShow, strHide); } } diff --git a/lib/weblib.php b/lib/weblib.php index a8e7d6c959..dc3c8ddc81 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -6403,7 +6403,7 @@ function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $fo } - print_side_block_end($attributes); + print_side_block_end($attributes, $title); echo $skip_dest; } @@ -6453,8 +6453,7 @@ function print_side_block_start($heading='', $attributes = array()) { echo '<div class="wrap">'."\n"; } if ($heading) { - //Accessibility: replaced <div> with H2; no, H2 more appropriate in moodleblock.class.php: _title_html. - // echo '<div class="header">'.$heading.'</div>'; + //Accessibility: H2 more appropriate in moodleblock.class.php: _title_html. echo '<div class="header">'; if (!empty($THEME->customcorners)) { echo '<div class="bt"><div> </div></div>'; @@ -6484,7 +6483,7 @@ function print_side_block_start($heading='', $attributes = array()) { /** * Print table ending tags for a side block box. */ -function print_side_block_end($attributes = array()) { +function print_side_block_end($attributes = array(), $title='') { global $CFG, $THEME; echo '</div>'; @@ -6495,10 +6494,13 @@ function print_side_block_end($attributes = array()) { echo '</div>'; + $strshow = addslashes_js(get_string('showblocka', 'access', $title)); + $strhide = addslashes_js(get_string('hideblocka', 'access', $title)); + // IE workaround: if I do it THIS way, it works! WTF? if (!empty($CFG->allowuserblockhiding) && isset($attributes['id'])) { - echo '<script type="text/javascript">'."\n//<![CDATA[\n".'elementCookieHide("'.$attributes['id'].'"); '. - "\n//]]>\n".'</script>'; + echo '<script type="text/javascript">'."\n//<![CDATA[\n".'elementCookieHide("'.$attributes['id']. + '","'.$strshow.'","'.$strhide."\");\n//]]>\n".'</script>'; } } diff --git a/pix/t/switch_minus.gif b/pix/t/switch_minus.gif index 959a5c2286ba8e2eacac86e2c917a0eec6be90db..96327ff410c6beb63d36821191d669f7c9b49f77 100644 GIT binary patch literal 108 zcmZ?wbhEHb<YwSz*v!CSXlOWR&YY!7m#$sAcI(!y{|N!bpDc_F4F4H)7=Qp|1_O(v h!3oc&yCrVVG2ef0JEICG+x)g={wH?Es=6~+0{}J7Iv4-| literal 119 zcmZ?wbhEHb<YwSz*v!kYY15{aD_15aCT`fUVdKV)D^{%7ym|AKDN~j&Up{Z%ytQlB zu3x`?&YU^_|NmzI1I3>#j0_CC3_2hl$P5M+6@x}jo>+}7XMbwMT4X4?Pe^rc=zXy3 V_Vi;JmFKc_jY6Jkw{tL90|4C(FZ=)i diff --git a/pix/t/switch_plus.gif b/pix/t/switch_plus.gif index 84ac3532459419c05bf4d53206d14f3864524fde..758b05e7b69e164bb924fd40b7d71cd6653b7653 100644 GIT binary patch literal 111 zcmZ?wbhEHb<YwSz*v!CSXlOWR&YY!7m#$sAcI(!y{|N!bpDc_F4F4H)7=Qp|1_O(X j!3oc&yCrVV`OX?Up>fs^292u9bc<avlG8&)85yhr?Jhds literal 124 zcmV-?0E7QWNk%w1VG95Y0J9DNva+)O|NmiOVX3L9u&}VPv9YMAsI#-Po}QkZoSc-D zl&7bst*x!Eudo0A{{R30A^8LW000gEEC2ui01E&M000Cj5P=B}ZELvAIWb*GXq?a$ e<YsaO=m;>pecd{z?}>+K*bxazWynxO0029>=rm;j diff --git a/theme/standard/styles_color.css b/theme/standard/styles_color.css index c43a675e72..d85666d8d9 100644 --- a/theme/standard/styles_color.css +++ b/theme/standard/styles_color.css @@ -408,19 +408,6 @@ table.flexible .r1 { border-bottom-color: #dddddd; } -.sideblock .header .hide-show img.hide-show-image { - background: url('../../pix/t/switch_minus.gif') no-repeat bottom; -} - -.sideblock.hidden .header .hide-show img.hide-show-image { - background: url('../../pix/t/switch_plus.gif') no-repeat bottom; -} - -/* Accessibility: for Windows High Contrast, partial fix MDL-7493. */ -.sideblock .hide-show a { - border:1px solid white; -} - /*** *** Blogs @@ -1073,4 +1060,4 @@ form.mform .fdescription.required { } form.mform .required .fgroup span label { color:#000; -} +} \ No newline at end of file diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index 0e411d6e04..0688f8e906 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -1184,11 +1184,8 @@ a.skip:focus, a.skip:active { padding:0; } -.sideblock .header .hide-show { +.sideblock .header .hide-show-image { float:right; -} - -.sideblock .header .hide-show img.hide-show-image { height:11px; width:11px; margin-top:0.25em; @@ -4156,4 +4153,4 @@ wikiadminactions { background: #eee; border: 1px dashed #ddd; padding: 3px; -} +} \ No newline at end of file -- 2.39.5