Sha256: dafe881ed4f2a1d46b303a4d438c14016202833b914066f0800dc97f6e2c3693

Contents?: true

Size: 1.7 KB

Versions: 26

Compression:

Stored size: 1.7 KB

Contents

var setup_toggle_list = function () {
  $(".list-group-toggler").click(function (e) {
    e.preventDefault();
    $(this).next('.list-group-item-child').toggleClass("is_open");
    $(this).find('.list-group-toggle-trigger').toggleClass("fa-plus fa-minus");
  });

  $('.list-group-link').on('click', function (e) {
    e.preventDefault();
    if(!$(this).parent().hasClass('list-group-toggler')) {

      var checkBox = $(this).next("input[type='checkbox']");
      checkBox.prop('checked', !checkBox.prop('checked'));

      if(checkBox.prop('checked')){
        $(this).toggleClass('list-group-link-is_active');
        $(this).append('<i class="fa fa-times"></i>');
        $(this).parents('.list-group-item').addClass('is_active');
      }
      else {
        $(this).toggleClass('list-group-link-is_active');
        $(this).find('i').remove();
        if( !$(this).parent().parents('.list-group-item').find('input:checkbox:checked').length) {
          $(this).parent().parents('.list-group-item').removeClass('is_active');
        }
      }

      $(this).parents('form[data-listToggle]').submit();
    }
  });

  var activeListItems = $('.list-group-link-is_active');

  if ($(activeListItems).length) {
    $(activeListItems).append('<i class="fa fa-times"></i>');
    $(activeListItems).next("input[type='checkbox']").prop('checked', true);
    $(activeListItems).addClass('list-group-link-is_active');
    $(activeListItems).parents('.list-group-item-child').addClass('is_open');
    $(activeListItems).parents('.list-group-item')
      .find('.list-group-toggle-trigger.fa')
      .removeClass('fa-plus')
      .addClass('fa-minus');
  }
};
$(document).ready(setup_toggle_list);
$(document).on('page:load', setup_toggle_list);

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
forever_style_guide-3.0.40 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.39 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.38 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.37 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.36 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.35 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.34 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.33 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.32 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.31 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.30 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.29 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.28 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.27 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.26 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.25 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.24 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.23 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.22 app/assets/javascripts/forever_style_guide/list-toggle.js
forever_style_guide-3.0.21 app/assets/javascripts/forever_style_guide/list-toggle.js