From f7ee72e75538ef450b3b1d32d11b0eb5967564b8 Mon Sep 17 00:00:00 2001 From: Trenton Smith Date: Thu, 30 Jun 2016 12:32:26 -0600 Subject: [PATCH 1/3] fix null pointer --- lib/collapse_diff.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/collapse_diff.js b/lib/collapse_diff.js index b26b627..009d09a 100644 --- a/lib/collapse_diff.js +++ b/lib/collapse_diff.js @@ -18,7 +18,7 @@ var bindToggler = function(buttonContainer, tableToToggle, addPlaceHolder) { var messageDiv, button; - if(!tableToToggle) { return; } + if(!tableToToggle || !buttonContainer) { return; } buttonContainer.insertAdjacentHTML('afterbegin', butHtml); tableToToggle.insertAdjacentHTML('afterend', collapsedHtml); From a95ac43a65bd6514f2e153a0e219044b0b17f537 Mon Sep 17 00:00:00 2001 From: Trenton Smith Date: Thu, 30 Jun 2016 14:18:37 -0600 Subject: [PATCH 2/3] insert button after 'Show File Notes' --- lib/collapse_diff.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/collapse_diff.js b/lib/collapse_diff.js index 009d09a..3812e88 100644 --- a/lib/collapse_diff.js +++ b/lib/collapse_diff.js @@ -20,7 +20,10 @@ var messageDiv, button; if(!tableToToggle || !buttonContainer) { return; } - buttonContainer.insertAdjacentHTML('afterbegin', butHtml); + showFileNotes = buttonContainer.querySelector('.show-file-notes'); + if(!showFileNotes) { return; } + + showFileNotes.insertAdjacentHTML('afterend', butHtml); tableToToggle.insertAdjacentHTML('afterend', collapsedHtml); button = buttonContainer.querySelector('.diff-collapse-button'); From 8e8c5262f16020dc9eed2698093e6f20b3078a26 Mon Sep 17 00:00:00 2001 From: Trenton Smith Date: Thu, 30 Jun 2016 14:30:16 -0600 Subject: [PATCH 3/3] add tooltip to buttons --- lib/collapse_diff.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/collapse_diff.js b/lib/collapse_diff.js index 3812e88..2afdac3 100644 --- a/lib/collapse_diff.js +++ b/lib/collapse_diff.js @@ -1,10 +1,12 @@ (function() { - var butHtml = 'Collapse'; + var butHtml = 'Collapse'; var collapsedHtml = ''; var expand = function(button, content, message) { button.textContent = 'Collapse'; + button.setAttribute('aria-label', 'Collapse the file diff') + button.blur() content.style.display = ''; // Restore original display (table/block) if(message) { message.style.display = 'none'; } @@ -12,6 +14,8 @@ var collapse = function(button, content, message) { button.textContent = 'Expand'; + button.setAttribute('aria-label', 'Expand the file diff') + button.blur() content.style.display = 'none'; if(message) { message.style.display = 'block'; } };