codemirror
3 years ago
datatables
3 years ago
admin-page.js
3 years ago
custom-admin-menu.js
3 years ago
hide-admin-notices.js
3 years ago
jBox.all.min.js
3 years ago
jquery.jsticky.mod.js
3 years ago
jquery.jsticky.mod.min.js
3 years ago
js.cookie.min.js
3 years ago
media-replace.js
3 years ago
public.js
3 years ago
toggle-hidden-menu.js
3 years ago
admin-page.js
918 lines
| 1 | (function( $ ) { |
| 2 | 'use strict'; |
| 3 | |
| 4 | $(document).ready( function() { |
| 5 | |
| 6 | // Make page header sticky on scroll. Using https://github.com/AndrewHenderson/jSticky |
| 7 | $('#asenha-header').sticky({ |
| 8 | topSpacing: 0, // Space between element and top of the viewport (in pixels) |
| 9 | zIndex: 100, // z-index |
| 10 | stopper: '', // Id, class, or number value |
| 11 | stickyClass: 'asenha-sticky' // Class applied to element when it's stuck. Class name or false. |
| 12 | }) |
| 13 | |
| 14 | // Clicking on header save button triggers click of the hidden form submit button |
| 15 | $('.asenha-save-button').click( function(e) { |
| 16 | |
| 17 | e.preventDefault(); |
| 18 | |
| 19 | // Get current tab's URL hash and save it in cookie |
| 20 | var hash = decodeURI(window.location.hash).substr(1); // get hash without the # character |
| 21 | Cookies.set('asenha_tab', hash, { expires: 1 }); // expires in 1 day |
| 22 | |
| 23 | // Submit the settings form |
| 24 | $('input[type="submit"]').click(); |
| 25 | |
| 26 | }); |
| 27 | |
| 28 | // Show all / less toggler for field options | Modified from https://codepen.io/symonsays/pen/rzgEgY |
| 29 | $('.asenha-field-with-options.field-show-more > .show-more').click(function(e) { |
| 30 | |
| 31 | e.preventDefault(); |
| 32 | |
| 33 | var $this = $(this); |
| 34 | $this.toggleClass('show-more'); |
| 35 | |
| 36 | if ($this.hasClass('show-more')) { |
| 37 | $this.next().removeClass('opened',0); |
| 38 | $this.html('Expand ▼'); |
| 39 | } else { |
| 40 | $this.next().addClass('opened',0); |
| 41 | $this.html('Collapse ▲'); |
| 42 | } |
| 43 | |
| 44 | }); |
| 45 | |
| 46 | // Initialize data tables |
| 47 | var table = $("#login-attempts-log").DataTable({ |
| 48 | pageLength: 10 |
| 49 | }); |
| 50 | |
| 51 | // Place fields into the "Content Management" tab |
| 52 | $('.enable-duplication').appendTo('.fields-content-management > table > tbody'); |
| 53 | $('.enable-media-replacement').appendTo('.fields-content-management > table > tbody'); |
| 54 | $('.enable-svg-upload').appendTo('.fields-content-management > table > tbody'); |
| 55 | $('.enable-svg-upload-for').appendTo('.fields-content-management .enable-svg-upload .asenha-subfields'); |
| 56 | $('.enable-external-permalinks').appendTo('.fields-content-management > table > tbody'); |
| 57 | $('.enable-external-permalinks-for').appendTo('.fields-content-management .enable-external-permalinks .asenha-subfields'); |
| 58 | $('.enable-missed-schedule-posts-auto-publish').appendTo('.fields-content-management > table > tbody'); |
| 59 | $('.enhance-list-tables').appendTo('.fields-content-management > table > tbody'); |
| 60 | $('.show-featured-image-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 61 | $('.show-excerpt-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 62 | $('.show-id-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 63 | $('.hide-comments-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 64 | $('.hide-post-tags-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 65 | $('.show-custom-taxonomy-filters').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 66 | |
| 67 | // Place fields into "Admin Interface" tab |
| 68 | $('.hide-admin-notices').appendTo('.fields-admin-interface > table > tbody'); |
| 69 | $('.customize-admin-menu').appendTo('.fields-admin-interface > table > tbody'); |
| 70 | $('.custom-menu-order').appendTo('.fields-admin-interface .customize-admin-menu .asenha-subfields'); |
| 71 | $('.disable-dashboard-widgets').appendTo('.fields-admin-interface > table > tbody'); |
| 72 | $('.disabled-dashboard-widgets').appendTo('.fields-admin-interface .disable-dashboard-widgets .asenha-subfields'); |
| 73 | $('.hide-modify-elements').appendTo('.fields-admin-interface > table > tbody'); |
| 74 | $('.hide-ab-wp-logo-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 75 | $('.hide-ab-customize-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 76 | $('.hide-ab-updates-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 77 | $('.hide-ab-comments-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 78 | $('.hide-ab-new-content-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 79 | $('.hide-ab-howdy').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 80 | $('.hide-help-drawer').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 81 | $('.hide-admin-bar').appendTo('.fields-admin-interface > table > tbody'); |
| 82 | $('.hide-admin-bar-for').appendTo('.fields-admin-interface .hide-admin-bar .asenha-subfields'); |
| 83 | |
| 84 | // Place fields into "Log In | Log Out" tab |
| 85 | $('.change-login-url').appendTo('.fields-login-logout > table > tbody'); |
| 86 | $('.custom-login-slug').appendTo('.fields-login-logout .change-login-url .asenha-subfields'); |
| 87 | $('.enable-login-logout-menu').appendTo('.fields-login-logout > table > tbody'); |
| 88 | $('.enable-last-login-column').appendTo('.fields-login-logout > table > tbody'); |
| 89 | $('.redirect-after-login').appendTo('.fields-login-logout > table > tbody'); |
| 90 | $('.redirect-after-login-to-slug').appendTo('.fields-login-logout .redirect-after-login .asenha-subfields'); |
| 91 | $('.redirect-after-login-for').appendTo('.fields-login-logout .redirect-after-login .asenha-subfields'); |
| 92 | $('.redirect-after-logout').appendTo('.fields-login-logout > table > tbody'); |
| 93 | $('.redirect-after-logout-to-slug').appendTo('.fields-login-logout .redirect-after-logout .asenha-subfields'); |
| 94 | $('.redirect-after-logout-for').appendTo('.fields-login-logout .redirect-after-logout .asenha-subfields'); |
| 95 | |
| 96 | // Place fields into "Custom Code" tab |
| 97 | $('.enable-custom-admin-css').appendTo('.fields-custom-code > table > tbody'); |
| 98 | $('.custom-admin-css').appendTo('.fields-custom-code .enable-custom-admin-css .asenha-subfields'); |
| 99 | $('.enable-custom-frontend-css').appendTo('.fields-custom-code > table > tbody'); |
| 100 | $('.custom-frontend-css').appendTo('.fields-custom-code .enable-custom-frontend-css .asenha-subfields'); |
| 101 | $('.insert-head-body-footer-code').appendTo('.fields-custom-code > table > tbody'); |
| 102 | $('.head-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 103 | $('.head-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 104 | $('.body-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 105 | $('.body-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 106 | $('.footer-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 107 | $('.footer-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 108 | $('.enable-custom-body-class').appendTo('.fields-custom-code > table > tbody'); |
| 109 | $('.enable-custom-body-class-for').appendTo('.fields-custom-code .enable-custom-body-class .asenha-subfields'); |
| 110 | $('.manage-ads-appads-txt').appendTo('.fields-custom-code > table > tbody'); |
| 111 | $('.ads-txt-content').appendTo('.fields-custom-code .manage-ads-appads-txt .asenha-subfields'); |
| 112 | $('.app-ads-txt-content').appendTo('.fields-custom-code .manage-ads-appads-txt .asenha-subfields'); |
| 113 | $('.manage-robots-txt').appendTo('.fields-custom-code > table > tbody'); |
| 114 | $('.robots-txt-content').appendTo('.fields-custom-code .manage-robots-txt .asenha-subfields'); |
| 115 | |
| 116 | // Place fields into the "Disable Components" tab |
| 117 | $('.disable-gutenberg').appendTo('.fields-disable-components > table > tbody'); |
| 118 | $('.disable-gutenberg-for').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields'); |
| 119 | $('.disable-gutenberg-frontend-styles').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields'); |
| 120 | $('.disable-comments').appendTo('.fields-disable-components > table > tbody'); |
| 121 | $('.disable-comments-for').appendTo('.fields-disable-components .disable-comments .asenha-subfields'); |
| 122 | $('.disable-rest-api').appendTo('.fields-disable-components > table > tbody'); |
| 123 | $('.disable-feeds').appendTo('.fields-disable-components > table > tbody'); |
| 124 | $('.disable-all-updates').appendTo('.fields-disable-components > table > tbody'); |
| 125 | $('.disable-smaller-components').appendTo('.fields-disable-components > table > tbody'); |
| 126 | $('.disable-head-generator-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 127 | $('.disable-head-wlwmanifest-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 128 | $('.disable-head-rsd-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 129 | $('.disable-head-shortlink-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 130 | $('.disable-frontend-dashicons').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 131 | $('.disable-emoji-support').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 132 | |
| 133 | // Place fields into "Security" tab |
| 134 | $('.limit-login-attempts').appendTo('.fields-security > table > tbody'); |
| 135 | $('.login-fails-allowed').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 136 | $('.login-lockout-maxcount').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 137 | $('.login-attempts-log-table').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 138 | $('.obfuscate-author-slugs').appendTo('.fields-security > table > tbody'); |
| 139 | $('.disable-xmlrpc').appendTo('.fields-security > table > tbody'); |
| 140 | |
| 141 | // Place fields into "Optimizations" tab |
| 142 | $('.image-upload-control').appendTo('.fields-optimizations > table > tbody'); |
| 143 | $('.image-max-width').appendTo('.fields-optimizations .image-upload-control .asenha-subfields'); |
| 144 | $('.image-max-height').appendTo('.fields-optimizations .image-upload-control .asenha-subfields'); |
| 145 | $('.enable-revisions-control').appendTo('.fields-optimizations > table > tbody'); |
| 146 | $('.revisions-max-number').appendTo('.fields-optimizations .enable-revisions-control .asenha-subfields'); |
| 147 | $('.enable-revisions-control-for').appendTo('.fields-optimizations .enable-revisions-control .asenha-subfields'); |
| 148 | $('.enable-heartbeat-control').appendTo('.fields-optimizations > table > tbody'); |
| 149 | $('.heartbeat-control-for-admin-pages').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 150 | $('.heartbeat-interval-for-admin-pages').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 151 | $('.heartbeat-control-for-post-edit').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 152 | $('.heartbeat-interval-for-post-edit').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 153 | $('.heartbeat-control-for-frontend').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 154 | $('.heartbeat-interval-for-frontend').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 155 | |
| 156 | // Place fields into "Utilities" tab |
| 157 | $('.smtp-email-delivery').appendTo('.fields-utilities > table > tbody'); |
| 158 | $('.smtp-host').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 159 | $('.smtp-port').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 160 | $('.smtp-security').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 161 | $('.smtp-username').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 162 | $('.smtp-password').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 163 | $('.smtp-default-from-name').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 164 | $('.smtp-default-from-email').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 165 | $('.smtp-default-from-description').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 166 | $('.smtp-debug').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 167 | $('.view-admin-as-role').appendTo('.fields-utilities > table > tbody'); |
| 168 | $('.enable-password-protection').appendTo('.fields-utilities > table > tbody'); |
| 169 | $('.password-protection-password').appendTo('.fields-utilities .enable-password-protection .asenha-subfields'); |
| 170 | $('.maintenance-mode').appendTo('.fields-utilities > table > tbody'); |
| 171 | $('.maintenance-page-heading').appendTo('.fields-utilities .maintenance-mode .asenha-subfields'); |
| 172 | $('.maintenance-page-description').appendTo('.fields-utilities .maintenance-mode .asenha-subfields'); |
| 173 | $('.maintenance-page-background').appendTo('.fields-utilities .maintenance-mode .asenha-subfields'); |
| 174 | $('.maintenance-mode-description').appendTo('.fields-utilities .maintenance-mode .asenha-subfields'); |
| 175 | $('.redirect-404-to-homepage').appendTo('.fields-utilities > table > tbody'); |
| 176 | |
| 177 | // Remove empty .form-table that originally holds the fields |
| 178 | const formTableCount = $('.form-table').length; |
| 179 | // $('.form-table')[formTableCount-1].remove(); |
| 180 | |
| 181 | // Enable Custom Admin CSS => Initialize CodeMirror |
| 182 | var adminCssTextarea = document.getElementById("admin_site_enhancements[custom_admin_css]"); |
| 183 | var adminCssEditor = CodeMirror.fromTextArea(adminCssTextarea, { |
| 184 | mode: "css", |
| 185 | lineNumbers: true, |
| 186 | lineWrapping: true |
| 187 | }); |
| 188 | |
| 189 | adminCssEditor.setSize("100%",600); |
| 190 | |
| 191 | // Enable Custom Frontend CSS => Initialize CodeMirror |
| 192 | var frontendCssTextarea = document.getElementById("admin_site_enhancements[custom_frontend_css]"); |
| 193 | var frontendCssEditor = CodeMirror.fromTextArea(frontendCssTextarea, { |
| 194 | mode: "css", |
| 195 | lineNumbers: true, |
| 196 | lineWrapping: true |
| 197 | }); |
| 198 | |
| 199 | frontendCssEditor.setSize("100%",600); |
| 200 | |
| 201 | // Manage ads.txt and app-ads.txt=> Initialize CodeMirror |
| 202 | var adsTxtTextarea = document.getElementById("admin_site_enhancements[ads_txt_content]"); |
| 203 | var adsTxtEditor = CodeMirror.fromTextArea(adsTxtTextarea, { |
| 204 | mode: "markdown", |
| 205 | lineNumbers: true, |
| 206 | lineWrapping: true |
| 207 | }); |
| 208 | |
| 209 | adsTxtEditor.setSize("100%",300); |
| 210 | |
| 211 | var appAdsTxtTextarea = document.getElementById("admin_site_enhancements[app_ads_txt_content]"); |
| 212 | var appAdsTxtEditor = CodeMirror.fromTextArea(appAdsTxtTextarea, { |
| 213 | mode: "markdown", |
| 214 | lineNumbers: true, |
| 215 | lineWrapping: true |
| 216 | }); |
| 217 | |
| 218 | appAdsTxtEditor.setSize("100%",300); |
| 219 | |
| 220 | // Manage robots.txt => Initialize CodeMirror |
| 221 | var robotsTxtTextarea = document.getElementById("admin_site_enhancements[robots_txt_content]"); |
| 222 | var robotsTxtEditor = CodeMirror.fromTextArea(robotsTxtTextarea, { |
| 223 | mode: "markdown", |
| 224 | lineNumbers: true, |
| 225 | lineWrapping: true |
| 226 | }); |
| 227 | |
| 228 | robotsTxtEditor.setSize("100%",400); |
| 229 | |
| 230 | // Insert <head>, <body> and <footer> code => Initialize CodeMirror |
| 231 | var headCodeTextarea = document.getElementById("admin_site_enhancements[head_code]"); |
| 232 | var headCodeEditor = CodeMirror.fromTextArea(headCodeTextarea, { |
| 233 | mode: "htmlmixed", |
| 234 | lineNumbers: true, |
| 235 | lineWrapping: true |
| 236 | }); |
| 237 | headCodeEditor.setSize("100%",300); |
| 238 | |
| 239 | var bodyCodeTextarea = document.getElementById("admin_site_enhancements[body_code]"); |
| 240 | var bodyCodeEditor = CodeMirror.fromTextArea(bodyCodeTextarea, { |
| 241 | mode: "htmlmixed", |
| 242 | lineNumbers: true, |
| 243 | lineWrapping: true |
| 244 | }); |
| 245 | bodyCodeEditor.setSize("100%",300); |
| 246 | |
| 247 | var footerCodeTextarea = document.getElementById("admin_site_enhancements[footer_code]"); |
| 248 | var footerCodeEditor = CodeMirror.fromTextArea(footerCodeTextarea, { |
| 249 | mode: "htmlmixed", |
| 250 | lineNumbers: true, |
| 251 | lineWrapping: true |
| 252 | }); |
| 253 | footerCodeEditor.setSize("100%",300); |
| 254 | |
| 255 | // Show and hide corresponding fields on tab clicks |
| 256 | |
| 257 | $('#tab-content-management + label').click( function() { |
| 258 | $('.fields-content-management').show(); |
| 259 | $('.asenha-fields:not(.fields-content-management)').hide(); |
| 260 | window.location.hash = 'content-management'; |
| 261 | Cookies.set('asenha_tab', 'content-management', { expires: 1 }); // expires in 1 day |
| 262 | }); |
| 263 | |
| 264 | $('#tab-admin-interface + label').click( function() { |
| 265 | $('.fields-admin-interface').show(); |
| 266 | $('.asenha-fields:not(.fields-admin-interface)').hide(); |
| 267 | window.location.hash = 'admin-interface'; |
| 268 | Cookies.set('asenha_tab', 'admin-interface', { expires: 1 }); // expires in 1 day |
| 269 | }); |
| 270 | |
| 271 | $('#tab-login-logout + label').click( function() { |
| 272 | $('.fields-login-logout').show(); |
| 273 | $('.asenha-fields:not(.fields-login-logout)').hide(); |
| 274 | window.location.hash = 'login-logout'; |
| 275 | Cookies.set('asenha_tab', 'login-logout', { expires: 1 }); // expires in 1 day |
| 276 | }); |
| 277 | |
| 278 | $('#tab-custom-code + label').click( function() { |
| 279 | $('.fields-custom-code').show(); |
| 280 | $('.asenha-fields:not(.fields-custom-code)').hide(); |
| 281 | window.location.hash = 'custom-code'; |
| 282 | Cookies.set('asenha_tab', 'custom-code', { expires: 1 }); // expires in 1 day |
| 283 | adminCssEditor.refresh(); // Custom Admin CSS >> CodeMirror |
| 284 | frontendCssEditor.refresh(); // Custom Fronend CSS >> CodeMirror |
| 285 | adsTxtEditor.refresh(); // Manage ads.txt >> CodeMirror |
| 286 | appAdsTxtEditor.refresh(); // Manage app-ads.txt >> CodeMirror |
| 287 | headCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 288 | bodyCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 289 | footerCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 290 | robotsTxtEditor.refresh(); // Manage robots.txt >> CodeMirror |
| 291 | }); |
| 292 | |
| 293 | $('#tab-disable-components + label').click( function() { |
| 294 | $('.fields-disable-components').show(); |
| 295 | $('.asenha-fields:not(.fields-disable-components)').hide(); |
| 296 | window.location.hash = 'disable-components'; |
| 297 | Cookies.set('asenha_tab', 'disable-components', { expires: 1 }); // expires in 1 day |
| 298 | }); |
| 299 | |
| 300 | $('#tab-security + label').click( function() { |
| 301 | $('.fields-security').show(); |
| 302 | $('.asenha-fields:not(.fields-security)').hide(); |
| 303 | window.location.hash = 'security'; |
| 304 | Cookies.set('asenha_tab', 'security', { expires: 1 }); // expires in 1 day |
| 305 | }); |
| 306 | |
| 307 | $('#tab-optimizations + label').click( function() { |
| 308 | $('.fields-optimizations').show(); |
| 309 | $('.asenha-fields:not(.fields-optimizations)').hide(); |
| 310 | window.location.hash = 'optimizations'; |
| 311 | Cookies.set('asenha_tab', 'optimizations', { expires: 1 }); // expires in 1 day |
| 312 | }); |
| 313 | |
| 314 | $('#tab-utilities + label').click( function() { |
| 315 | $('.fields-utilities').show(); |
| 316 | $('.asenha-fields:not(.fields-utilities)').hide(); |
| 317 | window.location.hash = 'utilities'; |
| 318 | Cookies.set('asenha_tab', 'utilities', { expires: 1 }); // expires in 1 day |
| 319 | }); |
| 320 | |
| 321 | // Open tab set in 'asenha_tab' cookie set on saving changes. Defaults to content-management tab when cookie is empty |
| 322 | var asenhaTabHash = Cookies.get('asenha_tab'); |
| 323 | |
| 324 | if (typeof asenhaTabHash === 'undefined') { |
| 325 | $('#tab-content-management + label').trigger('click'); |
| 326 | } else { |
| 327 | $('#tab-' + asenhaTabHash + ' + label').trigger('click'); |
| 328 | } |
| 329 | |
| 330 | // Enable SVG Upload => show/hide roles checkboxes on document ready |
| 331 | if ( document.getElementById('admin_site_enhancements[enable_svg_upload]').checked ) { |
| 332 | $('.enable-svg-upload .asenha-subfields').show(); |
| 333 | $('.asenha-toggle.enable-svg-upload td .asenha-field-with-options').addClass('is-enabled'); |
| 334 | } else { |
| 335 | $('.enable-svg-upload .asenha-subfields').hide(); |
| 336 | } |
| 337 | |
| 338 | // Enable SVG Upload => show/hide roles checkboxes on toggle click |
| 339 | document.getElementById('admin_site_enhancements[enable_svg_upload]').addEventListener('click', event => { |
| 340 | if (event.target.checked) { |
| 341 | $('.enable-svg-upload .asenha-subfields').fadeIn(); |
| 342 | $('.enable-svg-upload .asenha-field-with-options').toggleClass('is-enabled'); |
| 343 | } else { |
| 344 | $('.enable-svg-upload .asenha-subfields').hide(); |
| 345 | $('.enable-svg-upload .asenha-field-with-options').toggleClass('is-enabled'); |
| 346 | } |
| 347 | }); |
| 348 | |
| 349 | // Enable External Permalinks => show/hide post types checkboxes on document ready |
| 350 | if ( document.getElementById('admin_site_enhancements[enable_external_permalinks]').checked ) { |
| 351 | $('.enable-external-permalinks .asenha-subfields').show(); |
| 352 | $('.asenha-toggle.enable-external-permalinks td .asenha-field-with-options').addClass('is-enabled'); |
| 353 | } else { |
| 354 | $('.enable-external-permalinks .asenha-subfields').hide(); |
| 355 | } |
| 356 | |
| 357 | // Enable External Permalinks => show/hide post types checkboxes on toggle click |
| 358 | document.getElementById('admin_site_enhancements[enable_external_permalinks]').addEventListener('click', event => { |
| 359 | if (event.target.checked) { |
| 360 | $('.enable-external-permalinks .asenha-subfields').fadeIn(); |
| 361 | $('.enable-external-permalinks .asenha-field-with-options').toggleClass('is-enabled'); |
| 362 | } else { |
| 363 | $('.enable-external-permalinks .asenha-subfields').hide(); |
| 364 | $('.enable-external-permalinks .asenha-field-with-options').toggleClass('is-enabled'); |
| 365 | } |
| 366 | }); |
| 367 | |
| 368 | // Enable SVG Upload => show/hide roles checkboxes on toggle click |
| 369 | document.getElementById('admin_site_enhancements[enable_revisions_control]').addEventListener('click', event => { |
| 370 | if (event.target.checked) { |
| 371 | $('.enable-revisions-control .asenha-subfields').fadeIn(); |
| 372 | $('.enable-revisions-control .asenha-field-with-options').toggleClass('is-enabled'); |
| 373 | } else { |
| 374 | $('.enable-revisions-control .asenha-subfields').hide(); |
| 375 | $('.enable-revisions-control .asenha-field-with-options').toggleClass('is-enabled'); |
| 376 | } |
| 377 | }); |
| 378 | |
| 379 | // Enhance List Tables => show/hide subfields on document ready |
| 380 | if ( document.getElementById('admin_site_enhancements[enhance_list_tables]').checked ) { |
| 381 | $('.enhance-list-tables .asenha-subfields').show(); |
| 382 | $('.asenha-toggle.enhance-list-tables td .asenha-field-with-options').addClass('is-enabled'); |
| 383 | } else { |
| 384 | $('.enhance-list-tables .asenha-subfields').hide(); |
| 385 | } |
| 386 | |
| 387 | // Enhance List Tables => show/hide subfields on toggle click |
| 388 | document.getElementById('admin_site_enhancements[enhance_list_tables]').addEventListener('click', event => { |
| 389 | if (event.target.checked) { |
| 390 | $('.enhance-list-tables .asenha-subfields').fadeIn(); |
| 391 | $('.enhance-list-tables .asenha-field-with-options').toggleClass('is-enabled'); |
| 392 | } else { |
| 393 | $('.enhance-list-tables .asenha-subfields').hide(); |
| 394 | $('.enhance-list-tables .asenha-field-with-options').toggleClass('is-enabled'); |
| 395 | } |
| 396 | }); |
| 397 | |
| 398 | // Hide Admin Bar => show/hide roles checkboxes on document ready |
| 399 | if ( document.getElementById('admin_site_enhancements[hide_admin_bar]').checked ) { |
| 400 | $('.hide-admin-bar .asenha-subfields').show(); |
| 401 | $('.asenha-toggle.hide-admin-bar td .asenha-field-with-options').addClass('is-enabled'); |
| 402 | } else { |
| 403 | $('.hide-admin-bar .asenha-subfields').hide(); |
| 404 | } |
| 405 | |
| 406 | // Hide Admin Bar => show/hide roles checkboxes on toggle click |
| 407 | document.getElementById('admin_site_enhancements[hide_admin_bar]').addEventListener('click', event => { |
| 408 | if (event.target.checked) { |
| 409 | $('.hide-admin-bar .asenha-subfields').fadeIn(); |
| 410 | $('.hide-admin-bar .asenha-field-with-options').toggleClass('is-enabled'); |
| 411 | } else { |
| 412 | $('.hide-admin-bar .asenha-subfields').hide(); |
| 413 | $('.hide-admin-bar .asenha-field-with-options').toggleClass('is-enabled'); |
| 414 | } |
| 415 | }); |
| 416 | |
| 417 | // Disable Dashboard Widgets => show/hide subfields on document ready |
| 418 | if ( document.getElementById('admin_site_enhancements[disable_dashboard_widgets]').checked ) { |
| 419 | $('.disable-dashboard-widgets .asenha-subfields').show(); |
| 420 | $('.asenha-toggle.disable-dashboard-widgets td .asenha-field-with-options').addClass('is-enabled'); |
| 421 | } else { |
| 422 | $('.disable-dashboard-widgets .asenha-subfields').hide(); |
| 423 | } |
| 424 | |
| 425 | // Disable Dashboard Widgets => show/hide subfields on toggle click |
| 426 | document.getElementById('admin_site_enhancements[disable_dashboard_widgets]').addEventListener('click', event => { |
| 427 | if (event.target.checked) { |
| 428 | $('.disable-dashboard-widgets .asenha-subfields').fadeIn(); |
| 429 | $('.disable-dashboard-widgets .asenha-field-with-options').toggleClass('is-enabled'); |
| 430 | } else { |
| 431 | $('.disable-dashboard-widgets .asenha-subfields').hide(); |
| 432 | $('.disable-dashboard-widgets .asenha-field-with-options').toggleClass('is-enabled'); |
| 433 | } |
| 434 | }); |
| 435 | |
| 436 | // Hide or Modify Elements => show/hide subfields on document ready |
| 437 | if ( document.getElementById('admin_site_enhancements[hide_modify_elements]').checked ) { |
| 438 | $('.hide-modify-elements .asenha-subfields').show(); |
| 439 | $('.asenha-toggle.hide-modify-elements td .asenha-field-with-options').addClass('is-enabled'); |
| 440 | } else { |
| 441 | $('.hide-modify-elements .asenha-subfields').hide(); |
| 442 | } |
| 443 | |
| 444 | // Hide or Modify Elements => show/hide subfields on toggle click |
| 445 | document.getElementById('admin_site_enhancements[hide_modify_elements]').addEventListener('click', event => { |
| 446 | if (event.target.checked) { |
| 447 | $('.hide-modify-elements .asenha-subfields').fadeIn(); |
| 448 | $('.hide-modify-elements .asenha-field-with-options').toggleClass('is-enabled'); |
| 449 | } else { |
| 450 | $('.hide-modify-elements .asenha-subfields').hide(); |
| 451 | $('.hide-modify-elements .asenha-field-with-options').toggleClass('is-enabled'); |
| 452 | } |
| 453 | }); |
| 454 | |
| 455 | // Customize Admin Menu => show/hide subfields on document ready |
| 456 | if ( document.getElementById('admin_site_enhancements[customize_admin_menu]').checked ) { |
| 457 | $('.customize-admin-menu .asenha-subfields').show(); |
| 458 | $('.asenha-toggle.customize-admin-menu td .asenha-field-with-options').addClass('is-enabled'); |
| 459 | } else { |
| 460 | $('.customize-admin-menu .asenha-subfields').hide(); |
| 461 | } |
| 462 | |
| 463 | // Customize Admin Menu => show/hide subfields on toggle click |
| 464 | document.getElementById('admin_site_enhancements[customize_admin_menu]').addEventListener('click', event => { |
| 465 | if (event.target.checked) { |
| 466 | $('.customize-admin-menu .asenha-subfields').fadeIn(); |
| 467 | $('.customize-admin-menu .asenha-field-with-options').toggleClass('is-enabled'); |
| 468 | |
| 469 | // Initialize sortable elements: https://api.jqueryui.com/sortable/ |
| 470 | $('#custom-admin-menu').sortable(); |
| 471 | |
| 472 | } else { |
| 473 | $('.customize-admin-menu .asenha-subfields').hide(); |
| 474 | $('.customize-admin-menu .asenha-field-with-options').toggleClass('is-enabled'); |
| 475 | } |
| 476 | }); |
| 477 | |
| 478 | // Disable Gutenberg => show/hide post type checkboxes on document ready |
| 479 | if ( document.getElementById('admin_site_enhancements[disable_gutenberg]').checked ) { |
| 480 | $('.disable-gutenberg .asenha-subfields').show(); |
| 481 | $('.asenha-toggle.disable-gutenberg td .asenha-field-with-options').addClass('is-enabled'); |
| 482 | } else { |
| 483 | $('.disable-gutenberg .asenha-subfields').hide(); |
| 484 | } |
| 485 | |
| 486 | // Disable Gutenberg => show/hide post type checkboxes on toggle click |
| 487 | document.getElementById('admin_site_enhancements[disable_gutenberg]').addEventListener('click', event => { |
| 488 | if (event.target.checked) { |
| 489 | $('.disable-gutenberg .asenha-subfields').fadeIn(); |
| 490 | $('.disable-gutenberg .asenha-field-with-options').toggleClass('is-enabled'); |
| 491 | } else { |
| 492 | $('.disable-gutenberg .asenha-subfields').hide(); |
| 493 | $('.disable-gutenberg .asenha-field-with-options').toggleClass('is-enabled'); |
| 494 | } |
| 495 | }); |
| 496 | |
| 497 | // Disable Comments => show/hide post type checkboxes on document ready |
| 498 | if ( document.getElementById('admin_site_enhancements[disable_comments]').checked ) { |
| 499 | $('.disable-comments .asenha-subfields').show(); |
| 500 | $('.asenha-toggle.disable-comments td .asenha-field-with-options').addClass('is-enabled'); |
| 501 | } else { |
| 502 | $('.disable-comments .asenha-subfields').hide(); |
| 503 | } |
| 504 | |
| 505 | // Disable Comments => show/hide post type checkboxes on toggle click |
| 506 | document.getElementById('admin_site_enhancements[disable_comments]').addEventListener('click', event => { |
| 507 | if (event.target.checked) { |
| 508 | $('.disable-comments .asenha-subfields').fadeIn(); |
| 509 | $('.disable-comments .asenha-field-with-options').toggleClass('is-enabled'); |
| 510 | } else { |
| 511 | $('.disable-comments .asenha-subfields').hide(); |
| 512 | $('.disable-comments .asenha-field-with-options').toggleClass('is-enabled'); |
| 513 | } |
| 514 | }); |
| 515 | |
| 516 | // Disable Smaller Components => show/hide components checkboxes on document ready |
| 517 | if ( document.getElementById('admin_site_enhancements[disable_smaller_components]').checked ) { |
| 518 | $('.disable-smaller-components .asenha-subfields').show(); |
| 519 | $('.asenha-toggle.disable-smaller-components td .asenha-field-with-options').addClass('is-enabled'); |
| 520 | } else { |
| 521 | $('.disable-smaller-components .asenha-subfields').hide(); |
| 522 | } |
| 523 | |
| 524 | // Smaller Components => show/hide post components checkboxes on toggle click |
| 525 | document.getElementById('admin_site_enhancements[disable_smaller_components]').addEventListener('click', event => { |
| 526 | if (event.target.checked) { |
| 527 | $('.disable-smaller-components .asenha-subfields').fadeIn(); |
| 528 | $('.disable-smaller-components .asenha-field-with-options').toggleClass('is-enabled'); |
| 529 | } else { |
| 530 | $('.disable-smaller-components .asenha-subfields').hide(); |
| 531 | $('.disable-smaller-components .asenha-field-with-options').toggleClass('is-enabled'); |
| 532 | } |
| 533 | }); |
| 534 | |
| 535 | // Change Login URL => show/hide custom slug input on document ready |
| 536 | if ( document.getElementById('admin_site_enhancements[change_login_url]').checked ) { |
| 537 | $('.change-login-url .asenha-subfields').show(); |
| 538 | $('.asenha-toggle.change-login-url td .asenha-field-with-options').addClass('is-enabled'); |
| 539 | } else { |
| 540 | $('.change-login-url .asenha-subfields').hide(); |
| 541 | } |
| 542 | |
| 543 | // Change Login URL => show/hide custom slug input on toggle click |
| 544 | document.getElementById('admin_site_enhancements[change_login_url]').addEventListener('click', event => { |
| 545 | if (event.target.checked) { |
| 546 | $('.change-login-url .asenha-subfields').fadeIn(); |
| 547 | $('.change-login-url .asenha-field-with-options').toggleClass('is-enabled'); |
| 548 | } else { |
| 549 | $('.change-login-url .asenha-subfields').hide(); |
| 550 | $('.change-login-url .asenha-field-with-options').toggleClass('is-enabled'); |
| 551 | } |
| 552 | }); |
| 553 | |
| 554 | // Limit Login Attempts => show/hide custom slug input on document ready |
| 555 | if ( document.getElementById('admin_site_enhancements[limit_login_attempts]').checked ) { |
| 556 | $('.limit-login-attempts .asenha-subfields').show(); |
| 557 | $('.asenha-toggle.limit-login-attempts td .asenha-field-with-options').addClass('is-enabled'); |
| 558 | } else { |
| 559 | $('.limit-login-attempts .asenha-subfields').hide(); |
| 560 | } |
| 561 | |
| 562 | // Limit Login Attempts => show/hide custom slug input on toggle click |
| 563 | document.getElementById('admin_site_enhancements[limit_login_attempts]').addEventListener('click', event => { |
| 564 | if (event.target.checked) { |
| 565 | $('.limit-login-attempts .asenha-subfields').fadeIn(); |
| 566 | $('.limit-login-attempts .asenha-field-with-options').toggleClass('is-enabled'); |
| 567 | } else { |
| 568 | $('.limit-login-attempts .asenha-subfields').hide(); |
| 569 | $('.limit-login-attempts .asenha-field-with-options').toggleClass('is-enabled'); |
| 570 | } |
| 571 | }); |
| 572 | // Redirect After Login => show/hide roles checkboxes on document ready |
| 573 | if ( document.getElementById('admin_site_enhancements[redirect_after_login]').checked ) { |
| 574 | $('.redirect-after-login .asenha-subfields').show(); |
| 575 | $('.asenha-toggle.redirect-after-login td .asenha-field-with-options').addClass('is-enabled'); |
| 576 | } else { |
| 577 | $('.redirect-after-login .asenha-subfields').hide(); |
| 578 | } |
| 579 | |
| 580 | // Redirect After Login => show/hide roles checkboxes on toggle click |
| 581 | document.getElementById('admin_site_enhancements[redirect_after_login]').addEventListener('click', event => { |
| 582 | if (event.target.checked) { |
| 583 | $('.redirect-after-login .asenha-subfields').fadeIn(); |
| 584 | $('.redirect-after-login .asenha-field-with-options').toggleClass('is-enabled'); |
| 585 | } else { |
| 586 | $('.redirect-after-login .asenha-subfields').hide(); |
| 587 | $('.redirect-after-login .asenha-field-with-options').toggleClass('is-enabled'); |
| 588 | } |
| 589 | }); |
| 590 | |
| 591 | // Redirect After Logout => show/hide roles checkboxes on document ready |
| 592 | if ( document.getElementById('admin_site_enhancements[redirect_after_logout]').checked ) { |
| 593 | $('.redirect-after-logout .asenha-subfields').show(); |
| 594 | $('.asenha-toggle.redirect-after-logout td .asenha-field-with-options').addClass('is-enabled'); |
| 595 | } else { |
| 596 | $('.redirect-after-logout .asenha-subfields').hide(); |
| 597 | } |
| 598 | |
| 599 | // Redirect After Logout => show/hide roles checkboxes on toggle click |
| 600 | document.getElementById('admin_site_enhancements[redirect_after_logout]').addEventListener('click', event => { |
| 601 | if (event.target.checked) { |
| 602 | $('.redirect-after-logout .asenha-subfields').fadeIn(); |
| 603 | $('.redirect-after-logout .asenha-field-with-options').toggleClass('is-enabled'); |
| 604 | } else { |
| 605 | $('.redirect-after-logout .asenha-subfields').hide(); |
| 606 | $('.redirect-after-logout .asenha-field-with-options').toggleClass('is-enabled'); |
| 607 | } |
| 608 | }); |
| 609 | |
| 610 | // Enable Custom Admin CSS => show/hide CSS textarea on document ready |
| 611 | if ( document.getElementById('admin_site_enhancements[enable_custom_admin_css]').checked ) { |
| 612 | $('.enable-custom-admin-css .asenha-subfields').show(); |
| 613 | $('.asenha-toggle.enable-custom-admin-css td .asenha-field-with-options').addClass('is-enabled'); |
| 614 | adminCssEditor.refresh(); |
| 615 | } else { |
| 616 | $('.enable-custom-admin-css .asenha-subfields').hide(); |
| 617 | } |
| 618 | |
| 619 | // Enable Custom Admin CSS => show/hide CSS textarea on toggle click |
| 620 | document.getElementById('admin_site_enhancements[enable_custom_admin_css]').addEventListener('click', event => { |
| 621 | if (event.target.checked) { |
| 622 | $('.enable-custom-admin-css .asenha-subfields').fadeIn(); |
| 623 | $('.enable-custom-admin-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 624 | adminCssEditor.refresh(); |
| 625 | } else { |
| 626 | $('.enable-custom-admin-css .asenha-subfields').hide(); |
| 627 | $('.enable-custom-admin-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 628 | } |
| 629 | }); |
| 630 | |
| 631 | // Enable Custom Frontend CSS => show/hide CSS textarea on document ready |
| 632 | if ( document.getElementById('admin_site_enhancements[enable_custom_frontend_css]').checked ) { |
| 633 | $('.enable-custom-frontend-css .asenha-subfields').show(); |
| 634 | $('.asenha-toggle.enable-custom-frontend-css td .asenha-field-with-options').addClass('is-enabled'); |
| 635 | frontendCssEditor.refresh(); |
| 636 | } else { |
| 637 | $('.enable-custom-frontend-css .asenha-subfields').hide(); |
| 638 | } |
| 639 | |
| 640 | // Enable Custom Frontend CSS => show/hide CSS textarea on toggle click |
| 641 | document.getElementById('admin_site_enhancements[enable_custom_frontend_css]').addEventListener('click', event => { |
| 642 | if (event.target.checked) { |
| 643 | $('.enable-custom-frontend-css .asenha-subfields').fadeIn(); |
| 644 | $('.enable-custom-frontend-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 645 | frontendCssEditor.refresh(); |
| 646 | } else { |
| 647 | $('.enable-custom-frontend-css .asenha-subfields').hide(); |
| 648 | $('.enable-custom-frontend-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 649 | } |
| 650 | }); |
| 651 | |
| 652 | // Enable Custom Body Class => show/hide post types checkboxes on document ready |
| 653 | if ( document.getElementById('admin_site_enhancements[enable_custom_body_class]').checked ) { |
| 654 | $('.enable-custom-body-class .asenha-subfields').show(); |
| 655 | $('.asenha-toggle.enable-custom-body-class td .asenha-field-with-options').addClass('is-enabled'); |
| 656 | } else { |
| 657 | $('.enable-custom-body-class .asenha-subfields').hide(); |
| 658 | } |
| 659 | |
| 660 | // Enable Custom Body Class => show/hide post types checkboxes on toggle click |
| 661 | document.getElementById('admin_site_enhancements[enable_custom_body_class]').addEventListener('click', event => { |
| 662 | if (event.target.checked) { |
| 663 | $('.enable-custom-body-class .asenha-subfields').fadeIn(); |
| 664 | $('.enable-custom-body-class .asenha-field-with-options').toggleClass('is-enabled'); |
| 665 | } else { |
| 666 | $('.enable-custom-body-class .asenha-subfields').hide(); |
| 667 | $('.enable-custom-body-class .asenha-field-with-options').toggleClass('is-enabled'); |
| 668 | } |
| 669 | }); |
| 670 | |
| 671 | // Manage ads.txt and app-ads.txt => show/hide CodeMirror textarea on document ready |
| 672 | if ( document.getElementById('admin_site_enhancements[manage_ads_appads_txt]').checked ) { |
| 673 | $('.manage-ads-appads-txt .asenha-subfields').show(); |
| 674 | $('.asenha-toggle.manage-ads-appads-txt td .asenha-field-with-options').addClass('is-enabled'); |
| 675 | adsTxtEditor.refresh(); |
| 676 | appAdsTxtEditor.refresh(); |
| 677 | } else { |
| 678 | $('.manage-ads-appads-txt .asenha-subfields').hide(); |
| 679 | } |
| 680 | |
| 681 | // Manage ads.txt and app-ads.txt => show/hide CodeMirror textarea on toggle click |
| 682 | document.getElementById('admin_site_enhancements[manage_ads_appads_txt]').addEventListener('click', event => { |
| 683 | if (event.target.checked) { |
| 684 | $('.manage-ads-appads-txt .asenha-subfields').fadeIn(); |
| 685 | $('.manage-ads-appads-txt .asenha-field-with-options').toggleClass('is-enabled'); |
| 686 | adsTxtEditor.refresh(); |
| 687 | appAdsTxtEditor.refresh(); |
| 688 | } else { |
| 689 | $('.manage-ads-appads-txt .asenha-subfields').hide(); |
| 690 | $('.manage-ads-appads-txt .asenha-field-with-options').toggleClass('is-enabled'); |
| 691 | } |
| 692 | }); |
| 693 | |
| 694 | // Manage ads.txt and app-ads.txt => show/hide CodeMirror textarea on document ready |
| 695 | if ( document.getElementById('admin_site_enhancements[manage_robots_txt]').checked ) { |
| 696 | $('.manage-robots-txt .asenha-subfields').show(); |
| 697 | $('.asenha-toggle.manage-robots-txt td .asenha-field-with-options').addClass('is-enabled'); |
| 698 | robotsTxtEditor.refresh(); |
| 699 | } else { |
| 700 | $('.manage-robots-txt .asenha-subfields').hide(); |
| 701 | } |
| 702 | |
| 703 | // Manage ads.txt and app-ads.txt => show/hide CodeMirror textarea on toggle click |
| 704 | document.getElementById('admin_site_enhancements[manage_robots_txt]').addEventListener('click', event => { |
| 705 | if (event.target.checked) { |
| 706 | $('.manage-robots-txt .asenha-subfields').fadeIn(); |
| 707 | $('.manage-robots-txt .asenha-field-with-options').toggleClass('is-enabled'); |
| 708 | robotsTxtEditor.refresh(); |
| 709 | } else { |
| 710 | $('.manage-robots-txt .asenha-subfields').hide(); |
| 711 | $('.manage-robots-txt .asenha-field-with-options').toggleClass('is-enabled'); |
| 712 | } |
| 713 | }); |
| 714 | |
| 715 | // Insert <head>, <body> and <footer> code => show/hide CSS textarea on document ready |
| 716 | if ( document.getElementById('admin_site_enhancements[insert_head_body_footer_code]').checked ) { |
| 717 | $('.insert-head-body-footer-code .asenha-subfields').show(); |
| 718 | $('.asenha-toggle.insert-head-body-footer-code td .asenha-field-with-options').addClass('is-enabled'); |
| 719 | headCodeEditor.refresh(); |
| 720 | bodyCodeEditor.refresh(); |
| 721 | footerCodeEditor.refresh(); |
| 722 | } else { |
| 723 | $('.manage-app-ads-txt .asenha-subfields').hide(); |
| 724 | } |
| 725 | |
| 726 | // Insert <head>, <body> and <footer> code => show/hide CSS textarea on toggle click |
| 727 | document.getElementById('admin_site_enhancements[insert_head_body_footer_code]').addEventListener('click', event => { |
| 728 | if (event.target.checked) { |
| 729 | $('.insert-head-body-footer-code .asenha-subfields').fadeIn(); |
| 730 | $('.insert-head-body-footer-code .asenha-field-with-options').toggleClass('is-enabled'); |
| 731 | headCodeEditor.refresh(); |
| 732 | bodyCodeEditor.refresh(); |
| 733 | footerCodeEditor.refresh(); |
| 734 | } else { |
| 735 | $('.insert-head-body-footer-code .asenha-subfields').hide(); |
| 736 | $('.insert-head-body-footer-code .asenha-field-with-options').toggleClass('is-enabled'); |
| 737 | } |
| 738 | }); |
| 739 | |
| 740 | // Image Upload Control => show/hide sub-fields on document ready |
| 741 | if ( document.getElementById('admin_site_enhancements[image_upload_control]').checked ) { |
| 742 | $('.image-upload-control .asenha-subfields').show(); |
| 743 | $('.asenha-toggle.image-upload-control td .asenha-field-with-options').addClass('is-enabled'); |
| 744 | } else { |
| 745 | $('.image-upload-control .asenha-subfields').hide(); |
| 746 | } |
| 747 | |
| 748 | // Image Upload Control => show/hide sub-fields on toggle click |
| 749 | document.getElementById('admin_site_enhancements[image_upload_control]').addEventListener('click', event => { |
| 750 | if (event.target.checked) { |
| 751 | $('.image-upload-control .asenha-subfields').fadeIn(); |
| 752 | $('.image-upload-control .asenha-field-with-options').toggleClass('is-enabled'); |
| 753 | } else { |
| 754 | $('.image-upload-control .asenha-subfields').hide(); |
| 755 | $('.image-upload-control .asenha-field-with-options').toggleClass('is-enabled'); |
| 756 | } |
| 757 | }); |
| 758 | |
| 759 | // Enable Revisions Control => show/hide roles checkboxes on document ready |
| 760 | if ( document.getElementById('admin_site_enhancements[enable_revisions_control]').checked ) { |
| 761 | $('.enable-revisions-control .asenha-subfields').show(); |
| 762 | $('.asenha-toggle.enable-revisions-control td .asenha-field-with-options').addClass('is-enabled'); |
| 763 | } else { |
| 764 | $('.enable-revisions-control .asenha-subfields').hide(); |
| 765 | } |
| 766 | |
| 767 | // Enable Revisions Control => show/hide sub-fields on toggle click |
| 768 | document.getElementById('admin_site_enhancements[enable_revisions_control]').addEventListener('click', event => { |
| 769 | if (event.target.checked) { |
| 770 | $('.enable-revisions-control .asenha-subfields').fadeIn(); |
| 771 | $('.enable-revisions-control .asenha-field-with-options').toggleClass('is-enabled'); |
| 772 | } else { |
| 773 | $('.enable-revisions-control .asenha-subfields').hide(); |
| 774 | $('.enable-revisions-control .asenha-field-with-options').toggleClass('is-enabled'); |
| 775 | } |
| 776 | }); |
| 777 | |
| 778 | // Enable Heartbeat Control => show/hide subfields on document ready |
| 779 | if ( document.getElementById('admin_site_enhancements[enable_heartbeat_control]').checked ) { |
| 780 | $('.enable-heartbeat-control .asenha-subfields').show(); |
| 781 | $('.asenha-toggle.enable-heartbeat-control td .asenha-field-with-options').addClass('is-enabled'); |
| 782 | } else { |
| 783 | $('.enable-heartbeat-control .asenha-subfields').hide(); |
| 784 | } |
| 785 | |
| 786 | // Enable Heartbeat Control => show/hide subfields on toggle click |
| 787 | document.getElementById('admin_site_enhancements[enable_heartbeat_control]').addEventListener('click', event => { |
| 788 | if (event.target.checked) { |
| 789 | $('.enable-heartbeat-control .asenha-subfields').fadeIn(); |
| 790 | $('.enable-heartbeat-control .asenha-field-with-options').toggleClass('is-enabled'); |
| 791 | } else { |
| 792 | $('.enable-heartbeat-control .asenha-subfields').hide(); |
| 793 | $('.enable-heartbeat-control .asenha-field-with-options').toggleClass('is-enabled'); |
| 794 | } |
| 795 | }); |
| 796 | |
| 797 | // Enable Heartbeat Control => Check if "Modify interval" is chosen/clicked and show/hide the corresponding select field |
| 798 | if ( $('input[name="admin_site_enhancements[heartbeat_control_for_admin_pages]"]:checked').val() == 'modify' ) { |
| 799 | $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').show(); |
| 800 | } |
| 801 | $('input[name="admin_site_enhancements[heartbeat_control_for_admin_pages]"]').click(function() { |
| 802 | var radioValue = $(this).attr('value'); |
| 803 | if ( radioValue == 'modify' ) { |
| 804 | $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').show(); |
| 805 | } else { |
| 806 | $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').hide(); |
| 807 | } |
| 808 | }); |
| 809 | |
| 810 | if ( $('input[name="admin_site_enhancements[heartbeat_control_for_post_edit]"]:checked').val() == 'modify' ) { |
| 811 | $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').show(); |
| 812 | } |
| 813 | $('input[name="admin_site_enhancements[heartbeat_control_for_post_edit]"]').click(function() { |
| 814 | var radioValue = $(this).attr('value'); |
| 815 | if ( radioValue == 'modify' ) { |
| 816 | $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').show(); |
| 817 | } else { |
| 818 | $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').hide(); |
| 819 | } |
| 820 | }); |
| 821 | |
| 822 | if ( $('input[name="admin_site_enhancements[heartbeat_control_for_frontend]"]:checked').val() == 'modify' ) { |
| 823 | $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').show(); |
| 824 | } |
| 825 | $('input[name="admin_site_enhancements[heartbeat_control_for_frontend]"]').click(function() { |
| 826 | var radioValue = $(this).attr('value'); |
| 827 | if ( radioValue == 'modify' ) { |
| 828 | $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').show(); |
| 829 | } else { |
| 830 | $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').hide(); |
| 831 | } |
| 832 | }); |
| 833 | |
| 834 | // SMTP Email Delivery => show/hide subfields on document ready |
| 835 | if ( document.getElementById('admin_site_enhancements[smtp_email_delivery]').checked ) { |
| 836 | $('.smtp-email-delivery .asenha-subfields').show(); |
| 837 | $('.asenha-toggle.smtp-email-delivery td .asenha-field-with-options').addClass('is-enabled'); |
| 838 | } else { |
| 839 | $('.smtp-email-delivery .asenha-subfields').hide(); |
| 840 | } |
| 841 | |
| 842 | // SMTP Email Delivery => show/hide subfields on toggle click |
| 843 | document.getElementById('admin_site_enhancements[smtp_email_delivery]').addEventListener('click', event => { |
| 844 | if (event.target.checked) { |
| 845 | $('.smtp-email-delivery .asenha-subfields').fadeIn(); |
| 846 | $('.smtp-email-delivery .asenha-field-with-options').toggleClass('is-enabled'); |
| 847 | } else { |
| 848 | $('.smtp-email-delivery .asenha-subfields').hide(); |
| 849 | $('.smtp-email-delivery .asenha-field-with-options').toggleClass('is-enabled'); |
| 850 | } |
| 851 | }); |
| 852 | |
| 853 | // SMTP Email Delivery => Empty field value on click, so new password can be easily entered |
| 854 | var oldSmtpPassValue = ''; |
| 855 | $('input[name="admin_site_enhancements[smtp_password]"]').focusin(function() { |
| 856 | oldSmtpPassValue = $(this).val(); |
| 857 | $(this).val(''); |
| 858 | }); |
| 859 | |
| 860 | $('input[name="admin_site_enhancements[smtp_password]"]').focusout(function() { |
| 861 | if ( $(this).val() == '' ) { |
| 862 | $(this).val(oldSmtpPassValue); |
| 863 | } |
| 864 | }); |
| 865 | // Enable Password Protection => show/hide password input on document ready |
| 866 | if ( document.getElementById('admin_site_enhancements[enable_password_protection]').checked ) { |
| 867 | $('.enable-password-protection .asenha-subfields').show(); |
| 868 | $('.asenha-toggle.enable-password-protection td .asenha-field-with-options').addClass('is-enabled'); |
| 869 | } else { |
| 870 | $('.enable-password-protection .asenha-subfields').hide(); |
| 871 | } |
| 872 | |
| 873 | // Enable Password Protection => show/hide password input input on toggle click |
| 874 | document.getElementById('admin_site_enhancements[enable_password_protection]').addEventListener('click', event => { |
| 875 | if (event.target.checked) { |
| 876 | $('.enable-password-protection .asenha-subfields').fadeIn(); |
| 877 | $('.enable-password-protection .asenha-field-with-options').toggleClass('is-enabled'); |
| 878 | } else { |
| 879 | $('.enable-password-protection .asenha-subfields').hide(); |
| 880 | $('.enable-password-protection .asenha-field-with-options').toggleClass('is-enabled'); |
| 881 | } |
| 882 | }); |
| 883 | |
| 884 | // Enable Password protection => Empty field value on click, so new password can be easily entered |
| 885 | var oldValue = ''; |
| 886 | $('input[name="admin_site_enhancements[password_protection_password]"]').focusin(function() { |
| 887 | oldValue = $(this).val(); |
| 888 | $(this).val(''); |
| 889 | }); |
| 890 | |
| 891 | $('input[name="admin_site_enhancements[password_protection_password]"]').focusout(function() { |
| 892 | if ( $(this).val() == '' ) { |
| 893 | $(this).val(oldValue); |
| 894 | } |
| 895 | }); |
| 896 | |
| 897 | // Maintenance Mode => show/hide subfields on document ready |
| 898 | if ( document.getElementById('admin_site_enhancements[maintenance_mode]').checked ) { |
| 899 | $('.maintenance-mode .asenha-subfields').show(); |
| 900 | $('.asenha-toggle.maintenance-mode td .asenha-field-with-options').addClass('is-enabled'); |
| 901 | } else { |
| 902 | $('.maintenance-mode .asenha-subfields').hide(); |
| 903 | } |
| 904 | |
| 905 | // Maintenance Mode => show/hide subfields on toggle click |
| 906 | document.getElementById('admin_site_enhancements[maintenance_mode]').addEventListener('click', event => { |
| 907 | if (event.target.checked) { |
| 908 | $('.maintenance-mode .asenha-subfields').fadeIn(); |
| 909 | $('.maintenance-mode .asenha-field-with-options').toggleClass('is-enabled'); |
| 910 | } else { |
| 911 | $('.maintenance-mode .asenha-subfields').hide(); |
| 912 | $('.maintenance-mode .asenha-field-with-options').toggleClass('is-enabled'); |
| 913 | } |
| 914 | }); |
| 915 | |
| 916 | }); |
| 917 | |
| 918 | })( jQuery ); |