Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Details | Compare with Previous | 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
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.html.iframe");
14
dojo.require("dojo.html.util");
15
dojo.html.iframeContentWindow = function (iframe_el) {
16
	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;
17
	return win;
18
};
19
dojo.html.iframeContentDocument = function (iframe_el) {
20
	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;
21
	return doc;
22
};
23
dojo.html.BackgroundIframe = function (node) {
24
	if (dojo.render.html.ie55 || dojo.render.html.ie60) {
25
		var html = "<iframe src='javascript:false'" + " style='position: absolute; left: 0px; top: 0px; width: 100%; height: 100%;" + "z-index: -1; filter:Alpha(Opacity=\"0\");' " + ">";
26
		this.iframe = dojo.doc().createElement(html);
27
		this.iframe.tabIndex = -1;
28
		if (node) {
29
			node.appendChild(this.iframe);
30
			this.domNode = node;
31
		} else {
32
			dojo.body().appendChild(this.iframe);
33
			this.iframe.style.display = "none";
34
		}
35
	}
36
};
37
dojo.lang.extend(dojo.html.BackgroundIframe, {iframe:null, onResized:function () {
38
	if (this.iframe && this.domNode && this.domNode.parentNode) {
39
		var outer = dojo.html.getMarginBox(this.domNode);
40
		if (outer.width == 0 || outer.height == 0) {
41
			dojo.lang.setTimeout(this, this.onResized, 100);
42
			return;
43
		}
44
		this.iframe.style.width = outer.width + "px";
45
		this.iframe.style.height = outer.height + "px";
46
	}
47
}, size:function (node) {
48
	if (!this.iframe) {
49
		return;
50
	}
51
	var coords = dojo.html.toCoordinateObject(node, true, dojo.html.boxSizing.BORDER_BOX);
52
	with (this.iframe.style) {
53
		width = coords.width + "px";
54
		height = coords.height + "px";
55
		left = coords.left + "px";
56
		top = coords.top + "px";
57
	}
58
}, setZIndex:function (node) {
59
	if (!this.iframe) {
60
		return;
61
	}
62
	if (dojo.dom.isNode(node)) {
63
		this.iframe.style.zIndex = dojo.html.getStyle(node, "z-index") - 1;
64
	} else {
65
		if (!isNaN(node)) {
66
			this.iframe.style.zIndex = node;
67
		}
68
	}
69
}, show:function () {
70
	if (this.iframe) {
71
		this.iframe.style.display = "block";
72
	}
73
}, hide:function () {
74
	if (this.iframe) {
75
		this.iframe.style.display = "none";
76
	}
77
}, remove:function () {
78
	if (this.iframe) {
79
		dojo.html.removeNode(this.iframe, true);
80
		delete this.iframe;
81
		this.iframe = null;
82
	}
83
}});
84