Skip to content

Commit

Permalink
Optimize the behavior of back2top and a[role="button"]
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Oct 9, 2019
1 parent cec9b7e commit 38dc1de
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion layout/_partials/header/menu.swig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

{%- if hasSearch %}
<li class="menu-item menu-item-search">
<a href="javascript:;" class="popup-trigger">
<a role="button" class="popup-trigger">

This comment has been minimized.

Copy link
@1v9

1v9 Oct 30, 2019

Member

This comment has been minimized.

Copy link
@1v9

1v9 Oct 30, 2019

Member

反复横跳

This comment has been minimized.

Copy link
@stevenjoezhang

stevenjoezhang Oct 30, 2019

Author Contributor

「按照 HTML5 规范的话,这里应该用 button」
「本来 javascript: 就是不合理的写法应该被过滤掉」
「……」
「真香!」

{%- if theme.menu_settings.icons %}
<i class="fa fa-search fa-fw"></i>{#
#}{%- endif %}{#
Expand Down
2 changes: 1 addition & 1 deletion layout/_partials/widgets.swig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="reading-progress-bar"></div>
{%- endif %}
{%- if theme.bookmark.enable %}
<a class="book-mark-link book-mark-link-fixed" href="#"></a>
<a role="button" class="book-mark-link book-mark-link-fixed"></a>
{%- endif %}
{%- if theme.github_banner.enable %}
{%- set github_URL = theme.github_banner.permalink %}
Expand Down
19 changes: 6 additions & 13 deletions source/css/_common/components/back-to-top-sidebar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,21 @@
cursor: pointer;
font-size: $b2t-font-size;
margin: 20px - $sidebar-offset -10px -20px;
opacity: $b2t-opacity;
opacity: 0;
text-align: center;
visibility: hidden;
the-transition();

if (!hexo-config('back2top.scrollpercent')) {
span {
display: none;
}
}

&:hover {
opacity: $b2t-opacity-hover;
}
&.back-to-top-on {
opacity: $b2t-opacity;

+tablet-mobile() {
if (!hexo-config('sidebar.onmobile')) {
display: none;
&:hover {
opacity: $b2t-opacity-hover;
}
}

&.back-to-top-on {
visibility: visible;
the-transition();
}
}
3 changes: 1 addition & 2 deletions source/js/bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ window.addEventListener('DOMContentLoaded', () => {
window.addEventListener('pjax:send', doSaveScroll);
}
// Save the position by clicking the icon
link.addEventListener('click', event => {
event.preventDefault();
link.addEventListener('click', () => {
doSaveScroll();
window.anime({
targets : link,
Expand Down
3 changes: 1 addition & 2 deletions source/js/local-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ window.addEventListener('DOMContentLoaded', () => {
}

// Handle and trigger popup window
document.querySelector('.popup-trigger').addEventListener('click', event => {
event.stopPropagation();
document.querySelector('.popup-trigger').addEventListener('click', () => {
if (isfetched === false) {
searchFunc();
} else {
Expand Down

0 comments on commit 38dc1de

Please sign in to comment.