refactored some js to make sense of how we're going to attack the post show page with a js Page
This commit is contained in:
parent
30de08b340
commit
7acbfe1b78
4 changed files with 65 additions and 19 deletions
|
|
@ -6,7 +6,8 @@
|
||||||
= post_page_title @post
|
= post_page_title @post
|
||||||
|
|
||||||
- content_for :head do
|
- content_for :head do
|
||||||
= javascript_include_tag 'vendor/bootstrap/bootstrap-transition', 'vendor/bootstrap/bootstrap-modal', 'posts-show'
|
= javascript_include_tag 'vendor/bootstrap/bootstrap-transition', 'vendor/bootstrap/bootstrap-modal'
|
||||||
|
|
||||||
.header
|
.header
|
||||||
.header-container
|
.header-container
|
||||||
#post-author.media
|
#post-author.media
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ app.Router = Backbone.Router.extend({
|
||||||
"u/:name": "stream",
|
"u/:name": "stream",
|
||||||
"followed_tags": "stream",
|
"followed_tags": "stream",
|
||||||
"tags/:name": "stream",
|
"tags/:name": "stream",
|
||||||
|
|
||||||
"posts/:id": "singlePost",
|
"posts/:id": "singlePost",
|
||||||
"p/:id": "singlePost"
|
"p/:id": "singlePost"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,69 @@
|
||||||
app.views.SinglePost = app.views.Post.extend({
|
app.views.SinglePost = app.views.Post.extend({
|
||||||
|
|
||||||
|
/* SINGLE POST SHOULD BE BROKEN OUT INTO A PAGE VIEW!!!! */
|
||||||
|
|
||||||
className : "loaded",
|
className : "loaded",
|
||||||
next_arrow: $('#forward'),
|
|
||||||
previous_arrow: $('#back'),
|
|
||||||
|
|
||||||
postRenderTemplate : function() {
|
postRenderTemplate : function() {
|
||||||
$('#forward').attr('href', this.model.get('next_post'));
|
/* nav should be a subview! and tested! (this is some prototyping stuff right here... */
|
||||||
$('#back').attr('href', this.model.get('previous_post'));
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
$(function(){
|
|
||||||
$(document).keypress(function(event){
|
|
||||||
$('#text').focus();
|
|
||||||
$('#comment').modal();
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).keydown(function(e){
|
|
||||||
if (e.keyCode == 37) {
|
|
||||||
window.location = $('#back').attr('href');
|
|
||||||
}else if(e.keyCode == 39) {
|
|
||||||
window.location = $('#forward').attr('href');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Loading…
Reference in a new issue