forked from graulund/tweetnest
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tweets.js
79 lines (75 loc) · 2.68 KB
/
tweets.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// PONGSOCKET TWEET ARCHIVE
// JavaScript features
// Requires jQuery
var searchPlaceholder = "Search for tweets..."
$(document).ready(function(){
$("#search input").focus(function(){
if(this.className == "empty"){
this.value = ""
$(this).removeClass("empty")
}
}).blur(function(){
if(this.value == ""){
$(this).addClass("empty")
this.value = searchPlaceholder
}
})
if($("#search input").val() == "" || $("#search input").val() == searchPlaceholder){
$("#search input").addClass("empty").val(searchPlaceholder)
}
// Hover associations
$("a.picl").each(function(){
var cn = this.className.split(" ")
for(var c in cn){
if(m = cn[c].match(/picl-([0-9]+)/)){ this.n = m[1]; break }
}
if(this.n && $(this).parents(".tweet").length > 0){
$(this).hover(function(){
$(this).parents(".tweet").children("a.pic-" + this.n).addClass("hoverin")
}, function(){
$(this).parents(".tweet").children("a.pic-" + this.n).removeClass("hoverin")
})
}
})
$("a.pic").each(function(){
var cn = this.className.split(" ")
for(var c in cn){
if(m = cn[c].match(/pic-([0-9]+)/)){ this.n = m[1]; break }
}
if(this.n && $(this).parents(".tweet").length > 0){
$(this).hover(function(){
$(this).parents(".tweet").children(".text").children("a.picl-" + this.n).addClass("hoverin")
}, function(){
$(this).parents(".tweet").children(".text").children("a.picl-" + this.n).removeClass("hoverin")
})
}
})
// Appendix: If people are using IE7 or below, they get some layout-enhancing fixes...
if($.browser.msie && $.browser.version < 8){
var daysShown = ($("#days").length > 0)
if(daysShown){
var m = $("#days").get(0).className.match(/days-([0-9]{2})/)
if(m){
var daysSpacing = 3 // Pixels
var daysInMonth = parseInt(m[1])
var w = ($("#days").width() - daysSpacing*(daysInMonth-1)) / daysInMonth, maxHeight = 0
$("#days .d").css({ display: "block", float: "left", width: w + "px", "margin-right": "3px" })
$("#days .d")[$("#days .d").length-1].style.marginRight = 0
$("#days .d").each(function(){ if($(this).height() > maxHeight){ maxHeight = $(this).height() } })
$("#days .d").each(function(){ $(this).css("margin-top", (maxHeight - $(this).height()) + "px") })
}
}
function IEresize(){
if(daysShown){
var w = ($("#days").width() - daysSpacing*(daysInMonth-1)) / daysInMonth
$("#days .d").css("width", w + "px")
$("#days .d .n").css({ width: w + "px", right: "auto" }) // Helping text center correctly
}
if($.browser.version >= 7){
$("#months li:not(.home, .fav, .search, .meta)").css({ width: $("#months").width() + "px", "margin-bottom" : "-3px" })
}
}
IEresize()
$(window).resize(IEresize)
}
})