summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury German <blueknight@gentoo.org>2019-05-22 01:01:36 -0400
committerYury German <blueknight@gentoo.org>2019-05-22 01:01:36 -0400
commit0914c92da22824025992c368c745546e41fbeb84 (patch)
tree965f6adf3b725e56d559fe4a93eff02281499dcc /plugins/jetpack/modules/post-by-email/post-by-email.js
parentDeleting plugins for update (diff)
downloadblogs-gentoo-0914c92da22824025992c368c745546e41fbeb84.tar.gz
blogs-gentoo-0914c92da22824025992c368c745546e41fbeb84.tar.bz2
blogs-gentoo-0914c92da22824025992c368c745546e41fbeb84.zip
Adding Plugins
Updating the following akismet.4.1.2, google-authenticator.0.52, jetpack.7.3.1 Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules/post-by-email/post-by-email.js')
-rw-r--r--plugins/jetpack/modules/post-by-email/post-by-email.js128
1 files changed, 128 insertions, 0 deletions
diff --git a/plugins/jetpack/modules/post-by-email/post-by-email.js b/plugins/jetpack/modules/post-by-email/post-by-email.js
new file mode 100644
index 00000000..a8141684
--- /dev/null
+++ b/plugins/jetpack/modules/post-by-email/post-by-email.js
@@ -0,0 +1,128 @@
+/* global jetpack_post_by_email:true, ajaxurl, pbeVars */
+
+( function( $ ) {
+ var $pbeDisable,
+ $pbeEmail,
+ $pbeEmailWrapper,
+ $pbeEnable,
+ $pbeError,
+ $pbeInfo,
+ $pbeRegenerate,
+ $pbeSpinner;
+
+ jetpack_post_by_email = {
+ init: function() {
+ $pbeEnable.click( jetpack_post_by_email.enable );
+ $pbeRegenerate.click( jetpack_post_by_email.regenerate );
+ $pbeDisable.click( jetpack_post_by_email.disable );
+ },
+
+ enable: function() {
+ $pbeEnable.attr( 'disabled', 'disabled' );
+ $pbeError.fadeOut();
+ $pbeSpinner.fadeIn();
+
+ var data = {
+ action: 'jetpack_post_by_email_enable',
+ pbe_nonce: pbeVars.nonces.enable,
+ };
+
+ $.post( ajaxurl, data, jetpack_post_by_email.handle_enabled );
+ },
+
+ handle_enabled: function( response ) {
+ $pbeRegenerate.removeAttr( 'disabled' );
+ $pbeDisable.removeAttr( 'disabled' );
+
+ if ( response.success ) {
+ $pbeEnable.fadeOut( 400, function() {
+ $pbeEnable.removeAttr( 'disabled' );
+ $pbeEmail.val( response.data );
+ $pbeInfo.fadeIn();
+ } );
+ } else {
+ $pbeError.text( response.data );
+ $pbeError.fadeIn();
+ $pbeEnable.removeAttr( 'disabled' );
+ }
+
+ $pbeSpinner.fadeOut();
+ },
+
+ regenerate: function() {
+ $pbeRegenerate.attr( 'disabled', 'disabled' );
+ $pbeDisable.attr( 'disabled', 'disabled' );
+ $pbeError.fadeOut();
+ $pbeSpinner.fadeIn();
+
+ var data = {
+ action: 'jetpack_post_by_email_regenerate',
+ pbe_nonce: pbeVars.nonces.regenerate,
+ };
+
+ $.post( ajaxurl, data, jetpack_post_by_email.handle_regenerated );
+ },
+
+ handle_regenerated: function( response ) {
+ if ( response.success ) {
+ $pbeEmailWrapper.fadeOut( 400, function() {
+ $pbeEmail.val( response.data );
+ $pbeEmailWrapper.fadeIn();
+ } );
+ } else {
+ $pbeError.text( response.data );
+ $pbeError.fadeIn();
+ }
+
+ $pbeRegenerate.removeAttr( 'disabled' );
+ $pbeDisable.removeAttr( 'disabled' );
+ $pbeSpinner.fadeOut();
+ },
+
+ disable: function() {
+ $pbeRegenerate.attr( 'disabled', 'disabled' );
+ $pbeDisable.attr( 'disabled', 'disabled' );
+ $pbeError.fadeOut();
+ $pbeSpinner.fadeIn();
+
+ var data = {
+ action: 'jetpack_post_by_email_disable',
+ pbe_nonce: pbeVars.nonces.disable,
+ };
+
+ $.post( ajaxurl, data, jetpack_post_by_email.handle_disabled );
+ },
+
+ handle_disabled: function( response ) {
+ if ( response.success ) {
+ $pbeEnable.removeAttr( 'disabled' );
+ $pbeInfo.fadeOut( 400, function() {
+ $pbeRegenerate.removeAttr( 'disabled' );
+ $pbeDisable.removeAttr( 'disabled' );
+ $pbeEnable.fadeIn();
+ } );
+ } else {
+ $pbeRegenerate.removeAttr( 'disabled' );
+ $pbeDisable.removeAttr( 'disabled' );
+
+ $pbeError.text( response.data );
+ $pbeError.fadeIn();
+ }
+
+ $pbeSpinner.fadeOut();
+ },
+ };
+
+ $( function() {
+ $pbeDisable = $( '#jp-pbe-disable' );
+ $pbeEmail = $( '#jp-pbe-email' );
+ $pbeEmailWrapper = $( '#jp-pbe-email-wrapper' );
+ $pbeEnable = $( '#jp-pbe-enable' );
+ $pbeError = $( '#jp-pbe-error' );
+ $pbeInfo = $( '#jp-pbe-info' );
+ $pbeRegenerate = $( '#jp-pbe-regenerate' );
+ $pbeSpinner = $( '#jp-pbe-spinner' );
+
+ jetpack_post_by_email.init();
+ } );
+} )( jQuery );