1 var SOGoDragHandlesInterface = {
14 startHandleDraggingBinded: null,
15 stopHandleDraggingBinded: null,
18 this.startHandleDraggingBound = this.startHandleDragging.bindAsEventListener(this);
19 Event.observe(this, "mousedown", this.startHandleDraggingBound, false);
21 _determineType: function () {
22 if (this.leftBlock && this.rightBlock)
23 this.dhType = 'horizontal';
24 else if (this.upperBlock && this.lowerBlock)
25 this.dhType = 'vertical';
27 startHandleDragging: function (event) {
29 this._determineType();
32 var event = window.event;
35 else if (event.srcElement)
36 targ = event.srcElement
37 if (targ.nodeType == 1) {
38 if (this.dhType == 'horizontal') {
39 this.origX = this.offsetLeft;
40 this.origLeft = this.leftBlock.offsetWidth;
42 this.origRight = this.rightBlock.offsetLeft - 5;
43 document.body.setStyle({ cursor: "e-resize" });
44 } else if (this.dhType == 'vertical') {
45 this.origY = this.offsetTop;
46 this.origUpper = this.upperBlock.offsetHeight;
47 delta = event.clientY - this.offsetTop - 5;
48 this.origLower = this.lowerBlock.offsetTop - 5;
49 document.body.setStyle({ cursor: "n-resize" });
51 this.stopHandleDraggingBound = this.stopHandleDragging.bindAsEventListener(this);
52 Event.observe(document.body, "mouseup", this.stopHandleDraggingBound, true);
53 this.moveBound = this.move.bindAsEventListener(this);
54 Event.observe(document.body, "mousemove", this.moveBound, true);
56 event.cancelBubble = true;
61 stopHandleDragging: function (event) {
63 this._determineType();
64 if (this.dhType == 'horizontal') {
66 = Math.floor(event.clientX - this.origX - (this.offsetWidth / 2));
67 this.rightBlock.setStyle({ left: (this.origRight + deltaX) + 'px' });
68 this.leftBlock.setStyle({ width: (this.origLeft + deltaX) + 'px' });
69 } else if (this.dhType == 'vertical') {
71 = Math.floor(event.clientY - this.origY - (this.offsetHeight / 2));
72 this.lowerBlock.setStyle({ top: (this.origLower + deltaY - delta) + 'px' });
73 this.upperBlock.setStyle({ height: (this.origUpper + deltaY - delta) + 'px' });
76 Event.stopObserving(document.body, "mouseup", this.stopHandleDraggingBound, true);
77 Event.stopObserving(document.body, "mousemove", this.moveBound, true);
79 document.body.setAttribute('style', '');
82 event.cancelBubble = true;
86 move: function (event) {
88 this._determineType();
89 if (this.dhType == 'horizontal') {
90 var width = this.offsetWidth;
91 var hX = event.clientX;
93 var newLeft = Math.floor(hX - (width / 2));
94 this.setStyle({ left: newLeft + 'px' });
95 event.cancelBubble = true;
99 } else if (this.dhType == 'vertical') {
100 var height = this.offsetHeight;
101 var hY = event.clientY;
103 var newTop = Math.floor(hY - (height / 2)) - delta;
104 this.setStyle({ top: newTop + 'px' });
105 event.cancelBubble = true;
111 doubleClick: function (event) {
113 this._determineType();
114 if (this.dhType == 'horizontal') {
115 var lLeft = this.leftBlock.offsetLeft;
117 if (this.offsetLeft > lLeft) {
118 var leftdelta = this.rightBlock.offsetLeft - this.offsetLeft;
120 this.setStyle({ left: lLeft + 'px' });
121 this.leftBlock.setStyle({ width: '0px' });
122 this.rightBlock.setStyle({ left: (lLeft + leftdelta) + 'px' });
124 } else if (this.dhType == 'vertical') {
125 var uTop = this.upperBlock.offsetTop;
127 if (this.offsetTop > uTop) {
128 var topdelta = this.lowerBlock.offsetTop - this.offsetTop;
130 this.setStyle({ top: uTop + 'px' });
131 this.upperBlock.setStyle({ width: '0px' });
132 this.lowerBlock.setStyle({ top: (uTop + topdelta) + 'px' });