PageSourceSearch

https://ccnrb.org/wp-content/themes/space-ccnrb/js/main.js?ver=857100262

js ccnrb.org collected 2026-09-25 04:43:49 UTC 17,506 bytes, 628 lines download raw bytes

1var ww, hh, yy, initSlideShows, trickySlideshowId = 0, a_slideshows = new Array();
2var _page = 1,
3_currentCategory,
4 _moretoload = true //true unless we have loaded everything available
5, _ajaxisloading = false //is loading or not
6, _cancelloading = false, // to override
7_postType = '',
8_taxonomy = '';
9
10var displaySize, 
11desktop = 1221, 
12tablet1 = 1220, 
13tablet2 = 980, 
14mobile1 = 800, 
15mobile2 = 600,
16displaySizeN = 'desktop';
17var $tablet1 = window.matchMedia("(max-width: "+tablet1+"px)");
18var $tablet2 = window.matchMedia("(max-width: "+tablet2+"px)");
19var $mobile1 = window.matchMedia("(max-width: "+mobile1+"px)");
20var $mobile2 = window.matchMedia("(max-width: "+mobile2+"px)");
21
22
23
24jQuery(document).ready(function($){
25
26
27  if(window.location.hash){
28
29    //try to find something after the /#rub such as /#rub/new-page
30    var i = window.location.hash.indexOf('/');
31    
32    if(i != -1){
33      _idhash = window.location.hash.substr(i+1,window.location.hash.length);
34      _scroll = window.location.hash.substr(0,i);
35    }else{
36      _scroll = window.location.hash; 
37    }
38  }else{
39    _scroll = $(window).scrollTop();
40  }
41
42  scrollToContent(_scroll);
43
44  $('a[href*="#"]').not('a[href^="#"]').each(function(){
45    var lin = $(this).attr('href').lastIndexOf('/');
46    if($(this).attr('href').substr(0, lin+1) == window.location.href) {
47      $(this).attr('href',$(this).attr('href').substr(lin+1,$(this).attr('href').length));
48    }
49  });
50
51  jQuery('a[href^="#"]').not('a[href="#"]').click(preScrollTo);
52
53
54  // check if current page isn't in a nav..
55  var cururl = window.location.href;
56  jQuery('.menu-footer1-container a, .menu-header1-container a').each(function() {
57    var lin = jQuery(this).attr('href');
58    if(lin == cururl) {
59      if(!jQuery(this).parent().hasClass('current_page_item')) {
60        jQuery(this).parent().addClass('current_page_item');
61      }
62    }
63  })
64
65
66/* Flipped email address */
67    jQuery('.linema').each(function() {
68        jQuery(this).on('mousedown', function() {
69            var em = reverseString(jQuery(this).text());
70            window.location.href = "mailto:" + em;
71        })
72    }).css('cursor', 'pointer');
73
74  function reverseString(str) {
75    return str.split("").reverse().join("");
76  }
77    
78    function flipTextCopy() {
79      var selection = window.getSelection(),
80          copytext = reverseString(jQuery(this).text());
81          newdiv = document.createElement('div');
82      newdiv.style.position = 'absolute';
83      newdiv.style.left = '-99999px';
84      document.body.appendChild(newdiv);
85      newdiv.innerHTML = copytext;
86      selection.selectAllChildren(newdiv);
87
88      window.setTimeout(function () {
89          document.body.removeChild(newdiv);
90      }, 100);
91    }
92
93    jQuery('.linema').bind('copy', flipTextCopy);
94    /* /Flipped email address */
95
96    // jQuery('h1').each(function() {
97    //   let t = jQuery(this).html();
98    //   var i = t.indexOf(' – ');
99    //   if(i > -1) {
100    //     t = t.substr(0, i) + '<br>' + t.substr(i+3, t.length);
101    //   }
102    //   jQuery(this).html(t)
103    // })
104
105
106    //// Find External LInks
107    var cursite = window.location.hostname;
108    jQuery('a').each(function(){
109      if(jQuery(this).attr('href')){
110        if(jQuery(this).attr('href').indexOf(cursite) == -1 &&
111           jQuery(this).attr('href').substr(0,1) != '#' &&
112           jQuery(this).attr('href').substr(0,7) != 'mailto:' &&
113           jQuery(this).attr('href').substr(0,1) != '/' &&
114           jQuery(this).text() != '' &&
115           jQuery(this).attr('href').substr(0,6) != 'javasc') {
116              jQuery(this).addClass('external-link');
117              jQuery(this).attr('target', '_blank');
118        }
119      }
120    })
121
122    if(jQuery('.billetweb').length > 0) {
123      jQuery('body').addClass('full-length');
124    }
125
126    if(jQuery('.entry-content-section-newsletter_form').length > 0) {
127      cleanNewsletterForm();
128    }
129
130
131    // mobile nav
132    initMobileNav();
133
134
135
136initSlideShows = function() {
137    /* 221101 Archive weird slideshow-dots-wrapper confusing layout */
138
139    /*if($(this).hasClass('header-slides')){
140        o = {height:"auto",width:"fullscreen", minHeight: 662, clickableItems: false};
141      } else if($(this).hasClass('text-slides')) {
142        //o = {height:"auto",width:"100%", looping: false};
143      }*/
144      //}
145      
146      // var o = {height:"auto",width:"auto", mode:"manual"}
147
148    jQuery(".lbslideshow").each(function(){
149      var o;
150      o = {height:"auto",width:"auto", clickableItems: false, responsiveHeight: true, minHeight: 500, minHeightTablet: 400, minHeightMobile: 186};
151      
152
153      $(this).attr('data-status', '');
154      
155      var lbslideshow = new LBSlideshow($(this),o);
156      a_slideshows.push(lbslideshow);
157      lbslideshow.init(); 
158    });
159  }
160
161    initSlideShows();
162
163    jQuery('form.search-form').addClass('closed');
164    jQuery('a[href="#search').on('mousedown', function(e) {
165      e.preventDefault();
166      if(jQuery('form.search-form.closed').length > 0) {
167        jQuery('form.search-form.closed').removeClass('closed').addClass('open');
168        jQuery(this).addClass('open');
169      } else {
170        jQuery('form.search-form').addClass('closed').removeClass('open');
171        jQuery(this).removeClass('open');
172      }
173    })
174
175
176    // linkedcontent nav <>
177    if(jQuery('.entry-linked-nav').length > 0) {
178      initEntryLinkedNav();
179    }
180
181    initAjax();
182
183   
184    jQuery( window ).resize(resizeIt);
185    resizeIt(true);
186
187    jQuery( window ).scroll(scrollIt);
188    scrollIt();
189
190}
190);
191
192/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** NEWSLETTER FORM */ 
193function cleanNewsletterForm() {
194  // if(jQuery('.indicates-required').length > 0) {
195    //jQuery('.indicates-required').html('<span class="asterisk">*</span>');
196  // }
197  // if(jQuery('label[for="mce-EMAIL"').length > 0) {
198  //   jQuery('label[for="mce-EMAIL"').prepend('Adresse email / ');
199  // }
200}
201
202/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** MOBILE NAV */ 
203function initMobileNav() {
204
205  var memc = jQuery('.main-navigation-content').clone();
206  jQuery('.mobile-navigation-wrapper').prepend(memc);
207
208  jQuery('.mobile-navigation-button').on('mousedown', function(){
209    if(jQuery(this).hasClass('open')) {
210      closeMobileNav();
211    } else {
212      openMobileNav();
213    }
214  })
215}
216
217function openMobileNav() {
218  jQuery('.mobile-navigation-button').not('.open').addClass('open');
219  jQuery('.mobile-navigation-wrapper').not('.open').addClass('open');
220  jQuery('body').not('.mobile-navitation-open').addClass('mobile-navitation-open');
221}
222
223function closeMobileNav() {
224  jQuery('.mobile-navigation-button.open').removeClass('open');
225  jQuery('.mobile-navigation-wrapper.open').removeClass('open');
226  jQuery('body.mobile-navitation-open').removeClass('mobile-navitation-open');
227}
228
229
230
231
232/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
233///// RELATED CONTENT MICRO NAV
234var _aLinkedNav = new Array();
235
236function initEntryLinkedNav() {
237  jQuery('.entry-linked').not('.entry-linked-typeartist, .entry-linked-typedate').each(function(){
238    var arti = jQuery(this).find('.entry-linked-articles');
239    // console.log(arti.css('flex-wrap'));
240    if(arti.css('flex-wrap') == 'nowrap') {
241      jQuery(this).addClass('jsenabled');
242      var alin = new LBLinkedNav(jQuery(this));
243      alin.addSize(desktop, 31.9);
244      alin.addSize(tablet2, 48.6);
245      alin.addSize(mobile2, 100);
246
247      _aLinkedNav.push(alin);
248    }
249  })
250
251  // 260330 we add artists too but with a 4 item range
252  jQuery('.entry-linked.entry-linked-typeartist').not('.entry-linked-typedate').each(function(){
253    var arti = jQuery(this).find('.entry-linked-articles');
254    if(arti.css('flex-wrap') == 'nowrap') {
255      jQuery(this).addClass('jsenabled');
256      var alin = new LBLinkedNav(jQuery(this));
257      alin.addSize(desktop, 23.6);
258      alin.addSize(tablet1, 31.9);
259      alin.addSize(mobile1, 48.6);
260      alin.addSize(mobile2, 100);
261
262      _aLinkedNav.push(alin);
263    }
264  })
265}
266
267///// /RELATED CONTENT MICRO NAV
268
269//SMOOTH SCROLLING FOR ANCHORS
270function preScrollTo(e){
271  e.preventDefault();
272  scrollToContent(jQuery(e.currentTarget).attr('href'));
273}
274function scrollToContent(pContent){
275
276  var tmContent = pContent;
277  
278  var ny;
279
280  if(typeof(tmContent) == 'string'){
281  //if(toString.call(tmContent) == '[object String]'){
282    //link to anchor
283    
284    if(jQuery('a[name="'+tmContent.substr(1,tmContent.length)+'"]').length>0){
285
286      ny = jQuery('a[name='+tmContent.substr(1,tmContent.length)+']').offset().top-525;
287    
288    }else{
289    //or link to content
290      if(jQuery(tmContent) == undefined){
291        //nothing to scrollto
292        return '';
293      }else{
294        if(jQuery(tmContent).offset() == undefined) {
295          return '';
296        } else {
297          ny = jQuery(tmContent).offset().top;  
298        }
299      }
300      
301    }
302  }
303  //ny = ny-hh/10;
304  var t = .5;
305
306  window.scroll({
307    top: ny, 
308    left: 0, 
309    behavior: 'smooth'
310  });
311 
312
313  
314}
315
316function scrollIt(){
317  var ny = jQuery(window).scrollTop();
318  var animd = .6;
319  if(yy != ny){
320    yy = ny;
321    // header-content
322    //scroll = load more
323
324
325    closeMobileNav();
326    
327    // console.log(_postType);
328    if(jQuery('.ajax-loader').length > 0 && _postType != 'date' && _postType != 'activity' && _postType != 'artist'){
329      
330        if(jQuery(window).scrollTop() + jQuery(window).height() > jQuery(document).height() - jQuery('#colophon').height()) {
331         
332        
333              loadMoreProjects();
334            
335        }
336      }
337    
338    
339  }
340}
341
342
343
344
345function resizeIt(pForce){
346  var nw = jQuery(window).width();
347  var nh = jQuery(window).height();
348
349  if(nw != ww || nh != hh || pForce === true){
350
351    var oDisplaySizeN = displaySizeN;
352
353    if($mobile2.matches) {
354      displaySize = mobile2;
355      displaySizeN = 'mobile2';
356    } else if($mobile1.matches) {
357      displaySize = mobile1;
358      displaySizeN = 'mobile1';
359    } else if($tablet2.matches) {
360      displaySize = tablet2;
361      displaySizeN = 'tablet2';
362    } else if($tablet1.matches) {
363      displaySize = tablet1;
364      displaySizeN = 'tablet1';
365    } else {
366      displaySize = desktop;
367      displaySizeN = 'desktop';
368    }
369
370    ww = nw;
371    hh = nh;
372    
373    closeMobileNav();
374
375    for(var i = 0 ; i < a_slideshows.length ; i++){
376      var dev = (displaySize == desktop) ? 'desktop' : (displaySize == tablet1 || displaySize == tablet2 ? 'tablet' : 'mobile');
377      a_slideshows[i].resize(ww,hh, dev);
378    }
379
380    if(displaySizeN != oDisplaySizeN) {
381      for(var i = 0 ; i < _aLinkedNav.length ; i++){
382       // console.log(displaySize, displaySizeN);
383        _aLinkedNav[i].resize(displaySize);          
384      }
385    }
386
387    jQuery('.home-section-artist, .home-section-activity, .home-section-article, .home-section-spectacle').each(function() {
388      var hb = jQuery(this).find('.home-section-block-content').height();
389      hb = Math.max(hb) + 56;
390      jQuery(this).css('min-height', hb);
391    })
392  }
393
394
395}
396
397
398/* ------------------------------------------------------------------------------------------------------------------------
399/* LOAD MORE : Ajax loading of next n posts! (works with functions.php) */
400/* ------------------------------------------------------------------------------------------------------------------------*/
401function initAjax() {
402  if(jQuery('#agenda, body.is-date').length > 0) {
403    _postType = 'date';
404  } else if(jQuery('body.is-spectacle').length > 0) {
405    _postType = 'spectacle';
406  }  else if(jQuery('body.is-artist').length > 0) { // unused
407    _postType = 'artist';
408  } else if(jQuery('body.is-activity').length > 0) { // unused
409    _postType = 'activity';
410  } else {
411    _postType = 'post';
412  }
413
414
415  // _currentCategory + taxonomy
416  if(jQuery('.archive-category, #agenda')) {
417    // var curcat = jQuery('.archive-category').attr('data-category');
418    if(jQuery('.archive-category, #agenda').data('category')) {
419      _currentCategory = jQuery('.archive-category, #agenda').data('category');
420    }
421
422    if(jQuery('.archive-category, #agenda').data('taxonomy')) {
423      _taxonomy = jQuery('.archive-category, #agenda').data('taxonomy');
424    }
425  }
426  
427  // console.log('_currentCategory >>> '+_currentCategory);
428
429  // taxo
430  var c = document.body.className.split(' ');
431  for(var i = 0 ; i < c.length ; i++) {
432    if(c[i].substr(0, 4) == 'tax-') {
433      _taxonomy = (c[i].split('tax-')[1]);
434    }
435  }
436  
437  initAjaxNav();
438}
439var _direction;
440function initAjaxNav() {
441
442  //2606 Direction time switch
443  if(jQuery('.agenda-direction-switches').length > 0) {
444    jQuery('.agenda-direction-switches a').on('click', function(e) {
445      e.preventDefault();
446      if(!jQuery(this).hasClass('active')) {
447        var dir = jQuery(this).data('dir');
448        // console.log(dir);
449
450        jQuery('.agenda-direction-switches').attr('data-curdir', dir);
451        jQuery('#agenda').attr('data-curdir', dir);
452        _direction = dir;
453        jQuery('.agenda-direction-switches a.active').removeClass('active');
454        jQuery(this).addClass('active');
455
456
457
458        jQuery('.cat-list_item.active').click();
459
460      }
461    })
462  }
463  // /2606 Direction time switch
464
465  jQuery('.cat-list_item').on('click', function(e) {
466      e.preventDefault();
467
468      jQuery('.cat-list_item').removeClass('active');
469      jQuery(this).addClass('active');
470
471      _page = 1; //1;
472      
473      if(_postType == 'date' || _postType == 'spectacle') {
474        _currentCategory = jQuery(this).data('termid'); // for dates we use term id
475      } else {
476        _currentCategory = jQuery(this).data('slug');
477      }
478
479      if(_postType == 'date') {
480
481        if(!_direction) {
482          _direction = jQuery('.agenda-direction-switches').data('curdir');
483        }
484        // console.log(jQuery('.agenda-direction-switches').data('curdir'));
485        // console.log('DIRECTION :: ', _direction);
486      } else {
487        _direction = '';
488      }
489
490      _moretoload = true;
491
492      jQuery('.ajax-loader').css('display','inline-block');
493      jQuery('.posts, #agenda').empty();
494
495      // console.log(_page, _currentCategory, _postType, _taxonomy);
496
497
498      jQuery.post(phpVars.ajaxurl, {action: 'ajax_pagination', ppaged : _page, category:_currentCategory, post_type:_postType, taxonomy: _taxonomy, direction: _direction},
499        function( result ) {
500
501          // console.log(result);
502
503          _ajaxisloading = false;
504
505          jQuery('.ajax-loader').css('display','none');
506
507          if(result == 'empty') {
508            _moretoload = false;
509          } else {
510            jQuery('.posts, #agenda').html(result);  
511          }
512
513          // lazyloadImages();
514          postAjax();
515          
516        }
517    ).fail(function(){ 
518      console.log("failure");
519      console.log(arguments);
520    });
521  });
522}  
523
524//called on scroll to the bottom of the page
525  function loadMoreProjects(){
526    
527    // console.log(421);
528    
529    if(_moretoload == true){
530      if(!_ajaxisloading && !_cancelloading){
531
532        _ajaxisloading = true;
533
534        //_page = _page == 1 ? 3 : _page+1; //10 the first time, 5 after..
535        _page++; //now we starts only with 5 anyway so 5 all the way.
536
537  
538        jQuery('.ajax-loader').css('display','inline-block');
539
540        
541        if (typeof $archive_currentCategory !== 'undefined') {
542          _currentCategory = $archive_currentCategory;
543        }
544
545        // console.log(_page, _currentCategory, _postType, _taxonomy);
546
547        jQuery.ajax({
548          type: 'post',
549          url: phpVars.ajaxurl,
550          cache: false,
551          data:{action: 'ajax_pagination', ppaged : _page, category:_currentCategory, post_type:_postType, taxonomy: _taxonomy},
552          // contentType: "application/json; charset=utf-8",
553          // dataType: 'json',
554          dataType: "html",
555          async: true,
556          success: loadMoreProjects_success,
557          error: loadMoreProjects_error
558        });
559
560        // jQuery.post(phpVars.ajaxurl, {action: 'ajax_pagination', ppaged : _page, category:_currentCategory},
561        //   function( result ) {
562
563        //     _ajaxisloading = false;
564
565        //     jQuery('.ajax-loader').css('display','none');
566
567            
568        //     if(result == 'empty') {
569        //       _moretoload = false;
570        //     } else {
571        //       jQuery('.posts').append(result);  
572        //       postAjax();
573        //     }
574
575        //     // lazyloadImages();
576            
577        //   }
578        // )
579      }
580    }
581
582  }
583
584  function loadMoreProjects_success(result) {
585      _ajaxisloading = false;
586
587      // console.log(result);
588
589      jQuery('.ajax-loader').css('display','none');
590
591      
592      if(result.substr(0,5) == 'empty' || result == '') {
593        _moretoload = false;
594        // jQuery('.posts').append(result);  // debug
595
596      } else {
597        jQuery('.posts').append(result);  
598        postAjax();
599      }
600  }
601
602  function loadMoreProjects_error(result) {
603    alert("FAILED : " + result.status + ' ' + result.statusText); 
604    _moretoload = false;
605  }
606
607
608  function postAjax() {
609    if(jQuery('.context-list li').length >0) {
610      jQuery('.context-list li').each(function() {
611        var text = jQuery(this).text();
612        var text2 = text.replaceAll("--", ",");
613        jQuery(this).text(text2);
614        
615      })
616    }
617
618    lazyloadImages();
619  }
620
621  function lazyloadImages(){
622    
623    jQuery("img.lazy:not([data-status])").attr("data-status","ok").lazyload({
624          threshold : 200,
625          effect : "fadeIn",
626          placeholder: phpVars['templateDir']+'/images/px.jpg'
627       });  
628  }

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.