| 1 |
define([ |
| 2 |
"require", |
| 3 |
"./main", |
| 4 |
"dojo/_base/config", |
| 5 |
"dojo/dom-construct", |
| 6 |
"dojo/dom-style", |
| 7 |
"dojo/_base/lang", |
| 8 |
"dojo/on", |
| 9 |
"dojo/sniff" |
| 10 |
], function(require, dijit, config, domConstruct, domStyle, lang, on, has){ |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
has.add("config-bgIframe", |
| 22 |
(has("ie") || has("trident")) && !/IEMobile\/10\.0/.test(navigator.userAgent)); |
| 23 |
|
| 24 |
var _frames = new function(){ |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
var queue = []; |
| 29 |
|
| 30 |
this.pop = function(){ |
| 31 |
var iframe; |
| 32 |
if(queue.length){ |
| 33 |
iframe = queue.pop(); |
| 34 |
iframe.style.display=""; |
| 35 |
}else{ |
| 36 |
|
| 37 |
if(has("ie") < 9){ |
| 38 |
var burl = config["dojoBlankHtmlUrl"] || require.toUrl("dojo/resources/blank.html") || "javascript:\"\""; |
| 39 |
var html="<iframe src='" + burl + "' role='presentation'" |
| 40 |
+ " style='position: absolute; left: 0px; top: 0px;" |
| 41 |
+ "z-index: -1; filter:Alpha(Opacity=\"0\");'>"; |
| 42 |
iframe = document.createElement(html); |
| 43 |
}else{ |
| 44 |
iframe = domConstruct.create("iframe"); |
| 45 |
iframe.src = 'javascript:""'; |
| 46 |
iframe.className = "dijitBackgroundIframe"; |
| 47 |
iframe.setAttribute("role", "presentation"); |
| 48 |
domStyle.set(iframe, "opacity", 0.1); |
| 49 |
} |
| 50 |
iframe.tabIndex = -1; |
| 51 |
} |
| 52 |
return iframe; |
| 53 |
}; |
| 54 |
|
| 55 |
this.push = function(iframe){ |
| 56 |
iframe.style.display="none"; |
| 57 |
queue.push(iframe); |
| 58 |
} |
| 59 |
}(); |
| 60 |
|
| 61 |
|
| 62 |
dijit.BackgroundIframe = function( node){ |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
if(!node.id){ throw new Error("no id"); } |
| 73 |
if(has("config-bgIframe")){ |
| 74 |
var iframe = (this.iframe = _frames.pop()); |
| 75 |
node.appendChild(iframe); |
| 76 |
if(has("ie")<7 || has("quirks")){ |
| 77 |
this.resize(node); |
| 78 |
this._conn = on(node, 'resize', lang.hitch(this, "resize", node)); |
| 79 |
}else{ |
| 80 |
domStyle.set(iframe, { |
| 81 |
width: '100%', |
| 82 |
height: '100%' |
| 83 |
}); |
| 84 |
} |
| 85 |
} |
| 86 |
}; |
| 87 |
|
| 88 |
lang.extend(dijit.BackgroundIframe, { |
| 89 |
resize: function(node){ |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
if(this.iframe){ |
| 94 |
domStyle.set(this.iframe, { |
| 95 |
width: node.offsetWidth + 'px', |
| 96 |
height: node.offsetHeight + 'px' |
| 97 |
}); |
| 98 |
} |
| 99 |
}, |
| 100 |
destroy: function(){ |
| 101 |
|
| 102 |
|
| 103 |
if(this._conn){ |
| 104 |
this._conn.remove(); |
| 105 |
this._conn = null; |
| 106 |
} |
| 107 |
if(this.iframe){ |
| 108 |
this.iframe.parentNode.removeChild(this.iframe); |
| 109 |
_frames.push(this.iframe); |
| 110 |
delete this.iframe; |
| 111 |
} |
| 112 |
} |
| 113 |
}); |
| 114 |
|
| 115 |
return dijit.BackgroundIframe; |
| 116 |
}); |