PageSourceSearch

https://www.ipcc.ch/site/assets/themes/ipcc/resources/js/page-functions.js

js ipcc.ch collected 2026-10-01 06:52:22 UTC 13,759 bytes, 453 lines download raw bytes

1var site_url = '/';
2theme_dir = site_url + 'site/assets/themes/ipcc';
3
4// vimeo embed callback
5
6function embedVideo(video) {
7  document.getElementById('embed').innerHTML = unescape(video.html);
8}
9
10(function($) {
11  
12  $(function() {
13    
14    //
15    // PLUGINS
16    //
17        
18    // SLIDERS
19    
20    $('.content-slider-wrap').each(function() {
21      
22      var post_slider = $(this).find('.content-slider');
23      
24      var prev_btn = $(this).find('.prev .arrow');
25      var next_btn = $(this).find('.next .arrow');
26      
27      post_slider.slick({
28        slidesToShow: 1,
29        slidesToScroll: 1,
30        draggable: false,
31        prevArrow: prev_btn,
32        nextArrow: next_btn,
33        responsive: [{
34          breakpoint: 600,
35          settings: {
36            draggable: true
37          }
38        }],
39      });
40      
41    });   
42    
43    //
44    // JQUERY UI
45    //
46    
47    // TABS
48    
49    if ($('body').attr('id') == 'page-language') {
50      
51      $('#lang-tabs-wrap').tabs({
52        hide: { effect: "fadeOut", duration: 250 },
53        show: { effect: "fadeIn", duration: 500 }
54      });
55      
56    }
57    
58    //
59    // REPORT PAGES
60    //
61    
62    if ($('body').hasClass('single-report')) {
63      
64    }
65    
66    //
67    // REPORT
68    //
69    
70    if ($('body').attr('id') == 'page-report') {
71      
72      function close_expand(slider_section, expand_container, expand_content) {
73        
74        slider_section.find('.slide').removeClass('is-active');
75        
76        expand_container.slideUp(250, function() {
77          expand_content.empty();
78          expand_container.addClass('embed');
79        });
80        
81        $('.slide-link').each(function() {
82          
83          var this_ID = $(this).attr('data-id');
84          
85          $('script[data-id="' + this_ID + '"]').remove();
86          
87        });
88        
89      }
90      
91      $('.type-media-slider').each(function() {
92        
93        var slider_section = $(this);
94        
95        var slider = slider_section.find('.content-slider');
96        
97        var expand_container = slider_section.find('.slider-expand'),
98            expand_content = slider_section.find('.expand-content'),
99            expand_spinner = slider_section.find('.spinner');
100        
101        slider.find('.slide-link').click(function(e) {
102          e.preventDefault();
103          
104          if ($(this).parents('.slide').hasClass('is-active')) {
105            
106            $(this).removeClass('open');
107            
108            close_expand(slider_section, expand_container, expand_content);
109            
110          } else {
111          
112            var link_href = $(this).attr('href'),
113                link_type = $(this).attr('data-type'),
114                link_vid = $(this).attr('data-id'),
115                link_source = $(this).attr('data-source');
116                
117            slider_section.find('.slide').removeClass('is-active');
118            $(this).parents('.slide').addClass('is-active');
119                
120            expand_container.slideDown();
121                
122            expand_spinner.fadeIn(250, function() {
123              
124              if (link_type == 'attachment') {
125            
126                $.ajax({
127                  url: link_href,
128                  success: function(data) {
129                    
130                    expand_content.fadeOut(250, function() {
131                      
132                      expand_container.removeClass('embed');
133                      
134                      expand_content.empty();
135                      
136                      $(data).find('.ajax-content').appendTo(expand_content);
137                      $(expand_content).fadeIn(250);
138                      
139                      expand_spinner.fadeOut();
140                      
141                      setTimeout(function() {
142                        
143                        console.log($('#media-expand'));
144                        console.log($('#media-expand').find('.share-me'));
145                        
146                        $('#media-expand').find('.share-me').each(function() {
147                          
148                          var tweet_text = $(data).find('.attachment-meta h3').text() + ' — ' + document.title + ': ';
149                          
150                          $(this).share_widget({
151                            share_url: link_href,
152                            elements: {
153                              facebook: {
154                                display: true,
155                                icon: 'icon-social-facebook'
156                              },
157                              twitter: {
158                                display: true,
159                                text: tweet_text,
160                                icon: 'icon-social-twitter'
161                              }
162                            }
163                          });
164                          
165                        });
166                        
167                      }, 1000);
168                      
169                    });
170                    
171                  }
172                });
173              
174              } else if (link_type == 'embed') {
175                
176                expand_container.addClass('embed');
177                  
178                var callback = 'embedVideo';
179                var js;
180                
181                expand_content.html($('<div id="embed" class="expand-embed" />'));
182                
183                if ( link_source == 'youtube' ) {
184                  
185                  var iframe = $('<iframe/>', {
186                    'frameborder': '0',
187                    'src': "https://www.youtube.com/embed/" + link_vid + "?autohide=1"
188                  });
189                  
190                  expand_content.find('#embed').append(iframe);
191                  
192                } else if ( link_source == 'vimeo' ) {
193                  
194                  var url = 'http://www.vimeo.com/api/oembed.json?url=' + encodeURIComponent('http://www.vimeo.com/' + link_vid) + '&callback=' + callback + '&width=640';
195                  
196                  js = document.createElement('script');
197                  js.setAttribute('data-id', link_vid);
198                  js.setAttribute('type', 'text/javascript');
199                  js.setAttribute('src', url);
200                  
201                  document.getElementsByTagName('head').item(0).appendChild(js);
202                  
203                } else if ( link_source == 'slideshare' ) {
204                  
205                  var url = 'http://www.slideshare.net/api/oembed/2?url=' + encodeURIComponent(link_href) + '&format=json&callback=' + callback;
206                  
207                  js = document.createElement('script');
208                  js.setAttribute('data-id', link_vid);
209                  js.setAttribute('type', 'text/javascript');
210                  js.setAttribute('src', url);
211                  
212                  document.getElementsByTagName('head').item(0).appendChild(js);
213                  
214                }
215                
216                expand_spinner.fadeOut();
217                
218              }
219                    
220            });
221          
222          }
223          
224        });
225        
226        expand_container.find('.close-btn').click(function(e) {
227          
228          close_expand(slider_section, expand_container, expand_content);
229          
230        });
231        
232      });
233      
234    }
235    
236    // CHAPTER
237    
238    if ($('body').attr('id') == 'page-report-chapter') {
239      
240      $('.content-gridtab').gridtab({
241        grid: 6,
242        borderWidth: 0,
243        tabPadding: 0,
244        contentPadding: 0,
245        contentBackground: 'transparent',
246        config:{
247          layout: 'tab',
248          showClose: true,
249          scrollToTab: true
250        },
251        responsive: [{
252          breakpoint: 800,
253          settings: {
254            grid: 4
255          }
256        }, {
257          breakpoint: 600,
258          settings: {
259            grid: 2
260          }
261        }, {
262          breakpoint: 400,
263          settings: {
264            grid: 2
265          }
266        }]
267  		});
268      
269      $('.content-gridtab .slide-link').click(function(e) {
270        
271        e.preventDefault();
272        
273        var link_href = $(this).attr('href');
274        
275        var tab = $(this).parents('dt');
276        
277        if (!tab.hasClass('loaded')) {
278        
279          var expand_container = tab.next('dd');
280          
281          var expand_content = expand_container.find('.expand-content'),
282              expand_spinner = expand_container.find('.spinner');
283          
284          var new_html, tweet_text;
285          
286          $.ajax({
287            url: link_href,
288            success: function(data) {
289              
290              expand_content.fadeOut(250, function() {
291                
292                expand_content.empty();
293                
294                new_html = $(data).find('.ajax-content').appendTo(expand_content);
295                
296                tweet_text = $(data).find('.attachment-meta h3').text() + ' — ' + document.title + ': ';
297                
298                $(expand_content).fadeIn(250);
299                
300                expand_spinner.fadeOut();
301                
302              });
303              
304              tab.addClass('loaded');
305              
306            },
307            complete: function() {
308              
309              
310              
311              setTimeout(function() {
312                
313                new_html.find('.share-me').each(function() {
314                  $(this).share_widget({
315                    share_url: link_href,
316                    elements: {
317                      facebook: {
318                        display: true,
319                        icon: 'icon-social-facebook'
320                      },
321                      twitter: {
322                        display: true,
323                        text: tweet_text,
324                        icon: 'icon-social-twitter'
325                      }
326                    }
327                  });
328                });
329                
330              }, 1000);
331              
332            }
333          });
334          
335        }
336        
337      });
338      
339    }
340    
341    // NEWS / ACTIVITIES
342    
343    /*if ($('body').attr('id') == 'page-activities') {
344      
345      $(window).load(function() {
346        setTimeout(function() {
347          $('li[data-filter-value="meeting"]').trigger('click');
348        }, 1000);
349      });
350      
351    }
352    
353    if ($('body').attr('id') == 'page-news') {
354      
355      $(window).load(function() {
356        setTimeout(function() {
357          $('li[data-filter-value="press-release"]').trigger('click');
358        }, 1000);
359      });
360      
361    }*/
362    
363  });
364})(jQuery);
365
366
367
368
369jQuery(document).ready(function() {
370  if (jQuery('#page-reports').length == 1) {
371
372function getUrlParameter(url, parameter){
373    parameter = parameter.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
374    var regex = new RegExp('[\\?|&]' + parameter.toLowerCase() + '=([^&#]*)');
375    var results = regex.exec('?' + url.toLowerCase().split('?')[1]);
376    return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g,''));
377}
378
379function setUrlParameter(url, key, value) {
380    var key = encodeURIComponent(key),
381        value = encodeURIComponent(value);
382
383    var baseUrl = url.split('?')[0],
384        newParam = key + '=' + value,
385        params = '?' + newParam;
386
387    if (url.split('?')[1] === undefined){ // if there are no query strings, make urlQueryString empty
388        urlQueryString = '';
389    } else {
390        urlQueryString = '?' + url.split('?')[1];
391    }
392
393    // If the "search" string exists, then build params from it
394    if (urlQueryString) {
395        var updateRegex = new RegExp('([\?&])' + key + '=[^&]*');
396        var removeRegex = new RegExp('([\?&])' + key + '=[^&;]+[&;]?');
397
398        if (value === undefined || value === null || value === '') { // Remove param if value is empty
399            params = urlQueryString.replace(removeRegex, "$1");
400            params = params.replace(/[&;]$/, "");
401    
402        } else if (urlQueryString.match(updateRegex) !== null) { // If param exists already, update it
403            params = urlQueryString.replace(updateRegex, "$1" + newParam);
404    
405        } else if (urlQueryString == '') { // If there are no query strings
406            params = '?' + newParam;
407        } else { // Otherwise, add it to end of query string
408            params = urlQueryString + '&' + newParam;
409        }
410    }
411
412    // no parameter was set so we don't need the question mark
413    params = params === '?' ? '' : params;
414
415    return baseUrl + params;
416}
417
418jQuery('.post-grid-filter-item li').click(function() {
419var term = jQuery(this).closest('.post-grid-filter-item').data().filterTerm;
420var liItem = jQuery(this)[0].dataset.filterValue;
421if (term == 'assessment-report') {
422var newUrl = setUrlParameter(document.location.href, 'rp', liItem)
423} else if (term == 'working-group') {
424var newUrl = setUrlParameter(document.location.href, 'wg', liItem)
425}
426window.history.pushState('page2', document.title, newUrl);
427});
428
429jQuery('.clear-filter').click(function() {
430  var term = jQuery(this).next('ul').data().filterTerm;
431if (term == 'assessment-report') {
432var newUrl = setUrlParameter(document.location.href, 'rp', '')
433} else if (term == 'working-group') {
434var newUrl = setUrlParameter(document.location.href, 'wg', '')
435}
436window.history.pushState('page2', document.title, newUrl);
437});
438
439jQuery('.icon-close').click(function() {
440window.history.pushState('page2', document.title, '/reports/');
441});
442
443  var report = getUrlParameter(document.location.href, 'rp');
444  if (!!report) {
445  jQuery('.post-grid-filter-item').find(`[data-filter-value='`+report+`']`).click();
446  }
447  var wg = getUrlParameter(document.location.href, 'wg');
448  if (!!wg) {
449  jQuery('.post-grid-filter-item').find(`[data-filter-value='`+wg+`']`).click();
450  }
451  }
452
453});

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.