1 define("dijit/BackgroundIframe", [
2 "require", // require.toUrl
3 ".", // to export dijit.BackgroundIframe
5 "dojo/dom-construct", // domConstruct.create
6 "dojo/dom-style", // domStyle.set
7 "dojo/_base/lang", // lang.extend lang.hitch
9 "dojo/_base/sniff", // has("ie"), has("mozilla"), has("quirks")
10 "dojo/_base/window" // win.doc.createElement
11 ], function(require, dijit, config, domConstruct, domStyle, lang, on, has, win){
14 // dijit/BackgroundIFrame
16 // new dijit.BackgroundIframe(node)
17 // Makes a background iframe as a child of node, that fills
18 // area (and position) of node
20 // TODO: remove _frames, it isn't being used much, since popups never release their
21 // iframes (see [22236])
22 var _frames = new function(){
28 this.pop = function(){
32 iframe.style.display="";
35 var burl = config["dojoBlankHtmlUrl"] || require.toUrl("dojo/resources/blank.html") || "javascript:\"\"";
36 var html="<iframe src='" + burl + "' role='presentation'"
37 + " style='position: absolute; left: 0px; top: 0px;"
38 + "z-index: -1; filter:Alpha(Opacity=\"0\");'>";
39 iframe = win.doc.createElement(html);
41 iframe = domConstruct.create("iframe");
42 iframe.src = 'javascript:""';
43 iframe.className = "dijitBackgroundIframe";
44 iframe.setAttribute("role", "presentation");
45 domStyle.set(iframe, "opacity", 0.1);
47 iframe.tabIndex = -1; // Magic to prevent iframe from getting focus on tab keypress - as style didn't work.
52 this.push = function(iframe){
53 iframe.style.display="none";
59 dijit.BackgroundIframe = function(/*DomNode*/ node){
61 // For IE/FF z-index schenanigans. id attribute is required.
64 // new dijit.BackgroundIframe(node)
65 // Makes a background iframe as a child of node, that fills
66 // area (and position) of node
68 if(!node.id){ throw new Error("no id"); }
69 if(has("ie") || has("mozilla")){
70 var iframe = (this.iframe = _frames.pop());
71 node.appendChild(iframe);
72 if(has("ie")<7 || has("quirks")){
74 this._conn = on(node, 'resize', lang.hitch(this, function(){
78 domStyle.set(iframe, {
86 lang.extend(dijit.BackgroundIframe, {
87 resize: function(node){
89 // Resize the iframe so it's the same size as node.
90 // Needed on IE6 and IE/quirks because height:100% doesn't work right.
92 domStyle.set(this.iframe, {
93 width: node.offsetWidth + 'px',
94 height: node.offsetHeight + 'px'
100 // destroy the iframe
106 _frames.push(this.iframe);
112 return dijit.BackgroundIframe;