mirror of
https://github.com/JanGross/quicknotes.git
synced 2026-01-17 03:07:16 +01:00
Use handlebars templates to add insert new notes.
This commit is contained in:
23
js/script.js
23
js/script.js
@@ -551,22 +551,21 @@ View.prototype = {
|
|||||||
content: '',
|
content: '',
|
||||||
color: '#F7EB96'
|
color: '#F7EB96'
|
||||||
};
|
};
|
||||||
|
|
||||||
self._notes.create(note).done(function() {
|
self._notes.create(note).done(function() {
|
||||||
if (self._notes.length() > 1) {
|
if (self._notes.length() > 1) {
|
||||||
note = self._notes.getActive();
|
note = self._notes.getActive();
|
||||||
var $notehtml = $("<div class=\"note-grid-item\">" +
|
var $notehtml = $(Handlebars.templates['note-item']({
|
||||||
" <div class=\"quicknote noselect\" style=\"background-color: " + note.color + "\" data-id=\"" + note.id + "\">" +
|
color: note.color,
|
||||||
" <div>" +
|
id: note.id,
|
||||||
" <div class=\"icon-delete hide-delete-icon icon-delete-note\" title=\"Delete\"></div>" +
|
title: note.title,
|
||||||
" <div class=\"note-title\">" + note.title + "</div>" +
|
content: note.content,
|
||||||
" </div>" +
|
timestamp: note.timestamp,
|
||||||
" <div class=\"note-content\">" + note.content + "</div>" +
|
}));
|
||||||
" </div>" +
|
|
||||||
"</div>");
|
$(".notes-grid").prepend($notehtml)
|
||||||
$(".notes-grid").prepend( $notehtml )
|
.isotope('prepended', $notehtml)
|
||||||
.isotope({ filter: '*'})
|
.isotope({ filter: '*'})
|
||||||
.isotope( 'prepended', $notehtml);
|
.isotope('layout');
|
||||||
self._notes.unsetActive();
|
self._notes.unsetActive();
|
||||||
self.renderNavigation();
|
self.renderNavigation();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
30
js/templates/note-item.handlebars
Normal file
30
js/templates/note-item.handlebars
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<div class="note-grid-item">
|
||||||
|
<div class="quicknote noselect {{#if active}}note-active{{/if}} {{#if isshared}}shared{{/if}} {{#if sharedwith}}shareowner{{/if}}" style="background-color: {{color}}" data-id="{{ id }}" data-timestamp="{{ timestamp }}" >
|
||||||
|
{{#if isshared}}
|
||||||
|
<div>
|
||||||
|
<div class='icon-share shared-title' title="Shared by {{ userid }}"></div>
|
||||||
|
<div class='note-title'>
|
||||||
|
{{{ title }}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id='content' class='note-content'>
|
||||||
|
{{{ content }}}
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<div>
|
||||||
|
<div class="icon-delete hide-delete-icon icon-delete-note" title="Delete"></div>
|
||||||
|
<!--
|
||||||
|
{{#if sharedwith}}
|
||||||
|
<div class='icon-share shared-title-owner' title="Shared with {{ sharedwith }}"></div>
|
||||||
|
{{/if}}
|
||||||
|
-->
|
||||||
|
<div class='note-title'>
|
||||||
|
{{{ title }}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class='note-content'>
|
||||||
|
{{{ content }}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user