Merge branch 'MDL-32509' of git://github.com/danpoltawski/moodle
[moodle.git] / lib / yui / 3.5.0 / build / widget-autohide / widget-autohide-min.js
blob7b37201452a558eb62b03e2d419ad97421b9e76c
1 /*
2 YUI 3.5.0 (build 5089)
3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
6 */
7 YUI.add("widget-autohide",function(a){var o="widgetAutohide",m="autohide",k="clickoutside",c="focusoutside",l="document",e="key",p="esc",f="bindUI",n="syncUI",i="rendered",j="boundingBox",h="visible",d="Change",b=a.ClassNameManager.getClassName;function g(q){a.after(this._bindUIAutohide,this,f);a.after(this._syncUIAutohide,this,n);if(this.get(i)){this._bindUIAutohide();this._syncUIAutohide();}}g.ATTRS={hideOn:{validator:a.Lang.isArray,valueFn:function(){return[{node:a.one(l),eventName:e,keyCode:p}];}}};g.prototype={_uiHandlesAutohide:null,destructor:function(){this._detachUIHandlesAutohide();},_bindUIAutohide:function(){this.after(h+d,this._afterHostVisibleChangeAutohide);this.after("hideOnChange",this._afterHideOnChange);},_syncUIAutohide:function(){this._uiSetHostVisibleAutohide(this.get(h));},_uiSetHostVisibleAutohide:function(q){if(q){a.later(1,this,"_attachUIHandlesAutohide");}else{this._detachUIHandlesAutohide();}},_attachUIHandlesAutohide:function(){if(this._uiHandlesAutohide){return;}var w=this.get(j),u=a.bind(this.hide,this),r=[],q=this,s=this.get("hideOn"),t=0,v={node:undefined,ev:undefined,keyCode:undefined};for(;t<s.length;t++){v.node=s[t].node;v.ev=s[t].eventName;v.keyCode=s[t].keyCode;if(!v.node&&!v.keyCode&&v.ev){r.push(w.on(v.ev,u));}else{if(v.node&&!v.keyCode&&v.ev){r.push(v.node.on(v.ev,u));}else{if(v.node&&v.keyCode&&v.ev){r.push(v.node.on(v.ev,u,v.keyCode));}else{}}}}this._uiHandlesAutohide=r;},_detachUIHandlesAutohide:function(){a.each(this._uiHandlesAutohide,function(q){q.detach();});this._uiHandlesAutohide=null;},_afterHostVisibleChangeAutohide:function(q){this._uiSetHostVisibleAutohide(q.newVal);},_afterHideOnChange:function(q){this._detachUIHandlesAutohide();if(this.get(h)){this._attachUIHandlesAutohide();}}};a.WidgetAutohide=g;},"3.5.0",{requires:["base-build","widget","event-outside","event-key"]});