Skip to content
Extraits de code Groupes Projets
Valider c0eeb768 rédigé par danielgrippi's avatar danielgrippi
Parcourir les fichiers

pages wip

parent 7acbfe1b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -19,29 +19,7 @@ ...@@ -19,29 +19,7 @@
%i.icon-time %i.icon-time
= time_ago_in_words(@post.created_at) + ' ago' = time_ago_in_words(@post.created_at) + ' ago'
#container
#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'
#comment.modal.fade #comment.modal.fade
.modal-header .modal-header
......
...@@ -24,6 +24,7 @@ javascripts: ...@@ -24,6 +24,7 @@ javascripts:
- public/javascripts/app/views.js - public/javascripts/app/views.js
- public/javascripts/app/models/post.js - public/javascripts/app/models/post.js
- public/javascripts/app/models/* - public/javascripts/app/models/*
- public/javascripts/app/pages/*
- public/javascripts/app/collections/* - public/javascripts/app/collections/*
- public/javascripts/app/views/stream_object_view.js - public/javascripts/app/views/stream_object_view.js
- public/javascripts/app/views/content_view.js - public/javascripts/app/views/content_view.js
......
Fichier ajouté
...@@ -3,6 +3,7 @@ var app = { ...@@ -3,6 +3,7 @@ var app = {
models: {}, models: {},
helpers: {}, helpers: {},
views: {}, views: {},
pages: {},
user: function(userAttrs) { user: function(userAttrs) {
if(userAttrs) { return this._user = new app.models.User(userAttrs) } if(userAttrs) { return this._user = new app.models.User(userAttrs) }
......
app.views.SinglePost = app.views.Post.extend({ app.pages.PostViewer = app.views.Base.extend({
/* SINGLE POST SHOULD BE BROKEN OUT INTO A PAGE VIEW!!!! */ templateName: "post-viewer",
className : "loaded", subviews : {
"#post-content" : "postView",
postRenderTemplate : function() { "#post-nav" : "navView",
/* nav should be a subview! and tested! (this is some prototyping stuff right here... */ "#post-feedback" : "feedbackView"
this.setNav(); // "#post-author" : "authorView"
/* post author info should be a subview! and tested! */
this.setAuthor();
/* post author info should be a subview! and tested! */
this.setFeedback();
}, },
setNav : function() { postView : function(){
var mappings = {"#forward" : "next_post", return new app.views.Post({
"#back" : "previous_post"}; model : this.model,
className : "loaded",
templateName : this.options.postTemplateName
})
},
_.each(mappings, function(attribute, selector){ navView : function() {
this.setArrow($(selector), this.model.get(attribute)) return new app.views.PostViewerNav({ model : this.model })
}, this); },
this.setMappings(); feedbackView : function() {
if(!window.app.user()) { return null }
return new app.views.PostViewerFeedback({ model : this.model })
}, },
setArrow : function(arrow, loc) { postRenderTemplate : function() {
loc ? arrow.attr('href', loc) : arrow.remove() this.setKeyMappings();
}, },
setMappings : function() { setKeyMappings : function() {
var nextPostLocation = this.model.get("next_post"); var nextPostLocation = this.model.get("next_post");
var previousPostLocation = this.model.get("previous_post"); var previousPostLocation = this.model.get("previous_post");
var doc = $(document); var doc = $(document);
/* focus modal */ /* focus modal */
doc.keypress(function(event){ doc.keypress(function(){
$('#text').focus(); $('#text').focus();
$('#comment').modal(); $('#comment').modal();
}); });
...@@ -50,20 +50,6 @@ app.views.SinglePost = app.views.Post.extend({ ...@@ -50,20 +50,6 @@ app.views.SinglePost = app.views.Post.extend({
window.location = 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
} }
}); })
...@@ -41,14 +41,13 @@ app.Router = Backbone.Router.extend({ ...@@ -41,14 +41,13 @@ app.Router = Backbone.Router.extend({
singlePost : function(id) { singlePost : function(id) {
new app.models.Post({id : id}).fetch({success : function(resp){ new app.models.Post({id : id}).fetch({success : function(resp){
var postAttrs = resp.get("post"); 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), model : new app.models.Post(postAttrs),
templateName : templateName postTemplateName : resp.get("templateName")
}).render(); }).render();
$("#post-content").html(view.el); $("#container").html(page.el);
}}) }})
} }
}); });
......
<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>
<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>
<div id="post-content"></div>
<div id="post-nav"></div>
<div id="post-feedback"></div>
app.views.PostViewerFeedback = app.views.Base.extend({
templateName: "post-viewer-feedback"
})
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()
}
})
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter