From aba3d25d7a8124ae49c15f9bc81d7f74921aca37 Mon Sep 17 00:00:00 2001
From: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
Date: Mon, 14 Dec 2020 15:01:05 +0800
Subject: [PATCH] Always load browser default checkbox
---
_includes/refactor-content.html | 27 ++++++++++++++++++---------
assets/css/_addon/main.scss | 6 ++++--
assets/js/_commons/checkbox.js | 8 ++++----
3 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/_includes/refactor-content.html b/_includes/refactor-content.html
index 876d66e33..1e44de328 100644
--- a/_includes/refactor-content.html
+++ b/_includes/refactor-content.html
@@ -4,24 +4,33 @@
{% assign _content = include.content %}
-
+
{% if _content contains '
' %}
- {% assign _content = _content | replace: '', '' %}
- {% assign _content = _content | replace: '
', '
' %}
- {% assign _content = _content | replace: '
', '' %}
+ {% assign _content = _content
+ | replace: ''
+ | replace: '', ''
+ %}
{% endif %}
-
{% if _content contains '' %}
- {% assign _content = _content | replace: '', '' %}
+ {% assign _content = _content
+ | replace: '', ''
+ %}
{% endif %}
+
+{% if _content contains '
<' %}
+ {% assign _content = _content
+ | replace: '"task-list-item"><', '"task-list-item" hide-bullet><'
+ %}
+{% endif %}
+
+
{{ _content }}
diff --git a/assets/css/_addon/main.scss b/assets/css/_addon/main.scss
index f88615a40..ab8bd9f83 100644
--- a/assets/css/_addon/main.scss
+++ b/assets/css/_addon/main.scss
@@ -866,7 +866,7 @@ div.post-content .table-wrapper {
padding-left: 2rem;
}
- // attribute 'hide-bullet' added by JS
+ // attribute 'hide-bullet' was added by liquid
.task-list-item[hide-bullet] {
list-style-type: none;
@@ -898,10 +898,12 @@ div.post-content .table-wrapper {
}
}
}
+
} // .task-list-item
input[type=checkbox] {
- display: none;
+ margin: 0 .5rem .2rem -1.3rem;
+ vertical-align: middle;
}
} // ul
diff --git a/assets/js/_commons/checkbox.js b/assets/js/_commons/checkbox.js
index 39d9d3856..93ab6d1e8 100644
--- a/assets/js/_commons/checkbox.js
+++ b/assets/js/_commons/checkbox.js
@@ -3,10 +3,10 @@
*/
$(function() {
- /* hide bullet of checkbox item */
- $("li.task-list-item:has(input)").attr("hide-bullet", "");
+ /* hide browser default checkbox */
+ $("input[type=checkbox]").addClass("unloaded");
/* create checked checkbox */
- $("input[type=checkbox][checked=checked]").before("");
+ $("input[type=checkbox][checked]").before("");
/* create normal checkbox */
- $("input[type=checkbox]:not([checked=checked])").before("");
+ $("input[type=checkbox]:not([checked])").before("");
});