-
Notifications
You must be signed in to change notification settings - Fork 0
/
soulmatch-admin.js
executable file
·36 lines (34 loc) · 1001 Bytes
/
soulmatch-admin.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
// wp-admin scripts
//console.log( soulmatch_admin_data.options );
jQuery(function($){
jQuery('.soulrepeater-delete').click(soulmatch.delete_repeater);
jQuery('.soulrepeater-add').click(soulmatch.add_repeater);
});
var soulmatch = {
delete_repeater : function(e){
if ( confirm( soulmatch_admin_data.confirm ) ) {
jQuery(this).parents('.postbox').remove();
e.preventDefault();
}
},
add_repeater : function(e){
jQuery.get(
ajaxurl,
{
'action' : 'add_repeater',
},
soulmatch.insert_repeater
);
},
insert_repeater : function( response ) {
if ( !response.success ){
console.log( response.data );
return;
}
jQuery('#post-body-content .meta-box-sortables').append( response.data );
jQuery('#post-body-content .meta-box-sortables .postbox').last().find('.soulrepeater-delete').click(soulmatch.delete_repeater);
jQuery('html, body').animate({
scrollTop: jQuery('#post-body-content .meta-box-sortables .postbox').last().offset().top
}, 1000);
},
}