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

Version Path
trusty-cms-6.3.1 app/assets/javascripts/admin/more-or-less.js
trusty-cms-7.0.2 app/assets/javascripts/admin/more-or-less.js
trusty-cms-7.0.1 app/assets/javascripts/admin/more-or-less.js
trusty-cms-7.0.0 app/assets/javascripts/admin/more-or-less.js
trusty-cms-6.3 app/assets/javascripts/admin/more-or-less.js
trusty-cms-6.2.1 app/assets/javascripts/admin/more-or-less.js
trusty-cms-6.2.2.1 app/assets/javascripts/admin/more-or-less.js
trusty-cms-6.2.0 app/assets/javascripts/admin/more-or-less.js
trusty-cms-6.1.2 app/assets/javascripts/admin/more-or-less.js
trusty-cms-6.1.1 app/assets/javascripts/admin/more-or-less.js
trusty-cms-6.0.5 app/assets/javascripts/admin/more-or-less.js
trusty-cms-6.0.4 app/assets/javascripts/admin/more-or-less.js
trusty-cms-6.0.3 app/assets/javascripts/admin/more-or-less.js
trusty-cms-6.0.2 app/assets/javascripts/admin/more-or-less.js
trusty-cms-6.0.1 app/assets/javascripts/admin/more-or-less.js
trusty-cms-5.6.1 app/assets/javascripts/admin/more-or-less.js
trusty-cms-6.0.0 app/assets/javascripts/admin/more-or-less.js
trusty-cms-5.6.0 app/assets/javascripts/admin/more-or-less.js
trusty-cms-5.5.9 app/assets/javascripts/admin/more-or-less.js
trusty-cms-5.5.8 app/assets/javascripts/admin/more-or-less.js