Skip to content

Commit 077a1d7

Browse files
authored
Merge pull request #3280 from plotly/3268-watermark
implement watermark config option
2 parents 922bad6 + df10f70 commit 077a1d7

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

build/plotcss.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ var rules = {
3232
"X .cursor-ne-resize": "cursor:ne-resize;",
3333
"X .cursor-grab": "cursor:-webkit-grab;cursor:grab;",
3434
"X .modebar": "position:absolute;top:2px;right:2px;z-index:1001;",
35-
"X .modebar--hover": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;",
36-
"X:hover .modebar--hover": "opacity:1;",
35+
"X .modebar--hover>:not(.watermark)": "opacity:0;-webkit-transition:opacity 0.3s ease 0s;-moz-transition:opacity 0.3s ease 0s;-ms-transition:opacity 0.3s ease 0s;-o-transition:opacity 0.3s ease 0s;transition:opacity 0.3s ease 0s;",
36+
"X:hover .modebar--hover .modebar-group": "opacity:1;",
3737
"X .modebar-group": "float:left;display:inline-block;box-sizing:border-box;margin-left:8px;position:relative;vertical-align:middle;white-space:nowrap;",
3838
"X .modebar-btn": "position:relative;font-size:16px;padding:3px 4px;height:22px;cursor:pointer;line-height:normal;box-sizing:border-box;",
3939
"X .modebar-btn svg": "position:relative;top:2px;",

src/components/modebar/manage.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = function manageModeBar(gd) {
2929
context = gd._context,
3030
modeBar = fullLayout._modeBar;
3131

32-
if(!context.displayModeBar) {
32+
if(!context.displayModeBar && !context.watermark) {
3333
if(modeBar) {
3434
modeBar.destroy();
3535
delete fullLayout._modeBar;
@@ -57,6 +57,9 @@ module.exports = function manageModeBar(gd) {
5757
if(Array.isArray(customButtons) && customButtons.length) {
5858
buttonGroups = fillCustomButton(customButtons);
5959
}
60+
else if(!context.displayModeBar && context.watermark) {
61+
buttonGroups = [];
62+
}
6063
else {
6164
buttonGroups = getButtonGroups(
6265
gd,

src/components/modebar/modebar.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,16 @@ proto.update = function(graphInfo, buttons) {
8080

8181
this.updateButtons(buttons);
8282

83-
if(context.displaylogo) {
83+
if(context.watermark || context.displaylogo) {
84+
var logoGroup = this.getLogo();
85+
if(context.watermark) {
86+
logoGroup.className = logoGroup.className + ' watermark';
87+
}
88+
8489
if(fullLayout.modebar.orientation === 'v') {
85-
this.element.prepend(this.getLogo());
90+
this.element.prepend(logoGroup);
8691
} else {
87-
this.element.appendChild(this.getLogo());
92+
this.element.appendChild(logoGroup);
8893
}
8994

9095
this.hasLogo = true;

src/css/_modebar.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
z-index: 1001;
66
}
77

8-
.modebar--hover {
8+
.modebar--hover > :not(.watermark) {
99
opacity: 0;
1010
@include vendor('transition', opacity 0.3s ease 0s);
1111
}
1212

13-
&:hover .modebar--hover {
13+
&:hover .modebar--hover .modebar-group {
1414
opacity: 1;
1515
}
1616

src/plot_api/plot_config.js

+3
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ module.exports = {
133133
// add the plotly logo on the end of the mode bar
134134
displaylogo: true,
135135

136+
// watermark the images with the company's logo
137+
watermark: false,
138+
136139
// increase the pixel ratio for Gl plot images
137140
plotGlPixelRatio: 2,
138141

test/jasmine/tests/modebar_test.js

+10
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,16 @@ describe('ModeBar', function() {
756756
expect(countLogo(gd._fullLayout._modeBar)).toEqual(0);
757757
});
758758

759+
it('always displays the logo if watermark config arg is true', function() {
760+
var gd = getMockGraphInfo();
761+
gd._context.displaylogo = false;
762+
gd._context.displayModeBar = false;
763+
gd._context.watermark = true;
764+
manageModeBar(gd);
765+
expect(countLogo(gd._fullLayout._modeBar)).toEqual(1);
766+
expect(countButtons(gd._fullLayout._modeBar)).toEqual(1);
767+
});
768+
759769
// gives 11 buttons in 5 groups by default
760770
function setupGraphInfo() {
761771
var gd = getMockGraphInfo(['x'], ['y']);

0 commit comments

Comments
 (0)