PageSourceSearch

https://summerlandreview.com/wp-content/themes/2024-cmg/media/js/main.js?1773885978

js summerlandreview.com collected 2026-09-24 22:53:24 UTC 20,355 bytes, 665 lines download raw bytes

1var cmg = {}; // This is the setup for the namespace
2
3(function() {
4  var $ = jQuery;
5
6  $(document).ready(function() {
7    // These functions get called on DOM ready
8    // Moved redirect to top of header
9    //cmg.mobileRedirect();
10    //cmg.mobileStickyItems();
11    $('a').click(function() {
12      $(this).blur();
13    }); // prevents outlines on links for IE
14    $('time.timeago').timeago();
15    cmg.storyFeaturedGallery();
16    //$.slidebars();
17    //cmg.scrollNav();
18    //cmg.newScrollNav();
19    cmg.photoVideo();
20    cmg.homeSlider();
21    cmg.searchDefault();
22    cmg.searchToggle();
23    cmg.storyGallery();
24    //cmg.callOuts();
25    //cmg.heroshots();
26    cmg.preHomeSized();
27    cmg.print_this();
28    //cmg.mobFont();
29  });
30
31  $(window).load(function() {
32    // These functions get called when everything has loaded
33    cmg.flowNews();
34    cmg.homeSized();
35    cmg.navDropHeights();
36    $('#article .story_detail dl.wp-caption:first-child').css('width', 'auto');
37  });
38
39  cmg.callOuts = function() {
40    $('div.callouts')
41      .insertAfter('div#content div.story_detail p:nth-child(2)')
42      .show();
43  };
44
45  cmg.mobileRedirect = function() {
46    //var isMobile = window.matchMedia("only screen and (max-width: 700px)");
47
48    //if (isMobile.matches) {
49    if (screen.availWidth && screen.availWidth < 481) {
50      //Conditional script here
51      window.location.href =
52        'http://' + 'm.natchezdemocrat.com' + window.location.pathname;
53    }
54  };
55
56  cmg.mobileStickyItems = function() {
57    if (screen.availWidth && screen.availWidth < 720) {
58      if ($('body#articlePage').size()) {
59        //Conditional script here
60        var p_height = document.getElementById("prev_next_article_group").offsetHeight;
61        var s_height = document.getElementById("mobile_sticky_bottom_group").offsetHeight;
62        document.getElementById("mobile_sticky_bottom_group").style.bottom = p_height + 'px';
63        //if ($('#opt_video').size()) {
64          ////console.log('optimera v1');
65          //bottom_amt = p_height + s_height + 'px';
66          //$('.optimera-video-pip-BR').css("bottom", bottom_amt)
67        //}
68      }
69    }
70  };
71
72  cmg.storyFeaturedGallery = function() {
73		console.log('%c TESTING SPLIDE SLIDER V 1.1f', 'background: #08aff8; color: #222; font-weigit: bold;');
74    if ($('div#featured_gallery').size()) {
75
76      var splide = new Splide( '#featured_gallery_group', {
77        type: 'loop',
78        pagination: false,
79        autoplay: true,
80        width: '100%',
81      } );
82
83      splide.mount();
84
85      splide.on('move', function (newIndex, oldIndex, destIndex) {
86        slide_count_current = document.getElementById('slide_count_current');
87        slide_count_current.innerHTML = newIndex + 1;
88      });
89
90    }
91  };
92
93  cmg.storyGallery = function() {
94    if (!$('.gallery .gallery-icon').size()) {
95      return;
96    }
97    if ($('body.gallery_category').size()) {
98      var waitTimer,
99        lastWaitFireTime = 0;
100      var current_count = 1;
101      var controls =
102        '<div class="controls"><a href="#" class="back"><< back</a><a href="#" class="forward">forward >></a></div>';
103      var image_div = '<div class="image_main" />';
104      var caption = '<div class="caption" />';
105      $('.gallery').prepend(caption);
106      $('.gallery').prepend(image_div);
107      $('.gallery').prepend(controls);
108      var g_img_list = $('.gallery .gallery-icon a');
109      var g_item_list = $('.gallery .gallery-item');
110      //$('.gallery .gallery-item').hide();
111      var list_count = $(g_item_list).length;
112
113      //var g_img_list = $(".gallery .gallery-icon a").attr("href");
114      //var first_img = $(g_img_list).first();
115      var first_item = $(g_item_list).first();
116      var first_img = $(first_item).find('a');
117      var first_href = $(first_img).attr('href');
118      //var first_caption = $(first_img).attr('title');
119      var first_caption = $(first_item)
120        .find('.gallery-caption')
121        .text();
122      $(first_img).addClass('selected');
123      var img_item = '<img src="' + first_href + '" width=465 />';
124      $('.gallery .caption').html('<p>' + first_caption + '</p>');
125      $('.image_main').append(img_item);
126
127      function swap_img(current_count) {
128        var this_count = current_count;
129        //$(g_img_list).removeClass('selected');
130        $(g_item_list)
131          .find('a')
132          .removeClass('selected');
133        //var this_item = $(g_img_list).eq(this_count - 1);
134        var this_item = $(g_item_list).eq(this_count - 1);
135        var this_href = $(this_item)
136          .find('a')
137          .attr('href');
138        //var this_caption = $(this_item).attr('title');
139        var this_caption = $(this_item)
140          .find('.gallery-caption')
141          .text();
142        $(this_item)
143          .find('a')
144          .addClass('selected');
145        $('.image_main img').attr('src', this_href);
146        $('.gallery .caption').html('<p>' + this_caption + '</p>');
147      }
148
149      function refresh_ads() {
150        //googletag.pubads().refresh();
151        //var minWaitTime = 50000; // 50 seconds
152        var minWaitTime = 5; // 5 milliseconds
153        //var minWaitTime = 10000;
154        var now = new Date().getTime();
155
156        function processClick() {
157          //googletag.cmd.push(googletag.pubads().refresh(TESTING_G_BIGBLOCK));
158          googletag.pubads().refresh([TESTING_G_BIGBLOCK]);
159        }
160
161        if (!waitTimer) {
162          if (now - lastWaitFireTime > minWaitTime) {
163            processClick(); // fire immediately on first click
164            lastWaitFireTime = now;
165          }
166          waitTimer = setTimeout(function() {
167            waitTimer = null;
168          }, minWaitTime);
169        }
170
171        //googletag.cmd.push(googletag.pubads().refresh());
172        //googletag.pubads().refresh([ OTHER_BIGBLOCK, OTHER_MIDDLE_BIGBLOCK ]);
173      }
174
175      //$(g_img_list).each(function() {
176      $(g_item_list).each(function() {
177        var this_item = $(this).find('a');
178        $(this).click(function(c) {
179          var item_number = $('.gallery .gallery-icon a').index(this_item) + 1;
180          c.preventDefault();
181          current_count = item_number;
182          swap_img(item_number);
183        });
184      });
185
186      $('a.back').click(function(c) {
187        // back
188        c.preventDefault();
189        if (current_count > 1) {
190          current_count = current_count - 1;
191        } else {
192          current_count = list_count;
193        }
194        swap_img(current_count);
195        refresh_ads();
196      });
197
198      $('a.forward').click(function(c) {
199        // forward
200        c.preventDefault();
201        if (current_count < list_count) {
202          current_count = current_count + 1;
203        } else {
204          current_count = 1;
205        }
206        swap_img(current_count);
207        refresh_ads();
208      });
209    } else {
210      $('.gallery .gallery-icon a').colorbox({
211        scalePhotos: true,
212        maxWidth: '800px',
213        maxHeight: '800px',
214        rel: 'gal',
215      });
216    }
217  };
218
219  cmg.navDropHeights = function() {
220    $('ul.sub-nav').each(function() {
221      var this_ul = $(this);
222      var maxHeight = 0;
223
224      $(this_ul)
225        .find('.col')
226        .each(function() {
227          if ($(this).height() > maxHeight) {
228            maxHeight = $(this).height();
229          }
230        });
231
232      $(this_ul)
233        .find('.col')
234        .height(maxHeight);
235    });
236  };
237
238  cmg.preHomeSized = function() {
239    if (!$('body#homePage').size()) {
240      return;
241    }
242    $('div.main_top div.left div.river div.stories')
243      .height(500)
244      .css({
245        display: 'none',
246        left: 'auto',
247      })
248      .slideDown('slow');
249    $('div.river').css('max-height', 'none');
250  };
251
252  cmg.homeSized = function() {
253    if (!$('body#homePage').size()) {
254      return;
255    }
256
257    maxHeight = 0;
258    rightColHeight = $('div.main_top div.right').outerHeight(true);
259    leftHeader = $('div.main_top div.left div.river h3.section').outerHeight(
260      true,
261    );
262    leftColItems = $('div.main_top div.left div.top-home').outerHeight(true);
263    leftColItemsHeight = leftHeader + leftColItems;
264    maxHeight = rightColHeight - leftColItemsHeight;
265
266    $('#flow_news')
267      .insertAfter($('#navbar'))
268      .css({
269        display: 'none',
270        left: 'auto',
271      })
272      .slideDown('slow');
273
274    //$("div.main_top div.left div.river div.stories").height(maxHeight - 20).css({
275    //"display": "none",
276    //"left": "auto"
277    //}).slideDown('slow');
278    $('div.main_top div.left div.river div.stories').height(maxHeight - 20);
279  };
280
281  cmg.scrollNav = function() {
282    //console.log('===== TESTING old scroll 1.5 ===============');
283    //var theLocation = $('#navbar').offset().top;
284    //console.log(theLocation);
285    $(window).scroll(function() {
286      var sup_nav = document.getElementById("sup_nav");
287      var header = document.getElementById("main_header");
288      var theLocation = sup_nav.offsetHeight + header.offsetHeight;
289      if (theLocation >= $(window).scrollTop()) {
290        if ($('#navbar').hasClass('fixed')) {
291          $('#navbar').removeClass('fixed');
292          $('body').removeClass('fixed_stuff');
293          $('#flow_news').removeClass('fixed');
294          $('#notifications').removeClass('fixed');
295        }
296      } else {
297        if (!$('#navbar').hasClass('fixed')) {
298          $('#navbar').addClass('fixed');
299          $('body').addClass('fixed_stuff');
300          $('#flow_news').addClass('fixed');
301          $('#notifications').addClass('fixed');
302        }
303      }
304    });
305  };
306  cmg.newScrollNav = function() {
307    // When the user scrolls the page, execute scrollFunction
308    window.onscroll = function() {scrollFunction()};
309
310    function scrollFunction() {
311      var header = document.getElementById("main_header");
312      var sticky = header.offsetBottom;
313      if (window.pageYOffset >= sticky) {
314        if (!$('#navbar').hasClass('fixed')) {
315          $('#navbar').addClass('fixed');
316          $('body').addClass('fixed_stuff');
317          $('#flow_news').addClass('fixed');
318          $('#notifications').addClass('fixed');
319        }
320      } else {
321        if ($('#navbar').hasClass('fixed')) {
322          $('#navbar').removeClass('fixed');
323          $('body').removeClass('fixed_stuff');
324          $('#flow_news').removeClass('fixed');
325          $('#notifications').removeClass('fixed');
326        }
327      }
328    }
329  };
330
331  cmg.flowNews = function() {
332    if (!$('#flow_news').size()) {
333      return;
334    }
335    $('#flow_news_slider').contentcarousel({
336      // speed for the sliding animation
337      sliderSpeed: 500, // easing for the sliding animation
338      sliderEasing: 'easeOutExpo', // speed for the item animation (open / close)
339      itemSpeed: 500, // easing for the item animation (open / close)
340      itemEasing: 'easeOutExpo', // number of items to scroll at a time
341      scroll: 1,
342    });
343
344    //$('#flow_news .wrapper').width($('#flow_news div.story'));
345
346    //var maxHeight = 0;
347
348    //$("div#flow_news div.story").each(function(){
349    //if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
350    //});
351
352    //$("div#flow_news div.story").height(maxHeight);
353    //$("div#flow_news div.wrap").height(maxHeight + 1);
354
355    $('#flow_news')
356      .insertAfter($('#navbar'))
357      .css({
358        display: 'none',
359        left: 'auto',
360      })
361      .slideDown('slow');
362  };
363
364  cmg.photoVideo = function() {
365    if (!$('#photo_video_widget').size()) {
366      return;
367    }
368    $('#photo_video_slider').contentcarousel({
369      // speed for the sliding animation
370      sliderSpeed: 500, // easing for the sliding animation
371      sliderEasing: 'easeOutExpo', // speed for the item animation (open / close)
372      itemSpeed: 500, // easing for the item animation (open / close)
373      itemEasing: 'easeOutExpo', // number of items to scroll at a time
374      scroll: 1,
375    });
376  };
377
378  cmg.homeSlider = function() {
379    if (!$('body#homePage div.slider').size()) {
380      return;
381    }
382
383    var all_slides = $('div.all_slides div.slide');
384    var all_thumbs = $('div.thumbs div.thumb');
385    var slides_num = $(all_slides).size();
386    var detail_slide_area = $('div.detail_slide');
387    var slide_thumb_area = $('div.thumbs div.wrap');
388
389    $(detail_slide_area).html(
390      $(all_slides)
391        .first()
392        .html(),
393    );
394
395    $(all_slides).each(function(i) {
396      var slide_li =
397        '<div class="thumb ca-item"><div class="padding">' +
398        $(this).html() +
399        '</div></div>';
400      $(slide_li).appendTo(slide_thumb_area);
401    });
402
403    var slide_controls = $(
404      '<div class="slide_controls"><span class="prev">p</span><span class="next">n</span></div>',
405    );
406
407    $('div.slider').prepend($(slide_controls));
408
409    $('div.thumbs div.thumb')
410      .first()
411      .addClass('current')
412      .attr({current: 'current'});
413
414    $('div.slider div.thumbs').contentcarousel({
415      // speed for the sliding animation
416      sliderSpeed: 500, // easing for the sliding animation
417      sliderEasing: 'easeOutExpo', // speed for the item animation (open / close)
418      itemSpeed: 500, // easing for the item animation (open / close)
419      itemEasing: 'easeOutExpo', // number of items to scroll at a time
420      scroll: 1,
421    });
422
423    $('div.thumbs div.thumb').each(function(i) {
424      $(this).hover(function() {
425        // in
426        var this_index = $('div.thumbs div.thumb').index($(this));
427        cmg.homeSlider.rotate(this_index);
428      });
429    });
430
431    $('div.slide_controls span.prev').click(function() {
432      var current_slide = $('div.thumbs div.current');
433      var current_slide_index = $('div.thumbs div.thumb').index(current_slide);
434      if (current_slide_index == 0) {
435        cmg.homeSlider.rotate($(all_slides).length - 1);
436      } else {
437        cmg.homeSlider.rotate(current_slide_index - 1);
438        //console.log(current_slide_index - 1);
439      }
440    });
441
442    $('div.slide_controls span.next').click(function() {
443      var current_slide = $('div.thumbs div.current');
444      var current_slide_index = $('div.thumbs div.thumb').index(current_slide);
445      if (current_slide_index == $(all_slides).length - 1) {
446        cmg.homeSlider.rotate(0);
447      } else {
448        cmg.homeSlider.rotate(current_slide_index + 1);
449      }
450    });
451
452    //cmg.homeSlider.timeout = function() {
453    //setTimeout(function () {
454    //var current_slide = $('div.thumbs div.current');
455    //var current_slide_index = $('div.thumbs div.thumb').index(current_slide) + 1;
456    //if (current_slide_index == $(all_slides).length) {
457    //cmg.homeSlider.rotate(1);
458    //} else {
459    //cmg.homeSlider.rotate(current_slide_index + 1);
460    //}
461    //console.log(current_slide_index);
462    //console.log($(all_slides).length);
463    //cmg.homeSlider.timeout();
464    //}, 9000);
465    //}
466
467    //cmg.homeSlider.timeout();
468
469    cmg.homeSlider.rotate = function(num) {
470      var current = $('div.thumbs div.thumb[current]');
471      var to = $('div.thumbs div.thumb').get(num);
472
473      $(current)
474        .removeAttr('current')
475        .removeClass('current');
476      $(to)
477        .attr({current: 'current'})
478        .addClass('current');
479      $(detail_slide_area).html($(to).html());
480    };
481  };
482
483  cmg.heroshots = function() {
484    if (!$('.heroshot').length()) {
485      return;
486    }
487    $('.heroshot').each(function(index) {
488      var heroshot = $(this);
489      var fade = heroshot.find('input[name=fadevalue]');
490      fade = fade.val() * 1000;
491      heroshot.find('input[name=fadevalue]').remove();
492
493      var dur = heroshot.find('input[name=showvalue]');
494      dur = dur.val() * 1000;
495      heroshot.find('input[name=showvalue]').remove();
496
497      var do_rotate = heroshot.find('input[name=rotate]');
498      do_rotate = do_rotate.val();
499      heroshot.find('input[name=rotate]').remove();
500
501      heroshot.attr({
502        fade: fade,
503        dur: dur,
504        do_rotate: do_rotate,
505      });
506
507      heroshot.height(heroshot.find('div.slide img').height());
508
509      if (heroshot.children('div.slide').length() < 2) {
510        // Less than two images, we don't need to xfade or add controls
511        return;
512      }
513
514      function heroFadeIn() {
515        heroshot.children('div.slide:first-child').fadeIn('slow');
516        if (do_rotate == 1) {
517          setInterval(function() {
518            $('div.slide').stop(true, true);
519            cmg.heroshots.rotate('next', heroshot);
520          }, dur + fade);
521        }
522      }
523
524      heroshot.children('div.slide:first-child').attr({current: 'current'});
525      heroshot.children('div.slide:not(:first-child)').hide();
526      setTimeout(heroFadeIn, 100);
527    });
528
529    cmg.heroshots.rotate = function(dir, heroshot) {
530      if (typeof dir == 'undefined') {
531        var dir = 'next';
532      }
533      if (typeof heroshot == 'undefined') {
534        return;
535      }
536
537      var images = heroshot.children('div.slide');
538      var current = heroshot.children('div.slide[current]');
539      if (dir == 'next') {
540        if (current.next('div.slide').length()) {
541          var to = current.next('div.slide');
542        } else {
543          var to = $(images[0]);
544        }
545      } else {
546        if (current.prev('div.slide').length()) {
547          var to = current.prev('div.slide');
548        } else {
549          var to = $(images[images.length() - 1]);
550        }
551      }
552
553      var fade = heroshot.attr('fade');
554      current.removeAttr('current').fadeOut(fade / 2);
555      to.attr({current: 'current'}).fadeIn(fade / 2);
556    };
557  };
558
559  cmg.searchDefault = function() {
560    if (!$('form.searchForm input.searchQuery').size()) {
561      return;
562    }
563
564    var inputs = $('form.searchForm input.searchQuery');
565    inputs.each(function() {
566      var input = $(this);
567      var defaultText = $(input).attr('value');
568      input.val(defaultText);
569      input.focus(function() {
570        if (input.val() == defaultText) {
571          input.val('');
572        }
573      });
574      input.blur(function() {
575        if (input.val() == '') {
576          input.val(defaultText);
577        }
578      });
579    });
580  };
581
582
583
584  cmg.searchToggle = function() {
585    $("#search_bar").click(function(e) {
586      e.stopPropagation();
587      $("#search_bar").addClass( "focus" );
588      $("#search_bar").find(".searchQuery").focus();
589
590      $(document).click(function() {
591        var container = $("#search_bar");
592        if (!container.is(event.target) &&
593          !container.has(event.target).length) {
594          $("#search_bar").removeClass( "focus" );
595        }
596      });
597    });
598  };
599
600  cmg.mobFont = function() {
601    $('body').append(
602      $(
603        '<div class="f_controls" style="display: none;"><a href="#" class="reset">reset</a><a href="#" class="decrease">decrease</a><a href="#" class="increase">increase</a></div>',
604      ),
605    );
606
607    var fontSource = $('#content p');
608    var originalFontSize = $(fontSource).css('font-size');
609    $('.f_controls .reset').click(function(c) {
610      c.preventDefault();
611      $(fontSource).css('font-size', originalFontSize);
612    });
613    // Increase Font Size
614    $('.f_controls .increase').click(function(c) {
615      c.preventDefault();
616      var currentFontSize = $(fontSource).css('font-size');
617      var currentFontSizeNum = parseFloat(currentFontSize, 10);
618      var newFontSize = currentFontSizeNum * 1.2;
619      $(fontSource).css('font-size', newFontSize);
620      return false;
621    });
622    // Decrease Font Size
623    $('.f_controls .decrease').click(function(c) {
624      c.preventDefault();
625      var currentFontSize = $(fontSource).css('font-size');
626      var currentFontSizeNum = parseFloat(currentFontSize, 10);
627      var newFontSize = currentFontSizeNum * 0.8;
628      $(fontSource).css('font-size', newFontSize);
629      return false;
630    });
631  };
632
633  cmg.print_this = function() {
634    $('div.print_this a').click(function(c) {
635      c.preventDefault();
636      window.print();
637    });
638  };
639
640  ////The functions disableselect() and reEnable() are used to return the status of events.
641  //function disableselect(e) {
642  //return false
643  //}
644  //function reEnable() {
645  //return true
646  //}//if IE4
647  //// disable text selection
648  //document.onselectstart=new Function ('return false');
649  ////if NS6
650  //if (window.sidebar) {
651  ////document.onmousedown=disableselect
652  //// the above line creates issues in mozilla so keep it commented.
653  //document.onclick=reEnable
654  //}
655
656  //function clickIE() {
657  //if (document.all) { (message);
658  //return false;
659  //}
660  //}
661
662  //// disable right click
663  ////document.oncontextmenu=new Function('return false');
664
665})();

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.