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

  $ = jQuery


  class extends Marionette.Layout
    template: Templates['issues-layout']
    topOffset: 30


    regions:
      filtersRegion: '.issues-filters'
      facetsRegion: '.issues-facets'
      workspaceHeaderRegion: '.issues-workspace-header'
      workspaceListRegion: '.issues-workspace-list'
      workspaceComponentViewerRegion: '.issues-workspace-component-viewer'


    initialize: ->
      $(window).on 'scroll.issues-layout', (=> @onScroll())


    onClose: ->
      $(window).off 'scroll.issues-layout'


    onRender: ->
      @$('.issues-side').isolatedScroll()


    onScroll: ->
      scrollTop = $(window).scrollTop()
      $('.issues').toggleClass 'sticky', scrollTop >= @topOffset
      @$('.issues-side').css top: Math.max(0, Math.min(@topOffset - scrollTop, @topOffset))


    showSpinner: (region) ->
      @[region].show new Marionette.ItemView
        template: _.template('<i class="spinner"></i>')


    showComponentViewer: ->
      @scroll = $(window).scrollTop()
      $('.issues').addClass 'issues-extended-view'


    hideComponentViewer: ->
      $('.issues').removeClass 'issues-extended-view'
      $(window).scrollTop @scroll if @scroll?