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