summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pages/projects/init_blob.js
blob: bc08ccf35846aa91c50072984bf2aa503e55832e (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
37
38
import LineHighlighter from '~/line_highlighter';
import BlobLinePermalinkUpdater from '~/blob/blob_line_permalink_updater';
import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation';
import ShortcutsBlob from '~/behaviors/shortcuts/shortcuts_blob';
import BlobForkSuggestion from '~/blob/blob_fork_suggestion';
import initBlobBundle from '~/blob_edit/blob_bundle';

export default () => {
  new LineHighlighter(); // eslint-disable-line no-new

  // eslint-disable-next-line no-new
  new BlobLinePermalinkUpdater(
    document.querySelector('#blob-content-holder'),
    '.diff-line-num[data-line-number]',
    document.querySelectorAll('.js-data-file-blob-permalink-url, .js-blob-blame-link'),
  );

  const fileBlobPermalinkUrlElement = document.querySelector('.js-data-file-blob-permalink-url');
  const fileBlobPermalinkUrl = fileBlobPermalinkUrlElement && fileBlobPermalinkUrlElement.getAttribute('href');

  new ShortcutsNavigation(); // eslint-disable-line no-new

  // eslint-disable-next-line no-new
  new ShortcutsBlob({
    skipResetBindings: true,
    fileBlobPermalinkUrl,
  });

  new BlobForkSuggestion({
    openButtons: document.querySelectorAll('.js-edit-blob-link-fork-toggler'),
    forkButtons: document.querySelectorAll('.js-fork-suggestion-button'),
    cancelButtons: document.querySelectorAll('.js-cancel-fork-suggestion-button'),
    suggestionSections: document.querySelectorAll('.js-file-fork-suggestion-section'),
    actionTextPieces: document.querySelectorAll('.js-file-fork-suggestion-section-action'),
  }).init();

  initBlobBundle();
};