<?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>Antoine.Guiral.Info &#187; JS</title>
	<atom:link href="http://antoine.guiral.info/category/js/feed/" rel="self" type="application/rss+xml" />
	<link>http://antoine.guiral.info</link>
	<description></description>
	<lastBuildDate>Mon, 15 Feb 2010 16:24:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>[google closure] Hello world avec Closure Library</title>
		<link>http://antoine.guiral.info/2009/12/30/google-closure-hello-world-avec-closure-library/</link>
		<comments>http://antoine.guiral.info/2009/12/30/google-closure-hello-world-avec-closure-library/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 23:08:02 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[closure library]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[poo]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[Veille]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://antoine.guiral.info/?p=616</guid>
		<description><![CDATA[Allez hop, maintenant que vous connaissez Google Closure on va pouvoir attaquer les tutoriels   Bien sûr on ne va pas echapper au traditionnel &#171;&#160;hello world&#160;&#187;  
Première étape, chopper la &#171;&#160;Closure Library&#171;&#160;. Il va falloir faire un checkout SVN du projet.
Cette ligne de commande suffit (placez vous dans le dossier de votre projet ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Allez hop, maintenant que vous connaissez <a href="http://antoine.guiral.info/2009/12/26/google-closure-le-framework-javascript-de-google/">Google Closure </a>on va pouvoir attaquer les tutoriels <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Bien sûr on ne va pas echapper au traditionnel &laquo;&nbsp;hello world&nbsp;&raquo; <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Première étape, chopper la &laquo;&nbsp;<strong>Closure Library</strong>&laquo;&nbsp;. Il va falloir faire un checkout SVN du projet.</p>
<p>Cette ligne de commande suffit (placez vous dans le dossier de votre projet <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ). Sinon utilisez votre client SVN préféré&#8230;</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="bash" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">svn checkout http://closure-library.googlecode.com/svn/trunk/ closure-library-read-only</div></li></ol></div></div>
<p>Voila, maintenant vous avez la <strong>Closure Library</strong> nous allons pouvoir attaquer les choses sérieuses <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>L&#8217;objectif va être de créer un script javascript qui va créer un noeud dans l&#8217;arbre DOM de la page pour y insérer une balise H1 comprenant le texte&#8230;.&nbsp;&raquo;hello world&nbsp;&raquo;! </p>
<p>Allez C&#8217;est partit, créez un fichier javascript et appelez le, heu&#8230;hello.js.</p>
<p>A l&#8217;intérieur de celui ci, copiez ce petit bout de code. Essayer de le comprendre, les explications vont suivre <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="javascript" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//on appelle les libs google</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">goog.<span style="color: #006600;">require</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'goog.dom'</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//on crée une fonction qui dit bonjour &lt;img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /&gt;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> ditBonjour<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900; font-style: italic;">//on crée notre balise H1</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> newTitle = goog.<span style="color: #006600;">dom</span>.<span style="color: #006600;">createDom</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'h1'</span>, <span style="color: #66cc66;">&#123;</span><span style="color: #3366CC;">'style'</span>: <span style="color: #3366CC;">'background-color:#EEE'</span><span style="color: #66cc66;">&#125;</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #3366CC;">'Hello world!'</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900; font-style: italic;">//puis on l'append au body de notre page html</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; goog.<span style="color: #006600;">dom</span>.<span style="color: #006600;">appendChild</span><span style="color: #66cc66;">&#40;</span>document.<span style="color: #006600;">body</span>, newTitle<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div>
<p>Je pense que les commentaires dans le code ont dû vous aider :p Si je résume. Dans un premier temps on fait appel aux librairies google. &laquo;&nbsp;goog&nbsp;&raquo; est le namespace utilisé par google. Donc on utilise la méthode <em>require</em> du namespace &laquo;&nbsp;goog&nbsp;&raquo; et on lui demande de charger le namespace &laquo;&nbsp;goog.dom&nbsp;&raquo; afin de pouvoir utiliser ses méthodes. Les namespaces sont étroitements liés à l&#8217;objet, vous en déduirez qu&#8217;il va être très facile de faire du javascript objet avec <strong>Closure Library</strong>!! Ensuite nous créons notre balise h1 en utilisant la méthode &laquo;&nbsp;createDom&nbsp;&raquo; du namespace (ou package en java) &laquo;&nbsp;goog.dom&nbsp;&raquo; (lui même dans le namespace goog, vous suivez?). 3 paramètres : le type de balise qu&#8217;on veut créer, les attributs de cette balises au format json (ici des styles) et enfin le contenu de la balise.</p>
<p>Testons maintenant notre script. Un petit fichier html, allez, soyons fou : index.html.</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="html4strict" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;closure-library-read-only/closure/goog/base.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;hello.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">&lt;body</span></a> <span style="color: #000066;">onload</span>=<span style="color: #ff0000;">&quot;ditBonjour()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span></div></li></ol></div></div>
<p>Pas besoin d&#8217;explication je pense à ce niveau <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  On link les librairies et notre script puis on appelle notre méthode au chargement de la page. </p>
<p>Plus qu&#8217;à tester dans votre navigateur favori!! (chrome? firefox?)<!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2009/12/26/google-closure-le-framework-javascript-de-google/" title="<!--:fr-->[google closure] le framework javascript de google<!--:-->"><!--:fr-->[google closure] le framework javascript de google<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li><li><a href="http://antoine.guiral.info/2010/02/03/facebook-php-hiphop-for-php-une-petite-revolution-dans-le-monde-du-developpement-web-et-de-php/" title="[facebook php] hiphop for php : une petite révolution dans le monde du développement web et de php">[facebook php] hiphop for php : une petite révolution dans le monde du développement web et de php</a></li><li><a href="http://antoine.guiral.info/2009/07/17/google-rajoute-une-couche-sociale-a-google-reader/" title="<!--:fr-->google rajoute une couche sociale à google reader<!--:-->"><!--:fr-->google rajoute une couche sociale à google reader<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/16/poo-php-mysql-lextension-objet-de-mysql-en-php-mysqli/" title="<!--:fr-->[poo php mysql] l&#8217;extension objet de mysql en php : mysqli<!--:-->"><!--:fr-->[poo php mysql] l&#8217;extension objet de mysql en php : mysqli<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/07/poo-php-le-pattern-factory-1/" title="<!--:fr-->[poo php] le pattern factory #1<!--:-->"><!--:fr-->[poo php] le pattern factory #1<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/03/poo-php-notre-premiere-classe-en-action/" title="<!--:fr-->[poo php] notre première classe en action<!--:-->"><!--:fr-->[poo php] notre première classe en action<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/" title="<!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:-->"><!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2009/12/30/google-closure-hello-world-avec-closure-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[tuto mozilla jetpack] Débuter avec jetpack</title>
		<link>http://antoine.guiral.info/2009/11/04/tuto-mozilla-jetpack-debuter-avec-jetpack/</link>
		<comments>http://antoine.guiral.info/2009/11/04/tuto-mozilla-jetpack-debuter-avec-jetpack/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 11:23:46 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://antoine.guiral.info/?p=278</guid>
		<description><![CDATA[Je regarde depuis plusieurs mois du coté des extensions firefox. Deux options, soit me mettre au xul pour fournir un beau .xpi à installer. Soit utiliser jetpack, une des dernières nouveautés sortie du labs de mozilla.
Je me suis tourné vers jetpack. C&#8217;est tout neuf, c&#8217;est plutôt simle (javascript+html+css) et l&#8217;installation d&#8217;un plugin ne demande pas ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Je regarde depuis plusieurs mois du coté des extensions firefox. Deux options, soit me mettre au xul pour fournir un beau .xpi à installer. Soit utiliser <a title="Jetpack de mozilla" href="https://jetpack.mozillalabs.com/index.html" target="_blank">jetpack</a>, une des dernières nouveautés sortie du labs de mozilla.</p>
<p>Je me suis tourné vers jetpack. C&#8217;est tout neuf, c&#8217;est plutôt simle (javascript+html+css) et l&#8217;installation d&#8217;un plugin ne demande pas de redémarrage du navigateur <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Seul contrainte, utiliser firefox 3.5 et plus.</p>
<p>Première étape, il faut installer jetpack sur votre navigateur. Pour cela, cliquez sur le gros lien tout en bas de <a title="Installer jetpack" href="https://jetpack.mozillalabs.com/index.html" target="_blank">cette page</a>.</p>
<p>Ensuite tout se joue sur la page <a title="vous devez être sur firefox!" href="about:jetpack">about:jetpack</a>.</p>
<div id="attachment_279" class="wp-caption aligncenter" style="width: 618px"><a rel="attachment wp-att-279" href="http://antoine.guiral.info/2009/11/04/tuto-mozilla-jetpack-debuter-avec-jetpack/blog_jetpack_1/"><img class="size-full wp-image-279 " title="about:jetpack" src="http://antoine.guiral.info/wp-content/uploads/2009/11/blog_jetpack_1.png" alt="capture de about:jetpack" width="608" height="118" /></a><p class="wp-caption-text">capture de about:jetpack</p></div>
<p>Pour commencer, 4 onglets sont importants :</p>
<ul>
<li>Develop : une console en ligne pour tester directement votre code (et ca c&#8217;est magique)</li>
<li>Installed features : pour vois les extensions déjà installées, utile pour le petit bouton refresh</li>
<li>Tutorial : pour commencer <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </li>
<li>API référence : une <span style="text-decoration: line-through;">très</span> petite documentation sur les fonctions diposnible</li>
</ul>
<p>Avant de rentrer dans le vif du sujet, je vous propose d&#8217;aller sur la page &laquo;&nbsp;Tutorial&nbsp;&raquo;. Vous allez trouver plusieurs bloc de code. Vous pouvez directement les tester en cliquant dessus pour les passer en mode édition, puis en testant le code en cliquant sur le petit lien juste en dessous du code &laquo;&nbsp;try out this code&nbsp;&raquo;.</p>
<p style="text-align: center;"><a rel="attachment wp-att-282" href="http://antoine.guiral.info/2009/11/04/tuto-mozilla-jetpack-debuter-avec-jetpack/blog_jetpack_2/"><img class="aligncenter size-full wp-image-282" title="exemple de code " src="http://antoine.guiral.info/wp-content/uploads/2009/11/blog_jetpack_2.png" alt="exemple de code " width="581" height="237" /></a></p>
<p style="text-align: left;">Vous pouvez alors cliquer sur le petit &laquo;&nbsp;Boom!&nbsp;&raquo; en bas a droite de la status bar. Je ne pense pas avoir besoin de détailler le code, il est plus que limpide <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  C&#8217;est toute la force de jetpack : c&#8217;est facile.</p>
<p style="text-align: left;">Dans un prochain billet, nous fabriquerons notre première extensions. En attendant vous pouvez vous amuser à bidouiller un peu ce code ou repartir de zéro dans l&#8217;onglet &laquo;&nbsp;Develop&nbsp;&raquo; !</p>
<p style="text-align: left;"><em>Stay tuned !</em></p>
<p><!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/" title="<!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:-->"><!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/15/tuto-jquery-cadres-extensibles-animes-avec-jquery/" title="<!--:fr-->[tuto jquery] cadres extensibles animés avec jquery<!--:-->"><!--:fr-->[tuto jquery] cadres extensibles animés avec jquery<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/13/tuto-cadre-avec-bordures-extensibles-valide-xhtml-css/" title="<!--:fr-->[tuto web] cadre avec bordures extensibles valide xhtml/css<!--:-->"><!--:fr-->[tuto web] cadre avec bordures extensibles valide xhtml/css<!--:--></a></li><li><a href="http://antoine.guiral.info/2010/01/06/tuto-microformat-utiliser-le-microformat-hcalendar/" title="[tuto microformat] utiliser le microformat hCalendar">[tuto microformat] utiliser le microformat hCalendar</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2009/11/04/tuto-mozilla-jetpack-debuter-avec-jetpack/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Accessibilité : Faire du javascript non-intrusif</title>
		<link>http://antoine.guiral.info/2009/05/02/accessibilite-faire-du-javascript-non-intrusif/</link>
		<comments>http://antoine.guiral.info/2009/05/02/accessibilite-faire-du-javascript-non-intrusif/#comments</comments>
		<pubDate>Sat, 02 May 2009 18:03:57 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[accessibilité]]></category>
		<category><![CDATA[concept]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://antoine.guiral.info/?p=189</guid>
		<description><![CDATA[Aujourd&#8217;hui, en accord avec les standards actuels, il est important de faire des sites accessibles. Et parmi les principes d&#8217;accessibilité, il en est un qui nous concerne, nous les développeurs, particulièrement. Le fait de faire du javascript non intrusif.
Et dans cet optique, je crois que le plus dur n&#8217;est pas la réalisation technique mais l&#8217;adaptation ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Aujourd&#8217;hui, en accord avec les standards actuels, il est important de faire des sites <strong>accessibles</strong>. Et parmi les principes d&#8217;accessibilité, il en est un qui nous concerne, nous les développeurs, particulièrement. Le fait de faire du <strong>javascript non intrusif</strong>.<!--:--><span id="more-189"></span><!--:fr--></p>
<p>Et dans cet optique, je crois que le plus dur n&#8217;est pas la réalisation technique mais l&#8217;adaptation &laquo;&nbsp;philosophique&nbsp;&raquo; de la conception d&#8217;un site web. En effet, on a souvent tendance à vouloir faire les choses trop vite, à vouloir que notre travail soit de suite joli, hyper fonctionnel avec de l&#8217;ajax dans tout les sens, etc etc&#8230;</p>
<p><!--:--><!--more--><!--:fr--></p>
<p>Mais cette façon de penser nous fait souvent passer à coté de l&#8217;essentiel. Prenons un exemple simple : un formulaire d&#8217;inscription. De manière classique, on voudrait, dès le squelette du formulaire fini, réaliser les contrôles en javascript sur le mot de passe ou la validité des champs. Or imaginez un instant que le javascript soit désactivé!! Dans le meilleur des cas vous ajoutez un champ incomplet dans votre base de données. Dans le pire des cas, l&#8217;utilisateur ne pourra pas s&#8217;inscrire et aura droit à un magnifique message d&#8217;erreur. L&#8217;idéal serait de d&#8217;abord réaliser tout les contrôles coté serveur. Cela nous permet de renvoyer des messages d&#8217;erreurs adaptés et de contrôler nos enregistrement en base de données. Mais surtout, notre version dégradée (sans javascript) reste fonctionnelle!!</p>
<p>Donc ca c&#8217;était pour le coté philosophique du <strong>javascript non intrusif</strong>. Mettons un peu les mains dans le cambouis.</p>
<p>Je vous propose un petit screencast que j&#8217;ai réalisé et qui explique comment faire un formulaire d&#8217;inscription accessible (au moins au niveau des contrôles, ce qui correspond pour moi à la base). Pour votre confort je vous conseille de le visionner en HD (le texte est difficilement lisible sinon&#8230;) et en plein écran <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=4444965&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=4444965&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/4444965">javascript non intrusif [accessibilité]</a> from <a href="http://vimeo.com/user1255820">Antoine Guiral</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Bien sûe je reste ouvert à vos questions, critiques, suggestions tant sur le font que sur la forme (le screencast <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ).</p>
<p>Stay tuned <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/" title="<!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:-->"><!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/16/annonce-prochain-tutoriels-de-lajax-jquery-tuto/" title="<!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:-->"><!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/03/poo-php-notre-premiere-classe-en-action/" title="<!--:fr-->[poo php] notre première classe en action<!--:-->"><!--:fr-->[poo php] notre première classe en action<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li><li><a href="http://antoine.guiral.info/2010/01/06/tuto-microformat-utiliser-le-microformat-hcalendar/" title="[tuto microformat] utiliser le microformat hCalendar">[tuto microformat] utiliser le microformat hCalendar</a></li><li><a href="http://antoine.guiral.info/2009/12/26/google-closure-le-framework-javascript-de-google/" title="<!--:fr-->[google closure] le framework javascript de google<!--:-->"><!--:fr-->[google closure] le framework javascript de google<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2009/05/02/accessibilite-faire-du-javascript-non-intrusif/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>[tuto jquery] drag&#8217;n drop avec jquery et ajax V2</title>
		<link>http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/</link>
		<comments>http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 21:12:31 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[antoine]]></category>
		<category><![CDATA[concept]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://antoine.guiral.info/?p=114</guid>
		<description><![CDATA[Ca y est, cela fait un mois que l&#8217;article que j&#8217;ai rédigé pour linux+ magasine est sorti. Je peux donc vous le faire partager sur ce blog. Vous allez me dire que c&#8217;est du déjà vu&#8230;oui! C&#8217;est une mise à jour par rapport aux nouvelle versions de jquery et de jquery UI. Le première version ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Ca y est, cela fait un mois que l&#8217;article que j&#8217;ai rédigé pour linux+ magasine est sorti. Je peux donc vous le faire partager sur ce blog. Vous allez me dire que c&#8217;est du déjà vu&#8230;oui! C&#8217;est une mise à jour par rapport aux nouvelle versions de jquery et de <a href="http://antoine.guiral.info/2008/05/07/annonce-jquery-ui-fait-peau-neuve/">jquery UI</a>. Le première version de ce tuto était faite en deux parties : une <a href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/">partie sur les drag &#8216;n drop</a> et l&#8217;autre sur<a href="http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%E2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/"> les traitement en ajax effectués après le drop</a>.<br />
<!--:--><span id="more-114"></span><!--:fr--><br />
Là l&#8217;article propose les bases pour bien débuter avec jQuery puis le tutoriel sur les drag&#8217;n drop. Vous en apprendrez plus sur les sélécteurs jQuery avec XPATH qui donne le tournis quand on l&#8217;approfondit.</p>
<p>Bien sûr je suis ouvert à vos commentaires, questions, suggestions <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><object id="doc_33952786810342" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%" height="500" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="name" value="doc_33952786810342" /><param name="align" value="middle" /><param name="quality" value="high" /><param name="play" value="true" /><param name="loop" value="true" /><param name="scale" value="showall" /><param name="wmode" value="opaque" /><param name="devicefont" value="false" /><param name="bgcolor" value="#ffffff" /><param name="menu" value="true" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://documents.scribd.com/ScribdViewer.swf?document_id=6374723&amp;access_key=key-pp7p0f2ypajdemhkqgu&amp;page=&amp;version=1&amp;auto_size=true&amp;viewMode=" /><param name="allowfullscreen" value="true" /><embed id="doc_33952786810342" type="application/x-shockwave-flash" width="100%" height="500" src="http://documents.scribd.com/ScribdViewer.swf?document_id=6374723&amp;access_key=key-pp7p0f2ypajdemhkqgu&amp;page=&amp;version=1&amp;auto_size=true&amp;viewMode=" allowscriptaccess="always" allowfullscreen="true" menu="true" bgcolor="#ffffff" devicefont="false" wmode="opaque" scale="showall" loop="true" play="true" quality="high" align="middle" name="doc_33952786810342"></embed></object></p>
<div style="font-size: 10px; text-align: center; width: 100%;"><a href="http://www.scribd.com/doc/6374723/2627282930313233jqueryfrmt">26_27_28_29_30_31_32_33__jquery_fr_mt</a> &#8211; <a href="http://www.scribd.com/upload">Upload a Document to Scribd</a></div>
<p>Allé, je n&#8217;en dis pas plus et vous laisse découvrir la suite <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  :<!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/16/annonce-prochain-tutoriels-de-lajax-jquery-tuto/" title="<!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:-->"><!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/02/accessibilite-faire-du-javascript-non-intrusif/" title="<!--:fr-->Accessibilité : Faire du javascript non-intrusif<!--:-->"><!--:fr-->Accessibilité : Faire du javascript non-intrusif<!--:--></a></li><li><a href="http://antoine.guiral.info/2010/01/06/tuto-microformat-utiliser-le-microformat-hcalendar/" title="[tuto microformat] utiliser le microformat hCalendar">[tuto microformat] utiliser le microformat hCalendar</a></li><li><a href="http://antoine.guiral.info/2009/12/26/google-closure-le-framework-javascript-de-google/" title="<!--:fr-->[google closure] le framework javascript de google<!--:-->"><!--:fr-->[google closure] le framework javascript de google<!--:--></a></li><li><a href="http://antoine.guiral.info/2009/05/03/poo-php-notre-premiere-classe-en-action/" title="<!--:fr-->[poo php] notre première classe en action<!--:-->"><!--:fr-->[poo php] notre première classe en action<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>[tuto jQuery] navigation en ajax non-intrusif (2/2)</title>
		<link>http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/</link>
		<comments>http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/#comments</comments>
		<pubDate>Fri, 02 May 2008 00:09:49 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[2.0]]></category>
		<category><![CDATA[accessibilité]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[concept]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://antoine.guiral.info/?p=94</guid>
		<description><![CDATA[Vous l&#8217;attendiez avec impatience, la voila! La fin du tutoriel pour faire une navigation ajaxifiée tout en restant accessible. Un petit point sur ce que l&#8217;on a déjà fait :

La partie php qui va chercher le bon article en fonction des paramètres
Notre squelette XHTML
un peu d&#8217;habillage CSS

Nous allons maintenant jQueriser notre document. Cette transformation va ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Vous l&#8217;attendiez avec impatience, la voila! La fin du <a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/">tutoriel pour faire une navigation ajaxifiée </a>tout en restant accessible. Un petit point sur ce que l&#8217;on a déjà fait :<!--:--><span id="more-94"></span><!--:fr--></p>
<ul>
<li>La partie php qui va chercher le bon article en fonction des paramètres</li>
<li>Notre squelette XHTML</li>
<li>un peu d&#8217;habillage CSS</li>
</ul>
<p>Nous allons maintenant jQueriser notre document. Cette transformation va se présenter en trois parties.</p>
<h2 style="padding-left: 30px;">Appeler nos script</h2>
<p>Il faut modifier notre squelette xhtml afin de lier nos scripts à notre page. Cela se passe entre les balises head. Il faut préalablement <a title="jQuery" href="http://docs.jquery.com/Downloading_jQuery" target="_blank">télécharger jQuery</a> si vous ne l&#8217;avez pas déjà.</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="html4strict" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- les deux lignes du dessous --&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;jquery.js&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--mce:0--&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;script.js&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--mce:1--&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div></li></ol></div></div>
<h2 style="padding-left: 30px;">La transformation des liens</h2>
<p>En premier lieu nous allons modifier tous nos liens. En effet ils se présentaient sous cette forme :</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="html4strict" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;index.php?page=1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>page 1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span></div></li></ol></div></div>
<p>Or, si nous les gardons sous cette forme  notre page va s&#8217;afficher &laquo;&nbsp;en cascade&nbsp;&raquo; puisque nous afficherions dans notre div &laquo;&nbsp;contenu&nbsp;&raquo;  notre index.php.</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="javascript" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//pour chaque lien contenu dans un élément de liste</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'li&amp;gt;a'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//on récupere le contenu de l'attribut href</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> link=$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//et on remplace le index par page pour obtenir un lien : page.php?page=x&amp;amp;article=x</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span>,link.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;index&quot;</span>,<span style="color: #3366CC;">&quot;page&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div>
<h2 style="padding-left: 30px;">L&#8217; &laquo;&nbsp;ajaxification&nbsp;&raquo; des liens</h2>
<p>Maintenant il faut faire appel à la méthode load de jquery pour charger notre article dans le div &laquo;&nbsp;contenu&nbsp;&raquo;.</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="javascript" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//à chaque clic sur un lien contenu dans un élément de liste</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'li&amp;gt;a'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//on récupère l'attribut href</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> link=$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//et on charge le document avec load dans le div d'id contenu</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#contenu&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">load</span><span style="color: #66cc66;">&#40;</span>link<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div>
<p>Le script final :</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="javascript" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>document<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">ready</span><span style="color: #66cc66;">&#40;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//construction du menu</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//pour chaque lien contenu dans un élément de liste</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'li&amp;gt;a'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//on récupere le contenu de l'attribut href</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> link=$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//et on remplace le index par page pour obtenir un lien : page.php?page=x&amp;amp;article=x</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span>,link.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;index&quot;</span>,<span style="color: #3366CC;">&quot;page&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//à chaque clic sur un lien contenu dans un élément de liste</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'li&amp;gt;a'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//on récupère l'attribut href</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> link=$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//et on charge le document avec load dans le div d'id contenu</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#contenu&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">load</span><span style="color: #66cc66;">&#40;</span>link<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span></div></li></ol></div></div>
<p>Voilà, vous devriez avoir un menu parfaitement fonctionnel. Vous pouvez modifiez votre fichier page.php pour faire des includes de vos fichiers dans les switchs plutôt que d&#8217;écrire votre texte en dur.</p>
<p>Montrez nous vos réalisations et n&#8217;hésiter pas à faire des remarques, poser des questions, etc <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> <!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/" title="<!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:-->"><!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-flex-hello-world-en-flex-il-y-a-un-debut-a-tout/" title="<!--:fr-->[tuto flex] hello world en flex: il y a un début à tout!<!--:-->"><!--:fr-->[tuto flex] hello world en flex: il y a un début à tout!<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/16/annonce-prochain-tutoriels-de-lajax-jquery-tuto/" title="<!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:-->"><!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[tuto jQuery] navigation en ajax non-intrusif (1/2)</title>
		<link>http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/</link>
		<comments>http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/#comments</comments>
		<pubDate>Sun, 20 Apr 2008 13:26:55 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[concept]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://guiralantoine.wordpress.com/?p=79</guid>
		<description><![CDATA[Ca y est, il arrive. Le tutoriel sur la navigation en ajax non-intrusif débarque sur vos écrans! Le but est donc de proposer une navigation en ajax (on ne rechergera que le contenu de la page) qui soit non-intrusive. Cela veut dire que si le javascript n&#8217;est pas activé le site fonctionnera toujours. Un petit ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Ca y est, il arrive. Le tutoriel sur la navigation en ajax non-intrusif débarque sur vos écrans! Le but est donc de proposer une navigation en ajax (on ne rechergera que le contenu de la page) qui soit non-intrusive. Cela veut dire que si le javascript n&#8217;est pas activé le site fonctionnera toujours. <a href="http://www.e-caveavin.com/tuto/tuto_navigajax/" target="_blank">Un petit exemple</a> <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Nous allons commencer par faire notre site de manière classique, celle qui sera affichée quand le javascript sera désactivé. Afin de factoriser le code je vais utiliser du php pour afficher le contenu, mais le fonctionnement serait le même en utilisant différent fichiers.</p>
<p><!--:--><span id="more-79"></span><!--:fr--></p>
<ul>
<li>
<h2>Le XHTML</h2>
</li>
</ul>
<p>Notre fichier html portera l&#8217;extension .php parce que nous allons utiliser le même fichier de base (index.php). Grâce au php nous allons factoriser le code. Cela complique un poil le tuto mais qui peut le plus peut le moins! Donc nous aurons un titre une liste, pour les articles, imbriquée dans une liste pour les pages.</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="html4strict" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">&lt;h1&gt;</span></a></span>Tuto navig ajax non-intrusif<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Pour tester pleinement ce tuto, testez la navigation puis désactivez le javascript et testez la à nouveau</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;”menu”&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">&lt;ul&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">&lt;li&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;”index.php?page=1″&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>page 1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">&lt;li&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;”index.php?page=2″&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>page 2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">&lt;li&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;”index.php?page=3″&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>page 3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/ul.html"><span style="color: #000000; font-weight: bold;">&lt;ul&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">&lt;li&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;”index.php?page=3&amp;amp;article=1″&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>article 1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/li.html"><span style="color: #000000; font-weight: bold;">&lt;li&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;”index.php?page=3&amp;amp;article=2″&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>article 2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;”contenu”&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></div></div>
<ul>
<li>
<h2>Le php</h2>
</li>
</ul>
<p>Rien de très tordu ici : je récupère le numéro de la page que je veux afficher et le numéro de l&#8217;article le cas échéant et je l&#8217;affiche. Plus d&#8217;explications dans les commentaires du code du fichier page.php <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<div class="geshi" style="overflow: auto; width: 560px; height: 300px; padding-bottom: 15px;clear:both"><div class="php" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Normalement ça devrait marcher! Mais ce n<span style="color: #ff0000;">'est pas très beau...</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&lt;ul&gt;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&lt;li&gt;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&lt;h2&gt;Le CSS&lt;/h2&gt;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&lt;/li&gt;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&lt;/ul&gt;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">Un rapide fichier de styles pour avoir quelque chose de moins brut.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&lt;pre lang=&quot;css&quot;&gt;h1{</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">text-align:center;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">}</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">#menu{</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">border:1px solid black;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">width:180px;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">float:left</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">}</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">#menu ul{</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">list-style:none;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">}</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">#contenu{</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">width:800px;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">margin-left:200px</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">}</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;"</span></div></li></ol></div></div>
<p>Hop là! Un titre centré, un coup d'anti-puces (facile celle là...) et un menu qui flotte à gauche du contenu.<br />
La prochaine fois nous grefferons nos scripts jQuery afin de transformer la navigation actuelle en une belle navigation en ajax.<br />
<strong>[edit]</strong> <a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/">La suite est ici <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </a></pre>
<p><!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/" title="<!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:-->"><!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-flex-hello-world-en-flex-il-y-a-un-debut-a-tout/" title="<!--:fr-->[tuto flex] hello world en flex: il y a un début à tout!<!--:-->"><!--:fr-->[tuto flex] hello world en flex: il y a un début à tout!<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/16/annonce-prochain-tutoriels-de-lajax-jquery-tuto/" title="<!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:-->"><!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/31/de-la-bonne-utilisation-des-tableaux/" title="<!--:fr-->De la bonne utilisation des tableaux<!--:-->"><!--:fr-->De la bonne utilisation des tableaux<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/20/tuto-php-generer-des-images-png-dynamiquement-grace-a-php/" title="<!--:fr-->[tuto php] générer des images png dynamiquement grâce à php<!--:-->"><!--:fr-->[tuto php] générer des images png dynamiquement grâce à php<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)</title>
		<link>http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/</link>
		<comments>http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/#comments</comments>
		<pubDate>Sat, 08 Mar 2008 22:03:01 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://guiralantoine.wordpress.com/?p=55</guid>
		<description><![CDATA[Ça y est, la suite est enfin là! Dans la première partie de ce tutoriel nous avions vu comment faire un drag&#8217;n drop avec jQuery. Maintenant nous allons voir comment effectuer notre sauvegarde automatique grâce à l&#8217;AJAX. Il y a deux modifications majeures à apporter à notre code. La première est la partie base de ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Ça y est, la suite est <span style="text-decoration: line-through;">enfin</span> là! Dans <a title="Allez vite voir !!" href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/" target="_blank">la première partie de ce tutoriel</a> nous avions vu comment faire un drag&#8217;n drop avec <a title="La doc en français" href="http://jquery.developpeur-web2.com/">jQuery</a>. Maintenant nous allons voir comment effectuer notre sauvegarde automatique grâce à l&#8217;AJAX. Il y a deux modifications majeures à apporter à notre code. La première est la partie base de données : création des tables, des requêtes,etc&#8230; La seconde est l&#8217;ajout d&#8217;un traitement lors d&#8217;un drop d&#8217;ingrédient dans une recette. Autrement dit, effectuer les requêtes au bon moment.</p>
<ul>
<li>
<h2>La BDD</h2>
</li>
</ul>
<p>Notre base sera composée de 3 tables :</p>
<blockquote>
<ul>
<li>la table recette sera composée d&#8217;un identifiant (id_recette) et d&#8217;un nom de recette (recette).</li>
<li>la table ingrédient avec un identifiant (id_ingredient) et le nom de l&#8217;ingrédient (ingredient).</li>
<li>la table recette_ingredient qui  contiendra les compositions de nos recettes sous la forme de couples id_recette,id_ingredient.</li>
</ul>
</blockquote>
<p>Cette organisation vient de nos cardinalités : un ingrédient peut être dans plusieurs recettes et une recette peut contenir plusieurs ingrédients.</p>
<p>Voici le code SQL pour créer les tables :</p>
<div class="geshi" style="overflow: auto; width: 560px; height: 300px; padding-bottom: 15px;clear:both"><div class="sql" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> <span style="color: #ff0000;">`tuto_drag`</span> ;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`recettes`</span> <span style="color: #66cc66;">&#40;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">`id_recette`</span> INT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> ,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">`recette`</span> VARCHAR<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">50</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span> ENGINE = innodb;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`ingredients`</span> <span style="color: #66cc66;">&#40;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">`id_ingredient`</span> INT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> ,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">`ingredient`</span> VARCHAR<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">50</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span> ENGINE = innodb;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`recette_ingredient`</span> <span style="color: #66cc66;">&#40;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">`refid_ingredient`</span> INT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> ,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">`refid_recette`</span> INT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span> ENGINE = INNODB CHARACTER <span style="color: #993333; font-weight: bold;">SET</span> latin1 COLLATE latin1_swedish_ci</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`recette_ingredient`</span> <span style="color: #993333; font-weight: bold;">ADD</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">`id_ingredient`</span> , <span style="color: #ff0000;">`id_recette`</span> <span style="color: #66cc66;">&#41;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`ingredients`</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">`id_ingredient`</span> , <span style="color: #ff0000;">`ingredient`</span> <span style="color: #66cc66;">&#41;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span>,’oeuf’<span style="color: #66cc66;">&#41;</span>,<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span>,’sucre’<span style="color: #66cc66;">&#41;</span>,<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span>,’farine’<span style="color: #66cc66;">&#41;</span>,<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span>,’sel’<span style="color: #66cc66;">&#41;</span>,<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span>,’lait’<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`recettes`</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">`id_recette`</span> , <span style="color: #ff0000;">`recette`</span> <span style="color: #66cc66;">&#41;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span>,’Pâte à crêpe’<span style="color: #66cc66;">&#41;</span>,<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span>,’Pâte brisée’<span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div>
<ul>
<li>
<h2> Les traitements coté serveur</h2>
</li>
</ul>
<p>Maintenant que nous avons une base de données il faut créer les scripts qui vont nous permettre d&#8217;interagir avec elle. Nous devons pouvoir ajouter une recette, un ingrédient et faire nos sauvegarde de composition de recette. Appelons notre fichier &laquo;&nbsp;traitement.php&nbsp;&raquo;.</p>
<div class="geshi" style="overflow: auto; width: 560px; height: 300px; padding-bottom: 15px;clear:both"><div class="php" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">&lt;?php</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// on se connecte à MySQL</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$mysql_link</span>=<a href="http://www.php.net/mysql_connect"><span style="color: #000066;">mysql_connect</span></a><span style="color: #66cc66;">&#40;</span>”localhost”, “root”, “”<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//on selectionne notre base de donnée</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/mysql_select_db"><span style="color: #000066;">mysql_select_db</span></a><span style="color: #66cc66;">&#40;</span>”tuto_drag”, <span style="color: #0000ff;">$mysql_link</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//une petite fonction qui permet de proteger votre bdd des injections SQL</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> protection<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$string</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/get_magic_quotes_gpc"><span style="color: #000066;">get_magic_quotes_gpc</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/ini_get"><span style="color: #000066;">ini_get</span></a><span style="color: #66cc66;">&#40;</span>’magic_quotes_sybase’<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$string</span> = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">&#40;</span>”””, “‘”,<span style="color: #0000ff;">$string</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$string</span> = <a href="http://www.php.net/stripslashes"><span style="color: #000066;">stripslashes</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$string</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">return</span> <a href="http://www.php.net/mysql_real_escape_string"><span style="color: #000066;">mysql_real_escape_string</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$string</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//nous switchons suivant le parametre “action” vers le cas qui nous interesse</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_REQUEST</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'action'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//je pense que les case sont assez clair</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">case</span> ‘ajout_ingredient_recette’:</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$id_recette</span>=<a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'id_recette'</span><span style="color: #66cc66;">&#93;</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$id_ingredient</span>=<span style="color: #0000ff;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'id_ingredient'</span><span style="color: #66cc66;">&#93;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$sql</span>=’insert into recette_ingredient values<span style="color: #66cc66;">&#40;</span>\”.<span style="color: #0000ff;">$id_recette</span>.’\<span style="color: #ff0000;">',<span style="color: #000099; font-weight: bold;">\</span>.$id_ingredient.’<span style="color: #000099; font-weight: bold;">\'</span>)’;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">$req=mysql_query($sql) or die(’Erreur SQL !</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">’.$sql.’</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">’.mysql_error());</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">break;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">case ’suppression_ingredient_recette’:</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">$id_recette=substr($_GET['</span>id_recette<span style="color: #ff0000;">'],1,1);</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">$id_ingredient=$_GET['</span>id_ingredient<span style="color: #ff0000;">'];</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">$sql=’delete from recette_ingredient where refid_recette=’.$id_recette.’ and refid_ingredient=’.$id_ingredient;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">$req=mysql_query($sql) or die(’Erreur SQL !</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">’.$sql.’</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">’.mysql_error());</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">break;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">}</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">?&gt;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;"</span></div></li></ol></div></div>
<ul>
<li>
<h2>Modification de notre page XHTML</h2>
</li>
</ul>
<p>Alors qu&#8217;allons nous faire de cette page&#8230;Vu que nous voulons ajouter des ingrédients et des recettes dans notre base de données, il faut que nous générions notre page &laquo;&nbsp;creation-recette.html&nbsp;&raquo; dynamiquement. La première chose à faire est donc de renommer notre fichier en &laquo;&nbsp;creation-recette.php&nbsp;&raquo;.  Ensuite deux petites requêtes, avec deux boucles et en avant guingammmmmmmpppppp!</p>
<div class="geshi" style="overflow: auto; width: 560px; height: 300px; padding-bottom: 15px;clear:both"><div class="php" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">&lt;?php</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// on se connecte à MySQL</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$mysql_link</span>=<a href="http://www.php.net/mysql_connect"><span style="color: #000066;">mysql_connect</span></a><span style="color: #66cc66;">&#40;</span>”localhost”, “root”, “”<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//on selectionne notre base de donnée</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/mysql_select_db"><span style="color: #000066;">mysql_select_db</span></a><span style="color: #66cc66;">&#40;</span>”tuto_drag”, <span style="color: #0000ff;">$mysql_link</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//requete pour les recettes</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$sql</span>=’select * from recettes order by recette’;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$req_recettes</span>=<a href="http://www.php.net/mysql_query"><span style="color: #000066;">mysql_query</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$sql</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//requete pour les ingredients</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$sql</span>=’select * from ingredients order by ingredient’;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$req_ingredients</span>=<a href="http://www.php.net/mysql_query"><span style="color: #000066;">mysql_query</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$sql</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a>’</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;html&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;head&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;meta http-equiv=”Content-Type” content=”text/html; charset=iso<span style="color: #cc66cc;">-8859</span><span style="color: #cc66cc;">-1</span>″ /&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script type=”text/javascript” src=”jquery.js”&gt;&lt;/script&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script type=”text/javascript” src=”<span style="color: #000000; font-weight: bold;">interface</span>.js”&gt;&lt;/script&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script type=”text/javascript” src=”script.js”&gt;&lt;/script&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;link rel=”stylesheet” type=”text/css” href=”styles.css” media=”all”/&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/head&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;body&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;div&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;h1&gt;Waouuuuuuuhhhhhh&lt;/h1&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;div <span style="color: #000000; font-weight: bold;">class</span>=”ingredient”&gt;’;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//une petite boucle pour afficher les ingredients</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$data</span>=<a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #000066;">mysql_fetch_assoc</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$req_ingredients</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a>’</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;div id=”‘.<span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'id_ingredient'</span><span style="color: #66cc66;">&#93;</span>.’” <span style="color: #000000; font-weight: bold;">class</span>=”drag”&gt;’.<span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'ingredient'</span><span style="color: #66cc66;">&#93;</span>.’&lt;/div&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">’;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a>’&lt;/div&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">’;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//une autre boucle pour afficher les recettes…</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$data</span>=<a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #000066;">mysql_fetch_assoc</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$req_recettes</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a>’</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;div <span style="color: #000000; font-weight: bold;">class</span>=”recette” id=”‘.<span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'id_recette'</span><span style="color: #66cc66;">&#93;</span>.’”&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;h3&gt;’.<span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'recette'</span><span style="color: #66cc66;">&#93;</span>.’&lt;/h3&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;div <span style="color: #000000; font-weight: bold;">class</span>=”recette_ingredient”&gt;’;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//…si les recettes ont des ingredients il faut les récuperer et les afficher…</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$sql</span>=’select * from recette_ingredient left <a href="http://www.php.net/join"><span style="color: #000066;">join</span></a> ingredients on refid_ingredient=id_ingredient where refid_recette=’.<span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'id_recette'</span><span style="color: #66cc66;">&#93;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$req_compo_recette</span>=<a href="http://www.php.net/mysql_query"><span style="color: #000066;">mysql_query</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$sql</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//…avec une boucle! sans oublié de rajouter l’attribut recette sinon les drop de suppression ne marcherons plus! Allez y testez!</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$data1</span>=<a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #000066;">mysql_fetch_assoc</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$req_compo_recette</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a>’</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;div id=”‘.<span style="color: #0000ff;">$data1</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'id_ingredient'</span><span style="color: #66cc66;">&#93;</span>.’” <span style="color: #000000; font-weight: bold;">class</span>=”drag” recette=”‘.<span style="color: #0000ff;">$data</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'id_recette'</span><span style="color: #66cc66;">&#93;</span>.’”&gt;’.<span style="color: #0000ff;">$data1</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'ingredient'</span><span style="color: #66cc66;">&#93;</span>.’&lt;/div&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">’;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a>’&lt;/div&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/div&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">’;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a>’&lt;/div&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/body&gt;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/html&gt;’;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">?&gt;</span></div></li></ol></div></div>
<ul>
<li>
<h2> Notre script avec l&#8217;AJAX (hyper simple au passage :-p)</h2>
</li>
</ul>
<p>On reprend le script du premier tutoriel en rajoutant la méthode get qui nous permet de faire de l&#8217;AJAX très simplement grâce à jQuery <span style="text-decoration: line-through;">pooooowwwwwaaaaaaaa.</span></p>
<div class="geshi" style="overflow: auto; width: 560px; height: 300px; padding-bottom: 15px;clear:both"><div class="javascript" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//on créé uen fonction pour rendre nos éléments draggable (merci piouPiouM ^^)</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> addDraggable<span style="color: #66cc66;">&#40;</span>el<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">el.<span style="color: #006600;">Draggable</span><span style="color: #66cc66;">&#40;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">revert: <span style="color: #003366; font-weight: bold;">true</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">zIndex: <span style="color: #CC0000;">1000</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ghosting: <span style="color: #003366; font-weight: bold;">true</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">opacity: <span style="color: #CC0000;">0.7</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>document<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">ready</span><span style="color: #66cc66;">&#40;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//Nos élements draggable sont définis ici. Ce sont tous les éléments avec la class CSS ‘.drag’.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addDraggable<span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#40;</span>’.<span style="color: #006600;">drag</span>’<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//le div avec la class ‘.ingredient’ est notre première zone droppable. Elle contient nos ingrédients (original hein!).</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>’.<span style="color: #006600;">ingredient</span>’<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">Droppable</span><span style="color: #66cc66;">&#40;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//elle accept les élément ayant la class ‘drag’</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">accept : ‘drag’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//ici cela affecte des classes css suivant que la zone est active ou hover. Pratique pour changer de style au survol.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//activeclass: ‘activeEmplacement’,</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//hoverclass: ‘hoverEmplacement’,</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//plusieurs zone de tolérance existe. Allez faire un tour sur la doc.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//Ici nous choisissons de pouvoir dropper un élément quand le pointeur de la souris est dans la zone.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">tolerance: ‘pointer’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//on définit ce qu’il va se passer lorsqu’on drop un élément dans la zone. On passe l’élément draggé en paramètre.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ondrop: <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>drag<span style="color: #66cc66;">&#41;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//on récupère l’attribut recette si le drag en possede un</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> id_recette=$<span style="color: #66cc66;">&#40;</span>drag<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span>’recette’<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//et l’id de l’ingredient pour le cas de la suppression</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> id_ingredient=$<span style="color: #66cc66;">&#40;</span>drag<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span>’id’<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//si il en possède un on suprime le drag. Cela correspond à si un ingredient d’une recette est enlevé de sa recette.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//supprimez le bloc et testez!</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>id_recette<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>drag<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">remove</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//nous utilisons la methode get sur l’objet jQuery ($).</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//le premier parametre est la page de script (dans notre cas “traitement.php”)</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//le second est un tableau d’arguments sous la forme clé/valeur</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>”traitement.<span style="color: #006600;">php</span>”,<span style="color: #66cc66;">&#123;</span>action:”suppression_ingredient_recette”,id_ingredient:id_ingredient,id_recette:id_recette<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fit: <span style="color: #003366; font-weight: bold;">true</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//Ici nous allons dropper nos ingrédient pour construire nos recettes.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>’.<span style="color: #006600;">recette_ingredient</span>’<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">Droppable</span><span style="color: #66cc66;">&#40;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">accept : ‘drag’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">activeclass: ‘activeEmplacement’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">hoverclass: ‘hoverEmplacement’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">tolerance: ‘pointer’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ondrop: <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>drag<span style="color: #66cc66;">&#41;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//nous récuperons l’id de la recette. Il est contenu dans le div parent de la zone droppabe (allez revoir le xhtml ;-p).</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> id_recette=$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">parents</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span>’id’<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//on clone l’élément draggable. Cela permet de réutiliser un autre élément pour une autre recette!</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> drag1 = $<span style="color: #66cc66;">&#40;</span>drag<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">clone</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//nous ajoutons un attribut recette ayant pour valeur l’id de la recette.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>drag1<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span>’recette’,id_recette<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//puis nous récuperons l’id de l’ingredient…</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> id_ingredient=$<span style="color: #66cc66;">&#40;</span>drag1<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span>’id’<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//…pour verifier qu’il ne soit pas déjà présent!</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>!$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #66cc66;">&#40;</span>’#’ + id_ingredient<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//s’il n’est pas présent on l’ajoute</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span>drag1<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//on rend notre “clone” draggable</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addDraggable<span style="color: #66cc66;">&#40;</span>drag1<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//même combat pour l’ajax ^^</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>”traitement.<span style="color: #006600;">php</span>”,<span style="color: #66cc66;">&#123;</span>action:”ajout_ingredient_recette”,id_ingredient:id_ingredient,id_recette:id_recette<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//avec un petit effet pour l’apaprition :p</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>drag1<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fadeIn</span><span style="color: #66cc66;">&#40;</span>”slow”<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fit: <span style="color: #003366; font-weight: bold;">true</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div>
<ul>
<li>
<h2>Le CSS</h2>
</li>
</ul>
<p>Bon ben là je vous renvoi vers <a title="Allez vite voir !!" href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/">la première partie du tutoriel</a> <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>Voila! C&#8217;est fini! Bon j&#8217;aurais pu optimiser un peu le code par moment&#8230;en factorisant la connexion à la base, en evitant la requette pour chaque recette&#8230;mais bon ce n&#8217;était pas le but du tuto hein :-p. Si vous voulez vous entrainer vous pouvez par exemple rajouter deux champ qui permettent d&#8217;ajouter une recette et un ingrédient en AJAX!</p>
<p>Si vous avez des questions, comme d&#8217;hab&#8217; n&#8217;hésitez pas je me ferais un plaisir d&#8217;essayer d&#8217;y répondre! Et montrez moi vos essais! <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> <!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/" title="<!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:-->"><!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/16/annonce-prochain-tutoriels-de-lajax-jquery-tuto/" title="<!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:-->"><!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/15/tuto-jquery-cadres-extensibles-animes-avec-jquery/" title="<!--:fr-->[tuto jquery] cadres extensibles animés avec jquery<!--:-->"><!--:fr-->[tuto jquery] cadres extensibles animés avec jquery<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/20/tuto-php-generer-des-images-png-dynamiquement-grace-a-php/" title="<!--:fr-->[tuto php] générer des images png dynamiquement grâce à php<!--:-->"><!--:fr-->[tuto php] générer des images png dynamiquement grâce à php<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)</title>
		<link>http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/</link>
		<comments>http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/#comments</comments>
		<pubDate>Sun, 24 Feb 2008 17:24:19 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[2.0]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[concept]]></category>
		<category><![CDATA[creation]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://guiralantoine.wordpress.com/?p=50</guid>
		<description><![CDATA[Bonjour!
Je profite d&#8217;un peu de répit ce dimanche pour terminer la première partie de ce tutoriel. Nous allons voir comment faire des drag&#8217;n drop (glisser déposer) avec JQuery. Dans un second temps nous verrons comment sauvegarder les modifications directement en base de donnée avec de l&#8217;ajax. Pour voir un exemple je vous propose d&#8217;aller faire ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Bonjour!</p>
<p>Je profite d&#8217;un peu de répit ce dimanche pour terminer la première partie de ce tutoriel. Nous allons voir comment faire des drag&#8217;n drop (glisser déposer) avec <a title="Site non officiel mais en francais sur jquery" href="http://jquery.developpeur-web2.com/" target="_blank">JQuery</a>. Dans un second temps nous verrons comment sauvegarder les modifications directement en base de donnée avec de l&#8217;ajax. Pour voir un exemple je vous propose d&#8217;aller faire un tour sur mon site de gestion d&#8217;une équipe de rugby (projet en cour) : <a title="Allez y testez!" href="http://www.e-caveavin.com/rugby/gerer-effectif.php" target="_blank">teamManagerXV</a>.</p>
<p>Bon allez on attaque?!</p>
<ul>
<li>Le coté client : XHTML</li>
</ul>
<p>Comme d&#8217;habitude le code puis les explications <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<div class="geshi" style="overflow: auto; width: 560px; height: 300px; padding-bottom: 15px;clear:both"><div class="html4strict" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=”Content-<span style="color: #000066;">type</span>” <span style="color: #000066;">content</span>=”<span style="color: #000066;">text</span>/html; <span style="color: #000066;">charset</span>=utf<span style="color: #cc66cc;">-8</span>″ /<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">type</span>=”<span style="color: #000066;">text</span>/javascript” <span style="color: #000066;">src</span>=”jquery.js”<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">type</span>=”<span style="color: #000066;">text</span>/javascript” <span style="color: #000066;">src</span>=”interface.js”<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">type</span>=”<span style="color: #000066;">text</span>/javascript” <span style="color: #000066;">src</span>=”script.js”<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">&lt;link</span></a> <span style="color: #000066;">rel</span>=”stylesheet” <span style="color: #000066;">type</span>=”<span style="color: #000066;">text</span>/css” <span style="color: #000066;">href</span>=”styles.css” <span style="color: #000066;">media</span>=”all”/<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">&lt;h1&gt;</span></a></span>Waouuuuuuuhhhhhh<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">class</span>=”ingredient”<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=”<span style="color: #cc66cc;">1</span>″ <span style="color: #000066;">class</span>=”drag”<span style="color: #000000; font-weight: bold;">&gt;</span></span>sucre<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=”<span style="color: #cc66cc;">2</span>″ <span style="color: #000066;">class</span>=”drag”<span style="color: #000000; font-weight: bold;">&gt;</span></span>lait<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=”<span style="color: #cc66cc;">3</span>″ <span style="color: #000066;">class</span>=”drag”<span style="color: #000000; font-weight: bold;">&gt;</span></span>farine<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=”<span style="color: #cc66cc;">4</span>″ <span style="color: #000066;">class</span>=”drag”<span style="color: #000000; font-weight: bold;">&gt;</span></span>oeuf<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=”<span style="color: #cc66cc;">5</span>″ <span style="color: #000066;">class</span>=”drag”<span style="color: #000000; font-weight: bold;">&gt;</span></span>sel<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">class</span>=”recette” <span style="color: #000066;">id</span>=”r_1″<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/h3.html"><span style="color: #000000; font-weight: bold;">&lt;h3&gt;</span></a></span>Pâte à crêpe<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h3&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">class</span>=”recette_ingredient”<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">class</span>=”recette” <span style="color: #000066;">id</span>=”r_2″<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/h3.html"><span style="color: #000000; font-weight: bold;">&lt;h3&gt;</span></a></span>Pâte brisée<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h3&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">class</span>=”recette_ingredient”<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span></div></li></ol></div></div>
<p>Alors rien de particulier pour le moment en terme de structure du document. Vous pouvez remarquer que nous avons 3 divs &laquo;&nbsp;principaux&nbsp;&raquo; : un pour les ingrédients et un pour chaque recette. Celui pour les ingrédients contient nos éléments draggables tandis que ceux pour les recettes contiennent nos récepteurs (zone de drop).</p>
<ul>
<li>un peu de style : CSS</li>
</ul>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="css" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">div<span style="color: #66cc66;">&#123;</span>border<span style="color: #3333ff;">:<span style="color: #933;">1px</span></span> <span style="color: #993333;">solid</span> <span style="color: #000000; font-weight: bold;">black</span><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #6666ff;">.drag</span>,<span style="color: #6666ff;">.recette_ingredient</span><span style="color: #66cc66;">&#123;</span>height<span style="color: #3333ff;">:<span style="color: #933;">20px</span></span>;width<span style="color: #3333ff;">:<span style="color: #933;">60px</span></span><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div>
<p>Pas grand chose ici! Juste des bordures pour que ce soit &laquo;&nbsp;compréhensible&nbsp;&raquo; et un largeur/hauteur définie pour les zones de drop et les drags.</p>
<ul>
<li> Enfin des trucs cool! Le javascript!</li>
</ul>
<p>Comme notre code est basé sur le <a title="Article wikipedia sur les frameworks" href="http://fr.wikipedia.org/wiki/Framework" target="_blank">framework</a> JQuery il faut que vous téléchargiez la librairie ainsi que la sur-couche &laquo;&nbsp;interface&nbsp;&raquo; (vous pouvez télécharger les deux sur <a title="c'est de la balle" href="http://ui.jquery.com/download" target="_blank">le site d&#8217;interface</a>). Ajustez les noms avec votre fichier xhtml. Enfin créez votre fichier script.js. Je pense avoir suffisament commenté le code pour ne pas revenir dessus. Si vous avez des questions n&#8217;hésitez pas, un petit commentaire et je vous répond dans la journée!</p>
<p><strong>EDIT </strong>: grâce à <a title="vous connaissez the gimp?" href="http://gimp4you.eu.org/" target="_blank">piouPiouM</a> j&#8217;ai pu résoudre le problème du mouseover.</p>
<div class="geshi" style="overflow: auto; width: 560px; height: 300px; padding-bottom: 15px;clear:both"><div class="javascript" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//on créé uen fonction pour rendre nos éléments draggable (merci piouPiouM ^^)</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> addDraggable<span style="color: #66cc66;">&#40;</span>el<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">el.<span style="color: #006600;">Draggable</span><span style="color: #66cc66;">&#40;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">revert: <span style="color: #003366; font-weight: bold;">true</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">zIndex: <span style="color: #CC0000;">1000</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ghosting: <span style="color: #003366; font-weight: bold;">true</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">opacity: <span style="color: #CC0000;">0.7</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>document<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">ready</span><span style="color: #66cc66;">&#40;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//Nos élements draggable sont définis ici. Ce sont tous les éléments avec la class CSS ‘.drag’.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addDraggable<span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#40;</span>’.<span style="color: #006600;">drag</span>’<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//le div avec la class ‘.ingredient’ est notre première zone droppable. Elle contient nos ingrédients (original hein!).</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>’.<span style="color: #006600;">ingredient</span>’<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">Droppable</span><span style="color: #66cc66;">&#40;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//elle accept les élément ayant la class ‘drag’</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">accept : ‘drag’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//ici cela affecte des classes css suivant que la zone est active ou hover. Pratique pour changer de style au survol.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//activeclass: ‘activeEmplacement’,</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//hoverclass: ‘hoverEmplacement’,</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//plusieurs zone de tolerance existe. Allez faire un tour sur la doc.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//Ici nous choisissons de pouvoir dropper un élément quand le pointeur de la souri est dans la zone.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">tolerance: ‘pointer’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//on définit ce qu’il va se passer lorsqu’on drop un élément dans la zone. On passe l’élément draggé en parametre.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ondrop: <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>drag<span style="color: #66cc66;">&#41;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//on on récupère l’attribut recette si le drag en possede un</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> id_recette=$<span style="color: #66cc66;">&#40;</span>drag<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span>’recette’<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//si il en possède un on suprime le drag. Cela correspond à si un ingredient d’une recette est enlevé de sa recette.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//supprimez le bloc et testez!</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>id_recette<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>drag<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">remove</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fit: <span style="color: #003366; font-weight: bold;">true</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//Ici nous allons dropper nos ingrédient pour construire nos recettes.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>’.<span style="color: #006600;">recette_ingredient</span>’<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">Droppable</span><span style="color: #66cc66;">&#40;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">accept : ‘drag’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">activeclass: ‘activeEmplacement’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">hoverclass: ‘hoverEmplacement’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">tolerance: ‘pointer’,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ondrop: <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>drag<span style="color: #66cc66;">&#41;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//nous récuperons l’id de la recette. Il est contenu dans le div parent de la zone droppabe (alez revoir le xhtml ;-p).</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> id_recette=$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">parents</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span>’id’<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//on clone l’élément draggable. Cela permet de réutiliser un autre élément pour une autre recette!</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> drag1 = $<span style="color: #66cc66;">&#40;</span>drag<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">clone</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//nous ajoutons un attribut recette ayant pour valeur l’id de la recette.</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>drag1<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span>’recette’,id_recette<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//puis nous récuperons l’id de l’ingredient…</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> id_ingredient=$<span style="color: #66cc66;">&#40;</span>drag1<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span>’id’<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//…pour verifier qu’il ne soit pas déjà présent!</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>!$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">children</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #66cc66;">&#40;</span>’#’ + id_ingredient<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//s’il n’est pas présent on l’ajoute</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span>drag1<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//on rend notre “clone” draggable</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addDraggable<span style="color: #66cc66;">&#40;</span>drag1<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//avec un petit effet pour l’apaprition :p</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span>drag1<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fadeIn</span><span style="color: #66cc66;">&#40;</span>”slow”<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fit: <span style="color: #003366; font-weight: bold;">true</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div>
<p>Voila! Cette première partie est fini! Je ferais bientôt <a title="Ca y est la suite est là!!!" href="http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/">la suite avec la sauvegarde de vos recettes dans une base de donnée grâce à l&#8217;ajax</a>!</p>
<p>Si vous voulez que je détail un point précis demandez via un petit commentaire! Puis si vous avez aimé n&#8217;hésitez pas à le dire c&#8217;est toujours sympa et ça motive :p<!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/10/03/tuto-jquery-dragn-drop-avec-jquery-et-ajax-v2/" title="<!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:-->"><!--:fr-->[tuto jquery] drag&#8217;n drop avec jquery et ajax V2<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/15/tuto-jquery-cadres-extensibles-animes-avec-jquery/" title="<!--:fr-->[tuto jquery] cadres extensibles animés avec jquery<!--:-->"><!--:fr-->[tuto jquery] cadres extensibles animés avec jquery<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-flex-hello-world-en-flex-il-y-a-un-debut-a-tout/" title="<!--:fr-->[tuto flex] hello world en flex: il y a un début à tout!<!--:-->"><!--:fr-->[tuto flex] hello world en flex: il y a un début à tout!<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/16/annonce-prochain-tutoriels-de-lajax-jquery-tuto/" title="<!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:-->"><!--:fr-->[annonce] prochain tutoriels : de l&#8217;ajax avec jQuery<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)</title>
		<link>http://antoine.guiral.info/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/</link>
		<comments>http://antoine.guiral.info/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 18:10:12 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[2.0]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mashup]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://guiralantoine.wordpress.com/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/</guid>
		<description><![CDATA[La suite du tutoriel sur les mashup avec flickr est là! Sachez que ce tutoriel est applicable avec toutes vos photos, qu&#8217;elles proviennent de flickr ou non.
Pour ceux qui ne veulent pas ou n&#8217;ont pas le temps ou l&#8217;envie de lire la première partie voici ma page de test pour la galerie avec flickr (des ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->La suite du<a title="La première partie sur l'api flickr" href="http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/" target="_blank"> tutoriel sur les mashup avec flickr</a> est là! Sachez que ce tutoriel est applicable avec toutes vos photos, qu&#8217;elles proviennent de flickr ou non.</p>
<p>Pour ceux qui ne veulent pas ou n&#8217;ont pas le temps ou l&#8217;envie de lire la première partie voici ma page de test pour la<a title="Ma page de test toute bête pour flickr :)" href="http://www.e-caveavin.com/cv/test_flickr.php"> galerie avec flickr</a> (des fois il y a un bug, faites f5 le temps que je corrige ce problème&#8230;).</p>
<ul>
<li>Le javascript : jquery</li>
</ul>
<p>Nous allons d&#8217;abord télécharger <span style="text-decoration: line-through;">notre framework préféré</span> <a title="Télécharger la dernière version!" href="http://jquery.com/blog/2008/01/15/jquery-122-2nd-birthday-present/" target="_blank"><strong>&gt;&gt;JQuery&lt;&lt;</strong></a> et le plugin <a title="Ne prenez que ce qui vous interesse" href="http://interface.eyecon.ro/download#" target="_blank"><strong>&gt;&gt;Interface&lt;&lt;</strong></a> qui nous intéresse.</p>
<p align="center"><img src="http://guiralantoine.files.wordpress.com/2008/01/dl_interface.jpg" alt="Choisissez bien!" /></p>
<p align="center">
<p align="left">Je vous conseil de mettre vos deux librairie dans un dossier que vous nommerez <em>scripts</em> et qui contiendra tous vos scripts javascript et vos librairies. Maintenant que votre espace de travaille est préparé reprenons le <a title="Lisez le si ce n'est déjà fait :p" href="http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/" target="_blank">fil du tutoriel précédent</a> :</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="php" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #000000; font-weight: bold;">&lt;?php</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">require</span><span style="color: #66cc66;">&#40;</span>’flickr.php’<span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Paramètres API :</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$apiKey</span> = ‘010e8*************8c3e*******<span style="color: #cc66cc;">22</span>′;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$apiSecret</span> = ‘<span style="color: #cc66cc;">98</span>*********418e’;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Id du User :</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$userId</span> = ‘<span style="color: #cc66cc;">22</span>********<span style="color: #cc66cc;">3</span>@N07′;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Id de l’album :</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$albumId</span> = ‘<span style="color: #cc66cc;">721</span>***************<span style="color: #cc66cc;">4</span>′;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Nouvelle instance de Flickr :</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$flickr</span> = <span style="color: #000000; font-weight: bold;">new</span> Flickr<span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$apiKey</span> , <span style="color: #0000ff;">$apiSecret</span> <span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Nouvelle instance de Album :</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$album</span> = <span style="color: #000000; font-weight: bold;">new</span> Album<span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$flickr</span> , <span style="color: #0000ff;">$albumId</span> , <span style="color: #0000ff;">$userId</span> <span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">?&gt;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">&lt;?php</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Affiche les “thumbs” de toutes les photos de l’album :</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$album</span>-&gt;<span style="color: #006600;">getPhotos</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$photo</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> ‘&lt;a href=”<span style="color: #808080; font-style: italic;">#”&gt;’.$photo['imgThumbs'].’&lt;/a&gt;’ ;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">?&gt;</span></div></li></ol></div></div>
<p align="left">Pour rappel, ce petit bout de code permet de récupérer des photos que l&#8217;on héberge chez <span style="font-weight:bold;">flickr</span>. Nous allons le compléter. Vous remarquez que j&#8217;ai séparé le code en deux parties : la première regroupe tous les traitements (les instances, les assignations, les appels de fonctions,etc&#8230;) tandis que la seconde concerne l&#8217;affichage des photos. Vous remarquez aussi que j&#8217;ai rajouté un lien sur nos photos. Nous ne nous en servirons pas mais vous pourriez par exemple afficher la même image en taille réelle!&#8230;</p>
<p align="left">Nous allons commencer par placer notre entête <strong>XHTML</strong>. Elle contient une <strong>DTD </strong>qui spécifie au navigateur dans quelle langue vous &laquo;&nbsp;parlez&nbsp;&raquo; (<strong>HTML </strong>ou <strong>XHTML </strong>et quelle version). Viennent ensuite les balises &laquo;&nbsp;<em>head</em>&nbsp;&raquo; qui contiennent beaucoup d&#8217;informations dont les différent liens vers vos fichiers de styles ou de scripts.</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="html4strict" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”&gt;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html</span></a> xmlns=”http://www.w3.org/<span style="color: #cc66cc;">1999</span>/xhtml” xml:<span style="color: #000066;">lang</span>=”fr” <span style="color: #000066;">lang</span>=”fr”<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=”content-<span style="color: #000066;">type</span>” <span style="color: #000066;">content</span>=”<span style="color: #000066;">text</span>/html; <span style="color: #000066;">charset</span>=UTF<span style="color: #cc66cc;">-8</span>″ /<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=”Content-Style-<span style="color: #000066;">Type</span>” <span style="color: #000066;">content</span>=”<span style="color: #000066;">text</span>/css” /<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">&lt;link</span></a> <span style="color: #000066;">rel</span>=”stylesheet” <span style="color: #000066;">type</span>=”<span style="color: #000066;">text</span>/css” <span style="color: #000066;">media</span>=”screen” <span style="color: #000066;">href</span>=”styles/styles.css” /<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">type</span>=”<span style="color: #000066;">text</span>/javascript” <span style="color: #000066;">src</span>=”scripts/jquery.js”<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">type</span>=”<span style="color: #000066;">text</span>/javascript” <span style="color: #000066;">src</span>=”scripts/interface.js”<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span></div></li></ol></div></div>
<p align="left">Vient ensuite le corps de la page, le &laquo;&nbsp;<em>body</em>&laquo;&nbsp;. Le notre sera très sommaire : un titre et un div qui contiendra notre galerie. Pour y avoir accès facilement dans notre <strong>CSS </strong>nous lui assignerons un identifiant unique (&nbsp;&raquo;<em>id</em>&laquo;&nbsp;).</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="html4strict" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></a></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/h2.html"><span style="color: #000000; font-weight: bold;">&lt;h2&gt;</span></a></span>Test flickr<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h2&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=”carousel”<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">//mes photos<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span></div></li></ol></div></div>
<p align="left">Là si j&#8217;ai bien expliqué vous devriez déjà avoir copier le second bout de php à la place du commentaire &laquo;&nbsp;<em>//mes photos</em>&laquo;&nbsp;. Sinon ben faites le vite <img src='http://antoine.guiral.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p align="left">
<ul>
<li>Le CSS</li>
</ul>
<p>On est bientot arrivé! Il faut maintenant donner un peu de <span style="font-weight:bold;">style </span>à tout ça. Qu&#8217;est ce qu l&#8217;on a : un div avec un identifiant &laquo;&nbsp;<span style="font-style:italic;">carousel</span>&nbsp;&raquo; et des images dans ce <span style="font-weight:bold;">div</span>. Et bien allons-y! Petit rappel : nous travaillons dans le fichier <span style="font-weight:bold;">styles.css</span> qui se trouve dans le dossier styles à la racine de notre site web. Le <span style="font-style:italic;">border:none;</span> sur les images permet de ne pas avoir une belle bordure bleu autour de vos magnifiques photos de vacances. Le <span style="font-style:italic;">position:absolute;</span> sur les liens est nécessaire au bon fonctionnement du plugin!</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="css" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc00cc;">#carousel</span> a</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">position</span>: <span style="color: #993333;">absolute</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">width</span>: <span style="color: #933;">110px</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc00cc;">#carousel</span> img</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">border</span>: <span style="color: #993333;">none</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div>
<p>Voila le tuto est fini! J&#8217;espère qu&#8217;il vous a apporté des choses! Envoyez moi vos réalisations! Cela me ferait vraiment plaisir! De plus nous pourrions échanger sur nos façons de faire, ou si vous trouvez des p&#8217;tites astuces&#8230;enfin bref : laissez moi un <span style="font-weight:bold;">commentaire </span>qu&#8217;on discute un peu :p</p>
<p>See you!<!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/19/tuto-mashup-galerie-photo-animee-via-flickr-recuperer-les-photos-12/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : récupérer les photos (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/18/vous-avez-dit-mashup/" title="<!--:fr-->Vous avez dit mashup?<!--:-->"><!--:fr-->Vous avez dit mashup?<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/16/anniversaire-jquery-122-pour-les-2-ans-de-jquery/" title="<!--:fr-->[anniversaire] JQuery 1.2.2 pour les 2 ans de JQuery!<!--:-->"><!--:fr-->[anniversaire] JQuery 1.2.2 pour les 2 ans de JQuery!<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/15/tuto-jquery-cadres-extensibles-animes-avec-jquery/" title="<!--:fr-->[tuto jquery] cadres extensibles animés avec jquery<!--:-->"><!--:fr-->[tuto jquery] cadres extensibles animés avec jquery<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>[tuto jquery] cadres extensibles animés avec jquery</title>
		<link>http://antoine.guiral.info/2008/01/15/tuto-jquery-cadres-extensibles-animes-avec-jquery/</link>
		<comments>http://antoine.guiral.info/2008/01/15/tuto-jquery-cadres-extensibles-animes-avec-jquery/#comments</comments>
		<pubDate>Mon, 14 Jan 2008 22:09:05 +0000</pubDate>
		<dc:creator>Antoine</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[2.0]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://guiralantoine.wordpress.com/2008/01/15/tuto-jquery-cadres-extensibles-animes-avec-jquery/</guid>
		<description><![CDATA[Un petit tutoriel rapide pour terminer les explications par rapport à mon cv en ligne. Je vous conseille de lire le tutoriel précédent sur les cadres extensibles en xhtml/css.

JQuery kezako?

JQuery est un framework javascript. Il en existe d&#8217;autres comme MooTools [en] ou script.aculo.us [en]. Cela rajoute une couche javascript qui permet de manier les éléments ]]></description>
			<content:encoded><![CDATA[<p><!--:fr-->Un petit <strong>tutoriel </strong>rapide pour terminer les explications par rapport à <a title="Mon cv" href="http://cv.antoine-guiral.fr">mon cv en ligne</a>. Je vous conseille de lire le <strong>tutoriel </strong>précédent sur les cadres extensibles en xhtml/css.</p>
<ul>
<li><a title="Site non officiel mais en francais sur jquery" href="http://jquery.developpeur-web2.com/">JQuery</a> kezako?</li>
</ul>
<p><a title="Site non officiel mais en francais sur jquery" href="http://jquery.developpeur-web2.com/">JQuery</a> est un <a title="Article wikipedia sur les frameworks" href="http://fr.wikipedia.org/wiki/Framework" target="_blank">framework</a> javascript. Il en existe d&#8217;autres comme <a title="Le site officiel de MooTools" href="http://mootools.net/">MooTools [en]</a> ou <a title="Site officiel de MooTools en anglais" href="http://script.aculo.us/">script.aculo.us [en]</a>. Cela rajoute une couche <strong>javascript</strong> qui permet de manier les éléments <strong><a title="Article wikipedia sur le DOM" href="http://fr.wikipedia.org/wiki/Document_Object_Model">DOM</a></strong> plus facilement. Ils fournissent aussi une quantité impressionnante d&#8217;<strong>effets</strong> très &laquo;&nbsp;<strong>2.0</strong>&nbsp;&raquo; ou vous permettent d&#8217;utiliser <a title="Article wikipedia sur AJAX" href="http://fr.wikipedia.org/wiki/Asynchronous_JavaScript_and_XML"><strong>AJAX</strong></a> de manière très simple.</p>
<ul>
<li>Télécharger JQuery et faire le &laquo;&nbsp;linkage&nbsp;&raquo;</li>
</ul>
<p>Allez vite <strong>télécharger </strong>la dernière version stable de <strong>JQuery</strong> sur <a title="Site officiel de JQuery" href="http://jquery.com/">le site officiel</a>. Ensuite ouvrez votre editeur préféré et ouvrez le fichier html sur lequel vous voulez tester cet effet (si vous avez fait le <a title="Le tuto sur les cadres extensibles" href="http://guiralantoine.wordpress.com/2008/01/13/tuto-cadre-avec-bordures-extensibles-valide-xhtmlcss/">tutoriel</a> précédent servez vous en ;-p).</p>
<p>Placez vous entre vos balises &lt;head&gt; et &lt;/head&gt; et faites le lien entre votre fichier html et votre fichier javascript qui contient <strong>JQuery</strong> :</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="html4strict" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;path/to/jquery.js&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--mce:0--&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div></li></ol></div></div>
<p>Puis entre votre fichier html et le fichier composé de vos <strong>fonctions </strong>et/ou <strong>effets </strong>maisons basés sur <strong>JQuery </strong>(ou pas!) :</p>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="html4strict" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;scripts/script.js&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--mce:1--&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div></li></ol></div></div>
<p>Nous sommes parés pour rentrer dans le vif du sujet!</p>
<ul>
<li>La base</li>
</ul>
<p>Le sélécteur universel <strong>JQuery </strong>: &laquo;&nbsp;<em>$</em>&laquo;&nbsp;.  &laquo;&nbsp;<em>$</em>&nbsp;&raquo; désigne un objet <strong>JQuery </strong>étant lui même un ensemble d&#8217;éléments <strong>DOM</strong>.</p>
<p>Par exemple : <em>$(&nbsp;&raquo;a&nbsp;&raquo;)</em> désigne tout les liens présent dans le document. Un autre exemple plus &laquo;&nbsp;CSS&nbsp;&raquo; : <em>$(&nbsp;&raquo;.ma_class&nbsp;&raquo;)</em> retourne tout les éléments auxquels on a affécté la classe CSS ma_class. Nous allons donc accéder aux éléments que nous voulons animer grâce à ce sélécteur.</p>
<ul>
<li><a title="Doc en français sur la méthode animate" href="http://jquery.developpeur-web2.com/documentation/effets/animate.php">La méthode animate</a></li>
</ul>
<p>Animate est une méthode <strong>JQuery</strong>. C&#8217;est à dire qu&#8217;une fois un ensemble d&#8217;éléments séléctionné on va leurs affecter cette méthode. Cette affectation ce fait avec le &laquo;&nbsp;.&nbsp;&raquo; : <em>$(&nbsp;&raquo;mes_elements&nbsp;&raquo;).ma_methode()</em>;. Cette méthode peux prendre 4 arguments. Dans notre cas nous n&#8217;en utiliserons que 2 : le premier pour les attributs CSS que nous voulons modifier, le second pour la vitesse à laquelle s&#8217;executera l&#8217;effet.</p>
<ul>
<li><a title="Liste des événements JQuery en français" href="http://jquery.developpeur-web2.com/documentation/evenements.php">Le gestionnaire d&#8217;événement</a></li>
</ul>
<p>Vous pouvez déclancher vos effets sur plusieurs événements. Dans ce tutoriel  nous utiliserons le click qui se traduit par la méthode : &laquo;&nbsp;.clic()&nbsp;&raquo;. Pour mon cv j&#8217;utilise la méthode &laquo;&nbsp;.mouseover&nbsp;&raquo; pour faire bouger mes 3 cadres au passage de la sourie sur l&#8217;un d&#8217;eux.</p>
<ul>
<li>Le code pour un seul cadre</li>
</ul>
<div class="geshi" style="overflow: auto; width: 560px;padding-bottom: 15px;clear:both;"><div class="javascript" style="color: #000066; border-left: 5px solid rgb(195, 215, 234); background-color: rgb(240, 240, 240); padding:1px;width:100%"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#L&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#L&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">animate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>width: <span style="color: #CC0000;">300</span>,left:<span style="color: #CC0000;">300</span>,top:<span style="color: #CC0000;">190</span><span style="color: #66cc66;">&#125;</span>, <span style="color: #3366CC;">&quot;fast&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#B&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">animate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>height: <span style="color: #CC0000;">130</span><span style="color: #66cc66;">&#125;</span>, <span style="color: #3366CC;">&quot;fast&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 8pt 'Courier New', Courier, monospace; color: #003030;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div>
<p>Commentaire 1 : les <strong>effets </strong>seront déclanchés sur un clic sur l&#8217;élément &laquo;&nbsp;#L&nbsp;&raquo;. Le premier sélécteur <strong>JQuery </strong>est donc utilisé pour déclencher l&#8217;événement.</p>
<p>Commentaire 2 : on utilise ensuite une <strong>fonction anonyme</strong>. C&#8217;est juste la création d&#8217;une fonction temporaire qui n&#8217;a pas de nom. On l&#8217;a créé juste pour l&#8217;occasion et elle ne sera pas réutilisable à un autre endroit dans le code.</p>
<p>Commentaire 3 : on sélectionne ensuite les éléments que l&#8217;on veux animer grâce à un nouveau sélécteur <strong>JQuery</strong>. Dans notre cas nous sélectionnons le cadre le plus externe $(&nbsp;&raquo;#L&nbsp;&raquo;) pour l&#8217;élargir (ainsi tous les div plus &laquo;&nbsp;internes&nbsp;&raquo; prendront toute la largeur qu&#8217;on leur donne ce qui placera nos bordures correctements) en passant comme premier arguments à .animate() : {width:300,left:300,top:190}. Cela à pour effet de passer la largeur de l&#8217;élément séléctionné à 300, puis de positionner le cadre à 300 px du bord gauche de la fenêtre et 190 px du bord supérieur de la fenêtre. Le second argument définit la vitesse de l&#8217;animation, ici : &laquo;&nbsp;fast&nbsp;&raquo;. On aurais pu mettre un chiffre en milliseconde (par exemple 300). La même opération est effectuée sur le div le plus &laquo;&nbsp;interne&nbsp;&raquo; pour forcer l&#8217;étirement du cadre en hauteur.</p>
<p>Commentaire 4 : les attributs CSS composé comme &laquo;&nbsp;margin-left&nbsp;&raquo; s&#8217;ecriront &laquo;&nbsp;marginLeft&nbsp;&raquo; quand ils seront attributs de .animate().</p>
<p>Voila c&#8217;est fini! Surtout n&#8217;hésitez pas à me poser vos question. Et j&#8217;attend avec impatience les url&#8217;s de vos réalisations!</p>
<p>A bientôt!<!--:--></p>
<ul class="related_post"><li><a href="http://antoine.guiral.info/2008/02/24/tuto-jquery-drag-n-drop-avec-sauvegarde-automatique-en-base-de-donnees-12/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/22/tuto-mashup-galerie-photo-animee-via-flickr-animer-votre-galerie-22/" title="<!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:-->"><!--:fr-->[tuto mashup] Galerie photo animée via Flickr : animer votre galerie (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/05/02/tuto-jquery-navigation-en-ajax-non-intrusif-22/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/03/09/tuto-jquery-drag-%e2%80%98n-drop-avec-sauvegarde-automatique-en-base-de-donnees-22/" title="<!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:-->"><!--:fr-->[tuto jquery] drag ‘n drop avec sauvegarde automatique en base de données (2/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/17/annonce-prochain-tutoriel-flickrphpjquery-cest-pour-demain/" title="<!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:-->"><!--:fr-->[annonce] Prochain tutoriel flickr/php/jquery : c&#8217;est pour demain!<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/16/anniversaire-jquery-122-pour-les-2-ans-de-jquery/" title="<!--:fr-->[anniversaire] JQuery 1.2.2 pour les 2 ans de JQuery!<!--:-->"><!--:fr-->[anniversaire] JQuery 1.2.2 pour les 2 ans de JQuery!<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/04/20/tuto-jquery-navigation-en-ajax-non-intrusif-12/" title="<!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:-->"><!--:fr-->[tuto jQuery] navigation en ajax non-intrusif (1/2)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/24/tuto-mashup-google-maps-sur-votre-site-cest-possible-version-statique/" title="<!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:-->"><!--:fr-->[tuto mashup] Google maps sur votre site : c&#8217;est possible! (version statique)<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/16/gerez-et-partagez-vos-photos-avec-flickr-a-la-mode-20/" title="<!--:fr-->Gérez et partagez vos photos avec flickr à la mode 2.0<!--:-->"><!--:fr-->Gérez et partagez vos photos avec flickr à la mode 2.0<!--:--></a></li><li><a href="http://antoine.guiral.info/2008/01/13/tuto-cadre-avec-bordures-extensibles-valide-xhtml-css/" title="<!--:fr-->[tuto web] cadre avec bordures extensibles valide xhtml/css<!--:-->"><!--:fr-->[tuto web] cadre avec bordures extensibles valide xhtml/css<!--:--></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://antoine.guiral.info/2008/01/15/tuto-jquery-cadres-extensibles-animes-avec-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
