5
|
1 |
function update_images() { |
0
|
2 |
(function($){ |
5
|
3 |
setMessage( "<p>" + prtfl_var.update_img_message + "</p>" ); |
0
|
4 |
var curr = 0; |
|
5 |
$.ajax({ |
5
|
6 |
url: '../wp-admin/admin-ajax.php?action=prtfl_update_image', |
0
|
7 |
type: "POST", |
5
|
8 |
data: "action1=get_all_attachment" + '&prtfl_ajax_nonce_field=' + prtfl_var.prtfl_nonce, |
|
9 |
success: function( result ) { |
|
10 |
var list = eval( '(' + result + ')' ); |
|
11 |
if ( ! list ) { |
|
12 |
setError( "<p>" + prtfl_var.not_found_img_info + "</p>" ); |
|
13 |
$( "#ajax_update_images" ).removeAttr( "disabled" ); |
0
|
14 |
return; |
|
15 |
} |
5
|
16 |
$( '#prtfl_img_loader' ).show(); |
0
|
17 |
|
|
18 |
function updatenImageItem() { |
5
|
19 |
if ( curr >= list.length ) { |
0
|
20 |
$.ajax({ |
|
21 |
url: '../wp-admin/admin-ajax.php?action=prtfl_update_image', |
|
22 |
type: "POST", |
5
|
23 |
data: "action1=update_options" + '&prtfl_ajax_nonce_field=' + prtfl_var.prtfl_nonce, |
|
24 |
success: function( result ) { |
|
25 |
/**/ |
0
|
26 |
} |
|
27 |
}); |
5
|
28 |
$( "#ajax_update_images" ).removeAttr( "disabled" ); |
|
29 |
setMessage("<p>" + prtfl_var.img_success + "</p>"); |
|
30 |
$( '#prtfl_img_loader' ).hide(); |
0
|
31 |
return; |
|
32 |
} |
|
33 |
$.ajax({ |
|
34 |
url: '../wp-admin/admin-ajax.php?action=prtfl_update_image', |
|
35 |
type: "POST", |
5
|
36 |
data: "action1=update_image&id=" + list[ curr ].ID + '&prtfl_ajax_nonce_field=' + prtfl_var.prtfl_nonce, |
|
37 |
success: function( result ) { |
0
|
38 |
curr = curr + 1; |
|
39 |
updatenImageItem(); |
|
40 |
} |
|
41 |
}); |
|
42 |
} |
|
43 |
|
|
44 |
updatenImageItem(); |
|
45 |
}, |
|
46 |
error: function( request, status, error ) { |
5
|
47 |
setError( "<p>" + prtfl_var.img_error + request.status + "</p>" ); |
0
|
48 |
} |
|
49 |
}); |
|
50 |
})(jQuery); |
|
51 |
} |
|
52 |
|
5
|
53 |
function setMessage( msg ) { |
0
|
54 |
(function($){ |
5
|
55 |
$( ".error" ).hide(); |
|
56 |
$( ".updated" ).html( msg ); |
|
57 |
$( ".updated" ).show(); |
|
58 |
$( '#prtfl_settings_notice' ).hide(); |
0
|
59 |
})(jQuery); |
|
60 |
} |
|
61 |
|
5
|
62 |
function setError( msg ) { |
0
|
63 |
(function($){ |
5
|
64 |
$( ".updated" ).hide(); |
|
65 |
$( ".error" ).html( msg ); |
|
66 |
$( ".error" ).show(); |
0
|
67 |
})(jQuery); |
|
68 |
} |
5
|
69 |
|
|
70 |
(function($) { |
|
71 |
$(document).ready( function() { |
|
72 |
$( '#prtfl_form_image_size input' ).bind( "change click select", function() { |
|
73 |
if ( $( this ).attr( 'type' ) != 'submit' ) { |
|
74 |
$( '.updated.fade' ).css( 'display', 'none' ); |
|
75 |
$( '#prtfl_settings_notice' ).css( 'display', 'block' ); |
|
76 |
}; |
|
77 |
}); |
|
78 |
}); |
|
79 |
})(jQuery); |