[Jifty-commit] r2661 - in jifty/trunk: lib/Jifty/View/Static share/web/static/images/iepngfix share/web/static/js

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Jan 27 06:12:55 EST 2007


Author: hlb
Date: Sat Jan 27 06:12:00 2007
New Revision: 2661

Added:
   jifty/trunk/share/web/static/images/iepngfix/
   jifty/trunk/share/web/static/images/iepngfix/blank.gif   (contents, props changed)
   jifty/trunk/share/web/static/js/iepngfix.htc
Modified:
   jifty/trunk/lib/Jifty/Manual/Cookbook.pod
   jifty/trunk/lib/Jifty/View/Static/Handler.pm

Log:
* include iepngfix 1.0
* add MIME type text/x-component for .htc file
* howto document for iepngfix


Modified: jifty/trunk/lib/Jifty/Manual/Cookbook.pod
==============================================================================
--- jifty/trunk/lib/Jifty/Manual/Cookbook.pod	(original)
+++ jifty/trunk/lib/Jifty/Manual/Cookbook.pod	Sat Jan 27 06:12:00 2007
@@ -303,3 +303,21 @@
 Take care the indentation is significant. Use spaces, not tabs.
 Once you have done that you can restart your Jifty application and the
 edit links should then function correctly.
+
+=head2 Use iepngfix.htc to add PNG support in IE5.5+
+
+Jifty has included iepngfix.htc by Angus Turnbull. The HTC file will
+automatically add PNG support to IMG elements and also supports any
+element with a "background-image" CSS property.
+
+If you want to use this fix, please include this one line in your CSS
+file, whit tag names to which you want the script applied:
+
+    img, div { behavior: url(/static/js/iepngfix.htc) }
+
+Alternatively, you can specify that this will apply to all tags like so:
+
+    * { behavior: url(/static/js/iepngfix.htc) }
+
+Check details from Angus himself. ( http://www.twinhelix.com/ )
+

Modified: jifty/trunk/lib/Jifty/View/Static/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Static/Handler.pm	(original)
+++ jifty/trunk/lib/Jifty/View/Static/Handler.pm	Sat Jan 27 06:12:00 2007
@@ -154,6 +154,7 @@
         # chokes on ajax-fetched JS that has a type other than the one below
         # JSAN.js fetches JS via Ajax when it loads JSAN modules
         'js' => 'application/x-javascript',
+        'htc' => 'text/x-component',
     );
 
     return ($type_override{$1})

Added: jifty/trunk/share/web/static/images/iepngfix/blank.gif
==============================================================================
Binary file. No diff available.

Added: jifty/trunk/share/web/static/js/iepngfix.htc
==============================================================================
--- (empty file)
+++ jifty/trunk/share/web/static/js/iepngfix.htc	Sat Jan 27 06:12:00 2007
@@ -0,0 +1,55 @@
+<public:component>
+<public:attach event="onpropertychange" onevent="doFix()" />
+
+<script>
+
+// IE5.5+ PNG Alpha Fix v1.0 by Angus Turnbull http://www.twinhelix.com
+// Free usage permitted as long as this notice remains intact.
+
+// This must be a path to a blank image. That's all the configuration you need here.
+
+/*
+  USAGE: 
+  All you have to do is include this one line in your CSS file, with the
+  tag names to which you want the script applied:
+
+  img, div { behavior: url(iepngfix.htc) }
+
+  Alternatively, you can specify that this will apply to all tags like so:
+
+  * { behavior: url(iepngfix.htc) }
+*/
+
+var blankImg = '/static/images/iepngfix/blank.gif';
+
+var f = 'DXImageTransform.Microsoft.AlphaImageLoader';
+
+function filt(s, m) {
+ if (filters[f]) {
+  filters[f].enabled = s ? true : false;
+  if (s) with (filters[f]) { src = s; sizingMethod = m }
+ } else if (s) style.filter = 'progid:'+f+'(src="'+s+'",sizingMethod="'+m+'")';
+}
+
+function doFix() {
+ if ((parseFloat(navigator.userAgent.match(/MSIE (\S+)/)[1]) < 5.5) ||
+  (event && !/(background|src)/.test(event.propertyName))) return;
+
+ if (tagName == 'IMG') {
+  if ((/\.png$/i).test(src)) {
+   filt(src, 'image');  // was 'scale'
+   src = blankImg;
+  } else if (src.indexOf(blankImg) < 0) filt();
+ } else if (style.backgroundImage) {
+  if (style.backgroundImage.match(/^url[("']+(.*\.png)[)"']+$/i)) {
+   var s = RegExp.$1;
+   style.backgroundImage = '';
+   filt(s, 'crop');
+  } else filt();
+ }
+}
+
+doFix();
+
+</script>
+</public:component>


More information about the Jifty-commit mailing list