$(document).ready(function(){
$('#upload_form').ajaxForm({
dataType: 'json',
beforeSubmit: function(data) {
$('p.error').remove();
$('.image_dwld').removeClass('alert');
if ($('#upload_form input[type="file"]').val() == ''){
var new_image = '
You have not selected any file!
';
if ($('ul.img_action li').length == 0) {
$('ul.img_action').html(new_image).hide().fadeIn(500);
} else {
$('ul.img_action li').last().after(new_image);
$('ul.img_action li').last().hide().fadeIn(500);
}
return false;
} else {
if(data[0].value.size >= 200*1024){
var new_image = 'Image file must not be more then 200kb!
';
if ($('ul.img_action li').length == 0) {
$('ul.img_action').html(new_image).hide().fadeIn(500);
} else {
$('ul.img_action li').last().after(new_image);
$('ul.img_action li').last().hide().fadeIn(500);
}
return false;
} else {
$('.upload_process').show();
}
}
},
success: function(data) {
$('p.error').remove();
//$('#error_message').fadeOut(300,function(){
if (data.message_type == 'error') {
//$(this).html('' + data.message + '').fadeIn(500);
var new_image = '' + data.message + '
';
if ($('ul.img_action li').length == 0) {
$('ul.img_action').html(new_image).hide().fadeIn(500);
} else {
$('ul.img_action li').last().after(new_image);
$('ul.img_action li').last().hide().fadeIn(500);
}
$('.upload_process').hide();
} else {
//$(this).html(data.message).fadeIn(500);
}
//});
if (data.link != undefined) {
var new_image = ' '
if ($('ul.img_action li').length == 0) {
$('ul.img_action').html(new_image).hide().fadeIn(500);
} else {
$('ul.img_action li').last().after(new_image);
$('ul.img_action li').last().hide().fadeIn(500);
}
$('.upload_process').hide();
}
}
});
});