1/** 2 * -------------------------------------------------------------------- 3 * jQuery-Plugin "pngFix" 4 * Version: 1.1, 11.09.2007 5 * by Andreas Eberhard, [email protected] 6 * http://jquery.andreaseberhard.de/ 7 * 8 * Copyright (c) 2007 Andreas Eberhard 9 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php) 10 * 11 * Changelog: 12 * 11.09.2007 Version 1.1 13 * - removed noConflict 14 * - added png-support for input type=image 15 * - 01.08.2007 CSS background-image support extension added by Scott Jehl, [email protected], http://www.filamentgroup.com 16 * 31.05.2007 initial Version 1.0 17 * -------------------------------------------------------------------- 18 * @example $(function(){$(document).pngFix();}); 19 * @desc Fixes all PNG's in the document on document.ready 20 * 21 * jQuery(function(){jQuery(document).pngFix();}); 22 * @desc Fixes all PNG's in the document on document.ready when using noConflict 23 * 24 * @example $(function(){$('div.examples').pngFix();}); 25 * @desc Fixes all PNG's within div with class examples 26 * 27 * @example $(function(){$('div.examples').pngFix( { blankgif:'ext.gif' } );}); 28 * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png 29 * -------------------------------------------------------------------- 30 */ 31 32(function($) { 33 34jQuery.fn.pngFix = function(settings) { 35 36 // Settings 37 settings = jQuery.extend({ 38 blankgif: 'blank.gif' 39 }, settings); 40 41 var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1); 42 var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1); 43 44 if (jQuery.browser.msie && (ie55 || ie6)) { 45 46 //fix images with png-source 47 jQuery(this).find("img[@src$=.png]").each(function() { 48 49 jQuery(this).attr('width',jQuery(this).width()); 50 jQuery(this).attr('height',jQuery(this).height()); 51 52 var prevStyle = ''; 53 var strNewHTML = ''; 54 var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : ''; 55 var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : ''; 56 var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : ''; 57 var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : ''; 58 var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : ''; 59 var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : ''; 60 if (this.style.border) { 61 prevStyle += 'border:'+this.style.border+';'; 62 this.style.border = ''; 63 } 64 if (this.style.padding) { 65 prevStyle += 'padding:'+this.style.padding+';'; 66 this.style.padding = ''; 67 } 68 if (this.style.margin) { 69 prevStyle += 'margin:'+this.style.margin+';'; 70 this.style.margin = ''; 71 } 72 var imgStyle = (this.style.cssText); 73 74 strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt; 75 strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand; 76 strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'; 77 strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');'; 78 strNewHTML += imgStyle+'"></span>'; 79 if (prevStyle != ''){ 80 strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>'; 81 } 82 83 jQuery(this).hide(); 84 jQuery(this).after(strNewHTML); 85 86 }); 87 88 // fix css background pngs 89 jQuery(this).find("*").each(function(){ 90 var bgIMG = jQuery(this).css('background-image'); 91 if(bgIMG.indexOf(".png")!=-1){ 92 var iebg = bgIMG.split('url("')[1].split('")')[0]; 93 jQuery(this).css('background-image', 'none'); 94 jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')"; 95 } 96 }); 97 98 //fix input with png-source 99 jQuery(this).find("input[@src$=.png]").each(function() { 100 var bgIMG = jQuery(this).attr('src'); 101 jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(sr
101c=\'' + bgIMG + '\', sizingMethod=\'scale\');'; 102 jQuery(this).attr('src', settings.blankgif) 103 }); 104 105 } 106 107 return jQuery; 108 109}; 110 111})(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.