PageSourceSearch

https://www.greenfinanceinstitute.com/wp-content/themes/green_fina…/assets/js/utils/browser.js?ver=1761564216

js greenfinanceinstitute.com collected 2026-10-02 03:27:00 UTC 10,899 bytes, 303 lines download raw bytes

1// Create cross browser requestAnimationFrame method:
2window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function (f) {
3    setTimeout(f, 1000 / 60)
4};
5
6//Page functions
7var browser = {
8    _csrf: null,
9    _width: 0,
10    _height: 0,
11    _header_height: 0,
12    _filter_position: 0,
13    _position: 0,
14    _isotope: null,
15    _coords: [],
16    setup: function (init) {
17        this._width = $(window).width();
18        this._height = $(window).height();
19
20        if (init === 1) {
21            //Code that should be executed only once goes here
22            browser.mobileAsset(browser._width);
23            browser.contentTopSpace();
24
25            //Load videos
26            $('.banner [data-mp4]').each(function () {
27                browser.addVideo($(this));
28            });
29
30            if($('.latestNewsList')[0]){
31                $('.latestNewsList').each(function() {
32                    var wid = $(this).attr('data-wid');
33                    adjustHeights.setHeightByAll('.titleWrap'+wid);
34                    adjustHeights.setHeightByAll('.imageWrapper'+wid);
35                    adjustHeights.setHeightByAll('.descWrap'+wid);
36                });
37            }
38            if($('.faqs')[0]){
39                $('.faqs').each(function() {
40                    var wid = $(this).attr('data-wid');
41                    adjustHeights.setHeightByRow('.titleWrap'+wid);
42                    adjustHeights.setHeightByRow('.descWrap'+wid);
43                });
44            }
45            if($('.teamList')[0]){
46                $('.teamList').each(function() {
47                    var wid = $(this).attr('data-wid');
48                    adjustHeights.setHeightByAll('.titleWrap'+wid);
49                });
50            }
51            if($('.testimonialsListSlider')[0]){
52                browser.testimonialsList();
53            }
54            if($('.casestudySlider')[0]){
55                $('.casestudySlider').each(function() {
56                    var id = $(this).attr('id');
57                    var wid = $(this).attr('data-wid');
58                    browser.casestudyList(id,wid);
59                });
60            }
61            if($('.resourcesList')[0]){
62                $pagedNo = browser.getUrlParameter('pageno') ? browser.getUrlParameter('pageno') : '1';
63                resourceList.clearPagination($pagedNo);
64                resourceList.getResource($pagedNo);
65            }
66            if($('.eventList')[0]){ 
67                $pagedNo = browser.getUrlParameter('pageno') ? browser.getUrlParameter('pageno') : '1';
68                eventList.clearPagination($pagedNo);
69                eventList.getEventList($pagedNo);
70            }
71            
72            if($('.cardCarouselSlider')[0]){
73                $('.cardCarouselSlider').each(function() { 
74                    var id = $(this).attr('id');
75                    var wid = $(this).attr('data-wid'); 
76                    browser.cardCarousel(id,wid);
77                });
78            }
79        }
80
81        //Code that should execute on window resize goes here
82        adjustHeights.setHeightByAll('.megaMenuHeaderEqualHeight');
83        adjustHeights.setHeightByAll('.dateEqualHeight');
84        adjustHeights.setHeightByAll('.titleEqualHeight');
85        adjustHeights.setHeightByAll('.descEqualHeight');
86        browser.mobileAsset(browser._width);
87        browser.contentTopSpace();
88        video.objectFit();
89    },
90    scrollEvent: function (init) {
91        requestAnimationFrame(function () {
92            //Add layer behind sticky menu
93            var st = $(window).scrollTop();
94            if (st >= 100)
95                $('html').addClass('has-scrolled');
96            else
97                $('html').removeClass('has-scrolled');
98
99            //Pause or play Slideshows based on visibility
100            browser.playVisibleEvents();
101        });
102    },
103    pauseAllIntensiveEvents: function () {
104        //All slideshow/videos that needs to be paused should be written here
105        $('.cycle').each(function () {
106            $(this).cycle('pause');
107        });
108    },
109    playVisibleEvents: function () {
110        //Slideshow/videos that needs to be paused when out of view should be written here
111        $('.cycle').each(function () {
112            var slider = $(this);
113            if (slider.is(':in-viewport'))
114                slider.cycle('resume');
115            else
116                slider.cycle('pause');
117        });
118    },
119    get: function (key, default_) {
120        //Function to get the value of url parameters
121        if (default_ == null)
122            default_ = "";
123        key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
124        var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
125        var qs = regex.exec(window.location.href);
126        if (qs == null)
127            return default_;
128        else
129            return qs[1];
130    },
131    mobileAsset: function(_width){
132        if(_width > 1200){
133            $('.mobileMenuOpen .mobileSubMenuHeader').removeClass('active');
134            $('.mobileMenuOpen .megaMenuContainer').removeClass('active');
135            $('.mobileMenuOpen .menuItem').removeClass('active');
136            $('html').removeClass('mobileMenuOpen');
137            $('html').removeClass('mobileSideNavOpen');
138        }
139    },
140    contentTopSpace: function(){
141        var height = $('.header').height();
142        $('.content').css('margin-top', height);
143    },
144    addVideo: function (slide) {
145        var videoHtml = "",
146            mp4 = slide.data('mp4'),
147            webm = slide.data('webm'),
148            subtitle = slide.data('subtitle');
149
150        if (typeof mp4 != "undefined" && slide.length) {
151            videoHtml += '<video';
152            videoHtml += ' autoplay loop muted playsinline class="play">';
153            videoHtml += '<source src="' + mp4 + '" type="video/mp4">';
154            videoHtml += '<source src="' + webm + '" type="video/webm">';
155            if ((subtitle) && (subtitle != ''))
156                videoHtml += '<track label="English" kind="subtitles" srclang="en" src="' + subtitle + '" default>';
157            videoHtml += '</video>';
158            slide.removeAttr('data-mp4 data-webm').append(videoHtml);
159            browser.playVisibleEvents();
160            video.objectFit();
161        }
162    },
163    addVideoWithAudio: function (slide) {
164        var videoHtml = "",
165            mp4 = slide.data('mp4'),
166            webm = slide.data('webm');
167        if (typeof mp4 != "undefined" && slide.length) {
168            videoHtml += '<video';
169            videoHtml += ' autoplay loop playsinline class="play">';
170            videoHtml += '<source src="' + mp4 + '" type="video/mp4">';
171            videoHtml += '<source src="' + webm + '" type="video/webm">';
172            videoHtml += '</video>';
173            slide.removeAttr('data-mp4 data-webm').append(videoHtml);
174            browser.playVisibleEvents();
175            video.objectFit();
176        }
177    },
178    pauseVideo: function () {
179        $('.bg-video video').each(function () {
180            this.pause();
181        });
182    },
183    testimonialsList: function(){
184        var testimonialsList = new Swiper('.testimonialsListSlider', {
185            slidesPerView: 1,
186            loop: false,
187            grabCursor: false,
188            initialSlide: 0,
189            speed: 500,
190            autoplay:false,
191            navigation: {
192                nextEl: `${'.tsliderRightNavbar'}`,
193                prevEl: `${'.tsliderLeftNavbar'}`
194            },
195        });
196
197        if(document.querySelectorAll('.testimonialsListSlider .swiper-slide').length > 1){
198            $('.testimonialsList .sliderNavbarWrap').css('display','flex');
199        }else{
200            $('.testimonialsList .sliderNavbarWrap').css('display','none');
201        }
202    },
203    casestudyList: function(id,wid){
204        var nextId = "#sliderRightNavbar"+wid;
205        var prevId = "#sliderLeftNavbar"+wid;
206        var casestudyList = new Swiper('#'+id, {
207            slidesPerView: 1,
208            spaceBetween: 16,
209            loop: false,
210            grabCursor: false,
211            initialSlide: 0,
212            speed: 500,
213            autoplay:false,
214            navigation: {
215                nextEl: `${nextId}`,
216                prevEl: `${prevId}`
217            },
218            breakpoints: {
219                780: {
220                    slidesPerView: 2,
221                    spaceBetween: 16,
222                },
223                860: {
224                    slidesPerView: 2,
225                    spaceBetween: 16,
226                },
227                900: {
228                    slidesPerView: 2,
229                    spaceBetween: 16,
230                },
231                1024: {
232                    slidesPerView: 2,
233                    spaceBetween: 16,
234                },
235                1200: {
236                    slidesPerView: 3,
237                    spaceBetween: 24,
238                }
239            }
240        });
241    },
242    cardCarousel: function(id, wid) { 
243        var nextId = "#sliderRightNavbar" + wid; 
244        var prevId = "#sliderLeftNavbar" + wid;
245        var casestudyList = new Swiper('#' + id, {
246            spaceBetween: 16,
247            loop: true,
248            grabCursor: false,
249            initialSlide: 0,
250            speed: 500,
251            autoplay: false,
252            navigation: {
253                nextEl: `${nextId}`,
254                prevEl: `${prevId}`
255            },
256            breakpoints: {
257                420: {
258                    slidesPerView: 1,
259                    spaceBetween: 16
260                },
261                768: {
262                  slidesPerView: 3,
263                  spaceBetween: 16
264                },
265                1024: {
266                  slidesPerView: 4,
267                  spaceBetween: 16
268                },
269                1280: {
270                  slidesPerView: 4,
271                  spaceBetween: 16
272                }
273              }
274        });
275    },    
276    tab: function(evt, cityName){
277        var i, tabcontent, tablinks;
278        tabcontent = document.getElementsByClassName("tabContent");
279        for (i = 0; i < tabcontent.length; i++) {
280          tabcontent[i].style.display = "none";
281        }
282        tablinks = document.getElementsByClassName("tabItem");
283        for (i = 0; i < tablinks.length; i++) {
284          tablinks[i].className = tablinks[i].className.replace(" active", "");
285        }
286        document.getElementById(cityName).style.display = "block";
287        evt.currentTarget.className += " active";
288    },
289    getUrlParameter: function(sParam) {
290		var sPageURL = decodeURIComponent(window.location.search.substring(1)),
291			sURLVariables = sPageURL.split('&'),
292			sParameterName,
293			i;
294
295		for (i = 0; i < sURLVariables.length; i++) {
296			sParameterName = sURLVariables[i].split('=');
297
298			if (sParameterName[0] === sParam) {
299				return sParameterName[1] === undefined ? true : sParameterName[1];
300			}
301		}
302	},
303};

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.