PageSourceSearch

https://finaccelerate.com/js/jquery.readmore.js

js finaccelerate.com collected 2026-10-06 13:17:27 UTC 4,125 bytes, 116 lines download raw bytes

1; (function ($, window, document, undefined) {
2	'use strict';
3	let plugin;
4	var pluginName = 'readmore',
5		defaults = {
6			maxHeight: 130,
7			speed: 'fast',
8			btnclass: 'btn btn-primary-outline rounded-2 mt-3'
9		};
10	function Plugin(element, options) {
11		this.element = element;
12		this.settings = $.extend({}, defaults, options);
13		this._defaults = defaults;
14		this._name = pluginName;
15		this.init();
16	}
17	$.extend(Plugin.prototype, {
18		init: function () {
19			plugin = this;
20			var el = $(this.element);
21			var elTotal = el.length;
22			var readmoretotal = el.find('.readmore-content').length;
23			el.find('.readmore-content').each(function (index) {
24				$(this).attr('data-index', index);
25				$(this).attr('data-height', $(this).height());
26				$(this).attr('data-content', 'expanded');
27				plugin.collapse(index, false);
28				plugin.readmore(index);
29			});
30		},
31		collapse: function (elIndex, animate) {
32			var el = $(this.element);
33			var elatindex = el.find('.readmore-content[data-index="' + elIndex + '"]');
34			elatindex.css({ 'overflow': 'hidden' });
35			switch (animate) {
36				case true:
37					elatindex.animate({
38						'height': plugin.settings.maxHeight
39					}, plugin.settings.speed, 'linear');
40					break;
41				case false:
42					elatindex.css({ 'height': plugin.settings.maxHeight });
43					break;
44			}
45			elatindex.attr('data-content', 'collapsed');
46		},
47		readmore: function (elIndex) {
48			var el = $(this.element);
49			var elatindex = el.find('.readmore-content[data-index="' + elIndex + '"]');
50			var elheight = elatindex.attr('data-height');
51			if (elheight > plugin.settings.maxHeight) {
52				elatindex.parent().append('<button class="rmbtn readmorebtn ' + plugin.settings.btnclass + '" data-action="expand" data-target_index="' + elIndex + '">Read More</button>');
53				elatindex.parent().find('.readmorebtn').on('click.' + plugin, function (event) {
54					var targetindex = $(this).attr('data-target_index');
55					var readmorebtn = elatindex.parent().find('.readmorebtn');
56					plugin.collapseall();
57					readmorebtn.remove();
58					plugin.expand(elIndex, true);
59					plugin.readless(elIndex);
60				});
61			}
62		},
63		expand: function (elIndex, animate) {
64			var el = $(this.element);
65			var elatindex = el.find('.readmore-content[data-index="' + elIndex + '"]');
66			var elheight = elatindex.attr('data-height');
67			elatindex.attr('data-content', 'expanded');
68			elatindex.css({ 'overflow': 'hidden' });
69			switch (animate) {
70				case true:
71					elatindex.animate({
72						'height': elheight
73					}, plugin.settings.speed, 'linear');
74					break;
75				case false:
76					elatindex.csse({ 'height': elheight });
77					break;
78			}
79		},
80		readless: function (elIndex) {
81			var el = $(this.element);
82			var elatindex = el.find('.readmore-content[data-index="' + elIndex + '"]');
83			var elHeight = elatindex.height();
84			elatindex.parent().append('<button class="rmbtn readlessbtn ' + plugin.settings.btnclass + '" data-action="collapse" data-target_index="' + elIndex + '">Read Less</button>');
85			$('.readlessbtn[data-target_index="' + elIndex + '"]').on('click.' + plugin, function (event) {
86				var targetindex = $(this).attr('data-target_index');
87				var readlessbtn = $('.readlessbtn[data-target_index="' + elIndex + '"]');
88				if (readlessbtn.length) {
89					readlessbtn.remove();
90					plugin.collapse(elIndex, true);
91					plugin.readmore(elIndex);
92				}
93			});
94		}, collapseall: function () {
95			var el = $(this.element);
96			var expanded = el.find('.readmore-content[data-content="expanded"]');
97			if (expanded.length) {
98				expanded.each(function (index) {
99					var targetindex = $(this).attr('data-index');
100					$(this).parent().find('.readlessbtn').remove();
101					plugin.collapse(targetindex, true);
102					plugin.readmore(targetindex);
103				});
104			}
105		}
106	});
107	$.fn[pluginName] = function (options) {
108		return this.each(function () {
109			if (!$.data(this, "plugin_" + pluginName)) {
110				$.data(this, "plugin_" +
111					pluginName, new Plugin(this, options));
112			}
113		});
114	};
115	return this;
116})(jQuery, window, document);

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.