YUI.add("moodle-atto_accessibilitychecker-button",function(u,t){var h="atto_accessibilitychecker";u.namespace("M.atto_accessibilitychecker").Button=u.Base.create("button",u.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",h),width:"500px",focusAfterHide:!0}).set("bodyContent",this._getDialogueContent()).show()},_getDialogueContent:function(){var t=u.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"),i=t.currentTarget.getData("sourceNode"),r=this.getDialogue();i?(r.set("focusAfterHide",this.editor).hide(),e.setSelection(e.getSelectionFromNode(i))):r.hide()},"a",this),t},_getWarnings:function(){var s,t=u.Node.create("<div></div>");return s=[],this.editor.all("img").each(function(t){var e=t.getAttribute("alt");void 0!==e&&""!==e||"presentation"!==t.getAttribute("role")&&s.push(t)},this),this._addWarnings(t,M.util.get_string("imagesmissingalt",h),s,!0),s=[],this.editor.all("*").each(function(t){var e,i,r,o,n,a;if(""!==u.Lang.trim(t.get("text"))&&(e=u.Color.fromArray(this._getComputedBackgroundColor(t,t.getComputedStyle("color")),u.Color.TYPES.RGBA),i=u.Color.fromArray(this._getComputedBackgroundColor(t),u.Color.TYPES.RGBA),r=this._getLuminanceFromCssColor(e),((o=this._getLuminanceFromCssColor(i))<r?(r+.05)/(o+.05):(o+.05)/(r+.05))<=4.5)){for(a=!1,n=n=0;n<s.length;n++){if(-1!==t.ancestors("*").indexOf(s[n])){a=!0;break}if(-1!==s[n].ancestors("*").indexOf(t)){s[n]=t,a=!0;break}}a||s.push(t)}},this),this._addWarnings(t,M.util.get_string("needsmorecontrast",h),s,!1),1e3<this.editor.get("text").length&&!this.editor.one("h3, h4, h5")&&this._addWarnings(t,M.util.get_string("needsmoreheadings",h),[this.editor],!1),s=[],this.editor.all("table").each(function(t){var e=t.one("caption");null!==e&&""!==e.get("text").trim()||s.push(t)},this),this._addWarnings(t,M.util.get_string("tablesmissingcaption",h),s,!1),s=[],this.editor.all("table").each(function(t){null!==t.one("[colspan],[rowspan]")&&s.push(t)},this),this._addWarnings(t,M.util.get_string("tableswithmergedcells",h),s,!1),s=[],this.editor.all("table").each(function(i){if(i.one("tr").one("td"))i.all("tr").some(function(t){var e=t.one("th");return(!e||""===e.get("text").trim())&&(s.push(i),!0)},this);else{var e=!1;i.one("tr").all("th").some(function(t){return e=!0,""===t.get("text").trim()&&(s.push(i),!0)}),e||s.push(i)}},this),this._addWarnings(t,M.util.get_string("tablesmissingheaders",h),s,!1),t.hasChildNodes()||t.append("<p>"+M.util.get_string("nowarnings",h)+"</p>"),t},_addWarnings:function(t,e,i,r){var o,n,a,s,l,d,g,c;if(0<i.length){for(o=u.Node.create("<p>"+e+"</p>"),n=u.Node.create('<ol class="accessibilitywarnings"></ol>'),a=a=0;a<i.length;a++)d=u.Node.create("<li></li>"),(g=r?(s=i[a].getAttribute("src"),u.Node.create('<a href="#"><img src="'+s+'" /> '+s+"</a>")):(l="innerText"in i[a]?"innerText":"textContent",""===(c=i[a].get(l).trim())&&(c=M.util.get_string("emptytext",h)),i[a]===this.editor&&(c=M.util.get_string("entiredocument",h)),u.Node.create('<a href="#">'+c+"</a>"))).setData("sourceNode",i[a]),d.append(g),n.append(d);o.append(n),t.append(o)}},_getLuminanceFromCssColor:function(t){var e,i;return"transparent"===t&&(t="#ffffff"),.2126*(i=function(t){return(t=parseInt(t,10)/255)<=.03928?t/=12.92:t=Math.pow((t+.055)/1.055,2.4),t})((e=u.Color.toArray(u.Color.toRGB(t)))[0])+.7152*i(e[1])+.0722*i(e[2])},_getComputedBackgroundColor:function(t,e){var i,r,o;return"transparent"===(e=e||t.getComputedStyle("backgroundColor")).toLowerCase()&&(e="rgba(1, 1, 1, 0)"),1===(r=(i=u.Color.toArray(e))[3])?i:[(1-r)*(o=this._getComputedBackgroundColor(t.get("parentNode")))[0]+r*i[0],(1-r)*o[1]+r*i[1],(1-r)*o[2]+r*i[2],1]}})},"@VERSION@",{requires:["color-base","moodle-editor_atto-plugin"]});