Converting the autoscroll code to attach to the browser binding and folding it directly into Firebird. Thanks to the folks at autoscroll.mozdev.org for providing this great functionality!

This commit is contained in:
blakeross%telocity.com 2003-07-04 05:02:35 +00:00
Родитель 0c5dc097d7
Коммит d7e6606ca5
5 изменённых файлов: 147 добавлений и 0 удалений

Просмотреть файл

@ -239,6 +239,20 @@
</field>
<field name="_mStrBundle">null</field>
<field name="_AUTOSCROLL_SPEED">3</field>
<field name="_AUTOSCROLL_SNAP">10</field>
<field name="_clientFrameDoc">null</field>
<field name="_clientFrameBody">null</field>
<field name="_isScrolling">false</field>
<field name="_hasScrolled">false</field>
<field name="_autoScrollMarkerImage">null</field>
<field name="_overlayContainer">null</field>
<field name="_snapOn">false</field>
<field name="_scrollCount">0</field>
<field name="_startX">null</field>
<field name="_startY">null</field>
<field name="_clientX">null</field>
<field name="_clientY">null</field>
<property name="mStrBundle">
<getter>
@ -436,6 +450,48 @@
]]>
</body>
</method>
<method name="stopScroll">
<body>
<![CDATA[
this._isScrolling = false;
if (this._autoScrollMarkerImage) {
this._autoScrollMarkerImage.style.display = 'none'; // seems to avoid blocking when autoscroll is initited during pageload
this._autoScrollMarkerImage.parentNode.removeChild(this._autoScrollMarkerImage);
}
if (this._overlayContainer) {
this._overlayContainer.style.display = 'none';
this._overlayContainer.parentNode.removeChild(this._overlayContainer);
}
this._overlayContainer = null;
this._autoScrollMarkerImage = null;
]]>
</body>
</method>
<method name="autoScrollLoop">
<body>
<![CDATA[
if (this._isScrolling) {
var x = (this._clientX - this._startX) / this._AUTOSCROLL_SPEED;
var y = (this._clientY - this._startY) / this._AUTOSCROLL_SPEED;
if(Math.abs(x) > 0 && Math.abs(y) > 0)
{
if (this._scrollCount++ % 2)
y = 0;
else
x = 0;
}
this._clientFrameDoc.defaultView.scrollBy(x, y);
setTimeout(function foo(a) { a.autoScrollLoop() }, 5, this);
}
]]>
</body>
</method>
</implementation>
<handlers>
@ -485,6 +541,94 @@
}
]]>
</handler>
<handler event="mouseup">
<![CDATA[
if (!this._snapOn)
this.stopScroll();
]]>
</handler>
<handler event="mousedown" button="1">
<![CDATA[
if (!this._isScrolling) {
this._startX = event.clientX;
this._startY = event.clientY;
this._clientFrameDoc = event.originalTarget.ownerDocument;
this._clientFrameBody = (this._clientFrameDoc.getElementsByTagName('body')[0]) ? this._clientFrameDoc.getElementsByTagName('body')[0] : this._clientFrameDoc.getElementsByTagName('*')[0];
this._isScrolling = true;
this._hasScrolled = true;
this._snapOn = true;
var scrollCursor = new Array("move", "n-resize", "e-resize");
var docBox = this._clientFrameDoc.getBoxObjectFor(this._clientFrameDoc.documentElement);
var left = event.screenX - docBox.screenX;
var top = event.screenY - docBox.screenY;
var documentWidth = docBox.width;
var documentHeight = docBox.height;
var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
var scrollType = 0;
if (windowHeight < documentHeight && windowWidth >= documentWidth)
scrollType = 1;
else if (windowHeight >= documentHeight && windowWidth < documentWidth)
scrollType = 2;
var imageWidth = 28;
var imageHeight = 28;
// overlay
var el = this._clientFrameDoc.createElementNS("http://www.w3.org/1999/xhtml", "div");
el.style.position = "fixed";
el.style.left = "0px";
el.style.top = "0px";
el.style.width = documentWidth + "px";
el.style.height = documentHeight + "px";
el.style.cursor = scrollCursor[scrollType];
this._clientFrameBody.appendChild(el);
this._overlayContainer = el;
// marker
el = this._clientFrameDoc.createElementNS("http://www.w3.org/1999/xhtml", "img");
var scrollImages = new Array("chrome://global/skin/arrow/autoscroll_all.png",
"chrome://global/skin/arrow/autoscroll_v.png",
"chrome://global/skin/arrow/autoscroll_h.png");
el.src = scrollImages[scrollType];
el.style.position = "fixed";
el.style.left = left - imageWidth / 2 + "px";
el.style.top = top - imageHeight / 2 + "px";
el.style.width = imageWidth + "px";
el.style.height = imageHeight + "px";
el.style.cursor = scrollCursor[scrollType];
this._clientFrameBody.appendChild(el);
this._autoScrollMarkerImage = el;
window.setTimeout(function foo(a) { a.autoScrollLoop() }, 5, this);
}
else if (this._hasScrolled)
stopScroll();
]]>
</handler>
<handler event="mousemove">
<![CDATA[
this._clientX = event.clientX;
this._clientY = event.clientY;
if (this._isScrolling) {
var x = this._clientX - this._startX;
var y = this._clientY - this._startY;
if((x > this._AUTOSCROLL_SNAP || x < -this._AUTOSCROLL_SNAP) || (y > this._AUTOSCROLL_SNAP || y < -this._AUTOSCROLL_SNAP))
this._snapOn = false;
}
]]>
</handler>
</handlers>
</binding>

Двоичные данные
toolkit/skin/win/arrow/autoscroll_all.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.6 KiB

Двоичные данные
toolkit/skin/win/arrow/autoscroll_h.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Двоичные данные
toolkit/skin/win/arrow/autoscroll_v.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Просмотреть файл

@ -49,6 +49,9 @@ classic.jar:
+ skin/classic/global/arrow/arrow-up-hov.gif (arrow/arrow-up-hov.gif)
+ skin/classic/global/arrow/arrow-up-sharp.gif (arrow/arrow-up-sharp.gif)
+ skin/classic/global/arrow/arrow-up.gif (arrow/arrow-up.gif)
+ skin/classic/global/arrow/autoscroll_all.png (arrow/autoscroll_all.png)
+ skin/classic/global/arrow/autoscroll_h.png (arrow/autoscroll_h.png)
+ skin/classic/global/arrow/autoscroll_v.png (arrow/autoscroll_v.png)
+ skin/classic/global/checkbox/cbox-check-dis.gif (checkbox/cbox-check-dis.gif)
+ skin/classic/global/checkbox/cbox-check.gif (checkbox/cbox-check.gif)
+ skin/classic/global/icons/Error.png (icons/Error.png)