/[drupal]/contributions/themes/colorpaper/pngfix.js
ViewVC logotype

Contents of /contributions/themes/colorpaper/pngfix.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Sun Dec 21 06:16:28 2008 UTC (11 months ago) by ktleow
Branch: MAIN
CVS Tags: DRUPAL-6--2-0-BETA1, DRUPAL-6--2-0-BETA2, DRUPAL-6--2-0-BETA3, DRUPAL-6--2-0-BETA4, HEAD
File MIME type: text/javascript
New version of Color Paper, a lot of changes. Now compatible with IE6.
1 /**
2 * --------------------------------------------------------------------
3 * jQuery-Plugin "pngFix"
4 * Version: 1.1, 11.09.2007
5 * by Andreas Eberhard, andreas.eberhard@gmail.com
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
12 (function($) {
13
14 jQuery.fn.pngFix = function(settings) {
15
16 // Settings
17 settings = jQuery.extend({
18 blankgif: 'blank.gif'
19 }, settings);
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 //fix images with png-source
27 jQuery(this).find("img[@src$=.png]").each(function() {
28
29 jQuery(this).attr('width',jQuery(this).width());
30 jQuery(this).attr('height',jQuery(this).height());
31
32 var prevStyle = '';
33 var strNewHTML = '';
34 var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
35 var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
36 var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
37 var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
38 var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
39 var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
40 if (this.style.border) {
41 prevStyle += 'border:'+this.style.border+';';
42 this.style.border = '';
43 }
44 if (this.style.padding) {
45 prevStyle += 'padding:'+this.style.padding+';';
46 this.style.padding = '';
47 }
48 if (this.style.margin) {
49 prevStyle += 'margin:'+this.style.margin+';';
50 this.style.margin = '';
51 }
52 var imgStyle = (this.style.cssText);
53
54 strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
55 strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
56 strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
57 strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
58 strNewHTML += imgStyle+'"></span>';
59 if (prevStyle != ''){
60 strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
61 }
62
63 jQuery(this).hide();
64 jQuery(this).after(strNewHTML);
65
66 });
67
68 // fix css background pngs
69 jQuery(this).find("*").each(function(){
70 var bgIMG = jQuery(this).css('background-image');
71 if(bgIMG.indexOf(".png")!=-1){
72 var iebg = bgIMG.split('url("')[1].split('")')[0];
73 jQuery(this).css('background-image', 'none');
74 jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
75 }
76 });
77
78 //fix input with png-source
79 jQuery(this).find("input[@src$=.png]").each(function() {
80 var bgIMG = jQuery(this).attr('src');
81 jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
82 jQuery(this).attr('src', settings.blankgif)
83 });
84
85 }
86
87 return jQuery;
88
89 };
90
91 })(jQuery);

  ViewVC Help
Powered by ViewVC 1.1.2