/usr/share/GNUstep/SOGo/WebServerResources/SOGoDragHandles.js is in sogo-common 2.1.1b-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | /* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Drag handle widget interface to be added to a DIV (the drag handle)
*
* Available events:
* handle:dragged -- fired once the handle has been dropped
*
*/
var SOGoDragHandlesInterface = {
leftMargin: 180,
topMargin: 180,
dhType: null,
dhLimit: -1,
origX: -1,
origLeft: -1,
origRight: -1,
origY: -1,
origUpper: -1,
origLower: -1,
delta: -1,
btn: null,
leftBlock: null,
rightBlock: null,
upperBlock: null,
lowerBlock: null,
rightSafetyBlock: null,
startHandleDraggingBound: null,
stopHandleDraggingBound: null,
moveBound: null,
delayedSave: null,
bind: function () {
this.startHandleDraggingBound = this.startHandleDragging.bindAsEventListener(this);
this.observe("mousedown", this.startHandleDraggingBound, false);
},
enableRightSafety: function () {
this.rightSafetyBlock = new Element('div', {'class': 'safetyBlock'});
this.rightSafetyBlock.hide();
document.body.appendChild(this.rightSafetyBlock);
},
adjust: function () {
if (!this.dhType)
this._determineType();
if (this.dhType == 'horizontal') {
this.dhLimit = window.width() - 20;
if (parseInt(this.getStyle("left")) > this.dhLimit) {
this.setStyle({ left: this.dhLimit + "px" });
this.rightBlock.setStyle({ left: (this.dhLimit) + 'px' });
this.leftBlock.setStyle({ width: (this.dhLimit) + 'px' });
if (this.delayedSave) window.clearTimeout(this.delayedSave);
this.delayedSave = this.saveDragHandleState.delay(3, this.dhType, this.dhLimit, this.saveDragHandleStateCallback);
}
}
else if (this.dhType == 'vertical') {
var windowHeight = window.height();
this.dhLimit = windowHeight - 20 - this.upperBlock.cumulativeOffset().top + this.upperBlock.offsetTop;
if (parseInt(this.getStyle("top")) > this.dhLimit &&
windowHeight > this.topMargin) {
this.setStyle({ top: this.dhLimit + 'px' });
this.lowerBlock.setStyle({ top: this.dhLimit + 'px' });
this.upperBlock.setStyle({ height: (this.dhLimit - this.upperBlock.offsetTop) + 'px' });
if (this.delayedSave) window.clearTimeout(this.delayedSave);
this.delayedSave = this.saveDragHandleState.delay(3, this.dhType, this.dhLimit, this.saveDragHandleStateCallback);
}
}
},
_determineType: function () {
if (this.leftBlock && this.rightBlock)
this.dhType = 'horizontal';
else if (this.upperBlock && this.lowerBlock)
this.dhType = 'vertical';
},
startHandleDragging: function (event) {
this.btn = event.button;
if (!this.dhType)
this._determineType();
var targ = getTarget(event);
if (targ.nodeType == 1) {
if (this.dhType == 'horizontal') {
this.dhLimit = window.width() - 20;
this.origX = this.offsetLeft;
this.origLeft = this.leftBlock.offsetWidth;
this.delta = 0;
this.origRight = this.rightBlock.offsetLeft - 5;
document.body.setStyle({ cursor: "e-resize" });
if (this.rightSafetyBlock) {
this.rightSafetyBlock.setStyle({
top: this.rightBlock.getStyle('top'),
left: this.rightBlock.getStyle('left') });
this.rightSafetyBlock.show();
}
} else if (this.dhType == 'vertical') {
this.dhLimit = window.height() - 20;
this.origY = this.offsetTop;
this.origUpper = this.upperBlock.offsetHeight;
var pointY = Event.pointerY(event);
this.delta = pointY - this.offsetTop - 5;
this.origLower = this.lowerBlock.offsetTop - 5;
document.body.setStyle({ cursor: "n-resize" });
}
this.stopHandleDraggingBound = this.stopHandleDragging.bindAsEventListener(this);
if (Prototype.Browser.IE)
Event.observe(document.body, "mouseup", this.stopHandleDraggingBound);
else
Event.observe(window, "mouseup", this.stopHandleDraggingBound);
this.moveBound = this.move.bindAsEventListener(this);
Event.observe(document.body, "mousemove", this.moveBound);
this.move(event);
}
return false;
},
stopHandleDragging: function (event) {
if (!this.dhType)
this._determineType();
if (this.dhType == 'horizontal') {
var pointerX = Event.pointerX(event);
if (pointerX <= this.leftMargin) {
this.rightBlock.setStyle({ left: (this.leftMargin) + 'px' });
this.leftBlock.setStyle({ width: (this.leftMargin) + 'px' });
}
else if (pointerX >= this.dhLimit) {
this.rightBlock.setStyle({ left: (this.dhLimit) + 'px' });
this.leftBlock.setStyle({ width: (this.dhLimit) + 'px' });
}
else {
var deltaX = Math.floor(pointerX - this.origX - (this.offsetWidth / 2));
this.rightBlock.setStyle({ left: (this.origRight + deltaX) + 'px' });
this.leftBlock.setStyle({ width: (this.origLeft + deltaX) + 'px' });
}
this.saveDragHandleState(this.dhType, parseInt(this.leftBlock.getStyle("width")));
if (this.rightSafetyBlock)
this.rightSafetyBlock.hide();
}
else if (this.dhType == 'vertical') {
var pointerY = Event.pointerY(event);
var deltaY;
if (pointerY <= this.topMargin)
deltaY = Math.floor(this.topMargin - this.origY - (this.offsetHeight / 2));
else if (pointerY >= this.dhLimit)
deltaY = Math.floor(this.dhLimit - this.origY - (this.offsetHeight / 2));
else
deltaY = Math.floor(pointerY - this.origY - (this.offsetHeight / 2));
this.lowerBlock.setStyle({ top: (this.origLower + deltaY - this.delta) + 'px' });
this.upperBlock.setStyle({ height: (this.origUpper + deltaY - this.delta) + 'px' });
this.saveDragHandleState(this.dhType, parseInt(this.lowerBlock.getStyle("top")));
}
if (Prototype.Browser.IE)
Event.stopObserving(document.body, "mouseup", this.stopHandleDraggingBound);
else
Event.stopObserving(window, "mouseup", this.stopHandleDraggingBound);
Event.stopObserving(document.body, "mousemove", this.moveBound);
document.body.setAttribute('style', '');
document.body.setStyle({ cursor: "default" });
this.fire("handle:dragged");
Event.stop(event);
},
move: function (event) {
if (!this.dhType)
this._determineType();
if (this.dhType == 'horizontal') {
var hX = Event.pointerX(event);
var width = this.offsetWidth;
if (hX < this.leftMargin)
hX = this.leftMargin + Math.floor(width / 2);
else if (hX > this.dhLimit)
hX = this.dhLimit + Math.floor(width / 2);
var newLeft = Math.floor(hX - (width / 2));
this.setStyle({ left: newLeft + 'px' });
} else if (this.dhType == 'vertical') {
var hY = Event.pointerY(event);
var height = this.offsetHeight;
if (hY < this.topMargin)
hY = this.topMargin;
else if (hY > this.dhLimit)
hY = this.dhLimit;
var newTop = Math.floor(hY - (height / 2)) - this.delta;
this.setStyle({ top: newTop + 'px' });
}
Event.stop(event);
if (Prototype.Browser.IE && event.button != this.btn)
this.stopHandleDragging(event);
},
saveDragHandleState: function (type, position, fcn) {
if (!$(document.body).hasClassName("popup")) {
var urlstr = ApplicationBaseURL + "saveDragHandleState"
+ "?" + type + "=" + position;
var callbackFunction = fcn || this.saveDragHandleStateCallback;
triggerAjaxRequest(urlstr, callbackFunction);
}
},
saveDragHandleStateCallback: function (http) {
if (isHttpStatus204(http.status)) {
log ("Drag handle state saved");
}
else if (http.readyState == 4) {
log ("Can't save handle state");
}
}
};
|