'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
/**
 * Created by geweimin on 17/5/27.
 */

var scrollListener = function scrollListener() {
  var activeElement = document.activeElement;
  /* eslint-disable */
  if (activeElement.className === 'mx-input mx-cascader-input ' || activeElement.className === 'mx-calendar' || activeElement.className.replace(/\ +/g, '').replace(/[\r\n]/g, '') === 'mx-select-selectionmx-select-selection--single') {
    var selectDropdowns = document.querySelectorAll(".mx-select-dropdown");
    var isClick = false;
    selectDropdowns.forEach(function (item) {
      if (item.className.indexOf('mx-select-dropdown-hidden') === -1) {
        activeElement.click();
        activeElement.blur();
        isClick = true;
      }
    });
    if (!isClick) {
      var mxCalendar = document.querySelector('.mx-calendar-picker-container');
      if (mxCalendar) {
        mxCalendar.style.display = 'none';
        activeElement.click();
        activeElement.blur();
      }
    }

    // document.querySelector('#root').click();
  }
  return false;
};

var addEventToBlurForm = exports.addEventToBlurForm = function addEventToBlurForm(ele) {
  ele && ele.addEventListener('scroll', scrollListener, { detailPage: true });
};

var removeEventToBlurForm = exports.removeEventToBlurForm = function removeEventToBlurForm(ele) {
  ele && ele.removeEventListener('scroll', scrollListener, { detailPage: true });
};