aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/source-viewer/app.js
blob: 31b6047d152e5f08fa22a407d1188f6c0de3906d (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
define([
  'backbone.marionette',
  'components/source-viewer/main'
], function (Marionette, 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.component.uuid);
        if (window.line) {
          viewer.on('loaded', function () {
            viewer
                .highlightLine(window.line)
                .scrollToLine(window.line);
          });
        }
      };

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

  return App;

});