Changeset 6981

Show
Ignore:
Timestamp:
01/04/07 14:36:01 (23 months ago)
Author:
jburke
Message:

Fixes #2274: allow modules that use iframes to have djConfig overrides to specify local file paths. Also made it so that if using iframe_history.html, you can pass init args via fragment identifiers so iframe_history.html can be more easily cached.

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/iframe_history.html

    r4226 r6981  
    1111        var domain = ""; 
    1212        // document.domain = "localhost"; 
    13         function init(){ 
    14                 // parse the query string if there is one to try to get args that 
    15                 // we can act on 
    16                 var sparams = document.location.search; 
    17                 if(sparams.length >= 0){ 
    18                         if(sparams.charAt(0) == "?"){ 
    19                                 sparams = sparams.substring(1); 
    20                         } 
     13         
     14        function defineParams(sparams){ 
     15                if(sparams){ 
    2116                        var ss = (sparams.indexOf("&") >= 0) ? "&" : "&"; 
    2217                        sparams = sparams.split(ss); 
     
    2823                        } 
    2924                } 
     25        } 
     26         
     27        function init(){ 
     28                // parse the query string if there is one to try to get params that 
     29                // we can act on. Also allow params to be in a fragment identifier. 
     30                var query = null; 
     31                var frag = null; 
     32                var url = document.location.href; 
     33                var hashIndex = url.indexOf("#"); 
     34                 
     35                //Extract fragment identifier 
     36                if(hashIndex != -1){ 
     37                        frag = url.substring(hashIndex + 1, url.length); 
     38                        url = url.substring(0, hashIndex); 
     39                } 
     40 
     41                //Extract querystring 
     42                var parts = url.split("?"); 
     43                if(parts.length == 2){ 
     44                        query = parts[1]; 
     45                } 
     46 
     47                defineParams(query); 
     48                defineParams(frag); 
    3049 
    3150                if(noInit){ return; } 
     
    3352                        document.domain = domain; 
    3453                } 
    35                 if((window.parent != window)&&(window.parent["dojo"])){ 
     54                var hasParentDojo = false; 
     55                try{ 
     56                        hasParentDojo = window.parent != window && window.parent["dojo"]; 
     57                }catch(e){ 
     58                        alert("Initializing iframe_history.html failed. If you are using a cross-domain Dojo build," 
     59                                + " please save iframe_history.html to your domain and set djConfig.dojoIframeHistoryUrl" 
     60                                + " to the path on your domain to iframe_history.html"); 
     61                        throw e; 
     62                } 
     63 
     64                if(hasParentDojo){ 
    3665                        //Set the page title so IE history shows up with a somewhat correct name. 
    3766                        document.title = window.parent.document.title; 
     
    4372                        } 
    4473                } 
     74 
    4575        } 
    4676        // --> 
  • trunk/src/io/IframeIO.js

    r6973 r6981  
    1919        var r = dojo.render.html; 
    2020        var cframe = null; 
    21         var turi = uri||dojo.uri.moduleUri("dojo", "../iframe_history.html?noInit=true"); 
     21        var turi = uri; 
     22        if(!turi){ 
     23                if(djConfig["useXDomain"] && !djConfig["dojoIframeHistoryUrl"]){ 
     24                        dojo.debug("dojo.io.createIFrame: When using cross-domain Dojo builds," 
     25                                + " please save iframe_history.html to your domain and set djConfig.dojoIframeHistoryUrl" 
     26                                + " to the path on your domain to iframe_history.html"); 
     27                } 
     28                turi = (djConfig["dojoIframeHistoryUrl"]||dojo.uri.moduleUri("dojo", "../iframe_history.html")) + "#noInit=true"; 
     29        } 
    2230        var ifrstr = ((r.ie)&&(dojo.render.os.win)) ? '<iframe name="'+fname+'" src="'+turi+'" onload="'+onloadstr+'">' : 'iframe'; 
    2331        cframe = document.createElement(ifrstr); 
  • trunk/src/undo/browser.js

    r6747 r6981  
    44try{ 
    55        if((!djConfig["preventBackButtonFix"])&&(!dojo.hostenv.post_load_)){ 
    6                 document.write("<iframe style='border: 0px; width: 1px; height: 1px; position: absolute; bottom: 0px; right: 0px; visibility: visible;' name='djhistory' id='djhistory' src='"+(dojo.hostenv.getBaseScriptUri()+'iframe_history.html')+"'></iframe>"); 
     6                document.write("<iframe style='border: 0px; width: 1px; height: 1px; position: absolute; bottom: 0px; right: 0px; visibility: visible;' name='djhistory' id='djhistory' src='" + (djConfig["dojoIframeHistoryUrl"] || dojo.hostenv.getBaseScriptUri()+'iframe_history.html') + "'></iframe>"); 
    77        } 
    88}catch(e){/* squelch */} 
     
    9797                var url = null; 
    9898                if(!this.historyIframe){ 
     99                        if(djConfig["useXDomain"] && !djConfig["dojoIframeHistoryUrl"]){ 
     100                                dojo.debug("dojo.undo.browser: When using cross-domain Dojo builds," 
     101                                        + " please save iframe_history.html to your domain and set djConfig.dojoIframeHistoryUrl" 
     102                                        + " to the path on your domain to iframe_history.html"); 
     103                        } 
    99104                        this.historyIframe = window.frames["djhistory"]; 
    100105                } 
     
    305310        _loadIframeHistory: function(){ 
    306311                //summary: private method. Do not call this directly. 
    307                 var url = dojo.hostenv.getBaseScriptUri()+"iframe_history.html?"+(new Date()).getTime(); 
     312                var url = (djConfig["dojoIframeHistoryUrl"] || dojo.hostenv.getBaseScriptUri()+'iframe_history.html') 
     313                        + "?" + (new Date()).getTime(); 
    308314                this.moveForward = true; 
    309315                dojo.io.setIFrameSrc(this.historyIframe, url, false);    
  • trunk/src/widget/RichText.js

    r6973 r6981  
    511511                        } 
    512512                        // opera likes this to be outside the with block 
    513                         this.iframe.src = dojo.uri.moduleUri("dojo", "widget/templates/richtextframe.html") + ((dojo.doc().domain != currentDomain) ? ("#"+dojo.doc().domain) : ""); 
     513                        if(djConfig["useXDomain"] && !djConfig["dojoRichTextFrameUrl"]){ 
     514                                dojo.debug("dojo.widget.RichText: When using cross-domain Dojo builds," 
     515                                        + " please save src/widget/templates/richtextframe.html to your domain and set djConfig.dojoRichTextFrameUrl" 
     516                                        + " to the path on your domain to richtextframe.html"); 
     517                        } 
     518                        this.iframe.src = (djConfig["dojoRichTextFrameUrl"] || dojo.uri.moduleUri("dojo", "widget/templates/richtextframe.html"))  
     519                                + ((dojo.doc().domain != currentDomain) ? ("#"+dojo.doc().domain) : ""); 
    514520                        this.iframe.width = this.inheritWidth ? this._oldWidth : "100%"; 
    515521                        if(this.height){