Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/ninja-fo.../deprecat.../upgrade
File: upgrade.js
jQuery(document).ready(function($) {
[0] Fix | Delete
[1] Fix | Delete
/*
[2] Fix | Delete
|--------------------------------------------------------------------------
[3] Fix | Delete
| Ninja Forms THREE Upgrade App
[4] Fix | Delete
|--------------------------------------------------------------------------
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
var nfUpgradeApp = {
[8] Fix | Delete
[9] Fix | Delete
forms: [],
[10] Fix | Delete
[11] Fix | Delete
step: 'checking',
[12] Fix | Delete
[13] Fix | Delete
container: '#nfUpgradeApp',
[14] Fix | Delete
[15] Fix | Delete
tmpl: {
[16] Fix | Delete
test: wp.template( 'test' ),
[17] Fix | Delete
table: wp.template( 'table' ),
[18] Fix | Delete
legend: wp.template( 'legend' ),
[19] Fix | Delete
},
[20] Fix | Delete
[21] Fix | Delete
formCheckPointer: 0,
[22] Fix | Delete
formConvertPointer: 0,
[23] Fix | Delete
[24] Fix | Delete
updateTable: function(){
[25] Fix | Delete
[26] Fix | Delete
var data = {
[27] Fix | Delete
title: '',
[28] Fix | Delete
headers: [ 'Title', 'Status' ],
[29] Fix | Delete
rows: this.forms,
[30] Fix | Delete
step: this.step,
[31] Fix | Delete
showSupportLink: 0,
[32] Fix | Delete
};
[33] Fix | Delete
[34] Fix | Delete
if( 'checking' == this.step ) {
[35] Fix | Delete
[36] Fix | Delete
data.title = 'Form Upgrade List';
[37] Fix | Delete
[38] Fix | Delete
data.legend = this.tmpl.legend( {
[39] Fix | Delete
no_issues_detected: 'No Issues Detected',
[40] Fix | Delete
will_need_attention: 'Will Need Attention After Upgrade',
[41] Fix | Delete
}),
[42] Fix | Delete
[43] Fix | Delete
data.next = 'Start Upgrade';
[44] Fix | Delete
[45] Fix | Delete
data.readyToConvert = 1;
[46] Fix | Delete
_.each(this.forms, function (form) {
[47] Fix | Delete
if ( ! form.checked ) data.readyToConvert = 0;
[48] Fix | Delete
}, this);
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
if( 'converting' == this.step ) {
[52] Fix | Delete
data.title = 'Converting Forms';
[53] Fix | Delete
[54] Fix | Delete
var redirectToThree = 1;
[55] Fix | Delete
_.each(this.forms, function (form) {
[56] Fix | Delete
if ( ! form.converted ) redirectToThree = 0;
[57] Fix | Delete
if ( form.failed ) data.showSupportLink = 1;
[58] Fix | Delete
}, this);
[59] Fix | Delete
if( redirectToThree ) {
[60] Fix | Delete
jQuery( window ).unbind( 'beforeunload' );
[61] Fix | Delete
window.location.href = nfThreeUpgrade.redirectURL;
[62] Fix | Delete
}
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
jQuery( this.container ).html( this.tmpl.table( data ) );
[66] Fix | Delete
},
[67] Fix | Delete
[68] Fix | Delete
checkForms: function() {
[69] Fix | Delete
var form = this.forms[ this.formCheckPointer ] || null;
[70] Fix | Delete
if( form ) this.checkForm( form );
[71] Fix | Delete
this.formCheckPointer++;
[72] Fix | Delete
},
[73] Fix | Delete
[74] Fix | Delete
checkForm: function( form ) {
[75] Fix | Delete
[76] Fix | Delete
var that = this;
[77] Fix | Delete
$.post( ajaxurl, { action: 'ninja_forms_upgrade_check', formID: form.id }, function( response ) {
[78] Fix | Delete
[79] Fix | Delete
var icon = ( response.canUpgrade ) ? '' : 'flag';
[80] Fix | Delete
var flagged = ( response.canUpgrade ) ? 0 : 1;
[81] Fix | Delete
that.updateForm( form.id, 'title', response.title );
[82] Fix | Delete
that.updateForm( form.id, 'icon', icon );
[83] Fix | Delete
that.updateForm( form.id, 'checked', true );
[84] Fix | Delete
that.updateForm( form.id, 'flagged', flagged );
[85] Fix | Delete
that.updateTable();
[86] Fix | Delete
[87] Fix | Delete
that.checkForms();
[88] Fix | Delete
}, 'json' );
[89] Fix | Delete
},
[90] Fix | Delete
[91] Fix | Delete
updateForm: function( formID, property, value ) {
[92] Fix | Delete
_.each( this.forms, function( form ) {
[93] Fix | Delete
if( formID != form.id ) return;
[94] Fix | Delete
form[ property ] = value;
[95] Fix | Delete
});
[96] Fix | Delete
},
[97] Fix | Delete
[98] Fix | Delete
start: function () {
[99] Fix | Delete
[100] Fix | Delete
_.each( nfThreeUpgrade.forms, function( formID ) {
[101] Fix | Delete
this.forms.push({
[102] Fix | Delete
id: formID,
[103] Fix | Delete
title: '',
[104] Fix | Delete
icon: 'update',
[105] Fix | Delete
checked: false,
[106] Fix | Delete
converted: false,
[107] Fix | Delete
failed: false,
[108] Fix | Delete
});
[109] Fix | Delete
}, this );
[110] Fix | Delete
[111] Fix | Delete
this.checkForms();
[112] Fix | Delete
this.updateTable();
[113] Fix | Delete
[114] Fix | Delete
var that = this;
[115] Fix | Delete
jQuery( '#nfUpgradeApp' ).on( 'click','.js-nfUpgrade-startConversion', function() {
[116] Fix | Delete
that.startConversion( that );
[117] Fix | Delete
} );
[118] Fix | Delete
},
[119] Fix | Delete
[120] Fix | Delete
startConversion: function( app ) {
[121] Fix | Delete
console.log( 'HERE' );
[122] Fix | Delete
console.log( app );
[123] Fix | Delete
app.step = 'converting';
[124] Fix | Delete
[125] Fix | Delete
// Add a notice if the user tries to navigate away during conversion.
[126] Fix | Delete
jQuery( window ).bind( 'beforeunload', function(){
[127] Fix | Delete
return 'You have unsaved changes.';
[128] Fix | Delete
} );
[129] Fix | Delete
[130] Fix | Delete
$.post( ajaxurl, { nf2to3: 1, action: 'ninja_forms_ajax_migrate_database', security: nfThreeUpgrade.nonce }, function( response ) {
[131] Fix | Delete
[132] Fix | Delete
$.post( ajaxurl, { action: 'nfThreeUpgrade_GetSerializedFields' }, function( fieldsExport ) {
[133] Fix | Delete
$.post(ajaxurl, { nf2to3: 1, fields: fieldsExport.serialized, action: 'ninja_forms_ajax_import_fields', security: nfThreeUpgrade.nonce }, function ( fieldsImport ) {
[134] Fix | Delete
app.convertForms();
[135] Fix | Delete
}, 'json' );
[136] Fix | Delete
}, 'json' );
[137] Fix | Delete
});
[138] Fix | Delete
},
[139] Fix | Delete
[140] Fix | Delete
[141] Fix | Delete
convertForms: function() {
[142] Fix | Delete
var form = this.forms[ this.formConvertPointer ] || null;
[143] Fix | Delete
if( form ) this.convertForm( form );
[144] Fix | Delete
this.formConvertPointer++;
[145] Fix | Delete
},
[146] Fix | Delete
[147] Fix | Delete
convertForm: function( form ) {
[148] Fix | Delete
var app = this;
[149] Fix | Delete
console.log( 'Converting...' );
[150] Fix | Delete
console.log( form );
[151] Fix | Delete
[152] Fix | Delete
form.icon = 'update'
[153] Fix | Delete
app.updateTable();
[154] Fix | Delete
[155] Fix | Delete
$.post(ajaxurl, {action: 'nfThreeUpgrade_GetSerializedForm', formID: form.id}, function ( formExport ) {
[156] Fix | Delete
$.post(ajaxurl, { nf2to3: 1, action: 'ninja_forms_ajax_import_form', security: nfThreeUpgrade.nonce, formID: form.id, import: formExport.serialized, flagged: form.flagged }, function ( formImport ) {
[157] Fix | Delete
form.converted = true;
[158] Fix | Delete
form.icon = 'yes';
[159] Fix | Delete
app.updateTable();
[160] Fix | Delete
}, 'json').fail( function() {
[161] Fix | Delete
form.converted = false;
[162] Fix | Delete
form.failed = true;
[163] Fix | Delete
form.icon = 'no';
[164] Fix | Delete
app.updateTable();
[165] Fix | Delete
}).always( function() {
[166] Fix | Delete
app.convertForms();
[167] Fix | Delete
});
[168] Fix | Delete
[169] Fix | Delete
}, 'json' );
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
};
[173] Fix | Delete
[174] Fix | Delete
nfUpgradeApp.start();
[175] Fix | Delete
[176] Fix | Delete
});
[177] Fix | Delete
[178] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function