forked from hberberoglu/wp-favorite-posts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
45 lines (41 loc) · 1.23 KB
/
Copy pathscript.js
File metadata and controls
45 lines (41 loc) · 1.23 KB
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
jQuery(document).ready( function($) {
$('body').on('click', '.wpfp-link', function() {
dhis = $(this);
wpfp_do_js( dhis, 1 );
// for favorite post listing page
if (dhis.hasClass('remove-parent')) {
dhis.parent("li").fadeOut();
}
return false;
});
});
function wpfp_do_js( dhis, doAjax ) {
loadingImg = dhis.prev();
loadingImg.show();
beforeImg = dhis.prev().prev();
beforeImg.hide();
url = document.location.href.split('#')[0];
params = dhis.attr('href').replace('?', '') + '&ajax=1';
if ( doAjax ) {
jQuery.get(url, params, function(data) {
dhis.parent().html(data);
if(typeof wpfp_after_ajax == 'function') {
wpfp_after_ajax( dhis ); // use this like a wp action.
}
loadingImg.hide();
}
);
}
}
function wpfp_after_ajax(dthis) {
wpfp_user_favorite_list();
}
function wpfp_user_favorite_list() {
var mylist = jQuery(".user-favorite-list");
url = document.location.href.split('#')[0];
params = 'wpfpaction=user-favorite-list&ajax=1';
jQuery.get(url, params, function(data) {
mylist.html(data);
}
);
}