summaryrefslogtreecommitdiffstats
path: root/js/yui3/event-base/event-base-min.js
blob: c1fef0d2cb456f691f3dd140067d64b455a03294 (plain)
1
2
3
4
5
6
7
/*
YUI 3.7.3 (build 5687)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
(function(){var e=YUI.Env;e._ready||(e._ready=function(){e.DOMReady=!0,e.remove(YUI.config.doc,"DOMContentLoaded",e._ready)},e.add(YUI.config.doc,"DOMContentLoaded",e._ready))})(),YUI.add("event-base",function(e,t){e.publish("domready",{fireOnce:!0,async:!0}),YUI.Env.DOMReady?e.fire("domready"):e.Do.before(function(){e.fire("domready")},YUI.Env,"_ready");var n=e.UA,r={},i={63232:38,63233:40,63234:37,63235:39,63276:33,63277:34,25:9,63272:46,63273:36,63275:35},s=function(t){if(!t)return t;try{t&&3==t.nodeType&&(t=t.parentNode)}catch(n){return null}return e.one(t)},o=function(e,t,n){this._event=e,this._currentTarget=t,this._wrapper=n||r,this.init()};e.extend(o,Object,{init:function(){var e=this._event,t=this._wrapper.overrides,r=e.pageX,o=e.pageY,u,a=this._currentTarget;this.altKey=e.altKey,this.ctrlKey=e.ctrlKey,this.metaKey=e.metaKey,this.shiftKey=e.shiftKey,this.type=t&&t.type||e.type,this.clientX=e.clientX,this.clientY=e.clientY,this.pageX=r,this.pageY=o,u=e.keyCode||e.charCode,n.webkit&&u in i&&(u=i[u]),this.keyCode=u,this.charCode=u,this.which=e.which||e.charCode||u,this.button=this.which,this.target=s(e.target),this.currentTarget=s(a),this.relatedTarget=s(e.relatedTarget);if(e.type=="mousewheel"||e.type=="DOMMouseScroll")this.wheelDelta=e.detail?e.detail*-1:Math.round(e.wheelDelta/80)||(e.wheelDelta<0?-1:1);this._touch&&this._touch(e,a,this._wrapper)},stopPropagation:function(){this._event.stopPropagation(),this._wrapper.stopped=1,this.stopped=1},stopImmediatePropagation:function(){var e=this._event;e.stopImmediatePropagation?e.stopImmediatePropagation():this.stopPropagation(),this._wrapper.stopped=2,this.stopped=2},preventDefault:function(e){var t=this._event;t.preventDefault(),t.returnValue=e||!1,this._wrapper.prevented=1,this.prevented=1},halt:function(e){e?this.stopImmediatePropagation():this.stopPropagation(),this.preventDefault()}}),o.resolve=s,e.DOM2EventFacade=o,e.DOMEventFacade=o,function(){e.Env.evt.dom_wrappers={},e.Env.evt.dom_map={};var t=e.DOM,n=e.Env.evt,r=e.config,i=r.win,s=YUI.Env.add,o=YUI.Env.remove,u=function(){YUI.Env.windowLoaded=!0,e.Event._load(),o(i,"load",u)},a=function(){e.Event._unload()},f="domready",l="~yui|2|compat~",c=function(n){try{return n&&typeof n!="string"&&e.Lang.isNumber(n.length)&&!n.tagName&&!t.isWindow(n)}catch(r){return!1}},h=e.CustomEvent.prototype._delete,p=function(t){var n=h.apply(this,arguments);return this.hasSubs()||e.Event._clean(this),n},d=function(){var r=!1,u=0,h=[],v=n.dom_wrappers,m=null,g=n.dom_map;return{POLL_RETRYS:1e3,POLL_INTERVAL:40,lastError:null,_interval:null,_dri:null,DOMReady:!1,startInterval:function(){d._interval||(d._interval=setInterval(d._poll,d.POLL_INTERVAL))},onAvailable:function(t,n,r,i,s,o){var a=e.Array(t),f,l;for(f=0;f<a.length;f+=1)h.push({id:a[f],fn:n,obj:r,override:i,checkReady:s,compat:o});return u=this.POLL_RETRYS,setTimeout(d._poll,0),l=new e.EventHandle({_delete:function(){if(l.handle){l.handle.detach();return}var e,t;for(e=0;e<a.length;e++)for(t=0;t<h.length;t++)a[e]===h[t].id&&h.splice(t,1)}}),l},onContentReady:function(e,t,n,r,i){return d.onAvailable(e,t,n,r,!0,i)},attach:function(t,n,r,i){return d._attach(e.Array(arguments,0,!0))},_createWrapper:function(t,n,r,o,u){var a,f=e.stamp(t),l="event:"+f+n;return!1===u&&(l+="native"),r&&(l+="capture"),a=v[l],a||(a=e.publish(l,{silent:!0,bubbles:!1,contextFn:function(){return o?a.el:(a.nodeRef=a.nodeRef||e.one(a.el),a.nodeRef)}}),a.overrides={},a.el=t,a.key=l,a.domkey=f,a.type=n,a.fn=function(e){a.fire(d.getEvent(e,t,o||!1===u))},a.capture=r,t==i&&n=="load"&&(a.fireOnce=!0,m=l),a._delete=p,v[l]=a,g[f]=g[f]||{},g[f][l]=a,s(t,n,a.fn,r)),a},_attach:function(n,r){var s,o,u,a,f,h=!1,p,v=n[0],m=n[1],g=n[2]||i,y=r&&r.facade,b=r&&r.capture,w=r&&r.overrides;n[n.length-1]===l&&(s=!0);if(!m||!m.call)return!1;if(c(g))return o=[],e.each(g,function(e,t){n[2]=e,o.push(d._attach(n.slice(),r))}),new e.EventHandle(o);if(e.Lang.isString(g)){if(s)u=t.byId(g);else{u=e.Selector.query(g);switch(u.length){case 0:u=null;break;case 1:u=u[0];break;default:return n[2]=u,d._attach(n,r)}}if(!u)return p=d.onAvailable(g,function(){p.handle=d._attach(n,r)},d,!0,!1,s),p;g=u}return g?(e.Node&&e.instanceOf(g,e.Node)&&(g=e.Node.getDOMNode(g)),a=d._createWrapper(g,v,b,s,y),w&&e.mix(a.overrides,w),g==i&&v=="load"&&YUI.Env.windowLoaded&&(h=!0),s&&n.pop(),f=n[3],p=a._on(m,f,n.length>4?n.slice(4):null),h&&a.fire(),p):!1},detach:function(n,r,i,s){var o=e.Array(arguments,0,!0),u,a,f,h,p,m;o[o.length-1]===l&&(u=!0);if(n&&n.detach)return n.detach();typeof i=="string"&&(u?i=t.byId(i):(i=e.Selector.query(i),a=i.length,a<1?i=null:a==1&&(i=i[0])));if(!i)return!1;if(i.detach)return o.splice(2,1),i.detach.apply(i,o);if(c(i)){f=!0;for(h=0,a=i.length;h<a;++h)o[2]=i[h],f=e.Event.detach.apply(e.Event,o)&&f;return f}return!n||!r||!r.call?d.purgeElement(i,!1,n):(p="event:"+e.stamp(i)+n,m=v[p],m?m.detach(r):!1)},getEvent:function(t,n,r){var s=t||i.event;return r?s:new e.DOMEventFacade(s,n,v["event:"+e.stamp(n)+t.type])},generateId:function(e){return t.generateID(e)},_isValidCollection:c,_load:function(t){r||(r=!0,e.fire&&e.fire(f),d._poll())},_poll:function(){if(d.locked)return;if(e.UA.ie&&!YUI.Env.DOMReady){d.startInterval();return}d.locked=!0;var n,i,s,o,a,f,l=!r;l||(l=u>0),a=[],f=function(t,n){var r,i=n.override;try{n.compat?(n.override?i===!0?r=n.obj:r=i:r=t,n.fn.call(r,n.obj)):(r=n.obj||e.one(t),n.fn.apply(r,e.Lang.isArray(i)?i:[]))}catch(s){}};for(n=0,i=h.length;n<i;++n)s=h[n],s&&!s.checkReady&&(o=s.compat?t.byId(s.id):e.Selector.query(s.id,null,!0),o?(f(o,s),h[n]=null):a.push(s));for(n=0,i=h.length;n<i;++n){s=h[n];if(s&&s.checkReady){o=s.compat?t.byId(s.id):e.Selector.query(s.id,null,!0);if(o){if(r||o.get&&o.get("nextSibling")||o.nextSibling)f(o,s),h[n]=null}else a.push(s)}}u=a.length===0?0:u-1,l?d.startInterval():(clearInterval(d._interval),d._interval=null),d.locked=!1;return},purgeElement:function(t,n,r){var i=e.Lang.isString(t)?e.Selector.query(t,null,!0):t,s=d.getListeners(i,r),o,u,a,f;if(n&&i){s=s||[],a=e.Selector.query("*",i),u=a.length;for(o=0;o<u;++o)f=d.getListeners(a[o],r),f&&(s=s.concat(f))}if(s)for(o=0,u=s.length;o<u;++o)s[o].detachAll()},_clean:function(t){var n=t.key,r=t.domkey;o(t.el,t.type,t.fn,t.capture),delete v[n],delete e._yuievt.events[n],g[r]&&(delete g[r][n],e.Object.size(g[r])||delete g[r])},getListeners:function(t,r){var i=e.stamp(t,!0),s=g[i],o=[],u=r?"event:"+i+r:null,a=n.plugins;return s?(u?(a[r]&&a[r].eventDef&&(u+="_synth"),s[u]&&o.push(s[u]),u+="native",s[u]&&o.push(s[u])):e.each(s,function(e,t){o.push(e)}),o.length?o:null):null},_unload:function(t){e.each(v,function(e,n){e.type=="unload"&&e.fire(t),e.detachAll()}),o(i,"unload",a)},nativeAdd:s,nativeRemove:o}}();e.Event=d,r.injected||YUI.Env.windowLoaded?u():s(i,"load",u),e.UA.ie&&e.on(f,d._poll);try{s(i,"unload",a)}catch(v){}d.Custom=e.CustomEvent,d.Subscriber=e.Subscriber,d.Target=e.EventTarget,d.Handle=e.EventHandle,d.Facade=e.EventFacade,d._poll()}(),e.Env.evt.plugins.available={on:function(t,n,r,i){var s=arguments.length>4?e.Array(arguments,4,!0):null;return e.Event.onAvailable.call(e.Event,r,n,i,s)}},e.Env.evt.plugins.contentready={on:function(t,n,r,i){var s=arguments.length>4?e.Array(arguments,4,!0):null;return e.Event.onContentReady.call(e.Event,r,n,i,s)}}},"3.7.3",{requires:["event-custom-base"]});