Skip to content
Extraits de code Groupes Projets
Valider ada91e85 rédigé par Dennis Collinson's avatar Dennis Collinson
Parcourir les fichiers

next and last post don't have obnoxious blink 1/2 the time.

why not the rest, I don't know, time to start getting into event cleanup territory.
parent bd6a9cfe
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -50,29 +50,20 @@ app.pages.PostViewer = app.views.Base.extend({
},
bindNavHooks : function() {
/* navagation hooks */
var nextPostLocation = this.model.get("next_post");
var previousPostLocation = this.model.get("previous_post");
var model = this.model;
$(document).keydown(function(evt){
/* prevent nav from happening if the user is using the arrow
* keys to navigate through their comment text */
// prevent nav from happening if the user is using the arrow keys to navigate through their comment text
if($(evt.target).is("textarea")) { return }
switch(evt.keyCode) {
case 37:
navigate(nextPostLocation); break;
app.router.navigate(model.get("next_post"), true); break;
case 39:
navigate(previousPostLocation); break;
app.router.navigate(model.get("previous_post"), true); break;
default:
break;
}
})
function navigate(loc) {
loc ? window.location = loc : null
}
},
commentAnywhere : function(evt) {
......
......@@ -23,10 +23,23 @@ app.Router = Backbone.Router.extend({
"posts/new" : "composer",
"posts/:id": "singlePost",
"posts/:id/next": "siblingPost",
"posts/:id/previous": "siblingPost",
"p/:id": "singlePost",
"framer": "framer"
},
siblingPost : function(){ //next or previous
var post = new app.models.Post();
post.bind("change", setPreloadAttributesAndNavigate)
post.fetch({url : window.location})
function setPreloadAttributesAndNavigate(){
window.preloads.post = post.attributes
app.router.navigate(post.url(), true)
}
},
newProfile : function(personId) {
this.renderPage(new app.pages.Profile({ personId : personId }));
......
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()
}
templateName: "post-viewer/nav"
});
\ No newline at end of file
<a href="#" class="nav-arrow left" id="forward">
<a href="{{next_post}}" class="nav-arrow left" id="forward" rel="backbone">
<div class="nav-arrow-inner">
<img src="{{imageUrl "arrow-left.png"}}" />
</div>
</a>
<a href="#" class="nav-arrow right" id="back">
<a href="{{previous_post}}" class="nav-arrow right" id="back" rel="backbone">
<div class="nav-arrow-inner">
<img src="{{imageUrl "arrow-right.png"}}" />
</div>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter