| @@ -68,9 +68,9 @@ | ||
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * Handle Enable Gzip compression button click. |
| 71 | 71 | */ |
| 72 | - $('#wp_optimize_gzip_compression_enable').on('click', function() { | |
| 72 | + $('#wp-optimize-nav-tab-wpo_cache-gzip-contents').on('click', '#wp_optimize_gzip_compression_enable', function() { | |
| 73 | 73 | var button = $(this), |
| 74 | 74 | loader = button.next(); |
| 75 | 75 | |
| 76 | 76 | loader.show(); |
| @@ -75,20 +75,13 @@ | ||
| 75 | 75 | |
| 76 | 76 | loader.show(); |
| 77 | 77 | |
| 78 | 78 | send_command('enable_gzip_compression', {enable: button.data('enable')}, function(response) { |
| 79 | - var gzip_status_message = $('#wpo_gzip_compression_status'); | |
| 80 | 79 | if (response) { |
| 81 | - if (response.enabled) { | |
| 82 | - button.text(wpoptimize.disable); | |
| 83 | - button.data('enable', '0'); | |
| 84 | - gzip_status_message.removeClass('wpo-disabled').addClass('wpo-enabled'); | |
| 85 | - } else { | |
| 86 | - button.text(wpoptimize.enable); | |
| 87 | - button.data('enable', '1'); | |
| 88 | - gzip_status_message.addClass('wpo-disabled').removeClass('wpo-enabled'); | |
| 89 | - } | |
| 90 | 80 | |
| 81 | + $('#wpo_gzip_compression_test_btn').trigger('click'); | |
| 82 | + | |
| 83 | + // Handle error message | |
| 91 | 84 | if (response.message) { |
| 92 | 85 | $('#wpo_gzip_compression_error_message').text(response.message).show(); |
| 93 | 86 | } else { |
| 94 | 87 | $('#wpo_gzip_compression_error_message').hide(); |
| @@ -111,11 +104,52 @@ | ||
| 111 | 104 | }); |
| 112 | 105 | }); |
| 113 | 106 | |
| 114 | 107 | /** |
| 108 | + * Handle Test again compressions button click | |
| 109 | + */ | |
| 110 | + $('#wp-optimize-nav-tab-wpo_cache-gzip-contents').on('click', '#wpo_gzip_compression_test_btn', function() { | |
| 111 | + var btn = $(this); | |
| 112 | + | |
| 113 | + if (btn.prop('disabled')) return; | |
| 114 | + | |
| 115 | + btn.prop('disabled', true); | |
| 116 | + $('#wpo_gzip_compression_details').hide(); | |
| 117 | + $('#wpo_gzip_control_panel .wpo_shade').removeClass('hidden'); | |
| 118 | + | |
| 119 | + send_command('get_compression_test_results_html', {}, function(response) { | |
| 120 | + if (response.results_html) { | |
| 121 | + $('#wpo_gzip_compression_details').html(response.results_html); | |
| 122 | + } else { | |
| 123 | + $('#wpo_gzip_compression_details').text(wpoptimize.error_unexpected_response); | |
| 124 | + } | |
| 125 | + | |
| 126 | + if (response.gzip_compression_control_panel) { | |
| 127 | + $('#wpo_gzip_control_panel').html(response.gzip_compression_control_panel); | |
| 128 | + } | |
| 129 | + }).fail(function() { | |
| 130 | + alert(wpoptimize.error_unexpected_response); | |
| 131 | + }).always(function() { | |
| 132 | + $('#wpo_gzip_control_panel .wpo_shade').addClass('hidden'); | |
| 133 | + $('#wpo_gzip_compression_details').show(); | |
| 134 | + btn.prop('disabled', false); | |
| 135 | + }); | |
| 136 | + }); | |
| 137 | + | |
| 138 | + /** | |
| 139 | + * Update gzip test results when tab is activated | |
| 140 | + */ | |
| 141 | + $('#wp-optimize-wrap').on('tab-change/wpo_cache/gzip', function() { | |
| 142 | + if (!$('#wp-optimize-nav-tab-wpo_cache-gzip').data('activated')) { | |
| 143 | + $('#wp-optimize-nav-tab-wpo_cache-gzip').data('activated', true); | |
| 144 | + $('#wpo_gzip_compression_test_btn').trigger('click'); | |
| 145 | + } | |
| 146 | + }); | |
| 147 | + | |
| 148 | + /** | |
| 115 | 149 | * Manually check gzip status |
| 116 | 150 | */ |
| 117 | - $('.wpo-refresh-gzip-status').on('click', function(e) { | |
| 151 | + $('#wp-optimize-nav-tab-wpo_cache-gzip-contents').on('click', '.wpo-refresh-gzip-status', function(e) { | |
| 118 | 152 | e.preventDefault(); |
| 119 | 153 | $link = $(this); |
| 120 | 154 | $link.addClass('loading'); |
| 121 | 155 | send_command('get_gzip_compression_status', null, function(response) { |
| @@ -494,18 +528,8 @@ | ||
| 494 | 528 | } |
| 495 | 529 | cache_preload_status_el.text(response.message); |
| 496 | 530 | update_cache_size_information(response); |
| 497 | 531 | } |
| 498 | - | |
| 499 | - // Handle avatar display settings | |
| 500 | - $('#wpo-show-avatars').on('change', function() { | |
| 501 | - if ($(this).is(':checked')) { | |
| 502 | - $('#wpo-host-gravatars-locally-container').show(); | |
| 503 | - } else { | |
| 504 | - $('#wpo-host-gravatars-locally').prop('checked', false); | |
| 505 | - $('#wpo-host-gravatars-locally-container').hide(); | |
| 506 | - } | |
| 507 | - }); | |
| 508 | 532 | |
| 509 | 533 | /** |
| 510 | 534 | * Run update information about cache size. |
| 511 | 535 | * |