PageSourceSearch

https://pw.edu.pl/themes/custom/krowd_sub/js/main.js?v=11.4.7

js pw.edu.pl collected 2026-09-24 08:36:45 UTC 15,515 bytes, 351 lines download raw bytes

1var filterXHR = null;   //ostatnie wywołanie ajax
2
3function fixTopinfoMobile(){
4    //dodaje do topinfo element z tłem i position: fixed
5    /*jQuery('.topinfo').prepend( '<div class="topinfo-bg-mobile"></div>' ).ready(function(){
6        //jak apla z lewej, to kadrowanie trochę na prawo od środka, jak z prawej to odwrotnie
7        var bgPos = '40% center';
8        if(jQuery('.topinfo .gsc-column').hasClass('mr-auto')){
9            bgPos = '60% center';
10        };
11        jQuery('.topinfo-bg-mobile').css('background-image',jQuery('.topinfo').css('background-image')).css('background-position', bgPos);
12        console.log(jQuery(window).height());
13    });*/
14}
15
16function clearKierunkiStudiowForm() {
17    //czyszczenie filtrów do kierunków studiów
18    jQuery('.kierunki-studiow-filtry input[type="text"]').val('');
19    jQuery('.kierunki-studiow-filtry fieldset:not([disabled]) input[type="checkbox"]').prop("checked", false);
20}
21function hideKierunkiStudiowForm(duration = 400) {
22    //ukrywanie filtrów i czyszczenie panelu z wynikami
23    clearKierunkiStudiowForm();
24    jQuery('.kierunki-studiow-filtry .collapse-all').hide(duration);
25    jQuery('.kierunki-studiow-filtry .additional-filters').hide(duration);
26    jQuery('.kierunki-studiow-view-panel .gva-view').empty(); //dla widoków w gavias builderze
27    jQuery('.kierunki-studiow-view-wrapper').empty();
28}
29function showKierunkiStudiowForm() {
30    //pokazywanie filtrów
31    jQuery('.kierunki-studiow-filtry .collapse-all').show(400);
32    jQuery('.kierunki-studiow-filtry .additional-filters').show(400);
33}
34function disableUnnecessaryFilters() {
35    // ostatecznie nie dezaktywujemy filtrów poziomów kształcenia, tylko ich nie wyświetlamy
36    /*jQuery('#block-krowd-sub-udostepnionyformularzkierunki-studiowblock-1 .poziom-ksztalcenia fieldset').each(function(){
37        jQuery(this).addClass('text-muted').prop( "disabled", true );
38        jQuery(this).find('div[data-content="I stopień"] input').prop( "checked", true );
39    })
40    jQuery('#block-krowd-sub-udostepnionyformularzkierunki-studiowblock-1 .poziom-ksztalcenia').remove();
41    jQuery('#block-krowd-sub-udostepnionyformularzkierunki-studiowblock-1 .buttons').remove();
42    jQuery('#block-krowd-sub-udostepnionyformularzkierunki-studiowblock-2 .poziom-ksztalcenia fieldset').each(function(){
43        jQuery(this).addClass('text-muted').prop( "disabled", true );
44        jQuery(this).find('div[data-content="II stopień"] input').prop( "checked", true );
45    })
46    jQuery('#block-krowd-sub-udostepnionyformularzkierunki-studiowblock-dokt .poziom-ksztalcenia fieldset').each(function(){
47        jQuery(this).addClass('text-muted').prop( "disabled", true );
48        jQuery(this).find('div[data-content="doktorat"] input').prop( "checked", true );
49    })*/
50}
51
52
53function triggerSubmit(e) {
54    //handler do eventa 'change' na exposed forms
55    // e.keyCode: key.
56    var ignoredKeyCodes = [
57        16, // Shift.
58        17, // Ctrl.
59        18, // Alt.
60        20, // Caps lock.
61        33, // Page up.
62        34, // Page down.
63        35, // End.
64        36, // Home.
65        37, // Left arrow.
66        38, // Up arrow.
67        39, // Right arrow.
68        40, // Down arrow.
69        9, // Tab.
70        13, // Enter.
71        27 // Esc.
72    ];
73
74    // Triggering element.
75    var $target = jQuery(e.target);
76    var $submit = $target.closest('form').find('[data-bef-auto-submit-click]');
77
78    // Don't submit on changes to excluded elements or a submit element.
79    if ($target.is('[data-bef-auto-submit-exclude], :submit') || ($target.attr('autocomplete') == 'off' && !$target.hasClass('bef-datepicker'))) {
80        return true;
81    }
82
83    // Submit only if this is a non-datepicker textfield and if the
84    // incoming keycode is not one of the excluded values.
85    if (
86        $target.is(':text:not(.hasDatepicker), textarea') &&
87        $.inArray(e.keyCode, ignoredKeyCodes) === -1
88    ) {
89        if (filterXHR && filterXHR.readyState != 4) { //przed wysłaniem formularza anulujemy poprzednie wywołanie
90            // abort ajax request
91            filterXHR.abort();
92            jQuery('.ajax-progress').remove(); 
93        }
94        $submit.click();
95    }
96    // Only trigger submit if a change was the trigger (no keyup).
97    else if (e.type === 'change') {
98        if (filterXHR && filterXHR.readyState != 4) { //przed wysłaniem formularza anulujemy poprzednie wywołanie
99            // abort ajax request
100            filterXHR.abort();
101            jQuery('.ajax-progress').remove(); 
102        }
103        $submit.click();
104    }
105  
106}
107
108function initializePWCollapseRow() {
109    /* Inicjalizacja widoku accordion z niezależnymi rzędami (.pw-collapse-row) 
110       po kliknięciu:
111       - zmienia tekst między Zwiń a Rozwiń, zakłada że tekst linka to początkowo 'Rozwiń'
112       - włącza/wyłącza klasę .pw-link-collapse-up, która ustawia odpowiednią strzałkę
113       - przełącza tło z szarego na białe na sekcji, w którym jest element z linkiem .pw-link-collapse
114       - włącza/wyłącza na sekcji dolną kreskę, chyba że jest ustawione .border-none */
115
116    jQuery('.pw-link-collapse').click(function () {
117        jQuery(this).text(jQuery(this).text() == 'Zwiń' ? 'Rozwiń' : 'Zwi
117ń');
118        jQuery(this).toggleClass('pw-link-collapse-up');
119        jQuery(this).closest('.paragraph--type--wrapper.bg-transition.bg-pw-szary-10').toggleClass('bg-white').not('.border-none').toggleClass('border-bottom');
120    });
121
122    // zmiana kierunku strzałki w .pw-collapse-row po kliknięciu w nagłówek
123    jQuery('.pw-collapse-row .collapse').on('show.bs.collapse', function () {
124        jQuery(this).prev().find('.icon-arrow').toggleClass('icon-arrow-up');
125        jQuery(this).prev().find('.opis-strzalki').text('Zwiń');
126    });
127    jQuery('.pw-collapse-row .collapse').on('hide.bs.collapse', function () {
128        jQuery(this).prev().find('.icon-arrow').toggleClass('icon-arrow-up');
129        jQuery(this).prev().find('.opis-strzalki').text('Rozwiń');
130    });
131    jQuery(document).on("ajaxSend", function (event) {
132        uncompletedAjax = true;
133    })
134    jQuery(document).on("ajaxComplete", function (event) {
135        uncompletedAjax = false;
136        jQuery('.ajax-progress').remove(); 
137        jQuery('.pw-collapse-row .collapse').on('show.bs.collapse', function () {
138            jQuery(this).prev().find('.icon-arrow').toggleClass('icon-arrow-up');
139        })
140        jQuery('.pw-collapse-row .collapse').on('hide.bs.collapse', function () {
141            jQuery(this).prev().find('.icon-arrow').toggleClass('icon-arrow-up');
142        })
143    });
144
145    //jeśli hash jest w zamkniętym panelu, to rozwijamy go i przewijamy do hasha
146    if (window.location.hash) {
147        var $targetElement = jQuery(window.location.hash);        
148        if ($targetElement.length) {
149            // jeśli element istnieje, szukaj w górę najbliższego zwiniętego panelu (z klasą .collapse)
150            var $collapsedPanel = $targetElement.closest('.collapse');
151            
152            if ($collapsedPanel.length) {
153                // otwarcie panelu i aktualizacja strzałki / podpisu
154                $collapsedPanel.addClass('show');
155                $collapsedPanel.parent().prev().find('.pw-link-collapse').addClass('pw-link-collapse-up').text('Zwiń');
156                jQuery('html, body').animate({
157                    //uwzględniamy wartość scroll-margin-top
158                    scrollTop: $targetElement.offset().top - parseInt($targetElement.css('scroll-margin-top'))
159                }, 500);                
160            }
161        }
162    }
163}
164
165function setKierunkiFiltersButtosHandlers(){
166    // Zwijanie filtrów i czyszczenie panelu z wynikami
167    jQuery('.kierunki-studiow-filtry .collapse-all').on("click", function (event) {
168        event.preventDefault();
169        if (filterXHR && filterXHR.readyState != 4) { //przed wysłaniem formularza anulujemy poprzednie wywołanie
170            // abort ajax request
171            filterXHR.abort();
172            jQuery('.ajax-progress').remove(); 
173        }
174
175        //scroll-behavior przeszkadza w scrollowaniu js - wyłączamy, przewijamy na początek sekcji i włączamy
176        jQuery('html').css('scroll-behavior', 'auto');
177        jQuery('html, body').animate({
178            scrollTop: jQuery("#wyszukiwarka-kierunkow").offset().top - 101
179        }, 100, function() {
180            jQuery('html').css('scroll-behavior', 'smooth'); 
181            hideKierunkiStudiowForm();
182        });
183    });
184
185    //Rozwijanie filtrów + wysyłanie czystego formularza, aby pokazać wszystkie wyniki
186    jQuery('.kierunki-studiow-filtry .show-all').on("click", function (event) {
187        event.preventDefault();
188        if (filterXHR && filterXHR.readyState != 4) { //przed wysłaniem formularza anulujemy poprzednie wywołanie
189            filterXHR.abort();
190            jQuery('.ajax-progress').remove(); 
191        }
192        showKierunkiStudiowForm();
193        clearKierunkiStudiowForm();        
194        jQuery('.kierunki-studiow-filtry .form-submit').trigger('click');
195    });    
196}
197
198function initializeKierunkiStudiowForm() {
199    // Ustawia zachowanie bloku z filtrami kierunków studiów (.kierunki-studiow-filtry)
200
201    /* Domyślnie Better Exposed Filters ustawia 'change' na bloku z formularzem i na formularzu.
202       Przypinamy handler piętro niżej, do .additional-filters */
203
204    jQuery('.kierunki-studiow-filtry .views-exposed-form, .kierunki-studiow-filtry form').off('change');
205    jQuery('.kierunki-studiow-filtry .additional-filters').on('change', triggerSubmit);
206
207    jQuery('.view-kierunki-studiow.filters-hidden-on-start .kierunki-studiow-filtry').each(function(){
208        hideKierunkiStudiowForm(0);
209    });
210
211
212    // disableUnnecessaryFilters();
213
214    setKierunkiFiltersButtosHandlers();
215
216    jQuery(document).on("ajaxSend", function (event, jqXHR, settings) {
217        filterXHR = jqXHR; // cache XHR object for current ajax request
218
219        // Przewijamy na początek listy wyników, wyłączając uprzednio scroll-behavior
220        if(jQuery("#wyszukiwarka-kierunkow").length){
221            jQuery('html').css('scroll-behavior', 'auto');
222            jQuery('html, body').animate({
223                scrollTop: jQuery("#wyszukiwarka-kierunkow").offset().top - 101
224            }, 100, function() {
225                jQuery('html').css('scroll-behavior', 'smooth'); 
226            }); 
227        }
228    });
229
230    jQuery(document).on("ajaxComplete", function (event) {
231        // rozwinięcie filtrów jeśli są zwinięte
232        showKierunkiStudiowForm();
233
234        setKierunkiFiltersButtosHandlers();
235    });
236
237}
238
239jQuery(document).ready(function () {
240
241    initializePWCollapseRow();
242
243    initializeKierunkiStudiowForm()
244
245    jQuery('#back-to-top').off('click');
246
247    fixTopinfoMobile();
248
249    //dodawanie do colorboxa klasy umieszczonej na <a> jako atrybut data-colorbox-class
250    jQuery('.colorbox').colorbox({
251        onOpen: function() {
252            var customClass = jQuery(this).data('colorbox-class');
253            if (customClass) {
254                jQuery('#colorbox').addClass(customClass);
255            }
256            },
257            onClosed: function() {
258            var customClass = jQuery(this).data('colorbox-class');
259            if (customClass) {
260                jQuery('#colorbox').removeClass(customClass);
261            }
262        }
263    });
264
265    jQuery(document).bind('cbox_complete', function(){
266        //console.log('I am complete!');
267        jQuery('#colorbox #cboxTitle').each(function(){
268            var captionArray = jQuery(this).text().split("||");
269            if(captionArray.length == 2){
270                jQuery(this).text('').prepend('<h5>' + captionArray[0] + '</h5><p>' + captionArray[1] +'</p>');
271            }
272        });
273        jQuery( "#cboxLoadedContent" ).append( '<div class="click-zone zone-prev"></div><div class="click-zone zone-next"></div>' );
274        jQuery('#cboxLoadedContent .zone-prev').click(function(){
275            jQuery('#cboxLoadedContent').colorbox.prev();
276        });
277        jQuery('#cboxLoadedContent .zone-next').click(function(){
278            jQuery('#cboxLoadedContent').colorbox.next();
279        });
280    });
281
282    jQuery( window ).on( "resize", function() {
283        //wymiary okna
284        vWidth = jQuery(this).width();
285        vHeight = jQuery(this).height();
286
287        //wewnętrzne marginesy colorboxa, konieczne gdy na większych ekranach nawigazja jest poza obszarem zdjęcia
288        xMargin = vWidth >= 992 ? 75 : 0;
289        yMargin = vWidth >= 992 ? 50 : 0;
290
291        //colorbox dodaje na brzegach małe odstępy, trzeba je uwzględnić w kalkulacjach
292        offset = 15;
293        
294        //wymiary i proporcje zdjęcia
295        imgWidth = jQuery('div#colorbox img.cboxPhoto').prop('naturalWi
295dth');
296        imgHeight = jQuery('div#colorbox img.cboxPhoto').prop('naturalHeight');
297        imgRatio = imgWidth / imgHeight;
298
299        //przestrzeń na której ma się wyświetlić zdjęcie
300        availableWidth = vWidth - 2 * xMargin - 2*offset;
301        availableHeight = vHeight - 2 * yMargin - 2*offset;
302        availableRatio = availableWidth / availableHeight;
303
304        //wyszokość i szerokość przekazywane potem do colorbox.resize()
305        resizeWidth = 0;
306        resizeHeight = 0;
307
308        //jeśli zdjęcie mniejsze niż dostępna przestrzeń, to go nie skalujemy
309        if(imgWidth < availableWidth && imgHeight < availableHeight){
310            resizeWidth = imgWidth + 2 * xMargin;
311            resizeHeight = imgHeight + 2 * yMargin;
312        }
313        else{
314            if(imgRatio >= availableRatio ){
315                //jeśli zdjęcie ma bardziej panoramiczne proporcje niż dostępny obszar, to wypełnia go całego na szerokość, a wysokość jest obliczana
316                resizeWidth = vWidth - 2*offset;
317                resizeHeight = availableWidth / imgRatio + 2 * yMargin;
318            } else {
319                //jeśli zdjęcie ma bardziej portretowe proporcje niż dostępny obszar, to wypełnia go całego na wysokość, a szerokość jest obliczana
320                resizeHeight = vHeight - 2*offset;
321                resizeWidth = availableHeight * imgRatio + 2 * xMargin;
322            }
323        }
324
325        /*
326        console.log('Offset: ' + offset);
327        console.log('xMargin: ' + xMargin, ', yMargin: ' + yMargin);
328        console.log('vWidth: ' + vWidth, ', vHeight: ' + vHeight, ', imgWidth: ' + imgWidth, ', imgHeight: ' + imgHeight);
329        console.log('availableWidth: ' + availableWidth, ', availableHeight: ' + availableHeight, ', resizeWidth: ' + resizeWidth, ', resizegHeight: ' + resizeHeight);
330        */
331        
332        //ponowne przeliczenie i wyświetlenie colorboxa
333        jQuery().colorbox.resize({
334            'width': resizeWidth,
335            'height': resizeHeight
336        });
337
338        //korekta wymiarów zdjęcia - ma pokrywać cały udostępniony mu obszar
339        jQuery('div#colorbox img.cboxPhoto').width('100%').height('100%');
340
341        /*
342        //nałożenie korekty wymiarów cboxContent i cboxLoadedContent - działa tylko z opóźnieniem
343        setTimeout(function(){
344            jQuery('div#colorbox #cboxContent').width((resizeWidth - 2*xMargin) + 'px').height((resizeHeight - 2*yMargin) + 'px');
345            jQuery('div#colorbox #cboxLoadedContent').width((resizeWidth - 2*xMargin) + 'px').height((resizeHeight - 2*yMargin) + 'px');
346        }, 300);
347        console.log('popr x: ' + (resizeWidth - 2*xMargin) + 'px', ', popr y: ' + (resizeHeight - 2*yMargin) + 'px');        
348        */
349    } );
350
351});

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.