Browse Source

Retour d'iFixPng, mais sous forme de plugin.

svn/root/tags/plugins/msie_compat/1.0 v1.0
arno@rezo.net 13 years ago
commit
efb8562ed4
  1. 13
      .gitattributes
  2. 43
      action/configurer_iecompat.php
  3. 54
      configuration/ie6config.php
  4. BIN
      imgs/ie6-logo24.png
  5. BIN
      imgs/ie6-logo64.png
  6. 6
      javascript/IE7.js
  7. 6
      javascript/IE8.js
  8. 6
      javascript/IE9.js
  9. BIN
      javascript/blank.gif
  10. 45
      javascript/ie7-squish.js
  11. 137
      javascript/jquery.ifixpng.js
  12. 105
      msie_compat.php
  13. 43
      plugin.xml

13
.gitattributes vendored

@ -0,0 +1,13 @@
* text=auto !eol
action/configurer_iecompat.php -text
configuration/ie6config.php -text
imgs/ie6-logo24.png -text
imgs/ie6-logo64.png -text
javascript/IE7.js -text
javascript/IE8.js -text
javascript/IE9.js -text
javascript/blank.gif -text
javascript/ie7-squish.js -text
javascript/jquery.ifixpng.js -text
/msie_compat.php -text
/plugin.xml -text

43
action/configurer_iecompat.php

@ -0,0 +1,43 @@
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2010 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) return;
// Mise a jour de l'option de configuration $arg
// il faudrait limiter a arg plutot que d'executer tout modif_config
// on traite a part seulement le cas du proxy car c'est indispensable
// (message d'erreur eventuel a afficher)
include_spip('inc/config');
// http://doc.spip.org/@action_configurer_dist
function exec_configurer_iecompat() {
$securiser_action = charger_fonction('securiser_action', 'inc');
$arg = $securiser_action();
$r = rawurldecode(_request('redirect'));
$r = parametre_url($r, 'configuration', $arg,"&");
appliquer_modifs_config();
// Cette globale est fixee par appliquer_modifs_config();
// c'est un message a afficher dans l'exec de retour (relayeur si comme ici on est en ajax)
if ($arg == 'relayeur')
$r = parametre_url($r, 'retour_proxy', $GLOBALS['retour_proxy'],"&");
else if ($arg == 'langue') {
include_spip('inc/rubriques');
calculer_langues_rubriques();
}
if (_request('envoi_now')) cron(0, array('mail' => -1));
redirige_par_entete($r);
}
?>

54
configuration/ie6config.php

@ -0,0 +1,54 @@
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2010 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) return;
include_spip('inc/presentation');
include_spip('inc/config');
function configuration_ie6config()
{
$iecompat = $GLOBALS['meta']["iecompat"];
if (!$iecompat) $iecompat = "non";
$res = "<p>Cette configuration vous permet d&rsquo;am&eacute;liorer la compatibilit&eacute; du site public avec le navigateur Internet Explorer.</p>
<ul>
<li><a href='http://jquery.khurshid.com/ifixpng.php'>iFixPng</a> rétablit la semi-transparence les images au format PNG sous MSIE&nbsp;5&nbsp;et&nbsp;6.</li>
<li><a href='http://code.google.com/p/ie7-js/'>IE7.js</a> corrige les images PNG et ajoute des comportements de CSS2 pour MSIE&nbsp;5&nbsp;et&nbsp;6.</li>
<li>IE8.js complète IE7.js en enrichissant les comportements des CSS de MSIE 5 à&nbsp;7. </li>
<li>IE9.js complète les précédents en enrichissant MSIE&nbsp;5 à&nbsp;8.</li>
<li>IE7-squish corrige trois bugs de MSIE&nbsp;6 (notamment la double marge des éléments flottants), mais des effets indésirables peuvent apparaître (le webmestre doit vérifier la compatibilité).</li>
</ul>";
$res .= afficher_choix('iecompat', $iecompat,
array('non' => _L('Non: ne rien ajouter &agrave; mes squelettes'),
'ifixpng' => _L('iFixPng : activer l’affichage des PNG 24 (<b>recommandé</b>)'),
'IE7' => _L("IE7.js : affichages des PNG 24 et quelques comportements de styles"),
'IE7squish' => _L("IE7.js + ie7-squish.js : ajoute la correction des doubles marges sur les &eacute;l&eacute;ments flottants"),
'IE8' => _L('IE8.js'),
'IE8squish' => _L('IE8.js + ie7-squish.js'),
'IE9' => _L('IE9.js'),
'IE9squish' => _L('IE9.js + ie7-squish.js')
),
" <br /> ");
$res = debut_cadre_trait_couleur(find_in_path("imgs/ie6-logo24.png"), true, "", _L("Compatibilité Microsoft Internet Explorer"))
. ajax_action_post('configurer', 'ie6config', 'configuration','',$res)
. fin_cadre_trait_couleur(true);
return ajax_action_greffe('configurer-ie6config', '', $res);
}
?>

BIN
imgs/ie6-logo24.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
imgs/ie6-logo64.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

6
javascript/IE7.js

File diff suppressed because one or more lines are too long

6
javascript/IE8.js

File diff suppressed because one or more lines are too long

6
javascript/IE9.js

File diff suppressed because one or more lines are too long

BIN
javascript/blank.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 B

45
javascript/ie7-squish.js

@ -0,0 +1,45 @@
/*
IE7, version 0.9 (alpha) (2005-08-19)
Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
License: http://creativecommons.org/licenses/LGPL/2.1/
*/
IE7.addModule("ie7-squish", function() {
/* ---------------------------------------------------------------------
Squish some IE bugs!
Some of these bug fixes may have adverse effects so they are
not included in the standard library. Add your own if you want.
-dean
--------------------------------------------------------------------- */
// @NOTE: ie7Layout.boxSizing is the same as the "Holly Hack"
// "doubled margin" bug
// http://www.positioniseverything.net/explorer/doubled-margin.html
ie7CSS.addFix(/float\s*:\s*(left|right)/, "display:inline;$1");
if (ie7Layout) {
// "peekaboo" bug
// http://www.positioniseverything.net/explorer/peekaboo.html
if (appVersion >= 6) ie7CSS.addRecalc("float", "left|right", function($element) {
ie7Layout.boxSizing($element.parentElement);
// "doubled margin" bug
$element.runtimeStyle.display = "inline";
});
// "unscrollable content" bug
// http://www.positioniseverything.net/explorer/unscrollable.html
ie7CSS.addRecalc("position", "absolute|fixed", function($element) {
if ($element.offsetParent && $element.offsetParent.currentStyle.position == "relative")
ie7Layout.boxSizing($element.offsetParent);
});
}
//# // get rid of Microsoft's pesky image toolbar
//# if (!complete) document.write('<meta http-equiv="imagetoolbar" content="no">');
});

137
javascript/jquery.ifixpng.js

@ -0,0 +1,137 @@
/*
* jQuery ifixpng plugin
* (previously known as pngfix)
* Version 2.1 (23/04/2008)
* @requires jQuery v1.1.3 or above
*
* Examples at: http://jquery.khurshid.com
* Copyright (c) 2007 Kush M.
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
/**
*
* @example
*
* optional if location of pixel.gif if different to default which is images/pixel.gif
* $.ifixpng('media/pixel.gif');
*
* $('img[src$=.png], #panel').ifixpng();
*
* @apply hack to all png images and #panel which icluded png img in its css
*
* @name ifixpng
* @type jQuery
* @cat Plugins/Image
* @return jQuery
* @author jQuery Community
*/
(function($) {
/**
* helper variables and function
*/
$.ifixpng = function(customPixel) {
$.ifixpng.pixel = customPixel;
};
$.ifixpng.getPixel = function() {
return $.ifixpng.pixel || 'images/pixel.gif';
};
var hack = {
ltie7 : $.browser.msie && $.browser.version < 7,
filter : function(src) {
return "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='"+src+"')";
}
};
/**
* Applies ie png hack to selected dom elements
*
* $('img[src$=.png]').ifixpng();
* @desc apply hack to all images with png extensions
*
* $('#panel, img[src$=.png]').ifixpng();
* @desc apply hack to element #panel and all images with png extensions
*
* @name ifixpng
*/
$.fn.ifixpng = hack.ltie7 ? function() {
return this.each(function() {
var $$ = $(this);
// in case rewriting urls
var base = $('base').attr('href');
if (base) {
// remove anything after the last '/'
base = base.replace(/\/[^\/]+$/,'/');
}
if ($$.is('img') || $$.is('input')) { // hack image tags present in dom
if ($$.attr('src')) {
if ($$.attr('src').match(/.*\.png([?].*)?$/i)) { // make sure it is png image
// use source tag value if set
var source = (base && $$.attr('src').search(/^(\/|http:)/i)) ? base + $$.attr('src') : $$.attr('src');
// apply filter
$$.css({filter:hack.filter(source), width:$$.width(), height:$$.height()})
.attr({src:$.ifixpng.getPixel()})
.positionFix();
}
}
} else { // hack png css properties present inside css
var image = $$.css('backgroundImage');
if (image.match(/^url\(["']?(.*\.png([?].*)?)["']?\)$/i)) {
image = RegExp.$1;
image = (base && image.substring(0,1)!='/') ? base + image : image;
$$.css({backgroundImage:'none', filter:hack.filter(image)})
.children().children().positionFix();
}
}
});
} : function() { return this; };
/**
* Removes any png hack that may have been applied previously
*
* $('img[src$=.png]').iunfixpng();
* @desc revert hack on all images with png extensions
*
* $('#panel, img[src$=.png]').iunfixpng();
* @desc revert hack on element #panel and all images with png extensions
*
* @name iunfixpng
*/
$.fn.iunfixpng = hack.ltie7 ? function() {
return this.each(function() {
var $$ = $(this);
var src = $$.css('filter');
if (src.match(/src=["']?(.*\.png([?].*)?)["']?/i)) { // get img source from filter
src = RegExp.$1;
if ($$.is('img') || $$.is('input')) {
$$.attr({src:src}).css({filter:''});
} else {
$$.css({filter:'', background:'url('+src+')'});
}
}
});
} : function() { return this; };
/**
* positions selected item relatively
*/
$.fn.positionFix = function() {
return this.each(function() {
var $$ = $(this);
var position = $$.css('position');
if (position != 'absolute' && position != 'relative') {
$$.css({position:'relative'});
}
});
};
})(jQuery);

105
msie_compat.php

@ -0,0 +1,105 @@
<?php
function msie_compat_insert_head($flux) {
$iecompat = $GLOBALS['meta']["iecompat"];
if ($iecompat == "ifixpng") {
$flux .= "<!--[if lt IE 7]>
<script src='".find_in_path('javascript/jquery.ifixpng.js')."'></script>
<script type='text/javascript'><!--
jQuery.ifixpng('rien.gif');
function fixie() {
jQuery('img').ifixpng();
}
$(document).ready(function() { fixie(); });
onAjaxLoad(fixie);
--></script>
<![endif]-->
";
} else if ($iecompat == "IE7") {
$flux .= "<!--[if lt IE 7]>
<script type='text/javascript'><!--
var IE7_PNG_SUFFIX = '.png';
--></script>
<script src='".find_in_path('javascript/IE7.js')."'></script>
<![endif]-->
";
} else if ($iecompat == "IE7squish") {
$flux .= "<!--[if lt IE 7]>
<script type='text/javascript'><!--
var IE7_PNG_SUFFIX = '.png';
--></script>
<script src='".find_in_path('javascript/IE7.js')."'></script>
<script src='".find_in_path('javascript/ie7-squish.js')."'></script>
<![endif]-->
";
} else if ($iecompat == "IE8") {
$flux .= "<!--[if lt IE 8]>
<script type='text/javascript'><!--
var IE7_PNG_SUFFIX = '.png';
--></script>
<script src='".find_in_path('javascript/IE8.js')."'></script>
<![endif]-->
";
} else if ($iecompat == "IE8squish") {
$flux .= "<!--[if lt IE 8]>
<script type='text/javascript'><!--
var IE7_PNG_SUFFIX = '.png';
--></script>
<script src='".find_in_path('javascript/IE8.js')."'></script>
<script src='".find_in_path('javascript/ie7-squish.js')."'></script>
<![endif]-->
";
} else if ($iecompat == "IE9") {
$flux .= "<!--[if lt IE 9]>
<script type='text/javascript'><!--
var IE7_PNG_SUFFIX = '.png';
--></script>
<script src='".find_in_path('javascript/IE9.js')."'></script>
<![endif]-->
";
} else if ($iecompat == "IE9squish") {
$flux .= "<!--[if lt IE 9]>
<script type='text/javascript'><!--
var IE7_PNG_SUFFIX = '.png';
--></script>
<script src='".find_in_path('javascript/IE9.js')."'></script>
<script src='".find_in_path('javascript/ie7-squish.js')."'></script>
<![endif]-->
";
}
return $flux;
}
function msie_compat_affiche_milieu ($flux) {
if ($flux["args"]["exec"] == "config_fonctions") {
$configurer = charger_fonction('ie6config', 'configuration');
$flux["data"] .= $configurer();
}
return $flux;
}
function msie_compat_configurer_liste_metas ($metas) {
$metas['iecompat']='ifixpng';
return ($metas);
}
?>

43
plugin.xml

@ -0,0 +1,43 @@
<plugin>
<nom> <!-- Nom du plugin -->
Compatibilité MSIE 6
</nom>
<auteur> <!-- Auteur du plugin -->
[ARNO*->arno@rezo.net]
</auteur>
<version>
1.0
</version>
<etat>
stable
</etat>
<description>
</description>
<icon>imgs/ie6-logo64.png</icon>
<prefix>
msie_compat
</prefix>
<!-- Definitions des fonctions qui s'inserent dans les pipelines -->
<pipeline>
<nom>configurer_liste_metas</nom>
<inclure>msie_compat.php</inclure>
</pipeline>
<pipeline>
<nom>affiche_milieu</nom>
<inclure>msie_compat.php</inclure>
</pipeline>
<pipeline>
<nom>insert_head</nom>
<action>insert_head</action>
<inclure>msie_compat.php</inclure>
</pipeline>
<necessite id="SPIP" version="[2.1.0 dev;)" />
<!-- Le parametre action est facultatif : en son absence la methode de la classe portant le nom du pipeline est appelee. Le parametre inclure est facultatif. -->
</plugin>
Loading…
Cancel
Save