1 var SOGoDragHandlesInterface = {
15 this.addEventListener("mousedown", this.startHandleDragging, false);
16 this.onmousedown = function() { return false }
18 _determineType: function () {
19 if (this.leftBlock && this.rightBlock)
20 this.dhType = 'horizontal';
21 else if (this.upperBlock && this.lowerBlock)
22 this.dhType = 'vertical';
24 startHandleDragging: function (event) {
26 this._determineType();
29 var event = window.event;
32 else if (event.srcElement)
33 targ = event.srcElement
34 if (targ.nodeType == 1) {
35 if (this.dhType == 'horizontal') {
36 this.origX = this.offsetLeft;
37 this.origLeft = this.leftBlock.offsetWidth;
39 this.origRight = this.rightBlock.offsetLeft - 5;
40 document.body.style.cursor = "e-resize";
41 } else if (this.dhType == 'vertical') {
42 this.origY = this.offsetTop;
43 this.origUpper = this.upperBlock.offsetHeight;
44 delta = event.clientY - this.offsetTop - 5;
45 this.origLower = this.lowerBlock.offsetTop - 5;
46 document.body.style.cursor = "n-resize";
48 document._currentDragHandle = this;
49 if (document.addEventListener) {
50 document.addEventListener("mouseup", this.documentStopHandleDragging, true);
51 document.addEventListener("mousemove", this.documentMove, true);
52 } else if (window.addEventListener) {
53 window.addEventListener("mouseup", this.documentStopHandleDragging, true);
54 window.addEventListener("mousemove", this.documentMove, true);
57 event.cancelBubble = true;
62 documentStopHandleDragging: function (event) {
63 var handle = document._currentDragHandle;
64 return handle.stopHandleDragging(event);
66 documentMove: function (event) {
67 var handle = document._currentDragHandle;
68 if (!handle) return false;
69 return handle.move(event);
71 stopHandleDragging: function (event) {
73 this._determineType();
74 if (this.dhType == 'horizontal') {
76 = Math.floor(event.clientX - this.origX - (this.offsetWidth / 2));
77 this.rightBlock.style.left = (this.origRight + deltaX) + 'px';
78 this.leftBlock.style.width = (this.origLeft + deltaX) + 'px';
79 } else if (this.dhType == 'vertical') {
81 = Math.floor(event.clientY - this.origY - (this.offsetHeight / 2));
82 this.lowerBlock.style.top = (this.origLower + deltaY - delta) + 'px';
83 this.upperBlock.style.height = (this.origUpper + deltaY - delta) + 'px';
86 if (window.addEventListener) {
87 window.removeEventListener("mouseup", this.documentStopHandleDragging, true);
88 window.removeEventListener("mousemove", this.documentMove, true);
89 } else if (document.addEventListener) {
90 document.removeEventListener("mouseup", this.documentStopHandleDragging, true);
91 document.removeEventListener("mousemove", this.documentMove, true);
93 document.body.setAttribute('style', '');
96 document._currentDragHandle = null;
97 event.cancelBubble = true;
101 move: function (event) {
103 this._determineType();
104 if (this.dhType == 'horizontal') {
105 var width = this.offsetWidth;
106 var hX = event.clientX;
108 var newLeft = Math.floor(hX - (width / 2));
109 this.style.left = newLeft + 'px';
110 event.cancelBubble = true;
114 } else if (this.dhType == 'vertical') {
115 var height = this.offsetHeight;
116 var hY = event.clientY;
118 var newTop = Math.floor(hY - (height / 2)) - delta;
119 this.style.top = newTop + 'px';
120 event.cancelBubble = true;
126 doubleClick: function (event) {
128 this._determineType();
129 if (this.dhType == 'horizontal') {
130 var lLeft = this.leftBlock.offsetLeft;
132 if (this.offsetLeft > lLeft) {
133 var leftdelta = this.rightBlock.offsetLeft - this.offsetLeft;
135 this.style.left = lLeft + 'px';
136 this.leftBlock.style.width = '0px';
137 this.rightBlock.style.left = (lLeft + leftdelta) + 'px';
139 } else if (this.dhType == 'vertical') {
140 var uTop = this.upperBlock.offsetTop;
142 if (this.offsetTop > uTop) {
143 var topdelta = this.lowerBlock.offsetTop - this.offsetTop;
145 this.style.top = uTop + 'px';
146 this.upperBlock.style.width = '0px';
147 this.lowerBlock.style.top = (uTop + topdelta) + 'px';