/*
* BCDC.US - ULoverFlow jQuery plugin
* Examples and documentation at: http://bcdc.us
* Version: 1.0 ( Dec-12-2009 )
* Copyright (c) 2009 Bruno Correia
* Requires: jQuery v1.3+
* Demo at http://bcdc.us/jquery.plugins/jquery.uloverflow/demo.html
*/
(function($) {
$.fn.uloverflow = function(customOptions) {
return this.each(function () {
var options = $.extend({},$.fn.uloverflow.defaultOptions, customOptions);
var $this = $(this);
$this.children().eq(options.overflowAfter-1).nextAll().wrapAll('')
$('li.theflow').hide()
.after('' + options.expandName + '');
function _expand() {
$('a.expand').click(function(event) {
event.preventDefault();
$(this).toggleClass(options.expandedClass);
if ( $(this).text() == options.expandName ) {
$(this).text(options.collapseName);
} else {
$(this).text(options.expandName);
}
$this.find('li.theflow').toggle();
});
} _expand();
});
};
$.fn.uloverflow.defaultOptions = {
overflowAfter: 12, // items
expandName: 'Expand',
collapseName: 'Collapse',
expandedClass: 'on' // toggle on and off className
};
})(jQuery);