account
1 week ago
checkout
1 week ago
connect
1 week ago
debug
1 week ago
forms
1 week ago
js
1 week ago
partials
1 week ago
plugin-info
1 week ago
account.php
1 week ago
add-ons.php
1 week ago
add-trial-to-pricing.php
1 week ago
admin-notice.php
1 week ago
ajax-loader.php
1 week ago
api-connectivity-message-js.php
1 week ago
auto-installation.php
1 week ago
checkout.php
1 week ago
clone-resolution-js.php
1 week ago
connect.php
1 week ago
contact.php
1 week ago
debug.php
1 week ago
email.php
1 week ago
gdpr-optin-js.php
1 week ago
index.php
1 week ago
plugin-icon.php
1 week ago
pricing.php
1 week ago
secure-https-header.php
1 week ago
sticky-admin-notice-js.php
1 week ago
tabs-capture-js.php
1 week ago
tabs.php
1 week ago
clone-resolution-js.php
89 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package Freemius |
| 4 | * @copyright Copyright (c) 2015, Freemius, Inc. |
| 5 | * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 |
| 6 | * @since 2.5.0 |
| 7 | */ |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; |
| 11 | } |
| 12 | ?> |
| 13 | <script type="text/javascript"> |
| 14 | ( function( $ ) { |
| 15 | var $errorMessage = null; |
| 16 | |
| 17 | $( document ).ready( function() { |
| 18 | var $cloneResolutionNotice = $( 'div[data-id="clone_resolution_options_notice"], div[data-id="temporary_duplicate_notice"]' ); |
| 19 | |
| 20 | if ( 0 === $cloneResolutionNotice.length ) { |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | $errorMessage = $cloneResolutionNotice.find( '#fs_clone_resolution_error_message' ); |
| 25 | |
| 26 | /** |
| 27 | * Triggers an AJAX request when the license activation link or any of the buttons on the clone resolution options notice is clicked. The AJAX request will then handle the action the user has chosen. |
| 28 | */ |
| 29 | $cloneResolutionNotice.on( 'click', '.button, #fs_temporary_duplicate_license_activation_link', function( evt ) { |
| 30 | evt.preventDefault(); |
| 31 | |
| 32 | var $this = $( this ); |
| 33 | |
| 34 | if ( $this.hasClass( 'disabled' ) ) { |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | var $body = $( 'body' ), |
| 39 | $optionsContainer = $this.parents( '.fs-clone-resolution-options-container' ), |
| 40 | cursor = $body.css( 'cursor' ), |
| 41 | beforeUnload = function() { |
| 42 | return '<?php fs_esc_js_echo_inline( 'Please wait', 'please-wait' ) ?>'; |
| 43 | }; |
| 44 | |
| 45 | $.ajax( { |
| 46 | // Get the parent options container from the child as `$cloneResolutionNotice` can have different AJAX URLs if both the manual clone resolution options and temporary duplicate notices are shown (for different subsites in a multisite network). |
| 47 | url : $optionsContainer.data( 'ajax-url' ), |
| 48 | method : 'POST', |
| 49 | data : { |
| 50 | action : '<?php echo $VARS['ajax_action'] ?>', |
| 51 | security : '<?php echo wp_create_nonce( $VARS['ajax_action'] ) ?>', |
| 52 | clone_action: $this.data( 'clone-action' ), |
| 53 | blog_id : $optionsContainer.data( 'blog-id' ) |
| 54 | }, |
| 55 | beforeSend: function() { |
| 56 | $body.css( { cursor: 'wait' } ); |
| 57 | |
| 58 | $this.addClass( 'disabled' ); |
| 59 | |
| 60 | if ( $this.attr( 'id' ) === 'fs_temporary_duplicate_license_activation_link' ) { |
| 61 | $this.append( '<i class="fs-ajax-spinner"></i>' ); |
| 62 | } |
| 63 | |
| 64 | $( window ).on( 'beforeunload', beforeUnload ); |
| 65 | }, |
| 66 | success : function( resultObj ) { |
| 67 | $( window ).off( 'beforeunload', beforeUnload ); |
| 68 | |
| 69 | if ( |
| 70 | resultObj.data && |
| 71 | resultObj.data.redirect_url && |
| 72 | '' !== resultObj.data.redirect_url |
| 73 | ) { |
| 74 | window.location = resultObj.data.redirect_url; |
| 75 | } else { |
| 76 | window.location.reload(); |
| 77 | } |
| 78 | }, |
| 79 | complete : function() { |
| 80 | $body.css( { cursor: cursor } ); |
| 81 | $this.removeClass( 'disabled' ); |
| 82 | |
| 83 | $this.parent().find( '.fs-ajax-spinner' ).remove(); |
| 84 | } |
| 85 | } ); |
| 86 | } ); |
| 87 | } ); |
| 88 | } )( jQuery ); |
| 89 | </script> |