| 1 |
|
/** |
| 2 |
|
* -------------------------------------------------------------------- |
| 3 |
|
* jQuery-Plugin "pngFix" |
| 4 |
|
* by Andreas Eberhard, andreas.eberhard@gmail.com |
| 5 |
|
* http://jquery.andreaseberhard.de/ |
| 6 |
|
* |
| 7 |
|
* Copyright (c) 2007 Andreas Eberhard |
| 8 |
|
* Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php) |
| 9 |
|
* |
| 10 |
|
* Version: 1.0, 31.05.2007 |
| 11 |
|
* Changelog: |
| 12 |
|
* 31.05.2007 initial Version 1.0 |
| 13 |
|
* -------------------------------------------------------------------- |
| 14 |
|
*/ |
| 15 |
|
|
| 16 |
|
(function(jQuery) { |
| 17 |
|
|
| 18 |
|
|
| 19 |
|
jQuery.fn.pngFix = function() { |
| 20 |
|
|
| 21 |
|
var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1); |
| 22 |
|
var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1); |
| 23 |
|
|
| 24 |
|
if (jQuery.browser.msie && (ie55 || ie6)) { |
| 25 |
|
|
| 26 |
|
jQuery(this).find("img[@src$=.png]").each(function() { |
| 27 |
|
|
| 28 |
|
var prevStyle = ''; |
| 29 |
|
var strNewHTML = ''; |
| 30 |
|
var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : ''; |
| 31 |
|
var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : ''; |
| 32 |
|
var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : ''; |
| 33 |
|
var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : ''; |
| 34 |
|
var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : ''; |
| 35 |
|
var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : ''; |
| 36 |
|
if (this.style.border) { |
| 37 |
|
prevStyle += 'border:'+this.style.border+';'; |
| 38 |
|
this.style.border = ''; |
| 39 |
|
} |
| 40 |
|
if (this.style.padding) { |
| 41 |
|
prevStyle += 'padding:'+this.style.padding+';'; |
| 42 |
|
this.style.padding = ''; |
| 43 |
|
} |
| 44 |
|
if (this.style.margin) { |
| 45 |
|
prevStyle += 'margin:'+this.style.margin+';'; |
| 46 |
|
this.style.margin = ''; |
| 47 |
|
} |
| 48 |
|
var imgStyle = (this.style.cssText); |
| 49 |
|
|
| 50 |
|
strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt; |
| 51 |
|
strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand; |
| 52 |
|
strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'; |
| 53 |
|
strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');'; |
| 54 |
|
strNewHTML += imgStyle+'"></span>'; |
| 55 |
|
if (prevStyle != ''){ |
| 56 |
|
strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>'; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
jQuery(this).hide(); |
| 60 |
|
jQuery(this).after(strNewHTML); |
| 61 |
|
|
| 62 |
|
}); |
| 63 |
|
|
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
}; |
| 67 |
|
|
| 68 |
|
})(jQuery); |