jQuery BBQ: Better Blockquotes

jQuery BBQ: A blockquote (AKA pullquote) script, that will unobtrusively grab content from your webpage and display it similarly to the way newspapers do it (see Wikipedia's definition of a pull quote).

It can either be dropped directly into the webpage, with no configuration, or can take a number of customization parameters if you want to get creative with it. It is very lightweight - only 2.2 Kb (to which you will need to add the size of your jQuery distro).

Demo

I've set up a demo page for jBBQ, where you will find usage examples.

Download

Version 1.0 (initial release) is currently available for download.
Choose your download type below:
Compressed version, including the 1.6.2 distro of jQuery.
Commented / editable code.
 

Requirements

jQuery BBQ requires jQuery 1.6.2 or newer. You can either use the one provided in the archive, or download your own customized version from the jQuery download page.

Setup and basic usage

For a basic setup, you will only need the jbbq.js file included in your webpage (right next to the jQuery framework (jquery.js): <script type="text/javascript" src="/js/jquery.js"></script> <script type="text/javascript" src="/js/jbbq.js"></script> You will need to define a .jBBQ class in your CSS statements that sets the style to be used for the pullquotes. Then simply add class="pullquote" to any of the blocks of text you want displayed as block quotes.

Advanced Usage

Inside the area that you wish to scan (document.body by default), surround the text you wish to use as a pullquote with a span element, that will be identified by the 'pullquote' CSS class (you can specify an alternate CSS class to scan for in the options, see below).
Should you wish to force the side where the generated blockquote element will be placed, you will add an additional 'left' or 'right' CSS class. Otherwise, the default initial side will be used (see options below).
Similarly to the way you would declare a side, you may force a location for the pullquote to be inserted at, such as 'before', 'inline-prepend', 'inline', 'inline-append', 'after'.
If you would like to use additional classes on the pullquote, you can also specify them in the CSS class attribute of the span element, by prefixing them with a '>' sign (e.g. class="pullquote left >fancy-styling >fun-colours"). There is no restriction on the number of classes you can pass. An example usage for this option is when you may want to stick a pullquote on one side and using a negative margin, pull it out of the main block of text some more.
If you wish to scan inside one element only, you may use the default jQuery selectors, e.g.: $('div#article').jBBQ();
Leave the defaults untouched, instead call the function using options, such as: $(document.body).jBBQ({'location': 'before', 'escape_html': false});
The defaults are: var jBBQDefaultSettings = { 'default_side' : 'right', // 'left' or 'right' will be overridden if element has 'left' or 'right' CSS class 'alternate_side' : true, // if true, successive pullquotes will alternate left / right placement 'location' : 'inline', // where to place the blockquote - can be either 'before', 'after' or 'inline' 'css_class_to_scan' : 'pullquote', // span CSS class to scan for 'css_pullquote_class' : Array('jBBQ'), // feed it an array of CSS classes for the blockquote, to have it randomly go through it 'escape_html' : true // if true, HTML markup will be stripped from inside the span (i.e. text only will be displayed) };

Customization

If you have a look at the CSS file, you will find a few cool examples of pullquotes.

License:

MIT style, meaning you can do anything with the above code, but I won't be held responsible if it eats your broccoli or steals your cat.

Article Info

This article was read 1008 times.

All scripts on this site are free. However, if you feel you want to contribute, use the button below.

COMMENTS (One comment)

Very nice, i suggest Admin can set up a forum, so that we can talk and communicate.
Nancy

1 Charles / September 13th, 2011, 11:54 / #

Post a comment

Articles in the category

Quick & dirty fix for Slimbox to attach itself to all images

While implementing yet another a WordPress site, I found myself in the situation where I wanted to display any and all images in lightboxes, but with a minimum of interaction from the editor’s part. All current plugins that integrate Slimbox (that I know of – this one, for example) actually require the editor to add [...]

SkinShare tutorial for an age verification using MOOdalBox

MOOdalBox has the the honor to be the first featured post on the SkinShare dev blog, with a tutorial on how to make a quick and easy age verification procedure. Unfortunately, this is a JavaScript only method – so it’s easily bypassed. I’ll have a version that uses more server-side scripting ready some time soon [...]

Tutorial for an AJAX login using MOOdalBox

While browsing the e-magine forums, answering a topic here and there, I discovered very well written and simple to follow tutorial on bulding a modal login dialogue using MOOdalBox. I’m really happy to see such a piece of work – it makes the time I spent writing the scripts even more meaningful. Thank you, Jani [...]

Vertical MooTools Kwicks (Fx.Elements), using relative sizes

I started out to make a vertical menu using Fx.Elements (instead of the classic horizontal one), for one of the sites I’m working on and, as always, I chose to use relatively sized elements (namely ‘em’). However, although Fx.Base has support for specifying the unit, the original Kwicks demo doesn’t play well out of the [...]