Skip to content

Instantly share code, notes, and snippets.

@caleb
Created April 8, 2011 22:45
Show Gist options
  • Select an option

  • Save caleb/910881 to your computer and use it in GitHub Desktop.

Select an option

Save caleb/910881 to your computer and use it in GitHub Desktop.
MerionNavigator.PostItemView = SC.View.extend(
/** @scope MerionNavigator.PostItemView.prototype */ {
useStaticLayout: YES,
classNames: ["post-item-view"],
displayProperties: "isSelected".w(),
content: null,
isSelected: null,
render: function(context, firstTime) {
var post = this.get("content");
var title = post.get("title") || "";
var author = post.get("author") || "";
var summary = post.get("summary") || "";
var date = post.get("publishedAt") || "";
var selected = this.get("isSelected");
if (date != "") {
date = date.toFormattedString(MerionNavigator.dateFormatString);
}
if (firstTime) {
context.begin("div").addClass("sc-outline")
.begin("div").addClass("date").push(date).end()
.begin("h1").addClass("title").push(title).end()
.begin("div").addClass("author").push(author).end()
.begin("div").addClass("summary").push(summary).end()
.end();
}
if (selected) {
context.addClass("sel");
} else {
context.removeClass("sel");
}
this.$(".date").html(date);
this.$(".title").html(title);
this.$(".author").html(author);
this.$(".summary").html(summary);
}
});
list: SC.StackedView.design({
useStaticLayout: YES,
exampleView: MerionNavigator.PostItemView,
contentBinding: "MerionNavigator.postsController.content",
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment