function ADMINajax(datas){
return jQuery.ajax({
url: '/modules/SP_News/lib/ajax.php', //URL or the php script
data: datas,
type: 'POST',
async: false,
cache: false,
timeout: 30000
}).responseText;
}
jQuery(document).ready(function() {
// Post Delete ////////////////////////////
jQuery(document).on('click', '.post_delete', function() {
id = jQuery(this).attr('id');
if (confirm('Are you sure you would like to delete this Post?')) {
ADMINajax({func : 'deletePOST', pID: id});
jQuery('#SPNp_item_'+id).fadeOut('slow');
jQuery('.SPN-recent-link[href$="php?view='+id+'"]').fadeOut('slow');
}
});
// Category Edit/Delete ////////////////////////
if (jQuery('#SPNb_avatar_upload').length){
new AjaxUpload('SPNb_avatar_upload', {
action: '/modules/SP_News/lib/ajax.php',
name: 'imgupload',
onSubmit: function(file, ext){
// Allow only images. You should add security check on the server-side.
if (ext && /^(jpg|png|jpeg|gif)$/i.test(ext)) {
this.setData({
'func': 'avatar_upload',
'uploadto': '/modules/SP_News/img/avatars/',
'size': '100',
'prefix': 'avatar_'
});
} else {
return false;
}
},
onComplete : function(file,response){
if (response == 'error') {
alert('error uploading file');
} else {
jQuery('#SPNb_avatar_display').text(response);
jQuery('#SPNb_avatar').val(response);
}
}
});
}
jQuery('.tbox').addClass('form-control');
});