PageSourceSearch

https://thomashampson.com/wp-content/themes/thomashampson/dist/app.js?ver=1.0.1

js thomashampson.com collected 2026-09-24 22:49:00 UTC 13,297 bytes, 446 lines download raw bytes

1sethrefs = function () {
2	if (document.querySelectorAll) {
3		var datahrefs = document.querySelectorAll('[data-href]'),
4				dhcount = datahrefs.length;
5		while (dhcount-- > 0) {
6			var ele = datahrefs[dhcount],
7					addevent = function (ele, event, func) {
8						if(ele.addEventListener) ele.addEventListener(event, link, false);
9						else ele.attachEvent('on' + event, link);
10					},
11					link = function (event) {
12						var target = event.target,
13								url = this.getAttribute('data-href');
14						if (!target.href) {
15			    		var newevent = document.createEvent("MouseEvents");
16			    		if (newevent.initMouseEvent) {
17			    			var newlink = document.createElement("a");
18		    			  newlink.setAttribute('href', url);
19		    			  newlink.innerHTML = 'link event';
20	    					newevent.initMouseEvent(event.type, true, false, window, event.detail, event.screenX, event.screenY, event.clientX, event.clientY, event.ctrlKey, event.altKey, event.shiftKey, event.metaKey, event.button, null);
21	    					newlink.dispatchEvent(newevent);
22				    	}
23				    	else {
24				    		var meta = (event.metaKey) ? '_self' : '_blank';
25				    		window.open(url, meta);
26				    	}
27						}
28					};
29			addevent(ele, 'click', link);
30		}
31	}
32};
33
34sethrefs();
35
36(function($) {
37
38$.fn.extend({
39    list2Columns: function(numCols) {
40        var listItems = $(this).find('li'); /* get the list data */
41        var listHeader = $(this);
42        var numListItems = listItems.length;
43        var numItemsPerCol = Math.ceil(numListItems / numCols); /* divide by the number of columns requires */
44        var currentColNum = 1, currentItemNumber = 1, returnHtml = '', i = 0;
45
46        /* append the columns */
47        for (i=1;i<=numCols;i++) {
48            $(this).append('<ul class="column list-column-' + i + '"></ul>');
49        }
50
51        /* append the items to the columns */
52        $.each(listItems, function (i, v)
53        {
54            if (currentItemNumber <= numItemsPerCol){
55                currentItemNumber ++;
56            } else {
57                currentItemNumber = 1;
58                currentColNum ++;
59            }
60            $('.list-column-'+currentColNum).append(v);
61        });
62        // $(this).remove();
63    }
64});
65
66
67$.fn.slideFadeToggle  = function(speed, easing, callback) {
68  return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);
69};
70
71
72})(jQuery);
73
74(function($) {
75$(function(){
76
77  /*****
78    Set some global variables
79  *****/
80  var template_url = $('#template_url').val();
81
82
83  /*****
84    Nav toggle
85  *****/
86  $('.site-menu-open').on('click', function(e){
87    e.preventDefault();
88    $('html').attr('data-nav-state', 'open');
89  });
90
91  $('.site-menu-close').on('click', function(e){
92    e.preventDefault();
93    $('html').attr('data-nav-state', 'closed');
94  });
95
96  // Split <li> into 2 groups by class
97  $('#menu-header').list2Columns(2); // Change this number to change num of columns
98  $('#menu-header a').each(function(i) {
99    $(this).attr('data-hover', $(this).text());
100  });
101
102
103  /*****
104    Home header carousel
105  *****/
106  if ($('.home-header').length) {
107    $('.home-header').flickity({
108      cellSelector: '.home-header-item',
109      cellAlign: 'left',
110      contain: true,
111      pageDots: false,
112      prevNextButtons: false,
113      // autoPlay: 5000,
114      autoPlay: false,
115      wrapAround: true
116    });
117    $('.home-header').flickity('resize');
118    setTimeout(function(){
119      $('.home-header').flickity('resize');
120    }, 300);
121
122    $('.home-header-arrows .prev').on('click', function(e){
123      e.preventDefault();
124      var parent = $(this).parents('.home-header');
125      parent.flickity('previous');
126    });
127
128    $('.home-header-arrows .next').on('click', function(e){
129      e.preventDefault();
130      var parent = $(this).parents('.home-header');
131      parent.flickity('next');
132    });
133
134    $('.home-header').on( 'select.flickity', function(event, index) {
135      $('.home-header-nav-item').removeClass('is-selected');
136      $('.home-header-nav-item').eq(index).addClass('is-selected');
137    });
138
139    $('.home-header-nav-item').on('click', function(e){
140      e.preventDefault();
141      var index = $(this).index();
142      // console.log(index);
143      $('.home-header').flickity('select', index);
144    });
145  }
146
147
148  /*****
149    Home recordings carousel
150  *****/
151  if ($('.home-recordings').length) {
152    $('.home-recordings-carousel').flickity({
153      cellSelector: '.home-recording-item',
154      cellAlign: 'center',
155      contain: true,
156      pageDots: false,
157      prevNextButtons: false,
158      autoPlay: 5000,
159      wrapAround: true
160    });
161    $('.home-recordings-carousel').flickity('resize');
162    setTimeout(function(){
163      $('.home-recordings-carousel').flickity('resize');
164    }, 300);
165
166    $('.home-recordings-carousel-arrows .prev').on('click', function(e){
167      e.preventDefault();
168      var parent = $('.home-recordings-carousel');
169      parent.flickity('previous');
170    });
171
172    $('.home-recordings-carousel-arrows .next').on('click', function(e){
173      e.preventDefault();
174      var parent = $('.home-recordings-carousel');
175      parent.flickity('next');
176    });
177  }
178
179
180  /*****
181    Home videos carousel
182  *****/
183  if ($('.home-videos').length) {
184    $('.home-videos-carousel').flickity({
185      cellSelector: '.video-item',
186      cellAlign: 'center',
187      contain: true,
188      pageDots: false,
189      prevNextButtons: false,
190      autoPlay: 5000,
191      wrapAround: true
192    });
193    $('.home-videos-carousel').flickity('resize');
194    setTimeout(function(){
195      $('.home-videos-carousel').flickity('resize');
196    }, 300);
197
198    $('.home-videos-carousel .prev').on('click', function(e){
199      e.preventDefault();
200      var parent = $('.home-videos-carousel');
201      parent.flickity('previous');
202    });
203
204    $('.home-videos-carousel .next').on('click', function(e){
205      e.preventDefault();
206      var parent = $('.home-videos-carousel');
207      parent.flickity('next');
208    });
209  }
210
211
212  /*****
213    Texts Archive Toggling
214  *****/
215  if ($('[data-accordion]').length) {
216    $(document).on('click', '[data-accordion] [data-accordion-item]', function(e){
217      e.preventDefault();
218      $(this).toggleClass('open');
219      $(this).find('[data-accordion-content]').slideFadeToggle(300);
220    });
221
222    $('[data-accordion-toggle]').on('click', function(e){
223      e.preventDefault();
224
225      var state = $(this).attr('data-state');
226
227      if (state == 'opened') {
228        // Close them all
229        $('[data-accordion] [data-accordion-item]').each(function(){
230          if ($(this).hasClass('open')) {
231            $(this).removeClass('open');
232            $(this).find('[data-accordion-content]').stop(true, true).fadeOut({ duration: 300, queue: false }).slideUp(300);
233          }
234        });
235        $('[data-accordion-toggle]').attr('data-state', 'closed');
236      } else {
237        // Open them all
238        $('[data-accordion] [data-accordion-item]').each(function(){
239          if (!$(this).hasClass('open')) {
240            $(this).addClass('open');
241            $(this).find('[data-accordion-content]').stop(true, true).fadeIn({ duration: 300, queue: false }).css('display', 'none').slideDown(300);
242          }
243        });
244        $('[data-accordion-toggle]').attr('data-state', 'opened');
245      }//endif
246
247    });
248  }
249
250
251  /*****
252    Fancybox
253  *****/
254  $().fancybox({
255    selector : '.lightbox-item',
256    youtube : {
257      controls: true,
258      showinfo: false
259    },
260    hash: false,
261    buttons: ['close'],
262    infobar: false,
263    idleTime: 300,
264    loop: true,
265    btnTpl: {
266      close:
267        '<button data-fancybox-close class="fancybox-button fancybox-button--close" title="{{CLOSE}}">' +
268        '<svg data-icon="close" viewBox="0 0 26.8 26.8"><use xlink:href="#close"></use></svg>' +
269        "</button>"
270    }
271  });
272  $().fancybox({
273    selector : '.gallery-single-item',
274    hash: false,
275    buttons: ['close'],
276    infobar: false,
277    idleTime: 300,
278    loop: true,
279    btnTpl: {
280      close:
281        '<button data-fancybox-close class="fancybox-button fancybox-button--close" title="{{CLOSE}}">' +
282        '<svg data-icon="close" viewBox="0 0 26.8 26.8"><use xlink:href="#close"></use></svg>' +
283        "</button>"
284    },
285    beforeLoad: function(instance, slide){
286      $('.fancybox-bg').append('<div class="gallery-lightbox-bg" style="background-image: url(' + instance.current.src + ');"></div>');
287      $('.fancybox-bg .gallery-lightbox-bg').slice(0, ($('.fancybox-bg .gallery-lightbox-bg').length - 2)).remove();
288
289    }
290  });
291
292
293  /*****
294    Rep load more
295  *****/
296  if ($('.rep-load-more').length) {
297    $('.rep-load-more .button').on('click', function(e){
298      e.preventDefault();
299
300      var add = parseInt($(this).attr('data-load-num'));
301      var total = parseInt($(this).attr('data-total-count'));
302
303      $('.rep-items .rep-item:hidden').slice(0, add).slideDown(300);
304
305      setTimeout(function(){
306        if ($('.rep-items .rep-item:visible').length == total) {
307          $('.rep-load-more .button').slideUp(300);
308        }
309      }, 350);
310    });
311  }
312
313
314  /*****
315    Timeline Filters
316  *****/
317  if ($('.timeline-header').length) {
318
319    var initial_count = parseInt($('.timeline-more .button').attr('data-initial'));
320    $('.tl-block').slice(0, initial_count).show().attr('data-loaded', true);
321
322    $('.timeline-header [data-cat-slug]').on('click', function(e){
323      e.preventDefault();
324      var slug = $(this).attr('data-cat-slug');
325
326      // Swap active classes on nav
327      $('.timeline-header [data-cat-slug]').removeClass('active');
328      $(this).addClass('active');
329
330      // Toggle visibility of certain cats
331      if (slug == '*') {
332        $('.tl-block[data-loaded]').show();
333      } else {
334        // Hide other cats
335        $('.timeline-item[data-loaded]:not([data-cat-slug="'+ slug +'"])').hide();
336
337        // SHow the one selected
338        $('.timeline-year-circle[data-loaded]').show();
339        $('.timeline-item[data-loaded][data-cat-slug="'+ slug +'"]').show();
340      }
341    });
342  }
343
344
345  /*****
346    Timeline load more
347  *****/
348  if ($('.timeline-more').length) {
349
350    $('.timeline-more .button').attr('data-total-count', $('.timeline-items .tl-block').length);
351
352    $('.timeline-more .button').on('click', function(e){
353      e.preventDefault();
354
355      var add = parseInt($(this).attr('data-load-num'));
356      var total = parseInt($(this).attr('data-total-count'));
357      var active_filter = $('.timeline-header [data-cat-slug].active').attr('data-cat-slug');
358
359      // If we have a filter selected, respect that.
360      if (active_filter == '*') {
361        $('.timeline-items .tl-block:hidden').slice(0, add).show(200).attr('data-loaded', true);
362      } else {
363        $('.timeline-items .tl-block[data-cat-slug="'+ active_filter +'"]:hidden, .timeline-items .timeline-year-circle:hidden').slice(0, add).show(200).attr('data-loaded', true);
364        // $('.timeline-items .tl-block:hidden').slice(0, add).show(200).attr('data-loaded', true);
365      }
366
367
368
369      setTimeout(function(){
370        if ($('.timeline-items .tl-block:visible').length == total) {
371          $('.timeline-more .button').slideUp(300);
372        }
373      }, 350);
374    });
375  }
376
377
378  /*****
379    AJAX Load More
380  *****/
381  if ($('.js-load-more').length) {
382    $('.js-load-more').on('click', function(e){
383      e.preventDefault();
384
385      var self = $(this);
386      var container = $('' + self.attr('data-container'));
387      var single = container.find($('' + self.attr('data-single')));
388      var type = self.attr('data-type');
389      var offset = self.attr('data-offset');
390      var taxonomy = (self.attr('data-taxonomy'))? self.attr('data-taxonomy') : '';
391      var taxonomyterm = (self.attr('data-taxonomyterm'))? self.attr('data-taxonomyterm') : '';
392      var amount = self.attr('data-amount');
393      var total = self.attr('data-total');
394
395      var query = (self.attr('data-query'))? self.attr('data-query') : '';
396
397      var post_count = single.length;
398      var loading_text = self.attr('data-loading');
399      var initial_text = self.attr('data-initial');
400
401      self.addClass('loading');
402      self.find('span').html(loading_text);
403
404      $.ajax({
405        method: "GET",
406        url: template_url + "/load-more.php?postcount=" + post_count + "&type=" + type + "&amount=" + amount + "&taxonomy=" + taxonomy + "&taxonomyterm=" + taxonomyterm + "&offset=" + offset + "&query=" + query,
407        // complete: function(){
408        //   console.log(this.url);
409        // }
410      }).done(function(msg) {
411        setTimeout(function(){
412          container.append(msg);
413          self.find('span').html(initial_text);
414          self.removeClass('loading');
415          if (total == $('' + self.attr('data-single')).length) {
416            // $('.load-more-wrapper').remove();
417            $('.load-more-wrapper').html('');
418          }
419        }, 500);
420      });
421
422    });
423  }//if ($('.js-load-more').length)
424
425
426  /*****
427    Redirect away from calendar view if screen is too small
428  *****/
429  if ($('.show-calendar-outer').length) {
430    var mq_min_1000 = window.matchMedia("(min-width: 1000px)");
431    mq_min_1000.addListener(toggle_calendar);
432    toggle_calendar(mq_min_1000);
433
434    function toggle_calendar(mq) {
435      if (mq.matches) {
436        // Window is 1000px or more
437      } else {
438        // Window is 999px or less
439        window.location = '/schedule/';
440      }
441    }
442  }
443
444
445});
446})(jQuery);

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.