codemirror
3 years ago
admin-page.js
3 years ago
custom-admin-menu.js
3 years ago
hide-admin-notices.js
3 years ago
jBox.all.min.js
3 years ago
jquery.jsticky.mod.js
3 years ago
jquery.jsticky.mod.min.js
3 years ago
media-replace.js
3 years ago
toggle-hidden-menu.js
3 years ago
admin-page.js
296 lines
| 1 | (function( $ ) { |
| 2 | 'use strict'; |
| 3 | |
| 4 | $(document).ready( function() { |
| 5 | |
| 6 | // Make page header sticky on scroll. Using https://github.com/AndrewHenderson/jSticky |
| 7 | $('#asenha-header').sticky({ |
| 8 | topSpacing: 0, // Space between element and top of the viewport (in pixels) |
| 9 | zIndex: 100, // z-index |
| 10 | stopper: '', // Id, class, or number value |
| 11 | stickyClass: 'asenha-sticky' // Class applied to element when it's stuck. Class name or false. |
| 12 | }) |
| 13 | |
| 14 | // Clicking on header save button triggers click of the hidden form submit button |
| 15 | $('.asenha-save-button').click( function(e) { |
| 16 | e.preventDefault(); |
| 17 | $('input[type="submit"]').click(); |
| 18 | }); |
| 19 | |
| 20 | // Show all / less toggler for field options | Modified from https://codepen.io/symonsays/pen/rzgEgY |
| 21 | $('.asenha-field-with-options.field-show-more > .show-more').click(function(e) { |
| 22 | |
| 23 | e.preventDefault(); |
| 24 | |
| 25 | var $this = $(this); |
| 26 | $this.toggleClass('show-more'); |
| 27 | |
| 28 | if ($this.hasClass('show-more')) { |
| 29 | $this.next().removeClass('opened',0); |
| 30 | $this.html('Expand ▼'); |
| 31 | } else { |
| 32 | $this.next().addClass('opened',0); |
| 33 | $this.html('Collapse ▲'); |
| 34 | } |
| 35 | |
| 36 | }); |
| 37 | |
| 38 | // Place fields into the "Content Management" tab |
| 39 | $('.enable-duplication').appendTo('.fields-content-management tbody'); |
| 40 | $('.enable-media-replacement').appendTo('.fields-content-management tbody'); |
| 41 | $('.enhance-list-tables').appendTo('.fields-content-management tbody'); |
| 42 | $('.show-featured-image-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 43 | $('.show-excerpt-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 44 | $('.show-id-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 45 | $('.hide-comments-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 46 | $('.hide-post-tags-column').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 47 | $('.show-custom-taxonomy-filters').appendTo('.fields-content-management .enhance-list-tables .asenha-subfields'); |
| 48 | |
| 49 | // Place fields into "Admin Interface" tab |
| 50 | $('.hide-admin-notices').appendTo('.fields-admin-interface tbody'); |
| 51 | $('.view-admin-as-role').appendTo('.fields-admin-interface tbody'); |
| 52 | $('.customize-admin-menu').appendTo('.fields-admin-interface tbody'); |
| 53 | $('.custom-menu-order').appendTo('.fields-admin-interface .customize-admin-menu .asenha-subfields'); |
| 54 | $('.hide-modify-elements').appendTo('.fields-admin-interface tbody'); |
| 55 | $('.hide-ab-wp-logo-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 56 | $('.hide-ab-customize-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 57 | $('.hide-ab-updates-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 58 | $('.hide-ab-comments-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 59 | $('.hide-ab-new-content-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 60 | $('.hide-ab-howdy').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 61 | $('.hide-admin-bar').appendTo('.fields-admin-interface tbody'); |
| 62 | $('.hide-admin-bar-for').appendTo('.fields-admin-interface .hide-admin-bar .asenha-subfields'); |
| 63 | |
| 64 | // Place fields into "Security" tab |
| 65 | $('.change-login-url').appendTo('.fields-security tbody'); |
| 66 | $('.custom-login-slug').appendTo('.fields-security .change-login-url .asenha-subfields'); |
| 67 | $('.obfuscate-author-slugs').appendTo('.fields-security tbody'); |
| 68 | $('.disable-xmlrpc').appendTo('.fields-security tbody'); |
| 69 | |
| 70 | // Place fields into "Utilities" tab |
| 71 | $('.redirect-after-login').appendTo('.fields-utilities tbody'); |
| 72 | $('.redirect-after-login-to-slug').appendTo('.fields-utilities .redirect-after-login .asenha-subfields'); |
| 73 | $('.redirect-after-login-for').appendTo('.fields-utilities .redirect-after-login .asenha-subfields'); |
| 74 | $('.redirect-after-logout').appendTo('.fields-utilities tbody'); |
| 75 | $('.redirect-after-logout-to-slug').appendTo('.fields-utilities .redirect-after-logout .asenha-subfields'); |
| 76 | $('.redirect-after-logout-for').appendTo('.fields-utilities .redirect-after-logout .asenha-subfields'); |
| 77 | $('.redirect-404-to-homepage').appendTo('.fields-utilities tbody'); |
| 78 | $('.enable-custom-admin-css').appendTo('.fields-utilities tbody'); |
| 79 | $('.custom-admin-css').appendTo('.fields-utilities .enable-custom-admin-css .asenha-subfields'); |
| 80 | |
| 81 | // Place fields into the "Disable Components" tab |
| 82 | |
| 83 | // Remove empty .form-table that originally holds the fields |
| 84 | const formTableCount = $('.form-table').length; |
| 85 | // $('.form-table')[formTableCount-1].remove(); |
| 86 | |
| 87 | // Enable Custom Admin CSS => Initialize CodeMirror |
| 88 | var adminCssTextarea = document.getElementById("admin_site_enhancements[custom_admin_css]"); |
| 89 | var adminCssEditor = CodeMirror.fromTextArea(adminCssTextarea, { |
| 90 | mode: "css", |
| 91 | lineNumbers: true, |
| 92 | lineWrapping: true |
| 93 | }); |
| 94 | |
| 95 | adminCssEditor.setSize("100%",600); |
| 96 | |
| 97 | // Show and hide corresponding fields on tab clicks |
| 98 | |
| 99 | $('#tab-content-management + label').click( function() { |
| 100 | $('.fields-content-management').show(); |
| 101 | $('.asenha-fields:not(.fields-content-management)').hide(); |
| 102 | // window.location.hash = 'content-management'; |
| 103 | }); |
| 104 | |
| 105 | $('#tab-admin-interface + label').click( function() { |
| 106 | $('.fields-admin-interface').show(); |
| 107 | $('.asenha-fields:not(.fields-admin-interface)').hide(); |
| 108 | // window.location.hash = 'admin-interface'; |
| 109 | }); |
| 110 | |
| 111 | $('#tab-security + label').click( function() { |
| 112 | $('.fields-security').show(); |
| 113 | $('.asenha-fields:not(.fields-security)').hide(); |
| 114 | // window.location.hash = 'security'; |
| 115 | }); |
| 116 | |
| 117 | $('#tab-utilities + label').click( function() { |
| 118 | $('.fields-utilities').show(); |
| 119 | $('.asenha-fields:not(.fields-utilities)').hide(); |
| 120 | // window.location.hash = 'utilities'; |
| 121 | adminCssEditor.refresh(); // Custom Admin CSS >> CodeMirror |
| 122 | }); |
| 123 | |
| 124 | // $('#tab-disable-components + label').click( function() { |
| 125 | // $('.fields-disable-components').show(); |
| 126 | // $('.asenha-fields:not(.fields-disable-components)').hide(); |
| 127 | // window.location.hash = 'utilities'; |
| 128 | // }); |
| 129 | |
| 130 | // Open Content Management tab on document ready |
| 131 | $('#tab-content-management + label').trigger('click'); |
| 132 | |
| 133 | // Open tab by URL hash. Defaults to Content Management tab. |
| 134 | // var hash = decodeURI(window.location.hash).substr(1); // get hash without the # character |
| 135 | |
| 136 | // Enhance List Tables => show/hide subfields on document ready |
| 137 | if ( document.getElementById('admin_site_enhancements[enhance_list_tables]').checked ) { |
| 138 | $('.enhance-list-tables .asenha-subfields').show(); |
| 139 | $('.asenha-toggle.enhance-list-tables td .asenha-field-with-options').addClass('is-enabled'); |
| 140 | } else { |
| 141 | $('.enhance-list-tables .asenha-subfields').hide(); |
| 142 | } |
| 143 | |
| 144 | // Enhance List Tables => show/hide subfields on toggle click |
| 145 | document.getElementById('admin_site_enhancements[enhance_list_tables]').addEventListener('click', event => { |
| 146 | if (event.target.checked) { |
| 147 | $('.enhance-list-tables .asenha-subfields').fadeIn(); |
| 148 | $('.enhance-list-tables .asenha-field-with-options').toggleClass('is-enabled'); |
| 149 | } else { |
| 150 | $('.enhance-list-tables .asenha-subfields').hide(); |
| 151 | $('.enhance-list-tables .asenha-field-with-options').toggleClass('is-enabled'); |
| 152 | } |
| 153 | }); |
| 154 | |
| 155 | // Hide Admin Bar => show/hide roles checkboxes on document ready |
| 156 | if ( document.getElementById('admin_site_enhancements[hide_admin_bar]').checked ) { |
| 157 | $('.hide-admin-bar .asenha-subfields').show(); |
| 158 | $('.asenha-toggle.hide-admin-bar td .asenha-field-with-options').addClass('is-enabled'); |
| 159 | } else { |
| 160 | $('.hide-admin-bar .asenha-subfields').hide(); |
| 161 | } |
| 162 | |
| 163 | // Hide Admin Bar => show/hide roles checkboxes on toggle click |
| 164 | document.getElementById('admin_site_enhancements[hide_admin_bar]').addEventListener('click', event => { |
| 165 | if (event.target.checked) { |
| 166 | $('.hide-admin-bar .asenha-subfields').fadeIn(); |
| 167 | $('.hide-admin-bar .asenha-field-with-options').toggleClass('is-enabled'); |
| 168 | } else { |
| 169 | $('.hide-admin-bar .asenha-subfields').hide(); |
| 170 | $('.hide-admin-bar .asenha-field-with-options').toggleClass('is-enabled'); |
| 171 | } |
| 172 | }); |
| 173 | |
| 174 | // Hide or Modify Elements => show/hide subfields on document ready |
| 175 | if ( document.getElementById('admin_site_enhancements[hide_modify_elements]').checked ) { |
| 176 | $('.hide-modify-elements .asenha-subfields').show(); |
| 177 | $('.asenha-toggle.hide-modify-elements td .asenha-field-with-options').addClass('is-enabled'); |
| 178 | } else { |
| 179 | $('.hide-modify-elements .asenha-subfields').hide(); |
| 180 | } |
| 181 | |
| 182 | // Hide or Modify Elements => show/hide subfields on toggle click |
| 183 | document.getElementById('admin_site_enhancements[hide_modify_elements]').addEventListener('click', event => { |
| 184 | if (event.target.checked) { |
| 185 | $('.hide-modify-elements .asenha-subfields').fadeIn(); |
| 186 | $('.hide-modify-elements .asenha-field-with-options').toggleClass('is-enabled'); |
| 187 | } else { |
| 188 | $('.hide-modify-elements .asenha-subfields').hide(); |
| 189 | $('.hide-modify-elements .asenha-field-with-options').toggleClass('is-enabled'); |
| 190 | } |
| 191 | }); |
| 192 | |
| 193 | // Customize Admin Menu => show/hide subfields on document ready |
| 194 | if ( document.getElementById('admin_site_enhancements[customize_admin_menu]').checked ) { |
| 195 | $('.customize-admin-menu .asenha-subfields').show(); |
| 196 | $('.asenha-toggle.customize-admin-menu td .asenha-field-with-options').addClass('is-enabled'); |
| 197 | } else { |
| 198 | $('.customize-admin-menu .asenha-subfields').hide(); |
| 199 | } |
| 200 | |
| 201 | // Customize Admin Menu => show/hide subfields on toggle click |
| 202 | document.getElementById('admin_site_enhancements[customize_admin_menu]').addEventListener('click', event => { |
| 203 | if (event.target.checked) { |
| 204 | $('.customize-admin-menu .asenha-subfields').fadeIn(); |
| 205 | $('.customize-admin-menu .asenha-field-with-options').toggleClass('is-enabled'); |
| 206 | |
| 207 | // Initialize sortable elements: https://api.jqueryui.com/sortable/ |
| 208 | $('#custom-admin-menu').sortable(); |
| 209 | |
| 210 | } else { |
| 211 | $('.customize-admin-menu .asenha-subfields').hide(); |
| 212 | $('.customize-admin-menu .asenha-field-with-options').toggleClass('is-enabled'); |
| 213 | } |
| 214 | }); |
| 215 | |
| 216 | // Change Login URL => show/hide custom slug input on document ready |
| 217 | if ( document.getElementById('admin_site_enhancements[change_login_url]').checked ) { |
| 218 | $('.change-login-url .asenha-subfields').show(); |
| 219 | $('.asenha-toggle.change-login-url td .asenha-field-with-options').addClass('is-enabled'); |
| 220 | } else { |
| 221 | $('.change-login-url .asenha-subfields').hide(); |
| 222 | } |
| 223 | |
| 224 | // Change Login URL => show/hide custom slug input on toggle click |
| 225 | document.getElementById('admin_site_enhancements[change_login_url]').addEventListener('click', event => { |
| 226 | if (event.target.checked) { |
| 227 | $('.change-login-url .asenha-subfields').fadeIn(); |
| 228 | $('.change-login-url .asenha-field-with-options').toggleClass('is-enabled'); |
| 229 | } else { |
| 230 | $('.change-login-url .asenha-subfields').hide(); |
| 231 | $('.change-login-url .asenha-field-with-options').toggleClass('is-enabled'); |
| 232 | } |
| 233 | }); |
| 234 | |
| 235 | // Redirect After Login => show/hide roles checkboxes on document ready |
| 236 | if ( document.getElementById('admin_site_enhancements[redirect_after_login]').checked ) { |
| 237 | $('.redirect-after-login .asenha-subfields').show(); |
| 238 | $('.asenha-toggle.redirect-after-login td .asenha-field-with-options').addClass('is-enabled'); |
| 239 | } else { |
| 240 | $('.redirect-after-login .asenha-subfields').hide(); |
| 241 | } |
| 242 | |
| 243 | // Redirect After Login => show/hide roles checkboxes on toggle click |
| 244 | document.getElementById('admin_site_enhancements[redirect_after_login]').addEventListener('click', event => { |
| 245 | if (event.target.checked) { |
| 246 | $('.redirect-after-login .asenha-subfields').fadeIn(); |
| 247 | $('.redirect-after-login .asenha-field-with-options').toggleClass('is-enabled'); |
| 248 | } else { |
| 249 | $('.redirect-after-login .asenha-subfields').hide(); |
| 250 | $('.redirect-after-login .asenha-field-with-options').toggleClass('is-enabled'); |
| 251 | } |
| 252 | }); |
| 253 | |
| 254 | // Redirect After Logout => show/hide roles checkboxes on document ready |
| 255 | if ( document.getElementById('admin_site_enhancements[redirect_after_logout]').checked ) { |
| 256 | $('.redirect-after-logout .asenha-subfields').show(); |
| 257 | $('.asenha-toggle.redirect-after-logout td .asenha-field-with-options').addClass('is-enabled'); |
| 258 | } else { |
| 259 | $('.redirect-after-logout .asenha-subfields').hide(); |
| 260 | } |
| 261 | |
| 262 | // Redirect After Logout => show/hide roles checkboxes on toggle click |
| 263 | document.getElementById('admin_site_enhancements[redirect_after_logout]').addEventListener('click', event => { |
| 264 | if (event.target.checked) { |
| 265 | $('.redirect-after-logout .asenha-subfields').fadeIn(); |
| 266 | $('.redirect-after-logout .asenha-field-with-options').toggleClass('is-enabled'); |
| 267 | } else { |
| 268 | $('.redirect-after-logout .asenha-subfields').hide(); |
| 269 | $('.redirect-after-logout .asenha-field-with-options').toggleClass('is-enabled'); |
| 270 | } |
| 271 | }); |
| 272 | |
| 273 | // Enable Custom Admin CSS => show/hide CSS textarea on document ready |
| 274 | if ( document.getElementById('admin_site_enhancements[enable_custom_admin_css]').checked ) { |
| 275 | $('.enable-custom-admin-css .asenha-subfields').show(); |
| 276 | $('.asenha-toggle.enable-custom-admin-css td .asenha-field-with-options').addClass('is-enabled'); |
| 277 | adminCssEditor.refresh(); |
| 278 | } else { |
| 279 | $('.enable-custom-admin-css .asenha-subfields').hide(); |
| 280 | } |
| 281 | |
| 282 | // Enable Custom Admin CSS => show/hide CSS textarea on toggle click |
| 283 | document.getElementById('admin_site_enhancements[enable_custom_admin_css]').addEventListener('click', event => { |
| 284 | if (event.target.checked) { |
| 285 | $('.enable-custom-admin-css .asenha-subfields').fadeIn(); |
| 286 | $('.enable-custom-admin-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 287 | adminCssEditor.refresh(); |
| 288 | } else { |
| 289 | $('.enable-custom-admin-css .asenha-subfields').hide(); |
| 290 | $('.enable-custom-admin-css .asenha-field-with-options').toggleClass('is-enabled'); |
| 291 | } |
| 292 | }); |
| 293 | |
| 294 | }); |
| 295 | |
| 296 | })( jQuery ); |