<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>piouPiouM&#039;s dev</title>
	<atom:link href="http://pioupioum.fr/feed/" rel="self" type="application/rss+xml" />
	<link>http://pioupioum.fr</link>
	<description>Bloc-note d&#039;un développeur web</description>
	<lastBuildDate>Thu, 11 Mar 2010 17:12:33 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Optimiser le chargement des AdSense</title>
		<link>http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html</link>
		<comments>http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html#comments</comments>
		<pubDate>Thu, 11 Mar 2010 16:48:57 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Développement Web]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[optimiser]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=357</guid>
		<description><![CDATA[Il n&#8217;y a rien de plus horripilant que d&#8217;attendre que des publicités chargent pour accéder au contenu d&#8217;un article. C&#8217;est malheureusement une situation que l&#8217;on rencontre fréquemment. La faute en incombe au fonctionnement des blocs AdSense des publicitaires.

En effet, ils nécessitent que nous insérerions le code correspondant à un bloc à l&#8217;endroit où il sera [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Il n&#8217;y a rien de plus horripilant que d&#8217;attendre que des publicités chargent pour accéder au contenu d&#8217;un article. C&#8217;est malheureusement une situation que l&#8217;on rencontre fréquemment. La faute en incombe au fonctionnement des blocs <strong>AdSense</strong> des publicitaires.</p>

<p>En effet, ils nécessitent que nous insérerions le code correspondant à un bloc à l&#8217;endroit où il sera affiché. Cela pour deux raisons notamment&#160;:</p>

<ol>
<li>Des variables globales identifiants l&#8217;annonce sont déclarées.</li>
<li>Le script qui va charger l&#8217;annonce est immédiatement exécuté et fait appel à des actions d&#8217;écriture dans le flux <em>via</em> <a href="https://developer.mozilla.org/fr/DOM/document.write">write</a>.</li>
</ol>

<p>Le deuxième point oblige le navigateur à traiter le code de l&#8217;adsense dès qu&#8217;il le rencontre puisque ce dernier n&#8217;utilise pas de gestionnaire de chargement. En plus d&#8217;écrire dans le flux courant, le système du publicitaire va charger des éléments extérieurs. Pour peu que la latence des réponses soit élevée, l&#8217;impression de <strong>ralentissement du chargement de la page</strong> augmente.</p>

<p>S&#8217;est ainsi que si un article est précédé d&#8217;un encart publicitaire, l&#8217;utilisateur devra patiemment attendre le chargement de ce dernier avant de pouvoir accéder au contenu désiré.<br />
L&#8217;expérience utilisateur s&#8217;en trouve dégradée.</p>

<h2>En finir avec les ralentissements de chargement des pages</h2>

<p>Vous l&#8217;aurez peut-être remarqué, mais sur <a href="http://pioupioum.fr/" title="piouPiouM&#8217;s dev : bloc-note d&#8217;un développeur web. PHP, git, shell, plugins WordPress, SPIP, jQuery">piouPiouM&#8217;s dev</a>, le <strong>chargement des blocs publicitaires</strong> est comme <strong>temporisé</strong>, ne gênant ainsi en rien la navigation sur le site.<br />
Voyons dans la suite du billet comment y parvenir, en prenant pour exemple le service <a href="https://www.google.com/adsense/">Google Adsense</a>.
<span id="more-357"></span></p>

<h2 id="integration-maquette">Intégration dans une maquette</h2>

<p>On commence par définir les emplacements des encarts publicitaires. Cela vous permet ainsi d&#8217;intégrer les annonces dans vos maquettes <abbr title="Hyper Text Markup Language">HTML</abbr>, tout en vous assurant que cette apparence sera conservée pour les utilisateurs n&#8217;ayant pas JavaScript d&#8217;activé, ou qui bloquent les annonces publicitaires.<br />
Je prend ici le parti d&#8217;annoncer la couleur, en précisant la mention <em>Publicité</em>.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ads-[ads_id]&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ads [ads_format]&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    Publicité
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>


<p>En sommes, il s&#8217;agit d&#8217;un simple élément <code>&lt;div&gt;</code> ayant pour attributs&#160;:</p>

<ul>
<li>un identifiant <strong>[ads_id]</strong>&#160;: un identifiant unique qui va servir de point d&#8217;ancrage au contenu de l&#8217;adsense. Vous pouvez par exemple, dans le cas de Google Adsense, utiliser le nom du critère personnalisé en notation CamelCase.</li>
<li>une classe <strong>ads</strong>&#160;: le style des encarts de pub lorsque celles-ci sont en attente de chargement.</li>
<li>une classe <strong>[ads_format]</strong>&#160;: le format de l&#8217;encart publicitaire. Par exemple, <code>square250</code> pour une annonce de 250px de côtés ou encore <code>banner468</code> pour une bannière au format 468 x 60.</li>
</ul>

<p>Appliquez les styles <abbr title="Cascading Style Sheets">CSS</abbr> qui suivent.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* @group Tools */</span>
&nbsp;
<span style="color: #6666ff;">.hide</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* @end   Tools */</span>
<span style="color: #808080; font-style: italic;">/* @group Adsense */</span>
&nbsp;
<span style="color: #6666ff;">.ads</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#F4F4F4</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#666666</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">11px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-transform</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">uppercase</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.square250</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.banner468</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">60px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">60px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">468px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* @end   Adsense */</span></pre></td></tr></table></div>


<h2 id="ads-code-annonceur">Insertion du code de l&#8217;annonceur</h2>

<p>Insérez en fin de page les différents codes donnés par votre annonceur (ici, Google Adsense).</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;hide&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #808080; font-style: italic;">&lt;!-- Ads --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;adsref-[ads_id]&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
google_ad_client = &quot;pub-[client_id]&quot;;
google_ad_slot   = &quot;[slot_id]&quot;;
google_ad_width  = 250;
google_ad_height = 250;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>


<p><strong>Chaque annonce</strong> est incluse dans un élément ayant pour identifiant <code>adsref-[ads_id]</code> (voir <a href="#integration-maquette">Intégration de la maquette</a>) qui fait le lien avec l&#8217;emplacement final de la publicité.</p>

<p>Le tout étant masqué à l&#8217;aide d&#8217;un <code>div.hide</code>. Il serait en effet désagréable d&#8217;afficher les annonces publicitaires en bas de page, même si ce n&#8217;est que pour une poignée de [micro]secondes.</p>

<h2 id="jquery-ads-loader">Un Adsense Loader avec jQuery</h2>

<p>Il ne reste plus qu&#8217;à déplacer à l&#8217;aide de JavaScript les blocs AdSense aux endroits souhaités. Avec <a href="http://pioupioum.fr/tag/jquery/" title="Archives pour le tag jQuery – piouPiouM&#039;s dev">jQuery</a> cela donne&#160;:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> $ads<span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div[id^=&quot;adsref-&quot;]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>          <span style="color: #006600; font-style: italic;">// pour chaque bloc d'annonce #adsref-[ads_id]</span>
        $ads <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#ads-'</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">id</span>.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">7</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// supprimer de #ads-[ads_id] tout éventuel contenu</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ins:first'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span>$ads<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>           <span style="color: #006600; font-style: italic;">// déplacer l'annonce dans #ads-[ads_id]</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<p>Bien évidemment, et comme vous êtes sensible aux bonnes pratiques liées à la <a href="http://performance.survol.fr/" title="Performance web">performance web</a>, vous insérerez naturellement ce code en fin de page <img src='http://pioupioum.fr/wp/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/jquery-color-plugin-animation-rgba-support.html' title='Du RGBA dans vos animations avec le plugin jQuery Color'>Du RGBA dans vos animations avec le plugin jQuery Color</a></li><li><a href='http://pioupioum.fr/developpement/javascript-detecter-support-rgba.html' title='JavaScript : tester le support des couleurs RGBA'>JavaScript&#160;: tester le support des couleurs RGBA</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html' title='WordPress : autoriser l&#8217;upload de fichiers au format non-supporté'>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</a></li><li><a href='http://pioupioum.fr/snippets/apache-rotation-logs.html' title='Rotation des logs Apache'>Rotation des logs Apache</a></li><li><a href='http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html' title='WordPress jQuery UI Effects'>WordPress jQuery UI Effects</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP&#160;: convertir un DATETIME en un timestamp UNIX</title>
		<link>http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html</link>
		<comments>http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html#comments</comments>
		<pubDate>Tue, 09 Mar 2010 23:28:01 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[convertir]]></category>
		<category><![CDATA[licence MIT]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=346</guid>
		<description><![CDATA[Mise à jour à 10:57
Plus simple, rapide, intégré, toussa&#160;: utiliser strtotime tout simplement.
Merci à Éric Daspet et à Oncle Tom pour le rappel.

Une fonction utilitaire1 pour convertir une chaîne de type DATETIME ou DATE en un timestamp UNIX.
Les formats pris en charges en entrée sont AAAA-MM-JJ HH:MM:SS et AA-MM-JJ HH:MM:SS. L&#8217;heure étant optionnelle dans le [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p><strong>Mise à jour à 10:57</strong><br />
Plus simple, rapide, intégré, toussa&#160;: utiliser <a href="http://php.net/manual/fr/function.strtotime.php">strtotime</a> tout simplement.<br />
Merci à <a href="http://twitter.com/edasfr/status/10264669320" title="réaction sur twitter">Éric Daspet</a> et à <a href="http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html#comment-1187" title="réaction dans les commentaires">Oncle Tom</a> pour le rappel.</p>

<p>Une fonction utilitaire<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> pour convertir une chaîne de type <strong>DATETIME</strong> ou <strong>DATE</strong> en un <strong>timestamp UNIX</strong>.<br />
Les formats pris en charges en entrée sont <code>AAAA-MM-JJ HH:MM:SS</code> et <code>AA-MM-JJ HH:MM:SS</code>. L&#8217;heure étant optionnelle dans le cas de la conversion d&#8217;une date.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Get UNIX timestamp for a date or date time.
 *
 * Example:
 * &lt;code&gt;
 * &lt;?php
 * unix_timestamp('2010-03-09 22:43:46'); # 1268171026
 * unix_timestamp('10-03-09 22:43:46');   # 1268171026
 * unix_timestamp('2010-03-09');          # 1268089200
 * ?&gt;
 * &lt;/code&gt;
 *
 * @author    Mehdi Kabab &lt;http://pioupioum.fr/&gt;
 * @copyright 2010 Mehdi Kabab
 * @license   http://www.opensource.org/licenses/mit-license.html MIT License
 * @link      http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html
 *
 * @param string The date or datetime to convert.
 * @return int The UNIX timestamp corresponding to the datetime.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> unix_timestamp<span style="color: #009900;">&#40;</span><span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">':'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$c</span>    <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$c</span>    <span style="color: #339933;">=</span> <span style="color: #990000;">array_pad</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">array_walk</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'intval'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html' title='PHP : fonction uncamel() pour inverser une notation en CamelCase'>PHP&#160;: fonction uncamel() pour inverser une notation en CamelCase</a></li><li><a href='http://pioupioum.fr/snippets/bash-convertir-string-to-integer.html' title='Bash : convertir un string en entier'>Bash&#160;: convertir un string en entier</a></li><li><a href='http://pioupioum.fr/snippets/php-valider-url-domaine.html' title='PHP : valider qu&#8217;une URL pointe sur un domaine donné'>PHP&#160;: valider qu&#8217;une URL pointe sur un domaine donné</a></li><li><a href='http://pioupioum.fr/developpement/phing-header-task.html' title='Phing Header : une tâche pour ajouter un en-tête aux fichiers'>Phing Header&#160;: une tâche pour ajouter un en-tête aux fichiers</a></li><li><a href='http://pioupioum.fr/developpement/php-spl-supprimer-repertoire-recursif.html' title='PHP : supprimer récursivement un répertoire'>PHP&#160;: supprimer récursivement un répertoire</a></li></ul>

<div class="footnotes">
<hr />
<h4>Notes</h4>
<ol>

<li id="fn:1">
<p>vous allez dire qu&#8217;il en existe pléthore, mais je les trouve toutes trop lourdes (conditions, strlen, multiples explode, etc) pour le peu à faire. Sans parler du fait qu&#8217;elles ne supportent uniquement que le format DATETIME.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Bash&#160;: convertir un string en entier</title>
		<link>http://pioupioum.fr/snippets/bash-convertir-string-to-integer.html</link>
		<comments>http://pioupioum.fr/snippets/bash-convertir-string-to-integer.html#comments</comments>
		<pubDate>Sat, 06 Mar 2010 19:06:25 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[convertir]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=340</guid>
		<description><![CDATA[Bash n&#8217;offre pas de fonction pour convertir une chaîne de caractères ou un nombre flottant en un entier.
Cela n&#8217;est toute fois pas impossible, il suffit de faire appel à printf1 et le tour est joué&#160;!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
# string_to_int.sh - Shell script to convert a string or float number
# to an integer.
&#160;
function string_to_int &#40;&#41;
&#123;
    [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p><a href="http://fr.wikipedia.org/wiki/Bourne-Again_shell" title="Bourne-Again shell - Wikipédia">Bash</a> n&#8217;offre pas de fonction pour convertir une chaîne de caractères ou un nombre flottant en un entier.<br />
Cela n&#8217;est toute fois pas impossible, il suffit de faire appel à <code>printf</code><sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> et le tour est joué&#160;!</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/env bash</span>
<span style="color: #666666; font-style: italic;"># string_to_int.sh - Shell script to convert a string or float number</span>
<span style="color: #666666; font-style: italic;"># to an integer.</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> string_to_int <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #007800;">LANG</span>=C
    <span style="color: #007800;">d</span>=<span style="color: #800000;">${1##*.}</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${#1}</span> <span style="color: #660033;">-eq</span> <span style="color: #800000;">${#d}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">d</span>=<span style="color: #000000;">0</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #007800;">e</span>=<span style="color: #800000;">${1%.*}</span>
    <span style="color: #007800;">e</span>=<span style="color: #800000;">${e//,/}</span>
    <span style="color: #7a0874; font-weight: bold;">printf</span> <span style="color: #000000; font-weight: bold;">%</span>.0f <span style="color: #ff0000;">&quot;<span style="color: #007800;">$e</span>.<span style="color: #007800;">$d</span>&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #007800;">not_int</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;12.652&quot;</span> <span style="color: #ff0000;">&quot;-12.652&quot;</span> <span style="color: #000000;">12.652</span> <span style="color: #000000;">14</span> <span style="color: #ff0000;">&quot;12,652&quot;</span> foo <span style="color: #ff0000;">&quot;1,254.8&quot;</span> <span style="color: #000000;">1</span>,<span style="color: #000000;">254.8</span> <span style="color: #ff0000;">&quot;125,160,254.8&quot;</span> <span style="color: #ff0000;">&quot;125,160,254&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> value <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${not_int[@]}</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Convert <span style="color: #007800;">$value</span> to int: <span style="color: #007800;">$(string_to_int $value)</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>


<p>Ce qui nous donne&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ .<span style="color: #000000; font-weight: bold;">/</span>string_to_int.sh 
Convert <span style="color: #000000;">12.652</span> to int: <span style="color: #000000;">13</span>
Convert -<span style="color: #000000;">12.652</span> to int: <span style="color: #660033;">-13</span>
Convert <span style="color: #000000;">12.652</span> to int: <span style="color: #000000;">13</span>
Convert <span style="color: #000000;">14</span> to int: <span style="color: #000000;">14</span>
Convert <span style="color: #000000;">12</span>,<span style="color: #000000;">652</span> to int: <span style="color: #000000;">12652</span>
Convert foo to int: <span style="color: #000000;">0</span>
Convert <span style="color: #000000;">1</span>,<span style="color: #000000;">254.8</span> to int: <span style="color: #000000;">1255</span>
Convert <span style="color: #000000;">1</span>,<span style="color: #000000;">254.8</span> to int: <span style="color: #000000;">1255</span>
Convert <span style="color: #000000;">125</span>,<span style="color: #000000;">160</span>,<span style="color: #000000;">254.8</span> to int: <span style="color: #000000;">125160255</span>
Convert <span style="color: #000000;">125</span>,<span style="color: #000000;">160</span>,<span style="color: #000000;">254</span> to int: <span style="color: #000000;">125160254</span></pre></div></div>


<p>Voir <a href="http://gist.github.com/324313">sur Github</a>.</p>

<p><strong>Mis à jour le 7 mars 2010</strong><br />
Prise en charge de la notation US. Merci à <a href="http://pioupioum.fr/snippets/bash-convertir-string-to-integer.html#comment-1159">patpro</a>.</p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html' title='PHP : convertir un DATETIME en un timestamp UNIX'>PHP&#160;: convertir un DATETIME en un timestamp UNIX</a></li><li><a href='http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html' title='PHP : fonction uncamel() pour inverser une notation en CamelCase'>PHP&#160;: fonction uncamel() pour inverser une notation en CamelCase</a></li><li><a href='http://pioupioum.fr/snippets/convertir-icone-icns-png.html' title='Convertir une icône ICNS en une image PNG'>Convertir une icône ICNS en une image PNG</a></li><li><a href='http://pioupioum.fr/snippets/leopard-rechercher-nom-reel-utilisateur.html' title='Rechercher le nom réel d&#8217;un utilisateur sous Leopard'>Rechercher le nom réel d&#8217;un utilisateur sous Leopard</a></li></ul>

<div class="footnotes">
<hr />
<h4>Notes</h4>
<ol>

<li id="fn:1">
<p>une substitution du séparateur des décimals <code>.</code> en <code>,</code> est nécessaire avant de faire appel à <code>printf</code>.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/bash-convertir-string-to-integer.html/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP&#160;: fonction uncamel() pour inverser une notation en CamelCase</title>
		<link>http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html</link>
		<comments>http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html#comments</comments>
		<pubDate>Sun, 28 Feb 2010 18:17:12 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[convertir]]></category>
		<category><![CDATA[gist]]></category>
		<category><![CDATA[licence MIT]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=336</guid>
		<description><![CDATA[Une fonction PHP utilitaire pour convertir une chaîne en notation CamelCase en mots réunis par un séparateur (par défaut, le caractère underscore _).

La fonction uncamel() supporte indifféremment, en entrée, les notations lowerCamelCase et UpperCamelCase.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
&#60;?php
/**
 * Reverse a CamelCase string.
 *
 * Examples:
 *     uncamel('lowerCamelCase') === 'lower_camel_case'
 *     [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Une fonction <strong><a href="http://fr.wikipedia.org/wiki/PHP" title="PHP: Hypertext Preprocessor - Wikipédia">PHP</a></strong> utilitaire pour convertir une chaîne en notation <strong><a href="http://fr.wikipedia.org/wiki/CamelCase" title="CamelCase - Wikipédia">CamelCase</a></strong> en mots réunis par un séparateur (par défaut, le caractère <em>underscore</em> <code>_</code>).</p>

<p>La fonction <strong><code>uncamel()</code></strong> supporte indifféremment, en entrée, les notations <strong>lowerCamelCase</strong> et <strong>UpperCamelCase</strong>.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Reverse a CamelCase string.
 *
 * Examples:
 *     uncamel('lowerCamelCase') === 'lower_camel_case'
 *     uncamel('UpperCamelCase') === 'upper_camel_case'
 *     uncamel('ThisIsAString') === 'this_is_a_string'
 *     uncamel('notcamelcase') === 'notcamelcase'
 *     uncamel('lowerCamelCase', ' | ') === 'lower | camel | case'
 *
 * @author    Mehdi Kabab &lt;http://pioupioum.fr/&gt;
 * @copyright 2010 Mehdi Kabab
 * @license   http://www.opensource.org/licenses/mit-license.html MIT License
 * @link      http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html
 *
 * @param  string $content The CamelCase string.
 * @param  string $separator The glue for the compound words. Defaults to '_'.
 * @return string
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> uncamel<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$separator</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'_'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#(?&lt;=[a-zA-Z])([A-Z])(?=[a-zA-Z])#e'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;'<span style="color: #006699; font-weight: bold;">$separator</span>' . strtolower('<span style="color: #006699; font-weight: bold;">$1</span>')&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$content</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<p>Le <a href="http://gist.github.com/317702" title="gist: 317702 -  GitHub">forker (gist)</a>.</p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/snippets/php-convertir-datetime-unix-timestamp.html' title='PHP : convertir un DATETIME en un timestamp UNIX'>PHP&#160;: convertir un DATETIME en un timestamp UNIX</a></li><li><a href='http://pioupioum.fr/snippets/bash-convertir-string-to-integer.html' title='Bash : convertir un string en entier'>Bash&#160;: convertir un string en entier</a></li><li><a href='http://pioupioum.fr/snippets/php-valider-url-domaine.html' title='PHP : valider qu&#8217;une URL pointe sur un domaine donné'>PHP&#160;: valider qu&#8217;une URL pointe sur un domaine donné</a></li><li><a href='http://pioupioum.fr/developpement/phing-header-task.html' title='Phing Header : une tâche pour ajouter un en-tête aux fichiers'>Phing Header&#160;: une tâche pour ajouter un en-tête aux fichiers</a></li><li><a href='http://pioupioum.fr/developpement/php-spl-supprimer-repertoire-recursif.html' title='PHP : supprimer récursivement un répertoire'>PHP&#160;: supprimer récursivement un répertoire</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/php-uncamel-fonction-convertir-camel-case.html/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Du RGBA dans vos animations avec le plugin jQuery Color</title>
		<link>http://pioupioum.fr/developpement/jquery-color-plugin-animation-rgba-support.html</link>
		<comments>http://pioupioum.fr/developpement/jquery-color-plugin-animation-rgba-support.html#comments</comments>
		<pubDate>Sat, 20 Feb 2010 14:13:32 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Développement Web]]></category>
		<category><![CDATA[couleur]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[feature]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[rgba]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=332</guid>
		<description><![CDATA[J&#8217;ai récemment eu à (ré)utiliser le plugin jQuery Color mais je me suis heurté à une limitation. Je travaillais sur un jeu de couleurs RGBA et malheureusement le plugin ne supportait pas ce mode colorimétrique (il se contente de travailler sur des couleurs RGB).

Qu&#8217;à cela ne tienne, en attendant que ma modification soit intégrée1 au [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>J&#8217;ai récemment eu à (ré)utiliser le plugin <a href="http://plugins.jquery.com/project/color" title="Plugins Color Animations | jQuery Plugins">jQuery Color</a> mais je me suis heurté à une limitation. Je travaillais sur un jeu de couleurs RGBA et malheureusement le plugin ne supportait pas ce mode colorimétrique (il se contente de travailler sur des couleurs RGB).</p>

<p>Qu&#8217;à cela ne tienne, en attendant que <a href="http://github.com/piouPiouM/jquery-color/commit/92ee455320d7e32e0bccdd09166087c1ba5555e2" title="Voir le commit sur mon fork GitHub">ma modification</a> soit intégrée<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> au plugin, voici une version de <strong>jQuery Color</strong> pourvu du <strong><a href="http://pioupioum.fr/developpement/javascript-detecter-support-rgba.html" title="JavaScript : tester le support des couleurs RGBA &#8211; DOM, jQuery CSS3 RGBA &#8211; piouPiouM&#039;s dev">support des couleurs RGBA</a></strong>&#160;:</p>

<div class="box file-js">
    <a href="http://static.pioupioum.fr/code/jquery.color.js" title="Télécharger"><span>jquery.color.js (6&#160;Ko)</span></a>
</div>

<p>La <a href="http://pioupioum.fr/sandbox/jquery-color/" title="RBGA support for jQuery Color – jQuery Color test page – piouPiouM’s dev">page de démonstration</a> qui va bien.</p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/javascript-detecter-support-rgba.html' title='JavaScript : tester le support des couleurs RGBA'>JavaScript&#160;: tester le support des couleurs RGBA</a></li><li><a href='http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html' title='WordPress jQuery UI Effects'>WordPress jQuery UI Effects</a></li><li><a href='http://pioupioum.fr/outils-astuces/supprimer-neige-scripts-greasemonkey.html' title='Supprimer les effets de neige avec Greasemonkey'>Supprimer les effets de neige avec Greasemonkey</a></li><li><a href='http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html' title='Optimiser le chargement des AdSense'>Optimiser le chargement des AdSense</a></li><li><a href='http://pioupioum.fr/plugins-spip/google-tools-1-0-1.html' title='SPIP Google Tools 1.0.1'>SPIP Google Tools 1.0.1</a></li></ul>

<div class="footnotes">
<hr />
<h4>Notes</h4>
<ol>

<li id="fn:1">
<p>enfin, je l&#8217;espère :]&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/developpement/jquery-color-plugin-animation-rgba-support.html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaScript&#160;: tester le support des couleurs RGBA</title>
		<link>http://pioupioum.fr/developpement/javascript-detecter-support-rgba.html</link>
		<comments>http://pioupioum.fr/developpement/javascript-detecter-support-rgba.html#comments</comments>
		<pubDate>Sun, 14 Feb 2010 22:09:31 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Développement Web]]></category>
		<category><![CDATA[couleur]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[rgba]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=322</guid>
		<description><![CDATA[CSS3 introduit le support des couleurs en mode RGBA. Ce dernier permet de définir une valeur d&#8217;alpha à une couleur RGB. Voici comment détecter via JavaScript si un navigteur supporte la fonctionnalité1.

Comment détecter qu&#8217;un navigateur supporte RGBA&#160;?

Le principe est simple&#160;:


Atteindre le premier élément script2 du document.
Mémoriser sa couleur de police (ou de fond).
Tester si la [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>CSS3 introduit le support des <strong>couleurs en mode RGBA</strong>. Ce dernier permet de définir une valeur d&#8217;alpha à une couleur RGB. Voici comment <strong>détecter <em>via</em> JavaScript</strong> si un navigteur supporte la fonctionnalité<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>.</p>

<h2>Comment détecter qu&#8217;un navigateur supporte <strong>RGBA</strong>&#160;?</h2>

<p>Le principe est simple&#160;:</p>

<ol>
<li>Atteindre le premier élément <code>script</code><sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup> du document.</li>
<li>Mémoriser sa couleur de police (ou de fond).</li>
<li>Tester si la couleur n&#8217;est pas déjà en RGBA.</li>
<li>Oui&#160;? Sauter à 7. Non&#160;? Modifier la couleur de l&#8217;élément script en <code>rgba(0, 0, 0, 0.5)</code>. Si le navigateur ne supporte pas le mode de couleur RGBA, l&#8217;action n&#8217;aura aucun effet.</li>
<li>Tester la non correspondance de la couleur initiale et de la nouvelle.</li>
<li>Réinitialiser la couleur de l&#8217;élément script.</li>
<li>Retourner le résultat du test.
<span id="more-322"></span></li>
</ol>

<h2>Tester le support de RGBA <em>via</em> le <strong>DOM</strong></h2>

<p>L&#8217;implémentation DOM de l&#8217;algorithme n&#8217;a rien de complexe. Cependant, pour éviter de réitérer les manipulations DOM en cas de tests multiples, on assigne à la fonction une propriété <code>result</code> à l&#8217;aide de <a href="https://developer.mozilla.org/fr/Référence_de_JavaScript_1.5_Core/Fonctions/arguments/callee">arguments.callee</a>.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/**
 * Check whether the browser supports RGBA color mode.
 *
 * @author Mehdi Kabab &lt;http://pioupioum.fr&gt;
 * @type Boolean
 * @return True if the browser support RGBA. False otherwise.
 */</span>
<span style="color: #003366; font-weight: bold;">function</span> isRGBACapable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'result'</span> <span style="color: #000066; font-weight: bold;">in</span> arguments.<span style="color: #660066;">callee</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> dScript <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
            color   <span style="color: #339933;">=</span> dScript.<span style="color: #660066;">style</span>.<span style="color: #660066;">color</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^rgba/</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>color<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            arguments.<span style="color: #660066;">callee</span>.<span style="color: #660066;">result</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                dScript.<span style="color: #660066;">style</span>.<span style="color: #660066;">color</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'rgba(0, 0, 0, 0.5)'</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
            arguments.<span style="color: #660066;">callee</span>.<span style="color: #660066;">result</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>dScript.<span style="color: #660066;">style</span>.<span style="color: #660066;">color</span> <span style="color: #339933;">!=</span> color<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            dScript.<span style="color: #660066;">style</span>.<span style="color: #660066;">color</span>     <span style="color: #339933;">=</span>  color<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> arguments.<span style="color: #660066;">callee</span>.<span style="color: #660066;">result</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<h2>Tester le support de RGBA <em>via</em> <strong>jQuery</strong></h2>

<p>Avec jQuery, il peut être utile d&#8217;initialiser une proprité <code>jQuery.support.rgba</code> pour éviter de lancer le test à de multiples reprises.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rgba'</span> <span style="color: #000066; font-weight: bold;">in</span> jQuery.<span style="color: #660066;">support</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    jQuery.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>jQuery.<span style="color: #660066;">support</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">'rgba'</span><span style="color: #339933;">:</span> isRGBACapable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/**
 * Check whether the browser supports RGBA color mode.
 *
 * @author Mehdi Kabab &lt;http://pioupioum.fr&gt;
 * @type Boolean
 * @return True if the browser support RGBA. False otherwise.
 */</span>
<span style="color: #003366; font-weight: bold;">function</span> isRGBACapable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> $script <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script:first'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        color   <span style="color: #339933;">=</span> $script.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'color'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        result  <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^rgba/</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>color<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            result <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            result <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> color <span style="color: #339933;">!=</span> $script.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'color'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'rgba(0, 0, 0, 0.5)'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'color'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            $script.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'color'</span><span style="color: #339933;">,</span> color<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> result<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/jquery-color-plugin-animation-rgba-support.html' title='Du RGBA dans vos animations avec le plugin jQuery Color'>Du RGBA dans vos animations avec le plugin jQuery Color</a></li><li><a href='http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html' title='WordPress jQuery UI Effects'>WordPress jQuery UI Effects</a></li><li><a href='http://pioupioum.fr/outils-astuces/supprimer-neige-scripts-greasemonkey.html' title='Supprimer les effets de neige avec Greasemonkey'>Supprimer les effets de neige avec Greasemonkey</a></li><li><a href='http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html' title='Optimiser le chargement des AdSense'>Optimiser le chargement des AdSense</a></li><li><a href='http://pioupioum.fr/snippets/javascript-regex-capture-html-balise-contenu.html' title='Capturer les balises HTML et leur contenu avec une RegExp sous JavaScript'>Capturer les balises HTML et leur contenu avec une RegExp sous JavaScript</a></li></ul>

<div class="footnotes">
<hr />
<h4>Notes</h4>
<ol>

<li id="fn:1">
<p>toute autre propriété CSS3 peut être testée sur le même modèle, comme <a href="http://www.css3.info/preview/hsla/" title="HSLA Colors - CSS3 . Info">HSLA</a> ou encore <a href="http://www.css3.info/preview/box-shadow/" title="Box-shadow, one of CSS3&#8217;s best new features - CSS3 . Info">box-shadow</a>.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>nous utilisons JavaScript, il est naturel de trouver au moins un élément <code>script</code>.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/developpement/javascript-detecter-support-rgba.html/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</title>
		<link>http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html</link>
		<comments>http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html#comments</comments>
		<pubDate>Tue, 09 Feb 2010 14:50:30 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[upload]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=316</guid>
		<description><![CDATA[WordPress ne supporte en upload qu&#8217;une liste exhaustive de formats de fichiers. Si comme moi vous souhaitez uploader1 des fichiers issus de TextMate, comme les .tmCommand et autres .tmSnippet, ajoutez le code qui suit dans le fichier functions.php de votre thème2.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
&#60;?php
// Add the new filter
add_filter&#40;'upload_mimes', 'addUploadMimes'&#41;;
&#160;
/**
 * Adds new supported media types for upload.
 *
 [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>WordPress ne supporte en upload qu&#8217;une liste exhaustive de formats de fichiers. Si comme moi vous souhaitez uploader<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> des fichiers issus de <a href="http://macromates.com/" title="TextMate — The Missing Editor for Mac OS X">TextMate</a>, comme les <code>.tmCommand</code> et autres <code>.tmSnippet</code>, ajoutez le code qui suit dans le fichier <code>functions.php</code> de votre thème<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Add the new filter</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload_mimes'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'addUploadMimes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Adds new supported media types for upload.
 *
 * @see wp_check_filetype() or get_allowed_mime_types()
 * @param array $mimes Array of mime types keyed by the file extension regex corresponding to those types.
 * @return array
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> addUploadMimes<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mimes</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$mimes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mimes</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'tmbundle|tmCommand|tmDragCommand|tmSnippet|tmLanguage|tmPreferences'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'application/octet-stream'</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$mimes</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<p>Indiquez en clé les nouvelles extensions de fichier (séparées par des <em>pipes</em>) et en valeur le type mime associé.</p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/outils-astuces/wordpress-recuperation-avancee-images-article.html' title='WordPress : récupération avancée des images d&#8217;un article'>WordPress&#160;: récupération avancée des images d&#8217;un article</a></li><li><a href='http://pioupioum.fr/outils-astuces/afficher-images-article-page-media.html' title='WordPress : lister les images d&#8217;un article sur une page media'>WordPress&#160;: lister les images d&#8217;un article sur une page media</a></li><li><a href='http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html' title='Optimiser le chargement des AdSense'>Optimiser le chargement des AdSense</a></li><li><a href='http://pioupioum.fr/snippets/apache-rotation-logs.html' title='Rotation des logs Apache'>Rotation des logs Apache</a></li><li><a href='http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html' title='WordPress jQuery UI Effects'>WordPress jQuery UI Effects</a></li></ul>

<div class="footnotes">
<hr />
<h4>Notes</h4>
<ol>

<li id="fn:1">
<p>sous Mac OS X tout du moins, <a href="http://swfupload.org/" title="SWFUpload News | SWFUpload">SWFUpload</a> me désactive la sélection des fichiers de TextMate m&#8217;obligeant à passer par l&#8217;interface d&#8217;upload native du navigateur. Je suis preneur de toute solution.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>à choisir, l&#8217;ajouter dans un plugin serait plus judicieux puisque cette fonctionnalité ne dépend pas du thème.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git ignore pour un projet Flex Builder</title>
		<link>http://pioupioum.fr/snippets/git-ignore-projet-flex-builder.html</link>
		<comments>http://pioupioum.fr/snippets/git-ignore-projet-flex-builder.html#comments</comments>
		<pubDate>Fri, 22 Jan 2010 07:57:41 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=311</guid>
		<description><![CDATA[Contenu type d&#8217;un fichier .gitignore pour un projet Flex Builder&#160;:

bin-debug
html-template
.actionScriptProperties
.flexProperties
.project
.settings
.DS_Store


Continuez votre lecture sur des sujets similaires

Git&#160;: des alias pour aller plus viteGit&#160;: 10 commandes utiles
]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Contenu type d&#8217;un fichier <code>.gitignore</code> pour un projet <strong>Flex Builder</strong>&#160;:</p>

<pre><code>bin-debug
html-template
.actionScriptProperties
.flexProperties
.project
.settings
.DS_Store
</code></pre>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/git-alias-productivite.html' title='Git : des alias pour aller plus vite'>Git&#160;: des alias pour aller plus vite</a></li><li><a href='http://pioupioum.fr/developpement/git-10-commandes-utiles.html' title='Git : 10 commandes utiles'>Git&#160;: 10 commandes utiles</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/git-ignore-projet-flex-builder.html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rotation des logs Apache</title>
		<link>http://pioupioum.fr/snippets/apache-rotation-logs.html</link>
		<comments>http://pioupioum.fr/snippets/apache-rotation-logs.html#comments</comments>
		<pubDate>Wed, 20 Jan 2010 09:14:46 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=306</guid>
		<description><![CDATA[Effectuer une rotation de ses logs Apache chaque semaine à l&#8217;aide de rotatelogs&#160;:

CustomLog "&#124;/usr/sbin/rotatelogs /var/log/www/mondomaine.tld/mondomaine.tld-access_log 604800" "combined"


Notez le pipe au début d&#8217;argument qui permet la redirection du logfile vers rotatelogs.
Merci à patpro pour l&#8217;astuce.

Continuez votre lecture sur des sujets similaires

Optimiser le chargement des AdSenseWordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supportéGit&#160;: des alias pour aller [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Effectuer une <strong>rotation de ses logs Apache</strong> chaque semaine à l&#8217;aide de <strong><a href="http://httpd.apache.org/docs/2.0/programs/rotatelogs.html" title="rotatelogs - Piped logging program to rotate Apache logs - Apache HTTP Server">rotatelogs</a></strong>&#160;:</p>

<pre><code>CustomLog "|/usr/sbin/rotatelogs /var/log/www/mondomaine.tld/mondomaine.tld-access_log 604800" "combined"
</code></pre>

<p>Notez le <em>pipe</em> au début d&#8217;argument qui permet la redirection du logfile vers rotatelogs.<br />
Merci à <a href="http://www.patpro.net/" title="Je pensais qu'il était avec vous... | patpro.net">patpro</a> pour l&#8217;astuce.</p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html' title='Optimiser le chargement des AdSense'>Optimiser le chargement des AdSense</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html' title='WordPress : autoriser l&#8217;upload de fichiers au format non-supporté'>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</a></li><li><a href='http://pioupioum.fr/developpement/git-alias-productivite.html' title='Git : des alias pour aller plus vite'>Git&#160;: des alias pour aller plus vite</a></li><li><a href='http://pioupioum.fr/developpement/git-10-commandes-utiles.html' title='Git : 10 commandes utiles'>Git&#160;: 10 commandes utiles</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/apache-rotation-logs.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress jQuery UI Effects</title>
		<link>http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html</link>
		<comments>http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html#comments</comments>
		<pubDate>Wed, 06 Jan 2010 01:37:10 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Plugins WordPress]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[projet]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=301</guid>
		<description><![CDATA[WordPress jQuery UI Effects est un plugin pour WordPress permettant d&#8217;enregistrer et de charger les composants JavaScript de la librairie jQuery UI Effects.

Ce ne sont pas moins de 14 effets que vous pourrez utiliser dans vos développement de plugins ou dans la personnalisation de vos thèmes&#160;: Blind, Clip, Drop, Explode, Fold, Puff, Slide, Scale, Bounce, [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p><strong>WordPress jQuery UI Effects</strong> est un <strong>plugin</strong> pour <strong><a href="http://wordpress.org/" title="WordPress &#8250; Blog Tool and Publishing Platform">WordPress</a></strong> permettant d&#8217;enregistrer et de charger les composants JavaScript de la librairie <strong><a href="http://docs.jquery.com/UI/Effects/" title="UI/Effects - jQuery JavaScript Library">jQuery UI Effects</a></strong>.</p>

<p>Ce ne sont pas moins de 14 effets que vous pourrez utiliser dans vos développement de plugins ou dans la personnalisation de vos thèmes&#160;: <a href="http://docs.jquery.com/UI/Effects/Blind" title="UI/Effects/Blind - jQuery JavaScript Library">Blind</a>, <a href="http://docs.jquery.com/UI/Effects/Clip" title="UI/Effects/Clip - jQuery JavaScript Library">Clip</a>, <a href="http://docs.jquery.com/UI/Effects/Drop" title="UI/Effects/Drop - jQuery JavaScript Library">Drop</a>, <a href="http://docs.jquery.com/UI/Effects/Explode" title="UI/Effects/Explode - jQuery JavaScript Library">Explode</a>, <a href="http://docs.jquery.com/UI/Effects/Fold" title="UI/Effects/Fold - jQuery JavaScript Library">Fold</a>, <a href="http://docs.jquery.com/UI/Effects/Puff" title="UI/Effects/Puff - jQuery JavaScript Library">Puff</a>, <a href="http://docs.jquery.com/UI/Effects/Slide" title="UI/Effects/Slide - jQuery JavaScript Library">Slide</a>, <a href="http://docs.jquery.com/UI/Effects/Scale" title="UI/Effects/Scale - jQuery JavaScript Library">Scale</a>, <a href="http://docs.jquery.com/UI/Effects/Bounce" title="UI/Effects/Bounce - jQuery JavaScript Library">Bounce</a>, <a href="http://docs.jquery.com/UI/Effects/Highlight" title="UI/Effects/Highlight - jQuery JavaScript Library">Highlight</a>, <a href="http://docs.jquery.com/UI/Effects/Pulsate" title="UI/Effects/Pulsate - jQuery JavaScript Library">Pulsate</a>, <a href="http://docs.jquery.com/UI/Effects/Shake" title="UI/Effects/Shake - jQuery JavaScript Library">Shake</a>, <a href="http://docs.jquery.com/UI/Effects/Size" title="UI/Effects/Size - jQuery JavaScript Library">Size</a> et <a href="http://docs.jquery.com/UI/Effects/Transfer" title="UI/Effects/Transfer - jQuery JavaScript Library">Transfer</a>.</p>

<p><span id="more-301"></span></p>

<h2 id="toc">Table des matières</h2>

<ol>
<li><a href="#telecharger">Téléchargement</a></li>
<li><a href="#installer">Installation</a></li>
<li><a href="#faq">Foire aux questions</a>

<ol>
<li><a href="#usage">Comment utiliser ce plugin&#160;?</a></li>
<li><a href="#charger-dependance">Comment déclarer un script dépendant de l&#8217;effet jQuery UI Effect Highlight&#160;?</a></li>
<li><a href="#liste-gestionnaires">Comment trouver la liste des gestionnaires disponibles&#160;?</a></li>
<li><a href="#non-dependant-jquery-ui">La librairie jQuery UI est-elle nécessaire au fonctionnement de jQuery UI Effects&#160;?</a></li>
</ol></li>
<li><a href="#developpement">Développement</a></li>
<li><a href="#changelog">Historique des versions</a></li>
</ol>

<h2 id="telecharger">Téléchargement</h2>

<div class="download box">
    <a href="http://downloads.wordpress.org/plugin/wordpress-jquery-ui-effects.1.0.0.zip" title="Téléchargement depuis les serveurs de WordPress.org"><span>Télécharger la dernière version du plugin WordPress jQuery UI Effects</span></a>
</div>

<p>Vous pouvez également vous rendre sur la <a href="http://wordpress.org/extend/plugins/wordpress-jquery-ui-effects/" title="WordPress &#8250; WordPress jQuery UI Effects &laquo; WordPress Plugins">page WordPress.org du plugin</a> ou lancer son téléchargement et installation directement depuis l&#8217;interface d&#8217;administration de votre WordPress.</p>

<h2 id="installer">Installation</h2>

<p><strong>WordPress jQuery UI Effects</strong> s&#8217;installe en 3 étapes&#160;:</p>

<ol>
<li>Téléversez le répertoire <code>wp-jquery-ui-effects</code> et son contenu dans votre répertoire <code>/wp-content/plugins/</code>.</li>
<li>Activez le plugin <code>WordPress jQuery UI Effects</code> <em>via</em> le menu <em>Extensions</em> du panel d&#8217;administration de WordPress.</li>
<li>C&#8217;est tout <img src='http://pioupioum.fr/wp/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ol>

<h2 id="faq">Foire aux questions</h2>

<h3 id="usage">Comment utiliser ce plugin&#160;?</h3>

<p>Pour charger l&#8217;effet <strong>Bounce</strong> dans votre thème ou un plugin, utilisez la méthode <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" title="Function Reference/wp enqueue script &laquo; WordPress Codex">wp_enqueue_script</a>&#160;:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> my_init_method<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery-ui-effects-bounce'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_init_method'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<p>WordPress chargera<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> l&#8217;effet <em>jQuery UI Effects Bounce</em> et, si besoin est, ses dépendances&#160;: <em>jQuery</em> et <em>jQuery UI Effects Core</em>.</p>

<h3 id="charger-dependance">Comment déclarer un script dépendant de l&#8217;effet jQuery UI Effect Highlight&#160;?</h3>

<p>Déclarez et chargez en toute simplicité un nouveau script dépendant de jQuery UI Effect Highlight&#160;:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
wp_enqueue_script<span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'my-script'</span><span style="color: #339933;">,</span>
    get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_url'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'raw'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/js/my-script.js'</span><span style="color: #339933;">,</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery-ui-effects-highlight'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'1.0'</span><span style="color: #339933;">,</span>
    <span style="color: #009900; font-weight: bold;">true</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<h3 id="liste-gestionnaires">Comment trouver la liste des gestionnaires disponibles&#160;?</h3>

<p>Préfixez le nom de l&#8217;effet voulu par <code>jquery-ui-effects-</code> pour obtenir le nom du gestionnaire associé<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>. Attention, le nom du gestionnaire doit être en minuscules.</p>

<p>Par exemple, chargez l&#8217;effet <strong>Shake</strong> soit&#160;:</p>

<ul>
<li>avec le gestionnaire <code>jquery-ui-effects-shake</code>&#160;;</li>
<li>en utilisant la méthode statique <code>WPjQueryUIEffects::getHandle('shake')</code>.</li>
</ul>

<h3 id="non-dependant-jquery-ui">La librairie jQuery UI est-elle nécessaire au fonctionnement de jQuery UI Effects&#160;?</h3>

<p>Non. Vous n&#8217;avez donc pas à charger le gestionnaire <code>jquery-ui-core</code> (fichier <code>ui.core.js</code>) en tant que dépendance d&#8217;un quelconque effet pour que ce dernier fonctionne.</p>

<h3 id="version">Quelle est la version de jQuery UI Effects utilisé&#160;?</h3>

<p>Le <strong>plugin</strong> utilise <strong>jQuery UI Effects</strong> dans sa version <code>1.7.2</code>.<br />
Il nécessite également jQuery <code>1.3+</code>, disponible depuis WordPress 2.8.</p>

<h2 id="developpement">Développement</h2>

<p>Distribué sous licence <a href="http://fr.wikipedia.org/wiki/Licence_publique_générale_GNU">GNU/GLP</a>, le <a href="http://github.com/piouPiouM/wordpress-jquery-ui-effects" title="piouPiouM's wordpress-jquery-ui-effects at master - GitHub">code source du plugin</a> est accessible sur GitHub.</p>

<p>Une suggestion, une amélioration, une critique ou un bug à me soumettre&#160;? Ça se passe du côté du <a href="http://github.com/piouPiouM/wordpress-jquery-ui-effects/issues" title="Issues - piouPiouM/wordpress-jquery-ui-effects - GitHub">bugtracker</a> <img src='http://pioupioum.fr/wp/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<h2 id="changelog">Historique des versions</h2>

<h3>1.0.0</h3>

<ul>
<li>Version initiale.</li>
</ul>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/jquery-color-plugin-animation-rgba-support.html' title='Du RGBA dans vos animations avec le plugin jQuery Color'>Du RGBA dans vos animations avec le plugin jQuery Color</a></li><li><a href='http://pioupioum.fr/plugins-wordpress/get-authors-comments.html' title='Get Author&#8217;s Comments'>Get Author&#8217;s Comments</a></li><li><a href='http://pioupioum.fr/developpement/javascript-detecter-support-rgba.html' title='JavaScript : tester le support des couleurs RGBA'>JavaScript&#160;: tester le support des couleurs RGBA</a></li><li><a href='http://pioupioum.fr/outils-astuces/supprimer-neige-scripts-greasemonkey.html' title='Supprimer les effets de neige avec Greasemonkey'>Supprimer les effets de neige avec Greasemonkey</a></li><li><a href='http://pioupioum.fr/plugins-spip/google-tools-1-0-1.html' title='SPIP Google Tools 1.0.1'>SPIP Google Tools 1.0.1</a></li></ul>

<div class="footnotes">
<hr />
<h4>Notes</h4>
<ol>

<li id="fn:1">
<p>Les scripts sont chargés en pied de page.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>Notez que les effets <strong>Puff</strong> et <strong>Size</strong> sont accessibles en chargeant le composant <strong>Scale</strong>.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/plugins-wordpress/wordpress-jquery-ui-effects.html/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
