Subversion Repositories Applications.papyrus

Rev

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