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

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