PageSourceSearch

https://www.matheagerty.com/files/theme/mobile.js?1531150540

js matheagerty.com collected 2026-09-24 11:39:10 UTC 10,411 bytes, 426 lines download raw bytes

1//// mobile.js submenu nav - all below
2Weebly = Weebly || {};
3
4Weebly.mobile_navigation = (function($) {
5
6  var isOpen = false,
7      isMoving = false,
8      supportsTouch = false,
9      pendingResizeData = null,
10      isiOS = (navigator.userAgent.match(/(iPad|iPhone|iPod)/i) ? true : false),
11      supports3D = ('WebKitCSSMatrix' in window && 'm11' in new WebKitCSSMatrix()),
12      supportsTouch = false,
13      menuOffsetY = 0,
14      $menuWrapper, $menu, $body, supports3D;
15
16
17  /**
18   * Add a css transition
19   *
20   * @param jquery $o object to animate
21   * @param string property a css transitionable property
22   * @param number speed the ms speed of animation
23   * @param function cb callback function after animation completes
24   * @return undefined
25   */
26
27  var addTransition = function($o, property, speed, cb) {
28      if (!speed) {
29        speed = 500;
30      }
31
32      $o.css({
33        webkitTransitionDuration: speed + 'ms',
34        webkitTransitionProperty: property,
35        webkitTransitionTimingFunction: 'linear'
36      });
37
38      var onTransistionEnd = function(e) {
39          $o.off('webkitTransitionEnd', onTransistionEnd);
40
41          $o.css({
42            webkitTransitionDuration: '',
43            webkitTransitionProperty: '',
44            webkitTransitionTimingFunction: ''
45          });
46
47          cb();
48          }
49
50
51
52      $o.on('webkitTransitionEnd', onTransistionEnd);
53      };
54
55  /**
56   * Utility animate function for css transitions
57   *
58   * @param jquery $o object to animate
59   * @param object from css properties to animate from
60   * @param object to css properties to animate to
61   * @param number speed the ms speed of animation
62   * @param function cb callback function after animation completes
63   * @return undefined
64   */
65  var animate = function($o, from, to, speed, cb) {
66      if (!speed) {
67        speed = 500;
68      }
69      if (supports3D) {
70
71        $o.css({
72          webkitTransitionDuration: '0ms'
73        });
74        $o.css(from);
75
76        setTimeout(function() {
77          addTransition($o, 'all', speed, cb);
78
79          var props = {};
80          for (property in to) {
81            if (!to.hasOwnProperty(property)) {
82              continue;
83            }
84            props[property] = to[property];
85          }
86          $o.css(props);
87        }, 0);
88      } else {
89        //jquery.animate isn't working too well here, disable for now
90        to.avoidCSSTransitions = true;
91        $o.animate(to, {
92          duration: speed,
93          complete: cb
94        });
95      }
96      };
97
98  /**
99   * Controls the menu effect when a menu button is tapped
100   *
101   * @param event e event handler
102   * @return undefined
103   */
104  var menuTap = function(e) {
105      var menuHeight = '100%',
106          effectStart, effectEnd, fromCSS, toCSS;
107
108      if (isMoving) {
109        return;
110      }
111
112      isOpen = !isOpen;
113
114      isMoving = true;
115
116      if (isOpen) {
117        $body.addClass('menu-open');
118      }
119
120      var cb = function() {
121          isMoving = false;
122
123          if (!isOpen) {
124            $body.removeClass('menu-open');
125          }
126      };
127  };
128
129  /**
130   * Tweens the menu left or right
131   *
132   * @param jquery $oldSlide the current slide being moved out
133   * @param jquery $newSlide the new slide being moved in
134   * @param bool rightToLeft move to the right if true, left if false
135   * @return undefined
136   */
137  var tweenMenu = function($oldSlide, $newSlide, rightToLeft) {
138      var $animContainer = $('.wsite-animation-wrap', $menu),
139          sign = (rightToLeft) ? 1 : -1;
140
141      if (isMoving) {
142        return;
143      }
144
145      isMoving = true;
146
147      var menuWidth = $menu.width();
148
149      var toX = -sign * menuWidth + 'px';
150
151      var fromCSS = {
152        '-webkit-transform': 'translate3d( 0, 0px, 0)'
153      };
154
155      var toCSS = {
156        '-webkit-transform': 'translate3d(' + toX + ', 0px, 0)'
157      };
158
159      if (supports3D) {
160        $newSlide.css({
161          '-webkit-transform': 'translate3d(' + (sign * menuWidth) + 'px, 0px, 0)'
162        });
163      } else {
164        $newSlide.css({
165          'left': (sign * menuWidth) + 'px'
166        });
167
168        fromCSS = {
169          left: 0
170        };
171        toCSS = {
172          left: toX
173        };
174      }
175
176      $newSlide.show();
177
178      var cb = function() {
179          $oldSlide.hide();
180          $animContainer.css(fromCSS);
181          $newSlide.css(fromCSS);
182
183          isMoving = false;
184          };
185
186      animate($animContainer, fromCSS, toCSS, 300, cb);
187      };
188
189  /**
190   * Adds a an active state css class so that button presses
191   * can be styled
192   *
193   * @param jquery $element element(s) to add state to
194   * @param string tagName selector to filter dom elemenets
195   * @return undefined
196   */
197  var addActiveState = function($element, tagName) {
198      $element.on('touchstart', tagName, function(ev) {
199        $(this).addClass('active');
200      });
201      $element.on('touchend', tagName, function(ev) {
202        $(this).removeClass('active');
203      });
204      };
205
206
207  /**
208   * Measures the size of the content area to try and place footer
209   * fixed at the bottom of the screen if the screen space is larger
210   *
211   * @return undefined
212   */
213  var resizeContentWindow = function() {};
214
215
216  /**
217   * Resizes the vertical height of the mobile menu
218   *
219   * @return undefined
220   */
221  var resizeMenu = function() {
222      if (!$menu) {
223        return;
224      }
225      var menuHeight = $menu.find('.wsite-menu-slide:visible').outerHeight();
226      if (menuHeight > 0) {
227        $menu.css({
228          height: '100%',
229          'overflow-y': 'auto',
230          '-webkit-overflow-scrolling': 'touch'
231        });
232      }
233
234      };
235
236  /**
237   * Inits the body to detect touch support
238   *
239   * @return undefined
240   */
241  var initBody = function() {
242      $body = $('body');
243
244      if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
245        $body.removeClass('no-touch');
246        $body.addClass('touch');
247        supportsTouch = true;
248      }
249      };
250
251
252      /**
253       * Inits the mobile menu structure
254       *
255       * @return undefined
256       */
257
258  var initMenu = function() {
259		var $sideMenus = $('#navmobile .wsite-menu-wrap'),
260			  $headerUl, $sliderContainer;
261
262		  $headerUl = $('#navmobile .wsite-menu-default');
263
264      $headerUl.wrap('<div class="wsite-mobile-menu" />');
265      $menu = $headerUl.up('.wsite-mobile-menu');
266      $menuWrapper = $headerUl.up('#wrapper');
267      $menuWrapper = ($menuWrapper.length > 0) ? $menuWrapper : $menu;
268
269      isOpen = false;
270      isMoving = false;
271
272      var slideCSS = {
273        position: 'absolute',
274        top: '0',
275        left: '0',
276        width: '100%',
277        height: '100%'
278      };
279
280      // something to select on
281      $headerUl.addClass('wsite-menu-slide').css(slideCSS);
282      $sideMenus.addClass('wsite-menu-slide').css(slideCSS);
283
284      // new css settings can cause jarring while animations render,
285      // set the settings here even though they don't really 'do anything'
286      $headerUl.css({
287        'left': '0'
288      });
289      if (supports3D) {
290        $headerUl.css({
291          '-webkit-transform': 'translate3d( 0, 0px, 0)'
292        });
293      }
294
295      $menu.append('<div class="wsite-animation-wrap"></div>');
296      $sliderContainer = $('.wsite-animation-wrap', $menu);
297      $sliderContainer.css({
298        position: 'relative',
299        height: '100%'
300      });
301      if (supports3D) {
302        $sliderContainer.css({
303          '-webkit-backface-visibility': 'hidden'
304        });
305      }
306      $sliderContainer.append($headerUl);
307
308      $sideMenus.each(function() {
309        var $sideMenu = $(this),
310            $parentAnchor = $sideMenu.prev(),
311            $ul = $sideMenu.children('ul'),
312            $previousMenu = $sideMenu.parents('.wsite-menu-slide');
313
314        var $backLink = $('<li class="wsite-menu-back-item">' + '<a><span class="wsite-menu-mobile-arrow"></span><span class="wsite-menu-back">Back</span></a>' + '</li>');
315        $backLink.unbind("click");
316        $backLink.on('click', function(ev) {
317          tweenMenu($sideMenu, $previousMenu, false);
318          return false;
319        });
320
321
322        if ($parentAnchor.attr("href")) {
323          var $sideMenuRoot = $parentAnchor.clone(true, true);
324          var $rootLink = $('<li class="wsite-menu-master-item"></li>').html($sideMenuRoot);
325        }
326
327        $ul.prepend($rootLink);
328        $ul.prepend($backLink);
329
330        $parentAnchor.unbind( "click" );
331        $parentAnchor.append('<span class="wsite-menu-mobile-arrow"></span>');
332        $parentAnchor.on('click', function(ev) {
333          tweenMenu($previousMenu, $sideMenu, true);
334          return false;
335        });
336
337        $sideMenu.css({
338          'left': '0'
339        });
340        if (supports3D) {
341          $sideMenu.css({
342            '-webkit-transform': 'translate3d( 0, 0px, 0)'
343          });
344        }
345
346        $sliderContainer.append($sideMenu);
347      });
348
349      $menu.css({
350        'display': 'block'
351      });
352      $menuWrapper.css({
353        'display': 'block'
354      });
355      resizeMenu();
356
357      // prefer active state classes over html active
358      if (supportsTouch) {
359        addActiveState($('.wsite-home-link'));
360        addActiveState($menu, 'a');
361      }
362      };
363
364  /**
365   * Close the menu
366   *
367   * @return undefined
368   */
369  var closeMenu = function() {
370      if (isOpen) {
371        menuTap(null);
372      }
373      };
374
375  var isMenuOpen = function() {
376      return isOpen;
377      };
378
379  var init = function() {
380      $body = $('#icontent');
381      $body = ($body.length > 0) ? $body : $('body');
382
383      // May be able to dump this flag in the future,
384      // but fixing 3d transition flickering issues was in theme css
385      if (!$body.hasClass('wsite-render3d')) {
386        supports3D = false;
387      }
388
389      initMenu();
390      };
391
392  if (!Weebly.mobile) {
393    // reset iframe content sizes
394    $(window).on("message", function(event) {
395      if (!event.origin || event.origin.indexOf('weebly.com') === -1) {
396        return;
397      }
398
399      pendingResizeData = event.data;
400    });
401  }
402
403  // dom ready
404  $(function() {
405
406    setTimeout(function(){
407      initBody();
408      init();
409    }, 1000);
410
411    if (window.FastClick) {
412      FastClick.attach($('.wsite-mobile-menu')[0]);
413    }
414
415  });
416
417  return {
418    init: init,
419    closeMenu: closeMenu,
420    resizeScreen: resizeContentWindow,
421    resizeMenu: resizeMenu,
422    menuTap: menuTap,
423    isMenuOpen: isMenuOpen
424  };
425
426}(Weebly.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.