Skip to content

Commit 84d59c3

Browse files
committed
Prefix all CSS classes with hxr-
Avoid collisioning with other CSS frameworks/themes/etc. See executablebooks/sphinx-book-theme#577 Closes #180
1 parent 62f50fa commit 84d59c3

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

hoverxref/_static/css/tooltipster.custom.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.hoverxref {
1+
.hxr-hoverxref {
22
border-bottom: 1px dotted;
33
border-color: gray;
44
}

hoverxref/_static/js/hoverxref.js_t

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ $(document).ready(function() {
9696
// Remove ``title=`` attribute for intersphinx nodes that have hoverxref enabled.
9797
// It doesn't make sense the browser shows the default tooltip (browser's built-in)
9898
// and immediately after that our tooltip was shown.
99-
$('.hoverxref.external').each(function () { $(this).removeAttr('title') });
99+
$('.hxr-hoverxref.external').each(function () { $(this).removeAttr('title') });
100100

101-
$('.hoverxref.tooltip').tooltipster({
101+
$('.hxr-hoverxref.hxr-tooltip').tooltipster({
102102
theme: {{ hoverxref_tooltip_theme }},
103103
interactive: {{ 'true' if hoverxref_tooltip_interactive else 'false' }},
104104
maxWidth: {{ hoverxref_tooltip_maxwidth }},
@@ -235,7 +235,7 @@ $(document).ready(function() {
235235
};
236236

237237
var delay = {{ hoverxref_modal_hover_delay }}, setTimeoutConst;
238-
$('.hoverxref.modal').hover(function(event) {
238+
$('.hxr-hoverxref.hxr-modal').hover(function(event) {
239239
var element = $(this);
240240
console.debug('Event: ' + event + ' Element: ' + element);
241241
event.preventDefault();

hoverxref/domains.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@
77

88
class HoverXRefBaseDomain:
99

10+
css_class_prefix = 'hxr-'
1011
hoverxref_types = (
1112
'hoverxref',
1213
'hoverxreftooltip',
1314
'hoverxrefmodal',
1415
)
1516

1617
def _inject_hoverxref_data(self, env, refnode, typ):
17-
classes = ['hoverxref']
18+
classes = ['hxr-hoverxref']
1819
type_class = None
1920
if typ == 'hoverxreftooltip':
20-
type_class = 'tooltip'
21+
type_class = 'hxr-tooltip'
2122
classes.append(type_class)
2223
elif typ == 'hoverxrefmodal':
23-
type_class = 'modal'
24+
type_class = 'hxr-modal'
2425
classes.append(type_class)
2526
if not type_class:
2627
type_class = env.config.hoverxref_role_types.get(typ)
@@ -33,11 +34,13 @@ def _inject_hoverxref_data(self, env, refnode, typ):
3334
default,
3435
typ,
3536
)
36-
classes.append(type_class)
37+
38+
# Examples: hxr-tooltip, hxr-modal
39+
classes.append(f'{self.css_class_prefix}-{type_class}')
3740

3841
refnode.replace_attr('classes', classes)
3942
# TODO: log something else here, so we can unique identify this node
40-
logger.debug(
43+
logger.info(
4144
':%s: _hoverxref injected. classes=%s',
4245
typ,
4346
classes,

hoverxref/extension.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def missing_reference(app, env, node, contnode):
264264
hoverxref_type = hoverxref_type or app.config.hoverxref_default_type
265265

266266
classes = newnode.get('classes')
267-
classes.extend(['hoverxref', hoverxref_type])
267+
classes.extend(['hxr-hoverxref', hoverxref_type])
268268
newnode.replace_attr('classes', classes)
269269

270270
return newnode

0 commit comments

Comments
 (0)