Issues (865)

Security Analysis    4 potential vulnerabilities

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection (1)
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection (2)
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting (1)
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

ayecode/wp-ayecode-ui/includes/inc/bs4-js.php (1 issue)

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