« Return

/*
* BCDC.US - SmartExcerpt jQuery plugin
* Examples and documentation at: http://bcdc.us
* Version: 1.1 ( Dec-13-2009 )
* Copyright (c) 2009 Bruno Correia
* Requires: jQuery v1.3+
* Demo at http://bcdc.us/jquery.plugins/jquery.excerpt/demo.html
*/

(function($) {
		$.fn.excerpt = function(customOptions) {
					return this.each(function () {
					var options = $.extend({},$.fn.excerpt.defaultOptions, customOptions);
				
					var $this = $(this);
					$this.children().nextAll().hide();
				
					var firstPcontent = $this.children().eq(0).html(); // get first paragraph content 
					var excerpt = firstPcontent.slice(0, options.excerptLenght); // create excerpt 
					var excerpt = excerpt.concat(options.endTag); // add entTag to end of excerpt
					$this.children().eq(0).hide(); // now hide firstPcontent
				
					$this.prepend('

' + excerpt + '

'); function _expand() { $('a.reveal').text(options.expandName); // add options.expandName to tag $('a.reveal').click(function(event) { event.preventDefault(); $(this).toggleClass(options.expandedClass); if ( $(this).text() == options.expandName ) { $(this).text(options.collapseName); } else { $(this).text(options.expandName); } $this.children().nextAll().toggle(); $this.children('.excerpt').toggle(); }); } _expand(); }); }; $.fn.excerpt.defaultOptions = { excerptLenght: 100, // lenght of excerpt endTag: '…', // end tag expandName: 'Expand', collapseName: 'Collapse', expandedClass: 'on' // name of the class added to a href tag once expand }; })(jQuery);