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
413 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 | e.preventDefault(); |
| 17 | |
| 18 | // Get current tab's URL hash and save it in cookie |
| 19 | var hash = decodeURI(window.location.hash).substr(1); // get hash without the # character |
| 20 | Cookies.set('asenha_tab', hash, { expires: 1 }); // expires in 1 day |
| 21 | |
| 22 | $('input[type="submit"]').click(); |
| 23 | }); |
| 24 | |
| 25 | // Show all / less toggler for field options | Modified from https://codepen.io/symonsays/pen/rzgEgY |
| 26 | $('.asenha-field-with-options.field-show-more > .show-more').click(function(e) { |
| 27 | |
| 28 | e.preventDefault(); |
| 29 | |
| 30 | var $this = $(this); |
| 31 | $this.toggleClass('show-more'); |
| 32 | |
| 33 | if ($this.hasClass('show-more')) { |
| 34 | $this.next().removeClass('opened',0); |
| 35 | $this.html('Expand ▼'); |
| 36 | } else { |
| 37 | $this.next().addClass('opened',0); |
| 38 | $this.html('Collapse ▲'); |
| 39 | } |
| 40 | |
| 41 | }); |
| 42 | |
| 43 | // Initialize data tables |
| 44 | var table = $("#login-attempts-log").DataTable({ |
| 45 | pageLength: 10 |
| 46 | }); |
| 47 | |
| 48 | // Place fields into the "Content Management" tab |
| 49 | $('.enable-duplication').appendTo('.fields-content-management > table > tbody'); |
| 50 | $('.enable-media-replacement').appendTo('.fields-content-management > table > tbody'); |
| 51 | $('.enable-svg-upload').appendTo('.fields-content-management > table > tbody'); |
| 52 | $('.enable-svg-upload-for').appendTo('.fields-content-management .enable-svg-upload .asenha-subfields'); |
| 53 | $('.enhance-list-tables').appendTo('.fields-content-management > table > tbody'); |
| 54 | $('.show-featured-image-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 55 | $('.show-excerpt-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 56 | $('.show-id-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 57 | $('.hide-comments-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 58 | $('.hide-post-tags-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 59 | $('.show-custom-taxonomy-filters').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 60 | |
| 61 | // Place fields into "Admin Interface" tab |
| 62 | $('.hide-admin-notices').appendTo('.fields-admin-interface > table > tbody'); |
| 63 | $('.view-admin-as-role').appendTo('.fields-admin-interface > table > tbody'); |
| 64 | $('.customize-admin-menu').appendTo('.fields-admin-interface > table > tbody'); |
| 65 | $('.custom-menu-order').appendTo('.fields-admin-interface .customize-admin-menu .asenha-subfields'); |
| 66 | $('.hide-modify-elements').appendTo('.fields-admin-interface > table > tbody'); |
| 67 | $('.hide-ab-wp-logo-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 68 | $('.hide-ab-customize-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 69 | $('.hide-ab-updates-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 70 | $('.hide-ab-comments-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 71 | $('.hide-ab-new-content-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 72 | $('.hide-ab-howdy').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 73 | $('.hide-admin-bar').appendTo('.fields-admin-interface > table > tbody'); |
| 74 | $('.hide-admin-bar-for').appendTo('.fields-admin-interface .hide-admin-bar .asenha-subfields'); |
| 75 | |
| 76 | // Place fields into the "Disable Components" tab |
| 77 | $('.disable-comments').appendTo('.fields-disable-components > table > tbody'); |
| 78 | $('.disable-comments-for').appendTo('.fields-disable-components .disable-comments .asenha-subfields'); |
| 79 | |
| 80 | // Place fields into "Security" tab |
| 81 | $('.change-login-url').appendTo('.fields-security > table > tbody'); |
| 82 | $('.custom-login-slug').appendTo('.fields-security .change-login-url .asenha-subfields'); |
| 83 | $('.limit-login-attempts').appendTo('.fields-security > table > tbody'); |
| 84 | $('.login-fails-allowed').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 85 | $('.login-lockout-maxcount').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 86 | $('.login-attempts-log-table').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 87 | $('.obfuscate-author-slugs').appendTo('.fields-security > table > tbody'); |
| 88 | $('.disable-xmlrpc').appendTo('.fields-security > table > tbody'); |
| 89 | |
| 90 | // Place fields into "Utilities" tab |
| 91 | $('.enable-custom-admin-css').appendTo('.fields-utilities > table > tbody'); |
| 92 | $('.custom-admin-css').appendTo('.fields-utilities .enable-custom-admin-css .asenha-subfields'); |
| 93 | $('.enable-custom-frontend-css').appendTo('.fields-utilities > table > tbody'); |
| 94 | $('.custom-frontend-css').appendTo('.fields-utilities .enable-custom-frontend-css .asenha-subfields'); |
| 95 | $('.redirect-after-login').appendTo('.fields-utilities > table > tbody'); |
| 96 | $('.redirect-after-login-to-slug').appendTo('.fields-utilities .redirect-after-login .asenha-subfields'); |
| 97 | $('.redirect-after-login-for').appendTo('.fields-utilities .redirect-after-login .asenha-subfields'); |
| 98 | $('.redirect-after-logout').appendTo('.fields-utilities > table > tbody'); |
| 99 | $('.redirect-after-logout-to-slug').appendTo('.fields-utilities .redirect-after-logout .asenha-subfields'); |
| 100 | $('.redirect-after-logout-for').appendTo('.fields-utilities .redirect-after-logout .asenha-subfields'); |
| 101 | $('.redirect-404-to-homepage').appendTo('.fields-utilities > table > tbody'); |
| 102 | |
| 103 | // Remove empty .form-table that originally holds the fields |
| 104 | const formTableCount = $('.form-table').length; |
| 105 | // $('.form-table')[formTableCount-1].remove(); |
| 106 | |
| 107 | // Enable Custom Admin CSS => Initialize CodeMirror |
| 108 | var adminCssTextarea = document.getElementById("admin_site_enhancements[custom_admin_css]"); |
| 109 | var adminCssEditor = CodeMirror.fromTextArea(adminCssTextarea, { |
| 110 | mode: "css", |
| 111 | lineNumbers: true, |
| 112 | lineWrapping: true |
| 113 | }); |
| 114 | |
| 115 | adminCssEditor.setSize("100%",600); |
| 116 | |
| 117 | // Enable Custom Frontend CSS => Initialize CodeMirror |
| 118 | var frontendCssTextarea = document.getElementById("admin_site_enhancements[custom_frontend_css]"); |
| 119 | var frontendCssEditor = CodeMirror.fromTextArea(frontendCssTextarea, { |
| 120 | mode: "css", |
| 121 | lineNumbers: true, |
| 122 | lineWrapping: true |
| 123 | }); |
| 124 | |
| 125 | frontendCssEditor.setSize("100%",600); |
| 126 | |
| 127 | // Show and hide corresponding fields on tab clicks |
| 128 | |
| 129 | $('#tab-content-management + label').click( function() { |
| 130 | $('.fields-content-management').show(); |
| 131 | $('.asenha-fields:not(.fields-content-management)').hide(); |
| 132 | window.location.hash = 'content-management'; |
| 133 | Cookies.set('asenha_tab', 'content-management', { expires: 1 }); // expires in 1 day |
| 134 | }); |
| 135 | |
| 136 | $('#tab-admin-interface + label').click( function() { |
| 137 | $('.fields-admin-interface').show(); |
| 138 | $('.asenha-fields:not(.fields-admin-interface)').hide(); |
| 139 | window.location.hash = 'admin-interface'; |
| 140 | Cookies.set('asenha_tab', 'admin-interface', { expires: 1 }); // expires in 1 day |
| 141 | }); |
| 142 | |
| 143 | $('#tab-disable-components + label').click( function() { |
| 144 | $('.fields-disable-components').show(); |
| 145 | $('.asenha-fields:not(.fields-disable-components)').hide(); |
| 146 | window.location.hash = 'disable-components'; |
| 147 | Cookies.set('asenha_tab', 'disable-components', { expires: 1 }); // expires in 1 day |
| 148 | }); |
| 149 | |
| 150 | $('#tab-security + label').click( function() { |
| 151 | $('.fields-security').show(); |
| 152 | $('.asenha-fields:not(.fields-security)').hide(); |
| 153 | window.location.hash = 'security'; |
| 154 | Cookies.set('asenha_tab', 'security', { expires: 1 }); // expires in 1 day |
| 155 | }); |
| 156 | |
| 157 | $('#tab-utilities + label').click( function() { |
| 158 | $('.fields-utilities').show(); |
| 159 | $('.asenha-fields:not(.fields-utilities)').hide(); |
| 160 | window.location.hash = 'utilities'; |
| 161 | Cookies.set('asenha_tab', 'utilities', { expires: 1 }); // expires in 1 day |
| 162 | adminCssEditor.refresh(); // Custom Admin CSS >> CodeMirror |
| 163 | frontendCssEditor.refresh(); // Custom Fronend CSS >> CodeMirror |
| 164 | }); |
| 165 | |
| 166 | // Open tab set in 'asenha_tab' cookie set on saving changes. Defaults to content-management tab when cookie is empty |
| 167 | var asenhaTabHash = Cookies.get('asenha_tab'); |
| 168 | |
| 169 | if (typeof asenhaTabHash === 'undefined') { |
| 170 | $('#tab-content-management + label').trigger('click'); |
| 171 | } else { |
| 172 | $('#tab-' + asenhaTabHash + ' + label').trigger('click'); |
| 173 | } |
| 174 | |
| 175 | // Enable SVG Upload => show/hide roles checkboxes on document ready |
| 176 | if ( document.getElementById('admin_site_enhancements[enable_svg_upload]').checked ) { |
| 177 | $('.enable-svg-upload .asenha-subfields').show(); |
| 178 | $('.asenha-toggle.enable-svg-upload td .asenha-field-with-options').addClass('is-enabled'); |
| 179 | } else { |
| 180 | $('.enable-svg-upload .asenha-subfields').hide(); |
| 181 | } |
| 182 | |
| 183 | // Enable SVG Upload => show/hide roles checkboxes on toggle click |
| 184 | document.getElementById('admin_site_enhancements[enable_svg_upload]').addEventListener('click', event => { |
| 185 | if (event.target.checked) { |
| 186 | $('.enable-svg-upload .asenha-subfields').fadeIn(); |
| 187 | $('.enable-svg-upload .asenha-field-with-options').toggleClass('is-enabled'); |
| 188 | } else { |
| 189 | $('.enable-svg-upload .asenha-subfields').hide(); |
| 190 | $('.enable-svg-upload .asenha-field-with-options').toggleClass('is-enabled'); |
| 191 | } |
| 192 | }); |
| 193 | |
| 194 | |
| 195 | // Enhance List Tables => show/hide subfields on document ready |
| 196 | if ( document.getElementById('admin_site_enhancements[enhance_list_tables]').checked ) { |
| 197 | $('.enhance-list-tables .asenha-subfields').show(); |
| 198 | $('.asenha-toggle.enhance-list-tables td .asenha-field-with-options').addClass('is-enabled'); |
| 199 | } else { |
| 200 | $('.enhance-list-tables .asenha-subfields').hide(); |
| 201 | } |
| 202 | |
| 203 | // Enhance List Tables => show/hide subfields on toggle click |
| 204 | document.getElementById('admin_site_enhancements[enhance_list_tables]').addEventListener('click', event => { |
| 205 | if (event.target.checked) { |
| 206 | $('.enhance-list-tables .asenha-subfields').fadeIn(); |
| 207 | $('.enhance-list-tables .asenha-field-with-options').toggleClass('is-enabled'); |
| 208 | } else { |
| 209 | $('.enhance-list-tables .asenha-subfields').hide(); |
| 210 | $('.enhance-list-tables .asenha-field-with-options').toggleClass('is-enabled'); |
| 211 | } |
| 212 | }); |
| 213 | |
| 214 | // Hide Admin Bar => show/hide roles checkboxes on document ready |
| 215 | if ( document.getElementById('admin_site_enhancements[hide_admin_bar]').checked ) { |
| 216 | $('.hide-admin-bar .asenha-subfields').show(); |
| 217 | $('.asenha-toggle.hide-admin-bar td .asenha-field-with-options').addClass('is-enabled'); |
| 218 | } else { |
| 219 | $('.hide-admin-bar .asenha-subfields').hide(); |
| 220 | } |
| 221 | |
| 222 | // Hide Admin Bar => show/hide roles checkboxes on toggle click |
| 223 | document.getElementById('admin_site_enhancements[hide_admin_bar]').addEventListener('click', event => { |
| 224 | if (event.target.checked) { |
| 225 | $('.hide-admin-bar .asenha-subfields').fadeIn(); |
| 226 | $('.hide-admin-bar .asenha-field-with-options').toggleClass('is-enabled'); |
| 227 | } else { |
| 228 | $('.hide-admin-bar .asenha-subfields').hide(); |
| 229 | $('.hide-admin-bar .asenha-field-with-options').toggleClass('is-enabled'); |
| 230 | } |
| 231 | }); |
| 232 | |
| 233 | // Hide or Modify Elements => show/hide subfields on document ready |
| 234 | if ( document.getElementById('admin_site_enhancements[hide_modify_elements]').checked ) { |
| 235 | $('.hide-modify-elements .asenha-subfields').show(); |
| 236 | $('.asenha-toggle.hide-modify-elements td .asenha-field-with-options').addClass('is-enabled'); |
| 237 | } else { |
| 238 | $('.hide-modify-elements .asenha-subfields').hide(); |
| 239 | } |
| 240 | |
| 241 | // Hide or Modify Elements => show/hide subfields on toggle click |
| 242 | document.getElementById('admin_site_enhancements[hide_modify_elements]').addEventListener('click', event => { |
| 243 | if (event.target.checked) { |
| 244 | $('.hide-modify-elements .asenha-subfields').fadeIn(); |
| 245 | $('.hide-modify-elements .asenha-field-with-options').toggleClass('is-enabled'); |
| 246 | } else { |
| 247 | $('.hide-modify-elements .asenha-subfields').hide(); |
| 248 | $('.hide-modify-elements .asenha-field-with-options').toggleClass('is-enabled'); |
| 249 | } |
| 250 | }); |
| 251 | |
| 252 | // Customize Admin Menu => show/hide subfields on document ready |
| 253 | if ( document.getElementById('admin_site_enhancements[customize_admin_menu]').checked ) { |
| 254 | $('.customize-admin-menu .asenha-subfields').show(); |
| 255 | $('.asenha-toggle.customize-admin-menu td .asenha-field-with-options').addClass('is-enabled'); |
| 256 | } else { |
| 257 | $('.customize-admin-menu .asenha-subfields').hide(); |
| 258 | } |
| 259 | |
| 260 | // Customize Admin Menu => show/hide subfields on toggle click |
| 261 | document.getElementById('admin_site_enhancements[customize_admin_menu]').addEventListener('click', event => { |
| 262 | if (event.target.checked) { |
| 263 | $('.customize-admin-menu .asenha-subfields').fadeIn(); |
| 264 | $('.customize-admin-menu .asenha-field-with-options').toggleClass('is-enabled'); |
| 265 | |
| 266 | // Initialize sortable elements: https://api.jqueryui.com/sortable/ |
| 267 | $('#custom-admin-menu').sortable(); |
| 268 | |
| 269 | } else { |
| 270 | $('.customize-admin-menu .asenha-subfields').hide(); |
| 271 | $('.customize-admin-menu .asenha-field-with-options').toggleClass('is-enabled'); |
| 272 | } |
| 273 | }); |
| 274 | |
| 275 | // Disable Comments => show/hide post type checkboxes on document ready |
| 276 | if ( document.getElementById('admin_site_enhancements[disable_comments]').checked ) { |
| 277 | $('.disable-comments .asenha-subfields').show(); |
| 278 | $('.asenha-toggle.disable-comments td .asenha-field-with-options').addClass('is-enabled'); |
| 279 | } else { |
| 280 | $('.disable-comments .asenha-subfields').hide(); |
| 281 | } |
| 282 | |
| 283 | // Disable Comments => show/hide post type checkboxes on toggle click |
| 284 | document.getElementById('admin_site_enhancements[disable_comments]').addEventListener('click', event => { |
| 285 | if (event.target.checked) { |
| 286 | $('.disable-comments .asenha-subfields').fadeIn(); |
| 287 | $('.disable-comments .asenha-field-with-options').toggleClass('is-enabled'); |
| 288 | } else { |
| 289 | $('.disable-comments .asenha-subfields').hide(); |
| 290 | $('.disable-comments .asenha-field-with-options').toggleClass('is-enabled'); |
| 291 | } |
| 292 | }); |
| 293 | |
| 294 | // Change Login URL => show/hide custom slug input on document ready |
| 295 | if ( document.getElementById('admin_site_enhancements[change_login_url]').checked ) { |
| 296 | $('.change-login-url .asenha-subfields').show(); |
| 297 | $('.asenha-toggle.change-login-url td .asenha-field-with-options').addClass('is-enabled'); |
| 298 | } else { |
| 299 | $('.change-login-url .asenha-subfields').hide(); |
| 300 | } |
| 301 | |
| 302 | // Change Login URL => show/hide custom slug input on toggle click |
| 303 | document.getElementById('admin_site_enhancements[change_login_url]').addEventListener('click', event => { |
| 304 | if (event.target.checked) { |
| 305 | $('.change-login-url .asenha-subfields').fadeIn(); |
| 306 | $('.change-login-url .asenha-field-with-options').toggleClass('is-enabled'); |
| 307 | } else { |
| 308 | $('.change-login-url .asenha-subfields').hide(); |
| 309 | $('.change-login-url .asenha-field-with-options').toggleClass('is-enabled'); |
| 310 | } |
| 311 | }); |
| 312 | |
| 313 | // Limit Login Attempts => show/hide custom slug input on document ready |
| 314 | if ( document.getElementById('admin_site_enhancements[limit_login_attempts]').checked ) { |
| 315 | $('.limit-login-attempts .asenha-subfields').show(); |
| 316 | $('.asenha-toggle.limit-login-attempts td .asenha-field-with-options').addClass('is-enabled'); |
| 317 | } else { |
| 318 | $('.limit-login-attempts .asenha-subfields').hide(); |
| 319 | } |
| 320 | |
| 321 | // Limit Login Attempts => show/hide custom slug input on toggle click |
| 322 | document.getElementById('admin_site_enhancements[limit_login_attempts]').addEventListener('click', event => { |
| 323 | if (event.target.checked) { |
| 324 | $('.limit-login-attempts .asenha-subfields').fadeIn(); |
| 325 | $('.limit-login-attempts .asenha-field-with-options').toggleClass('is-enabled'); |
| 326 | } else { |
| 327 | $('.limit-login-attempts .asenha-subfields').hide(); |
| 328 | $('.limit-login-attempts .asenha-field-with-options').toggleClass('is-enabled'); |
| 329 | } |
| 330 | }); |
| 331 | // Redirect After Login => show/hide roles checkboxes on document ready |
| 332 | if ( document.getElementById('admin_site_enhancements[redirect_after_login]').checked ) { |
| 333 | $('.redirect-after-login .asenha-subfields').show(); |
| 334 | $('.asenha-toggle.redirect-after-login td .asenha-field-with-options').addClass('is-enabled'); |
| 335 | } else { |
| 336 | $('.redirect-after-login .asenha-subfields').hide(); |
| 337 | } |
| 338 | |
| 339 | // Redirect After Login => show/hide roles checkboxes on toggle click |
| 340 | document.getElementById('admin_site_enhancements[redirect_after_login]').addEventListener('click', event => { |
| 341 | if (event.target.checked) { |
| 342 | $('.redirect-after-login .asenha-subfields').fadeIn(); |
| 343 | $('.redirect-after-login .asenha-field-with-options').toggleClass('is-enabled'); |
| 344 | } else { |
| 345 | $('.redirect-after-login .asenha-subfields').hide(); |
| 346 | $('.redirect-after-login .asenha-field-with-options').toggleClass('is-enabled'); |
| 347 | } |
| 348 | }); |
| 349 | |
| 350 | // Redirect After Logout => show/hide roles checkboxes on document ready |
| 351 | if ( document.getElementById('admin_site_enhancements[redirect_after_logout]').checked ) { |
| 352 | $('.redirect-after-logout .asenha-subfields').show(); |
| 353 | $('.asenha-toggle.redirect-after-logout td .asenha-field-with-options').addClass('is-enabled'); |
| 354 | } else { |
| 355 | $('.redirect-after-logout .asenha-subfields').hide(); |
| 356 | } |
| 357 | |
| 358 | // Redirect After Logout => show/hide roles checkboxes on toggle click |
| 359 | document.getElementById('admin_site_enhancements[redirect_after_logout]').addEventListener('click', event => { |
| 360 | if (event.target.checked) { |
| 361 | $('.redirect-after-logout .asenha-subfields').fadeIn(); |
| 362 | $('.redirect-after-logout .asenha-field-with-options').toggleClass('is-enabled'); |
| 363 | } else { |
| 364 | $('.redirect-after-logout .asenha-subfields').hide(); |
| 365 | $('.redirect-after-logout .asenha-field-with-options').toggleClass('is-enabled'); |
| 366 | } |
| 367 | }); |
| 368 | |
| 369 | // Enable Custom Admin CSS => show/hide CSS textarea on document ready |
| 370 | if ( document.getElementById('admin_site_enhancements[enable_custom_admin_css]').checked ) { |
| 371 | $('.enable-custom-admin-css .asenha-subfields').show(); |
| 372 | $('.asenha-toggle.enable-custom-admin-css td .asenha-field-with-options').addClass('is-enabled'); |
| 373 | adminCssEditor.refresh(); |
| 374 | } else { |
| 375 | $('.enable-custom-admin-css .asenha-subfields').hide(); |
| 376 | } |
| 377 | |
| 378 | // Enable Custom Admin CSS => show/hide CSS textarea on toggle click |
| 379 | document.getElementById('admin_site_enhancements[enable_custom_admin_css]').addEventListener('click', event => { |
| 380 | if (event.target.checked) { |
| 381 | $('.enable-custom-admin-css .asenha-subfields').fadeIn(); |
| 382 | $('.enable-custom-admin-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 383 | adminCssEditor.refresh(); |
| 384 | } else { |
| 385 | $('.enable-custom-admin-css .asenha-subfields').hide(); |
| 386 | $('.enable-custom-admin-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 387 | } |
| 388 | }); |
| 389 | |
| 390 | // Enable Custom Frontend CSS => show/hide CSS textarea on document ready |
| 391 | if ( document.getElementById('admin_site_enhancements[enable_custom_admin_css]').checked ) { |
| 392 | $('.enable-custom-frontend-css .asenha-subfields').show(); |
| 393 | $('.asenha-toggle.enable-custom-frontend-css td .asenha-field-with-options').addClass('is-enabled'); |
| 394 | frontendCssEditor.refresh(); |
| 395 | } else { |
| 396 | $('.enable-custom-frontend-css .asenha-subfields').hide(); |
| 397 | } |
| 398 | |
| 399 | // Enable Custom Frontend CSS => show/hide CSS textarea on toggle click |
| 400 | document.getElementById('admin_site_enhancements[enable_custom_admin_css]').addEventListener('click', event => { |
| 401 | if (event.target.checked) { |
| 402 | $('.enable-custom-frontend-css .asenha-subfields').fadeIn(); |
| 403 | $('.enable-custom-frontend-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 404 | frontendCssEditor.refresh(); |
| 405 | } else { |
| 406 | $('.enable-custom-frontend-css .asenha-subfields').hide(); |
| 407 | $('.enable-custom-frontend-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 408 | } |
| 409 | }); |
| 410 | |
| 411 | }); |
| 412 | |
| 413 | })( jQuery ); |