weekly release 4.0dev
[moodle.git] / lib / yui / build / moodle-core-notification-dialogue / moodle-core-notification-dialogue-min.js
1 YUI.add("moodle-core-notification-dialogue",function(s,e){var t,n,i,a,l,d,r,h,u,o,c,g="moodle-dialogue",f="notificationBase",v={BASE:"moodle-dialogue-base",WRAP:"moodle-dialogue-wrap",HEADER:"moodle-dialogue-hd",BODY:"moodle-dialogue-bd",CONTENT:"moodle-dialogue-content",FOOTER:"moodle-dialogue-ft",HIDDEN:"hidden",LIGHTBOX:"moodle-dialogue-lightbox"};M.core=M.core||{},t="Moodle dialogue",i=g+"-fullscreen",a=g+"-hidden",l=" [role=dialog]",d="[role=menubar]",r=".",h="moodle-has-zindex",u='input:not([type="hidden"]):not([disabled]):not([tabindex^="-"]),a[href]:not([disabled]):not([tabindex^="-"]),button:not([disabled]):not([tabindex^="-"]),textarea:not([disabled]):not([tabindex^="-"]),select:not([disabled]):not([tabindex^="-"]),[tabindex]:not([disabled]):not([tabindex^="-"])',o="form",n=function(e){var t="moodle-dialogue-"+s.stamp(this)+"-wrap";e.notificationBase=s.Node.create('<div class="'+v.BASE+'">').append(s.Node.create('<div id="'+t+'" role="dialog" aria-labelledby="'+t+'-header-text" class="'+v.WRAP+'"  aria-live="polite"></div>').append(s.Node.create('<div class="'+v.HEADER+' yui3-widget-hd"></div>')).append(s.Node.create('<div class="'+v.BODY+' yui3-widget-bd"></div>')).append(s.Node.create('<div class="'+v.FOOTER+' yui3-widget-ft"></div>'))),e.attachmentPoint=e.attachmentPoint||document.body,s.one(e.attachmentPoint).append(e.notificationBase),e.srcNode="#"+t,delete e.buttons,n.superclass.constructor.apply(this,[e])},s.extend(n,s.Panel,{_resizeevent:null,_orientationevent:null,_calculatedzindex:!1,_currentMaskNodeId:null,_originalPosition:null,_hiddenSiblings:null,hideIfNotForm:function(){null===this.get("boundingBox").one(o)&&this.hide()},initializer:function(){var e,t,i,o;!1!==this.get("closeButton")&&(t=this.get("closeButtonTitle"),this.get("buttons").header[0].setAttribute("title",t),this.get("buttons").header[0].setAttribute("aria-label",t)),this.setStdModContent(s.WidgetStdMod.HEADER,'<h5 id="'+this.get("id")+'-wrap-header-text">'+this.get("headerContent")+"</h5>",s.WidgetStdMod.REPLACE),this._hiddenSiblings=[],this.get("render")&&this.render(),this.after("visibleChange",this.visibilityChanged,this),this.get("center")&&this.centerDialogue(),this.get("modal")&&(this.get(f).set("aria-hidden","true"),this.plug(s.M.core.LockScroll)),this.set("focusOn",s.Array(this.get("focusOn")).filter(function(e){return"focusoutside"!==e.eventName})),(e=this.get("boundingBox")).addClass(h),s.Array.each(this.get("extraClasses"),e.addClass,e),this.get("visible")&&this.applyZIndex(),this.on("maskShow",this.applyZIndex),this.on("maskShow",function(){var e,t=s.one(s.config.win),i=this.get("boundingBox");this.get("center")||(this._originalPosition=i.getXY()),e=this.get("maskNode"),this._currentMaskNodeId!==e.get("_yuid")&&(this._currentMaskNodeId=e.get("_yuid"),e.on("click",this.hideIfNotForm,this)),"fixed"!==i.getStyle("position")&&i.setStyles({top:t.get("scrollTop"),left:t.get("scrollLeft")})},this),i=this.get("notificationBase"),""!==(o=this.get("additionalBaseClass"))&&i.addClass(o),this.after("destroyedChange",function(){this.get(f).remove(!0)},this)},applyZIndex:function(){var i=1040,e=1,t=this.get("boundingBox"),o=this.get("maskNode"),n=this.get("zIndex");0===n||this._calculatedzindex?(s.all(l+", "+d+", "+r+h).each(function(e){var t=this.findZIndex(e);i<t&&(i=t)},this),e=(i+1).toString(),t.setStyle("zIndex",e),this.set("zIndex",e),this.get("modal")&&(o.setStyle("zIndex",e),s.UA.ie&&s.UA.compareVersions(s.UA.ie,9)<0&&setTimeout(function(){o.setStyle("position","static"),setTimeout(function(){o.setStyle("position","fixed")},0)},0)),this._calculatedzindex=!0):t.setStyle("zIndex",n)},findZIndex:function(e){var t=e.getStyle("zIndex")||e.ancestor().getStyle("zIndex");return t?parseInt(t,10):0},visibilityChanged:function(e){var t;"visible"===e.attrName&&(this.get("maskNode").addClass(v.LIGHTBOX),e.prevVal&&!e.newVal&&(this.get("boundingBox"),this._resizeevent&&(this._resizeevent.detach(),this._resizeevent=null),this._orientationevent&&(this._orientationevent.detach(),this._orientationevent=null),require(["core/local/aria/focuslock"],function(e){e.untrapFocus()}),this.get("modal")&&this.setAccessibilityHidden()),!e.prevVal&&e.newVal&&(this.applyZIndex(),this.makeResponsive(),this.shouldResizeFullscreen()||this.get("draggable")&&(t="#"+this.get("id")+" ."+v.HEADER,this.plug(s.Plugin.Drag,{handles:[t]}),s.one(t).setStyle("cursor","move")),this.get("modal")&&this.setAccessibilityVisible()),this.get("center")&&!e.prevVal&&e.newVal&&this.centerDialogue())},makeResponsive:function(){var e=this.get("boundingBox");this.shouldResizeFullscreen()?(e.addClass(i),e.setStyles({left:null,top:null,width:null,height:null,right:null,bottom:null})):this.get("responsive")&&e.removeClass(i).setStyles({width:this.get("width"),height:this.get("height")}),this.lockScroll&&this.lockScroll.updateScrollLock(this.shouldResizeFullscreen())},centerDialogue:function(){var e,t,i=this.get("boundingBox"),o=i.hasClass(a);this.shouldResizeFullscreen()||(o&&i.setStyle("top","-1000px").removeClass(a),e=Math.max(Math.round((i.get("winWidth")-i.get("offsetWidth"))/2),15),t=Math.max(Math.round((i.get("winHeight")-i.get("offsetHeight"))/2),15)+s.one(window).get("scrollTop"),i.setStyles({left:e,top:t}),o&&i.addClass(a),this.makeResponsive())},shouldResizeFullscreen:function(){return window===window.parent&&this.get("responsive")&&Math.floor(s.one(document.body).get("winWidth"))<this.get("responsiveWidth")},_focus:function(){this.focus()},show:function(){var e,t=this.bodyNode,i=this.get("focusOnShowSelector"),o=null;return e=n.superclass.show.call(this),!this.get("center")&&this._originalPosition&&this.get("boundingBox").setXY(this._originalPosition),null!==i&&(o=this.get("boundingBox").one(i)),o||t&&""!==t&&(o=t.one(u)),require(["core/local/aria/focuslock"],function(e){e.trapFocus(this.get("boundingBox").getDOMNode()),o&&o.focus()}.bind(this)),e},hide:function(e){if(!e||"key"!==e.type||27!==e.keyCode||this.get("focused")
2 )return this.lockScroll&&this.lockScroll.disableScrollLock(),n.superclass.hide.call(this,arguments)},keyDelegation:function(){this.get("boundingBox").delegate("key",function(e){var t=e.target,i="forward";e.shiftKey&&(i="backward"),this.trapFocus(t,i)&&e.preventDefault()},"down:9",u,this)},trapFocus:function(e,t){var i=this.get("boundingBox"),o=i.one(u),n=i.all(u).pop();return e===n&&"forward"===t?o.focus():e===o&&"backward"===t?n.focus():void 0},setAccessibilityVisible:function(){var i=this.get(f);s.one(document.body).get("children").each(function(e){if(e!==i){var t=e.get("aria-hidden");"true"!==t&&(e.setData("previous-aria-hidden",t),this._hiddenSiblings.push(e),e.set("aria-hidden","true"))}},this),i.set("aria-hidden","false")},setAccessibilityHidden:function(){this.get(f).set("aria-hidden","true"),s.Array.each(this._hiddenSiblings,function(e){var t=e.getData("previous-aria-hidden");null===t?e.removeAttribute("aria-hidden"):e.set("aria-hidden",t)}),this._hiddenSiblings=[]}},{NAME:t,CSS_PREFIX:g,ATTRS:{additionalBaseClass:{value:""},notificationBase:{},lightbox:{lazyAdd:!1,setter:function(e){this.set("modal",e)}},closeButton:{validator:s.Lang.isBoolean,value:!0},closeButtonTitle:{validator:s.Lang.isString,value:M.util.get_string("closebuttontitle","moodle")},center:{validator:s.Lang.isBoolean,value:!0},draggable:{validator:s.Lang.isBoolean,value:!1},COUNT:{writeOnce:!0,valueFn:function(){return s.stamp(this)}},responsive:{validator:s.Lang.isBoolean,value:!0},responsiveWidth:{value:768},focusOnShowSelector:{value:null}}}),s.Base.modifyAttrs(n,{width:{value:"400px",setter:function(e){return"auto"===e?"":e}},visible:{value:!1},centered:{setter:function(e){return e&&this.set("center",!0),!1}},render:{value:!0,writeOnce:!0},extraClasses:{value:[]},id:{writeOnce:!0,valueFn:function(){return"moodle-dialogue-"+s.stamp(this)}},buttons:{getter:s.WidgetButtons.prototype._getButtons,setter:s.WidgetButtons.prototype._setButtons,valueFn:function(){return!1===this.get("closeButton")?null:[{section:s.WidgetStdMod.HEADER,classNames:"closebutton",action:function(){this.hide()}}]}}}),s.Base.mix(n,[s.M.core.WidgetFocusAfterHide]),M.core.dialogue=n,c=function(){c.superclass.constructor.apply(this,arguments)},s.extend(c,M.core.dialogue,{initializer:function(){this.show()}},{NAME:"Moodle information dialogue",CSS_PREFIX:g}),s.Base.modifyAttrs(c,{modal:{validator:s.Lang.isBoolean,value:!0}}),M.core.notification=M.core.notification||{},M.core.notification.info=c},"@VERSION@",{requires:["base","node","panel","escape","event-key","dd-plugin","moodle-core-widget-focusafterclose","moodle-core-lockscroll"]});