From 960b7834a7112cb57ad700f99459d03189a3bead Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Sun, 24 Jun 2018 14:57:12 +0900 Subject: [PATCH] Reload diff when display mode is changed --- .../gitbucket/core/helper/diff.scala.html | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/main/twirl/gitbucket/core/helper/diff.scala.html b/src/main/twirl/gitbucket/core/helper/diff.scala.html index 0222d22e3..2dbe74c49 100644 --- a/src/main/twirl/gitbucket/core/helper/diff.scala.html +++ b/src/main/twirl/gitbucket/core/helper/diff.scala.html @@ -16,9 +16,9 @@ @if(oldCommitId.isDefined && newCommitId.isDefined) { Patch } -
- - +
Showing @diffs.size changed @helpers.plural(diffs.size, "file") @@ -151,29 +151,22 @@ $(function(){ }); } + window.params = {}; + // Render diffs as unified mode initially if(("&" + location.search.substring(1)).indexOf("&w=1") != -1){ - $('.ignore-whitespace').prop('checked',true); + $('.ignore-whitespace').prop('checked', true); + window.params['w'] = 1; } - window.viewType = 1; if(("&" + location.search.substring(1)).indexOf("&diff=split") != -1){ window.viewType = 0; - } - renderDiffs(); - - $('#btn-unified').click(function(){ + $('#btn-split').addClass('active'); + window.params['diff'] = 'split'; + } else { window.viewType = 1; $('#btn-unified').addClass('active'); - $('#btn-split').removeClass('active'); - renderDiffs(); - }); - - $('#btn-split').click(function(){ - window.viewType = 0; - $('#btn-unified').removeClass('active'); - $('#btn-split').addClass('active'); - renderDiffs(); - }); + } + renderDiffs(); $('.toggle-notes').change(function() { if (!$(this).prop('checked')) { @@ -188,7 +181,6 @@ $(function(){ function getInlineContainer(where) { if (window.viewType == 0) { - console.log(where); if (where === 'new') { return $(''); } else { @@ -410,4 +402,19 @@ $(function(){ render(); } }); + +function changeDisplaySetting(key, value){ + var url = ''; + window.params[key] = value; + for(key in window.params){ + if(window.params[key] != ''){ + if(url != ''){ + url = url + '&' + key + '=' + window.params[key]; + } else { + url = url + '?' + key + '=' + window.params[key]; + } + } + } + location.href = url; +}