summaryrefslogtreecommitdiff
path: root/static/js/src/palette.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2012-07-18 00:02:21 -0400
committerJules Laplace <jules@okfoc.us>2012-07-18 00:02:21 -0400
commitc4338d2ae878a167c409e91dea6d1783fc7e30ba (patch)
tree1e54fac722ac3153f9180a5a8332f2b19e11c00c /static/js/src/palette.js
parentd891a7ae1b205716c086363fba17a3249a665deb (diff)
put away back
Diffstat (limited to 'static/js/src/palette.js')
-rw-r--r--static/js/src/palette.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/static/js/src/palette.js b/static/js/src/palette.js
new file mode 100644
index 0000000..c9be597
--- /dev/null
+++ b/static/js/src/palette.js
@@ -0,0 +1,61 @@
+
+function paletteToChat(img){
+ var chatText = $("#msgInput").val()
+ if (chatText.length && chatText[chatText.length - 1] != " ")
+ chatText += " "
+ chatText += $(img).attr("src") + " "
+ $("#msgInput").val(chatText)
+ $("#msgInput").focus().val($("#msgInput").val()) // http://stackoverflow.com/questions/1056359/
+ paletteHide()
+}
+
+paletteImageCache = false
+function paletteBuildImageThumbs(){
+ if (paletteImageCache) {
+ var imgs = paletteImageCache
+ } else {
+ var imgs = []
+ var dupeFilter = {}
+ for(fav in RawFavs){
+ var parsedImgs = getImagesAsArray(RawFavs[fav])
+ for (var i=0; i<parsedImgs.length; i++){
+ var img = parsedImgs[i]
+ if (!dupeFilter[img]) {
+ imgs.push(img)
+ dupeFilter[img] = true
+ }
+ }
+ }
+ paletteImageCache = imgs
+ }
+
+ for(var i=0; i<imgs.length; i++){
+ $("#palette-thumbs").append("<img onclick='paletteToChat(this)' src='"+imgs[i]+"'>")
+ }
+}
+
+function paletteShow(){
+ $("#palette").css("display", "block")
+ if (isEmptyObject(RawFavs)) {
+ $('#palette-thumbs').html('<div style="width:300px;color:#000;">This is where all the stuff you FAV goes!<br><br>To FAV a post click the little heart <img src="/static/img/thumbs/smallheart.gif"> next to a users name.<br><br> Everything you fav gets saved to your profile.. Have fun!</div>');
+ } else {
+ paletteBuildImageThumbs();
+ }
+}
+function paletteHide(){
+ $("#palette").css("display", "none")
+ $("#palette-thumbs").html("")
+}
+
+function paletteToggle(){
+ if ($("#palette").css("display") == "none")
+ paletteShow()
+ else
+ paletteHide()
+}
+
+
+function paletteClicked(){
+ track('UI', 'FavPaletteActuallyClicked');
+ paletteToggle();
+}