PageSourceSearch

https://hbrarabic.com/wp-content/themes/majarra/js/global-main.js?ver=2.79.23

js hbrarabic.com collected 2026-10-02 07:45:23 UTC 40,653 bytes, 1,158 lines download raw bytes

1// Short for console.log
2function log($txt) {
3    console.log($txt);
4}
5
6// Used for debug info only
7function dlog($txt) {
8    if (GLOBAL_JS_SETTINGS.WP_JS_DEBUG)
9        log($txt);
10}
11
12// Replace all 404 images on webpage with a placeholder.
13window.addEventListener('error', function(e) {
14    var img_ele = e.srcElement;
15    // dlog(img_ele.src); // The 404 url
16
17    // if not image, ignore.
18    if( img_ele.tagName != 'IMG'){
19        return;
20    }
21    // if the 404 image is from a 3rd party (like tracking pixels). Ignore.
22    if( ! img_ele.src.includes(window.location.hostname) ){
23        return;
24    }
25    // if this code already processed this image skip it. Prevents infinite loops.
26    if( img_ele.classList.contains('4xx-image-replaced')){
27        return;
28    }
29
30    // IMPORTANT FOR DEVs:
31    // If the placeholder is also 404 the browser will go in infinite loop and crash !
32    img_ele.src = GLOBAL_JS_SETTINGS.SITE_URL + "/wp-content/themes/majarra/img/majarra-logo-new.svg";
33    img_ele.removeAttribute('srcset');
34    img_ele.removeAttribute('sizes');
35    img_ele.classList.add('4xx-image-replaced');
36
37    // // Set the max sizes for the newly loaded placeholder.
38    // img_ele.style.maxWidth = img_ele.getAttribute('width') + 'px';
39    // img_ele.style.maxHeight = img_ele.getAttribute('height') + 'px';
40
41    dlog("Replaced Image with Placeholder. ");
42}, true);
43
44
45document.addEventListener("DOMContentLoaded", function() {
46    injectUTM();
47    var currentUrl = window.location.origin + window.location.pathname; // Strips query params and fragments
48
49    // Select all menu items, excluding .sub-menu-toggle links
50    var menuItems = document.querySelectorAll("ul.menu li a:not(.sub-menu-toggle)");
51
52    menuItems.forEach(function(item) {
53        var itemUrl = item.href;  // Get the URL of the <a> tag
54        if (itemUrl === currentUrl) {
55            item.parentElement.classList.add("current-menu-item");  // Add the class to the parent <li>
56        }
57    });
58});
59
60
61
62
63var currentGiftPopupPostition = 0;
64var gift_bool = "false";
65var click_share_btn = "false";
66jQuery(function ($) {
67
68    // Reset button for lableb input field
69    $('.lableb-wrap .reset-button').click( function() {
70        this.style.display = 'none';
71    });
72    $('.lableb-wrap input').on('input', function() {
73        if ($(this).val() === '') {
74            $('.lableb-wrap .reset-button').hide();
75        } else {
76            $('.lableb-wrap .reset-button').show();
77        }
78    });
79
80
81    // Filter in search page
82    $('.tablinks').click(function() {
83        var tabName = $(this).data('tab');
84
85        // Hide all tab content
86        $('.tabcontent').addClass('d-none');
87
88        // Remove 'active' class from all tab links
89        $('.tablinks').removeClass('active');
90
91        // Show clicked tab content and add 'active' class to clicked tab link
92        $('#' + tabName).removeClass('d-none');
93        $(this).addClass('active');
94        $('.loader').hide();
95    });
96
97    // Activate first tab by default
98    $('.tablinks').eq(0).trigger('click');
99
100    // --------------------------------------------------------------------------------------
101    // Ajax Load Search Results Tab
102
103    $(".tab > button.tablinks").click(function(e){
104
105        if(document.querySelector('#' + this.dataset.tab)){
106            $(".tabcontent").hide(); // Hide all other tabs
107            $('#' + this.dataset.tab).show();
108            return false;
109        }
110        jQuery.ajax({
111            type: "get",
112            url: GLOBAL_JS_SETTINGS.AJAX_URL,
113            data: {
114                action: 'load_widget',
115                slug : "template-parts/search-results-tab",
116                name : null,
117                args : JSON.stringify({
118                    s: document.querySelector("#lableb-search-results").dataset.searchQuery,
119                    pt: this.dataset.tab,
120                    hide_tab: false
121                })
122            },
123            success: function (response) {
124                $(".tabcontent").hide(); // Hide all other tabs
125                $("#lableb-search-results").append(response);
126            }
127        });
128    })
129
130    // Sticky header
131    window.onscroll = function () {
132        sticky_header()
133    };
134
135    var header = document.getElementById("platform-header");
136    var sticky = header.offsetTop + 450;
137
138    function sticky_header() {
139        if (window.pageYOffset > sticky) {
140            header.classList.add("sticky");
141        } else {
142            header.classList.remove("sticky");
143        }
144    }
145    // Share on mobile
146    if (/Mobi/.test(navigator.userAgent)) {
147
148        // Code to be executed for mobile devices
149        const shareButton = document.getElementById('share-btn-mobile');
150        // Check if the Web Share API is supported by the browser
151        if (navigator.share != 'undefined' && shareButton != null) {
152            shareButton.addEventListener('click', () => {
153                // Call the share function
154                navigator.share({
155                    title: 'Share link',
156                    text: 'Check out this link',
157                    url: ""
158                })
159                    .then(() => log('Shared successfully'))
160                    .catch((error) => log('Error sharing:', error));
161            });
162        }
163    }
164
165    // declare screenSize variable
166    // let screenSize;
167    // // resizeEvent function
168    // const resizeEvent = function () {
169    //     // if viewportWidth width <= 991
170    //     if (window.innerWidth <= 576) {
171    //         // set screenSize as mobile
172    //         screenSize = 1;
173    //     } else if (window.innerWidth < 992) {
174    //         // set screenSize as tablet
175    //         screenSize = 2;
176    //     } else {
177    //         // set screenSize as desktop
178    //         screenSize = 3
179    //     }
180    // }
181    //
182    // resizeEvent(); // run resizeEvent function onload
183    //
184    // $(window).on('resize', resizeEvent); // run resizeEvent function onresize
185    //
186    // // Paywall login
187    // $(window).ready(() => {
188    //     // if screenSize is mobile
189    //     if (screenSize == 1) {
190    //         // append login paywall mobile
191    //         $(window).scroll(function () {
192    //             var height = $(window).scrollTop();
193    //             if (height > 20) {
194    //                 $('#login-paywall,#limit-daily').css('bottom', '0');
195    //             } else {
196    //                 $('#login-paywall,#limit-daily').css('bottom', '-50%');
197    //             }
198    //         });
199    //     }
200    //     // if screenSize is tablet
201    //     else if (screenSize == 2) {
202    //         // append login paywall tablet
203    //         $(window).ready(function () {
204    //             var height = $(window).scrollTop();
205    //             if (height < 20) {
206    //                 $('#login-paywall,#limit-daily').css('bottom', '0');
207    //             } else {
208    //                 $('#login-paywall,#limit-daily').css('bottom', '0');
209    //             }
210    //         });
211    //     }
212    //     // if screenSize is desktop
213    //     else {
214    //         // append login paywall desktop
215    //         $(window).scroll(function () {
216    //             var height = $(window).scrollTop();
217    //             if (height > 15) {
218    //                 $('#login-paywall,#limit-daily').css('bottom', '0');
219    //             } else {
220    //                 $('#login-paywall,#limit-daily').css('bottom', '-50%');
221    //             }
222    //         });
223    //     }
224    // });
225    //
226    // // Paywall limit reach
227    // $(window).ready(() => {
228    //     // if screenSize is mobile
229    //     if (screenSize == 1) {
230    //         // append login paywall mobile
231    //         $(window).scroll(function () {
232    //             var height = $(window).scrollTop();
233    //             if (height > 175) {
234    //                 $('#limit-reached-paywall,#subs-only-paywall').css('bottom', '0');
235    //             } else {
236    //                 $('#limit-reached-paywall,#subs-only-paywall').css('bottom', '-100%');
237    //             }
238    //         });
239    //     }
240    //     // if screenSize is tablet
241    //     else if (screenSize == 2) {
242    //         // append login paywall tablet
243    //         $(window).ready(function () {
244    //             var height = $(window).scrollTop();
245    //             if (height < 20) {
246    //                 $('#limit-reached-paywall,#subs-only-paywall').css('bottom', '0');
247    //             } else {
248    //                 $('#limit-reached-paywall,#subs-only-paywall').css('bottom', '0');
249    //             }
250    //         });
251    //     }
252    //     // if screenSize is desktop
253    //     else {
254    //         // append login paywall desktop
255    //         $(window).scroll(function () {
256    //             var height = $(window).scrollTop();
257    //             if (height > 15) {
258    //                 $('#limit-reached-paywall,#subs-only-paywall').css('bottom', '0');
259    //             } else {
260    //                 $('#limit-reached-paywall,#subs-only-paywall').css('bottom', '-100%');
261    //             }
262    //         });
263    //     }
264    // });
265
266    // Helper Functions
267    function copyToClipBoard(text_to_copy) {
268        var $temp = $("<input>");
269        $("body").append($temp);
270        $temp.val(text_to_copy).select();
271        document.execCommand("copy");
272        $temp.remove();
273    }
274
275    $('.burger-menu').click(function (e) {
276        $('.side-panel').css({'transform': 'translate(0,-50%)'});
277        $('.side-panel-underlay').show();
278    });
279    $('.user-profile img').click(function (e) {
280        $('.user-profile .dropdown').toggleClass('d-xl-none');
281    });
282
283    $('.side-panel-underlay, .side-panel-close-button').click(function (e) {
284        $('.side-panel').css({'transform': 'translate(-100%,-50%)'});
285        $('.side-panel-underlay').hide(100);
286    });
287
288    $('.majarra-platforms-button a').click(function (e) {
289        e.preventDefault();
290        $(this).toggleClass('active');
291        $('.majarra-platforms-button a > svg').toggleClass('active');
292    });
293
294    $('.majarra-platforms-button').on('click',
295        function(event) {
296            event.stopPropagation();
297            $('.platforms-logos').toggleClass('d-none');
298        });
299
300    $(document).on("mouseup", function (e) {
301        var container = jQuery(".majarra-platforms-button");
302        if ((!container.is(e.target) && container.has(e.target).length === 0)) {
303            $('.platforms-logos').addClass('d-none');
304            $('.majarra-platforms-button a').removeClass('active');
305            $('.majarra-platforms-button a > svg').removeClass('active');
306        }
307    });
308    $(document).on("mouseup", function (e) {
309        var container = jQuery(".menu-item-has-children");
310        if ((!container.is(e.target) && container.has(e.target).length === 0)) {
311            $(".sub-menu").removeClass('d-flex')
312            $("a.sub-menu-toggle > img").removeClass('rotate-180')
313        }
314    });
315
316    $('.menu-item-has-children > a').click(function (e) {
317        e.preventDefault();
318        var submenu = $('.sub-menu', $(this).parent());
319        var img = $('a.sub-menu-toggle > img', $(this).parent());
320
321        // If the sub-menu is already visible, hide it
322        if(submenu.hasClass('d-flex')) {
323            submenu.removeClass('d-flex');
324            img.removeClass('rotate-180');
325        } else {
326            // Hide all other dropdown menus
327            $('.menu-item-has-children').siblings().find('.sub-menu').removeClass('d-flex');
328            $('.menu-item-has-children').siblings().find('a.sub-menu-toggle > img').removeClass('rotate-180');
329
330            // Show the clicked dropdown menu
331            submenu.addClass('d-flex');
332            img.addClass('rotate-180');
333        }
334    });
335
336    $('.share-to-social-icons .share-icon').click(function (e) {
337        $('.share-to-social-icons').toggleClass('share-to-social-icons-expanded');
338    });
339
340    $('.search-icon').click(function (e) {
341        $('.lableb-wrap').removeClass('d-none');
342    });
343    $('.lableb-wrap').click(function (e) {
344        /* ignore if the click was on the input form or button not the underlay */
345        if (e.target !== this) {
346            return;
347        }
348        $('.lableb-wrap').addClass('d-none');
349    });
350
351    // Copy Current URL to clipboard
352    $('img[alt="copylink"], img[alt="Copy Link"]').parent().on('click', function (e) {
353        e.preventDefault();
354        copyToClipBoard($(location).attr('href'));
355    });
356
357    // --------------------------------------------------------------------------------------
358    // Paywalls
359
360    // Login Button
361    jQuery('button.sign-in').click(function (e) {
362
363        var email = $('input[name="email"]').val();
364        var purchaseKey = $(this).data('purchase-key');
365        var clientId = $(this).data('client');
366        var referral = $(this).data('referral');
367        var ssoApi = $(this).data('sso-api');
368        var sso_id = $.cookie('subscribed_content');
369
370        var url = ssoApi + 'integration?provider=email&email=' + email + '&secret=' + purchaseKey + '&client=' + clientId + '&sso_id=' + sso_id + '&referral=' + referral;
371        window.location.href = url;
372    });
373
374
375    // --------------------------------------------------------------------------------------
376    // Lableb Autocomplete Search
377    var lableb_field = document.getElementById('lableb-search');
378    var awesomplete = new Awesomplete(lableb_field, {
379        list: [],
380        container: function(input) {
381            return document.getElementById('lableb-autocomplete-results');
382        },
383        item: function(text, input) {
384            var link = document.createElement('a');
385            link.href = text.value;
386            link.dataset.lablebId = text.lableb_id;
387
388            // Highlight the matching part in the label
389            var label = text.label;
390            var regex = new RegExp(input.trim(), 'gi');
391            var highlightedLabel = label.replace(regex, function(match) {
392                return '<mark>' + match + '</mark>';
393            });
394            link.innerHTML = highlightedLabel;
395
396            var li = document.createElement('li');
397            li.appendChild(link);
398            return li;
399        },
400        filter: function() {
401            return true; // Don't match letters, return as lableb says.
402        },
403        sort: false // Disable sorting
404    });
405
406    lableb_field.addEventListener('input', function() {
407        var data = {
408            'action': 'lableb_autocomplete',
409            'q': lableb_field.value
410        };
411        jQuery.ajax({
412            type: "get",
413            url: GLOBAL_JS_SETTINGS.AJAX_URL,
414            data: data,
415            success: function (data) {
416                data = JSON.parse(data);
417                awesomplete.list = data;
418                document.getElementById('lableb-autocomplete-results').classList.remove('d-none');
419            }
420        });
421    });
422
423    awesomplete.replace = function(suggestion) {
424        if(suggestion.value == '#')return false;
425
426        this.input.value = suggestion.label;
427    };
428
429    // Click On Autocomplete Result
430    $(document).on('click', '#lableb-autocomplete-results a', function (event) {
431        // Send Feedback to Lableb
432        ele = $(this);
433        if(ele.attr('href') == '#')return false;
434
435        lableb_feedback(ele, 'autocomplete', ele.text());
436    });
437
438    // Any click outside that div will hide it
439    $(document).on('click', function (event) {
440        if (!$(event.target).closest('#lableb-results').length) {
441            $('#lableb-autocomplete-results').addClass('d-none');
442        }
443    });
444
445
446    // --------------------------------------------------------------------------------------
447    // Lableb Feedback
448
449    // Search Results
450    jQuery('#lableb-search-results a').click(function (e) {
451        e.preventDefault();
452        ele = $(this);
453        lableb_feedback(ele, 'search', lableb_field.value);
454    });
455
456    function lableb_feedback(clicked_ele, type, q) {
457        var data = {
458            'action': 'lableb_feedback',
459            'type': type, // "Search" or "Autocomplete"
460            'q': q, // Search Query
461            'clicked_result_index': clicked_ele.parent().index(), // Result order
462            'clicked_result_link': clicked_ele.attr('href'),
463        };
464        jQuery.ajax({
465            type: "post",
466            url: GLOBAL_JS_SETTINGS.AJAX_URL,
467            data: data,
468            complete: function (data) {
469                window.location.href =  clicked_ele.attr('href');
470            }
471        });
472    }
473
474    // --------------------------------------------------------------------------------------
475    // Recommendations Feedback
476
477    $(document).on('click', '.recommended-posts a.post-link', function (event) {
478        event.preventDefault();
479        clicked_ele = $(this);
480        parent_loop = $(this).closest('.related-posts');
481        var data = {
482            'action': 'recommended_posts_feedback',
483            'source_id': PAGE_INFO.id,
484            'content_id': $('.article-loop',parent_loop).data('post_id'),
485            'item_order': parent_loop.index(), // Result order
486        };
487        jQuery.ajax({
488            type: "post",
489            url: GLOBAL_JS_SETTINGS.AJAX_URL,
490            data: data,
491            complete: function (data) {
492               window.location.href =  clicked_ele.attr('href');
493            }
494        });
495    });
496
497
498    // --------------------------------------------------------------------------------------
499    // Newsletters Subscription
500    $('.newsletter_btn').click(function (e) {
501        var button = $(this);
502        var data_newsletter = {
503            'action': 'newsletter_' + $(button).attr('data-action'), // IMPORTANT: use .attr instead of .data here
504            'sso-newsletter-id': $(button).data('sso-newsletter-id'),
505            'email': $(button).siblings('input[type="email"]').val(),
506        };
507        button.attr('disabled', 'disabled');
508        jQuery.ajax({
509            type: "post",
510            url: GLOBAL_JS_SETTINGS.AJAX_URL,
511            data: data_newsletter,
512            success: function (data) {
513                data = JSON.parse(data);
514                $('.newsletter-subscription').remove();
515                if ((data.status ?? false) == 'success') {
516
517                    $(document).trigger('newsletter_sub_success');
518                    button.parent().parent().append('<span class="newsletter-subscription success">'+data.message+'</span>');
519
520                    // Toggle Button Action
521                    if($(button).attr('data-action') == 'subscribe' ){
522                        $(button ).attr('data-action', 'unsubscribe');
523                        $(button ).text('إلغاء الاشتراك');
524                    }
525                    else{
526                        $(button ).attr('data-action', 'subscribe');
527                        $(button ).text('إشتراك');
528                    }
529
530
531                } else {
532                    button.parent().parent().append('<span class="newsletter-subscription failed">'+data.message+'</span>');
533                }
534
535                setTimeout(function() {
536                        $('.newsletter-subscription').hide();
537                    }, 2000);
538            },
539            complete: function (data) {
540                button.removeAttr('disabled');
541            }
542        });
543
544    });
545
546    // --------------------------------------------------------------------------------------
547    // Cookie & Yellow Banner
548    var lastScrollTop = 0;
549    $(window).scroll(function () {
550        var currentScrollTop = $(this).scrollTop();
551        if (currentScrollTop > lastScrollTop) {
552            // Scrolling down
553            $('.yellow-pricing-container').hide();
554            $('.m-banner-app').hide();
555        } else {
556            // Scrolling up
557            $('.yellow-pricing-container').show();
558            $('.m-banner-app').show();
559        }
560        lastScrollTop = currentScrollTop;
561    });
562
563    $('.cookie-container button').click(function () {
564        document.cookie = 'hideCookieContainer=true; expires=' + new Date(new Date().getTime() + 365 * 24 * 60 * 60 * 1000).toUTCString() + '; path=/';
565        $('.cookie-container').hide();
566    });
567
568    // --------------------------------------------------------------------------------------
569    // Generate Gift (HTML in generate-link.php)
570
571    const gift_button = $('#gift-button');
572
573    gift_button.click(function (e) {
574        $('#gift-wrapper').show();
575    });
576
577    $('body').on('click', '.gift-popup-close', function(e) {
578        $('#gift-wrapper').hide();
579    });
580
581    $('body').on('click', '#gift-wrapper a[href="javascript:void(0)"]', function(e) {
582        e.preventDefault();
583        copyToClipBoard(copy_gift_link);
584
585        // Show Message
586        const link_copied_success_msg = $('#link-copied-successfully');
587        link_copied_success_msg.show();
588        link_copied_success_msg.click(function (e) {
589            link_copied_success_msg.hide();
590        });
591        setTimeout(function () {
592            link_copied_success_msg.fadeOut("slow");
593        }, 2000);
594    });
595
596    const gift_generate_link_button = $('#generate_gift');
597    gift_generate_link_button.click(function (e) {
598        $('.loader').show();
599        gift_generate_link_button.addClass('gift-button-loading');
600        gift_generate_link_button.html('يرجى الانتظار');
601        gift_generate_link_button.attr('disabled', 'disabled');
602
603        jQuery.ajax({
604            type: "post",
605            url: GLOBAL_JS_SETTINGS.AJAX_URL,
606            data: {
607                'action': 'generate_gift',
608                'post_id': PAGE_INFO.id,
609            },
610            success: function (data) {
611
612                data = JSON.parse(data);
613
614                // Replace the gift widget
615                $('#gift-wrapper').html(data.html);
616                $('#gift-wrapper').show();
617
618                injectUTM();
619            },
620            complete: function (data) {
621                $('.loader').hide();
622                gift_generate_link_button.removeClass('gift-button-loading');
623                gift_generate_link_button.removeAttr('disabled');
624            }
625        });
626    });
627
628    function injectUTM() {
629
630        const today  = new Date().toISOString().split("T")[0];
631        const userId = PAGE_INFO?.user_info?.id || '';
632
633        document.querySelectorAll(".gift-share-link").forEach(function(el){
634
635            let url = el.getAttribute("href");
636
637            if (url && url.startsWith("http")) {
638
639                // احذف أي UTM موجودة مسبقًا من PHP
640                url = url.split('?')[0];
641
642                // أعد بناء الرابط بالكامل من JS
643                url += '?utm_source=' + encodeURIComponent(userId);
644                url += '&utm_medium=gifting';
645                url += '&utm_campaign=' + today;
646
647                el.setAttribute("href", url);
648            }
649        });
650
651// Copy link
652        if (typeof copy_gift_link !== "undefined") {
653
654            let url = copy_gift_link;
655
656            // احذف أي UTM موجودة مسبقًا من PHP
657            url = url.split('?')[0];
658
659            // أعد بناء الرابط بالكامل من JS
660            url += '?utm_source=' + encodeURIComponent(userId);
661            url += '&utm_medium=gifting';
662            url += '&utm_campaign=' + today;
663
664            window.copy_gift_link = url;
665        }
666
667    }
668
669
670    // --------------------------------------------------------------------------------------
671    // Audio Drop Down Filter.
672    $('.audios-listing select.post_tag').change(function () {
673        window.location.href = $(this).val();
674    });
675
676
677    // --------------------------------------------------------------------------------------
678    // Ajax Load more    
679    $(document).on('click', 'button.load-more', load_more_posts);
680    function load_more_posts(e){
681
682        loadmore_button = $(this);
683        loadmore_container = loadmore_button.siblings('.load-more-container');
684
685        // if(loadmore_container.length == 0){
686        //     loadmore_container = loadmore_button.closest('.load-more-container');
687        // }
688
689        // Use .attr instead of .data !
690        current_page = parseInt(loadmore_button.attr('data-page')) + 1 ;
691        loadmore_button.attr('data-page', current_page);
692
693        var data = {
694            action: 'load_more_posts',
695            page: current_page,
696            per_page: loadmore_button.attr("data-per-page"),
697            template_to_use: loadmore_button.attr("data-template"),
698            card_col_class: loadmore_button.attr("data-card-col-class"),
699            query: loadmore_button.attr("data-query"),
700        };
701
702        loadmore_button.attr('disabled', 'disabled');
703
704        jQuery.ajax({
705            type: "post",
706            url: GLOBAL_JS_SETTINGS.AJAX_URL,
707            data: data,
708            success: function (response) {
709                if(response == '0'){
710                    loadmore_button.hide();
711                    return;
712                }
713                loadmore_button.show();
714                loadmore_container.append(response);
715
716                // Trigger a custom event
717                $(document).trigger('loaded_more_posts');
718            },
719            complete: function (data) {
720                loadmore_button.removeAttr('disabled');
721            }
722        });
723    }
724
725
726    // --------------------------------------------------------------------------------------
727    // Ajax Load Widget
728
729    ajax_widgets = $('div.ajax-widget-here');
730    ajax_widgets.each(function(){
731        var widget_placeholder = $(this);
732        jQuery.ajax({
733            type: "get",
734            url: GLOBAL_JS_SETTINGS.AJAX_URL,
735            data: {
736                action: 'load_widget',
737                slug : this.dataset.slug,
738                name : this.dataset.name,
739                args : this.dataset.args,
740                post_id : PAGE_INFO.id // The Org Page query should be passed
741            },
742            success: function (response) {
743                widget_placeholder.parent().append(response);
744                widget_placeholder.remove();
745            }
746        });
747    })
748
749
750    // --------------------------------------------------------------------------------------
751    // Ajax Dropdown filtering   
752    $('select.select-filter').change(function() {
753
754        var option = $(this).val();
755        dropdown = $(this);
756        container = $('.select-filter-container');
757
758        // Modify the wp_query args to filter on cat slug
759        if(option != "all"){
760            query = JSON.parse(dropdown.attr("data-query"));
761
762            query.tax_query = [{
763                'taxonomy': dropdown.attr("data-taxonomy") || 'category',
764                'field': 'slug',
765                'terms': option,
766                'operator': 'IN'
767            }];
768            query = JSON.stringify(query);
769        }else{
770            query = dropdown.attr("data-query");
771        }
772
773
774        var data = {
775            action: 'load_more_posts',
776            page: dropdown.attr("page"),
777            per_page: dropdown.attr("data-per-page"),
778            template_to_use: dropdown.attr("data-template"),
779            card_col_class: dropdown.attr("data-card-col-class"),
780            query: query,
781        };
782
783        jQuery.ajax({
784            type: "post",
785            url: GLOBAL_JS_SETTINGS.AJAX_URL,
786            data: data,
787            success: function (response) {
788                if(response == '0'){
789                    container.html("لا يوجد.");
790                    container.siblings('button.load-more').hide();
791                    return;
792                }
793                // Modify the query for the loadmore button
794                container.siblings('button.load-more').show();
795                container.siblings('button.load-more').removeAttr('disabled');
796                container.siblings('button.load-more').attr('data-query', query);
797
798                container.html(response);
799            }
800        });
801    });
802
803    // --------------------------------------------------------------------------------------
804    // banners
805    $('.m-banner-button-close').click(function (){
806        $('.m-update-number-container').hide();
807        // TODO: Cleanup
808        var name =$('.banner-dynamic-from-sso').attr("data-banner-name");
809        document.cookie = name + '=1; ' +
810        'expires=' + new Date(new Date().getTime() + 86400 * 15).toUTCString() +
811        '; path=/';
812    });
813
814    $('.m-banner-button-close-app').click(function (){
815        $('.m-banner-app').hide();
816        $('.m-banner-app').addClass('d-none');
817
818        // TODO: Cleanup
819        document.cookie = 'banner-app=1; ' +
820            'expires=' + new Date(new Date().getTime() + 86400 * 15).toUTCString() +
821            '; path=/';
822    });
823
824    // Show only 1 banner at a time.
825
826    var banners = $('.banner');
827    var lastBannerOrder = $.cookie('lastBannerOrder') || 0;
828    var bannerOrders = [];
829
830    // Hide all banners initially
831    banners.hide();
832
833    // Get all 'data-banner-order' values and sort them
834    banners.each(function() {
835        bannerOrders.push(+$(this).attr('data-banner-order'));
836    });
837    bannerOrders.sort(function(a, b) { return a - b; });
838    dlog('bannerOrders' +bannerOrders);
839    // Find the next banner order
840    var nextBannerOrder = bannerOrders.find(function(order) {
841        return order > lastBannerOrder;
842    });
843    dlog('nextBannerOrder' +nextBannerOrder);
844    if (nextBannerOrder === undefined) {
845        // If there's no greater order, show the first banner
846        nextBannerOrder = bannerOrders[0];
847    }
848
849    // Show the next banner
850    banners.filter('[data-banner-order="' + nextBannerOrder + '"]').show();
851
852    // Store the order of the banner just shown
853    $.cookie('lastBannerOrder', nextBannerOrder, { expires: 7 }); // Cookie will expire after 7 days
854
855
856    // --------------------------------------------------------------------------------------
857    // video-show thumbnail
858    $('.video-show').hide();
859    $('.video-thumbnail').click(function (){
860        $('.video-thumbnail').hide();
861        $('.video-show').show();
862    });
863
864    // --------------------------------------------------------------------------------------
865    // Trim Vids Cards title to not overflow. Show dot's instead
866    $('.video-loop .card-title > a').each(function() {
867        var $el = $(this);
868        var text = $el.text();
869        var maxLength = 150; // maximum number of characters to extract
870
871        // only alter text that is longer than maxLength
872        if (text.length > maxLength) {
873            // trim the text to the maximum number of characters
874            var trimmedText = text.substr(0, maxLength);
875
876            // re-trim if we are in the middle of a word
877            trimmedText = trimmedText.substr(0, Math.min(trimmedText.length, trimmedText.lastIndexOf(" ")))
878
879            $el.text(trimmedText + "...");
880        }
881    });
882
883    $('.summary_new_label2').click(function (){
884
885        $('.summary_button').show();
886        $('.summary_button').removeClass('d-none');
887
888        $('.summary_new_label3').show();
889        $('.summary_new_label3').removeClass('d-none');
890
891    });
892
893
894    const summaryButtonclick = $('#summaryButtonclick');
895    summaryButtonclick.click(function (e) {
896        dlog("summaryButtonclick");
897        var contentDiv = document.getElementById('summaryDiv');
898        if (contentDiv.classList.contains('hidden')) {
899            var data = {
900                'action': 'summary_read',
901                'sso_id': PAGE_INFO.sso_id
902            };
903            jQuery.ajax({
904                type: "GET",
905                url: GLOBAL_JS_SETTINGS.AJAX_URL,
906                data: data,
907                success: function (response) {
908                    data = JSON.parse(response);
909                    var summary = data.data.summary;
910                    $('#summary_content').html(summary);
911                    var interaction = data.data.interaction;
912                    if(data.status != 'error'){
913                        $('.summary_subscribe').addClass('d-none')
914                        $('.summary_svg_icon').removeClass('d-none')
915                        contentDiv.classList.remove('hidden');
916                        $('.summary_svg_icon').removeClass('summary_svg');
917
918                        if(summary == null){summary ="  "}
919                        $('#summary_content').html(summary);
920
921                        contentDiv.classList.remove('hidden');
922                        $('.summary_svg_icon').removeClass('summary_svg');
923                        if(interaction == "like"){
924                            var image = document.getElementById('mylike');
925                            image.src = GLOBAL_JS_SETTINGS.themeURI + '/img/like filled.svg'; // Use GLOBAL_JS_SETTINGS to set the new image URL
926                        }
927                        if(interaction == "dislike"){
928                            var image = document.getElementById('mydislike');
929                            image.src = GLOBAL_JS_SETTINGS.themeURI + '/img/Dislike filled.svg'; // Use GLOBAL_JS_SETTINGS to set the new image URL
930                        }
931
932
933                    }
934                    else {
935                        $('.summary_subscribe').removeClass('d-none')
936                        $('.summary_svg_icon').addClass('d-none')
937                    }
938                }
939            });
940
941        } else {
942            contentDiv.classList.add('hidden');
943            $('.summary_svg_icon').addClass('summary_svg');
944
945        }
946    });
947
948
949    const toggleSummaryButtonclick = $('#toggleSummary');
950    toggleSummaryButtonclick.click(function (e) {
951        dlog("toggleSummaryButtonclick");
952        var data = {
953            'action': 'summary_read',
954            'sso_id': PAGE_INFO.sso_id
955        };
956        jQuery.ajax({
957            type: "GET",
958            url: GLOBAL_JS_SETTINGS.AJAX_URL,
959            data: data,
960            success: function (response) {
961
962                data = JSON.parse(response);
963
964                if(data.status != 'error'){
965                    if(interaction == "like"){
966                        var image = document.getElementById('mylike');
967                        image.src = GLOBAL_JS_SETTINGS.themeURI + '/img/like filled.svg'; // Use GLOBAL_JS_SETTINGS to set the new image URL
968                    }
969                    if(interaction == "dislike"){
970                        var image = document.getElementById('mydislike');
971                        image.src = GLOBAL_JS_SETTINGS.themeURI + '/img/Dislike filled.svg'; // Use GLOBAL_JS_SETTINGS to set the new image URL
972                    }
973                }
974                else {
975
976                }
977            }
978        });
979    });
980
981    const changeLike = $('#changeLike');
982    changeLike.click(function (e) {
983        var imagemydislike = document.getElementById('mydislike');
984        var image = document.getElementById('mylike');
985
986        dlog("changeLike");
987        var data = {
988            'action': 'summary_like',
989            'sso_id': PAGE_INFO.sso_id
990        };
991
992        jQuery.ajax({
993            type: "post",
994            url: GLOBAL_JS_SETTINGS.AJAX_URL,
995            data: data,
996            success: function (response) {
997                data = JSON.parse(response);
998                var interaction = data.data.action;
999                dlog(data.data);
1000                if(data.status != 'error'){
1001                    if(interaction == "like"){
1002                        imagemydislike.src = GLOBAL_JS_SETTINGS.themeURI + '/img/Dislike.svg';
1003                        image.src = GLOBAL_JS_SETTINGS.themeURI + '/img/like filled.svg'; // Use GLOBAL_JS_SETTINGS to set the new image URL
1004                    }
1005                    if(interaction == "undo"){
1006                        image.src = GLOBAL_JS_SETTINGS.themeURI + '/img/thumb up.svg'; // Use GLOBAL_JS_SETTINGS to set the new image URL
1007                    }
1008                }
1009            }
1010        });
1011    });
1012
1013    const changedislike = $('#changedislike');
1014    changedislike.click(function (e) {
1015        var imagelike = document.getElementById('mylike');
1016        var image = document.getElementById('mydislike');
1017
1018        var data = {
1019            'action': 'summary_dislike',
1020            'sso_id': PAGE_INFO.sso_id
1021        };
1022        jQuery.ajax({
1023            type: "post",
1024            url: GLOBAL_JS_SETTINGS.AJAX_URL,
1025            data: data,
1026            success: function (response) {
1027                data = JSON.parse(response);
1028                var interaction = data.data.action;
1029                if(data.status != 'error'){
1030                    if(interaction == "dislike"){
1031                        imagelike.src = GLOBAL_JS_SETTINGS.themeURI + '/img/thumb up.svg';
1032                        image.src = GLOBAL_JS_SETTINGS.themeURI + '/img/Dislike filled.svg'; // Use GLOBAL_JS_SETTINGS to set the new image URL
1033                    }
1034                    if(interaction == "undo"){
1035                        image.src = GLOBAL_JS_SETTINGS.themeURI + '/img/Dislike.svg'; // Use GLOBAL_JS_SETTINGS to set the new image URL
1036                    }
1037                }
1038            }
1039        });
1040    });
1041
1042
1043    const clickShareBtn = $('.share-icon');
1044    clickShareBtn.click(function (e) {
1045
1046        if(click_share_btn == "false"){
1047            click_share_btn = 'true';
1048
1049        dlog("changeLike");
1050        var data = {
1051            'action': 'click_share_btn',
1052            'sso_id': PAGE_INFO.sso_id,
1053        };
1054
1055        jQuery.ajax({
1056            type: "post",
1057            url: GLOBAL_JS_SETTINGS.AJAX_URL,
1058            data: data,
1059            success: function (response) {
1060
1061            }
1062        });
1063        }
1064    });
1065
1066    const clickMobileShowNew = $('.sign-in-widget-mobile-show-new');
1067    clickMobileShowNew.click(function (e) {
1068        $('.show_mobile').addClass('d-none')
1069        $('.show_mobile_new').removeClass('d-none')
1070    })
1071
1072
1073    const clickMobileShowOld = $('.sign-in-widget-mobile-show-old');
1074    clickMobileShowOld.click(function (e) {
1075        $('.show_mobile').removeClass('d-none')
1076        $('.show_mobile_new').addClass('d-none')
1077    })
1078
1079    const clickShareBtnMobile = $('#share-btn-mobile');
1080    clickShareBtnMobile.click(function (e) {
1081        console.log('share-btn-mobile');
1082        if(click_share_btn == "false"){
1083            click_share_btn = 'true';
1084
1085        dlog("changeLike");
1086        var data = {
1087            'action': 'click_share_btn',
1088            'sso_id': PAGE_INFO.sso_id,
1089        };
1090
1091        jQuery.ajax({
1092            type: "post",
1093            url: GLOBAL_JS_SETTINGS.AJAX_URL,
1094            data: data,
1095            success: function (response) {
1096
1097            }
1098        });
1099        }
1100    });
1101
1102
1103    const clickSingUpBtn = $('.singup');
1104    clickSingUpBtn.click(function (e) {
1105        var email = $('input[name="email"]').val();
1106        var data = {
1107            'action': 'click_signUP',
1108            'email': email,
1109        };
1110        jQuery.ajax({
1111            type: "POST",
1112            url: GLOBAL_JS_SETTINGS.AJAX_URL,
1113            data: data,
1114            success: function(response) {
1115                var responseObj = JSON.parse(response);
1116                if(responseObj.status == "success"){
1117                    bearerToken = 'Bearer%20' + responseObj.data.access_token;
1118                    document.cookie = "sso_logged_in=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
1119                    document.cookie = "sso_is_logged_in=1; path=/; max-age=" + (86400 * 365);
1120                    document.cookie = "sso_logged_in=" + bearerToken + "; path=/; max-age=" + (30 * 24 * 60 * 60);
1121                    document.cookie = "sso_is_signup=1; path=/; max-age=" + (86400 * 365);
1122
1123                    window.location.href = window.location.href;
1124
1125
1126                }
1127                else {
1128                    const label = document.getElementById('singup_paywall');
1129                    const labelText = label.textContent;
1130                    window.location.href = labelText;
1131                }
1132
1133            },
1134            error: function(xhr, status, error) {
1135                const label = document.getElementById('singup_paywall');
1136                const labelText = label.textContent;
1137                window.location.href = labelText;
1138            }
1139        });
1140    });
1141
1142
1143    const today = new Date().toISOString().split("T")[0]; // مثال: 2026-06-29
1144
1145    document.querySelectorAll(".gift-share-link").forEach(function(el){
1146        let url = el.getAttribute("href");
1147
1148        if(url && url.startsWith("http")) {
1149            url += "&utm_campaign=" + today;
1150            el.setAttribute("href", url);
1151        }
1152    });
1153
1154    if (typeof copy_gift_link !== "undefined") {
1155        window.copy_gift_link = copy_gift_link + "&utm_campaign=" + today;
1156    }
1157
1158});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.