Sha256: 7458175cdadaf915eef32abae56c086c8a9bdc53450e91847f1b86cbe0f058b4

Contents?: true

Size: 740 Bytes

Versions: 28

Compression:

Stored size: 740 Bytes

Contents

/*
  Simple plugin to select form elements
  when other elements are clicked.
*/
(function($) {
  $.fn.selectRelatedInput = function() {
    var clickElements = this;

    $(clickElements).each(function() {
      var target = $($(this).data('input-select-target'));

      var event;

      if ($(this).is("select")) {
        event = 'change';
      } else {
        event = 'click';
      }

      $(this).on(event, function() {
        if (target.is(":checkbox") || target.is(":radio")) {
          target.prop('checked', true);
        } else {
          target.focus();
        }
      });
    });

    return this;
  };
})(jQuery);

export default class {
  connect() {
    $('[data-input-select-target]').selectRelatedInput();
  }
}

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
blacklight-spotlight-3.6.0.beta9 app/javascript/spotlight/admin/select_related_input.js
blacklight-spotlight-3.6.0.beta8 app/javascript/spotlight/admin/select_related_input.js
blacklight-spotlight-3.6.0.beta7 app/javascript/spotlight/admin/select_related_input.js
blacklight-spotlight-3.6.0.beta6 app/javascript/spotlight/admin/select_related_input.js
blacklight-spotlight-3.6.0.beta5 app/javascript/spotlight/admin/select_related_input.js
blacklight-spotlight-3.6.0.beta4 app/javascript/spotlight/admin/select_related_input.es6
blacklight-spotlight-3.6.0.beta3 app/javascript/spotlight/admin/select_related_input.es6
blacklight-spotlight-3.6.0.beta1 app/javascript/spotlight/admin/select_related_input.es6