PageSourceSearch

https://www.helakuru.lk/assets/js/jquery/jquery-position.js

js helakuru.lk collected 2026-09-29 22:36:54 UTC 16,643 bytes, 573 lines download raw bytes

vendor: 5,358 bytes, lines 1-194
1/*! jQuery UI - v1.12.1 - 2016-09-16
2 * http://jqueryui.com
3 * Includes: position.js
4 * Copyright jQuery Foundation and other contributors; Licensed MIT */
5
6(function ( factory ) {
7	if ( typeof define === "function" && define.amd )
8	{
9		// AMD. Register as an anonymous module.
10		define([ "jquery" ], factory );
11	}
12	else
13	{
14		// Browser globals
15		factory( jQuery );
16	}
17}(function ( $ ) {
18	$.ui = $.ui || {};
19
20	var version = $.ui.version = "1.12.1";
21
22	/*!
23	 * jQuery UI Position 1.12.1
24	 * http://jqueryui.com
25	 *
26	 * Copyright jQuery Foundation and other contributors
27	 * Released under the MIT license.
28	 * http://jquery.org/license
29	 *
30	 * http://api.jqueryui.com/position/
31	 */
32
33	//>>label: Position
34	//>>group: Core
35	//>>description: Positions elements relative to other elements.
36	//>>docs: http://api.jqueryui.com/position/
37	//>>demos: http://jqueryui.com/position/
38
39	( function () {
40		var cachedScrollbarWidth,
41			max         = Math.max,
42			abs         = Math.abs,
43			rhorizontal = /left|center|right/,
44			rvertical   = /top|center|bottom/,
45			roffset     = /[\+\-]\d+(\.[\d]+)?%?/,
46			rposition   = /^\w+/,
47			rpercent    = /%$/,
48			_position   = $.fn.position;
49
50		function getOffsets( offsets, width, height )
51		{
52			return [
53				parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
54				parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
55			];
56		}
57
58		function parseCss( element, property )
59		{
60			return parseInt( $.css( element, property ), 10 ) || 0;
61		}
62
63		function getDimensions( elem )
64		{
65			var raw = elem[ 0 ];
66			if ( raw.nodeType === 9 )
67			{
68				return {
69					width: elem.width(),
70					height: elem.height(),
71					offset: { top: 0, left: 0 }
72				};
73			}
74			if ( $.isWindow( raw ) )
75			{
76				return {
77					width: elem.width(),
78					height: elem.height(),
79					offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
80				};
81			}
82			if ( raw.preventDefault )
83			{
84				return {
85					width: 0,
86					height: 0,
87					offset: { top: raw.pageY, left: raw.pageX }
88				};
89			}
90			return {
91				width: elem.outerWidth(),
92				height: elem.outerHeight(),
93				offset: elem.offset()
94			};
95		}
96
97		$.position = {
98			scrollbarWidth: function () {
99				if ( cachedScrollbarWidth !== undefined )
100				{
101					return cachedScrollbarWidth;
102				}
103				var w1, w2,
104					div      = $( "<div " +
105						"style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'>" +
106						"<div style='height:100px;width:auto;'></div></div>" ),
107					innerDiv = div.children()[ 0 ];
108
109				$( "body" ).append( div );
110				w1 = innerDiv.offsetWidth;
111				div.css( "overflow", "scroll" );
112
113				w2 = innerDiv.offsetWidth;
114
115				if ( w1 === w2 )
116				{
117					w2 = div[ 0 ].clientWidth;
118				}
119
120				div.remove();
121
122				return ( cachedScrollbarWidth = w1 - w2 );
123			},
124			getScrollInfo: function ( within ) {
125				var overflowX    = within.isWindow || within.isDocument ? "" :
126						within.element.css( "overflow-x" ),
127					overflowY    = within.isWindow || within.isDocument ? "" :
128						within.element.css( "overflow-y" ),
129					hasOverflowX = overflowX === "scroll" ||
130						( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ),
131					hasOverflowY = overflowY === "scroll" ||
132						( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight );
133				return {
134					width: hasOverflowY ? $.position.scrollbarWidth() : 0,
135					height: hasOverflowX ? $.position.scrollbarWidth() : 0
136				};
137			},
138			getWithinInfo: function ( element ) {
139				var withinElement = $( element || window ),
140					isWindow      = $.isWindow( withinElement[ 0 ] ),
141					isDocument    = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9,
142					hasOffset     = !isWindow && !isDocument;
143				return {
144					element: withinElement,
145					isWindow: isWindow,
146					isDocument: isDocument,
147					offset: hasOffset ? $( element ).offset() : { left : 0, top : 0 },
148					scrollLeft: withinElement.scrollLeft(),
149					scrollTop: withinElement.scrollTop(),
150					width: withinElement.outerWidth(),
151					height: withinElement.outerHeight()
152				};
153			}
154		};
155
156		$.fn.position = function ( options ) {
157			if ( !options || !options.of )
158			{
159				return _position.apply( this, arguments );
160			}
161
162			// Make a copy, we don't want to modify arguments
163			options = $.extend( {}, options );
164
165			var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
166				target     = $( options.of ),
167				within     = $.position.getWithinInfo( options.within ),
168				scrollInfo = $.position.getScrollInfo( within ),
169				collision  = ( options.collision || "flip" ).split( " " ),
170				offsets    = {};
171
172			dimensions = getDimensions( target );
173			if ( target[ 0 ].preventDefault )
174			{
175				// Force left top to allow flipping
176				options.at = "left top";
177			}
178			targetWidth  = dimensions.width;
179			targetHeight = dimensions.height;
180			targetOffset = dimensions.offset;
181
182			// Clone to reuse original targetOffset later
183			basePosition = $.extend( {}, targetOffset );
184
185			// Force my and at to have valid horizontal and vertical positions
186			// if a value is missing or invalid, it will be converted to center
187			$.each( [ "my", "at" ], function () {
188				var pos = ( options[ this ] || "" ).split( " " ),
189					horizontalOffset,
190					verticalOffset;
191
192				if ( pos.length === 1 )
193				{
194					pos = rhorizontal.test( pos[ 0 ] ) ?
vendor: 5,069 bytes, lines 195-366
195						pos.concat( [ "center" ] ) :
196						rvertical.test( pos[ 0 ] ) ?
197							[ "center" ].concat( pos ) :
198							[ "center", "center" ];
199				}
200				pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
201				pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
202
203				// Calculate offsets
204				horizontalOffset = roffset.exec( pos[ 0 ] );
205				verticalOffset   = roffset.exec( pos[ 1 ] );
206				offsets[ this ]  = [
207					horizontalOffset ? horizontalOffset[ 0 ] : 0,
208					verticalOffset ? verticalOffset[ 0 ] : 0
209				];
210
211				// Reduce to just the positions without the offsets
212				options[ this ] = [
213					rposition.exec( pos[ 0 ] )[ 0 ],
214					rposition.exec( pos[ 1 ] )[ 0 ]
215				];
216			} );
217
218			// Normalize collision option
219			if ( collision.length === 1 )
220			{
221				collision[ 1 ] = collision[ 0 ];
222			}
223
224			if ( options.at[ 0 ] === "right" )
225			{
226				basePosition.left += targetWidth;
227			}
228			else if ( options.at[ 0 ] === "center" )
229			{
230				basePosition.left += targetWidth / 2;
231			}
232
233			if ( options.at[ 1 ] === "bottom" )
234			{
235				basePosition.top += targetHeight;
236			}
237			else if ( options.at[ 1 ] === "center" )
238			{
239				basePosition.top += targetHeight / 2;
240			}
241
242			atOffset           = getOffsets( offsets.at, targetWidth, targetHeight );
243			basePosition.left += atOffset[ 0 ];
244			basePosition.top  += atOffset[ 1 ];
245
246			return this.each( function () {
247				var collisionPosition, using,
248					elem            = $( this ),
249					elemWidth       = elem.outerWidth(),
250					elemHeight      = elem.outerHeight(),
251					marginLeft      = parseCss( this, "marginLeft" ),
252					marginTop       = parseCss( this, "marginTop" ),
253					collisionWidth  = elemWidth + marginLeft + parseCss( this, "marginRight" ) +
254						scrollInfo.width,
255					collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) +
256						scrollInfo.height,
257					position        = $.extend( {}, basePosition ),
258					myOffset        = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
259
260				if ( options.my[ 0 ] === "right" )
261				{
262					position.left -= elemWidth;
263				}
264				else if ( options.my[ 0 ] === "center" )
265				{
266					position.left -= elemWidth / 2;
267				}
268
269				if ( options.my[ 1 ] === "bottom" )
270				{
271					position.top -= elemHeight;
272				}
273				else if ( options.my[ 1 ] === "center" )
274				{
275					position.top -= elemHeight / 2;
276				}
277
278				position.left += myOffset[ 0 ];
279				position.top  += myOffset[ 1 ];
280
281				collisionPosition = {
282					marginLeft: marginLeft,
283					marginTop: marginTop
284				};
285
286				$.each( [ "left", "top" ], function ( i, dir ) {
287					if ( $.ui.position[ collision[ i ] ] )
288					{
289						$.ui.position[ collision[ i ] ][ dir ]( position, {
290							targetWidth: targetWidth,
291							targetHeight: targetHeight,
292							elemWidth: elemWidth,
293							elemHeight: elemHeight,
294							collisionPosition: collisionPosition,
295							collisionWidth: collisionWidth,
296							collisionHeight: collisionHeight,
297							offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
298							my: options.my,
299							at: options.at,
300							within: within,
301							elem: elem
302						} );
303					}
304				} );
305
306				if ( options.using )
307				{
308					// Adds feedback as second argument to using callback, if present
309					using = function ( props ) {
310						var left     = targetOffset.left - position.left,
311							right    = left + targetWidth - elemWidth,
312							top      = targetOffset.top - position.top,
313							bottom   = top + targetHeight - elemHeight,
314							feedback = {
315								target: {
316									element: target,
317									left: targetOffset.left,
318									top: targetOffset.top,
319									width: targetWidth,
320									height: targetHeight
321								},
322								element: {
323									element: elem,
324									left: position.left,
325									top: position.top,
326									width: elemWidth,
327									height: elemHeight
328								},
329								horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
330								vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
331						};
332						if ( targetWidth < elemWidth && abs( left + right ) < targetWidth )
333						{
334							feedback.horizontal = "center";
335						}
336						if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight )
337						{
338							feedback.vertical = "middle";
339						}
340						if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) )
341						{
342							feedback.important = "horizontal";
343						}
344						else
345						{
346							feedback.important = "vertical";
347						}
348						options.using.call( this, props, feedback );
349					};
350				}
351
352				elem.offset( $.extend( position, { using: using } ) );
353			} );
354		};
355
356		$.ui.position = {
357			fit: {
358				left: function ( position, data ) {
359					var within           = data.within,
360						withinOffset     = within.isWindow ? within.scrollLeft : within.offset.left,
361						outerWidth       = within.width,
362						collisionPosLeft = position.left - data.collisionPosition.marginLeft,
363						overLeft         = withinOffset - collisionPosLeft,
364						overRight        = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
365						newOverRight;
366
vendor: 6,216 bytes, lines 367-573
367					// Element is wider than within
368					if ( data.collisionWidth > outerWidth )
369					{
370						// Element is initially over the left side of within
371						if ( overLeft > 0 && overRight <= 0 )
372						{
373							newOverRight   = position.left + overLeft + data.collisionWidth - outerWidth -
374								withinOffset;
375							position.left += overLeft - newOverRight;
376
377							// Element is initially over right side of within
378						}
379						else if ( overRight > 0 && overLeft <= 0 )
380						{
381							position.left = withinOffset;
382
383							// Element is initially over both left and right sides of within
384						}
385						else
386						{
387							if ( overLeft > overRight )
388							{
389								position.left = withinOffset + outerWidth - data.collisionWidth;
390							}
391							else
392							{
393								position.left = withinOffset;
394							}
395						}
396
397						// Too far left -> align with left edge
398					}
399					else if ( overLeft > 0 )
400					{
401						position.left += overLeft;
402
403						// Too far right -> align with right edge
404					}
405					else if ( overRight > 0 )
406					{
407						position.left -= overRight;
408
409						// Adjust based on position and margin
410					}
411					else
412					{
413						position.left = max( position.left - collisionPosLeft, position.left );
414					}
415				},
416				top: function ( position, data ) {
417					var within          = data.within,
418						withinOffset    = within.isWindow ? within.scrollTop : within.offset.top,
419						outerHeight     = data.within.height,
420						collisionPosTop = position.top - data.collisionPosition.marginTop,
421						overTop         = withinOffset - collisionPosTop,
422						overBottom      = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
423						newOverBottom;
424
425					// Element is taller than within
426					if ( data.collisionHeight > outerHeight )
427					{
428						// Element is initially over the top of within
429						if ( overTop > 0 && overBottom <= 0 )
430						{
431							newOverBottom = position.top + overTop + data.collisionHeight - outerHeight -
432								withinOffset;
433							position.top += overTop - newOverBottom;
434
435							// Element is initially over bottom of within
436						}
437						else if ( overBottom > 0 && overTop <= 0 )
438						{
439							position.top = withinOffset;
440
441							// Element is initially over both top and bottom of within
442						}
443						else
444						{
445							if ( overTop > overBottom )
446							{
447								position.top = withinOffset + outerHeight - data.collisionHeight;
448							}
449							else
450							{
451								position.top = withinOffset;
452							}
453						}
454
455						// Too far up -> align with top
456					}
457					else if ( overTop > 0 )
458					{
459						position.top += overTop;
460
461						// Too far down -> align with bottom edge
462					}
463					else if ( overBottom > 0 )
464					{
465						position.top -= overBottom;
466
467						// Adjust based on position and margin
468					}
469					else
470					{
471						position.top = max( position.top - collisionPosTop, position.top );
472					}
473				}
474			},
475			flip: {
476				left: function ( position, data ) {
477					var within           = data.within,
478						withinOffset     = within.offset.left + within.scrollLeft,
479						outerWidth       = within.width,
480						offsetLeft       = within.isWindow ? within.scrollLeft : within.offset.left,
481						collisionPosLeft = position.left - data.collisionPosition.marginLeft,
482						overLeft         = collisionPosLeft - offsetLeft,
483						overRight        = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
484						myOffset         = data.my[ 0 ] === "left" ?
485							-data.elemWidth :
486							data.my[ 0 ] === "right" ?
487								data.elemWidth :
488								0,
489						atOffset         = data.at[ 0 ] === "left" ?
490							data.targetWidth :
491							data.at[ 0 ] === "right" ?
492								-data.targetWidth :
493								0,
494						offset           = -2 * data.offset[ 0 ],
495						newOverRight,
496						newOverLeft;
497
498					if ( overLeft < 0 )
499					{
500						newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth -
501							outerWidth - withinOffset;
502						if ( newOverRight < 0 || newOverRight < abs( overLeft ) )
503						{
504							position.left += myOffset + atOffset + offset;
505						}
506					}
507					else if ( overRight > 0 )
508					{
509						newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset +
510							atOffset + offset - offsetLeft;
511						if ( newOverLeft > 0 || abs( newOverLeft ) < overRight )
512						{
513							position.left += myOffset + atOffset + offset;
514						}
515					}
516				},
517				top: function ( position, data ) {
518					var within          = data.within,
519						withinOffset    = within.offset.top + within.scrollTop,
520						outerHeight     = within.height,
521						offsetTop       = within.isWindow ? within.scrollTop : within.offset.top,
522						collisionPosTop = position.top - data.collisionPosition.marginTop,
523						overTop         = collisionPosTop - offsetTop,
524						overBottom      = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
525						top             = data.my[ 1 ] === "top",
526						myOffset        = top ?
527							-data.elemHeight :
528							data.my[ 1 ] === "bottom" ?
529								data.elemHeight :
530								0,
531						atOffset        = data.at[ 1 ] === "top" ?
532							data.targetHeight :
533							data.at[ 1 ] === "bottom" ?
534								-data.targetHeight :
535								0,
536						offset          = -2 * data.offset[ 1 ],
537						newOverTop,
538						newOverBottom;
539					if ( overTop < 0 )
540					{
541						newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight -
542							outerHeight - withinOffset;
543						if ( newOverBottom < 0 || newOverBottom < abs( overTop ) )
544						{
545							position.top += myOffset + atOffset + offset;
546						}
547					}
548					else if ( overBottom > 0 )
549					{
550						newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset +
551							offset - offsetTop;
552						if ( newOverTop > 0 || abs( newOverTop ) < overBottom )
553						{
554							position.top += myOffset + atOffset + offset;
555						}
556					}
557				}
558			},
559			flipfit: {
560				left: function () {
561					$.ui.position.flip.left.apply( this, arguments );
562					$.ui.position.fit.left.apply( this, arguments );
563				},
564				top: function () {
565					$.ui.position.flip.top.apply( this, arguments );
566					$.ui.position.fit.top.apply( this, arguments );
567				}
568			}
569		};
570	} )();
571
572	var position = $.ui.position;
573}));

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.