Файловый менеджер - Редактировать - /home/avadvi5/public_html/wp-content/plugins/code4rest-pro/dist/elements/src/code4rest-pro-sticky.js
Ðазад
/* global code4restProMegaConfig */ /** * File code4rest-mega-menu.js. * Gets mega menu working. */ (function() { 'use strict'; window.code4restProSticky = { /** * Get element's offset. */ getOffset: function( el ) { if ( el instanceof HTMLElement ) { var rect = el.getBoundingClientRect(); return { top: rect.top + window.pageYOffset, left: rect.left + window.pageXOffset } } return { top: null, left: null }; }, /** * Find the sticky items. */ stickHeadItem: function( element ) { var offsetTop = parseInt( window.code4restProSticky.getOffset( document.getElementById( 'wrapper' ) ).top ), activeOffsetTop = parseInt( window.code4restProSticky.getOffset( element ).top ); var updateSticky = function( e ) { var parent = element.parentNode; parent.style.height = element.offsetHeight + 'px'; if ( Math.max(0, window.scrollY ) === Math.floor( activeOffsetTop - offsetTop ) ) { element.style.top = offsetTop + 'px'; element.classList.add('item-is-fixed'); element.classList.add('item-at-start'); element.classList.remove('item-is-stuck'); parent.classList.add('child-is-fixed'); } else if ( Math.max(0, window.scrollY ) > Math.floor( activeOffsetTop - offsetTop ) ) { element.style.top = offsetTop + 'px'; element.classList.add('item-is-fixed'); element.classList.add('item-is-stuck'); element.classList.remove('item-at-start'); parent.classList.add('child-is-fixed'); } else { if ( element.classList.contains( 'item-is-fixed' ) ) { element.classList.remove( 'item-is-fixed' ); element.classList.remove('item-at-start'); element.classList.remove('item-is-stuck'); element.style.height = null; element.style.top = null; parent.classList.remove('child-is-fixed'); } } } window.addEventListener( 'resize', updateSticky, false ); window.addEventListener( 'scroll', updateSticky, false ); window.addEventListener( 'load', updateSticky, false ); window.addEventListener( 'code4rest-update-sticky', updateSticky, false ); updateSticky(); }, /** * Find the sticky items. */ stickTransHeadItem: function( element ) { var offsetTop = window.code4restProSticky.getOffset( document.body ).top, activeOffsetTop = window.code4restProSticky.getOffset( element ).top; var updateSticky = function( e ) { var parent = element.parentNode; parent.style.height = element.offsetHeight + 'px'; if ( Math.max(0, window.scrollY ) === Math.floor( activeOffsetTop - offsetTop ) ) { element.style.top = offsetTop + 'px'; element.classList.add('item-is-fixed'); element.classList.add('item-at-start'); element.classList.remove('item-is-stuck'); parent.classList.add('child-is-fixed'); } else if ( Math.max(0, window.scrollY ) > Math.floor( activeOffsetTop - offsetTop ) ) { element.style.top = offsetTop + 'px'; element.classList.add('item-is-fixed'); element.classList.add('item-is-stuck'); element.classList.remove('item-at-start'); parent.classList.add('child-is-fixed'); } else { if ( element.classList.contains( 'item-is-fixed' ) ) { element.classList.remove( 'item-is-fixed' ); element.classList.remove('item-at-start'); element.classList.remove('item-is-stuck'); element.style.height = null; element.style.top = null; parent.classList.remove('child-is-fixed'); } } } window.addEventListener( 'resize', updateSticky, false ); window.addEventListener( 'scroll', updateSticky, false ); window.addEventListener( 'load', updateSticky, false ); window.addEventListener( 'code4rest-update-sticky', updateSticky, false ); updateSticky(); }, /** * Find the sticky items. */ stickScrollItem: function( element ) { var updateSticky = function( e ) { var offsetTop = window.code4restProSticky.getOffset( document.getElementById( 'wrapper' ) ).top, scrollOffset = element.getAttribute('data-scroll-offset'); if ( window.scrollY >= scrollOffset ) { element.style.top = offsetTop + 'px'; element.classList.add('item-is-fixed'); element.classList.add('item-is-stuck'); element.classList.remove('item-at-start'); } else { if ( element.classList.contains( 'item-is-fixed' ) ) { element.classList.remove( 'item-is-fixed' ); element.classList.remove('item-at-start'); element.classList.remove('item-is-stuck'); element.style.height = null; element.style.top = null; } } } window.addEventListener( 'resize', updateSticky, false ); window.addEventListener( 'scroll', updateSticky, false ); window.addEventListener( 'load', updateSticky, false ); updateSticky(); }, /** * Find the sticky items. */ stickScrollFooterItem: function( element ) { var updateScrollSticky = function( e ) { var scrollOffset = parseInt( element.getAttribute('data-scroll-offset') ); if ( window.scrollY >= scrollOffset ) { element.classList.add('item-is-fixed'); element.classList.add('item-is-stuck'); element.classList.remove('item-at-start'); } else { if ( element.classList.contains( 'item-is-fixed' ) ) { element.classList.remove('item-is-fixed'); element.classList.remove('item-at-start'); element.classList.remove('item-is-stuck'); } } } window.addEventListener( 'resize', updateScrollSticky, false ); window.addEventListener( 'scroll', updateScrollSticky, { passive: true } ); window.addEventListener( 'load', updateScrollSticky, false ); updateScrollSticky(); }, /** * Find the sticky items. */ stickScrollFooterItemSpace: function( element ) { var updateScrollSticky = function( e ) { var parent = element.parentNode; parent.style.height = element.offsetHeight + 'px'; var scrollOffset = parseInt( element.getAttribute('data-scroll-offset') ); if ( window.scrollY >= scrollOffset ) { element.classList.add('item-is-fixed'); element.classList.add('item-is-stuck'); element.classList.remove('item-at-start'); } else { if ( element.classList.contains( 'item-is-fixed' ) ) { element.classList.remove('item-is-fixed'); element.classList.remove('item-at-start'); element.classList.remove('item-is-stuck'); } } } window.addEventListener( 'resize', updateScrollSticky, false ); window.addEventListener( 'scroll', updateScrollSticky, false ); window.addEventListener( 'load', updateScrollSticky, false ); updateScrollSticky(); }, /** * Find the sticky items. */ stickFootItem: function( element ) { var updateSticky = function( e ) { element.classList.add('item-is-fixed'); element.classList.add('item-is-stuck'); element.classList.remove('item-at-start'); } window.addEventListener( 'resize', updateSticky, false ); updateSticky(); }, /** * Find the sticky items. */ stickFootItemBelow: function( element ) { var updateSticky = function( e ) { var parent = element.parentNode; parent.style.height = element.offsetHeight + 'px'; element.classList.add('item-is-fixed'); element.classList.add('item-is-stuck'); element.classList.remove('item-at-start'); } window.addEventListener( 'resize', updateSticky, false ); updateSticky(); }, /** * Find the sticky items. */ initStickyHeadItems: function() { var stickyHeadItems = document.querySelectorAll( '.code4rest-pro-fixed-above' ); // No point if no drawers. if ( ! stickyHeadItems.length ) { return; } for ( let i = 0; i < stickyHeadItems.length; i++ ) { window.code4restProSticky.stickHeadItem( stickyHeadItems[ i ] ); } }, /** * Find the sticky items. */ initStickyHeadTransItems: function() { var stickyHeadTransItems = document.querySelectorAll( '.code4rest-pro-fixed-above-trans' ); // No point if no drawers. if ( ! stickyHeadTransItems.length ) { return; } for ( let i = 0; i < stickyHeadTransItems.length; i++ ) { window.code4restProSticky.stickTransHeadItem( stickyHeadTransItems[ i ] ); } }, /** * Find the sticky items. */ initStickyScrollItems: function() { var stickyScrollItems = document.querySelectorAll( '.code4rest-pro-fixed-on-scroll' ); // No point if no drawers. if ( ! stickyScrollItems.length ) { return; } for ( let i = 0; i < stickyScrollItems.length; i++ ) { window.code4restProSticky.stickScrollItem( stickyScrollItems[ i ] ); } }, /** * Find the sticky items. */ initStickyScrollFooterItems: function() { var stickyScrollItemsFooter = document.querySelectorAll( '.code4rest-pro-fixed-on-scroll-footer' ); // No point if no drawers. if ( ! stickyScrollItemsFooter.length ) { return; } for ( let i = 0; i < stickyScrollItemsFooter.length; i++ ) { window.code4restProSticky.stickScrollFooterItem( stickyScrollItemsFooter[ i ] ); } }, /** * Find the sticky items. */ initStickyScrollFooterItemsSpace: function() { var stickyScrollItemsFooter = document.querySelectorAll( '.code4rest-pro-fixed-on-scroll-footer-space' ); // No point if no drawers. if ( ! stickyScrollItemsFooter.length ) { return; } for ( let i = 0; i < stickyScrollItemsFooter.length; i++ ) { window.code4restProSticky.stickScrollFooterItemSpace( stickyScrollItemsFooter[ i ] ); } }, /** * Find the sticky items. */ initStickyFootItems: function() { var stickyFootItems = document.querySelectorAll( '.code4rest-pro-fixed-below' ); // No point if no sticky if ( ! stickyFootItems.length ) { return; } for ( let i = 0; i < stickyFootItems.length; i++ ) { window.code4restProSticky.stickFootItemBelow( stickyFootItems[ i ] ); } }, /** * Find the sticky items. */ initStickyFootOnItems: function() { var stickyFootOnItems = document.querySelectorAll( '.code4rest-pro-fixed-bottom' ); // No point if no sticky if ( ! stickyFootOnItems.length ) { return; } for ( let i = 0; i < stickyFootOnItems.length; i++ ) { window.code4restProSticky.stickFootItem( stickyFootOnItems[ i ] ); } }, // Initiate sticky when the DOM loads. init: function() { window.code4restProSticky.initStickyHeadItems(); window.code4restProSticky.initStickyHeadTransItems(); window.code4restProSticky.initStickyScrollItems(); window.code4restProSticky.initStickyScrollFooterItems(); window.code4restProSticky.initStickyFootItems(); window.code4restProSticky.initStickyFootOnItems(); window.code4restProSticky.initStickyScrollFooterItemsSpace(); } } if ( 'loading' === document.readyState ) { // The DOM has not yet been loaded. document.addEventListener( 'DOMContentLoaded', window.code4restProSticky.init ); } else { // The DOM has already been loaded. window.code4restProSticky.init(); } })();
| ver. 1.1 | |
.
| PHP 8.3.30 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка