當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript hideOnEscapeOrOutsideClick.hideOnEscapeOrOutsideClick函數代碼示例

本文整理匯總了TypeScript中app/utils/hideOnEscapeOrOutsideClick.hideOnEscapeOrOutsideClick函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript hideOnEscapeOrOutsideClick函數的具體用法?TypeScript hideOnEscapeOrOutsideClick怎麽用?TypeScript hideOnEscapeOrOutsideClick使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了hideOnEscapeOrOutsideClick函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: createDatePickerButton

function createDatePickerButton(dateField) {
  var style = {
    width: '20px',
    height: '20px',
    padding: '0',
    border: 'none',
    backgroundColor: 'transparent',
    backgroundImage: 'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAJCAYAAAF4VF24AAAAAXNSR0IArs4c6QAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAAAG9JREFUGBltTu0RgCAIFc4FWiHdoJ1sptqpWVrAg3x2eHTGDx+8DyQEVEqp9CbkNSvhwTiaV/PMLFnIsK9C0Ig54lW4GISvT0RJ906Q0iksV8MDbggsvDUs3VClLn6N9ZHjPc4BiU/tPJujuYF/mx55tzEWYjQMAAAAAABJRU5ErkJggg==")',
    backgroundPosition: '50% 50%',
    backgroundRepeat: 'no-repeat',
    marginTop: '2px',
    marginLeft: '-18px',
    position: 'absolute'
  };

  var attributes = {
    'title': 'Deschide calendarul'
  };

  var button = createDOMElement('button', style, attributes);

  makeShy(button);
  button.addEventListener('click', toggleDatePickerFor(dateField));
  hideOnEscapeOrOutsideClick(DatePicker.instance);

  return button;
}
開發者ID:gurdiga,項目名稱:xo,代碼行數:27,代碼來源:DateFieldInput.ts

示例2: it

  it('works with a thing that has a `hide` method', function() {
    var thing = { hide: createSpy() };

    hideOnEscapeOrOutsideClick(thing);

    document.body.dispatchEvent(new Event('click'));
    assert.equal(thing.hide.calls.length, 1, 'calls thing’s hide method when clicking the body');

    simulateEscapeKey();
    assert.equal(thing.hide.calls.length, 2, 'calls thing’s hide method when pressing the Esc key');
  });
開發者ID:gurdiga,項目名稱:xo,代碼行數:11,代碼來源:hideOnEscapeOrOutsideClickTest.ts

示例3: addEventListeners

function addEventListeners(toggleButton, optionList) {
  toggleButton.addEventListener('click', optionList.toggle);
  toggleButton.addEventListener('keydown', ifKey('ArrowDown', selectFirstOption));
  toggleButton.addEventListener('keydown', ifKey('ArrowUp', selectLastOption));
  toggleButton.addEventListener('keydown', ifKey('Enter', optionList.executeSelectedOption));
  hideOnEscapeOrOutsideClick(optionList);

  addFocusEffect(toggleButton, {
    boxShadow: 'rgb(181, 213, 255) 0px 0px 3px 2px'
  });

  function selectFirstOption() {
    optionList.show();
    optionList.selectNext();
  }

  function selectLastOption() {
    optionList.show();
    optionList.selectPrevious();
  }
}
開發者ID:gurdiga,項目名稱:xo,代碼行數:21,代碼來源:DropdownButton.ts

示例4: hideOnEscapeOrOutsideClick

 assert.throws(function() {
   hideOnEscapeOrOutsideClick(42);
 },
開發者ID:gurdiga,項目名稱:xo,代碼行數:3,代碼來源:hideOnEscapeOrOutsideClickTest.ts


注:本文中的app/utils/hideOnEscapeOrOutsideClick.hideOnEscapeOrOutsideClick函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。