currentLeft = proxy.offset.left + proxy.dimension.width + offsetX - tooltipWidth;
1113 currentTop = proxy.offset.top + proxy.dimension.height + offsetY + 12; 1115 dontGoOffScreenY('top-right', 'bottom-right'); 1118 var tooltipStyle = getComputedStyle(self.tooltip, null); 1120 if (practicalPosition === 'left') { 1121 currentLeft = proxy.offset.left - offsetX - tooltipWidth - 12; 1122 currentLeftMirror = proxy.offset.left + offsetX + proxy.dimension.width + 12; 1124 proxy.offset.top + tooltipHeight - (proxy.offset.top + proxy.dimension.height); 1125 currentTop = proxy.offset.top - topDifference / 2 - offsetY; 1127 // if the tooltip goes off boths sides of the page 1128 if (currentLeft < 0 && currentLeftMirror + tooltipWidth > windowWidth) { 1129 var borderWidth = parseFloat(tooltipStyle.borderWidth) * 2; 1130 var newWidth = tooltipWidth + currentLeft - borderWidth; 1132 self.tooltip.style.width = newWidth + 'px'; 1133 tooltipHeight = self.tooltip.offsetHeight; 1134 currentLeft = proxy.offset.left - offsetX - newWidth - 12 - borderWidth; 1136 proxy.offset.top + tooltipHeight - (proxy.offset.top + proxy.dimension.height); 1137 currentTop = proxy.offset.top - topDifference / 2 - offsetY; 1138 } else if (currentLeft < 0) { 1139 // if it only goes off one side, flip it to the other side 1140 currentLeft = proxy.offset.left + offsetX + proxy.dimension.width + 12; 1141 arrowReposition = 'left'; 1145 if (practicalPosition == 'right') { 1146 currentLeft = proxy.offset.left + offsetX + proxy.dimension.width + 12; 1147 currentLeftMirror = proxy.offset.left - offsetX - tooltipWidth - 12; 1149 proxy.offset.top + tooltipHeight - (proxy.offset.top + proxy.dimension.height); 1150 currentTop = proxy.offset.top - topDifference / 2 - offsetY; 1152 // if the tooltip goes off boths sides of the page 1153 if (currentLeft + tooltipWidth > windowWidth && currentLeftMirror < 0) { 1154 var borderWidth = parseFloat(tooltipStyle.borderWidth) * 2; 1155 var newWidth = windowWidth - currentLeft - borderWidth; 1157 self.tooltip.style.width = newWidth + 'px'; 1158 tooltipHeight = self.tooltip.outerHeight(false); 1160 proxy.offset.top + tooltipHeight - (proxy.offset.top + proxy.dimension.height); 1161 currentTop = proxy.offset.top - topDifference / 2 - offsetY; 1162 } else if (currentLeft + tooltipWidth > windowWidth) { 1163 // if it only goes off one side, flip it to the other side 1164 currentLeft = proxy.offset.left - offsetX - tooltipWidth - 12; 1165 arrowReposition = 'right'; 1169 // if arrow is set true, style it and append it 1170 if (self.options.arrow) { 1171 var arrowClass = 'tooltipster-arrow-' + practicalPosition; 1173 // set color of the arrow 1174 if (self.options.arrowColor.length < 1) { 1175 var arrowColor = tooltipStyle.backgroundColor; 1177 var arrowColor = self.options.arrowColor; 1180 // if the tooltip was going off the page and had to re-adjust, we need to update the arrow's position 1181 if (!arrowReposition) { 1182 arrowReposition = ''; 1183 } else if (arrowReposition === 'left') { 1184 arrowClass = 'tooltipster-arrow-right'; 1185 arrowReposition = ''; 1186 } else if (arrowReposition == 'right') { 1187 arrowClass = 'tooltipster-arrow-left'; 1188 arrowReposition = ''; 1190 arrowReposition = 'left:' + Math.round(arrowReposition) + 'px;'; 1193 // building the logic to create the border around the arrow of the tooltip 1195 practicalPosition === 'top' || 1196 practicalPosition === 'top-left' || 1197 practicalPosition === 'top-right' 1199 var tooltipBorderWidth = parseFloat(tooltipStyle.borderBottomWidth); 1200 var tooltipBorderColor = tooltipStyle.borderBottomColor;