diff options
Diffstat (limited to 'lib/dojo/io')
-rw-r--r-- | lib/dojo/io/iframe.js | 70 | ||||
-rw-r--r-- | lib/dojo/io/script.js | 22 |
2 files changed, 33 insertions, 59 deletions
diff --git a/lib/dojo/io/iframe.js b/lib/dojo/io/iframe.js index 5b2af45a1..aa8ddf290 100644 --- a/lib/dojo/io/iframe.js +++ b/lib/dojo/io/iframe.js @@ -1,5 +1,5 @@ /* - Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. + Copyright (c) 2004-2011, 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 */ @@ -9,6 +9,8 @@ if(!dojo._hasResource["dojo.io.iframe"]){ //_hasResource checks added by build. dojo._hasResource["dojo.io.iframe"] = true; dojo.provide("dojo.io.iframe"); +dojo.getObject("io", true, dojo); + /*===== dojo.declare("dojo.io.iframe.__ioArgs", dojo.__IoArgs, { constructor: function(){ @@ -49,7 +51,7 @@ dojo.declare("dojo.io.iframe.__ioArgs", dojo.__IoArgs, { =====*/ dojo.io.iframe = { - // summary: + // summary: // Sends an Ajax I/O call using and Iframe (for instance, to upload files) create: function(/*String*/fname, /*String*/onloadstr, /*String?*/uri){ @@ -79,30 +81,12 @@ dojo.io.iframe = { } turi = (dojo.config["dojoBlankHtmlUrl"]||dojo.moduleUrl("dojo", "resources/blank.html")); } - var ifrstr = dojo.isIE ? '<iframe name="'+fname+'" src="'+turi+'" onload="'+onloadstr+'">' : 'iframe'; - cframe = dojo.doc.createElement(ifrstr); - with(cframe){ - name = fname; - setAttribute("name", fname); - id = fname; - } - dojo.body().appendChild(cframe); - window[fname] = cframe; - - with(cframe.style){ - if(!(dojo.isSafari < 3)){ - //We can't change the src in Safari 2.0.3 if absolute position. Bizarro. - position = "absolute"; - } - left = top = "1px"; - height = width = "1px"; - visibility = "hidden"; - } + var cframe = dojo.place( + '<iframe id="'+fname+'" name="'+fname+'" src="'+turi+'" onload="'+onloadstr+ + '" style="position: absolute; left: 1px; top: 1px; height: 1px; width: 1px; visibility: hidden">', + dojo.body()); - if(!dojo.isIE){ - this.setSrc(cframe, turi, true); - cframe.onload = new Function(onloadstr); - } + window[fname] = cframe; return cframe; }, @@ -122,11 +106,8 @@ dojo.io.iframe = { }else{ // Fun with DOM 0 incompatibilities! var idoc; - //WebKit > 521 corresponds with Safari 3, which started with 522 WebKit version. - if(dojo.isIE || dojo.isWebKit > 521){ + if(dojo.isIE || dojo.isWebKit){ idoc = iframe.contentWindow.document; - }else if(dojo.isSafari){ - idoc = iframe.document; }else{ // if(d.isMozilla){ idoc = iframe.contentWindow; } @@ -142,8 +123,8 @@ dojo.io.iframe = { idoc.location.replace(src); } } - }catch(e){ - console.log("dojo.io.iframe.setSrc: ", e); + }catch(e){ + console.log("dojo.io.iframe.setSrc: ", e); } }, @@ -152,7 +133,7 @@ dojo.io.iframe = { var doc = iframeNode.contentDocument || // W3 ( ( - (iframeNode.name) && (iframeNode.document) && + (iframeNode.name) && (iframeNode.document) && (dojo.doc.getElementsByTagName("iframe")[iframeNode.name].contentWindow) && (dojo.doc.getElementsByTagName("iframe")[iframeNode.name].contentWindow.document) ) @@ -165,7 +146,7 @@ dojo.io.iframe = { }, send: function(/*dojo.io.iframe.__ioArgs*/args){ - //summary: + //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. @@ -195,8 +176,8 @@ dojo.io.iframe = { if(handleAs != "html"){ if(handleAs == "xml"){ // FF, Saf 3+ and Opera all seem to be fine with ifd being xml. We have to - // do it manually for IE. Refs #6334. - if(dojo.isIE){ + // do it manually for IE6-8. Refs #6334. + if(dojo.isIE < 9 || (dojo.isIE && dojo.isQuirks)){ dojo.query("a", dii._frame.contentWindow.document.documentElement).orphan(); var xmlText=(dii._frame.contentWindow.document).documentElement.innerText; xmlText=xmlText.replace(/>\s+</g, "><"); @@ -218,7 +199,7 @@ dojo.io.iframe = { }catch(e){ value = e; }finally{ - ioArgs._callNext(); + ioArgs._callNext(); } return value; }, @@ -238,7 +219,7 @@ dojo.io.iframe = { dojo.io.iframe._currentDfd = null; dojo.io.iframe._fireNextRequest(); } - } + }; this._dfdQueue.push(dfd); this._fireNextRequest(); @@ -297,16 +278,7 @@ dojo.io.iframe = { // if we have things in content, we need to add them to the form // before submission var pHandler = function(name, value) { - var tn; - if(dojo.isIE){ - tn = dojo.doc.createElement("<input type='hidden' name='"+name+"'>"); - }else{ - tn = dojo.doc.createElement("input"); - tn.type = "hidden"; - tn.name = name; - } - tn.value = value; - fn.appendChild(tn); + dojo.create("input", {type: "hidden", name: name, value: value}, fn); ioArgs._contentToClean.push(name); }; for(var x in content){ @@ -325,7 +297,7 @@ dojo.io.iframe = { } } } - //IE requires going through getAttributeNode instead of just getAttribute in some form cases, + //IE requires going through getAttributeNode instead of just getAttribute in some form cases, //so use it for all. See #2844 var actnNode = fn.getAttributeNode("action"); var mthdNode = fn.getAttributeNode("method"); @@ -406,6 +378,6 @@ dojo.io.iframe = { ioArgs._finished = true; } -} +}; } diff --git a/lib/dojo/io/script.js b/lib/dojo/io/script.js index 9730c977d..a44e9f2ee 100644 --- a/lib/dojo/io/script.js +++ b/lib/dojo/io/script.js @@ -1,5 +1,5 @@ /* - Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. + Copyright (c) 2004-2011, 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 */ @@ -9,6 +9,8 @@ if(!dojo._hasResource["dojo.io.script"]){ //_hasResource checks added by build. dojo._hasResource["dojo.io.script"] = true; dojo.provide("dojo.io.script"); +dojo.getObject("io", true, dojo); + /*===== dojo.declare("dojo.io.script.__ioArgs", dojo.__IoArgs, { constructor: function(){ @@ -24,13 +26,13 @@ dojo.declare("dojo.io.script.__ioArgs", dojo.__IoArgs, { // 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 + // 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: + // A string of JavaScript that when evaluated like so: // "typeof(" + checkString + ") != 'undefined'" - // being true means that the script fetched has been loaded. + // 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 @@ -43,7 +45,7 @@ dojo.declare("dojo.io.script.__ioArgs", dojo.__IoArgs, { } }); =====*/ -;(function(){ +(function(){ var loadEvent = dojo.isIE ? "onreadystatechange" : "load", readyRegExp = /complete|loaded/; @@ -105,7 +107,7 @@ dojo.declare("dojo.io.script.__ioArgs", dojo.__IoArgs, { }, _makeScriptDeferred: function(/*Object*/args){ - //summary: + //summary: // sets up a Deferred object for an IO request. var dfd = dojo._ioSetArgs(args, this._deferredCancel, this._deferredOk, this._deferredError); @@ -152,7 +154,7 @@ dojo.declare("dojo.io.script.__ioArgs", dojo.__IoArgs, { //DO NOT use "this" and expect it to be dojo.io.script. var ioArgs = dfd.ioArgs; - //Add script to list of things that can be removed. + //Add script to list of things that can be removed. if(ioArgs.canDelete){ dojo.io.script._addDeadScript(ioArgs); } @@ -247,14 +249,14 @@ dojo.declare("dojo.io.script.__ioArgs", dojo.__IoArgs, { }, _jsonpCallback: function(/*JSON Object*/json){ - //summary: + //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; } - } + }; })(); } |