From 22bd7f4d83a255e3e23d3e421fbb1a56f0c67394 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Mon, 18 Apr 2016 16:51:30 -0500 Subject: Allow to pass custom classes to button --- app/helpers/diff_helper.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index d78b0b5a155..9f73edb4553 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -129,14 +129,14 @@ module DiffHelper end end - def commit_diff_whitespace_link(project, commit) + def commit_diff_whitespace_link(project, commit, options) url = namespace_project_commit_path(project.namespace, project, commit.id, params_with_whitespace) - toggle_whitespace_link(url) + toggle_whitespace_link(url, options) end - def diff_merge_request_whitespace_link(project, merge_request) + def diff_merge_request_whitespace_link(project, merge_request, options) url = diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, params_with_whitespace) - toggle_whitespace_link(url) + toggle_whitespace_link(url, options) end private @@ -149,7 +149,10 @@ module DiffHelper hide_whitespace? ? request.query_parameters.except(:w) : request.query_parameters.merge(w: 1) end - def toggle_whitespace_link(url) - link_to "#{hide_whitespace? ? 'Show' : 'Hide'} whitespace changes", url, class: 'btn btn-default hidden-xs' + def toggle_whitespace_link(url, options) + options[:class] ||= '' + options[:class] << ' btn btn-default' + + link_to "#{hide_whitespace? ? 'Show' : 'Hide'} whitespace changes", url, class: options[:class] end end -- cgit v1.2.1