summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/boards/mixins/sortable_default_options.js.es6
blob: e520170ef74f7bfeb72b3c43b543bcdbee91f51d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* eslint-disable */
((w) => {
  window.gl = window.gl || {};
  window.gl.issueBoards = window.gl.issueBoards || {};

  gl.issueBoards.onStart = () => {
    $('.has-tooltip').tooltip('hide')
      .tooltip('disable');
    document.body.classList.add('is-dragging');
  };

  gl.issueBoards.onEnd = () => {
    $('.has-tooltip').tooltip('enable');
    document.body.classList.remove('is-dragging');
  };

  gl.issueBoards.touchEnabled = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch;

  gl.issueBoards.getBoardSortableDefaultOptions = (obj) => {
    let defaultSortOptions = {
      forceFallback: true,
      fallbackClass: 'is-dragging',
      fallbackOnBody: true,
      ghostClass: 'is-ghost',
      filter: '.has-tooltip, .btn',
      delay: gl.issueBoards.touchEnabled ? 100 : 50,
      scrollSensitivity: gl.issueBoards.touchEnabled ? 60 : 100,
      scrollSpeed: 20,
      onStart: gl.issueBoards.onStart,
      onEnd: gl.issueBoards.onEnd
    }

    Object.keys(obj).forEach((key) => { defaultSortOptions[key] = obj[key]; });
    return defaultSortOptions;
  };
})(window);