Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 13:00:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 13:00:54 +0300
commit3cccd102ba543e02725d247893729e5c73b38295 (patch)
treef36a04ec38517f5deaaacb5acc7d949688d1e187 /app/assets/javascripts/sortable
parent205943281328046ef7b4528031b90fbda70c75ac (diff)
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'app/assets/javascripts/sortable')
-rw-r--r--app/assets/javascripts/sortable/constants.js19
-rw-r--r--app/assets/javascripts/sortable/sortable_config.js8
-rw-r--r--app/assets/javascripts/sortable/utils.js31
3 files changed, 50 insertions, 8 deletions
diff --git a/app/assets/javascripts/sortable/constants.js b/app/assets/javascripts/sortable/constants.js
new file mode 100644
index 00000000000..7fddac00ab2
--- /dev/null
+++ b/app/assets/javascripts/sortable/constants.js
@@ -0,0 +1,19 @@
+/**
+ * Default config options for sortablejs.
+ * @type {object}
+ *
+ * @example
+ * import Sortable from 'sortablejs';
+ *
+ * const sortable = Sortable.create(el, {
+ * ...defaultSortableOptions,
+ * });
+ */
+export const defaultSortableOptions = {
+ animation: 200,
+ forceFallback: true,
+ fallbackClass: 'is-dragging',
+ fallbackOnBody: true,
+ ghostClass: 'is-ghost',
+ fallbackTolerance: 1,
+};
diff --git a/app/assets/javascripts/sortable/sortable_config.js b/app/assets/javascripts/sortable/sortable_config.js
deleted file mode 100644
index a4c4cb7f101..00000000000
--- a/app/assets/javascripts/sortable/sortable_config.js
+++ /dev/null
@@ -1,8 +0,0 @@
-export default {
- animation: 200,
- forceFallback: true,
- fallbackClass: 'is-dragging',
- fallbackOnBody: true,
- ghostClass: 'is-ghost',
- fallbackTolerance: 1,
-};
diff --git a/app/assets/javascripts/sortable/utils.js b/app/assets/javascripts/sortable/utils.js
new file mode 100644
index 00000000000..c2c8fb03b58
--- /dev/null
+++ b/app/assets/javascripts/sortable/utils.js
@@ -0,0 +1,31 @@
+/* global DocumentTouch */
+
+import { defaultSortableOptions } from './constants';
+
+export function sortableStart() {
+ document.body.classList.add('is-dragging');
+}
+
+export function sortableEnd() {
+ document.body.classList.remove('is-dragging');
+}
+
+export function getSortableDefaultOptions(options) {
+ const touchEnabled =
+ 'ontouchstart' in window || (window.DocumentTouch && document instanceof DocumentTouch);
+
+ const defaultSortOptions = {
+ ...defaultSortableOptions,
+ filter: '.no-drag',
+ delay: touchEnabled ? 100 : 0,
+ scrollSensitivity: touchEnabled ? 60 : 100,
+ scrollSpeed: 20,
+ onStart: sortableStart,
+ onEnd: sortableEnd,
+ };
+
+ return {
+ ...defaultSortOptions,
+ ...options,
+ };
+}