1(function($) { 2 $.fn.viewimageresize = function(selector) 3 { 4 var cfg = { 5 selector: "img" 6 }; 7 8 if(typeof selector == "object") { 9 cfg = $.extend(cfg, selector); 10 } else { 11 if(selector) { 12 cfg = $.extend({ selector: selector }); 13 } 14 } 15 16 var $img = this.find(cfg.selector); 17 var $this = this; 18 19 $img.removeAttr("height") 20 .css("height", ""); 21 22 function image_resize() 23 { 24 var width = $this.width(); 25 26 $img.each(function() { 27 if($(this).data("width") == undefined) 28 $(this).data("width", $(this).width()); 29 30 if($(this).data("width") > width) { 31 $(this).removeAttr("width") 32 .removeAttr("height") 33 .css("width","") 34 .css("height", ""); 35 36 if($(this).data("width") > width) { 37 $(this).css("width", "100%"); 38 } 39 } else { 40 $(this).attr("width", $(this).data("width")); 41 } 42 }); 43 } 44 45 $(window).on("load", function() { 46 image_resize(); 47 }); 48 49 $(window).on("resize", function() { 50 image_resize(); 51 }); 52 } 53 54 $.fn.viewimageresize2 = function(selector) 55 { 56 var cfg = { 57 selector: "img" 58 }; 59 60 if(typeof selector == "object") { 61 cfg = $.extend(cfg, selector); 62 } else { 63 if(selector) { 64 cfg = $.extend({ selector: selector }); 65 } 66 } 67 68 var $img = this.find(cfg.selector); 69 var $this = this; 70 71 function image_resize() 72 { 73 var width = $this.width(); 74 75 $img.each(function() { 76 $(this).removeAttr("width") 77 .removeAttr("height") 78 .css("width","") 79 .css("height", ""); 80 81 if($(this).data("width") == undefined) 82 $(this).data("width", $(this).width()); 83 84 if($(this).data("width") > width) { 85 $(this).css("width", "100%"); 86 } 87 }); 88 } 89 90 $(window).on("resize", function() { 91 image_resize(); 92 }); 93 94 image_resize(); 95 } 96}(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.