/*
	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/io/script","../_base/connect ../_base/kernel ../_base/lang ../sniff ../_base/window ../_base/xhr ../dom ../dom-construct ../request/script ../aspect".split(" "),function(p,g,l,q,r,k,t,u,h,m){g.deprecated("dojo/io/script","Use dojo/request/script.","2.0");var e={get:function(a){var c=this._makeScriptDeferred(a,function(f){b&&b.cancel()}),d=c.ioArgs;k._ioAddQueryToUrl(d);k._ioNotifyStart(c);var b=h.get(d.url,{timeout:a.timeout,jsonp:d.jsonp,checkString:a.checkString,ioArgs:d,frameDoc:a.frameDoc,
canAttach:function(f){d.requestId=f.id;d.scriptId=f.scriptId;d.canDelete=f.canDelete;return e._canAttach(d)}},!0);m.around(b,"isValid",function(f){return function(n){e._validCheck(c);return f.call(this,n)}});b.then(function(){c.resolve(c)}).otherwise(function(f){c.ioArgs.error=f;c.reject(f)});return c},attach:h._attach,remove:h._remove,_makeScriptDeferred:function(a,c){var d=k._ioSetArgs(a,c||this._deferredCancel,this._deferredOk,this._deferredError),b=d.ioArgs;b.id=g._scopeName+"IoScript"+this._counter++;
b.canDelete=!1;b.jsonp=a.callbackParamName||a.jsonp;b.jsonp&&(b.query=b.query||"",0<b.query.length&&(b.query+="\x26"),b.query+=b.jsonp+"\x3d"+(a.frameDoc?"parent.":"")+g._scopeName+".io.script.jsonp_"+b.id+"._jsonpCallback",b.frameDoc=a.frameDoc,b.canDelete=!0,d._jsonpCallback=this._jsonpCallback,this["jsonp_"+b.id]=d);d.addBoth(function(f){b.canDelete&&(f instanceof Error?e["jsonp_"+b.id]._jsonpCallback=function(){delete e["jsonp_"+b.id];if(b.requestId)g.global[h._callbacksProperty][b.requestId]()}:
e._addDeadScript(b))});return d},_deferredCancel:function(a){a.canceled=!0},_deferredOk:function(a){a=a.ioArgs;return a.json||a.scriptLoaded||a},_deferredError:function(a,c){return a},_deadScripts:[],_counter:1,_addDeadScript:function(a){e._deadScripts.push({id:a.id,frameDoc:a.frameDoc});a.frameDoc=null},_validCheck:function(a){if((a=e._deadScripts)&&0<a.length){for(var c=0;c<a.length;c++)e.remove(a[c].id,a[c].frameDoc),delete e["jsonp_"+a[c].id],a[c].frameDoc=null;e._deadScripts=[]}return!0},_ioCheck:function(a){a=
a.ioArgs;return a.json||a.scriptLoaded&&!a.args.checkString?!0:(a=a.args.checkString)&&eval("typeof("+a+") !\x3d 'undefined'")},_resHandle:function(a){e._ioCheck(a)?a.callback(a):a.errback(Error("inconceivable dojo.io.script._resHandle error"))},_canAttach:function(){return!0},_jsonpCallback:function(a){this.ioArgs.json=a;if(this.ioArgs.requestId)g.global[h._callbacksProperty][this.ioArgs.requestId](a)}};l.setObject("dojo.io.script",e);return e});