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
716 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-revisions-control').appendTo('.fields-content-management > table > tbody'); |
| 59 | $('.revisions-max-number').appendTo('.fields-content-management .enable-revisions-control .asenha-subfields'); |
| 60 | $('.enable-revisions-control-for').appendTo('.fields-content-management .enable-revisions-control .asenha-subfields'); |
| 61 | $('.enable-missed-schedule-posts-auto-publish').appendTo('.fields-content-management > table > tbody'); |
| 62 | $('.enhance-list-tables').appendTo('.fields-content-management > table > tbody'); |
| 63 | $('.show-featured-image-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 64 | $('.show-excerpt-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 65 | $('.show-id-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 66 | $('.hide-comments-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 67 | $('.hide-post-tags-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 68 | $('.show-custom-taxonomy-filters').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 69 | |
| 70 | // Place fields into "Admin Interface" tab |
| 71 | $('.hide-admin-notices').appendTo('.fields-admin-interface > table > tbody'); |
| 72 | $('.view-admin-as-role').appendTo('.fields-admin-interface > table > tbody'); |
| 73 | $('.customize-admin-menu').appendTo('.fields-admin-interface > table > tbody'); |
| 74 | $('.custom-menu-order').appendTo('.fields-admin-interface .customize-admin-menu .asenha-subfields'); |
| 75 | $('.hide-modify-elements').appendTo('.fields-admin-interface > table > tbody'); |
| 76 | $('.hide-ab-wp-logo-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 77 | $('.hide-ab-customize-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 78 | $('.hide-ab-updates-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 79 | $('.hide-ab-comments-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 80 | $('.hide-ab-new-content-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 81 | $('.hide-ab-howdy').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 82 | $('.hide-admin-bar').appendTo('.fields-admin-interface > table > tbody'); |
| 83 | $('.hide-admin-bar-for').appendTo('.fields-admin-interface .hide-admin-bar .asenha-subfields'); |
| 84 | |
| 85 | // Place fields into "Log In | Log Out" tab |
| 86 | $('.change-login-url').appendTo('.fields-login-logout > table > tbody'); |
| 87 | $('.custom-login-slug').appendTo('.fields-login-logout .change-login-url .asenha-subfields'); |
| 88 | $('.enable-login-logout-menu').appendTo('.fields-login-logout > table > tbody'); |
| 89 | $('.enable-last-login-column').appendTo('.fields-login-logout > table > tbody'); |
| 90 | $('.redirect-after-login').appendTo('.fields-login-logout > table > tbody'); |
| 91 | $('.redirect-after-login-to-slug').appendTo('.fields-login-logout .redirect-after-login .asenha-subfields'); |
| 92 | $('.redirect-after-login-for').appendTo('.fields-login-logout .redirect-after-login .asenha-subfields'); |
| 93 | $('.redirect-after-logout').appendTo('.fields-login-logout > table > tbody'); |
| 94 | $('.redirect-after-logout-to-slug').appendTo('.fields-login-logout .redirect-after-logout .asenha-subfields'); |
| 95 | $('.redirect-after-logout-for').appendTo('.fields-login-logout .redirect-after-logout .asenha-subfields'); |
| 96 | |
| 97 | // Place fields into "Custom Code" tab |
| 98 | $('.enable-custom-admin-css').appendTo('.fields-custom-code > table > tbody'); |
| 99 | $('.custom-admin-css').appendTo('.fields-custom-code .enable-custom-admin-css .asenha-subfields'); |
| 100 | $('.enable-custom-frontend-css').appendTo('.fields-custom-code > table > tbody'); |
| 101 | $('.custom-frontend-css').appendTo('.fields-custom-code .enable-custom-frontend-css .asenha-subfields'); |
| 102 | $('.insert-head-body-footer-code').appendTo('.fields-custom-code > table > tbody'); |
| 103 | $('.head-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 104 | $('.head-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 105 | $('.body-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 106 | $('.body-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 107 | $('.footer-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 108 | $('.footer-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 109 | $('.manage-ads-appads-txt').appendTo('.fields-custom-code > table > tbody'); |
| 110 | $('.ads-txt-content').appendTo('.fields-custom-code .manage-ads-appads-txt .asenha-subfields'); |
| 111 | $('.app-ads-txt-content').appendTo('.fields-custom-code .manage-ads-appads-txt .asenha-subfields'); |
| 112 | $('.manage-robots-txt').appendTo('.fields-custom-code > table > tbody'); |
| 113 | $('.robots-txt-content').appendTo('.fields-custom-code .manage-robots-txt .asenha-subfields'); |
| 114 | |
| 115 | // Place fields into the "Disable Components" tab |
| 116 | $('.disable-gutenberg').appendTo('.fields-disable-components > table > tbody'); |
| 117 | $('.disable-gutenberg-for').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields'); |
| 118 | $('.disable-gutenberg-frontend-styles').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields'); |
| 119 | $('.disable-comments').appendTo('.fields-disable-components > table > tbody'); |
| 120 | $('.disable-comments-for').appendTo('.fields-disable-components .disable-comments .asenha-subfields'); |
| 121 | $('.disable-rest-api').appendTo('.fields-disable-components > table > tbody'); |
| 122 | $('.disable-feeds').appendTo('.fields-disable-components > table > tbody'); |
| 123 | |
| 124 | // Place fields into "Security" tab |
| 125 | $('.limit-login-attempts').appendTo('.fields-security > table > tbody'); |
| 126 | $('.login-fails-allowed').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 127 | $('.login-lockout-maxcount').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 128 | $('.login-attempts-log-table').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 129 | $('.obfuscate-author-slugs').appendTo('.fields-security > table > tbody'); |
| 130 | $('.disable-xmlrpc').appendTo('.fields-security > table > tbody'); |
| 131 | |
| 132 | // Place fields into "Optimizations" tab |
| 133 | $('.enable-heartbeat-control').appendTo('.fields-optimizations > table > tbody'); |
| 134 | $('.heartbeat-control-for-admin-pages').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 135 | $('.heartbeat-interval-for-admin-pages').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 136 | $('.heartbeat-control-for-post-edit').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 137 | $('.heartbeat-interval-for-post-edit').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 138 | $('.heartbeat-control-for-frontend').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 139 | $('.heartbeat-interval-for-frontend').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 140 | |
| 141 | // Place fields into "Utilities" tab |
| 142 | $('.redirect-404-to-homepage').appendTo('.fields-utilities > table > tbody'); |
| 143 | |
| 144 | // Remove empty .form-table that originally holds the fields |
| 145 | const formTableCount = $('.form-table').length; |
| 146 | // $('.form-table')[formTableCount-1].remove(); |
| 147 | |
| 148 | // Enable Custom Admin CSS => Initialize CodeMirror |
| 149 | var adminCssTextarea = document.getElementById("admin_site_enhancements[custom_admin_css]"); |
| 150 | var adminCssEditor = CodeMirror.fromTextArea(adminCssTextarea, { |
| 151 | mode: "css", |
| 152 | lineNumbers: true, |
| 153 | lineWrapping: true |
| 154 | }); |
| 155 | |
| 156 | adminCssEditor.setSize("100%",600); |
| 157 | |
| 158 | // Enable Custom Frontend CSS => Initialize CodeMirror |
| 159 | var frontendCssTextarea = document.getElementById("admin_site_enhancements[custom_frontend_css]"); |
| 160 | var frontendCssEditor = CodeMirror.fromTextArea(frontendCssTextarea, { |
| 161 | mode: "css", |
| 162 | lineNumbers: true, |
| 163 | lineWrapping: true |
| 164 | }); |
| 165 | |
| 166 | frontendCssEditor.setSize("100%",600); |
| 167 | |
| 168 | // Manage ads.txt and app-ads.txt=> Initialize CodeMirror |
| 169 | var adsTxtTextarea = document.getElementById("admin_site_enhancements[ads_txt_content]"); |
| 170 | var adsTxtEditor = CodeMirror.fromTextArea(adsTxtTextarea, { |
| 171 | mode: "markdown", |
| 172 | lineNumbers: true, |
| 173 | lineWrapping: true |
| 174 | }); |
| 175 | |
| 176 | adsTxtEditor.setSize("100%",300); |
| 177 | |
| 178 | var appAdsTxtTextarea = document.getElementById("admin_site_enhancements[app_ads_txt_content]"); |
| 179 | var appAdsTxtEditor = CodeMirror.fromTextArea(appAdsTxtTextarea, { |
| 180 | mode: "markdown", |
| 181 | lineNumbers: true, |
| 182 | lineWrapping: true |
| 183 | }); |
| 184 | |
| 185 | appAdsTxtEditor.setSize("100%",300); |
| 186 | |
| 187 | // Manage robots.txt => Initialize CodeMirror |
| 188 | var robotsTxtTextarea = document.getElementById("admin_site_enhancements[robots_txt_content]"); |
| 189 | var robotsTxtEditor = CodeMirror.fromTextArea(robotsTxtTextarea, { |
| 190 | mode: "markdown", |
| 191 | lineNumbers: true, |
| 192 | lineWrapping: true |
| 193 | }); |
| 194 | |
| 195 | robotsTxtEditor.setSize("100%",400); |
| 196 | |
| 197 | // Insert <head>, <body> and <footer> code => Initialize CodeMirror |
| 198 | var headCodeTextarea = document.getElementById("admin_site_enhancements[head_code]"); |
| 199 | var headCodeEditor = CodeMirror.fromTextArea(headCodeTextarea, { |
| 200 | mode: "htmlmixed", |
| 201 | lineNumbers: true, |
| 202 | lineWrapping: true |
| 203 | }); |
| 204 | headCodeEditor.setSize("100%",300); |
| 205 | |
| 206 | var bodyCodeTextarea = document.getElementById("admin_site_enhancements[body_code]"); |
| 207 | var bodyCodeEditor = CodeMirror.fromTextArea(bodyCodeTextarea, { |
| 208 | mode: "htmlmixed", |
| 209 | lineNumbers: true, |
| 210 | lineWrapping: true |
| 211 | }); |
| 212 | bodyCodeEditor.setSize("100%",300); |
| 213 | |
| 214 | var footerCodeTextarea = document.getElementById("admin_site_enhancements[footer_code]"); |
| 215 | var footerCodeEditor = CodeMirror.fromTextArea(footerCodeTextarea, { |
| 216 | mode: "htmlmixed", |
| 217 | lineNumbers: true, |
| 218 | lineWrapping: true |
| 219 | }); |
| 220 | footerCodeEditor.setSize("100%",300); |
| 221 | |
| 222 | // Show and hide corresponding fields on tab clicks |
| 223 | |
| 224 | $('#tab-content-management + label').click( function() { |
| 225 | $('.fields-content-management').show(); |
| 226 | $('.asenha-fields:not(.fields-content-management)').hide(); |
| 227 | window.location.hash = 'content-management'; |
| 228 | Cookies.set('asenha_tab', 'content-management', { expires: 1 }); // expires in 1 day |
| 229 | }); |
| 230 | |
| 231 | $('#tab-admin-interface + label').click( function() { |
| 232 | $('.fields-admin-interface').show(); |
| 233 | $('.asenha-fields:not(.fields-admin-interface)').hide(); |
| 234 | window.location.hash = 'admin-interface'; |
| 235 | Cookies.set('asenha_tab', 'admin-interface', { expires: 1 }); // expires in 1 day |
| 236 | }); |
| 237 | |
| 238 | $('#tab-login-logout + label').click( function() { |
| 239 | $('.fields-login-logout').show(); |
| 240 | $('.asenha-fields:not(.fields-login-logout)').hide(); |
| 241 | window.location.hash = 'login-logout'; |
| 242 | Cookies.set('asenha_tab', 'login-logout', { expires: 1 }); // expires in 1 day |
| 243 | }); |
| 244 | |
| 245 | $('#tab-custom-code + label').click( function() { |
| 246 | $('.fields-custom-code').show(); |
| 247 | $('.asenha-fields:not(.fields-custom-code)').hide(); |
| 248 | window.location.hash = 'custom-code'; |
| 249 | Cookies.set('asenha_tab', 'custom-code', { expires: 1 }); // expires in 1 day |
| 250 | adminCssEditor.refresh(); // Custom Admin CSS >> CodeMirror |
| 251 | frontendCssEditor.refresh(); // Custom Fronend CSS >> CodeMirror |
| 252 | adsTxtEditor.refresh(); // Manage ads.txt >> CodeMirror |
| 253 | appAdsTxtEditor.refresh(); // Manage app-ads.txt >> CodeMirror |
| 254 | headCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 255 | bodyCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 256 | footerCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 257 | robotsTxtEditor.refresh(); // Manage robots.txt >> CodeMirror |
| 258 | }); |
| 259 | |
| 260 | $('#tab-disable-components + label').click( function() { |
| 261 | $('.fields-disable-components').show(); |
| 262 | $('.asenha-fields:not(.fields-disable-components)').hide(); |
| 263 | window.location.hash = 'disable-components'; |
| 264 | Cookies.set('asenha_tab', 'disable-components', { expires: 1 }); // expires in 1 day |
| 265 | }); |
| 266 | |
| 267 | $('#tab-security + label').click( function() { |
| 268 | $('.fields-security').show(); |
| 269 | $('.asenha-fields:not(.fields-security)').hide(); |
| 270 | window.location.hash = 'security'; |
| 271 | Cookies.set('asenha_tab', 'security', { expires: 1 }); // expires in 1 day |
| 272 | }); |
| 273 | |
| 274 | $('#tab-optimizations + label').click( function() { |
| 275 | $('.fields-optimizations').show(); |
| 276 | $('.asenha-fields:not(.fields-optimizations)').hide(); |
| 277 | window.location.hash = 'optimizations'; |
| 278 | Cookies.set('asenha_tab', 'optimizations', { expires: 1 }); // expires in 1 day |
| 279 | }); |
| 280 | |
| 281 | $('#tab-utilities + label').click( function() { |
| 282 | $('.fields-utilities').show(); |
| 283 | $('.asenha-fields:not(.fields-utilities)').hide(); |
| 284 | window.location.hash = 'utilities'; |
| 285 | Cookies.set('asenha_tab', 'utilities', { expires: 1 }); // expires in 1 day |
| 286 | }); |
| 287 | |
| 288 | // Open tab set in 'asenha_tab' cookie set on saving changes. Defaults to content-management tab when cookie is empty |
| 289 | var asenhaTabHash = Cookies.get('asenha_tab'); |
| 290 | |
| 291 | if (typeof asenhaTabHash === 'undefined') { |
| 292 | $('#tab-content-management + label').trigger('click'); |
| 293 | } else { |
| 294 | $('#tab-' + asenhaTabHash + ' + label').trigger('click'); |
| 295 | } |
| 296 | |
| 297 | // Enable SVG Upload => show/hide roles checkboxes on document ready |
| 298 | if ( document.getElementById('admin_site_enhancements[enable_svg_upload]').checked ) { |
| 299 | $('.enable-svg-upload .asenha-subfields').show(); |
| 300 | $('.asenha-toggle.enable-svg-upload td .asenha-field-with-options').addClass('is-enabled'); |
| 301 | } else { |
| 302 | $('.enable-svg-upload .asenha-subfields').hide(); |
| 303 | } |
| 304 | |
| 305 | // Enable SVG Upload => show/hide roles checkboxes on toggle click |
| 306 | document.getElementById('admin_site_enhancements[enable_svg_upload]').addEventListener('click', event => { |
| 307 | if (event.target.checked) { |
| 308 | $('.enable-svg-upload .asenha-subfields').fadeIn(); |
| 309 | $('.enable-svg-upload .asenha-field-with-options').toggleClass('is-enabled'); |
| 310 | } else { |
| 311 | $('.enable-svg-upload .asenha-subfields').hide(); |
| 312 | $('.enable-svg-upload .asenha-field-with-options').toggleClass('is-enabled'); |
| 313 | } |
| 314 | }); |
| 315 | |
| 316 | // Enable External Permalinks => show/hide post types checkboxes on document ready |
| 317 | if ( document.getElementById('admin_site_enhancements[enable_external_permalinks]').checked ) { |
| 318 | $('.enable-external-permalinks .asenha-subfields').show(); |
| 319 | $('.asenha-toggle.enable-external-permalinks td .asenha-field-with-options').addClass('is-enabled'); |
| 320 | } else { |
| 321 | $('.enable-external-permalinks .asenha-subfields').hide(); |
| 322 | } |
| 323 | |
| 324 | // Enable External Permalinks => show/hide post types checkboxes on toggle click |
| 325 | document.getElementById('admin_site_enhancements[enable_external_permalinks]').addEventListener('click', event => { |
| 326 | if (event.target.checked) { |
| 327 | $('.enable-external-permalinks .asenha-subfields').fadeIn(); |
| 328 | $('.enable-external-permalinks .asenha-field-with-options').toggleClass('is-enabled'); |
| 329 | } else { |
| 330 | $('.enable-external-permalinks .asenha-subfields').hide(); |
| 331 | $('.enable-external-permalinks .asenha-field-with-options').toggleClass('is-enabled'); |
| 332 | } |
| 333 | }); |
| 334 | |
| 335 | // Enable Revisions Control => show/hide roles checkboxes on document ready |
| 336 | if ( document.getElementById('admin_site_enhancements[enable_revisions_control]').checked ) { |
| 337 | $('.enable-revisions-control .asenha-subfields').show(); |
| 338 | $('.asenha-toggle.enable-revisions-control td .asenha-field-with-options').addClass('is-enabled'); |
| 339 | } else { |
| 340 | $('.enable-revisions-control .asenha-subfields').hide(); |
| 341 | } |
| 342 | |
| 343 | // Enable SVG Upload => show/hide roles checkboxes on toggle click |
| 344 | document.getElementById('admin_site_enhancements[enable_revisions_control]').addEventListener('click', event => { |
| 345 | if (event.target.checked) { |
| 346 | $('.enable-revisions-control .asenha-subfields').fadeIn(); |
| 347 | $('.enable-revisions-control .asenha-field-with-options').toggleClass('is-enabled'); |
| 348 | } else { |
| 349 | $('.enable-revisions-control .asenha-subfields').hide(); |
| 350 | $('.enable-revisions-control .asenha-field-with-options').toggleClass('is-enabled'); |
| 351 | } |
| 352 | }); |
| 353 | |
| 354 | // Enhance List Tables => show/hide subfields on document ready |
| 355 | if ( document.getElementById('admin_site_enhancements[enhance_list_tables]').checked ) { |
| 356 | $('.enhance-list-tables .asenha-subfields').show(); |
| 357 | $('.asenha-toggle.enhance-list-tables td .asenha-field-with-options').addClass('is-enabled'); |
| 358 | } else { |
| 359 | $('.enhance-list-tables .asenha-subfields').hide(); |
| 360 | } |
| 361 | |
| 362 | // Enhance List Tables => show/hide subfields on toggle click |
| 363 | document.getElementById('admin_site_enhancements[enhance_list_tables]').addEventListener('click', event => { |
| 364 | if (event.target.checked) { |
| 365 | $('.enhance-list-tables .asenha-subfields').fadeIn(); |
| 366 | $('.enhance-list-tables .asenha-field-with-options').toggleClass('is-enabled'); |
| 367 | } else { |
| 368 | $('.enhance-list-tables .asenha-subfields').hide(); |
| 369 | $('.enhance-list-tables .asenha-field-with-options').toggleClass('is-enabled'); |
| 370 | } |
| 371 | }); |
| 372 | |
| 373 | // Hide Admin Bar => show/hide roles checkboxes on document ready |
| 374 | if ( document.getElementById('admin_site_enhancements[hide_admin_bar]').checked ) { |
| 375 | $('.hide-admin-bar .asenha-subfields').show(); |
| 376 | $('.asenha-toggle.hide-admin-bar td .asenha-field-with-options').addClass('is-enabled'); |
| 377 | } else { |
| 378 | $('.hide-admin-bar .asenha-subfields').hide(); |
| 379 | } |
| 380 | |
| 381 | // Hide Admin Bar => show/hide roles checkboxes on toggle click |
| 382 | document.getElementById('admin_site_enhancements[hide_admin_bar]').addEventListener('click', event => { |
| 383 | if (event.target.checked) { |
| 384 | $('.hide-admin-bar .asenha-subfields').fadeIn(); |
| 385 | $('.hide-admin-bar .asenha-field-with-options').toggleClass('is-enabled'); |
| 386 | } else { |
| 387 | $('.hide-admin-bar .asenha-subfields').hide(); |
| 388 | $('.hide-admin-bar .asenha-field-with-options').toggleClass('is-enabled'); |
| 389 | } |
| 390 | }); |
| 391 | |
| 392 | // Hide or Modify Elements => show/hide subfields on document ready |
| 393 | if ( document.getElementById('admin_site_enhancements[hide_modify_elements]').checked ) { |
| 394 | $('.hide-modify-elements .asenha-subfields').show(); |
| 395 | $('.asenha-toggle.hide-modify-elements td .asenha-field-with-options').addClass('is-enabled'); |
| 396 | } else { |
| 397 | $('.hide-modify-elements .asenha-subfields').hide(); |
| 398 | } |
| 399 | |
| 400 | // Hide or Modify Elements => show/hide subfields on toggle click |
| 401 | document.getElementById('admin_site_enhancements[hide_modify_elements]').addEventListener('click', event => { |
| 402 | if (event.target.checked) { |
| 403 | $('.hide-modify-elements .asenha-subfields').fadeIn(); |
| 404 | $('.hide-modify-elements .asenha-field-with-options').toggleClass('is-enabled'); |
| 405 | } else { |
| 406 | $('.hide-modify-elements .asenha-subfields').hide(); |
| 407 | $('.hide-modify-elements .asenha-field-with-options').toggleClass('is-enabled'); |
| 408 | } |
| 409 | }); |
| 410 | |
| 411 | // Customize Admin Menu => show/hide subfields on document ready |
| 412 | if ( document.getElementById('admin_site_enhancements[customize_admin_menu]').checked ) { |
| 413 | $('.customize-admin-menu .asenha-subfields').show(); |
| 414 | $('.asenha-toggle.customize-admin-menu td .asenha-field-with-options').addClass('is-enabled'); |
| 415 | } else { |
| 416 | $('.customize-admin-menu .asenha-subfields').hide(); |
| 417 | } |
| 418 | |
| 419 | // Customize Admin Menu => show/hide subfields on toggle click |
| 420 | document.getElementById('admin_site_enhancements[customize_admin_menu]').addEventListener('click', event => { |
| 421 | if (event.target.checked) { |
| 422 | $('.customize-admin-menu .asenha-subfields').fadeIn(); |
| 423 | $('.customize-admin-menu .asenha-field-with-options').toggleClass('is-enabled'); |
| 424 | |
| 425 | // Initialize sortable elements: https://api.jqueryui.com/sortable/ |
| 426 | $('#custom-admin-menu').sortable(); |
| 427 | |
| 428 | } else { |
| 429 | $('.customize-admin-menu .asenha-subfields').hide(); |
| 430 | $('.customize-admin-menu .asenha-field-with-options').toggleClass('is-enabled'); |
| 431 | } |
| 432 | }); |
| 433 | |
| 434 | // Disable Gutenberg => show/hide post type checkboxes on document ready |
| 435 | if ( document.getElementById('admin_site_enhancements[disable_gutenberg]').checked ) { |
| 436 | $('.disable-gutenberg .asenha-subfields').show(); |
| 437 | $('.asenha-toggle.disable-gutenberg td .asenha-field-with-options').addClass('is-enabled'); |
| 438 | } else { |
| 439 | $('.disable-gutenberg .asenha-subfields').hide(); |
| 440 | } |
| 441 | |
| 442 | // Disable Gutenberg => show/hide post type checkboxes on toggle click |
| 443 | document.getElementById('admin_site_enhancements[disable_gutenberg]').addEventListener('click', event => { |
| 444 | if (event.target.checked) { |
| 445 | $('.disable-gutenberg .asenha-subfields').fadeIn(); |
| 446 | $('.disable-gutenberg .asenha-field-with-options').toggleClass('is-enabled'); |
| 447 | } else { |
| 448 | $('.disable-gutenberg .asenha-subfields').hide(); |
| 449 | $('.disable-gutenberg .asenha-field-with-options').toggleClass('is-enabled'); |
| 450 | } |
| 451 | }); |
| 452 | |
| 453 | // Disable Comments => show/hide post type checkboxes on document ready |
| 454 | if ( document.getElementById('admin_site_enhancements[disable_comments]').checked ) { |
| 455 | $('.disable-comments .asenha-subfields').show(); |
| 456 | $('.asenha-toggle.disable-comments td .asenha-field-with-options').addClass('is-enabled'); |
| 457 | } else { |
| 458 | $('.disable-comments .asenha-subfields').hide(); |
| 459 | } |
| 460 | |
| 461 | // Disable Comments => show/hide post type checkboxes on toggle click |
| 462 | document.getElementById('admin_site_enhancements[disable_comments]').addEventListener('click', event => { |
| 463 | if (event.target.checked) { |
| 464 | $('.disable-comments .asenha-subfields').fadeIn(); |
| 465 | $('.disable-comments .asenha-field-with-options').toggleClass('is-enabled'); |
| 466 | } else { |
| 467 | $('.disable-comments .asenha-subfields').hide(); |
| 468 | $('.disable-comments .asenha-field-with-options').toggleClass('is-enabled'); |
| 469 | } |
| 470 | }); |
| 471 | |
| 472 | // Change Login URL => show/hide custom slug input on document ready |
| 473 | if ( document.getElementById('admin_site_enhancements[change_login_url]').checked ) { |
| 474 | $('.change-login-url .asenha-subfields').show(); |
| 475 | $('.asenha-toggle.change-login-url td .asenha-field-with-options').addClass('is-enabled'); |
| 476 | } else { |
| 477 | $('.change-login-url .asenha-subfields').hide(); |
| 478 | } |
| 479 | |
| 480 | // Change Login URL => show/hide custom slug input on toggle click |
| 481 | document.getElementById('admin_site_enhancements[change_login_url]').addEventListener('click', event => { |
| 482 | if (event.target.checked) { |
| 483 | $('.change-login-url .asenha-subfields').fadeIn(); |
| 484 | $('.change-login-url .asenha-field-with-options').toggleClass('is-enabled'); |
| 485 | } else { |
| 486 | $('.change-login-url .asenha-subfields').hide(); |
| 487 | $('.change-login-url .asenha-field-with-options').toggleClass('is-enabled'); |
| 488 | } |
| 489 | }); |
| 490 | |
| 491 | // Limit Login Attempts => show/hide custom slug input on document ready |
| 492 | if ( document.getElementById('admin_site_enhancements[limit_login_attempts]').checked ) { |
| 493 | $('.limit-login-attempts .asenha-subfields').show(); |
| 494 | $('.asenha-toggle.limit-login-attempts td .asenha-field-with-options').addClass('is-enabled'); |
| 495 | } else { |
| 496 | $('.limit-login-attempts .asenha-subfields').hide(); |
| 497 | } |
| 498 | |
| 499 | // Limit Login Attempts => show/hide custom slug input on toggle click |
| 500 | document.getElementById('admin_site_enhancements[limit_login_attempts]').addEventListener('click', event => { |
| 501 | if (event.target.checked) { |
| 502 | $('.limit-login-attempts .asenha-subfields').fadeIn(); |
| 503 | $('.limit-login-attempts .asenha-field-with-options').toggleClass('is-enabled'); |
| 504 | } else { |
| 505 | $('.limit-login-attempts .asenha-subfields').hide(); |
| 506 | $('.limit-login-attempts .asenha-field-with-options').toggleClass('is-enabled'); |
| 507 | } |
| 508 | }); |
| 509 | // Redirect After Login => show/hide roles checkboxes on document ready |
| 510 | if ( document.getElementById('admin_site_enhancements[redirect_after_login]').checked ) { |
| 511 | $('.redirect-after-login .asenha-subfields').show(); |
| 512 | $('.asenha-toggle.redirect-after-login td .asenha-field-with-options').addClass('is-enabled'); |
| 513 | } else { |
| 514 | $('.redirect-after-login .asenha-subfields').hide(); |
| 515 | } |
| 516 | |
| 517 | // Redirect After Login => show/hide roles checkboxes on toggle click |
| 518 | document.getElementById('admin_site_enhancements[redirect_after_login]').addEventListener('click', event => { |
| 519 | if (event.target.checked) { |
| 520 | $('.redirect-after-login .asenha-subfields').fadeIn(); |
| 521 | $('.redirect-after-login .asenha-field-with-options').toggleClass('is-enabled'); |
| 522 | } else { |
| 523 | $('.redirect-after-login .asenha-subfields').hide(); |
| 524 | $('.redirect-after-login .asenha-field-with-options').toggleClass('is-enabled'); |
| 525 | } |
| 526 | }); |
| 527 | |
| 528 | // Redirect After Logout => show/hide roles checkboxes on document ready |
| 529 | if ( document.getElementById('admin_site_enhancements[redirect_after_logout]').checked ) { |
| 530 | $('.redirect-after-logout .asenha-subfields').show(); |
| 531 | $('.asenha-toggle.redirect-after-logout td .asenha-field-with-options').addClass('is-enabled'); |
| 532 | } else { |
| 533 | $('.redirect-after-logout .asenha-subfields').hide(); |
| 534 | } |
| 535 | |
| 536 | // Redirect After Logout => show/hide roles checkboxes on toggle click |
| 537 | document.getElementById('admin_site_enhancements[redirect_after_logout]').addEventListener('click', event => { |
| 538 | if (event.target.checked) { |
| 539 | $('.redirect-after-logout .asenha-subfields').fadeIn(); |
| 540 | $('.redirect-after-logout .asenha-field-with-options').toggleClass('is-enabled'); |
| 541 | } else { |
| 542 | $('.redirect-after-logout .asenha-subfields').hide(); |
| 543 | $('.redirect-after-logout .asenha-field-with-options').toggleClass('is-enabled'); |
| 544 | } |
| 545 | }); |
| 546 | |
| 547 | // Enable Custom Admin CSS => show/hide CSS textarea on document ready |
| 548 | if ( document.getElementById('admin_site_enhancements[enable_custom_admin_css]').checked ) { |
| 549 | $('.enable-custom-admin-css .asenha-subfields').show(); |
| 550 | $('.asenha-toggle.enable-custom-admin-css td .asenha-field-with-options').addClass('is-enabled'); |
| 551 | adminCssEditor.refresh(); |
| 552 | } else { |
| 553 | $('.enable-custom-admin-css .asenha-subfields').hide(); |
| 554 | } |
| 555 | |
| 556 | // Enable Custom Admin CSS => show/hide CSS textarea on toggle click |
| 557 | document.getElementById('admin_site_enhancements[enable_custom_admin_css]').addEventListener('click', event => { |
| 558 | if (event.target.checked) { |
| 559 | $('.enable-custom-admin-css .asenha-subfields').fadeIn(); |
| 560 | $('.enable-custom-admin-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 561 | adminCssEditor.refresh(); |
| 562 | } else { |
| 563 | $('.enable-custom-admin-css .asenha-subfields').hide(); |
| 564 | $('.enable-custom-admin-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 565 | } |
| 566 | }); |
| 567 | |
| 568 | // Enable Custom Frontend CSS => show/hide CSS textarea on document ready |
| 569 | if ( document.getElementById('admin_site_enhancements[enable_custom_frontend_css]').checked ) { |
| 570 | $('.enable-custom-frontend-css .asenha-subfields').show(); |
| 571 | $('.asenha-toggle.enable-custom-frontend-css td .asenha-field-with-options').addClass('is-enabled'); |
| 572 | frontendCssEditor.refresh(); |
| 573 | } else { |
| 574 | $('.enable-custom-frontend-css .asenha-subfields').hide(); |
| 575 | } |
| 576 | |
| 577 | // Enable Custom Frontend CSS => show/hide CSS textarea on toggle click |
| 578 | document.getElementById('admin_site_enhancements[enable_custom_frontend_css]').addEventListener('click', event => { |
| 579 | if (event.target.checked) { |
| 580 | $('.enable-custom-frontend-css .asenha-subfields').fadeIn(); |
| 581 | $('.enable-custom-frontend-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 582 | frontendCssEditor.refresh(); |
| 583 | } else { |
| 584 | $('.enable-custom-frontend-css .asenha-subfields').hide(); |
| 585 | $('.enable-custom-frontend-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 586 | } |
| 587 | }); |
| 588 | |
| 589 | // Manage ads.txt and app-ads.txt => show/hide CodeMirror textarea on document ready |
| 590 | if ( document.getElementById('admin_site_enhancements[manage_ads_appads_txt]').checked ) { |
| 591 | $('.manage-ads-appads-txt .asenha-subfields').show(); |
| 592 | $('.asenha-toggle.manage-ads-appads-txt td .asenha-field-with-options').addClass('is-enabled'); |
| 593 | adsTxtEditor.refresh(); |
| 594 | appAdsTxtEditor.refresh(); |
| 595 | } else { |
| 596 | $('.manage-ads-appads-txt .asenha-subfields').hide(); |
| 597 | } |
| 598 | |
| 599 | // Manage ads.txt and app-ads.txt => show/hide CodeMirror textarea on toggle click |
| 600 | document.getElementById('admin_site_enhancements[manage_ads_appads_txt]').addEventListener('click', event => { |
| 601 | if (event.target.checked) { |
| 602 | $('.manage-ads-appads-txt .asenha-subfields').fadeIn(); |
| 603 | $('.manage-ads-appads-txt .asenha-field-with-options').toggleClass('is-enabled'); |
| 604 | adsTxtEditor.refresh(); |
| 605 | appAdsTxtEditor.refresh(); |
| 606 | } else { |
| 607 | $('.manage-ads-appads-txt .asenha-subfields').hide(); |
| 608 | $('.manage-ads-appads-txt .asenha-field-with-options').toggleClass('is-enabled'); |
| 609 | } |
| 610 | }); |
| 611 | |
| 612 | // Manage ads.txt and app-ads.txt => show/hide CodeMirror textarea on document ready |
| 613 | if ( document.getElementById('admin_site_enhancements[manage_robots_txt]').checked ) { |
| 614 | $('.manage-robots-txt .asenha-subfields').show(); |
| 615 | $('.asenha-toggle.manage-robots-txt td .asenha-field-with-options').addClass('is-enabled'); |
| 616 | robotsTxtEditor.refresh(); |
| 617 | } else { |
| 618 | $('.manage-robots-txt .asenha-subfields').hide(); |
| 619 | } |
| 620 | |
| 621 | // Manage ads.txt and app-ads.txt => show/hide CodeMirror textarea on toggle click |
| 622 | document.getElementById('admin_site_enhancements[manage_robots_txt]').addEventListener('click', event => { |
| 623 | if (event.target.checked) { |
| 624 | $('.manage-robots-txt .asenha-subfields').fadeIn(); |
| 625 | $('.manage-robots-txt .asenha-field-with-options').toggleClass('is-enabled'); |
| 626 | robotsTxtEditor.refresh(); |
| 627 | } else { |
| 628 | $('.manage-robots-txt .asenha-subfields').hide(); |
| 629 | $('.manage-robots-txt .asenha-field-with-options').toggleClass('is-enabled'); |
| 630 | } |
| 631 | }); |
| 632 | |
| 633 | // Insert <head>, <body> and <footer> code => show/hide CSS textarea on document ready |
| 634 | if ( document.getElementById('admin_site_enhancements[insert_head_body_footer_code]').checked ) { |
| 635 | $('.insert-head-body-footer-code .asenha-subfields').show(); |
| 636 | $('.asenha-toggle.insert-head-body-footer-code td .asenha-field-with-options').addClass('is-enabled'); |
| 637 | headCodeEditor.refresh(); |
| 638 | bodyCodeEditor.refresh(); |
| 639 | footerCodeEditor.refresh(); |
| 640 | } else { |
| 641 | $('.manage-app-ads-txt .asenha-subfields').hide(); |
| 642 | } |
| 643 | |
| 644 | // Insert <head>, <body> and <footer> code => show/hide CSS textarea on toggle click |
| 645 | document.getElementById('admin_site_enhancements[insert_head_body_footer_code]').addEventListener('click', event => { |
| 646 | if (event.target.checked) { |
| 647 | $('.insert-head-body-footer-code .asenha-subfields').fadeIn(); |
| 648 | $('.insert-head-body-footer-code .asenha-field-with-options').toggleClass('is-enabled'); |
| 649 | headCodeEditor.refresh(); |
| 650 | bodyCodeEditor.refresh(); |
| 651 | footerCodeEditor.refresh(); |
| 652 | } else { |
| 653 | $('.insert-head-body-footer-code .asenha-subfields').hide(); |
| 654 | $('.insert-head-body-footer-code .asenha-field-with-options').toggleClass('is-enabled'); |
| 655 | } |
| 656 | }); |
| 657 | |
| 658 | // Enable Heartbeat Control => show/hide subfields on document ready |
| 659 | if ( document.getElementById('admin_site_enhancements[enable_heartbeat_control]').checked ) { |
| 660 | $('.enable-heartbeat-control .asenha-subfields').show(); |
| 661 | $('.asenha-toggle.enable-heartbeat-control td .asenha-field-with-options').addClass('is-enabled'); |
| 662 | } else { |
| 663 | $('.enable-heartbeat-control .asenha-subfields').hide(); |
| 664 | } |
| 665 | |
| 666 | // Enable Heartbeat Control => show/hide subfields on toggle click |
| 667 | document.getElementById('admin_site_enhancements[enable_heartbeat_control]').addEventListener('click', event => { |
| 668 | if (event.target.checked) { |
| 669 | $('.enable-heartbeat-control .asenha-subfields').fadeIn(); |
| 670 | $('.enable-heartbeat-control .asenha-field-with-options').toggleClass('is-enabled'); |
| 671 | } else { |
| 672 | $('.enable-heartbeat-control .asenha-subfields').hide(); |
| 673 | $('.enable-heartbeat-control .asenha-field-with-options').toggleClass('is-enabled'); |
| 674 | } |
| 675 | }); |
| 676 | |
| 677 | // Enable Heartbeat Control => Check if "Modify interval" is chosen/clicked and show/hide the corresponding select field |
| 678 | if ( $('input[name="admin_site_enhancements[heartbeat_control_for_admin_pages]"]:checked').val() == 'modify' ) { |
| 679 | $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').show(); |
| 680 | } |
| 681 | $('input[name="admin_site_enhancements[heartbeat_control_for_admin_pages]"]').click(function() { |
| 682 | var radioValue = $(this).attr('value'); |
| 683 | if ( radioValue == 'modify' ) { |
| 684 | $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').show(); |
| 685 | } else { |
| 686 | $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').hide(); |
| 687 | } |
| 688 | }); |
| 689 | |
| 690 | if ( $('input[name="admin_site_enhancements[heartbeat_control_for_post_edit]"]:checked').val() == 'modify' ) { |
| 691 | $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').show(); |
| 692 | } |
| 693 | $('input[name="admin_site_enhancements[heartbeat_control_for_post_edit]"]').click(function() { |
| 694 | var radioValue = $(this).attr('value'); |
| 695 | if ( radioValue == 'modify' ) { |
| 696 | $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').show(); |
| 697 | } else { |
| 698 | $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').hide(); |
| 699 | } |
| 700 | }); |
| 701 | |
| 702 | if ( $('input[name="admin_site_enhancements[heartbeat_control_for_frontend]"]:checked').val() == 'modify' ) { |
| 703 | $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').show(); |
| 704 | } |
| 705 | $('input[name="admin_site_enhancements[heartbeat_control_for_frontend]"]').click(function() { |
| 706 | var radioValue = $(this).attr('value'); |
| 707 | if ( radioValue == 'modify' ) { |
| 708 | $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').show(); |
| 709 | } else { |
| 710 | $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').hide(); |
| 711 | } |
| 712 | }); |
| 713 | |
| 714 | }); |
| 715 | |
| 716 | })( jQuery ); |