Skip to content

Commit 4c11a88

Browse files
committed
Making comment tooltips mobile-friendly
1 parent e34cdb4 commit 4c11a88

18 files changed

+150
-55
lines changed

_includes/comments/new.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<input id="post-id" name="post_id" type="hidden" value="{{ slug }}" />
66

77
<div id="comment-box">
8-
<img id="avatar-preview" class="avatar light-border" data-role="user-avatar"
8+
<img id="avatar-preview" class="avatar medium-border" data-role="user-avatar"
99
src="{{ site.baseurl }}/assets/images/comments/avatar-unknown.gif" alt="avatar" />
1010

1111
<div id="comment-text">
@@ -21,15 +21,16 @@
2121

2222
<input type="text" id="identity" name="identity" class="form-input"
2323
placeholder="email/@twitter/github" value="" />
24-
<span class="icon-wrapper" title="Identity is only used to generate an avatar. It is not submitted with the form.">
24+
<span class="icon-wrapper has-tooltip" data-tooltip="Identity is only used to generate an avatar. It is not submitted with the form.">
2525
{% include icons/info.html %}
2626
</span>
2727

2828
<input id="comment-submit" type="submit" value="Add comment" />
2929

3030
<div id="remember-me">
3131
<input type="checkbox" id="remember" name="remember"><label for="remember">Remember me</label>
32-
<span title="Stores your name and email in the browser so you don't have to fill out the form again. This does not set a cookie.">
32+
<span class="has-tooltip" data-tooltip-pos="above-left"
33+
data-tooltip="Stores your name and email in the browser so you don't have to fill out the form again. Does not set a cookie.">
3334
{% include icons/info.html %}
3435
</span>
3536
</div>

_includes/featuredbox.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
<article class="post post-featured has-image">
33
<div class="post-inside">
44
{% if post.featured_image %}
5-
<a href="{{ post.url | absolute_url }}" class="post-thumbnail">
6-
<img src="{{ post.featured_image | prepend: site.baseurl }}"
5+
<a href="{{ post.url }}" class="post-thumbnail">
6+
<img src="/{{ post.featured_image }}"
77
alt="{% if post.featured_image_alt %}{{ post.featured_image_alt }}{% else %}{{ post.title }}{% endif %}">
88
</a>
99
{% endif %}
1010
<header class="post-header">
1111
<h2 class="post-title">
12-
<a href="{{ site.baseurl }}{{ post.url }}" rel="bookmark">{{ post.title }}</a>
12+
<a href="{{ post.url }}" rel="bookmark">{{ post.title }}</a>
1313
</h2>
1414
<div class="post-meta">
1515
<time class="published" datetime="{{ post.date | date: '%Y-%m-%d' }}">{{ post.date | date: '%B %-d, %Y' }}</time>
1616
</div><!-- .post-meta -->
1717
{% if post.tags.size > 0 %}
1818
<div class="post-tags">
19-
{% for tag in post.tags %}<a href="{{ site.baseurl }}/tags/#{{ tag | cgi_encode }}" rel="tag">{{ tag }}</a>
19+
{% for tag in post.tags %}<a href="/tags/#{{ tag | cgi_encode }}" rel="tag">{{ tag }}</a>
2020
{% unless forloop.last %} {% endunless %}{% endfor %}
2121
</div>
2222
{% endif %}

_includes/postbox.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<article class="post">
22
<header class="post-header">
33
<h2 class="post-title">
4-
<a href="{{ post.url | absolute_url }}" rel="bookmark">{{ post.title }}</a>
4+
<a href="{{ post.url }}" rel="bookmark">{{ post.title }}</a>
55
</h2>
66
</header><!-- .post-header -->
77
<div class="post-content">
88
<p>{{ post.excerpt | strip_html }} </p>
99
{% if post.tags.size > 0 %}
1010
<p class="post-tags">
11-
{% for tag in post.tags %}<a href="{{ site.baseurl }}/tags/#{{ tag | cgi_encode }}" rel="tag">{{ tag }}</a>
11+
{% for tag in post.tags %}<a href="/tags/#{{ tag | cgi_encode }}" rel="tag">{{ tag }}</a>
1212
{% unless forloop.last %} {% endunless %}{% endfor %}
1313
</p>
1414
{% endif %}

_includes/to-top-link.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<p class="tag-top"><a href="#page" class="button-small">Return to top </a></p>
1+
<p class="tag-top"><a href="#page" class="button-small">Back to top </a></p>

_posts/2020-05-01-readableexpressions-v3.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ Colourized with Visual Studio 2019's light theme colours!
3030

3131
The options menu let you switch the theme - perhaps you prefer dark? (as I obviously do):
3232

33-
![v3 dark theme]({{ site.post_images_dir }}{{ page.images_dir }}v3-dark.gif#light-border)
33+
![v3 dark theme]({{ site.post_images_dir }}{{ page.images_dir }}v3-dark.gif#medium-border)
3434

3535
There's also various ways to customise the translation - maybe you'd prefer to declare out parameter
3636
variable inline:
3737

38-
![v3 out param declared inline]({{ site.post_images_dir }}{{ page.images_dir }}v3-dark-inline.gif#light-border)
38+
![v3 out param declared inline]({{ site.post_images_dir }}{{ page.images_dir }}v3-dark-inline.gif#medium-border)
3939

4040
...and perhaps you'd rather use the parameter type name, instead of `var`:
4141

42-
![v3 out param declared with type name]({{ site.post_images_dir }}{{ page.images_dir }}v3-dark-inline-explicit.gif#light-border)
42+
![v3 out param declared with type name]({{ site.post_images_dir }}{{ page.images_dir }}v3-dark-inline-explicit.gif#medium-border)
4343

4444
...or be shown the type of the lambda's `ip` parameter:
4545

46-
![v3 with lambda parameter type name]({{ site.post_images_dir }}{{ page.images_dir }}v3-dark-inline-explicit-lambda-param.gif#light-border)
46+
![v3 with lambda parameter type name]({{ site.post_images_dir }}{{ page.images_dir }}v3-dark-inline-explicit-lambda-param.gif#medium-border)
4747

4848
## More to come
4949

_sass/_forms.scss

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ input.confirm-button {
100100
}
101101

102102
/* Form progress */
103-
104103
.ajax-form {
105104
position: relative;
106105
}
@@ -173,3 +172,26 @@ input.confirm-button {
173172
color: $red;
174173
width: 30px;
175174
}
175+
176+
/* Tooltips */
177+
.has-tooltip {
178+
display: inline-block;
179+
position: relative;
180+
181+
.tooltip {
182+
background-color: $tooltip-bg-color;
183+
border: 1px solid $gray-lighter;
184+
color: $tooltip-text-color;
185+
font-size: 80%;
186+
left: 23px;
187+
padding: 3px 5px;
188+
position: absolute;
189+
visibility: hidden;
190+
width: 180px;
191+
z-index: 1;
192+
}
193+
194+
&:hover .tooltip {
195+
visibility: visible;
196+
}
197+
}

_sass/_general.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ img {
126126
max-width: 100%;
127127
}
128128

129-
.light-border, img[src*="#light-border"] {
129+
.medium-border, img[src*="#medium-border"] {
130130
border: 1px solid $gray;
131131
}
132132

_sass/_variables.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ $updated-bg-color: $cyan;
3838
$updated-text-color: $white;
3939

4040
$form-error-color: $red;
41+
42+
$tooltip-bg-color: $black;
43+
$tooltip-text-color: $white
44+

assets/js/ao-forms.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@
5454
this._base.call(this, input);
5555

5656
this.on('blur keyup', this.validate);
57-
this._msg = ao(this.e.nextElementSibling);
58-
if (this._msg.e.classList.contains('error-message') === false) {
59-
this._msg = ao(document.createElement('span')).addClass('error-message');
57+
this._msg = ao(input.nextElementSibling);
58+
if (this._msg.hasClass('error-message') === false) {
59+
this._msg = ao('<span>').addClass('error-message');
6060
this.after(this._msg);
6161
}
6262
this._validators = [];
6363
for (var i = 0; i < validatorsCount; ++i) {
6464
var validatorName = validatorNames[i];
65-
var msg = input.getAttribute('data-val-' + validatorName);
65+
var msg = this.attr('data-val-' + validatorName);
6666
if (Boolean(msg)) {
6767
this._validators.push({ test: validators[validatorName], msg: msg });
6868
}
@@ -139,4 +139,17 @@
139139
}
140140
return new AoForm(form);
141141
};
142+
143+
ao(function () {
144+
var tooltips = ao.getAllByCss('.has-tooltip');
145+
for (var i = 0, l = tooltips.length; i < l; ++i) {
146+
var tooltipOwner = ao(tooltips[i]);
147+
var text = tooltipOwner.attr('data-tooltip');
148+
var tooltip = ao('<span>').addClass('tooltip').html(text);
149+
tooltipOwner.removeAttr('data-tooltip').append(tooltip);
150+
var pos = tooltipOwner.attr('data-tooltip-pos');
151+
if (!Boolean(pos)) { continue; }
152+
tooltip.css('left', 'auto', 'right', 0, 'bottom', '29px');
153+
}
154+
});
142155
})(Ao);

assets/js/ao-forms.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)