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