Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/externals/javelin/lib/Scrollbar.js
| Show All 28 Lines | construct: function(frame) { | ||||
| JX.DOM.listen(frame, 'load', null, JX.bind(this, this._onload)); | JX.DOM.listen(frame, 'load', null, JX.bind(this, this._onload)); | ||||
| this._onload(); | this._onload(); | ||||
| // Before doing anything, check if the scrollbar control has a measurable | // Before doing anything, check if the scrollbar control has a measurable | ||||
| // width. If it doesn't, we're already in an environment with an aesthetic | // width. If it doesn't, we're already in an environment with an aesthetic | ||||
| // scrollbar (like Safari on OSX with no mouse connected, or an iPhone) | // scrollbar (like Safari on OSX with no mouse connected, or an iPhone) | ||||
| // and we don't need to do anything. | // and we don't need to do anything. | ||||
| if (JX.Scrollbar._getScrollbarControlWidth() === 0) { | if (JX.Scrollbar.getScrollbarControlWidth() === 0) { | ||||
| return; | return; | ||||
| } | } | ||||
| // Wrap the frame content in a bunch of nodes. The frame itself stays on | // Wrap the frame content in a bunch of nodes. The frame itself stays on | ||||
| // the outside so that any positioning information the node had isn't | // the outside so that any positioning information the node had isn't | ||||
| // disrupted. | // disrupted. | ||||
| // We put a "viewport" node inside of it, which is what actually scrolls. | // We put a "viewport" node inside of it, which is what actually scrolls. | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | JX.install('Scrollbar', { | ||||
| statics: { | statics: { | ||||
| _controlWidth: null, | _controlWidth: null, | ||||
| /** | /** | ||||
| * Compute the width of the browser's scrollbar control, in pixels. | * Compute the width of the browser's scrollbar control, in pixels. | ||||
| */ | */ | ||||
| _getScrollbarControlWidth: function() { | getScrollbarControlWidth: function() { | ||||
| var self = JX.Scrollbar; | var self = JX.Scrollbar; | ||||
| if (self._controlWidth === null) { | if (self._controlWidth === null) { | ||||
| var tmp = JX.$N('div', {className: 'jx-scrollbar-test'}, '-'); | var tmp = JX.$N('div', {className: 'jx-scrollbar-test'}, '-'); | ||||
| document.body.appendChild(tmp); | document.body.appendChild(tmp); | ||||
| var d1 = JX.Vector.getDim(tmp); | var d1 = JX.Vector.getDim(tmp); | ||||
| tmp.style.overflowY = 'scroll'; | tmp.style.overflowY = 'scroll'; | ||||
| var d2 = JX.Vector.getDim(tmp); | var d2 = JX.Vector.getDim(tmp); | ||||
| Show All 19 Lines | statics: { | ||||
| * | * | ||||
| * @return int Control margin width in pixels. | * @return int Control margin width in pixels. | ||||
| */ | */ | ||||
| getScrollbarControlMargin: function() { | getScrollbarControlMargin: function() { | ||||
| var self = JX.Scrollbar; | var self = JX.Scrollbar; | ||||
| // If this browser and OS don't render a real scrollbar control, we | // If this browser and OS don't render a real scrollbar control, we | ||||
| // need to leave a margin. Generally, this is OSX with no mouse attached. | // need to leave a margin. Generally, this is OSX with no mouse attached. | ||||
| if (self._getScrollbarControlWidth() === 0) { | if (self.getScrollbarControlWidth() === 0) { | ||||
| return 12; | return 12; | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| }, | }, | ||||
| ▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | members: { | ||||
| /** | /** | ||||
| * Shove the scrollbar on the viewport under the edge of the frame so the | * Shove the scrollbar on the viewport under the edge of the frame so the | ||||
| * user can't see it. | * user can't see it. | ||||
| */ | */ | ||||
| _resizeViewport: function() { | _resizeViewport: function() { | ||||
| var fdim = JX.Vector.getDim(this._frame); | var fdim = JX.Vector.getDim(this._frame); | ||||
| fdim.x += JX.Scrollbar._getScrollbarControlWidth(); | fdim.x += JX.Scrollbar.getScrollbarControlWidth(); | ||||
| fdim.setDim(this._viewport); | fdim.setDim(this._viewport); | ||||
| }, | }, | ||||
| /** | /** | ||||
| * Figure out the correct size and offset of the scrollbar handle. | * Figure out the correct size and offset of the scrollbar handle. | ||||
| */ | */ | ||||
| _resizeBar: function() { | _resizeBar: function() { | ||||
| ▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines | |||||