PageSourceSearch

https://www.tataplay.com/dth/core/misc/position.js?v=9.5.11

js tataplay.com collected 2026-10-01 10:25:42 UTC 14,920 bytes, 374 lines download raw bytes

1/**
2* DO NOT EDIT THIS FILE.
3* See the following change record for more information,
4* https://www.drupal.org/node/2815083
5* @preserve
6**/
7(function ($) {
8  var cachedScrollbarWidth = null;
9  var max = Math.max,
10    abs = Math.abs;
11  var regexHorizontal = /left|center|right/;
12  var regexVertical = /top|center|bottom/;
13  var regexOffset = /[+-]\d+(\.[\d]+)?%?/;
14  var regexPosition = /^\w+/;
15  var regexPercent = /%$/;
16  var _position = $.fn.position;
17  function getOffsets(offsets, width, height) {
18    return [parseFloat(offsets[0]) * (regexPercent.test(offsets[0]) ? width / 100 : 1), parseFloat(offsets[1]) * (regexPercent.test(offsets[1]) ? height / 100 : 1)];
19  }
20  function parseCss(element, property) {
21    return parseInt($.css(element, property), 10) || 0;
22  }
23  function getDimensions(elem) {
24    var raw = elem[0];
25    if (raw.nodeType === 9) {
26      return {
27        width: elem.width(),
28        height: elem.height(),
29        offset: {
30          top: 0,
31          left: 0
32        }
33      };
34    }
35    if ($.isWindow(raw)) {
36      return {
37        width: elem.width(),
38        height: elem.height(),
39        offset: {
40          top: elem.scrollTop(),
41          left: elem.scrollLeft()
42        }
43      };
44    }
45    if (raw.preventDefault) {
46      return {
47        width: 0,
48        height: 0,
49        offset: {
50          top: raw.pageY,
51          left: raw.pageX
52        }
53      };
54    }
55    return {
56      width: elem.outerWidth(),
57      height: elem.outerHeight(),
58      offset: elem.offset()
59    };
60  }
61  var collisions = {
62    fit: {
63      left: function left(position, data) {
64        var within = data.within;
65        var withinOffset = within.isWindow ? within.scrollLeft : within.offset.left;
66        var outerWidth = within.width;
67        var collisionPosLeft = position.left - data.collisionPosition.marginLeft;
68        var overLeft = withinOffset - collisionPosLeft;
69        var overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset;
70        var newOverRight;
71        if (data.collisionWidth > outerWidth) {
72          if (overLeft > 0 && overRight <= 0) {
73            newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
74            position.left += overLeft - newOverRight;
75          } else if (overRight > 0 && overLeft <= 0) {
76            position.left = withinOffset;
77          } else if (overLeft > overRight) {
78            position.left = withinOffset + outerWidth - data.collisionWidth;
79          } else {
80            position.left = withinOffset;
81          }
82        } else if (overLeft > 0) {
83          position.left += overLeft;
84        } else if (overRight > 0) {
85          position.left -= overRight;
86        } else {
87          position.left = max(position.left - collisionPosLeft, position.left);
88        }
89      },
90      top: function top(position, data) {
91        var within = data.within;
92        var withinOffset = within.isWindow ? within.scrollTop : within.offset.top;
93        var outerHeight = data.within.height;
94        var collisionPosTop = position.top - data.collisionPosition.marginTop;
95        var overTop = withinOffset - collisionPosTop;
96        var overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset;
97        var newOverBottom;
98        if (data.collisionHeight > outerHeight) {
99          if (overTop > 0 && overBottom <= 0) {
100            newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
101            position.top += overTop - newOverBottom;
102          } else if (overBottom > 0 && overTop <= 0) {
103            position.top = withinOffset;
104          } else if (overTop > overBottom) {
105            position.top = withinOffset + outerHeight - data.collisionHeight;
106          } else {
107            position.top = withinOffset;
108          }
109        } else if (overTop > 0) {
110          position.top += overTop;
111        } else if (overBottom > 0) {
112          position.top -= overBottom;
113        } else {
114          position.top = max(position.top - collisionPosTop, position.top);
115        }
116      }
117    },
118    flip: {
119      left: function left(position, data) {
120        var within = data.within;
121        var withinOffset = within.offset.left + within.scrollLeft;
122        var outerWidth = within.width;
123        var offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left;
124        var collisionPosLeft = position.left - data.collisionPosition.marginLeft;
125        var overLeft = collisionPosLeft - offsetLeft;
126        var overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft;
127        var myOffset = data.my[0] === 'left' ? -data.elemWidth : data.my[0] === 'right' ? data.elemWidth : 0;
128        var atOffset = data.at[0] === 'left' ? data.targetWidth : data.at[0] === 'right' ? -data.targetWidth : 0;
129        var offset = -2 * data.offset[0];
130        var newOverRight;
131        var newOverLeft;
132        if (overLeft < 0) {
133          newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
134          if (newOverRight < 0 || newOverRight < abs(overLeft)) {
135            position.left += myOffset + atOffset + offset;
136          }
137        } else if (overRight > 0) {
138          newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
139          if (newOverLeft > 0 || abs(newOverLeft) < overRight) {
140            position.left += myOffset + atOffset + offset;
141          }
142        }
143      },
144      top: function top(position, data) {
145        var within = data.within;
146        var withinOffset = within.offset.top + within.scrollTop;
147        var outerHeight = within.height;
148        var offsetTop = within.isWindow ? within.scrollTop : within.offset.top;
149        var collisionPosTop = position.top - data.collisionPosition.marginTop;
150        var overTop = collisionPosTop - offsetTop;
151        var overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop;
152        var top = data.my[1] === 'top';
153        var myOffset = top ? -data.elemHeight : data.my[1] === 'bottom' ? data.elemHeight : 0;
154        var atOffset = data.at[1] === 'top' ? data.targetHeight : data.at[1] === 'bottom' ? -data.targetHeight : 0;
155        var offset = -2 * data.offset[1];
156        var newOverTop;
157        var newOverBottom;
158        if (overTop < 0) {
159          newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
160          if (newOverBottom < 0 || newOverBottom < abs(overTop)) {
161            position.top += myOffset + atOffset + offset;
162          }
163        } else if (overBottom > 0) {
164          newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
165          if (newOverTop > 0 || abs(newOverTop) < overBottom) {
166            position.top += myOffset + atOffset + offset;
167          }
168        }
169      }
170    },
171    flipfit: {
172      left: function left() {
173        for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
174          args[_key] = arguments[_key];
175        }
176        collisions.flip.left.apply(this, args);
177        collisions.fit.left.apply(this, args);
178      },
179      top: function top() {
180        for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
181          args[_key2] = arguments[_key2];
182        }
183        collisions.flip.top.apply(this, args);
184        collisions.fit.top.apply(this, args);
185      }
186    }
187  };
188  $.position = {
189    scrollbarWidth: function scrollbarWidth() {
190      if (cachedScrollbarWidth !== undefined) {
191        return cachedScrollbarWidth;
192      }
193      var div = $('<div ' + "style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'>" + "<div style='height:100px;width:auto;'></div></div>");
194      var innerDiv = div.children()[0];
195      $('body').append(div);
196      var w1 = innerDiv.offsetWidth;
197      div.css('overflow', 'scroll');
198      var w2 = innerDiv.offsetWidth;
199      if (w1 === w2) {
200        w2 = div[0].clientWidth;
201      }
202      div.remove();
203      cachedScrollbarWidth = w1 - w2;
204      return cachedScrollbarWidth;
205    },
206    getScrollInfo: function getScrollInfo(within) {
207      var overflowX = within.isWindow || within.isDocument ? '' : within.element.css('overflow-x');
208      var overflowY = within.isWindow || within.isDocument ? '' : within.element.css('overflow-y');
209      var hasOverflowX = overflowX === 'scroll' || overflowX === 'auto' && within.width < within.element[0].scrollWidth;
210      var hasOverflowY = overflowY === 'scroll' || overflowY === 'auto' && within.height < within.element[0].scrollHeight;
211      return {
212        width: hasOverflowY ? $.position.scrollbarWidth() : 0,
213        height: hasOverflowX ? $.position.scrollbarWidth() : 0
214      };
215    },
216    getWithinInfo: function getWithinInfo(element) {
217      var withinElement = $(element || window);
218      var isWindow = $.isWindow(withinElement[0]);
219      var isDocument = !!withinElement[0] && withinElement[0].nodeType === 9;
220      var hasOffset = !isWindow && !isDocument;
221      return {
222        element: withinElement,
223        isWindow: isWindow,
224        isDocument: isDocument,
225        offset: hasOffset ? $(element).offset() : {
226          left: 0,
227          top: 0
228        },
229        scrollLeft: withinElement.scrollLeft(),
230        scrollTop: withinElement.scrollTop(),
231        width: withinElement.outerWidth(),
232        height: withinElement.outerHeight()
233      };
234    }
235  };
236  $.fn.position = function (options) {
237    if (!options || !options.of) {
238      return _position.apply(this, arguments);
239    }
240    options = $.extend({}, options);
241    var within = $.position.getWithinInfo(options.within);
242    var scrollInfo = $.position.getScrollInfo(within);
243    var collision = (options.collision || 'flip').split(' ');
244    var offsets = {};
245    var target = typeof options.of === 'string' ? $(document).find(options.of) : $(options.of);
246    var dimensions = getDimensions(target);
247    var targetWidth = dimensions.width;
248    var targetHeight = dimensions.height;
249    var targetOffset = dimensions.offset;
250    if (target[0].preventDefault) {
251      options.at = 'left top';
252    }
253    var basePosition = $.extend({}, targetOffset);
254    $.each(['my', 'at'], function () {
255      var pos = (options[this] || '').split(' ');
256      if (pos.length === 1) {
257        pos = regexHorizontal.test(pos[0]) ? pos.concat(['center']) : regexVertical.test(pos[0]) ? ['center'].concat(pos) : ['center', 'center'];
258      }
259      pos[0] = regexHorizontal.test(pos[0]) ? pos[0] : 'center';
260      pos[1] = regexVertical.test(pos[1]) ? pos[1] : 'center';
261      var horizontalOffset = regexOffset.exec(pos[0]);
262      var verticalOffset = regexOffset.exec(pos[1]);
263      offsets[this] = [horizontalOffset ? horizontalOffset[0] : 0, verticalOffset ? verticalOffset[0] : 0];
264      options[this] = [regexPosition.exec(pos[0])[0], regexPosition.exec(pos[1])[0]];
265    });
266    if (collision.length === 1) {
267      collision[1] = collision[0];
268    }
269    if (options.at[0] === 'right') {
270      basePosition.left += targetWidth;
271    } else if (options.at[0] === 'center') {
272      basePosition.left += targetWidth / 2;
273    }
274    if (options.at[1] === 'bottom') {
275      basePosition.top += targetHeight;
276    } else if (options.at[1] === 'center') {
277      basePosition.top += targetHeight / 2;
278    }
279    var atOffset = getOffsets(offsets.at, targetWidth, targetHeight);
280    basePosition.left += atOffset[0];
281    basePosition.top += atOffset[1];
282    return this.each(function () {
283      var using;
284      var elem = $(this);
285      var elemWidth = elem.outerWidth();
286      var elemHeight = elem.outerHeight();
287      var marginLeft = parseCss(this, 'marginLeft');
288      var marginTop = parseCss(this, 'marginTop');
289      var collisionWidth = elemWidth + marginLeft + parseCss(this, 'marginRight') + scrollInfo.width;
290      var collisionHeight = elemHeight + marginTop + parseCss(this, 'marginBottom') + scrollInfo.height;
291      var position = $.extend({}, basePosition);
292      var myOffset = getOffsets(offsets.my, elem.outerWidth(), elem.outerHeight());
293      if (options.my[0] === 'right') {
294        position.left -= elemWidth;
295      } else if (options.my[0] === 'center') {
296        position.left -= elemWidth / 2;
297      }
298      if (options.my[1] === 'bottom') {
299        position.top -= elemHeight;
300      } else if (options.my[1] === 'center') {
301        position.top -= elemHeight / 2;
302      }
303      position.left += myOffset[0];
304      position.top += myOffset[1];
305      var collisionPosition = {
306        marginLeft: marginLeft,
307        marginTop: marginTop
308      };
309      $.each(['left', 'top'], function (i, dir) {
310        if (collisions[collision[i]]) {
311          collisions[collision[i]][dir](position, {
312            targetWidth: targetWidth,
313            targetHeight: targetHeight,
314            elemWidth: elemWidth,
315            elemHeight: elemHeight,
316            collisionPosition: collisionPosition,
317            collisionWidth: collisionWidth,
318            collisionHeight: collisionHeight,
319            offset: [atOffset[0] + myOffset[0], atOffset[1] + myOffset[1]],
320            my: options.my,
321            at: options.at,
322            within: within,
323            elem: elem
324          });
325        }
326      });
327      if (options.using) {
328        using = function using(props) {
329          var left = targetOffset.left - position.left;
330          var right = left + targetWidth - elemWidth;
331          var top = targetOffset.top - position.top;
332          var bottom = top + targetHeight - elemHeight;
333          var feedback = {
334            target: {
335              element: target,
336              left: targetOffset.left,
337              top: targetOffset.top,
338              width: targetWidth,
339              height: targetHeight
340            },
341            element: {
342              element: elem,
343              left: position.left,
344              top: position.top,
345              width: elemWidth,
346              height: elemHeight
347            },
348            horizontal: right < 0 ? 'left' : left > 0 ? 'right' : 'center',
349            vertical: bottom < 0 ? 'top' : top > 0 ? 'bottom' : 'middle'
350          };
351          if (targetWidth < elemWidth && abs(left + right) < targetWidth) {
352            feedback.horizontal = 'center';
353          }
354          if (targetHeight < elemHeight && abs(top + bottom) < targetHeight) {
355            feedback.vertical = 'middle';
356          }
357          if (max(abs(left), abs(right)) > max(abs(top), abs(bottom))) {
358            feedback.important = 'horizontal';
359          } else {
360            feedback.important = 'vertical';
361          }
362          options.using.call(this, props, feedback);
363        };
364      }
365      elem.offset($.extend(position, {
366        using: using
367      }));
368    });
369  };
370  if (!$.hasOwnProperty('ui')) {
371    $.ui = {};
372  }
373  $.ui.position = collisions;
374})(jQuery);

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.