From d5a26a43d7d7b61ff7661ca160a65d00699b9356 Mon Sep 17 00:00:00 2001 From: hy9be_uva Date: Wed, 5 Apr 2017 15:26:52 -0400 Subject: [PATCH 1/6] Do nothing when showLink is set to be false --- src/plots/plots.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plots/plots.js b/src/plots/plots.js index 6f4dfcf913e..e2a50ee9265 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -257,6 +257,8 @@ plots.previousPromises = function(gd) { * Add source links to your graph inside the 'showSources' config argument. */ plots.addLinks = function(gd) { + if(gd._context.showLink === false) return; + var fullLayout = gd._fullLayout; var linkContainer = fullLayout._paper From 72a604cd3879d1c54bf2d9b09a0d018d989c65bb Mon Sep 17 00:00:00 2001 From: hy9be_uva Date: Wed, 5 Apr 2017 15:28:27 -0400 Subject: [PATCH 2/6] Update unit test for showLink --- test/jasmine/tests/config_test.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/jasmine/tests/config_test.js b/test/jasmine/tests/config_test.js index 9181e56d4e5..5ff20cfda94 100644 --- a/test/jasmine/tests/config_test.js +++ b/test/jasmine/tests/config_test.js @@ -160,11 +160,7 @@ describe('config argument', function() { var link = document.getElementsByClassName('js-plot-link-container')[0]; - expect(link.textContent).toBe(''); - - var bBox = link.getBoundingClientRect(); - expect(bBox.width).toBe(0); - expect(bBox.height).toBe(0); + expect(link).toBeUndefined(); }); it('should display a link when true', function() { From 69bc864971d64575d4c9390005bdd347be5fddbe Mon Sep 17 00:00:00 2001 From: hy9be_uva Date: Wed, 5 Apr 2017 16:15:33 -0400 Subject: [PATCH 3/6] Remove spaces as the CI check returns error Error: "Trailing spaces not allowed" --- src/plots/plots.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plots/plots.js b/src/plots/plots.js index e2a50ee9265..06473e45795 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -258,7 +258,7 @@ plots.previousPromises = function(gd) { */ plots.addLinks = function(gd) { if(gd._context.showLink === false) return; - + var fullLayout = gd._fullLayout; var linkContainer = fullLayout._paper From 5bd40955e240f6c714a2c10f73d3743255404758 Mon Sep 17 00:00:00 2001 From: hy9be_uva Date: Thu, 6 Apr 2017 09:52:05 -0400 Subject: [PATCH 4/6] Handle showSource config Made changes according to code review feedback. --- src/plots/plots.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plots/plots.js b/src/plots/plots.js index 06473e45795..ce0b0c792e3 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -257,7 +257,7 @@ plots.previousPromises = function(gd) { * Add source links to your graph inside the 'showSources' config argument. */ plots.addLinks = function(gd) { - if(gd._context.showLink === false) return; + if(!gd._context.showLink || !gd._context.showSources) return; var fullLayout = gd._fullLayout; From 7636cb531a5f0cf3599e5bf24293bc6e1e2a3366 Mon Sep 17 00:00:00 2001 From: Haowen You Date: Thu, 6 Apr 2017 15:24:26 -0400 Subject: [PATCH 5/6] Change the OR conditon to AND for triggering addLinks logic --- src/plots/plots.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plots/plots.js b/src/plots/plots.js index ce0b0c792e3..f1e7edb0b60 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -257,7 +257,7 @@ plots.previousPromises = function(gd) { * Add source links to your graph inside the 'showSources' config argument. */ plots.addLinks = function(gd) { - if(!gd._context.showLink || !gd._context.showSources) return; + if(!gd._context.showLink && !gd._context.showSources) return; var fullLayout = gd._fullLayout; From 603656cc737f2f43d5fbcc271ad1e8a334c5b32c Mon Sep 17 00:00:00 2001 From: hy9be Date: Fri, 7 Apr 2017 12:13:31 -0400 Subject: [PATCH 6/6] Add comments --- src/plots/plots.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plots/plots.js b/src/plots/plots.js index f1e7edb0b60..7b10320ac2d 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -257,6 +257,7 @@ plots.previousPromises = function(gd) { * Add source links to your graph inside the 'showSources' config argument. */ plots.addLinks = function(gd) { + // Do not do anything if showLink and showSources are not set to true in config if(!gd._context.showLink && !gd._context.showSources) return; var fullLayout = gd._fullLayout;