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