/*
	Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/

//>>built
define("dojo/_base/connect","./kernel ../on ../topic ../aspect ./event ../mouse ./sniff ./lang ../keys".split(" "),function(q,m,r,x,B,u,k,n){function y(a,c,d,e,f){e=n.hitch(d,e);if(!a||!a.addEventListener&&!a.attachEvent)return x.after(a||q.global,c,e,!0);"string"==typeof c&&"on"==c.substring(0,2)&&(c=c.substring(2));a||(a=q.global);if(!f)switch(c){case "keypress":c=v;break;case "mouseenter":c=u.enter;break;case "mouseleave":c=u.leave}return m(a,c,e,f)}function w(a){a.keyChar=a.charCode?String.fromCharCode(a.charCode):
"";a.charOrCode=a.keyChar||a.keyCode}k.add("events-keypress-typed",function(){var a={charCode:0};try{a=document.createEvent("KeyboardEvent"),(a.initKeyboardEvent||a.initKeyEvent).call(a,"keypress",!0,!0,null,!1,!1,!1,!1,9,3)}catch(c){}return 0==a.charCode&&!k("opera")});var z={106:42,111:47,186:59,187:43,188:44,189:45,190:46,191:47,192:96,219:91,220:92,221:93,222:39,229:113},A=k("mac")?"metaKey":"ctrlKey",t=function(a,c){var d=n.mixin({},a,c);w(d);d.preventDefault=function(){a.preventDefault()};d.stopPropagation=
function(){a.stopPropagation()};return d};var v=k("events-keypress-typed")?function(a,c){var d=m(a,"keydown",function(f){var b=f.keyCode,g=13!=b&&32!=b&&(27!=b||!k("ie"))&&(48>b||90<b)&&(96>b||111<b)&&(186>b||192<b)&&(219>b||222<b)&&229!=b;if(g||f.ctrlKey){g=g?0:b;if(f.ctrlKey){if(3==b||13==b)return c.call(f.currentTarget,f);g=95<g&&106>g?g-48:!f.shiftKey&&65<=g&&90>=g?g+32:z[g]||g}b=t(f,{type:"keypress",faux:!0,charCode:g});c.call(f.currentTarget,b);if(k("ie"))try{f.keyCode=b.keyCode}catch(h){}}}),
e=m(a,"keypress",function(f){var b=f.charCode;f=t(f,{charCode:32<=b?b:0,faux:!0});return c.call(this,f)});return{remove:function(){d.remove();e.remove()}}}:k("opera")?function(a,c){return m(a,"keypress",function(d){var e=d.which;3==e&&(e=99);e=32>e&&!d.shiftKey?0:e;d.ctrlKey&&!d.shiftKey&&65<=e&&90>=e&&(e+=32);return c.call(this,t(d,{charCode:e}))})}:function(a,c){return m(a,"keypress",function(d){w(d);return c.call(this,d)})};var l={_keypress:v,connect:function(a,c,d,e,f){var b=arguments,g=[],h=
0;g.push("string"==typeof b[0]?null:b[h++],b[h++]);var p=b[h+1];g.push("string"==typeof p||"function"==typeof p?b[h++]:null,b[h++]);for(p=b.length;h<p;h++)g.push(b[h]);return y.apply(this,g)},disconnect:function(a){a&&a.remove()},subscribe:function(a,c,d){return r.subscribe(a,n.hitch(c,d))},publish:function(a,c){return r.publish.apply(r,[a].concat(c))},connectPublisher:function(a,c,d){var e=function(){l.publish(a,arguments)};return d?l.connect(c,d,e):l.connect(c,e)},isCopyKey:function(a){return a[A]}};
l.unsubscribe=l.disconnect;n.mixin(q,l);return l});