jQuery(document).ready( function($){
$('#featured_id').click(function(){
$('#featured_field').click();
})
$('#gallery_id').click(function(){
$('#gallery_field').click();
})
$('#download_id').click(function(){
$('#download_field').click();
})
$('#featured_field').change( function(){
jQuery('#submit-featured').click();
} )
$('#gallery_field').change( function(){
jQuery('#submit-gallery').click();
} )
$('#download_field').change( function(){
jQuery('#submit-download').click();
} )
/*
$('.close_button').live( 'click', function(){
$('.featured_preview').html('');
$('#featured_preview_input').val('');
})
*/
//########################
var options_featured = {
target: '#status', // target element(s) to be updated with server response
beforeSubmit: featuredShowRequest, // pre-submit callback
success: featuredShowResponse, // post-submit callback
url: $('#ajaxurl').val() // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
};
// bind form using 'ajaxForm'
jQuery('#featured_upload').ajaxForm( options_featured );
function featuredShowRequest(formData, jqForm, options_featured ) {
//do extra stuff before submit like disable the submit button
jQuery('#featured_stat').html( '
' );
}
function featuredShowResponse(responseText, statusText, xhr, $form) {
var arr = responseText.split('|');
$('.featured_preview').html('
');
$('#featured_preview_input').val( arr[0] );
jQuery('#featured_stat').html( '' );
}
//gallery ##########################
var options = {
target: '#status', // target element(s) to be updated with server response
beforeSubmit: galleryShowRequest, // pre-submit callback
success: galleryShowResponse, // post-submit callback
url: $('#ajaxurl').val() // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
};
// bind form using 'ajaxForm'
jQuery('#gallery_upload').ajaxForm(options);
function galleryShowRequest(formData, jqForm, options) {
//do extra stuff before submit like disable the submit button
jQuery('#gallery_stat').html( '
' );
}
function galleryShowResponse(responseText, statusText, xhr, $form) {
//do extra stuff after submit
jQuery('#gallery_stat').html( '' );
var obj = jQuery.parseJSON( responseText );
var ids = [];
$.each( obj, function(index) {
$('.gallery_preview').html( $('.gallery_preview').html()+'
.val()+'/images/close-button.png)
' );
}
function downloadShowResponse(responseText, statusText, xhr, $form) {
//do extra stuff after submit
console.log( responseText );
jQuery('#download_stat').html( '' );
var obj = jQuery.parseJSON( responseText );
var urls = [];
$.each( obj, function(index) {
$('.download_preview').html( $('.download_preview').html()+'.val()+'/images/close-button.png)