All Downloads are FREE. Search and download functionalities are using the official Maven repository.

.selenide-core.7.3.3.source-code.drag_and_drop_script.js Maven / Gradle / Ivy

There is a newer version: 7.6.1
Show newest version
(function() {
  function createEvent(typeOfEvent) {
    var event = document.createEvent("CustomEvent");
    event.initCustomEvent(typeOfEvent, true, true, null);
    event.dataTransfer = {
      data: {},
      setData: function(key, value) {
        this.data[key] = value;
      },
      getData: function(key) {
        return this.data[key];
      }
    };
    return event;
  }

  function dispatchEvent(element, event, transferData) {
    if (transferData !== undefined) {
      event.dataTransfer = transferData;
    }
    if (element.dispatchEvent) {
      element.dispatchEvent(event);
    } else if (element.fireEvent) {
      element.fireEvent("on" + event.type, event);
    }
  }

  function dragAndDrop(element, target) {
    var dragStartEvent = createEvent('dragstart');
    dispatchEvent(element, dragStartEvent);
    var dropEvent = createEvent('drop');
    dispatchEvent(target, dropEvent, dragStartEvent.dataTransfer);
    var dragEndEvent = createEvent('dragend');
    dispatchEvent(element, dragEndEvent, dropEvent.dataTransfer);
  }

  return dragAndDrop(arguments[0], arguments[1]);
})(...arguments)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy