took some functions out of stream-element widget; refactored Header view; refactored tooltip logic in Post view
This commit is contained in:
parent
1a5e493b22
commit
b120faa4f9
9 changed files with 32 additions and 58 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
<% if(photos_count > 0) { %>
|
<% if(photos_count > 0) { %>
|
||||||
<div class="photo_attachments">
|
<div class="photo_attachments">
|
||||||
<img src="<%= photos[0].sizes.large %>" class="stream-photo big_stream_photo">
|
<img src="<%= photos[0].sizes.large %>" class="stream-photo big_stream_photo" data-small-photo="<%= photos[0].sizes.small %>">
|
||||||
<% for(photo in photos) {
|
<% for(photo in photos) {
|
||||||
if(photo == 0){ continue; }
|
if(photo == 0){ continue; }
|
||||||
if(photo == 8){ break; } %>
|
if(photo == 8){ break; } %>
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,10 @@
|
||||||
<div class="right controls">
|
<div class="right controls">
|
||||||
<% if(author.id != current_user.id) { %>
|
<% if(author.id != current_user.id) { %>
|
||||||
<img src="/images/icons/ignoreuser.png" alt="Ignoreuser" class="block_user control_icon" title= "Ignore" data-person_id="<%= author.id %>" />
|
<img src="/images/icons/ignoreuser.png" alt="Ignoreuser" class="block_user control_icon" title= "Ignore" data-person_id="<%= author.id %>" />
|
||||||
|
<% } else { %>
|
||||||
|
<img src="/images/deletelabel.png" class="delete control_icon remove_post" title="Delete" />
|
||||||
<% } %>
|
<% } %>
|
||||||
<img src="/images/deletelabel.png" class="delete control_icon remove_post" title="Delete" />
|
|
||||||
<img src="/images/ajax-loader.gif" class="hide_loader hidden"/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sm_body">
|
<div class="sm_body">
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ app.views.Feedback = app.views.StreamObject.extend({
|
||||||
var user_like = this.model.get("user_like")
|
var user_like = this.model.get("user_like")
|
||||||
this.like = user_like && this.model.likes.get(user_like.id);
|
this.like = user_like && this.model.likes.get(user_like.id);
|
||||||
|
|
||||||
this.model.likes.bind("change", this.render, this);
|
_.each(["change", "remove", "add"], function(listener) {
|
||||||
this.model.likes.bind("remove", this.render, this);
|
this.model.likes.bind(listener, this.render, this);
|
||||||
this.model.likes.bind("add", this.render, this);
|
}, this)
|
||||||
},
|
},
|
||||||
|
|
||||||
presenter : function(){
|
presenter : function(){
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,33 @@
|
||||||
app.views.Header = Backbone.View.extend({
|
app.views.Header = app.views.Base.extend({
|
||||||
|
|
||||||
|
template_name : "#header-template",
|
||||||
|
|
||||||
events : {
|
events : {
|
||||||
"click ul.dropdown li:first-child" : "toggleDropdown"
|
"click ul.dropdown li:first-child" : "toggleDropdown"
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize : function(options) {
|
initialize : function(options) {
|
||||||
this.menuElement = this.$("ul.dropdown");
|
$(document.body).click($.proxy(this.hideDropdown, this));
|
||||||
|
|
||||||
_.bindAll(this, "toggleDropdown", "hideDropdown");
|
|
||||||
this.menuElement.find("li a").slice(1).click(function(evt) { evt.stopPropagation(); });
|
|
||||||
$(document.body).click(this.hideDropdown);
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
render : function(){
|
menuElement : function() {
|
||||||
this.template = _.template($("#header-template").html());
|
return this.$("ul.dropdown");
|
||||||
$(this.el).html(this.template(app.user()));
|
|
||||||
return this;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleDropdown : function(evt) {
|
toggleDropdown : function(evt) {
|
||||||
evt.preventDefault();
|
if(evt){ evt.preventDefault(); }
|
||||||
evt.stopPropagation();
|
|
||||||
|
|
||||||
this.$("ul.dropdown").toggleClass("active");
|
this.menuElement().toggleClass("active");
|
||||||
|
|
||||||
if ( $.browser.msie ) {
|
if($.browser.msie) {
|
||||||
this.$('header').toggleClass('ie-user-menu-active');
|
this.$("header").toggleClass('ie-user-menu-active');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hideDropdown : function(evt) {
|
hideDropdown : function(evt) {
|
||||||
if(this.$("ul.dropdown").hasClass("active") && !$(evt.target).parents("#user_menu").length) {
|
if(this.menuElement().hasClass("active") && !$(evt.target).parents("#user_menu").length) {
|
||||||
this.$("ul.dropdown").removeClass("active");
|
this.menuElement().removeClass("active");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,12 @@ app.views.Post = app.views.StreamObject.extend({
|
||||||
".comments" : "commentStreamView"
|
".comments" : "commentStreamView"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
tooltips : [
|
||||||
|
".delete",
|
||||||
|
".block_user",
|
||||||
|
".post_scope"
|
||||||
|
],
|
||||||
|
|
||||||
initialize : function() {
|
initialize : function() {
|
||||||
this.feedbackView = new app.views.Feedback({model : this.model});
|
this.feedbackView = new app.views.Feedback({model : this.model});
|
||||||
this.commentStreamView = new app.views.CommentStream({ model : this.model});
|
this.commentStreamView = new app.views.CommentStream({ model : this.model});
|
||||||
|
|
@ -50,16 +56,13 @@ app.views.Post = app.views.StreamObject.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
initializeTooltips: function(){
|
initializeTooltips: function(){
|
||||||
$([
|
_.each(this.tooltips, function(selector){
|
||||||
this.$(".delete"),
|
this.$(selector).twipsy();
|
||||||
this.$(".block_user"),
|
}, this);
|
||||||
this.$(".post_scope")
|
|
||||||
]).map(function() { this.twipsy(); });
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
expandLikes: function(evt){
|
expandLikes: function(evt){
|
||||||
if(evt) { evt.preventDefault(); }
|
if(evt) { evt.preventDefault(); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,6 @@ Diaspora.Pages.MultisIndex = function() {
|
||||||
|
|
||||||
this.subscribe("page/ready", function(evt, document) {
|
this.subscribe("page/ready", function(evt, document) {
|
||||||
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
|
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
|
||||||
|
self.stream = self.instantiate("Stream", document.find("#aspect_stream_container"));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,7 @@ Diaspora.Pages.TagFollowingsIndex = function() {
|
||||||
|
|
||||||
this.subscribe("page/ready", function(evt, document) {
|
this.subscribe("page/ready", function(evt, document) {
|
||||||
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
|
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
|
||||||
|
|
||||||
|
self.stream = self.instantiate("Stream", document.find("#aspect_stream_container"));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,9 @@
|
||||||
|
|
||||||
var Stream = {
|
var Stream = {
|
||||||
selector: "#main_stream",
|
selector: "#main_stream",
|
||||||
nsfw_links: ".shield a",
|
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
Diaspora.page.directionDetector.updateBinds();
|
Diaspora.page.directionDetector.updateBinds();
|
||||||
|
|
||||||
Stream.setUpAudioLinks();
|
Stream.setUpAudioLinks();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -27,14 +25,6 @@ var Stream = {
|
||||||
box.toggle();
|
box.toggle();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
setUpNsfwLinks:function(){
|
|
||||||
$(this.nsfw_links).click(function(e){
|
|
||||||
e.preventDefault();
|
|
||||||
$(this).parent().fadeOut();
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setUpAudioLinks: function() {
|
setUpAudioLinks: function() {
|
||||||
|
|
|
||||||
|
|
@ -15,22 +15,11 @@
|
||||||
timeAgo: self.instantiate("TimeAgo", element.find(".timeago a abbr.timeago")),
|
timeAgo: self.instantiate("TimeAgo", element.find(".timeago a abbr.timeago")),
|
||||||
|
|
||||||
content: element.find(".content .collapsible"),
|
content: element.find(".content .collapsible"),
|
||||||
blockUserLink: element.find(".block_user"),
|
|
||||||
deletePostLink: element.find(".remove_post"),
|
|
||||||
focusCommentLink: element.find("a.focus_comment_textarea"),
|
|
||||||
hidePostLoader: element.find("img.hide_loader"),
|
hidePostLoader: element.find("img.hide_loader"),
|
||||||
hidePostUndo: element.find("a.stream_element_hide_undo"),
|
hidePostUndo: element.find("a.stream_element_hide_undo"),
|
||||||
post: element,
|
post: element
|
||||||
postScope: element.find("span.post_scope")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// twipsy tooltips
|
|
||||||
$([
|
|
||||||
self.blockUserLink,
|
|
||||||
self.deletePostLink,
|
|
||||||
self.postScope
|
|
||||||
]).map(function() { this.twipsy(); });
|
|
||||||
|
|
||||||
// collapse long posts
|
// collapse long posts
|
||||||
self.content.expander({
|
self.content.expander({
|
||||||
slicePoint: 400,
|
slicePoint: 400,
|
||||||
|
|
@ -52,12 +41,6 @@
|
||||||
} );
|
} );
|
||||||
});
|
});
|
||||||
|
|
||||||
self.focusCommentLink.click(function(evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
|
|
||||||
self.commentForm.commentInput.focus();
|
|
||||||
});
|
|
||||||
|
|
||||||
self.hidePostUndo.click(function(evt) {
|
self.hidePostUndo.click(function(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue