From 7ca3ad91a0292e8a12e5a0632a4063deb92e169a Mon Sep 17 00:00:00 2001 From: Jerome Mouneyrac Date: Tue, 25 Feb 2014 14:03:38 +0800 Subject: [PATCH] MDL-44227 Atto: the screenreader helper now displays some texts when alt or title don\'t exist --- .../moodle-atto_accessibilityhelper-button-debug.js | 12 +++++++++++- .../moodle-atto_accessibilityhelper-button-min.js | 2 +- .../moodle-atto_accessibilityhelper-button.js | 12 +++++++++++- .../accessibilityhelper/yui/src/button/js/button.js | 12 +++++++++++- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/lib/editor/atto/plugins/accessibilityhelper/yui/build/moodle-atto_accessibilityhelper-button/moodle-atto_accessibilityhelper-button-debug.js b/lib/editor/atto/plugins/accessibilityhelper/yui/build/moodle-atto_accessibilityhelper-button/moodle-atto_accessibilityhelper-button-debug.js index 776fde8e97b58..6a849558ade8a 100644 --- a/lib/editor/atto/plugins/accessibilityhelper/yui/build/moodle-atto_accessibilityhelper-button/moodle-atto_accessibilityhelper-button-debug.js +++ b/lib/editor/atto/plugins/accessibilityhelper/yui/build/moodle-atto_accessibilityhelper-button/moodle-atto_accessibilityhelper-button-debug.js @@ -138,9 +138,19 @@ M.atto_accessibilityhelper = M.atto_accessibilityhelper || { listitem, selectimage; editable.all('img').each(function(image) { + + // Get the alt or title or img url of the image. + var imgalt = image.getAttribute('alt'); + if (imgalt === '') { + imgalt = image.getAttribute('title'); + if (imgalt === '') { + imgalt = image.getAttribute('src'); + } + } + selectimage = Y.Node.create('' + - Y.Escape.html(image.getAttribute('alt')) + + Y.Escape.html(imgalt) + ''); selectimage.setData('sourceimage', image); diff --git a/lib/editor/atto/plugins/accessibilityhelper/yui/build/moodle-atto_accessibilityhelper-button/moodle-atto_accessibilityhelper-button-min.js b/lib/editor/atto/plugins/accessibilityhelper/yui/build/moodle-atto_accessibilityhelper-button/moodle-atto_accessibilityhelper-button-min.js index fea706586cc7d..80e0359464a60 100644 --- a/lib/editor/atto/plugins/accessibilityhelper/yui/build/moodle-atto_accessibilityhelper-button/moodle-atto_accessibilityhelper-button-min.js +++ b/lib/editor/atto/plugins/accessibilityhelper/yui/build/moodle-atto_accessibilityhelper-button/moodle-atto_accessibilityhelper-button-min.js @@ -1 +1 @@ -YUI.add("moodle-atto_accessibilityhelper-button",function(e,t){var n={STYLESLABEL:"atto_accessibilityhelper_styleslabel",LISTSTYLES:"atto_accessibilityhelper_liststyles",LINKSLABEL:"atto_accessibilityhelper_linkslabel",LISTLINKS:"atto_accessibilityhelper_listlinks",IMAGESLABEL:"atto_accessibilityhelper_imageslabel",LISTIMAGES:"atto_accessibilityhelper_listimages"},r={LISTSTYLES:"#atto_accessibilityhelper_liststyles",LISTLINKS:"#atto_accessibilityhelper_listlinks",LISTIMAGES:"#atto_accessibilityhelper_listimages"};M.atto_accessibilityhelper=M.atto_accessibilityhelper||{dialogue:null,display_ui:function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t);var n;M.atto_accessibilityhelper.dialogue?n=M.atto_accessibilityhelper.dialogue:(n=new M.core.dialogue({visible:!1,modal:!0,close:!0,draggable:!0}),n.set("headerContent",M.util.get_string("pluginname","atto_accessibilityhelper")),n.render()),n.set("bodyContent",M.atto_accessibilityhelper.get_content(t)),n.centerDialogue(),n.show(),M.atto_accessibilityhelper.dialogue=n},init:function(e){var t=M.util.image_url("e/visual_aid","core");M.editor_atto.add_toolbar_button(e.elementid,"accessibilityhelper",t,e.group,this.display_ui)},image_selected:function(e,t){e.preventDefault(),M.atto_accessibilityhelper.dialogue.hide();var n=e.target.getData("sourceimage"),r=M.editor_atto.get_selection_from_node(n);M.editor_atto.selections[t]=r,M.editor_atto.focus(t)},list_images:function(t){var n=e.Node.create("
    "),r=M.editor_atto.get_editable_node(t),i,s;return r.all("img").each(function(r){s=e.Node.create(''+e.Escape.html(r.getAttribute("alt"))+""),s.setData("sourceimage",r),s.on("click",this.image_selected,this,t),i=e.Node.create("
  1. "),i.append(s),n.append(i)},this),n.hasChildNodes()||n.append("
  2. "+M.util.get_string("noimages","atto_accessibilityhelper")+"
  3. "),n},link_selected:function(e,t){e.preventDefault(),M.atto_accessibilityhelper.dialogue.hide();var n=e.target.getData("sourcelink"),r=M.editor_atto.get_selection_from_node(n);M.editor_atto.selections[t]=r,M.editor_atto.focus(t)},list_links:function(t){var n=e.Node.create("
      "),r=M.editor_atto.get_editable_node(t),i,s;return r.all("a").each(function(r){s=e.Node.create(''+e.Escape.html(r.get("text"))+""),s.setData("sourcelink",r),s.on("click",this.link_selected,this,t),i=e.Node.create("
    1. "),i.append(s),n.append(i)},this),n.hasChildNodes()||n.append("
    2. "+M.util.get_string("nolinks","atto_accessibilityhelper")+"
    3. "),n},list_styles:function(t){var n=[],r=M.editor_atto.get_selection_parent_node(),i=M.editor_atto.get_editable_node(t),s;r&&(r=e.one(r));while(r&&r!==i)s=r.get("tagName"),typeof s!="undefined"&&n.push(e.Escape.html(s)),r=r.ancestor();return n.length===0&&n.push(M.util.get_string("nostyles","atto_accessibilityhelper")),n.reverse(),n.join(", ")},get_content:function(t){var i='

      '+M.util.get_string("liststyles","atto_accessibilityhelper")+"
      "+'

      ',s=e.Node.create(i);return s.one(r.LISTSTYLES).append(this.list_styles(t)),i='

      '+M.util.get_string("listlinks","atto_accessibilityhelper")+"
      "+'

      ',s.append(i),s.one(r.LISTLINKS).append(this.list_links(t)),i='

      '+M.util.get_string("listimages","atto_accessibilityhelper")+"
      "+'

      ',s.append(i),s.one(r.LISTIMAGES).append(this.list_images(t)),s}}},"@VERSION@",{requires:["node","escape"]}); +YUI.add("moodle-atto_accessibilityhelper-button",function(e,t){var n={STYLESLABEL:"atto_accessibilityhelper_styleslabel",LISTSTYLES:"atto_accessibilityhelper_liststyles",LINKSLABEL:"atto_accessibilityhelper_linkslabel",LISTLINKS:"atto_accessibilityhelper_listlinks",IMAGESLABEL:"atto_accessibilityhelper_imageslabel",LISTIMAGES:"atto_accessibilityhelper_listimages"},r={LISTSTYLES:"#atto_accessibilityhelper_liststyles",LISTLINKS:"#atto_accessibilityhelper_listlinks",LISTIMAGES:"#atto_accessibilityhelper_listimages"};M.atto_accessibilityhelper=M.atto_accessibilityhelper||{dialogue:null,display_ui:function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t);var n;M.atto_accessibilityhelper.dialogue?n=M.atto_accessibilityhelper.dialogue:(n=new M.core.dialogue({visible:!1,modal:!0,close:!0,draggable:!0}),n.set("headerContent",M.util.get_string("pluginname","atto_accessibilityhelper")),n.render()),n.set("bodyContent",M.atto_accessibilityhelper.get_content(t)),n.centerDialogue(),n.show(),M.atto_accessibilityhelper.dialogue=n},init:function(e){var t=M.util.image_url("e/visual_aid","core");M.editor_atto.add_toolbar_button(e.elementid,"accessibilityhelper",t,e.group,this.display_ui)},image_selected:function(e,t){e.preventDefault(),M.atto_accessibilityhelper.dialogue.hide();var n=e.target.getData("sourceimage"),r=M.editor_atto.get_selection_from_node(n);M.editor_atto.selections[t]=r,M.editor_atto.focus(t)},list_images:function(t){var n=e.Node.create("
        "),r=M.editor_atto.get_editable_node(t),i,s;return r.all("img").each(function(r){var o=r.getAttribute("alt");o===""&&(o=r.getAttribute("title"),o===""&&(o=r.getAttribute("src"))),s=e.Node.create(''+e.Escape.html(o)+""),s.setData("sourceimage",r),s.on("click",this.image_selected,this,t),i=e.Node.create("
      1. "),i.append(s),n.append(i)},this),n.hasChildNodes()||n.append("
      2. "+M.util.get_string("noimages","atto_accessibilityhelper")+"
      3. "),n},link_selected:function(e,t){e.preventDefault(),M.atto_accessibilityhelper.dialogue.hide();var n=e.target.getData("sourcelink"),r=M.editor_atto.get_selection_from_node(n);M.editor_atto.selections[t]=r,M.editor_atto.focus(t)},list_links:function(t){var n=e.Node.create("
          "),r=M.editor_atto.get_editable_node(t),i,s;return r.all("a").each(function(r){s=e.Node.create(''+e.Escape.html(r.get("text"))+""),s.setData("sourcelink",r),s.on("click",this.link_selected,this,t),i=e.Node.create("
        1. "),i.append(s),n.append(i)},this),n.hasChildNodes()||n.append("
        2. "+M.util.get_string("nolinks","atto_accessibilityhelper")+"
        3. "),n},list_styles:function(t){var n=[],r=M.editor_atto.get_selection_parent_node(),i=M.editor_atto.get_editable_node(t),s;r&&(r=e.one(r));while(r&&r!==i)s=r.get("tagName"),typeof s!="undefined"&&n.push(e.Escape.html(s)),r=r.ancestor();return n.length===0&&n.push(M.util.get_string("nostyles","atto_accessibilityhelper")),n.reverse(),n.join(", ")},get_content:function(t){var i='

          '+M.util.get_string("liststyles","atto_accessibilityhelper")+"
          "+'

          ',s=e.Node.create(i);return s.one(r.LISTSTYLES).append(this.list_styles(t)),i='

          '+M.util.get_string("listlinks","atto_accessibilityhelper")+"
          "+'

          ',s.append(i),s.one(r.LISTLINKS).append(this.list_links(t)),i='

          '+M.util.get_string("listimages","atto_accessibilityhelper")+"
          "+'

          ',s.append(i),s.one(r.LISTIMAGES).append(this.list_images(t)),s}}},"@VERSION@",{requires:["node","escape"]}); diff --git a/lib/editor/atto/plugins/accessibilityhelper/yui/build/moodle-atto_accessibilityhelper-button/moodle-atto_accessibilityhelper-button.js b/lib/editor/atto/plugins/accessibilityhelper/yui/build/moodle-atto_accessibilityhelper-button/moodle-atto_accessibilityhelper-button.js index 776fde8e97b58..6a849558ade8a 100644 --- a/lib/editor/atto/plugins/accessibilityhelper/yui/build/moodle-atto_accessibilityhelper-button/moodle-atto_accessibilityhelper-button.js +++ b/lib/editor/atto/plugins/accessibilityhelper/yui/build/moodle-atto_accessibilityhelper-button/moodle-atto_accessibilityhelper-button.js @@ -138,9 +138,19 @@ M.atto_accessibilityhelper = M.atto_accessibilityhelper || { listitem, selectimage; editable.all('img').each(function(image) { + + // Get the alt or title or img url of the image. + var imgalt = image.getAttribute('alt'); + if (imgalt === '') { + imgalt = image.getAttribute('title'); + if (imgalt === '') { + imgalt = image.getAttribute('src'); + } + } + selectimage = Y.Node.create('' + - Y.Escape.html(image.getAttribute('alt')) + + Y.Escape.html(imgalt) + ''); selectimage.setData('sourceimage', image); diff --git a/lib/editor/atto/plugins/accessibilityhelper/yui/src/button/js/button.js b/lib/editor/atto/plugins/accessibilityhelper/yui/src/button/js/button.js index cf4db4bb4ea02..c415c2ca26f69 100644 --- a/lib/editor/atto/plugins/accessibilityhelper/yui/src/button/js/button.js +++ b/lib/editor/atto/plugins/accessibilityhelper/yui/src/button/js/button.js @@ -136,9 +136,19 @@ M.atto_accessibilityhelper = M.atto_accessibilityhelper || { listitem, selectimage; editable.all('img').each(function(image) { + + // Get the alt or title or img url of the image. + var imgalt = image.getAttribute('alt'); + if (imgalt === '') { + imgalt = image.getAttribute('title'); + if (imgalt === '') { + imgalt = image.getAttribute('src'); + } + } + selectimage = Y.Node.create('' + - Y.Escape.html(image.getAttribute('alt')) + + Y.Escape.html(imgalt) + ''); selectimage.setData('sourceimage', image);