added checkbox handler + state...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-08-13 19:43:53 +03:00
parent 6a16b1b023
commit 66f83629e3
5 changed files with 41 additions and 9 deletions

2
bootstrap.js vendored

File diff suppressed because one or more lines are too long

View File

@ -3,8 +3,7 @@
display: block;
}
input[type="checkbox"][checked]~*,
.checked {
.item.checked .item-content * {
text-decoration: line-through;
}
@ -34,6 +33,7 @@ input[type="checkbox"][checked]~*,
padding-left: 5px;
padding-right: 5px;
cursor: pointer;
text-decoration: none;
}
.item:hover .sort-handle {
opacity: 0.3;
@ -41,3 +41,5 @@ input[type="checkbox"][checked]~*,
.sort-placeholder {
display: block;
}
/* vim:set ts=4 sw=4 ft=css : */

View File

@ -1,6 +1,6 @@
<macro name="item-pre-controls"/>
<macro name="item-content">
<macro name="item-content" class="item-content">
<include
class="raw"
contenteditable
@ -31,7 +31,7 @@
<div>
<span class="sort-handle">&#x2630;</span>
<macro name="item-pre-controls" src="."/>
<macro name="item-content" src="."/>
<macro name="item-content" src="." />
<span class="separator"/>
<macro name="item-post-controls" src="."/>
</div>

View File

@ -1,5 +1,5 @@
<macro name="item-pre-controls">
<input type="checkbox"/>
<input type="checkbox" class="state" saveto="@source(./path)"/>
</macro>
<include src="../outline">

View File

@ -27,16 +27,46 @@ var clear = () => {
delete localStorage['wiki-location']
}
var save = () => {
// XXX save...
localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data)
localStorage['wiki-location'] = Wiki.location
}
var reload = () => {
$('.wiki')
.html(Wiki.title[0] == '_' ? Wiki.text : Wiki.get('./_view').text)
.ready(update_editor)
// XXX save...
localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data)
localStorage['wiki-location'] = Wiki.location
save()
$('title').text(Wiki.location)
$('input[type="checkbox"].state')
// initial state...
.each(function(){
var path = $(this).attr('saveto')
var value = !!Wiki.get(path).data.checked
$(this)
.prop('checked', value)
.parents('.item').first()
[value ? 'addClass' : 'removeClass']('checked')
})
// handle clicks...
.click(function(){
var path = $(this).attr('saveto')
var value = $(this).prop('checked')
Wiki.get(path).data.checked = value
$(this)
.parents('.item').first()
[value ? 'addClass' : 'removeClass']('checked')
// XXX
save()
})
}
var update_editor = function(){