Skip to content

Commit 0337d29

Browse files
Andreu Botelladomenic
authored andcommitted
Meta: Update the dfn panels to match Bikeshed's output more closely
This change removes the HTML-specific styles dealing with the dfn panels, and changes html-dfn.js to have those panels match Bikeshed's output more closely. The particular changes are: - Panels have the "dfn-panel" class, rather than "dfnPanel". They also have the "on" class, to make them visible. - Moved panels gain the "activated" class, instead of gaining inline styles. - The elements that can open a dfn panel when clicked now include headings with the "data-dfn-type" attribute (corresponding to a "dfn" attribute in the source). See whatwg/whatwg.org#343, which adds Bikeshed's dfn panel styles to standard.css.
1 parent c69ec0f commit 0337d29

File tree

2 files changed

+5
-31
lines changed

2 files changed

+5
-31
lines changed

html-dfn.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ function handleClick(event) {
2020
var node;
2121
var eventInDfnPanel = false;
2222
while (current) {
23-
if (current.localName === 'dfn') {
23+
if (current.matches(
24+
"dfn, h2[data-dfn-type], h3[data-dfn-type], h4[data-dfn-type], h5[data-dfn-type], h6[data-dfn-type]"
25+
)) {
2426
node = current;
2527
}
2628
if (dfnPanel && current === dfnPanel) {
@@ -81,7 +83,7 @@ function loadReferences(id, path, specURL) {
8183

8284
function createPanel(id, path, specURL) {
8385
var panel = document.createElement('div');
84-
panel.className = 'dfnPanel';
86+
panel.className = 'dfn-panel on';
8587
if (id) {
8688
var permalinkP = document.createElement('p');
8789
var permalinkA = document.createElement('a');
@@ -162,12 +164,7 @@ function movePanel(event) {
162164
if (!dfnPanel) {
163165
return;
164166
}
165-
dfnPanel.style.position = 'fixed';
166-
dfnPanel.style.left = '1em';
167-
dfnPanel.style.bottom = '1em';
168-
dfnPanel.style.maxWidth = '20em';
169-
dfnPanel.style.maxHeight = '50vh';
170-
dfnPanel.style.overflow = 'auto';
167+
dfnPanel.classList.add("activated");
171168
if (event) {
172169
event.stopPropagation();
173170
}

styles.css

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
body.dfnEnabled dfn, body.dfnEnabled h2[data-dfn-type], body.dfnEnabled h3[data-dfn-type], body.dfnEnabled h4[data-dfn-type], body.dfnEnabled h5[data-dfn-type], body.dfnEnabled h6[data-dfn-type] { cursor: pointer; }
2-
.dfnPanel {
3-
cursor: auto;
4-
display: inline;
5-
position: absolute;
6-
z-index: 35;
7-
height: auto;
8-
width: auto;
9-
padding: 0.5em 0.75em;
10-
font: small Helvetica Neue, sans-serif, Droid Sans Fallback;
11-
background: #DDDDDD;
12-
color: black;
13-
border: outset 0.2em;
14-
}
15-
.dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
16-
.dfnPanel :link, .dfnPanel :visited { color: black; cursor: pointer; }
17-
/* Delicate specificity wars to pretend isolation from pre:hover rules elsewhere... */
18-
.dfnPanel *, pre:hover .dfnPanel * { text-decoration: none; }
19-
pre:hover .dfnPanel :link:hover, pre:hover .dfnPanel :visited:hover { text-decoration: underline; }
20-
.dfnPanel p:not(.spec-link) { font-weight: bolder; }
21-
.dfnPanel * + p { margin-top: 0.25em; }
22-
.dfnPanel li { list-style-position: inside; list-style-type: disc; }
23-
241
.bad, .bad *:not(.X\58X) { color: gray; }
252

263
.applies .yes, .yesno .yes { background: yellow; }

0 commit comments

Comments
 (0)