A jQuery plugin that sets a division to flip between text messages like a flight board at an airport. If you find this plugin useful please vote for it on the jQuery site.
The current version is 1.0.2 and is available under the GPL and MIT licences. For more detail see the documentation reference page. Or see a minimal page that you could use as a basis for your own investigations.
The flight board functionality can easily be added to a division with appropriate default settings. It then displays the messages in a cycle after two seconds. Highlights and shadows are used to enhance the 3D effect.
Stop and restart the automatic flipping with the appropriate commands.
You can also remove the flight board functionality with the 'destroy' command if it is no longer required.
This widget is costly when animating. I would recommend only having one per page.
Basic board:
$('#defaultBoard').flightboard();
$('#stopBoard').toggle(function() {
$(this).text('Start');
$('#defaultBoard').flightboard('stop');
}, function() {
$(this).text('Stop');
$('#defaultBoard').flightboard('start');
}
);
$('#removeBoard').toggle(function() {
$(this).text('Re-attach');
$('#defaultBoard').flightboard('destroy');
},
function() {
$(this).text('Remove');
$('#defaultBoard').flightboard();
}
);
You can override the defaults globally as shown below:
$.flightboard.setDefaults({speed: 750, pause: 3000});
Processed fields are marked with a class of hasFlightBoard
and are not re-processed if targetted a second time.
Control how the flight board works by supplying various options when attaching it. You can change the options on the fly with
$(selector).flightboard('change', {...})
You can trigger a new message change with
$(selector).flightboard('flip')
This command can also take a callback function to notify you of the completion of the change.
Change flip speed: ms per flip with ms pause
Number of flips: to
Shading:
Sequential letters:
Next message:
Alternate image:
Repeat:
$('#optionsBoard').flightboard({maxLength: 14,
messages: ['FIRST MESSAGE', 'SECOND MESSAGE', 'THIRD MESSAGE']});
var imageOptions = [];
imageOptions[0] = {lettersImage: 'img/flightBoardLarge.png', lettersSize: [25, 34]};
imageOptions[1] = {lettersImage: 'img/flightBoardLarge2.png', lettersSize: [25, 34]};
imageOptions[2] = {lettersImage: 'img/flightBoardSmall.png', lettersSize: [14, 18]};
$('#options select').change(function() {
var minFlips = parseInt($('#minFlips').val());
var maxFlips = Math.max(minFlips, parseInt($('#maxFlips').val()));
$('#optionsBoard').flightboard('change',
$.extend(imageOptions[$('#image').val()],
{flips: [minFlips, maxFlips],
speed: parseInt($('#speed').val()),
pause: parseInt($('#pause').val()),
shading: $('#shading').val() == 'true',
sequential: $('#sequential').val() == 'true',
selection: $('#selection').val(),
repeat: $('#repeat').val() == 'true'}));
$('#flipButton').attr('disabled',
($('#repeat').val() == 'true' ? 'disabled' : ''));
});
$('#flipButton').click(function() {
$('#optionsBoard').flightboard('flip');
});
There are two callbacks available: one just as the flip is starting and another as the flip ends.
Before/after flip:
Status:
$('#callbackBoard').flightboard(
{beforeFlip: startingFlip, afterFlip: endedFlip});
function startingFlip(current, next) {
$('#flipStatus').text('started ' + current + ' » ' + next);
}
function endedFlip(current, next) {
$('#flipStatus').text('ended ' + current + ' » ' + next);
}
Use the flight board as a clock.
Clock:
$('#clock .board').flightboard({
maxLength: 2, messages: [''], flips: 1, repeat: false});
// setInterval(updateClock, 1000);
var lastTime = currentTime();
function updateClock() {
var thisTime = currentTime();
for (var i = 0; i <= 4; i++) {
if (thisTime[i] != lastTime[i]) {
$('#clock' + timeNames[i] + 'Board').
flightboard('change', 'messages', [lastTime[i], thisTime[i]]).
flightboard('flip');
}
}
lastTime = thisTime;
}
function currentTime() {
var now = new Date();
var hour = now.getHours() % 12 || 12;
var min = now.getMinutes();
var sec = now.getSeconds();
return [(hour < 10 ? '0' : '') + hour,
(min < 10 ? '0' : '') + min,
(sec < 10 ? '0' : '') + sec,
(now.getHours() < 12 ? 'AM' : 'PM')];
}
<div id="clockHrBoard" class="board"></div>
<div class="clockSep">:</div>
<div id="clockMinBoard" class="board"></div>
<div class="clockSep">:</div>
<div id="clockSecBoard" class="board"></div>
<div id="clockAPBoard" class="board"></div>
This tab highlights examples of this plugin in use "in the wild".
tru_crumbsA trail of crumbs on the truth of life.
This digital creative studio has a novel approach to using the Flightboard plugin - switching images with the flip affect.
To add another example, please contact me (kbwood{at}iinet.com.au) and provide the plugin name, the URL of your site, its title, and a short description of its purpose and where/how the plugin is used.
A full list of all possible settings is shown below. Note that not all would apply in all cases. For more detail see the documentation reference page.
$(selector).flightboard({
lettersImage: 'img/flightBoardLarge.png', // Amalgamated image for letters background
lettersSize: [25, 34], // Width and height of individual letters
lettersSeq: ' ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', // Positioning of letters within image
messages: ['SEE THE FLIGHT BOARD', 'CHANGE MESSAGES'], // Messages to display
maxLength: 20, // Maximum length of flight board
flips: [3, 5], // Number of flips before new value,
// may be an array with minimum and maximum flips
sequential: false, // True to step through all letters, false for random ones
speed: 500, // Time taken (milliseconds) for a single transition
repeat: true, // True to automatically trigger a new transition after a pause
pause: 2000, // Time (milliseconds) between transitions
selection: 'forward', // How to choose the next item to show:
// 'forward', 'backward', 'random'
shading: true, // True to add shading effects, false for no effects
opacity: 0.5, // Maximum opacity (0.0 - 1.0) for highlights and shadows
// Locations of the highlight/shadow images for IE
shadingImages: ['img/flightBoardHigh.png', 'img/flightBoardShad.png'],
beforeFlip: null, // Callback before flipping
afterFlip: null // Callback after flipping
});
$.flightboard.setDefaults(options) // Change global settings
$(selector).flightboard('change', options) // Change settings
$(selector).flightboard('change', name, value) // Change one setting
$(selector).flightboard('destroy') // Remove flight board
$(selector).flightboard('stop') // Stop automatic flipping
$(selector).flightboard('start') // Start automatic flipping
$(selector).flightboard('flip', next) // Flip to next message
$(selector).flightboard('current') // Retrieve current message
$(selector).flightboard('next') // Retrieve next message
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script><script type="text/javascript" src="jquery.flightboard.js"></script>
Alternately, you can use the packed version jquery.flightboard.pack.js (6.7K vs 17.3K),
or the minified version jquery.flightboard.min.js (8.5K, 2.9K when zipped).$(selector).flightboard();
You can include custom settings as part of this process.
$(selector).flightboard({speed: 750});For more detail see the documentation reference page.
WOW, what a great nice plugin Flightboard is. Congratulations.
I think this is one of the best jQuery plugins I've ever seen, and it is going to be perfect for one of my websites.
It is very awsome and it would be a great help for a website I supervise.
Contact Keith Wood at kbwood{at}iinet.com.au with comments or suggestions.
| Version | Date | Changes |
|---|---|---|
| 1.0.2 | 05 Nov 2011 |
|
| 1.0.1 | 30 Jan 2010 |
|
| 1.0.0 | 07 Nov 2009 |
|