Files
Testing/newlayout/js/menu.js
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

286 lines
5.7 KiB
JavaScript

/*
* SS MENU
* Copyright 2015 MadeInPluto
* www.madeinpluto.com
*
* Version 1.0 - Last Updated: Apr 17, 2015
*
* Licenced to BateWorld for exclusive use on www.bateworld.com
*
*/
( function( $ ) {
/***
* Run this code when the #toggle-menu link has been tapped
* or clicked
*/
/* var isTouch = !!('ontouchstart' in window ),
TorC = isTouch ? 'touchstart' : 'click'; */
var isTouch = ('ontouchstart' in window ) || window.DocumentTouch && document instanceof DocumentTouch;
TorC = isTouch ? 'touchstart' : 'click';
/* var isTouch1 = !!('ontouchstart' in window ),
TorC1 = isTouch1 ? 'touchstart' : 'click'; */
$( '#toggle-menuA' ).on( TorC, function (e1) {
e1.preventDefault();
$( "#toggle-menu" ).trigger(TorC);
});
$( '#toggle-menu' ).on( TorC, function(e) {
e.preventDefault();
var $body = $( 'body' ),
$page = $( '.page' ),
$menu = $( '#menu' ),
/* Cross browser support for CSS "transition end" event */
transitionEnd = 'transitionend webkitTransitionEnd otransitionend MSTransitionEnd';
/* When the toggle menu link is clicked, animation starts */
$body.addClass( 'animating' );
/***
* Determine the direction of the animation and
* add the correct direction class depending
* on whether the menu was already visible.
*/
if ( $body.hasClass( 'menu-visible' ) ) {
$body.addClass( 'right' );
$('.pippro').css('display', 'block');
} else {
$body.addClass( 'left' );
$('.pippro').css('display', 'none');
}
/***
* When the animation (technically a CSS transition)
* has finished, remove all animating classes and
* either add or remove the "menu-visible" class
* depending whether it was visible or not previously.
*/
$page.on( transitionEnd, function() {
$body
.removeClass( 'animating left right' )
.toggleClass( 'menu-visible' );
var zndxneg = '-2';
var zndxpos = '200';
if( $('.overlay-content').css('z-index') == zndxneg )
{
$('.overlay-content').css('z-index', zndxpos);
$('.overlay-content').css('position', 'fixed');
$('.overlay-content').css('height', ($("#menu").height()));
} else {
$('.overlay-content').removeAttr("style");
}
$page.off( transitionEnd );
$(document).scrollTop(0);
var eTop = 0 /* $("#menu").offset().top; */
/* $(document).scrollTop(eTop); */
var eHeight = $("#menu").height();
var eBottom = eTop + eHeight - $(window).height()+100;
$(document).on("scroll", function(e){
if( $('#menu').is(':visible') )
{
var windowScrollTop = $(window).scrollTop();
if(windowScrollTop < eTop){
console.log("not allowed");
$(document).scrollTop(eTop);
}
else if(windowScrollTop > eBottom){
$(document).scrollTop(eBottom);
}
else{
console.log("allowed");
}
}
});
} );
} );
} )( jQuery );
( function( $ ) {
/***
* Run this code when the #toggle-menu link has been tapped
* or clicked
*/
var isTouch = !!('ontouchstart' in window ),
TorC = isTouch ? 'touchstart' : 'click';
$( "#toggle-menu-1A" ).on(TorC, function (e1) {
e1.preventDefault();
$( "#toggle-menu-1" ).trigger(TorC);
});
$( '#toggle-menu-1' ).on( TorC, function(e) {
e.preventDefault();
var $body = $( 'body' ),
$page = $( '.page' ),
$menu = $( '#accordion-mb' ),
/* Cross browser support for CSS "transition end" event */
transitionEnd = 'transitionend webkitTransitionEnd otransitionend MSTransitionEnd';
/* When the toggle menu link is clicked, animation starts */
$body.addClass( 'animating' );
/***
* Determine the direction of the animation and
* add the correct direction class depending
* on whether the menu was already visible.
*/
if ( $body.hasClass( 'menu-visible-mb' ) ) {
$body.addClass( 'right-srch' );
$('.pippro').css('display', 'block');
} else {
$body.addClass( 'left-srch' );
$('.pippro').css('display', 'none');
}
/***
* When the animation (technically a CSS transition)
* has finished, remove all animating classes and
* either add or remove the "menu-visible" class
* depending whether it was visible or not previously.
*/
$page.on( transitionEnd, function() {
$body
.removeClass( 'animating left-srch right-srch' )
.toggleClass( 'menu-visible-mb' );
var zndxneg = '-2';
var zndxpos = '200';
if( $('.overlay-content').css('z-index') == zndxneg )
{
$('.overlay-content').css('z-index', zndxpos);
$('.overlay-content').css('position', 'fixed');
$('.overlay-content').css('height', ($("#accordion-mb").height()));
} else {
$('.overlay-content').removeAttr("style");
}
$page.off( transitionEnd );
$(document).scrollTop(0);
var eTop = 0 /* $("#accordion-mb").offset().top; */
/* $(document).scrollTop(eTop); */
var eHeight = $("#accordion-mb").height();
var eBottom = eTop + eHeight - $(window).height();
$(document).on("scroll", function(e){
if( $('#accordion-mb').is(':visible') )
{
var windowScrollTop = $(window).scrollTop();
if(windowScrollTop < eTop){
console.log("not allowed");
$(document).scrollTop(eTop);
}
else if(windowScrollTop > eBottom){
$(document).scrollTop(eBottom);
}
else{
console.log("allowed");
}
}
});
} );
} );
} )( jQuery );
( function( $ ) {
var isTouch = !!('ontouchstart' in window ),
TorC = isTouch ? 'touchstart' : 'click';
$('.overlay-content').on( TorC, function(e){
e.preventDefault();
var $body = $( 'body' );
if ( $body.hasClass( 'menu-visible' ) ) {
$('#toggle-menu').trigger(TorC);
} else {
$('#toggle-menu-1').trigger(TorC);
}
});
} )( jQuery );