Skip to content

Commit

Permalink
1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
notslang committed Nov 20, 2014
1 parent 0ceabb1 commit 00fda90
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 53 deletions.
3 changes: 3 additions & 0 deletions asset/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.sub-option {
margin: 5px 0 0 25px;
}
43 changes: 31 additions & 12 deletions asset/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,7 @@ var media_successfully_determined;

$.wpmdb.add_action( 'move_connection_info_box', function() {
hide_show_options( remote_media_files_unavailable );
$('.remove-scope-1').html('remote');
$('.remove-scope-2').html('local');
if( migration_type() == 'pull' ){
$('.remove-scope-1').html('local');
$('.remove-scope-2').html('remote');
}
action_text_toggle();
});

$.wpmdb.add_action( 'verify_connection_to_remote_site', function( connection_data ) {
Expand All @@ -88,12 +83,21 @@ var media_successfully_determined;

determine_media_to_migrate = function() {
connection_info = $.trim( $('.pull-push-connection-info').val() ).split("\n");
$('.progress-text').html( wpmdbmf_strings.determining );

var remove_local_media = 0;
var copy_entire_media = 0;

var media_type = $('input[name="media_migration_option"]:checked').val();

if ( 'compare' == media_type ) {
$('.progress-text').html( wpmdbmf_strings.determining );

if( $('#remove-local-media').is(':checked') ) {
remove_local_media = 1;
if( $('#remove-local-media').is(':checked') ) {
remove_local_media = 1;
}
} else {
$('.progress-text').html( wpmdbmf_strings.migrating_media_files );
copy_entire_media = 1;
}

$.ajax({
Expand All @@ -104,6 +108,7 @@ var media_successfully_determined;
data: {
action: 'wpmdbmf_determine_media_to_migrate',
remove_local_media: remove_local_media,
copy_entire_media: copy_entire_media,
intent: migration_type(),
url: connection_info[0],
key: connection_info[1],
Expand All @@ -112,7 +117,7 @@ var media_successfully_determined;
},
error: function(jqXHR, textStatus, errorThrown){
$('.progress-title').html( wpmdbmf_strings.migration_failed );
$('.progress-text').html( wpmdbmf_strings.error_determining + ' (#101mf)' );
$('.progress-text').html( wpmdbGetAjaxErrors( wpmdbmf_strings.error_determining, '(#101mf)', jqXHR.responseText, jqXHR ) );
$('.progress-text').addClass('migration-error');
console.log( jqXHR );
console.log( textStatus );
Expand All @@ -139,7 +144,7 @@ var media_successfully_determined;

function migration_failed( data ) {
$('.progress-title').html( wpmdbmf_strings.migration_failed );
$('.progress-text').html(data);
$('.progress-text').html( wpmdbGetAjaxErrors( '', '', data ) );
$('.progress-text').addClass('migration-error');
migration_error = true;
migration_complete_events();
Expand Down Expand Up @@ -225,7 +230,7 @@ var media_successfully_determined;
},
error: function(jqXHR, textStatus, errorThrown){
$('.progress-title').html('Migration failed');
$('.progress-text').html( wpmdbmf_strings.problem_migrating_media + ' (#102mf)');
$('.progress-text').html( wpmdbGetAjaxErrors( wpmdbmf_strings.problem_migrating_media, '(#102mf)', jqXHR.responseText, jqXHR ) );
$('.progress-text').addClass('migration-error');
console.log( jqXHR );
console.log( textStatus );
Expand Down Expand Up @@ -271,6 +276,20 @@ var media_successfully_determined;
return $('input[name=action]:checked').val();
}

function action_text_toggle() {
$('.action-text').hide();
$('.action-text.' + migration_type() ).show();
}

$('input[name="media_migration_option"]').change(function () {
if ($(this).is(':checked') && $(this).val() == 'entire') {
$('#remove-local-media').prop("disabled", true);
$('#remove-local-media').prop("checked", false);
} else {
$('#remove-local-media').prop("disabled", false);
}
});

});

})(jQuery);
Loading

0 comments on commit 00fda90

Please sign in to comment.