Make diff view name getter less error prone

This commit is contained in:
Alfredo Sumaran 2016-02-19 16:32:29 -05:00
parent ebceae3ead
commit 27a0310f23
2 changed files with 3 additions and 5 deletions

View file

@ -179,11 +179,9 @@ class @MergeRequestTabs
$.ajax(options)
# Returns diff view type
diffViewMode: ->
# Gets diff view mode based from its ID
# See diff_btn helper method
btnID = $('a[id$="-diff-btn"].active').attr('id')
btnID.substr(0, btnID.indexOf('-'))
$('.diffs a[id$="-diff-btn"].active').data('view-type')
expandViewContainer: ->
$('.container-fluid').removeClass('container-limited')

View file

@ -137,7 +137,7 @@ module DiffHelper
# Always use HTML to handle case where JSON diff rendered this button
params_copy.delete(:format)
link_to url_for(params_copy), id: "#{name}-diff-btn", class: (selected ? 'btn active' : 'btn') do
link_to url_for(params_copy), id: "#{name}-diff-btn", class: (selected ? 'btn active' : 'btn'), data: {view_type: name} do
title
end
end