From: nfreear Date: Mon, 19 Nov 2007 17:22:04 +0000 (+0000) Subject: Fixes for bug MDL-12256, "Course AJAX has very poor accessibility - ALT text" (includ... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f8eaeffa21db05661b75690f9e947a7c834674cb;p=moodle.git Fixes for bug MDL-12256, "Course AJAX has very poor accessibility - ALT text" (includes white-space cleanup). --- diff --git a/lib/ajax/ajaxcourse.js b/lib/ajax/ajaxcourse.js index 723140944f..8b6c55e45b 100644 --- a/lib/ajax/ajaxcourse.js +++ b/lib/ajax/ajaxcourse.js @@ -145,13 +145,18 @@ main_class.prototype.get_section_index = function(el) { } -main_class.prototype.mk_button = function(tag, imgSrc, attributes, imgAttributes) { - //create button and return object +main_class.prototype.mk_button = function(tag, imgSrc, text, attributes, imgAttributes) { + //Create button and return object. + //Set the text: the container TITLE or image ALT attributes can be overridden, eg. + // main.mk_button('a', '/i/move_2d.gif', strmove, [['title', strmoveshort]]); var container = document.createElement(tag); - container.style.cursor = 'pointer'; + container.style.cursor = 'pointer'; + container.setAttribute('title', text); var image = document.createElement('img'); image.setAttribute('src', main.portal.strings['pixpath']+imgSrc); + image.setAttribute('alt', text); + //image.setAttribute('title', ''); container.appendChild(image); if (attributes != null) { @@ -161,7 +166,7 @@ main_class.prototype.mk_button = function(tag, imgSrc, attributes, imgAttributes } if (imgAttributes != null) { for (var c=0; cwwwroot."';\n"; $output .= " main.portal.strings['pixpath']='".$CFG->pixpath."';\n"; + $output .= " main.portal.strings['marker']='".get_string('markthistopic', '', '_var_')."';\n"; + $output .= " main.portal.strings['marked']='".get_string('markedthistopic', '', '_var_')."';\n"; + $output .= " main.portal.strings['hide']='".get_string('hide')."';\n"; + $output .= " main.portal.strings['hidesection']='".get_string('hidesection', '', '_var_')."';\n"; + $output .= " main.portal.strings['show']='".get_string('show')."';\n"; + $output .= " main.portal.strings['delete']='".get_string('delete')."';\n"; $output .= " main.portal.strings['move']='".get_string('move')."';\n"; + $output .= " main.portal.strings['movesection']='".get_string('movesection', '', '_var_')."';\n"; $output .= " main.portal.strings['moveleft']='".get_string('moveleft')."';\n"; $output .= " main.portal.strings['moveright']='".get_string('moveright')."';\n"; $output .= " main.portal.strings['update']='".get_string('update')."';\n"; diff --git a/lib/ajax/block_classes.js b/lib/ajax/block_classes.js index 51a0479bee..decb237b6f 100644 --- a/lib/ajax/block_classes.js +++ b/lib/ajax/block_classes.js @@ -202,10 +202,10 @@ block_class.prototype.reset_regions = function() { block_class.prototype.init_buttons = function() { - var viewbutton = main.mk_button('a', '/t/hide.gif', [['class', 'icon hide']]); + var viewbutton = main.mk_button('a', '/t/hide.gif', main.portal.strings['hide'], [['class', 'icon hide']]); YAHOO.util.Event.addListener(viewbutton, 'click', this.toggle_hide, this, true); - var deletebutton = main.mk_button('a', '/t/delete.gif', [['class', 'icon delete']]); + var deletebutton = main.mk_button('a', '/t/delete.gif', main.portal.strings['delete'], [['class', 'icon delete']]); YAHOO.util.Event.addListener(deletebutton, 'click', this.delete_button, this, true); this.viewbutton = viewbutton; @@ -220,10 +220,13 @@ block_class.prototype.init_buttons = function() { block_class.prototype.toggle_hide = function(e, target, isCosmetic) { - + var strhide = main.portal.strings['hide']; + var strshow = main.portal.strings['show']; if (YAHOO.util.Dom.hasClass(this.getEl(), 'hidden')) { this.getEl().className = this.originalClass; this.viewbutton.childNodes[0].src = this.viewbutton.childNodes[0].src.replace(/show.gif/i, 'hide.gif'); + this.viewbutton.childNodes[0].alt = this.viewbutton.childNodes[0].alt.replace(strshow, strhide); + this.viewbutton.title = this.viewbutton.title.replace(strshow, strhide); if (!isCosmetic) { main.connect('POST', 'class=block&field=visible', null, @@ -233,6 +236,8 @@ block_class.prototype.toggle_hide = function(e, target, isCosmetic) { this.originalClass = this.getEl().className; this.getEl().className = "hidden sideblock"; this.viewbutton.childNodes[0].src = this.viewbutton.childNodes[0].src.replace(/hide.gif/i,'show.gif'); + this.viewbutton.childNodes[0].alt = this.viewbutton.childNodes[0].alt.replace(strhide, strshow); + this.viewbutton.title = this.viewbutton.title.replace(strhide, strshow); if (!isCosmetic) { main.connect('POST', 'class=block&field=visible', null, diff --git a/lib/ajax/section_classes.js b/lib/ajax/section_classes.js index 1adcc78930..9c3cd5ef92 100755 --- a/lib/ajax/section_classes.js +++ b/lib/ajax/section_classes.js @@ -88,13 +88,14 @@ section_class.prototype.init_buttons = function() { commandContainer.removeChild(commandContainer.childNodes[i]) } - if (!this.isWeekFormat) { - var highlightbutton = main.mk_button('div', '/i/marker.gif'); + if (!this.isWeekFormat) { + var highlightbutton = main.mk_button('div', '/i/marker.gif', main.getString('marker', this.sectionId)); YAHOO.util.Event.addListener(highlightbutton, 'click', this.mk_marker, this, true); commandContainer.appendChild(highlightbutton); - this.highlightButton = highlightbutton; + this.highlightButton = highlightbutton; } - var viewbutton = main.mk_button('div', '/i/hide.gif'); + var viewbutton = main.mk_button('div', '/i/hide.gif', main.getString('hidesection', this.sectionId), + [['title', main.portal.strings['hide'] ]]); YAHOO.util.Event.addListener(viewbutton, 'click', this.toggle_hide, this,true); commandContainer.appendChild(viewbutton); this.viewButton = viewbutton; @@ -102,8 +103,8 @@ section_class.prototype.init_buttons = function() { section_class.prototype.add_handle = function() { - var handleRef = main.mk_button('a', '/i/move_2d.gif', - [['style','cursor:move'], ['title', main.portal.strings['move']]]); + var handleRef = main.mk_button('a', '/i/move_2d.gif', main.getString('movesection', this.sectionId), + [['title', main.portal.strings['move'] ], ['style','cursor:move']]); YAHOO.util.Dom.generateId(handleRef, 'sectionHandle'); @@ -284,9 +285,13 @@ section_class.prototype.swap_with_section = function(sectionIn) { section_class.prototype.toggle_hide = function(e,target,superficial) { - if (this.hidden) { + var strhide = main.portal.strings['hide']; + var strshow = main.portal.strings['show']; + if (this.hidden) { YAHOO.util.Dom.removeClass(this.getEl(), 'hidden'); - this.viewButton.childNodes[0].src = this.viewButton.childNodes[0].src.replace(/show.gif/i, 'hide.gif'); + this.viewButton.childNodes[0].src = this.viewButton.childNodes[0].src.replace(/show.gif/i, 'hide.gif'); + this.viewButton.childNodes[0].alt = this.viewButton.childNodes[0].alt.replace(strshow, strhide); + this.viewButton.title = this.viewButton.title.replace(strshow, strhide); this.hidden = false; if (!superficial) { @@ -299,7 +304,9 @@ section_class.prototype.toggle_hide = function(e,target,superficial) { } else { YAHOO.util.Dom.addClass(this.getEl(), 'hidden'); - this.viewButton.childNodes[0].src = this.viewButton.childNodes[0].src.replace(/hide.gif/i, 'show.gif'); + this.viewButton.childNodes[0].src = this.viewButton.childNodes[0].src.replace(/hide.gif/i, 'show.gif'); + this.viewButton.childNodes[0].alt = this.viewButton.childNodes[0].alt.replace(strhide, strshow); + this.viewButton.title = this.viewButton.title.replace(strhide, strshow); this.hidden = true; if (!superficial) { @@ -606,8 +613,8 @@ resource_class.prototype.init_buttons = function() { commandContainer.innerHTML = ''; // Add move-handle for drag and drop. - var handleRef = main.mk_button('a', '/i/move_2d.gif', - [['style', 'cursor:move'], ['title', main.portal.strings['move']]], + var handleRef = main.mk_button('a', '/i/move_2d.gif', main.portal.strings['move'], + [['style', 'cursor:move']], [['height', '11'], ['width', '11'], ['style', 'margin-right:3px; border:0;']]); YAHOO.util.Dom.generateId(handleRef, 'sectionHandle'); @@ -617,16 +624,16 @@ resource_class.prototype.init_buttons = function() { // Add indentation buttons if needed (move left, move right). if (moveLeft) { - var button = main.mk_button('a', '/t/left.gif', [['title', main.portal.strings['moveleft']], - ['class', 'editing_moveleft']]); + var button = main.mk_button('a', '/t/left.gif', main.portal.strings['moveleft'], + [['class', 'editing_moveleft']]); YAHOO.util.Event.addListener(button, 'click', this.indent_left, this, true); commandContainer.appendChild(button); this.indentLeftButton = button; } if (moveRight) { - var button = main.mk_button('a', '/t/right.gif', [['title', main.portal.strings['moveright']], - ['class', 'editing_moveright']]); + var button = main.mk_button('a', '/t/right.gif', main.portal.strings['moveright'], + [['class', 'editing_moveright']]); YAHOO.util.Event.addListener(button, 'click', this.indent_right, this, true); commandContainer.appendChild(button); this.indentRightButton = button; @@ -636,15 +643,15 @@ resource_class.prototype.init_buttons = function() { commandContainer.appendChild(updateButton); // Add the delete button. - var button = main.mk_button('a', '/t/delete.gif'); + var button = main.mk_button('a', '/t/delete.gif', main.portal.strings['delete']); YAHOO.util.Event.addListener(button, 'click', this.delete_button, this, true); commandContainer.appendChild(button); // Add the hide or show button. if (this.hidden) { - var button = main.mk_button('a', '/t/show.gif'); + var button = main.mk_button('a', '/t/show.gif', main.portal.strings['show']); } else { - var button = main.mk_button('a', '/t/hide.gif'); + var button = main.mk_button('a', '/t/hide.gif', main.portal.strings['hide']); } YAHOO.util.Event.addListener(button, 'click', this.toggle_hide, this, true); commandContainer.appendChild(button); @@ -653,11 +660,11 @@ resource_class.prototype.init_buttons = function() { // Add the groupmode button if needed. if (this.groupmode != null) { if (this.groupmode == this.NOGROUPS) { - var button = main.mk_button('a', '/t/groupn.gif', [['title', strgroupsnone]]); + var button = main.mk_button('a', '/t/groupn.gif', strgroupsnone); } else if (this.groupmode == this.SEPARATEGROUPS) { - var button = main.mk_button('a', '/t/groups.gif', [['title', strgroupsseparate]]); + var button = main.mk_button('a', '/t/groups.gif', strgroupsseparate); } else { - var button = main.mk_button('a', '/t/groupv.gif', [['title', strgroupsvisible]]); + var button = main.mk_button('a', '/t/groupv.gif', strgroupsvisible); } YAHOO.util.Event.addListener(button, 'click', this.toggle_groupmode, this, true); commandContainer.appendChild(button); @@ -704,6 +711,7 @@ resource_class.prototype.indent_right = function() { spacer.setAttribute('src', main.portal.strings['pixpath']+'/spacer.gif'); spacer.className = 'spacer'; + spacer.setAttribute('alt', ''); spacer.setAttribute('width', '20'); spacer.setAttribute('height', '12'); @@ -717,8 +725,8 @@ resource_class.prototype.indent_right = function() { 'span', this.getEl())[0]; if (!this.indentLeftButton) { - var button = main.mk_button('a', '/t/left.gif', [['title', main.portal.strings['moveleft']], - ['class', 'editing_moveleft']]); + var button = main.mk_button('a', '/t/left.gif', main.portal.strings['moveleft'], + [['class', 'editing_moveleft']]); YAHOO.util.Event.addListener(button, 'click', this.indent_left, this, true); commandContainer.insertBefore(button, this.indentRightButton); this.indentLeftButton = button; @@ -729,6 +737,8 @@ resource_class.prototype.indent_right = function() { resource_class.prototype.toggle_hide = function(target, e, superficial, force) { + var strhide = main.portal.strings['hide']; + var strshow = main.portal.strings['show']; if (force != null) { if (this.debug) { YAHOO.log("Resource "+this.getEl().id+" forced to "+force); @@ -738,6 +748,8 @@ resource_class.prototype.toggle_hide = function(target, e, superficial, force) { if (this.hidden) { YAHOO.util.Dom.removeClass(this.linkContainer, 'dimmed'); this.viewButton.childNodes[0].src = this.viewButton.childNodes[0].src.replace(/show.gif/i, 'hide.gif'); + this.viewButton.childNodes[0].alt = this.viewButton.childNodes[0].alt.replace(strshow, strhide); + this.viewButton.title = this.viewButton.title.replace(strshow, strhide); this.hidden = false; if (!superficial) { @@ -746,6 +758,8 @@ resource_class.prototype.toggle_hide = function(target, e, superficial, force) { } else { YAHOO.util.Dom.addClass(this.linkContainer, 'dimmed'); this.viewButton.childNodes[0].src = this.viewButton.childNodes[0].src.replace(/hide.gif/i, 'show.gif'); + this.viewButton.childNodes[0].alt = this.viewButton.childNodes[0].alt.replace(strhide, strshow); + this.viewButton.title = this.viewButton.title.replace(strhide, strshow); this.hidden = true; if (!superficial) { @@ -764,7 +778,7 @@ resource_class.prototype.toggle_groupmode = function() { this.groupmode = 0; } - var newtitle = this.groupButton.getElementsByTagName('img')[0].title; + var newtitle = this.groupButton.title; switch (this.groupmode) { case 0: @@ -777,8 +791,9 @@ resource_class.prototype.toggle_groupmode = function() { newtitle = main.portal.strings['groupsvisible']+' ('+main.portal.strings['clicktochange']+')'; break; } - - this.groupButton.getElementsByTagName('img')[0].title = newtitle; + + this.groupButton.getElementsByTagName('img')[0].alt = newtitle; + this.groupButton.title = newtitle; this.groupButton.getElementsByTagName('img')[0].src = main.portal.strings['pixpath']+this.groupImages[this.groupmode]; main.connect('POST', 'class=resource&field=groupmode', null, 'value='+this.groupmode+'&id='+this.id);