From 968faa6192e7c95a7b1cbfdd5d35fb7253b8984f Mon Sep 17 00:00:00 2001 From: Scott Ostler Date: Mon, 30 Aug 2010 22:52:44 -0400 Subject: Fixed directory queries and heart animations --- static/js/pichat.js | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'static/js') diff --git a/static/js/pichat.js b/static/js/pichat.js index 9287cc1..13e0036 100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -501,7 +501,7 @@ function initChat() { messageList = $("#messageList")[0] - initChatThumb() + initChatThumb(); scrollToEnd() scrollWatcher() @@ -583,14 +583,13 @@ function initLog() { var t = $(this); t.html(buildMsgContent(t.text())); }); - initLogThumb(); + initLogThumb(".logged-dump .thumb", '.dump'); } -// jesus this logic is ugly -function initLogThumb(){ - $(".logged-dump .thumb").bind('mouseover mouseout', +function initLogThumb(selector, parentSelector) { + $(selector).bind('mouseover mouseout', function(e) { - var favorited = $(this).parents(".dump").hasClass("favorite") ? true : false; + var favorited = $(this).parents(parentSelector).hasClass("favorite") ? true : false; if (e.type == "mouseover") { if (favorited) { $(this).attr("src", Imgs.logThumbOff); @@ -602,19 +601,29 @@ function initLogThumb(){ if (favorited) { $(this).attr("src", Imgs.logThumb); $(this).stop().animate(Anim.logThumb, 'fast'); - } else { + } else { $(this).attr("src", Imgs.logThumbOff); $(this).stop().animate(Anim.logThumb, 'fast'); } } }) -} + } -function initChatThumb(){ - - $(".chat-thumb").live('mouseover mouseout', +function initChatThumb() { + $(".chat-thumb").live('mouseover mouseout', function(e) { var favorited = $(this).parents(".dump").hasClass("favorite") ? true : false; + if (e.type == "mouseover") { + if (favorited) { + $(this).attr("src", Imgs.chatThumbOff); + } else { + $(this).attr("src", Imgs.chatThumbBig); + $(this).stop().animate(Anim.chatThumbBig, 'fast') + } + } else { // mouseout + if (favorited) { + $(this).attr("src", Imgs.chatThumb); + var favorited = $(this).parents(".dump").hasClass("favorite") ? true : false; if (e.type == "mouseover") { if (favorited) { $(this).attr("src", Imgs.chatThumbOff); @@ -626,17 +635,15 @@ function initChatThumb(){ if (favorited) { $(this).attr("src", Imgs.chatThumb); $(this).stop().animate(Anim.chatThumb, 'fast'); - } else { - $(this).stop().animate(Anim.chatThumbTiny, 'fast', 'swing', + } else { + $(this).stop().animate(Anim.chatThumbTiny, 'fast', 'swing', function(){ $(this).attr("src", Imgs.chatThumbDot) - $(this).animate(Anim.chatThumb, 0) + $(this).animate(Anim.chatThumb, 0) }) + }} } - } - }) -} - + }})} function paletteToChat(img){ var chatText = $("#msgInput").val() @@ -986,7 +993,8 @@ function initDirectory() { var t = $(this); t.html(buildMsgContent(t.text())); }); - Search.init() + Search.init() + initLogThumb('.dlogged-dump .thumb', '.dlogged-dump'); } //big hand stuff -- cgit v1.2.3-70-g09d2