aboutsummaryrefslogtreecommitdiff
path: root/mod/riverdashboard/views/default/riverdashboard/js.php
blob: 37de3ad049f5b6ce27dee3ef453f3214c87d5236 (plain)
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
<script type="text/javascript">
	$(document).ready(function() {
		$('.river_comment_form_button').click(function() {
			elgg_slide_toggle(this, '.river_item', '.river_comment_form');
		});

		$('.likes_user_list_button').click(function() {
			var myParent = $(this).closest('.river_item');
			if (myParent.find('.likes_list').css('display') == 'none') {
				// hide comments
				myParent.find('.comments_container').animate({"height": "toggle", "opacity": "toggle"}, { duration: 400 });
				// change selected tab
				myParent.find('.show_comments_button').addClass('off');
				myParent.find('.likes_user_list_button').removeClass('off');
				// show users that liked object
				elgg_slide_toggle(this, '.river_item', '.likes_list');
			}
		});

		$('.show_comments_button').click(function() {
			var myParent = $(this).closest('.river_item');
			if (myParent.find('.comments_container').css('display') == 'none') {
				// hide likes
				myParent.find('.likes_list').animate({"height": "toggle", "opacity": "toggle"}, { duration: 400 });
				// change selected tab
				myParent.find('.show_comments_button').removeClass('off');
				myParent.find('.likes_user_list_button').addClass('off');
				// show users that liked object
				elgg_slide_toggle(this, '.river_item', '.comments_container');
			}
		});

		// grab more comments
		$('.river_show_more_comments').click(function() {
			var riverItem = $(this).closest('.river_item');
			var guid = riverItem.attr('id').replace('river_entity_', '');
			var commentsList = riverItem.find('.comments_list');
			var numComments = riverItem.find('.river_comment').length;

			var params = {
				'entity_guid': guid,
				'offset': numComments
			}

			$.post('<?php echo $vars['url'];?>mod/riverdashboard/endpoint/get_comments.php', params, function(data) {
				commentsList.prepend(data);
				commentsList.prev('.river_show_more_comments').hide();
			});
		});
	});
</script>