dispatcher.js 20.9 KB
Newer Older
1
/* 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 */
F
Filipa Lacerda 已提交
2
import Milestone from './milestone';
P
Phil Hughes 已提交
3
import notificationsDropdown from './notifications_dropdown';
P
Phil Hughes 已提交
4 5 6
import LineHighlighter from './line_highlighter';
import MergeRequest from './merge_request';
import Sidebar from './right_sidebar';
7
import Flash from './flash';
D
Douwe Maan 已提交
8
import BlobViewer from './blob/viewer/index';
9
import GfmAutoComplete from './gfm_auto_complete';
10
import Star from './star';
11
import ZenMode from './zen_mode';
12
import PerformanceBar from './performance_bar';
P
Phil Hughes 已提交
13 14
import initNotes from './init_notes';
import initIssuableSidebar from './init_issuable_sidebar';
C
Clement Ho 已提交
15
import { convertPermissionToBoolean } from './lib/utils/common_utils';
16
import GlFieldErrors from './gl_field_errors';
17 18
import Shortcuts from './shortcuts';
import ShortcutsIssuable from './shortcuts_issuable';
19
import Diff from './diff';
F
Filipa Lacerda 已提交
20
import SearchAutocomplete from './search_autocomplete';
21

F
Fatih Acet 已提交
22 23 24 25 26 27
(function() {
  var Dispatcher;

  Dispatcher = (function() {
    function Dispatcher() {
      this.initSearch();
28
      this.initFieldErrors();
F
Fatih Acet 已提交
29 30 31 32
      this.initPageScripts();
    }

    Dispatcher.prototype.initPageScripts = function() {
33
      var path, shortcut_handler;
34
      const page = $('body').attr('data-page');
F
Fatih Acet 已提交
35 36 37
      if (!page) {
        return false;
      }
38

39
      const fail = () => Flash('Error loading dynamic module');
40
      const callDefault = m => m.default();
41

F
Fatih Acet 已提交
42 43
      path = page.split(':');
      shortcut_handler = null;
44

F
Filipa Lacerda 已提交
45
      $('.js-gfm-input:not(.js-vue-textarea)').each((i, el) => {
46
        const gfm = new GfmAutoComplete(gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources);
47
        const enableGFM = convertPermissionToBoolean(el.dataset.supportsAutocomplete);
48 49 50 51 52 53 54 55 56
        gfm.setup($(el), {
          emojis: true,
          members: enableGFM,
          issues: enableGFM,
          milestones: enableGFM,
          mergeRequests: enableGFM,
          labels: enableGFM,
        });
      });
57

F
Fatih Acet 已提交
58
      switch (page) {
59
        case 'sessions:new':
C
Clement Ho 已提交
60 61 62
          import('./pages/sessions/new')
            .then(callDefault)
            .catch(fail);
63
          break;
64
        case 'projects:boards:show':
65
        case 'projects:boards:index':
66 67 68 69
          import('./pages/projects/boards/index')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
70
          break;
71
        case 'projects:merge_requests:index':
72 73 74 75
          import('./pages/projects/merge_requests/index')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
76
          break;
S
Simon Knox 已提交
77 78 79 80 81 82
        case 'projects:issues:index':
          import('./pages/projects/issues/index')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
          break;
F
Fatih Acet 已提交
83
        case 'projects:issues:show':
S
Simon Knox 已提交
84 85 86 87
          import('./pages/projects/issues/show')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
88
          break;
P
Phil Hughes 已提交
89
        case 'dashboard:milestones:index':
90 91 92
          import('./pages/dashboard/milestones/index')
            .then(callDefault)
            .catch(fail);
P
Phil Hughes 已提交
93
          break;
F
Fatih Acet 已提交
94 95 96
        case 'projects:milestones:show':
        case 'groups:milestones:show':
          new Milestone();
97
          new Sidebar();
F
Fatih Acet 已提交
98
          break;
99 100 101 102 103
        case 'dashboard:milestones:show':
          import('./pages/dashboard/milestones/show')
            .then(callDefault)
            .catch(fail);
          break;
104
        case 'dashboard:issues':
C
Clement Ho 已提交
105 106 107
          import('./pages/dashboard/issues')
            .then(callDefault)
            .catch(fail);
C
Clement Ho 已提交
108
          break;
109
        case 'dashboard:merge_requests':
110 111 112
          import('./pages/dashboard/merge_requests')
            .then(callDefault)
            .catch(fail);
113
          break;
114
        case 'groups:issues':
S
Simon Knox 已提交
115 116 117 118
          import('./pages/groups/issues')
            .then(callDefault)
            .catch(fail);
          break;
119
        case 'groups:merge_requests':
S
Simon Knox 已提交
120 121 122
          import('./pages/groups/merge_requests')
            .then(callDefault)
            .catch(fail);
123
          break;
F
Fatih Acet 已提交
124
        case 'dashboard:todos:index':
125
          import('./pages/dashboard/todos/index').then(callDefault).catch(fail);
F
Fatih Acet 已提交
126
          break;
127 128 129 130 131
        case 'admin:jobs:index':
          import('./pages/admin/jobs/index')
            .then(callDefault)
            .catch(fail);
          break;
132 133
        case 'dashboard:projects:index':
        case 'dashboard:projects:starred':
C
Clement Ho 已提交
134 135 136
          import('./pages/dashboard/projects')
            .then(callDefault)
            .catch(fail);
137
          break;
138 139 140
        case 'explore:projects:index':
        case 'explore:projects:trending':
        case 'explore:projects:starred':
141
          import('./pages/explore/projects')
J
Jacob Schatz 已提交
142
            .then(callDefault)
J
Jacob Schatz 已提交
143 144
            .catch(fail);
          break;
F
Filipa Lacerda 已提交
145
        case 'explore:groups:index':
146
          import('./pages/explore/groups')
J
Jacob Schatz 已提交
147
            .then(callDefault)
J
Jacob Schatz 已提交
148
            .catch(fail);
F
Filipa Lacerda 已提交
149
          break;
F
Fatih Acet 已提交
150
        case 'projects:milestones:new':
151 152 153 154 155
        case 'projects:milestones:create':
          import('./pages/projects/milestones/new')
            .then(callDefault)
            .catch(fail);
          break;
F
Fatih Acet 已提交
156
        case 'projects:milestones:edit':
157
        case 'projects:milestones:update':
158 159 160
          import('./pages/projects/milestones/edit')
            .then(callDefault)
            .catch(fail);
161
          break;
162
        case 'groups:milestones:new':
163 164 165 166 167
        case 'groups:milestones:create':
          import('./pages/groups/milestones/new')
            .then(callDefault)
            .catch(fail);
          break;
168 169
        case 'groups:milestones:edit':
        case 'groups:milestones:update':
170 171 172
          import('./pages/groups/milestones/edit')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
173 174
          break;
        case 'projects:compare:show':
175 176 177
          import('./pages/projects/compare/show')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
178
          break;
179
        case 'projects:branches:new':
180 181 182 183
          import('./pages/projects/branches/new')
            .then(callDefault)
            .catch(fail);
          break;
184
        case 'projects:branches:create':
185 186 187
          import('./pages/projects/branches/new')
            .then(callDefault)
            .catch(fail);
188
          break;
189
        case 'projects:branches:index':
190 191 192
          import('./pages/projects/branches/index')
            .then(callDefault)
            .catch(fail);
193
          break;
F
Fatih Acet 已提交
194
        case 'projects:issues:new':
S
Simon Knox 已提交
195 196 197 198 199
          import('./pages/projects/issues/new')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
          break;
F
Fatih Acet 已提交
200
        case 'projects:issues:edit':
S
Simon Knox 已提交
201 202 203 204
          import('./pages/projects/issues/edit')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
205
          break;
D
Douwe Maan 已提交
206
        case 'projects:merge_requests:creations:new':
207 208 209
          import('./pages/projects/merge_requests/creations/new')
            .then(callDefault)
            .catch(fail);
D
Douwe Maan 已提交
210
        case 'projects:merge_requests:creations:diffs':
211 212 213 214 215
          import('./pages/projects/merge_requests/creations/diffs')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
          break;
F
Fatih Acet 已提交
216
        case 'projects:merge_requests:edit':
217 218 219 220
          import('./pages/projects/merge_requests/edit')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
221 222
          break;
        case 'projects:tags:new':
223 224 225
          import('./pages/projects/tags/new')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
226
          break;
227
        case 'projects:snippets:show':
J
Jacob Schatz 已提交
228 229 230
          import('./pages/projects/snippets/show')
            .then(callDefault)
            .catch(fail);
231
          break;
232 233
        case 'projects:snippets:new':
        case 'projects:snippets:create':
C
Clement Ho 已提交
234
          import('./pages/projects/snippets/new')
J
Jacob Schatz 已提交
235 236 237
            .then(callDefault)
            .catch(fail);
          break;
C
Clement Ho 已提交
238
        case 'projects:snippets:edit':
239
        case 'projects:snippets:update':
C
Clement Ho 已提交
240
          import('./pages/projects/snippets/edit')
J
Jacob Schatz 已提交
241 242
            .then(callDefault)
            .catch(fail);
243
          break;
244
        case 'snippets:new':
245 246 247 248
          import('./pages/snippets/new')
            .then(callDefault)
            .catch(fail);
          break;
249
        case 'snippets:edit':
250 251 252 253
          import('./pages/snippets/edit')
            .then(callDefault)
            .catch(fail);
          break;
254
        case 'snippets:create':
C
Clement Ho 已提交
255
          import('./pages/snippets/new')
256 257 258
            .then(callDefault)
            .catch(fail);
          break;
259
        case 'snippets:update':
C
Clement Ho 已提交
260
          import('./pages/snippets/edit')
261 262
            .then(callDefault)
            .catch(fail);
263
          break;
F
Fatih Acet 已提交
264
        case 'projects:releases:edit':
C
Clement Ho 已提交
265
          import('./pages/projects/releases/edit')
J
Jacob Schatz 已提交
266 267
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
268 269
          break;
        case 'projects:merge_requests:show':
270
          new Diff();
F
Fatih Acet 已提交
271
          new ZenMode();
272

273 274
          initIssuableSidebar();
          initNotes();
275

276 277 278 279
          const mrShowNode = document.querySelector('.merge-request');
          window.mergeRequest = new MergeRequest({
            action: mrShowNode.dataset.mrAction,
          });
280
          shortcut_handler = new ShortcutsIssuable(true);
F
Fatih Acet 已提交
281 282
          break;
        case 'dashboard:activity':
C
Clement Ho 已提交
283 284 285
          import('./pages/dashboard/activity')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
286 287
          break;
        case 'projects:commit:show':
288 289 290 291
          import('./pages/projects/commit/show')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
292
          break;
293
        case 'projects:commit:pipelines':
294 295 296
          import('./pages/projects/commit/pipelines')
            .then(callDefault)
            .catch(fail);
297
          break;
298
        case 'projects:activity':
299
          import('./pages/projects/activity')
300 301
            .then(callDefault)
            .catch(fail);
302
          shortcut_handler = true;
303
          break;
304
        case 'projects:commits:show':
305 306 307 308
          import('./pages/projects/commits/show')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
309 310
          break;
        case 'projects:show':
311 312 313
          import('./pages/projects/show')
            .then(callDefault)
            .catch(fail);
C
Clement Ho 已提交
314
          shortcut_handler = true;
F
Fatih Acet 已提交
315
          break;
316
        case 'projects:edit':
S
Simon Knox 已提交
317 318 319
          import('./pages/projects/edit')
            .then(callDefault)
            .catch(fail);
320
          break;
321
        case 'projects:imports:show':
S
Simon Knox 已提交
322 323 324
          import('./pages/projects/imports/show')
            .then(callDefault)
            .catch(fail);
325
          break;
326
        case 'projects:pipelines:new':
327
        case 'projects:pipelines:create':
328 329 330
          import('./pages/projects/pipelines/new')
            .then(callDefault)
            .catch(fail);
331
          break;
F
Filipa Lacerda 已提交
332
        case 'projects:pipelines:builds':
333
        case 'projects:pipelines:failures':
L
Luke Bennett 已提交
334
        case 'projects:pipelines:show':
335 336 337
          import('./pages/projects/pipelines/builds')
            .then(callDefault)
            .catch(fail);
L
Luke Bennett 已提交
338
          break;
F
Fatih Acet 已提交
339
        case 'groups:activity':
S
Simon Knox 已提交
340 341 342
          import('./pages/groups/activity')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
343 344
          break;
        case 'groups:show':
S
Simon Knox 已提交
345 346 347 348
          import('./pages/groups/show')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
349 350
          break;
        case 'groups:group_members:index':
S
Simon Knox 已提交
351 352 353
          import('./pages/groups/group_members/index')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
354
          break;
355
        case 'projects:project_members:index':
356 357 358
          import('./pages/projects/project_members/')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
359
          break;
360
        case 'groups:create':
S
Simon Knox 已提交
361 362 363 364 365 366 367 368 369
        case 'groups:new':
          import('./pages/groups/new')
            .then(callDefault)
            .catch(fail);
          break;
        case 'groups:edit':
          import('./pages/groups/edit')
            .then(callDefault)
            .catch(fail);
370
          break;
P
Phil Hughes 已提交
371 372
        case 'admin:groups:create':
        case 'admin:groups:new':
P
Phil Hughes 已提交
373 374 375
          import('./pages/admin/groups/new')
            .then(callDefault)
            .catch(fail);
P
Phil Hughes 已提交
376
          break;
F
Fatih Acet 已提交
377
        case 'admin:groups:edit':
P
Phil Hughes 已提交
378 379 380
          import('./pages/admin/groups/edit')
            .then(callDefault)
            .catch(fail);
P
Phil Hughes 已提交
381
          break;
382
        case 'projects:tree:show':
383
          import('./pages/projects/tree/show')
384
            .then(callDefault)
385
            .catch(fail);
386
          shortcut_handler = true;
387
          break;
F
Fatih Acet 已提交
388
        case 'projects:find_file:show':
S
Simon Knox 已提交
389 390 391
          import('./pages/projects/find_file/show')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
392 393
          shortcut_handler = true;
          break;
394
        case 'projects:blob:show':
395 396 397 398
          import('./pages/projects/blob/show')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
399
          break;
F
Fatih Acet 已提交
400
        case 'projects:blame:show':
401 402 403 404
          import('./pages/projects/blame/show')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
405
          break;
406
        case 'groups:labels:new':
S
Simon Knox 已提交
407 408 409 410
          import('./pages/groups/labels/new')
            .then(callDefault)
            .catch(fail);
          break;
411
        case 'groups:labels:edit':
S
Simon Knox 已提交
412 413 414
          import('./pages/groups/labels/edit')
            .then(callDefault)
            .catch(fail);
C
Clement Ho 已提交
415
          break;
F
Fatih Acet 已提交
416
        case 'projects:labels:new':
J
Jacob Schatz 已提交
417 418 419 420
          import('./pages/projects/labels/new')
            .then(callDefault)
            .catch(fail);
          break;
F
Fatih Acet 已提交
421
        case 'projects:labels:edit':
C
Clement Ho 已提交
422
          import('./pages/projects/labels/edit')
J
Jacob Schatz 已提交
423 424
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
425
          break;
S
Simon Knox 已提交
426 427 428 429 430
        case 'groups:labels:index':
          import('./pages/groups/labels/index')
            .then(callDefault)
            .catch(fail);
          break;
F
Fatih Acet 已提交
431
        case 'projects:labels:index':
J
Jacob Schatz 已提交
432 433 434 435
          import('./pages/projects/labels/index')
            .then(callDefault)
            .catch(fail);
          break;
F
Fatih Acet 已提交
436
        case 'projects:network:show':
437 438
          // Ensure we don't create a particular shortcut handler here. This is
          // already created, where the network graph is created.
F
Fatih Acet 已提交
439 440 441
          shortcut_handler = true;
          break;
        case 'projects:forks:new':
S
Simon Knox 已提交
442
          import('./pages/projects/forks/new')
J
Jacob Schatz 已提交
443 444
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
445 446
          break;
        case 'projects:artifacts:browse':
447
          import('./pages/projects/artifacts/browse')
448 449
            .then(callDefault)
            .catch(fail);
450
          shortcut_handler = true;
F
Fatih Acet 已提交
451
          break;
452
        case 'projects:artifacts:file':
453
          import('./pages/projects/artifacts/file')
454 455
            .then(callDefault)
            .catch(fail);
456
          shortcut_handler = true;
457
          break;
458
        case 'help:index':
459 460 461
          import('./pages/help')
            .then(callDefault)
            .catch(fail);
462
          break;
F
Fatih Acet 已提交
463
        case 'search:show':
C
Clement Ho 已提交
464 465 466
          import('./pages/search/show')
            .then(callDefault)
            .catch(fail);
467
          break;
D
Douwe Maan 已提交
468
        case 'projects:settings:repository:show':
469 470 471
          import('./pages/projects/settings/repository/show')
            .then(callDefault)
            .catch(fail);
472
          break;
D
Douwe Maan 已提交
473
        case 'projects:settings:ci_cd:show':
474 475 476 477
          import('./pages/projects/settings/ci_cd/show')
            .then(callDefault)
            .catch(fail);
          break;
S
Shinya Maeda 已提交
478
        case 'groups:settings:ci_cd:show':
S
Simon Knox 已提交
479 480 481
          import('./pages/groups/settings/ci_cd/show')
            .then(callDefault)
            .catch(fail);
S
Stan Hu 已提交
482
          break;
483 484
        case 'ci:lints:create':
        case 'ci:lints:show':
485
          import('./pages/ci/lints').then(m => m.default()).catch(fail);
486
          break;
487
        case 'users:show':
488
          import('./pages/users/show').then(callDefault).catch(fail);
489
          break;
490
        case 'admin:conversational_development_index:show':
491
          import('./pages/admin/conversational_development_index/show').then(m => m.default()).catch(fail);
492
          break;
D
Douwe Maan 已提交
493
        case 'snippets:show':
C
Clement Ho 已提交
494 495 496
          import('./pages/snippets/show')
            .then(callDefault)
            .catch(fail);
D
Douwe Maan 已提交
497
          break;
498
        case 'import:fogbugz:new_user_map':
499
          import('./pages/import/fogbugz/new_user_map').then(m => m.default()).catch(fail);
500
          break;
501
        case 'profiles:personal_access_tokens:index':
502 503 504 505
          import('./pages/profiles/personal_access_tokens')
            .then(callDefault)
            .catch(fail);
          break;
506
        case 'admin:impersonation_tokens:index':
P
Phil Hughes 已提交
507 508 509
          import('./pages/admin/impersonation_tokens')
            .then(callDefault)
            .catch(fail);
P
Phil Hughes 已提交
510
          break;
F
Filipa Lacerda 已提交
511
        case 'projects:clusters:show':
512 513
        case 'projects:clusters:update':
        case 'projects:clusters:destroy':
514 515 516
          import('./pages/projects/clusters/show')
            .then(callDefault)
            .catch(fail);
517 518
          break;
        case 'projects:clusters:index':
519 520 521
          import('./pages/projects/clusters/index')
            .then(callDefault)
            .catch(fail);
F
Filipa Lacerda 已提交
522
          break;
F
Fatih Acet 已提交
523
      }
524
      switch (path[0]) {
525
        case 'sessions':
526 527 528 529
          import('./pages/sessions')
            .then(callDefault)
            .catch(fail);
          break;
530
        case 'omniauth_callbacks':
531 532 533 534
          import('./pages/omniauth_callbacks')
            .then(callDefault)
            .catch(fail);
          break;
F
Fatih Acet 已提交
535
        case 'admin':
P
Phil Hughes 已提交
536 537 538
          import('./pages/admin')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
539
          switch (path[1]) {
M
Mike Greiling 已提交
540
            case 'broadcast_messages':
P
Phil Hughes 已提交
541 542 543
              import('./pages/admin/broadcast_messages')
                .then(callDefault)
                .catch(fail);
M
Mike Greiling 已提交
544
              break;
S
Sean McGivern 已提交
545
            case 'cohorts':
P
Phil Hughes 已提交
546 547 548
              import('./pages/admin/cohorts')
                .then(callDefault)
                .catch(fail);
549
              break;
F
Fatih Acet 已提交
550
            case 'groups':
P
Phil Hughes 已提交
551 552
              switch (path[2]) {
                case 'show':
P
Phil Hughes 已提交
553 554 555
                  import('./pages/admin/groups/show')
                    .then(callDefault)
                    .catch(fail);
P
Phil Hughes 已提交
556 557
                  break;
              }
F
Fatih Acet 已提交
558 559
              break;
            case 'projects':
P
Phil Hughes 已提交
560 561 562
              import('./pages/admin/projects')
                .then(callDefault)
                .catch(fail);
563 564
              break;
            case 'labels':
565
              switch (path[2]) {
566
                case 'new':
P
Phil Hughes 已提交
567 568 569
                  import('./pages/admin/labels/new')
                    .then(callDefault)
                    .catch(fail);
P
Phil Hughes 已提交
570
                  break;
571
                case 'edit':
P
Phil Hughes 已提交
572 573 574
                  import('./pages/admin/labels/edit')
                    .then(callDefault)
                    .catch(fail);
P
Phil Hughes 已提交
575
                  break;
576
              }
577
            case 'abuse_reports':
P
Phil Hughes 已提交
578 579 580
              import('./pages/admin/abuse_reports')
                .then(callDefault)
                .catch(fail);
581
              break;
F
Fatih Acet 已提交
582 583 584
          }
          break;
        case 'profiles':
585 586 587
          import('./pages/profiles/index/')
            .then(callDefault)
            .catch(fail);
F
Fatih Acet 已提交
588 589
          break;
        case 'projects':
590 591 592 593
          import('./pages/projects')
            .then(callDefault)
            .catch(fail);
          shortcut_handler = true;
F
Fatih Acet 已提交
594 595
          switch (path[1]) {
            case 'compare':
596 597 598
              import('./pages/projects/compare')
                .then(callDefault)
                .catch(fail);
F
Fatih Acet 已提交
599
              break;
600 601 602
            case 'create':
            case 'new':
              import('./pages/projects/new')
J
Jacob Schatz 已提交
603 604
                .then(callDefault)
                .catch(fail);
F
Fatih Acet 已提交
605 606
              break;
            case 'show':
607
              new Star();
P
Phil Hughes 已提交
608
              notificationsDropdown();
F
Fatih Acet 已提交
609 610
              break;
            case 'wikis':
611 612 613 614
              import('./pages/projects/wikis')
                .then(callDefault)
                .catch(fail);
              shortcut_handler = true;
F
Fatih Acet 已提交
615 616 617 618
              break;
            case 'snippets':
              if (path[2] === 'show') {
                new ZenMode();
D
Douwe Maan 已提交
619 620
                new LineHighlighter();
                new BlobViewer();
F
Fatih Acet 已提交
621 622 623
              }
              break;
          }
624
          break;
F
Fatih Acet 已提交
625
      }
626
      // If we haven't installed a custom shortcut handler, install the default one
F
Fatih Acet 已提交
627
      if (!shortcut_handler) {
628
        new Shortcuts();
F
Fatih Acet 已提交
629
      }
630 631 632 633

      if (document.querySelector('#peek')) {
        new PerformanceBar({ container: '#peek' });
      }
F
Fatih Acet 已提交
634 635 636
    };

    Dispatcher.prototype.initSearch = function() {
637
      // Only when search form is present
F
Fatih Acet 已提交
638
      if ($('.search').length) {
F
Filipa Lacerda 已提交
639
        return new SearchAutocomplete();
F
Fatih Acet 已提交
640 641 642
      }
    };

643
    Dispatcher.prototype.initFieldErrors = function() {
644
      $('.gl-show-field-errors').each((i, form) => {
645
        new GlFieldErrors(form);
646
      });
647 648
    };

F
Fatih Acet 已提交
649 650
    return Dispatcher;
  })();
651

652
  $(window).on('load', function() {
653 654
    new Dispatcher();
  });
655
}).call(window);