File manager - Edit - /home/premiey/www/wp-includes/images/media/sticky.tar
Back
module.php 0000666 00000012362 15165400136 0006553 0 ustar 00 <?php namespace ElementorPro\Modules\Sticky; use Elementor\Controls_Manager; use Elementor\Element_Base; use Elementor\Element_Section; use Elementor\Widget_Base; use ElementorPro\Base\Module_Base; use ElementorPro\Plugin; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } class Module extends Module_Base { public function __construct() { parent::__construct(); $this->add_actions(); } public function get_name() { return 'sticky'; } /** * Check if `$element` is an instance of a class in the `$types` array. * * @param $element * @param $types * * @return bool */ private function is_instance_of( $element, array $types ) { foreach ( $types as $type ) { if ( $element instanceof $type ) { return true; } } return false; } public function register_controls( Element_Base $element ) { $element->add_control( 'sticky', [ 'label' => esc_html__( 'Sticky', 'elementor-pro' ), 'type' => Controls_Manager::SELECT, 'options' => [ '' => esc_html__( 'None', 'elementor-pro' ), 'top' => esc_html__( 'Top', 'elementor-pro' ), 'bottom' => esc_html__( 'Bottom', 'elementor-pro' ), ], 'separator' => 'before', 'render_type' => 'none', 'frontend_available' => true, 'assets' => $this->get_asset_conditions_data(), ] ); // TODO: In Pro 3.5.0, get the active devices using Breakpoints/Manager::get_active_devices_list(). $active_breakpoint_instances = Plugin::elementor()->breakpoints->get_active_breakpoints(); // Devices need to be ordered from largest to smallest. $active_devices = array_reverse( array_keys( $active_breakpoint_instances ) ); // Add desktop in the correct position. if ( in_array( 'widescreen', $active_devices, true ) ) { $active_devices = array_merge( array_slice( $active_devices, 0, 1 ), [ 'desktop' ], array_slice( $active_devices, 1 ) ); } else { $active_devices = array_merge( [ 'desktop' ], $active_devices ); } $sticky_device_options = []; foreach ( $active_devices as $device ) { $label = 'desktop' === $device ? esc_html__( 'Desktop', 'elementor-pro' ) : $active_breakpoint_instances[ $device ]->get_label(); $sticky_device_options[ $device ] = $label; } $element->add_control( 'sticky_on', [ 'label' => esc_html__( 'Sticky On', 'elementor-pro' ), 'type' => Controls_Manager::SELECT2, 'multiple' => true, 'label_block' => true, 'default' => $active_devices, 'options' => $sticky_device_options, 'condition' => [ 'sticky!' => '', ], 'render_type' => 'none', 'frontend_available' => true, ] ); $element->add_responsive_control( 'sticky_offset', [ 'label' => esc_html__( 'Offset', 'elementor-pro' ), 'type' => Controls_Manager::NUMBER, 'default' => 0, 'min' => 0, 'max' => 500, 'required' => true, 'condition' => [ 'sticky!' => '', ], 'render_type' => 'none', 'frontend_available' => true, ] ); $element->add_responsive_control( 'sticky_effects_offset', [ 'label' => esc_html__( 'Effects Offset', 'elementor-pro' ), 'type' => Controls_Manager::NUMBER, 'default' => 0, 'min' => 0, 'max' => 1000, 'required' => true, 'condition' => [ 'sticky!' => '', ], 'render_type' => 'none', 'frontend_available' => true, ] ); // Add `Stay In Column` only to the following types: $types = [ Element_Section::class, Widget_Base::class, ]; // TODO: Remove when Container is the default. if ( Plugin::elementor()->experiments->is_feature_active( 'container' ) ) { $types[] = \Elementor\Includes\Elements\Container::class; } if ( $this->is_instance_of( $element, $types ) ) { $conditions = [ 'sticky!' => '', ]; // Target only inner sections. // Checking for `$element->get_data( 'isInner' )` in both editor & frontend causes it to work properly on the frontend but // break on the editor, because the inner section is created in JS and not rendered in PHP. // So this is a hack to force the editor to show the `sticky_parent` control, and still make it work properly on the frontend. if ( $element instanceof Element_Section && Plugin::elementor()->editor->is_edit_mode() ) { $conditions['isInner'] = true; } $element->add_control( 'sticky_parent', [ 'label' => esc_html__( 'Stay In Column', 'elementor-pro' ), 'type' => Controls_Manager::SWITCHER, 'condition' => $conditions, 'render_type' => 'none', 'frontend_available' => true, ] ); } $element->add_control( 'sticky_divider', [ 'type' => Controls_Manager::DIVIDER, ] ); } private function get_asset_conditions_data() { return [ 'scripts' => [ [ 'name' => 'e-sticky', 'conditions' => [ 'terms' => [ [ 'name' => 'sticky', 'operator' => '!==', 'value' => '', ], ], ], ], ], ]; } private function add_actions() { add_action( 'elementor/element/section/section_effects/after_section_start', [ $this, 'register_controls' ] ); add_action( 'elementor/element/container/section_effects/after_section_start', [ $this, 'register_controls' ] ); add_action( 'elementor/element/common/section_effects/after_section_start', [ $this, 'register_controls' ] ); } } jquery.sticky.js 0000666 00000023043 15165400371 0007736 0 ustar 00 /* * By Elementor Team */ ( function( $ ) { var Sticky = function( element, userSettings ) { var $element, isSticky = false, isFollowingParent = false, isReachedEffectsPoint = false, elements = {}, settings, elementOffsetValue, elementWidth; var defaultSettings = { to: 'top', offset: 0, effectsOffset: 0, parent: false, classes: { sticky: 'sticky', stickyActive: 'sticky-active', stickyEffects: 'sticky-effects', spacer: 'sticky-spacer', }, isRTL: false, handleScrollbarWidth: false, }; var initElements = function() { $element = $( element ).addClass( settings.classes.sticky ); elements.$window = $( window ); if ( settings.parent ) { elements.$parent = $element.parent(); if ( 'parent' !== settings.parent ) { elements.$parent = elements.$parent.closest( settings.parent ); } } }; var initSettings = function() { settings = jQuery.extend( true, defaultSettings, userSettings ); }; var bindEvents = function() { elements.$window.on( { scroll: onWindowScroll, resize: onWindowResize, } ); }; var unbindEvents = function() { elements.$window .off( 'scroll', onWindowScroll ) .off( 'resize', onWindowResize ); }; var init = function() { initSettings(); initElements(); bindEvents(); checkPosition(); }; var backupCSS = function( $elementBackupCSS, backupState, properties ) { var css = {}, elementStyle = $elementBackupCSS[ 0 ].style; properties.forEach( function( property ) { css[ property ] = undefined !== elementStyle[ property ] ? elementStyle[ property ] : ''; } ); $elementBackupCSS.data( 'css-backup-' + backupState, css ); }; var getCSSBackup = function( $elementCSSBackup, backupState ) { return $elementCSSBackup.data( 'css-backup-' + backupState ); }; const updateElementSizesData = () => { elementWidth = getElementOuterSize( $element, 'width' ); elementOffsetValue = $element.offset().left; if ( settings.isRTL ) { // `window.innerWidth` includes the scrollbar while `document.body.offsetWidth` doesn't. const documentWidth = settings.handleScrollbarWidth ? window.innerWidth : document.body.offsetWidth; elementOffsetValue = Math.max( documentWidth - elementWidth - elementOffsetValue, 0 ); } } var addSpacer = function() { elements.$spacer = $element.clone() .addClass( settings.classes.spacer ) .css( { visibility: 'hidden', transition: 'none', animation: 'none', } ); $element.after( elements.$spacer ); }; var removeSpacer = function() { elements.$spacer.remove(); }; var stickElement = function() { backupCSS( $element, 'unsticky', [ 'position', 'width', 'margin-top', 'margin-bottom', 'top', 'bottom', 'inset-inline-start' ] ); const css = { position: 'fixed', width: elementWidth, marginTop: 0, marginBottom: 0, }; css[ settings.to ] = settings.offset; css[ 'top' === settings.to ? 'bottom' : 'top' ] = ''; if ( elementOffsetValue ) { css[ 'inset-inline-start' ] = elementOffsetValue + 'px'; } $element .css( css ) .addClass( settings.classes.stickyActive ); }; var unstickElement = function() { $element .css( getCSSBackup( $element, 'unsticky' ) ) .removeClass( settings.classes.stickyActive ); }; var followParent = function() { backupCSS( elements.$parent, 'childNotFollowing', [ 'position' ] ); elements.$parent.css( 'position', 'relative' ); backupCSS( $element, 'notFollowing', [ 'position', 'inset-inline-start', 'top', 'bottom' ] ); const css = { position: 'absolute', }; elementOffsetValue = elements.$spacer.position().left; if ( settings.isRTL ) { const parentWidth = $element.parent().outerWidth(), elementOffsetValueLeft = elements.$spacer.position().left; elementWidth = elements.$spacer.outerWidth(); elementOffsetValue = Math.max( parentWidth - elementWidth - elementOffsetValueLeft, 0 ); } css[ 'inset-inline-start' ] = elementOffsetValue + 'px'; css[ settings.to ] = ''; css[ 'top' === settings.to ? 'bottom' : 'top' ] = 0; $element.css( css ); isFollowingParent = true; }; var unfollowParent = function() { elements.$parent.css( getCSSBackup( elements.$parent, 'childNotFollowing' ) ); $element.css( getCSSBackup( $element, 'notFollowing' ) ); isFollowingParent = false; }; var getElementOuterSize = function( $elementOuterSize, dimension, includeMargins ) { var computedStyle = getComputedStyle( $elementOuterSize[ 0 ] ), elementSize = parseFloat( computedStyle[ dimension ] ), sides = 'height' === dimension ? [ 'top', 'bottom' ] : [ 'left', 'right' ], propertiesToAdd = []; if ( 'border-box' !== computedStyle.boxSizing ) { propertiesToAdd.push( 'border', 'padding' ); } if ( includeMargins ) { propertiesToAdd.push( 'margin' ); } propertiesToAdd.forEach( function( property ) { sides.forEach( function( side ) { elementSize += parseFloat( computedStyle[ property + '-' + side ] ); } ); } ); return elementSize; }; var getElementViewportOffset = function( $elementViewportOffset ) { var windowScrollTop = elements.$window.scrollTop(), elementHeight = getElementOuterSize( $elementViewportOffset, 'height' ), viewportHeight = innerHeight, elementOffsetFromTop = $elementViewportOffset.offset().top, distanceFromTop = elementOffsetFromTop - windowScrollTop, topFromBottom = distanceFromTop - viewportHeight; return { top: { fromTop: distanceFromTop, fromBottom: topFromBottom, }, bottom: { fromTop: distanceFromTop + elementHeight, fromBottom: topFromBottom + elementHeight, }, }; }; var stick = function() { updateElementSizesData(); addSpacer(); stickElement(); isSticky = true; $element.trigger( 'sticky:stick' ); }; var unstick = function() { unstickElement(); removeSpacer(); isSticky = false; $element.trigger( 'sticky:unstick' ); }; var checkParent = function() { var elementOffset = getElementViewportOffset( $element ), isTop = 'top' === settings.to; if ( isFollowingParent ) { var isNeedUnfollowing = isTop ? elementOffset.top.fromTop > settings.offset : elementOffset.bottom.fromBottom < -settings.offset; if ( isNeedUnfollowing ) { unfollowParent(); } } else { var parentOffset = getElementViewportOffset( elements.$parent ), parentStyle = getComputedStyle( elements.$parent[ 0 ] ), borderWidthToDecrease = parseFloat( parentStyle[ isTop ? 'borderBottomWidth' : 'borderTopWidth' ] ), parentViewportDistance = isTop ? parentOffset.bottom.fromTop - borderWidthToDecrease : parentOffset.top.fromBottom + borderWidthToDecrease, isNeedFollowing = isTop ? parentViewportDistance <= elementOffset.bottom.fromTop : parentViewportDistance >= elementOffset.top.fromBottom; if ( isNeedFollowing ) { followParent(); } } }; var checkEffectsPoint = function( distanceFromTriggerPoint ) { if ( isReachedEffectsPoint && -distanceFromTriggerPoint < settings.effectsOffset ) { $element.removeClass( settings.classes.stickyEffects ); isReachedEffectsPoint = false; } else if ( ! isReachedEffectsPoint && -distanceFromTriggerPoint >= settings.effectsOffset ) { $element.addClass( settings.classes.stickyEffects ); isReachedEffectsPoint = true; } }; var checkPosition = function() { var offset = settings.offset, distanceFromTriggerPoint; if ( isSticky ) { var spacerViewportOffset = getElementViewportOffset( elements.$spacer ); distanceFromTriggerPoint = 'top' === settings.to ? spacerViewportOffset.top.fromTop - offset : -spacerViewportOffset.bottom.fromBottom - offset; if ( settings.parent ) { checkParent(); } if ( distanceFromTriggerPoint > 0 ) { unstick(); } } else { var elementViewportOffset = getElementViewportOffset( $element ); distanceFromTriggerPoint = 'top' === settings.to ? elementViewportOffset.top.fromTop - offset : -elementViewportOffset.bottom.fromBottom - offset; if ( distanceFromTriggerPoint <= 0 ) { stick(); if ( settings.parent ) { checkParent(); } } } checkEffectsPoint( distanceFromTriggerPoint ); }; var onWindowScroll = function() { checkPosition(); }; var onWindowResize = function() { if ( ! isSticky ) { return; } unstickElement(); removeSpacer(); updateElementSizesData(); addSpacer(); stickElement(); if ( settings.parent ) { // Force recalculation of the relation between the element and its parent. isFollowingParent = false; checkParent(); } }; this.destroy = function() { if ( isSticky ) { unstick(); } unbindEvents(); $element.removeClass( settings.classes.sticky ); }; init(); }; $.fn.sticky = function( settings ) { var isCommand = 'string' === typeof settings; this.each( function() { var $this = $( this ); if ( ! isCommand ) { $this.data( 'sticky', new Sticky( this, settings ) ); return; } var instance = $this.data( 'sticky' ); if ( ! instance ) { throw Error( 'Trying to perform the `' + settings + '` method prior to initialization' ); } if ( ! instance[ settings ] ) { throw ReferenceError( 'Method `' + settings + '` not found in sticky instance' ); } instance[ settings ].apply( instance, Array.prototype.slice.call( arguments, 1 ) ); if ( 'destroy' === settings ) { $this.removeData( 'sticky' ); } } ); return this; }; window.Sticky = Sticky; } )( jQuery ); jquery.sticky.min.js 0000666 00000007211 15165400371 0010517 0 ustar 00 !function(t){var o=function(o,s){var i,e,n,r,a=!1,c=!1,f=!1,p={},l={to:"top",offset:0,effectsOffset:0,parent:!1,classes:{sticky:"sticky",stickyActive:"sticky-active",stickyEffects:"sticky-effects",spacer:"sticky-spacer"},isRTL:!1,handleScrollbarWidth:!1},d=function(t,o,s){var i={},e=t[0].style;s.forEach((function(t){i[t]=void 0!==e[t]?e[t]:""})),t.data("css-backup-"+o,i)},m=function(t,o){return t.data("css-backup-"+o)};const u=()=>{if(r=b(i,"width"),n=i.offset().left,e.isRTL){const t=e.handleScrollbarWidth?window.innerWidth:document.body.offsetWidth;n=Math.max(t-r-n,0)}};var h=function(){p.$spacer=i.clone().addClass(e.classes.spacer).css({visibility:"hidden",transition:"none",animation:"none"}),i.after(p.$spacer)},y=function(){p.$spacer.remove()},k=function(){d(i,"unsticky",["position","width","margin-top","margin-bottom","top","bottom","inset-inline-start"]);const t={position:"fixed",width:r,marginTop:0,marginBottom:0};t[e.to]=e.offset,t["top"===e.to?"bottom":"top"]="",n&&(t["inset-inline-start"]=n+"px"),i.css(t).addClass(e.classes.stickyActive)},v=function(){i.css(m(i,"unsticky")).removeClass(e.classes.stickyActive)},b=function(t,o,s){var i=getComputedStyle(t[0]),e=parseFloat(i[o]),n="height"===o?["top","bottom"]:["left","right"],r=[];return"border-box"!==i.boxSizing&&r.push("border","padding"),s&&r.push("margin"),r.forEach((function(t){n.forEach((function(o){e+=parseFloat(i[t+"-"+o])}))})),e},w=function(t){var o=p.$window.scrollTop(),s=b(t,"height"),i=innerHeight,e=t.offset().top-o,n=e-i;return{top:{fromTop:e,fromBottom:n},bottom:{fromTop:e+s,fromBottom:n+s}}},g=function(){v(),y(),a=!1,i.trigger("sticky:unstick")},$=function(){var t=w(i),o="top"===e.to;if(c){(o?t.top.fromTop>e.offset:t.bottom.fromBottom<-e.offset)&&(p.$parent.css(m(p.$parent,"childNotFollowing")),i.css(m(i,"notFollowing")),c=!1)}else{var s=w(p.$parent),a=getComputedStyle(p.$parent[0]),f=parseFloat(a[o?"borderBottomWidth":"borderTopWidth"]),l=o?s.bottom.fromTop-f:s.top.fromBottom+f;(o?l<=t.bottom.fromTop:l>=t.top.fromBottom)&&function(){d(p.$parent,"childNotFollowing",["position"]),p.$parent.css("position","relative"),d(i,"notFollowing",["position","inset-inline-start","top","bottom"]);const t={position:"absolute"};if(n=p.$spacer.position().left,e.isRTL){const t=i.parent().outerWidth(),o=p.$spacer.position().left;r=p.$spacer.outerWidth(),n=Math.max(t-r-o,0)}t["inset-inline-start"]=n+"px",t[e.to]="",t["top"===e.to?"bottom":"top"]=0,i.css(t),c=!0}()}},T=function(){var t,o=e.offset;if(a){var s=w(p.$spacer);t="top"===e.to?s.top.fromTop-o:-s.bottom.fromBottom-o,e.parent&&$(),t>0&&g()}else{var n=w(i);(t="top"===e.to?n.top.fromTop-o:-n.bottom.fromBottom-o)<=0&&(u(),h(),k(),a=!0,i.trigger("sticky:stick"),e.parent&&$())}!function(t){f&&-t<e.effectsOffset?(i.removeClass(e.classes.stickyEffects),f=!1):!f&&-t>=e.effectsOffset&&(i.addClass(e.classes.stickyEffects),f=!0)}(t)},B=function(){T()},C=function(){a&&(v(),y(),u(),h(),k(),e.parent&&(c=!1,$()))};this.destroy=function(){a&&g(),p.$window.off("scroll",B).off("resize",C),i.removeClass(e.classes.sticky)},e=jQuery.extend(!0,l,s),i=t(o).addClass(e.classes.sticky),p.$window=t(window),e.parent&&(p.$parent=i.parent(),"parent"!==e.parent&&(p.$parent=p.$parent.closest(e.parent))),p.$window.on({scroll:B,resize:C}),T()};t.fn.sticky=function(s){var i="string"==typeof s;return this.each((function(){var e=t(this);if(i){var n=e.data("sticky");if(!n)throw Error("Trying to perform the `"+s+"` method prior to initialization");if(!n[s])throw ReferenceError("Method `"+s+"` not found in sticky instance");n[s].apply(n,Array.prototype.slice.call(arguments,1)),"destroy"===s&&e.removeData("sticky")}else e.data("sticky",new o(this,s))})),this},window.Sticky=o}(jQuery);
| ver. 1.4 |
Github
|
.
| PHP 5.4.45 | Generation time: 0 |
proxy
|
phpinfo
|
Settings