aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/source-viewer/app.js
blob: 1c6947db3ee2305c7ca41cdd2461d7a4ec331282 (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
define([
  'components/source-viewer/main'
], function (SourceViewer) {

  var App = new Marionette.Application(),
      init = function (options) {
        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 (options) {
    window.requestMessages().done(function () {
      init.call(App, options);
    });
  });

  return App;

});