felixarntz/wp-gcs-offload

View on GitHub
assets/dist/js/attachment-edit.min.js

Summary

Maintainability
A
0 mins
Test Coverage
/*!
 * WP GCS Offload (https://wordpress.org/plugins/wp-gcs-offload/)
 * By Felix Arntz (https://leaves-and-love.net)
 * Licensed under GNU General Public License v3 (http://www.gnu.org/licenses/gpl-3.0.html)
 */
!function(t,e,n){function c(t,c,a){var o=e('<div id="wp-gcs-offload-sync-notice-wrap" class="misc-pub-section" />'),s=e('<div id="wp-gcs-offload-sync-notice" class="notice notice-'+c+'" />');"error"===c&&(t="<strong>"+n.error_prefix+"</strong> "+t),s.html("<p>"+t+"</p>"),o.append(s),e(a).after(o)}function a(){var t=e("#wp-gcs-offload-sync-notice-wrap");t.length&&t.remove()}function o(n,o,s){t.ajax.post(n,o).done(function(t){e("#wp-gcs-offload-data");e("#wp-gcs-offload-data").replaceWith(t.html),c(t.message,"success",s)}).fail(function(t){a(),c(t,"error",s)})}var s;e(document).ready(function(){s=e("#post_ID").val(),s&&(s=parseInt(s,10))}),e(document).on("click","#wp-gcs-offload-sync-attachment-upstream",function(t){t.preventDefault(),s&&o("wpgcso_sync_attachment_upstream",{nonce:n.sync_attachment_upstream_nonce,attachment_id:s},"misc-pub-gcs-sync-upstream")}),e(document).on("click","#wp-gcs-offload-sync-attachment-downstream",function(t){t.preventDefault(),s&&o("wpgcso_sync_attachment_downstream",{nonce:n.sync_attachment_downstream_nonce,attachment_id:s},"misc-pub-gcs-sync-downstream")}),e(document).on("click","#wp-gcs-offload-delete-attachment-upstream",function(t){t.preventDefault(),s&&o("wpgcso_delete_attachment_upstream",{nonce:n.delete_attachment_upstream_nonce,attachment_id:s},"misc-pub-gcs-delete-upstream")}),e(document).on("click","#wp-gcs-offload-delete-attachment-downstream",function(t){t.preventDefault(),s&&o("wpgcso_delete_attachment_downstream",{nonce:n.delete_attachment_downstream_nonce,attachment_id:s},"misc-pub-gcs-delete-downstream")})}(wp,jQuery,_wpGCSOffloadAttachmentEdit);