jQuery Columnize is a plugin for the Javascript library jQuery which allows to create a newspaper-like column layout. The original HTML code only needs small adaptions. In most cases, it is not necessary to adapt the HTML code at all.
Documentation
Throbber creates a loading animation for jQuery, ready to be used in your AJAX applications. Of course, the throbber is not limited to AJAX.
Using the plugin is easy:
$("#button").throbber("click")
adds a loading animation (›throbber‹) to the DOM node with the ID ›button‹ which shows up when a click event is triggered.
The following is a list of all functions provided by the plugin:
- $().throbber()
$().throbber(event)
$().throbber(options)
$().throbber(event, options)
event is a string specifying the event to which the throbber should bind. The default here is ›click‹. options is a set of options (see below). Both parameters can be omitted - $.throbberShow(options)
Immediately shows a throbber as specified. If no parent element is specified with options.parent, the throbber will be appended to the element. - $.throbberHide()
Hide all throbbers.
Options
The plugin recognizes several options which are denoted in curly brackets.
- ajax: ›true‹ if the throbbers should listen to AJAX events. In this case, the throbbers are automatically hidden if all AJAX requests are completed. ›false‹ if you use AJAX, but want to hide the throbbers manually. Default: ›true‹
- delay: The timeout (in milliseconds) until the throbber should appear. Default: ›0‹
- image: The filename of the throbber image. Default: ›throbber.gif‹
- parent: A jQuery selector specifying the parent element to which the throbber should be appended. All other child elements are automatically hidden when the throbber is appended. If this is left blank, the throbber replaces the element to which it was attached. Default: ›‹
- wrap: The HTML code that should wrap the throbber. Default: ›‹
Tips
If you don't use AJAX, you don't have to explicitly set the ›ajax‹ parameter to ›false‹. The ›ajax‹ is merely there to prevent that
The throbber element uses this HTML code:
<img src="throbber.gif" class="throbber" />
You can set wrapping code using the ›wrap‹ option.
You can create throbber images using http://www.ajaxload.info/.
Examples
- $("#button").throbber()
Show a throbber when the button is clicked, replacing the button and stopping when all AJAX requests are completed. - $("#div").throbber("dblclick", {image: "throbber_2.gif"})
Show a throbber when #div is double-clicked, using a custom throbber image.
Using the plugin is easy:
$("#text").columnize()
sets the contents of the DOM node with the ID ›text‹ in a two-column layout with balanced column lengths.
The plugin recognizes different options which are denoted in curly brackets.
Options
- balance: ›true‹ if the column lengths should be balanced. ›false‹ if the columns should grow to the height of the containing element. Default: ›true‹
- column: The CSS class which should be applied to columns. Default: ›column‹
- columns: The desired number of columns if balance mode is on. Default: ›2‹
- continued: The CSS class which should be applied to DOM nodes which are continued in the next column. Default: ›continued‹
Tips
If balance mode is off, the element to which the column layout should be applied has to define a maximum height via the CSS property ›max-height‹. The columns will then grow to at most this height.
If balance mode is on, the maximum height is taken into account, too. If balancing the column lengths would exceed the maximum height the plugin automatically disables balance mode. In this case, the plugin creates more columns than specified in the columns option.
The column width is derived from the CSS properties of the columns. You can control the width using the CSS class specified in the columns option.. Typical properties for a column are the following:
float: left
width: 200px
margin-right: 1em
For a beautiful layout it is recommended to use the CSS property ›line-height‹. By setting the line height explicitly and calculate all vertical distances as multiples of the line height you ensure that all baselines are aligned to the same grid.
Examples
- $("#text").columnize({columns: 3})
Three columns with balanced column lengths. - $("#text").columnize({columns: 3, balanced: false})
Three columns with balanced column lengths if the column lengths do not exceed the maximum height of the containing element. In this case, the plugin abandons the limitation to three columns and creates as many columns as needed for the text. - $("#text").columnize({balanced: false})
Columns grow until the maximum height of the containing element. The number of columns is determined by the amount of text.
License
jQuery Columnize is a contribution to the jQuery community and is therefore distributed as open source software. The plugin is licensed under the GNU Lesser General Public License.
Download
Please go to the project website in the jQuery plugin repository to download the latest release.
--> website