From 6cfd80e8581e675d11b975ae3b94d3a517063457 Mon Sep 17 00:00:00 2001
From: Mike Gifford <mike@openconcept.ca>
Date: Mon, 14 Mar 2011 10:49:22 -0400
Subject: [PATCH] Issue #1003346 by slashrsm & mgifford

---
 jquery.pngFix.js      |  224 +++++++++++++++++++++++++------------------------
 jquery.pngFix.pack.js |   11 +++
 pngfix.admin.inc      |   13 +++-
 pngfix.info           |    2 +-
 pngfix.install        |   16 +++-
 pngfix.module         |   35 +++++---
 6 files changed, 172 insertions(+), 129 deletions(-)
 create mode 100644 jquery.pngFix.pack.js

diff --git a/jquery.pngFix.js b/jquery.pngFix.js
index 9dc4edb..6adfcc9 100644
--- a/jquery.pngFix.js
+++ b/jquery.pngFix.js
@@ -1,111 +1,113 @@
-/**
- * --------------------------------------------------------------------
- * jQuery-Plugin "pngFix"
- * Version: 1.1, 11.09.2007
- * 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:
- *    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 += '<span '+imgId+imgClass+imgTitle+imgAlt;
-			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
-			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
-			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
-			strNewHTML += imgStyle+'"></span>';
-			if (prevStyle != ''){
-				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
-			}
-
-			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);
+/**
+ * --------------------------------------------------------------------
+ * 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 += '<span '+imgId+imgClass+imgTitle+imgAlt;
+			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
+			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
+			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
+			strNewHTML += imgStyle+'"></span>';
+			if (prevStyle != ''){
+				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
+			}
+
+			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);
diff --git a/jquery.pngFix.pack.js b/jquery.pngFix.pack.js
new file mode 100644
index 0000000..ef4c0c0
--- /dev/null
+++ b/jquery.pngFix.pack.js
@@ -0,0 +1,11 @@
+/**
+ * --------------------------------------------------------------------
+ * jQuery-Plugin "pngFix"
+ * Version: 1.1, 11.09.2007
+ * 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)
+ */
+eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([237-9n-zA-Z]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(s(m){3.fn.pngFix=s(c){c=3.extend({P:\'blank.gif\'},c);8 e=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 5.5")!=-1);8 f=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 6.0")!=-1);p(3.browser.msie&&(e||f)){3(2).B("img[n$=.C]").D(s(){3(2).7(\'q\',3(2).q());3(2).7(\'r\',3(2).r());8 a=\'\';8 b=\'\';8 g=(3(2).7(\'E\'))?\'E="\'+3(2).7(\'E\')+\'" \':\'\';8 h=(3(2).7(\'F\'))?\'F="\'+3(2).7(\'F\')+\'" \':\'\';8 i=(3(2).7(\'G\'))?\'G="\'+3(2).7(\'G\')+\'" \':\'\';8 j=(3(2).7(\'H\'))?\'H="\'+3(2).7(\'H\')+\'" \':\'\';8 k=(3(2).7(\'V\'))?\'float:\'+3(2).7(\'V\')+\';\':\'\';8 d=(3(2).parent().7(\'href\'))?\'cursor:hand;\':\'\';p(2.9.v){a+=\'v:\'+2.9.v+\';\';2.9.v=\'\'}p(2.9.w){a+=\'w:\'+2.9.w+\';\';2.9.w=\'\'}p(2.9.x){a+=\'x:\'+2.9.x+\';\';2.9.x=\'\'}8 l=(2.9.cssText);b+=\'<y \'+g+h+i+j;b+=\'9="W:X;white-space:pre-line;Y:Z-10;I:transparent;\'+k+d;b+=\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;\';b+=\'J:K:L.t.M(n=\\\'\'+3(2).7(\'n\')+\'\\\', N=\\\'O\\\');\';b+=l+\'"></y>\';p(a!=\'\'){b=\'<y 9="W:X;Y:Z-10;\'+a+d+\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;">\'+b+\'</y>\'}3(2).hide();3(2).after(b)});3(2).B("*").D(s(){8 a=3(2).11(\'I-12\');p(a.A(".C")!=-1){8 b=a.13(\'url("\')[1].13(\'")\')[0];3(2).11(\'I-12\',\'none\');3(2).14(0).15.J="K:L.t.M(n=\'"+b+"\',N=\'O\')"}});3(2).B("input[n$=.C]").D(s(){8 a=3(2).7(\'n\');3(2).14(0).15.J=\'K:L.t.M(n=\\\'\'+a+\'\\\', N=\\\'O\\\');\';3(2).7(\'n\',c.P)})}return 3}})(3);',[],68,'||this|jQuery||||attr|var|style||||||||||||||src|navigator|if|width|height|function|Microsoft|appVersion|border|padding|margin|span|px|indexOf|find|png|each|id|class|title|alt|background|filter|progid|DXImageTransform|AlphaImageLoader|sizingMethod|scale|blankgif|appName|Internet|Explorer|parseInt|MSIE|align|position|relative|display|inline|block|css|image|split|get|runtimeStyle'.split('|'),0,{}))
\ No newline at end of file
diff --git a/pngfix.admin.inc b/pngfix.admin.inc
index 3909ee5..5613138 100644
--- a/pngfix.admin.inc
+++ b/pngfix.admin.inc
@@ -4,10 +4,10 @@
  * @file
  * Provides the administration page for PNG Fix.
  */
-  
+
 /**
  * Administration settings page
- */ 
+ */
 function pngfix_admin() {
   $form = array();
   $form['pngfix_css_classes'] = array(
@@ -16,5 +16,14 @@ function pngfix_admin() {
     '#default_value' => variable_get('pngfix_css_classes', ''),
     '#description' => t('Comma seperated list of CSS classes to apply the PNG Fix to (use <a href="@jqueryselector">jQuery Selectors</a>).  The CSS class must be for the element that surrounds the image, and not for the image itself.  In the case of <code>&lt;div class="pngfix"&gt;&lt;img ... /&gt;&lt;/div&gt;</code>, use .pngfix to apply the PNG Fix to the image.', array('@jqueryselector' => 'http://docs.jquery.com/Selectors')),
   );
+
+  $form['pngfix_packed_js'] = array(
+    '#type' => 'radios',
+    '#title' => t('Enable packed version'),
+    '#default_value' => variable_get('pngfix_packed_js', 0),
+    '#description' => t("When enabled packed version of pngFix will be used."),
+    '#options' => array(t('Disabled'), t('Enabled')),
+  );
+
   return system_settings_form($form);
 } // function pngfix_admin
diff --git a/pngfix.info b/pngfix.info
index 638bd42..1601ede 100644
--- a/pngfix.info
+++ b/pngfix.info
@@ -1,3 +1,3 @@
 name = PNG Fix
 description = "Includes a fix to correctly handle PNG transparency in Windows IE 5.5 & 6."
-core = 6.x
+core = 7.x
diff --git a/pngfix.install b/pngfix.install
index e95b740..436b4de 100644
--- a/pngfix.install
+++ b/pngfix.install
@@ -1,9 +1,21 @@
 <?php
 
 /**
- * Implementation of hook_uninstall()
- *
+ * @file
+ * Module's installation hooks.
+ */
+
+/**
+ * Implements hook_install().
+ */
+function hook_install() {
+  variable_set('pngfix_packed_js', 0);
+}
+
+/**
+ * Implements hook_uninstall().
  */
 function pngfix_uninstall() {
   variable_del('pngfix_css_classes');
+  variable_del('pngfix_packed_js');
 }
diff --git a/pngfix.module b/pngfix.module
index 635db56..291bf1b 100644
--- a/pngfix.module
+++ b/pngfix.module
@@ -1,38 +1,47 @@
 <?php
 
 /**
-* Implementation of hook_help
-*/
+ * Implements hook_help().
+ */
 function pngfix_help($path = '', $arg = NULL) {
   $output = '';
   switch ($path) {
     case 'admin/help#pngfix':
-    case 'admin/settings/pngfix':
-      $output = '<p>'.  t("Includes a fix to correctly handle PNG transparency in Windows IE 5.5 & 6."). '</p>';
+    case 'admin/config/development/pngfix':
+      $output = '<p>' . t("Includes a fix to correctly handle PNG transparency in Windows IE 5.5 & 6.") . '</p>';
       break;
   }
   return $output;
 } // function pngfix_help
 
 /**
- * Implementation of hook_init
- */ 
+ * Implements hook_init().
+ */
 function pngfix_init() {
   $pngfixclasses = variable_get('pngfix_css_classes', '');
+  $library = variable_get('pngfix_packed_js', 0) ? 'jquery.pngFix.pack.js' : 'jquery.pngFix.js';
   if (!empty($pngfixclasses)) {
-    $jquerypngfixjs = drupal_get_path('module', 'pngfix') .'/jquery.pngFix.js';
-    drupal_add_js($jquerypngfixjs, 'module');
-    $js = "Drupal.behaviors.pngfix = function(){ $('$pngfixclasses').pngFix(); };";
-    drupal_add_js($js, 'inline');
+    $jquerypngfixjs = drupal_get_path('module', 'pngfix') . '/' . $library;
+    drupal_add_js($jquerypngfixjs);
+    $js = "(function ($) {
+
+              Drupal.behaviors.pngfix = {
+                attach: function(context, settings) {
+                  $('$pngfixclasses').pngFix();
+                }
+              };
+
+            })(jQuery);";
+    drupal_add_js($js, array('type' => 'inline', 'scope' => 'footer'));
   }
 } // function pngfix_init
 
 /**
- * Implementation of hook_menu
- */ 
+ * Implements hook_menu().
+ */
 function pngfix_menu() {
   $items = array();
-  $items['admin/settings/pngfix'] = array(
+  $items['admin/config/development/pngfix'] = array(
     'title' => 'PNG Fix',
     'description' => 'Configure how the PNG Fix operates.',
     'access arguments' => array('administer site configuration'),
-- 
1.5.6.5

