YUI.add("moodle-atto_media-button",function(e,t){var n="atto_media",r={URLINPUT:"atto_media_urlentry",NAMEINPUT:"atto_media_nameentry"},i={URLINPUT:"."+r.URLINPUT,NAMEINPUT:"."+r.NAMEINPUT},s='


';e.namespace("M.atto_media").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,_content:null,initializer:function(){this.get("host").canShowFilepicker("media")&&this.addButton({icon:"e/insert_edit_video",callback:this._displayDialogue})},_displayDialogue:function(){this._currentSelection=this.get("host").getSelection();if(this._currentSelection===!1)return;var e=this.getDialogue({headerContent:M.util.get_string("createmedia",n),focusAfterHide:!0,focusOnShowSelector:i.URLINPUT});e.set("bodyContent",this._getDialogueContent()).show()},_getDialogueContent:function(){var t=e.Handlebars.compile(s);return this._content=e.Node.create(t({component:n,elementid:this.get("host").get("elementid"),CSS:r})),this._content.one(".submit").on("click",this._setMedia,this),this._content.one(".openmediabrowser").on("click",function(e){e.preventDefault(),this.get("host").showFilepicker("media",this._filepickerCallback,this)},this),this._content},_filepickerCallback:function(e){e.url!==""&&(this._content.one(i.URLINPUT).set("value",e.url),this._content.one(i.NAMEINPUT).set("value",e.file))},_setMedia:function(t){t.preventDefault(),this.getDialogue({focusAfterHide:null}).hide();var n=t.currentTarget.ancestor(".atto_form"),r=n.one(i.URLINPUT).get("value"),s=n.one(i.NAMEINPUT).get("value"),o=this.get("host");if(r!==""&&s!==""){o.setSelection(this._currentSelection);var u=''+s+"";o.insertContentAtFocusPoint(u),this.markUpdated()}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); YUI.add("moodle-atto_managefiles-button",function(e,t){var n="atto_managefiles";e.namespace("M.atto_managefiles").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,initializer:function(){if(this.get("disabled"))return;var e=this.get("host"),t=this.get("area"),n=e.get("filepickeroptions");if(!n.image||!n.image.itemid)return;t.itemid=n.image.itemid,this.set("area",t),this.addButton({icon:"e/manage_files",callback:this._displayDialogue})},_displayDialogue:function(t){t.preventDefault();var r=this.getDialogue({headerContent:M.util.get_string("managefiles",n),width:"800px",focusAfterHide:!0}),i=e.Node.create("");i.setStyles({height:"700px",border:"none",width:"100%"}),i.setAttribute("src",this._getIframeURL()),r.set("bodyContent",i).show(),this.markUpdated()},_getIframeURL:function(){var t=e.mix({elementid:this.get("host").get("elementid")},this.get("area"));return M.cfg.wwwroot+"/lib/editor/atto/plugins/managefiles/manage.php?"+e.QueryString.stringify(t)}},{ATTRS:{disabled:{value:!0},area:{value:{}}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); YUI.add("moodle-atto_underline-button",function(e,t){e.namespace("M.atto_underline").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{initializer:function(){this.addBasicButton({exec:"underline",keys:"85",tags:"u"})}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); YUI.add("moodle-atto_strike-button",function(e,t){e.namespace("M.atto_strike").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{initializer:function(){this.addBasicButton({exec:"strikeThrough",icon:"e/strikethrough",tags:"strike"})}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); YUI.add("moodle-atto_subscript-button",function(e,t){e.namespace("M.atto_subscript").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{initializer:function(){this.addBasicButton({exec:"subscript",tags:"sub"})}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); YUI.add("moodle-atto_superscript-button",function(e,t){e.namespace("M.atto_superscript").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{initializer:function(){this.addBasicButton({exec:"superscript",tags:"sup"})}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); YUI.add("moodle-atto_align-button",function(e,t){e.namespace("M.atto_align").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{initializer:function(){var e;e="justifyLeft",this.addButton({icon:"e/align_left",title:"leftalign",buttonName:e,callback:this._changeStyle,callbackArgs:e}),e="justifyCenter",this.addButton({icon:"e/align_center",title:"center",buttonName:e,callback:this._changeStyle,callbackArgs:e}),e="justifyRight",this.addButton({icon:"e/align_right",title:"rightalign",buttonName:e,callback:this._changeStyle,callbackArgs:e})},_changeStyle:function(e,t){var n=this.get("host");n.enableCssStyling(),document.execCommand(t,!1,null),n.disableCssStyling(),this.markUpdated(),this.editor.focus()}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); YUI.add("moodle-atto_indent-button",function(e,t){e.namespace("M.atto_indent").Button=e.Base.create("button",e.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=rangy.saveSelection(),t=this.editor.all("blockquote"),n=t.size();this.editor.all(".rangySelectionBoundary").setStyle("display",null),t.addClass("pre-existing"),document.execCommand("indent",!1,null),t=this.editor.all("blockquote"),t.size()!==n?(this.replaceBlockquote(this.editor),rangy.restoreSelection(e)):t.size()>0&&t.removeClass("pre-existing"),rangy.removeMarkers(e),this.markUpdated()},outdent:function(){var e=rangy.saveSelection(),t=this.editor.all("blockquote"),n=t.size();t.addClass("pre-existing"),this.replaceEditorIndents(this.editor),rangy.restoreSelection(e),e=rangy.saveSelection(),document.execCommand("outdent",!1,null),t=this.editor.all("blockquote"),t.size()!==n?(this.replaceBlockquote(this.editor),rangy.restoreSelection(e)):t.size()>0&&t.removeClass("pre-existing"),rangy.removeMarkers(e),this.markUpdated()},replaceBlockquote:function(t){t.all("blockquote").setAttribute("data-iterate",!0);var n=t.one("blockquote"),r=e.one("body.dir-ltr")?"marginLeft":"marginRight";while(n){n.removeAttribute("data-iterate");if(n.hasClass("pre-existing"))n.removeClass("pre-existing");else{var i=e.Node.create("
").setAttrs(n.getAttrs()).setStyle(r,"30px").addClass("editor-indent"),s=n.getDOMNode().childNodes,o;o=s[0];while(typeof o!="undefined")i.append(o),o=s[0];n.replace(i)}n=t.one("blockquote[data-iterate]")}},replaceEditorIndents:function(t){var n=t.one(".editor-indent");while(n){var r=e.Node.create("
").setAttrs(n.getAttrs()).removeClass("editor-indent"),i=n.getDOMNode().childNodes,s;s=i[0];while(typeof s!="undefined")r.append(s),s=i[0];n.replace(r),n=t.one(".editor-indent")}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add("arraylist",function(e,t){function s(t){t!==undefined?this._items=e.Lang.isArray(t)?t:n(t):this._items=this._items||[]}var n=e.Array,r=n.each,i;i={item:function(e){return this._items[e]},each:function(e,t){return r(this._items,function(n,r){n=this.item(r),e.call(t||n,n,r,this)},this),this},some:function(e,t){return n.some(this._items,function(n,r){return n=this.item(r),e.call(t||n,n,r,this)},this)},indexOf:function(e){return n.indexOf(this._items,e)},size:function(){return this._items.length},isEmpty:function(){return!this.size()},toJSON:function(){return this._items}},i._item=i.item,e.mix(s.prototype,i),e.mix(s,{addMethod:function(e,t){t=n(t),r(t,function(t){e[t]=function(){var e=n(arguments,0,!0),i=[];return r(this._items,function(n,r){n=this._item(r);var s=n[t].apply(n,e);s!==undefined&&s!==n&&(i[r]=s)},this),i.length?i:this}})}}),e.ArrayList=s},"3.17.2",{requires:["yui-base"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add("widget-parent",function(e,t){function s(t){this.publish("addChild",{defaultTargetOnly:!0,defaultFn:this._defAddChildFn}),this.publish("removeChild",{defaultTargetOnly:!0,defaultFn:this._defRemoveChildFn}),this._items=[];var n,r;t&&t.children&&(n=t.children,r=this.after("initializedChange",function(e){this._add(n),r.detach()})),e.after(this._renderChildren,this,"renderUI"),e.after(this._bindUIParent,this,"bindUI"),this.after("selectionChange",this._afterSelectionChange),this.after("selectedChange",this._afterParentSelectedChange),this.after("activeDescendantChange",this._afterActiveDescendantChange),this._hDestroyChild=this.after("*:destroy",this._afterDestroyChild),this.after("*:focusedChange",this._updateActiveDescendant)}var n=e.Lang,r="rendered",i="boundingBox";s.ATTRS={defaultChildType:{setter:function(t){var r=e.Attribute.INVALID_VALUE,i=n.isString(t)?e[t]:t;return n.isFunction(i)&&(r=i),r}},activeDescendant:{readOnly:!0},multiple:{value:!1,validator:n.isBoolean,writeOnce:!0,getter:function(e){var t=this.get("root");return t&&t!=this?t.get("multiple"):e}},selection:{readOnly:!0,setter:"_setSelection",getter:function(t){var r=n.isArray(t)?new e.ArrayList(t):t;return r}},selected:{setter:function(t){var n=t;return t===1&&!this.get("multiple")&&(n=e.Attribute.INVALID_VALUE),n}}},s.prototype={destructor:function(){this._destroyChildren()},_afterDestroyChild:function(e){var t=e.target;t.get("parent")==this&&t.remove()},_afterSelectionChange:function(t){if(t.target==this&&t.src!=this){var n=t.newVal,r=0;n&&(r=2,e.instanceOf(n,e.ArrayList)&&n.size()===this.size()&&(r=1)),this.set("selected",r,{src:this})}},_afterActiveDescendantChange:function(e){var t=this.get("parent");t&&t._set("activeDescendant",e.newVal)},_afterParentSelectedChange:function(e){var t=e.newVal;this==e.target&&e.src!=this&&(t===0||t===1)&&this.each(function(e){e.set("selected",t,{src:this})},this)},_setSelection:function(e){var t=null,n;return this.get("multiple")&&!this.isEmpty()?(n=[],this.each(function(e){e.get("selected")>0&&n.push(e)}),n.length>0&&(t=n)):e.get("selected")>0&&(t=e),t},_updateSelection:function(e){var t=e.target,n;t.get("parent")==this&&(e.src!="_updateSelection"&&(n=this.get("selection"),!this.get("multiple")&&n&&e.newVal>0&&n.set("selected",0,{src:"_updateSelection"}),this._set("selection",t)),e.src==this&&this._set("selection",t,{src:this}))},_updateActiveDescendant:function(e){var t=e.newVal===!0?e.target:null;this._set("activeDescendant",t)},_createChild:function(t){var r=this.get("defaultChildType"),i=t.childType||t.type,s,o,u;return i&&(o=n.isString(i)?e[i]:i),n.isFunction(o)?u=o:r&&(u=r),u?s=new u(t):e.error("Could not create a child instance because its constructor is either undefined or invalid."),s},_defAddChildFn:function(t){var r=t.child,i=t.index,s=this._items;r.get("parent")&&r.remove(),n.isNumber(i)?s.splice(i,0,r):s.push(r),r._set("parent",this),r.addTarget(this),t.index=r.get("index"),r.after("selectedChange",e.bind(this._updateSelection,this))},_defRemoveChildFn:function(e){var t=e.child,n=e.index,r=this._items;t.get("focused")&&t.blur(),t.get("selected")&&t.set("selected",0),r.splice(n,1),t.removeTarget(this),t._oldParent=t.get("parent"),t._set("parent",null)},_add:function(t,r){var i,s,o;return n.isArray(t)?(i=[],e.each(t,function(e,t){s=this._add(e,r+t),s&&i.push(s)},this),i.length>0&&(o=i)):(e.instanceOf(t,e.Widget)?s=t:s=this._createChild(t),s&&this.fire("addChild",{child:s,index:r})&&(o=s)),o},add:function(){var t=this._add.apply(this,arguments),r=t?n.isArray(t)?t:[t]:[];return new e.ArrayList(r)},remove:function(e){var t=this._items[e],n;return t&&this.fire("removeChild",{child:t,index:e})&&(n=t),n},removeAll:function(){var t=[],n;return e.each(this._items.concat(),function(){n=this.remove(0),n&&t.push(n)},this),new e.ArrayList(t)},selectChild:function(e){this.item(e).set("selected",1)},selectAll:function(){this.set("selected",1)},deselectAll:function(){this.set("selected",0)},_uiAddChild:function(e,t){e.render(t);var n=e.get("boundingBox"),s,o=e.next(!1),u;o&&o.get(r)?(s=o.get(i),s.insert(n,"before")):(u=e.previous(!1),u&&u.get(r)?(s=u.get(i),s.insert(n,"after")):t.contains(n)||t.appendChild(n))},_uiRemoveChild:function(e){e.get("boundingBox").remove()},_afterAddChild:function(e){var t=e.child;t.get("parent")==this&&this._uiAddChild(t,this._childrenContainer)},_afterRemoveChild:function(e){var t=e.child;t._oldParent==this&&this._uiRemoveChild(t)},_bindUIParent:function(){this.after("addChild",this._afterAddChild),this.after("removeChild",this._afterRemoveChild)},_renderChildren:function(){var e=this._childrenContainer||this.get("contentBox");this._childrenContainer=e,this.each(function(t){t.render(e)})},_destroyChildren:function(){this._hDestroyChild.detach(),this.each(function(e){e.destroy()})}},e.augment(s,e.ArrayList),e.WidgetParent=s},"3.17.2",{requires:["arraylist","base-build","widget"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add("widget-child",function(e,t){function r(){e.after(this._syncUIChild,this,"syncUI"),e.after(this._bindUIChild,this,"bindUI")}var n=e.Lang;r.ATTRS={selected:{value:0,validator:n.isNumber},index:{readOnly:!0,getter:function(){var e=this.get("parent"),t=-1;return e&&(t=e.indexOf(this)),t}},parent:{readOnly:!0},depth:{readOnly:!0,getter:function(){var e=this.get("parent"),t=this.get("root"),n=-1;while(e){n+=1;if(e==t)break;e=e.get("parent")}return n}},root:{readOnly:!0,getter:function(){var t=function(n){var r=n.get("parent"),i=n.ROOT_TYPE,s=r;return i&&(s=r&&e.instanceOf(r,i)),s?t(r):n};return t(this)}}},r.prototype={ROOT_TYPE:null,_getUIEventNode:function(){var e=this.get("root"),t;return e&&(t=e.get("boundingBox")),t},next:function(e){var t=this.get("parent"),n;return t&&(n=t.item(this.get("index")+1)),!n&&e&&(n=t.item(0)),n},previous:function(e){var t=this.get("parent"),n=this.get("index"),r;return t&&n>0&&(r=t.item([n-1])),!r&&e&&(r=t.item(t.size()-1)),r},remove:function(t){var r,i;return n.isNumber(t)?i=e.WidgetParent.prototype.remove.apply(this,arguments):(r=this.get("parent"),r&&(i=r.remove(this.get("index")))),i},isRoot:function(){return this==this.get("root")},ancestor:function(e){var t=this.get("root"),n;if(this.get("depth")>e){n=this.get("parent");while(n!=t&&n.get("depth")>e)n=n.get("parent")}return n},_uiSetChildSelected:function(e){var t=this.get("boundingBox"),n=this.getClassName("selected");e===0?t.removeClass(n):t.addClass(n)},_afterChildSelectedChange:function(e){this._uiSetChildSelected(e.newVal)},_syncUIChild:function(){this._uiSetChildSelected(this.get("selected"))},_bindUIChild:function(){this.after("selectedChange",this._afterChildSelectedChange)}},e.WidgetChild=r},"3.17.2",{requires:["base-build","widget"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add("tabview-base",function(e,t){var n=e.ClassNameManager.getClassName,r="tabview",i="tab",s="panel",o="selected",u={},a=".",f=function(){this.init.apply(this,arguments)};f.NAME="tabviewBase",f._classNames={tabview:n(r),tabviewPanel:n(r,s),tabviewList:n(r,"list"),tab:n(i),tabLabel:n(i,"label"),tabPanel:n(i,s),selectedTab:n(i,o),selectedPanel:n(i,s,o)},f._queries={tabview:a+f._classNames.tabview,tabviewList:"> ul",tab:"> ul > li",tabLabel:"> ul > li > a",tabviewPanel:"> div",tabPanel:"> div > div",selectedTab:"> ul > "+a+f._classNames.selectedTab,selectedPanel:"> div "+a+f._classNames.selectedPanel},e.mix(f.prototype,{init:function(t){t=t||u,this._node=t.host||e.one(t.node),this.refresh()},initClassNames:function(t){var n=e.TabviewBase._classNames;e.Object.each(e.TabviewBase._queries,function(e,r){if(n[r]){var i=this.all(e);t!==undefined&&(i=i.item(t)),i&&i.addClass(n[r])}},this._node),this._node.addClass(n.tabview)},_select:function(t){var n=e.TabviewBase._classNames,r=e.TabviewBase._queries,i=this._node,s=i.one(r.selectedTab),o=i.one(r.selectedPanel),u=i.all(r.tab).item(t),a=i.all(r.tabPanel).item(t);s&&s.removeClass(n.selectedTab),o&&o.removeClass(n.selectedPanel),u&&u.addClass(n.selectedTab),a&&a.addClass(n.selectedPanel)},initState:function(){var t=e.TabviewBase._queries,n=this._node,r=n.one(t.selectedTab),i=r?n.all(t.tab).indexOf(r):0;this._select(i)},_scrubTextNodes:function(){this._node.one(e.TabviewBase._queries.tabviewList).get("childNodes").each(function(e){e.get("nodeType")===3&&e.remove()})},refresh:function(){this._scrubTextNodes(),this.initClassNames(),this.initState(),this.initEvents()},tabEventName:"click",initEvents:function(){this._node.delegate(this.tabEventName,this.onTabEvent,e.TabviewBase._queries.tab,this)},onTabEvent:function(t){t.preventDefault(),this._select(this._node.all(e.TabviewBase._queries.tab).indexOf(t.currentTarget))},destroy:function(){this._node.detach(this.tabEventName)}}),e.TabviewBase=f},"3.17.2",{requires:["node-event-delegate","classnamemanager"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add("node-focusmanager",function(e,t){var n="activeDescendant",r="id",i="disabled",s="tabIndex",o="focused",u="focusClass",a="circular",f="UI",l="key",c=n+"Change",h="host",p={37:!0,38:!0,39:!0,40:!0},d={a:!0,button:!0,input:!0,object:!0},v=e.Lang,m=e.UA,g=function(){g.superclass.constructor.apply(this,arguments)};g.ATTRS={focused:{value:!1,readOnly:!0},descendants:{getter:function(e){return this.get(h).all(e)}},activeDescendant:{setter:function(t){var n=v.isNumber,i=e.Attribute.INVALID_VALUE,s=this._descendantsMap,o=this._descendants,u,a,f;return n(t)?(u=t,a=u):t instanceof e.Node&&s?(u=s[t.get(r)],n(u)?a=u:a=i):a=i,o&&(f=o.item(u),f&&f.get("disabled")&&(a=i)),a}},keys:{value:{next:null,previous:null}},focusClass:{},circular:{value:!0}},e.extend(g,e.Plugin.Base,{_stopped:!0,_descendants:null,_descendantsMap:null,_focusedNode:null,_lastNodeIndex:0,_eventHandlers:null,_initDescendants:function(){var t=this.get("descendants"),o={},u=-1,a,f=this.get(n),l,c,h=0;v.isUndefined(f)&&(f=-1);if(t){a=t.size();for(h=0;h=0&&(r-=1,r===-1&&this.get(a)&&(r=this._lastNodeIndex),i=this._descendants.item(r),i&&(i.get("disabled")?this._focusPrevious(e,r):this.focus(r))),this._preventScroll(e)},_afterActiveDescendantChange:function(e){var t=this._descendants.item(e.prevVal);t&&t.set(s,-1),t=this._descendants.item(e.newVal),t&&t.set(s,0)},initializer:function(e){this.start()},destructor:function(){this.stop(),this.get(h).focusManager=null},focus:function(e){v.isUndefined(e)&&(e=this.get(n)),this.set(n,e,{src:f});var t=this._descendants.item(this.get(n));t&&(t.focus(),m.opera&&t.get("nodeName").toLowerCase()==="button"&&(this._focusTarget=t))},blur:function(){var e;this.get(o)&&(e=this._descendants.item(this.get(n)),e&&(e.blur(),this._removeFocusClass()),this._set(o,!1,{src:f}))},start:function(){this._stopped&&(this._initDescendants(),this._attachEventHandlers(),this._stopped=!1)},stop:function(){this._stopped||(this._detachEventHandlers(),this._descendants=null,this._focusedNode=null,this._lastNodeIndex=0,this._stopped=!0)},refresh:function(){this._initDescendants(),this._eventHandlers||this._attachEventHandlers()}}),g.NAME="nodeFocusManager",g.NS="focusManager",e.namespace("Plugin"),e.Plugin.NodeFocusManager=g},"3.17.2",{requires:["attribute","node","plugin","node-event-simulate","event-key","event-focus"]}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add("tabview",function(e,t){var n=".",r=e.Base.create("tabView",e.Widget,[e.WidgetParent],{_afterChildAdded:function(){this.get("contentBox").focusManager.refresh()},_defListNodeValueFn:function(){var t=e.Node.create(this.LIST_TEMPLATE);return t.addClass(e.TabviewBase._classNames.tabviewList),t},_defPanelNodeValueFn:function(){var t=e.Node.create(this.PANEL_TEMPLATE);return t.addClass(e.TabviewBase._classNames.tabviewPanel),t},_afterChildRemoved:function(e){var t=e.index,n=this.get("selection");n||(n=this.item(t-1)||this.item(0),n&&n.set("selected",1)),this.get("contentBox").focusManager.refresh()},_initAria:function(t){var n=t.one(e.TabviewBase._queries.tabviewList);n&&n.setAttrs({role:"tablist"})},bindUI:function(){this.get("contentBox").plug(e.Plugin.NodeFocusManager,{descendants:n+e.TabviewBase._classNames.tabLabel,keys:{next:"down:39",previous:"down:37"},circular:!0}),this.after("render",this._setDefSelection),this.after("addChild",this._afterChildAdded),this.after("removeChild",this._afterChildRemoved)},renderUI:function(){var e=this.get("contentBox");this._renderListBox(e),this._renderPanelBox(e),this._childrenContainer=this.get("listNode"),this._renderTabs(e),this._initAria(e)},_setDefSelection:function(){var e=this.get("selection")||this.item(0);this.some(function(t){if(t.get("selected"))return e=t,!0}),e&&(this.set("selection",e),e.set("selected",1))},_renderListBox:function(e){var t=this.get("listNode");t.inDoc()||e.append(t)},_renderPanelBox:function(e){var t=this.get("panelNode");t.inDoc()||e.append(t)},_renderTabs:function(t){var r=e.TabviewBase._classNames,i=e.TabviewBase._queries,s=t.all(i.tab),o=this.get("panelNode"),u=o?this.get("panelNode").get("children"):null,a=this;s&&(s.addClass(r.tab),t.all(i.tabLabel).addClass(r.tabLabel),t.all(i.tabPanel).addClass(r.tabPanel),s.each(function(e,t){var i=u?u.item(t):null;a.add({boundingBox:e,contentBox:e.one(n+r.tabLabel),panelNode:i})}))}},{ATTRS:{defaultChildType:{value:"Tab"},listNode:{setter:function(t){return t=e.one(t),t&&t.addClass(e.TabviewBase._classNames.tabviewList),t},valueFn:"_defListNodeValueFn"},panelNode:{setter:function(t){return t=e.one(t),t&&t.addClass(e.TabviewBase._classNames.tabviewPanel),t},valueFn:"_defPanelNodeValueFn"},tabIndex:{value:null}},HTML_PARSER:{listNode:function(t){return t.one(e.TabviewBase._queries.tabviewList)},panelNode:function(t){return t.one(e.TabviewBase._queries.tabviewPanel)}},LIST_TEMPLATE:"",PANEL_TEMPLATE:"
"});r.prototype.LIST_TEMPLATE=r.LIST_TEMPLATE,r.prototype.PANEL_TEMPLATE=r.PANEL_TEMPLATE,e.TabView=r,e.Tab=e.Base.create("tab",e.Widget,[e.WidgetChild],{BOUNDING_TEMPLATE:"
  • ",CONTENT_TEMPLATE:"",PANEL_TEMPLATE:"
    ",_uiSetSelectedPanel:function(t){this.get("panelNode").toggleClass(e.TabviewBase._classNames.selectedPanel,t)},_afterTabSelectedChange:function(e){this._uiSetSelectedPanel(e.newVal)},_afterParentChange:function(e){e.newVal?this._add():this._remove()},_initAria:function(){var t=this.get("contentBox"),n=t.get("id"),r=this.get("panelNode");n||(n=e.guid(),t.set("id",n)),t.set("role","tab"),t.get("parentNode").set("role","presentation"),r.setAttrs({role:"tabpanel","aria-labelledby":n})},syncUI:function(){var t=e.TabviewBase._classNames;this.get("boundingBox").addClass(t.tab),this.get("contentBox").addClass(t.tabLabel),this.set("label",this.get("label")),this.set("content",this.get("content")),this._uiSetSelectedPanel(this.get("selected"))},bindUI:function(){this.after("selectedChange",this._afterTabSelectedChange),this.after("parentChange",this._afterParentChange)},renderUI:function(){this._renderPanel(),this._initAria()},_renderPanel:function(){this.get("parent").get("panelNode").appendChild(this.get("panelNode"))},_add:function(){var e=this.get("parent").get("contentBox"),t=e.get("listNode"),n=e.get("panelNode");t&&t.appendChild(this.get("boundingBox")),n&&n.appendChild(this.get("panelNode"))},_remove:function(){this.get("boundingBox").remove(),this.get("panelNode").remove()},_onActivate:function(e){e.target===this&&(e.domEvent.preventDefault(),e.target.set("selected",1))},initializer:function(){this.publish(this.get("triggerEvent"),{defaultFn:this._onActivate})},_defLabelGetter:function(){return this.get("contentBox").getHTML()},_defLabelSetter:function(e){var t=this.get("contentBox");return t.getHTML()!==e&&t.setHTML(e),e},_defContentSetter:function(e){var t=this.get("panelNode");return t.getHTML()!==e&&t.setHTML(e),e},_defContentGetter:function(){return this.get("panelNode").getHTML()},_defPanelNodeValueFn:function(){var t=e.TabviewBase._classNames,n=this.get("contentBox").get("href")||"",r=this.get("parent"),i=n.indexOf("#"),s;return n=n.substr(i),n.charAt(0)==="#"&&(s=e.one(n),s&&s.addClass(t.tabPanel)),!s&&r&&(s=r.get("panelNode").get("children").item(this.get("index"))),s||(s=e.Node.create(this.PANEL_TEMPLATE),s.addClass(t.tabPanel)),s}},{ATTRS:{triggerEvent:{value:"click"},label:{setter:"_defLabelSetter",getter:"_defLabelGetter"},content:{setter:"_defContentSetter",getter:"_defContentGetter"},panelNode:{setter:function(t){return t=e.one(t),t&&t.addClass(e.TabviewBase._classNames.tabPanel),t},valueFn:"_defPanelNodeValueFn"},tabIndex:{value:null,validator:"_validTabIndex"}},HTML_PARSER:{selected:function(){var t=this.get("boundingBox").hasClass(e.TabviewBase._classNames.selectedTab)?1:0;return t}}})},"3.17.2",{requires:["widget","widget-parent","widget-child","tabview-base","node-pluginhost","node-focusmanager"],skinnable:!0}); /* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add("array-extras",function(e,t){var n=e.Array,r=e.Lang,i=Array.prototype;n.lastIndexOf=r._isNative(i.lastIndexOf)?function(e,t,n){return n||n===0?e.lastIndexOf(t,n):e.lastIndexOf(t)}:function(e,t,n){var r=e.length,i=r-1;if(n||n===0)i=Math.min(n<0?r+n:n,r);if(i>-1&&r>0)for(;i>-1;--i)if(i in e&&e[i]===t)return i;return-1},n.unique=function(e,t){var n=0,r=e.length,i=[],s,o,u,a;e:for(;n div > div",EQUATION_TEXT:"."+i.EQUATION_TEXT,EQUATION_PREVIEW:"."+i.EQUATION_PREVIEW,SUBMIT:"."+i.SUBMIT,LIBRARY_BUTTON:"."+i.LIBRARY+" button"},o={START:"\\(",END:"\\)"},u={FORM:'
    {{{library}}}
    {{get_string "cursorinfo" component}}

    ',LIBRARY:'
    {{#each library}}
    {{#split "\n" elements}}{{/split}}
    {{/each}}
    '};e.namespace("M.atto_equation").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,_lastCursorPos:0,_content:null,_sourceEquation:null,_groupFocus:null,_equationPatterns:[/\$\$([\S\s]+?)\$\$/,/\\\(([\S\s]+?)\\\)/,/\\\[([\S\s]+?)\\\]/,/\[tex\]([\S\s]+?)\[\/tex\]/],initializer:function(){this._groupFocus={},this.get("texfilteractive")&&(this.addButton({icon:"e/math",callback:this._displayDialogue}),this.get("host").on("atto:selectionchanged",function(){this._resolveEquation()?this.highlightButtons():this.unHighlightButtons()},this),this.editor.all("tex").each(function(t){var n=e.Node.create(""+o.START+" "+t.get("text")+" "+o.END+"");t.replace(n)}))},_displayDialogue:function(){this._currentSelection=this.get("host").getSelection();if(this._currentSelection===!1)return;var t=this._resolveEquation(),r=this.getDialogue({headerContent:M.util.get_string("pluginname",n),focusAfterHide:!0,width:600,focusOnShowSelector:s.EQUATION_TEXT}),i=this._getDialogueContent();r.set("bodyContent",i);var o=i.one(s.LIBRARY),u=new e.TabView({srcNode:o});u.render(),r.show(),e.fire(M.core.event.FILTER_CONTENT_UPDATED,{nodes:new e.NodeList(r.get("boundingBox"))}),t&&i.one(s.EQUATION_TEXT).set("text",t),this._updatePreview(!1)},_resolveEquation:function(){var t=this.get("host").getSelectionParentNode(),n=this.get("host").getSelection(),r,i=!1;return this.get("host").isActive()?t?!n||n.length===0?!1:(this.sourceEquation=null,n=n[0],r=e.one(t).get("text"),e.Array.find(this._equationPatterns,function(t){var s=r.match(new RegExp(t.source,"g"));if(s&&s.length)return e.Array.find(s,function(e){var s=0;while(r.indexOf(e,s)!==-1){var o=r.indexOf(e,s),u=o+e.length,a=n.startOffset>=o&&n.startOffseto;if(a&&f){var l=e.match(t);if(l&&l.length){var c=r.indexOf(l[1],o),h=c+l[1].length;return i=l[1],this.sourceEquation={startOuterPosition:o,endOuterPosition:u,outerMatch:e,startInnerPosition:c,endInnerPosition:h,innerMatch:l},!0}}s=u}},this)},this),i!==!1&&(i=i.trim()),i):!1:!1},_setEquation:function(t){var n,r,i,s,u;u=this.get("host"),t.preventDefault(),this.getDialogue({focusAfterHide:null}).hide(),n=t.currentTarget.ancestor(".atto_form").one("textarea"),s=n.get("value"),s!==""&&(u.setSelection(this._currentSelection),this.sourceEquation?(r=e.one(u.getSelectionParentNode()),i=r.get("text"),s=" "+s+" ",newText=i.slice(0,this.sourceEquation.startInnerPosition)+s+i.slice(this.sourceEquation.endInnerPosition),r.set("text",newText)):(s=o.START+" "+s+" "+o.END,u.insertContentAtFocusPoint(s)),this.markUpdated())},_throttle:function(e,t){var n=null;return function(){var r=this,i=arguments;clearTimeout(n),n=setTimeout(function(){e.apply(r,i)},t)}},_updatePreview:function(t){var n=this._content.one(s.EQUATION_TEXT),r=n.get("value"),i,u=n.get("selectionStart"),a="",f="\\Downarrow ",l,c;t&&t.preventDefault(),u||(u=0);while(r.charAt(u)==="\\"&&u>=0)u-=1;l=/[a-zA-Z\{\}]/;if(u!==0)while(l.test(r.charAt(u))&&u=r.size()&&(s=0),o=r.item(s),this._setGroupTabFocus(n,o),o.focus()},_setGroupTabFocus:function(e,t){var n=e.generateID();typeof this._groupFocus[n]!="undefined"&&this._groupFocus[n].setAttribute("tabindex","-1"),this._groupFocus[n]=t,t.setAttribute("tabindex",0),e.setAttribute("aria-activedescendant",t.generateID())},_selectLibraryItem:function(e){var t=e.currentTarget.getAttribute("data-tex"),n,r,i,s=0;e.preventDefault(),this._setGroupTabFocus(e.currentTarget.get("parentNode"),e.currentTarget),i=e.currentTarget.ancestor(".atto_form").one("textarea"),n=i.get("value"),r=n.substring(0,this._lastCursorPos),r.charAt(r.length-1)!==" "&&(r+=" "),r+=t,s=r.length,n.charAt(this._lastCursorPos)!==" "&&(r+=" "),r+=n.substring(this._lastCursorPos,n.length),i.set("value",r),i.focus();var o=i.getDOMNode();if(typeof o.selectionStart=="number")o.selectionStart=o.selectionEnd=s;else if(typeof o.createTextRange!="undefined"){var u=o.createTextRange();u.moveToPoint(s),u.select()}this._updatePreview(!1)},_getLibraryContent:function(){var t=e.Handlebars.compile(u.LIBRARY),r=this.get("library"),s="";e.Handlebars.registerHelper("split",function(e,t,n){var r,i,s;if(typeof e=="undefined"||typeof t=="undefined")return"";s="",r=t.trim().split(e);while(r.length>0)i=r.shift().trim(),s+=n.fn(i);return s}),s=t({elementid:this.get("host").get("elementid"),component:n,library:r,CSS:i,DELIMITERS:o});var a=M.cfg.wwwroot+"/lib/editor/atto/plugins/equation/ajax.php",f={sesskey:M.cfg.sesskey,contextid:this.get("contextid"),action:"filtertext",text:s};return preview=e.io(a,{sync:!0,data:f,method:"POST"}),preview.status===200&&(s=preview.responseText),s}},{ATTRS:{texfilteractive:{value:!1},contextid:{value:null},library:{value:{}},texdocsurl:{value:null}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin","moodle-core-event","io","event-valuechange","tabview","array-extras"]}); YUI.add("moodle-atto_charmap-button",function(e,t){var n="atto_charmap",r={BUTTON:"atto_charmap_character",CHARMAP:"atto_charmap_selector"},i=[[" "," ",!0,"nobreakspace"],["&","&",!0,"ampersand"],[""",""",!0,"quotationmark"],["¢","¢",!0,"centsign"],["€","€",!0,"eurosign"],["£","£",!0,"poundsign"],["¥","¥",!0,"yensign"],["©","©",!0,"copyrightsign"],["®","®",!0,"registeredsign"],["™","™",!0,"trademarksign"],["‰","‰",!0,"permillesign"],["µ","µ",!0,"microsign"],["·","·",!0,"middledot"],["•","•",!0,"bullet"],["…","…",!0,"threedotleader"],["′","′",!0,"minutesfeet"],["″","″",!0,"secondsinches"],["§","§",!0,"sectionsign"],["¶","¶",!0,"paragraphsign"],["ß","ß",!0,"sharpsesszed"],["‹","‹",!0,"singleleftpointinganglequotationmark"],["›","›",!0,"singlerightpointinganglequotationmark"],["«","«",!0,"leftpointingguillemet"],["»","»",!0,"rightpointingguillemet"],["‘","‘",!0,"leftsinglequotationmark"],["’","’",!0,"rightsinglequotationmark"],["“","“",!0,"leftdoublequotationmark"],["”","”",!0,"rightdoublequotationmark"],["‚","‚",!0,"singlelow9quotationmark"],["„","„",!0,"doublelow9quotationmark"],["<","<",!0,"lessthansign"],[">",">",!0,"greaterthansign"],["≤","≤",!0,"lessthanorequalto"],["≥","≥",!0,"greaterthanorequalto"],["–","–",!0,"endash"],["—","—",!0,"emdash"],["¯","¯",!0,"macron"],["‾","‾",!0,"overline"],["¤","¤",!0,"currencysign"],["¦","¦",!0,"brokenbar"],["¨","¨",!0,"diaeresis"],["¡","¡",!0,"invertedexclamationmark"],["¿","¿",!0,"turnedquestionmark"],["ˆ","ˆ",!0,"circumflexaccent"],["˜","˜",!0,"smalltilde"],["°","°",!0,"degreesign"],["−","−",!0,"minussign"],["±","±",!0,"plusminussign"],["÷","÷",!0,"divisionsign"],["⁄","⁄",!0,"fractionslash"],["×","×",!0,"multiplicationsign"],["¹","¹",!0,"superscriptone"],["²","²",!0,"superscripttwo"],["³","³",!0,"superscriptthree"],["¼","¼",!0,"fractiononequarter"],["½","½",!0,"fractiononehalf"],["¾","¾",!0,"fractionthreequarters"],["ƒ","ƒ",!0,"functionflorin"],["∫","∫",!0,"integral"],["∑","∑",!0,"narysumation"],["∞","∞",!0,"infinity"],["√","√",!0,"squareroot"],["∼","∼",!1,"similarto"],["≅","≅",!1,"approximatelyequalto"],["≈","≈",!0,"almostequalto"],["≠","≠",!0,"notequalto"],["≡","≡",!0,"identicalto"],["∈","∈",!1,"elementof"],["∉","∉",!1,"notanelementof"],["∋","∋",!1,"containsasmember"],["∏","∏",!0,"naryproduct"],["∧","∧",!1,"logicaland"],["∨","∨",!1,"logicalor"],["¬","¬",!0,"notsign"],["∩","∩",!0,"intersection"],["∪","∪",!1,"union"],["∂","∂",!0,"partialdifferential"],["∀","∀",!1,"forall"],["∃","∃",!1,"thereexists"],["∅","∅",!1,"diameter"],["∇","∇",!1,"backwarddifference"],["∗","∗",!1,"asteriskoperator"],["∝","∝",!1,"proportionalto"],["∠","∠",!1,"angle"],["´","´",!0,"acuteaccent"],["¸","¸",!0,"cedilla"],["ª","ª",!0,"feminineordinalindicator"],["º","º",!0,"masculineordinalindicator"],["†","†",!0,"dagger"],["‡","‡",!0,"doubledagger"],["À","À",!0,"agrave_caps"],["Á","Á",!0,"aacute_caps"],["Â","Â",!0,"acircumflex_caps"],["Ã","Ã",!0,"atilde_caps"],["Ä","Ä",!0,"adiaeresis_caps"],["Å","Å",!0,"aringabove_caps"],["Æ","Æ",!0,"ligatureae_caps"],["Ç","Ç",!0,"ccedilla_caps"],["È","È",!0,"egrave_caps"],["É","É",!0,"eacute_caps"],["Ê","Ê",!0,"ecircumflex_caps"],["Ë","Ë",!0,"ediaeresis_caps"],["Ì","Ì",!0,"igrave_caps"],["Í","Í",!0,"iacute_caps"],["Î","Î",!0,"icircumflex_caps"],["Ï","Ï",!0,"idiaeresis_caps"],["Ð","Ð",!0,"eth_caps"],["Ñ","Ñ",!0,"ntilde_caps"],["Ò","Ò",!0,"ograve_caps"],["Ó","Ó",!0,"oacute_caps"],["Ô","Ô",!0,"ocircumflex_caps"],["Õ","Õ",!0,"otilde_caps"],["Ö","Ö",!0,"odiaeresis_caps"],["Ø","Ø",!0,"oslash_caps"],["Œ","Œ",!0,"ligatureoe_caps"],["Š","Š",!0,"scaron_caps"],["Ù","Ù",!0,"ugrave_caps"],["Ú","Ú",!0,"uacute_caps"],["Û","Û",!0,"ucircumflex_caps"],["Ü","Ü",!0,"udiaeresis_caps"],["Ý","Ý",!0,"yacute_caps"],["Ÿ","Ÿ",!0,"ydiaeresis_caps"],["Þ","Þ",!0,"thorn_caps"],["à","à",!0,"agrave"],["á","á",!0,"aacute"],["â","â",!0,"acircumflex"],["ã","ã",!0,"atilde"],["ä","ä",!0,"adiaeresis"],["å","å",!0,"aringabove"],["æ","æ",!0,"ligatureae"],["ç","ç",!0,"ccedilla"],["è","è",!0,"egrave"],["é","é",!0,"eacute"],["ê","ê",!0,"ecircumflex"],["ë","ë",!0,"ediaeresis"],["ì","ì",!0,"igrave"],["í","í",!0,"iacute"],["î","î",!0,"icircumflex"],["ï","ï",!0,"idiaeresis"],["ð","ð",!0,"eth"],["ñ","ñ",!0,"ntilde"],["ò","ò",!0,"ograve"],["ó","ó",!0,"oacute"],["ô","ô",!0,"ocircumflex"],["õ","õ",!0,"otilde"],["ö","ö",!0,"odiaeresis"],["ø","ø",!0,"oslash"],["œ","œ",!0,"ligatureoe"],["š" ,"š",!0,"scaron"],["ù","ù",!0,"ugrave"],["ú","ú",!0,"uacute"],["û","û",!0,"ucircumflex"],["ü","ü",!0,"udiaeresis"],["ý","ý",!0,"yacute"],["þ","þ",!0,"thorn"],["ÿ","ÿ",!0,"ydiaeresis"],["Α","Α",!0,"alpha_caps"],["Β","Β",!0,"beta_caps"],["Γ","Γ",!0,"gamma_caps"],["Δ","Δ",!0,"delta_caps"],["Ε","Ε",!0,"epsilon_caps"],["Ζ","Ζ",!0,"zeta_caps"],["Η","Η",!0,"eta_caps"],["Θ","Θ",!0,"theta_caps"],["Ι","Ι",!0,"iota_caps"],["Κ","Κ",!0,"kappa_caps"],["Λ","Λ",!0,"lambda_caps"],["Μ","Μ",!0,"mu_caps"],["Ν","Ν",!0,"nu_caps"],["Ξ","Ξ",!0,"xi_caps"],["Ο","Ο",!0,"omicron_caps"],["Π","Π",!0,"pi_caps"],["Ρ","Ρ",!0,"rho_caps"],["Σ","Σ",!0,"sigma_caps"],["Τ","Τ",!0,"tau_caps"],["Υ","Υ",!0,"upsilon_caps"],["Φ","Φ",!0,"phi_caps"],["Χ","Χ",!0,"chi_caps"],["Ψ","Ψ",!0,"psi_caps"],["Ω","Ω",!0,"omega_caps"],["α","α",!0,"alpha"],["β","β",!0,"beta"],["γ","γ",!0,"gamma"],["δ","δ",!0,"delta"],["ε","ε",!0,"epsilon"],["ζ","ζ",!0,"zeta"],["η","η",!0,"eta"],["θ","θ",!0,"theta"],["ι","ι",!0,"iota"],["κ","κ",!0,"kappa"],["λ","λ",!0,"lambda"],["μ","μ",!0,"mu"],["ν","ν",!0,"nu"],["ξ","ξ",!0,"xi"],["ο","ο",!0,"omicron"],["π","π",!0,"pi"],["ρ","ρ",!0,"rho"],["ς","ς",!0,"finalsigma"],["σ","σ",!0,"sigma"],["τ","τ",!0,"tau"],["υ","υ",!0,"upsilon"],["φ","φ",!0,"phi"],["χ","χ",!0,"chi"],["ψ","ψ",!0,"psi"],["ω","ω",!0,"omega"],["ℵ","ℵ",!1,"alefsymbol"],["ϖ","ϖ",!1,"pisymbol"],["ℜ","ℜ",!1,"realpartsymbol"],["ϑ","ϑ",!1,"thetasymbol"],["ϒ","ϒ",!1,"upsilonhooksymbol"],["℘","℘",!1,"weierstrassp"],["ℑ","ℑ",!1,"imaginarypart"],["←","←",!0,"leftwardsarrow"],["↑","↑",!0,"upwardsarrow"],["→","→",!0,"rightwardsarrow"],["↓","↓",!0,"downwardsarrow"],["↔","↔",!0,"leftrightarrow"],["↵","↵",!1,"carriagereturn"],["⇐","⇐",!1,"leftwardsdoublearrow"],["⇑","⇑",!1,"upwardsdoublearrow"],["⇒","⇒",!1,"rightwardsdoublearrow"],["⇓","⇓",!1,"downwardsdoublearrow"],["⇔","⇔",!1,"leftrightdoublearrow"],["∴","∴",!1,"therefore"],["⊂","⊂",!1,"subsetof"],["⊃","⊃",!1,"supersetof"],["⊄","⊄",!1,"notasubsetof"],["⊆","⊆",!1,"subsetoforequalto"],["⊇","⊇",!1,"supersetoforequalto"],["⊕","⊕",!1,"circledplus"],["⊗","⊗",!1,"circledtimes"],["⊥","⊥",!1,"perpendicular"],["⋅","⋅",!1,"dotoperator"],["⌈","⌈",!1,"leftceiling"],["⌉","⌉",!1,"rightceiling"],["⌊","⌊",!1,"leftfloor"],["⌋","⌋",!1,"rightfloor"],["⟨","〈",!1,"leftpointinganglebracket"],["⟩","〉",!1,"rightpointinganglebracket"],["◊","◊",!0,"lozenge"],["♠","♠",!0,"blackspadesuit"],["♣","♣",!0,"blackclubsuit"],["♥","♥",!0,"blackheartsuit"],["♦","♦",!0,"blackdiamondsuit"],[" "," ",!1,"enspace"],[" "," ",!1,"emspace"],[" "," ",!1,"thinspace"],["‌","‌",!1,"zerowidthnonjoiner"],["‍","‍",!1,"zerowidthjoiner"],["‎","‎",!1,"lefttorightmark"],["‏","‏",!1,"righttoleftmark"],["­","­",!1,"softhyphen"]];e.namespace("M.atto_charmap").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,initializer:function(){this.addButton({icon:"e/special_character",callback:this._displayDialogue})},_displayDialogue:function(){this._currentSelection=this.get("host").getSelection();if(this._currentSelection===!1)return;var e=this.getDialogue({headerContent:M.util.get_string("insertcharacter",n),focusAfterHide:!0},!0);e.set("bodyContent",this._getDialogueContent()).show()},_getDialogueContent:function(){var t=e.Handlebars.compile('
    {{#each CHARMAP}}{{#if this.[2]}}{{/if}}{{/each}}
    '),s=e.Node.create(t({component:n,CSS:r,CHARMAP:i}));return s.delegate("click",this._insertChar,"."+r.BUTTON,this),s},_insertChar:function(e){var t=e.target.getData("character");this.getDialogue({focusAfterHide:null}).hide();var n=this.get("host");n.setSelection(this._currentSelection),n.insertContentAtFocusPoint(t),this.markUpdated()}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); YUI.add("moodle-editor_atto-menu",function(e,t){var n='
    ';Menu=function(){Menu.superclass.constructor.apply(this,arguments)},e.extend(Menu,M.core.dialogue,{_menuHandlers:null,initializer:function(t){var r,i;this._menuHandlers=[];var s=e.Handlebars.compile(n),o=e.Node.create(s({config:t}));this.set("bodyContent",o),i=this.get("boundingBox"),i.addClass("editor_atto_controlmenu"),i.addClass("editor_atto_menu"),i.one(".moodle-dialogue-wrap").removeClass("moodle-dialogue-wrap").addClass("moodle-dialogue-content"),r=e.Node.create("

    ").addClass("accesshide").setHTML(this.get("headerText")),this.get("bodyContent").prepend(r),this.headerNode.hide(),this.footerNode.hide(),this._setupHandlers()},_setupHandlers:function(){var e=this.get("contentBox");this._menuHandlers.push(e.delegate("key",this._chooseMenuItem,"32, enter",".atto_menuentry",this),e.delegate("key",this._handleKeyboardEvent,"down:38,40",".dropdown-menu",this),e.on("focusoutside",this.hide,this),e.delegate("key",this.hide,"down:37,39,esc",".dropdown-menu",this))},_chooseMenuItem:function(e){e.target.simulate("click"),e.preventDefault()},hide:function(e){if(this.get("preventHideMenu")===!0)return;return e&&e.preventDefault(),Menu.superclass.hide.call(this,arguments)},_handleKeyboardEvent:function(e){e.preventDefault();var t=e.currentTarget.all('a[role="menuitem"]'),n=!1,r=0,i=1,s=0,o=e.target.ancestor('a[role="menuitem"]',!0);while(!n&&r=t.size()&&(r=0),next=t.item(r),s++;while(s");return r.setAttrs(t.getAttrs()),t.get("childNodes").each(function(e){r.append(e.remove())}),t.replace(r),r},_updateTable:function(t){var n,r,i,s;t.preventDefault(),this.getDialogue({focusAfterHide:null}).hide(),n=t.currentTarget.ancestor(o.FORM).one(o.CAPTION),r=t.currentTarget.ancestor(o.FORM).one(o.HEADERS),i=this._lastTarget.ancestor("table"),s=i.one("caption"),s||(s=e.Node.create(""+l,u+=""+e.Escape.html(n.get("value"))+""+l,a=0;if(s.get("value")==="columns"||s.get("value")==="both"){a=1,u+=""+l+""+l;for(f=0;f'+l;u+=""+l+""+l}u+=""+l;for(;a"+l:u+=''+l;u+=""+l}u+=""+l,u+=""+l+"
    ",this.get("host").insertContentAtFocusPoint(u),this.markUpdated()},_findColumnCells:function(){var t=this._getColumnIndex(this._lastTarget),n=this._lastTarget.ancestor("table").all("tr"),r=new e.NodeList,i=new e.NodeList,s=new e.NodeList;return n.each(function(e){var n=e.all("td, th"),o=n.item(t),u=n.item(t-1),a=n.item(t+1);r.push(o),u&&i.push(u),a&&s.push(a)}),{current:r,prev:i,next:s}},_hideInvalidEntries:function(e){var t=this._lastTarget.ancestor("table"),n=this._lastTarget.ancestor("tr"),r=t.all("tr"),i=r.indexOf(n),s=r.item(i-1),o=s?s.one("td"):null;!n||!o?e.one('[data-change="moverowup"]').hide():e.one('[data-change="moverowup"]').show();var u=r.item(i+1),a=n?n.one("td"):!1;!n||!u||!a?e.one('[data-change="moverowdown"]').hide():e.one('[data-change="moverowdown"]').show();var f=this._findColumnCells();f.prev.filter("td").size()>0?e.one('[data-change="movecolumnleft"]').show():e.one('[data-change="movecolumnleft"]').hide();var l=f.current.filter("td").size()>0;f.next.size()>0&&l?e.one('[data-change="movecolumnright"]').show():e.one('[data-change="movecolumnright"]').hide(),f.current.filter("td").size()>0?e.one('[data-change="deletecolumn"]').show():e.one('[data-change="deletecolumn"]').hide(),!n||!n.one("td")?e.one('[data-change="deleterow"]').hide():e.one('[data-change="deleterow"]').show()},_showTableMenu:function(t){t.preventDefault();var r;this._contextMenu||(this._menuOptions=[{text:M.util.get_string("addcolumnafter",n),data:{change:"addcolumnafter"}},{text:M.util.get_string("addrowafter",n),data:{change:"addrowafter"}},{text:M.util.get_string("moverowup",n),data:{change:"moverowup"}},{text:M.util.get_string("moverowdown",n),data:{change:"moverowdown"}},{text:M.util.get_string("movecolumnleft",n),data:{change:"movecolumnleft"}},{text:M.util.get_string("movecolumnright",n),data:{change:"movecolumnright"}},{text:M.util.get_string("deleterow",n),data:{change:"deleterow"}},{text:M.util.get_string("deletecolumn",n),data:{change:"deletecolumn"}},{text:M.util.get_string("edittable",n),data:{change:"edittable"}}],this._contextMenu=new e.M.editor_atto.Menu({items:this._menuOptions}),r=this._contextMenu.get("boundingBox"),r.delegate("click",this._handleTableChange,"a",this)),r=this._contextMenu.get("boundingBox"),this._lastTarget=t.tableCell.ancestor(".editor_atto_content td, .editor_atto_content th",!0),this._hideInvalidEntries(r),e.Array.each(this.get("host").openMenus,function(e){e.set("focusAfterHide",null)});var i=this.buttons[this.name];this.get("host")._setTabFocus(i),this._contextMenu.show(),this._contextMenu.align(this.buttons.table,[e.WidgetPositionAlign.TL,e.WidgetPositionAlign.BL]),this._contextMenu.set("focusAfterHide",i),r.one("a")&&r.one("a").focus(),this.get("host").openMenus=[this._contextMenu]},_handleTableChange:function(e){e.preventDefault(),this._contextMenu.set("focusAfterHide",this.get("host").editor),this._contextMenu.hide(e);switch(e.target.getData("change")){case"addcolumnafter":this._addColumnAfter();break;case"addrowafter":this._addRowAfter();break;case"deleterow":this._deleteRow();break;case"deletecolumn":this._deleteColumn();break;case"edittable":this._editTable();break;case"moverowdown":this._moveRowDown();break;case"moverowup":this._moveRowUp();break;case"movecolumnleft":this._moveColumnLeft();break;case"movecolumnright":this._moveColumnRight()}},_getRowIndex:function(e){var t=e.ancestor("table"),n=e.ancestor("tr");if(!t||!n)return;var r=t.all("tr");return r.indexOf(n)},_getColumnIndex:function(e){var t=e.ancestor("tr");if(!t)return;var n=t.all("td, th");return n.indexOf(e)},_deleteRow:function(){var e=this._lastTarget.ancestor("tr");e&&e.one("td")&&e.remove(!0),this.markUpdated()},_moveRowUp:function(){var e=this._lastTarget.ancestor("tr"),t=e.previous("tr");if(!e||!t)return;e.swap(t),this.markUpdated()},_moveColumnLeft:function(){var e=this._findColumnCells();if(e.current.size()>0&&e.prev.size()>0&&e.current.size()===e.prev.size()){var t=0;for(t=0;t "),1)},_removeCaption:function(){var e=this._lastTarget.ancestor("table"),t=e.one("caption");t&&t.remove(!0)},_moveColumnRight:function(){var e=this._findColumnCells();if(e.next.size()>0&&e.current.size()===e.next.size()&&e.current.filter("td").size()>0){var t=0;for(t=0;t");t.replace(n),t=n}t.setHTML(" ")}),n.insert(newrow,t),this.markUpdated()},_addColumnAfter:function(){var t=this._findColumnCells(),n=!0,r=t.next;t.next.size()<=0&&(n=!1,r=t.current),e.each(r,function(e){var t=e.cloneNode();t.setHTML(" "),n?e.get("parentNode").insert(t,e):(e.get("parentNode").insert(t,e),e.swap(t))},this),this.markUpdated()}})},"@VERSION@",{requires:["moodle-editor_atto-plugin","moodle-editor_atto-menu","event","event-valuechange"]}); YUI.add("moodle-atto_clear-button",function(e,t){e.namespace("M.atto_clear").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{initializer:function(){this.addBasicButton({exec:"removeFormat",icon:"e/clear_formatting"})}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); YUI.add("moodle-atto_undo-button",function(e,t){var n="moodle-atto_undo-button";e.namespace("M.atto_undo").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_maxUndos:40,_undoStack:null,_redoStack:null,initializer:function(){this._undoStack=[],this._redoStack=[],this.addButton({title:"undo",icon:"e/undo",callback:this._undoHandler,buttonName:"undo",keys:90}),this.addButton({title:"redo",icon:"e/redo",callback:this._redoHandler,buttonName:"redo",keys:89}),this.get("host").on("pluginsloaded",function(){this._addToUndo(this._getHTML()),this.get("host").on("atto:selectionchanged",this._changeListener,this)},this),this._updateButtonsStates()},_addToRedo:function(e){this._redoStack.push(e)},_addToUndo:function(e,t){var n=this._undoStack[this._undoStack.length-1];typeof t=="undefined"&&(t=!1),n!==e&&(this._undoStack.push(e),t&&(this._redoStack=[]));while(this._undoStack.length>this._maxUndos)this._undoStack.shift()},_getHTML:function(){return this.get("host").getCleanHTML()},_getRedo:function(){return this._redoStack.pop()},_getUndo:function(e){return this._undoStack.length===1?this._undoStack[0]:(last=this._undoStack.pop(),last===e&&(last=this._undoStack.pop()),this._undoStack.length===0&&this._addToUndo(last),last)},_restoreValue:function(e){this.editor.setHTML(e),this._addToUndo(e)},_updateButtonsStates:function(){this._undoStack.length>1?this.enableButtons("undo"):this.disableButtons("undo"),this._redoStack.length>0?this.enableButtons("redo"):this.disableButtons("redo")},_undoHandler:function(e){e.preventDefault();var t=this._getHTML(),n=this._getUndo(t);if(t===n){this._updateButtonsStates();return}this._restoreValue(n),this._addToRedo(t),this._updateButtonsStates()},_redoHandler:function(e){e.preventDefault();var t=this._getHTML(),n=this._getRedo();if(t===n){this._updateButtonsStates();return}this._restoreValue(n),this._updateButtonsStates()},_changeListener:function(e){if(e.event&&e.event.type.indexOf("key")!==-1&&e.event.keyCode!==39&&e.event.keyCode!==37&&e.event.keyCode!==40&&e.event.keyCode!==38)return;this._addToUndo(this._getHTML(),!0),this._updateButtonsStates()}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});