<?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>BinaryKitten&#039;s Development Dropbox &#187; jQuery</title>
	<atom:link href="http://binarykitten.com/tag/jquery-web/feed" rel="self" type="application/rss+xml" />
	<link>http://binarykitten.com</link>
	<description>Curently a work in progress. Please be patient</description>
	<lastBuildDate>Thu, 27 Oct 2011 21:49:50 +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>jQuery Keyz Plugin</title>
		<link>http://binarykitten.com/dev/jq-plugins/259-jquery-keyz-plugin.html</link>
		<comments>http://binarykitten.com/dev/jq-plugins/259-jquery-keyz-plugin.html#comments</comments>
		<pubDate>Wed, 24 Feb 2010 15:20:45 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[jQuery Plugins]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[keypress]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://binarykitten.me.uk/?p=259</guid>
		<description><![CDATA[The purpose of this plugin is to easily facilitate the end user to create and hook key presses for their own use. Usually you would need to know what key links with which keycode etc. Usage It&#8217;s as easy as these steps: Include jquery &#8211; either from CDN or local source Include jquery.keyz.js call the [...]]]></description>
			<content:encoded><![CDATA[<p>The purpose of this plugin is to easily facilitate the end user to  create and hook key presses for their own use. Usually you would need to know what key links with which keycode etc.</p>
<h3>Usage</h3>
<p>It&#8217;s as easy as these steps:</p>
<ol>
<li>Include jquery &#8211; either from CDN or local source</li>
<li>Include jquery.keyz.js</li>
<li>call the following within your document ready or after the item exists</li>
</ol>
<pre class="brush: javascript">
$(&#039;selector&#039;).keyz({
&quot;enter&quot;: function(ctl,sft,alt,event) {
alert(&#039;you pressed enter!&#039;);
}
});
</pre>
<p>this will hook the enter key and raise an alert when pressed.</p>
<p>If you  want to cancel the key either return false from the function or set the  value to false like so:</p>
<pre class="brush: javascript">
$(&#039;selector&#039;).keyz({
&quot;enter&quot;: function(ctl,sft,alt,event) {
return false;
}
});
</pre>
<p>OR</p>
<pre class="brush: javascript">
$(&#039;selector&#039;).keyz({
&quot;enter&quot;:false
});</pre>
<p>You can either use the key names in singular or in a grouping like so:</p>
<pre class="brush: javascript">
$(&#039;selector&#039;).keyz({
&quot;enter&quot;: function(ctl,sft,alt,event) {
/* single key */
return false;
},
&quot;F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12&quot;: function(ctl,sft,alt,event) {
/* mapped to all F-Keys */
return false;
}
});
</pre>
<p>Download jquery.keyz.js here: <a href="/keyzDemo/jquery.keyz.js">Full Source</a> &amp;&amp;  <a href="/keyzDemo/jquery.keyz.gc.js">Google Closure Compiled version</a></p>
<p>Visit the demo page here: <a href="/keyzDemo/">Full Source</a></p>
<h3>Planned Features</h3>
<ul>
<li>support for keypress chains .. passing a sequence of keys and an event firing upon completion</li>
<li><span style="text-decoration: line-through;">support for all three key states &#8211; presently only triggers on key down</span> &#8211; Added in 1.0.2</li>
<li>to add some <a href="http://paulirish.com/2010/duck-punching-with-jquery/" target="_blank">duck punching</a> to add the keyname to the event for the three standard events</li>
</ul>
<h3>Supported Keys</h3>
<p>The keys listed below are the current ones supported by the plugin.<br />
They also support the hyphenated name eg numpad-1 or in upper case like &#8220;F1&#8243; or &#8220;f1&#8243;</p>
<ul>
<li>enter</li>
<li>return</li>
<li>esc</li>
<li>escape</li>
<li>numerics</li>
<li>upper</li>
<li>lower</li>
<li>alphanumeric</li>
<li>tab</li>
<li>shift</li>
<li>alt</li>
<li>ctrl</li>
<li>f1</li>
<li>f2</li>
<li>f3</li>
<li>f4</li>
<li>f5</li>
<li>f6</li>
<li>f7</li>
<li>f8</li>
<li>f9</li>
<li>f10</li>
<li>f11</li>
<li>f12</li>
<li>caps</li>
<li>capslock</li>
<li>numlock</li>
<li>winflag</li>
<li>winkey</li>
<li>windows</li>
<li>scrolllock</li>
<li>left</li>
<li>up</li>
<li>right</li>
<li>down</li>
<li>volumeup</li>
<li>volumedown</li>
<li>menu</li>
<li>contextmenu</li>
<li>backspace</li>
<li>pause</li>
<li>break</li>
<li>pausebreak</li>
<li>pageup</li>
<li>pagedown</li>
<li>end</li>
<li>home</li>
<li>insert</li>
<li>del</li>
<li>delete</li>
<li>numpad0</li>
<li>numpad1</li>
<li>numpad2</li>
<li>numpad3</li>
<li>numpad4</li>
<li>numpad5</li>
<li>numpad6</li>
<li>numpad7</li>
<li>numpad8</li>
<li>numpad9</li>
<li>*</li>
<li>multiply</li>
<li>+</li>
<li>add</li>
<li>-</li>
<li>subtract</li>
<li>.</li>
<li>fullstop</li>
<li>decimal</li>
<li>/</li>
<li>divide</li>
<li>;</li>
<li>semicolon</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/jq-plugins/259-jquery-keyz-plugin.html/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>jQuery Plugin: Element Existence</title>
		<link>http://binarykitten.com/dev/jq-plugins/131-jquery-plugin-element-existence.html</link>
		<comments>http://binarykitten.com/dev/jq-plugins/131-jquery-plugin-element-existence.html#comments</comments>
		<pubDate>Wed, 25 Feb 2009 03:13:25 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[jQuery Plugins]]></category>
		<category><![CDATA[exists]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://binarykitten.jkrswebsolutions.co.uk/?p=131</guid>
		<description><![CDATA[Just a Quick little snippet really.. Over at JqueryForDesigners.com @rem mentioned about checking if an element exists or not, I&#8217;ve been doing this for some time using the following snippet: jQuery.fn.exists = function() { return (this.length &#62; 0); }; to use it you can now do this: if ($(&#039;#elem&#039;).exists()) { /* do something */ } [...]]]></description>
			<content:encoded><![CDATA[<p>Just a Quick little snippet really..</p>
<p>Over at JqueryForDesigners.com  <a href="http://twitter.com/rem">@rem</a> mentioned about <a href="http://jqueryfordesigners.com/element-exists/">checking if an element exists or not</a>, I&#8217;ve been doing this for some time using the following snippet:</p>
<pre class="brush: javascript">
jQuery.fn.exists = function() {
    return (this.length &gt; 0);
};
</pre>
<p>to use it you can now do this:</p>
<pre class="brush: javascript">
if ($(&#039;#elem&#039;).exists()) { /* do something */ }
</pre>
<p>Hope this is helpful to some people</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/jq-plugins/131-jquery-plugin-element-existence.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Enhancing your listings with jQuery and QuickSearch</title>
		<link>http://binarykitten.com/dev/jq-plugins/118-enhancing-your-listings-with-jquery-and-quicksearch.html</link>
		<comments>http://binarykitten.com/dev/jq-plugins/118-enhancing-your-listings-with-jquery-and-quicksearch.html#comments</comments>
		<pubDate>Tue, 17 Feb 2009 21:37:52 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[jQuery Plugins]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[enhance]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[quicksearch]]></category>

		<guid isPermaLink="false">http://binarykitten.jkrswebsolutions.co.uk/?p=118</guid>
		<description><![CDATA[Ever Wanted to have a way to filter/search a list without having to code extra to the serverside? Well maybe the jquery QuickSearch plugin from rikrikrik.com might be the answer Recently I came across the need to filter my results after they had been displayed. I really didn&#8217;t want to start messing with optional WHERE [...]]]></description>
			<content:encoded><![CDATA[<p>Ever Wanted to have a way to filter/search a list without having to code extra to the serverside? Well maybe the jquery QuickSearch plugin from rikrikrik.com might be the answer</p>
<p><span id="more-118"></span></p>
<p>Recently I came across the need to filter my results after they had been displayed. I really didn&#8217;t want to start messing with optional WHERE statements in teh php to control the output of the php as that was rather annoying.</p>
<p>Just at that moment, up popped a tweet fron jQuery telling me about a plugin called QuickSearch after taking a look at it, I found that the search options were nice and simple to use. So I went about implementing it.</p>
<p>The Plugin (available from http://rikrikrik.com/jquery/quicksearch/) was quickly installed and a few lines of js later it was up and working, nicely hiding the elements set up that didn&#8217;t match the search term, quick, simple. Nice.</p>
<p><strong>Setup</strong></p>
<ol>
<li>Download jQuery (is you don&#8217;t already have it) and Link it to your document</li>
<li>Download the plugin and place into the right place (like /js possibly)</li>
<li>Link to the file &lt;script type=&#8221;text/javascript&#8221; src=&#8221;/js/jquery.quicksearch.js&#8221;&gt;&lt;/script&gt;</li>
<li>Setup the JS to load the Quicksearch</li>
</ol>
<p>for Example, lets take the setup list we just had:<br />
Html:
<pre class="brush: html">
&lt;ul id=&quot;listings&quot;&gt;
	&lt;li&gt;Download jQuery (is you don&#039;t already have it) and Link it to your document&lt;/li&gt;
	&lt;li&gt;Download the plugin and place into the right place (like /js possibly)&lt;/li&gt;
	&lt;li&gt;Link to the file &lt;script type=&quot;text/javascript&quot; src=&quot;/js/jquery.quicksearch.js&quot;&gt;&lt;/script&gt;&lt;/li&gt;
	&lt;li&gt;Setup the JS to load the Quicksearch&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>JS</p>
<pre class="brush: javascript">
$(function(){ /* Wait for Document Ready */
/* take the items we want searching and call quicksearch on them

*/
$(&#039;ul#listings li&#039;).quicksearch({
position: &#039;before&#039;,
attached: &#039;#listings&#039;,
loaderText: &#039;&#039;,
delay: 100
});
});
</pre>
<p>This will create the demo you can see over at <a href="http://jsbin.com/atafi" target="_blank">http://jsbin.com/atafi</a> as you type into the box you can search the list.. only displaying items that match.</p>
<p>Now for the fun part.<br />
When you call the .quicksearch function.. it indexes the content of the items you have passed. So we can actively enhance this search by having hidden data in side each element..</p>
<p>Html:
<pre class="brush: html">
&lt;ul id=&quot;listings&quot;&gt;
	&lt;li&gt;Download jQuery (is you don&#039;t already have it) and Link it to your document&lt;span style=&quot;display:none&quot;&gt;1 first 1st&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;Download the plugin and place into the right place (like /js possibly)&lt;span style=&quot;display:none&quot;&gt;2 second 2nd&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;Link to the file &lt;script type=&quot;text/javascript&quot; src=&quot;/js/jquery.quicksearch.js&quot;&gt;&lt;/script&gt;&lt;span style=&quot;display:none&quot;&gt;3 third 3rd&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;Setup the JS to load the Quicksearch&lt;span style=&quot;display:none&quot;&gt;4 fourth 4th&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>Just using exactly the same JS as before we now can search to options by using 4  or third for example..<br />
<a href="http://jsbin.com/exumu">http://jsbin.com/exumu</a></p>
<p>Finally now we have the basics.. we can really go to town.<br />
1st we need to Hide the quicksearch with css </p>
<pre class="brush: css">
#quicksearch { display: none; }
</pre>
<p>This will hide the quicksearch form.</p>
<p>Next we take our html and add a couple of buttons</p>
<pre class="brush: html">
&lt;input type=&quot;button&quot; id=&quot;btnclear&quot; value=&quot;reset&quot; /&gt;
&lt;input type=&quot;button&quot; id=&quot;btn1&quot; value=&quot;show 1&quot; /&gt;
&lt;input type=&quot;button&quot; id=&quot;btn2&quot; value=&quot;show 2nd&quot; /&gt;
&lt;input type=&quot;button&quot; id=&quot;btn4&quot; value=&quot;show fourth&quot; /&gt;
&lt;ul id=&quot;listings&quot;&gt;
	&lt;li&gt;Download jQuery (is you don&#039;t already have it) and Link it to your document&lt;span style=&quot;display:none&quot;&gt;1 first 1st&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;Download the plugin and place into the right place (like /js possibly)&lt;span style=&quot;display:none&quot;&gt;2 second 2nd&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;Link to the file &lt;script type=&quot;text/javascript&quot; src=&quot;/js/jquery.quicksearch.js&quot;&gt;&lt;/script&gt;&lt;span style=&quot;display:none&quot;&gt;3 third 3rd&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;Setup the JS to load the Quicksearch&lt;span style=&quot;display:none&quot;&gt;4 fourth 4th&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>and update the js to:</p>
<pre class="brush: javascript">
$(function(){
  /* append to the end of the document */
  $(&#039;ul#listings li&#039;).quicksearch({
    position: &#039;append&#039;,
    attached: &#039;body&#039;,
    loaderText: &#039;&#039;,
    delay: 100
  });
  $(&#039;#btn1&#039;).click(function(){
    $(&#039;.qs_input&#039;).val(&#039;1&#039;).keydown(); /* Set key and trigger keydown, which is what quicksearch responds to */
  });
  $(&#039;#btn2&#039;).click(function(){    $(&#039;.qs_input&#039;).val(&#039;2nd&#039;).keydown(); });
  $(&#039;#btn4&#039;).click(function(){    $(&#039;.qs_input&#039;).val(&#039;fourth&#039;).keydown(); });
  $(&#039;#btnclear&#039;).click(function(){    $(&#039;.qs_input&#039;).val(&#039;&#039;).keydown(); });
});
</pre>
<p>This gives us clickable buttons that do our filtering using the quicksearch plugin. Demo is here: <a href="http://jsbin.com/obixa">http://jsbin.com/obixa</a></p>
<p>As you can see this makes for a interesting system.<br />
Hope you get as much use out of this as I am</p>
<p>~ Kat ~</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/jq-plugins/118-enhancing-your-listings-with-jquery-and-quicksearch.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery image Preloader Plus Callbacks</title>
		<link>http://binarykitten.com/dev/jq-plugins/107-jquery-image-preloader-plus-callbacks.html</link>
		<comments>http://binarykitten.com/dev/jq-plugins/107-jquery-image-preloader-plus-callbacks.html#comments</comments>
		<pubDate>Wed, 11 Feb 2009 21:56:26 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[jQuery Plugins]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[preloader]]></category>

		<guid isPermaLink="false">http://binarykitten.jkrswebsolutions.co.uk/?p=107</guid>
		<description><![CDATA[Hi all, After comments on the previous version by Roberto, I looked into creating callbacks within the code so that it can be used in the way that Roberto had outlined, also I used it as a way to improve my knowledge a little. After a while I got stuck and figured out a potential [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all, After comments on the previous version by Roberto, I looked into creating callbacks within the code so that it can be used in the way that Roberto had outlined, also I used it as a way to improve my knowledge a little.</p>
<p>After a while I got stuck and figured out a potential method thanks to ai-a in #Javascript on UnderNet, then I spoke to Remy Sharp on Twitter and always being impressed with the work he does on his site (<a href="http://www.jqueryfordesigners.com" target="_blank">http://www.jqueryfordesigners.com</a>) I asked politely if he would give my code a quick look over. He did so, and so much more besides.</p>
<p>So I present to you now v0.95 of the Image Pre-loader which is now Split into 3 functions (rather than the 2 from before)<br />
<span id="more-107"></span><br />
So the main functionality is the same as the one from <a href="http://binarykitten.jkrswebsolutions.co.uk/2009/01/06/jquery-image-preloader/" target="_blank">http://binarykitten.jkrswebsolutions.co.uk/2009/01/06/jquery-image-preloader/</a> but now has the following functions</p>
<ol>
<li><strong>$.preLoadImages</strong> &#8211; Preload the passed list of images, calling the passed call back function when all images are preloaded</li>
<li><strong>$.preLoadCSSImages</strong> &#8211; Preload all images found within the stylesheets of the document, then call the passed call back function when all the images are preloaded</li>
<li><strong>$.preLoadAllImages</strong> &#8211; Processes the stylesheet images and then if passed additional images, will process them too. When all are complete will call the passed callback function.</li>
</ol>
<p>Here&#8217;s the actual code now for the plugin:</p>
<pre class="brush: javascript">
/* jQuery.preloader - v0.95 - K Reeve aka BinaryKitten
*
* v0.95
* 	# Note - keeping below v1 as really not sure that I consider it public usable.
* 	# But it saying that it does the job it was intended to do.
* 	Added Completion of loading callback.
* 	Main Reworking With Thanks to Remy Sharp of jQuery for Designers
*
*
* v0.9
* 	Fixed .toString being .toSteing
*
* v0.8
*		Fixed sheet.href being null error (was causing issues in FF3RC1)
*
* v0.7
*		Remade the preLoadImages from jQuery to DOM
*
* v0.6
* 		Fixed IE6 Compatability!
*		Moved from jQuery to DOM
*
* v0.5
* 		Shifted the additionalimages loader in the preLoadAllImages so it wasn&#039;t called multiple times
* 		Created secondary .preLoadImages to handle additionalimages and so it can be called on itself
*/

(function ($) {
	$.preLoadImages = function(imageList,callback) {
		var pic = [], i, total, loaded = 0;
		if (typeof imageList != &#039;undefined&#039;) {
			if ($.isArray(imageList)) {
				total = imageList.length; // used later
					for (i=0; i &lt; total; i++) {
						pic[i] = new Image();
						pic[i].onload = function() {
							loaded++; // should never hit a race condition due to JS&#039;s non-threaded nature
							if (loaded == total) {
								if ($.isFunction(callback)) {
									callback();
								}
							}
						};
						pic[i].src = imageList[i];
					}
			}
			else {
				pic[0] = new Image();
				pic[0].onload = function() {
					if ($.isFunction(callback)) {
						callback();
					}
				}
				pic[0].src = imageList;
			}
		}
		pic = undefined;
	};

	$.preLoadCSSImages = function(callback) {
		var pic = [], i, imageList = [], loaded = 0, total, regex = new RegExp(&quot;url\((.*)\)&quot;,&#039;i&#039;),spl;
		var cssSheets = document.styleSheets, path,myRules,Rule,match,txt,img,sheetIdx,ruleIdx;
		for (sheetIdx=0;sheetIdx &lt; cssSheets.length;sheetIdx++){
			var sheet = cssSheets[sheetIdx];
			if (typeof sheet.href == &#039;string&#039; &amp;&amp; sheet.href.length &gt; 0) {
				spl = sheet.href.split(&#039;/&#039;);spl.pop();path = spl.join(&#039;/&#039;)+&#039;/&#039;;
			}
			else {
				path = &#039;./&#039;;
			}
			myRules = sheet.cssRules ? sheet.cssRules : sheet.rules;
			for (ruleIdx=0;ruleIdx &lt; myRules.length;ruleIdx++) {
				Rule = myRules[ruleIdx];
				txt = Rule.cssText ? Rule.cssText : Rule.style.cssText;
				match = regex.exec(txt);
				if (match != null) {
					img = match[1].substring(1,match[1].indexOf(&#039;)&#039;,1));
					if (img.substring(0,4) == &#039;http&#039;) {
						imageList[imageList.length] = img;
					}
					else if ( match[1].substring(1,2) == &#039;/&#039;) {
						var p2 = path.split(&#039;/&#039;);p2.pop();p2.pop();p2x = p2.join(&quot;/&quot;);
						imageList[imageList.length] = p2x+img;
					}
					else {
						imageList[imageList.length] = path+img;
					}
				}
			};
		};

		total = imageList.length; // used later
		for (i=0; i &lt; total; i++) {
			pic[i] = new Image();
			pic[i].onload = function() {
				loaded++; // should never hit a race condition due to JS&#039;s non-threaded nature
				if (loaded == total) {
					if ($.isFunction(callback)) {
						callback();
					}
				}
			};
			pic[i].src = imageList[i];
		}

	};
	$.preLoadAllImages = function(imageList,callback) {
		if (typeof imageList != &#039;undefined&#039;) {
			if ($.isFunction(imageList)) {
				callback = imageList;
			}
			else if (!$.isArray(imageList)) {
				imageList = [imageList];
			}
		}
		$.preLoadCSSImages(function(){
			if (imageList.length &gt; 0) {
				$.preLoadImages(imageList,function(){
					callback();
				});
			}
			else {
				callback();
			}
		});
	}
})(jQuery);
</pre>
<p>So now with these in place we can call them as so:</p>
<pre class="brush: javascript">
     $.preLoadImages(
          [
               &#039;http://www.google.co.uk/intl/en_uk/images/logo.gif&#039;,
               &#039;http://l.yimg.com/eur.yimg.com/i/uk/hp/yahoo1.png&#039;,
               &#039;http://tk2.stc.s-msn.com/br/hp/11/en-us/css/i/msn_b2.gif&#039;
          ],function(){
               alert(&#039;All Passed Images Loaded&#039;);
          }
     );
</pre>
<pre class="brush: javascript">
     $.preLoadCSSImages(function(){
          alert(&#039;All CSS Images Loaded&#039;);
     });
</pre>
<pre class="brush: javascript">
     $.preLoadAllImages(
          [
               &#039;http://www.google.co.uk/intl/en_uk/images/logo.gif&#039;,
               &#039;http://l.yimg.com/eur.yimg.com/i/uk/hp/yahoo1.png&#039;,
               &#039;http://tk2.stc.s-msn.com/br/hp/11/en-us/css/i/msn_b2.gif&#039;
          ],function(){
               alert(&#039;All Passed Images and All CSS Images Loaded&#039;);
          }
     );
</pre>
<p>To match up with Robert&#8217;s request for a loader image&#8230;</p>
<pre class="brush: javascript">
$.preLoadImages(&#039;/images/loader.gif&#039;,function() {
  /* Pre Load the loader gif first */
  $(&#039;&lt;img /&gt;&#039;).attr({
  	src:&#039;/images/loader.gif&#039;,
  	id:&#039;loader&#039;
  }).appendTo(&#039;#position&#039;);
  /* now preload stuff */
  $.preLoadCSSImages(function() {
     $(&#039;#loader&#039;).remove();
  })
});
</pre>
<p>Hopefully you have found this useful, as usual.. comments gratefully received.</p>
<p>[edit]<br />
 Thanks to Roberto for pointing out that the source had become corrupted in the post </p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/jq-plugins/107-jquery-image-preloader-plus-callbacks.html/feed</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>jQuery plugin:  ajax Head Request</title>
		<link>http://binarykitten.com/dev/jq-plugins/88-jquery-plugin-ajax-head-request.html</link>
		<comments>http://binarykitten.com/dev/jq-plugins/88-jquery-plugin-ajax-head-request.html#comments</comments>
		<pubDate>Wed, 21 Jan 2009 13:34:32 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[jQuery Plugins]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[head]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[xmlhttprequest]]></category>

		<guid isPermaLink="false">http://binarykitten.jkrswebsolutions.co.uk/?p=88</guid>
		<description><![CDATA[I recently looked into the head request for pulling data without much overhead. PHP can send headers out to the browser in a response.. so I looked into a way to get these headers. I came across a page that outlined using head requests via the xmlhttprequest object. I looked inside jQuery for this functionality [...]]]></description>
			<content:encoded><![CDATA[<p>I recently looked into the head request for pulling data without much overhead. PHP can send headers out to the browser in a response.. so I looked into a way to get these headers. I came across <a href="http://www.jibbering.com/2002/4/httprequest.html" target="_blank">a page</a> that outlined using head requests via the xmlhttprequest object.</p>
<p>I looked inside jQuery for this functionality and noticed it wasn&#8217;t there so I copied the $.post functionality and modified it into $.head.</p>
<p>So I present to you my Plugin for jQuery</p>
<pre class="brush: javascript">
/* jQuery.head - v1.0.3 - K Reeve aka BinaryKitten
*
*	makes a Head Request via XMLHttpRequest (ajax) and returns an object/array of headers returned from the server
*	$.head(url, [data], [callback])
*		url			The url to which to place the head request
*		data		(optional) any data you wish to pass - see $.post and $.get for more info
*		callback	(optional) Function to call when the head request is complete.
*					This function will be passed an object containing the headers with
*					the object consisting of key/value pairs where the key is the header name and the
*					value it&#039;s corresponding value
*
*	for discussion and info please visit: http://binarykitten.me.uk/jQHead
*
* ------------ Version History -----------------------------------
* v1.0.3
* 	Fixed the zero-index issue with the for loop for the headers
* v1.0.2
* 	placed the function inside an enclosure
*
* v1.0.1
* 	The 1st version - based on $.post/$.get
*/

(function ($) {
  $.extend({
	head: function( url, data, callback ) {
	  if ( $.isFunction( data ) ) {
		  callback = data;
		  data = {};
	  }

	  return $.ajax({
		type: &quot;HEAD&quot;,
		url: url,
		data: data,
		complete: function (XMLHttpRequest, textStatus) {
		  var headers = XMLHttpRequest.getAllResponseHeaders().split(&quot;\n&quot;);
		  var new_headers = {};
		  var l = headers.length;
		  for (var key=0;key&lt;l;key++) {
			  if (headers[key].length != 0) {
				  header = headers[key].split(&quot;: &quot;);
				  new_headers[header[0]] = header[1];
			  }
		  }
		  if ($.isFunction(callback)) {
			callback(new_headers);
		  }
		}
	  });
	}
  });
})(jQuery);
</pre>
<p>The function calls the passed url, passing the data and then processes the headers on completion. It takes the long text passed and splits it up into each header line and then splits it into array. The passed array is sent back to the callback function where the key of the array is the header name and the value being the header value.</p>
<p>To call our new function, we use the form just like the basic functionality of $.post and $.get:</p>
<pre class="brush: javascript">
/* $.head(&quot;url&quot;,{data},callback_function(headers) { }); */
/* Example */
$.head(&quot;index.php&quot;,{&#039;a&#039;:5,&#039;bc&#039;:&#039;help&#039;},function(headers) {
	$.each(headers,function(key,header){ console.log(key+&#039;:--:&#039;+header);});
});
</pre>
<p>This will use firebug&#8217;s console.log to output the details of each header.</p>
<p>all straight forward yes?<br />
Hopefully this will help or do something for the people out there<br />
Enjoy</p>
<p><strong>&lt; Edit &gt;</strong><br />
This has now been placed on plugins.jquery.com   ->  <a href="http://plugins.jquery.com/project/jqHead">http://plugins.jquery.com/project/jqHead</a></p>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/jq-plugins/88-jquery-plugin-ajax-head-request.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>jQuery image Preloader</title>
		<link>http://binarykitten.com/dev/jq-plugins/11-jquery-image-preloader.html</link>
		<comments>http://binarykitten.com/dev/jq-plugins/11-jquery-image-preloader.html#comments</comments>
		<pubDate>Tue, 06 Jan 2009 16:20:16 +0000</pubDate>
		<dc:creator>BinaryKitten</dc:creator>
				<category><![CDATA[jQuery Plugins]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://binarykitten.jkrswebsolutions.co.uk/?p=11</guid>
		<description><![CDATA[&#8211; New version with Callbacks now available &#8211; Recently I looked into preloading images via Javascript. I found all the usual ones which require you have a list of all the images you wish to preload. For me though, specifying the images is rather annoying. Also I much prefer CSS roll overs to Javascript ones [...]]]></description>
			<content:encoded><![CDATA[<h2><a href="http://binarykitten.me.uk/dev/jq-plugins/107-jquery-image-preloader-plus-callbacks.html">&#8211; New version with Callbacks now available &#8211;</a></h2>
<p>Recently I looked into preloading images via Javascript. I found all the usual ones which require you have a list of all the images you wish to preload. For me though, specifying the images is rather annoying. Also I much prefer CSS roll overs to Javascript ones so I created this to make it easier.<span id="more-11"></span></p>
<p>This &#8220;plugin&#8221; for jQuery just allows you to preload All the images based in url enclosures within the css files attached to the current page.<br />
I call it a &#8220;plugin&#8221; rather than a plugin as technically it doesn&#8217;t actually need jQuery at all so just remove the &#8220;jQuery.&#8221;  on the function</p>
<pre class="brush: javascript">
/* jQuery.preloader - v0.9 - K Reeve aka BinaryKitten
*
* v0.9
* 	Fixed .toString being .toSteing
*
* v0.8
*		Fixed sheet.href being null error (was causing issues in FF3RC1)
*
* v0.7
*		Remade the preLoadImages from jQuery to DOM
*
* v0.6
* 		Fixed IE6 Compatability!
*		Moved from jQuery to DOM
*
* v0.5
* 		Shifted the additionalimages loader in the preLoadAllImages so it wasn&#039;t called multiple times
* 		Created secondary .preLoadImages to handle additionalimages and so it can be called on itself
*/
jQuery.preLoadImages = function(imagesList) {
	var pic = new Array();
	if (typeof imageList != &#039;undefined&#039;) {
		if (imageList.constructor.toString().indexOf(&#039;Array&#039;) != -1) {
			var l = imageList.length;
			for(apicsIdx=0;apicsIdx&lt;l;apicsIdx++) {
				var c = pic.length;
				pic[c] = new Image();
				pic[c].src = imageList[apicsIdx];
			};
		}
		else {
			var c = pic.length;
			pic[c] = new Image();
			pic[c].src = imageList;
		}
	}
	pic = undefined;
}
jQuery.preLoadAllImages =  function(additionalimages) {
	var regex = new RegExp(&quot;url\((.*)\) &quot;,&#039;i&#039;);
	var pic = new Array();
	var l = document.styleSheets.length;
	for (sheetIdx=0;sheetIdx &lt; l;sheetIdx++){
	var sheet = document.styleSheets[sheetIdx];
	if (typeof sheet.href == &#039;string&#039; &amp;amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp;amp; sheet.href.length &gt; 0) {
		var spl = sheet.href.split(&#039;/&#039;);
		var filename = spl.pop();
		var path = spl.join(&#039;/&#039;)+&#039;/&#039;;
	}
	else {
		var path = &#039;./&#039;;
	}
	myRules = sheet.cssRules ? sheet.cssRules : sheet.rules;
	for (ruleIdx=0;ruleIdx&lt;myRules.length;ruleIdx++) {
		var Rule = myRules[ruleIdx];
		txt = Rule.cssText ? Rule.cssText : Rule.style.cssText
		var match = regex.exec(Rule.cssText);
		if (match != null) {
			if ( match[1].substring(0,1) == &#039;/&#039;) {
				var pic2Load = match[1];
			}
		else {
			var pic2Load = path+match[1];
		}
		if (typeof console != &#039;undefined&#039;)
			if (typeof console.log != &#039;undefined&#039;)
				console.log(pic2Load);
				var c = pic.length;
				pic[c] = new Image();
				pic[c].src = pic2Load;
			}
		};
		sheet = undefined;
		match = undefined;
		styleList = undefined;
		Rule = undefined;
	}
	if (typeof additionalimages != &#039;undefined&#039;) {
		if (additionalimages.constructor.toString().indexOf(&#039;Array&#039;) != -1) {
			var l = additionalimages.length;
			for(apicsIdx=0;apicsIdx&lt;l;apicsIdx++) {
				var c = pic.length;
				pic[c] = new Image();
				pic[c].src = additionalimages[apicsIdx];
			};
		}
		else {
			var c = pic.length;
			pic[c] = new Image();
			pic[c].src = additionalimages;
		}
	}
	regex = undefined;
	pic = undefined;
};
</pre>
<p>Thanks to <strong>Roberto</strong> for pointing this out, I forgot to add how to use it and what it does..</p>
<p><strong>What it does:</strong><br />
Basically the $.preLoadAllImages() function cycles through all your style sheets looking for background images and creates an array that will handle them. After this is done, it cycles through this array and creates a cached image for each file.<br />
If you passthrough an array or filname to the function it will preload those/that image(s) as well.</p>
<p>Finally the $.preLoadImages just preloads images passed to it.. be it a single item or an array of items.</p>
<p><strong>Usage</strong><br />
This really is the simple part.</p>
<ol>
<li>copy the code above to a new file.. save it as jquery.Preloader.js</li>
<li>make sure you know the relative filepath to this new js file</li>
<li>add jquery to the list of included files by doing <script type="text/javascript" src="/file/path/jquery.js"></script></li>
<li>add the new js file to the page: <script type="text/javascript" src="/file/path/jquery.Preloader.js"></script></li>
<li>Finally call the function you want.. you don&#8217;t have to use jquery&#8217;s document ready, as really you might want to have the images ready before hand.. but that&#8217;s down to you.. just call $.preLoadAllImages();  and Voila!</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://binarykitten.com/dev/jq-plugins/11-jquery-image-preloader.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

