Last active
December 21, 2015 20:29
-
-
Save scottbaggett/6361433 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Template.articlesForm.events | |
| 'submit #formNewArticle': (e, tmpl) -> | |
| e.preventDefault() | |
| # article properties | |
| article = | |
| created_at: new Date() | |
| published_on: new Date(tmpl.find(".datepicker").value) | |
| title: tmpl.find('#inputTitle').value | |
| content: $("#editor").html() | |
| # update if there's an id, | |
| # create if not | |
| if @_id | |
| _id = Articles.update this._id, $set: | |
| created_at: article.createdAt | |
| title: article.title | |
| published_on: article.published_on | |
| content: article.content | |
| else | |
| _id = Articles.insert article | |
| # redirect back to articles | |
| Router.go "/articles" | |
| Template.articlesForm.rendered = -> | |
| # article content editor | |
| $("#editor").wysiwyg | |
| hotKeys: | |
| "ctrl+b meta+b": "bold" | |
| "ctrl+i meta+i": "italic" | |
| "ctrl+u meta+u": "underline" | |
| "ctrl+z meta+z": "undo" | |
| "ctrl+y meta+y meta+shift+z": "redo" | |
| # published_on date picker | |
| $('.datepicker').datepicker() | |
| Template.articlesForm.published_on = -> | |
| moment(@published_on).format('MM/DD/YY hh:mma') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment