-
Notifications
You must be signed in to change notification settings - Fork 0
/
js-more.js
46 lines (34 loc) · 972 Bytes
/
js-more.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
var jsMoreElements;
(function($) {
jsMoreElements = {
init : function() {
this.attachListeners();
},
attachListeners : function() {
var that = this;
$('[id^="show-more-"]').click(function() {
var id = $(this).attr('id').substring(10);
// get full article for statistical / reporting purposes
// (showing the user viewed the full article)
$.get($(this).attr('href'), function(data) {
//no action needed
});
$(this).hide();
$('#more-' + id).show();
//don't actually go to address
return false;
});
$('[id^="show-less-"]').click(function() {
var id = $(this).attr('id').substring(10);
$('#more-' + id).hide();
$('#show-more-' + id).show();
//scroll back to the summary article
var post = document.getElementById('post-' + id);
if(post) post.scrollIntoView(false);
//don't refresh after click
return false;
});
},
};
$(document).ready(function($){ jsMoreElements.init(); });
})(jQuery);