1//showmore plugin 2(function ($){ 3 var methods = { 4 init: function(options){ 5 var opts = $.extend({}, $.fn.htmlexpandable.defaults, options); 6 7 return this.each(function(){ 8 var $this = $(this); 9 var $parent = $this.parent(); 10 var scrollHeight = this.scrollHeight; 11 if (scrollHeight > opts.height){ 12 $("<a>") 13 .addClass("show-more") 14 .insertAfter($this) 15 .html(opts.lang.showMore) 16 .click(function(){ 17 var $a = $(this); 18 if ($a.hasClass("show-more")) 19 $this.animate({ 20 'maxHeight': scrollHeight 21 }, function(){ 22 $a.removeClass("show-more").addClass("show-less").html(opts.lang.showLess); 23 }); 24 else if ($a.hasClass("show-less")) 25 $this.animate({ 26 'maxHeight': opts.height 27 }, function(){ 28 $a.removeClass("show-less").addClass("show-more").html(opts.lang.showMore); 29 }); 30 }); 31 } 32 }); 33 } 34 }; 35 36 $.fn.htmlexpandable = function(method){ 37 if (methods[method]) 38 return methods[method].apply(this, Array.prototype.slice(arguments, 1)); 39 else if ( typeof method === 'object' || !method) 40 return methods.init.apply(this, arguments); 41 else 42 $.error('Method ' + method + ' does not exists'); 43 } 44 45 $.fn.htmlexpandable.defaults = { 46 height: 150, 47 lang: { 48 showMore: "Show more", 49 showLess: "Show less" 50 } 51 } 52 53}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.