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
toggle-hidden-menu.js
3 years ago
admin-page.js
550 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-missed-schedule-posts-auto-publish').appendTo('.fields-content-management > table > tbody'); |
| 57 | $('.enhance-list-tables').appendTo('.fields-content-management > table > tbody'); |
| 58 | $('.show-featured-image-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 59 | $('.show-excerpt-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 60 | $('.show-id-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 61 | $('.hide-comments-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 62 | $('.hide-post-tags-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 63 | $('.show-custom-taxonomy-filters').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 64 | |
| 65 | // Place fields into "Admin Interface" tab |
| 66 | $('.hide-admin-notices').appendTo('.fields-admin-interface > table > tbody'); |
| 67 | $('.view-admin-as-role').appendTo('.fields-admin-interface > table > tbody'); |
| 68 | $('.customize-admin-menu').appendTo('.fields-admin-interface > table > tbody'); |
| 69 | $('.custom-menu-order').appendTo('.fields-admin-interface .customize-admin-menu .asenha-subfields'); |
| 70 | $('.hide-modify-elements').appendTo('.fields-admin-interface > table > tbody'); |
| 71 | $('.hide-ab-wp-logo-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 72 | $('.hide-ab-customize-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 73 | $('.hide-ab-updates-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 74 | $('.hide-ab-comments-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 75 | $('.hide-ab-new-content-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 76 | $('.hide-ab-howdy').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 77 | $('.hide-admin-bar').appendTo('.fields-admin-interface > table > tbody'); |
| 78 | $('.hide-admin-bar-for').appendTo('.fields-admin-interface .hide-admin-bar .asenha-subfields'); |
| 79 | |
| 80 | // Place fields into the "Disable Components" tab |
| 81 | $('.disable-gutenberg').appendTo('.fields-disable-components > table > tbody'); |
| 82 | $('.disable-gutenberg-for').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields'); |
| 83 | $('.disable-gutenberg-frontend-styles').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields'); |
| 84 | $('.disable-comments').appendTo('.fields-disable-components > table > tbody'); |
| 85 | $('.disable-comments-for').appendTo('.fields-disable-components .disable-comments .asenha-subfields'); |
| 86 | $('.disable-rest-api').appendTo('.fields-disable-components > table > tbody'); |
| 87 | $('.disable-feeds').appendTo('.fields-disable-components > table > tbody'); |
| 88 | |
| 89 | // Place fields into "Security" tab |
| 90 | $('.change-login-url').appendTo('.fields-security > table > tbody'); |
| 91 | $('.custom-login-slug').appendTo('.fields-security .change-login-url .asenha-subfields'); |
| 92 | $('.limit-login-attempts').appendTo('.fields-security > table > tbody'); |
| 93 | $('.login-fails-allowed').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 94 | $('.login-lockout-maxcount').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 95 | $('.login-attempts-log-table').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 96 | $('.obfuscate-author-slugs').appendTo('.fields-security > table > tbody'); |
| 97 | $('.disable-xmlrpc').appendTo('.fields-security > table > tbody'); |
| 98 | |
| 99 | // Place fields into "Utilities" tab |
| 100 | $('.enable-custom-admin-css').appendTo('.fields-utilities > table > tbody'); |
| 101 | $('.custom-admin-css').appendTo('.fields-utilities .enable-custom-admin-css .asenha-subfields'); |
| 102 | $('.enable-custom-frontend-css').appendTo('.fields-utilities > table > tbody'); |
| 103 | $('.custom-frontend-css').appendTo('.fields-utilities .enable-custom-frontend-css .asenha-subfields'); |
| 104 | $('.insert-head-body-footer-code').appendTo('.fields-utilities > table > tbody'); |
| 105 | $('.head-code-priority').appendTo('.fields-utilities .insert-head-body-footer-code .asenha-subfields'); |
| 106 | $('.head-code').appendTo('.fields-utilities .insert-head-body-footer-code .asenha-subfields'); |
| 107 | $('.body-code-priority').appendTo('.fields-utilities .insert-head-body-footer-code .asenha-subfields'); |
| 108 | $('.body-code').appendTo('.fields-utilities .insert-head-body-footer-code .asenha-subfields'); |
| 109 | $('.footer-code-priority').appendTo('.fields-utilities .insert-head-body-footer-code .asenha-subfields'); |
| 110 | $('.footer-code').appendTo('.fields-utilities .insert-head-body-footer-code .asenha-subfields'); |
| 111 | $('.manage-ads-appads-txt').appendTo('.fields-utilities > table > tbody'); |
| 112 | $('.ads-txt-content').appendTo('.fields-utilities .manage-ads-appads-txt .asenha-subfields'); |
| 113 | $('.app-ads-txt-content').appendTo('.fields-utilities .manage-ads-appads-txt .asenha-subfields'); |
| 114 | $('.enable-login-logout-menu').appendTo('.fields-utilities > table > tbody'); |
| 115 | $('.redirect-after-login').appendTo('.fields-utilities > table > tbody'); |
| 116 | $('.redirect-after-login-to-slug').appendTo('.fields-utilities .redirect-after-login .asenha-subfields'); |
| 117 | $('.redirect-after-login-for').appendTo('.fields-utilities .redirect-after-login .asenha-subfields'); |
| 118 | $('.redirect-after-logout').appendTo('.fields-utilities > table > tbody'); |
| 119 | $('.redirect-after-logout-to-slug').appendTo('.fields-utilities .redirect-after-logout .asenha-subfields'); |
| 120 | $('.redirect-after-logout-for').appendTo('.fields-utilities .redirect-after-logout .asenha-subfields'); |
| 121 | $('.redirect-404-to-homepage').appendTo('.fields-utilities > table > tbody'); |
| 122 | |
| 123 | // Remove empty .form-table that originally holds the fields |
| 124 | const formTableCount = $('.form-table').length; |
| 125 | // $('.form-table')[formTableCount-1].remove(); |
| 126 | |
| 127 | // Enable Custom Admin CSS => Initialize CodeMirror |
| 128 | var adminCssTextarea = document.getElementById("admin_site_enhancements[custom_admin_css]"); |
| 129 | var adminCssEditor = CodeMirror.fromTextArea(adminCssTextarea, { |
| 130 | mode: "css", |
| 131 | lineNumbers: true, |
| 132 | lineWrapping: true |
| 133 | }); |
| 134 | |
| 135 | adminCssEditor.setSize("100%",600); |
| 136 | |
| 137 | // Enable Custom Frontend CSS => Initialize CodeMirror |
| 138 | var frontendCssTextarea = document.getElementById("admin_site_enhancements[custom_frontend_css]"); |
| 139 | var frontendCssEditor = CodeMirror.fromTextArea(frontendCssTextarea, { |
| 140 | mode: "css", |
| 141 | lineNumbers: true, |
| 142 | lineWrapping: true |
| 143 | }); |
| 144 | |
| 145 | frontendCssEditor.setSize("100%",600); |
| 146 | |
| 147 | // Manage ads.txt => Initialize CodeMirror |
| 148 | var adsTxtTextarea = document.getElementById("admin_site_enhancements[ads_txt_content]"); |
| 149 | var adsTxtEditor = CodeMirror.fromTextArea(adsTxtTextarea, { |
| 150 | mode: "markdown", |
| 151 | lineNumbers: true, |
| 152 | lineWrapping: true |
| 153 | }); |
| 154 | |
| 155 | adsTxtEditor.setSize("100%",300); |
| 156 | |
| 157 | // Manage app-ads.txt => Initialize CodeMirror |
| 158 | var appAdsTxtTextarea = document.getElementById("admin_site_enhancements[app_ads_txt_content]"); |
| 159 | var appAdsTxtEditor = CodeMirror.fromTextArea(appAdsTxtTextarea, { |
| 160 | mode: "markdown", |
| 161 | lineNumbers: true, |
| 162 | lineWrapping: true |
| 163 | }); |
| 164 | |
| 165 | appAdsTxtEditor.setSize("100%",300); |
| 166 | |
| 167 | // Insert <head>, <body> and <footer> code => Initialize CodeMirror |
| 168 | var headCodeTextarea = document.getElementById("admin_site_enhancements[head_code]"); |
| 169 | var headCodeEditor = CodeMirror.fromTextArea(headCodeTextarea, { |
| 170 | mode: "htmlmixed", |
| 171 | lineNumbers: true, |
| 172 | lineWrapping: true |
| 173 | }); |
| 174 | headCodeEditor.setSize("100%",300); |
| 175 | |
| 176 | var bodyCodeTextarea = document.getElementById("admin_site_enhancements[body_code]"); |
| 177 | var bodyCodeEditor = CodeMirror.fromTextArea(bodyCodeTextarea, { |
| 178 | mode: "htmlmixed", |
| 179 | lineNumbers: true, |
| 180 | lineWrapping: true |
| 181 | }); |
| 182 | bodyCodeEditor.setSize("100%",300); |
| 183 | |
| 184 | var footerCodeTextarea = document.getElementById("admin_site_enhancements[footer_code]"); |
| 185 | var footerCodeEditor = CodeMirror.fromTextArea(footerCodeTextarea, { |
| 186 | mode: "htmlmixed", |
| 187 | lineNumbers: true, |
| 188 | lineWrapping: true |
| 189 | }); |
| 190 | footerCodeEditor.setSize("100%",300); |
| 191 | |
| 192 | // Show and hide corresponding fields on tab clicks |
| 193 | |
| 194 | $('#tab-content-management + label').click( function() { |
| 195 | $('.fields-content-management').show(); |
| 196 | $('.asenha-fields:not(.fields-content-management)').hide(); |
| 197 | window.location.hash = 'content-management'; |
| 198 | Cookies.set('asenha_tab', 'content-management', { expires: 1 }); // expires in 1 day |
| 199 | }); |
| 200 | |
| 201 | $('#tab-admin-interface + label').click( function() { |
| 202 | $('.fields-admin-interface').show(); |
| 203 | $('.asenha-fields:not(.fields-admin-interface)').hide(); |
| 204 | window.location.hash = 'admin-interface'; |
| 205 | Cookies.set('asenha_tab', 'admin-interface', { expires: 1 }); // expires in 1 day |
| 206 | }); |
| 207 | |
| 208 | $('#tab-disable-components + label').click( function() { |
| 209 | $('.fields-disable-components').show(); |
| 210 | $('.asenha-fields:not(.fields-disable-components)').hide(); |
| 211 | window.location.hash = 'disable-components'; |
| 212 | Cookies.set('asenha_tab', 'disable-components', { expires: 1 }); // expires in 1 day |
| 213 | }); |
| 214 | |
| 215 | $('#tab-security + label').click( function() { |
| 216 | $('.fields-security').show(); |
| 217 | $('.asenha-fields:not(.fields-security)').hide(); |
| 218 | window.location.hash = 'security'; |
| 219 | Cookies.set('asenha_tab', 'security', { expires: 1 }); // expires in 1 day |
| 220 | }); |
| 221 | |
| 222 | $('#tab-utilities + label').click( function() { |
| 223 | $('.fields-utilities').show(); |
| 224 | $('.asenha-fields:not(.fields-utilities)').hide(); |
| 225 | window.location.hash = 'utilities'; |
| 226 | Cookies.set('asenha_tab', 'utilities', { expires: 1 }); // expires in 1 day |
| 227 | adminCssEditor.refresh(); // Custom Admin CSS >> CodeMirror |
| 228 | frontendCssEditor.refresh(); // Custom Fronend CSS >> CodeMirror |
| 229 | adsTxtEditor.refresh(); // Manage ads.txt >> CodeMirror |
| 230 | appAdsTxtEditor.refresh(); // Manage app-ads.txt >> CodeMirror |
| 231 | headCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 232 | bodyCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 233 | footerCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 234 | }); |
| 235 | |
| 236 | // Open tab set in 'asenha_tab' cookie set on saving changes. Defaults to content-management tab when cookie is empty |
| 237 | var asenhaTabHash = Cookies.get('asenha_tab'); |
| 238 | |
| 239 | if (typeof asenhaTabHash === 'undefined') { |
| 240 | $('#tab-content-management + label').trigger('click'); |
| 241 | } else { |
| 242 | $('#tab-' + asenhaTabHash + ' + label').trigger('click'); |
| 243 | } |
| 244 | |
| 245 | // Enable SVG Upload => show/hide roles checkboxes on document ready |
| 246 | if ( document.getElementById('admin_site_enhancements[enable_svg_upload]').checked ) { |
| 247 | $('.enable-svg-upload .asenha-subfields').show(); |
| 248 | $('.asenha-toggle.enable-svg-upload td .asenha-field-with-options').addClass('is-enabled'); |
| 249 | } else { |
| 250 | $('.enable-svg-upload .asenha-subfields').hide(); |
| 251 | } |
| 252 | |
| 253 | // Enable SVG Upload => show/hide roles checkboxes on toggle click |
| 254 | document.getElementById('admin_site_enhancements[enable_svg_upload]').addEventListener('click', event => { |
| 255 | if (event.target.checked) { |
| 256 | $('.enable-svg-upload .asenha-subfields').fadeIn(); |
| 257 | $('.enable-svg-upload .asenha-field-with-options').toggleClass('is-enabled'); |
| 258 | } else { |
| 259 | $('.enable-svg-upload .asenha-subfields').hide(); |
| 260 | $('.enable-svg-upload .asenha-field-with-options').toggleClass('is-enabled'); |
| 261 | } |
| 262 | }); |
| 263 | |
| 264 | |
| 265 | // Enhance List Tables => show/hide subfields on document ready |
| 266 | if ( document.getElementById('admin_site_enhancements[enhance_list_tables]').checked ) { |
| 267 | $('.enhance-list-tables .asenha-subfields').show(); |
| 268 | $('.asenha-toggle.enhance-list-tables td .asenha-field-with-options').addClass('is-enabled'); |
| 269 | } else { |
| 270 | $('.enhance-list-tables .asenha-subfields').hide(); |
| 271 | } |
| 272 | |
| 273 | // Enhance List Tables => show/hide subfields on toggle click |
| 274 | document.getElementById('admin_site_enhancements[enhance_list_tables]').addEventListener('click', event => { |
| 275 | if (event.target.checked) { |
| 276 | $('.enhance-list-tables .asenha-subfields').fadeIn(); |
| 277 | $('.enhance-list-tables .asenha-field-with-options').toggleClass('is-enabled'); |
| 278 | } else { |
| 279 | $('.enhance-list-tables .asenha-subfields').hide(); |
| 280 | $('.enhance-list-tables .asenha-field-with-options').toggleClass('is-enabled'); |
| 281 | } |
| 282 | }); |
| 283 | |
| 284 | // Hide Admin Bar => show/hide roles checkboxes on document ready |
| 285 | if ( document.getElementById('admin_site_enhancements[hide_admin_bar]').checked ) { |
| 286 | $('.hide-admin-bar .asenha-subfields').show(); |
| 287 | $('.asenha-toggle.hide-admin-bar td .asenha-field-with-options').addClass('is-enabled'); |
| 288 | } else { |
| 289 | $('.hide-admin-bar .asenha-subfields').hide(); |
| 290 | } |
| 291 | |
| 292 | // Hide Admin Bar => show/hide roles checkboxes on toggle click |
| 293 | document.getElementById('admin_site_enhancements[hide_admin_bar]').addEventListener('click', event => { |
| 294 | if (event.target.checked) { |
| 295 | $('.hide-admin-bar .asenha-subfields').fadeIn(); |
| 296 | $('.hide-admin-bar .asenha-field-with-options').toggleClass('is-enabled'); |
| 297 | } else { |
| 298 | $('.hide-admin-bar .asenha-subfields').hide(); |
| 299 | $('.hide-admin-bar .asenha-field-with-options').toggleClass('is-enabled'); |
| 300 | } |
| 301 | }); |
| 302 | |
| 303 | // Hide or Modify Elements => show/hide subfields on document ready |
| 304 | if ( document.getElementById('admin_site_enhancements[hide_modify_elements]').checked ) { |
| 305 | $('.hide-modify-elements .asenha-subfields').show(); |
| 306 | $('.asenha-toggle.hide-modify-elements td .asenha-field-with-options').addClass('is-enabled'); |
| 307 | } else { |
| 308 | $('.hide-modify-elements .asenha-subfields').hide(); |
| 309 | } |
| 310 | |
| 311 | // Hide or Modify Elements => show/hide subfields on toggle click |
| 312 | document.getElementById('admin_site_enhancements[hide_modify_elements]').addEventListener('click', event => { |
| 313 | if (event.target.checked) { |
| 314 | $('.hide-modify-elements .asenha-subfields').fadeIn(); |
| 315 | $('.hide-modify-elements .asenha-field-with-options').toggleClass('is-enabled'); |
| 316 | } else { |
| 317 | $('.hide-modify-elements .asenha-subfields').hide(); |
| 318 | $('.hide-modify-elements .asenha-field-with-options').toggleClass('is-enabled'); |
| 319 | } |
| 320 | }); |
| 321 | |
| 322 | // Customize Admin Menu => show/hide subfields on document ready |
| 323 | if ( document.getElementById('admin_site_enhancements[customize_admin_menu]').checked ) { |
| 324 | $('.customize-admin-menu .asenha-subfields').show(); |
| 325 | $('.asenha-toggle.customize-admin-menu td .asenha-field-with-options').addClass('is-enabled'); |
| 326 | } else { |
| 327 | $('.customize-admin-menu .asenha-subfields').hide(); |
| 328 | } |
| 329 | |
| 330 | // Customize Admin Menu => show/hide subfields on toggle click |
| 331 | document.getElementById('admin_site_enhancements[customize_admin_menu]').addEventListener('click', event => { |
| 332 | if (event.target.checked) { |
| 333 | $('.customize-admin-menu .asenha-subfields').fadeIn(); |
| 334 | $('.customize-admin-menu .asenha-field-with-options').toggleClass('is-enabled'); |
| 335 | |
| 336 | // Initialize sortable elements: https://api.jqueryui.com/sortable/ |
| 337 | $('#custom-admin-menu').sortable(); |
| 338 | |
| 339 | } else { |
| 340 | $('.customize-admin-menu .asenha-subfields').hide(); |
| 341 | $('.customize-admin-menu .asenha-field-with-options').toggleClass('is-enabled'); |
| 342 | } |
| 343 | }); |
| 344 | |
| 345 | // Disable Gutenberg => show/hide post type checkboxes on document ready |
| 346 | if ( document.getElementById('admin_site_enhancements[disable_gutenberg]').checked ) { |
| 347 | $('.disable-gutenberg .asenha-subfields').show(); |
| 348 | $('.asenha-toggle.disable-gutenberg td .asenha-field-with-options').addClass('is-enabled'); |
| 349 | } else { |
| 350 | $('.disable-gutenberg .asenha-subfields').hide(); |
| 351 | } |
| 352 | |
| 353 | // Disable Gutenberg => show/hide post type checkboxes on toggle click |
| 354 | document.getElementById('admin_site_enhancements[disable_gutenberg]').addEventListener('click', event => { |
| 355 | if (event.target.checked) { |
| 356 | $('.disable-gutenberg .asenha-subfields').fadeIn(); |
| 357 | $('.disable-gutenberg .asenha-field-with-options').toggleClass('is-enabled'); |
| 358 | } else { |
| 359 | $('.disable-gutenberg .asenha-subfields').hide(); |
| 360 | $('.disable-gutenberg .asenha-field-with-options').toggleClass('is-enabled'); |
| 361 | } |
| 362 | }); |
| 363 | |
| 364 | // Disable Comments => show/hide post type checkboxes on document ready |
| 365 | if ( document.getElementById('admin_site_enhancements[disable_comments]').checked ) { |
| 366 | $('.disable-comments .asenha-subfields').show(); |
| 367 | $('.asenha-toggle.disable-comments td .asenha-field-with-options').addClass('is-enabled'); |
| 368 | } else { |
| 369 | $('.disable-comments .asenha-subfields').hide(); |
| 370 | } |
| 371 | |
| 372 | // Disable Comments => show/hide post type checkboxes on toggle click |
| 373 | document.getElementById('admin_site_enhancements[disable_comments]').addEventListener('click', event => { |
| 374 | if (event.target.checked) { |
| 375 | $('.disable-comments .asenha-subfields').fadeIn(); |
| 376 | $('.disable-comments .asenha-field-with-options').toggleClass('is-enabled'); |
| 377 | } else { |
| 378 | $('.disable-comments .asenha-subfields').hide(); |
| 379 | $('.disable-comments .asenha-field-with-options').toggleClass('is-enabled'); |
| 380 | } |
| 381 | }); |
| 382 | |
| 383 | // Change Login URL => show/hide custom slug input on document ready |
| 384 | if ( document.getElementById('admin_site_enhancements[change_login_url]').checked ) { |
| 385 | $('.change-login-url .asenha-subfields').show(); |
| 386 | $('.asenha-toggle.change-login-url td .asenha-field-with-options').addClass('is-enabled'); |
| 387 | } else { |
| 388 | $('.change-login-url .asenha-subfields').hide(); |
| 389 | } |
| 390 | |
| 391 | // Change Login URL => show/hide custom slug input on toggle click |
| 392 | document.getElementById('admin_site_enhancements[change_login_url]').addEventListener('click', event => { |
| 393 | if (event.target.checked) { |
| 394 | $('.change-login-url .asenha-subfields').fadeIn(); |
| 395 | $('.change-login-url .asenha-field-with-options').toggleClass('is-enabled'); |
| 396 | } else { |
| 397 | $('.change-login-url .asenha-subfields').hide(); |
| 398 | $('.change-login-url .asenha-field-with-options').toggleClass('is-enabled'); |
| 399 | } |
| 400 | }); |
| 401 | |
| 402 | // Limit Login Attempts => show/hide custom slug input on document ready |
| 403 | if ( document.getElementById('admin_site_enhancements[limit_login_attempts]').checked ) { |
| 404 | $('.limit-login-attempts .asenha-subfields').show(); |
| 405 | $('.asenha-toggle.limit-login-attempts td .asenha-field-with-options').addClass('is-enabled'); |
| 406 | } else { |
| 407 | $('.limit-login-attempts .asenha-subfields').hide(); |
| 408 | } |
| 409 | |
| 410 | // Limit Login Attempts => show/hide custom slug input on toggle click |
| 411 | document.getElementById('admin_site_enhancements[limit_login_attempts]').addEventListener('click', event => { |
| 412 | if (event.target.checked) { |
| 413 | $('.limit-login-attempts .asenha-subfields').fadeIn(); |
| 414 | $('.limit-login-attempts .asenha-field-with-options').toggleClass('is-enabled'); |
| 415 | } else { |
| 416 | $('.limit-login-attempts .asenha-subfields').hide(); |
| 417 | $('.limit-login-attempts .asenha-field-with-options').toggleClass('is-enabled'); |
| 418 | } |
| 419 | }); |
| 420 | // Redirect After Login => show/hide roles checkboxes on document ready |
| 421 | if ( document.getElementById('admin_site_enhancements[redirect_after_login]').checked ) { |
| 422 | $('.redirect-after-login .asenha-subfields').show(); |
| 423 | $('.asenha-toggle.redirect-after-login td .asenha-field-with-options').addClass('is-enabled'); |
| 424 | } else { |
| 425 | $('.redirect-after-login .asenha-subfields').hide(); |
| 426 | } |
| 427 | |
| 428 | // Redirect After Login => show/hide roles checkboxes on toggle click |
| 429 | document.getElementById('admin_site_enhancements[redirect_after_login]').addEventListener('click', event => { |
| 430 | if (event.target.checked) { |
| 431 | $('.redirect-after-login .asenha-subfields').fadeIn(); |
| 432 | $('.redirect-after-login .asenha-field-with-options').toggleClass('is-enabled'); |
| 433 | } else { |
| 434 | $('.redirect-after-login .asenha-subfields').hide(); |
| 435 | $('.redirect-after-login .asenha-field-with-options').toggleClass('is-enabled'); |
| 436 | } |
| 437 | }); |
| 438 | |
| 439 | // Redirect After Logout => show/hide roles checkboxes on document ready |
| 440 | if ( document.getElementById('admin_site_enhancements[redirect_after_logout]').checked ) { |
| 441 | $('.redirect-after-logout .asenha-subfields').show(); |
| 442 | $('.asenha-toggle.redirect-after-logout td .asenha-field-with-options').addClass('is-enabled'); |
| 443 | } else { |
| 444 | $('.redirect-after-logout .asenha-subfields').hide(); |
| 445 | } |
| 446 | |
| 447 | // Redirect After Logout => show/hide roles checkboxes on toggle click |
| 448 | document.getElementById('admin_site_enhancements[redirect_after_logout]').addEventListener('click', event => { |
| 449 | if (event.target.checked) { |
| 450 | $('.redirect-after-logout .asenha-subfields').fadeIn(); |
| 451 | $('.redirect-after-logout .asenha-field-with-options').toggleClass('is-enabled'); |
| 452 | } else { |
| 453 | $('.redirect-after-logout .asenha-subfields').hide(); |
| 454 | $('.redirect-after-logout .asenha-field-with-options').toggleClass('is-enabled'); |
| 455 | } |
| 456 | }); |
| 457 | |
| 458 | // Enable Custom Admin CSS => show/hide CSS textarea on document ready |
| 459 | if ( document.getElementById('admin_site_enhancements[enable_custom_admin_css]').checked ) { |
| 460 | $('.enable-custom-admin-css .asenha-subfields').show(); |
| 461 | $('.asenha-toggle.enable-custom-admin-css td .asenha-field-with-options').addClass('is-enabled'); |
| 462 | adminCssEditor.refresh(); |
| 463 | } else { |
| 464 | $('.enable-custom-admin-css .asenha-subfields').hide(); |
| 465 | } |
| 466 | |
| 467 | // Enable Custom Admin CSS => show/hide CSS textarea on toggle click |
| 468 | document.getElementById('admin_site_enhancements[enable_custom_admin_css]').addEventListener('click', event => { |
| 469 | if (event.target.checked) { |
| 470 | $('.enable-custom-admin-css .asenha-subfields').fadeIn(); |
| 471 | $('.enable-custom-admin-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 472 | adminCssEditor.refresh(); |
| 473 | } else { |
| 474 | $('.enable-custom-admin-css .asenha-subfields').hide(); |
| 475 | $('.enable-custom-admin-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 476 | } |
| 477 | }); |
| 478 | |
| 479 | // Enable Custom Frontend CSS => show/hide CSS textarea on document ready |
| 480 | if ( document.getElementById('admin_site_enhancements[enable_custom_frontend_css]').checked ) { |
| 481 | $('.enable-custom-frontend-css .asenha-subfields').show(); |
| 482 | $('.asenha-toggle.enable-custom-frontend-css td .asenha-field-with-options').addClass('is-enabled'); |
| 483 | frontendCssEditor.refresh(); |
| 484 | } else { |
| 485 | $('.enable-custom-frontend-css .asenha-subfields').hide(); |
| 486 | } |
| 487 | |
| 488 | // Enable Custom Frontend CSS => show/hide CSS textarea on toggle click |
| 489 | document.getElementById('admin_site_enhancements[enable_custom_frontend_css]').addEventListener('click', event => { |
| 490 | if (event.target.checked) { |
| 491 | $('.enable-custom-frontend-css .asenha-subfields').fadeIn(); |
| 492 | $('.enable-custom-frontend-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 493 | frontendCssEditor.refresh(); |
| 494 | } else { |
| 495 | $('.enable-custom-frontend-css .asenha-subfields').hide(); |
| 496 | $('.enable-custom-frontend-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 497 | } |
| 498 | }); |
| 499 | |
| 500 | // Manage ads.txt and app-ads.txt => show/hide CodeMirror textarea on document ready |
| 501 | if ( document.getElementById('admin_site_enhancements[manage_ads_appads_txt]').checked ) { |
| 502 | $('.manage-ads-appads-txt .asenha-subfields').show(); |
| 503 | $('.asenha-toggle.manage-ads-appads-txt td .asenha-field-with-options').addClass('is-enabled'); |
| 504 | adsTxtEditor.refresh(); |
| 505 | appAdsTxtEditor.refresh(); |
| 506 | } else { |
| 507 | $('.manage-ads-appads-txt .asenha-subfields').hide(); |
| 508 | } |
| 509 | |
| 510 | // Create and Edit ads.txt => show/hide CodeMirror textarea on toggle click |
| 511 | document.getElementById('admin_site_enhancements[manage_ads_appads_txt]').addEventListener('click', event => { |
| 512 | if (event.target.checked) { |
| 513 | $('.manage-ads-appads-txt .asenha-subfields').fadeIn(); |
| 514 | $('.manage-ads-appads-txt .asenha-field-with-options').toggleClass('is-enabled'); |
| 515 | adsTxtEditor.refresh(); |
| 516 | appAdsTxtEditor.refresh(); |
| 517 | } else { |
| 518 | $('.manage-ads-appads-txt .asenha-subfields').hide(); |
| 519 | $('.manage-ads-appads-txt .asenha-field-with-options').toggleClass('is-enabled'); |
| 520 | } |
| 521 | }); |
| 522 | |
| 523 | // Insert <head>, <body> and <footer> code => show/hide CSS textarea on document ready |
| 524 | if ( document.getElementById('admin_site_enhancements[insert_head_body_footer_code]').checked ) { |
| 525 | $('.insert-head-body-footer-code .asenha-subfields').show(); |
| 526 | $('.asenha-toggle.insert-head-body-footer-code td .asenha-field-with-options').addClass('is-enabled'); |
| 527 | headCodeEditor.refresh(); |
| 528 | bodyCodeEditor.refresh(); |
| 529 | footerCodeEditor.refresh(); |
| 530 | } else { |
| 531 | $('.manage-app-ads-txt .asenha-subfields').hide(); |
| 532 | } |
| 533 | |
| 534 | // Insert <head>, <body> and <footer> code => show/hide CSS textarea on toggle click |
| 535 | document.getElementById('admin_site_enhancements[insert_head_body_footer_code]').addEventListener('click', event => { |
| 536 | if (event.target.checked) { |
| 537 | $('.insert-head-body-footer-code .asenha-subfields').fadeIn(); |
| 538 | $('.insert-head-body-footer-code .asenha-field-with-options').toggleClass('is-enabled'); |
| 539 | headCodeEditor.refresh(); |
| 540 | bodyCodeEditor.refresh(); |
| 541 | footerCodeEditor.refresh(); |
| 542 | } else { |
| 543 | $('.insert-head-body-footer-code .asenha-subfields').hide(); |
| 544 | $('.insert-head-body-footer-code .asenha-field-with-options').toggleClass('is-enabled'); |
| 545 | } |
| 546 | }); |
| 547 | |
| 548 | }); |
| 549 | |
| 550 | })( jQuery ); |