PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / trunk
Search Atlas SEO – OTTO AI SEO Automation for WordPress vtrunk
2.6.26 2.6.25 2.6.24 2.6.23 2.6.22 2.6.21 2.6.20 2.6.19 2.6.18 2.6.17 2.6.16 2.6.15 2.6.14 2.6.13 2.6.12 2.6.11 2.6.10 2.6.9 2.6.8 2.6.7 2.6.6 2.6.5 2.6.4 2.6.3 2.5.23 All 138 releases
metasync / code-minification / assets / js / code-minification-settings.js

code-minification-settings.js in Search Atlas SEO – OTTO AI SEO Automation for WordPress trunk, at code-minification/assets/js/code-minification-settings.js

120 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Code Minification Settings Tab Scripts
3 *
4 * @package Search Atlas SEO
5 * @copyright Copyright (C) 2021-2025, Search Atlas Group - support@searchatlas.com
6 * @since 2.5.23
7 *
8 * Localized data expected via metasyncCodeMin:
9 * - ajaxUrl: string
10 * - nonce: string
11 * - purgeConfirm: string
12 * - resetConfirm: string
13 */
14 (function() {
15 'use strict';
16
17 var config = window.metasyncCodeMin || {};
18
19 // Toggle section show/hide based on master toggle
20 var toggleCheckboxes = document.querySelectorAll('.metasync-code-minification-page .metasync-toggle input[type="checkbox"]');
21 toggleCheckboxes.forEach(function(checkbox) {
22 checkbox.addEventListener('change', function() {
23 var name = this.name;
24 var match = name.match(/\[([^\]]+)\]/);
25 if (!match) return;
26
27 var key = match[1];
28 var section = document.querySelector('.metasync-toggle-section[data-toggle="' + key + '"]');
29 if (section) {
30 if (this.checked) {
31 section.style.display = '';
32 section.style.opacity = '0';
33 section.style.maxHeight = '0';
34 section.offsetHeight; // Trigger reflow
35 section.style.opacity = '1';
36 section.style.maxHeight = section.scrollHeight + 'px';
37 setTimeout(function() { section.style.maxHeight = 'none'; }, 300);
38 } else {
39 section.style.maxHeight = section.scrollHeight + 'px';
40 section.offsetHeight; // Trigger reflow
41 section.style.opacity = '0';
42 section.style.maxHeight = '0';
43 setTimeout(function() { section.style.display = 'none'; }, 300);
44 }
45 }
46 });
47 });
48
49 // Tab switching
50 var tabLinks = document.querySelectorAll('.metasync-code-minification-page .metasync-tab-nav a');
51 tabLinks.forEach(function(link) {
52 link.addEventListener('click', function(e) {
53 e.preventDefault();
54 var tab = this.getAttribute('data-tab');
55
56 // Update active tab link
57 tabLinks.forEach(function(l) { l.classList.remove('active'); });
58 this.classList.add('active');
59
60 // Update active tab content
61 document.querySelectorAll('.metasync-code-minification-page .metasync-tab-content').forEach(function(content) {
62 content.classList.remove('active');
63 });
64 var targetContent = document.getElementById(tab + '-content');
65 if (targetContent) {
66 targetContent.classList.add('active');
67 }
68 });
69 });
70
71 // Purge minification cache
72 var purgeBtn = document.getElementById('metasync-purge-minification-cache');
73 if (purgeBtn) {
74 purgeBtn.addEventListener('click', function() {
75 if (!confirm(config.purgeConfirm || 'Purge cache?')) return;
76
77 var statusEl = document.getElementById('cache-purge-status');
78 purgeBtn.disabled = true;
79 if (statusEl) statusEl.textContent = 'Purging...';
80
81 var formData = new FormData();
82 formData.append('action', 'metasync_purge_minification_cache');
83 formData.append('nonce', config.nonce);
84
85 fetch(config.ajaxUrl, {
86 method: 'POST',
87 body: formData,
88 credentials: 'same-origin'
89 })
90 .then(function(res) { return res.json(); })
91 .then(function(data) {
92 purgeBtn.disabled = false;
93 if (data.success) {
94 if (statusEl) statusEl.textContent = data.data.message;
95 // Update stats
96 var stats = data.data.stats;
97 if (stats) {
98 updateStatEl('cache-total-files', stats.total_files);
99 updateStatEl('cache-css-files', stats.css_files);
100 updateStatEl('cache-js-files', stats.js_files);
101 updateStatEl('cache-total-size', '0 B');
102 }
103 } else {
104 if (statusEl) statusEl.textContent = 'Error: ' + (data.data || 'Unknown error');
105 }
106 })
107 .catch(function() {
108 purgeBtn.disabled = false;
109 if (statusEl) statusEl.textContent = 'Network error. Please try again.';
110 });
111 });
112 }
113
114 function updateStatEl(id, value) {
115 var el = document.getElementById(id);
116 if (el) el.textContent = value;
117 }
118
119 })();
120