]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/BackgroundIframe.js.uncompressed.js
update dojo to 1.7.3
[tt-rss.git] / lib / dijit / BackgroundIframe.js.uncompressed.js
1 define("dijit/BackgroundIframe", [
2 "require", // require.toUrl
3 ".", // 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/_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){
12
13 // module:
14 // dijit/BackgroundIFrame
15 // summary:
16 // new dijit.BackgroundIframe(node)
17 // Makes a background iframe as a child of node, that fills
18 // area (and position) of node
19
20 // TODO: remove _frames, it isn't being used much, since popups never release their
21 // iframes (see [22236])
22 var _frames = new function(){
23 // summary:
24 // cache of iframes
25
26 var queue = [];
27
28 this.pop = function(){
29 var iframe;
30 if(queue.length){
31 iframe = queue.pop();
32 iframe.style.display="";
33 }else{
34 if(has("ie") < 9){
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);
40 }else{
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);
46 }
47 iframe.tabIndex = -1; // Magic to prevent iframe from getting focus on tab keypress - as style didn't work.
48 }
49 return iframe;
50 };
51
52 this.push = function(iframe){
53 iframe.style.display="none";
54 queue.push(iframe);
55 }
56 }();
57
58
59 dijit.BackgroundIframe = function(/*DomNode*/ node){
60 // summary:
61 // For IE/FF z-index schenanigans. id attribute is required.
62 //
63 // description:
64 // new dijit.BackgroundIframe(node)
65 // Makes a background iframe as a child of node, that fills
66 // area (and position) of node
67
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")){
73 this.resize(node);
74 this._conn = on(node, 'resize', lang.hitch(this, function(){
75 this.resize(node);
76 }));
77 }else{
78 domStyle.set(iframe, {
79 width: '100%',
80 height: '100%'
81 });
82 }
83 }
84 };
85
86 lang.extend(dijit.BackgroundIframe, {
87 resize: function(node){
88 // summary:
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.
91 if(this.iframe){
92 domStyle.set(this.iframe, {
93 width: node.offsetWidth + 'px',
94 height: node.offsetHeight + 'px'
95 });
96 }
97 },
98 destroy: function(){
99 // summary:
100 // destroy the iframe
101 if(this._conn){
102 this._conn.remove();
103 this._conn = null;
104 }
105 if(this.iframe){
106 _frames.push(this.iframe);
107 delete this.iframe;
108 }
109 }
110 });
111
112 return dijit.BackgroundIframe;
113 });