aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/coffee/quality-gate/layout.coffee
blob: 0b5941655d54a34b2fe60e3483f823bb74be5de9 (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
define [
  'backbone.marionette',
  'templates/quality-gates'
], (
  Marionette,
  Templates
) ->

  class AppLayout extends Marionette.Layout
    className: 'navigator quality-gates-navigator'
    template: Templates['quality-gates-layout']


    regions:
      headerRegion: '.navigator-header'
      actionsRegion: '.navigator-actions'
      resultsRegion: '.navigator-results'
      detailsRegion: '.navigator-details'


    initialize: (options) ->
      @listenTo options.app.qualityGates, 'all', @updateLayout
      jQuery(window).on 'resize', => @onResize()


    updateLayout: ->
      empty = @options.app.qualityGates.length == 0
      @$(@headerRegion.el).toggle !empty
      @$(@detailsRegion.el).toggle !empty


    onResize: ->
      footerEl = jQuery('#footer')
      footerHeight = footerEl.outerHeight true

      resultsEl = jQuery('.navigator-results')
      resultsHeight = jQuery(window).height() - resultsEl.offset().top -
      parseInt(resultsEl.css('margin-bottom'), 10) - footerHeight
      resultsEl.height resultsHeight

      detailsEl = jQuery('.navigator-details')
      detailsWidth = jQuery(window).width() - detailsEl.offset().left -
      parseInt(detailsEl.css('margin-right'), 10)
      detailsHeight = jQuery(window).height() - detailsEl.offset().top -
      parseInt(detailsEl.css('margin-bottom'), 10) - footerHeight
      detailsEl.width(detailsWidth).height detailsHeight


    onRender: ->
      @updateLayout()