1(function ($) { 2 'use strict'; 3 $('img[longdesc], picture[longdesc]').each(function () { 4 var target = $(this); 5 var image = $(this); 6 7 if (target.parent().is( 'a')) 8 target = $(this).parent(); 9 10 if (target.parent().is( 'picture')) 11 target = $(this).parent(); 12 13 var longdesc = image.attr('longdesc'); 14 var alt = image.attr('alt'); 15 var classes = image.attr('class'); 16 //console.log(classes); 17 //var class_array = classes.split(' '); 18 var class_array = (classes !== undefined ? classes.split(' ') : '' ); 19 var image_id = ''; 20 console.log('class_array', class_array); 21 if ( class_array ) { 22 23 $.each(class_array, function (index, value) { 24 if (value.match(/wp-image-/gi)) { 25 image_id = value; 26 } 27 }); 28 29 $(this).attr('class', ''); 30 target.wrap('<div class="wpa-ld" />'); 31 target.parent('.wpa-ld').addClass(classes); 32 image.attr('class', ''); 33 target.parent('.wpa-ld').append('<p><a href="' + longdesc + '" class="hide-for-print longdesc-link" aria-label="Image description for: ' + alt + '" id="longdesc-link-'+image_id+'">Image description</a></p><p class="print-only"><strong>Title:</strong> ' + alt + '</p><p class="print-only"><strong>Image description:</strong></p>'); 34 target.parent('.wpa-ld').append('<div class="longdesc"></div>'); 35 target.parent('.wpa-ld').children('.longdesc').addClass('print-only'); 36 console.log('#desc_', longdesc + ' #desc_' + image_id); 37 target.parent('.wpa-ld').children('.longdesc').load(longdesc + ' #desc_' + image_id); 38 if (target.parent('.wpa-ld').is(':visible')) { 39 setTimeout(function(){ 40 var height = parseInt(target.parent('.wpa-ld').outerHeight(true)); 41 var width = parseInt(image.width()); 42 //console.log('innerwidth', parseInt(target.parent('.wpa-ld').innerWidth())); 43 target.parent('.wpa-ld').css('width', width + 'px'); 44 target.parent('.wpa-ld').css('height', height + 'px'); 45 },500); 46 $(window).on('resize', function(){ 47 resize_image(target, image ); 48 }); 49 } 50 } 51 52 }); 53 54 function resize_image(tar, img) { 55 tar.parent('.wpa-ld').css('width', 'auto' ); 56 tar.parent('.wpa-ld').css('height', 'auto' ); 57 var height = parseInt(tar.parent('.wpa-ld').outerHeight(true)); 58 var width = parseInt(img.width()); 59 console.log('innerwidth', parseInt(tar.parent('.wpa-ld').innerWidth())); 60 tar.parent('.wpa-ld').css('width', width + 'px'); 61 tar.parent('.wpa-ld').css('height', height + 'px'); 62 } 63}(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.