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.ResizeHandle");
13
dojo.provide("dojo.widget.ResizeHandle");
12
dojo.require("dojo.widget.*");
14
dojo.require("dojo.widget.*");
13
dojo.require("dojo.html.layout");
15
dojo.require("dojo.html.layout");
14
dojo.require("dojo.event.*");
16
dojo.require("dojo.event.*");
15
dojo.widget.defineWidget("dojo.widget.ResizeHandle", dojo.widget.HtmlWidget, {targetElmId:"", templateCssString:".dojoHtmlResizeHandle {\n\tfloat: right;\n\tposition: absolute;\n\tright: 2px;\n\tbottom: 2px;\n\twidth: 13px;\n\theight: 13px;\n\tz-index: 20;\n\tcursor: nw-resize;\n\tbackground-image: url(grabCorner.gif);\n\tline-height: 0px;\n}\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/ResizeHandle.css"), templateString:"<div class=\"dojoHtmlResizeHandle\"><div></div></div>", postCreate:function () {
17
dojo.widget.defineWidget("dojo.widget.ResizeHandle", dojo.widget.HtmlWidget, {targetElmId:"", templateCssString:".dojoHtmlResizeHandle {\n\tfloat: right;\n\tposition: absolute;\n\tright: 2px;\n\tbottom: 2px;\n\twidth: 13px;\n\theight: 13px;\n\tz-index: 20;\n\tcursor: nw-resize;\n\tbackground-image: url(grabCorner.gif);\n\tline-height: 0px;\n}\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/ResizeHandle.css"), templateString:"<div class=\"dojoHtmlResizeHandle\"><div></div></div>", postCreate:function () {
16
	dojo.event.connect(this.domNode, "onmousedown", this, "_beginSizing");
18
	dojo.event.connect(this.domNode, "onmousedown", this, "_beginSizing");
17
}, _beginSizing:function (e) {
19
}, _beginSizing:function (e) {
18
	if (this._isSizing) {
20
	if (this._isSizing) {
19
		return false;
21
		return false;
20
	}
22
	}
21
	this.targetWidget = dojo.widget.byId(this.targetElmId);
23
	this.targetWidget = dojo.widget.byId(this.targetElmId);
22
	this.targetDomNode = this.targetWidget ? this.targetWidget.domNode : dojo.byId(this.targetElmId);
24
	this.targetDomNode = this.targetWidget ? this.targetWidget.domNode : dojo.byId(this.targetElmId);
23
	if (!this.targetDomNode) {
25
	if (!this.targetDomNode) {
24
		return;
26
		return;
25
	}
27
	}
26
	this._isSizing = true;
28
	this._isSizing = true;
27
	this.startPoint = {"x":e.clientX, "y":e.clientY};
29
	this.startPoint = {"x":e.clientX, "y":e.clientY};
28
	var mb = dojo.html.getMarginBox(this.targetDomNode);
30
	var mb = dojo.html.getMarginBox(this.targetDomNode);
29
	this.startSize = {"w":mb.width, "h":mb.height};
31
	this.startSize = {"w":mb.width, "h":mb.height};
30
	dojo.event.kwConnect({srcObj:dojo.body(), srcFunc:"onmousemove", targetObj:this, targetFunc:"_changeSizing", rate:25});
32
	dojo.event.kwConnect({srcObj:dojo.body(), srcFunc:"onmousemove", targetObj:this, targetFunc:"_changeSizing", rate:25});
31
	dojo.event.connect(dojo.body(), "onmouseup", this, "_endSizing");
33
	dojo.event.connect(dojo.body(), "onmouseup", this, "_endSizing");
32
	e.preventDefault();
34
	e.preventDefault();
33
}, _changeSizing:function (e) {
35
}, _changeSizing:function (e) {
34
	try {
36
	try {
35
		if (!e.clientX || !e.clientY) {
37
		if (!e.clientX || !e.clientY) {
36
			return;
38
			return;
37
		}
39
		}
38
	}
40
	}
39
	catch (e) {
41
	catch (e) {
40
		return;
42
		return;
41
	}
43
	}
42
	var dx = this.startPoint.x - e.clientX;
44
	var dx = this.startPoint.x - e.clientX;
43
	var dy = this.startPoint.y - e.clientY;
45
	var dy = this.startPoint.y - e.clientY;
44
	var newW = this.startSize.w - dx;
46
	var newW = this.startSize.w - dx;
45
	var newH = this.startSize.h - dy;
47
	var newH = this.startSize.h - dy;
46
	if (this.minSize) {
48
	if (this.minSize) {
47
		var mb = dojo.html.getMarginBox(this.targetDomNode);
49
		var mb = dojo.html.getMarginBox(this.targetDomNode);
48
		if (newW < this.minSize.w) {
50
		if (newW < this.minSize.w) {
49
			newW = mb.width;
51
			newW = mb.width;
50
		}
52
		}
51
		if (newH < this.minSize.h) {
53
		if (newH < this.minSize.h) {
52
			newH = mb.height;
54
			newH = mb.height;
53
		}
55
		}
54
	}
56
	}
55
	if (this.targetWidget) {
57
	if (this.targetWidget) {
56
		this.targetWidget.resizeTo(newW, newH);
58
		this.targetWidget.resizeTo(newW, newH);
57
	} else {
59
	} else {
58
		dojo.html.setMarginBox(this.targetDomNode, {width:newW, height:newH});
60
		dojo.html.setMarginBox(this.targetDomNode, {width:newW, height:newH});
59
	}
61
	}
60
	e.preventDefault();
62
	e.preventDefault();
61
}, _endSizing:function (e) {
63
}, _endSizing:function (e) {
62
	dojo.event.disconnect(dojo.body(), "onmousemove", this, "_changeSizing");
64
	dojo.event.disconnect(dojo.body(), "onmousemove", this, "_changeSizing");
63
	dojo.event.disconnect(dojo.body(), "onmouseup", this, "_endSizing");
65
	dojo.event.disconnect(dojo.body(), "onmouseup", this, "_endSizing");
64
	this._isSizing = false;
66
	this._isSizing = false;
65
}});
67
}});
66
 
68