PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 2.0.9
Adminify – White Label, Admin Menu Editor, Login Customizer v2.0.9
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / assets / js / wp-adminify.js

wp-adminify.js in Adminify – White Label, Admin Menu Editor, Login Customizer 2.0.9, at assets/js/wp-adminify.js

566 lines 19.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // JS codes by WP Adminify
2
3 (function ($)
4 {
5 'use strict';
6
7 // START Menu hover blink issue fixed
8 if($(".wp_adminify_sidebar_admin-menu").length > 0){
9 $(window).scroll(function() {
10 menu_bottom_extra_space();
11 });
12 }
13 function menu_bottom_extra_space(){
14 const subMenuBound = document.querySelector("#adminmenu").getBoundingClientRect();
15 const windowHeight = document.getElementsByTagName("body")[0].clientHeight;
16 const subMenuY = Math.abs(subMenuBound.y);
17 const subMenuHeight = subMenuBound.height;
18 const bottomRestSpace = windowHeight - subMenuHeight;
19 const lastSubMenuList = [...document.querySelector("#adminmenu .wp_adminify_admin-menu li.menu-top:last-child > ul").getElementsByTagName("li")];
20 const lastSubMenuHeight = lastSubMenuList.length * 35;
21 if (bottomRestSpace < lastSubMenuHeight) {
22 document.querySelector("#adminmenu").style.paddingBottom = (lastSubMenuHeight - 45) + 'px';
23 } else {
24 document.querySelector("#adminmenu").style.paddingBottom = '0';
25 }
26 }
27 // END Menu hover blink issue fixed
28
29 var adminHeight = $('.wp-adminify.adminify-top_bar').height();
30 $('.wp-adminify-admin-bar.position-bottom').css('padding-bottom', adminHeight * 1.25);
31
32
33 // User Wrapper On / Off
34
35 var openBtn = $(".wp-adminify--user--account"),
36 colseBtn = $(".user-wrapper-close"),
37 menu = $(".wp-adminify--user--wrapper");
38
39 // Open menu when click on menu button
40 openBtn.on("click", function (e)
41 {
42 menu.addClass("active");
43 });
44
45 // Close menu when click on Close button
46 colseBtn.on("click", function ()
47 {
48 menu.removeClass("active");
49 });
50
51 // Close menu when click on anywhere on the document
52 $(document).on("click", function (e)
53 {
54 var target = $(e.target);
55 if (target.is(".wp-adminify--user--wrapper *, .wp-adminify--user--wrapper, img.avatar.avatar-45.photo.is-rounded") === false)
56 {
57 menu.removeClass("active");
58 e.stopPropagation();
59 }
60 });
61
62
63 // Widget #dashboard_right_now count style
64
65 jQuery("#dashboard_right_now li a").html(function ()
66 {
67 var text = jQuery(this).text().trim().split(" ");
68 var first = text.shift();
69 return (text.length > 0 ? "<span class='counter'>" + first + "</span> " : first) + text.join(" ");
70 });
71
72 // Accordion
73
74 jQuery(".accordion .accordion-body").css("display", "none");
75
76 jQuery(".accordion-button, .accordion-opener").on('click', function (e)
77 {
78 e.preventDefault();
79 jQuery(this).toggleClass('show');
80
81 var jQuerythis = jQuery(this);
82
83 if (jQuerythis.next().hasClass('show'))
84 {
85 jQuerythis.next().removeClass('show');
86 jQuerythis.next().slideUp(100);
87 } else
88 {
89 jQuerythis.parent().parent().find('.accordion-body').removeClass('show');
90 jQuerythis.parent().parent().find('.accordion-body').slideUp(100);
91 jQuerythis.prev('.accordion-title').toggleClass('show');
92 jQuerythis.next().toggleClass('show');
93 jQuerythis.next().slideToggle(100);
94 }
95 });
96
97 // Admin Columns Accordions
98
99 $('.accordion-opener').on('click', function (e)
100 {
101 e.preventDefault();
102
103 let $this = $(this);
104
105 if ($this.next().hasClass('show'))
106 {
107 $this.next().removeClass('show');
108 $this.next().slideUp(100);
109 } else
110 {
111 $this.parent().parent().find('.accordion-body').removeClass('show');
112 $this.parent().parent().find('.accordion-body').slideUp(100);
113 $this.prev('.accordion-title').toggleClass('show');
114 $this.next().toggleClass('show');
115 $this.next().slideToggle(100);
116 }
117 });
118
119
120
121 $(window).on( 'load', function () {
122
123 // WP_Adminify.animateCSS('body.wp-adminify', 'fadeIn');
124 // WP_Adminify.animateCSS('.my-element', 'fadeIn').then((message) => {
125 // // Do something after the animation
126 // });
127
128 // Circle Menu Functions
129 var $circle_menu = $('#circle-menu');
130 var direction = 'left-half';
131 if( WPAdminify_QuickMenu.is_rtl ){
132 direction = 'right-half';
133 }
134 $(".wp-adminify-loader").delay(300).fadeOut("slow");
135 if ( $circle_menu.length ) {
136 $circle_menu.circleMenu({
137 direction: direction,
138 trigger: 'hover',
139 delay: 200
140 }).fadeIn("slow").show();
141 }
142
143 // Adminbar Loader
144 $(".wp-adminify-topbar-loader").delay(100).fadeOut("fast");
145 setTimeout(function () { $('.wp-adminify.adminify-top_bar').fadeIn('fast'); }, 100);
146
147 // Menu Editor Preloader
148 setTimeout(function () { $('.wp-adminify-menu-editor-loader').css({ 'display': 'none' }); }, 700)
149 setTimeout(function () { $('.wp-adminify--menu--editor--settings').addClass('loaded'); }, 700);
150
151 });
152
153
154 // Google page speed origin on / off
155
156 jQuery('.origin-summery-trigger button').on('click', function () {
157 alert('clicked!');
158 jQuery('.result-body').toggleClass('show-origin');
159 });
160
161 // Wrap content get extra margin if folder options exist
162 jQuery('body').has('#wp-adminify--folder-app').addClass('has-folder-options');
163
164
165 // tippy('[data-tippy-content]');
166
167 // Admin Topbar Search
168 function admin_top_search_hide_result()
169 {
170 $("#top-header-search-results").hide();
171 }
172 function admin_top_search_show_result()
173 {
174 $("#top-header-search-results").show();
175 }
176
177 $("#top-header-search-input").on("input", function ()
178 {
179 var search_val = $("#top-header-search-input").val();
180 admin_top_bar_search(search_val);
181 if (!search_val.length)
182 {
183 admin_top_search_hide_result();
184 }
185 });
186
187 var cansearch;
188 function admin_top_bar_search(searchTerm)
189 {
190
191 // Admin Bar Search
192 if (cansearch == false)
193 {
194 return;
195 }
196
197 if (searchTerm == "")
198 {
199 return;
200 }
201
202 // var count_rows = $('#top-header-search-results .top-header-result-table > tbody > tr').length;
203 // console.log(count_rows);
204 // $("#top-header-search-results").css('display','block');
205
206 $.ajax({
207 url: WPAdminify.ajax_url,
208 type: "post",
209 data: {
210 action: "adminify_all_search",
211 security: WPAdminify.security_nonce,
212 search: searchTerm
213 },
214 beforeSend: function (xhr)
215 {
216 cansearch = false;
217 },
218 success: function (response)
219 {
220
221 if (response)
222 {
223 var data = JSON.parse(response);
224
225 // if (data.error) {
226 // Toastr Code here
227 // } else {
228 admin_top_search_show_result();
229
230 $("#top-header-search-results .top-header-results-wrapper").html(data);
231
232 // $("#top-header-search-results").show();
233 cansearch = true;
234 // }
235 }
236 },
237 });
238 }
239
240
241
242 var WP_Adminify = {
243
244 ToggleSwitcher: function (key, value)
245 {
246 if (key == "") { return; }
247 jQuery.ajax({
248 url: WPAdminify.ajax_url,
249 type: "post",
250 data: {
251 action: "wp_adminify_color_mode",
252 security: WPAdminify.security_nonce,
253 key: key,
254 value: value,
255 }
256 });
257 },
258
259 // Light/Dark Mode
260 Color_Mode_Switcher: function ()
261 {
262 $('#light-dark-switcher-btn').on('click', function ()
263 {
264 var color_mode = $("#light-dark-switcher-btn").is(":checked") ? 'dark' : 'light';
265 WP_Adminify.ToggleSwitcher("color_mode", color_mode);
266 if (color_mode === 'dark') {
267 $("body").removeClass("adminify-light-mode");
268 $("body").addClass("adminify-dark-mode");
269 } else if (color_mode === 'light') {
270 $("body").removeClass("adminify-dark-mode");
271 $("body").addClass("adminify-light-mode");
272 }
273 });
274 },
275
276 // Screens Tab
277 Screen_Option_Switcher: function ()
278 {
279 $('#screen-option-switcher-btn').on('click', function ()
280 {
281 var screen_options_tab = $("#screen-option-switcher-btn").is(":checked") ? 1 : 0;
282 WP_Adminify.ToggleSwitcher("screen_options_tab", screen_options_tab);
283 if (screen_options_tab)
284 {
285 $('#screen-options-link-wrap').css('display', 'none');
286 }
287 });
288 },
289
290 // Help Tab
291 Help_Tab: function ()
292 {
293 $('#help-option-switcher-btn').on('click', function ()
294 {
295 var adminify_help_tab = $("#help-option-switcher-btn").is(":checked") ? 1 : 0;
296 WP_Adminify.ToggleSwitcher("adminify_help_tab", adminify_help_tab);
297 if (adminify_help_tab)
298 {
299 $('#contextual-help-link-wrap').css('display', 'none');
300 }
301 });
302 },
303
304 // Hide WP Links
305 Hide_WP_Links: function ()
306 {
307 $('#hide-wp-links-switcher-btn').on('click', function ()
308 {
309 var hide_wp_links = $("#hide-wp-links-switcher-btn").is(":checked") ? 1 : 0;
310 WP_Adminify.ToggleSwitcher("hide_wp_links", hide_wp_links);
311 });
312 },
313
314 // Copy Active Plugins
315 Copy_Active_Plugins: function (e)
316 {
317 e.preventDefault();
318 $('.adminify-copy-btn').copyToClipboard({
319 parent: '.adminify-server-info',
320 content: '.adminify-active-plugins-data',
321 onSuccess: function ($element, source, selection)
322 {
323 $('span', $element).text($element.attr("data-text-copied"));
324 setTimeout(function ()
325 {
326 $('span', $element).text($element.attr("data-text"));
327 }, 200000);
328 }
329 });
330 },
331
332 Dismiss_Notice: function(){
333 $( 'div[data-dismissible] .notice-dismiss,div[data-dismissible] .adminify-notice-dismiss, div[data-dismissible] .dismiss-this' ).on('click', function (event) {
334 event.preventDefault();
335 var $this = $( this );
336 var attr_value, option_name, dismissible_length, data;
337
338 attr_value = $this.closest("div[data-dismissible]").attr( 'data-dismissible' ).split( '-' );
339
340 // remove the dismissible length from the attribute value and rejoin the array.
341 dismissible_length = attr_value.pop();
342 option_name = attr_value.join( '-' );
343 data = {
344 'action' : 'adminify_dismiss_admin_notice',
345 'option_name' : option_name,
346 'dismissible_length': dismissible_length,
347 'notice_nonce' : WPAdminify.notice_nonce
348 };
349
350 // We can also pass the url value separately from ajaxurl for front end AJAX implementations
351 $.post( WPAdminify.ajax_url, data );
352 $this.closest("div[data-dismissible]").hide('slow');
353 });
354 },
355
356 animateCSS: function (element, animation, prefix = 'animate__')
357 {
358 // We create a Promise and return it
359 new Promise((resolve, reject) =>
360 {
361 var animationName = `${prefix}${animation}`;
362 var node = document.querySelector(element);
363
364 node.classList.add(`${prefix}animated`, animationName);
365
366 // When the animation ends, we clean the classes and resolve the Promise
367 function handleAnimationEnd(event)
368 {
369 event.stopPropagation();
370 node.classList.remove(`${prefix}animated`, animationName);
371 resolve('Animation ended');
372 }
373
374 node.addEventListener('animationend', handleAnimationEnd, { once: true });
375 });
376 },
377
378 VersionRollback:function(){
379 $('select.wp-adminify-rollback-select').on('change', function () {
380 var $this = $(this),
381 $rollbackButton = $this.next('.wp-adminify-rollback-button'),
382 placeholderText = $rollbackButton.data('placeholder-text'),
383 placeholderUrl = $rollbackButton.data('placeholder-url');
384 $rollbackButton.html(placeholderText.replace('{VERSION}', $this.val()));
385 $rollbackButton.attr('href', placeholderUrl.replace('VERSION', $this.val()));
386 }).trigger('change');
387
388 $('body').removeClass('wp-adminify--popup-show');
389
390 $('.wp-adminify-rollback-button').on('click', function (event) {
391 event.preventDefault();
392 var $this = $(this);
393 $('body').addClass('wp-adminify--popup-show');
394 $('.wp-adminify-dialog-ok').on('click', function(event){
395 event.preventDefault();
396 location.href = $this.attr('href');
397 });
398 });
399 },
400
401
402 };
403
404 // Documents Loaded
405 $(function () {
406
407 // Adminify vertical menu
408
409 $('.adminify-accordion-v-menu #adminmenu .wp-submenu, .adminify-toggle-v-menu #adminmenu .wp-submenu').hide();
410 $('.adminify-accordion-v-menu .wp-adminify-active .wp-submenu').show();
411 $('.adminify-accordion-v-menu #adminmenu .wp-adminify-parent > a.menu-top, .adminify-toggle-v-menu #adminmenu .wp-adminify-parent > a.menu-top').data('href', $(this).attr('href')).removeAttr('href');
412
413 // Adminify Accordion type vertical menu
414
415 $(".adminify-accordion-v-menu #adminmenu .wp-adminify-parent > a.menu-top").on('click', function (e) {
416 $(this).each(function ()
417 {
418 $(".wp_adminify_admin-menu ul").slideUp().parent('li.menu-top').removeClass('wp-adminify-active');
419 $(this).next().is(":visible") || $(this).next().slideDown().parent('li.menu-top').toggleClass('wp-adminify-active');
420 })
421 e.stopPropagation()
422 });
423
424 // Adminify Toggle type vertical menu
425
426 $(".adminify-toggle-v-menu #adminmenu .wp-adminify-parent > a.menu-top").on('click', function () {
427 $(this).parent(".adminify-toggle-v-menu #adminmenu li.wp-adminify-parent").toggleClass('wp-adminify-active');
428 });
429
430 // Extra space appears on Folder Widget in Horizontal Menu mode
431 var hmenuHeight = $('.wp-adminify-horizontal-menu').height();
432 $('.wp-adminify.horizontal-menu.has-folder-options .wp-adminify--folder-widget').css('top', hmenuHeight * 1.05);
433
434 function fixClasses() {
435 var width = $(window).innerWidth();
436 if ( width <= 767 ) {
437 $('body').removeClass('folded auto-fold');
438 }
439 if ( width <= 1023 && width > 767 ) {
440 $('body').addClass('folded');
441 }
442 }
443
444 fixClasses();
445
446 $(window).on('resize', function() {
447 fixClasses();
448 });
449
450 $('.navbar-brand .navbar-burger').on('click', function () {
451 if ( $(window).innerWidth() <= 767 ) {
452 $('body').toggleClass('adminify-collapse-menu');
453 $('#adminmenumain').toggleClass('adminify-menu-expanded');
454 } else {
455 jQuery('#collapse-button').trigger('click');
456 }
457 });
458
459 // Range Slider
460
461 // var textinput = $( ".range-value" ).val();
462 // var myslider = $( ".range-slider" ).slider({
463 // min: 0,
464 // max: 900,
465 // range: "min",
466 // value: $(".range-value").val(),
467 // slide: function( event, ui ) {
468 // $(".range-value").val(ui.value);
469 // }
470 // });
471
472 // $( ".range-value" ).on( "keyup", function() {
473 // myslider.slider( "value", this.value );
474 // });
475
476
477 // WP_Adminify.ToggleSwitcher();
478 WP_Adminify.Color_Mode_Switcher();
479 WP_Adminify.Screen_Option_Switcher();
480 WP_Adminify.Help_Tab();
481 WP_Adminify.Hide_WP_Links();
482 WP_Adminify.Dismiss_Notice();
483 WP_Adminify.VersionRollback();
484 // WP_Adminify.Copy_Active_Plugins();
485
486
487
488
489 // Copy to Clipboard Section
490 (function (n) {
491 n.fn.copyToClipboard = function (e)
492 {
493 var t = n.extend({
494 parent: "body",
495 content: "",
496 onSuccess: function () { },
497 onError: function () { }
498 }, e);
499 return this.each(function ()
500 {
501 var e = n(this);
502 e.on("click", function ()
503 {
504 var n = e.parents(t.parent).find(t.content);
505 var o = document.createRange();
506 var c = window.getSelection();
507 o.selectNodeContents(n[0]);
508 c.removeAllRanges();
509 c.addRange(o);
510 try
511 {
512 var r = document.execCommand("copy");
513 var a = r ? "onSuccess" : "onError";
514 t[a](e, n, c.toString())
515 } catch (i) { }
516 c.removeAllRanges()
517 });
518 })
519 }
520 })(jQuery);
521
522
523 $('.adminify-copy-btn').on( 'click', function (e)
524 {
525 e.preventDefault();
526 $('.adminify-copy-btn').copyToClipboard({
527 parent: '.adminify-server-info',
528 content: '.adminify-active-plugins-data',
529 onSuccess: function ($element, source, selection)
530 {
531 $('span', $element).text($element.attr("data-text-copied"));
532 setTimeout(function ()
533 {
534 $('span', $element).text($element.attr("data-text"));
535 }, 2000);
536 }
537 });
538 });
539
540 if ($(window).innerWidth() <= 1200)
541 {
542 $('.adminify-search-expand').on('click', function ()
543 {
544 $('.top-header--search--form').toggleClass('adminify-form-expand');
545 });
546 }
547
548 // betterlinks menu settings
549 if( WPAdminify_ThirdParty.better_links.active === true ) {
550 var { menu_name, submenu_manage, submenu_name, submenu_settings } = WPAdminify_ThirdParty.better_links;
551
552 if( $("body").hasClass("toplevel_page_betterlinks") ){
553 if(menu_name) $('.toplevel_page_betterlinks #toplevel_page_betterlinks .wp-menu-name').text(menu_name);
554 setTimeout(()=>{
555 if(menu_name) $('.toplevel_page_betterlinks #toplevel_page_betterlinks .wp-submenu .wp-submenu-head').text(menu_name);
556 if(submenu_manage) $('.toplevel_page_betterlinks #toplevel_page_betterlinks .wp-submenu li:nth-child(2) a').text(submenu_manage);
557 if(submenu_name) $('.toplevel_page_betterlinks #toplevel_page_betterlinks .wp-submenu li:nth-child(3) a').text(submenu_name);
558 if(submenu_settings) $('.toplevel_page_betterlinks #toplevel_page_betterlinks .wp-submenu li:nth-child(4) a').text(submenu_settings);
559 },500);
560 }
561 }
562
563 });
564
565 })(jQuery);
566