summaryrefslogtreecommitdiff
path: root/lib/dojo/io
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-03-18 10:26:24 +0400
committerAndrew Dolgov <[email protected]>2013-03-18 10:26:26 +0400
commitf0cfe83e3725f9a3928da97a6e3085e79cb25309 (patch)
tree4b0af188defaa807c7bc6ff3a101b41c9166c463 /lib/dojo/io
parent9a2885da170ffd64358b99194095851a2d09c1b6 (diff)
upgrade dojo to 1.8.3 (refs #570)
Diffstat (limited to 'lib/dojo/io')
-rw-r--r--lib/dojo/io/iframe.js4
-rw-r--r--lib/dojo/io/iframe.js.uncompressed.js190
-rw-r--r--lib/dojo/io/script.js4
-rw-r--r--lib/dojo/io/script.js.uncompressed.js249
4 files changed, 443 insertions, 4 deletions
diff --git a/lib/dojo/io/iframe.js b/lib/dojo/io/iframe.js
index 9db3fbcfc..66ec8da2d 100644
--- a/lib/dojo/io/iframe.js
+++ b/lib/dojo/io/iframe.js
@@ -1,8 +1,8 @@
/*
- Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Copyright (c) 2004-2012, The Dojo 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/io/iframe",["../main","require"],function(_1,_2){_1.getObject("io",true,_1);_1.io.iframe={create:function(_3,_4,_5){if(window[_3]){return window[_3];}if(window.frames[_3]){return window.frames[_3];}var _6=_5;if(!_6){if(_1.config["useXDomain"]&&!_1.config["dojoBlankHtmlUrl"]){console.warn("dojo.io.iframe.create: When using cross-domain Dojo builds,"+" please save dojo/resources/blank.html to your domain and set djConfig.dojoBlankHtmlUrl"+" to the path on your domain to blank.html");}_6=(_1.config["dojoBlankHtmlUrl"]||_2.toUrl("../resources/blank.html"));}var _7=_1.place("<iframe id=\""+_3+"\" name=\""+_3+"\" src=\""+_6+"\" onload=\""+_4+"\" style=\"position: absolute; left: 1px; top: 1px; height: 1px; width: 1px; visibility: hidden\">",_1.body());window[_3]=_7;return _7;},setSrc:function(_8,_9,_a){try{if(!_a){if(_1.isWebKit){_8.location=_9;}else{frames[_8.name].location=_9;}}else{var _b;if(_1.isIE||_1.isWebKit){_b=_8.contentWindow.document;}else{_b=_8.contentWindow;}if(!_b){_8.location=_9;}else{_b.location.replace(_9);}}}catch(e){}},doc:function(_c){return _c.contentDocument||(((_c.name)&&(_c.document)&&(_1.doc.getElementsByTagName("iframe")[_c.name].contentWindow)&&(_1.doc.getElementsByTagName("iframe")[_c.name].contentWindow.document)))||((_c.name)&&(_1.doc.frames[_c.name])&&(_1.doc.frames[_c.name].document))||null;},send:function(_d){if(!this["_frame"]){this._frame=this.create(this._iframeName,_1._scopeName+".io.iframe._iframeOnload();");}var _e=_1._ioSetArgs(_d,function(_f){_f.canceled=true;_f.ioArgs._callNext();},function(dfd){var _10=null;try{var _11=dfd.ioArgs;var dii=_1.io.iframe;var ifd=dii.doc(dii._frame);var _12=_11.handleAs;_10=ifd;if(_12!="html"){if(_12=="xml"){if(_1.isIE<9||(_1.isIE&&_1.isQuirks)){_1.query("a",dii._frame.contentWindow.document.documentElement).orphan();var _13=(dii._frame.contentWindow.document).documentElement.innerText;_13=_13.replace(/>\s+</g,"><");_13=_1.trim(_13);var _14={responseText:_13};_10=_1._contentHandlers["xml"](_14);}}else{_10=ifd.getElementsByTagName("textarea")[0].value;if(_12=="json"){_10=_1.fromJson(_10);}else{if(_12=="javascript"){_10=_1.eval(_10);}}}}}catch(e){_10=e;}finally{_11._callNext();}return _10;},function(_15,dfd){dfd.ioArgs._hasError=true;dfd.ioArgs._callNext();return _15;});_e.ioArgs._callNext=function(){if(!this["_calledNext"]){this._calledNext=true;_1.io.iframe._currentDfd=null;_1.io.iframe._fireNextRequest();}};this._dfdQueue.push(_e);this._fireNextRequest();_1._ioWatch(_e,function(dfd){return !dfd.ioArgs["_hasError"];},function(dfd){return (!!dfd.ioArgs["_finished"]);},function(dfd){if(dfd.ioArgs._finished){dfd.callback(dfd);}else{dfd.errback(new Error("Invalid dojo.io.iframe request state"));}});return _e;},_currentDfd:null,_dfdQueue:[],_iframeName:_1._scopeName+"IoIframe",_fireNextRequest:function(){try{if((this._currentDfd)||(this._dfdQueue.length==0)){return;}do{var dfd=this._currentDfd=this._dfdQueue.shift();}while(dfd&&dfd.canceled&&this._dfdQueue.length);if(!dfd||dfd.canceled){this._currentDfd=null;return;}var _16=dfd.ioArgs;var _17=_16.args;_16._contentToClean=[];var fn=_1.byId(_17["form"]);var _18=_17["content"]||{};if(fn){if(_18){var _19=function(_1a,_1b){_1.create("input",{type:"hidden",name:_1a,value:_1b},fn);_16._contentToClean.push(_1a);};for(var x in _18){var val=_18[x];if(_1.isArray(val)&&val.length>1){var i;for(i=0;i<val.length;i++){_19(x,val[i]);}}else{if(!fn[x]){_19(x,val);}else{fn[x].value=val;}}}}var _1c=fn.getAttributeNode("action");var _1d=fn.getAttributeNode("method");var _1e=fn.getAttributeNode("target");if(_17["url"]){_16._originalAction=_1c?_1c.value:null;if(_1c){_1c.value=_17.url;}else{fn.setAttribute("action",_17.url);}}if(!_1d||!_1d.value){if(_1d){_1d.value=(_17["method"])?_17["method"]:"post";}else{fn.setAttribute("method",(_17["method"])?_17["method"]:"post");}}_16._originalTarget=_1e?_1e.value:null;if(_1e){_1e.value=this._iframeName;}else{fn.setAttribute("target",this._iframeName);}fn.target=this._iframeName;_1._ioNotifyStart(dfd);fn.submit();}else{var _1f=_17.url+(_17.url.indexOf("?")>-1?"&":"?")+_16.query;_1._ioNotifyStart(dfd);this.setSrc(this._frame,_1f,true);}}catch(e){dfd.errback(e);}},_iframeOnload:function(){var dfd=this._currentDfd;if(!dfd){this._fireNextRequest();return;}var _20=dfd.ioArgs;var _21=_20.args;var _22=_1.byId(_21.form);if(_22){var _23=_20._contentToClean;for(var i=0;i<_23.length;i++){var key=_23[i];for(var j=0;j<_22.childNodes.length;j++){var _24=_22.childNodes[j];if(_24.name==key){_1.destroy(_24);break;}}}if(_20["_originalAction"]){_22.setAttribute("action",_20._originalAction);}if(_20["_originalTarget"]){_22.setAttribute("target",_20._originalTarget);_22.target=_20._originalTarget;}}_20._finished=true;}};return _1.io.iframe;}); \ No newline at end of file
+define("dojo/io/iframe",["../_base/config","../_base/json","../_base/kernel","../_base/lang","../_base/xhr","../sniff","../_base/window","../dom","../dom-construct","../query","require","../aspect","../request/iframe"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d){_3.deprecated("dojo/io/iframe","Use dojo/request/iframe.","2.0");var _e=_d._iframeName;_e=_e.substring(0,_e.lastIndexOf("_"));var _f=_4.delegate(_d,{create:function(){return _f._frame=_d.create.apply(_d,arguments);},get:null,post:null,send:function(_10){var _11;var dfd=_5._ioSetArgs(_10,function(dfd){_11&&_11.cancel();},function(dfd){var _12=null,_13=dfd.ioArgs;try{var _14=_13.handleAs;if(_14==="xml"||_14==="html"){_12=_11.response.data;}else{_12=_11.response.text;if(_14==="json"){_12=_2.fromJson(_12);}else{if(_14==="javascript"){_12=_3.eval(_12);}}}}catch(e){_12=e;}return _12;},function(_15,dfd){dfd.ioArgs._hasError=true;return _15;});var _16=dfd.ioArgs;var _17="GET",_18=_8.byId(_10.form);if(_10.method&&_10.method.toUpperCase()==="POST"&&_18){_17="POST";}var _19={method:_17,handleAs:_10.handleAs==="json"||_10.handleAs==="javascript"?"text":_10.handleAs,form:_10.form,query:_18?null:_10.content,data:_18?_10.content:null,timeout:_10.timeout,ioArgs:_16};if(_19.method){_19.method=_19.method.toUpperCase();}if(_1.ioPublish&&_3.publish&&_16.args.ioPublish!==false){var _1a=_c.after(_d,"_notifyStart",function(_1b){if(_1b.options.ioArgs===_16){_1a.remove();_5._ioNotifyStart(dfd);}},true);}_11=_d(_16.url,_19,true);_16._callNext=_11._callNext;_11.then(function(){dfd.resolve(dfd);}).otherwise(function(_1c){dfd.ioArgs.error=_1c;dfd.reject(_1c);});return dfd;},_iframeOnload:_7.global[_e+"_onload"]});_4.setObject("dojo.io.iframe",_f);return _f;}); \ No newline at end of file
diff --git a/lib/dojo/io/iframe.js.uncompressed.js b/lib/dojo/io/iframe.js.uncompressed.js
new file mode 100644
index 000000000..3ce93e0b2
--- /dev/null
+++ b/lib/dojo/io/iframe.js.uncompressed.js
@@ -0,0 +1,190 @@
+define("dojo/io/iframe", [
+ "../_base/config", "../_base/json", "../_base/kernel", /*===== "../_base/declare", =====*/ "../_base/lang",
+ "../_base/xhr", "../sniff", "../_base/window",
+ "../dom", "../dom-construct", "../query", "require", "../aspect", "../request/iframe"
+], function(config, json, kernel, /*===== declare, =====*/ lang, xhr, has, win, dom, domConstruct, query, require, aspect, _iframe){
+
+// module:
+// dojo/io/iframe
+
+kernel.deprecated("dojo/io/iframe", "Use dojo/request/iframe.", "2.0");
+
+/*=====
+var __ioArgs = declare(kernel.__IoArgs, {
+ // method: String?
+ // The HTTP method to use. "GET" or "POST" are the only supported
+ // values. It will try to read the value from the form node's
+ // method, then try this argument. If neither one exists, then it
+ // defaults to POST.
+ // handleAs: String?
+ // Specifies what format the result data should be given to the
+ // load/handle callback. Valid values are: text, html, xml, json,
+ // javascript. IMPORTANT: For all values EXCEPT html and xml, The
+ // server response should be an HTML file with a textarea element.
+ // The response data should be inside the textarea element. Using an
+ // HTML document the only reliable, cross-browser way this
+ // transport can know when the response has loaded. For the html
+ // handleAs value, just return a normal HTML document. NOTE: xml
+ // is now supported with this transport (as of 1.1+); a known issue
+ // is if the XML document in question is malformed, Internet Explorer
+ // will throw an uncatchable error.
+ // content: Object?
+ // If "form" is one of the other args properties, then the content
+ // object properties become hidden form form elements. For
+ // instance, a content object of {name1 : "value1"} is converted
+ // to a hidden form element with a name of "name1" and a value of
+ // "value1". If there is not a "form" property, then the content
+ // object is converted into a name=value&name=value string, by
+ // using xhr.objectToQuery().
+});
+=====*/
+
+/*=====
+return kernel.io.iframe = {
+ // summary:
+ // Deprecated, use dojo/request/iframe instead.
+ // Sends an Ajax I/O call using and Iframe (for instance, to upload files)
+
+ create: function(fname, onloadstr, uri){
+ // summary:
+ // Creates a hidden iframe in the page. Used mostly for IO
+ // transports. You do not need to call this to start a
+ // dojo/io/iframe request. Just call send().
+ // fname: String
+ // The name of the iframe. Used for the name attribute on the
+ // iframe.
+ // onloadstr: String
+ // A string of JavaScript that will be executed when the content
+ // in the iframe loads.
+ // uri: String
+ // The value of the src attribute on the iframe element. If a
+ // value is not given, then dojo/resources/blank.html will be
+ // used.
+ },
+ setSrc: function(iframe, src, replace){
+ // summary:
+ // Sets the URL that is loaded in an IFrame. The replace parameter
+ // indicates whether location.replace() should be used when
+ // changing the location of the iframe.
+ },
+ doc: function(iframeNode){
+ // summary:
+ // Returns the document object associated with the iframe DOM Node argument.
+ }
+};
+=====*/
+
+
+var mid = _iframe._iframeName;
+mid = mid.substring(0, mid.lastIndexOf('_'));
+
+var iframe = lang.delegate(_iframe, {
+ // summary:
+ // Deprecated, use dojo/request/iframe instead.
+ // Sends an Ajax I/O call using and Iframe (for instance, to upload files)
+
+ create: function(){
+ return iframe._frame = _iframe.create.apply(_iframe, arguments);
+ },
+
+ // cover up delegated methods
+ get: null,
+ post: null,
+
+ send: function(/*__ioArgs*/args){
+ // summary:
+ // Function that sends the request to the server.
+ // This transport can only process one send() request at a time, so if send() is called
+ // multiple times, it will queue up the calls and only process one at a time.
+ var rDfd;
+
+ //Set up the deferred.
+ var dfd = xhr._ioSetArgs(args,
+ function(/*Deferred*/dfd){
+ // summary:
+ // canceller function for xhr._ioSetArgs call.
+ rDfd && rDfd.cancel();
+ },
+ function(/*Deferred*/dfd){
+ // summary:
+ // okHandler function for xhr._ioSetArgs call.
+ var value = null,
+ ioArgs = dfd.ioArgs;
+ try{
+ var handleAs = ioArgs.handleAs;
+
+ //Assign correct value based on handleAs value.
+ if(handleAs === "xml" || handleAs === "html"){
+ value = rDfd.response.data;
+ }else{
+ value = rDfd.response.text;
+ if(handleAs === "json"){
+ value = json.fromJson(value);
+ }else if(handleAs === "javascript"){
+ value = kernel.eval(value);
+ }
+ }
+ }catch(e){
+ value = e;
+ }
+ return value;
+ },
+ function(/*Error*/error, /*Deferred*/dfd){
+ // summary:
+ // errHandler function for xhr._ioSetArgs call.
+ dfd.ioArgs._hasError = true;
+ return error;
+ }
+ );
+
+ var ioArgs = dfd.ioArgs;
+
+ var method = "GET",
+ form = dom.byId(args.form);
+ if(args.method && args.method.toUpperCase() === "POST" && form){
+ method = "POST";
+ }
+
+ var options = {
+ method: method,
+ handleAs: args.handleAs === "json" || args.handleAs === "javascript" ? "text" : args.handleAs,
+ form: args.form,
+ query: form ? null : args.content,
+ data: form ? args.content : null,
+ timeout: args.timeout,
+ ioArgs: ioArgs
+ };
+
+ if(options.method){
+ options.method = options.method.toUpperCase();
+ }
+
+ if(config.ioPublish && kernel.publish && ioArgs.args.ioPublish !== false){
+ var start = aspect.after(_iframe, "_notifyStart", function(data){
+ if(data.options.ioArgs === ioArgs){
+ start.remove();
+ xhr._ioNotifyStart(dfd);
+ }
+ }, true);
+ }
+ rDfd = _iframe(ioArgs.url, options, true);
+
+ ioArgs._callNext = rDfd._callNext;
+
+ rDfd.then(function(){
+ dfd.resolve(dfd);
+ }).otherwise(function(error){
+ dfd.ioArgs.error = error;
+ dfd.reject(error);
+ });
+
+ return dfd;
+ },
+
+ _iframeOnload: win.global[mid + '_onload']
+});
+
+lang.setObject("dojo.io.iframe", iframe);
+
+return iframe;
+});
diff --git a/lib/dojo/io/script.js b/lib/dojo/io/script.js
index 03459fae1..130a5391f 100644
--- a/lib/dojo/io/script.js
+++ b/lib/dojo/io/script.js
@@ -1,8 +1,8 @@
/*
- Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Copyright (c) 2004-2012, The Dojo 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/io/script",["../main"],function(_1){_1.getObject("io",true,_1);var _2=_1.isIE?"onreadystatechange":"load",_3=/complete|loaded/;_1.io.script={get:function(_4){var _5=this._makeScriptDeferred(_4);var _6=_5.ioArgs;_1._ioAddQueryToUrl(_6);_1._ioNotifyStart(_5);if(this._canAttach(_6)){var _7=this.attach(_6.id,_6.url,_4.frameDoc);if(!_6.jsonp&&!_6.args.checkString){var _8=_1.connect(_7,_2,function(_9){if(_9.type=="load"||_3.test(_7.readyState)){_1.disconnect(_8);_6.scriptLoaded=_9;}});}}_1._ioWatch(_5,this._validCheck,this._ioCheck,this._resHandle);return _5;},attach:function(id,_a,_b){var _c=(_b||_1.doc);var _d=_c.createElement("script");_d.type="text/javascript";_d.src=_a;_d.id=id;_d.async=true;_d.charset="utf-8";return _c.getElementsByTagName("head")[0].appendChild(_d);},remove:function(id,_e){_1.destroy(_1.byId(id,_e));if(this["jsonp_"+id]){delete this["jsonp_"+id];}},_makeScriptDeferred:function(_f){var dfd=_1._ioSetArgs(_f,this._deferredCancel,this._deferredOk,this._deferredError);var _10=dfd.ioArgs;_10.id=_1._scopeName+"IoScript"+(this._counter++);_10.canDelete=false;_10.jsonp=_f.callbackParamName||_f.jsonp;if(_10.jsonp){_10.query=_10.query||"";if(_10.query.length>0){_10.query+="&";}_10.query+=_10.jsonp+"="+(_f.frameDoc?"parent.":"")+_1._scopeName+".io.script.jsonp_"+_10.id+"._jsonpCallback";_10.frameDoc=_f.frameDoc;_10.canDelete=true;dfd._jsonpCallback=this._jsonpCallback;this["jsonp_"+_10.id]=dfd;}return dfd;},_deferredCancel:function(dfd){dfd.canceled=true;if(dfd.ioArgs.canDelete){_1.io.script._addDeadScript(dfd.ioArgs);}},_deferredOk:function(dfd){var _11=dfd.ioArgs;if(_11.canDelete){_1.io.script._addDeadScript(_11);}return _11.json||_11.scriptLoaded||_11;},_deferredError:function(_12,dfd){if(dfd.ioArgs.canDelete){if(_12.dojoType=="timeout"){_1.io.script.remove(dfd.ioArgs.id,dfd.ioArgs.frameDoc);}else{_1.io.script._addDeadScript(dfd.ioArgs);}}return _12;},_deadScripts:[],_counter:1,_addDeadScript:function(_13){_1.io.script._deadScripts.push({id:_13.id,frameDoc:_13.frameDoc});_13.frameDoc=null;},_validCheck:function(dfd){var _14=_1.io.script;var _15=_14._deadScripts;if(_15&&_15.length>0){for(var i=0;i<_15.length;i++){_14.remove(_15[i].id,_15[i].frameDoc);_15[i].frameDoc=null;}_1.io.script._deadScripts=[];}return true;},_ioCheck:function(dfd){var _16=dfd.ioArgs;if(_16.json||(_16.scriptLoaded&&!_16.args.checkString)){return true;}var _17=_16.args.checkString;return _17&&eval("typeof("+_17+") != 'undefined'");},_resHandle:function(dfd){if(_1.io.script._ioCheck(dfd)){dfd.callback(dfd);}else{dfd.errback(new Error("inconceivable dojo.io.script._resHandle error"));}},_canAttach:function(_18){return true;},_jsonpCallback:function(_19){this.ioArgs.json=_19;}};return _1.io.script;}); \ No newline at end of file
+define("dojo/io/script",["../_base/connect","../_base/kernel","../_base/lang","../sniff","../_base/window","../_base/xhr","../dom","../dom-construct","../request/script"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9){_2.deprecated("dojo/io/script","Use dojo/request/script.","2.0");var _a={get:function(_b){var _c;var _d=this._makeScriptDeferred(_b,function(_e){_c&&_c.cancel();});var _f=_d.ioArgs;_6._ioAddQueryToUrl(_f);_6._ioNotifyStart(_d);_c=_9.get(_f.url,{timeout:_b.timeout,jsonp:_f.jsonp,checkString:_b.checkString,ioArgs:_f,frameDoc:_b.frameDoc,canAttach:function(_10){_f.requestId=_10.id;_f.scriptId=_10.scriptId;_f.canDelete=_10.canDelete;return _a._canAttach(_f);}},true);_c.then(function(){_d.resolve(_d);}).otherwise(function(_11){_d.ioArgs.error=_11;_d.reject(_11);});return _d;},attach:_9._attach,remove:_9._remove,_makeScriptDeferred:function(_12,_13){var dfd=_6._ioSetArgs(_12,_13||this._deferredCancel,this._deferredOk,this._deferredError);var _14=dfd.ioArgs;_14.id=_2._scopeName+"IoScript"+(this._counter++);_14.canDelete=false;_14.jsonp=_12.callbackParamName||_12.jsonp;if(_14.jsonp){_14.query=_14.query||"";if(_14.query.length>0){_14.query+="&";}_14.query+=_14.jsonp+"="+(_12.frameDoc?"parent.":"")+_2._scopeName+".io.script.jsonp_"+_14.id+"._jsonpCallback";_14.frameDoc=_12.frameDoc;_14.canDelete=true;dfd._jsonpCallback=this._jsonpCallback;this["jsonp_"+_14.id]=dfd;}return dfd;},_deferredCancel:function(dfd){dfd.canceled=true;},_deferredOk:function(dfd){var _15=dfd.ioArgs;return _15.json||_15.scriptLoaded||_15;},_deferredError:function(_16,dfd){return _16;},_deadScripts:[],_counter:1,_addDeadScript:function(_17){_a._deadScripts.push({id:_17.id,frameDoc:_17.frameDoc});_17.frameDoc=null;},_validCheck:function(dfd){var _18=_a._deadScripts;if(_18&&_18.length>0){for(var i=0;i<_18.length;i++){_a.remove(_18[i].id,_18[i].frameDoc);_18[i].frameDoc=null;}_a._deadScripts=[];}return true;},_ioCheck:function(dfd){var _19=dfd.ioArgs;if(_19.json||(_19.scriptLoaded&&!_19.args.checkString)){return true;}var _1a=_19.args.checkString;return _1a&&eval("typeof("+_1a+") != 'undefined'");},_resHandle:function(dfd){if(_a._ioCheck(dfd)){dfd.callback(dfd);}else{dfd.errback(new Error("inconceivable dojo.io.script._resHandle error"));}},_canAttach:function(){return true;},_jsonpCallback:function(_1b){this.ioArgs.json=_1b;_2.global[_9._callbacksProperty][this.ioArgs.requestId](_1b);}};_3.setObject("dojo.io.script",_a);return _a;}); \ No newline at end of file
diff --git a/lib/dojo/io/script.js.uncompressed.js b/lib/dojo/io/script.js.uncompressed.js
new file mode 100644
index 000000000..3fea9f208
--- /dev/null
+++ b/lib/dojo/io/script.js.uncompressed.js
@@ -0,0 +1,249 @@
+define("dojo/io/script", [
+ "../_base/connect", /*===== "../_base/declare", =====*/ "../_base/kernel", "../_base/lang",
+ "../sniff", "../_base/window","../_base/xhr",
+ "../dom", "../dom-construct", "../request/script"
+], function(connect, /*===== declare, =====*/ kernel, lang, has, win, xhr, dom, domConstruct, _script){
+
+ // module:
+ // dojo/io/script
+
+ kernel.deprecated("dojo/io/script", "Use dojo/request/script.", "2.0");
+
+ /*=====
+ var __ioArgs = declare(kernel.__IoArgs, {
+ // summary:
+ // All the properties described in the dojo.__ioArgs type, apply to this
+ // type as well, EXCEPT "handleAs". It is not applicable to
+ // dojo/io/script.get() calls, since it is implied by the usage of
+ // "jsonp" (response will be a JSONP call returning JSON)
+ // or the response is pure JavaScript defined in
+ // the body of the script that was attached.
+ // callbackParamName: String
+ // Deprecated as of Dojo 1.4 in favor of "jsonp", but still supported for
+ // legacy code. See notes for jsonp property.
+ // jsonp: String
+ // The URL parameter name that indicates the JSONP callback string.
+ // For instance, when using Yahoo JSONP calls it is normally,
+ // jsonp: "callback". For AOL JSONP calls it is normally
+ // jsonp: "c".
+ // checkString: String
+ // A string of JavaScript that when evaluated like so:
+ // "typeof(" + checkString + ") != 'undefined'"
+ // being true means that the script fetched has been loaded.
+ // Do not use this if doing a JSONP type of call (use callbackParamName instead).
+ // frameDoc: Document
+ // The Document object for a child iframe. If this is passed in, the script
+ // will be attached to that document. This can be helpful in some comet long-polling
+ // scenarios with Firefox and Opera.
+ });
+ =====*/
+
+ var script = {
+ // summary:
+ // TODOC
+
+ get: function(/*__ioArgs*/ args){
+ // summary:
+ // sends a get request using a dynamically created script tag.
+ var rDfd;
+ var dfd = this._makeScriptDeferred(args, function(dfd){
+ rDfd && rDfd.cancel();
+ });
+ var ioArgs = dfd.ioArgs;
+ xhr._ioAddQueryToUrl(ioArgs);
+
+ xhr._ioNotifyStart(dfd);
+
+ rDfd = _script.get(ioArgs.url, {
+ timeout: args.timeout,
+ jsonp: ioArgs.jsonp,
+ checkString: args.checkString,
+ ioArgs: ioArgs,
+ frameDoc: args.frameDoc,
+ canAttach: function(rDfd){
+ // sync values
+ ioArgs.requestId = rDfd.id;
+ ioArgs.scriptId = rDfd.scriptId;
+ ioArgs.canDelete = rDfd.canDelete;
+
+ return script._canAttach(ioArgs);
+ }
+ }, true);
+
+ rDfd.then(function(){
+ dfd.resolve(dfd);
+ }).otherwise(function(error){
+ dfd.ioArgs.error = error;
+ dfd.reject(error);
+ });
+
+ return dfd;
+ },
+
+ attach: _script._attach,
+ remove: _script._remove,
+
+ _makeScriptDeferred: function(/*Object*/ args, /*Function?*/ cancel){
+ // summary:
+ // sets up a Deferred object for an IO request.
+ var dfd = xhr._ioSetArgs(args, cancel || this._deferredCancel, this._deferredOk, this._deferredError);
+
+ var ioArgs = dfd.ioArgs;
+ ioArgs.id = kernel._scopeName + "IoScript" + (this._counter++);
+ ioArgs.canDelete = false;
+
+ //Special setup for jsonp case
+ ioArgs.jsonp = args.callbackParamName || args.jsonp;
+ if(ioArgs.jsonp){
+ //Add the jsonp parameter.
+ ioArgs.query = ioArgs.query || "";
+ if(ioArgs.query.length > 0){
+ ioArgs.query += "&";
+ }
+ ioArgs.query += ioArgs.jsonp +
+ "=" + (args.frameDoc ? "parent." : "") +
+ kernel._scopeName + ".io.script.jsonp_" + ioArgs.id + "._jsonpCallback";
+
+ ioArgs.frameDoc = args.frameDoc;
+
+ //Setup the Deferred to have the jsonp callback.
+ ioArgs.canDelete = true;
+ dfd._jsonpCallback = this._jsonpCallback;
+ this["jsonp_" + ioArgs.id] = dfd;
+ }
+ return dfd; // dojo/_base/Deferred
+ },
+
+ _deferredCancel: function(/*Deferred*/ dfd){
+ // summary:
+ // canceller function for xhr._ioSetArgs call.
+
+ //DO NOT use "this" and expect it to be script.
+ dfd.canceled = true;
+ },
+
+ _deferredOk: function(/*Deferred*/ dfd){
+ // summary:
+ // okHandler function for xhr._ioSetArgs call.
+
+ //DO NOT use "this" and expect it to be script.
+ var ioArgs = dfd.ioArgs;
+
+ //Favor JSONP responses, script load events then lastly ioArgs.
+ //The ioArgs are goofy, but cannot return the dfd since that stops
+ //the callback chain in Deferred. The return value is not that important
+ //in that case, probably a checkString case.
+ return ioArgs.json || ioArgs.scriptLoaded || ioArgs;
+ },
+
+ _deferredError: function(/*Error*/ error, /*Deferred*/ dfd){
+ // summary:
+ // errHandler function for xhr._ioSetArgs call.
+
+ console.log("dojo.io.script error", error);
+ return error;
+ },
+
+ _deadScripts: [],
+ _counter: 1,
+
+ _addDeadScript: function(/*Object*/ ioArgs){
+ // summary:
+ // sets up an entry in the deadScripts array.
+ script._deadScripts.push({id: ioArgs.id, frameDoc: ioArgs.frameDoc});
+ //Being extra paranoid about leaks:
+ ioArgs.frameDoc = null;
+ },
+
+ _validCheck: function(/*Deferred*/ dfd){
+ // summary:
+ // inflight check function to see if dfd is still valid.
+
+ // TODO: why isn't dfd accessed?
+
+ //Do script cleanup here. We wait for one inflight pass
+ //to make sure we don't get any weird things by trying to remove a script
+ //tag that is part of the call chain (IE 6 has been known to
+ //crash in that case).
+ var deadScripts = script._deadScripts;
+ if(deadScripts && deadScripts.length > 0){
+ for(var i = 0; i < deadScripts.length; i++){
+ //Remove the script tag
+ script.remove(deadScripts[i].id, deadScripts[i].frameDoc);
+ deadScripts[i].frameDoc = null;
+ }
+ script._deadScripts = [];
+ }
+
+ return true;
+ },
+
+ _ioCheck: function(dfd){
+ // summary:
+ // inflight check function to see if IO finished.
+ // dfd: Deferred
+ var ioArgs = dfd.ioArgs;
+ //Check for finished jsonp
+ if(ioArgs.json || (ioArgs.scriptLoaded && !ioArgs.args.checkString)){
+ return true;
+ }
+
+ //Check for finished "checkString" case.
+ var checkString = ioArgs.args.checkString;
+ return checkString && eval("typeof(" + checkString + ") != 'undefined'");
+
+
+ },
+
+ _resHandle: function(/*Deferred*/ dfd){
+ // summary:
+ // inflight function to handle a completed response.
+ if(script._ioCheck(dfd)){
+ dfd.callback(dfd);
+ }else{
+ //This path should never happen since the only way we can get
+ //to _resHandle is if _ioCheck is true.
+ dfd.errback(new Error("inconceivable dojo.io.script._resHandle error"));
+ }
+ },
+
+ _canAttach: function(/*===== ioArgs =====*/ ){
+ // summary:
+ // A method that can be overridden by other modules
+ // to control when the script attachment occurs.
+ // ioArgs: Object
+ return true;
+ },
+
+ _jsonpCallback: function(/*JSON Object*/ json){
+ // summary:
+ // generic handler for jsonp callback. A pointer to this function
+ // is used for all jsonp callbacks. NOTE: the "this" in this
+ // function will be the Deferred object that represents the script
+ // request.
+ this.ioArgs.json = json;
+ kernel.global[_script._callbacksProperty][this.ioArgs.requestId](json);
+ }
+ };
+
+ lang.setObject("dojo.io.script", script);
+
+ /*=====
+ script.attach = function(id, url, frameDocument){
+ // summary:
+ // creates a new `<script>` tag pointing to the specified URL and
+ // adds it to the document.
+ // description:
+ // Attaches the script element to the DOM. Use this method if you
+ // just want to attach a script to the DOM and do not care when or
+ // if it loads.
+ };
+ script.remove = function(id, frameDocument){
+ // summary:
+ // removes the script element with the given id, from the given frameDocument.
+ // If no frameDocument is passed, the current document is used.
+ };
+ =====*/
+
+ return script;
+});