Skip to content

Commit 9a34cd3

Browse files
committed
Merge pull request #4487 from plotly/bye-bye-jQuery
Bye bye jQuery
2 parents 2ad39be + 2d88325 commit 9a34cd3

File tree

5 files changed

+46
-34
lines changed

5 files changed

+46
-34
lines changed

shelly/plotlyjs/static/plotlyjs/src/annotations.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,8 @@ annotations.draw = function(gd, index, opt, value) {
771771
// add the arrow
772772
// uses options[arrowwidth,arrowcolor,arrowhead] for styling
773773
var drawArrow = function(dx, dy){
774-
$(gd).find('.annotation-arrow-g[data-index="' + index + '"]')
774+
d3.select(gd)
775+
.selectAll('.annotation-arrow-g[data-index="' + index + '"]')
775776
.remove();
776777
// find where to start the arrow:
777778
// at the border of the textbox, if that border is visible,

shelly/plotlyjs/static/plotlyjs/src/graph_interact.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict';
22

3-
/* jshint camelcase: false */
4-
53
var Plotly = require('./plotly'),
64
d3 = require('d3'),
75
tinycolor = require('tinycolor2'),
@@ -90,6 +88,7 @@ fx.init = function(gd) {
9088
}
9189
return fullLayout._plots[a].mainplot ? 1 : -1;
9290
});
91+
9392
subplots.forEach(function(subplot) {
9493
var plotinfo = fullLayout._plots[subplot];
9594

@@ -172,21 +171,23 @@ fx.init = function(gd) {
172171
}
173172
});
174173

175-
// in case you mousemove over some hovertext, send it to fx.hover too
174+
// In case you mousemove over some hovertext, send it to fx.hover too
176175
// we do this so that we can put the hover text in front of everything,
177176
// but still be able to interact with everything as if it isn't there
178-
$(fullLayout._hoverlayer.node())
179-
.off('mousemove click')
180-
.on('mousemove',function(evt){
181-
evt.target = fullLayout._lasthover;
182-
fx.hover(gd,evt,fullLayout._hoversubplot);
183-
})
184-
.on('click',function(evt){
185-
evt.target = fullLayout._lasthover;
186-
fx.click(gd,evt);
187-
});
177+
var hoverLayer = fullLayout._hoverlayer.node();
178+
179+
hoverLayer.onmousemove = function(evt) {
180+
evt.target = fullLayout._lasthover;
181+
fx.hover(gd, evt, fullLayout._hoversubplot);
182+
};
183+
184+
hoverLayer.onclick = function(evt) {
185+
evt.target = fullLayout._lasthover;
186+
fx.click(gd, evt);
187+
};
188+
188189
// also delegate mousedowns... TODO: does this actually work?
189-
fullLayout._hoverlayer.node().onmousedown = function(evt){
190+
hoverLayer.onmousedown = function(evt) {
190191
fullLayout._lasthover.onmousedown(evt);
191192
};
192193
};
@@ -552,11 +553,13 @@ function hover(gd, evt, subplot){
552553

553554
if(!hoverChanged(gd, evt, oldhoverdata)) return;
554555

555-
// emit the custom hover handler. Bind this like:
556-
// $(gd).on('hover.plotly',
557-
// function(event,extras){ do something with extras.data });
556+
/* Emit the custom hover handler. Bind this like:
557+
* gd.on('hover.plotly', function(extras) {
558+
* // do something with extras.data
559+
* });
560+
*/
558561
if(oldhoverdata) {
559-
gd.emit('plotly_unhover', {points: oldhoverdata});
562+
gd.emit('plotly_unhover', { points: oldhoverdata });
560563
}
561564
gd.emit('plotly_hover', {
562565
points: gd._hoverdata,

shelly/plotlyjs/static/plotlyjs/src/graph_obj.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,29 @@ function positionPlayWithData(gd, container){
364364

365365
var baseUrl = (window.PLOTLYENV && window.PLOTLYENV.BASE_URL) || 'https://plot.ly';
366366

367-
var hiddenform = $(
368-
'<div id="hiddenform" style="display:none;">' +
369-
'<form action="' + baseUrl + '/external" ' +
370-
'method="post" target="_blank">'+
371-
'<input type="text" name="data" /></form></div>'
372-
).appendTo(gd);
373-
374-
hiddenform.find('input').val(plots.graphJson(gd,false,'keepdata'));
375-
hiddenform.find('form').submit();
376-
hiddenform.remove();
367+
var hiddenformDiv = d3.select(gd)
368+
.append('div')
369+
.attr('id', 'hiddenform')
370+
.style('display', 'none');
371+
372+
var hiddenform = hiddenformDiv
373+
.append('form')
374+
.attr({
375+
action: baseUrl + '/external',
376+
method: 'post',
377+
target: '_blank'
378+
});
379+
380+
var hiddenformInput = hiddenform
381+
.append('input')
382+
.attr({
383+
type: 'text',
384+
name: 'data'
385+
});
386+
387+
hiddenformInput.node().value = plots.graphJson(gd, false, 'keepdata');
388+
hiddenform.node().submit();
389+
hiddenformDiv.remove();
377390

378391
gd.emit('plotly_afterexport');
379392
return false;

test-dashboard/index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
">
1818
</div>
1919

20-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
21-
2220
<script type="text/javascript" src="./../shelly/shelly/static/js/plugins/mathjax/MathJax.js?config=TeX-AMS-MML_SVG"></script>
2321

2422
<script>

test-dashboard/toolpanel-dashboard/index.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
<div id="main"></div>
1313

14-
<!-- PlotlyJS Requirements -->
15-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
16-
1714
<!-- ToolPanel JS dependencies Bundle -->
1815
<script type="text/javascript" src="./../../shelly/toolpanel/static/toolpanel/dist/toolpanel-dependencies-bundle.js"></script>
1916

0 commit comments

Comments
 (0)