PageSourceSearch

https://krebs.com.pl/wp-content/plugins/divi-soical-feed/assets/js/dsf-fb-custom.js?ver=1.0.0

js krebs.com.pl collected 2026-10-08 07:33:41 UTC 7,825 bytes, 219 lines download raw bytes

1jQuery(document).ready(function($) {
2    $('.dsf_fb_slider_wrapper').each(function() {
3        let $this = $(this);
4        // Convert string values to numbers (default to 20 if empty)
5        let spacingDesktop = parseInt($this.data('spacing-desktop')) || 20;
6        let spacingTablet = parseInt($this.data('spacing-tablet')) || 20;
7        let spacingMobile = parseInt($this.data('spacing-mobile')) || 20;
8
9        let columnDesktop = $this.data('desktop-column');
10        let columnTablet = $this.data('tablet-column');
11        let columnPhone = $this.data('phone-column');
12
13        $this.find('.owl-carousel.dsf_fb_slider').owlCarousel({
14            items: 1,
15            loop: true,
16            nav: true,
17            dots: true,
18            autoplay: false,
19            autoplayTimeout: 3000,
20            navText: ['<span class="prev-arrow">‹</span>', '<span class="next-arrow">›</span>'],
21            responsive: {
22                0: {
23                    items: columnPhone || 1,
24                    margin: spacingMobile
25                },
26                768: {
27                    items: columnTablet || 2,
28                    margin: spacingTablet
29                },
30                981: {
31                    items: columnDesktop || 3,
32                    margin: spacingDesktop
33                }
34            }
35        });
36    });
37});
38
39
40jQuery(document).ready(function ($) {
41
42// Open popup when clicking the feed item — but ignore clicks on the external link
43    $(document).on("click", ".dsf_fb_feed_item", function (e) {
44        if ($(e.target).closest('a.dsf_fb_view_post_button').length) {
45            return; // ignore and allow the link to open in a new tab
46        }
47        // Optionally ignore any clicks on other interactive children (buttons, inputs, etc.)
48        if ($(e.target).closest('a, button').length) {
49            return;
50        }
51
52        let postId = $(this).data("id");
53        let postObject = $(this).data("object");
54
55        if (typeof window[postObject] === "undefined") {
56            console.error("Facebook data object not found:", postObject);
57            return;
58        }
59
60        let postData = window[postObject].media.find(post => String(post.id) === String(postId));
61        if (!postData) {
62            console.error("Post data not found for ID:", postId);
63            return;
64        }
65
66        let popup = $(".dsf_fb_popup");
67        let popupLeft = popup.find(".dsf_fb_popup_left");
68        let popupRight = popup.find(".dsf_fb_popup_right");
69
70        let popupImage = popupLeft.find("img");
71        let popupVideoContainer = popupLeft.find(".dsf_popup_video_container");
72
73        // Reset previous content
74        popupVideoContainer.empty().hide();
75        popupImage.hide();
76
77        // Handle media types
78        let attachmentType = postData.attachments?.data?.[0]?.type || postData.attachment_type || "";
79        let attachments = postData.attachments?.data || [];
80        let postSource = attachments[0]?.media?.source || "";
81        let displayImage = attachments[0]?.media?.image?.src || postData.attachment_thumb || postData.full_picture || "";
82
83        if (attachmentType === "video_inline" && postSource) {
84            // Facebook video
85            popupVideoContainer.html(`
86                <video controls autoplay>
87                    <source src="${postSource}" type="video/mp4">
88                </video>
89            `).show();
90
91        } else if (attachmentType === "share" && postSource.includes("youtube.com/embed")) {
92            // YouTube share
93            let videoUrl = postSource + "?autoplay=0&rel=0";
94            popupVideoContainer.html(`
95                <iframe 
96                    src="${videoUrl}" 
97                    frameborder="0" 
98                    allowfullscreen
99                    style="width:100%;aspect-ratio:16/9;"
100                    sandbox="allow-same-origin allow-scripts allow-presentation allow-popups">
101                </iframe>
102            `).show();
103
104        } else if (displayImage) {
105            // Single image fallback
106            popupImage.attr("src", displayImage).show();
107        }
108
109        // --- Right side data ---
110        popupRight.find(".dsf_fb_popup_username").text(postData.author_name || "Facebook Page");
111
112        let postDate = postData.created_time || "Unknown Date";
113        popupRight.find(".dsf_fb_popup_data").text(postDate);
114
115       let caption =
116            postData.message ||
117            postData.attachments?.data?.[0]?.description ||
118            postData.attachments?.data?.[0]?.title ||
119            postData.story ||
120            "No caption available.";
121
122        // Replace line breaks with <br>
123        caption = caption.replace(/\n/g, "<br>");
124
125        popupRight.find(".dsf_fb_popup_caption").html(caption);
126
127        let postLink = postData.permalink_url || "#";
128        popupRight.find(".dsf_fb_popup_view_post_button").attr("href", postLink);
129
130        let likeCount = postData.reactions?.summary?.total_count || postData.reaction_count || 0;
131        let commentCount = postData.comments?.summary?.total_count || postData.comment_count || 0;
132
133        popupRight.find(".dsf_fb_popup_meta .dsf_fb_like_count .like-count")
134            .text(likeCount ?? "0");
135
136        popupRight.find(".dsf_fb_popup_meta .dsf_fb_comment_count .comment-count")
137            .text(commentCount ?? "0");
138
139        // Show popup
140        $(".dsf_fb_popup").fadeIn(function () {
141            $("body").addClass("dsf-popup-open");
142        });
143    });
144
145    
146     /**
147     * Popup close handlers
148     */
149    $(document).on("click", ".dsf_fb_popup_close", function () {
150        stopPopupVideo(); // stop video before closing
151        $(".dsf_fb_popup").fadeOut(function () {
152            $("body").removeClass("dsf-popup-open"); // Remove class when popup closes
153        });
154    });
155
156    $(document).on("click", function (e) {
157        if ($(e.target).hasClass("dsf_fb_popup")) {
158            stopPopupVideo(); // stop video before closing
159            $(".dsf_fb_popup").fadeOut(function () {
160                $("body").removeClass("dsf-popup-open"); // Remove class when popup closes
161            });
162        }
163    });
164});
165
166/**
167 *  Helper: Stop video playback
168 */
169function stopPopupVideo() {
170    let popupVideoContainer = $(".dsf_popup_video_container");
171    popupVideoContainer.find("video").each(function () {
172        this.pause(); // stop playback
173        this.currentTime = 0; // reset time
174    });
175    popupVideoContainer.empty().hide(); // clear from DOM
176}
177
178
179 jQuery(document).ready(function ($) {
180    $(".dsf_fb_post_caption").each(function () {
181        let text = $(this).text();  
182        text = text.replace(/&lt;br\s*\/?&gt;/gi, "<br>");
183        $(this).html(text); 
184    });
185});
186
187
188jQuery(document).ready(function ($) {
189    var $grid = $('.dsf_fb_grid_masonry');
190
191    // Initialize Masonry after images load
192    $grid.imagesLoaded(function () {
193        $grid.masonry({
194            itemSelector: '.dsf_fb_feed_item',
195            columnWidth: '.grid-sizer',
196            gutter: '.gutter-sizer',
197            percentPosition: true
198        });
199    });
200
201    // Fix: Re-layout when videos are ready
202    $grid.find('video').each(function () {
203        $(this).on('loadedmetadata', function () {
204            $grid.masonry('layout');
205        });
206    });
207
208    // Fix: Re-layout when iframes (like YouTube) are loaded
209    $grid.find('iframe').each(function () {
210        $(this).on('load', function () {
211            $grid.masonry('layout');
212        });
213    });
214
215    // Optional: small delayed re-layout (for safety)
216    setTimeout(function () {
217        $grid.masonry('layout');
218    }, 2000);
219});

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.