-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
70 lines (52 loc) · 1.94 KB
/
app.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
$(document).ready(function(){
$(".editor-toggle").on("click",function(){
$(".editor").toggleClass("original");
})
$(".comment").on("click",".bubble",function(){
$(this).closest(".comment").toggleClass("expanded");
$(this).closest(".comment").find(".comment-text").slideToggle();
});
//Hover states
$(".comment:not(.expanded)").on("mouseenter",".bubble",function(){
$(this).closest(".comment").addClass("hover");
});
$(".comment:not(.expanded)").on("mouseout",".bubble",function(){
$(this).closest(".comment").removeClass("hover");
});
$(".comment").on("click",".close-comment",function(){
$(this).closest(".comment").toggleClass("expanded");
$(this).closest(".comment").find(".comment-text").slideToggle();
});
$(".comment-text").on("click","a",function(){
$(this).closest(".comment").toggleClass("expanded");
$(this).closest(".comment").find(".comment-text").slideToggle();
var thisComment = parseInt($(this).closest(".comment").attr("comment-number"));
if($(this).hasClass("next-comment")){
if(thisComment == commentCount) {
thisComment = 0;
}
openComment(thisComment + 1);
} else {
if(thisComment == 1) {
thisComment = commentCount + 1;
}
openComment(thisComment - 1);
}
return false;
});
$(".comment").each(function(){
commentCount++;
$(this).find(".this-comment").text(commentCount);
$(this).attr("comment-number",commentCount);
})
$(".comment").find(".total-comments").text(commentCount);
});
var commentCount = 0;;
function openComment(number){
var newComment = $("[comment-number="+number+"]");
if(newComment.hasClass("expanded")){
} else {
newComment.find(".comment-text").slideToggle();
newComment.toggleClass("expanded");
}
}