<?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>l'indicible blog &#187; Javascript</title>
	<atom:link href="http://www.lindicible.com/blog/category/dev/js/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lindicible.com/blog</link>
	<description>&#60;!--:en--&#62;the details of the inexpressible&#60;!--:--&#62;&#60;!--:fr--&#62;les détails de l'ineffable&#60;!--:--&#62;</description>
	<lastBuildDate>Fri, 02 Sep 2011 19:30:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>BkgSlider</title>
		<link>http://www.lindicible.com/blog/en/2011/02/24/bkgslider/</link>
		<comments>http://www.lindicible.com/blog/en/2011/02/24/bkgslider/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 20:26:34 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.lindicible.com/blog/?p=702</guid>
		<description><![CDATA[BkgSlider is a jQuery plugin giving you the opportunity to have a CSS background-image gallery. Demo You can check out an example on the demonstration page. Usage There&#8217;s nothing simpler than to use BkgSlide : you just have to include the jQery library and the BkgSlider plugin in your page and instanciate the plugin with [...]]]></description>
			<content:encoded><![CDATA[<p>BkgSlider is a jQuery plugin giving you the opportunity to have a CSS background-image gallery.</p>
<h3>Demo</h3>
<p>You can check out an example on <a rel="external" href="http://blog.lindicible.com/wp-content/_custom/bkgslide/">the demonstration page</a>.</p>
<h3>Usage</h3>
<p>There&#8217;s nothing simpler than to use BkgSlide : you just have to include the jQery library and the BkgSlider plugin in your page and instanciate the plugin with its options.</p>
<pre>&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="jquery.bkgslide.js"&gt; &lt;/script&gt;
&lt;script type="text/javascript"&gt;
$(document).ready(function(){
    $('#target').bkgSlide({
        images: ['images/img1.jpg', 'images/img2.jpg']
    });
});</pre>
<h3>Options</h3>
<h4>images</h4>
<p>An array containing the name of the images to use.</p>
<h4>imagePath</h4>
<p>The path where to find the images.<br />
The script automatically adds an ending slash if necessary.</p>
<h4>speed</h4>
<p>The duration in milliseconds between two image changes.<br />
<strong>Default :</strong> 7000<br />
If you don&#8217;t want autoplay, set this value to 0.</p>
<h4>direction</h4>
<p>The direction to go to when changing image.<br />
<strong>Possible values :</strong> &#8216;random&#8217;, &#8216;next&#8217;, &#8216;prev&#8217;<br />
<strong>Default :</strong> &#8216;random&#8217;</p>
<h4>wrap</h4>
<p>Defines wheter or not to wrap around when reaching one end of the imges list.<br />
<strong>Default :</strong> true</p>
<h4>nav</h4>
<p>Defines the navigation tools.<br />
<strong>Possible values :</strong> true, an option as a string, an array of navigation tools in the order you want to see them</p>
<p>true / &#8216;all&#8217; : all the navigation tools<br />
&#8216;list&#8217;       : list of shortcuts to each image<br />
&#8216;prev&#8217;       : button to go to the previous image<br />
&#8216;next&#8217;       : bbutton to go to the next image<br />
&#8216;toggle&#8217;     : button to start or stop the slideshow</p>
<p><strong>Default :</strong> ['prev', 'list', 'next', 'toggle']</p>
<h4>stopOnNav</h4>
<p>Defines wheter or not to stop the slideshow when the user interacts with one of the navigation tools.<br />
<strong>Default :</strong> false</p>
<h4>width</h4>
<p>The width to give to the image containers.<br />
With the &#8216;auto&#8217; value, the script will use the width of the target element.<br />
<strong>Default :</strong> &#8216;auto&#8217;</p>
<h4>height</h4>
<p>The height to give to the image containers.<br />
With the &#8216;auto&#8217; value, the script will use the height of the target element.<br />
<strong>Default :</strong> &#8216;auto&#8217;</p>
<h4>containersClass</h4>
<p>Used to add a custom class to the image containers.<br />
<strong>Default :</strong> null</p>
<h4>effect</h4>
<p>The effect to apply when transitioning between two images.<br />
<strong>Possible values :</strong>  &#8216;fadeOut&#8217;, &#8216;slideUp&#8217;, &#8216;hide&#8217;<br />
<strong>Default :</strong> &#8216;fadeOut&#8217;</p>
<h4>duration</h4>
<p>The transition duration between two images (in milliseconds)<br />
</strong>Default :</strong> 500</p>
<h4>afterInit</h4>
<p>A callback function to do something right after the BkgSlider initialization.<br />
This function will have has parameter the target element and its BkgSlider.</p>
<h3>Methods</h3>
<h4>move</h4>
<p>Move within the images list.<br />
</strong>Possible values :</strong> &#8216;next&#8217;, &#8216;prev&#8217;, &#8216;random&#8217;<br />
If no parameter is passed, the direction set in the options is used.</p>
<h4>changeTo</h4>
<p>Move to the specified image index.<br />
This method requires the index of the image in the array as a parameter (a number between 0 and the number of images -1).</p>
<h4>play</h4>
<p>Begin the slideshow.<br />
This method accepts a number of milliseconds as a parameter, representing the time interval between two image changes.<br />
If no parameter is passed, the speed set in the options will be used.</p>
<h4>stop</h4>
<p>Stop the slideshow.</p>

<div class="like">
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.lindicible.com%2Fblog%2Fen%2F2011%2F02%2F24%2Fbkgslider%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font=&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:62px; "></iframe>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.lindicible.com/blog/en/2011/02/24/bkgslider/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How to detect when the mouse leaves the browser&#8217;s viewport in javascript</title>
		<link>http://www.lindicible.com/blog/en/2009/09/29/comment-detecter-quand-la-souris-quitte-la-fenetre-du-navigateur-en-javascript/</link>
		<comments>http://www.lindicible.com/blog/en/2009/09/29/comment-detecter-quand-la-souris-quitte-la-fenetre-du-navigateur-en-javascript/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 15:57:13 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.lindicible.com/blog/?p=421</guid>
		<description><![CDATA[Javascript is a very useful language for many things nowadays. Unfortunately, each browser implements it in a different way, and of course they don&#8217;t offer the same way of handling events ! Let&#8217;s take an example : you&#8217;ve just made a div that you can drag at will with the mouse. We click, the dragging [...]]]></description>
			<content:encoded><![CDATA[<p>Javascript is a very useful language for many things nowadays.<br />
Unfortunately, each browser implements it in a different way, and of course they don&#8217;t offer the same way of handling events !</p>
<p>Let&#8217;s take an example : you&#8217;ve just made a div that you can drag at will with the mouse. We click, the dragging begins&#8230; we let go of the mouse button, the dragging stops. But here&#8217;s the thing : if we let go of the mouse button while outside the browser&#8217;s viewport, no event is triggered, and we keep on dragging our div indefinitely !</p>
<p>The best way to prevent that is to stop the dragging as soon as we leave the browser&#8217;s viewport. But : javascript doesn&#8217;t trigger any event in that case. One has to cheat&#8230;</p>
<p>We begin by saying that if we stop hovering the dragged object, we&#8217;ll stop the dragging&#8230;<br />
And we soon realise it&#8217;s not cool at all ! Indeed, the mouse will nearly always go faster that the div and the dragging will stop instantly, except if we move in slow motion.</p>
<p>To prevent that, one can check toward which element the mouse left the div, and only stop the dragging if that element is not within the html tag.<br />
Easy&#8230; in theory. But all browsers don&#8217;t use the same attributes for the event, and of course IE will be causing trouble !</p>
<p>Without any further introduction, here is a bit of jQuery (&#8220;code less do more&#8221;) that will help you a lot to solve that issue :</p>
<pre>
$('div#dragged').bind('mouseleave.dragged',function(e) {
	var ev = e || window.event;
	if(ev.relatedTarget){
		if(ev.relatedTarget == $('html').get(0)){
			stopDrag();
		}
	} else {
	// IE
		if(!ev.toElement){
			stopDrag();
		} else if(ev.toElement.tagName == "HTML"){
			stopDrag();
		}
	}
})</pre>
<h3>Now, the explanations :</h3>
<pre>$('div#dragged').bind('mouseleave.dragged',function(e) {</pre>
<p>We associate a function to the &#8216;mouseleave&#8217; event on the draggable div.<br />
Please note that jQuery allows us to associate a name to that function (here: &#8216;.dragged&#8217;), which is very useful to then handle the events by name, specially in the case where several events of the same type are associated with this object.</p>
<pre>	var ev = e || window.event;</pre>
<p>We get the triggered event. Firefox and the standard compliant browsers will have it as a parameter of the function (here : &#8216;e&#8217;), for Internet Explorer we&#8217;ll have to fetch it from the window.event.<br />
the double pipe (&#8216;||&#8217;) allows us to give to the variable &#8216;ev&#8217; the value of &#8216;e&#8217; if it exists, and the value of &#8216;window.event&#8217; if that&#8217;s not the case.</p>
<pre>	if(ev.relatedTarget){
		if(ev.relatedTarget == $('html').get(0)){
			stopDrag();
		}</pre>
<p>For the standard browsers, the event contains a &#8216;relatedTarget&#8217; property.<br />
If it exists, we are in the case of a standard browser, else we&#8217;re probably dealing with IE.</p>
<p>This property contains the &#8216;html&#8217; element when we leave the browser&#8217;s viewport.<br />
Here we&#8217;ll use a jQuery syntax to compare the content of that property to the html content (&#8216;get(0)&#8217; on the jQuery object) of the &#8216;html&#8217; tag. If they&#8217;re identical, we can stop the dragging.</p>
<pre>	} else {
	// IE</pre>
<p>If the &#8216;relatedTarget&#8217; property doesn&#8217;t exist, we&#8217;re in the case of IE. Two case are then to be taken care of :</p>
<pre>		if(!ev.toElement){
			stopDrag();</pre>
<p>For some versions of IE, the &#8216;toElement&#8217; property of the event is undefined. This is enough information to stop the dragging.</p>
<pre>		} else if(ev.toElement.tagName == "HTML"){
			stopDrag();
		}
	}
})</pre>
<p>For some other versions of IE, the &#8216;toElement&#8217; property exists. We&#8217;ll then have to check that the &#8216;tagName&#8217; property of the &#8216;toElement&#8217; is indeed &#8216;HTML&#8217;. If that&#8217;s the case, we&#8217;ll stop the dragging.</p>
<p>Here it is, I hope this short explanation may help you out, it&#8217;s not always easy to find on the internet the needed resources to do that thing that seems so basic !</p>

<div class="like">
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.lindicible.com%2Fblog%2Fen%2F2009%2F09%2F29%2Fcomment-detecter-quand-la-souris-quitte-la-fenetre-du-navigateur-en-javascript%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font=&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:62px; "></iframe>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.lindicible.com/blog/en/2009/09/29/comment-detecter-quand-la-souris-quitte-la-fenetre-du-navigateur-en-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Disable a select option in IE with jQuery</title>
		<link>http://www.lindicible.com/blog/en/2009/04/08/disable-a-select-option-in-ie-with-jquerydesactiver-une-option-de-select-avec-jquery/</link>
		<comments>http://www.lindicible.com/blog/en/2009/04/08/disable-a-select-option-in-ie-with-jquerydesactiver-une-option-de-select-avec-jquery/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 18:29:58 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.lindicible.com/blog/?p=99</guid>
		<description><![CDATA[What would we do if we didn&#8217;t have Internet Explorer to help us torture our brain ? We would risk getting bored ! It appears that in the 7th version of this browser beloved by masochists deveveloppers, we still don&#8217;t have the useful possibility of disabling an option in a &#8216;select&#8217;. Hopefully, javascript (enhanced by [...]]]></description>
			<content:encoded><![CDATA[<p>What would we do if we didn&#8217;t have Internet Explorer to help us torture our brain ? We would risk getting bored !</p>
<p>It appears that in the 7th version of this browser beloved by masochists deveveloppers, we still don&#8217;t have the useful possibility of disabling an option in a &#8216;select&#8217;.</p>
<p>Hopefully, javascript (enhanced by jQuery) allows us to fix many issues of that browser we love to hate.</p>
<p>Here is a bit of script found on the internet that may help you if you face this problem :</p>
<pre class="javascript" style="font-family: monospace;">$<span style="color: #009900;">(</span>document<span style="color: #009900;">)</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">(</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
  <span style="color: #006600; font-style: italic;">// Disabled options fix for Internet Explorer</span>
  $<span style="color: #009900;">(</span><span style="color: #3366cc;">'select'</span><span style="color: #009900;">)</span>.<span style="color: #660066;">each</span><span style="color: #009900;">(</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">rejectDisabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">(</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">options</span><span style="color: #009900;">[</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">]</span>.<span style="color: #660066;">disabled</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">(</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">lastSelectedIndex</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
          <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">selectedIndex</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">lastSelectedIndex</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">}</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">{</span>
          <span style="color: #003366; font-weight: bold;">var</span> first_enabled <span style="color: #339933;">=</span> $<span style="color: #009900;">(</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">)</span>.<span style="color: #660066;">children</span><span style="color: #009900;">(</span><span style="color: #3366cc;">'option:not(:disabled)'</span><span style="color: #009900;">)</span>.<span style="color: #660066;">get</span><span style="color: #009900;">(</span><span style="color: #cc0000;">0</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">selectedIndex</span> <span style="color: #339933;">=</span> first_enabled <span style="color: #339933;">?</span> first_enabled.<span style="color: #660066;">index</span> <span style="color: #339933;">:</span> <span style="color: #cc0000;">0</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">}</span>
      <span style="color: #009900;">}</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">{</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">lastSelectedIndex</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">selectedIndex</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">}</span>
    <span style="color: #009900;">}</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">rejectDisabled</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">lastSelectedIndex</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">selectedIndex</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">(</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">)</span>.<span style="color: #660066;">children</span><span style="color: #009900;">(</span><span style="color: #3366cc;">'option[disabled]'</span><span style="color: #009900;">)</span>.<span style="color: #660066;">each</span><span style="color: #009900;">(</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span>
      $<span style="color: #009900;">(</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">)</span>.<span style="color: #660066;">css</span><span style="color: #009900;">(</span><span style="color: #3366cc;">'color'</span><span style="color: #339933;">,</span> <span style="color: #3366cc;">'#CCC'</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">(</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">)</span>.<span style="color: #660066;">change</span><span style="color: #009900;">(</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
      <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">rejectDisabled</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">}</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
<span style="color: #009900;">}</span><span style="color: #009900;">)</span><span style="color: #339933;">;
</span>
</pre>
<p>Thank you jQuery <img src='http://www.lindicible.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="like">
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.lindicible.com%2Fblog%2Fen%2F2009%2F04%2F08%2Fdisable-a-select-option-in-ie-with-jquerydesactiver-une-option-de-select-avec-jquery%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font=&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:62px; "></iframe>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.lindicible.com/blog/en/2009/04/08/disable-a-select-option-in-ie-with-jquerydesactiver-une-option-de-select-avec-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pickwhip jQuery</title>
		<link>http://www.lindicible.com/blog/en/2008/10/28/pickwhip-jquery/</link>
		<comments>http://www.lindicible.com/blog/en/2008/10/28/pickwhip-jquery/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 20:02:01 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[after effects]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[pickwhip]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.lindicible.com/blog/?p=7</guid>
		<description><![CDATA[In the world of computers like in any other, good ideas exist that spread slower than others. The &#8216;pickwhip&#8217; used in the Adobe After Effects application is one of those. It&#8217;s a tool the allows you to link an element to another in a simple way. This can be useful to link the color of [...]]]></description>
			<content:encoded><![CDATA[<p>In the world of computers like in any other, good ideas exist that spread slower than others. The &#8216;pickwhip&#8217; used in the Adobe After Effects application is one of those. It&#8217;s a tool the allows you to link an element to another in a simple way. This can be useful to link the color of a graphic element to the rotation of another one&#8230; or a project to a category. And it&#8217;s very useful !</p>
<p>Not being able to find any equivalent to use in a web admin, I&#8217;ve decided to write one by myself. So I&#8217;ve used the convenience of jQuery to write a javascript plug-in that simulates the pickwhip&#8217;s behaviour.</p>
<h3>Demo</h3>
<p>Basically, we bind to a source element a list of target elements to which it can link. From then on, when we click on that source element, we activate a pickwhip that will react differently to a rollover on a target element, on an already linked element, or on a non-target element, and commit the linking when needed.</p>
<p>A demonstration being better that a long speech, you can <a rel="external" href="http://blog.lindicible.com/wp-content/_custom/the_whip/">test the pickwhip</a>.</p>
<h3>In practice</h3>
<p>To use the pickwhip, you first need to load <a rel="external" href="http://docs.jquery.com/Downloading_jQuery#Current_Release">jquery.js</a> and <a rel="external" href="http://blog.lindicible.com/wp-content/_custom/the_whip/jquery.pickwhip.js">jquery.pickwhip.js</a>, preferably in the &lt;head&gt; section of your page.</p>
<pre>&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="jquery.pickwhip.js"&gt; &lt;/script&gt;</pre>
<p>Then you have to initialize the pickwhip.</p>
<pre>$(document).ready(function(){
	$.pickWhip.init({
		imageDir: 'whipImg/'
	});
});</pre>
<p>If you want to move the pickwhip images, you can replace &#8216;whipImg/&#8217; by the path to their new location, else you can just launch $.pickWhip.init() with no parameter.</p>
<p>Now you just have to declare the targets and the options for each pickwhip, as in the present example :</p>
<pre>$('#src1').pickWhip('.dropzone, .dropzone2',{
	unlinkedHoverClass	: 'whipHover1',
	linkedHoverClass	: 'whipHoverLinked1',
	linkList		: Array( $('#drop2') ),
	showLinks		: true,
	linkedClass		: 'whipLinked1',
	unlinkedClass		: 'whipUnlinked1',
	callback		: function(source, target){
		alert("The link between the source " + source.attr('id') + " and the target " + target.attr('id') + " has been updated.";
	}
});</pre>
<p>This code binds a pickwhip to an element of id &#8216;src1&#8242;.</p>
<p>The first parameter passed to the pickWhip() method is a String to be interpreted by the jQuery selector.</p>
<p>Here, we ask elements of class &#8216;dropzone&#8217; and &#8216;dropzone2&#8242; to react to this pickwhip.</p>
<p>The second parameter is a list of options formatted in json&#8230;</p>
<h3>Options available :</h3>
<ul>
<li><strong>linkedHoverClass</strong> : css class to set to a target element <em>already linked</em> to this source when hovered.<br />
Type : String<br />
default: linkedWhipHoverTarget</li>
<li><strong>unlinkedHoverClass</strong> : css class to set to a target element <em>not linked</em> to this source when hovered.<br />
Type : String<br />
default: unlinkedWhipHoverTarget</li>
<li><strong>linkedClass</strong> : css class to set to a target element <em>already linked</em> to this source showLink is active.<br />
Type : String<br />
Par défaut : linkedWhipTarget</li>
<li><strong>unlinkedClass</strong>s : css class to set to a target element <em>not linked</em> to this source when showLink is active.<br />
Type : String<br />
Par défaut : unlinkedWhipTarget</li>
<li><strong>showLinks</strong> : set the linkedClass/unlinkedClass classes to the targets when the user activates this pickwhip.<br />
Type : Boolean<br />
default : true</li>
<li><strong>linkList</strong> : list of jQuery elements or associative arrays (source, target) already linked to this source.<br />
Type : Array( [jQuery Object target], [Array( jQuery Object source, jQuery Object target)], [...] )</li>
<li><strong>callback</strong> : function to run after linking.<br />
Type : Function<br />
Note : This function can take 2 parameters, that will respectively be the source and the target being linked together.</li>
</ul>
<p>The linkList option will prove very useful to initialize the current state of associations. You can pass it targets for this pickwhip, the pickwhip&#8217;s source will be considered as linked to them. But you can also pass it asscociative arrays formatted like Array(source, target), because it&#8217;s not always to the source of the pickwhip that you want to link the target.  For example, you may want to link the target to the parent element of the pickwhip&#8230; or exploit in a more straight forward way what&#8217;s in your database !</p>
<p>To get the current associations list, you can check the global list $.pickWhip.allLinks as described in this example :</p>
<pre>function showLinks(){
	var links = '&lt;p&gt;Current associations are :&lt;\/p&gt;
&lt;ul&gt;';
	for (var i=0; i&lt;$.pickWhip.allLinks.length; i++) {
		for (var j=0; j&lt;$.pickWhip.allLinks[i].length; j++) {
			links += '&lt;li&gt;source : '+$.pickWhip.allLinks[i][j][0].html()+' _ dest : '+$.pickWhip.allLinks[i][j][1].html()+'&lt;\/li&gt;';
		}
	}
	links +='&lt;\/ul&gt;';
	$('#links').html(links);
}</pre>

<div class="like">
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.lindicible.com%2Fblog%2Fen%2F2008%2F10%2F28%2Fpickwhip-jquery%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font=&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:62px; "></iframe>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.lindicible.com/blog/en/2008/10/28/pickwhip-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Préchargement d&#8217;images avec jQuery</title>
		<link>http://www.lindicible.com/blog/en/2008/05/23/prechargement-dimages-avec-jquery/</link>
		<comments>http://www.lindicible.com/blog/en/2008/05/23/prechargement-dimages-avec-jquery/#comments</comments>
		<pubDate>Fri, 23 May 2008 19:54:01 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[préchargement]]></category>
		<category><![CDATA[preload]]></category>
		<category><![CDATA[preloading]]></category>

		<guid isPermaLink="false">http://www.lindicible.com/blog/?p=5</guid>
		<description><![CDATA[Sorry, this entry is only available in Français.]]></description>
			<content:encoded><![CDATA[<p>Sorry, this entry is only available in <a href="http://www.lindicible.com/blog/category/dev/js/feed/">Français</a>.</p>

<div class="like">
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.lindicible.com%2Fblog%2Fen%2F2008%2F05%2F23%2Fprechargement-dimages-avec-jquery%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font=&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:62px; "></iframe>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.lindicible.com/blog/en/2008/05/23/prechargement-dimages-avec-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

