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

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