Add checklist item toggling (close #2)
This commit is contained in:
parent
82583f45ba
commit
5dfc6da7c9
@ -1,5 +1,5 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<widget id="com.netsyms.NotePostApp" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
||||
<widget id="com.netsyms.NotePostApp" version="1.1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
||||
<name>NotePost</name>
|
||||
<description>
|
||||
A cross-platform client app for NotePost.
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.netsyms.NotePostApp",
|
||||
"displayName": "NotePost",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"description": "A cross-platform client app for NotePost.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -86,6 +86,35 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
background-image: url(../img/starbg_light.svg);
|
||||
}
|
||||
|
||||
.notecard .card-content ul, .notecard .card-content ol {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.notecard .card-content li > ul, .notecard .card-content li > ol {
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.notecard .card-content li > ul > li.parsedown-task-list-close, .notecard .card-content li > ul > li.parsedown-task-list-open {
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
.notecard .card-content li:not(.parsedown-task-list-close):not(.parsedown-task-list-open) {
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
.parsedown-task-list-close {
|
||||
text-decoration: line-through;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.parsedown-task-list-open {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.parsedown-task-list {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.popover .list .list-button {
|
||||
color: inherit;
|
||||
}
|
@ -19,6 +19,55 @@ $(".view-main").on("input change", "#searchbar-input", function () {
|
||||
});
|
||||
});
|
||||
|
||||
$(".view-main").on("click", ".parsedown-task-list", function (e) {
|
||||
var noteid = $(this).closest(".notecard").data("id");
|
||||
var note = NOTES.get(noteid);
|
||||
var checkbox = $(this).find("input[type=checkbox]");
|
||||
var line = $(this);
|
||||
var text = line.text().trim();
|
||||
// The checkbox has already changed by itself if it was clicked directly
|
||||
var checked = checkbox.prop("checked");
|
||||
if (e.target.nodeName != "INPUT") {
|
||||
checked = !checked;
|
||||
}
|
||||
console.log(checkbox);
|
||||
console.log(line);
|
||||
console.log(checked);
|
||||
|
||||
var lines = note.content.split("\n");
|
||||
var newcontent = "";
|
||||
|
||||
for (i in lines) {
|
||||
var li = lines[i].trim();
|
||||
if (!li.match(/^- \[[x ]\] .*/i)) {
|
||||
continue;
|
||||
}
|
||||
var linecleaned = li.replace(/^- \[[x ]\] /i, '').trim();
|
||||
if (text != linecleaned) {
|
||||
continue;
|
||||
}
|
||||
if (li.match(/^- \[[x]\] .*/i)) {
|
||||
lines[i] = li.replace(/^- \[[x]\] /i, "- [ ] ");
|
||||
line.addClass("parsedown-task-list-open");
|
||||
line.removeClass("parsedown-task-list-close");
|
||||
checkbox.prop("checked", false);
|
||||
} else if (li.match(/^- \[[ ]\] .*/i)) {
|
||||
lines[i] = li.replace(/^- \[[ ]\] /i, "- [x] ");
|
||||
line.addClass("parsedown-task-list-close");
|
||||
line.removeClass("parsedown-task-list-open");
|
||||
checkbox.prop("checked", true);
|
||||
}
|
||||
}
|
||||
|
||||
note.content = lines.join("\n");
|
||||
note.modified = null;
|
||||
note.html = null;
|
||||
|
||||
NOTES.set(NOTES.fix(note));
|
||||
|
||||
NOTES.sync();
|
||||
});
|
||||
|
||||
function loadCards(callback) {
|
||||
// Do it twice as a workaround for the stupid sync issue
|
||||
NOTES.sync(function () {
|
||||
@ -46,7 +95,10 @@ function loadCards(callback) {
|
||||
id: note.noteid
|
||||
});
|
||||
}
|
||||
console.log(trayitems);
|
||||
$(".notecard .card-content ul li:has(input[type=checkbox])").addClass("parsedown-task-list");
|
||||
$(".notecard .card-content ul li:has(input[type=checkbox]:checkbox:not(:checked))").addClass("parsedown-task-list-open");
|
||||
$(".notecard .card-content ul li:has(input[type=checkbox]:checkbox:checked)").addClass("parsedown-task-list-close");
|
||||
$(".parsedown-task-list input[type=checkbox]").removeAttr("disabled");
|
||||
var noteElements = document.getElementsByClassName("notecard-col");
|
||||
window.shuffleInstance.add(noteElements);
|
||||
window.shuffleInstance.sort({
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.netsyms.NotePostApp",
|
||||
"displayName": "NotePost",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"description": "A cross-platform client app for NotePost.",
|
||||
"author": "Netsyms Technologies",
|
||||
"license": "MPL-2.0",
|
||||
|
@ -109,7 +109,7 @@ var routes = [
|
||||
},
|
||||
{
|
||||
setting: "versions",
|
||||
title: "NotePost app v1.0.0",
|
||||
title: "NotePost app v1.1.0",
|
||||
text: "Copyright © 2018-2019 Netsyms Technologies. License: <span style=\"text-decoration: underline;\" onclick=\"openBrowser('https://source.netsyms.com/Apps/NotePostApp?pk_campaign=NotePostApp');\">Mozilla Public License 2.0</span>.",
|
||||
onclick: ""
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user