root / trunk / web / dojo / dojox / io / windowName.js @ 10
History | View | Annotate | Download (3.27 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.io.windowName"]){ |
||
9 | dojo._hasResource["dojox.io.windowName"]=true; |
||
10 | dojo.provide("dojox.io.windowName");
|
||
11 | dojox.io.windowName={send:function(_1,_2){ |
||
12 | _2.url+=(_2.url.match(/\?/)?"&":"?")+"windowname="+(_2.authElement?"auth":true); |
||
13 | var _3=_2.authElement;
|
||
14 | var _4=function(_5){ |
||
15 | try{
|
||
16 | var _6=_7.ioArgs.frame.contentWindow.document;
|
||
17 | _6.write(" ");
|
||
18 | _6.close(); |
||
19 | } |
||
20 | catch(e){
|
||
21 | } |
||
22 | (_3||dojo.body()).removeChild(_7.ioArgs.outerFrame); |
||
23 | return _5;
|
||
24 | }; |
||
25 | var _7=dojo._ioSetArgs(_2,_4,_4,_4);
|
||
26 | if(_2.timeout){
|
||
27 | setTimeout(function(){
|
||
28 | if(_7.fired==-1){ |
||
29 | _7.callback(new Error("Timeout")); |
||
30 | } |
||
31 | },_2.timeout); |
||
32 | } |
||
33 | var _8=dojox.io.windowName;
|
||
34 | if(dojo.body()){
|
||
35 | _8._send(_7,_1,_3,_2.onAuthLoad); |
||
36 | }else{
|
||
37 | dojo.addOnLoad(function(){
|
||
38 | _8._send(_7,_1,_3,_2.onAuthLoad); |
||
39 | }); |
||
40 | } |
||
41 | return _7;
|
||
42 | },_send:function(_9,_a,_b,_c){ |
||
43 | var _d=_9.ioArgs;
|
||
44 | var _e=dojox.io.windowName._frameNum++;
|
||
45 | var _f=(dojo.config.dojoBlankHtmlUrl||dojo.config.dojoCallbackUrl||dojo.moduleUrl("dojo","resources/blank.html"))+"#"+_e; |
||
46 | var _10=new dojo._Url(window.location,_f); |
||
47 | var doc=dojo.doc;
|
||
48 | var _11=_b||dojo.body();
|
||
49 | function _12(_13){ |
||
50 | _13.style.width="100%";
|
||
51 | _13.style.height="100%";
|
||
52 | _13.style.border="0px";
|
||
53 | }; |
||
54 | if(dojo.isMoz&&![].reduce){
|
||
55 | var _14=doc.createElement("iframe"); |
||
56 | _12(_14); |
||
57 | if(!_b){
|
||
58 | _14.style.display="none";
|
||
59 | } |
||
60 | _11.appendChild(_14); |
||
61 | var _15=_14.contentWindow;
|
||
62 | doc=_15.document; |
||
63 | doc.write("<html><body margin='0px'><iframe style='width:100%;height:100%;border:0px' name='protectedFrame'></iframe></body></html>");
|
||
64 | doc.close(); |
||
65 | var _16=_15[0]; |
||
66 | _15.__defineGetter__(0,function(){ |
||
67 | }); |
||
68 | _15.__defineGetter__("protectedFrame",function(){ |
||
69 | }); |
||
70 | doc=_16.document; |
||
71 | doc.write("<html><body margin='0px'></body></html>");
|
||
72 | doc.close(); |
||
73 | _11=doc.body; |
||
74 | } |
||
75 | var _17=_d.frame=_17=doc.createElement(dojo.isIE?"<iframe name=\""+_10+"\" onload=\"dojox.io.windowName["+_e+"]()\">":"iframe"); |
||
76 | _12(_17); |
||
77 | _d.outerFrame=_14=_14||_17; |
||
78 | if(!_b){
|
||
79 | _14.style.display="none";
|
||
80 | } |
||
81 | var _18=0; |
||
82 | function _19(){ |
||
83 | var _1a=_17.contentWindow.name;
|
||
84 | if(typeof _1a=="string"){ |
||
85 | if(_1a!=_10){
|
||
86 | _18=2;
|
||
87 | _9.ioArgs.hash=_17.contentWindow.location.hash; |
||
88 | _9.callback(_1a); |
||
89 | } |
||
90 | } |
||
91 | }; |
||
92 | dojox.io.windowName[_e]=_17.onload=function(){ |
||
93 | try{
|
||
94 | if(!dojo.isMoz&&_17.contentWindow.location=="about:blank"){ |
||
95 | return;
|
||
96 | } |
||
97 | } |
||
98 | catch(e){
|
||
99 | } |
||
100 | if(!_18){
|
||
101 | _18=1;
|
||
102 | if(_b){
|
||
103 | if(_c){
|
||
104 | _c(); |
||
105 | } |
||
106 | }else{
|
||
107 | _17.contentWindow.location=_f; |
||
108 | } |
||
109 | } |
||
110 | try{
|
||
111 | if(_18<2){ |
||
112 | _19(); |
||
113 | } |
||
114 | } |
||
115 | catch(e){
|
||
116 | } |
||
117 | }; |
||
118 | _17.name=_10; |
||
119 | if(_a.match(/GET/i)){ |
||
120 | dojo._ioAddQueryToUrl(_d); |
||
121 | _17.src=_d.url; |
||
122 | _11.appendChild(_17); |
||
123 | if(_17.contentWindow){
|
||
124 | _17.contentWindow.location.replace(_d.url); |
||
125 | } |
||
126 | }else{
|
||
127 | if(_a.match(/POST/i)){ |
||
128 | _11.appendChild(_17); |
||
129 | var _1b=dojo.doc.createElement("form"); |
||
130 | dojo.body().appendChild(_1b); |
||
131 | var _1c=dojo.queryToObject(_d.query);
|
||
132 | for(var i in _1c){ |
||
133 | var _1d=_1c[i];
|
||
134 | _1d=_1d instanceof Array?_1d:[_1d];
|
||
135 | for(var j=0;j<_1d.length;j++){ |
||
136 | var _1e=doc.createElement("input"); |
||
137 | _1e.type="hidden";
|
||
138 | _1e.name=i; |
||
139 | _1e.value=_1d[j]; |
||
140 | _1b.appendChild(_1e); |
||
141 | } |
||
142 | } |
||
143 | _1b.method="POST";
|
||
144 | _1b.action=_d.url; |
||
145 | _1b.target=_10; |
||
146 | _1b.submit(); |
||
147 | _1b.parentNode.removeChild(_1b); |
||
148 | }else{
|
||
149 | throw new Error("Method "+_a+" not supported with the windowName transport"); |
||
150 | } |
||
151 | } |
||
152 | if(_17.contentWindow){
|
||
153 | _17.contentWindow.name=_10; |
||
154 | } |
||
155 | },_frameNum:0}; |
||
156 | } |