Created
September 20, 2012 11:44
-
-
Save abrkn/3755445 to your computer and use it in GitHub Desktop.
COFFEE-fied
This file contains 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
App.Meta = Backbone.Model.extend(initialize: -> | |
# Locate tags and find current values. | |
@$titleTag = $("title") | |
@$titleTag = $("<title></title>").appendTo($("head")) unless @$titleTag.length | |
@$descriptionTag = $("meta[name=\"description\"]") | |
@$descriptionTag = $("<meta name=\"description\" content=\"\" />").appendTo("head") unless @$descriptionTag.length | |
@attributes.title = window.title or @$titleTag.text() | |
@attributes.description = @$descriptionTag.attr("content") | |
@attributes.rendered = false | |
# Subscribe to events | |
@on "change:title", (model, title) -> | |
model.$titleTag.val title | |
document.title = title | |
@on "change:description", (model, description) -> | |
model.$descriptionTag.attr "content", description | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment