JAWS: news ticker and mini accordion
- » Overview
- » Example
- » Usage and params
- » Data format
- » Notes
Overview
This widget-esq script is at once both a news ticker and a mini accordion. It takes a config file of data (headlines, image SRCs, URLs etc) and paginates your headlines into folds. It will optionally auto-rotate through these folds, though you can navigate between them with the numeric tabs at the top right. If an item has 'more info' data set in the config, then clicking the headline will reveal that data in an accordion fashion. See below for an example.
Example
Click the list items to reveal more info.
Here's the code behind this example:
1new Jaws({
2 container: '#jawsHolder',
3 title: 'latest news',
4 jsonFile: '../inc/script_demos/jaws/json.json',
5 itemsPerFold: 4,
6 doNumbers: true
7});
Usage and params
Create a Jaws in your page by calling new Jaws(params), where 'params' is an object of parameters including:
container (string) - a jQuery selector string targeting the container element you want to insert the Jaws into
title (string) - the title to appear at the top of your Jaws, e.g. "latest headlines"
jsonFile (string) - a filepath to a JSON-formatted data file to feed the Jaws (see data format below for info on this)
data (object) - if you want to directly pass in data to feed your Jaws, rather than loading it from a JSON file, pass it in as an object in this parameter
itemsPerFold (integer) - the number of items that should be visible without needing to scroll (i.e. this decides the height of your Jaws)
doNumbers (boolean; default: false) - if true, the items in your list will be numbered
Data format
Jaws reads JSON data. You can have it load your data either by specifying a path to a file where it's stored (see the jsonFile parameter above) or by passing in data directly as an object literal (see the data parameter above).
The format is simple, and looks like this:
1[
2 {
3 "title": "item 1 title",
4 "url": "http://www.someurl.com",
5 "moreInfo": {
6 "info": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse laoreet hendrerit arcu",
7 "image": "images/someImage.jpg"
8 }
9 },
10 {
11 "title": "Item 2 title",
12 "url": "http://www.someotherurl.com",
13 "moreInfo": {
14 "info": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse laoreet hendrerit arcu,",
15 "image": "images/someOtherImage.jpg"
16 }
17 }
18 //etc
19]
As you can see, it's rather self-explanatory. Click here to see the JSON file that powers the example at the top of this page.
Notes
Dependencies
There is an accompanying CSS file for this script, included in the source download, that you will need to call into your page.
Items with no 'more info'
If you don't pass moreInfo for a particular item, clicking an item will take the user directly to its associated URL, without showing any more info.
Curvy corners
Obviously the CSS-powered curvy corners won't show up in IE. You can get round this by using my CurveMe plugin.
Comments (27)
User, at 20/10/'10 00:00, said:
Shopsystem, at 20/10/'10 13:10, said:
Mitya, at 21/10/'10 08:50, said:
Mitya, at 21/10/'10 09:10, said:
Mietshop, at 21/10/'10 17:11, said:
Okoweb, at 26/10/'10 09:04, said:
dsc, at 1/11/'10 03:46, said:
samson, at 2/11/'10 10:27, said:
xiarra, at 2/11/'10 10:28, said:
Mitya, at 2/11/'10 11:19, said:
xiarra, at 2/11/'10 11:50, said:
Mitya, at 2/11/'10 11:52, said:
James, at 1/12/'10 21:49, said:
Mitya, at 1/12/'10 22:41, said:
Ali, at 5/01/'11 04:38, said:
raghib.suleman, at 7/01/'11 12:09, said:
Aman, at 16/04/'11 12:18, said:
Heretic, at 24/04/'11 17:38, said:
Bernard, at 19/05/'11 14:50, said:
L, at 2/09/'11 07:46, said:
shwetaec, at 30/11/'11 11:26, said:
haicheng.jin, at 21/12/'11 17:21, said:
serkan, at 14/03/'12 11:17, said:
Debi, at 29/03/'12 19:33, said:
Debi, at 2/04/'12 15:46, said:
Michel, at 6/04/'12 05:35, said:
Mintik, at 15/12/'12 01:57, said: