Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1372 Rev 1422
1
/*
1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
3
	All Rights Reserved.
4
 
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
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:
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
9
*/
-
 
10
 
-
 
11
 
10
 
12
 
11
dojo.provide("dojo.widget.Editor2Plugin.AlwaysShowToolbar");
13
dojo.provide("dojo.widget.Editor2Plugin.AlwaysShowToolbar");
12
dojo.event.topic.subscribe("dojo.widget.Editor2::onLoad", function (editor) {
14
dojo.event.topic.subscribe("dojo.widget.Editor2::onLoad", function (editor) {
13
	if (editor.toolbarAlwaysVisible) {
15
	if (editor.toolbarAlwaysVisible) {
14
		var p = new dojo.widget.Editor2Plugin.AlwaysShowToolbar(editor);
16
		var p = new dojo.widget.Editor2Plugin.AlwaysShowToolbar(editor);
15
	}
17
	}
16
});
18
});
17
dojo.declare("dojo.widget.Editor2Plugin.AlwaysShowToolbar", null, function (editor) {
19
dojo.declare("dojo.widget.Editor2Plugin.AlwaysShowToolbar", null, function (editor) {
18
	this.editor = editor;
20
	this.editor = editor;
19
	this.editor.registerLoadedPlugin(this);
21
	this.editor.registerLoadedPlugin(this);
20
	this.setup();
22
	this.setup();
21
}, {_scrollSetUp:false, _fixEnabled:false, _scrollThreshold:false, _handleScroll:true, setup:function () {
23
}, {_scrollSetUp:false, _fixEnabled:false, _scrollThreshold:false, _handleScroll:true, setup:function () {
22
	var tdn = this.editor.toolbarWidget;
24
	var tdn = this.editor.toolbarWidget;
23
	if (!tdn.tbBgIframe) {
25
	if (!tdn.tbBgIframe) {
24
		tdn.tbBgIframe = new dojo.html.BackgroundIframe(tdn.domNode);
26
		tdn.tbBgIframe = new dojo.html.BackgroundIframe(tdn.domNode);
25
		tdn.tbBgIframe.onResized();
27
		tdn.tbBgIframe.onResized();
26
	}
28
	}
27
	this.scrollInterval = setInterval(dojo.lang.hitch(this, "globalOnScrollHandler"), 100);
29
	this.scrollInterval = setInterval(dojo.lang.hitch(this, "globalOnScrollHandler"), 100);
28
	dojo.event.connect("before", this.editor.toolbarWidget, "destroy", this, "destroy");
30
	dojo.event.connect("before", this.editor.toolbarWidget, "destroy", this, "destroy");
29
}, globalOnScrollHandler:function () {
31
}, globalOnScrollHandler:function () {
30
	var isIE = dojo.render.html.ie;
32
	var isIE = dojo.render.html.ie;
31
	if (!this._handleScroll) {
33
	if (!this._handleScroll) {
32
		return;
34
		return;
33
	}
35
	}
34
	var dh = dojo.html;
36
	var dh = dojo.html;
35
	var tdn = this.editor.toolbarWidget.domNode;
37
	var tdn = this.editor.toolbarWidget.domNode;
36
	var db = dojo.body();
38
	var db = dojo.body();
37
	if (!this._scrollSetUp) {
39
	if (!this._scrollSetUp) {
38
		this._scrollSetUp = true;
40
		this._scrollSetUp = true;
39
		var editorWidth = dh.getMarginBox(this.editor.domNode).width;
41
		var editorWidth = dh.getMarginBox(this.editor.domNode).width;
40
		this._scrollThreshold = dh.abs(tdn, true).y;
42
		this._scrollThreshold = dh.abs(tdn, true).y;
41
		if ((isIE) && (db) && (dh.getStyle(db, "background-image") == "none")) {
43
		if ((isIE) && (db) && (dh.getStyle(db, "background-image") == "none")) {
42
			with (db.style) {
44
			with (db.style) {
43
				backgroundImage = "url(" + dojo.uri.moduleUri("dojo.widget", "templates/images/blank.gif") + ")";
45
				backgroundImage = "url(" + dojo.uri.moduleUri("dojo.widget", "templates/images/blank.gif") + ")";
44
				backgroundAttachment = "fixed";
46
				backgroundAttachment = "fixed";
45
			}
47
			}
46
		}
48
		}
47
	}
49
	}
48
	var scrollPos = (window["pageYOffset"]) ? window["pageYOffset"] : (document["documentElement"] || document["body"]).scrollTop;
50
	var scrollPos = (window["pageYOffset"]) ? window["pageYOffset"] : (document["documentElement"] || document["body"]).scrollTop;
49
	if (scrollPos > this._scrollThreshold) {
51
	if (scrollPos > this._scrollThreshold) {
50
		if (!this._fixEnabled) {
52
		if (!this._fixEnabled) {
51
			var tdnbox = dojo.html.getMarginBox(tdn);
53
			var tdnbox = dojo.html.getMarginBox(tdn);
52
			this.editor.editorObject.style.marginTop = tdnbox.height + "px";
54
			this.editor.editorObject.style.marginTop = tdnbox.height + "px";
53
			if (isIE) {
55
			if (isIE) {
54
				tdn.style.left = dojo.html.abs(tdn, dojo.html.boxSizing.MARGIN_BOX).x;
56
				tdn.style.left = dojo.html.abs(tdn, dojo.html.boxSizing.MARGIN_BOX).x;
55
				if (tdn.previousSibling) {
57
				if (tdn.previousSibling) {
56
					this._IEOriginalPos = ["after", tdn.previousSibling];
58
					this._IEOriginalPos = ["after", tdn.previousSibling];
57
				} else {
59
				} else {
58
					if (tdn.nextSibling) {
60
					if (tdn.nextSibling) {
59
						this._IEOriginalPos = ["before", tdn.nextSibling];
61
						this._IEOriginalPos = ["before", tdn.nextSibling];
60
					} else {
62
					} else {
61
						this._IEOriginalPos = ["", tdn.parentNode];
63
						this._IEOriginalPos = ["", tdn.parentNode];
62
					}
64
					}
63
				}
65
				}
64
				dojo.body().appendChild(tdn);
66
				dojo.body().appendChild(tdn);
65
				dojo.html.addClass(tdn, "IEFixedToolbar");
67
				dojo.html.addClass(tdn, "IEFixedToolbar");
66
			} else {
68
			} else {
67
				with (tdn.style) {
69
				with (tdn.style) {
68
					position = "fixed";
70
					position = "fixed";
69
					top = "0px";
71
					top = "0px";
70
				}
72
				}
71
			}
73
			}
72
			tdn.style.width = tdnbox.width + "px";
74
			tdn.style.width = tdnbox.width + "px";
73
			tdn.style.zIndex = 1000;
75
			tdn.style.zIndex = 1000;
74
			this._fixEnabled = true;
76
			this._fixEnabled = true;
75
		}
77
		}
76
		if (!dojo.render.html.safari) {
78
		if (!dojo.render.html.safari) {
77
			var eHeight = (this.height) ? parseInt(this.editor.height) : this.editor._lastHeight;
79
			var eHeight = (this.height) ? parseInt(this.editor.height) : this.editor._lastHeight;
78
			if (scrollPos > (this._scrollThreshold + eHeight)) {
80
			if (scrollPos > (this._scrollThreshold + eHeight)) {
79
				tdn.style.display = "none";
81
				tdn.style.display = "none";
80
			} else {
82
			} else {
81
				tdn.style.display = "";
83
				tdn.style.display = "";
82
			}
84
			}
83
		}
85
		}
84
	} else {
86
	} else {
85
		if (this._fixEnabled) {
87
		if (this._fixEnabled) {
86
			(this.editor.object || this.editor.iframe).style.marginTop = null;
88
			(this.editor.object || this.editor.iframe).style.marginTop = null;
87
			with (tdn.style) {
89
			with (tdn.style) {
88
				position = "";
90
				position = "";
89
				top = "";
91
				top = "";
90
				zIndex = "";
92
				zIndex = "";
91
				display = "";
93
				display = "";
92
			}
94
			}
93
			if (isIE) {
95
			if (isIE) {
94
				tdn.style.left = "";
96
				tdn.style.left = "";
95
				dojo.html.removeClass(tdn, "IEFixedToolbar");
97
				dojo.html.removeClass(tdn, "IEFixedToolbar");
96
				if (this._IEOriginalPos) {
98
				if (this._IEOriginalPos) {
97
					dojo.html.insertAtPosition(tdn, this._IEOriginalPos[1], this._IEOriginalPos[0]);
99
					dojo.html.insertAtPosition(tdn, this._IEOriginalPos[1], this._IEOriginalPos[0]);
98
					this._IEOriginalPos = null;
100
					this._IEOriginalPos = null;
99
				} else {
101
				} else {
100
					dojo.html.insertBefore(tdn, this.editor.object || this.editor.iframe);
102
					dojo.html.insertBefore(tdn, this.editor.object || this.editor.iframe);
101
				}
103
				}
102
			}
104
			}
103
			tdn.style.width = "";
105
			tdn.style.width = "";
104
			this._fixEnabled = false;
106
			this._fixEnabled = false;
105
		}
107
		}
106
	}
108
	}
107
}, destroy:function () {
109
}, destroy:function () {
108
	this._IEOriginalPos = null;
110
	this._IEOriginalPos = null;
109
	this._handleScroll = false;
111
	this._handleScroll = false;
110
	clearInterval(this.scrollInterval);
112
	clearInterval(this.scrollInterval);
111
	this.editor.unregisterLoadedPlugin(this);
113
	this.editor.unregisterLoadedPlugin(this);
112
	if (dojo.render.html.ie) {
114
	if (dojo.render.html.ie) {
113
		dojo.html.removeClass(this.editor.toolbarWidget.domNode, "IEFixedToolbar");
115
		dojo.html.removeClass(this.editor.toolbarWidget.domNode, "IEFixedToolbar");
114
	}
116
	}
115
}});
117
}});
116
 
118