<?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>JQuery, PHP, html, design... // arnaud-k : un blog de geek &#187; JavaScript</title>
	<atom:link href="http://blog.arnaud-k.fr/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.arnaud-k.fr</link>
	<description>Le blog JQuery, PHP, html, design… // un blog de geek</description>
	<lastBuildDate>Wed, 08 Sep 2010 20:12:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Détecter l&#8217;iPad en Javascript ou PHP</title>
		<link>http://blog.arnaud-k.fr/2010/developpement-web/detecter-lipad-en-javascript-ou-php/</link>
		<comments>http://blog.arnaud-k.fr/2010/developpement-web/detecter-lipad-en-javascript-ou-php/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 11:27:11 +0000</pubDate>
		<dc:creator>arnaud</dc:creator>
				<category><![CDATA[développement web]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.arnaud-k.fr/?p=1664</guid>
		<description><![CDATA[Tu souhaites adapter ton site pour l&#8217;iPad ? Il faut pouvoir l&#8217;identifier afin de charger les bonnes feuilles de styles, les bons templates et les bon JavaScript. Plusieurs solutions s&#8217;offrent à toi faire la détection en PHP ou en JavaScript. Tout d&#8217;abord voyons le Javascript : if&#40; navigator.userAgent.match&#40;/iPad/i&#41; != null &#41; &#123; // javascript à [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.arnaud-k.fr%2F2010%2Fdeveloppement-web%2Fdetecter-lipad-en-javascript-ou-php%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.arnaud-k.fr%2F2010%2Fdeveloppement-web%2Fdetecter-lipad-en-javascript-ou-php%2F&amp;source=arnaudk&amp;style=compact&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p class="aligncenter"><img src="http://blog.arnaud-k.fr/wp-content/uploads/2010/04/iPad_by_yamcharevenge.jpg" alt="" title="" width="500" height="203" class="aligncenter size-full wp-image-1666" /></p>
<p>Tu souhaites adapter ton site pour l&#8217;iPad ? Il faut pouvoir l&#8217;identifier afin de charger les bonnes feuilles de styles, les bons templates et les bon JavaScript.</p>
<p>Plusieurs solutions s&#8217;offrent à toi faire la détection en PHP ou en JavaScript. Tout d&#8217;abord voyons le Javascript :</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> navigator.<span style="color: #660066;">userAgent</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/iPad/i</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">// javascript à faire si l'iPad est détecté</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Enfin pour le PHP :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'iPad'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
     <span style="color: #666666; font-style: italic;">// PHP à faire si l'iPad est détecté</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p class="alignright"><em><a href="http://yamcharevenge.deviantart.com/art/iPad-152197039">Photo</a></em></p>


<p>Pas encore de billet sur le même sujet !</p>]]></content:encoded>
			<wfw:commentRss>http://blog.arnaud-k.fr/2010/developpement-web/detecter-lipad-en-javascript-ou-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Inspiration du jour : Theymakeapps.com</title>
		<link>http://blog.arnaud-k.fr/2010/design/inspiration-du-jour-theymakeapps-com/</link>
		<comments>http://blog.arnaud-k.fr/2010/design/inspiration-du-jour-theymakeapps-com/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 07:28:54 +0000</pubDate>
		<dc:creator>arnaud</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[inspiration]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[webdesign]]></category>

		<guid isPermaLink="false">http://blog.arnaud-k.fr/?p=1577</guid>
		<description><![CDATA[Le site du jour, que je viens tout juste de découvrir : TheyMakeApps.com. Le site propose de référencer les agences de création d&#8217;applications pour &#171;&#160;ordiphone&#160;&#187; &#8211; smartphone en anglais &#8211; : Iphone, Android&#8230; Le design tout d&#8217;abord. Tout, ou presque, est en gris (#303232) et blanc. Cela donne un certain style (assez classe je trouve) [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.arnaud-k.fr%2F2010%2Fdesign%2Finspiration-du-jour-theymakeapps-com%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.arnaud-k.fr%2F2010%2Fdesign%2Finspiration-du-jour-theymakeapps-com%2F&amp;source=arnaudk&amp;style=compact&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://theymakeapps.com/"><img class="aligncenter size-full wp-image-1578" title="theymakeapps" src="http://blog.arnaud-k.fr/wp-content/uploads/2010/02/theymakeapps.jpg" alt="" width="600" height="319" /></a></p>
<p><strong>Le site du jour, que je viens tout juste de découvrir : </strong><a href="http://theymakeapps.com/"><strong>TheyMakeApps.com</strong></a>. Le site propose de référencer les agences de création d&#8217;applications pour &laquo;&nbsp;ordiphone&nbsp;&raquo; &#8211; smartphone en anglais &#8211; : Iphone, Android&#8230;</p>
<p>Le design tout d&#8217;abord. Tout, ou presque, est en gris (#303232) et blanc. Cela donne un certain style (assez classe je trouve) au site. <strong>Un gros travail a donc été fait sur les typographies</strong> (tu peux déjà compter le nombre de typos différentes sur la capture ci-dessus !). Les icônes et petites illustrations (en dehors des images des agences) sont également très travaillés et bien réussies.</p>
<p>Ensuite la navigation sur le site lui-même. La première fois que l&#8217;on y accède, il est demandé de <strong>choisir entre modes de navigation</strong> : à la souris (classique) ou tout au clavier (avec, nous promettent-ils &laquo;&nbsp;more fun&nbsp;&raquo;). Après avoir choisi clavier, tu pourras constater que tout a bien été étudié pour naviguer dans le contenu, activer un bloc, voir les détails d&#8217;une agence et revenir sur le listing&#8230;</p>
<p>Cela faisait quelques temps que je n&#8217;étais pas tombé sur un site web tel que celui là <img src='http://blog.arnaud-k.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>


<p>Sur le même sujet :<ol><li><a href='http://blog.arnaud-k.fr/2010/design/inspiration-du-jour-swiths/' rel='bookmark' title='Permanent Link: Inspiration du jour : swiths'>Inspiration du jour : swiths</a></li>
<li><a href='http://blog.arnaud-k.fr/2009/design/web-design-du-jour-10-guillaume-verdon/' rel='bookmark' title='Permanent Link: Web design du jour #10 : Guillaume Verdon'>Web design du jour #10 : Guillaume Verdon</a></li>
<li><a href='http://blog.arnaud-k.fr/2009/design/web-design-du-jour-13-rut-m-fl/' rel='bookmark' title='Permanent Link: Web design du jour #13 : Rut m.fl'>Web design du jour #13 : Rut m.fl</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.arnaud-k.fr/2010/design/inspiration-du-jour-theymakeapps-com/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>5 conseils pour développer avec JQuery</title>
		<link>http://blog.arnaud-k.fr/2009/developpement-web/cat-jquery/5-conseils-pour-developper-avec-jquery/</link>
		<comments>http://blog.arnaud-k.fr/2009/developpement-web/cat-jquery/5-conseils-pour-developper-avec-jquery/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 07:00:26 +0000</pubDate>
		<dc:creator>arnaud</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[exemple de JQuery]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.arnaud-k.fr/?p=1492</guid>
		<description><![CDATA[Pour prolonger la série des tutorials et conseils sur JQuery, je propose un article pour livrer quelques astuces que j&#8217;ai découvert par moi-même ou glanées sur le web dans le but de mieux coder et d&#8217;optimiser le code JQuery. En effet, si celui-ci n&#8217;est pas bien optimisé, les perfomances peuvent être détérioriées en fonction des [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.arnaud-k.fr%2F2009%2Fdeveloppement-web%2Fcat-jquery%2F5-conseils-pour-developper-avec-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.arnaud-k.fr%2F2009%2Fdeveloppement-web%2Fcat-jquery%2F5-conseils-pour-developper-avec-jquery%2F&amp;source=arnaudk&amp;style=compact&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Pour prolonger la série des tutorials et conseils sur JQuery, je propose un article pour livrer <strong>quelques astuces que j&#8217;ai découvert par moi-même ou glanées sur le web dans le but de mieux coder et d&#8217;optimiser le code JQuery.</strong></p>
<p>En effet, si celui-ci n&#8217;est pas bien optimisé, les perfomances peuvent être détérioriées en fonction des capacités de la machine de visiteur. Le JavaScript est un langage côté client, <strong>il ne faut pas négliger les visiteurs ayant une machine de moindre puissance</strong> !</p>
<p><img class="aligncenter size-full wp-image-1495" title="jQuery_Rock_Star_by_tsinilas" src="http://blog.arnaud-k.fr/wp-content/uploads/2009/10/jQuery_Rock_Star_by_tsinilas.jpg" alt="jQuery_Rock_Star_by_tsinilas" width="500" height="218" /></p>
<h2>1 &#8211; Optimisation des sélecteurs</h2>
<p>Pour commencer, un petit rappel de l&#8217;ordre des sélecteurs de JQuery en fonction de leurs vitesses d&#8217;interprétation (la liste n&#8217;est pas exhaustive) :</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot; #monbloc&quot;</span><span style="color: #009900;">&#41;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;p&quot;</span><span style="color: #009900;">&#41;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.laclasse&quot;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Quelques explications s&#8217;imposent.<strong> Le plus rapide reste d&#8217;utiliser directement l&#8217;ID</strong> de ce que l&#8217;on recherche, la fonction étant basé sur la fonction getElementById() de JavaScript. La fonction recherche un objet du DOM unique et s&#8217;arrête dès qu&#8217;elle l&#8217;a trouvé !</p>
<p>Le deuxième sélecteur est basé sur la fonction JavaScript getElementByTagName(). Le nombre d&#8217;éléments à parcourir est moindre par rapport à simplement &laquo;&nbsp;.laclasse&nbsp;&raquo;. <strong>Avec un sélecteur composé simplement d&#8217;un nom de classe, tout le DOM est parcouru !</strong> C&#8217;est ce qu&#8217;il y a de pire !</p>
<p>Dernier petit conseil concernant les sélecteurs, il est toujours mieux de <strong>donner un contexte au sélecteur</strong> si l&#8217;on doit utiliser une classe :</p>
<p>$(&laquo;&nbsp;#monID .maclasse&nbsp;&raquo;) est plus rapide que $(&laquo;&nbsp;.maclasse&nbsp;&raquo;)</p>
<h2>2 &#8211; Utilisation des objets JQuery et des variables JavaScript</h2>
<p>Si tu dois utiliser plusieurs fois le même sélecteur, il faut <strong>utiliser les objets JQuery et enregistrer celui-ci dans une variable</strong>.</p>
<p>Regardons ce bout de code (ceci est bien entendu un exemple à ne pas reproduire !) :</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#monLien&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// quand on clique sur le lien ayant l'id monLien</span>
     <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#monBloc&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:visible&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// si le bloc &quot;monBloc&quot; est visible</span>
     <span style="color: #009900;">&#123;</span>
          $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#monBloc&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// on l'enroule</span>
          $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#monBloc&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ferme&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// et on y ajoute la classe &quot;ferme&quot;</span>
     <span style="color: #009900;">&#125;</span>
     e.<span style="color: #660066;">preventDefault</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;">// pour empecher le navigateur de suivre le lien</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Le sélecteur $(&laquo;&nbsp;#monBloc&nbsp;&raquo;) est utilisé 3 fois. Le DOM est donc parcouru autant de fois pour toujours avoir le même résultat.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#monLien&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">// on affecte à la variable monBloc l'objet JQuery correspondant :</span>
     <span style="color: #003366; font-weight: bold;">var</span> monBloc <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#monBloc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> monBloc.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:visible&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// si le bloc &quot;monBloc&quot; est visible</span>
     <span style="color: #009900;">&#123;</span>
          monBloc.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// on enroule le bloc</span>
          monBloc.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ferme&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// et on y ajoute la classe &quot;ferme&quot;</span>
     <span style="color: #009900;">&#125;</span>
     e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</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></div></div>

<p>Le simple fait de mettre dans une variable le résultat de $(&laquo;&nbsp;#monBloc&nbsp;&raquo;) permet de n&#8217;<strong>utiliser le sélecteur qu&#8217;une seule fois</strong>. On peut appliquer n&#8217;importe quelle fonction JQuery à la variable monBloc qui contient l&#8217;objet JQuery retourné par le sélecteur !</p>
<h2>3 &#8211; La chainabilité</h2>
<p>L&#8217;un des avantages de JQuery est la possibilité d&#8217;<strong>utiliser la &laquo;&nbsp;chainabilité&nbsp;&raquo; pour écrire son code</strong>. Un exemple vaudra toute les explications.</p>
<p>Reprenons le bout de code précédent :</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#monLien&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #003366; font-weight: bold;">var</span> monBloc <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#monBloc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> monBloc.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:visible&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
     <span style="color: #009900;">&#123;</span>
          monBloc.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          monBloc.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ferme&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
     e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</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></div></div>

<p>On constate que dans la condition if (monBloc&#8230; il y a 2 actions à effectuer sur &laquo;&nbsp;monBloc&nbsp;&raquo;. La chainabilité permet de <strong>raccourcir l&#8217;écriture du code :<br />
</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#monLien&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #003366; font-weight: bold;">var</span> monBloc <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#monBloc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> monBloc.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:visible&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
     <span style="color: #009900;">&#123;</span>
          <span style="color: #006600; font-style: italic;">// on enroule le bloc et on y ajoute la classe &quot;ferme&quot; :</span>
          monBloc.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ferme&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
     e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</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></div></div>

<p>Par la suite, il est donc possible de faire des choses comme ceci :</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span>
   .<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.class1&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// si un lien à la classe .class1</span>
     .<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// et qu'on clique dessus</span>
       <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Un clique sur le lien .class1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// on alert</span>
       e.<span style="color: #660066;">preventDefault</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;">// et on empeche le navigateur de suivre le lien</span>
     <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
   .<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// on retire le sélecteur ajouté avec filter()</span>
   .<span style="color: #660066;">not</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#superId&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// si un lien n'a pas pour id superId</span>
     .<span style="color: #660066;">click</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;">// et qu'on clique dessus</span>
       $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</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;">// on cache le lien</span>
       e.<span style="color: #660066;">preventDefault</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;">// et on empeche le navigateur de suivre le lien</span>
     <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
   .<span style="color: #660066;">end</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;">// et on retire le sélecteur</span>
   ... <span style="color: #006600; font-style: italic;">// on peut continuer trèèèèès longtemps comme ça.</span></pre></div></div>

<p>La chainabilité est possible grâce au fait que <strong>chaque fonction JQuery retourne l&#8217;objet auquel est appliqué la méthode</strong> (ou fonction pour rester dans des termes compréhensibles <img src='http://blog.arnaud-k.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ). La fonction end() permet de &laquo;&nbsp;retirer&nbsp;&raquo; le dernier sélecteur de &laquo;&nbsp;Traversing&nbsp;&raquo; (je vois pas trop le mot à utiliser pour le traduire). Pour voir la liste de ces sélecteurs, <strong>n&#8217;hésite pas à faire un tour sur la <a href="http://docs.jquery.com/Traversing">Doc JQuery</a> !</strong></p>
<h2>4 &#8211; Utiliser le fonctions de toggle</h2>
<p>Une petite astuce toute simple et pourtant très utile. Je ne vois pas très souvent les fonctions de &laquo;&nbsp;toggle&nbsp;&raquo; utilisées&#8230; Or ces fonctions permettent d&#8217;<strong>inverser un état d&#8217;un élément</strong>. Il y en a plusieurs, mais je parle notamment de :</p>
<ul>
<li><strong>toggle()</strong> qui rend visible un élément non visible ou qui cache l&#8217;élément si celui-ci est visible</li>
<li><strong>slideToggle()</strong> qui slideDown (déroule) un élément non visible ou qui slideUp (enroule) l&#8217;élément si celui-ci est visible</li>
<li><strong>toggleClass(&laquo;&nbsp;maClass&nbsp;&raquo;)</strong> ajoute la classe à l&#8217;élément si celui-ci ne l&#8217;a pas ou supprime la classe à l&#8217;élément si celui-ci l&#8217;a déjà</li>
</ul>
<p>Par exemple :</p>

<div class="wp_syntax"><div 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: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#monTest&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:visible&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// si le bloc ayant pour id &quot;monTest&quot; est visible</span>
<span style="color: #009900;">&#123;</span>
     $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#monTest&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</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;">// on le cache</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #006600; font-style: italic;">// sinon</span>
<span style="color: #009900;">&#123;</span>
     $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#monTest&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</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;">// on le montre</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Tout ce bloc peut être réduit (et donc optimisé) à <strong>1 seule ligne de code :</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#monTest&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggle</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;">// !!</span></pre></div></div>

<h2>5 &#8211; Utiliser la fonction data() de JQuery</h2>
<p>Chose que j&#8217;ai découverte il y a peu (en refaisant <a title="Portfolio - Arnaud Koncina" href="http://cv.arnaud-k.fr">mon portfolio</a>), il est possible avec JQuery d&#8217;<strong>attacher des données à un élément</strong>.  Cette fonction est très utiliser par certans plugins (comme par exemple <a href="http://jqueryui.com/">JQueryUI</a>). La fonction data() s&#8217;utilise comme ceci :</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#id&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'color'</span><span style="color: #339933;">,</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#id&quot;</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>  <span style="color: #006600; font-style: italic;">// On enregistre la couleur du bloc à ce moment</span>
<span style="color: #009900;">&#91;</span>...<span style="color: #009900;">&#93;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#autreId&quot;</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: #339933;">,</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#id&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">data</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>  <span style="color: #006600; font-style: italic;">// On affecte la couleur enregistré à un autre élément</span>
<span style="color: #009900;">&#91;</span>...<span style="color: #009900;">&#93;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#id&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeData</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'color'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//Et on n'oublie pas de vider le data quand on a fini</span></pre></div></div>

<h3>J&#8217;espère avoir appris au moins une astuce à une personne, comme ça je n&#8217;aurai rien perdu !</h3>
<p style="text-align: right;"><em>[image : <a href="http://tsinilas.deviantart.com/art/jQuery-Rock-Star-118613585">JQuery Rock Star</a> by<small></small><small> <span class="u">tsinilas]</span></small></em></p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 2560px; width: 1px; height: 1px;">http://jqueryui.com/</div>


<p>Sur le même sujet :<ol><li><a href='http://blog.arnaud-k.fr/2009/developpement-web/cat-jquery/tutorial-plugin-jquery-delectable-pour-afficher-les-derniers-bookmarks-delicious/' rel='bookmark' title='Permanent Link: Tutorial plugin JQuery : Delectable pour afficher les derniers bookmarks Delicious'>Tutorial plugin JQuery : Delectable pour afficher les derniers bookmarks Delicious</a></li>
<li><a href='http://blog.arnaud-k.fr/2010/developpement-web/cat-jquery/astuce-jquery-la-fonction-serialize/' rel='bookmark' title='Permanent Link: Astuce JQuery : la fonction serialize ()'>Astuce JQuery : la fonction serialize ()</a></li>
<li><a href='http://blog.arnaud-k.fr/2009/developpement-web/cat-jquery/plugin-jquery-info-bulles-simple-avec-wtooltip/' rel='bookmark' title='Permanent Link: Plugin JQuery : info-bulles simple avec Wtooltip'>Plugin JQuery : info-bulles simple avec Wtooltip</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.arnaud-k.fr/2009/developpement-web/cat-jquery/5-conseils-pour-developper-avec-jquery/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Minning.de, design du jour</title>
		<link>http://blog.arnaud-k.fr/2009/news-du-web/minningde-design-du-jour/</link>
		<comments>http://blog.arnaud-k.fr/2009/news-du-web/minningde-design-du-jour/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 11:17:31 +0000</pubDate>
		<dc:creator>arnaud</dc:creator>
				<category><![CDATA[news du web]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[illustrateur]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[webdesign]]></category>

		<guid isPermaLink="false">http://blog.arnaud-k.fr/?p=816</guid>
		<description><![CDATA[Pour aujourd&#8217;hui je voulais parler du site minning.de. Un site au design minimaliste mais qui a de la classe (comme tous les sites aux designs minimalistes réussis). C&#8217;est le site web d&#8217;un graphiste Berlinois, les diverses illustrations sont assez réussies je dois dite (j&#8217;aime particulièrement l&#8217;image de la page d&#8217;accueil). A noter que la navigation [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.arnaud-k.fr%2F2009%2Fnews-du-web%2Fminningde-design-du-jour%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.arnaud-k.fr%2F2009%2Fnews-du-web%2Fminningde-design-du-jour%2F&amp;source=arnaudk&amp;style=compact&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.minning.de/"><img class="aligncenter size-full wp-image-817" title="minning" src="http://blog.arnaud-k.fr/wp-content/uploads/2009/07/minning.png" alt="minning" /></a>Pour aujourd&#8217;hui je voulais parler du site <a href="http://www.minning.de/">minning.de</a>. Un site au design minimaliste mais qui a de la classe (comme tous les sites aux designs minimalistes réussis). C&#8217;est le site web d&#8217;un graphiste Berlinois, les diverses illustrations sont assez réussies je dois dite (j&#8217;aime particulièrement l&#8217;image de la page d&#8217;accueil).</p>
<p>A noter que la navigation sur le site est faite tout en Javascript (apparemment sans JQuery, d&#8217;après ce que j&#8217;ai pu voir dans le code) et est agréable à utiliser !</p>


<p>Sur le même sujet :<ol><li><a href='http://blog.arnaud-k.fr/2009/design/web-design-du-jour-12-websarga/' rel='bookmark' title='Permanent Link: Web design du jour #12 : Websarga'>Web design du jour #12 : Websarga</a></li>
<li><a href='http://blog.arnaud-k.fr/2009/design/web-design-du-jour-19-orman-clark/' rel='bookmark' title='Permanent Link: Web design du jour #19 : Orman Clark'>Web design du jour #19 : Orman Clark</a></li>
<li><a href='http://blog.arnaud-k.fr/2009/design/web-design-du-jour-10-guillaume-verdon/' rel='bookmark' title='Permanent Link: Web design du jour #10 : Guillaume Verdon'>Web design du jour #10 : Guillaume Verdon</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.arnaud-k.fr/2009/news-du-web/minningde-design-du-jour/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Utiliser les fonctions php en JavaScript avec PHP-JS</title>
		<link>http://blog.arnaud-k.fr/2009/developpement-web/utiliser-les-fonctions-php-en-javascript-avec-php-js/</link>
		<comments>http://blog.arnaud-k.fr/2009/developpement-web/utiliser-les-fonctions-php-en-javascript-avec-php-js/#comments</comments>
		<pubDate>Mon, 04 May 2009 10:11:45 +0000</pubDate>
		<dc:creator>arnaud</dc:creator>
				<category><![CDATA[développement web]]></category>
		<category><![CDATA[fonctions]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.arnaud-k.fr/?p=454</guid>
		<description><![CDATA[Lorsque l&#8217;on a l&#8217;habitude de coder en php avec ses multiples fonctions natives (avec ses fonctions de date, sur les tableaux, les chaînes de caractère&#8230;), on a parfois du mal à s&#8217;y retrouver en JavaScript. C&#8217;est de ce constat qu&#8217;est parti le projet PHP-JS. PHP-JS permet l&#8217;utilisation des fonctions natives de php en JavaScript ! [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.arnaud-k.fr%2F2009%2Fdeveloppement-web%2Futiliser-les-fonctions-php-en-javascript-avec-php-js%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.arnaud-k.fr%2F2009%2Fdeveloppement-web%2Futiliser-les-fonctions-php-en-javascript-avec-php-js%2F&amp;source=arnaudk&amp;style=compact&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Lorsque l&#8217;on a l&#8217;habitude de coder en php avec ses multiples fonctions natives (avec ses fonctions de date, sur les tableaux, les chaînes de caractère&#8230;), on a parfois du mal à s&#8217;y retrouver en JavaScript.</p>
<p>C&#8217;est de ce constat qu&#8217;est parti le projet <a href="http://phpjs.org">PHP-JS</a>. <strong>PHP-JS permet l&#8217;utilisation des fonctions natives de php en JavaScript !</strong> Pour le moment <strong>386 fonctions</strong> sont disponibles. Pour créer cela, ils ont simplement re-coder les fonctions php en JavaScript. On retrouve toute sorte de fonctions de l&#8217;include() (qui ajoute les balises script) à date() en passant par in_array() (pour savoir si un élément est dans un tableau).</p>
<p><img src="file:///tmp/moz-screenshot.jpg" alt="" /> Le pack complet de fonction est <strong>disponible en téléchargement</strong> sur le site, mais je vous recommande d&#8217;utiliser l&#8217;outil qui permet de <a href="http://phpjs.org/packages/configure">générer un fichier js</a> contenant uniquement les  fonctions qui seront nécessaires.</p>
<p><a href="http://phpjs.org"><img class="aligncenter size-full wp-image-455" title="php-js" src="http://blog.arnaud-k.fr/wp-content/uploads/2009/05/php-js.png" alt="php-js" width="600" height="300" /></a></p>


<p>Sur le même sujet :<ol><li><a href='http://blog.arnaud-k.fr/2010/developpement-web/detecter-lipad-en-javascript-ou-php/' rel='bookmark' title='Permanent Link: Détecter l&#8217;iPad en Javascript ou PHP'>Détecter l&#8217;iPad en Javascript ou PHP</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.arnaud-k.fr/2009/developpement-web/utiliser-les-fonctions-php-en-javascript-avec-php-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nouvelle documentation JQuery en Français</title>
		<link>http://blog.arnaud-k.fr/2009/developpement-web/cat-jquery/nouvelle-documentation-jquery-en-francais/</link>
		<comments>http://blog.arnaud-k.fr/2009/developpement-web/cat-jquery/nouvelle-documentation-jquery-en-francais/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 16:22:21 +0000</pubDate>
		<dc:creator>arnaud</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.arnaud-k.fr/?p=17</guid>
		<description><![CDATA[Découverte de cet après-midi : une nouvelle documentation de JQuery en Français. Elle reprend les textes originaux d&#8217;une autre documentation JQuery en Français mais apporte des nouveautés comme les toutes dernières fonctions de la dernière version de JQuery (live(), die()&#8230;) et surtout la possibilité de publier des commentaires sur n&#8217;importe quelle fonctions. Cette dernière fonctionnalité [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.arnaud-k.fr%2F2009%2Fdeveloppement-web%2Fcat-jquery%2Fnouvelle-documentation-jquery-en-francais%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.arnaud-k.fr%2F2009%2Fdeveloppement-web%2Fcat-jquery%2Fnouvelle-documentation-jquery-en-francais%2F&amp;source=arnaudk&amp;style=compact&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: left;">Découverte de cet après-midi : une nouvelle <a href="http://jquery.jarodxxx.com/">documentation de JQuery en Français</a>. Elle reprend les textes originaux d&#8217;une autre documentation JQuery en Français mais apporte des nouveautés comme les toutes dernières fonctions de la dernière version de JQuery (live(), die()&#8230;) et surtout la possibilité de publier des commentaires sur n&#8217;importe quelle fonctions. Cette dernière fonctionnalité augmente sensiblement l&#8217;intérêt de ce genre de site (un peu comme les commentaires explicatifs sur la <a href="http://www.php.net/manual/fr/">doc php</a>). Et pour finir, le site a un design bien sympa, avec des couleurs chaudes et dynamiques (ça change pour une documentation!)</p>
<p style="text-align: left;">
<p style="text-align: center;"><img class="size-full wp-image-18 aligncenter" title="jquery" src="http://blog.arnaud-k.fr/wp-content/uploads/2009/03/jquery.png" alt="Documentation JQuery en Français" width="600" height="200" /></p>
<p style="text-align: left;">Bref une adresse à Bookmarker!</p>


<p>Pas encore de billet sur le même sujet !</p>]]></content:encoded>
			<wfw:commentRss>http://blog.arnaud-k.fr/2009/developpement-web/cat-jquery/nouvelle-documentation-jquery-en-francais/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
