PageSourceSearch

https://townofcable.com/wp-content/themes/twt2019/js/theme-custom.js?ver=1.1.8

js townofcable.com collected 2026-10-02 21:41:53 UTC 5,211 bytes, 166 lines download raw bytes

1
2jQuery(function($) {
3
4
5  // inital variables
6  var $window = $(window),
7      $html = $('html'),
8      $body = $(document.body);
9
10
11  // if vertical blog posts, make them equal height
12  $('.post-style-default').matchHeight();
13
14
15  $('[data-toggle="tooltip"]').tooltip({html: true});
16
17
18  // homepage events
19  if ($('[data-tw-events]').length && 'twEventsLoad' in window) {
20    var wrap = $('[data-tw-events]');
21
22    twEventsLoad({
23      callback: function(events) {
24        $.each(events, function(i, event) {
25          var day = new Date(event.date).getUTCDate();
26          var mon = new Date(event.date).getMonth();
27          var mon2 = mon;
28          var year = new Date(event.date).getFullYear();
29          var full_date = day+"-"+(mon2+1)+"-"+year;
30          if (day == 1) {
31              var dateSet = new Date(event.date);
32              dateSet.setUTCDate(dateSet.getUTCDate()+1);
33              mon = dateSet.getMonth();
34          }
35          mon = getMonthName(mon);
36          var content = event.detail.title;
37          var event_id = 'twd-event-' + event.detail.id;
38
39          if (event.all_day) {
40            var time = 'All day';
41          } else {
42            var format = moment(event.date).format('mm') == '00' ? 'hA' : 'h:mm A';
43            var time = moment(event.date).format(format);
44          }
45
46          wrap.append('<div class="event-item row"> \
47              <div class="col-xs-3 col-md-2 event-date"> ' + day + '<sup>' + mon + '</sup></div> \
48              <div class="col-xs-9 col-md-10">\
49                <h2>' + content + '</h2>\
50                <p class="entry-meta">' + time + '</p> \
51                <div class="entry-content">' + event.description + '</div> \
52              </div> \
53            </div>');
54        });
55      }
56    });
57  }
58
59
60
61  // theme options
62  $('.js-theme-option').click(function(e) {
63    e.preventDefault();
64
65    switch($(this).data('action')) {
66      case 'font-minus':
67        var currentFontSize = parseInt($html.css('font-size'), 10);
68        $html.css('font-size', currentFontSize - 1);
69      break;
70      case 'font-plus':
71        var currentFontSize = parseInt($html.css('font-size'), 10);
72        $html.css('font-size', currentFontSize + 1);
73      break;
74    }
75
76  });
77
78
79  // menu
80  $('#main-menu').prepend('<li class="menu-item nav-item menu-hide hidden-lg-up"><span title="Hide menu" class="nav-link"><i class="fa fa-arrow-left"></i></span></li>');
81
82  $('.menu-show, .menu-hide').click(function() {
83    $('.exCollapsingNavbar').toggleClass('is-expanded');
84  });
85
86
87  // show/hide menu on mobile
88  var lastY = $body.scrollTop();
89  var windowCalculateScroll = $.throttle(500, function(e) {
90    var currentY = $body.scrollTop();
91
92    if (lastY > currentY || currentY < 100) {
93      $body.removeClass('scroll-down');
94    } else {
95      $body.addClass('scroll-down');
96    }
97
98    lastY = currentY;
99  });
100
101  $(document).on('touchmove touchend', windowCalculateScroll);
102  $(window).on('scroll', windowCalculateScroll);
103
104
105  // show/hide logo in menu
106  if ($('.page-template-homepage').length) {
107    var introHeight = $('.homepage-intro').height(),
108        menuPosition = $body.hasClass('menu-position-top') ? 'top' : 'bottom';
109
110    $window.on('scroll', function() {
111
112      if( $( ".header-main" ).hasClass( "header-static-color" ) == false ){
113        // different calculations depending of menu position
114        if (menuPosition == 'top') {
115          if (introHeight / 2 > $window.scrollTop()) {
116            $body.addClass('hide-logo');
117          } else {
118            $body.removeClass('hide-logo');
119          }
120        } else {
121          if (introHeight > $window.scrollTop()) {
122            $body.addClass('hide-logo');
123          } else {
124            $body.removeClass('hide-logo');
125          }
126        }
127      }
128
129    }).trigger('scroll');
130
131    $body.removeClass('hide-logo-initial');
132  }
133
134
135  // homepage posts navigation
136  var homepagePostsScrollEl = $('.homepage-posts .inner-wrap'),
137      homepagePostWidth = homepagePostsScrollEl.width(),
138      homepagePostsTotalWidth = homepagePostsScrollEl.find('.row').width(),
139      homepagePostsNav = $('.homepage-posts .posts-navigation li');
140
141  homepagePostsScrollEl.on('scroll', function() {
142    var left = homepagePostsScrollEl.scrollLeft();
143
144    var index = Math.round((left * 100 / (homepagePostsTotalWidth - homepagePostWidth)) / 33);
145    if (index > 2) {
146      index = 2;
147    }
148
149    homepagePostsNav.eq(index).addClass('active').siblings().removeClass('active');
150  });
151
152
153});
154
155
156
157
158/*
159 * jQuery throttle / debounce - v1.1 - 3/7/2010
160 * http://benalman.com/projects/jquery-throttle-debounce-plugin/
161 *
162 * Copyright (c) 2010 "Cowboy" Ben Alman
163 * Dual licensed under the MIT and GPL licenses.
164 * http://benalman.com/about/license/
165 */
166(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this);

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.