PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.76
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.76
1.2.76 1.2.75 1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 All 176 releases
userswp / vendor / ayecode / wp-ayecode-ui / includes / inc / bs4-js.php

bs4-js.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.76, at vendor/ayecode/wp-ayecode-ui/includes/inc/bs4-js.php

1,013 lines 38.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <script>
2 /**
3 * An AUI bootstrap adaptation of GreedyNav.js ( by Luke Jackson ).
4 *
5 * Simply add the class `greedy` to any <nav> menu and it will do the rest.
6 * Licensed under the MIT license - http://opensource.org/licenses/MIT
7 * @ver 0.0.1
8 */
9 function aui_init_greedy_nav(){
10 jQuery('nav.greedy').each(function(i, obj) {
11
12 // Check if already initialized, if so continue.
13 if(jQuery(this).hasClass("being-greedy")){return true;}
14
15 // Make sure its always expanded
16 jQuery(this).addClass('navbar-expand');
17
18 // vars
19 var $vlinks = '';
20 var $dDownClass = '';
21 if(jQuery(this).find('.navbar-nav').length){
22 if(jQuery(this).find('.navbar-nav').hasClass("being-greedy")){return true;}
23 $vlinks = jQuery(this).find('.navbar-nav').addClass("being-greedy w-100").removeClass('overflow-hidden');
24 }else if(jQuery(this).find('.nav').length){
25 if(jQuery(this).find('.nav').hasClass("being-greedy")){return true;}
26 $vlinks = jQuery(this).find('.nav').addClass("being-greedy w-100").removeClass('overflow-hidden');
27 $dDownClass = ' mt-2 ';
28 }else{
29 return false;
30 }
31
32 jQuery($vlinks).append('<li class="nav-item list-unstyled ml-auto greedy-btn d-none dropdown ">' +
33 '<a href="javascript:void(0)" data-toggle="dropdown" class="nav-link"><i class="fas fa-ellipsis-h"></i> <span class="greedy-count badge badge-dark badge-pill"></span></a>' +
34 '<ul class="greedy-links dropdown-menu dropdown-menu-right '+$dDownClass+'"></ul>' +
35 '</li>');
36
37 var $hlinks = jQuery(this).find('.greedy-links');
38 var $btn = jQuery(this).find('.greedy-btn');
39
40 var numOfItems = 0;
41 var totalSpace = 0;
42 var closingTime = 1000;
43 var breakWidths = [];
44
45 // Get initial state
46 $vlinks.children().outerWidth(function(i, w) {
47 totalSpace += w;
48 numOfItems += 1;
49 breakWidths.push(totalSpace);
50 });
51
52 var availableSpace, numOfVisibleItems, requiredSpace, buttonSpace ,timer;
53
54 /*
55 The check function.
56 */
57 function check() {
58
59 // Get instant state
60 buttonSpace = $btn.width();
61 availableSpace = $vlinks.width() - 10;
62 numOfVisibleItems = $vlinks.children().length;
63 requiredSpace = breakWidths[numOfVisibleItems - 1];
64
65 // There is not enough space
66 if (numOfVisibleItems > 1 && requiredSpace > availableSpace) {
67 $vlinks.children().last().prev().prependTo($hlinks);
68 numOfVisibleItems -= 1;
69 check();
70 // There is more than enough space
71 } else if (availableSpace > breakWidths[numOfVisibleItems]) {
72 $hlinks.children().first().insertBefore($btn);
73 numOfVisibleItems += 1;
74 check();
75 }
76 // Update the button accordingly
77 jQuery($btn).find(".greedy-count").html( numOfItems - numOfVisibleItems);
78 if (numOfVisibleItems === numOfItems) {
79 $btn.addClass('d-none');
80 } else $btn.removeClass('d-none');
81 }
82
83 // Window listeners
84 jQuery(window).on("resize",function() {
85 check();
86 });
87
88 // do initial check
89 check();
90 });
91 }
92
93 function aui_select2_locale() {
94 var aui_select2_params = <?php echo self::select2_locale(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>;
95
96 return {
97 'language': {
98 errorLoading: function() {
99 // Workaround for https://github.com/select2/select2/issues/4355 instead of i18n_ajax_error.
100 return aui_select2_params.i18n_searching;
101 },
102 inputTooLong: function(args) {
103 var overChars = args.input.length - args.maximum;
104 if (1 === overChars) {
105 return aui_select2_params.i18n_input_too_long_1;
106 }
107 return aui_select2_params.i18n_input_too_long_n.replace('%item%', overChars);
108 },
109 inputTooShort: function(args) {
110 var remainingChars = args.minimum - args.input.length;
111 if (1 === remainingChars) {
112 return aui_select2_params.i18n_input_too_short_1;
113 }
114 return aui_select2_params.i18n_input_too_short_n.replace('%item%', remainingChars);
115 },
116 loadingMore: function() {
117 return aui_select2_params.i18n_load_more;
118 },
119 maximumSelected: function(args) {
120 if (args.maximum === 1) {
121 return aui_select2_params.i18n_selection_too_long_1;
122 }
123 return aui_select2_params.i18n_selection_too_long_n.replace('%item%', args.maximum);
124 },
125 noResults: function() {
126 return aui_select2_params.i18n_no_matches;
127 },
128 searching: function() {
129 return aui_select2_params.i18n_searching;
130 }
131 }
132 };
133 }
134
135 /**
136 * Initiate Select2 items.
137 */
138 function aui_init_select2(){
139 var select2Args, select2Locale = aui_select2_locale();
140 jQuery("select.aui-select2").each(function() {
141 if (!jQuery(this).hasClass("select2-hidden-accessible")) {
142 select2Args = jQuery.extend({}, select2Locale);
143 if (jQuery(this).closest('.modal.show').length && jQuery(this).closest('.modal-body').length) {
144 // Keep the dropdown inside the modal to prevent focus trapping.
145 select2Args.dropdownParent = jQuery(this).closest('.modal-body');
146 }
147 jQuery(this).select2(select2Args);
148 }
149 });
150 }
151
152 /**
153 * A function to convert a time value to a "ago" time text.
154 *
155 * @param selector string The .class selector
156 */
157 function aui_time_ago(selector) {
158 var aui_timeago_params = <?php echo self::timeago_locale(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>;
159
160 var templates = {
161 prefix: aui_timeago_params.prefix_ago,
162 suffix: aui_timeago_params.suffix_ago,
163 seconds: aui_timeago_params.seconds,
164 minute: aui_timeago_params.minute,
165 minutes: aui_timeago_params.minutes,
166 hour: aui_timeago_params.hour,
167 hours: aui_timeago_params.hours,
168 day: aui_timeago_params.day,
169 days: aui_timeago_params.days,
170 month: aui_timeago_params.month,
171 months: aui_timeago_params.months,
172 year: aui_timeago_params.year,
173 years: aui_timeago_params.years
174 };
175 var template = function (t, n) {
176 return templates[t] && templates[t].replace(/%d/i, Math.abs(Math.round(n)));
177 };
178
179 var timer = function (time) {
180 if (!time)
181 return;
182 time = time.replace(/\.\d+/, ""); // remove milliseconds
183 time = time.replace(/-/, "/").replace(/-/, "/");
184 time = time.replace(/T/, " ").replace(/Z/, " UTC");
185 time = time.replace(/([\+\-]\d\d)\:?(\d\d)/, " $1$2"); // -04:00 -> -0400
186 time = new Date(time * 1000 || time);
187
188 var now = new Date();
189 var seconds = ((now.getTime() - time) * .001) >> 0;
190 var minutes = seconds / 60;
191 var hours = minutes / 60;
192 var days = hours / 24;
193 var years = days / 365;
194
195 return templates.prefix + (
196 seconds < 45 && template('seconds', seconds) ||
197 seconds < 90 && template('minute', 1) ||
198 minutes < 45 && template('minutes', minutes) ||
199 minutes < 90 && template('hour', 1) ||
200 hours < 24 && template('hours', hours) ||
201 hours < 42 && template('day', 1) ||
202 days < 30 && template('days', days) ||
203 days < 45 && template('month', 1) ||
204 days < 365 && template('months', days / 30) ||
205 years < 1.5 && template('year', 1) ||
206 template('years', years)
207 ) + templates.suffix;
208 };
209
210 var elements = document.getElementsByClassName(selector);
211 if (selector && elements && elements.length) {
212 for (var i in elements) {
213 var $el = elements[i];
214 if (typeof $el === 'object') {
215 $el.innerHTML = '<i class="far fa-clock"></i> ' + timer($el.getAttribute('title') || $el.getAttribute('datetime'));
216 }
217 }
218 }
219
220 // update time every minute
221 setTimeout(function() {
222 aui_time_ago(selector);
223 }, 60000);
224
225 }
226
227 /**
228 * Initiate tooltips on the page.
229 */
230 function aui_init_tooltips(){
231 if (typeof jQuery.fn.tooltip === 'function') {
232 jQuery('[data-toggle="tooltip"]').tooltip();
233 } else {
234 console.log('jQuery.fn.tooltip not found');
235 }
236
237 if (typeof jQuery.fn.popover === 'function') {
238 jQuery('[data-toggle="popover"]').popover();
239 jQuery('[data-toggle="popover-html"]').popover({
240 html: true
241 });
242 } else {
243 console.log('jQuery.fn.popover not found');
244 }
245
246 // Fix popover container compatibility.
247 jQuery('[data-toggle="popover"],[data-toggle="popover-html"]').on('inserted.bs.popover', function() {
248 jQuery('body > .popover').wrapAll("<div class='bsui' />");
249 });
250 }
251
252 /**
253 * Initiate flatpickrs on the page.
254 */
255 $aui_doing_init_flatpickr = false;
256 function aui_init_flatpickr(){
257 if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) {
258 $aui_doing_init_flatpickr = true;
259 <?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>);}catch(err){console.log(err.message);}<?php } ?>
260 jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr();
261 }
262 $aui_doing_init_flatpickr = false;
263 }
264
265 /**
266 * Initiate iconpicker on the page.
267 */
268 $aui_doing_init_iconpicker = false;
269 function aui_init_iconpicker(){
270 if ( typeof jQuery.fn.iconpicker === "function" && !$aui_doing_init_iconpicker) {
271 $aui_doing_init_iconpicker = true;
272 jQuery('input[data-aui-init="iconpicker"]:not(.iconpicker-input)').iconpicker();
273 }
274 $aui_doing_init_iconpicker= false;
275 }
276
277 function aui_modal_iframe($title,$url,$footer,$dismissible,$class,$dialog_class,$body_class,responsive){
278 if(!$body_class){$body_class = 'p-0';}
279 var wClass = 'text-center position-absolute w-100 text-dark overlay overlay-white p-0 m-0 d-none d-flex justify-content-center align-items-center';
280 var $body = "", sClass = "w-100 p-0 m-0";
281 if (responsive) {
282 $body += '<div class="embed-responsive embed-responsive-16by9">';
283 wClass += ' h-100';
284 sClass += ' embed-responsive-item';
285 } else {
286 wClass += ' vh-100';
287 sClass += ' vh-100';
288 }
289 $body += '<div class="ac-preview-loading ' + wClass + '" style="left:0;top:0"><div class="spinner-border" role="status"></div></div>';
290 $body += '<iframe id="embedModal-iframe" class="' + sClass + '" src="" width="100%" height="100%" frameborder="0" allowtransparency="true"></iframe>';
291 if (responsive) {
292 $body += '</div>';
293 }
294
295 $m = aui_modal($title,$body,$footer,$dismissible,$class,$dialog_class,$body_class);
296 jQuery( $m ).on( 'shown.bs.modal', function ( e ) {
297 iFrame = jQuery( '#embedModal-iframe') ;
298
299 jQuery('.ac-preview-loading').addClass('d-flex');
300 iFrame.attr({
301 src: $url
302 });
303
304 //resize the iframe once loaded.
305 iFrame.load(function() {
306 jQuery('.ac-preview-loading').removeClass('d-flex');
307 });
308 });
309
310 return $m;
311
312 }
313
314 function aui_modal($title,$body,$footer,$dismissible,$class,$dialog_class,$body_class) {
315 if(!$class){$class = '';}
316 if(!$dialog_class){$dialog_class = '';}
317 if(!$body){$body = '<div class="text-center"><div class="spinner-border" role="status"></div></div>';}
318 // remove it first
319 jQuery('.aui-modal').modal('hide').modal('dispose').remove();
320 jQuery('.modal-backdrop').remove();
321
322 var $modal = '';
323
324 $modal += '<div class="modal aui-modal fade shadow bsui '+$class+'" tabindex="-1">'+
325 '<div class="modal-dialog modal-dialog-centered '+$dialog_class+'">'+
326 '<div class="modal-content border-0 shadow">';
327
328 if($title) {
329 $modal += '<div class="modal-header">' +
330 '<h5 class="modal-title">' + $title + '</h5>';
331
332 if ($dismissible) {
333 $modal += '<button type="button" class="close" data-dismiss="modal" aria-label="Close">' +
334 '<span aria-hidden="true">&times;</span>' +
335 '</button>';
336 }
337
338 $modal += '</div>';
339 }
340 $modal += '<div class="modal-body '+$body_class+'">'+
341 $body+
342 '</div>';
343
344 if($footer){
345 $modal += '<div class="modal-footer">'+
346 $footer +
347 '</div>';
348 }
349
350 $modal +='</div>'+
351 '</div>'+
352 '</div>';
353
354 jQuery('body').append($modal);
355
356 return jQuery('.aui-modal').modal('hide').modal({
357 //backdrop: 'static'
358 });
359 }
360
361 /**
362 * Show / hide fields depending on conditions.
363 */
364 function aui_conditional_fields(form){
365 jQuery(form).find(".aui-conditional-field").each(function () {
366
367 var $element_require = jQuery(this).data('element-require');
368
369 if ($element_require) {
370
371 $element_require = $element_require.replace("&#039;", "'"); // replace single quotes
372 $element_require = $element_require.replace("&quot;", '"'); // replace double quotes
373 if (aui_check_form_condition($element_require,form)) {
374 jQuery(this).removeClass('d-none');
375 } else {
376 jQuery(this).addClass('d-none');
377 }
378 }
379 });
380 }
381
382 /**
383 * Check form condition
384 */
385 function aui_check_form_condition(condition,form) {
386 if (form) {
387 condition = condition.replace(/\(form\)/g, "('"+form+"')");
388 }
389 return new Function("return " + condition+";")();
390 }
391
392 /**
393 * A function to determine if a element is on screen.
394 */
395 jQuery.fn.aui_isOnScreen = function(){
396
397 var win = jQuery(window);
398
399 var viewport = {
400 top : win.scrollTop(),
401 left : win.scrollLeft()
402 };
403 viewport.right = viewport.left + win.width();
404 viewport.bottom = viewport.top + win.height();
405
406 var bounds = this.offset();
407 bounds.right = bounds.left + this.outerWidth();
408 bounds.bottom = bounds.top + this.outerHeight();
409
410 return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
411
412 };
413
414 /**
415 * Maybe show multiple carousel items if set to do so.
416 */
417 function aui_carousel_maybe_show_multiple_items($carousel){
418 var $items = {};
419 var $item_count = 0;
420
421 // maybe backup
422 if(!jQuery($carousel).find('.carousel-inner-original').length){
423 jQuery($carousel).append('<div class="carousel-inner-original d-none">'+jQuery($carousel).find('.carousel-inner').html()+'</div>');
424 }
425
426 // Get the original items html
427 jQuery($carousel).find('.carousel-inner-original .carousel-item').each(function () {
428 $items[$item_count] = jQuery(this).html();
429 $item_count++;
430 });
431
432 // bail if no items
433 if(!$item_count){return;}
434
435 if(jQuery(window).width() <= 576){
436 // maybe restore original
437 if(jQuery($carousel).find('.carousel-inner').hasClass('aui-multiple-items') && jQuery($carousel).find('.carousel-inner-original').length){
438 jQuery($carousel).find('.carousel-inner').removeClass('aui-multiple-items').html(jQuery($carousel).find('.carousel-inner-original').html());
439 jQuery($carousel).find(".carousel-indicators li").removeClass("d-none");
440 }
441
442 }else{
443 // new items
444 var $md_count = jQuery($carousel).data('limit_show');
445 var $new_items = '';
446 var $new_items_count = 0;
447 var $new_item_count = 0;
448 var $closed = true;
449 Object.keys($items).forEach(function(key,index) {
450
451 // close
452 if(index != 0 && Number.isInteger(index/$md_count) ){
453 $new_items += '</div></div>';
454 $closed = true;
455 }
456
457 // open
458 if(index == 0 || Number.isInteger(index/$md_count) ){
459 $active = index == 0 ? 'active' : '';
460 $new_items += '<div class="carousel-item '+$active+'"><div class="row m-0">';
461 $closed = false;
462 $new_items_count++;
463 $new_item_count = 0;
464 }
465
466 // content
467 $new_items += '<div class="col pr-1 pl-0">'+$items[index]+'</div>';
468 $new_item_count++;
469
470
471 });
472
473 // close if not closed in the loop
474 if(!$closed){
475 // check for spares
476 if($md_count-$new_item_count > 0){
477 $placeholder_count = $md_count-$new_item_count;
478 while($placeholder_count > 0){
479 $new_items += '<div class="col pr-1 pl-0"></div>';
480 $placeholder_count--;
481 }
482
483 }
484
485 $new_items += '</div></div>';
486 }
487
488 // insert the new items
489 jQuery($carousel).find('.carousel-inner').addClass('aui-multiple-items').html($new_items);
490
491 // fix any lazyload images in the active slider
492 jQuery($carousel).find('.carousel-item.active img').each(function () {
493 // fix the srcset
494 if(real_srcset = jQuery(this).attr("data-srcset")){
495 if(!jQuery(this).attr("srcset")) jQuery(this).attr("srcset",real_srcset);
496 }
497 // fix the src
498 if(real_src = jQuery(this).attr("data-src")){
499 if(!jQuery(this).attr("srcset")) jQuery(this).attr("src",real_src);
500 }
501 });
502
503 // maybe fix carousel indicators
504 $hide_count = $new_items_count-1;
505 jQuery($carousel).find(".carousel-indicators li:gt("+$hide_count+")").addClass("d-none");
506 }
507
508 // trigger a global action to say we have
509 jQuery( window ).trigger( "aui_carousel_multiple" );
510 }
511
512 /**
513 * Init Multiple item carousels.
514 */
515 function aui_init_carousel_multiple_items(){
516 jQuery(window).on("resize",function(){
517 jQuery('.carousel-multiple-items').each(function () {
518 aui_carousel_maybe_show_multiple_items(this);
519 });
520 });
521
522 // run now
523 jQuery('.carousel-multiple-items').each(function () {
524 aui_carousel_maybe_show_multiple_items(this);
525 });
526 }
527
528 /**
529 * Allow navs to use multiple sub menus.
530 */
531 function init_nav_sub_menus(){
532
533 jQuery('.navbar-multi-sub-menus').each(function(i, obj) {
534 // Check if already initialized, if so continue.
535 if(jQuery(this).hasClass("has-sub-sub-menus")){return true;}
536
537 // Make sure its always expanded
538 jQuery(this).addClass('has-sub-sub-menus');
539
540 jQuery(this).find( '.dropdown-menu a.dropdown-toggle' ).on( 'click', function ( e ) {
541 var $el = jQuery( this );
542 $el.toggleClass('active-dropdown');
543 var $parent = jQuery( this ).offsetParent( ".dropdown-menu" );
544 if ( !jQuery( this ).next().hasClass( 'show' ) ) {
545 jQuery( this ).parents( '.dropdown-menu' ).first().find( '.show' ).removeClass( "show" );
546 }
547 var $subMenu = jQuery( this ).next( ".dropdown-menu" );
548 $subMenu.toggleClass( 'show' );
549
550 jQuery( this ).parent( "li" ).toggleClass( 'show' );
551
552 jQuery( this ).parents( 'li.nav-item.dropdown.show' ).on( 'hidden.bs.dropdown', function ( e ) {
553 jQuery( '.dropdown-menu .show' ).removeClass( "show" );
554 $el.removeClass('active-dropdown');
555 } );
556
557 if ( !$parent.parent().hasClass( 'navbar-nav' ) ) {
558 $el.next().addClass('position-relative border-top border-bottom');
559 }
560
561 return false;
562 } );
563
564 });
565
566 }
567
568
569 /**
570 * Open a lightbox when an embed item is clicked.
571 */
572 function aui_lightbox_embed($link,ele){
573 ele.preventDefault();
574
575 // remove it first
576 jQuery('.aui-carousel-modal').remove();
577
578 var $modal = '<div class="modal fade aui-carousel-modal bsui" tabindex="-1" role="dialog" aria-labelledby="aui-modal-title" aria-hidden="true"><div class="modal-dialog modal-dialog-centered modal-xl mw-100"><div class="modal-content bg-transparent border-0 shadow-none"><div class="modal-header"><h5 class="modal-title" id="aui-modal-title"></h5></div><div class="modal-body text-center"><i class="fas fa-circle-notch fa-spin fa-3x"></i></div></div></div></div>';
579 jQuery('body').append($modal);
580
581 jQuery('.aui-carousel-modal').modal({
582 //backdrop: 'static'
583 });
584 jQuery('.aui-carousel-modal').on('hidden.bs.modal', function (e) {
585 jQuery("iframe").attr('src', '');
586 });
587
588 $container = jQuery($link).closest('.aui-gallery');
589
590 $clicked_href = jQuery($link).attr('href');
591 $images = [];
592 $container.find('.aui-lightbox-image').each(function() {
593 var a = this;
594 var href = jQuery(a).attr('href');
595 if (href) {
596 $images.push(href);
597 }
598 });
599
600 if( $images.length ){
601 var $carousel = '<div id="aui-embed-slider-modal" class="carousel slide" >';
602
603 // indicators
604 if($images.length > 1){
605 $i = 0;
606 $carousel += '<ol class="carousel-indicators position-fixed">';
607 $container.find('.aui-lightbox-image').each(function() {
608 $active = $clicked_href == jQuery(this).attr('href') ? 'active' : '';
609 $carousel += '<li data-target="#aui-embed-slider-modal" data-slide-to="'+$i+'" class="'+$active+'"></li>';
610 $i++;
611 });
612 $carousel += '</ol>';
613 }
614
615 // items
616 $i = 0;
617 $carousel += '<div class="carousel-inner">';
618 $container.find('.aui-lightbox-image').each(function() {
619 var a = this;
620 var href = jQuery(a).attr('href');
621
622 $active = $clicked_href == jQuery(this).attr('href') ? 'active' : '';
623 $carousel += '<div class="carousel-item '+ $active+'"><div>';
624
625 // image
626 var css_height = window.innerWidth > window.innerHeight ? '90vh' : 'auto';
627 var img = href ? jQuery(a).find('img').clone().attr('src', href ).attr('sizes', '').removeClass().addClass('mx-auto d-block w-auto mw-100 rounded').css('max-height',css_height).get(0).outerHTML : jQuery(a).find('img').clone().removeClass().addClass('mx-auto d-block w-auto mw-100 rounded').css('max-height',css_height).get(0).outerHTML;
628 $carousel += img;
629 // captions
630 if(jQuery(a).parent().find('.carousel-caption').length ){
631 $carousel += jQuery(a).parent().find('.carousel-caption').clone().removeClass('sr-only').get(0).outerHTML;
632 }else if(jQuery(a).parent().find('.figure-caption').length ){
633 $carousel += jQuery(a).parent().find('.figure-caption').clone().removeClass('sr-only').addClass('carousel-caption').get(0).outerHTML;
634 }
635 $carousel += '</div></div>';
636 $i++;
637 });
638
639 $container.find('.aui-lightbox-iframe').each(function() {
640 var a = this;
641
642 $active = $clicked_href == jQuery(this).attr('href') ? 'active' : '';
643 $carousel += '<div class="carousel-item '+ $active+'"><div class="modal-xl mx-auto embed-responsive embed-responsive-16by9">';
644
645 // iframe
646 var css_height = window.innerWidth > window.innerHeight ? '95vh' : 'auto';
647 var url = jQuery(a).attr('href');
648 var iframe = '<iframe class="embed-responsive-item" style="height:'+css_height +'" src="'+url+'?rel=0&amp;showinfo=0&amp;modestbranding=1&amp;autoplay=1" id="video" allow="autoplay"></iframe>';
649 var img = iframe ;//.css('height',css_height).get(0).outerHTML;
650 $carousel += img;
651
652 $carousel += '</div></div>';
653 $i++;
654 });
655 $carousel += '</div>';
656
657 // next/prev indicators
658 if($images.length > 1) {
659 $carousel += '<a class="carousel-control-prev" href="#aui-embed-slider-modal" role="button" data-slide="prev">';
660 $carousel += '<span class="carousel-control-prev-icon" aria-hidden="true"></span>';
661 $carousel += ' <a class="carousel-control-next" href="#aui-embed-slider-modal" role="button" data-slide="next">';
662 $carousel += '<span class="carousel-control-next-icon" aria-hidden="true"></span>';
663 $carousel += '</a>';
664 }
665
666 $carousel += '</div>';
667
668 var $close = '<button type="button" class="close text-white text-right position-fixed" style="font-size: 2.5em;right: 20px;top: 10px; z-index: 1055;" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
669
670 jQuery('.aui-carousel-modal .modal-content').html($carousel).prepend($close);
671
672 // enable ajax load
673 //gd_init_carousel_ajax();
674 }
675 }
676
677 /**
678 * Init lightbox embed.
679 */
680 function aui_init_lightbox_embed(){
681 // Open a lightbox for embeded items
682 jQuery('.aui-lightbox-image, .aui-lightbox-iframe').off('click').on("click",function(ele) {
683 aui_lightbox_embed(this,ele);
684 });
685 }
686
687 /**
688 * Init modal iframe.
689 */
690 function aui_init_modal_iframe() {
691 jQuery('.aui-has-embed, [data-aui-embed="iframe"]').each(function(e){
692 if (!jQuery(this).hasClass('aui-modal-iframed') && jQuery(this).data('embed-url')) {
693 jQuery(this).addClass('aui-modal-iframed');
694
695 jQuery(this).on("click",function(e1) {
696 aui_modal_iframe('',jQuery(this).data('embed-url'),'',true,'','modal-lg','aui-modal-iframe p-0',true);
697 return false;
698 });
699 }
700 });
701 }
702
703 /**
704 * Show a toast.
705 */
706 $aui_doing_toast = false;
707 function aui_toast($id,$type,$title,$title_small,$body,$time,$can_close){
708
709 if($aui_doing_toast){setTimeout(function(){
710 aui_toast($id,$type,$title,$title_small,$body,$time,$can_close);
711 }, 500); return;}
712
713 $aui_doing_toast = true;
714
715 if($can_close == null){$can_close = false;}
716 if($time == '' || $time == null ){$time = 3000;}
717
718 // if already setup then just show
719 if(document.getElementById($id)){
720 jQuery('#'+$id).toast('show');
721 setTimeout(function(){ $aui_doing_toast = false; }, 500);
722 return;
723 }
724
725 var uniqid = Date.now();
726 if($id){
727 uniqid = $id;
728 }
729
730 $op = "";
731 $tClass = '';
732 $thClass = '';
733 $icon = "";
734
735 if ($type == 'success') {
736 $op = "opacity:.92;";
737 $tClass = 'alert alert-success';
738 $thClass = 'bg-transparent border-0 alert-success';
739 $icon = "<div class='h5 m-0 p-0'><i class='fas fa-check-circle mr-2'></i></div>";
740 } else if ($type == 'error' || $type == 'danger') {
741 $op = "opacity:.92;";
742 $tClass = 'alert alert-danger';
743 $thClass = 'bg-transparent border-0 alert-danger';
744 $icon = "<div class='h5 m-0 p-0'><i class='far fa-times-circle mr-2'></i></div>";
745 } else if ($type == 'info') {
746 $op = "opacity:.92;";
747 $tClass = 'alert alert-info';
748 $thClass = 'bg-transparent border-0 alert-info';
749 $icon = "<div class='h5 m-0 p-0'><i class='fas fa-info-circle mr-2'></i></div>";
750 } else if ($type == 'warning') {
751 $op = "opacity:.92;";
752 $tClass = 'alert alert-warning';
753 $thClass = 'bg-transparent border-0 alert-warning';
754 $icon = "<div class='h5 m-0 p-0'><i class='fas fa-exclamation-triangle mr-2'></i></div>";
755 }
756
757
758 // add container if not exist
759 if(!document.getElementById("aui-toasts")){
760 jQuery('body').append('<div class="bsui" id="aui-toasts"><div class="position-fixed aui-toast-bottom-right pr-3 mb-1" style="z-index: 500000;right: 0;bottom: 0;'+$op+'"></div></div>');
761 }
762
763 $toast = '<div id="'+uniqid+'" class="toast fade hide shadow hover-shadow '+$tClass+'" style="" role="alert" aria-live="assertive" aria-atomic="true" data-delay="'+$time+'">';
764 if($type || $title || $title_small){
765 $toast += '<div class="toast-header '+$thClass+'">';
766 if($icon ){$toast += $icon;}
767 if($title){$toast += '<strong class="mr-auto">'+$title+'</strong>';}
768 if($title_small){$toast += '<small>'+$title_small+'</small>';}
769 if($can_close){$toast += '<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close"><span aria-hidden="true">×</span></button>';}
770 $toast += '</div>';
771 }
772
773 if($body){
774 $toast += '<div class="toast-body">'+$body+'</div>';
775 }
776
777 $toast += '</div>';
778
779 jQuery('.aui-toast-bottom-right').prepend($toast);
780 jQuery('#'+uniqid).toast('show');
781 setTimeout(function(){ $aui_doing_toast = false; }, 500);
782 }
783
784 /**
785 * Animate a number.
786 */
787 function aui_init_counters(){
788
789 const animNum = (EL) => {
790
791 if (EL._isAnimated) return; // Animate only once!
792 EL._isAnimated = true;
793
794 let end = EL.dataset.auiend;
795 let start = EL.dataset.auistart;
796 let duration = EL.dataset.auiduration ? EL.dataset.auiduration : 2000;
797 let seperator = EL.dataset.auisep ? EL.dataset.auisep: '';
798
799 jQuery(EL).prop('Counter', start).animate({
800 Counter: end
801 }, {
802 duration: Math.abs(duration),
803 easing: 'swing',
804 step: function(now) {
805 const text = seperator ? (Math.ceil(now)).toLocaleString('en-US') : Math.ceil(now);
806 const html = seperator ? text.split(",").map(n => `<span class="count">${n}</span>`).join(",") : text;
807 if(seperator && seperator!=','){
808 html.replace(',',seperator);
809 }
810 jQuery(this).html(html);
811 }
812 });
813 };
814
815 const inViewport = (entries, observer) => {
816 // alert(1);
817 entries.forEach(entry => {
818 if (entry.isIntersecting) animNum(entry.target);
819 });
820 };
821
822 jQuery("[data-auicounter]").each((i, EL) => {
823 const observer = new IntersectionObserver(inViewport);
824 observer.observe(EL);
825 });
826 }
827
828
829 /**
830 * Initiate all AUI JS.
831 */
832 function aui_init(){
833
834 // init counters
835 aui_init_counters();
836
837 // nav menu submenus
838 init_nav_sub_menus();
839
840 // init tooltips
841 aui_init_tooltips();
842
843 // init select2
844 aui_init_select2();
845
846 // init flatpickr
847 aui_init_flatpickr();
848
849 // init iconpicker
850 aui_init_iconpicker();
851
852 // init Greedy nav
853 aui_init_greedy_nav();
854
855 // Set times to time ago
856 aui_time_ago('timeago');
857
858 // init multiple item carousels
859 aui_init_carousel_multiple_items();
860
861 // init lightbox embeds
862 aui_init_lightbox_embed();
863
864 /* Init modal iframe */
865 aui_init_modal_iframe();
866 }
867
868 // run on window loaded
869 jQuery(window).on("load",function() {
870 aui_init();
871 });
872
873 /* Fix modal background scroll on iOS mobile device */
874 jQuery(function($) {
875 var ua = navigator.userAgent.toLowerCase();
876 var isiOS = ua.match(/(iphone|ipod|ipad)/);
877 if (isiOS) {
878 var pS = 0; pM = parseFloat($('body').css('marginTop'));
879
880 $(document).on('show.bs.modal', function() {
881 pS = window.scrollY;
882 $('body').css({
883 marginTop: -pS,
884 overflow: 'hidden',
885 position: 'fixed',
886 });
887 }).on('hidden.bs.modal', function() {
888 $('body').css({
889 marginTop: pM,
890 overflow: 'visible',
891 position: 'inherit',
892 });
893 window.scrollTo(0, pS);
894 });
895 }
896 });
897
898 /**
899 * Show a "confirm" dialog to the user (using jQuery UI's dialog)
900 *
901 * @param {string} message The message to display to the user
902 * @param {string} okButtonText OPTIONAL - The OK button text, defaults to "Yes"
903 * @param {string} cancelButtonText OPTIONAL - The Cancel button text, defaults to "No"
904 * @returns {Q.Promise<boolean>} A promise of a boolean value
905 */
906 var aui_confirm = function (message, okButtonText, cancelButtonText, isDelete, large ) {
907 okButtonText = okButtonText || 'Yes';
908 cancelButtonText = cancelButtonText || 'Cancel';
909 message = message || 'Are you sure?';
910 sizeClass = large ? '' : 'modal-sm';
911 btnClass = isDelete ? 'btn-danger' : 'btn-primary';
912
913 deferred = jQuery.Deferred();
914 var $body = "";
915 $body += "<h3 class='h4 py-3 text-center text-dark'>"+message+"</h3>";
916 $body += "<div class='d-flex'>";
917 $body += "<button class='btn btn-outline-secondary w-50 btn-round' data-dismiss='modal' onclick='deferred.resolve(false);'>"+cancelButtonText+"</button>";
918 $body += "<button class='btn "+btnClass+" ml-2 w-50 btn-round' data-dismiss='modal' onclick='deferred.resolve(true);'>"+okButtonText+"</button>";
919 $body += "</div>";
920 $modal = aui_modal('',$body,'',false,'',sizeClass);
921
922 return deferred.promise();
923 };
924
925 /**
926 * Flip the color scheem on scroll
927 * @param $value
928 * @param $iframe
929 */
930 function aui_flip_color_scheme_on_scroll($value, $iframe){
931 if(!$value) $value = window.scrollY;
932 var navbar = $iframe ? $iframe.querySelector('.color-scheme-flip-on-scroll') : document.querySelector('.color-scheme-flip-on-scroll');
933 if (navbar == null) return;
934
935 let cs_original = navbar.dataset.cso;
936 let cs_scroll = navbar.dataset.css;
937
938 if (!cs_scroll && !cs_original) {
939 if( navbar.classList.contains('navbar-light') ){
940 cs_original = 'navbar-light';
941 cs_scroll = 'navbar-dark';
942 }else if( navbar.classList.contains('navbar-dark') ){
943 cs_original = 'navbar-dark';
944 cs_scroll = 'navbar-light';
945 }
946
947 navbar.dataset.cso = cs_original;
948 navbar.dataset.css = cs_scroll;
949 }
950
951 if($value > 0 ){
952 navbar.classList.remove(cs_original);
953 navbar.classList.add(cs_scroll);
954 }else{
955 navbar.classList.remove(cs_scroll);
956 navbar.classList.add(cs_original);
957 }
958 }
959
960 /**
961 * Add a window scrolled data element.
962 */
963 window.onscroll = function () {
964 aui_set_data_scroll()
965 };
966
967 /**
968 * Set scroll data element.
969 */
970 function aui_set_data_scroll(){
971 document.documentElement.dataset.scroll = window.scrollY;
972 }
973
974 // call data scroll function ASAP.
975 aui_set_data_scroll();
976 aui_flip_color_scheme_on_scroll();
977
978 <?php
979 // FSE tweaks.
980 if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template' || !empty($_REQUEST['canvas']) ){ ?>
981 function aui_fse_set_data_scroll() {
982 console.log('init scroll');
983 let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas");
984 if( Iframe[0] === undefined ){ return; }
985 let iframe_doc = Iframe[0].contentWindow ? Iframe[0].contentWindow.document : Iframe[0].contentDocument;
986 Iframe[0].contentWindow.onscroll = function () {
987 iframe_doc.documentElement.dataset.scroll = Iframe[0].contentWindow.scrollY;
988 aui_flip_color_scheme_on_scroll(Iframe[0].contentWindow.scrollY,iframe_doc);
989 };
990 }
991
992 setTimeout(function(){
993 aui_fse_set_data_scroll();
994 }, 3000);
995
996 // fire when URL changes also.
997 let FSElastUrl = location.href;
998 new MutationObserver(() => {
999 const url = location.href;
1000 if (url !== FSElastUrl) {
1001 FSElastUrl = url;
1002 aui_fse_set_data_scroll();
1003 // fire a second time incase of load delays.
1004 setTimeout(function(){
1005 aui_fse_set_data_scroll();
1006 }, 2000);
1007 }
1008 }).observe(document, {subtree: true, childList: true});
1009 <?php } ?>
1010
1011
1012 </script>
1013