1/** 2 * ------------------------------------------------------------------------ 3 * resizeImage Plugin 4 * ------------------------------------------------------------------------ 5 * Copyright (C) 2012-2013 SUNLAND Co., JSC. All Rights Reserved. 6 * license - GNU/GPL, http://www.gnu.org/licenses/gpl.html 7 * Author: Sonle 8 * Email: [email protected] 9 * Websites: http://www.templaza.com 10 * ------------------------------------------------------------------------ 11 */ 12 13 14 15function TzTemplateResizeImage(obj){ 16 17 var widthStage; 18 var heightStage ; 19 var widthImage; 20 var heightImage; 21 22 obj.each(function (i,el){ 23 heightStage = jQuery(this).height(); 24 widthStage = jQuery (this).width(); 25 var img_url = jQuery(this).find('img').attr('src'); 26 var image = new Image(); 27 image.src = img_url; 28 image.onload = function() { 29 } 30 widthImage = image.naturalWidth; 31 heightImage = image.naturalHeight; 32 var tzimg = new resizeImage(widthImage, heightImage, widthStage, heightStage); 33 34 jQuery(this).find('img').css ({ top: tzimg.top, left: tzimg.left, width: tzimg.width, height: tzimg.height }); 35 }); 36} 37 38var resizeImage = function (widthImage, heightImage, widthStage, heightStage) { 39 40 var escImageX = widthStage / widthImage; 41 var escImageY = heightStage / heightImage; 42 43 var escalaImage = (escImageX > escImageY) ? escImageX : escImageY; 44 45 var widthV = widthImage * escalaImage; 46 var heightV = heightImage * escalaImage; 47 var posImageY = 0; 48 var posImageX = 0; 49 50 if (heightV > heightStage) { 51 posImageY = (heightStage - heightV) / 2; 52 }; 53 54 if (widthV > widthStage) { 55 posImageX = (widthStage - widthV) / 2; 56 }; 57 return { top: posImageY, left: posImageX, width: widthV, height: heightV }; 58};
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.