https://aleshamebel.ru/local/templates/romza_bitronic2_2.17.0/js/c…/utils/posPopup.js?14714033304948
1/* === check if $el is in viewport. If not, move it via margins === */ 2function checkViewport($el, $view){ 3 $view = $view ? $view : $(window); 4 // calc el dimensions and coords 5 var width = $el.outerWidth(), 6 height = $el.outerHeight(), 7 elTop = $el.offset().top, 8 elLeft = $el.offset().left; 9 10 // calc viewport limits 11 var vWidth = $view.outerWidth(), 12 vHeight = $view.outerHeight(), 13 vLeft = $.isWindow($view.get(0)) ? $view.scrollLeft() : $view.offset().left, 14 vTop = $.isWindow($view.get(0)) ? $view.scrollTop() : $view.offset().top, 15 vRight = vLeft + vWidth, 16 vBottom = vTop + vHeight; 17 18 var curMarginLeft = parseFloat($el.css('margin-left')); 19 var curMarginTop = parseFloat($el.css('margin-top')); 20 21 var diff = elLeft - vLeft; 22 if ( diff < 0 ) $el.css('margin-left', curMarginLeft - diff); 23 diff = vRight - (elLeft + width); 24 if ( diff < 0 ) $el.css('margin-left', curMarginLeft + diff); 25 diff = elTop - vTop; 26 if ( diff < 0 ) $el.css('margin-top', curMarginTop - diff); 27 diff = vBottom - (elTop + height); 28 if ( diff < 0 ) $el.css('margin-top', curMarginTop + diff); 29} 30 31/* === positioning popup relative to base === 32position options: 33horizontal - left, right, leftborder, rightborder, centered (default) 34vertical - top, bottom (default), topborder, bottomborder, centered 35*/ 36function posPopup($popup, options){ 37 var $base = options.base ? options.base : false; 38 var $view = options.viewport ? options.viewport : $(window); 39 40 var position = (options.position !== undefined) ? options.position.split(' ') : false; 41 if ( !$base || position === false){ 42 // if no base or position - just check against viewport 43 checkViewport($popup, $view); 44 return false; 45 } 46 47 position = { left: position[0] || 'centered', top: position[1] || 'bottom' } 48 $popup.attr('data-h-align', position.left) 49 .attr('data-v-align', position.top); 50 51 // calc base dimensions and coords 52 var bWidth = $base.outerWidth(), 53 bHeight = $base.outerHeight(), 54 bTop = $base.offset().top, 55 bLeft = $base.offset().left, 56 bRight = bLeft + bWidth, 57 bBottom = bTop + bHeight; 58 59 // calc popup dimensions 60 var pWidth = $popup.outerWidth(), 61 pHeight = $popup.outerHeight(); 62 63 // calc viewport limits 64 var vWidth = $view.outerWidth(), 65 vHeight = $view.outerHeight(), 66 vLeft = $.isWindow($view.get(0)) ? $view.scrollLeft() : $view.offset().left, 67 vTop = $.isWindow($view.get(0)) ? $view.scrollTop() : $view.offset().top, 68 vRight = vLeft + vWidth, 69 vBottom = vTop + vHeight; 70 71 // calc new coords for popup 72 var posParentOffset = $popup.offsetParent().offset(), 73 newLeft, newTop; 74 75 // horizontal 76 switch (position.left){ 77 case 'left': 78 newLeft = bLeft - pWidth; 79 // if outside viewport - switch to right 80 if (newLeft < vLeft){ 81 newLeft = bRight; 82 position.left = 'right'; 83 } 84 break; 85 case 'leftborder': 86 newLeft = bLeft; 87 // if outside viewport - switch to rightborder 88 if ((newLeft + pWidth) > vRight){ 89 newLeft = bRight - pWidth; 90 position.left = 'rightborder'; 91 } 92 break; 93 case 'right': 94 newLeft = bRight; 95 // if outside viewport - switch to left 96 if ((newLeft + pWidth) > vRight){ 97 newLeft = bLeft - pWidth; 98 position.left = 'left'; 99 } 100 break; 101 case 'rightborder': 102 newLeft = bRight - pWidth; 103 // if outside viewport - switch to leftborder 104 if (newLeft < vLeft){ 105 newLeft = bLeft; 106 position.left = 'leftborder'; 107 } 108 break; 109 case 'centered': 110 default: 111 // by default we center! 112 newLeft = bLeft + (bWidth / 2) - (pWidth / 2);
113 if (newLeft < vLeft) newLeft = vLeft; 114 if ((newLeft + pWidth) > vRight) newLeft = vRight - pWidth; 115 } 116 117 // vertical 118 switch (position.top){ 119 case 'top': 120 newTop = bTop - pHeight; 121 // if outside viewport - switch to bottom 122 if (newTop < vTop){ 123 newTop = bBottom; 124 position.top = 'bottom'; 125 } 126 break; 127 case 'topborder': 128 newTop = bTop; 129 // if outside viewport - switch to bottomborder 130 if ((newTop + pHeight) > vBottom){ 131 newTop = bBottom - pHeight; 132 position.top = 'bottomborder'; 133 } 134 break; 135 case 'centered': 136 newTop = bTop + (bHeight / 2) - (pHeight / 2); 137 if (newTop < vTop) newTop = vTop; 138 if ((newTop + pHeight) > vBottom) newTop = vBottom - pHeight; 139 break; 140 case 'bottomborder': 141 newTop = bBottom - pHeight; 142 // if outside viewport - switch to topborder 143 if (newTop < vTop){ 144 newTop = bTop; 145 position.top = 'topborder'; 146 } 147 break; 148 case 'bottom': 149 default: 150 // by default - bottom! 151 newTop = bBottom; 152 // if outside viewport - switch to top 153 if ((newTop + pHeight) > vBottom){ 154 newTop = bTop - pHeight; 155 position.top = 'top'; 156 } 157 } 158 159 $popup.attr('data-h-align', position.left) 160 .attr('data-v-align', position.top) 161 .css({ 162 left: newLeft - posParentOffset.left, 163 top: newTop - posParentOffset.top 164 }); 165}
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.