Sha256: a59475cd333b0d2bc5cd7bca7d6d6456c1b0722bd64e84535e063ca96d724f4a

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

:css
  #batch-action-dropdown {
    display: none;
  }

%form{ method: 'post', id: 'batch-action-form' }
  = hidden_field_tag :authenticity_token, form_authenticity_token
.dropdown.batch-action-dropdown
  %button.btn.btn-default.dropdown-toggle{"aria-expanded" => "true", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button", id: 'batch-action-dropdown' }
    = t('.batch_actions')
    %span.caret
  %ul.dropdown-menu{"aria-labelledby" => 'batch-action-dropdown' }
    - options[:actions].each do |action, target|
      %li
        %a{ href: target, class: 'batch-action-form-submit-link' }= t(".#{action}")

:javascript
  $(document).ready(function() {
    $('.batch-action-checkbox').click(function() {
      var check_count = $('.batch-action-checkbox:checked').size();
      if( check_count > 0 ) {
        $("#batch-action-dropdown").show();
      } else {
        $("#batch-action-dropdown").hide();
      }
    });

    $('#batch-action-form').submit(function() {
      $('#batch-action-form input:checked').remove();
      var selected_items = $('.batch-action-checkbox:checked').clone();
      selected_items.css('display', 'none');
      $('#batch-action-form').append(selected_items);
      return true;
    });

    $('.batch-action-form-submit-link').click(function(e) {
        e.preventDefault();
        var target = $(this).attr('href');
        $("#batch-action-form").attr("action", target);
        $('#batch-action-form').submit();
    });
  });

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-add_ons-2.2.1 app/views/component/table/header_cells/_batch_actions.haml
rails-add_ons-2.2.0 app/views/component/table/header_cells/_batch_actions.haml