YUI.add("moodle-atto_indent-button",function(r,e){r.namespace("M.atto_indent").Button=r.Base.create("button",r.M.editor_atto.EditorPlugin,[],{initializer:function(){this.addButton({icon:"e/decrease_indent",title:"outdent",buttonName:"outdent",callback:this.outdent}),this.addButton({icon:"e/increase_indent",title:"indent",buttonName:"indent",callback:this.indent})},indent:function(){var e=window.rangy.saveSelection(),t=this.editor.all("blockquote"),i=t.size();this.editor.all(".rangySelectionBoundary").setStyle("display",null),t.addClass("pre-existing"),document.execCommand("indent",!1,null),this.fixupListItemsAfterIndent(),(t=this.editor.all("blockquote")).size()!==i?(this.replaceBlockquote(this.editor),window.rangy.restoreSelection(e)):0<t.size()&&t.removeClass("pre-existing"),window.rangy.removeMarkers(e),this.markUpdated()},outdent:function(){var e=window.rangy.saveSelection(),t=this.editor.all("blockquote"),i=t.size();t.addClass("pre-existing"),this.replaceEditorIndents(this.editor),window.rangy.restoreSelection(e),e=window.rangy.saveSelection(),document.execCommand("outdent",!1,null),(t=this.editor.all("blockquote")).size()!==i?(this.replaceBlockquote(this.editor),window.rangy.restoreSelection(e)):0<t.size()&&t.removeClass("pre-existing"),window.rangy.removeMarkers(e),this.markUpdated()},replaceBlockquote:function(e){var t,i,o,n,d;for(e.all("blockquote").setAttribute("data-iterate",!0),t=e.one("blockquote"),i=r.one("body.dir-ltr")?"marginLeft":"marginRight";t;){if(t.removeAttribute("data-iterate"),t.hasClass("pre-existing"))t.removeClass("pre-existing");else{for(o=r.Node.create("<div></div>").setAttrs(t.getAttrs()).setStyle(i,"30px").addClass("editor-indent"),d=(n=t.getDOMNode().childNodes)[0];void 0!==d;)o.append(d),d=n[0];t.replace(o)}t=e.one("blockquote[data-iterate]")}},replaceEditorIndents:function(e){for(var t,i,o,n=e.one(".editor-indent");n;){for(t=r.Node.create("<blockquote></blockquote>").setAttrs(n.getAttrs()).removeClass("editor-indent"),o=(i=n.getDOMNode().childNodes)[0];void 0!==o;)t.append(o),o=i[0];n.replace(t),n=e.one(".editor-indent")}},fixupListItemsAfterIndent:function(){var e,t=window.rangy.getSelection(),i=this.editor.getDOMNode(),o=t.anchorNode.parentElement,o=o.closest("ol, ul");o&&i.contains(o)&&(e=o.previousElementSibling)&&"LI"===e.tagName&&(e.appendChild(o),t.collapseToEnd())}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});