diff --git a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js
index a3e1b563395..98084c9280b 100644
--- a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js
+++ b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js
@@ -740,38 +740,50 @@ EditorToolbarNav.prototype = {
// Prevent the default browser behaviour.
e.preventDefault();
- var buttons = this.toolbar.all('button');
-
// On cursor moves we loops through the buttons.
- var found = false,
- index = 0,
+ var buttons = this.toolbar.all('button'),
direction = 1,
- checkCount = 0,
- group,
- candidate,
button,
current = e.target.ancestor('button', true);
- // Determine which button is currently selected.
- while (!found && index < buttons.size()) {
- if (buttons.item(index) === current) {
- found = true;
- } else {
- index++;
- }
- }
-
- if (!found) {
- Y.log("Unable to find this button in the list of buttons", 'debug', LOGNAME);
- return;
- }
-
if (e.keyCode === 37) {
// Moving left so reverse the direction.
direction = -1;
}
- // Try to find the next
+ button = this._findFirstFocusable(buttons, current, direction);
+ if (button) {
+ button.focus();
+ } else {
+ Y.log("Unable to find a button to focus on", 'debug', LOGNAME);
+ }
+ },
+
+ /**
+ * Find the first focusable button.
+ *
+ * @param {NodeList} buttons A list of nodes.
+ * @param {Node} startAt The node in the list to start the search from.
+ * @param {Number} direction The direction in which to search (1 or -1).
+ * @return {Node | Undefined} The Node or undefined.
+ * @method _findFirstFocusable
+ * @private
+ */
+ _findFirstFocusable: function(buttons, startAt, direction) {
+ var checkCount = 0,
+ group,
+ candidate,
+ button,
+ index;
+
+ // Determine which button to start the search from.
+ index = buttons.indexOf(startAt);
+ if (index < -1) {
+ Y.log("Unable to find the button in the list of buttons", 'debug', LOGNAME);
+ index = 0;
+ }
+
+ // Try to find the next.
while (checkCount < buttons.size()) {
index += direction;
if (index < 0) {
@@ -802,12 +814,35 @@ EditorToolbarNav.prototype = {
break;
}
- if (button) {
- button.focus();
- this._setTabFocus(button);
- } else {
- Y.log("Unable to find a button to focus on", 'debug', LOGNAME);
+ return button;
+ },
+
+ /**
+ * Check the tab focus.
+ *
+ * When we disable or hide a button, we should call this method to ensure that the
+ * focus is not currently set on an inaccessible button, otherwise tabbing to the toolbar
+ * would be impossible.
+ *
+ * @method checkTabFocus
+ * @chainable
+ */
+ checkTabFocus: function() {
+ if (this._tabFocus) {
+ if (this._tabFocus.hasAttribute('disabled') || this._tabFocus.hasAttribute('hidden')
+ || this._tabFocus.ancestor('.atto_group').hasAttribute('hidden')) {
+ // Find first available button.
+ button = this._findFirstFocusable(this.toolbar.all('button'), this._tabFocus, -1);
+ if (button) {
+ if (this._tabFocus.compareTo(document.activeElement)) {
+ // We should also move the focus, because the inaccessible button also has the focus.
+ button.focus();
+ }
+ this._setTabFocus(button);
+ }
+ }
}
+ return this;
},
/**
diff --git a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js
index c0ac46f7273..c2cf00d1fe7 100644
--- a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js
+++ b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js
@@ -1,2 +1,2 @@
-YUI.add("moodle-editor_atto-editor",function(e,t){function i(){i.superclass.constructor.apply(this,arguments)}function s(){}function o(){}function u(){}function a(){}function f(){}function l(){}function c(){}var n="moodle-editor_atto-editor",r={CONTENT:"editor_atto_content",CONTENTWRAPPER:"editor_atto_content_wrap",TOOLBAR:"editor_atto_toolbar",WRAPPER:"editor_atto",HIGHLIGHT:"highlight"};e.extend(i,e.Base,{BLOCK_TAGS:["address","article","aside","audio","blockquote","canvas","dd","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","noscript","ol","output","p","pre","section","table","tfoot","ul","video"],PLACEHOLDER_FONTNAME:"yui-tmp",ALL_NODES_SELECTOR:"[style],font[face]",FONT_FAMILY:"fontFamily",_wrapper:null,editor:null,textarea:null,textareaLabel:null,plugins:null,initializer:function(){var t;this.textarea=e.one(document.getElementById(this.get("elementid")));if(!this.textarea)return;this._wrapper=e.Node.create('
'),t=e.Handlebars.compile(''),this.editor=e.Node.create(t({elementid:this.get("elementid"),CSS:r})),this.textareaLabel=e.one('[for="'+this.get("elementid")+'"]'),this.textareaLabel&&(this.textareaLabel.generateID(),this.editor.setAttribute("aria-labelledby",this.textareaLabel.get("id"))),this.setupToolbar();var n=e.Node.create('');n.appendChild(this.editor),this._wrapper.appendChild(n),this.editor.setStyle("minHeight",1.2*this.textarea.getAttribute("rows")+"em"),this.disableCssStyling(),this.textarea.get("parentNode").insert(this._wrapper,this.textarea),this.textarea.hide(),this.updateFromTextArea(),this.publishEvents(),this.setupSelectionWatchers(),this.setupPlugins()},focus:function(){return this.editor.focus(),this},publishEvents:function(){return this.publish("change",{broadcast:!0,preventable:!0}),this.publish("pluginsloaded",{fireOnce:!0}),this.publish("atto:selectionchanged",{prefix:"atto"}),e.delegate(["mouseup","keyup","focus"],this._hasSelectionChanged,document.body,"."+r.CONTENT,this),this},setupPlugins:function(){this.plugins={};var t=this.get("plugins"),n,r,i,s,o;for(n in t){r=t[n];if(!r.plugins)continue;for(i in r.plugins){s=r.plugins[i],o=e.mix({name:s.name,group:r.group,editor:this.editor,toolbar:this.toolbar,host:this},s);if(typeof e.M["atto_"+s.name]=="undefined")continue;this.plugins[s.name]=new e.M["atto_"+s.name].Button(o)}}return this.fire("pluginsloaded"),this},enablePlugins:function(e){this._setPluginState(!0,e)},disablePlugins:function(e){this._setPluginState(!1,e)},_setPluginState:function(t,n){var r="disableButtons";t&&(r="enableButtons"),n?this.plugins[n][r]():e.Object.each(this.plugins,function(e){e[r]()},this)}},{NS:"editor_atto",ATTRS:{elementid:{value:null,writeOnce:!0},plugins:{value:{},writeOnce:!0}}}),e.augment(i,e.EventTarget),e.namespace("M.editor_atto").Editor=i,e.namespace("M.editor_atto.Editor").init=function(t){return new e.M.editor_atto.Editor(t)},s.ATTRS={},s.prototype={updateFromTextArea:function(){this.editor.setHTML(""),this.editor.append(this.textarea.get("value")),this.cleanEditorHTML(),this.editor.getHTML()===""&&(e.UA.ie&&e.UA.ie<10?this.editor.setHTML(""):this.editor.setHTML("