Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5356ef0

Browse filesBrowse files
committed
Replace jquery by vanilla JS.
This is a mix of the change in ipympl, plus the same thing for our original version of other stuff. Fixes #14596.
1 parent c46699c commit 5356ef0
Copy full SHA for 5356ef0

File tree

Expand file treeCollapse file tree

6 files changed

+228
-169
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+228
-169
lines changed

‎examples/user_interfaces/embedding_webagg_sgskip.py

Copy file name to clipboardExpand all lines: examples/user_interfaces/embedding_webagg_sgskip.py
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,15 @@ def create_figure():
7171
window.open('download.' + format, '_blank');
7272
};
7373
74-
$(document).ready(
74+
function ready(fn) {
75+
if (document.readyState != "loading") {
76+
fn();
77+
} else {
78+
document.addEventListener("DOMContentLoaded", fn);
79+
}
80+
}
81+
82+
ready(
7583
function() {
7684
/* It is up to the application to provide a websocket that the figure
7785
will use to communicate to the server. This websocket object can
@@ -89,7 +97,7 @@ def create_figure():
8997
// A function called when a file type is selected for download
9098
ondownload,
9199
// The HTML element in which to place the figure
92-
$('div#figure'));
100+
document.getElementById("figure"));
93101
}
94102
);
95103
</script>

‎lib/matplotlib/backends/web_backend/all_figures.html

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/web_backend/all_figures.html
+22-14Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,33 @@
1010
<script src="{{ prefix }}/js/mpl.js"></script>
1111

1212
<script>
13-
{% for (fig_id, fig_manager) in figures %}
14-
$(document).ready(
15-
function() {
16-
var main_div = $('div#figures');
17-
var figure_div = $('<div id="figure-div"/>')
18-
main_div.append(figure_div);
13+
function ready(fn) {
14+
if (document.readyState != "loading") {
15+
fn();
16+
} else {
17+
document.addEventListener("DOMContentLoaded", fn);
18+
}
19+
}
20+
21+
function figure_ready(fig_id) {
22+
return function () {
23+
var main_div = document.querySelector("div#figures");
24+
var figure_div = document.createElement("div");
25+
figure_div.id = "figure-div";
26+
main_div.appendChild(figure_div);
1927
var websocket_type = mpl.get_websocket_type();
20-
var websocket = new websocket_type(
21-
"{{ ws_uri }}" + "{{ fig_id }}" + "/ws");
22-
var fig = new mpl.figure(
23-
"{{ fig_id }}", websocket, mpl_ondownload, figure_div);
28+
var websocket = new websocket_type("{{ ws_uri }}" + fig_id + "/ws");
29+
var fig = new mpl.figure(fig_id, websocket, mpl_ondownload, figure_div);
2430

2531
fig.focus_on_mouseover = true;
2632

27-
$(fig.canvas).attr('tabindex', {{ fig_id }});
28-
}
29-
);
33+
fig.canvas.setAttribute("tabindex", fig_id);
34+
}
35+
};
3036

31-
{% end %}
37+
{% for (fig_id, fig_manager) in figures %}
38+
ready(figure_ready({{ repr(str(fig_id)) }}));
39+
{% end %}
3240
</script>
3341

3442
<title>MPL | WebAgg current figures</title>

‎lib/matplotlib/backends/web_backend/ipython_inline_figure.html

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/web_backend/ipython_inline_figure.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
function init_figure{{ fig_id }}(e) {
1313
$('div.output').off('resize');
1414

15-
var output_div = $(e.target).find('div.output_subarea');
15+
var output_div = e.target.querySelector('div.output_subarea');
1616
var websocket_type = mpl.get_websocket_type();
1717
var websocket = new websocket_type(
1818
"ws://" + window.location.hostname + ":{{ port }}{{ prefix}}/" +

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.