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