mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-16 16:11:39 +00:00
added checkbox handler + state...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6a16b1b023
commit
66f83629e3
2
bootstrap.js
vendored
2
bootstrap.js
vendored
File diff suppressed because one or more lines are too long
@ -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 : */
|
||||
|
||||
@ -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">☰</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>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<macro name="item-pre-controls">
|
||||
<input type="checkbox"/>
|
||||
<input type="checkbox" class="state" saveto="@source(./path)"/>
|
||||
</macro>
|
||||
|
||||
<include src="../outline">
|
||||
|
||||
36
index.html
36
index.html
@ -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(){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user