PageSourceSearch

https://init.lt/wp-content/themes/pi/assets/js/scripts.js?t=1790244151

js init.lt collected 2026-09-24 10:02:53 UTC 10,673 bytes, 327 lines download raw bytes

1var Nav = null;
2
3AOS.init({
4    startEvent: 'DOMContentLoaded',
5    initClassName: 'aos-init',
6    animatedClassName: 'aos-animate',
7    useClassNames: false,
8    disableMutationObserver: false,
9    debounceDelay: 50,
10    throttleDelay: 99,
11
12    offset: 120,
13    delay: 0,
14    duration: 1000,
15    easing: 'ease',
16    once: true,
17    mirror: false,
18    anchorPlacement: 'top-bottom',
19
20});
21
22jQuery(document).ready(function(){
23
24    //determine window scroll position
25    jQuery(window).scroll(function() {
26        if (jQuery(this).scrollTop() > 100) {
27            jQuery('body').addClass('scrolled');
28        } else {
29            if (jQuery('body').hasClass('scrolled')) {
30                jQuery('body').removeClass('scrolled');
31            }
32        }
33    });
34
35    jQuery(window).resize(function(){
36        sameHeight();
37    })
38    sameHeight();
39
40    jQuery(document).click(function(e) {
41        closeAllCustomElements(e);
42    });
43
44    jQuery('.btn').each(function (){
45        let rippleBtn = this;
46        let ripples = document.createElement("i");
47
48        jQuery(this).prepend(ripples).hover(function (e){
49            const rect = rippleBtn.getBoundingClientRect();
50            const xx = e.clientX - rect.left;
51            const yy = e.clientY - rect.top;
52            ripples.style.left = xx + "px";
53            ripples.style.top = yy + "px";
54        }, function (e){
55            const rect = rippleBtn.getBoundingClientRect();
56            const xx = e.clientX - rect.left;
57            const yy = e.clientY - rect.top;
58            ripples.style.left = xx + "px";
59            ripples.style.top = yy + "px";
60        });
61    });
62
63    PITheme();
64
65    Nav = jQuery('#mob-menu-wrap').hcOffcanvasNav({
66        disableAt: 1480,
67        customToggle: jQuery('#mob-menu-toggle'),
68        navTitle: '',
69        disableBody: true,
70        levelTitles: true,
71        levelTitleAsBack: true,
72        width: 360,
73        position: 'right',
74        ariaLabels: {
75            open:     'Open Menu',
76            close:    'Close Menu',
77            submenu:  'Submenu',
78            back: ''
79        }
80    });
81
82    jQuery('[data-tooltiphtml]').each(function (e){
83        jQuery(this).tooltip({
84            items: "[data-tooltiphtml]",
85            position: { my: "center bottom-8", at: "center top" },
86            content: function() {
87                return jQuery(this).attr('data-tooltiphtml');
88            }
89        });
90    });
91
92    lightbox.option({
93        'albumLabel': '',
94    });
95
96    const phoneFields = document.querySelectorAll('input[name="phone-number"]');
97    phoneFields.forEach(function (field) {
98        field.addEventListener('input', function () {
99            // Allow only digits and +
100            this.value = this.value.replace(/[^0-9+]/g, '');
101
102            // Allow only ONE leading +
103            this.value = this.value.replace(/(?!^)\+/g, '');
104        });
105    });
106
107});
108
109function PITheme() {
110    //theme: custom select
111    jQuery('.custom-select').not('.pitheme-init').click(function(event){
112        event.stopPropagation();
113    }).each(function (){
114
115        if (!jQuery(this).hasClass('pitheme-init')) {
116            jQuery(this).addClass('pitheme-init');
117
118            jQuery(this).find('.value-wrap a.act-value').not('.pitheme-init').addClass('pitheme-init').click(function (e){
119                closeAllCustomElements(e);
120                jQuery(this).parents('.custom-select').addClass('open').find('.content-wrap').slideDown('fast').find('.search-wrap input[type="text"]').focus();
121            });
122
123            jQuery(this).find('.options-wrap a').click(function (e){
124                closeAllCustomElements(e);
125                jQuery(this).parents('.content-wrap').siblings('input[type="text"].hidden').val(jQuery(this).data('value')!=='undefined'?jQuery(this).data('value'):jQuery(this).text()).trigger('change').parents('.custom-select').find('.value-wrap .label').text(jQuery(this).text());
126            });
127        }
128    });
129
130    //theme: custom radio input
131    jQuery('.custom-radio-label input[type="radio"]').not('.pitheme-init').each(function (){
132        if (!jQuery(this).hasClass('pitheme-init')) {
133            jQuery(this).addClass('pitheme-init');
134
135            jQuery(this).change(function (){
136                jQuery(this).closest('.combo-options-wrap').find('.custom-radio-label.active').removeClass('active');
137                jQuery(this).closest('.custom-radio-label').addClass('active');
138            });
139        }
140    })
141
142    //theme: ajaxsearchhide
143    if (jQuery('.abs-ajaxsearch-wrap').length>0) {
144        jQuery('.proclose').click(function () {
145            jQuery('.abs-ajaxsearch-wrap').hide();
146        });
147    }
148}
149
150function calcComboPrice(el) {
151    var basePrice = 0;
152    var basePriceOld = 0;
153    var price = 0;
154    var priceOld = 0;
155
156    jQuery(el).parents('.option-content').find('input[type="radio"]:checked').each(function (){
157        if (jQuery(this).data('baseprice') !== undefined) {
158            basePrice += parseFloat(jQuery(this).data('baseprice'));
159        }
160        if (jQuery(this).data('basepriceold') !== undefined) {
161            basePriceOld += parseFloat(jQuery(this).data('basepriceold'));
162        }
163
164        if (jQuery(this).data('price') !== undefined) {
165            price += parseFloat(jQuery(this).data('price'));
166        }
167        if (jQuery(this).data('priceold') !== undefined) {
168            priceOld += parseFloat(jQuery(this).data('priceold'));
169        }
170    });
171
172    jQuery(el).parents('.option-content').find('.title-3 strong').text((basePrice+price).toFixed(2).replace('.', ','));
173    jQuery(el).parents('.option-content').find('.title-old strong').text((basePriceOld+priceOld).toFixed(2).replace('.', ','));
174}
175
176/**
177 * "Rinkinių fiksuota" kainodara.
178 *
179 * Kaina imama ne iš pasirinkimų "kaina" reikšmių, o iš fiksuotų kainų lentelės
180 * (ACF laukas "rinkiniu_fiksuotos_kainos"), kuri į .option-content patenka kaip
181 * data-fixed-prices="{"p4-p5": kaina}", o senos – data-fixed-prices-old="{"p4-p5": kaina}".
182 * Pažymėti radio mygtukai turi savo eilučių
183 * indeksus data-p4 / data-p5; jei vienos pusės pasirinkimų nėra, indeksas yra -1.
184 */
185function calcComboFixedPrice(el) {
186    var content = jQuery(el).parents('.option-content');
187    var prices = parseFixedPrices(content.data('fixedPrices'));
188    var pricesOld = parseFixedPrices(content.data('fixedPricesOld'));
189
190    var p4 = content.find('.dynamic-bandwidth input[type="radio"]:checked').attr('data-p4');
191    var p5 = content.find('.dynamic-channels input[type="radio"]:checked').attr('data-p5');
192
193    if (p4 === undefined) {
194        p4 = -1;
195    }
196    if (p5 === undefined) {
197        p5 = -1;
198    }
199
200    var price = parseFloat(prices[p4 + '-' + p5]);
201    var priceOld = parseFloat(pricesOld[p4 + '-' + p5]);
202
203    if (isNaN(price)) {
204        price = 0;
205    }
206
207    content.find('.title-3 strong').text(price.toFixed(2).replace('.', ','));
208
209    // Sena kaina rodoma tik toms kombinacijoms, kurioms ji įvesta.
210    var titleOld = content.find('.title-old');
211
212    if (titleOld.length) {
213        if (isNaN(priceOld) || priceOld <= 0) {
214            titleOld.hide();
215        } else {
216            titleOld.find('strong').text(priceOld.toFixed(2).replace('.', ','));
217            titleOld.show();
218        }
219    }
220}
221
222/**
223 * Fiksuotų kainų lentelė iš data atributo (jQuery ją grąžina arba kaip objektą, arba kaip tekstą).
224 */
225function parseFixedPrices(value) {
226    if (typeof value === 'string') {
227        try {
228            value = JSON.parse(value);
229        } catch (e) {
230            value = {};
231        }
232    }
233
234    return value ? value : {};
235}
236
237function CSFilter(e) {
238    var filter, a, i;
239    filter = $(e).val().toUpperCase();
240    if (filter.length > 0) {
241        $(e).parent().siblings('.options-wrap').find('li.group-label').hide();
242    } else {
243        $(e).parent().siblings('.options-wrap').find('li.group-label').show();
244    }
245    a = $(e).parent().siblings('.options-wrap').find('a');
246    for (i = 0; i < a.length; i++) {
247        if (a[i].innerText.toUpperCase().indexOf(filter) > -1) {
248            $(a[i]).parent('li').show();
249        } else {
250            $(a[i]).parent('li').hide();
251        }
252    }
253}
254
255function closeAllCustomElements(e = null) {
256    jQuery('.custom-select .value-wrap a.act-value').not(this).each(function(){
257        jQuery(this).parents('.custom-select').removeClass('open').find('.content-wrap').slide
257Up('fast');
258    });
259
260    if (!$(e.target).is('a.toggle-abs-ajaxsearch.link-with-icon.btn-icon')) {
261        $('.abs-ajaxsearch-wrap.open').removeClass('open').hide();
262    }
263}
264
265function scrollToElement(target, margin = 15) {
266    jQuery("html, body").animate({ scrollTop: jQuery(target).position().top-margin }, "fast");
267    return false;
268}
269
270function sameHeight() {
271    let shElements = jQuery('.same-height');
272    let shMaxHeight = [];
273
274    shElements.css('min-height', '');
275
276    shElements.each(function (){
277        let shg = parseInt(jQuery(this).data('shg'));
278        let height = jQuery(this).outerHeight();
279        if (shMaxHeight[shg] === undefined) {shMaxHeight[shg] = height;}
280        if (height > shMaxHeight[shg]) {shMaxHeight[shg] = height;}
281    })
282
283    shElements.each(function (){
284        jQuery(this).css('min-height', shMaxHeight[jQuery(this).data('shg')]);
285    })
286}
287
288function showTabContent(tabid, el) {
289    jQuery(el).siblings('.active').removeClass('active');
290    jQuery(el).addClass('active').parents('.tabs-wrap').siblings('.tabs-content-wrap').find('.tab-content-'+tabid).fadeIn('fast').siblings('.tab-content').hide();
291    sameHeight();
292}
293
294(function () {
295    let vv = window.visualViewport;
296    if (!vv) return;
297
298    let frame = null;
299
300    function syncViewport() {
301        frame = null;
302
303        document.documentElement.style.setProperty('--vvh', Math.round(vv.height) + 'px');
304        document.documentElement.style.setProperty('--vvt', Math.round(vv.offsetTop) + 'px');
305
306        let keyboardOpen = vv.scale <= 1.05 && (window.innerHeight - vv.height) > window.innerHeight * 0.15;
307        if (document.body) {
308            document.body.classList.toggle('keyboard-open', keyboardOpen);
309        }
310    }
311
312    function queueSync() {
313        if (frame === null) {
314            frame = window.requestAnimationFrame(syncViewport);
315        }
316    }
317
318    vv.addEventListener('resize', queueSync);
319    vv.addEventListener('scroll', queueSync);
320    window.addEventListener('orientationchange', queueSync);
321    syncViewport();
322})();
323
324function showTVPackageContent(tabid, el) {
325    jQuery(el).siblings('.active').removeClass('active');
326    jQuery(el).addClass('active').parents('.cb-2col-tv-packages-list').find('.tv-package-content-'+tabid).fadeIn('fast').siblings('.tv-package-content').hide();
327}

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.