Merge branch 'MDL-76673-master' of https://github.com/meirzamoodle/moodle
This commit is contained in:
+1
-1
@@ -128,7 +128,7 @@ Y.namespace('M.atto_accessibilitychecker').Button = Y.Base.create('button', Y.M.
|
||||
lum2;
|
||||
|
||||
// Check for non-empty text.
|
||||
if (Y.Lang.trim(node.get('text')) !== '') {
|
||||
if (node.hasChildNodes() && Y.Lang.trim(node._node.childNodes[0].nodeValue) !== '') {
|
||||
foreground = Y.Color.fromArray(
|
||||
this._getComputedBackgroundColor(node, node.getComputedStyle('color')),
|
||||
Y.Color.TYPES.RGBA
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
YUI.add("moodle-atto_accessibilitychecker-button",function(d,t){var g="atto_accessibilitychecker";d.namespace("M.atto_accessibilitychecker").Button=d.Base.create("button",d.M.editor_atto.EditorPlugin,[],{initializer:function(){this.addButton({icon:"e/accessibility_checker",callback:this._displayDialogue})},_displayDialogue:function(){this.getDialogue({headerContent:M.util.get_string("pluginname",g),width:"500px",focusAfterHide:!0}).set("bodyContent",this._getDialogueContent()).show()},_getDialogueContent:function(){var t=d.Node.create('<div style="word-wrap: break-word;"></div>');return t.append(this._getWarnings()),t.delegate("click",function(t){t.preventDefault();var e=this.get("host"),t=t.currentTarget.getData("sourceNode"),i=this.getDialogue();t?(i.set("focusAfterHide",this.editor).hide(),e.setSelection(e.getSelectionFromNode(t))):i.hide()},"a",this),t},_getWarnings:function(){var t=d.Node.create("<div></div>"),n=[];return this.editor.all("img").each(function(t){var e=t.getAttribute("alt");void 0!==e&&""!==e||"presentation"!==t.getAttribute("role")&&n.push(t)},this),this._addWarnings(t,M.util.get_string("imagesmissingalt",g),n,!0),n=[],this.editor.all("*").each(function(t){var e,i,r,o;if(""!==d.Lang.trim(t.get("text"))&&(e=d.Color.fromArray(this._getComputedBackgroundColor(t,t.getComputedStyle("color")),d.Color.TYPES.RGBA),i=d.Color.fromArray(this._getComputedBackgroundColor(t),d.Color.TYPES.RGBA),e=this._getLuminanceFromCssColor(e),((i=this._getLuminanceFromCssColor(i))<e?(e+.05)/(i+.05):(i+.05)/(e+.05))<=4.5)){for(o=!1,r=r=0;r<n.length;r++){if(-1!==t.ancestors("*").indexOf(n[r])){o=!0;break}if(-1!==n[r].ancestors("*").indexOf(t)){n[r]=t,o=!0;break}}o||n.push(t)}},this),this._addWarnings(t,M.util.get_string("needsmorecontrast",g),n,!1),1e3<this.editor.get("text").length&&!this.editor.one("h3, h4, h5")&&this._addWarnings(t,M.util.get_string("needsmoreheadings",g),[this.editor],!1),n=[],this.editor.all("table").each(function(t){var e=t.one("caption");null!==e&&""!==e.get("text").trim()||n.push(t)},this),this._addWarnings(t,M.util.get_string("tablesmissingcaption",g),n,!1),n=[],this.editor.all("table").each(function(t){null!==t.one("[colspan],[rowspan]")&&n.push(t)},this),this._addWarnings(t,M.util.get_string("tableswithmergedcells",g),n,!1),n=[],this.editor.all("table").each(function(e){var i;e.one("tr").one("td")?e.all("tr").some(function(t){t=t.one("th");return(!t||""===t.get("text").trim())&&(n.push(e),!0)},this):(i=!1,e.one("tr").all("th").some(function(t){return i=!0,""===t.get("text").trim()&&(n.push(e),!0)}),i||n.push(e))},this),this._addWarnings(t,M.util.get_string("tablesmissingheaders",g),n,!1),t.hasChildNodes()||t.append("<p>"+M.util.get_string("nowarnings",g)+"</p>"),t},_addWarnings:function(t,e,i,r){var o,n,a,s,l;if(0<i.length){for(e=d.Node.create("<p>"+e+"</p>"),o=d.Node.create('<ol class="accessibilitywarnings"></ol>'),n=n=0;n<i.length;n++)s=d.Node.create("<li></li>"),(l=r?(a=i[n].getAttribute("src"),d.Node.create('<a href="#"><img src="'+a+'" /> '+a+"</a>")):(a="innerText"in i[n]?"innerText":"textContent",""===(l=i[n].get(a).trim())&&(l=M.util.get_string("emptytext",g)),i[n]===this.editor&&(l=M.util.get_string("entiredocument",g)),d.Node.create('<a href="#">'+l+"</a>"))).setData("sourceNode",i[n]),s.append(l),o.append(s);e.append(o),t.append(e)}},_getLuminanceFromCssColor:function(t){var e;return.2126*(e=function(t){return(t=parseInt(t,10)/255)<=.03928?t/=12.92:t=Math.pow((t+.055)/1.055,2.4),t})((t=d.Color.toArray(d.Color.toRGB(t="transparent"===t?"#ffffff":t)))[0])+.7152*e(t[1])+.0722*e(t[2])},_getComputedBackgroundColor:function(t,e){var i;return"transparent"===(e=e||t.getComputedStyle("backgroundColor")).toLowerCase()&&(e="rgba(1, 1, 1, 0)"),1===(i=(e=d.Color.toArray(e))[3])?e:[(1-i)*(t=this._getComputedBackgroundColor(t.get("parentNode")))[0]+i*e[0],(1-i)*t[1]+i*e[1],(1-i)*t[2]+i*e[2],1]}})},"@VERSION@",{requires:["color-base","moodle-editor_atto-plugin"]});
|
||||
YUI.add("moodle-atto_accessibilitychecker-button",function(d,t){var g="atto_accessibilitychecker";d.namespace("M.atto_accessibilitychecker").Button=d.Base.create("button",d.M.editor_atto.EditorPlugin,[],{initializer:function(){this.addButton({icon:"e/accessibility_checker",callback:this._displayDialogue})},_displayDialogue:function(){this.getDialogue({headerContent:M.util.get_string("pluginname",g),width:"500px",focusAfterHide:!0}).set("bodyContent",this._getDialogueContent()).show()},_getDialogueContent:function(){var t=d.Node.create('<div style="word-wrap: break-word;"></div>');return t.append(this._getWarnings()),t.delegate("click",function(t){t.preventDefault();var e=this.get("host"),t=t.currentTarget.getData("sourceNode"),i=this.getDialogue();t?(i.set("focusAfterHide",this.editor).hide(),e.setSelection(e.getSelectionFromNode(t))):i.hide()},"a",this),t},_getWarnings:function(){var t=d.Node.create("<div></div>"),n=[];return this.editor.all("img").each(function(t){var e=t.getAttribute("alt");void 0!==e&&""!==e||"presentation"!==t.getAttribute("role")&&n.push(t)},this),this._addWarnings(t,M.util.get_string("imagesmissingalt",g),n,!0),n=[],this.editor.all("*").each(function(t){var e,i,o,r;if(t.hasChildNodes()&&""!==d.Lang.trim(t._node.childNodes[0].nodeValue)&&(e=d.Color.fromArray(this._getComputedBackgroundColor(t,t.getComputedStyle("color")),d.Color.TYPES.RGBA),i=d.Color.fromArray(this._getComputedBackgroundColor(t),d.Color.TYPES.RGBA),e=this._getLuminanceFromCssColor(e),((i=this._getLuminanceFromCssColor(i))<e?(e+.05)/(i+.05):(i+.05)/(e+.05))<=4.5)){for(r=!1,o=o=0;o<n.length;o++){if(-1!==t.ancestors("*").indexOf(n[o])){r=!0;break}if(-1!==n[o].ancestors("*").indexOf(t)){n[o]=t,r=!0;break}}r||n.push(t)}},this),this._addWarnings(t,M.util.get_string("needsmorecontrast",g),n,!1),1e3<this.editor.get("text").length&&!this.editor.one("h3, h4, h5")&&this._addWarnings(t,M.util.get_string("needsmoreheadings",g),[this.editor],!1),n=[],this.editor.all("table").each(function(t){var e=t.one("caption");null!==e&&""!==e.get("text").trim()||n.push(t)},this),this._addWarnings(t,M.util.get_string("tablesmissingcaption",g),n,!1),n=[],this.editor.all("table").each(function(t){null!==t.one("[colspan],[rowspan]")&&n.push(t)},this),this._addWarnings(t,M.util.get_string("tableswithmergedcells",g),n,!1),n=[],this.editor.all("table").each(function(e){var i;e.one("tr").one("td")?e.all("tr").some(function(t){t=t.one("th");return(!t||""===t.get("text").trim())&&(n.push(e),!0)},this):(i=!1,e.one("tr").all("th").some(function(t){return i=!0,""===t.get("text").trim()&&(n.push(e),!0)}),i||n.push(e))},this),this._addWarnings(t,M.util.get_string("tablesmissingheaders",g),n,!1),t.hasChildNodes()||t.append("<p>"+M.util.get_string("nowarnings",g)+"</p>"),t},_addWarnings:function(t,e,i,o){var r,n,a,s,l;if(0<i.length){for(e=d.Node.create("<p>"+e+"</p>"),r=d.Node.create('<ol class="accessibilitywarnings"></ol>'),n=n=0;n<i.length;n++)s=d.Node.create("<li></li>"),(l=o?(a=i[n].getAttribute("src"),d.Node.create('<a href="#"><img src="'+a+'" /> '+a+"</a>")):(a="innerText"in i[n]?"innerText":"textContent",""===(l=i[n].get(a).trim())&&(l=M.util.get_string("emptytext",g)),i[n]===this.editor&&(l=M.util.get_string("entiredocument",g)),d.Node.create('<a href="#">'+l+"</a>"))).setData("sourceNode",i[n]),s.append(l),r.append(s);e.append(r),t.append(e)}},_getLuminanceFromCssColor:function(t){var e;return.2126*(e=function(t){return(t=parseInt(t,10)/255)<=.03928?t/=12.92:t=Math.pow((t+.055)/1.055,2.4),t})((t=d.Color.toArray(d.Color.toRGB(t="transparent"===t?"#ffffff":t)))[0])+.7152*e(t[1])+.0722*e(t[2])},_getComputedBackgroundColor:function(t,e){var i;return"transparent"===(e=e||t.getComputedStyle("backgroundColor")).toLowerCase()&&(e="rgba(1, 1, 1, 0)"),1===(i=(e=d.Color.toArray(e))[3])?e:[(1-i)*(t=this._getComputedBackgroundColor(t.get("parentNode")))[0]+i*e[0],(1-i)*t[1]+i*e[1],(1-i)*t[2]+i*e[2],1]}})},"@VERSION@",{requires:["color-base","moodle-editor_atto-plugin"]});
|
||||
+1
-1
@@ -128,7 +128,7 @@ Y.namespace('M.atto_accessibilitychecker').Button = Y.Base.create('button', Y.M.
|
||||
lum2;
|
||||
|
||||
// Check for non-empty text.
|
||||
if (Y.Lang.trim(node.get('text')) !== '') {
|
||||
if (node.hasChildNodes() && Y.Lang.trim(node._node.childNodes[0].nodeValue) !== '') {
|
||||
foreground = Y.Color.fromArray(
|
||||
this._getComputedBackgroundColor(node, node.getComputedStyle('color')),
|
||||
Y.Color.TYPES.RGBA
|
||||
|
||||
@@ -126,7 +126,7 @@ Y.namespace('M.atto_accessibilitychecker').Button = Y.Base.create('button', Y.M.
|
||||
lum2;
|
||||
|
||||
// Check for non-empty text.
|
||||
if (Y.Lang.trim(node.get('text')) !== '') {
|
||||
if (node.hasChildNodes() && Y.Lang.trim(node._node.childNodes[0].nodeValue) !== '') {
|
||||
foreground = Y.Color.fromArray(
|
||||
this._getComputedBackgroundColor(node, node.getComputedStyle('color')),
|
||||
Y.Color.TYPES.RGBA
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -333,8 +333,9 @@ export default class {
|
||||
return (lum2 + 0.05) / (lum1 + 0.05);
|
||||
}
|
||||
};
|
||||
this.editor.dom.select('body > *')
|
||||
.filter((node) => node.textContent?.trim().length)
|
||||
|
||||
this.editor.dom.select('body *')
|
||||
.filter((node) => node.hasChildNodes() && node.childNodes[0].nodeValue !== null)
|
||||
.forEach((node) => {
|
||||
const foreground = this.colorBase.fromArray(
|
||||
this.getComputedBackgroundColor(
|
||||
|
||||
@@ -36,10 +36,9 @@
|
||||
}}
|
||||
<div class="warning-desc">
|
||||
{{#warnings}}
|
||||
<p>
|
||||
{{{description}}}
|
||||
{{#nodeData}}
|
||||
<ol class="accessibilitywarnings">
|
||||
<p>{{{description}}}</p>
|
||||
<ol class="accessibilitywarnings">
|
||||
{{#nodeData}}
|
||||
<li>
|
||||
{{#text}}
|
||||
{{text}}
|
||||
@@ -49,9 +48,8 @@
|
||||
{{/src}}
|
||||
- <a href="#" data-action="highlightfault" data-node-name="{{nodeName}}" data-node-index="{{nodeIndex}}">{{#str}} viewissue, tiny_accessibilitychecker {{/str}}</a>
|
||||
</li>
|
||||
</ol>
|
||||
{{/nodeData}}
|
||||
</p>
|
||||
{{/nodeData}}
|
||||
</ol>
|
||||
{{/warnings}}
|
||||
{{^warnings}}
|
||||
<p>{{#str}} nowarnings, tiny_accessibilitychecker {{/str}}</p>
|
||||
|
||||
Reference in New Issue
Block a user