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

View File

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

View File

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

View File

@ -27,16 +27,46 @@ var clear = () => {
delete localStorage['wiki-location'] delete localStorage['wiki-location']
} }
var save = () => {
// XXX save...
localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data)
localStorage['wiki-location'] = Wiki.location
}
var reload = () => { var reload = () => {
$('.wiki') $('.wiki')
.html(Wiki.title[0] == '_' ? Wiki.text : Wiki.get('./_view').text) .html(Wiki.title[0] == '_' ? Wiki.text : Wiki.get('./_view').text)
.ready(update_editor) .ready(update_editor)
// XXX save... save()
localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data)
localStorage['wiki-location'] = Wiki.location
$('title').text(Wiki.location) $('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(){ var update_editor = function(){