Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
11
dojo.provide("dojo.html.iframe");
12
dojo.require("dojo.html.util");
13
dojo.html.iframeContentWindow = function (iframe_el) {
14
	var win = dojo.html.getDocumentWindow(dojo.html.iframeContentDocument(iframe_el)) || dojo.html.iframeContentDocument(iframe_el).__parent__ || (iframe_el.name && document.frames[iframe_el.name]) || null;
15
	return win;
16
};
17
dojo.html.iframeContentDocument = function (iframe_el) {
18
	var doc = iframe_el.contentDocument || ((iframe_el.contentWindow) && (iframe_el.contentWindow.document)) || ((iframe_el.name) && (document.frames[iframe_el.name]) && (document.frames[iframe_el.name].document)) || null;
19
	return doc;
20
};
21
dojo.html.BackgroundIframe = function (node) {
22
	if (dojo.render.html.ie55 || dojo.render.html.ie60) {
23
		var html = "<iframe src='javascript:false'" + " style='position: absolute; left: 0px; top: 0px; width: 100%; height: 100%;" + "z-index: -1; filter:Alpha(Opacity=\"0\");' " + ">";
24
		this.iframe = dojo.doc().createElement(html);
25
		this.iframe.tabIndex = -1;
26
		if (node) {
27
			node.appendChild(this.iframe);
28
			this.domNode = node;
29
		} else {
30
			dojo.body().appendChild(this.iframe);
31
			this.iframe.style.display = "none";
32
		}
33
	}
34
};
35
dojo.lang.extend(dojo.html.BackgroundIframe, {iframe:null, onResized:function () {
36
	if (this.iframe && this.domNode && this.domNode.parentNode) {
37
		var outer = dojo.html.getMarginBox(this.domNode);
38
		if (outer.width == 0 || outer.height == 0) {
39
			dojo.lang.setTimeout(this, this.onResized, 100);
40
			return;
41
		}
42
		this.iframe.style.width = outer.width + "px";
43
		this.iframe.style.height = outer.height + "px";
44
	}
45
}, size:function (node) {
46
	if (!this.iframe) {
47
		return;
48
	}
49
	var coords = dojo.html.toCoordinateObject(node, true, dojo.html.boxSizing.BORDER_BOX);
50
	with (this.iframe.style) {
51
		width = coords.width + "px";
52
		height = coords.height + "px";
53
		left = coords.left + "px";
54
		top = coords.top + "px";
55
	}
56
}, setZIndex:function (node) {
57
	if (!this.iframe) {
58
		return;
59
	}
60
	if (dojo.dom.isNode(node)) {
61
		this.iframe.style.zIndex = dojo.html.getStyle(node, "z-index") - 1;
62
	} else {
63
		if (!isNaN(node)) {
64
			this.iframe.style.zIndex = node;
65
		}
66
	}
67
}, show:function () {
68
	if (this.iframe) {
69
		this.iframe.style.display = "block";
70
	}
71
}, hide:function () {
72
	if (this.iframe) {
73
		this.iframe.style.display = "none";
74
	}
75
}, remove:function () {
76
	if (this.iframe) {
77
		dojo.html.removeNode(this.iframe, true);
78
		delete this.iframe;
79
		this.iframe = null;
80
	}
81
}});
82