How to use the basis.dom.event.addGlobalHandler function in basis

To help you get started, we’ve selected a few basis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github basisjs / basisjs / src / basis / tracker.js View on Github external
function getSelectorList(eventName){
  if (hasOwnProperty.call(eventMap, eventName))
    return eventMap[eventName];

  var selectorList = eventMap[eventName] = [];

  switch (eventName) {
    case 'show':
      selectorList.visible = {};
      setInterval(checkShow, VISIBLE_CHECK_INTERVAL);
      break;

    default:
      eventUtils.addGlobalHandler(eventName, function(event){
        var path = event.path.reduce(function(res, node){
          var role = node.getAttribute ? node.getAttribute('role-marker') : null;
          if (role)
            res.unshift(parseRole(role));
          return res;
        }, []);

        if (path.length)
          selectorList.forEach(function(item){
            if (isPathMatchSelector(path, item.selector))
              track({
                type: 'ui',
                path: stringifyPath(path),
                selector: stringifyPath(item.selector),
                event: event.type,
                data: item.data
github basisjs / basisjs / src / devpanel / inspector / template.js View on Github external
function startInspect(){
  if (!inspecting)
  {
    if (templateInfo.isResolved())
      templateInfo().set();

    domEventUtils.addGlobalHandler('mousemove', mousemoveHandler);
    domEventUtils.addGlobalHandler('mousewheel', mouseWheelHandler);
    domEventUtils.addGlobalHandler('wheel', mouseWheelHandler);
    domEventUtils.addGlobalHandler('DOMMouseScroll', mouseWheelHandler);
    inspectBasisEvent.captureEvent('mousedown', domEventUtils.kill);
    inspectBasisEvent.captureEvent('mouseup', domEventUtils.kill);
    inspectBasisEvent.captureEvent('contextmenu', stopInspect);
    inspectBasisEvent.captureEvent('click', pickHandler);

    inspecting = true;
  }
}
github lahmatiy / component-inspector / src / backbone / inspector / template.js View on Github external
function startInspect(){
  if (!inspectMode.value)
  {
    if (templateInfo.isResolved())
      templateInfo().set();

    domEventUtils.addGlobalHandler('mousemove', mousemoveHandler);
    domEventUtils.addGlobalHandler('mousewheel', mouseWheelHandler);
    domEventUtils.addGlobalHandler('wheel', mouseWheelHandler);
    domEventUtils.addGlobalHandler('DOMMouseScroll', mouseWheelHandler);
    domEventUtils.addGlobalHandler('mousedown', domEventUtils.kill);
    domEventUtils.addGlobalHandler('mouseup', domEventUtils.kill);
    domEventUtils.addGlobalHandler('contextmenu', function(e){
      e.die();
      stopInspect();
    });
    domEventUtils.addGlobalHandler('click', pickHandler);

    inspectMode.set(true);
  }
}
github lahmatiy / component-inspector / src / inspector-rempl / publisher / picker / index.js View on Github external
function startInspect() {
  if (!inspectMode.value) {
    selectedNode.set();

    domEventUtils.addGlobalHandler('mousemove', mousemoveHandler);
    domEventUtils.addGlobalHandler('mousewheel', mouseWheelHandler);
    domEventUtils.addGlobalHandler('wheel', mouseWheelHandler);
    domEventUtils.addGlobalHandler('DOMMouseScroll', mouseWheelHandler);
    domEventUtils.addGlobalHandler('mousedown', domEventUtils.kill);
    domEventUtils.addGlobalHandler('mouseup', domEventUtils.kill);
    domEventUtils.addGlobalHandler('contextmenu', contextmenuHandler);
    domEventUtils.addGlobalHandler('click', pickHandler);

    inspectMode.set(true);
  }
}
github lahmatiy / component-inspector / src / inspector-rempl / publisher / picker / index.js View on Github external
function startInspect() {
  if (!inspectMode.value) {
    selectedNode.set();

    domEventUtils.addGlobalHandler('mousemove', mousemoveHandler);
    domEventUtils.addGlobalHandler('mousewheel', mouseWheelHandler);
    domEventUtils.addGlobalHandler('wheel', mouseWheelHandler);
    domEventUtils.addGlobalHandler('DOMMouseScroll', mouseWheelHandler);
    domEventUtils.addGlobalHandler('mousedown', domEventUtils.kill);
    domEventUtils.addGlobalHandler('mouseup', domEventUtils.kill);
    domEventUtils.addGlobalHandler('contextmenu', contextmenuHandler);
    domEventUtils.addGlobalHandler('click', pickHandler);

    inspectMode.set(true);
  }
}
github basisjs / basisjs / src / basis / ui / popup.js View on Github external
emit_childNodesModified: function(delta){
      if (delta.deleted)
        for (var i = delta.deleted.length - 1, item; item = delta.deleted[i]; i--)
          item.hide();

      if (delta.inserted && !delta.deleted && this.childNodes.length == delta.inserted.length)
      {
        Event.addGlobalHandler('click', this.hideByClick, this);
        Event.addGlobalHandler('keydown', this.hideByKey, this);
        Event.addGlobalHandler('scroll', this.hideByScroll, this);
        Event.addHandler(window, 'resize', this.realignAll, this);
      }

      if (this.lastChild)
        this.lastChild.select();
      else
      {
        Event.removeGlobalHandler('click', this.hideByClick, this);
        Event.removeGlobalHandler('keydown', this.hideByKey, this);
        Event.removeGlobalHandler('scroll', this.hideByScroll, this);
        Event.removeHandler(window, 'resize', this.realignAll, this);
      }

      UINode.prototype.emit_childNodesModified.call(this, delta);
    },
github basisjs / basisjs / src / basis / ui / scroller.js View on Github external
onMouseDown: function(event){
      this.stopUpdate();

      this.panningActive = true;
      this.isMoved = false;

      this.lastMouseX = event.mouseX;
      this.lastMouseY = event.mouseY;

      this.lastMotionUpdateTime = Date.now();

      Event.addGlobalHandler('mousemove', this.onMouseMove, this);
      Event.addGlobalHandler('touchmove', this.onMouseMove, this);
      Event.addGlobalHandler('mouseup', this.onMouseUp, this);
      Event.addGlobalHandler('touchend', this.onMouseUp, this);

      event.preventDefault();
    },
github lahmatiy / component-inspector / src / inspector-rempl / publisher / picker / index.js View on Github external
function startInspect() {
  if (!inspectMode.value) {
    selectedNode.set();

    domEventUtils.addGlobalHandler('mousemove', mousemoveHandler);
    domEventUtils.addGlobalHandler('mousewheel', mouseWheelHandler);
    domEventUtils.addGlobalHandler('wheel', mouseWheelHandler);
    domEventUtils.addGlobalHandler('DOMMouseScroll', mouseWheelHandler);
    domEventUtils.addGlobalHandler('mousedown', domEventUtils.kill);
    domEventUtils.addGlobalHandler('mouseup', domEventUtils.kill);
    domEventUtils.addGlobalHandler('contextmenu', contextmenuHandler);
    domEventUtils.addGlobalHandler('click', pickHandler);

    inspectMode.set(true);
  }
}
github basisjs / basisjs / src / basis / template / buildDom.js View on Github external
tmplEventListeners[eventName] = createEventHandler('event-' + eventName);

  if (USE_CAPTURE_FALLBACK)
    return;

  if (!MOUSE_ENTER_LEAVE_SUPPORT)
  {
    if (eventName == 'mouseenter')
      return emulateEvent(eventName, 'mouseover');
    if (eventName == 'mouseleave')
      return emulateEvent(eventName, 'mouseout');
  }

  for (var i = 0, names = eventUtils.browserEvents(eventName), browserEventName; browserEventName = names[i]; i++)
    eventUtils.addGlobalHandler(browserEventName, tmplEventListeners[eventName]);
}