PageSourceSearch

https://www.premiercottages.co.uk/blog/public/Grimag/assets/js/jquery.st.js

js premiercottages.co.uk collected 2026-10-04 02:17:17 UTC 13,403 bytes, 609 lines download raw bytes

1/*
2
3	01. - Dinamic styles holder
4	02. - Drop-Down menu
5	03. - Quick reply form
6	04. - Textarea
7	05. - Sticked div
8	06. - Tag cloud
9	07. - Archives & Categories
10	08. - Original size of images
11	09. - Max size for YouTube & Vimeo video
12	10. - ST Gallery
13	11. - Sticked menu
14	12. - Search form on header
15	13. - BuddyPress fixes
16
17*/
18
19/* jshint -W099 */
20/* global jQuery:false */
21
22var p = jQuery.noConflict();
23
24p(function(){
25
26	'use strict';
27
28
29
30/*==01.==========================================
31
32 	D I N A M I C   S T Y L E S
33	Holder for dinamic styles
34
35===============================================*/
36
37	if ( !p('#st-dynamic-css').length ) {
38
39		p('head').append('<style id="st-dynamic-css" type="text/css"></style>');
40
41	}
42
43
44
45/*==02.==========================================
46
47	D R O P - D O W N   M E N U
48	Main menu on responsive mode
49
50===============================================*/
51
52/*
53
54	1 - DROP-DOWN MENU
55
56		1.1 - Default
57		1.2 - Custom
58
59*/
60
61	/*-------------------------------------------
62		1.1 - Default
63	-------------------------------------------*/
64
65	p('#menu #page_id').change(function() {
66
67		var
68			val = p(this).val();
69
70			if ( val ) {
71				p(this).parent().submit(); }
72
73	});
74
75
76	/*-------------------------------------------
77		1.2 - Custom
78	-------------------------------------------*/
79
80	p('#selectElement').change(function() {
81
82		if ( p(this).val() ) {
83			window.open( p(this).val(), '_parent' ); }
84
85	});
86
87
88
89/*==03.==========================================
90
91	Q U I C K   R E P L Y   F O R M
92	Append and remove quick form
93
94===============================================*/
95
96/*
97
98	1 - QUICK REPLY FORM
99
100		1.1 - Open form
101		1.2 - Cancel reply
102
103*/
104
105	/*-------------------------------------------
106		1.1 - Open form
107	-------------------------------------------*/
108
109	p('a.quick-reply').click(function(){
110
111
112		/*--- First of all -----------------------------*/
113
114		// Make previous Reply link visible
115		p('.quick-reply').removeClass('none');
116
117		// Make previous Cancel Reply link hidden
118		p('.quick-reply-cancel').addClass('none');
119
120		// Erase all quick holders
121		p('.quick-holder').html('');
122
123		// Make comment form visible
124		p('#commentform').removeClass('none');
125
126
127		/*--- Append new form -----------------------------*/
128
129		var
130			id = p(this).attr('title'),
131			form = p('#respond').html();
132
133			// Make this Reply link hidden
134			p(this).addClass('none');
135
136			// Make this Cancel Reply link visible
137			p(this).next().removeClass('none');
138
139			// Hide major form
140			p('#commentform, #reply-title').addClass('none');
141
142			// Put the form to the holder
143			p('#quick-holder-' + id).append(form).find('h3').remove();
144
145			// Set an ID for hidden field
146			p('#quick-holder-' + id + ' input[name="comment_parent"]').val(id);
147
148			// Fix placeholders for IE8,9
149			if ( p('#ie-version').hasClass('ie-version-8') || p('#ie-version').hasClass('ie-version-9') ) {
150				
151				p('.input-text-box input[type="text"], .input-text-box input[type="email"], .input-text-box input[type="url"]', '#quick-holder-' + id).each( function(){ p(this).val( p(this).attr('placeholder') ); } );
152
153			}
154
155
156		return false;
157
158	});
159
160
161	/*-------------------------------------------
162		1.2 - Cancel reply
163	-------------------------------------------*/
164
165	p('.quick-reply-cancel').click(function(){
166
167		// Make previous Reply link visible
168		p('.quick-reply').removeClass('none');
169
170		// Make this Cancel Reply link hidden
171		p(this).addClass('none');
172
173		// Erase all quick holders
174		p('.quick-holder').html('');
175
176		// Make comment form visible
177		p('#commentform, #reply-title').removeClass('none');
178
179		return false;
180
181	});
182
183
184
185/*==04.==========================================
186
187 	T E X T A R E A
188	Animation by focus
189
190===============================================*/
191
192	p('#layout').on('focus', 'textarea', function() {
193
194		if ( !p(this).is('#whats-new') && p(this).height() < 151 && ! p(this).hasClass( 'height-ready' ) ) {
195
196			p(this)
197				.css({ height: 70 })
198				.animate({ height: 150 }, 300, function(){ p(this).addClass( 'height-ready' ); });
199
200		}
201
202	});
203
204
205
206/*==05.==========================================
207
208 	S T I C K E D   D I V
209	Sticked container
210
211===============================================*/
212
213	st_sticky_div();
214
215	function st_sticky_div() {
216
217		if ( p('#stickyDiv').length ) {
218	
219			var
220				el = p('#stickyDiv'),
221				stickyTop = p('#stickyDiv').offset().top,
222				margin = p('#wpadminbar').length ? p('#wpadminbar').height() : 0;
223
224				p(window).scroll(function(){
225
226					var
227						stickyHeight = p('#stickyDiv').outerHeight(true),
228						limit = p('#footer').offset().top - stickyHeight,
229						windowTop = p(window).scrollTop();
230
231
232						/*--- by top -----------------------------*/
233	
234						if ( stickyTop < windowTop + 90 + margin ) {
235
236							el.css({ position: 'fixed', top: 90 + margin });
237
238						}
239	
240						else {
241
242							el.css( 'position', 'static' );
243	
244						}
245
246	
247						/*--- by footer -----------------------------*/
248	
249						if ( limit < windowTop + 90 ) {
250							
251							var
252								diff = limit - windowTop;
253
254								el.css({ position: 'fixed', top: diff });
255	
256						}
257
258				});
259	
260		}
261
262	}
263
264
265
266/*==06.==========================================
267
268 	T A G   C L O U D
269	Add number of posts for each tag
270
271===============================================*/
272
273	p('.tagcloud a').each(function(){
274
275		var
276			number = p(this).attr('title').split(' ');
277
278			number = '<span>' + number[0] + '</span>';
279
280			p(this).append(number).attr('title','');
281
282	});
283
284
285
286/*==07.==========================================
287
288 	A R C H I V E S & C A T E G O R I E S
289	Replace count wrapper on widgets,
290	e.g. from (7) to <span>7</span>
291
292===============================================*/
293
294	p('.widget_archive li, .widget_categories li').each(function(){
295
296		var
297			str = p(this).html();
298
299			str = str.replace(/\(/g,"<span>");
300			str = str.replace(/\)/g,"</span>");
301			
302			p(this).html(str);
303
304	});
305
306
307
308/*==08.==========================================
309
310 	O R I G I N A L   S I Z E
311	For images and others
312
313===============================================*/
314
315	p('.size-original').removeAttr('width').removeAttr('height');
316
317
318
319/*==09.==========================================
320
321 	V I D E O   R E S I Z E
322	Max size for YouTube & Vimeo video
323
324===============================================*/
325
326	function st_video_resize() {
327
328		p('iframe').each(function(){
329
330			var
331				src = p(this).attr('src');
332
333				if ( src ) {
334
335					var
336						check_youtube = src.split('youtube.com'),
337						check_vimeo = src.split('vimeo.com');
338						
339						if ( check_youtube[1] || check_vimeo[1] ) {
340		
341							var
342								width = p(this).parent().width(),
343								height = width * 0.61;
344		
345								if ( width > 1 ) {
346									p(this).css({ 'width': width, 'height': height }); }
347		
348						}
349
350				}
351
352		});
353
354	}
355
356	st_video_resize();
357
358	p(window).resize( st_video_resize );
359
360
361
362/*==10.==========================================
363
364 	S T   G A L L E R Y
365	ST Gallery script
366
367===============================================*/
368
369	stG_init();
370	
371	function stG_init() {
372
373		p('.st-gallery').each(function(){
374
375			p('img',this).addClass('st-gallery-pending').last().addClass('st-gallery-last');
376
377			var
378				slides = p(this).html(),
379				check = slides.split('img'),
380				controls = '<ol>';
381
382				for ( var i = 1; i < check.length; i++ ) {
383					if ( i === 1 ) {
384						controls += '<li class="st-gallery-tab-current"></li>'; }
385					else {
386						controls += '<li></li>'; }
387				}
388
389				controls += '</ol>';
390
391				p(this).html( '<div>' + slides + '</div>' + controls );
392
393				p('div img:first-child',this).removeClass('st-gallery-pending').addClass('st-gallery-current');
394
395		});
396
397	}
398
399	p('.st-gallery div img').on( 'click touchstart', function(){
400
401		if ( ! p(this).parent().hasClass('st-gallery-locked') ) {
402
403			var
404				img = p(this),
405				gallery = p(this).parent(),
406				current = gallery.find('.st-gallery-current'),
407				hCurrent = gallery.height(),
408				imgIndex = img.prevAll().length,
409				tabs = img.parent().next( 'ol' );
410
411				gallery.addClass('st-gallery-locked');
412
413				var
414					nextImage = ( current.hasClass('st-gallery-last') ? gallery.find('img').first() : gallery.children().eq( imgIndex + 1 ) );
415
416					current
417						.removeClass('st-gallery-current').addClass('st-gallery-flushed').stop(true,fal
417se)
418						.animate({ 'opacity': 0 }, 300,
419							function(){
420								p(this).removeAttr('style').removeClass('st-gallery-flushed').addClass('st-gallery-pending');
421								gallery.removeClass('st-gallery-locked');
422							});
423
424					nextImage.removeClass('st-gallery-pending').addClass('st-gallery-current');
425
426					var
427						hNext = nextImage.height();
428
429						if ( hNext !== 0 ) {
430							gallery.css( 'height', hCurrent ).stop(true,false).animate({ 'height': hNext }, 700 ); }
431						else {
432							gallery.css( 'height', 'auto' ); }
433
434					var
435						currentTab = nextImage.prevAll().length;
436	
437						tabs.children( '.st-gallery-tab-current' ).removeClass( 'st-gallery-tab-current' );
438						tabs.children().eq( currentTab ).addClass( 'st-gallery-tab-current' );
439
440		}
441
442	});
443
444	p('.st-gallery ol li').click(function(){
445
446		p(this).each(function(){
447
448			var
449				no = p(this).prevAll().length,
450				gallery = p(this).parent().parent().find('div'),
451				current = gallery.find('.st-gallery-current'),
452				h = gallery.children().eq( no ).height();
453
454				p(this).parent().find('.st-gallery-tab-current').removeClass('st-gallery-tab-current');
455				p(this).addClass('st-gallery-tab-current');
456
457				current.removeClass('st-gallery-current').addClass('st-gallery-pending');
458
459				gallery.css( 'height', h );
460
461				gallery.children().eq( no )
462					.removeClass('st-gallery-pending')
463					.addClass('st-gallery-flushed')
464					.css({ opacity: 0 })
465					.animate({ opacity: 1 }, 300, 
466						function(){
467							p(this).removeClass('st-gallery-flushed').addClass('st-gallery-current').removeAttr('style');
468							gallery.removeAttr('style');
469						});
470
471		});
472
473	});
474
475
476
477/*==11.==========================================
478
479 	S T I C K E D   M E N U
480	Sticked primary menu
481
482===============================================*/
483
484	function st_sticky_menu() {
485
486		if ( p('#menu').length && !p('#menu').hasClass('no-sticky-menu') ) {
487	
488			var
489				el = p('#menu'),
490				stickyTop = p('#menu').offset().top,
491				stickyHeight = p('#menu').outerHeight(true),
492				margin = p('#wpadminbar').length ? p('#wpadminbar').height() : 0;
493	
494				p(window).scroll(function(){
495
496					if ( p('#content-holder').width() > 934 ) {
497
498						var
499							windowTop = p(window).scrollTop();
500		
501		
502							if ( stickyTop < windowTop - 1000 ) {
503	
504								if ( !el.hasClass('menu-sticky') ) {
505									el.addClass('menu-sticky').addClass('menu-sticky-now').css({ opacity: 1, top: -stickyHeight }).stop(true,false).animate({ top: 0 + margin }, 300);
506									p('#header-holder').css({ paddingBottom: stickyHeight });
507									st_search_on_top();
508								}
509		
510							}
511		
512							else {
513	
514								if ( el.hasClass('menu-sticky-now') ) {
515
516									el.removeClass('menu-sticky-now').stop(true,false).animate({ top: -stickyHeight }, 300,
517										function(){
518											el.css({ 'display': 'table', top: 'auto', opacity: 0 }).removeClass('menu-sticky').stop(true,false).animate({ opacity: 1 }, 300, function(){ p('#menu').removeAttr('style'); });
519											p('#header-holder').css({ paddingBottom: 0 });
520											st_search_on_top();
521										});
522
523								}
524	
525							}
526
527					}
528
529					else {
530
531						if ( el.hasClass('menu-sticky') ) {
532
533							el.css({ opacity: 1, top: 'auto' }).removeClass('menu-sticky');
534							p('#header-holder').css({ paddingBottom: 0 });
535
536						}
537
538					}
539
540				});
541
542		}
543
544	}
545
546	function st_the_sticky_menu() {
547		st_sticky_menu();
548	}
549
550	st_the_sticky_menu();
551
552	p(window).resize( st_the_sticky_menu );
553
554
555/*==12.==========================================
556
557	S E A R C H
558	Search form on header
559
560===============================================*/
561
562	/*-------------------------------------------
563		2.1 - Search
564	-------------------------------------------*/
565
566	setInterval(st_search_on_top, 500);
567
568	function st_search_on_top() {
569
570		var
571			barH = p('#menu .menu').height() + 1;
572
573			p('#search-form-header span, #search-form-header input').css({ 'height': barH });
574			p('#search-form-header').show();
575
576	}
577
578	p('#search-form-header span').click(function(){
579
580		var
581			width = 320;
582
583			if ( p('#content-holder').width() == 1200 ) {
584				width = 313; }
585			if ( p('#content-holder').width() < 936 ) {
586				width = 240; }
587
588			if ( !p(this).hasClass('inProgress') ) {
589				p(this).addClass('inProgress').parent().stop(true,false).animate({ 'width': width }, 300);
590			}
591	
592			else {
593				p(this).removeClass('inProgress').parent().stop(true,false).animate({ 'width': 54 }, 300);
594			}
595
596	});
597
598
599/*==13.==========================================
600
601	B U D D Y P R E S S
602	BuddyPress fixes
603
604===============================================*/
605
606	p('body.group-create h1.page-title a').addClass('button').addClass('bp-title-button');
607
608
609});

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.