Scroller

Adds a scrollbar to a specific div.  The scrollbar is implemented using a Script.aculo.us slider.  The class reparents the original div, creates a slider and ties the reparented div to the slider, setting any properties necessary on the divs to make it all work.  The scrollbar can be styled using CSS.  The track of the scrollbar has class ‘scroll-track’, the thumb has class ‘scroll-handle’.

properties

myIndexan integer used to generate a unique ID for use in, for example, div ids.
outerBoxthe div that holds the scrollpane + scrollbar
innerBoxthe div that holds the scrollpane
innerHeightthe height of the inner box.
viewportHeightthe height of the view onto the scrolled div.
tracka div that holds the script.aculo.us slider (the scrollbar)
trackHeightthe height of the slider
handlethe div for the ‘thumb’ of the scrollbar
handleHeightthe height of the thumb
sliderthe script.aculo.us slider itself
ieDecreaseBya fudge factor used when calculating the width of innerBox
Summary
ScrollerAdds a scrollbar to a specific div.
Properties
Scroller.idsA cache of Scrollers indexed by the ID of the original div.
Scroller.iA unique ID generator.
Functions
initializeWrap the passed div in a scrollpane.
decoratecreate the necessary elements to implement the scrollbar and wire up events.
resetScrollbarRe-calculate the geometry of the scrollbar.
setWidthSet the width of of the scrollpane (aka innerBox).
getHeightGet the height of the passed element.
getWidthGet the width of the passed element.
onChangeCalled when the script.aculo.us slider has changed (i.e.
Scroller. setAllSearch for divs of the class ‘makeScroll’ and wrap them in a Scroller.
Scroller. resetIf the passed element has class ‘makeScroll’, wrap it in a Scroller.
Properties
Scroller. updateAllReset all of the scrollbars.

Properties

Scroller.ids

A cache of Scrollers indexed by the ID of the original div.

Scroller.i

A unique ID generator.

Functions

initialize

initialize: function(el)

Wrap the passed div in a scrollpane.

parameters

elthe div to add a scrollbar to.

decorate

decorate: function()

create the necessary elements to implement the scrollbar and wire up events.

resetScrollbar

resetScrollbar: function(full)

Re-calculate the geometry of the scrollbar.  Typically called from an event handler.

args

fullif true, re-calculate the geometry of the scrollpane as well as the scrollbar.

setWidth

setWidth: function()

Set the width of of the scrollpane (aka innerBox).

getHeight

getHeight: function(el)

Get the height of the passed element.

args

elthe element to get the height of.

getWidth

getWidth: function(el)

Get the width of the passed element.

args

elthe element to get the width of.

onChange

onChange: function(val)

Called when the script.aculo.us slider has changed (i.e. when it has been dragged).  Scroll the inner box.

args

valnot used.

Scroller. setAll

Scroller.setAll = function ()

Search for divs of the class ‘makeScroll’ and wrap them in a Scroller.

Scroller. reset

Scroller.reset = function (body_id)

If the passed element has class ‘makeScroll’, wrap it in a Scroller.

Properties

Scroller. updateAll

Reset all of the scrollbars.

initialize: function(el)
Wrap the passed div in a scrollpane.
decorate: function()
create the necessary elements to implement the scrollbar and wire up events.
resetScrollbar: function(full)
Re-calculate the geometry of the scrollbar.
setWidth: function()
Set the width of of the scrollpane (aka innerBox).
getHeight: function(el)
Get the height of the passed element.
getWidth: function(el)
Get the width of the passed element.
onChange: function(val)
Called when the script.aculo.us slider has changed (i.e.
Scroller.setAll = function ()
Search for divs of the class ‘makeScroll’ and wrap them in a Scroller.
Scroller.reset = function (body_id)
If the passed element has class ‘makeScroll’, wrap it in a Scroller.