PageSourceSearch

https://volsker.ru/wp-content/themes/pen/assets/js/pen-scripts.js?ver=1.4.7

js volsker.ru collected 2026-10-08 13:01:21 UTC 7,271 bytes, 245 lines download raw bytes

1/**
2 * Front-end JavaScript.
3 *
4 * @package Pen
5 */
6
7;( function( $ ) {
8
9	'use strict';
10
11	$( 'html' ).removeClass( 'no-js' ).addClass( 'js' );
12
13	var $window = $( window ),
14		$body = $( 'body' ),
15		$page = $( '#page' ),
16		$page_wrapper = $page.children( '.pen_wrapper' );
17
18	if ( $body.hasClass( 'pen_loading_spinner' ) ) {
19		$page_wrapper.addClass( 'pen_hidden' );
20	}
21
22	$( document ).ready( function() {
23
24		if ( $body.hasClass( 'pen_width_narrow' ) || ( pen_function_exists( typeof Modernizr ) && Modernizr.mq( 'only all and (max-width:728px)' ) ) ) {
25			if ( pen_js.font_resize.site_title === 'dynamic' && pen_function_exists( typeof $window.fitText ) ) {
26				$( '#site-title' ).fitText( 1, { minFontSize: 20, maxFontSize: 48 } );
27				$window.on( 'resize orientationchange', function() {
28					$window.trigger( 'resize.fittext' );
29				});
30			}
31			if ( pen_js.font_resize.site_title === 'resize' ) {
32				var $site_title = $( '#pen_header #pen_site_title a .site-title' );
33				$site_title.pen_font_resize( parseInt( $site_title.css( 'font-size' ) ) );
34				$window.on( 'resize orientationchange', function() {
35					if ( pen_function_exists( typeof Modernizr ) && Modernizr.mq( 'only all and (max-width:728px)' ) ) {
36						$site_title.pen_font_resize( parseInt( $site_title.css( 'font-size' ) ) );
37					} else {
38						$site_title.css( { fontSize: '' } );
39					}
40				});
41			}
42		}
43
44		if ( pen_function_exists( typeof autosize ) ) {
45			autosize( $page.find( 'textarea' ) );
46		}
47
48		$page.find( '.search-form' ).on( 'submit', function( event ) {
49			if ( pen_text_trim( $( this ).find( '.search-field' ).val() ) === '' ) {
50				alert( pen_js.text.enter_keyword );
51				event.preventDefault();
52			}
53		});
54
55		$( '#pen_back' ).hide().on( 'click', function ( event ) {
56			$( 'html, body' ).animate( { scrollTop: 0 }, { queue: false, duration: 1000 } );
57			event.preventDefault();
58		});
59
60		$( '#content' ).find( 'iframe' ).each( function() {
61			$( this ).on( 'load', function() {
62				pen_content_height();
63			} );
64		} );
65
66	});
67
68	$window.on( 'load', function() {
69		var $main = $( '#main' );
70
71		if ( $body.hasClass( 'pen_loading_spinner' ) ) {
72			$page.children( '.pen_loading' ).fadeOut(
73				100,
74				function() {
75					$page_wrapper.removeClass( 'pen_hidden' )
76					.css( { display: 'none', visibility: 'visible' } ).fadeIn( 100 );
77				}
78			);
79		}
80
81		if ( pen_js.animation_comments ) {
82			var $comments = $( '#comments .comment-list' );
83			if ( $comments.length ) {
84				$comments.children( 'li' )
85				.addClass( 'pen_animate_on_scroll pen_custom_animation_' + pen_js.animation_comments );
86				if ( pen_js.animation_delay_comments ) {
87					$comments.children( 'li' ).attr( 'delay', pen_js.animation_delay_comments );
88				}
89			}
90		}
91
92		pen_animation( $page.find( '.pen_animate_on_scroll' ), 'automatic' );
93
94		pen_footer_position();
95
96		pen_content_height();
97
98	})
99	.on( 'resize orientationchange', function() {
100
101		pen_footer_position();
102
103		pen_content_height();
104
105	})
106	.on( 'scroll', function() {
107			if ( $( this ).scrollTop() > 400 ) {
108				$( '#pen_back' ).fadeIn( 200 );
109			} else {
110				$( '#pen_back' ).fadeOut( 200 );
111			}
112		}
113	);
114
115	$.fn.extend(
116		{
117			pen_font_resize: function( font_size ) {
118				var $element = this,
119					parent_width = $element.parent().outerWidth( false ),
120					element_width = $element.css( { position: 'fixed', whiteSspace: 'nowrap' } ).outerWidth( true );
121					$element.css( { position: 'relative' } );
122					font_size = font_size - 2;
123				if ( font_size > 12 && element_width > parent_width ) {
124					$element.animate( { fontSize: font_size } )
125					.end().pen_font_resize( font_size );
126				}
127			}
128		}
129	);
130
131})( jQuery );
132
133function pen_animation( $items, animation ) {
134	var animation_offset = '90%';
135
136	$items = $items.filter( '.pen_animate_on_scroll' );
137
138	if ( pen_function_exists( typeof jQuery( window ).waypoint ) && animation ) {
139		$items.not( '.animate__animated' ).addClass( 'animate__animated' ).css( 'visibility', 'hidden' );
140
141		for ( var i = 0; i < $items.length; i++ ) {
142			var $item = $items.eq(i);
143			if ( $item.closest( '#pen_footer, #pen_bottom' ).length ) {
144				animation_offset = '99%';
145			}
146			$item.waypoint(
147				{
148					handler: function( direction ) {
149						var timer,
150							$item = jQuery( this.element ),
151							add_animation = '';
152
153						var animation_delay = 0,
154							custom_animation_delay = this.element.className.match( /(^|\s)pen_custom_animation_delay_\S+/g );
155						if ( custom_animation_delay && custom_animation_delay[0] ) {
156							animation_delay = ( 1000 * parseInt( pen_text_trim( custom_animation_delay[0].replace( 'pen_custom_animation_delay_', '' ) ) ) );
157						}
158
159						var custom_animation = this.element.className.match( /(^|\s)pen_custom_animation_\S+/g );
160						if ( custom_animation && custom_animation[0] ) {
161							add_animation = pen_text_trim( custom_animation[0].replace( 'pen_custom_animation_', 'animate__' ) );
162						} else {
163							add_animation = 'animate__' + animation;
164						}
165
166						timer = setTimeout( function() {
167							if ( ! $item.hasClass( add_animation ) ) {
168								$item.addClass( add_animation ).css( 'visibility', 'visible' );
169							}
170						}, animation_delay ? animation_delay : 1 );
171
172					},
173					offset: animation_offset
174				}
175			);
176		}
177	}
178}
179
180function pen_footer_position() {
181	var $body = jQuery( 'body' ),
182		$content = jQuery( '#content' ),
183		$bottom = jQuery( '#pen_bottom' ),
184		$footer = jQuery( '#pen_footer' ),
185		width_content = '100%',
186		offset_left = 0,
187		height_bottom = $bottom.length ? $bottom.outerHeight( true ) : 0,
188		height_footer = pen_js.site_footer_display ? $footer.outerHeight( true ) : 0;
189
190	if ( $body.hasClass( 'pen_width_narrow' ) || $body.hasClass( 'pen_width_boxed' ) ) {
191		width_content = $content.outerWidth( true );
192		offset_left = $content.offset().left;
193	}
194
195	$content.css( { paddingBottom: '' } );
196	var content_padding_bottom = parseInt( $content.css( 'padding-bottom' ) ) + ( he
196ight_bottom + height_footer );
197	$content.css( { paddingBottom: content_padding_bottom } );
198
199	if ( $bottom.length ) {
200		$bottom.css( {
201			bottom: pen_js.site_footer_display ? height_footer : 0,
202			position: 'absolute',
203			width: width_content
204		} );
205	}
206	$footer.css( { bottom: 0, left: offset_left, position: 'absolute', width: width_content } );
207}
208
209function pen_content_height() {
210	var left_height = 0,
211		right_height = 0,
212		$content = jQuery( '#content' ),
213		$left = jQuery( '#pen_left' ),
214		$right = jQuery( '#pen_right' );
215	if ( pen_function_exists( typeof Modernizr ) && Modernizr.mq( 'only all and (max-width:728px)' ) ) {
216		$content.css( { minHeight: '' } );
217		return;
218	}
219	if ( $left.length ) {
220		left_height = $left.outerHeight( true );
221	}
222	if ( $right.length ) {
223		right_height = $right.outerHeight( true );
224	}
225	var content_height = Math.max( left_height, right_height );
226	if ( content_height ) {
227		content_height = content_height + parseInt( $content.css( 'padding-bottom' ) ) + 30;
228		$content.css( 'min-height', content_height );
229	}
230}
231
232function pen_function_exists( type_of ) {
233	if ( type_of !== 'undefined' && type_of !== undefined && type_of !== null ) {
234		return true;
235	}
236	return false;
237}
238
239function pen_text_trim( input ) {
240	if ( ! input ) {
241		return input;
242	}
243	var output = input.replace( /\s/g, ' ' ).replace( /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '' );
244	return output;
245}

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.