PageSourceSearch

https://refugees.org/wp-content/plugins/cool-timeline-pro/assets/js/load-more.js?ver=3.5

js refugees.org collected 2026-10-02 03:43:40 UTC 18,449 bytes, 482 lines download raw bytes

1jQuery(function($){
2
3  // on scroll stories animations
4function ctlStoryAnimation_loadMore(){
5	// enabled animation on page scroll
6	$(".cooltimeline_cont").each(function(index ){
7		var timeline_id=$(this).attr('id');
8		var animations=$("#"+timeline_id).attr("data-animations");
9	if(animations!="none") {
10		// You can also pass an optional settings object
11		// below listed default settings
12		AOS.init({
13			// Global settings:
14			disable:'mobile', // accepts following values: 'phone', 'tablet', 'mobile', boolean, expression or function
15			startEvent: 'DOMContentLoaded', // name of the event dispatched on the document, that AOS should initialize on
16			offset: 75, // offset (in px) from the original trigger point
17			delay: 0, // values from 0 to 3000, with step 50ms
18			duration: 750, // values from 0 to 3000, with step 50ms
19			easing: 'ease-in-out-sine', // default easing for AOS animations
20			mirror: true,
21		});
22			
23			}
24	});
25}
26
27  // story timeline load more 
28  if(typeof ctlloadmore != 'undefined' && typeof ctlloadmore.attribute != 'undefined') 
29    {   
30    var page =2;
31    var loading = false;
32
33      if($('.cool_timeline').find('.ctl_load_more').attr("data-max-num-pages") == 1) {
34        $('.cool_timeline').find('.ctl_load_more').hide();
35      }
36      else{
37        // enable load more button in year navigation
38        var timelineWrapper=$(".cool_timeline");
39        naviLoadMoreBtn(timelineWrapper);
40      }
41  
42   
43    $('body').on('click', '.ctl_load_more', function(){
44       var timeline_wrp= $(this).parents('.cool_timeline');
45       var org_label=$(this).text();
46       var loading_text=$(this).attr("data-loading-text");
47       var button = timeline_wrp.find('.ctl_load_more');
48       var type=$(this).attr("data-timeline-type");
49       var last_year = timeline_wrp.find('.timeline-year:last').data('section-title');
50        if(type=="compact"){
51            var last_year = timeline_wrp.find('.compact-year:last').data('section-title');
52         }else{
53            var last_year = timeline_wrp.find('.timeline-year:last').data('section-title');
54         }
55         var allAtts= ctlloadmore.attribute;
56         var alternate = timeline_wrp.find('.timeline-post:last').data('alternate');
57         
58       if($('.ct-cat-filters').length  && $('.ct-cat-filters').hasClass('active-category')) {
59            var filterCat=$('.active-category').data('term-slug');
60            allAtts.category=filterCat;
61       }
62
63        if( ! loading ) {
64           $(this).html(loading_text);
65          var max_pages= $(this).attr("data-max-num-pages");
66          var max_page_num=parseInt(max_pages)+1;
67          loading = true;
68                var data = {
69                    action: 'ctl_ajax_load_more',
70                    page: page,
71                    last_year:last_year,
72                    alternate:alternate,
73                    attribute:allAtts,
74                    nonce:ctlloadmore.nonce
75                };
76                $.post(ctlloadmore.url, data, function(res) {
77                    if( res.success) {
78                    if(type=="compact"){
79                        var $grid= timeline_wrp.find('.clt-compact-cont').append( res.data );
80                        ctlCompactSettings($grid);
81                    }else{
82                       timeline_wrp.find('.cooltimeline_cont').append( res.data );
83                    }
84                //    if(type!="compact"){
85                    storyYearNavigation(timeline_wrp);
86                  //  }
87                    enableStoryPopup(timeline_wrp);
88                    storySlideShow(timeline_wrp);
89                    naviLoadMoreBtn(timeline_wrp);
90                   ctlStoryAnimation_loadMore();
91                       button.html(org_label);
92                       page = page + 1;
93                         loading = false;
94                       if(page>=max_page_num){
95                        $('.ctl_load_more , .ctl_load_more_clone').hide();
96                          }
97
98                    } else {
99                        // console.log(res);
100                    }
101                }).fail(function(xhr, textStatus, e) {
102                   console.log(xhr.responseText);
103                });
104
105            }
106        });
107  }
108
109// content timeline load more
110if(typeof ct_load_more != 'undefined' && typeof ct_load_more.attribute != 'undefined') 
111    {   
112
113    var page =2;
114    var loading = false;
115    
116    $('body').on('click', '.ctl_load_more', function(){
117       var timeline_wrp= $(this).parents('.cool_timeline');
118       var button = timeline_wrp.find('.ctl_load_more');
119         var type=$(this).attr("data-timeline-type");
120         if(type=="compact"){
121            var last_year = timeline_wrp.find('.compact-year:last').data('section-title');
122         }else{
123        var last_year = timeline_wrp.find('.timeline-year:last').data('section-title');
124         }
125 
126       var alternate = timeline_wrp.find('.timeline-post:last').data('alternate');
127       var org_label=$(this).text();
128       var loading_text=$(this).attr("data-loading-text");
129       var allAtts= ct_load_more.attribute;
130     
131       if($('.ct-cat-filters').length  && $('.ct-cat-filters').hasClass('active-category')) {
132            var filterCat=$('.active-category').data('term-slug');
133            allAtts['post-category']=filterCat;
134           
135       }
136
137        if( ! loading ) {
138          $(this).html(loading_text);
139          var max_pages= $(this).attr("data-max-num-pages");
140          var max_page_num=parseInt(max_pages)+1;
141         
142             loading = true;
143                var data = {
144                    action: 'ct_ajax_load_more',
145                    page: page,
146                    last_year:last_year,
147                    alternate:alternate,
148                    attribute:allAtts,
149                    nonce:ct_load_more.nonce
150                };
151
152             $.post(ct_load_more.url, data, function(res) {
153                    if( res.success) {
154                     if(type=="compact"){
155                        var $grid= timeline_wrp.find('.clt-compact-cont').append( res.data );
156                        ctlCompactSettings($grid);
157                    }else{
158                       timeline_wrp.find('.cooltimeline_cont').append( res.data );
159                    }
160                       storyYearNavigation(timeline_wrp);
161                       enableStoryPopup(timeline_wrp);
162                         page = page + 1;
163                         loading = false;
164                        button.html(org_label);
165                         timeline_wrp.find("a[class^='ctl_prettyPhoto']").prettyPhoto({
166                             social_tools: false 
167                             });
168                           timeline_wrp.find("a[rel^='ctl_prettyPhoto']").prettyPhoto({
169                              social_tools: false
170                            });
171                       if(page>=max_page_num){
172                            button.hide();
173                          }
174
175                    } else {
176                        // console.log(res);
177                    }
178                }).fail(function(xhr, textStatus, e) {
179                   console.log(xhr.responseText);
180                });
181
182            }
183       });
184   }
185
186   // category based dynamic filtering for both layouts
187    $(".ct-cat-filters").on("click",function($event){
188        $event.preventDefault();
189        
190      $(".cat-filter-wrp ul li a").removeClass('active-category');
191      $(this).addClass('active-category');
192       var cat_name=$(this).text();
193       var parent_wrp= $(this).parents(".cool_timeline");
194       var preloader= parent_wrp.find('.filter-preloaders');
195 //   parent_wrp.find(".custom-pagination").hide();
196 //    parent_wrp.find(".ctl_load_more").hide();
197   //     $(this).parents().find('.ctl_load_more').show();
198  
199       preloader.show();
200       var parent_id=parent_wrp.attr("id");
201       var navigation="#"+parent_id+"-navi";
202       var termSlug=$(this).data("term-slug");
203       var totalPosts=parseInt($(this).data("post-count"));
204        var action=$(this).data("action");
205        var tm_type=$(this).data("tm-type");
206        var type=$(this).data("type"); 
207       var loading = false;
208       var org_label=$(this).text();
209       var loading_text=$(this).attr("data-loading-text");
210     
211       if(type=="compact"){
212          var last_year = parent_wrp.find('.compact-year:last').data('section-title');
213       }else{
214      var last_year = parent_wrp.find('.timeline-year:last').data('section-title');
215       }
216       var alternate = parent_wrp.find('.timeline-post:last').data('alternate');
217        if(tm_type=="story-tm"){
218           var all_attrs= ctlloadmore.attribute;
219           var ajax_url= ctlloadmore.url;
220           var nonce= ctlloadmore.nonce;
221        }else{
222         var all_attrs= ct_load_more.attribute;
223         var ajax_url= ct_load_more.url;
224         var nonce= ct_load_more.nonce;
225        }
226    
227        var showPosts=$(".cool-timeline-wrapper").attr("data-showposts");
228        var countPages=Math.ceil(totalPosts/showPosts);
229
230        $('.ctl_load_more').attr('data-max-num-pages',  countPages);
231        page =2;
232       
233        if(totalPosts>showPosts){
234            $(this).parents('.cool_timeline').find('.ctl_load_more').show();
235         }
236        else {
237            $(this).parents('.cool_timeline').find('.ctl_load_more').hide();
238        }
239
240        all_attrs.category=termSlug;
241        if( ! loading ) {
242            if(type=="compact"){
243                 parent_wrp.find('.clt-compact-cont').html(' ');
244            }else{
245                 parent_wrp.find('.cooltimeline_cont').html(' ');
246            }
247               loading = true;
248                var data = {
249                    action:action,
250                    last_year:last_year,
251                    alternate:alternate,
252                    termslug:termSlug,
253                    attribute:all_attrs,
254                    nonce:nonce
255                };
256                $.post(ajax_url, data, function(res) {
257                    if(typeof res =='string'){
258                        if(res!= 'undefined'){
259                          res = JSON.parse(res) 
260                          }
261                    }
262                    if( res.success) {
263                        if(type=="compact"){
264                          if(res.data!==undefined && res.data!=""){
265                        parent_wrp.find('.clt-compact-cont').append('<div class="center-line"></div>');
266                        var $grid= parent_wrp.find('.clt-compact-cont').append( res.data );
267                        ctlCompactSettings($grid);
268                        parent_wrp.find(".ctl_load_more").removeClass('clt-hide-it');
269                          }else{
270                            parent_wrp.find(".ctl_load_more").addClass('clt-hide-it'); 
271                          }
272                    }else{
273                      if(res.data!==undefined && res.data!=""){
274                       parent_wrp.find('.cooltimeline_cont').append( res.data );
275                       parent_wrp.find(".ctl_load_more").removeClass('clt-hide-it');
276                      }else{
277                        parent_wrp.find(".ctl_load_more").addClass('clt-hide-it');
278                      }
279                    }   
280                           loading = false;
281                           preloader.hide();
282                      
283                          $(parent_wrp).find(".timeline-main-title").text(cat_name);
284                          $(parent_wrp).find(".no-content").hide();
285                           storyYearNavigation(parent_wrp);
286                           enableStoryPopup(parent_wrp);
287                           storySlideShow(parent_wrp);
288                            naviLoadMoreBtn(parent_wrp);
289                        
290                            var timeline_id=jQuery('.cooltimeline_cont').attr('id');
291                            var animations=jQuery("#"+timeline_id).attr("data-animations");
292                            if(animations!="none") {
293                              AOS.refreshHard();
294                            }
295                    } else {
296                        // console.log(res);
297                    }
298                }).fail(function(xhr, textStatus, e) {
299                   console.log(xhr.responseText);
300                });
301               
302          }      
303       });
304
305    /*
306    *  Helper funcitons
307    */
308
309
310  // re-enable compact masonry layout grid
311  function ctlCompactSettings($grid){
312    if($grid !=undefined){
313      $grid.masonry('reloadItems');
314      $grid.imagesLoaded().progress( function() {
315        $grid.masonry('layout');
316      });
317      $grid.on( 'layoutComplete',
318        function() {
319          var leftPos = 0;
320          var topPosDiff;
321          $grid.find('.timeline-mansory').each(function(index) {
322              leftPos = $(this).position().left;
323              if (leftPos <= 0) {
324                  $(this).removeClass("ctl-right").addClass('ctl-left');
325              } else {
326                  $(this).removeClass("ctl-left").addClass('ctl-right');
327              }
328
329              topPosDiff = $(this).position().top - $(this).prev().position().top;
330              if(topPosDiff < 40) {
331                  $(this).find('.timeline-icon').css({
332                      'margin-top': '32px'
333                  });
334                  $(this).prev().find('.timeline-icon').css({
335                      'margin-top': '6px'
336                  });
337
338                  $(this).find('.content-title').removeClass("compact-afterup").addClass('compact-afterdown');
339                  $(this).prev().find('.content-title').removeClass("compact-afterdown").addClass('compact-afterup');
340              }
341          });
342          var timeline_id=jQuery('.cooltimeline_cont').attr('id');
343          var animations=jQuery("#"+timeline_id).attr("data-animations");
344         	if(animations!="none") {
345        		AOS.refreshHard();
346        	}
347          
348        }
349      );
350    }  
351  }
352
353
354    // re-enable pretty photo
355  function enableStoryPopup(timeline_wrp){
356     if(timeline_wrp !=undefined){
357    timeline_wrp.find("a[class^='ctl_prettyPhoto']").prettyPhoto({
358     social_tools: false 
359     });
360    timeline_wrp.find("a[rel^='ctl_prettyPhoto']").prettyPhoto({
361      social_tools: false
362    });
363    $(".cool_timeline").find("a[ref^='prettyPhoto']").prettyPhoto({
364      social_tools: false,
365      show_title:false,
366     changepicturecallback: function(){ initialize(); },
367      callback: function(){unInitialize()},
368   }); 
369    }     
370  }
371
372
373
374function storySlideShow(container){
375 	container.find(".ctl_flexslider .slides").not('.slick-initialized').each(function(){
376	$(this).find("a[class^='ctl_prettyPhoto']").prettyPhoto({ social_tools:false, show_title:false }); 
377	var autoplaySpeed=parseInt($(this).data('animationspeed'));
378	var slideshow=$(this).data('slideshow');
379	$(this).slick({
380		dots: false,
381		infinite: false,
382		arrows:true,
383		mobileFirst:true,
384		pauseOnHover:true,
385		slidesToShow:1,
386		autoplay:slideshow,
387		autoplaySpeed:autoplaySpeed,
388		 adaptiveHeight: true,
389	  });      
390	}); 
391}
392// year navigation load more function
393  function naviLoadMoreBtn(parent_wrp){
394 
395    if(parent_wrp.find(".ctl_load_more").length && $("body").find(".ctl-bullets-container ul li").length){
396      parent_wrp.find(".ctl_load_more").each(function(){
397        var loadMoreBtn=$(this);
398        var timelineId=loadMoreBtn.parents(".cool_timeline").attr("id");
399          var naviContainer=$("#"+timelineId+"-navi");
400         
401          var buttonHtml='<button data-text="..Loading" class="ctl_load_more_clone">Load More</button>'
402           naviContainer.find("ul").after(buttonHtml);
403           naviContainer.find(".ctl_load_more_clone").on("click",function(){
404            var text=$(this).data("text");
405            $(this).text(text);
406            loadMoreBtn.trigger("click");
407          });
408      });
409  
410   
411     
412 /*  $(".ctl_load_more_clone").on("click",function(){
413     var text=$(this).data("text");
414     $(this).text(text);
415      $('.cool_timeline').find('.ctl_load_more').trigger("click");
416    }); */
417  }
418  }
419
420  // enable slideshow in popup in minimal design
421  function initialize(){
422    $(".ctl_popup_slick .slides").each(function(){
423      $(this).slick({
424        dots: false,
425        infinite: false,
426        slidesToShow:1,
427        autoplay:false,
428        autoplaySpeed: 2000,
429         adaptiveHeight: true
430      });      
431      }); 
432    }
433
434    //unset on close
435    function unInitialize(){
436      $(".ctl_popup_slick .slides").each(function(){
437      $(this).slick('unslick');      
438      }); 
439      }
440
441
442  // re-enable scrolling navigation 
443function storyYearNavigation(timeline_wrp){
444      if(timeline_wrp !=undefined){
445      var wrp_id= timeline_wrp.attr("id");
446      $("#"+wrp_id+'-navi').remove();
447
448      var pagination= timeline_wrp.attr('data-pagination');
449              var pagination_position= timeline_wrp.attr('data-pagination-position');
450              var bull_cls='';
451              var position='';
452              if(pagination_position=="left"){
453                 bull_cls='section-bullets-left';
454                position='left';
455              }else if(pagination_position=="right"){
456                 bull_cls='section-bullets-right';
457                position='right';
458              }else if(pagination_position=="bottom"){
459                 bull_cls='section-bullets-bottom';
460                position='bottom';
461              } 
462            $('body').sectionScroll({
463                // CSS class for bullet navigation
464                bulletsClass:bull_cls,
465               // CSS class for sectioned content
466                sectionsClass:'scrollable-section',
467                // scroll duration in ms
468                scrollDuration: 1500,
469               // displays titles on hover
470                titles: true,
471                 // top offset in pixels
472                topOffset:2,
473              // easing opiton
474                easing: '',
475                id:wrp_id,
476                position:position,
477              });
478              }        
479      }
480
481
482});

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.