PageSourceSearch

https://deltamoms.gr/wp-content/themes/deltamoms/assets/js/archive.js?ver=6351

js deltamoms.gr collected 2026-09-26 21:40:01 UTC 7,010 bytes, 222 lines download raw bytes

1var dots, loader, tlLoader;
2document.addEventListener("DOMContentLoaded", function (event) {
3
4  //Timeline loader
5  dots = $('.dot');
6  loader = $('#loader');
7  tlLoader = new TimelineMax({
8      paused: true,
9      repeat: -1
10  });
11
12  tlLoader.staggerFromTo(dots, 0.5, {
13              y: 0,
14              autoAlpha: 0
15          }, {
16              y: 20,
17              autoAlpha: 1,
18              ease: Back.easeInOut
19          },
20          0.1
21  ).fromTo(loader, 0.3, {
22              autoAlpha: 1,
23              scale: 1
24          }, {
25              autoAlpha: 0,
26              ease: Power0.easeNone
27          },
28          1
29  );
30
31  gsap.set(".filtered-posts-items .post-item", { y: 100, opacity: 0 });
32  ScrollTrigger.batch(".filtered-posts-items .post-item", {
33      onEnter: batch => gsap.to(batch, { opacity: 1, y: 0, duration: 2, ease: "power4.out", stagger: { each: 0.1, grid: [1, 3] }, overwrite: true }),
34      onLeaveBack: batch => gsap.set(batch, { opacity: 0, y: 100, duration: 2, overwrite: true })
35  });
36  ScrollTrigger.addEventListener("refreshInit", () => gsap.set(".filtered-posts-items .post-item", { y: 0 }));
37
38  $('.sub-filter-item').click(function(){
39    if ( !$(this).hasClass('active-sub-filter') ){
40        $(this).addClass('active-sub-filter');
41    }else{
42        $(this).removeClass('active-sub-filter');
43    }
44    setArticleBoxesArchiveSingleCat();
45    return false;
46  });
47
48
49});
50
51
52
53// infinite scroll
54let count_ajax_calls = 0;
55
56window.addEventListener('scroll', function() {
57  var viewMorePosts = document.querySelector('.view-more-posts');
58  let offset = 600;
59  if (viewMorePosts)
60    if (window.scrollY + offset >= viewMorePosts.offsetTop + viewMorePosts.offsetHeight - window.innerHeight) {
61      viewMorePosts.parentNode.removeChild(viewMorePosts);
62      getMoreArticles();
63    }
64});
65
66function getMoreArticles(){
67
68count_ajax_calls++;
69const data = new FormData();
70
71data.append( 'action', 'archive_infinite_scroll' );
72data.append( 'count_ajax_calls', count_ajax_calls );
73
74var filterIDs = getFilterIds();
75
76if ($('body').hasClass('tag')){
77  data.append( 'categ_type', 'tag' );
78  data.append( 'tag_ids', filterIDs );
79}else{
80  data.append( 'categ_type', 'category' );
81  data.append( 'cat_ids', filterIDs );
82}
83
84
85
86data.append( 'nonce', $('#archive_infinite_scroll_nonce').val() );
87
88fetch(ajaxUrl, {
89  method: 'POST',
90  mode: "cors", // no-cors, *cors, same-origin
91  cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
92  credentials: "same-origin", // include, *same-origin, omit
93  body: data
94})
95.then(response => response.json())
96.then(data => {
97
98    // console.log(data.html);
99
100    // Assuming there are elements with the classes '.filtered-posts-items' and '.view-more-wrap'
101    const filteredPostsItems = document.querySelector('.filtered-posts-items');
102    const viewMoreWrap = document.querySelector('.view-more-wrap');
103
104    if (data.html == '') return;
105
106    // Append the HTML response
107    filteredPostsItems.insertAdjacentHTML('beforeend', data.html);
108
109    // Create a new div with the class 'view-more-posts'
110    const viewMorePostsDiv = document.createElement('div');
111    viewMorePostsDiv.classList.add('view-more-posts');
112
113    // Append the new div to the '.view-more-wrap' element
114    viewMoreWrap.appendChild(viewMorePostsDiv);
115
116    gsap.set(".filtered-posts-items .post-item.new-item-" + count_ajax_calls, { y: 100, opacity: 0 });
117    ScrollTrigger.batch(".filtered-posts-items .post-item.new-item-" + count_ajax_calls, {
118        onEnter: batch => gsap.to(batch, { opacity: 1, y: 0, duration: 2, ease: "power4.out", stagger: { each: 0.1, grid: [1, 3] }, overwrite: true }),
119        onLeaveBack: batch => gsap.set(batch, { opacity: 0, y: 100, duration: 2, overwrite: true })
120    });
121    boxWithIconEffect();
122    // ScrollTrigger.addEventListener("refreshInit", () => gsap.set(".filtered-posts-items .post-item.new-item-" + _count_ajax_calls, { y: 0 }));
123
124})
125.catch(error => console.error('Error:', error));
126
127}
128
129
130var StoreFirstLoadBoxes = '';
131function setArticleBoxesArchiveSingleCat(){
132
133  if ( document.querySelector('.view-more-posts') === null ){
134    const _viewMoreWrap = document.querySelector('.view-more-wrap');
135    const _viewMorePostsDiv = document.createElement('div');
136    _viewMorePostsDiv.classList.add('view-more-posts');
137    _viewMoreWrap.appendChild(_viewMorePostsDiv);
138 }
139 
140  // clean boxes
141  if (StoreFirstLoadBoxes==''){
142      StoreFirstLoadBoxes = $('.filtered-posts-items').html();
143  }
144  $('.filtered-posts-items').html('');
145  tlLoader.play();
146  $('.loader-wraper').removeClass('hidden');
147
148  var filterIDs = getFilterIds();
149
150  // console.log('filterIDs', filterIDs);
151
152  if (filterIDs.length == 0){
153      $('.filtered-posts-items').html(StoreFirstLoadBoxes);
154      $('.loader-wraper').addClass('hidden');
155      tlLoader.pause();
156      setAnimationForArchiveArticles();
157      return;
158  }
159
160  // if filters are selected run the ajax
161  const data = new FormData();
162
163  data.append( 'action', 'get_first_boxes' );
164  data.append( 'how_many', 12 );
165  data.append( 'cat_ids', filterIDs );
166  data.append( 'nonce', $('#get_first_boxes_nonce').val() );
167
168  fetch(ajaxUrl, {
169      method: 'POST',
170
171      mode: "cors", // no-cors, *cors, same-origin
172      cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
173      credentials: "same-origin", // include, *same-origin, omit
174      body: data
175  })
176  .then(response => response.json())
177  .then(data => {
178
179      // console.log(data.html);
180      $('.filtered-posts-items').html('');
181      $('.loader-wraper').addClass('hidden');
182      tlLoader.pause();
183
184      // Assuming there are elements with the classes '.filtered-posts-items' and '.view-more-wrap'
185      const filteredPostsItems = document.querySelector('.filtered-posts-items');
186      const viewMoreWrap = document.querySelector('.view-more-wrap');
187
188      if (data.html == '') return;
189
190      // Append the HTML response
191      filteredPostsItems.insertAdjacentHTML('beforeend', data.html);
192
193      setAnimationForArchiveArticles()
194  })
195  .catch(error => console.error('Error:', error));
196
197}
198
199function getFilterIds(){
200var filterIDs = [ ];
201
202filterIDs.push($('.category-mainsection').data('categories'));
203
204// add ids of all active children and remothe their fathers
205$('.active-sub-filter').each(function(){
206    filterIDs.push( $(this).data('subcatid') );
207    // exclude parents that have active children form parent filters
208    if ( filterIDs.indexOf( $(this).data('parentid')) >-1  ) 
209    removeAllInstances(filterIDs, $(this).data('parentid'))
210});
211
212return filterIDs;
213}
214
215function setAnimationForArchiveArticles(){
216  gsap.set(".filtered-posts-items .post-item", { y: 100, opacity: 0 });
217  ScrollTrigger.batch(".filtered-posts-items .post-item", {
218      onEnter: batch => gsap.to(batch, { opacity: 1, y: 0, duration: 2, ease: "power4.out", stagger: { each: 0.1, grid: [1, 3] }, overwrite: true }),
219      onLeaveBack: batch => gsap.set(batch, { opacity: 0, y: 100, duration: 2, overwrite: true })
220  });
221  boxWithIconEffect()
222}

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.