Sha256: 892fe63dd3858b7cb45ddab1ac23cce4d3c01b072203eaa067a82de2eb263fc3

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

/*
 * selection control focus
 * chrome persists the focus style on checkboxes/radio buttons after clicking
 */
var SelectionControlFocus = function ($) {
  // constants >>>
  var DATA_KEY = 'md.selectioncontrolfocus';
  var EVENT_KEY = "." + DATA_KEY;
  var ClassName = {
    FOCUS: 'focus'
  };
  var LastInteraction = {
    IS_MOUSEDOWN: false
  };
  var Event = {
    BLUR: "blur" + EVENT_KEY,
    FOCUS: "focus" + EVENT_KEY,
    MOUSEDOWN: "mousedown" + EVENT_KEY,
    MOUSEUP: "mouseup" + EVENT_KEY
  };
  var Selector = {
    CONTROL: '.custom-control',
    INPUT: '.custom-control-input' // <<< constants

  };
  $(document).on("" + Event.BLUR, Selector.INPUT, function () {
    $(this).removeClass(ClassName.FOCUS);
  }).on("" + Event.FOCUS, Selector.INPUT, function () {
    if (LastInteraction.IS_MOUSEDOWN === false) {
      $(this).addClass(ClassName.FOCUS);
    }
  }).on("" + Event.MOUSEDOWN, Selector.CONTROL, function () {
    LastInteraction.IS_MOUSEDOWN = true;
  }).on("" + Event.MOUSEUP, Selector.CONTROL, function () {
    setTimeout(function () {
      LastInteraction.IS_MOUSEDOWN = false;
    }, 1);
  });
}($);

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
material-sass-4.0.0 assets/javascripts/material/components/selection-control-focus.js