sourceRegion: '.component-viewer-source'
- initialize: ->
+ initialize: (options) ->
@workspace = new Backbone.Collection()
@component = new Backbone.Model()
@workspaceView = new WorkspaceView
duplications: false
scm: false
workspace: false
+ @settings.set options.settings
onRender: ->
@workspace.where(key: key).forEach (model) =>
model.set 'component': @component.toJSON()
@render()
+ if @settings.get('issues') then @showIssues() else @hideIssues()
if @settings.get('coverage') then @showCoverage() else @hideCoverage()
if @settings.get('duplications') then @showDuplications() else @hideDuplications()
expandTemplate: Templates['code-expand']
LINES_AROUND_ISSUE = 4
- LINES_AROUND_COVERAGE = 4
- LINES_AROUND_DUPLICATION = 4
EXPAND_LINES = 20
events:
'click .js-toggle-settings': 'toggleSettings'
'click .js-toggle-measures': 'toggleMeasures'
+ 'change #source-issues': 'toggleIssues'
'change #source-coverage': 'toggleCoverage'
'change #source-duplications': 'toggleDuplications'
'change #source-workspace': 'toggleWorkspace'
@$('.component-viewer-measures-section').toggleClass 'brief'
- toggleCoverage: (e) ->
+ toggleSetting: (e, show, hide) ->
@showBlocks = []
active = $(e.currentTarget).is ':checked'
@showSettings = true
- if active then @options.main.showCoverage() else @options.main.hideCoverage()
+ if active then show.call @options.main else hide.call @options.main
+
+
+ toggleIssues: (e) ->
+ @toggleSetting e, @options.main.showIssues, @options.main.hideIssues
+
+
+ toggleCoverage: (e) ->
+ @toggleSetting e, @options.main.showCoverage, @options.main.hideCoverage
toggleDuplications: (e) ->
- @showBlocks = []
- active = $(e.currentTarget).is ':checked'
- @showSettings = true
- if active then @options.main.showDuplications() else @options.main.hideDuplications()
+ @toggleSetting e, @options.main.showDuplications, @options.main.hideDuplications
toggleWorkspace: (e) ->
- active = $(e.currentTarget).is ':checked'
- @showSettings = true
- if active then @options.main.showWorkspace() else @options.main.hideWorkspace()
+ @toggleSetting e, @options.main.showWorkspace, @options.main.hideWorkspace
showCoveragePopup: (e) ->