1 var SOGoDragHandlesInterface = {
15 this.addEventListener("mousedown", this.startHandleDragging, false);
17 _determineType: function () {
18 if (this.leftBlock && this.rightBlock)
19 this.dhType = 'horizontal';
20 else if (this.upperBlock && this.lowerBlock)
21 this.dhType = 'vertical';
23 startHandleDragging: function (event) {
25 this._determineType();
26 if (event.button == 0) {
27 if (this.dhType == 'horizontal') {
28 this.origX = this.offsetLeft;
29 this.origLeft = this.leftBlock.offsetWidth;
31 this.origRight = this.rightBlock.offsetLeft - 5;
32 document.body.style.cursor = "e-resize";
33 } else if (this.dhType == 'vertical') {
34 this.origY = this.offsetTop;
35 this.origUpper = this.upperBlock.offsetHeight;
36 delta = event.clientY - this.offsetTop - 5;
37 this.origLower = this.lowerBlock.offsetTop - 5;
38 document.body.style.cursor = "n-resize";
40 document._currentDragHandle = this;
41 document.addEventListener("mouseup", this.documentStopHandleDragging, true);
42 document.addEventListener("mousemove", this.documentMove, true);
44 event.cancelBubble = true;
49 documentStopHandleDragging: function (event) {
50 var handle = document._currentDragHandle;
51 return handle.stopHandleDragging(event);
53 documentMove: function (event) {
54 var handle = document._currentDragHandle;
55 return handle.move(event);
57 stopHandleDragging: function (event) {
59 this._determineType();
60 if (this.dhType == 'horizontal') {
62 = Math.floor(event.clientX - this.origX - (this.offsetWidth / 2));
63 this.rightBlock.style.left = (this.origRight + deltaX) + 'px;';
64 this.leftBlock.style.width = (this.origLeft + deltaX) + 'px;';
65 } else if (this.dhType == 'vertical') {
67 = Math.floor(event.clientY - this.origY - (this.offsetHeight / 2));
68 this.lowerBlock.style.top = (this.origLower + deltaY - delta) + 'px;';
69 this.upperBlock.style.height = (this.origUpper + deltaY - delta) + 'px;';
72 document.removeEventListener("mouseup", this.documentStopHandleDragging, true);
73 document.removeEventListener("mousemove", this.documentMove, true);
74 document.body.setAttribute('style', '');
77 document._currentDragHandle = null;
78 event.cancelBubble = true;
82 move: function (event) {
84 this._determineType();
85 if (this.dhType == 'horizontal') {
86 var width = this.offsetWidth;
87 var hX = event.clientX;
89 var newLeft = Math.floor(hX - (width / 2));
90 this.style.left = newLeft + 'px;';
91 event.cancelBubble = true;
95 } else if (this.dhType == 'vertical') {
96 var height = this.offsetHeight;
97 var hY = event.clientY;
99 var newTop = Math.floor(hY - (height / 2)) - delta;
100 this.style.top = newTop + 'px;';
101 event.cancelBubble = true;
107 doubleClick: function (event) {
109 this._determineType();
110 if (this.dhType == 'horizontal') {
111 var lLeft = this.leftBlock.offsetLeft;
113 if (this.offsetLeft > lLeft) {
114 var leftdelta = this.rightBlock.offsetLeft - this.offsetLeft;
116 this.style.left = lLeft + 'px;';
117 this.leftBlock.style.width = '0px';
118 this.rightBlock.style.left = (lLeft + leftdelta) + 'px;';
120 } else if (this.dhType == 'vertical') {
121 var uTop = this.upperBlock.offsetTop;
123 if (this.offsetTop > uTop) {
124 var topdelta = this.lowerBlock.offsetTop - this.offsetTop;
126 this.style.top = uTop + 'px;';
127 this.upperBlock.style.width = '0px';
128 this.lowerBlock.style.top = (uTop + topdelta) + 'px;';