Scroll Box Add-on

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:

Parameter Description Default
name Name of the box. Must be unique per page.
Use only alphanumeric characters and underscore!
(none)
title Title of the box. (no title)
content Content of the box. Can be of any form, such as TML, HTML, images.
Make sure to escape double quotes with a backslash, such as <br clear=\"all\">.
(none)
delay Delay between scrolls, in milliseconds. "1000"
vstep Vertical step taken per scroll, in pixels. (container height)
width Box width, in pixels. "300"
height Box height of scrollable area, in pixels. "40"
boxstyle CSS of outer box. "border: solid #d0d0d0 1px;
  padding: 15px;"
titlestyle CSS of title. "text-align:center;
  font-size:19px;
  font-weight:bold;
  color: #333335;
  padding:0 0 12px 0;
  white-space: nowrap;
  overflow: hidden;"
contentstyle CSS of content. "text-align: justify;"

Scroll Box Using HTML & CSS

You can define your own style and create your own scroll box. Example:

%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="scroll_box_engine" }% <!-- once per page -->
<div id="myOwnBoxContainer">
 <div id="myOwnBoxContent">
  (put content here)
 </div><!-- id="myOwnBoxContent" -->
</div><!-- id="myOwnBoxContainer" -->
<script type="text/javascript">
 initScrollBox( 'myOwnBoxContainer', 100, 1, 200, 400 );
</script>

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:

Parameter Description Default
title Title of the box. (no title)
content Content of the box. Can be of any form, such as TML, HTML, images.
Make sure to escape double quotes with a backslash, such as <br clear=\"all\">.
(none)
width Box width, in pixels. "300"
height Height of content, in pixels. (auto)
boxstyle CSS of outer box. "border: solid #d0d0d0 1px;
  padding: 15px;"
titlestyle CSS of title. "text-align:center;
  font-size:19px;
  font-weight:bold;
  color: #333335;
  padding:0 0 12px 0;
  white-space: nowrap;
  overflow: hidden;"
contentstyle CSS of content. (none)

Static Box Using 2 INCLUDEs

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:

Parameter Description Default
title Title of the box. (no title)
width Box width, in pixels. "300"
height Height of content, in pixels. (auto)
boxstyle CSS of outer box. "border: solid #d0d0d0 1px;
  padding: 15px;"
titlestyle CSS of title. "text-align:center;
  font-size:19px;
  font-weight:bold;
  color: #333335;
  padding:0 0 12px 0;
  white-space: nowrap;
  overflow: hidden;"
contentstyle CSS of content. (none)

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:

cisco hp fedex nasa google intel sony motorola ebay ubs cmu

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.

Rendered logo roll:

TWiki Users Around the Globe
com-cisco.png hp fedex nasa google intel sony motorola ebay ubs cmu

    Raw text:
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="scroll_box_engine" }%
%INCLUDE{
  "%SYSTEMWEB%.ScrollBoxAddOn"
  section="scroll_box"
  name="logoExample"
  title="TWiki Users Around the Globe"
  content="<img src='%ATTACHURLPATH%/com-cisco.png' alt='cisco' width='56' height='30' />
     <img src='%ATTACHURLPATH%/com-hp.png' alt='hp' width='43' height='30' />
     ...
     <img src='%ATTACHURLPATH%/com-cmu.png' alt='cmu' width='117' height='30' />"
  delay="2000"
  vstep="30"
  width="300"
  height="30"
}%

Image swap demo

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.

Rendered image box:

Beverly Hills
Beverly Hills park Beverly Hills Rodeo Drive Expensive cars Beverly Hills City Hall

    Raw text:
%INCLUDE{ "%SYSTEMWEB%.ScrollBoxAddOn" section="scroll_box_engine" }%
%INCLUDE{
  "%SYSTEMWEB%.ScrollBoxAddOn"
  section="scroll_box"
  name="imageExample"
  title="Beverly Hills"
  content="<img src='%ATTACHURLPATH%/Dsc08566.jpg' alt='Beverly Hills' width='300' height='225' />
     <img src='%ATTACHURLPATH%/Dsc08581.jpg' alt='Rodeo Drive' width='300' height='225' />
     <img src='%ATTACHURLPATH%/Dsc08580.jpg' alt='Expensive cars' width='300' height='225' />
     <img src='%ATTACHURLPATH%/Dsc08567.jpg' alt='Beverly Hills City Hall' width='300' height='225' />"
  delay="3000"
  vstep="225"
  width="300"
  height="225"
}%

Static box demo

Rendered static box:

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"
  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.

  • Download the ZIP file from the Add-on Home (see below)
  • Unzip ScrollBoxAddOn.zip in your twiki installation directory. Content:
    File: Description:
    data/TWiki/ScrollBoxAddOn.txt Add-on topic
    pub/TWiki/ScrollBoxAddOn/* Images used by the examples
  • Test if the installation was successful:
    • See if above examples work

Add-On Info

  • Set SHORTDESCRIPTION = Add scroll boxes, image rotation and static boxes to TWiki pages

Add-on Author: TWiki:Main.PeterThoeny
Copyright: © 2012-2018 TWiki:Main.PeterThoeny
License: GPL (GNU General Public License)
Add-on Version: 2018-07-05
2018-07-05: TWikibug:Item7841: Copyright update to 2018
2016-01-09: TWikibug:Item7708: Copyright update to 2016
2013-10-11: TWikibug:Item7328: Fix for ScrollBoxAddOn not working on IE9 -- TWiki:Main.YaojunFei
2013-05-04: TWikibug:Item7154: Document need to specify image width & height; add Twisty to history and installation section
2012-10-14: TWikibug:Item6985: Dark link colors in scroll box titles
2012-10-12: TWikibug:Item6971: Add ScrollBoxAddOn to core distribution
2012-10-04: TWikibug:Item6956: CSS based box shadow and rounded corners
2012-05-14: TWikibug:Item6837: Add non-scrolling box feature with "static_box*" sections; change padding from 10px to 15px; add boxstyle, titlestyle and contentstyle parameters
2011-02-10: TWikibug:Item6638: Avoid <p /> tag when including scroll box engine
2011-01-25: TWikibug:Item6638: Small style change: More padding below title
2010-12-23: TWikibug:Item6623: Doc improvements; changing function initScrollContent to initScrollBox
2010-12-22: TWikibug:Item6623: Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.1 (TWiki 4.0)
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.005
Add-on Home: http://TWiki.org/cgi-bin/view/Plugins/ScrollBoxAddOn
Feedback: http://TWiki.org/cgi-bin/view/Plugins/ScrollBoxAddOnDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/ScrollBoxAddOnAppraisal

Related Topic: TWikiAddOns

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 06 Jul 2018 - TWikiContributor
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.ScrollBoxAddOn.