pages wip
This commit is contained in:
parent
7acbfe1b78
commit
c0eeb7680b
12 changed files with 113 additions and 96 deletions
|
|
@ -19,29 +19,7 @@
|
|||
%i.icon-time
|
||||
= time_ago_in_words(@post.created_at) + ' ago'
|
||||
|
||||
|
||||
#post-content
|
||||
|
||||
- if current_user
|
||||
#user-controls
|
||||
= link_to "#", :class => "label", do
|
||||
%i.icon-user.icon-white
|
||||
|
||||
= link_to "#", :class => "label" do
|
||||
%i.icon-heart.icon-white
|
||||
|
||||
= link_to "#", :class => "label" do
|
||||
%i.icon-plus.icon-white
|
||||
|
||||
= link_to "#", :class => "label" do
|
||||
%i.icon-retweet.icon-white
|
||||
|
||||
= link_to "#", :class => "label", do
|
||||
%i.icon-comment.icon-white
|
||||
|
||||
|
||||
= link_to image_tag('arrow-left.png'), '#', :class => 'nav-arrow left', :id => 'forward'
|
||||
= link_to image_tag('arrow-right.png'), '#', :class => 'nav-arrow right', :id => 'back'
|
||||
#container
|
||||
|
||||
#comment.modal.fade
|
||||
.modal-header
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ javascripts:
|
|||
- public/javascripts/app/views.js
|
||||
- public/javascripts/app/models/post.js
|
||||
- public/javascripts/app/models/*
|
||||
- public/javascripts/app/pages/*
|
||||
- public/javascripts/app/collections/*
|
||||
- public/javascripts/app/views/stream_object_view.js
|
||||
- public/javascripts/app/views/content_view.js
|
||||
|
|
|
|||
BIN
public/images/arrow.psd
Normal file
BIN
public/images/arrow.psd
Normal file
Binary file not shown.
|
|
@ -3,6 +3,7 @@ var app = {
|
|||
models: {},
|
||||
helpers: {},
|
||||
views: {},
|
||||
pages: {},
|
||||
|
||||
user: function(userAttrs) {
|
||||
if(userAttrs) { return this._user = new app.models.User(userAttrs) }
|
||||
|
|
|
|||
55
public/javascripts/app/pages/post-viewer.js
Normal file
55
public/javascripts/app/pages/post-viewer.js
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
app.pages.PostViewer = app.views.Base.extend({
|
||||
|
||||
templateName: "post-viewer",
|
||||
|
||||
subviews : {
|
||||
"#post-content" : "postView",
|
||||
"#post-nav" : "navView",
|
||||
"#post-feedback" : "feedbackView"
|
||||
// "#post-author" : "authorView"
|
||||
},
|
||||
|
||||
postView : function(){
|
||||
return new app.views.Post({
|
||||
model : this.model,
|
||||
className : "loaded",
|
||||
templateName : this.options.postTemplateName
|
||||
})
|
||||
},
|
||||
|
||||
navView : function() {
|
||||
return new app.views.PostViewerNav({ model : this.model })
|
||||
},
|
||||
|
||||
feedbackView : function() {
|
||||
if(!window.app.user()) { return null }
|
||||
return new app.views.PostViewerFeedback({ model : this.model })
|
||||
},
|
||||
|
||||
postRenderTemplate : function() {
|
||||
this.setKeyMappings();
|
||||
},
|
||||
|
||||
setKeyMappings : function() {
|
||||
var nextPostLocation = this.model.get("next_post");
|
||||
var previousPostLocation = this.model.get("previous_post");
|
||||
var doc = $(document);
|
||||
|
||||
/* focus modal */
|
||||
doc.keypress(function(){
|
||||
$('#text').focus();
|
||||
$('#comment').modal();
|
||||
});
|
||||
|
||||
/* navagation hooks */
|
||||
doc.keydown(function(e){
|
||||
if (e.keyCode == 37 && nextPostLocation) {
|
||||
window.location = nextPostLocation
|
||||
|
||||
}else if(e.keyCode == 39 && previousPostLocation) {
|
||||
window.location = previousPostLocation
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
|
|
@ -41,14 +41,13 @@ app.Router = Backbone.Router.extend({
|
|||
singlePost : function(id) {
|
||||
new app.models.Post({id : id}).fetch({success : function(resp){
|
||||
var postAttrs = resp.get("post");
|
||||
var templateName = resp.get("templateName");
|
||||
|
||||
var view = new app.views.SinglePost({
|
||||
var page = new app.pages.PostViewer({
|
||||
model : new app.models.Post(postAttrs),
|
||||
templateName : templateName
|
||||
postTemplateName : resp.get("templateName")
|
||||
}).render();
|
||||
|
||||
$("#post-content").html(view.el);
|
||||
$("#container").html(page.el);
|
||||
}})
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
<div id="user-controls">
|
||||
<a href="#" class="label">
|
||||
<i class="icon-user icon-white"></i>
|
||||
</a>
|
||||
<a href="#" class="label">
|
||||
<i class="icon-heart icon-white"></i>
|
||||
</a>
|
||||
<a href="#" class="label">
|
||||
<i class="icon-plus icon-white"></i>
|
||||
</a>
|
||||
<a href="#" class="label">
|
||||
<i class="icon-retweet icon-white"></i>
|
||||
</a>
|
||||
<a href="#" class="label">
|
||||
<i class="icon-comment icon-white"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<a href="#" class="nav-arrow left" id="forward">
|
||||
<img src="/images/arrow-left.png" />
|
||||
</a>
|
||||
|
||||
<a href="#" class="nav-arrow right" id="back">
|
||||
<img src="/images/arrow-right.png" />
|
||||
</a>
|
||||
3
public/javascripts/app/templates/post-viewer.handlebars
Normal file
3
public/javascripts/app/templates/post-viewer.handlebars
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div id="post-content"></div>
|
||||
<div id="post-nav"></div>
|
||||
<div id="post-feedback"></div>
|
||||
6
public/javascripts/app/views/post_feedback_view.js
Normal file
6
public/javascripts/app/views/post_feedback_view.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
app.views.PostViewerFeedback = app.views.Base.extend({
|
||||
|
||||
templateName: "post-viewer-feedback"
|
||||
|
||||
})
|
||||
|
||||
19
public/javascripts/app/views/post_nav_view.js
Normal file
19
public/javascripts/app/views/post_nav_view.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
app.views.PostViewerNav = app.views.Base.extend({
|
||||
|
||||
templateName: "post-viewer-nav",
|
||||
|
||||
postRenderTemplate : function() {
|
||||
var mappings = {"#forward" : "next_post",
|
||||
"#back" : "previous_post"};
|
||||
|
||||
_.each(mappings, function(attribute, selector){
|
||||
this.setArrow(this.$(selector), this.model.get(attribute))
|
||||
}, this);
|
||||
},
|
||||
|
||||
setArrow : function(arrow, loc) {
|
||||
loc ? arrow.attr('href', loc) : arrow.remove()
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
app.views.SinglePost = app.views.Post.extend({
|
||||
|
||||
/* SINGLE POST SHOULD BE BROKEN OUT INTO A PAGE VIEW!!!! */
|
||||
|
||||
className : "loaded",
|
||||
|
||||
postRenderTemplate : function() {
|
||||
/* nav should be a subview! and tested! (this is some prototyping stuff right here... */
|
||||
this.setNav();
|
||||
|
||||
/* post author info should be a subview! and tested! */
|
||||
this.setAuthor();
|
||||
|
||||
/* post author info should be a subview! and tested! */
|
||||
this.setFeedback();
|
||||
},
|
||||
|
||||
setNav : function() {
|
||||
var mappings = {"#forward" : "next_post",
|
||||
"#back" : "previous_post"};
|
||||
|
||||
_.each(mappings, function(attribute, selector){
|
||||
this.setArrow($(selector), this.model.get(attribute))
|
||||
}, this);
|
||||
|
||||
this.setMappings();
|
||||
},
|
||||
|
||||
setArrow : function(arrow, loc) {
|
||||
loc ? arrow.attr('href', loc) : arrow.remove()
|
||||
},
|
||||
|
||||
setMappings : function() {
|
||||
var nextPostLocation = this.model.get("next_post");
|
||||
var previousPostLocation = this.model.get("previous_post");
|
||||
var doc = $(document);
|
||||
|
||||
/* focus modal */
|
||||
doc.keypress(function(event){
|
||||
$('#text').focus();
|
||||
$('#comment').modal();
|
||||
});
|
||||
|
||||
/* navagation hooks */
|
||||
doc.keydown(function(e){
|
||||
if (e.keyCode == 37 && nextPostLocation) {
|
||||
window.location = nextPostLocation
|
||||
|
||||
}else if(e.keyCode == 39 && previousPostLocation) {
|
||||
window.location = previousPostLocation
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
setAuthor : function() {
|
||||
// author avatar
|
||||
// time of post
|
||||
// reshared via... (if appliciable)
|
||||
},
|
||||
|
||||
setFeedback : function() {
|
||||
// go back to profile (app.user())
|
||||
// liking
|
||||
// following
|
||||
// resharing
|
||||
// commenting
|
||||
}
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue