windowName.js
2.63 KB
//>>built
define("dojo/_base/kernel dojo/_base/window dojo/_base/xhr dojo/_base/sniff dojo/_base/url dojo/domReady!".split(" "),function(c){c.getObject("io.windowName",!0,dojox);dojox.io.windowName={send:function(p,a){a.url+=(a.url.match(/\?/)?"\x26":"?")+"windowname\x3d"+(a.authElement?"auth":!0);var k=a.authElement,n=function(a){try{var h=g.ioArgs.frame.contentWindow.document;h.write(" ");h.close()}catch(t){}(k||c.body()).removeChild(g.ioArgs.outerFrame);return a},g=c._ioSetArgs(a,n,n,n);a.timeout&&setTimeout(function(){-1==
g.fired&&g.callback(Error("Timeout"))},a.timeout);dojox.io.windowName._send(g,p,k,a.onAuthLoad);return g},_send:function(p,a,k,n){function g(a){a.style.width="100%";a.style.height="100%";a.style.border="0px"}var l=p.ioArgs,h=dojox.io.windowName._frameNum++,t=(c.config.dojoBlankHtmlUrl||c.config.dojoCallbackUrl||c.moduleUrl("dojo","resources/blank.html"))+"#"+h,q=new c._Url(window.location,t),e=c.doc,f=k||c.body();if(c.isMoz&&![].reduce){var d=e.createElement("iframe");g(d);k||(d.style.display="none");
f.appendChild(d);f=d.contentWindow;e=f.document;e.write("\x3chtml\x3e\x3cbody margin\x3d'0px'\x3e\x3ciframe style\x3d'width:100%;height:100%;border:0px' name\x3d'protectedFrame'\x3e\x3c/iframe\x3e\x3c/body\x3e\x3c/html\x3e");e.close();e=f[0];f.__defineGetter__(0,function(){});f.__defineGetter__("protectedFrame",function(){});e=e.document;e.write("\x3chtml\x3e\x3cbody margin\x3d'0px'\x3e\x3c/body\x3e\x3c/html\x3e");e.close();f=e.body}var b;if(c.isIE){var m=e.createElement("div");m.innerHTML='\x3ciframe name\x3d"'+
q+'" onload\x3d"dojox.io.windowName['+h+']()"\x3e';b=m.firstChild}else b=e.createElement("iframe");l.frame=b;g(b);l.outerFrame=d=d||b;k||(d.style.display="none");var r=0;dojox.io.windowName[h]=b.onload=function(){try{if(!c.isMoz&&"about:blank"==b.contentWindow.location)return}catch(v){}r||(r=1,k?n&&n():b.contentWindow.location=t);try{if(2>r){var a=b.contentWindow.name;"string"==typeof a&&a!=q&&(r=2,p.ioArgs.hash=b.contentWindow.location.hash,p.callback(a))}}catch(v){}};b.name=q;if(a.match(/GET/i))c._ioAddQueryToUrl(l),
b.src=l.url,f.appendChild(b),b.contentWindow&&b.contentWindow.location.replace(l.url);else if(a.match(/POST/i)){f.appendChild(b);a=c.doc.createElement("form");c.body().appendChild(a);var h=c.queryToObject(l.query),u;for(u in h)for(d=h[u],d=d instanceof Array?d:[d],f=0;f<d.length;f++)m=e.createElement("input"),m.type="hidden",m.name=u,m.value=d[f],a.appendChild(m);a.method="POST";a.action=l.url;a.target=q;a.submit();a.parentNode.removeChild(a)}else throw Error("Method "+a+" not supported with the windowName transport");
b.contentWindow&&(b.contentWindow.name=q)},_frameNum:0};return dojox.io.windowName});