1function extendReleaseList() 2{ 3 4 // functionality not required for this screen size and below 5 if ($(window).width() < 768) return; 6 7 $('.enquiry').each(function() { 8 9 var release_length = $(this).find('.release_title').outerWidth(true); 10 var media_length = $(this).find('.attatchment').outerWidth(true); 11 var date_length = $(this).find('.date').outerWidth(true); 12 var permitted_length = $(this).innerWidth(); 13 var new_length = permitted_length - (media_length + date_length) - 50; 14 $(this).find('release_title').width(new_length); 15 16 }); 17} 18 19function shrinkReleaseList() 20{ 21 22 // functionality not required for this screen size and below 23 if ($(window).width() < 768) return; 24 25 $('.enquiry').each(function() { 26 27 $(this).find('release_title').width('auto'); 28 29 }); 30} 31 32function updateReleaseList() 33{ 34 35 // functionality not required for this screen size and below 36 if ($(window).width() < 768) return; 37 38 $('.release').each(function() { 39 var date_length = 0; 40 var media_length = 0; 41 // get lengths 42 if($(this).find('.date').outerWidth(true)) { 43 date_length = $(this).find('.date').outerWidth(true); 44 } 45 if($(this).find('.attachment').outerWidth(true)) { 46 media_length = $(this).find('.attachment').outerWidth(true); 47 } 48 var release_length = $(this).find('.release_title').outerWidth(true); 49 var permitted_length = $(this).innerWidth(); // should be 759 without image 50 var title_html = $(this).find('.release_title').attr('title'); 51 // calculate overflow 52 var overflow = (release_length + media_length + date_length) - permitted_length; 53 54 // before, after, percentage change 55 var title_inner = Math.round($(this).find('.release_title').width()); 56 var new_width = title_inner - overflow - 10; 57 58 // resize the container 59 var title_parent = $(this).find('.release_title'); 60 var title_anchor = title_parent.children(''); 61 var title_chars = title_parent.attr('title').length; 62 63 // resize string 64 var font_size = title_anchor.css('font-size'); 65 font_size = parseInt(font_size.replace("px","")); 66 title_anchor.html(cropReleaseTitle(title_html,new_width,font_size)); 67 68 // add trailing periods if string as been cropped 69 if (title_anchor.text().length < title_chars) title_anchor.append('...'); 70 71 }); 72} 73 74function cropReleaseTitle($string, $allowance, $fontsize) 75{ 76 // work out font-size adjustment 77 var font_consideration = (21/$fontsize); 78 // removing trailing periods 79 $string = $string.replace('...', ''); 80 // set a penalty for uppercase characters 81 var upper_penalty = Math.round(($string.replace(/[^A-Z]/g, "").length/4) * font_consideration); 82 // set new length as a function of $allowance (pixels) 83 var length = Math.floor(($allowance * (0.095*font_consideration))-upper_penalty); 84 $string = $string.substring(0,length); 85 // remove trailing periods or white space 86 return $string.replace(/^[.\s]+|[.\s]+$/g, ""); 87} 88 89 90$(document).ready(function() { updateReleaseList(); }); 91$(window).resize(function(){ extendReleaseList(); updateReleaseList(); shrinkReleaseList() });
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.