PageSourceSearch

https://realitatea.md/wp-content/themes/realitatea/js/script.js?ver=9241

js realitatea.md collected 2026-09-24 18:18:26 UTC 14,591 bytes, 486 lines download raw bytes

1function setupAdditionalInfo(){
2    let currencyButtons = document.querySelectorAll(".currency-button");
3    let weatherButtons = document.querySelectorAll(".weather-button");
4    let infoSection = document.querySelector(".additional-info");
5    let currencyBlock = document.querySelector(".curs-valutar");
6    let weatherBlock = document.querySelector(".meteo");
7    let background = document.querySelector(".additional-info-background");
8
9    let isCurrency = false;
10
11    infoSection.style["margin"] = "0";
12
13    currencyButtons.forEach(
14        function (currencyButton) {
15            currencyButton.addEventListener("click",
16            function(){
17                infoSection.style.display = "flex";
18                currencyBlock.style.display = "block";
19                isCurrency = true;
20            });
21        }
22    );
23
24    weatherButtons.forEach(
25        function (weatherButton) {
26            weatherButton.addEventListener("click",
27            function(){
28                infoSection.style.display = "flex";
29                weatherBlock.style.display = "block";
30                isCurrency = false;
31            });
32        }
33    );
34
35
36    background.addEventListener("click",
37    function(){
38        infoSection.style.display = "none";
39        if(isCurrency){
40            currencyBlock.style.display = "none";
41        }else{
42            weatherBlock.style.display = "none";
43        }
44    });
45}
46
47
48function setupBody(){
49    var fileName = location.pathname.split("/").slice(-1)[0];
50    for(let i = 0; i < fileName.length; i++){
51        if(fileName[i] == '.'){
52            fileName = fileName.substring(0,i);
53            break;
54        }
55    }
56
57    document.querySelector("body").id = fileName;
58}
59
60function setupSmallArticles(){
61    let smallArticles = document.querySelectorAll(".small-article");
62
63    smallArticles.forEach(positionTitle);
64}
65
66function positionTitle(item){
67    if(!item.querySelector("img")){
68        item.querySelector(".article-title").style.left = "0";
69        item.querySelector(".article-header").style["padding-left"] = "0";
70    }
71}
72
73function fadeIn(button, target, closeButton = null){
74    button.addEventListener("click",
75        function () {
76            target.style["display"] = "block";
77            let op = 0;
78            for(let i=0;i<10;i++){
79                setTimeout(
80                    function () {
81                        op+=0.1;
82                        target.style["opacity"] = op;
83                        if(op > 0.9){
84                            if(closeButton === null){
85                                fadeOut(button,target);
86                            }else{
87                                fadeOut(closeButton,target,button);
88                            }
89                        }
90                    }
91                    ,30);
92            }
93        }
94    );
95}
96
97function fadeOut(button, target, openButton = null){
98    button.addEventListener("click",
99        function () {
100            let op = 1;
101            setTimeout(function () {
102                target.style["display"] = "none";
103            },300);
104            for(let i=0;i<10;i++){
105                setTimeout(
106                    function () {
107                        op-=0.1;
108                        target.style["opacity"] = 0;
109                        if(op < 0.1){
110                            if(openButton === null){
111                                fadeIn(button,target);
112                            }
113                        }
114                    }
115                    ,30);
116            }
117        }
118    );
119}
120
121function slideIn(button, target) {
122    button.onclick = function () {
123        setTimeout(
124            function () {
125                target.style["bottom"] = 0;
126                slideOut(button,target);
127            }
128        ,1);
129    }
130}
131
132function slideOut(button, target) {
133    button.onclick = function () {
134        setTimeout(
135            function () {
136                target.style["bottom"] = "100px";
137                slideIn(button,target);
138            }
139        ,1);
140    }
141}
142
143function setupMobileHeader(){
144    let menuButton = document.querySelector(".menu-icon");
145    let menuCloseButton = document.querySelector(".close-menu-icon");
146    let searchButton = document.querySelector(".search-icon-header");
147
148    let menuTarget = document.querySelector(".menu");
149    let searchTarget = document.querySelector(".search-box");
150
151    fadeIn(menuButton,menuTarget,menuCloseButton);
152    slideIn(searchButton, searchTarget);
153}
154
155function setupToateStirilePanel(){
156    let openButton = document.getElementById("toate-stirile-button");
157    let openmobileButton = document.getElementById("toate-stirile-mobile-button");
158    let closeButton = document.getElementById("toate-stirile-panel-close");
159    let panel = document.getElementById("toate-stirile-panel");
160    let overlay = panel ? panel.querySelector(".toate-stirile-panel-overlay") : null;
161    let body = document.body;
162
163    if (!openButton || !panel) {
164        return;
165    }
166
167    // Calculate scrollbar width to prevent content shift
168    function getScrollbarWidth() {
169        // Create a temporary div to measure scrollbar width
170        const outer = document.createElement('div');
171        outer.style.visibility = 'hidden';
172        outer.style.overflow = 'scroll';
173        outer.style.msOverflowStyle = 'scrollbar';
174        document.body.appendChild(outer);
175        
176        const inner = document.createElement('div');
177        outer.appendChild(inner);
178        
179        const scrollbarWidth = outer.offsetWidth - inner.offsetWidth;
180        outer.parentNode.removeChild(outer);
181        
182        return scrollbarWidth;
183    }
184
185    const scrollbarWidth = getScrollbarWidth();
186    if (scrollbarWidth > 0) {
187        document.documentElement.style.setProperty('--scrollbar-width', scrollbarWidth + 'px');
188    }
189
190    function openPanel() {
191        // Add padding to compensate for scrollbar before hiding it
192        if (scrollbarWidth > 0) {
193            body.style.paddingRight = scrollbarWidth + 'px';
194            // Also apply to html element if it has scroll
195            const html = document.documentElement;
196            if (html.scrollHeight > html.clientHeight) {
197                html.style.paddingRight = scrollbarWidth + 'px';
198            }
199        }
200        body.classList.add("toate-stirile-panel-open");
201        
202        // Trigger fade-in animation
203        requestAnimationFrame(function() {
204            panel.classList.add("active");
205        });
206    }
207
208    function closePanel() {
209        // Remove active class first for fade-out
210        panel.classList.remove("active");
211        
212        // Wait for fade-out animation to complete before removing body classes
213        setTimeout(function() {
214            body.classList.remove("toate-stirile-panel-open");
215            body.style.paddingRight = '';
216            document.documentElement.style.paddingRight = '';
217        }, 300); // Match CSS transition duration
218    }
219
220    // Open panel on button click
221    openButton.addEventListener("click", function(e) {
222        e.preventDefault();
223        openPanel();
224    });
225
226    openmobileButton.addEventListener("click", function(e) {
227        e.preventDefault();
228        openPanel();
229    });
230
231
232    // Close panel on close button click
233    if (closeButton) {
234        closeButton.addEventListener("click", function(e) {
235            e.preventDefault();
236            closePanel();
237        });
238    }
239
240    // Close panel on overlay click
241    if (overlay) {
242        overlay.addEventListener("click", function(e) {
243            e.preventDefault();
244            closePanel();
245        });
246    }
247
248    // Close panel on Escape key
249    document.addEventListener("keydown", function(e) {
250        if (e.key === "Escape" && panel.classList.contains("active")) {
251            closePanel();
252        }
253    });
254}
255
256setupMobileHeader();
257setupSmallArticles();
258setupBody();
259setupToateStirilePanel();
260
261
262$(function() {
263
264    // $('body.single').swipeleft(function(){
265    //     alert("You swiped left!1");
266    // });
267
268    // $('body.single').swiperight(function(){
269    //     alert("You swiped left!1");
270    // });
271
272    // $(document).swipeleft(function(){
273    //     alert("You swiped left!2");
274    // });
275
276    // $(document).swiperight(function(){
277    //     alert("You swiped left!2");
278    // });
279
280    // $(window).swipeleft(function(){
281    //     alert("You swiped left!3");
282    // });
283
284    // $(window).swiperight(function(){
285    //     alert("You swiped left!3");
286    // });
287
288
289    // Set the active zodiak selected item
290    $('.zodii a').on('click', function(e) {
291        e.preventDefault();
292
293        $(document).find('.zodii li').removeClass('selected');
294        $(this).parent().addClass('selected');
295
296        $(document).find('.zodiac-article').removeClass('active');
297        const zodiac_name = $(this).attr('id');
298        $(document).find('.zodiac-article[data-zodie='+zodiac_name+']').addClass('active');
299    });
300
301    // Show all hidden tags
302    $('.last-tag').on('click', function(e) {
303        e.preventDefault();
304        $(document).find('.popular-tags .tag.hidden').show();
305        // $(this).hide();
306    });
307
308    // Currency button to show the currency exchanges and close it
309    $('.currency-button').on('click', function() {
310        $(".additional-info").attr('style','display: flex;');
311        $(".curs-valutar").attr('style','display: block;');
312    });
313
314    $(".additional-info-background").on('click', function() {
315        $(".additional-info").attr('style','display: none;');
316    });
317
318    $("body section").on('click', function() {
319        $("header.mobile .menu").attr('style','display: none;');
320    });
321
322    var updated=0,st;
323    $('body').on({
324        'touchmove': function(e) {
325        st = $(this).scrollTop();
326        if(st > updated) {
327            // console.log('down');
328        }
329        else {
330           $("header.mobile .menu").attr('style','display: none;');
331        }
332        updated = st;
333        }
334    });
335
336
337
338    $(document).on('keyup', function(e) {
339        if(e.key === "Escape") {
340            $(".additional-info").attr('style','display: none;');
341            $("header.mobile .menu").attr('style','display: none;');
342        }
343    });
344
345    // Close the Popup Important News
346    $(".popup-info-background").on('click', function() {
347        $(".section-popup-important-news").attr('style','display: none;');
348    });
349
350    $(".popup-important-news-close").on('click', function() {
351        $(".section-popup-important-news").attr('style','display: none;');
352    });
353
354    // Updated the video block to be the same as the image block
355    function resize_block_video() {
356        window_width = $(window).width();
357        if (window_width >= 992) {
358            news_block_image_height = $(document).find('.rlive-row-news .block-image').height();
359            $(document).find('.rlive-tv-stream .block-video').height(news_block_image_height);
360        } else {
361            $(document).find('.rlive-tv-stream .block-video').attr('style','height: auto; margin: initial;');
362        }
363    }
364
365    resize_block_video();
366
367    $(window).on('resize', function() {
368        resize_block_video();
369    })
370
371    //  Display the window width and height
372    function window_details() {
373        window_width = $(window).width();
374        window_height = $(window).height();
375        document_height = $(document).height();
376        document_width = $(document).width();
377    }
378
379    window_details();
380
381    $(window).on('resize', function() {
382        window_details();
383    });
384
385    function setHeight(col) {
386        var $col = $(col);
387        var $maxHeight = 0;
388        $col.each(function () {
389            var $thisHeight = $(this).find('.article a').height();
390            if ($thisHeight > $maxHeight && $thisHeight <= 300) {
391                $maxHeight = $thisHeight;
392            }
393        });
394        $col.find('.article a').height($maxHeight);
395    }
396    setHeight($(document).find('ul.stiri-list > li'));
397    $(window).on('resize', function() {
398        setHeight($(document).find('ul.stiri-list > li'));
399    });
400
401
402    function setHeightHoroscope(col1, col2, col3) {
403        var $col1 = $(col1);
404        var $col2 = $(col2);
405        var $col3 = $(col3);
406        var $maxHeight = 0;
407
408        var $thisHeight1 = $(col1).height();
409        var $thisHeight2 = $(col2).height();
410        var $thisHeight3 = $(col3).height();
411        window_width = $(window).width();
412
413        if ($thisHeight1 > $thisHeight2 + $thisHeight3 && window_width >= 991) {
414            $col2.height($thisHeight1 - $thisHeight3 - 75);
415        } else {
416            $col2.height('auto');
417        }
418    }
419    setHeightHoroscope(
420        $(document).find('.opinii.horoscope-module .opinions'),
421        $(document).find('.zodiac-article'),
422        $(document).find('.zodii')
423    );
424    $(window).on('resize', function() {
425        setHeightHoroscope(
426            $(document).find('.opinii.horoscope-module .opinions'),
427            $(document).find('.zodiac-article'),
428            $(document).find('.zodii')
429        );
430    });
431
432
433    $( window ).on( "swipeleft", function( event ) {
434        $(document).find('body.single #swipe-prev-post').trigger('click');
435        alert("body.single #swipe-prev-post CLICK");
436    } );
437
438    $( window ).on( "swiperight", function( event ) {
439        $(document).find('body.single #swipe-next-post CLICK').trigger('click');
440    } );
441});
442
443
444
445// Vanilla version of FitVids
446// Still licencened under WTFPL
447//
448// Not as robust and fault tolerant as the jQuery version.
449// It's BYOCSS.
450// And also, I don't support this at all whatsoever.
451// https://css-tricks.com/fluid-width-video/
452
453(function(window, document, undefined) {
454  "use strict";
455
456  // List of Video Vendors embeds you want to support
457  var players = ['iframe[src*="youtube.com"]', 'iframe[src*="vimeo.com"]'];
458
459  // Select videos
460  var fitVids = document.querySelectorAll(players.join(","));
461
462  // If there are videos on the page...
463  if (fitVids.length) {
464    // Loop through videos
465    for (var i = 0; i < fitVids.length; i++) {
466      // Get Video Information
467      var fitVid = fitVids[i];
468      var width = fitVid.getAttribute("width");
469      var height = fitVid.getAttribute("height");
470      var aspectRatio = height / width;
471      var parentDiv = fitVid.parentNode;
472
473      // Wrap it in a DIV
474      var div = document.createElement("div");
475      div.className = "fitVids-wrapper";
476      div.style.paddingBottom = aspectRatio * 100 + "%";
477      parentDiv.insertBefore(div, fitVid);
478      fitVid.remove();
479      div.appendChild(fitVid);
480
481      // Clear height/width from fitVid
482      fitVid.removeAttribute("height");
483      fitVid.removeAttribute("width");
484    }
485  }
486})(window, document);

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.