aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/source-viewer/app.js
blob: 8d7ecb575f79535a54adfaa6c486e32d64a731c8 (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
import Marionette from 'backbone.marionette';
import SourceViewer from '../../components/source-viewer/main';
import '../../helpers/handlebars-helpers';

var App = new Marionette.Application(),
    init = function () {
      let options = window.sonarqube;

      this.addRegions({ mainRegion: options.el });

      var viewer = new SourceViewer();
      this.mainRegion.show(viewer);
      viewer.open(options.file.uuid);
      if (typeof options.file.line === 'number') {
        viewer.on('loaded', function () {
          viewer
              .highlightLine(options.file.line)
              .scrollToLine(options.file.line);
        });
      }
    };

App.on('start', function () {
  init.call(App);
});

window.sonarqube.appStarted.then(options => App.start(options));