Sha256: 4b06ddb3711b0a694490aefe9b803c0868ecec5e536a8684d9f5fbb31b8e32b7

Contents?: true

Size: 801 Bytes

Versions: 5

Compression:

Stored size: 801 Bytes

Contents

"use strict";

$("[data-checkboxes]").each(function() {
  var me = $(this),
    group = me.data('checkboxes'),
    role = me.data('checkbox-role');

  me.change(function() {
    var all = $('[data-checkboxes="' + group + '"]:not([data-checkbox-role="dad"])'),
      checked = $('[data-checkboxes="' + group + '"]:not([data-checkbox-role="dad"]):checked'),
      dad = $('[data-checkboxes="' + group + '"][data-checkbox-role="dad"]'),
      total = all.length,
      checked_length = checked.length;

    if(role == 'dad') {
      if(me.is(':checked')) {
        all.prop('checked', true);
      }else{
        all.prop('checked', false);
      }
    }else{
      if(checked_length >= total) {
        dad.prop('checked', true);
      }else{
        dad.prop('checked', false);
      }
    }
  });
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stisla-rails-0.2.0 vendor/assets/javascripts/page/features-posts.js
stisla-rails-0.1.5 vendor/assets/javascripts/page/features-posts.js
stisla-rails-0.1.4 vendor/assets/javascripts/page/features-posts.js
stisla-rails-0.1.3 vendor/assets/javascripts/page/features-posts.js
stisla-rails-0.0.2 vendor/assets/javascripts/page/features-posts.js