window.wp=window.wp||{},function(d,u,n){u.updates={},u.updates.ajaxNonce=window._wpUpdatesSettings.ajax_nonce,u.updates.l10n=window._wpUpdatesSettings.l10n,u.updates.shouldRequestFilesystemCredentials=null,u.updates.filesystemCredentials={ftp:{host:null,username:null,password:null,connectionType:null},ssh:{publicKey:"",privateKey:""},fsNonce:""},u.updates.updateLock=!1,u.updates.updateDoneSuccessfully=!1,u.updates.updateQueue=[],u.updates.$elToReturnFocusToFromCredentialsModal=null,u.updates.decrementCount=function(e){var a,t=d("#wp-admin-bar-updates .ab-label"),s=d('a[href="update-core.php"] .update-plugins'),u=d("#menu-plugins"),n=t.text();(n=parseInt(n,10)-1)<0||isNaN(n)||(d("#wp-admin-bar-updates .ab-item").removeAttr("title"),t.text(n),s.each(function(e,t){t.className=t.className.replace(/count-\d+/,"count-"+n)}),s.removeAttr("title"),s.find(".update-count").text(n),"plugin"===e&&(a=u.find(".plugin-count").eq(0).text(),(a=parseInt(a,10)-1)<0||isNaN(a)||(u.find(".plugin-count").text(a),u.find(".update-plugins").each(function(e,t){t.className=t.className.replace(/count-\d+/,"count-"+a)}),0'+e+"")},u.updates.credentialError=function(e,t){u.updates.updateQueue.push({type:t,data:{plugin:e.plugin,slug:e.slug}}),u.updates.showErrorInCredentialsForm(e.error),u.updates.requestFilesystemCredentials()},u.updates.queueChecker=function(){var e;u.updates.updateLock||u.updates.updateQueue.length<=0||(e=u.updates.updateQueue.shift(),u.updates.updatePlugin(e.data.plugin,e.data.slug))},u.updates.requestFilesystemCredentials=function(e){!1===u.updates.updateDoneSuccessfully&&("plugin-install"===n&&e&&(u.updates.$elToReturnFocusToFromCredentialsModal=d(e.target)),u.updates.updateLock=!0,u.updates.requestForCredentialsModalOpen())},u.updates.keydown=function(e){27===e.keyCode?u.updates.requestForCredentialsModalCancel():9===e.keyCode&&("upgrade"!==e.target.id||e.shiftKey?"hostname"===e.target.id&&e.shiftKey&&(d("#upgrade").focus(),e.preventDefault()):(d("#hostname").focus(),e.preventDefault()))},u.updates.requestForCredentialsModalOpen=function(){var e=d("#request-filesystem-credentials-dialog");d("body").addClass("modal-open"),e.show(),e.find("input:enabled:first").focus(),e.keydown(u.updates.keydown)},u.updates.requestForCredentialsModalClose=function(){d("#request-filesystem-credentials-dialog").hide(),d("body").removeClass("modal-open"),u.updates.$elToReturnFocusToFromCredentialsModal.focus()},u.updates.requestForCredentialsModalCancel=function(){var e,t;!1===u.updates.updateLock&&0===u.updates.updateQueue.length||(e=u.updates.updateQueue[0].data.slug,u.updates.updateLock=!1,u.updates.updateQueue=[],u.updates.requestForCredentialsModalClose(),"plugins"===n||"plugins-network"===n?t=d('[data-slug="'+e+'"]').next().find(".update-message"):"plugin-install"===n&&(t=d(".plugin-card-"+e).find(".update-now")),t.removeClass("updating-message"),t.html(t.data("originaltext")),u.a11y.speak(u.updates.l10n.updateCancel))},u.updates.beforeunload=function(){if(u.updates.updateLock)return u.updates.l10n.beforeunload},d(document).ready(function(){u.updates.shouldRequestFilesystemCredentials=!(d("#request-filesystem-credentials-dialog").length<=0),d("#request-filesystem-credentials-dialog form").on("submit",function(){return u.updates.filesystemCredentials.fsNonce=d("#_fs_nonce").val(),u.updates.filesystemCredentials.ftp.hostname=d("#hostname").val(),u.updates.filesystemCredentials.ftp.username=d("#username").val(),u.updates.filesystemCredentials.ftp.password=d("#password").val(),u.updates.filesystemCredentials.ftp.connectionType=d('input[name="connection_type"]:checked').val(),u.updates.filesystemCredentials.ssh.publicKey=d("#public_key").val(),u.updates.filesystemCredentials.ssh.privateKey=d("#private_key").val(),u.updates.requestForCredentialsModalClose(),u.updates.updateLock=!1,u.updates.queueChecker(),!1}),d('#request-filesystem-credentials-dialog [data-js-action="close"], .notification-dialog-background').on("click",function(){u.updates.requestForCredentialsModalCancel()}),d('#request-filesystem-credentials-dialog input[name="connection_type"]').on("change",function(){d(this).parents("form").find("#private_key, #public_key").parents("label").toggle("ssh"==d(this).val())}).change(),d(".plugin-update-tr").on("click",".update-link",function(e){e.preventDefault(),u.updates.shouldRequestFilesystemCredentials&&!u.updates.updateLock&&u.updates.requestFilesystemCredentials(e);e=d(e.target).parents(".plugin-update-tr");u.updates.$elToReturnFocusToFromCredentialsModal=d("#"+e.data("slug")).find(".check-column input"),u.updates.updatePlugin(e.data("plugin"),e.data("slug"))}),d(".plugin-card").on("click",".update-now",function(e){e.preventDefault();var t=d(e.target);u.updates.shouldRequestFilesystemCredentials&&!u.updates.updateLock&&u.updates.requestFilesystemCredentials(e),u.updates.updatePlugin(t.data("plugin"),t.data("slug"))}),d("#plugin_update_from_iframe").on("click",function(e){var t=window.parent==window?null:window.parent;d.support.postMessage=!!window.postMessage,!1!==d.support.postMessage&&null!==t&&-1===window.parent.location.pathname.indexOf("update-core.php")&&(e.preventDefault(),e={action:"updatePlugin",slug:d(this).data("slug")},t.postMessage(JSON.stringify(e),window.location.origin))})}),d(window).on("message",function(e){var t,a=e.originalEvent,e=document.location,e=e.protocol+"//"+e.hostname;if(a.origin===e&&void 0!==(t=d.parseJSON(a.data)).action)switch(t.action){case"decrementUpdateCount":u.updates.decrementCount(t.upgradeType);break;case"updatePlugin":tb_remove(),"plugins"===n||"plugins-network"===n?(d("#"+t.slug).find(".check-column input").focus(),d('.plugin-update-tr[data-slug="'+t.slug+'"]').find(".update-link").trigger("click")):"plugin-install"===n&&(d(".plugin-card-"+t.slug).find("h4 a").focus(),d(".plugin-card-"+t.slug).find('[data-slug="'+t.slug+'"]').trigger("click"))}}),d(window).on("beforeunload",u.updates.beforeunload)}(jQuery,window.wp,window.pagenow,window.ajaxurl);