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

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