Add scroll boxes, image rotation and static boxes to TWiki pages
Introduction
Scroll Box Use Cases
Scrolling text box
Logo roll
Image rotation
What's new box
RSS feed
Twitter feed
New registrations
Recent changes box
Use this add-on to create nice looking text scroll boxes, logo rolls and boxes with images that get replaced in regular intervals. Scrolling stops if you hover the mouse pointer over the scroll area.
This add-on uses CSS and JavaScript. It falls back to show initial content in case JavaScript is not available. All code is included, e.g. there are no external dependencies. The Scroll Box Add-on is inspired by the scrolling content script of dhtmlgoodies.com.
The twiki.org redesign of December 2010 added a logo roll to the homepage. This add-on was created based on that work.
Usage
There are two options to create scroll boxes:
Using INCLUDE
Using HTML & CSS
Scroll Box Using INCLUDE
Create scroll boxes in TWiki pages by including two named sections defined in the ScrollBoxAddOn topic, called "scroll_box_engine" and "scroll_box", respectively. Example:
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="scroll_box_engine" }%
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="scroll_box"
name="must_be_unique"
title="This is a test"
content="TWiki keeps getting more and more useful."
delay="100"
vstep="1"
width="400"
height="30"
}%
The "scroll_box_engine" section defines the CSS and JavaScript. It must be included once per page.
The "scroll_box" section generates a scroll box. It can be included more than once on a page to create multiple scroll boxes. Parameters of "scroll_box" section:
The first parameter of initScrollBox() is the ID of the div that contains the scroll box. The numeric parameters are delay, vstep, width and height, respectively.
Static Box Using INCLUDE
Create static boxes in TWiki pages by including two named sections defined in the ScrollBoxAddOn topic, called "scroll_box_engine" and "static_box", respectively. Example:
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="scroll_box_engine" }%
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="static_box"
title="Nice box"
content="Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
width="400"
height="225"
}%
The "scroll_box_engine" section defines the CSS and JavaScript. It must be included once per page.
The "static_box" section generates a static box. It can be included more than once on a page to create multiple boxes. Parameters of "static_box" section:
This is an alternative to the previous example. The box is split up into two INCLUDEs with a "static_box_start" section, the box content, and a "static_box_end" section. Example:
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="scroll_box_engine" }%
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="static_box_start"
title="Nice box"
width="400"
height="225"
}%
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="static_box_end" }%
The "scroll_box_engine" section defines the CSS and JavaScript. It must be included once per page.
The "static_box_start" section generates the start of a static box. Parameters of "static_box_start" section:
The "static_box_end" section generates the end of the static box. Pairs of "static_box_start" and "static_box_end" section INCLUDEs can be done on a page to create multiple boxes.
Named sections
This section defines the named sections "scroll_box_engine", "scroll_box", "static_box", "static_box_start" and "static_box_end". View the raw text of this topic to look under the hood.
Examples
Text scroll demo
This example shows a box that scrolls text in one pixel increments.
How it works: We place the text in a scrollable canvas that is 300 pixels wide. The text is justified left and right as specified in the style sheet of the scroll box content. We tell the scroll box to show a container 300 pixels wide and 150 pixels high. That is, we only see part of the canvas. We move the canvas up 1 pixel at a time and to wait 100 milliseconds between steps, e.g. we get the impression of smoothly scrolling text in the container.
Rendered text scroll:
Lorem ipsum
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Raw text:
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="scroll_box_engine" }%
%INCLUDE{
"%SYSTEMWEB%.ScrollBoxAddOn"
section="scroll_box"
name="textExample"
title="Lorem ipsum"
content="<br /><!-- make space on top -->
Lorem ipsum dolor sit amet, consectetur
...
deserunt mollit anim id est laborum."
delay="100"
vstep="1"
width="300"
height="150"
}%
Logo roll demo
This example shows a logo roll that changes every 2 seconds.
How it works: We have a set of logos that all have the same height of 30 pixels:
We place the logos in a scrollable canvas that is 300 pixels wide. The logos wrap around; they are justified left and right as specified in the style sheet of the scroll box content. We tell the scroll box to step by 30 pixels at a time, e.g. we will cycle through the logos row by row because the icons are 30 pixels high.
Note: It is important to specify the width and height of the images, or scrolling might not work on some browsers. Browsers need to know the total scrollable area before all images are loaded.
This example shows a box containing an image that get replaced every 3 seconds.
How it works: The images are 300 pixels wide and 225 pixels high. We place the images in a scrollable canvas that is 300 pixels wide, e.g. one image fits on each "line". In other words, the images are stacked on top of each other. We tell the scroll box to step by 225 pixels at a time, e.g. the same as the image height. This results in cycling through the images one by one.
Note: It is important to specify the width and height of the images, or scrolling might not work on some browsers. Browsers need to know the total scrollable area before all images are loaded.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.
Raw text:
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="scroll_box_engine" }%
%INCLUDE{
"%SYSTEMWEB%.ScrollBoxAddOn"
section="static_box"
title="Nice box"
content="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat."
width="300"
contentstyle="text-align: justify;"
}%
Same static box, alternative syntax:
Nice box
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.
Raw text:
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="scroll_box_engine" }%
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="static_box_start"
title="Nice box" width="300" contentstyle="text-align: justify;" }%
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="static_box_end" }%
Installation Instructions
Note: You do not need to install anything on the browser to use this add-on. The following instructions are for the administrator who installs the add-on on the TWiki server.
TWikibug:Item6837: Add non-scrolling box feature with "static_box*" sections; change padding from 10px to 15px; add boxstyle, titlestyle and contentstyle parameters