25
37
this.is_moved = false;
26
38
this.is_resized = false;
45
this.ctrl_min = false;
47
this.allow_move = true;
48
this.allow_resize = true;
49
this.allow_resize_e = true;
50
this.allow_resize_w = true;
51
this.allow_resize_n = true;
52
this.allow_resize_s = true;
55
DIALOG_DRAGGER.prototype.RegisterCallbacks = function(cb_start, cb_step, cb_done, cbattr) {
56
this.cb_start = cb_start;
57
this.cb_step = cb_step;
58
this.cb_end = cb_done;
59
this.cb_attr = cbattr;
62
DIALOG_DRAGGER.prototype.ControlMinimumSize = function(min_width, min_height) {
63
if ((Prototype.Browser.Gecko)&&(domGetStyleProp(this.dialog.node, this.dialog.node.style.minWidth, "min-width"))) {
65
this.min_width = min_width;
66
this.min_height = min_height;
70
DIALOG_DRAGGER.prototype.Disable = function(move, resize) {
71
if (!move) this.allow_move = false;
72
if (typeof resize == "string") {
73
if (resize.indexOf('n') >= 0) this.allow_resize_n = false;
74
if (resize.indexOf('s') >= 0) this.allow_resize_s = false;
75
if (resize.indexOf('w') >= 0) this.allow_resize_w = false;
76
if (resize.indexOf('e') >= 0) this.allow_resize_e = false;
77
} else if (!resize) this.allow_resize = false;
30
80
DIALOG_DRAGGER.prototype.Setup = function() {
31
// IE7 :) needs it to adjust widths of sub-divs
32
domSetWidth(this.dialog.node, this.dialog.node.offsetWidth);
81
if (this.dialog.content) {
82
// IE7 and not only :) needs it to adjust widths of sub-divs
83
domSetWidth(this.dialog.node, this.dialog.node.offsetWidth);
34
85
// IE6 :) fixing size for iframes
35
if (this.dialog.iframe) {
36
this.SaveDimenssions();
41
Event.observe(this.dialog.maximize_node, 'click', this.MaximizeBind );
86
if (this.dialog.iframe) {
87
this.SaveDimenssions();
92
if (this.dialog.maximize_node)
93
Event.observe(this.dialog.maximize_node, 'click', this.MaximizeBind );
95
if ((this.allow_move)&&(this.dialog.titlebar))
96
Event.observe(this.dialog.titlebar, 'mousedown', this.MoveBind );
98
if (this.allow_resize)
99
Event.observe(this.dialog.node, 'mousedown', this.ResizeBind );
42
101
Event.observe(this.dialog.node, 'mousemove', this.MouseMoveBind );
43
102
Event.observe(this.dialog.node, 'mouseout', this.MouseOutBind );
44
Event.observe(this.dialog.node, 'mousedown', this.ResizeBind );
45
Event.observe(this.dialog.titlebar, 'mousedown', this.MoveBind );
51
105
DIALOG_DRAGGER.prototype.Clean = function() {
52
Event.stopObserving(this.dialog.maximize_node, 'click', this.MaximizeBind );
106
if (this.dialog.maximize_node)
107
Event.stopObserving(this.dialog.maximize_node, 'click', this.MaximizeBind );
109
if ((this.allow_move)&&(this.dialog.titlebar))
110
Event.stopObserving(this.dialog.titlebar, 'mousedown', this.MoveBind );
112
if (this.allow_resize)
113
Event.stopObserving(this.dialog.node, 'mousedown', this.ResizeBind );
53
115
Event.stopObserving(this.dialog.node, 'mousemove', this.MouseMoveBind );
54
116
Event.stopObserving(this.dialog.node, 'mouseout', this.MouseOutBind );
55
Event.stopObserving(this.dialog.node, 'mousedown', this.ResizeBind );
56
Event.stopObserving(this.dialog.titlebar, 'mousedown', this.MoveBind );
59
119
DIALOG_DRAGGER.prototype.MouseMove = function(ev) {
65
125
this.dialog.node.style.cursor = "";
69
129
var width = this.dialog.node.offsetWidth;
70
130
var height = this.dialog.node.offsetHeight;
72
132
var offset = domGetEventLayerOffset(ev);
73
134
var xOff = offset[0];
74
135
var yOff = offset[1];
137
if (!this.float_mode) {
138
var node_offset = domGetNodeOffset(this.dialog.node);
139
xOff -= node_offset[0];
140
yOff -= node_offset[1];
76
143
var resizeDirection = ""
77
if (yOff < this.resizeCornerSize)
144
if ((this.allow_resize_n)&&(yOff < this.resizeCornerSize))
78
145
resizeDirection += "n";
79
else if (yOff > (height - this.resizeCornerSize))
146
else if ((this.allow_resize_s)&&(yOff > (height - this.resizeCornerSize)))
80
147
resizeDirection += "s";
81
if (xOff < this.resizeCornerSize)
148
if ((this.allow_resize_w)&&(xOff < this.resizeCornerSize))
82
149
resizeDirection += "w";
83
else if (xOff > (width - this.resizeCornerSize))
150
else if ((this.allow_resize_e)&&(xOff > (width - this.resizeCornerSize)))
84
151
resizeDirection += "e";
86
153
if (resizeDirection) {
131
197
this.corr_x = csize[0] - size[0];
132
198
this.corr_y = csize[1] - size[1];
135
200
this.oldWidth = size[0] - this.corr_x;//parseInt(domGetStyleProp(node, node.style.width, "width"), 10);
136
201
this.oldHeight = size[1] - this.corr_y;//parseInt(domGetStyleProp(node, node.style.height, "height"), 10);
138
203
node.style.width = this.oldWidth + "px";
139
204
node.style.height = this.oldHeight + "px";
141
// Obtaining content element size
142
size = domGetNodeSize(mnode);
207
node.style.minWidth = this.min_width + "px";
208
node.style.minHeight = this.min_height + "px";
211
if (this.dialog.content) {
212
var mnode = this.dialog.content;
213
// Obtaining content element size
214
size = domGetNodeSize(mnode);
144
216
// mnode.style.width = size[0] + "px";
145
mnode.style.height = size[1] + "px";
217
mnode.style.height = size[1] + "px";
147
var csize = domGetNodeSize(mnode);
219
var csize = domGetNodeSize(mnode);
148
220
// this.corr_cx = csize[0] - size[0];
149
this.corr_cy = csize[1] - size[1];
221
this.corr_cy = csize[1] - size[1];
151
223
// this.cWidth = size[0] - this.corr_cx;
152
this.cHeight = size[1] - this.corr_cy;
224
this.cHeight = size[1] - this.corr_cy;
154
226
// mnode.style.width = this.cWidth + "px";
155
mnode.style.height = this.cHeight + "px";
227
mnode.style.height = this.cHeight + "px";
158
231
DIALOG_DRAGGER.prototype.Resize = function(ev) {
159
232
var target = domGetEventTarget(ev);
160
233
if (target != this.dialog.node) return;
162
235
var node = this.dialog.node;
163
var lnode = this.dialog.titlebar;
165
237
Event.observe(document, 'mousemove', this.TrackBind );
166
238
Event.observe(document, 'mouseup', this.DoneBind );
168
240
this.in_resize = true;
170
242
// If max-height not supported set titlebar height
171
var tb = this.dialog.titlebar;
172
var mh = parseInt(domGetStyleProp(tb, tb.style.maxHeight, "max-height"),10);
173
if ((!mh)||((tb.offsetHeight - mh)>10)) {
174
domSetWidth(node, node.offsetWidth);
175
if (mh>0) domSetHeight(tb, mh);
176
else domSetHeight(tb, 21);
243
if (this.dialog.titlebar) {
244
var tb = this.dialog.titlebar;
245
var mh = parseInt(domGetStyleProp(tb, tb.style.maxHeight, "max-height"),10);
246
if ((!mh)||((tb.offsetHeight - mh)>10)) {
247
domSetWidth(node, node.offsetWidth);
248
if (mh>0) domSetHeight(tb, mh);
249
else domSetHeight(tb, 21);
179
if (!this.label_width) {
180
this.label_width = this.dialog.label.offsetWidth + this.dialog.label.offsetLeft;
253
if (this.dialog.label) {
254
if (!this.label_width) {
255
this.label_width = this.dialog.label.offsetWidth + this.dialog.label.offsetLeft;
183
259
var offset = domGetEventPageOffset(ev);
184
260
this.xPosition = offset[0];
185
261
this.yPosition = offset[1];
187
263
this.SaveDimenssions();
189
265
// Obtaining titlebar size (no correction, since preciese size is not important
190
var size = domGetNodeSize(lnode);
191
size[1] += this.corr_y;
192
if ((size[1] + 10) > this.minimumHeight) this.minimumHeight = size[1] + 10;
266
if (this.dialog.titlebar) {
267
var lnode = this.dialog.titlebar;
268
var size = domGetNodeSize(lnode);
269
size[1] += this.corr_y;
270
if ((size[1] + 10) > this.minimumHeight) this.minimumHeight = size[1] + 10;
195
274
DIALOG_DRAGGER.prototype.Restore = function(ev) {
243
321
var east = false;
244
322
var west = false;
246
if (this.resizeDirection.charAt(0) == "n") north = true;
247
if (this.resizeDirection.charAt(0) == "s") south = true;
248
if (this.resizeDirection.charAt(0) == "e" || this.resizeDirection.charAt(1) == "e") east = true;
249
if (this.resizeDirection.charAt(0) == "w" || this.resizeDirection.charAt(1) == "w") west = true;
324
if (this.resizeDirection.charAt(0) == "n") north = this.allow_resize_n;
325
if (this.resizeDirection.charAt(0) == "s") south = this.allow_resize_s;
326
if (this.resizeDirection.charAt(0) == "e" || this.resizeDirection.charAt(1) == "e") east = this.allow_resize_e;
327
if (this.resizeDirection.charAt(0) == "w" || this.resizeDirection.charAt(1) == "w") west = this.allow_resize_w;
251
329
var offset = domGetEventPageOffset(ev);
252
330
var dx = offset[0] - this.xPosition;
284
362
node.style.width = w + "px";
285
363
if (west) node.style.left = (this.oldLeft - dx) + "px";
288
366
if (north || south) {
289
367
node.style.height = h + "px";
290
if ((this.cHeight + dy) < 0) mnode.style.height = 0 + "px";
291
else mnode.style.height = (this.cHeight + dy) + "px";
293
var size = domGetNodeSize(mnode);
294
var rdy = size[1] - this.corr_cy - this.cHeight;
296
node.style.height = (this.oldHeight + rdy) + "px";
369
if (this.dialog.content) {
370
var mnode = this.dialog.content;
371
if ((this.cHeight + dy) < 0) mnode.style.height = 0 + "px";
372
else mnode.style.height = (this.cHeight + dy) + "px";
374
var size = domGetNodeSize(mnode);
375
var rdy = size[1] - this.corr_cy - this.cHeight;
377
node.style.height = (this.oldHeight + rdy) + "px";
300
382
if (north) node.style.top = (this.oldTop - dy) + "px";