mirror of
https://github.com/fazo96/homework.git
synced 2025-01-10 12:14:22 +01:00
notes are now editable
This commit is contained in:
parent
0f195f57e8
commit
1f957770f7
50
app.coffee
50
app.coffee
@ -13,19 +13,39 @@ if Meteor.isClient
|
||||
|
||||
Meteor.subscribe "my-notes"
|
||||
|
||||
# User Interface
|
||||
Template.userInfo.events {
|
||||
'click #logout': (e,template) ->
|
||||
Meteor.logout()
|
||||
'keypress #newNote': (e,template) ->
|
||||
if e.keyCode is 13
|
||||
notes.insert {
|
||||
title: template.find('#newNote').value
|
||||
content: "..."
|
||||
userId: Meteor.userId()
|
||||
}
|
||||
template.find('#newNote').value = ""
|
||||
}
|
||||
Template.userInfo.in = -> Meteor.user().emails[0].address
|
||||
|
||||
# Notes template
|
||||
Template.notes.notes = -> notes.find().fetch()
|
||||
Template.notes.notes = ->
|
||||
d = notes.find().fetch();
|
||||
#d.splice d.indexOf(Session.get('note')), 1 ; d
|
||||
Template.notes.events {
|
||||
'click .close-note': -> notes.remove @_id
|
||||
'click .edit': -> Session.set 'note', this
|
||||
'click .edit-note': -> Session.set 'note', this
|
||||
}
|
||||
|
||||
# Note Editor
|
||||
Template.editor.show = -> Session.get 'note'
|
||||
Template.editor.events {
|
||||
'click .close': -> Session.set 'note', undefined
|
||||
'click .save': -> null
|
||||
}
|
||||
Template.editor.note = -> Session.get 'note'
|
||||
Template.editor.events
|
||||
'click .close-editor': -> Session.set 'note', undefined
|
||||
'click .save-editor': (e,t) ->
|
||||
notes.update Session.get('note')._id,
|
||||
$set:
|
||||
title: t.find('.title').value
|
||||
content: t.find('.area').value
|
||||
|
||||
# Notifications
|
||||
alerts = []
|
||||
@ -48,11 +68,12 @@ if Meteor.isClient
|
||||
alerts.splice alerts.indexOf(this), 1
|
||||
alertDep.changed()
|
||||
}
|
||||
|
||||
# Login and Register
|
||||
pressLogin = (template) ->
|
||||
mail = template.find('#mail').value; pass = template.find('#pass').value
|
||||
Meteor.loginWithPassword mail, pass, (err) ->
|
||||
errCallback err; if Meteor.userId() then clearNotifications()
|
||||
# Login and Register
|
||||
Template.auth.events {
|
||||
'keypress .login': (e,template) ->
|
||||
if e.keyCode is 13 then pressLogin template
|
||||
@ -72,16 +93,3 @@ if Meteor.isClient
|
||||
catch err
|
||||
notify { msg: err }
|
||||
}
|
||||
# User Logged In
|
||||
Template.userInfo.events {
|
||||
'click #logout': (e,template) ->
|
||||
Meteor.logout()
|
||||
'keypress #newNote': (e,template) ->
|
||||
if e.keyCode is 13
|
||||
notes.insert {
|
||||
content: template.find('#newNote').value
|
||||
userId: Meteor.userId()
|
||||
}
|
||||
template.find('#newNote').value = ""
|
||||
}
|
||||
Template.userInfo.in = -> Meteor.user().emails[0].address
|
||||
|
10
index.html
10
index.html
@ -24,7 +24,7 @@
|
||||
{{#each notes}}
|
||||
<li class="note list-group-item">
|
||||
<button type="button" class="edit-note close"><i class="fa fa-pencil-square-o"></i></button>
|
||||
{{content}}
|
||||
<b>{{title}}</b> <span class="subtitle">{{content}}</span>
|
||||
<button type="button" class="close-note close">×</button>
|
||||
</li>
|
||||
{{/each}}
|
||||
@ -58,12 +58,14 @@
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">
|
||||
<input type="text" class="form-control title" placeholder="Title">
|
||||
<div align="center">
|
||||
<input type="text" class="form-control title" value="{{note.title}}" placeholder="Title"></div>
|
||||
<button type="button" class="close close-editor">×</button>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<textarea class="area form-control" rows="3">{{note.content}}</textarea>
|
||||
<div align="center" class="panel-body">
|
||||
<textarea class="area form-control" rows="3" placeholder="">{{note.content}}</textarea>
|
||||
<button type="button" class="btn btn-info save-editor">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
13
style.css
13
style.css
@ -15,6 +15,8 @@ input {
|
||||
clear:both;
|
||||
}
|
||||
|
||||
.subtitle { color: #999; }
|
||||
|
||||
/* Custom Classes */
|
||||
|
||||
.edit-note {
|
||||
@ -22,6 +24,17 @@ input {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.title { width: 85%; }
|
||||
|
||||
.close-editor {
|
||||
margin-top: -28px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.save-editor {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.btn-auth {
|
||||
width: 100px;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user