Sha256: aefa96e17a2d2d0eee41ce99fc14030b49d9b7b4a40c42e3a5b3775cd226c49a

Contents?: true

Size: 1.5 KB

Versions: 47

Compression:

Stored size: 1.5 KB

Contents

import { IE11OrLess, Edge } from './BrowserInfo.js';
import { expando } from './utils.js';
import PluginManager from './PluginManager.js';

export default function dispatchEvent(
	{
		sortable, rootEl, name,
		targetEl, cloneEl, toEl, fromEl,
		oldIndex, newIndex,
		oldDraggableIndex, newDraggableIndex,
		originalEvent, putSortable, extraEventProperties
	}
) {
	sortable = (sortable || (rootEl && rootEl[expando]));
	if (!sortable) return;

	let evt,
		options = sortable.options,
		onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
	// Support for new CustomEvent feature
	if (window.CustomEvent && !IE11OrLess && !Edge) {
		evt = new CustomEvent(name, {
			bubbles: true,
			cancelable: true
		});
	} else {
		evt = document.createEvent('Event');
		evt.initEvent(name, true, true);
	}

	evt.to = toEl || rootEl;
	evt.from = fromEl || rootEl;
	evt.item = targetEl || rootEl;
	evt.clone = cloneEl;

	evt.oldIndex = oldIndex;
	evt.newIndex = newIndex;

	evt.oldDraggableIndex = oldDraggableIndex;
	evt.newDraggableIndex = newDraggableIndex;

	evt.originalEvent = originalEvent;
	evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;

	let allEventProperties = { ...extraEventProperties, ...PluginManager.getEventProperties(name, sortable) };
	for (let option in allEventProperties) {
		evt[option] = allEventProperties[option];
	}

	if (rootEl) {
		rootEl.dispatchEvent(evt);
	}

	if (options[onName]) {
		options[onName].call(sortable, evt);
	}
}

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
govuk_publishing_components-49.1.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-49.0.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-48.0.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-47.0.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-46.4.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-46.3.1 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-46.3.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-46.2.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-46.1.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-46.0.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-45.10.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-45.9.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-45.8.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-45.7.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-45.6.1 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-45.6.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-45.5.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-45.4.1 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-45.4.0 node_modules/sortablejs/src/EventDispatcher.js
govuk_publishing_components-45.3.0 node_modules/sortablejs/src/EventDispatcher.js