aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/api-documentation/app.js
blob: 0afabaf7501a1784e68de50b005c8623f332f410 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import $ from 'jquery';
import Backbone from 'backbone';
import Marionette from 'backbone.marionette';
import Router from './router';
import Controller from './controller';
import Layout from './layout';
import List from './list';
import ListView from './list-view';
import FiltersView from './filters-view';
import SearchView from './search-view';

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

      // State
      this.state = new Backbone.Model({ internal: false });
      this.state.match = function (test, internal) {
        var pattern = new RegExp(this.get('query'), 'i');
        var internalCheck = !this.get('internal') && internal;
        return test.search(pattern) !== -1 && !internalCheck;
      };

      // Layout
      this.layout = new Layout({ el: options.el });
      this.layout.render();
      $('#footer').addClass('search-navigator-footer');

      // Web Services List
      this.list = new List();

      // Controller
      this.controller = new Controller({
        app: this,
        state: this.state
      });

      // List View
      this.listView = new ListView({
        collection: this.list,
        state: this.state
      });
      this.layout.resultsRegion.show(this.listView);

      // Filters View
      this.filtersView = new FiltersView({
        collection: this.list,
        state: this.state
      });
      this.layout.actionsRegion.show(this.filtersView);

      // Search View
      this.searchView = new SearchView({
        state: this.state
      });
      this.layout.searchRegion.show(this.searchView);

      // Router
      this.router = new Router({ app: this });
      Backbone.history.start({
        pushState: true,
        root: options.urlRoot
      });
    };

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

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