<?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>The JavaScript Blog &#187; Snippets</title>
	<atom:link href="http://thejavascriptblog.com/category/snippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://thejavascriptblog.com</link>
	<description>Everything JavaScript</description>
	<lastBuildDate>Sat, 09 Jul 2011 19:16:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>jQuery UI Close Dialog on Overlay Click</title>
		<link>http://thejavascriptblog.com/jquery-ui-close-dialog-on-overlay-click/</link>
		<comments>http://thejavascriptblog.com/jquery-ui-close-dialog-on-overlay-click/#comments</comments>
		<pubDate>Sat, 09 Jul 2011 19:16:00 +0000</pubDate>
		<dc:creator>Merrick Christensen</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://thejavascriptblog.com/?p=111</guid>
		<description><![CDATA[I have seen a lot of overly complex solutions for this simple problem and none of them have been valid solutions, here is a snippet that accomplishes it in an unambiguous manner. $('#el').dialog({ open: function(e){ var self = this; $('.ui-widget-overlay').bind('click', function(){ $(self).dialog('close'); }); }, close: function(){ $('.ui-widget-overlay').unbind('click'); } });]]></description>
			<content:encoded><![CDATA[<p>I have seen a lot of overly complex solutions for this simple problem and none of them have been valid solutions, here is a snippet that accomplishes it in an unambiguous manner.</p>
<pre>
$('#el').dialog({
open: function(e){
          var self = this;
          $('.ui-widget-overlay').bind('click', function(){
            $(self).dialog('close');
          });
        },

        close: function(){
          $('.ui-widget-overlay').unbind('click');
        }
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://thejavascriptblog.com/jquery-ui-close-dialog-on-overlay-click/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When Percents Just Don&#8217;t Cut It</title>
		<link>http://thejavascriptblog.com/when-percents-just-dont-cut-it/</link>
		<comments>http://thejavascriptblog.com/when-percents-just-dont-cut-it/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 16:46:57 +0000</pubDate>
		<dc:creator>Merrick Christensen</dc:creator>
				<category><![CDATA[Extensions]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://thejavascriptblog.com/?p=105</guid>
		<description><![CDATA[The Code $.fn.fill = function(options){ var settings, container, el, calculateHeight, calculateWidth; settings = { fill: window, margins: { x: 0, y: 0 } }; if(options){ $.extend(settings, options); } container = $(settings.fill); el = $(this); calculateWidth = function(){ return (container.width() - settings.margins.x); }; calculateHeight = function(){ return (container.height() - settings.margins.y); } el.css({ width: calculateWidth(), height: calculateHeight() [...]]]></description>
			<content:encoded><![CDATA[<h2>The Code</h2>
<pre>
$.fn.fill = function(options){
	var settings, container, el, calculateHeight, calculateWidth;

	settings = {
		fill: window,
		margins: {
			x: 0,
			y: 0
		}
	};

	if(options){
		$.extend(settings, options);
	}

	container = $(settings.fill);
	el = $(this);

	calculateWidth = function(){
		return (container.width() - settings.margins.x);
	};

	calculateHeight = function(){
		return (container.height() - settings.margins.y);
	}

	el.css({
		width: calculateWidth(),
		height: calculateHeight()
	});

	container.resize(function(){
	       el.css({
	       width: calculateWidth(),
	       height: calculateHeight()
		});

	});
};
</pre>
<h2>Usage</h2>
<pre>
$('#dashboard').fill({
	margins : {
		x: (80 + $('#sidebar').width()),
		y: 100
	}
});
</pre>
<p>This snippet fills the entire window with the dashboard minus the sidebar and 100 pixel padding on the y axis.</p>
]]></content:encoded>
			<wfw:commentRss>http://thejavascriptblog.com/when-percents-just-dont-cut-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove jQuery From Your WordPress Theme</title>
		<link>http://thejavascriptblog.com/remove-jquery-from-your-wordpress-theme/</link>
		<comments>http://thejavascriptblog.com/remove-jquery-from-your-wordpress-theme/#comments</comments>
		<pubDate>Sat, 27 Nov 2010 20:44:00 +0000</pubDate>
		<dc:creator>Merrick Christensen</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://thejavascriptblog.com/?p=99</guid>
		<description><![CDATA[WordPress will generally inject jQuery into your front-end theme which in my opinion is a huge fail. Often times plugins will do it, fortunately there is a simple fix...]]></description>
			<content:encoded><![CDATA[<p>WordPress will generally inject jQuery into your front-end theme which in my opinion is a huge fail. Often times plugins will do it, fortunately there is a simple fix, just above wp_head() or inside of an init callback put:</p>
<pre>
&lt;?php
    	if ( !is_admin() ) wp_deregister_script('jquery');
?&gt;
</pre>
<p>jQuery won&#8217;t be linked anymore. Writing this post has made me start wondering if I should write a more detailed post about WP_Scripts to show how to create dependancies and registering your own scripts. Any interest?</p>
]]></content:encoded>
			<wfw:commentRss>http://thejavascriptblog.com/remove-jquery-from-your-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Grid Bookmarklets</title>
		<link>http://thejavascriptblog.com/grid-bookmarklets/</link>
		<comments>http://thejavascriptblog.com/grid-bookmarklets/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 22:29:55 +0000</pubDate>
		<dc:creator>Merrick Christensen</dc:creator>
				<category><![CDATA[Extensions]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://thejavascriptblog.com/?p=90</guid>
		<description><![CDATA[This morning I was seeking after a sweet bookmarklet to overlay a grid to the current website. Andy Budd had a pretty cool one but there was no way to turn it off, also the image was a little busy. So with the help of Jacob O&#8217;Neal for the images I created a modified version [...]]]></description>
			<content:encoded><![CDATA[<p>This morning I was seeking after a sweet bookmarklet to overlay a grid to the current website. Andy Budd had a pretty cool <a href="http://www.andybudd.com/archives/2006/07/layout_grid_bookmarklet/">one</a> but there was no way to turn it off, also the image was a little busy.</p>
<p>So with the help of <a href="http://jacoboneal.com/">Jacob O&#8217;Neal</a> for the images I created a modified version of Andy Budd&#8217;s bookmarklet. You can now turn off the grid by pressing &#8220;G&#8221;. There is also a white and black version available.</p>
<p>The solid lines represent every 100 pixels. The dotted lines represent every 10 pixels.</p>
<p>To install just drag the below links into your bookmarks bar.</p>
<p><a href="javascript:void(myDiv=document.createElement('div'));void(myBody=document.getElementsByTagName('body'));void(myDiv.style.background='url(http://www.thejavascriptblog.com/public/grid-overlay-white.png)');void(myDiv.style.position='fixed');void(myDiv.style.width='100%');void(myDiv.style.height='100%');void(myDiv.style.top='0');void(myDiv.style.left='0');void(myDiv.style.display='block');void(document.body.appendChild(myDiv));window.addEventListener('keypress',%20function(e){if(e.keyCode%20==%20103){if(myDiv.style.display%20==%20'block'){myDiv.style.display='none';}else{myDiv.style.display='block';}}},%20false);">White Grid</a> <a href="javascript:void(myDiv=document.createElement('div'));void(myBody=document.getElementsByTagName('body'));void(myDiv.style.background='url(http://www.thejavascriptblog.com/public/grid-overlay-black.png)');void(myDiv.style.position='fixed');void(myDiv.style.width='100%');void(myDiv.style.height='100%');void(myDiv.style.top='0');void(myDiv.style.left='0');void(myDiv.style.display='block');void(document.body.appendChild(myDiv));window.addEventListener('keypress',%20function(e){if(e.keyCode%20==%20103){if(myDiv.style.display%20==%20'block'){myDiv.style.display='none';}else{myDiv.style.display='block';}}},%20false);">Black Grid</a></p>
<p>Note: Due to an immense amount of laziness the toggling is only supported in Webkit.</p>
]]></content:encoded>
			<wfw:commentRss>http://thejavascriptblog.com/grid-bookmarklets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WTFramework &#8211; Detect Which Framework A Site Is Using, The Easy Way</title>
		<link>http://thejavascriptblog.com/wtframework-detect-which-framework-a-site-is-using-the-easy-way/</link>
		<comments>http://thejavascriptblog.com/wtframework-detect-which-framework-a-site-is-using-the-easy-way/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 20:20:02 +0000</pubDate>
		<dc:creator>Merrick Christensen</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://thejavascriptblog.com/?p=71</guid>
		<description><![CDATA[WTFramework Summary WTFramework is a dead simple, and well designed way to detect which framework a site is using as well as version. Being primarily a JavaScript developer I was always looking through the source to find which framework a certain site was using. Or to see if the developer had done something particularly cool [...]]]></description>
			<content:encoded><![CDATA[<h2>WTFramework Summary</h2>
<p>WTFramework is a dead simple, and well designed way to detect which framework a site is using as well as version. Being primarily a JavaScript developer I was always looking through the source to find which framework a certain site was using. Or to see if the developer had done something particularly cool with my favorite framework <a href="http://mootools.net" target="_blank">MooTools</a>. </p>
<p>It was developed by <a href="http://twitter.com/oskar">Oskar Krawczyk</a> and is implemented as a bookmark for any A grade browser. You simply drag it into your bookmarks bar and its installed. You can now use it on any site you visit. The notifications are &#8220;Growl&#8221; like and are very well designed. </p>
<p>Kudos to Oskar on this one, a dead simple, but time saving tool.</p>
<h2>Installation</h2>
<ol>
<li><a href="http://nouincolor.com/wtframework/2.0/">Visit The Site</a></li>
<li>Drag the big red icon into your bookmarks.</li>
<li>It is now installed.</li>
</ol>
<h2>Fortunately For Us</h2>
<p>Oskar has a public Git Hub repository for this. So if needs be you can change it to suit your needs.</p>
<h2>Gallery</h2>

<a href='http://thejavascriptblog.com/wtframework-detect-which-framework-a-site-is-using-the-easy-way/screen-shot-2009-12-29-at-7-15-25-pm/' title='Screen shot 2009-12-29 at 7.15.25 PM'><img width="150" height="150" src="http://thejavascriptblog.com/wp-content/uploads/2009/12/Screen-shot-2009-12-29-at-7.15.25-PM-150x150.png" class="attachment-thumbnail" alt="Screen shot 2009-12-29 at 7.15.25 PM" title="Screen shot 2009-12-29 at 7.15.25 PM" /></a>
<a href='http://thejavascriptblog.com/wtframework-detect-which-framework-a-site-is-using-the-easy-way/screen-shot-2009-12-29-at-7-16-01-pm/' title='Screen shot 2009-12-29 at 7.16.01 PM'><img width="150" height="150" src="http://thejavascriptblog.com/wp-content/uploads/2009/12/Screen-shot-2009-12-29-at-7.16.01-PM-150x150.png" class="attachment-thumbnail" alt="Screen shot 2009-12-29 at 7.16.01 PM" title="Screen shot 2009-12-29 at 7.16.01 PM" /></a>

]]></content:encoded>
			<wfw:commentRss>http://thejavascriptblog.com/wtframework-detect-which-framework-a-site-is-using-the-easy-way/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Making Every Specified Link Send Via Ajax Using MooTools</title>
		<link>http://thejavascriptblog.com/making-every-specified-link-send-via-ajax-using-mootools/</link>
		<comments>http://thejavascriptblog.com/making-every-specified-link-send-via-ajax-using-mootools/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 05:44:24 +0000</pubDate>
		<dc:creator>Merrick Christensen</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://thejavascriptblog.com/?p=67</guid>
		<description><![CDATA[This is a relatively simple concept and is nothing to elaborate but I wanted to share a small piece of code that will take every link with the class of &#8220;ajax&#8221; and access it using AJAX instead of actually going to that page. This using the same Request instance which will keep it optimized and [...]]]></description>
			<content:encoded><![CDATA[<p>This is a relatively simple concept and is nothing to elaborate but I wanted to share a small piece of code that will take every link with the class of &#8220;ajax&#8221; and access it using AJAX instead of actually going to that page. This using the same Request instance which will keep it optimized and manageable. MooTools is going to make this nice and easy on us&#8230;</p>
<h2>Usage</h2>
<h3>JavaScript</h3>
<pre>
var ajax_request = new Request(
{
	onSuccess: function(responseText, responseXML)
	{
		$('message').set('html', responseText);
	}
});

$$('.ajax').each(function(item){
	var url = item.get('href');
	item.addEvent('click', function(event){
		ajax_request.options.url = url;
		ajax_request.send();
		return false;
	});
});
</pre>
<h3>HTML</h3>
<pre>
<a href="ajax.php" class="ajax">Sent Via AJAX</a>
<a href="ajax_alternative.php" class="ajax">Also Sent Via AJAX</a>
<div id="message">I am filled with the results of our AJAX requests.</div>
</pre>
<p>Its incredibly simple so no demo for this. The important concept here is that we are using the same request and pulling the href attribute base on a class selection. So changing something from AJAX to regular is as easy as adding or removing the class &#8220;ajax&#8221;. Pretty cool eh?</p>
]]></content:encoded>
			<wfw:commentRss>http://thejavascriptblog.com/making-every-specified-link-send-via-ajax-using-mootools/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

