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"]});