Debian Codegraph @

dijit/BackgroundIframe.js

raw symbols SCIP
1 define([
2 "require", // require.toUrl
3 "./main", // to export dijit.BackgroundIframe
4 "dojo/_base/config",
5 "dojo/dom-construct", // domConstruct.create
6 "dojo/dom-style", // domStyle.set
7 "dojo/_base/lang", // lang.extend lang.hitch
8 "dojo/on",
9 "dojo/sniff" // has("ie"), has("trident"), has("quirks")
10 ], function(require, dijit, config, domConstruct, domStyle, lang, on, has){
11
12 // module:
13 // dijit/BackgroundIFrame
14
15 // Flag for whether to create background iframe behind popups like Menus and Dialog.
16 // A background iframe is useful to prevent problems with popups appearing behind applets/pdf files,
17 // and is also useful on older versions of IE (IE6 and IE7) to prevent the "bleed through select" problem.
18 // By default, it's enabled for IE6-11, excluding Windows Phone 8.
19 // TODO: For 2.0, make this false by default. Also, possibly move definition to has.js so that this module can be
20 // conditionally required via dojo/has!bgIfame?dijit/BackgroundIframe
21 has.add("config-bgIframe",
22 (has("ie") || has("trident")) && !/IEMobile\/10\.0/.test(navigator.userAgent)); // No iframe on WP8, to match 1.9 behavior
23
24 var _frames = new function(){
25 // summary:
26 // cache of iframes
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 // transparency needed for DialogUnderlay and for tooltips on IE (to see screen near connector)
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; // Magic to prevent iframe from getting focus on tab keypress - as style didn't work.
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(/*DomNode*/ node){
63 // summary:
64 // For IE/FF z-index shenanigans. id attribute is required.
65 //
66 // description:
67 // new dijit.BackgroundIframe(node).
68 //
69 // Makes a background iframe as a child of node, that fills
70 // area (and position) of node
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 // summary:
91 // Resize the iframe so it's the same size as node.
92 // Needed on IE6 and IE/quirks because height:100% doesn't work right.
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 // summary:
102 // destroy the iframe
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 });