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 d8841db

Browse filesBrowse files
committed
Implement spacers in nbagg toolbar.
For nbAgg, encapsulate buttons in a button group, and create new groups whenever we encounter a spacer. Change the toolbar's style to use Bootstrap.
1 parent 4b182e2 commit d8841db
Copy full SHA for d8841db

File tree

Expand file treeCollapse file tree

1 file changed

+15
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-4
lines changed

‎lib/matplotlib/backends/web_backend/js/nbagg_mpl.js

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/web_backend/js/nbagg_mpl.js
+15-4Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ mpl.figure.prototype._init_toolbar = function () {
9494
var fig = this;
9595

9696
var toolbar = document.createElement('div');
97-
toolbar.setAttribute('style', 'width: 100%');
97+
toolbar.classList = 'btn-toolbar';
9898
this.root.appendChild(toolbar);
9999

100100
function on_click_closure(name) {
@@ -109,6 +109,8 @@ mpl.figure.prototype._init_toolbar = function () {
109109
};
110110
}
111111

112+
var buttonGroup = document.createElement('div');
113+
buttonGroup.classList = 'btn-group';
112114
var button;
113115
for (var toolbar_ind in mpl.toolbar_items) {
114116
var name = mpl.toolbar_items[toolbar_ind][0];
@@ -117,6 +119,12 @@ mpl.figure.prototype._init_toolbar = function () {
117119
var method_name = mpl.toolbar_items[toolbar_ind][3];
118120

119121
if (!name) {
122+
/* Instead of a spacer, we start a new button group. */
123+
if (buttonGroup.hasChildNodes()) {
124+
toolbar.appendChild(buttonGroup);
125+
}
126+
buttonGroup = document.createElement('div');
127+
buttonGroup.classList = 'btn-group';
120128
continue;
121129
}
122130

@@ -127,13 +135,16 @@ mpl.figure.prototype._init_toolbar = function () {
127135
button.innerHTML = '<i class="fa ' + image + ' fa-lg"></i>';
128136
button.addEventListener('click', on_click_closure(method_name));
129137
button.addEventListener('mouseover', on_mouseover_closure(tooltip));
130-
toolbar.appendChild(button);
138+
buttonGroup.appendChild(button);
139+
}
140+
141+
if (buttonGroup.hasChildNodes()) {
142+
toolbar.appendChild(buttonGroup);
131143
}
132144

133145
// Add the status bar.
134146
var status_bar = document.createElement('span');
135-
status_bar.classList = 'mpl-message';
136-
status_bar.setAttribute('style', 'text-align:right; float: right;');
147+
status_bar.classList = 'mpl-message pull-right';
137148
toolbar.appendChild(status_bar);
138149
this.message = status_bar;
139150

0 commit comments

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