Permalink
Browse files

style: Task Lists

Change click[0] to click[1] if you want to set checkbox un-clickable

#80
  • Loading branch information...
MOxFIVE committed Apr 27, 2016
1 parent ee94e78 commit e922391c734167dd0b5f38ed1290fc84ee6c8b15
Showing with 10 additions and 8 deletions.
  1. +10 −8 source/js/main.js
View
@@ -172,7 +172,7 @@ require([], function (){
// Task lists in markdown
$('ul > li').each(function() {
var taskList = {
field: $(this).text().substring(0, 2),
field: this.textContent.substring(0, 2),
check: function(str) {
var re = new RegExp(str);
return this.field.match(re);
@@ -184,18 +184,20 @@ require([], function (){
var unchecked = taskList.check(string[0]);
var $current = $(this);
function add(str, check) {
$current.html($current.html().replace(str, ""));
// In order html > prepend
$current.prepend("<input type='checkbox'" + check + ">");
function update(str, check) {
var click = ["disabled", ""];
$current.html($current.html().replace(
str, "<input type='checkbox' " + check + " " + click[1] + " >")
)
}
if (checked || unchecked) {
$(this).addClass('task-list');
this.classList.add("task-list");
if (checked) {
add(string[1][0], string[1][1]);
update(string[1][0], string[1][1]);
this.classList.add("check");
} else {
add(string[0], "");
update(string[0], "");
}
}
})

1 comment on commit e922391

@MOxFIVE

This comment has been minimized.

Show comment
Hide comment
@MOxFIVE

MOxFIVE Apr 27, 2016

Owner
- Change click[0] to click[1] if you want to set checkbox un-clickable
+ Change click[1] to click[0] if you want to set checkbox un-clickable

Add class "check" for checked lists

Owner

MOxFIVE commented on e922391 Apr 27, 2016

- Change click[0] to click[1] if you want to set checkbox un-clickable
+ Change click[1] to click[0] if you want to set checkbox un-clickable

Add class "check" for checked lists

Please sign in to comment.