PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4
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 3.2.4, at assets/js/wp-adminify.js

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