« Return

/*
* BCDC.US - listSplit jQuery plugin
* Examples and documentation at: http://bcdc.us
*
* This Version: 1.0 ( Jun-04-2010 )
* [ history - Version: 1.0 ( Jun-04-2010 ) ]
*
* Requires: jQuery v1.4+
*
* Demo at http://bcdc.us/jquery.plugins/jquery.listsplit/demo.html
*/

(function($) {
    $.fn.listSplit = function(customOptions) {

       return this.each(function () {
          var options = $.extend({},$.fn.listSplit.defaultOptions, customOptions);
          var originalList = $(this); 
          var listsToAdd = originalList.children("li").length / options.splitOn;

          if ( options.class_name === null )
             for (i = 1; i < listsToAdd; i += 1) {
                originalList.before("");
             }
           
          else
             for (i = 1; i < listsToAdd; i += 1) {
                originalList.before("");
             }
           
          while (originalList.children("li").length > options.splitOn) {
             originalList.children("li:lt(" + options.splitOn + ")").appendTo("ul:empty:first");
          }
       });
    };

    $.fn.listSplit.defaultOptions = {
      splitOn: 4,
      class_name: null
    };

})(jQuery);