Skip to content
Snippets Groups Projects
dispatcher.js 21.9 KiB
Newer Older
  • Learn to ignore specific revisions
  • /* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, wrap-iife, no-shadow, consistent-return, one-var, one-var-declaration-per-line, camelcase, default-case, no-new, quotes, no-duplicate-case, no-case-declarations, no-fallthrough, max-len */
    
    /* global ProjectSelect */
    
    /* global IssuableIndex */
    
    /* global ShortcutsIssuable */
    /* global Milestone */
    /* global IssuableForm */
    /* global LabelsSelect */
    /* global MilestoneSelect */
    /* global Commit */
    
    /* global CommitsList */
    
    /* global NotificationsForm */
    /* global NotificationsDropdown */
    /* global GroupAvatar */
    /* global LineHighlighter */
    /* global ProjectFork */
    /* global BuildArtifacts */
    /* global GroupsSelect */
    /* global Search */
    /* global Admin */
    /* global NamespaceSelects */
    
    /* global NewCommitForm */
    /* global NewBranchForm */
    
    /* global Project */
    /* global ProjectAvatar */
    
    /* global MergeRequest */
    /* global Compare */
    
    /* global ProjectFindFile */
    
    /* global ProjectNew */
    /* global ProjectShow */
    
    /* global ProjectImport */
    
    /* global Labels */
    /* global Shortcuts */
    
    /* global ShortcutsFindFile */
    
    /* global Sidebar */
    
    /* global ShortcutsWiki */
    
    import Issue from './issue';
    
    Z.J. van de Weg's avatar
    Z.J. van de Weg committed
    import BindInOut from './behaviors/bind_in_out';
    
    import DeleteModal from './branches/branches_delete_modal';
    
    import Group from './group';
    
    import GroupName from './group_name';
    
    import GroupsList from './groups_list';
    
    import ProjectsList from './projects_list';
    
    import setupProjectEdit from './project_edit';
    
    import MiniPipelineGraph from './mini_pipeline_graph_dropdown';
    
    import BlobLinePermalinkUpdater from './blob/blob_line_permalink_updater';
    
    import Landing from './landing';
    
    import BlobForkSuggestion from './blob/blob_fork_suggestion';
    
    Mike Greiling's avatar
    Mike Greiling committed
    import UserCallout from './user_callout';
    
    geoandri's avatar
    geoandri committed
    import ShortcutsWiki from './shortcuts_wiki';
    
    import Pipelines from './pipelines';
    
    Douwe Maan's avatar
    Douwe Maan committed
    import BlobViewer from './blob/viewer/index';
    
    import AutoWidthDropdownSelect from './issuable/auto_width_dropdown_select';
    
    import UsersSelect from './users_select';
    
    import RefSelectDropdown from './ref_select_dropdown';
    
    import GfmAutoComplete from './gfm_auto_complete';
    
    import ShortcutsBlob from './shortcuts_blob';
    
    import SigninTabsMemoizer from './signin_tabs_memoizer';
    
    import Star from './star';
    
    import Todos from './todos';
    
    import TreeView from './tree';
    
    import UsagePing from './usage_ping';
    
    import UsernameValidator from './username_validator';
    
    import VersionCheckImage from './version_check_image';
    
    import Wikis from './wikis';
    
    import ZenMode from './zen_mode';
    
    import initSettingsPanels from './settings_panels';
    
    import initExperimentalFlags from './experimental_flags';
    
    import OAuthRememberMe from './oauth_remember_me';
    
    import PerformanceBar from './performance_bar';
    
    import initNotes from './init_notes';
    import initLegacyFilters from './init_legacy_filters';
    import initIssuableSidebar from './init_issuable_sidebar';
    
    import GpgBadges from './gpg_badges';
    
    Fatih Acet's avatar
    Fatih Acet committed
    (function() {
      var Dispatcher;
    
      Dispatcher = (function() {
        function Dispatcher() {
          this.initSearch();
    
          this.initFieldErrors();
    
    Fatih Acet's avatar
    Fatih Acet committed
          this.initPageScripts();
        }
    
        Dispatcher.prototype.initPageScripts = function() {
    
          var page, path, shortcut_handler, fileBlobPermalinkUrlElement, fileBlobPermalinkUrl;
    
    Fatih Acet's avatar
    Fatih Acet committed
          page = $('body').attr('data-page');
          if (!page) {
            return false;
          }
          path = page.split(':');
          shortcut_handler = null;
    
          $('.js-gfm-input').each((i, el) => {
            const gfm = new GfmAutoComplete(gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources);
            const enableGFM = gl.utils.convertPermissionToBoolean(el.dataset.supportsAutocomplete);
            gfm.setup($(el), {
              emojis: true,
              members: enableGFM,
              issues: enableGFM,
              milestones: enableGFM,
              mergeRequests: enableGFM,
              labels: enableGFM,
            });
          });
    
          function initBlob() {
            new LineHighlighter();
    
            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'),
            );
    
            shortcut_handler = new ShortcutsNavigation();
            fileBlobPermalinkUrlElement = document.querySelector('.js-data-file-blob-permalink-url');
            fileBlobPermalinkUrl = fileBlobPermalinkUrlElement && fileBlobPermalinkUrlElement.getAttribute('href');
            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'),
    
          const filteredSearchEnabled = gl.FilteredSearchManager && document.querySelector('.filtered-search');
    
    
    Fatih Acet's avatar
    Fatih Acet committed
          switch (page) {
    
            case 'profiles:preferences:show':
              initExperimentalFlags();
              break;
    
            case 'sessions:new':
              new UsernameValidator();
    
              new SigninTabsMemoizer();
    
              new OAuthRememberMe({ container: $(".omniauth-container") }).bindEvents();
    
            case 'projects:boards:show':
    
            case 'projects:boards:index':
    
              shortcut_handler = new ShortcutsNavigation();
    
              new UsersSelect();
    
            case 'projects:merge_requests:index':
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'projects:issues:index':
    
              if (filteredSearchEnabled) {
    
                const filteredSearchManager = new gl.FilteredSearchManager(page === 'projects:issues:index' ? 'issues' : 'merge_requests');
                filteredSearchManager.setup();
    
    Clement Ho's avatar
    Clement Ho committed
              }
    
              const pagePrefix = page === 'projects:merge_requests:index' ? 'merge_request_' : 'issue_';
              IssuableIndex.init(pagePrefix);
    
    
    Fatih Acet's avatar
    Fatih Acet committed
              shortcut_handler = new ShortcutsNavigation();
    
              new UsersSelect();
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
            case 'projects:issues:show':
              new Issue();
              shortcut_handler = new ShortcutsIssuable();
              new ZenMode();
    
              initIssuableSidebar();
              initNotes();
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
    
    Phil Hughes's avatar
    Phil Hughes committed
            case 'dashboard:milestones:index':
              new ProjectSelect();
              break;
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'projects:milestones:show':
            case 'groups:milestones:show':
            case 'dashboard:milestones:show':
              new Milestone();
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
    
            case 'dashboard:issues':
            case 'dashboard:merge_requests':
    
            case 'groups:merge_requests':
    
              new ProjectSelect();
    
              initLegacyFilters();
    
            case 'groups:issues':
              if (filteredSearchEnabled) {
                const filteredSearchManager = new gl.FilteredSearchManager('issues');
                filteredSearchManager.setup();
              }
              new ProjectSelect();
              break;
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'dashboard:todos:index':
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
    
            case 'dashboard:projects:index':
            case 'dashboard:projects:starred':
            case 'explore:projects:index':
            case 'explore:projects:trending':
            case 'explore:projects:starred':
            case 'admin:projects:index':
              new ProjectsList();
              break;
    
            case 'explore:groups:index':
              new GroupsList();
    
              const landingElement = document.querySelector('.js-explore-groups-landing');
              if (!landingElement) break;
              const exploreGroupsLanding = new Landing(
                landingElement,
                landingElement.querySelector('.dismiss-button'),
                'explore_groups_landing_dismissed',
              );
              exploreGroupsLanding.toggle();
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'projects:milestones:new':
            case 'projects:milestones:edit':
    
            case 'projects:milestones:update':
    
            case 'groups:milestones:new':
            case 'groups:milestones:edit':
            case 'groups:milestones:update':
    
    Fatih Acet's avatar
    Fatih Acet committed
              new ZenMode();
    
              new gl.DueDateSelectors();
    
              new gl.GLForm($('.milestone-form'), true);
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
            case 'projects:compare:show':
    
              new gl.Diff();
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
    
            case 'projects:branches:new':
            case 'projects:branches:create':
              new NewBranchForm($('.js-create-branch-form'), JSON.parse(document.getElementById('availableRefs').innerHTML));
              break;
    
            case 'projects:branches:index':
              gl.AjaxLoadingSpinner.init();
    
              new DeleteModal();
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'projects:issues:new':
            case 'projects:issues:edit':
              shortcut_handler = new ShortcutsNavigation();
    
              new gl.GLForm($('.issue-form'), true);
    
    Fatih Acet's avatar
    Fatih Acet committed
              new IssuableForm($('.issue-form'));
    
              new LabelsSelect();
              new MilestoneSelect();
    
              new gl.IssuableTemplateSelectors();
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
    
            case 'projects:merge_requests:creations:new':
    
              const mrNewCompareNode = document.querySelector('.js-merge-request-new-compare');
              if (mrNewCompareNode) {
                new Compare({
                  targetProjectUrl: mrNewCompareNode.dataset.targetProjectUrl,
                  sourceBranchUrl: mrNewCompareNode.dataset.sourceBranchUrl,
                  targetBranchUrl: mrNewCompareNode.dataset.targetBranchUrl,
                });
              } else {
                const mrNewSubmitNode = document.querySelector('.js-merge-request-new-submit');
                new MergeRequest({
                  action: mrNewSubmitNode.dataset.mrSubmitAction,
                });
              }
    
            case 'projects:merge_requests:creations:diffs':
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'projects:merge_requests:edit':
    
              new gl.Diff();
    
    Fatih Acet's avatar
    Fatih Acet committed
              shortcut_handler = new ShortcutsNavigation();
    
              new gl.GLForm($('.merge-request-form'), true);
    
    Fatih Acet's avatar
    Fatih Acet committed
              new IssuableForm($('.merge-request-form'));
    
              new LabelsSelect();
              new MilestoneSelect();
    
              new gl.IssuableTemplateSelectors();
    
              new AutoWidthDropdownSelect($('.js-target-branch-select')).init();
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
            case 'projects:tags:new':
              new ZenMode();
    
              new gl.GLForm($('.tag-form'), true);
    
              new RefSelectDropdown($('.js-branch-select'));
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
    
            case 'projects:snippets:show':
              initNotes();
              break;
    
            case 'projects:snippets:new':
            case 'projects:snippets:edit':
            case 'projects:snippets:create':
            case 'projects:snippets:update':
    
              new gl.GLForm($('.snippet-form'), true);
              break;
    
            case 'snippets:new':
            case 'snippets:edit':
            case 'snippets:create':
            case 'snippets:update':
    
              new gl.GLForm($('.snippet-form'), false);
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'projects:releases:edit':
              new ZenMode();
    
              new gl.GLForm($('.release-form'), true);
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
            case 'projects:merge_requests:show':
    
              new gl.Diff();
    
    Fatih Acet's avatar
    Fatih Acet committed
              shortcut_handler = new ShortcutsIssuable(true);
              new ZenMode();
    
              initIssuableSidebar();
              initNotes();
    
              const mrShowNode = document.querySelector('.merge-request');
              window.mergeRequest = new MergeRequest({
                action: mrShowNode.dataset.mrAction,
              });
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
            case 'dashboard:activity':
    
              new gl.Activities();
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
            case 'projects:commit:show':
              new Commit();
    
              new gl.Diff();
    
    Fatih Acet's avatar
    Fatih Acet committed
              new ZenMode();
              shortcut_handler = new ShortcutsNavigation();
    
              new MiniPipelineGraph({
                container: '.js-commit-pipeline-graph',
              }).bindEvents();
    
              initNotes();
    
              $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath);
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
    
            case 'projects:commit:pipelines':
    
              new MiniPipelineGraph({
    
                container: '.js-commit-pipeline-graph',
    
              }).bindEvents();
    
              $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath);
    
            case 'projects:activity':
              new gl.Activities();
    
              shortcut_handler = new ShortcutsNavigation();
              break;
    
            case 'projects:commits:show':
              CommitsList.init(document.querySelector('.js-project-commits-show').dataset.commitsLimit);
              new gl.Activities();
    
    Fatih Acet's avatar
    Fatih Acet committed
              shortcut_handler = new ShortcutsNavigation();
    
              GpgBadges.fetch();
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
            case 'projects:show':
              shortcut_handler = new ShortcutsNavigation();
              new NotificationsForm();
              if ($('#tree-slider').length) {
                new TreeView();
    
              }
              if ($('.blob-viewer').length) {
    
                new BlobViewer();
    
    Fatih Acet's avatar
    Fatih Acet committed
              }
              break;
    
              // Initialize expandable settings panels
              initSettingsPanels();
    
            case 'projects:imports:show':
              new ProjectImport();
              break;
    
            case 'projects:pipelines:new':
    
              new NewBranchForm($('.js-new-pipeline-form'));
    
    Filipa Lacerda's avatar
    Filipa Lacerda committed
            case 'projects:pipelines:builds':
    
            case 'projects:pipelines:failures':
    
            case 'projects:pipelines:show':
    
              const { controllerAction } = document.querySelector('.js-pipeline-container').dataset;
    
              const pipelineStatusUrl = `${document.querySelector('.js-pipeline-tab-link a').getAttribute('href')}/status.json`;
    
    Filipa Lacerda's avatar
    Filipa Lacerda committed
    
    
    Filipa Lacerda's avatar
    Filipa Lacerda committed
                initTabs: true,
    
    Filipa Lacerda's avatar
    Filipa Lacerda committed
                tabsOptions: {
                  action: controllerAction,
                  defaultAction: 'pipelines',
                  parentEl: '.pipelines-tabs',
                },
              });
    
              break;
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'groups:activity':
    
              new gl.Activities();
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
            case 'groups:show':
              shortcut_handler = new ShortcutsNavigation();
              new NotificationsForm();
              new NotificationsDropdown();
    
              new ProjectsList();
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
            case 'groups:group_members:index':
    
              new gl.MemberExpirationDate();
    
              new gl.Members();
    
    Fatih Acet's avatar
    Fatih Acet committed
              new UsersSelect();
              break;
    
            case 'projects:project_members:index':
    
              new gl.MemberExpirationDate('.js-access-expiration-date-groups');
              new GroupsSelect();
    
              new gl.MemberExpirationDate();
    
              new gl.Members();
    
    Fatih Acet's avatar
    Fatih Acet committed
              new UsersSelect();
              break;
            case 'groups:new':
    
    Luke "Jared" Bennett's avatar
    Luke "Jared" Bennett committed
            case 'admin:groups:new':
    
            case 'groups:create':
            case 'admin:groups:create':
    
    Z.J. van de Weg's avatar
    Z.J. van de Weg committed
              BindInOut.initAll();
    
              new Group();
              new GroupAvatar();
              break;
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'groups:edit':
            case 'admin:groups:edit':
              new GroupAvatar();
              break;
            case 'projects:tree:show':
              shortcut_handler = new ShortcutsNavigation();
              new TreeView();
    
              new BlobViewer();
    
              new NewCommitForm($('.js-create-dir-form'));
    
              $('#tree-slider').waitForImages(function() {
                gl.utils.ajaxGet(document.querySelector('.js-tree-content').dataset.logsPath);
              });
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
            case 'projects:find_file:show':
    
              const findElement = document.querySelector('.js-file-finder');
              const projectFindFile = new ProjectFindFile($(".file-finder-holder"), {
                url: findElement.dataset.fileFindUrl,
                treeUrl: findElement.dataset.findTreeUrl,
                blobUrlTemplate: findElement.dataset.blobUrlTemplate,
              });
              new ShortcutsFindFile(projectFindFile);
    
    Fatih Acet's avatar
    Fatih Acet committed
              shortcut_handler = true;
              break;
            case 'projects:blob:show':
    
    Douwe Maan's avatar
    Douwe Maan committed
              new BlobViewer();
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'projects:blame:show':
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
    
            case 'groups:labels:new':
            case 'groups:labels:edit':
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'projects:labels:new':
            case 'projects:labels:edit':
              new Labels();
              break;
    
            case 'groups:labels:index':
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'projects:labels:index':
              if ($('.prioritized-labels').length) {
    
                new gl.LabelManager();
    
    Fatih Acet's avatar
    Fatih Acet committed
              }
    
              $('.label-subscription').each((i, el) => {
                const $el = $(el);
    
                if ($el.find('.dropdown-group-label').length) {
                  new gl.GroupLabelSubscription($el);
                } else {
                  new gl.ProjectLabelSubscription($el);
                }
              });
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
            case 'projects:network:show':
    
              // Ensure we don't create a particular shortcut handler here. This is
              // already created, where the network graph is created.
    
    Fatih Acet's avatar
    Fatih Acet committed
              shortcut_handler = true;
              break;
            case 'projects:forks:new':
              new ProjectFork();
              break;
            case 'projects:artifacts:browse':
    
              new ShortcutsNavigation();
    
    Fatih Acet's avatar
    Fatih Acet committed
              new BuildArtifacts();
              break;
    
            case 'projects:artifacts:file':
    
              new ShortcutsNavigation();
    
              new BlobViewer();
              break;
    
              VersionCheckImage.bindErrorEvent($('img.js-version-status-badge'));
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'search:show':
              new Search();
    
            case 'projects:settings:repository:show':
    
              // Initialize expandable settings panels
              initSettingsPanels();
    
            case 'projects:settings:ci_cd:show':
    
    Shinya Maeda's avatar
    Shinya Maeda committed
            case 'groups:settings:ci_cd:show':
    
              new gl.ProjectVariables();
              break;
    
            case 'ci:lints:create':
            case 'ci:lints:show':
              new gl.CILintEditor();
              break;
    
            case 'admin:conversational_development_index:show':
              new UserCallout();
              break;
    
            case 'snippets:show':
              new LineHighlighter();
              new BlobViewer();
    
              initNotes();
    
              break;
    
            case 'import:fogbugz:new_user_map':
              new UsersSelect();
              break;
    
            case 'profiles:personal_access_tokens:index':
            case 'admin:impersonation_tokens:index':
              new gl.DueDateSelectors();
              break;
    
    Fatih Acet's avatar
    Fatih Acet committed
          }
    
            case 'sessions':
            case 'omniauth_callbacks':
              if (!gon.u2f) break;
              gl.u2fAuthenticate = new gl.U2FAuthenticate(
                $('#js-authenticate-u2f'),
                '#js-login-u2f-form',
                gon.u2f,
                document.querySelector('#js-login-2fa-device'),
                document.querySelector('.js-2fa-form'),
              );
              gl.u2fAuthenticate.start();
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'admin':
              new Admin();
              switch (path[1]) {
    
                case 'cohorts':
    
    Fatih Acet's avatar
    Fatih Acet committed
                case 'groups':
                  new UsersSelect();
                  break;
                case 'projects':
                  new NamespaceSelects();
    
                    case 'edit':
                      new Labels();
                  }
    
                case 'abuse_reports':
    
                  new gl.AbuseReports();
    
    Fatih Acet's avatar
    Fatih Acet committed
              }
              break;
            case 'dashboard':
            case 'root':
    
    Fatih Acet's avatar
    Fatih Acet committed
              break;
    
            case 'groups':
              new GroupName();
              break;
    
    Fatih Acet's avatar
    Fatih Acet committed
            case 'profiles':
              new NotificationsForm();
              new NotificationsDropdown();
              break;
            case 'projects':
              new Project();
              new ProjectAvatar();
    
              new GroupName();
    
    Fatih Acet's avatar
    Fatih Acet committed
              switch (path[1]) {
                case 'compare':
                  new CompareAutocomplete();
                  break;
                case 'edit':
                  shortcut_handler = new ShortcutsNavigation();
                  new ProjectNew();
                  break;
                case 'new':
                  new ProjectNew();
                  break;
                case 'show':
    
    Fatih Acet's avatar
    Fatih Acet committed
                  new ProjectNew();
                  new ProjectShow();
                  new NotificationsDropdown();
                  break;
                case 'wikis':
    
                  shortcut_handler = new ShortcutsWiki();
    
    Fatih Acet's avatar
    Fatih Acet committed
                  new ZenMode();
    
                  new gl.GLForm($('.wiki-form'), true);
    
                  new Sidebar();
    
    Fatih Acet's avatar
    Fatih Acet committed
                  break;
                case 'snippets':
                  shortcut_handler = new ShortcutsNavigation();
                  if (path[2] === 'show') {
                    new ZenMode();
    
                    new LineHighlighter();
                    new BlobViewer();
    
    Fatih Acet's avatar
    Fatih Acet committed
                  }
                  break;
                case 'labels':
                case 'graphs':
                case 'compare':
                case 'pipelines':
                case 'forks':
                case 'milestones':
                case 'project_members':
                case 'deploy_keys':
                case 'builds':
                case 'hooks':
                case 'services':
                case 'protected_branches':
                  shortcut_handler = new ShortcutsNavigation();
              }
    
              break;
            case 'users':
              const action = path[1];
              import(/* webpackChunkName: 'user_profile' */ './users')
                .then(user => user.default(action))
                .catch(() => {});
              break;
    
    Fatih Acet's avatar
    Fatih Acet committed
          }
    
          // If we haven't installed a custom shortcut handler, install the default one
    
    Fatih Acet's avatar
    Fatih Acet committed
          if (!shortcut_handler) {
    
    Fatih Acet's avatar
    Fatih Acet committed
          }
    
    
          if (document.querySelector('#peek')) {
            new PerformanceBar({ container: '#peek' });
          }
    
    Fatih Acet's avatar
    Fatih Acet committed
        };
    
        Dispatcher.prototype.initSearch = function() {
    
          // Only when search form is present
    
    Fatih Acet's avatar
    Fatih Acet committed
          if ($('.search').length) {
    
            return new gl.SearchAutocomplete();
    
        Dispatcher.prototype.initFieldErrors = function() {
    
          $('.gl-show-field-errors').each((i, form) => {
    
            new gl.GlFieldErrors(form);
          });
    
    Fatih Acet's avatar
    Fatih Acet committed
        return Dispatcher;
      })();