diff options
Diffstat (limited to 'static/js/pichat.js')
| -rw-r--r--[-rwxr-xr-x] | static/js/pichat.js | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/static/js/pichat.js b/static/js/pichat.js index 4d4ed17..ce27ebd 100755..100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -378,8 +378,55 @@ function initLog() { var t = $(this); t.html(buildMsgContent(t.text())); }); + initAnimThumb(); } +// jesus this logic is ugly +function initAnimThumb(){ + $(".buttons .thumb").bind('mouseover mouseout', + function(e) { + var favorited = $(this).hasClass("favorite") ? true : false; + if (e.type == "mouseover") { + if (favorited) { + $(this).attr("src", "/static/thumbup.gif"); +/* $(this).stop().animate({ + "width": "14px", + "height": "15px", + "marginLeft": "0px", + "marginTop": "0px" + }, 'fast'); */ + } else { + $(this).attr("src", "/static/thumbup.colored.4x.gif"); + $(this).stop().animate({ + "width": "56px", + "height": "60px", + "marginLeft": "-44px", + "marginTop": "-27px" + }, 'fast'); + } + } else { // mouseout + if (favorited) { + $(this).attr("src", "/static/thumbup.colored.gif"); + $(this).stop().animate({ + "width": "14px", + "height": "15px", + "marginLeft": "0px", + "marginTop": "0px" + }, 'fast'); + } else { + $(this).attr("src", "/static/thumbup.gif"); + $(this).stop().animate({ + "width": "14px", + "height": "15px", + "marginLeft": "0px", + "marginTop": "0px" + }, 'fast'); + } + } + }) +} + + // TODO function favoriteImage() {}; @@ -591,6 +638,49 @@ Share = { } } +Tag = { + // todo: get rid of all the duplicated code here and in share + "getMessage": function(button){ + var message = $(button).parents(".logged-dump") + var id = message.attr("id").substr(8) // cut "message-001" to "001" + var nick = message.attr("nick") // cut "/u/timb" to "timb" + var link = "http://dump.fm/p/" + nick + "/" + id + var content = message.find(".linkify") + if (!content.length) content = message.find(".content") + var rawContent = content.html() + var img = content.find("img").attr("src") + var via = "via " + nick + " on dump.fm" + return {"nick": nick, "id": id, "link": encodeURIComponent(link), "content": content, "img": encodeURIComponent(img), "via": encodeURIComponent(via)} + }, + "favorite": function(button){ + var message = Share.getMessage(button) + var favorited = ($(button).hasClass("favorite")) ? true : false + if (favorited) { + Tag.rm(message.id, "favorite") + $(button).removeClass("favorite") + } else { + Tag.add(message.id, "favorite") + $(button).addClass("favorite") + } + }, + "add": function(message_id, tag){ + Tag.ajax("/cmd/tag/add", {"message_id": message_id, "tag": tag}) + }, + "rm": function(message_id, tag){ + Tag.ajax("/cmd/tag/rm", {"message_id": message_id, "tag": tag}) + }, + "ajax": function(url, data) { + $.ajax({ + "type": 'POST', + "timeout": 5000, + "url": url, + "data": data, + "cache": false + }); + } +} + + // uhhh todo: move preload stuff into js: // var nextImage = new Image(); // nextImage.src = "your-url/newImage.gif"; |
