<?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>Weedle &#187; jQuery</title>
	<atom:link href="http://www.weedle.fr/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.weedle.fr</link>
	<description>Un blog utilisant WordPress</description>
	<lastBuildDate>Sat, 14 Aug 2010 10:00:50 +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>EasySlider : un plugin jQuery pour réaliser des diaporamas</title>
		<link>http://www.weedle.fr/easyslider-plugin-jquery-diaporamas/</link>
		<comments>http://www.weedle.fr/easyslider-plugin-jquery-diaporamas/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 16:00:35 +0000</pubDate>
		<dc:creator>Fred</dc:creator>
				<category><![CDATA[Ressources]]></category>
		<category><![CDATA[Tutoriels]]></category>
		<category><![CDATA[Développement]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.weedle.fr/?p=2841</guid>
		<description><![CDATA[Depuis un moment déjà, le web a pris une toute nouvelle tournure. Les sites internet ont changé de visage, deviennent des webwares et l&#8217;interactivité est désormais une priorité pour tous les webmestres. Oui et ce changement s&#8217;est en grande partie fait grâce à l&#8217;avènement des nouvelles techniques de développement et de certaines librairies comme le [...]<p><small>Cet article original a &eacute;t&eacute; publi&eacute; sur <a href="http://www.weedle.fr" title="Weedle, tout sur le design, l'illustration, le motion et Wordpress">Weedle</a>. <br />Toute reproduction, m&ecirc;me partielle, est interdite sans l'accord explicite de ses auteurs sauf citation de quelques lignes accompagn&eacute;es d'un lien vers ce billet.<br /> Si vous aimez <a href="http://www.weedle.fr" title="Weedle, tout sur le design, l'illustration, le motion et Wordpress">Weedle</a>, vous pouvez nous rejoindre sur <a href="http://www.twitter.com/weedlefr" title="Weedle sur Twitter">Twitter</a>, sur <a href="http://www.facebook.fr/frederic.pereira" title="Weedle sur Facebook">Facebook</a> ou rejoindre notre groupe sur <a href="http://www.flickr.com/groups/" title="Weedle sur Flickr">Flickr</a>.</small></p>
]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Depuis un moment déjà, le web a pris une toute nouvelle tournure. Les sites internet ont changé de visage, deviennent des <em>webwares </em>et l&#8217;interactivité est désormais une priorité pour tous les webmestres. <strong>Oui et ce changement s&#8217;est en grande partie fait grâce à l&#8217;avènement des nouvelles techniques de <a href="http://www.weedle.fr/tag/developpement/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Développement">développement</a> et de certaines librairies comme le <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a>.</strong> Pour <a title="Tutoriel jQuery : créer une boite à onglets" href="http://www.weedle.fr/tutoriel-jquery-creer-boite-onglets/" target="_blank">continuer sur notre lancée</a>, nous allons aujourd&#8217;hui nous intéresser à <a title="EasySlider, un plugin jQuery pour réaliser des diaporamas" href="http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider" target="_blank">EasySlider</a>, un plugin <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a> pour réaliser de chouettes diaporamas.</p>
<p style="text-align: justify;"><a href="http://www.weedle.fr/wp-content/uploads/2010/03/jquery.png"><img class="aligncenter size-full wp-image-2843" title="EasySlider : un plugin jQuery pour réaliser des diaporamas" src="http://www.weedle.fr/wp-content/uploads/2010/03/jquery.png" alt="" width="581" height="380" /></a></p>
<p><span id="more-2841"></span></p>
<h3>1. Développer moins pour gagner plus</h3>
<p style="text-align: justify;">La plupart des développeurs vous diront qu&#8217;il faut tout coder soi-même, quitte à passer des nuits blanches devant son Notepad++. En ce qui me concerne, je pars du principe qu&#8217;<strong>il ne sert à rien de réinventer la roue</strong> et qu&#8217;il est préférable d&#8217;utiliser une solution fiable et éprouvée plutôt que de se risquer à coder un script tout seul dans son coin tard la nuit.</p>
<p style="text-align: justify;">Cela dit, je ne suis plus webdesigner que développeur, hein&#8230;</p>
<p style="text-align: justify;">A l&#8217;époque où j&#8217;ai souhaité intégré un diaporama sur Weedle, je me suis beaucoup renseigné sur le sujet. <strong>Développer un script de ce genre n&#8217;est pas difficile en soi.</strong> Ce qui est plus délicat, c&#8217;est de faire en sorte qu&#8217;il soit doté de toutes les fonctionnalités dont on a besoin, qu&#8217;il respecte les standards établis<strong> et</strong> qu&#8217;il soit compatible avec tous les navigateurs du marché.</p>
<p style="text-align: justify;"><a title="EasySlider, un plugin jQuery pour réaliser des diaporamas" href="http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider" target="_blank">EasySlider</a> réunit justement toutes ses qualités et c&#8217;est la raison pour laquelle c&#8217;est vers cet outil que je me suis tourné.</p>
<h3>2. EasySlider, les fonctionnalités du script</h3>
<p style="text-align: justify;">En plus d&#8217;être respectueux des normes et d&#8217;être compatible avec les différents navigateurs web du marché, <a title="EasySlider, un plugin jQuery pour réaliser des diaporamas" href="http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider" target="_blank">EasySlider</a> propose de nombreuses options de personnalisation. Il est ainsi possible de déterminer la rapidité d&#8217;exécution des différents slides, d&#8217;opter pour deux systèmes de navigation différents <em>(précédent / suivant et contrôles numériques)</em> et bien d&#8217;autres choses encore.</p>
<p style="text-align: justify;"><strong>Voici d&#8217;ailleurs une liste non exhaustive des options du script :</strong></p>
<ul>
<li style="text-align: justify;">Deux systèmes de navigation : précédent / suivant, contrôles numériques.</li>
<li style="text-align: justify;">Possibilité d&#8217;afficher / de masquer les différents contrôles.</li>
<li style="text-align: justify;">Possibilité de choisir l&#8217;ID des composantes du système de navigation.</li>
<li style="text-align: justify;">Deux orientations possible pour le diaporama : horizontale ou verticale.</li>
<li style="text-align: justify;">Possibilité de choisir la rapidité d&#8217;exécution des slides.</li>
<li style="text-align: justify;">Possibilité de définir un défilement continu ou pas.</li>
</ul>
<p style="text-align: justify;"><strong>Pour avoir plus d&#8217;informations sur le sujet, je vous encourage vivement à aller consulter la page dédiée du plugin.</strong> N&#8217;hésitez pas non plus à aller consulter celles des versions précédentes, elles contiennent de nombreuses informations qui vous permettront de mieux comprendre le fonctionnement de notre <a title="EasySlider, un plugin jQuery pour réaliser des diaporamas" href="http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider" target="_blank">EasySlider</a>.</p>
<h3>3. EasySlider, l&#8217;installer et l&#8217;utiliser</h3>
<p style="text-align: justify;">Maintenant que les présentations sont faites, nous allons pouvoir passer au vif du sujet et voir comment s&#8217;installe et s&#8217;utilise <a title="EasySlider, un plugin jQuery pour réaliser des diaporamas" href="http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider" target="_blank">EasySlider</a>. <strong>Pour se faire, vous aurez besoin d&#8217;un minimum de connaissances techniques et maîtriser le HTML ainsi que les CSS.</strong> Si ce n&#8217;est pas le cas, ce n&#8217;est pas grave, vous pouvez garder cet article dans un coin puisque je pense publier dans les semaines qui viennent des guides complets sur les bases du <a href="http://www.weedle.fr/tag/developpement/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Développement">développement</a> web.</p>
<h4>3.1. Installer <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a> et  EasySlider :</h4>
<p style="text-align: justify;"><strong>Pour commencer, il est nécessaire de récupérer la dernière version du plugin <a title="Télécharger EasySlider" href="http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider" target="_blank">sur la page dédiée</a>. </strong>Une fois l&#8217;archive téléchargée, contentez-vous de la décompresser dans le dossier de votre site. Puis, ouvrez votre éditeur préféré ainsi que le fichier <em>header.php</em> si vous utilisez WordPress ou sinon le fichier de votre site qui va bien.</p>
<p style="text-align: justify;">Placez-vous entre les balise <em>&lt;head&gt;</em> et <em>&lt;/head&gt;</em> et insérez les deux lignes suivantes :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;script src=&quot;http://chemin-de-votre-site/jquery-1.3.2.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://chemin-de-votre-site/easySlider1.7.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<p style="text-align: justify;"><strong>Deux choses à noter :</strong></p>
<ol>
<li style="text-align: justify;">Il est primordial d&#8217;intégrer EasySlider après <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a>. Si vous ne le faites pas, alors le script ne pourra pas fonctionner.</li>
<li style="text-align: justify;">Le chemin indiqué soit être complet. Attention, donc, si vous avez tendance à mettre vos fichiers JS dans un sous-dossier.</li>
</ol>
<h4>3.2. La base HTML + CSS :</h4>
<p style="text-align: justify;">A présent que <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a> et EasySlider sont bien installés, nous allons pouvoir commencer à préparer notre <em>template</em> HTML. <strong>Notons que les <a href="http://www.weedle.fr/tag/scripts/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Scripts">scripts</a> qui suivent ont été volontairement allégés au maximum afin d&#8217;insister sur l&#8217;essentiel.</strong> Globalement, donc, vous aurez ensuite encore un peu de travail à faire au niveau de la mise en forme.</p>
<p style="text-align: justify;">Côté HTML, c&#8217;est relativement simple puisqu&#8217;il suffit d&#8217;insérer les lignes qui suivent à l&#8217;endroit où vous souhaitez voir apparaître votre diaporama. <strong>Précisons juste que notre structure s&#8217;appuie essentiellement sur les listes.</strong></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="html" style="font-family:monospace;">&lt;div id=&quot;diaporamali&quot;&gt;
&lt;ul&gt;
&lt;li &gt;Mon premier slide&lt;/li&gt;
&lt;li &gt;Mon second slide&lt;/li&gt;
&lt;li &gt;Mon troisième slide&lt;/li&gt;
&lt;li &gt;Mon quatrième slide&lt;/li&gt;
&lt;li &gt;Mon cinquième slide&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p style="text-align: justify;">Au niveau des CSS, ce n&#8217;est guère plus compliqué, il suffit d&#8217;insérer ces lignes dans votre feuille de style. Notons le overflow: hidden placé sur nos listes. Sans lui, le diaporama ne pourra pas fonctionner correctement, il est donc indispensable. <strong>Notons également que votre conteneur et vos listes doivent avoir les mêmes dimensions.</strong></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="css" style="font-family:monospace;">div<span style="color: #cc00cc;">#diaporamali</span><span style="color: #00AA00;">,</span>div<span style="color: #cc00cc;">#diaporamali</span> li <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h3>3.3. Le script <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a> :</h3>
<p style="text-align: justify;">Maintenant que notre structure est prête, il ne nous reste plus qu&#8217;une étape à accomplir : nous allons devoir insérer entre nos balises <em>&lt;head&gt;</em> et <em>&lt;/head&gt;</em> le script qui nous permettra d&#8217;initialiser et de paramétrer notre diaporama. A toute fin utile, je préfère tout de même préciser un point important : <strong>ce script doit obligatoirement être inséré après <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a> et EasySlider</strong>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script text<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</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: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#diaporamali&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">easySlider</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		speed<span style="color: #339933;">:</span> <span style="color: #CC0000;">1200</span><span style="color: #339933;">,</span>
		pause <span style="color: #339933;">:</span> <span style="color: #CC0000;">10000</span><span style="color: #339933;">,</span>
		auto<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> 
		continuous<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
		numeric <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</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>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p style="text-align: justify;">Alors évidemment, libre à vous de personnaliser ce script à votre convenance. Ici, j&#8217;ai finalement repris le même script que celui qui anime le diaporama de Weedle : un défilement continu, une pause assez longue et un système de navigation numérique transformé en boutons afin de permettre aux internautes de se promener au travers des différents slides.</p>
<h3>4. Et après ?</h3>
<p style="text-align: justify;">Voilà, cette courte présentation de <a title="EasySlider, un plugin jQuery pour réaliser des diaporamas" href="http://cssglobe.com/post/3783/jquery-plugin-easy-image-or-content-slider" target="_blank">EasySlider</a> touche à sa fin. <strong>Je tiens à préciser que ce script n&#8217;est pas le seul du genre mais il a néanmoins le mérite d&#8217;être très simple à intégrer et très rapide à déployer.</strong> Et si vous avez des questions ou si vous souhaitez simplement remercier son auteur, n&#8217;hésitez pas à aller faire un tour chez lui.</p>
<p style="text-align: justify;">Alors maintenant, il y a sans doute une question que vous devez vous poser, à savoir comment j&#8217;ai fait pour intégrer les images de mes articles dans ce diaporama. <strong>C&#8217;est une bonne question, et c&#8217;est la raison pour laquelle j&#8217;ai décidé d&#8217;insérer ci-dessous mon script complet. </strong>Comme vous le verrez, ce n&#8217;est pas très compliqué.</p>
<p style="text-align: justify;"><strong>Le code HTML :</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;div id=&quot;diaporamali&quot;&gt;
&lt;ul&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$myposts</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'numberposts=5&amp;orderby=post_date&amp;order=DESC'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myposts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;li style=&quot;background:url(<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_first_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>)&quot;&gt;
&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; class=&quot;diaporamatitre&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;
&lt;/li&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/ul&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p style="text-align: justify;"><strong>Le code CSS :</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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #cc00cc;">#diaporamali</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">4px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#dedede</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
div<span style="color: #cc00cc;">#diaporamali</span> ul <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
div<span style="color: #cc00cc;">#diaporamali</span><span style="color: #00AA00;">,</span> div<span style="color: #cc00cc;">#diaporamali</span> li <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">573px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">170px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
a<span style="color: #6666ff;">.diaporamatitre</span><span style="color: #3333ff;">:link</span><span style="color: #00AA00;">,</span> a<span style="color: #6666ff;">.diaporamatitre</span><span style="color: #3333ff;">:visited</span><span style="color: #00AA00;">,</span> a<span style="color: #6666ff;">.diaporamatitre</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#9dd1eb</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</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;">14px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">22px</span><span style="color: #00AA00;">;</span> 
<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">67px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">358px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
a<span style="color: #6666ff;">.diaporamatitre</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
opacity<span style="color: #00AA00;">:</span> <span style="color: #933;">0.9px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #808080; font-style: italic;">/* CONTROLES DIAPORAMA  */</span>
ol<span style="color: #cc00cc;">#controls</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">511px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
ol<span style="color: #cc00cc;">#controls</span> li <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/bouton_diaporama.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
ol<span style="color: #cc00cc;">#controls</span> li a<span style="color: #3333ff;">:link</span><span style="color: #00AA00;">,</span>ol<span style="color: #cc00cc;">#controls</span> li a<span style="color: #3333ff;">:visited</span><span style="color: #00AA00;">,</span>ol<span style="color: #cc00cc;">#controls</span> li a<span style="color: #3333ff;">:hover </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;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">text-indent</span><span style="color: #00AA00;">:</span> -<span style="color: #cc66cc;">9999</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p style="text-align: justify;"><strong>Le script <a href="http://www.weedle.fr/tag/javascript/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Javascript">Javascript</a> :</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script text<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</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: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#diaporamali&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">easySlider</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		speed<span style="color: #339933;">:</span> <span style="color: #CC0000;">1200</span><span style="color: #339933;">,</span>
		pause <span style="color: #339933;">:</span> <span style="color: #CC0000;">10000</span><span style="color: #339933;">,</span>
		auto<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> 
		continuous<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
		numeric <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</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>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p style="text-align: justify;"><a href="http://himynameiznate.deviantart.com/art/jQuery-MNML-v2-46544703" target="_blank">Crédits Photo</a></p>
<p><small>Cet article original a &eacute;t&eacute; publi&eacute; sur <a href="http://www.weedle.fr" title="Weedle, tout sur le design, l'illustration, le motion et WordPress">Weedle</a>. <br />Toute reproduction, m&ecirc;me partielle, est interdite sans l'accord explicite de ses auteurs sauf citation de quelques lignes accompagn&eacute;es d'un lien vers ce billet.<br /> Si vous aimez <a href="http://www.weedle.fr" title="Weedle, tout sur le design, l'illustration, le motion et WordPress">Weedle</a>, vous pouvez nous rejoindre sur <a href="http://www.twitter.com/weedlefr" title="Weedle sur Twitter">Twitter</a>, sur <a href="http://www.facebook.fr/frederic.pereira" title="Weedle sur Facebook">Facebook</a> ou rejoindre notre groupe sur <a href="http://www.flickr.com/groups/" title="Weedle sur Flickr">Flickr</a>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.weedle.fr/easyslider-plugin-jquery-diaporamas/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Tutoriel jQuery : créer une boîte d&#8217;onglets</title>
		<link>http://www.weedle.fr/tutoriel-jquery-creer-boite-onglets/</link>
		<comments>http://www.weedle.fr/tutoriel-jquery-creer-boite-onglets/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 09:00:39 +0000</pubDate>
		<dc:creator>Fred</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Tutoriels]]></category>
		<category><![CDATA[Développement]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.weedle.fr/?p=2485</guid>
		<description><![CDATA[Très populaire, le jQuery est utilisé par de nombreux développeurs pour la mise en place de leurs projets web. Et pour cause puisque cette bibliothèque Javascript facilite grandement les choses et permet de déployer facilement des effets saisissants. Une bonne manière d&#8217;améliorer l&#8217;interaction homme / machine et de donner un coup de fouet à l&#8217;expérience utilisateur [...]<p><small>Cet article original a &eacute;t&eacute; publi&eacute; sur <a href="http://www.weedle.fr" title="Weedle, tout sur le design, l'illustration, le motion et Wordpress">Weedle</a>. <br />Toute reproduction, m&ecirc;me partielle, est interdite sans l'accord explicite de ses auteurs sauf citation de quelques lignes accompagn&eacute;es d'un lien vers ce billet.<br /> Si vous aimez <a href="http://www.weedle.fr" title="Weedle, tout sur le design, l'illustration, le motion et Wordpress">Weedle</a>, vous pouvez nous rejoindre sur <a href="http://www.twitter.com/weedlefr" title="Weedle sur Twitter">Twitter</a>, sur <a href="http://www.facebook.fr/frederic.pereira" title="Weedle sur Facebook">Facebook</a> ou rejoindre notre groupe sur <a href="http://www.flickr.com/groups/" title="Weedle sur Flickr">Flickr</a>.</small></p>
]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Très populaire, le <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a> est utilisé par de nombreux développeurs pour la mise en place de leurs projets web. Et pour cause puisque cette bibliothèque <a href="http://www.weedle.fr/tag/javascript/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Javascript">Javascript</a> facilite grandement les choses et permet de déployer facilement des effets saisissants.<strong> Une bonne manière d&#8217;améliorer l&#8217;interaction homme / machine et de donner un coup de fouet à l&#8217;expérience utilisateur proposée. </strong>Pour ce premier tutoriel sur le sujet, nous allons apprendre à réaliser facilement une boîte d&#8217;onglets du même genre que celles utilisées dans la barre latérale de Weedle.</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-2502" title="Tutoriel jQuery : créer une boîte d'onglets" src="http://www.weedle.fr/wp-content/uploads/2010/01/jQuery_MNML_v1_by_himynameiznate1.png" alt="" width="581" height="380" /></p>
<p><span id="more-2485"></span></p>
<h3><a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a>, présentation de la bibliothèque</h3>
<p style="text-align: justify;">Avant de vous présenter <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a> et de vous parler de son histoire, il est préférable de commencer par le début et de vous expliquer ce qu&#8217;est une bibliothèque. <strong> Il s&#8217;agit d&#8217;un ensemble d&#8217;outils et d&#8217;instructions permettant le <a href="http://www.weedle.fr/tag/developpement/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Développement">développement</a> rapide d&#8217;applications.</strong> Constituée de différentes &laquo;&nbsp;briques&nbsp;&raquo;, elle propose ainsi de nombreuses fonctions destinées à faciliter le travail du développeur. Un bon moyen de ne pas perdre son temps en tout codant de zéro.</p>
<p style="text-align: justify;">Le <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a> est donc une bibliothèque <a href="http://www.weedle.fr/tag/javascript/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Javascript">Javascript</a>, ce qui signifie qu&#8217;elle est entièrement dédiée à ce langage et qu&#8217;elle a pour objectif de simplifier l&#8217;utilisation de certaines commandes. En effet, l&#8217;avènement du Web 2.0 a donné lieu à une véritable révolution en matière de <a href="http://www.weedle.fr/tag/developpement/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Développement">développement</a> web. <strong>Les sites ne se contentent ainsi plus de présenter de l&#8217;information, ils se doivent en effet de proposer une interface riche et une expérience utilisateur améliorée. </strong>C&#8217;est ainsi que l&#8217;on a vu apparaître de véritables <em>webwares</em> <em>(ou applications web)</em> finalement très proches des fonctions proposées par un logiciel traditionnel.</p>
<p style="text-align: justify;">Pour en finir avec cette courte présentation, on ajoutera simplement que <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a> a vu le jour en 2006.</p>
<h3><a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a>, l&#8217;installation</h3>
<p style="text-align: justify;">Bien que le terme soit assez mal choisi <em>(on installe un programme, pas une bibliothèque)</em>, le fait est que <strong>nous allons devoir commencer par intégrer <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a> à notre site</strong> pour pouvoir profiter de toutes ses possibilités. La procédure à suivre est relativement simple. Pour commencer, il est nécessaire de se rendre sur le site officiel, <a title="Télécharger jQuery" href="http://www.jquery.com" target="_blank">http://www.jquery.com</a>, et de télécharger notre bibliothèque, soit en version complète, soit en version compressée. Précisons juste que la différence entre ces deux versions est assez simple : la version compressée, légère mais illisible, convient aux sites en production alors que la version complète, plus lourde mais plus claire, vous permettra de mieux comprendre comment les choses se passent.</p>
<p style="text-align: justify;">Une fois le fichier téléchargé, nous allons devoir le lier à notre site. Pour se faire, dans le code source de votre site, entre les balise &lt;head&gt; et &lt;/head&gt;, nous allons simplement ajouter la ligne suivante :</p>
<p style="text-align: justify;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;VOTRE_FICHIER.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> <span style="color: #339933;">/&gt;</span></pre></td></tr></table></div>

<p style="text-align: justify;">Précisons que tous vos <a href="http://www.weedle.fr/tag/scripts/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Scripts">scripts</a> <a href="http://www.weedle.fr/tag/javascript/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Javascript">Javascript</a> devront <strong>nécessairement </strong>se situer après cette ligne. Sans cela, ils ne seront pas correctement interprétés. De la même manière, assurez-vous que le chemin indiqué est correct.</p>
<h3>Tutoriel <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a> : écrire le squelette de notre boîte d&#8217;onglets</h3>
<p style="text-align: justify;">La première étape de notre tutoriel est relativement simple puisque nous allons devoir commencer par créer<strong> le squelette de notre boîte d&#8217;onglets</strong> et donc définir sa structure HTML ainsi que ses CSS. Pour se faire, vous aurez besoin d&#8217;un minimum de connaissances en la matière.</p>
<h4>Etape 1 : la structure HTML</h4>
<p style="text-align: justify;">Notre boîte d&#8217;onglets sera constituée de plusieurs éléments. Nous aurons tout d&#8217;abord une liste horizontale comprenant nos trois onglets dotés d&#8217;un ID unique. En dessous, nous aurons trois DIV portant chacun un ID unique aussi. Globalement, votre code devrait ressembler à ça :</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="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>ul id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;cap_nav&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;tab_1&quot;</span> <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;cap_onglet cap_active&quot;</span> title<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;content_1&quot;</span><span style="color: #339933;">&gt;</span>Onglet <span style="color: #CC0000;">1</span><span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;tab_2&quot;</span> <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;cap_onglet&quot;</span> title<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;content_2&quot;</span><span style="color: #339933;">&gt;</span>Onglet <span style="color: #CC0000;">2</span><span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;tab_3&quot;</span> <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;cap_onglet&quot;</span> title<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;content_3&quot;</span><span style="color: #339933;">&gt;</span>Onglet <span style="color: #CC0000;">3</span><span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;content_1&quot;</span> <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;cap_content&quot;</span><span style="color: #339933;">&gt;</span>Content <span style="color: #CC0000;">1</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;content_2&quot;</span> <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;cap_content&quot;</span><span style="color: #339933;">&gt;</span>Content <span style="color: #CC0000;">2</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;content_3&quot;</span> <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;cap_content&quot;</span><span style="color: #339933;">&gt;</span>Content <span style="color: #CC0000;">3</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p style="text-align: justify;">Dans un premier temps, je vous recommande de ne pas faire de fioritures. <strong>Une fois que vous aurez vérifié le bon fonctionnement de votre boîte à onglets, vous pourrez commencer à les personnaliser.</strong> Avoir une structure simplifiée et épurée vous permettra de résoudre plus facilement les éventuels bogues que vous pourriez rencontrer.</p>
<p style="text-align: justify;">Précisons également que tous nos onglets portent la classe &laquo;&nbsp;cap_onglet&nbsp;&raquo; mais que nous avons ajouté la classe &laquo;&nbsp;cap_active&nbsp;&raquo; au premier pour qu&#8217;il soit affiché par défaut.</p>
<h4>Etape 2 : les CSS</h4>
<p style="text-align: justify;">Là encore, afin de conserver une certaine lisibilité<em> (et donc vous faciliter les choses)</em>, le morceau de code qui suit ne comporte aucune fioriture, <strong>uniquement</strong> les propriétés indispensables pour que notre boîte d&#8217;onglets puisse fonctionner dans de bonnes conditions.</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
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.cap_onglet</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.cap_active</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">cursor</span> <span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">float</span> <span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.cap_onglet</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#863486</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.cap_active</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">color</span> <span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
div<span style="color: #cc00cc;">#content_2</span><span style="color: #00AA00;">,</span> div<span style="color: #cc00cc;">#content_3</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></pre></td></tr></table></div>

<p style="text-align: justify;">Plusieurs choses à signaler ici. En premier lieu, on va utiliser deux classes pour les onglets : la classe  &nbsp;&raquo;.cap_onglet&nbsp;&raquo; et la classe &laquo;&nbsp;.cap_active&nbsp;&raquo;. Ainsi, nous pourrons modifier l&#8217;apparence de l&#8217;onglet actif <em>(sur Weedle, ce dernier est noir)</em>. Même chose, nous ajoutons la propriété &laquo;&nbsp;cursor:pointer&nbsp;&raquo; dans un souci d&#8217;accessibilité : en passant leur curseur sur nos onglets, les internautes verront qu&#8217;ils peuvent cliquer dessus.</p>
<p style="text-align: justify;">Enfin, par défaut, nos DIV &laquo;&nbsp;content_2&#8243; et &laquo;&nbsp;content_3&#8243; sont masqués. Ce n&#8217;est pas le cas de &laquo;&nbsp;content_1&#8243; car il est affiché par défaut.</p>
<h3>Tutoriel <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a> : écrire le script qui animera l&#8217;ensemble</h3>
<p style="text-align: justify;">En l&#8217;état, notre boîte d&#8217;onglets est complètement figée. Si nous cliquons sur l&#8217;un de ces derniers, rien ne se passe. C&#8217;est normal, car il manque encore une dernière étape, la plus complexe pour les néophytes : le script. Il faudra bien entendu le copier entre les balise &lt;head&gt; et &lt;/head&gt;, <strong>juste après</strong> la ligne qui appelle le fichier <a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a>.</p>
<p style="text-align: justify;">Afin de le rendre plus clair pour vous, je l&#8217;ai commenté et nous allons ensuite l&#8217;expliquer en détails.</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
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script text<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</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;">// Lorsqu'on clique sur un onglet</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;li.cap_onglet&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><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// On les met tous en inactif</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.cap_active&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;cap_active&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// On met l'onglet cliqué en actif</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;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;cap_active&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// On cache toutes les boîtes de contenu</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.cap_content&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// On affiche la boîte de contenu liée à notre onglet</span>
            <span style="color: #003366; font-weight: bold;">var</span> contenu_aff <span style="color: #339933;">=</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;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;title&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#&quot;</span> <span style="color: #339933;">+</span> contenu_aff<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</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>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p style="text-align: justify;">Dans un premier temps, on attend la fin du chargement de la page<em> (ce qui correspond à la première ligne de notre script)</em>. Ensuite, on appelle tous les onglets possédant la classe &laquo;&nbsp;cap_onglet&nbsp;&raquo;.<strong> Les lignes qui suivent ne concerneront que ces derniers. </strong></p>
<p style="text-align: justify;">On commence par retirer la classe &laquo;&nbsp;cap_active&nbsp;&raquo; à <strong>tous </strong>les onglets, puis on l&#8217;ajoute à celui sur lequel on vient de cliquer afin de changer son apparence. On enchaine ensuite en cachant toutes les boîtes de contenu <em>(c&#8217;est le fameux &laquo;&nbsp;slideUp&nbsp;&raquo;)</em> et on termine en déroulant uniquement la boîte liée à l&#8217;onglet sur lequel on vient de cliquer <em>(le &laquo;&nbsp;slideDown&nbsp;&raquo;)</em>.</p>
<p style="text-align: justify;">Petite précision à ce sujet. <strong>Pour trouver la boîte de contenu liée à l&#8217;onglet cliqué, on passe par le contenu de la balise &laquo;&nbsp;title&nbsp;&raquo; de ce dernier</strong>. Si vous regardez attentivement notre structure HTML, vous pourrez remarquer que tous les onglets possèdent un &laquo;&nbsp;title&nbsp;&raquo; unique qui n&#8217;est autre que l&#8217;ID du DIV rattaché.</p>
<h3>Et pour aller plus loin</h3>
<p style="text-align: justify;"><strong>En l&#8217;état, nos onglets fonctionnent parfaitement mais il reste encore beaucoup de choses à faire, notamment au niveau des CSS de chaque élément.</strong> J&#8217;aurais pu y consacrer une rubrique dans cet article mais j&#8217;ai préféré me concentrer sur l&#8217;essentiel et ce sera donc à vous de compléter ce point.</p>
<p style="text-align: justify;">En revanche, <strong><a href="http://www.weedle.fr/tag/jquery/" class="st_tag internal_tag" rel="tag" title="Posts tagged with jQuery">jQuery</a> </strong>propose de nombreux autres effets que le &laquo;&nbsp;slideUp&nbsp;&raquo; ou le &laquo;&nbsp;slideDown&nbsp;&raquo;. Si ces derniers ne vous conviennent pas, ou si vous souhaitez en expérimenter d&#8217;autres, il suffit de vous reporter à <a title="jQuery : tous les effets" href="http://docs.jquery.com/Effects" target="_blank">la liste du site officiel</a>. Au passage, vous trouverez également à cette adresse une documentation complète pour aller un peu plus loin.</p>
<p style="text-align: justify;">Bien évidemment, je ne manquerai pas de vous proposer d&#8217;autres tutoriels sur le sujet dans les semaines qui viennent. En tout cas, j&#8217;espère que celui-ci vous aidera à mieux comprendre le fonctionnement de la bibliothèque.</p>
<p style="text-align: justify;"><a href="http://himynameiznate.deviantart.com/art/jQuery-MNML-v1-46544618" target="_blank">Crédits Photo</a></p>
<p style="text-align: justify;">
<p><small>Cet article original a &eacute;t&eacute; publi&eacute; sur <a href="http://www.weedle.fr" title="Weedle, tout sur le design, l'illustration, le motion et WordPress">Weedle</a>. <br />Toute reproduction, m&ecirc;me partielle, est interdite sans l'accord explicite de ses auteurs sauf citation de quelques lignes accompagn&eacute;es d'un lien vers ce billet.<br /> Si vous aimez <a href="http://www.weedle.fr" title="Weedle, tout sur le design, l'illustration, le motion et WordPress">Weedle</a>, vous pouvez nous rejoindre sur <a href="http://www.twitter.com/weedlefr" title="Weedle sur Twitter">Twitter</a>, sur <a href="http://www.facebook.fr/frederic.pereira" title="Weedle sur Facebook">Facebook</a> ou rejoindre notre groupe sur <a href="http://www.flickr.com/groups/" title="Weedle sur Flickr">Flickr</a>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.weedle.fr/tutoriel-jquery-creer-boite-onglets/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>
