Added more caching of jQuery objects, saved a line by using .toggleClass()

This commit is contained in:
OhaiBBQ 2010-11-01 10:07:41 -07:00
parent c8e8ef06e7
commit 6474f5c5f3

View file

@ -5,7 +5,7 @@
$(document).ready(function(){
var $stream = $("#stream");
// expand all comments on page load
$("#stream:not('.show')").find('.comments').each(function(index) {
var comments = $(this);
@ -16,17 +16,17 @@ $(document).ready(function(){
});
// comment toggle action
$("#stream:not('.show')").delegate("a.show_post_comments", "click", function(evt) {
$stream.not(".show").delegate("a.show_post_comments", "click", function(evt) {
evt.preventDefault();
expandComments($(this));
});
// comment submit action
$("#stream").delegate("a.comment_submit", "click", function(evt){
$stream.delegate("a.comment_submit", "click", function(evt){
$(this).closest("form").children(".comment_box").attr("rows", 1);
});
$("#stream").delegate("textarea.comment_box", "focus", function(evt){
$stream.delegate("textarea.comment_box", "focus", function(evt){
var commentBox = $(this);
commentBox.attr("rows", 2)
.closest("form").find(".comment_submit").fadeIn(200);
@ -41,16 +41,10 @@ $(document).ready(function(){
});
// reshare button action
$("#stream").delegate(".reshare_button", "click", function(evt){
$stream.delegate(".reshare_button", "click", function(evt){
evt.preventDefault();
var button = $(this);
if(button.hasClass("active")) {
button.closest(".reshare_pane").children(".reshare_box").hide();
button.removeClass("active");
} else {
button.closest(".reshare_pane").children(".reshare_box").show();
button.addClass("active");
}
$(this).toggleClass("active")
.closest(".reshare_pane").children(".reshare_box").toggle();
});
});//end document ready