mirror of
https://github.com/aelve/guide.git
synced 2024-12-24 13:26:08 +03:00
66 lines
1.9 KiB
Plaintext
66 lines
1.9 KiB
Plaintext
Description
|
|
============================================================
|
|
|
|
The “summary” section of an item.
|
|
|
|
Required context:
|
|
|
|
* item
|
|
|
|
|
|
HTML
|
|
============================================================
|
|
<div class="item-description">
|
|
<div class="section normal shown noscript-shown">
|
|
<strong>Summary</strong>
|
|
{{> space em=0.5 }}
|
|
{{> small-control
|
|
src = "/pencil.svg"
|
|
title = "edit summary"
|
|
action = [| editItemDescription(
|
|
{{{%js item.uid}}},
|
|
{{{%js item.description.text}}}); |] }}
|
|
<div class="notes-like">
|
|
{{# item.description.text}}
|
|
{{{item.description.html}}}
|
|
{{/ item.description.text}}
|
|
{{^ item.description.text}}
|
|
<p>write something here!</p>
|
|
{{/ item.description.text}}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section editing">
|
|
<strong>Summary</strong>
|
|
{{> space em=0.5 }}
|
|
{{> small-control
|
|
src = "/pencil.svg"
|
|
title = "quit editing summary"
|
|
action = [| stopEditingItemDescription({{{%js item.uid}}}); |] }}
|
|
<div class="editor"></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
JS
|
|
============================================================
|
|
function editItemDescription(itemUid, descrText) {
|
|
var descrNode = "#item-" + itemUid + " .item-description";
|
|
switchSection(descrNode, "editing");
|
|
var editor = bigEditor({
|
|
rows: 10,
|
|
text: descrText,
|
|
hint: "or press Ctrl+Enter to save",
|
|
saveAction: function(newDescrText) {
|
|
submitItemDescription(descrNode, itemUid, descrText, newDescrText); },
|
|
cancelAction: function() {
|
|
switchSection(descrNode, "normal"); }
|
|
});
|
|
$(descrNode + " .editor").html(editor);
|
|
focusOn(descrNode + " .editor-area");
|
|
}
|
|
function stopEditingItemDescription(itemUid) {
|
|
var descrNode = "#item-" + itemUid + " .item-description";
|
|
switchSection(descrNode, "normal");
|
|
}
|