PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.72
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.72
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 1.0.20 1.0.21 All 174 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.72, at vendor/ayecode/wp-ayecode-ui/includes/inc/bs4-js.php

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