/** * -------------------------------------------------------------------- * jquery-plugin "pngfix" * version: 1.2, 09.03.2009 * by andreas eberhard, andreas.eberhard@gmail.com * http://jquery.andreaseberhard.de/ * * copyright (c) 2007 andreas eberhard * licensed under gpl (http://www.opensource.org/licenses/gpl-license.php) * * changelog: * 09.03.2009 version 1.2 * - update for jquery 1.3.x, removed @ from selectors * 11.09.2007 version 1.1 * - removed noconflict * - added png-support for input type=image * - 01.08.2007 css background-image support extension added by scott jehl, scott@filamentgroup.com, http://www.filamentgroup.com * 31.05.2007 initial version 1.0 * -------------------------------------------------------------------- * @example $(function(){$(document).pngfix();}); * @desc fixes all png's in the document on document.ready * * jquery(function(){jquery(document).pngfix();}); * @desc fixes all png's in the document on document.ready when using noconflict * * @example $(function(){$('div.examples').pngfix();}); * @desc fixes all png's within div with class examples * * @example $(function(){$('div.examples').pngfix( { blankgif:'ext.gif' } );}); * @desc fixes all png's within div with class examples, provides blank gif for input with png * -------------------------------------------------------------------- */ (function($) { jquery.fn.pngfix = function(settings) { // settings settings = jquery.extend({ blankgif: 'blank.gif' }, settings); var ie55 = (navigator.appname == "microsoft internet explorer" && parseint(navigator.appversion) == 4 && navigator.appversion.indexof("msie 5.5") != -1); var ie6 = (navigator.appname == "microsoft internet explorer" && parseint(navigator.appversion) == 4 && navigator.appversion.indexof("msie 6.0") != -1); if (jquery.browser.msie && (ie55 || ie6)) { //fix images with png-source jquery(this).find("img[src$=.png]").each(function() { jquery(this).attr('width',jquery(this).width()); jquery(this).attr('height',jquery(this).height()); var prevstyle = ''; var strnewhtml = ''; var imgid = (jquery(this).attr('id')) ? 'id="' + jquery(this).attr('id') + '" ' : ''; var imgclass = (jquery(this).attr('class')) ? 'class="' + jquery(this).attr('class') + '" ' : ''; var imgtitle = (jquery(this).attr('title')) ? 'title="' + jquery(this).attr('title') + '" ' : ''; var imgalt = (jquery(this).attr('alt')) ? 'alt="' + jquery(this).attr('alt') + '" ' : ''; var imgalign = (jquery(this).attr('align')) ? 'float:' + jquery(this).attr('align') + ';' : ''; var imghand = (jquery(this).parent().attr('href')) ? 'cursor:hand;' : ''; if (this.style.border) { prevstyle += 'border:'+this.style.border+';'; this.style.border = ''; } if (this.style.padding) { prevstyle += 'padding:'+this.style.padding+';'; this.style.padding = ''; } if (this.style.margin) { prevstyle += 'margin:'+this.style.margin+';'; this.style.margin = ''; } var imgstyle = (this.style.csstext); strnewhtml += ''; if (prevstyle != ''){ strnewhtml = '' + strnewhtml + ''; } jquery(this).hide(); jquery(this).after(strnewhtml); }); // fix css background pngs jquery(this).find("*").each(function(){ var bgimg = jquery(this).css('background-image'); if(bgimg.indexof(".png")!=-1){ var iebg = bgimg.split('url("')[1].split('")')[0]; jquery(this).css('background-image', 'none'); jquery(this).get(0).runtimestyle.filter = "progid:dximagetransform.microsoft.alphaimageloader(src='" + iebg + "',sizingmethod='scale')"; } }); //fix input with png-source jquery(this).find("input[src$=.png]").each(function() { var bgimg = jquery(this).attr('src'); jquery(this).get(0).runtimestyle.filter = 'progid:dximagetransform.microsoft.alphaimageloader' + '(src=\'' + bgimg + '\', sizingmethod=\'scale\');'; jquery(this).attr('src', settings.blankgif) }); } return jquery; }; })(jquery);