Sha256: ff209564d489d1824957f707dd63d09da3f80f0db1922e50147ead474616419e
Contents?: true
Size: 1.01 KB
Versions: 74
Compression:
Stored size: 1.01 KB
Contents
(function(MoreOrLess, $) { MoreOrLess.setupToggle = function (link){ if (link.innerHTML.match(/less/i)) { MoreOrLess.toggle(link); } $(link).on('click', function(event){ event.preventDefault(); MoreOrLess.toggle(this); }); } MoreOrLess.toggle = function(link) { var elements = MoreOrLess.extractToggleObjects($(link).attr('rel')); $(elements).slideToggle(); $(link).toggleClass('less more'); if (link.innerHTML.match(/less/i)) { link.innerHTML = 'More <i class="fas fa-angle-down"></i>'; } else if (link.innerHTML.match(/more/i)) { link.innerHTML = 'Less <i class="fas fa-angle-up"></i>'; } } MoreOrLess.extractToggleObjects = function(rel) { var matches = rel.match(/^toggle\[(.+)\]$/); if (matches) { var ids = matches[1].split(','); return $("#" + ids.join(", #")); } } }(window.MoreOrLess = window.MoreOrLess || {}, jQuery)); $(function () { $('a.toggle').each(function(){ MoreOrLess.setupToggle(this); }); });
Version data entries
74 entries across 74 versions & 1 rubygems