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.widget.ResizeHandle");
14
dojo.require("dojo.widget.*");
15
dojo.require("dojo.html.layout");
16
dojo.require("dojo.event.*");
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 () {
18
	dojo.event.connect(this.domNode, "onmousedown", this, "_beginSizing");
19
}, _beginSizing:function (e) {
20
	if (this._isSizing) {
21
		return false;
22
	}
23
	this.targetWidget = dojo.widget.byId(this.targetElmId);
24
	this.targetDomNode = this.targetWidget ? this.targetWidget.domNode : dojo.byId(this.targetElmId);
25
	if (!this.targetDomNode) {
26
		return;
27
	}
28
	this._isSizing = true;
29
	this.startPoint = {"x":e.clientX, "y":e.clientY};
30
	var mb = dojo.html.getMarginBox(this.targetDomNode);
31
	this.startSize = {"w":mb.width, "h":mb.height};
32
	dojo.event.kwConnect({srcObj:dojo.body(), srcFunc:"onmousemove", targetObj:this, targetFunc:"_changeSizing", rate:25});
33
	dojo.event.connect(dojo.body(), "onmouseup", this, "_endSizing");
34
	e.preventDefault();
35
}, _changeSizing:function (e) {
36
	try {
37
		if (!e.clientX || !e.clientY) {
38
			return;
39
		}
40
	}
41
	catch (e) {
42
		return;
43
	}
44
	var dx = this.startPoint.x - e.clientX;
45
	var dy = this.startPoint.y - e.clientY;
46
	var newW = this.startSize.w - dx;
47
	var newH = this.startSize.h - dy;
48
	if (this.minSize) {
49
		var mb = dojo.html.getMarginBox(this.targetDomNode);
50
		if (newW < this.minSize.w) {
51
			newW = mb.width;
52
		}
53
		if (newH < this.minSize.h) {
54
			newH = mb.height;
55
		}
56
	}
57
	if (this.targetWidget) {
58
		this.targetWidget.resizeTo(newW, newH);
59
	} else {
60
		dojo.html.setMarginBox(this.targetDomNode, {width:newW, height:newH});
61
	}
62
	e.preventDefault();
63
}, _endSizing:function (e) {
64
	dojo.event.disconnect(dojo.body(), "onmousemove", this, "_changeSizing");
65
	dojo.event.disconnect(dojo.body(), "onmouseup", this, "_endSizing");
66
	this._isSizing = false;
67
}});
68