PluginProbe
Admin and Site Enhancements (ASE) / 2.4.0
Admin and Site Enhancements (ASE) v2.4.0
9.1.1 9.1.0 9.0.2 9.0.1 9.0.0 8.9.2 8.9.1 8.9.0 8.8.8 8.8.7 8.8.6 8.8.5 8.8.4 8.8.3 8.8.2 8.8.1 8.8.0 8.7.3 8.7.2 8.7.1 8.2.1 8.2.2 8.2.3 8.3.0 8.3.1 All 273 releases
admin-site-enhancements / assets / js / admin-page.js
admin-page.js
329 lines 16.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 $('.enable-custom-admin-css').appendTo('.fields-utilities tbody');
72 $('.custom-admin-css').appendTo('.fields-utilities .enable-custom-admin-css .asenha-subfields');
73 $('.enable-custom-frontend-css').appendTo('.fields-utilities tbody');
74 $('.custom-frontend-css').appendTo('.fields-utilities .enable-custom-frontend-css .asenha-subfields');
75 $('.redirect-after-login').appendTo('.fields-utilities tbody');
76 $('.redirect-after-login-to-slug').appendTo('.fields-utilities .redirect-after-login .asenha-subfields');
77 $('.redirect-after-login-for').appendTo('.fields-utilities .redirect-after-login .asenha-subfields');
78 $('.redirect-after-logout').appendTo('.fields-utilities tbody');
79 $('.redirect-after-logout-to-slug').appendTo('.fields-utilities .redirect-after-logout .asenha-subfields');
80 $('.redirect-after-logout-for').appendTo('.fields-utilities .redirect-after-logout .asenha-subfields');
81 $('.redirect-404-to-homepage').appendTo('.fields-utilities tbody');
82
83 // Place fields into the "Disable Components" tab
84
85 // Remove empty .form-table that originally holds the fields
86 const formTableCount = $('.form-table').length;
87 // $('.form-table')[formTableCount-1].remove();
88
89 // Enable Custom Admin CSS => Initialize CodeMirror
90 var adminCssTextarea = document.getElementById("admin_site_enhancements[custom_admin_css]");
91 var adminCssEditor = CodeMirror.fromTextArea(adminCssTextarea, {
92 mode: "css",
93 lineNumbers: true,
94 lineWrapping: true
95 });
96
97 adminCssEditor.setSize("100%",600);
98
99 // Enable Custom Frontend CSS => Initialize CodeMirror
100 var frontendCssTextarea = document.getElementById("admin_site_enhancements[custom_frontend_css]");
101 var frontendCssEditor = CodeMirror.fromTextArea(frontendCssTextarea, {
102 mode: "css",
103 lineNumbers: true,
104 lineWrapping: true
105 });
106
107 frontendCssEditor.setSize("100%",600);
108
109 // Show and hide corresponding fields on tab clicks
110
111 $('#tab-content-management + label').click( function() {
112 $('.fields-content-management').show();
113 $('.asenha-fields:not(.fields-content-management)').hide();
114 // window.location.hash = 'content-management';
115 });
116
117 $('#tab-admin-interface + label').click( function() {
118 $('.fields-admin-interface').show();
119 $('.asenha-fields:not(.fields-admin-interface)').hide();
120 // window.location.hash = 'admin-interface';
121 });
122
123 $('#tab-security + label').click( function() {
124 $('.fields-security').show();
125 $('.asenha-fields:not(.fields-security)').hide();
126 // window.location.hash = 'security';
127 });
128
129 $('#tab-utilities + label').click( function() {
130 $('.fields-utilities').show();
131 $('.asenha-fields:not(.fields-utilities)').hide();
132 // window.location.hash = 'utilities';
133 adminCssEditor.refresh(); // Custom Admin CSS >> CodeMirror
134 frontendCssEditor.refresh(); // Custom Fronend CSS >> CodeMirror
135 });
136
137 // $('#tab-disable-components + label').click( function() {
138 // $('.fields-disable-components').show();
139 // $('.asenha-fields:not(.fields-disable-components)').hide();
140 // window.location.hash = 'utilities';
141 // });
142
143 // Open Content Management tab on document ready
144 $('#tab-content-management + label').trigger('click');
145
146 // Open tab by URL hash. Defaults to Content Management tab.
147 // var hash = decodeURI(window.location.hash).substr(1); // get hash without the # character
148
149 // Enhance List Tables => show/hide subfields on document ready
150 if ( document.getElementById('admin_site_enhancements[enhance_list_tables]').checked ) {
151 $('.enhance-list-tables .asenha-subfields').show();
152 $('.asenha-toggle.enhance-list-tables td .asenha-field-with-options').addClass('is-enabled');
153 } else {
154 $('.enhance-list-tables .asenha-subfields').hide();
155 }
156
157 // Enhance List Tables => show/hide subfields on toggle click
158 document.getElementById('admin_site_enhancements[enhance_list_tables]').addEventListener('click', event => {
159 if (event.target.checked) {
160 $('.enhance-list-tables .asenha-subfields').fadeIn();
161 $('.enhance-list-tables .asenha-field-with-options').toggleClass('is-enabled');
162 } else {
163 $('.enhance-list-tables .asenha-subfields').hide();
164 $('.enhance-list-tables .asenha-field-with-options').toggleClass('is-enabled');
165 }
166 });
167
168 // Hide Admin Bar => show/hide roles checkboxes on document ready
169 if ( document.getElementById('admin_site_enhancements[hide_admin_bar]').checked ) {
170 $('.hide-admin-bar .asenha-subfields').show();
171 $('.asenha-toggle.hide-admin-bar td .asenha-field-with-options').addClass('is-enabled');
172 } else {
173 $('.hide-admin-bar .asenha-subfields').hide();
174 }
175
176 // Hide Admin Bar => show/hide roles checkboxes on toggle click
177 document.getElementById('admin_site_enhancements[hide_admin_bar]').addEventListener('click', event => {
178 if (event.target.checked) {
179 $('.hide-admin-bar .asenha-subfields').fadeIn();
180 $('.hide-admin-bar .asenha-field-with-options').toggleClass('is-enabled');
181 } else {
182 $('.hide-admin-bar .asenha-subfields').hide();
183 $('.hide-admin-bar .asenha-field-with-options').toggleClass('is-enabled');
184 }
185 });
186
187 // Hide or Modify Elements => show/hide subfields on document ready
188 if ( document.getElementById('admin_site_enhancements[hide_modify_elements]').checked ) {
189 $('.hide-modify-elements .asenha-subfields').show();
190 $('.asenha-toggle.hide-modify-elements td .asenha-field-with-options').addClass('is-enabled');
191 } else {
192 $('.hide-modify-elements .asenha-subfields').hide();
193 }
194
195 // Hide or Modify Elements => show/hide subfields on toggle click
196 document.getElementById('admin_site_enhancements[hide_modify_elements]').addEventListener('click', event => {
197 if (event.target.checked) {
198 $('.hide-modify-elements .asenha-subfields').fadeIn();
199 $('.hide-modify-elements .asenha-field-with-options').toggleClass('is-enabled');
200 } else {
201 $('.hide-modify-elements .asenha-subfields').hide();
202 $('.hide-modify-elements .asenha-field-with-options').toggleClass('is-enabled');
203 }
204 });
205
206 // Customize Admin Menu => show/hide subfields on document ready
207 if ( document.getElementById('admin_site_enhancements[customize_admin_menu]').checked ) {
208 $('.customize-admin-menu .asenha-subfields').show();
209 $('.asenha-toggle.customize-admin-menu td .asenha-field-with-options').addClass('is-enabled');
210 } else {
211 $('.customize-admin-menu .asenha-subfields').hide();
212 }
213
214 // Customize Admin Menu => show/hide subfields on toggle click
215 document.getElementById('admin_site_enhancements[customize_admin_menu]').addEventListener('click', event => {
216 if (event.target.checked) {
217 $('.customize-admin-menu .asenha-subfields').fadeIn();
218 $('.customize-admin-menu .asenha-field-with-options').toggleClass('is-enabled');
219
220 // Initialize sortable elements: https://api.jqueryui.com/sortable/
221 $('#custom-admin-menu').sortable();
222
223 } else {
224 $('.customize-admin-menu .asenha-subfields').hide();
225 $('.customize-admin-menu .asenha-field-with-options').toggleClass('is-enabled');
226 }
227 });
228
229 // Change Login URL => show/hide custom slug input on document ready
230 if ( document.getElementById('admin_site_enhancements[change_login_url]').checked ) {
231 $('.change-login-url .asenha-subfields').show();
232 $('.asenha-toggle.change-login-url td .asenha-field-with-options').addClass('is-enabled');
233 } else {
234 $('.change-login-url .asenha-subfields').hide();
235 }
236
237 // Change Login URL => show/hide custom slug input on toggle click
238 document.getElementById('admin_site_enhancements[change_login_url]').addEventListener('click', event => {
239 if (event.target.checked) {
240 $('.change-login-url .asenha-subfields').fadeIn();
241 $('.change-login-url .asenha-field-with-options').toggleClass('is-enabled');
242 } else {
243 $('.change-login-url .asenha-subfields').hide();
244 $('.change-login-url .asenha-field-with-options').toggleClass('is-enabled');
245 }
246 });
247
248 // Redirect After Login => show/hide roles checkboxes on document ready
249 if ( document.getElementById('admin_site_enhancements[redirect_after_login]').checked ) {
250 $('.redirect-after-login .asenha-subfields').show();
251 $('.asenha-toggle.redirect-after-login td .asenha-field-with-options').addClass('is-enabled');
252 } else {
253 $('.redirect-after-login .asenha-subfields').hide();
254 }
255
256 // Redirect After Login => show/hide roles checkboxes on toggle click
257 document.getElementById('admin_site_enhancements[redirect_after_login]').addEventListener('click', event => {
258 if (event.target.checked) {
259 $('.redirect-after-login .asenha-subfields').fadeIn();
260 $('.redirect-after-login .asenha-field-with-options').toggleClass('is-enabled');
261 } else {
262 $('.redirect-after-login .asenha-subfields').hide();
263 $('.redirect-after-login .asenha-field-with-options').toggleClass('is-enabled');
264 }
265 });
266
267 // Redirect After Logout => show/hide roles checkboxes on document ready
268 if ( document.getElementById('admin_site_enhancements[redirect_after_logout]').checked ) {
269 $('.redirect-after-logout .asenha-subfields').show();
270 $('.asenha-toggle.redirect-after-logout td .asenha-field-with-options').addClass('is-enabled');
271 } else {
272 $('.redirect-after-logout .asenha-subfields').hide();
273 }
274
275 // Redirect After Logout => show/hide roles checkboxes on toggle click
276 document.getElementById('admin_site_enhancements[redirect_after_logout]').addEventListener('click', event => {
277 if (event.target.checked) {
278 $('.redirect-after-logout .asenha-subfields').fadeIn();
279 $('.redirect-after-logout .asenha-field-with-options').toggleClass('is-enabled');
280 } else {
281 $('.redirect-after-logout .asenha-subfields').hide();
282 $('.redirect-after-logout .asenha-field-with-options').toggleClass('is-enabled');
283 }
284 });
285
286 // Enable Custom Admin CSS => show/hide CSS textarea on document ready
287 if ( document.getElementById('admin_site_enhancements[enable_custom_admin_css]').checked ) {
288 $('.enable-custom-admin-css .asenha-subfields').show();
289 $('.asenha-toggle.enable-custom-admin-css td .asenha-field-with-options').addClass('is-enabled');
290 adminCssEditor.refresh();
291 } else {
292 $('.enable-custom-admin-css .asenha-subfields').hide();
293 }
294
295 // Enable Custom Admin CSS => show/hide CSS textarea on toggle click
296 document.getElementById('admin_site_enhancements[enable_custom_admin_css]').addEventListener('click', event => {
297 if (event.target.checked) {
298 $('.enable-custom-admin-css .asenha-subfields').fadeIn();
299 $('.enable-custom-admin-css .asenha-field-with-options').toggleClass('is-enabled');
300 adminCssEditor.refresh();
301 } else {
302 $('.enable-custom-admin-css .asenha-subfields').hide();
303 $('.enable-custom-admin-css .asenha-field-with-options').toggleClass('is-enabled');
304 }
305 });
306
307 // Enable Custom Frontend CSS => show/hide CSS textarea on document ready
308 if ( document.getElementById('admin_site_enhancements[enable_custom_admin_css]').checked ) {
309 $('.enable-custom-frontend-css .asenha-subfields').show();
310 $('.asenha-toggle.enable-custom-frontend-css td .asenha-field-with-options').addClass('is-enabled');
311 frontendCssEditor.refresh();
312 } else {
313 $('.enable-custom-frontend-css .asenha-subfields').hide();
314 }
315
316 // Enable Custom Frontend CSS => show/hide CSS textarea on toggle click
317 document.getElementById('admin_site_enhancements[enable_custom_admin_css]').addEventListener('click', event => {
318 if (event.target.checked) {
319 $('.enable-custom-frontend-css .asenha-subfields').fadeIn();
320 $('.enable-custom-frontend-css .asenha-field-with-options').toggleClass('is-enabled');
321 frontendCssEditor.refresh();
322 } else {
323 $('.enable-custom-frontend-css .asenha-subfields').hide();
324 $('.enable-custom-frontend-css .asenha-field-with-options').toggleClass('is-enabled');
325 }
326 });
327 });
328
329 })( jQuery );