1function doAdjustCaptionContainer(image) { 2 var captionContainer = getNextSibling(image, ".cd-image-caption-container"); 3 if (captionContainer == null) { 4 return; 5 } 6 setTimeout(function () { 7 if (image.naturalHeight / image.naturalWidth > image.height / image.width) { 8 var dw = (image.width - image.height * image.naturalWidth / image.naturalHeight) / 2; 9 captionContainer.style.cssText = 'left: ' + dw + 'px; right: ' + dw + 'px;'; 10 } 11 if (image.naturalHeight / image.naturalWidth < image.height / image.width) { 12 var dh = (image.height - image.width * image.naturalHeight / image.naturalWidth) / 2; 13 captionContainer.style.cssText = 'top: ' + dh + 'px; bottom: ' + dh + 'px;'; 14 } 15 }, 100) 16 17} 18 19var getNextSibling = function (elem, selector) { 20 var sibling = elem.nextElementSibling; 21 while (sibling) { 22 if (sibling.matches(selector)) { 23 return sibling; 24 } 25 sibling = sibling.nextElementSibling 26 } 27} 28 29function adjustCaptionContainer() { 30 document.querySelectorAll('.cd-image-contain').forEach(function (image) { 31 if (image.width > 0) { 32 doAdjustCaptionContainer(image); 33 } else { 34 image.addEventListener('load', 35 function (e) { 36 doAdjustCaptionContainer(image); 37 }); 38 } 39 } 40 ) 41}
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.