<?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>Programming Blog &#187; new element</title>
	<atom:link href="http://www.neurosoftware.ro/programming-blog/tag/new-element/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.neurosoftware.ro/programming-blog</link>
	<description>Web development , php , ajax , symfony, framework, zend</description>
	<lastBuildDate>Thu, 18 Aug 2011 08:11:19 +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>MooTools Wall&#160;Plugin</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-wallplugin/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-wallplugin/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 03:35:18 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[ccc]]></category>
		<category><![CDATA[div id]]></category>
		<category><![CDATA[img width]]></category>
		<category><![CDATA[maxlength]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[new image]]></category>
		<category><![CDATA[two elements]]></category>
		<category><![CDATA[viewport]]></category>
		<category><![CDATA[x 450]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-wallplugin/</guid>
		<description><![CDATA[One of the more impressive MooTools plugins to hit the Forge recently was The Wall by Marco Dell&#8217;Anna.  The Wall creates an endless grid of elements which can be grabbed and dragged, fading in elements as they are encountered.  Let me show you a quick usage of the Wall! View Demo The&#160;HTML There are two elements [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://davidwalsh.name/dw-content/wall.php"><img src="http://davidwalsh.name/dw-content/wall.png" alt="MooTools Wall" class="image" /></a>
<p>One of the more impressive MooTools plugins to hit the Forge recently was <a href="http://mootools.net/forge/p/the_wall" rel="nofollow">The Wall</a> by Marco Dell&#8217;Anna.  <a href="http://wall.plasm.it/" rel="nofollow">The Wall</a> creates an endless grid of elements which can be grabbed and dragged, fading in elements as they are encountered.  Let me show you a quick usage of the Wall!</p>
<div><a href="http://davidwalsh.name/dw-content/wall.php">View Demo</a>
<div></div>
</div>
<h2>The&nbsp;HTML</h2>
<p>There are two elements in the setup: a viewport and a wall holder:</p>
<pre>
&lt;div id="viewport"&gt;
	&lt;div id="wall"&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>Easy enough.</p>
<h2>The&nbsp;CSS</h2>
<p>The CSS must be configured to accommodate your wall.  Your viewport&#8217;s <code>height</code> and <code>width</code> properties should be multiples of your block heights.  You don&#8217;t <em>have</em> to configure the viewport that way, but it you wall will be more visually appealing.</p>
<pre>
#viewport		{ border:1px solid #ccc; width:450px; height:450px; position:relative; overflow:hidden; }
#wall			{ z-index:1; }
#wall img		{ width:150px; height:150px; display:block; float:left; }
</pre>
<p>My viewport will be 450 x 450, with each element being 150 x 150.</p>
<h2>The MooTools&nbsp;JavaScript</h2>
<p>It all starts by creating a Wall instance, providing <code>width</code>, <code>height</code>, <code>rangex</code>, and <code>rangey</code> attributes, providing them as the size of the elements (or not):</p>
<pre>
// When the DOM is ready
window.addEvent("domready", function() {

	// Define a few variables, including the number of images and the "current index"
	var numImages = 23, // 24 images, 0 index
		counter = 0;

	// Create the Wall
	new Wall("wall", {
		width: 150,
		height: 150,
		rangex: [-150,150],
		rangey: [-150,150],
		callOnUpdate: function(items) {
			// For every item returned...
			items.each(function(item) {
				// Inject a new image, fade it in
				new Element("img", {
					src: (++counter) + ".jpg",
					styles: {
						opacity: 0
					}
				}).inject(item.node).fade(1);
				// Reset to image one if the maxlength is greater than the counter
				if(counter &gt; numImages) counter = 1;
			});
		}
	}).initWall();
});
</pre>
<p>The callOnUpdate method is most important, providing an index by which you can inject your new element (in our case, an image).  Once the counter reaches its maximum length, the index is reset, and the wall continues!</p>
<div><a href="http://davidwalsh.name/dw-content/wall.php">View Demo</a>
<div></div>
</div>
<p>Awesome work by Marco.  My example is just the most basic of usages &#8212; visit <a href="http://wall.plasm.it/">Marco&#8217;s website</a> to see the additional options and examples he has provided.  I can see someone using The Wall to generate a very creative, all-encompassing website!</p>
<p><a href="http://davidwalsh.name/mootools-wall">MooTools Wall&nbsp;Plugin</a> is a post from: <a href="http://davidwalsh.name">David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</a></p>
<p> <img src="http://feeds.feedburner.com/~r/Bludice/~4/oQrXVfEzxJQ" height="1" width="1" /><br />
<a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-wallplugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Vector Masks using the HTML5 Canvas</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-vector-masks-using-the-html5-canvas/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-vector-masks-using-the-html5-canvas/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 03:48:00 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Clipping]]></category>
		<category><![CDATA[cool things]]></category>
		<category><![CDATA[drawimage]]></category>
		<category><![CDATA[image element]]></category>
		<category><![CDATA[image img]]></category>
		<category><![CDATA[img element]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[video effects]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-vector-masks-using-the-html5-canvas/</guid>
		<description><![CDATA[The HTML5 canvas can be used to create a lot of cool things, like games, video effects, graphs and more. It can also be used to produce some slightly less complex effects, like manipulating images on the page. In this post we will look at how to use the canvas tag and clipping to create [...]]]></description>
			<content:encoded><![CDATA[<p>The HTML5 canvas can be used to create a lot of cool things, like games, video effects, graphs and more. It can also be used to produce some slightly less complex effects, like manipulating images on the page.</p>
<p>In this post we will look at how to use the canvas tag and clipping to create images that aren&#8217;t so rectangular.</p>
<p><span></span></p>
<h2>Setting up the Canvas</h2>
<p>In this example, I am going to be using an image of Ryan, and see if I can modify the shape of it, using the canvas.</p>
<p>First we need a canvas tag in our page</p>
<div>
<table>
<tr>
<td>
<pre>1
</pre>
</td>
<td>
<pre>&lt;canvas id=&quot;c&quot; width=&quot;200&quot; height=&quot;158&quot;&gt;&lt;/canvas&gt;</pre>
</td>
</tr>
</table>
</div>
<p>This just sets up a simple canvas with the width and height of our image. I chose these dimensions so that it does not take up any more space than is needed.</p>
<p>Next in JavaScript we will get the canvas and its drawing context in JavaScript</p>
<div>
<table>
<tr>
<td>
<pre>1
2
3
</pre>
</td>
<td>
<pre><span>// Grab the Canvas and Drawing Context</span>
<span>var</span> canvas <span>=</span> document.<span>getElementById</span><span>&#040;</span><span>'c'</span><span>&#041;</span><span>;</span>
<span>var</span> ctx <span>=</span> canvas.<span>getContext</span><span>&#040;</span><span>'2d'</span><span>&#041;</span><span>;</span></pre>
</td>
</tr>
</table>
</div>
<p>So now we are ready to begin drawing our image into the canvas.</p>
<h2>Drawing the Image into the Canvas</h2>
<p>We have our canvas set up, now we need to draw the image into that canvas. We can do this easily, but we need an HTML img element with our image in order to draw it.</p>
<p>We could grab an &lt;img&gt; tag from our page, but we can do it using JavaScript.</p>
<div>
<table>
<tr>
<td>
<pre>1
2
3
4
5
6
7
8
9
10
</pre>
</td>
<td>
<pre><span>// Create an image element</span>
<span>var</span> img <span>=</span> document.<span>createElement</span><span>&#040;</span><span>'IMG'</span><span>&#041;</span><span>;</span>
&nbsp;
<span>// When the image is loaded, draw it</span>
img.<span>onload</span> <span>=</span> <span>function</span> <span>&#040;</span><span>&#041;</span> <span>&#123;</span>
    ctx.<span>drawImage</span><span>&#040;</span>img<span>,</span> <span>0</span><span>,</span> <span>0</span><span>&#041;</span><span>;</span>
<span>&#125;</span>
&nbsp;
<span>// Specify the src to load the image</span>
img.<span>src</span> <span>=</span> <span>&quot;http://i.imgur.com/gwlPu.jpg&quot;</span><span>;</span></pre>
</td>
</tr>
</table>
</div>
<p><a href="http://jsfiddle.net/jimrhoskins/Sv87G/">Run this code</a></p>
<p>Here we are creating a new element for our image. Since we can&#8217;t draw the image until it has been downloaded, we need to wait for onload to draw it. Inside of the onload listener, we call the ctx.drawImage(), and pass it the img element. We also pass 0, 0 meaning we want to draw 0 pixels from the top and left.</p>
<p>Finally we set the src of our image, which triggers the browser to fetch the image data.</p>
<h2>Clip that Image</h2>
<p>In the canvas, we can use a technique called clipping. We can use a path we define to specify that future operations should only affect the area within the path.</p>
<p>Since the canvas is transparent, if we create a clipping path, and then draw the image, the image will only show up inside the shape of that path.</p>
<p>So let&#8217;s draw a circle, clip to that path, and draw the image.</p>
<div>
<table>
<tr>
<td>
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre>
</td>
<td>
<pre><span>// Create an image element</span>
<span>var</span> img <span>=</span> document.<span>createElement</span><span>&#040;</span><span>'IMG'</span><span>&#041;</span><span>;</span>
&nbsp;
<span>// When the image is loaded, draw it</span>
img.<span>onload</span> <span>=</span> <span>function</span> <span>&#040;</span><span>&#041;</span> <span>&#123;</span>
&nbsp;
    <span>// Save the state, so we can undo the clipping</span>
    ctx.<span>save</span><span>&#040;</span><span>&#041;</span><span>;</span>
&nbsp;
&nbsp;
    <span>// Create a circle</span>
    ctx.<span>beginPath</span><span>&#040;</span><span>&#041;</span><span>;</span>
    ctx.<span>arc</span><span>&#040;</span><span>106</span><span>,</span> <span>77</span><span>,</span> <span>74</span><span>,</span> <span>0</span><span>,</span> Math.<span>PI</span> <span>*</span> <span>2</span><span>,</span> <span>false</span><span>&#041;</span><span>;</span>
&nbsp;
    <span>// Clip to the current path</span>
    ctx.<span>clip</span><span>&#040;</span><span>&#041;</span><span>;</span>
&nbsp;
&nbsp;
    ctx.<span>drawImage</span><span>&#040;</span>img<span>,</span> <span>0</span><span>,</span> <span>0</span><span>&#041;</span><span>;</span>
&nbsp;
    <span>// Undo the clipping</span>
    ctx.<span>restore</span><span>&#040;</span><span>&#041;</span><span>;</span>
<span>&#125;</span>
&nbsp;
<span>// Specify the src to load the image</span>
img.<span>src</span> <span>=</span> <span>&quot;http://i.imgur.com/gwlPu.jpg&quot;</span><span>;</span></pre>
</td>
</tr>
</table>
</div>
<p><a href="http://jsfiddle.net/jimrhoskins/Sv87G/1/">Run this code</a></p>
<p>You may notice the ctx.save() and ctx.restore() calls. This is because anything we try to do to the canvas after we clip it will only work within the clipping region. We call save() before we clip and then call restore() after, and the state of the canvas will be restored to before the clipping was applied. Everything you drew will remain, but the clipping definition will be gone.</p>
<h2>Go Crazy</h2>
<p>You can clip to more than just circles. You can clip to any shape you want. You just need to define your path.</p>
<div>
<table>
<tr>
<td>
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre>
</td>
<td>
<pre><span>// Create an image element</span>
<span>var</span> img <span>=</span> document.<span>createElement</span><span>&#040;</span><span>'IMG'</span><span>&#041;</span><span>;</span>
&nbsp;
<span>// When the image is loaded, draw it</span>
img.<span>onload</span> <span>=</span> <span>function</span> <span>&#040;</span><span>&#041;</span> <span>&#123;</span>
&nbsp;
    <span>// Save the state, so we can undo the clipping</span>
    ctx.<span>save</span><span>&#040;</span><span>&#041;</span><span>;</span>
&nbsp;
&nbsp;
    <span>// Create a shape, of some sort</span>
    ctx.<span>beginPath</span><span>&#040;</span><span>&#041;</span><span>;</span>
    ctx.<span>moveTo</span><span>&#040;</span><span>10</span><span>,</span> <span>10</span><span>&#041;</span><span>;</span>
    ctx.<span>lineTo</span><span>&#040;</span><span>100</span><span>,</span> <span>30</span><span>&#041;</span><span>;</span>
    ctx.<span>lineTo</span><span>&#040;</span><span>180</span><span>,</span> <span>10</span><span>&#041;</span><span>;</span>
    ctx.<span>lineTo</span><span>&#040;</span><span>200</span><span>,</span> <span>60</span><span>&#041;</span><span>;</span>
    ctx.<span>arcTo</span><span>&#040;</span><span>180</span><span>,</span> <span>70</span><span>,</span> <span>120</span><span>,</span> <span>0</span><span>,</span> <span>10</span><span>&#041;</span><span>;</span>
    ctx.<span>lineTo</span><span>&#040;</span><span>200</span><span>,</span> <span>180</span><span>&#041;</span><span>;</span>
    ctx.<span>lineTo</span><span>&#040;</span><span>100</span><span>,</span> <span>150</span><span>&#041;</span><span>;</span>
    ctx.<span>lineTo</span><span>&#040;</span><span>70</span><span>,</span> <span>180</span><span>&#041;</span><span>;</span>
    ctx.<span>lineTo</span><span>&#040;</span><span>20</span><span>,</span> <span>130</span><span>&#041;</span><span>;</span>
    ctx.<span>lineTo</span><span>&#040;</span><span>50</span><span>,</span> <span>70</span><span>&#041;</span><span>;</span>
    ctx.<span>closePath</span><span>&#040;</span><span>&#041;</span><span>;</span>
    <span>// Clip to the current path</span>
    ctx.<span>clip</span><span>&#040;</span><span>&#041;</span><span>;</span>
&nbsp;
&nbsp;
    ctx.<span>drawImage</span><span>&#040;</span>img<span>,</span> <span>0</span><span>,</span> <span>0</span><span>&#041;</span><span>;</span>
&nbsp;
    <span>// Undo the clipping</span>
    ctx.<span>restore</span><span>&#040;</span><span>&#041;</span><span>;</span>
<span>&#125;</span>
&nbsp;
<span>// Specify the src to load the image</span>
img.<span>src</span> <span>=</span> <span>&quot;http://i.imgur.com/gwlPu.jpg&quot;</span><span>;</span></pre>
</td>
</tr>
</table>
</div>
<p><a href="http://jsfiddle.net/jimrhoskins/dDUC3/1/">Run this code</a></p>
<p>You can use clipping in combination with other techniques to create some pretty interesting effects. What cool effects can you create?</p>
<div>
</div>
<p><img src="http://feeds.feedburner.com/~r/vitaminmasterfeed/~4/QwPxk5O009I" height="1" width="1" /><br />
<a href="http://feeds2.feedburner.com/vitaminmasterfeed">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-vector-masks-using-the-html5-canvas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MooTools ScrollSpy, Mobile Devices, JavaScript Scroll Events, and CSS&#160;Positioning</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-scrollspy-mobile-devices-javascript-scroll-events-and-csspositioning/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-scrollspy-mobile-devices-javascript-scroll-events-and-csspositioning/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 21:25:18 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[document body]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[mobile browser]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[other mobile device]]></category>
		<category><![CDATA[text shadow]]></category>
		<category><![CDATA[traditional browser]]></category>
		<category><![CDATA[typical web]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-scrollspy-mobile-devices-javascript-scroll-events-and-csspositioning/</guid>
		<description><![CDATA[One question I&#8217;ve been asked often is why ScrollSpy and my Go To Top link functionality don&#8217;t appear to work well on the iPhone, iPad, or any other mobile device.  The problem is simple to identify and easy to fix.  The issue comes down to the way mobile devices view fixed-positioned elements.  Let me explain [...]]]></description>
			<content:encoded><![CDATA[<p>One question I&#8217;ve been asked often is why <a href="http://davidwalsh.name/js/scrollspy">ScrollSpy</a> and my <a href="http://davidwalsh.name/mootools-watermark">Go To Top link</a> functionality don&#8217;t appear to work well on the iPhone, iPad, or any other mobile device.  The problem is simple to identify and easy to fix.  The issue comes down to the way mobile devices view fixed-positioned elements.  Let me explain to you the scenario, problem, and solution to making the &#8220;Go To Top&#8221; link follow the user as they scroll.</p>
<div><a href="http://davidwalsh.name/dw-content/scrollspy-mobile.php">View Demo</a>
<div></div>
</div>
<h2>ScrollSpy&#8217;s / &#8220;Go To Top&#8221; Basic&nbsp;Usage</h2>
<p>The first step will be creating the CSS for the &#8220;Go To Top&#8221; link.  The link will be styled to work well within the traditional browser since that&#8217;s our priority.</p>
<pre>
#totop {
	color:#090;
	font-weight:bold;
	text-shadow:1px 1px 0 #ccc;
	bottom:10px;
	right:10px;
	font-size:1.1em;
	position:fixed;
	display:block;
	z-index:10;
}
</pre>
<p>The link is set to display 10px from the bottom of the screen at any given time.  The ScrollSpy usage is fairly simple;  when the &#8220;enter&#8221; threshold is met, the element fades in:</p>
<pre>
// When the DOM is ready
window.addEvent("domready",function() {
	// Create the "top" link
	var top = new Element('a', {
		id: 'totop',
		text: 'Top',
		styles: { opacity: 0 },
		href: '#top'
	}).inject(document.body);
	// Create a ScrollSpy instance
	var spy = new ScrollSpy({
		min: 150,
		onEnter: function(pos) {
			top.fade(1);
		},
		onLeave: function(pos) {
			top.fade(0);
		}
	});
});
</pre>
<p>At this point, the &#8220;Go To Top&#8221; link functionality will work great within your typical web browser.  Your mobile browser?  Not so much.  Why?</p>
<h2>The Mobile&nbsp;Issue</h2>
<p>The reason you wont see the GTT link follow the browser as it scrolls is two fold:</p>
<ol>
<li>Your mobile device&#8217;s browser sees the the page as one &#8220;view&#8221;, and pages downward.  Thus, fixing a link to the bottom keeps it there, regardless of where the user is in the page.</li>
<li>The scroll event only fires at the end of the user&#8217;s scroll, not during, so the link will not follow the user as they scroll.  Once the scroll ends, the link will &#8220;jump&#8221; down to the bottom of the view.</li>
</ol>
<p>With those two details in mind, let&#8217;s fix this scrolling CSS problem.</p>
<h2>The Solution:  Position Reassignment&nbsp;onScroll</h2>
<p>The only way to fix the scrolling problem is to adjust a few of the CSS settings we provided for the traditional browser.  Instead of using <code>fixed</code> positioning, we&#8217;re going to use <code>absolute</code> positioning and we&#8217;ll also update the CSS <code>top</code> setting to place the element within the viewport.</p>
<pre>
// If this is an iOS mobile platform...
if(Browser.Platform.ios || Browser.Platform.android) {
	// Change styling of the TOP element's position
	top.setStyles({
		position: "absolute",
		bottom: "auto"
	});
	// Add a scroll event to...
	spy.addEvent("scroll",function(position) {
		// ...position the element
		 // 20px offset from bottom
		top.setStyle("top",(position.y + window.getSize().y - 20) + "px");
	});
}
</pre>
<p>One we establish that the client is a mobile browser, we swap out the positioning styles and add a scroll event to ScrollSpy to update the top position of the GTT link at the end of every scroll.  Probably easier than you thought, no?  This solution was tested on iPad, iPhone, and Android.</p>
<div><a href="http://davidwalsh.name/dw-content/scrollspy-mobile.php">View Demo</a>
<div></div>
</div>
<p>There you have it!  The problem isn&#8217;t with ScrollSpy;  it&#8217;s with the way that mobile browsers handle fixed positioning.  No updates to ScrollSpy will be made on account of mobile, as ScrollSpy is simply used to get positioning information;  as long as the position information is provided, you can add positioning styles to desired elements.</p>
<p><strong>Follow Me!</strong> <a href="http://twitter.com/davidwalshblog">Twitter</a> | <a href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a></p>
<p>Full David Walsh Blog Post: <a href="http://davidwalsh.name/scrollspy-mobile">MooTools ScrollSpy, Mobile Devices, JavaScript Scroll Events, and CSS&nbsp;Positioning</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/css-fixed-position" rel="bookmark" title="Permanent Link: CSS Fixed Positioning">CSS Fixed&nbsp;Positioning</a></li>
<li><a href="http://davidwalsh.name/mootools-touch" rel="bookmark" title="Permanent Link: Mobile Touch Events in MooTools 1.3">Mobile Touch Events in MooTools&nbsp;1.3</a></li>
<li><a href="http://davidwalsh.name/zoom-mobile-browsers" rel="bookmark" title="Permanent Link: Prevent Page Zooming in Mobile Browsers">Prevent Page Zooming in Mobile&nbsp;Browsers</a></li>
<li><a href="http://davidwalsh.name/mootools-watermark" rel="bookmark" title="Permanent Link: “Top” Watermark Using MooTools">&#8220;Top&#8221; Watermark Using&nbsp;MooTools</a></li>
<li><a href="http://davidwalsh.name/scrollspy-terms" rel="bookmark" title="Permanent Link: Scrolling “Agree to Terms” Component with MooTools ScrollSpy">Scrolling &#8220;Agree to Terms&#8221; Component with MooTools&nbsp;ScrollSpy</a></li>
</ol>
<p><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/50b4e_1sgqe-dLNeI" height="1" width="1" /><br />
<a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-scrollspy-mobile-devices-javascript-scroll-events-and-csspositioning/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>MooTools 1.3 Hits the Street</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-1-3-hits-the-street/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-1-3-hits-the-street/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 04:10:11 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[core api]]></category>
		<category><![CDATA[cow moo]]></category>
		<category><![CDATA[css selector]]></category>
		<category><![CDATA[element method]]></category>
		<category><![CDATA[fabio costa]]></category>
		<category><![CDATA[future proof]]></category>
		<category><![CDATA[global variables]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[pojer]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-1-3-hits-the-street/</guid>
		<description><![CDATA[After almost a year in development, the MooTools team announced the release of version 1.3 with major notable enhancements. Slick Selector Engine The biggest update is the inclusion of the new Slick standalone selector engine. The engine was developed by Thomas Aylott, Fabio Costa and Valerio Proietti with accuracy and portability in mind, allowing the [...]]]></description>
			<content:encoded><![CDATA[<p>After almost a year in development, the MooTools team <a href="http://mootools.net/blog/2010/10/11/mootools-core-1-3-stable-and-mootools-more-1-3rc/">announced the release of version 1.3</a> with major notable enhancements.</p>
<h3>Slick Selector Engine</h3>
<p>The biggest update is the inclusion of the new <a href="http://github.com/subtleGradient/slick">Slick standalone selector engine</a>. The engine was developed by Thomas Aylott, Fabio Costa and Valerio Proietti with accuracy and portability in mind, allowing the engine to not only provide MooTools developers with excellent selector support but also the ability for it to be included in other projects as well. The MooTools team created over 3,000 tests to ensure that even the most obscure scenarios were considered. The inclusion of Slick also allowed the team to extend the Element method to allow creation of DOM elements using complex CSS selector expressions. Very cool!</p>
<div><a href="showCodeTxt('javascript-2');">PLAIN TEXT</a></div>
<div><span>JAVASCRIPT:</span></p>
<div>
<div><span>var</span> newElement = <span>new</span> Element<span>&#040;</span><span>&#8216;div#cow.moo.big[data-size=5]&#8216;</span><span>&#041;</span></div>
</div>
</div>
<h3>Core Updates</h3>
<p>The MooTools team also focused on enhancing the core API in preparation for MooTools 2.0 by deprecated every $- prefixed function and nd moving those to the relevant natives namespaces:</p>
<blockquote><p>We have revised the whole base of our library to speed up MooTools, to provide an even more beautiful API and to make our library future-proof. In order to reduce the amount of global variables we have moved all $-prefixed functions into their according namespace ($splat » Array.from, …). In short we think that with 1.3 you are getting the best MooTools experience ever.</p>
</blockquote>
<h3>New Build Manager</h3>
<p>Building a new version of MooTools has always been easy using the builder and now it&#8217;s been improved via the <a href="http://github.com/kamicane/packager">new Packager preprocessor</a> which allows you to create custom MooTools builds from Github repositories. It handles code dependencies and already provides support for several MooTools plugins. The new Packager is a PHP 5.2+ library but can also be found as a <a href="http://github.com/anutron/mootools-depender">Python app thanks to Aaron Newton&#8217;s work</a>.</p>
<h3>MooTools Runner</h3>
<p>To make sure that MooTools continues to adhere to the projects&#8217;s specifications, <a href="http://cpojer.net">Christoph Pojer</a> &#038; <a href="http://aryweb.nl/">Arian Stolwijk</a> spent some time over the summer building a new spec testing engine called MooTools Runner which has been adopted by all major MooTools projects &#8211; Core, More and Slick. The engine is based on <a href="http://pivotal.github.com/jasmine/">Jasmine</a> and runs all specs within just 2 seconds. In addition, code coverage was increased to about 95%, ensuring excellent test coverage for Core.</p>
<h3>Download it!</h3>
<p>Once you&#8217;re ready, you can grab the latest version of MooTools or roll your own via the following links:</p>
<ul>
<li><a href="http://mootools.net/download">Download MooTools Core 1.3</a></li>
<li>
</li>
<li><a href="http://mootools.net/core/">Build MooTools Core 1.3</a></li>
<li><a href="http://mootools.net/more-rc/">Build MooTools More 1.3RC</a></li>
<li><a href="http://github.com/mootools/mootools-core/wiki/Update-from-1.2-to-1.3">Update from 1.2 to 1.3</a> with 1.2 compatibility.</li>
<li><a href="http://github.com/mootools/mootools-core/wiki/Upgrade-from-1.2-to-1.3">Upgrade from 1.2 to 1.3</a> and drop 1.2 compatibility.</li>
<li>Fork / clone <a href="http://github.com/mootools/mootools-core/tree/1.3">MooTools 1.3 from GitHub</a>, and build it yourself with <a href="http://github.com/kamicane/packager">Packager</a>.</li>
<li><a href="http://github.com/mootools/mootools-core/commits/1.3">Read the commit logs</a> to see precisely what has changed.</li>
<li><a href="http://mootools.net/docs">Browse the Documentation for Core &amp; More.</a></li>
</ul>
<div>
</div>
<p><a href="http://feeds2.feedburner.com/ajaxian">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-1-3-hits-the-street/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image onLoad Event + JavaScript Issue with Internet&#160;Explorer</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/image-onload-event-javascript-issue-with-internetexplorer/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/image-onload-event-javascript-issue-with-internetexplorer/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 21:00:17 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[css image]]></category>
		<category><![CDATA[cursor pointer]]></category>
		<category><![CDATA[david walsh]]></category>
		<category><![CDATA[error function]]></category>
		<category><![CDATA[Hunch]]></category>
		<category><![CDATA[image filters]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[messagebox]]></category>
		<category><![CDATA[new element]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/image-onload-event-javascript-issue-with-internetexplorer/</guid>
		<description><![CDATA[I was recently coding an application that would inject an image into the page and then execute a given function when the image&#8217;s onLoad event fires. My code was working everywhere except Internet Explorer. That wasn&#8217;t all together shocking initially but the fact that even IE8 was failing to the fire the onLoad event was [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently coding an application that would inject an image into the page and then execute a given function when the image&#8217;s onLoad event fires.  My code was working everywhere <em>except</em> Internet Explorer.  That wasn&#8217;t all together shocking initially but the fact that even IE8 was failing to the fire the onLoad event was discouraging.  Here&#8217;s what my code looked like:</p>
<pre>
var img = new Element('img',{
	alt: this.title ? this.title.get('html') : this.options.url,
	src: this.options.url,
	events: {
		error: function() {
			this.messageBox.set('html',this.options.errorMessage);
			img.dispose();
		}.bind(this),
		load: function() {
			img.setStyle('display','');
			this.unfade();
			if(!this.footer) {
				img.setStyle('cursor','pointer').addEvent('click',this.close.bind(this));
			}
		}.bind(this)
	},
	styles: {
		display: 'none'
	}
}).inject(this.messageBox);
</pre>
<p>On a hunch I detached the &#8220;src&#8221; assignment and coded that as a separate statement:</p>
<pre>
var img = new Element('img',{
	alt: this.title ? this.title.get('html') : this.options.url,
	events: {
		error: function() {
			this.messageBox.set('html',this.options.errorMessage);
			img.dispose();
		}.bind(this),
		load: function() {
			img.setStyle('display','');
			this.unfade();
			if(!this.footer) {
				img.setStyle('cursor','pointer').addEvent('click',this.close.bind(this));
			}
		}.bind(this)
	},
	styles: {
		display: 'none'
	}
});
img.set('src',this.options.url).inject(this.messageBox); //for ie
</pre>
<p>Not too surprisingly that worked.  The reason my modification worked is that image was being pulled from cache as soon as the SRC attribute was set, thus &#8220;beating&#8221; the event assignment to the punch.  Keep this in mind if you run into onLoad issues with your images.</p>
<p><strong>Follow Me!</strong> <a href="http://twitter.com/davidwalshblog">Twitter</a> | <a href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a></p>
<p>Full David Walsh Blog Post: <a href="http://davidwalsh.name/image-load-event">Image onLoad Event + JavaScript Issue with Internet&nbsp;Explorer</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/css-image-filters-internet-explorer" rel="bookmark" title="Permanent Link: CSS Image Filters in Internet Explorer">CSS Image Filters in Internet&nbsp;Explorer</a></li>
<li><a href="http://davidwalsh.name/mootools-onload-smoothscroll" rel="bookmark" title="Permanent Link: MooTools onLoad SmoothScrolling">MooTools onLoad&nbsp;SmoothScrolling</a></li>
<li><a href="http://davidwalsh.name/rounded-corners-ie" rel="bookmark" title="Permanent Link: Rounded Corners in Internet Explorer">Rounded Corners in Internet&nbsp;Explorer</a></li>
<li><a href="http://davidwalsh.name/prevent-internet-explorers-default-image-dragging-action" rel="bookmark" title="Permanent Link: Prevent Internet Explorer’s Default Image Dragging Action">Prevent Internet Explorer&#8217;s Default Image Dragging&nbsp;Action</a></li>
<li><a href="http://davidwalsh.name/internet-explorer-cannot-open-internet-site" rel="bookmark" title="Permanent Link: IE Says “Internet Explorer cannot open the Internet Site ________. Operation Aborted.”  I Say “WTF?”">IE Says &#8220;Internet Explorer cannot open the Internet Site ________. Operation Aborted.&#8221;  I Say&nbsp;&#8220;WTF?&#8221;</a></li>
</ol>
<p><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/3b7b0_c2uzJaXwzcQ" height="1" width="1" /><br />
<a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/image-onload-event-javascript-issue-with-internetexplorer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AJAX Username Availability Checker Using&#160;MooTools</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/ajax-username-availability-checker-usingmootools/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/ajax-username-availability-checker-usingmootools/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 19:45:20 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[amp nbsp]]></category>
		<category><![CDATA[class basis]]></category>
		<category><![CDATA[class implements]]></category>
		<category><![CDATA[element options]]></category>
		<category><![CDATA[element value]]></category>
		<category><![CDATA[img element]]></category>
		<category><![CDATA[input element]]></category>
		<category><![CDATA[input type text]]></category>
		<category><![CDATA[new element]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/ajax-username-availability-checker-usingmootools/</guid>
		<description><![CDATA[Another one of my popular, early blog posts has been AJAX Username Availability Checker Using MooTools 1.2. Looking back now, the code is atrocious and very inflexible. I&#8217;ve taken some time to update the post to be more reliable, clean, and speedy. View Demo The HTML &#60;p&#62;&#60;strong&#62;Please provide your desired username: &#38;nbsp;&#38;nbsp;&#38;nbsp;&#60;/strong&#62; &#60;input type="text" name="username" [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://davidwalsh.name/dw-content/ajax-username-check-updated.php"><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/67eb0_username-checker.jpg" alt="MooTools Username Checker" class="image" /></a>
<p>Another one of my popular, early blog posts has been <a href="http://davidwalsh.name/ajax-username-availability-checker-mootools">AJAX Username Availability Checker Using MooTools 1.2</a>.  Looking back now, the code is atrocious and very inflexible.  I&#8217;ve taken some time to update the post to be more reliable, clean, and speedy.</p>
<div><a href="http://davidwalsh.name/dw-content/ajax-username-check-updated.php">View Demo</a>
<div></div>
</div>
<h2>The HTML</h2>
<pre>
&lt;p&gt;&lt;strong&gt;Please provide your desired username: &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/strong&gt;
	&lt;input type="text" name="username" id="username" size="30" class="basis" /&gt;
&lt;/p&gt;
</pre>
<p>The foundation of the system is the INPUT element with a specific ID.  No other elements are required.  The eventual IMG element will be generated by MooTools.</p>
<h2>The CSS</h2>
<pre>
.basis		{ padding:5px; border:1px solid #ccc; }
.available	{ border:1px solid #008000; background:#90ee90; }
.taken		{ border:1px solid #fc0; background:#fffea1; }
</pre>
<p>You&#8217;ll want to create three CSS classes:  one that is always applied to the input, another class which represents an available username, and one last class to represent a taken username.  Green is always good to use for positive results.  As for how you denote a taken username, please <a href="http://davidwalsh.name/dont-be-a-f00">don&#8217;t be a #f00</a>.</p>
<h2>The MooTools JavaScript</h2>
<pre>
var AvailabilityChecker = new Class({

	//implements
	Implements: [Options,Events],

	//options
	options: {
		trigger: 'keyup',
		offset: { x:0, y:0 },
		minLength: 5,
		availableClass: 'available',
		takenClass: 'taken',
		availableImage: '',
		takenImage: '',
		url: 'ajax-username-check.php'
	},

	//initialization
	initialize: function(element,options) {
		//set options
		this.setOptions(options);
		this.element = document.id(element);
		this.lastValue = this.element.value;
		this.cache = {};
		//create the image which will display to the side
		var pos = this.element.getCoordinates();
		this.image = new Element('img',{
			src: '',
			styles: {
				'z-index': 100000,
				position: 'absolute',
				top: pos.top + this.options.offset.y,
				left: pos.left + pos.width + this.options.offset.x
			}
		}).inject(document.body);
		//workers and removers
		this.comparer = function(response) {
			this.cache[this.element.value] = response;
			var state = (response == '1') ? 'available' : 'taken';
			this.element.addClass(this.options[state + 'Class']);
			this.image.set('src',this.options[state + 'Image']);
			return state;
		};
		this.remover = function() {
			this.element.removeClass(this.options.availableClass).removeClass(this.options.takenClass);
		};
		//create the request which will be frequently used
		this.request = new Request({
			url: this.options.url,
			method: 'get',
			link: 'cancel',
			onRequest: this.remover.bind(this),
			onComplete: this.comparer.bind(this)
		});
		//add listener
		this.element.addEvent(this.options.trigger,function() {
			var value = this.element.value;
			if(value.length &gt;= this.options.minLength &amp;&amp; value != this.lastValue) {
				this.validate(this.lastValue = value);
			}
		}.bind(this));
	},

	//a method that does whatever you want
	validate: function(value) {
		this.fireEvent('check');
		if(this.cache[value] != undefined) {
			return this.comparer(this.cache[value]);
		}
		else {
			return this.request.send('username=' + value + '&amp;ajax=1');
		}
		return this;
	}

});

//USAGE!
window.addEvent('domready', function() {
	var validator = new AvailabilityChecker('username',{
		trigger: 'keyup',
		availableImage: 'checkmark.jpg',
		takenImage: 'warning.jpg',
		offset: { x: 4, y: 4 },
		minLength: 4,
		url: '&lt;?php echo $_SERVER["PHP_SELF"]; ?&gt;'
	});
});
</pre>
<p>The original class featured a host of problems.  No element was required, a new Request was being generated every keystroke, results weren&#8217;t cached.  Ugh.  Those have all been fixed and I&#8217;ve added event functionality to the class.  I&#8217;ve also implemented many new MooTools best practices.</p>
<div><a href="http://davidwalsh.name/dw-content/ajax-username-check-updated.php">View Demo</a>
<div></div>
</div>
<p>I know the class doesn&#8217;t feature many methods and still isn&#8217;t ultimately flexible but the truth is that this type of widget can be very specific.  What this class aims to accomplish to provide you with a basic class you can build from.</p>
<p><strong>Follow Me!</strong> <a href="http://twitter.com/davidwalshblog">Twitter</a> | <a href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a></p>
<p>Full David Walsh Blog Post: <a href="http://davidwalsh.name/ajax-checker-mootools">AJAX Username Availability Checker Using&nbsp;MooTools</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/ajax-username-availability-checker-mootools" rel="bookmark" title="Permanent Link: AJAX Username Availability Checker Using MooTools 1.2">AJAX Username Availability Checker Using MooTools&nbsp;1.2</a></li>
<li><a href="http://davidwalsh.name/ajax-spinner" rel="bookmark" title="Permanent Link: Form Element AJAX Spinner Attachment Using MooTools">Form Element AJAX Spinner Attachment Using&nbsp;MooTools</a></li>
<li><a href="http://davidwalsh.name/cache-ajax" rel="bookmark" title="Permanent Link: Caching AJAX Results in JavaScript">Caching AJAX Results in&nbsp;JavaScript</a></li>
<li><a href="http://davidwalsh.name/ajax-spinner-jquery" rel="bookmark" title="Permanent Link: Form Element AJAX Spinner Attachment Using jQuery">Form Element AJAX Spinner Attachment Using&nbsp;jQuery</a></li>
<li><a href="http://davidwalsh.name/ajax-mootools-fx-explode" rel="bookmark" title="Permanent Link: AJAX Page Loads Using MooTools Fx.Explode">AJAX Page Loads Using MooTools&nbsp;Fx.Explode</a></li>
</ol>
<p><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/67eb0_7KOiHgXIRM8" height="1" width="1" /><br />
<a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/ajax-username-availability-checker-usingmootools/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Create a Drop-down Nav Menu with HTML5, CSS3 and jQuery</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/how-to-create-a-drop-down-nav-menu-with-html5-css3-and-jquery/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/how-to-create-a-drop-down-nav-menu-with-html5-css3-and-jquery/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 15:32:29 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[doctype html]]></category>
		<category><![CDATA[drop down navigation menu]]></category>
		<category><![CDATA[html lang]]></category>
		<category><![CDATA[link rel stylesheet]]></category>
		<category><![CDATA[meta charset]]></category>
		<category><![CDATA[navigation menus]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[new folders]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/how-to-create-a-drop-down-nav-menu-with-html5-css3-and-jquery/</guid>
		<description><![CDATA[In this tutorial, we’ll take a look and see what we can achieve with HTML5 and CSS3 when it comes to the staple of current web sites: the humble drop-down navigation menu. We’ll also use jQuery to handle the effects and add the finishing touches for us. HTML5 brings to the spec a dedicated &#60;nav&#62; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://feedads.g.doubleclick.net/~a/jOAGwMqhc9XtD7GEB7KkCQsrvjs/0/da"><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/d1bfd_di" border="0"></img></a><br />
<a href="http://feedads.g.doubleclick.net/~a/jOAGwMqhc9XtD7GEB7KkCQsrvjs/1/da"><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/d1bfd_di" border="0"></img></a></p>
<p>In this tutorial, we’ll take a look and see what we can achieve with HTML5 and CSS3 when it comes to the staple of current web sites: the humble drop-down navigation menu. We’ll also use jQuery to handle the effects and add the finishing touches for us.</p>
<p><span></span></p>
<p>HTML5 brings to the spec a dedicated <strong>&lt;nav&gt;</strong> element that should be used as the container for any major navigation structure, such as the main vertical or horizontal site navigation menus, or an in-page table of contents for example. IE unfortunately doesn’t support this new element yet, but there is a simple fix we can use, of which I’m sure you’re all aware.</p>
<p>Using CSS3 we can do away with what would have required the use of several background images and possibly an additional wrapping container or two and rely (almost) purely on some of the new style properties, such as rounded corners and drop-shadows for example, that are available to supporting browsers. Again, not all browsers (cough, IE!) support these new rules, but we can very easily provide fall-back solutions for the browsers that can’t handle our styles.</p>
<hr />
<h2><span>Step 1. </span>Getting Started</h2>
<p>We’ll need a copy of the latest release of <a href="http://jquery.com/" title="jQuery">jQuery</a>, version 1.4.2 at the time of writing, as well as a copy of the current version (1.1) of the excellent <a href="http://modernizr.com/" title="Modernizr">Modernizr</a> library, which we’ll use to target supporting browsers with the CSS3 we use.</p>
<p>Create a project folder for the files we’ll create somewhere on your machine and call it <strong>nav</strong>, inside this folder create three new folders; one called <strong>js</strong>, one called <strong>css</strong> and one called <strong>fallback</strong>. Make sure copies of both jQuery and Modernizr are saved in the <strong>js</strong> folder.</p>
<hr />
<h2><span>Step 2. </span>The Underlying Page</h2>
<p>Begin the coding by creating the following page in your favourite code editor:</p>
<pre>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
	&lt;head&gt;
		&lt;meta charset="utf-8"&gt;
		&lt;title&gt;HTML5, CSS3 and jQuery Navigation menu&lt;/title&gt;
		&lt;link rel="stylesheet" href="css/nav.css"&gt;
		&lt;!--[if IE]&gt;
			&lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
		&lt;![endif]--&gt;
	&lt;/head&gt;
	&lt;body class="no-js"&gt;
		&lt;nav id="topNav"&gt;
	        	&lt;ul&gt;
       		     	&lt;li&gt;&lt;a href="#" title="Nav Link 1"&gt;Nav Link 1&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;
                	&lt;a href="#" title="Nav Link 1"&gt;Nav Link 2</a>
					&lt;ul&gt;
                    	&lt;li&gt;&lt;a href="#" title="Sub Nav Link 1"&gt;Sub Nav Link 1&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#" title="Sub Nav Link 2"&gt;Sub Nav Link 2&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#" title="Sub Nav Link 3"&gt;Sub Nav Link 3&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#" title="Sub Nav Link 4"&gt;Sub Nav Link 4&lt;/a&gt;&lt;/li&gt;
						&lt;li class="last"&gt;&lt;a href="#" title="Sub Nav Link 5"&gt;Sub Nav Link 5&lt;/a&gt;&lt;/li&gt;
                    &lt;/ul&gt;
				&lt;/li&gt;
				&lt;li&gt;&lt;a href="#" title="Nav Link 1"&gt;Nav Link 3&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="#" title="Nav Link 1"&gt;Nav Link 4&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="#" title="Nav Link 1"&gt;Nav Link 5&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/nav&gt;
		&lt;script src="js/jquery.js"&gt;&lt;/script&gt;
		&lt;script src="js/modernizr.js"&gt;&lt;/script&gt;
	&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Save this as <strong>nav.html</strong> in the <strong>nav</strong> folder. We start out with the minimal HTML5 doctype, which allows us to specify the type of document in a quarter of the code we used to use. We also specify the default language and the character encoding; although the document will still validate without these two things, it’s good practice to include them and the page will trigger validator warnings if the default language isn’t specified. We then link to a style sheet (we’ll create this next) and use a conditional comment that targets IE to load Remy Sharp’s excellent <strong>html5.js</strong> script if required.</p>
<p>In the body of the page we have the <strong>&lt;nav&gt;</strong> element as the container for a traditional list of links, and we’ve thrown in a sub-menu for good measure too. The element doesn’t magically create a navigation menu for us, and it doesn’t include any new menuitem elements or anything like that so an unordered list is still an appropriate choice. The <strong>&lt;nav&gt;</strong> element is just a semantic container for our menu, which describes its function within the document, to replace the generic <strong>&#38;div&gt;</strong> element which states nothing inherently about its purpose on the page.</p>
<p>At the end of the body we link to our script files jQuery and Modernizr. We’ll use jQuery a little later on when we come to add the behaviour for the menu, but Modernizr will do its thing straight away, detecting the capabilities of the browser in use and adding a series of class names to the HTML element, which we can use to add our CSS3 so that it is only applied to browsers that can make use of them. We’ve also added the class name <strong>no-j</strong>s to the <strong>&lt;body&gt;</strong> of the page; we’ll remove it later if JavaScript is enabled so we can also use it to add styles that should only be applied when JavaScript is disabled.</p>
<hr />
<h2><span>Step 3. </span>Some Basic Styling</h2>
<p>Now let’s add some basic styling; create the following style-sheet:</p>
<pre>/* JS disabled styles */
.no-js nav li:hover ul { display:block; }

/* base nav styles */
nav { display:block; margin:0 auto 20px; border:1px solid #222; position:relative; background-color:#6a6a6a; font:16px Tahoma, Sans-serif; }
nav ul { padding:0; margin:0; }
nav li { position:relative; float:left; list-style-type:none; }
nav ul:after { content:"."; display:block; height:0; clear:both; visibility:hidden; }
nav li a { display:block; padding:10px 20px; border-left:1px solid #999; border-right:1px solid #222; color:#eee; text-decoration:none; }
nav li a:focus { outline:none; text-decoration:underline; }
nav li:first-child a { border-left:none; }
nav li.last a { border-right:none; }
nav a span { display:block; float:right; margin-left:5px; }
nav ul ul { display:none; width:100%; position:absolute; left:0; background:#6a6a6a; }
nav ul ul li { float:none; }
nav ul ul a { padding:5px 10px; border-left:none; border-right:none; font-size:14px; }
nav ul ul a:hover { background-color:#555; }
Save this file in the css directory as nav.css. The first rule is purely for when JavaScript is disabled, and allows the hidden submenu to be displayed on hover purely with CSS. The rest of the code defines a set of base styles that format the &lt;nav&gt; menu in the way that we want without adding anything too decorative. Note that we’re using the :after pseudo-selector to clear the floated list items; normally this would be added using a class name to that it could be applied to the containers of any floated elements on the page. At this point our page should look like this:</pre>
<div>
 <img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/1f841_img1.jpg" />
</div>
<hr />
<h2><span>Step 4. </span>CSS3</h2>
<p>Next we can add our CSS3:</p>
<pre>/* CSS3 */
.borderradius nav { -moz-border-radius:4px; -webkit-border-radius:4px; border-radius:4px; }
.cssgradients nav { background-image:-moz-linear-gradient(0% 22px 90deg, #222, #999); background-image:-webkit-gradient(linear, 0% 0%, 0% 70%, from(#999), to(#222)); }
.boxshadow.rgba nav { -moz-box-shadow:2px 2px 2px rgba(0,0,0,.75); -webkit-box-shadow:2px 2px 2px rgba(0,0,0,.75); box-shadow:2px 2px 2px rgba(0,0,0,.75); }
.cssgradients nav li:hover { background-image:-moz-linear-gradient(0% 100px 90deg, #999, #222); background-image:-webkit-gradient(linear, 0% 0%, 0% 100%, from(#222), to(#555)); }
.borderradius nav ul ul { -moz-border-radius-bottomleft:4px; -moz-border-radius-bottomright:4px; -webkit-border-bottom-left-radius:4px; -webkit-border-bottom-right-radius:4px; border-bottom-left-radius:4px; border-bottom-right-radius:4px; }
.boxshadow.rgba nav ul ul { background-color:rgba(0,0,0,0.8); -moz-box-shadow:2px 2px 2px rgba(0,0,0,.8); -webkit-box-shadow:2px 2px 2px rgba(0,0,0,.8); box-shadow:2px 2px 2px rgba(0,0,0,.8); }
.rgba nav ul ul li { border-left:1px solid rgba(0,0,0,0.1); border-right:1px solid rgba(0,0,0,0.1); }
.rgba nav ul ul a:hover { background-color:rgba(85,85,85,.9); }
.borderradius.rgba nav ul ul li.last { border-left:1px solid rgba(0,0,0,0.1); border-bottom:1px solid rgba(0,0,0,0.1); -moz-border-radius-bottomleft:4px; -moz-border-radius-bottomright:4px; -webkit-border-bottom-left-radius:4px; -webkit-border-bottom-right-radius:4px; border-bottom-left-radius:4px; border-bottom-right-radius:4px; }
.csstransforms ul a span { -moz-transform:rotate(-180deg);-webkit-transform:rotate(-180deg); }</pre>
<p>Using the classes added to the <strong>&lt;html&gt;</strong> element by Modernizr we can easily and safely add the CSS3 styles that we want. We use the <strong>border-radius</strong> style to give the <strong>&lt;nav&gt;</strong> element rounded corners; We need to give Mozilla and Webkit prefixed style declarations as well as the standard <strong>border-radius</strong> styles for browsers that support them, such as Opera. We need to do this with most of our CSS3 styles.</p>
<p>As well as corner-rounding of the <strong>&lt;nav&gt;</strong> we also give it a gradient and a drop shadow. The gradient styles are fairly complex and are different for Mozilla and Webkit based browsers, which are the only browsers currently implementing them. Both browsers use the <strong>background-image</strong> property. In Firefox we use <strong>-moz-linear-gradient</strong> to add a linear gradient. It requires values which correspond to the starting point of the gradient (0%), the point at which the first color blends into the second color (22px), the angle of the gradient axis (90deg), the first color (#999) and the second color (#222).</p>
<p>We can get the same gradient in Safari or Chrome using <strong>-webkit-gradient</strong> and the syntax is subtly different; we specify that it should be a <strong>linear</strong> gradient and then provide two points which tell the browser where the gradient should start and end. The values in the example correspond to left, top and right values of 0% and 70% for the bottom, which gives us the same style as that used in Firefox. Lastly we specify the colors of the gradient.</p>
<p>When we apply the drop-shadow we combine it with the Modernizr class for RGBA as well as boxshadow so that our shadow can be transparent. The properties for Mozilla and webkit are the same, and we also supply the actual <strong>box-shadow</strong> property for supporting browsers. The values we specify for this rule are the left offset (2px), the top offset (2px), the amount of blurring (2px) and lastly the color of the shadow (0,0,0). The color is where we use RGBA, which allows us to set the opacity to 75% (.75).</p>
<p>Another interesting style we use is <strong>transform</strong> to rotate some text 180 degrees; when we write the script in a moment, you’ll see that we add a sub menu indicator in the form of a caret sign to any list items that contain a submenu – this style will rotate the character to that it is pointing down, which means that in supporting browsers we don’t even need to use an image for this feature.</p>
<p>The remaining rules set different gradients, rounded edges, opacity with RGBA and drop shadows on other elements in the <strong>&lt;nav&gt;</strong> menu, such as nice bottom rounded corners and a drop shadow on the submenu, as well inverting the gradient for an attractive hover state. Now our navigation menu should look like this in a supporting browser:</p>
<div><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/cab3b_img2.jpg" /></div>
<p>In supporting browsers we can make our elements look pretty hot without using a single image, which means our pages will load much quicker with far fewer HTTP requests. However, not all browsers will support the CSS3 styling, notably any version of IE, so we still need to define our fallback styles. Add the following code to the style sheet:</p>
<pre>/* fallbacks */
.no-cssgradients nav, .no-js nav { padding-bottom:4px; border:none; background:url(../fallback/navBG.gif) repeat-x 0 0; }
.no-borderradius nav ul, .no-js nav ul { background:url(../fallback/navRight.gif) no-repeat 100% 0; }
.no-borderradius nav ul ul, .no-js nav ul ul { background:none; }
.no-borderradius nav li, .no-js nav li { height:44px; }
.no-cssgradients nav li:hover, .no-js nav li:hover { background:url(../fallback/navOverBG.gif) repeat-x 0 0; }
.no-borderradius nav li li, .no-js nav li li { height:auto; width:98%; left:-2px; }
.no-borderradius nav li:first-child, .no-js nav li:first-child { background:url(../fallback/navLeft.gif) no-repeat 0 0; }
.no-borderradius nav li:first-child:hover, .no-js nav li:first-child:hover { background:url(../fallback/navOverLeft.gif) no-repeat 0 0; }
.no-borderradius nav li li:first-child, .no-js nav li li:first-child { background:none; }
.no-rgba nav ul ul, .no-js nav ul ul { left:1px; padding-left:2px; background:url(../fallback/subnavBG.png) no-repeat 100% 100%; }
.no-rgba nav ul ul a, .no-js nav ul ul a { left:3px; }
.no-rgba nav ul ul a:hover { background:url(../fallback/subOverBG.png) repeat 0 0; }
.no-csstransforms ul a span { height:7px; width:12px; margin-top:8px; text-indent:-5000px; overflow:hidden; background:url(../fallback/indicator.png) no-repeat 0 0; }
.no-borderradius ul ul li.last { margin-bottom:10px; }
.no-cssgradients.boxshadow nav { box-shadow:none; }</pre>
<p>Modernizr will also add class names showing which CSS3 features are not available to the browser, so we can easily supply alternative rules, which make use of image-based fallbacks where features are not supported as well as any styles we may need as a result of using the images.</p>
<p>You’ll notice that we also use selectors that target our <strong>no-js</strong> class here too; this is because when JavaScript is disabled, Modernizr will not run and will not add the class names we need to the document, so our non-CSS3 fallbacks also become our non-js fallbacks as well.</p>
<hr />
<h2><span>Step 5. </span>Adding the Script</h2>
<p>Now let’s add some script. The first thing we need to do is remove the <strong>no-js</strong> class from the body of the page when JavaScript is not disabled. We want to do this as soon in the page rendering process as possible to avoid a flicker when the styles are changed. Directly after the opening body tag add the following code:</p>
<pre>&lt;script&gt;
	var el = document.getElementsByTagName("body")[0];
	el.className = "";
&lt;/script&gt;</pre>
<p>All we do is get the <strong>&lt;body&gt;</strong> element by tag name and set its className property to an empty string. Normally we would use jQuery to do that for us, but because jQuery won’t have loaded when this script is executed we can’t use it. We could load jQuery before this of course, but we’d then take a massive performance hit. Our script is only 2 lines of code so it won’t cause a significant delay, and because it will be executed before the browser has even processed the mark-up for the <strong>&lt;nav&gt;</strong> element, there will be no flash of unstyled content.</p>
<p>Now that the class has been removed from the body our CSS submenus will no longer work so we can add this behaviour back in with jQuery and enhance it a little at the same time. At the end of the document, directly after the script reference for Modernizr add the following code:</p>
<pre>&lt;script&gt;
	(function($){

		//cache nav
		var nav = $("#topNav");

		//add indicators and hovers to submenu parents
		nav.find("li").each(function() {
			if ($(this).find("ul").length &gt; 0) {

				$("&lt;span&gt;").text("^").appendTo($(this).children(":first"));

				//show subnav on hover
				$(this).mouseenter(function() {
					$(this).find("ul").stop(true, true).slideDown();
				});

				//hide submenus on exit
				$(this).mouseleave(function() {
					$(this).find("ul").stop(true, true).slideUp();
				});
			}
		});
	})(jQuery);
&lt;/script&gt;</pre>
<p>The script is relatively straight-forward; we wrap our code within a closure and pass in the jQuery object safely name-spaced to the dollar sign, just in case another library is in use when the code is put into production. We then cache a reference to the <strong>&lt;nav&gt;</strong> element so that we can refer to it without selecting it from the document repeatedly. We then process each list item within the menu.</p>
<p>For each matching element we check it to see if it contains any nested <strong>&lt;ul&gt;</strong> elements and if it does we add a new <strong>&lt;span&gt;</strong> element to the list item. This will become our submenu indicator. When a submenu is found we also attach <strong>mouseenter()</strong> and <strong>mouseleave()</strong> event helpers to the list item that contains the menu. All these helpers do is show and hide the submenu by sliding it down or up respectively. Note the use of the <strong>stop()</strong> method which helps to prevent the opening and closing animations queuing up if the mouse pointer is repeatedly moved onto and off of the target list items.</p>
<p>At this point we should be in quite a nice place with regard to most situations; in any browser that supports HTML5 our menu should look relatively similar regardless of whether CSS3 is supported or not, and whether scripting is enabled or not. However, IE presents us with a problem; when JS is enabled, the <strong>htmlshiv.js</strong> script makes IE understand the <strong>&lt;nav&gt;</strong> element and our non-css3 styles are picked up and implemented – all very well and good (we still have some issues with IE7, as among other things our auto-clearing <strong>:after</strong> rules are not understood or applied, but we’ll come to the in a little while).</p>
<p>However, the problems start when IE is used with scripting disabled – in this situation, the <strong>html5shiv.js</strong> script is not executed and IE doesn’t understand the <strong>&lt;nav&gt;</strong> element. None of our selectors that include nav in them will be implemented! It’s not the end of the world though; we can provide an alternative style sheet that is only used when the browser has JS disabled and is IE. Directly after the script that removes the <strong>no-js</strong> class from the <strong>&lt;body&gt;</strong> element add the following:</p>
<pre>&lt;noscript&gt;
&lt;!--[if IE]&gt;
	&lt;link rel="stylesheet" href="css/ie.css"&gt;
&lt;![endif]--&gt;
&lt;/noscript&gt;</pre>
<p>A simple solution indeed. We now need to create the new styles sheet; add the following rules to a new document in your code editor:</p>
<pre>/* ie styles for when js disabled */
ul { display:block; padding:0; margin:0; background:url(../fallback/navRightIE.gif) no-repeat 100% 0; font:16px Tahoma, Sans-serif; }
ul:after { content:"."; display:block; height:0; clear:both; visibility:hidden; }
li { height:44px; position:relative; float:left; list-style-type:none; background:url(../fallback/navBG.gif) repeat-x 0 0; }
li.last a { border-right:none; }
li:hover { background:url(../fallback/navOverBG.gif) repeat-x 0 0; }
li:first-child { background:url(../fallback/navLeftIE.gif) no-repeat 0 0; }
li:first-child a { border-left:none; }
li:first-child:hover { background:url(../fallback/navOverLeft.gif) no-repeat 0 0; }
li a { display:block; padding:10px 20px; border-left:1px solid #999; border-right:1px solid #222; color:#eee; text-decoration:none; }
li li { width:auto; clear:left; }
li li:first-child { background:none; }
li li:hover { background-image:none; }
ul li li a:hover { border-right:none; }
ul ul { display:none; padding-left:2px; position:absolute; left:2px; background:url(../fallback/subnavBG.png) no-repeat 100% 100%; }
ul li:hover ul { display:block; }
li li { height:auto; width:98%; left:-2px; }
ul ul a:hover { background:url(../fallback/subOverBG.png) repeat 0 0; }
ul a span { height:7px; width:12px; margin-top:8px; text-indent:-5000px; overflow:hidden; background:url(../fallback/indicator.png) no-repeat 0 0; }
ul ul li { background:none; }
ul ul li.last { margin-bottom:10px; }
ul ul li a { padding:5px 10px; border-left:0; left:3px; font-size:14px; white-space:pre; }</pre>
<p>Save this in the css folder as <strong>ie.css</strong>.  As you can see, we aren’t targeting the <strong>&lt;nav</strong> element at all in this style sheet; some of the styles we gave to the <strong>&lt;nav&gt;</strong> element earlier have been added to the <strong>&lt;ul&gt;</strong> element instead, and there are a few new styles that need to be included specifically for this scenario. Essentially though, the style sheet creates the same effect as before, so IE8 with JS disabled should still appear like this:</p>
<div><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/c70bc_img3.jpg" /> </div>
<p>We’ve had to make use of a couple more images for this scenario because we no longer have the <strong>&lt;nav</strong> element to hang the background-repeat on for the main gradient. So that’s all modern browsers, with JS enabled and disabled, working as expected – using CS3 where possible and image fallbacks where not.</p>
<p>IE7 will still create problems for us, even with scripting enabled, but we can fix that easily enough using another conditional comment to target IE7 specifically, and supplying a new style sheet just for IE7 which fixes the layout problems; something like this is all we need:</p>
<pre>* styles to fix IE7 */
ul { display:inline-block; }
ul li a span { position:absolute; right:5px; top:10px; }
ul ul li a { border-right:none; padding:5px 10px; }
.content { clear:both; }</pre>
<p>Save this in the <strong>css</strong> folder as <strong>ie7.css</strong> and add a new conditional comment to the <strong>&lt;head</strong> of the page:</p>
<pre>&lt;!--[if IE 7]&gt;
	&lt;link rel="stylesheet" href="css/ie.css"&gt;
 	&lt;link rel="stylesheet" href="css/ie7.css"&gt;
&lt;![endif]--&gt;</pre>
<p>There we go; a navigation menu built and styled with the latest elements and styles with fallbacks and fixes for older browsers.</p>
<div>
<a href="http://feeds.feedburner.com/~ff/nettuts?a=wkSdti17MA0:YMloaidxgNQ:yIl2AUoC8zA"><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/c70bc_nettuts?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=wkSdti17MA0:YMloaidxgNQ:F7zBnMyn0Lo"><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/c70bc_nettuts?i=wkSdti17MA0:YMloaidxgNQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=wkSdti17MA0:YMloaidxgNQ:V_sGLiPBpWU"><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/e193d_nettuts?i=wkSdti17MA0:YMloaidxgNQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=wkSdti17MA0:YMloaidxgNQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/nettuts?i=wkSdti17MA0:YMloaidxgNQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=wkSdti17MA0:YMloaidxgNQ:TzevzKxY174"><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/c800a_nettuts?d=TzevzKxY174" border="0"></img></a>
</div>
<p><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/e7f9d_wkSdti17MA0" height="1" width="1" /><br />
<a href="http://feedproxy.google.com/nettuts">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/how-to-create-a-drop-down-nav-menu-with-html5-css3-and-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Create Elements on the Fly with MooTools 1.3 and&#160;Slick</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-elements-on-the-fly-with-mootools-1-3-andslick/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-elements-on-the-fly-with-mootools-1-3-andslick/#comments</comments>
		<pubDate>Mon, 10 May 2010 15:00:15 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[attribute selectors]]></category>
		<category><![CDATA[class myclass]]></category>
		<category><![CDATA[david walsh]]></category>
		<category><![CDATA[div element]]></category>
		<category><![CDATA[element creation]]></category>
		<category><![CDATA[fabio costa]]></category>
		<category><![CDATA[independent project]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[text element]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-elements-on-the-fly-with-mootools-1-3-andslick/</guid>
		<description><![CDATA[As we were so excited to announce last week, MooTools 1.3 beta has been released. MooTools 1.3 marks the introduction of Slick, an ultra flexible, ultra powerful selector engine created by Thomas Aylott, Fabio Costa, and Valerio Proietti. As the release blog post cited: Slick is an independent project; it may be implemented in any [...]]]></description>
			<content:encoded><![CDATA[<p>As we were so excited to announce last week, <a href="http://mootools.net/blog/2010/04/27/mootools-1-3-beta-1/" rel="nofollow">MooTools 1.3 beta has been released</a>.  MooTools 1.3 marks the introduction of <a href="http://github.com/mootools/slick" rel="nofollow">Slick</a>, an ultra flexible, ultra powerful selector engine created by <a href="http://subtlegradient.com/" rel="nofollow">Thomas Aylott</a>, <a href="http://www.meiocodigo.com/" rel="nofollow">Fabio Costa</a>, and <a href="http://mad4milk.net/" rel="nofollow">Valerio Proietti</a>.  As the release blog post cited:</p>
<ul>
<li>Slick is an independent project;  it may be implemented in any framework that is flexible enough to allow it.</li>
<li>Slick is much, much faster than the MooTools 1.2 selector engine.</li>
<li>Supports just about every selector you can think of.</li>
<li>Slick has a detached parser. You can parse a CSS-style-selector string and get back a property-filled object.</li>
<li>Supports XML documents.</li>
<li>Slick is so customizable that you can create your own Pseudo Selectors and Attribute Selectors.</li>
</ul>
<p>And if that&#8217;s not enough, MooTools 1.3 has flawlessly incorporated Slick to allow you to create new elements on the fly.  Check this out!</p>
<h2>MooTools &amp; Slick Shorthand Element Creation</h2>
<pre>
var div = new Element('div');
//creates &lt;div /&gt;
</pre>
<p>The above snippet creates a DIV element.  Too simple, lets get a bit trickier.</p>
<pre>
var div = new Element('div.myClass');
//creates &lt;div class="myClass" /&gt;
</pre>
<p>The above snippet creates a DIV element with a myClass CSS class.  Still too simple.</p>
<pre>
var div = new Element('div#myId.myClass.myOtherClass[title=My Title][text=Element Inner Text]');
//creates &lt;div class="myClass myOtherClass" title="My Title"&gt;Element Inner Text&lt;/div&gt;
</pre>
<p>The above snippet creates a DIV element with an ID, CSS classes, a title attribute, and the text &#8220;My Text.&#8221;  I mean that&#8217;s just stupid <span>cool</span> slick, right?</p>
<p>Slick is just one great enhancement within MooTools 1.3.  Even if you don&#8217;t use MooTools, you can still use Slick within your framework or project.  Be sure to download Slick for your own work.  Oh&#8230;an that small MooTools 1.3 thing too&#8230;.</p>
<p><strong>Follow Me!</strong> <a href="http://twitter.com/davidwalshblog">Twitter</a> | <a href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a></p>
<p>Full David Walsh Blog Post: <a href="http://davidwalsh.name/elements-shorthand-slick">Create Elements on the Fly with MooTools 1.3 and&nbsp;Slick</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/mootools-sizzle" rel="bookmark" title="Permanent Link: Implementing the Sizzle Selector Engine in MooTools">Implementing the Sizzle Selector Engine in&nbsp;MooTools</a></li>
<li><a href="http://davidwalsh.name/create-custom-pseudo-selector-mootools-selected" rel="bookmark" title="Permanent Link: Create a Custom “:selected” Pseudo Selector in MooTools">Create a Custom &#8220;:selected&#8221; Pseudo Selector in&nbsp;MooTools</a></li>
<li><a href="http://davidwalsh.name/simple-mootools-accordion" rel="bookmark" title="Permanent Link: Build a Slick and Simple MooTools Accordion">Build a Slick and Simple MooTools&nbsp;Accordion</a></li>
<li><a href="http://davidwalsh.name/jquery-css-attr-mootools" rel="bookmark" title="Permanent Link: Implementing .css() and .attr() in MooTools 1.2.3">Implementing .css() and .attr() in MooTools&nbsp;1.2.3</a></li>
<li><a href="http://davidwalsh.name/peppy-mootools" rel="bookmark" title="Permanent Link: Peppy and MooTools">Peppy and&nbsp;MooTools</a></li>
</ol>
<p><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/d53ba_xwr2f9T_v6o" height="1" width="1" /><br />
<a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-elements-on-the-fly-with-mootools-1-3-andslick/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The new  element has been added to the HTML5 spec</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/the-new-element-has-been-added-to-the-html5-spec/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/the-new-element-has-been-added-to-the-html5-spec/#comments</comments>
		<pubDate>Wed, 05 May 2010 14:00:20 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[audio synthesis]]></category>
		<category><![CDATA[john dyer]]></category>
		<category><![CDATA[media elements]]></category>
		<category><![CDATA[media resource]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[resource metadata]]></category>
		<category><![CDATA[textual descriptions]]></category>
		<category><![CDATA[video component]]></category>
		<category><![CDATA[visual component]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/the-new-element-has-been-added-to-the-html5-spec/</guid>
		<description><![CDATA[It is always fun to get a new tweet from Mr. WHATWG and these came through recently: HTML5: Captions &#8211; Stage 1: the &#60;track&#62; element. HTML5: Captions &#8211; Stage 2: the IDL additions. HTML5: Captions &#8211; Stage 3: defining what a timed track and a timed track cue are. John Dyer noticed the new &#60;track&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>It is always fun to get a new tweet from <a href="http://twitter.com/whatwg">Mr. WHATWG</a> and these came through recently:</p>
<blockquote><p>
HTML5: Captions &#8211; Stage 1: <a href="http://html5.org/tools/web-apps-tracker?from=5066&amp;to=5067">the &lt;track&gt; element</a>.</p>
<p>HTML5: Captions &#8211; Stage 2: <a href="http://html5.org/tools/web-apps-tracker?from=5070&amp;to=5071">the IDL additions</a>.</p>
<p>HTML5: Captions &#8211; Stage 3: <a href="http://html5.org/tools/web-apps-tracker?from=5071&amp;to=5072">defining what a timed track and a timed track cue are</a>.
</p>
</blockquote>
<p>John Dyer noticed the new &lt;track&gt; element too, and noted how useful they would be for his <a href="https://my.dts.edu/player-html5">multi-lingual HTML5 video player for a school&#8217;s online education program</a>.</p>
<p><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/c25e5_image.axd?picture=2010%2F4%2Fhtml5player-landscape.jpg" /></p>
<p>Here is what the spec has to say about the new element:</p>
<blockquote><p>
The track element allows authors to specify explicit external timed tracks for media elements. It does not represent anything on its own.</p>
<p>The kind attribute is an enumerated attribute. The following table lists the keywords defined for this attribute. The states given in the first cell of the rows with keywords give the states to which those keywords map.</p>
<ul>
<li>subtitles: Translation of the dialogue, suitable for when the sound is available but not understood (e.g. because the user does not understand the language of the media resource&#8217;s soundtrack).
</li>
<li>captions: Transcription of the dialogue, suitable for when the soundtrack is unavailable (e.g. because it is muted or because the user is deaf).
</li>
<li>descriptions: Textual descriptions of the video component of the media resource, intended for audio synthesis when the visual component is unavailable (e.g. because the user is interacting with the application without a screen while driving, or because the user is blind).
</li>
<li>chapters: Chapter titles, intended to be used for navigating the media resource.
</li>
<li>metadata: Tracks intended for use from script.
</li>
</ul>
</blockquote>
<div>
</div>
<p><a href="http://feeds2.feedburner.com/ajaxian">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/the-new-element-has-been-added-to-the-html5-spec/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MooTools 1.3b1: A “Slick” release</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-1-3b1-a-%e2%80%9cslick%e2%80%9d-release/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-1-3b1-a-%e2%80%9cslick%e2%80%9d-release/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 23:16:36 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[APIs]]></category>
		<category><![CDATA[attribute selectors]]></category>
		<category><![CDATA[css style]]></category>
		<category><![CDATA[fabio costa]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[release cycles]]></category>
		<category><![CDATA[style selector]]></category>
		<category><![CDATA[text javascript]]></category>
		<category><![CDATA[xml documents]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-1-3b1-a-%e2%80%9cslick%e2%80%9d-release/</guid>
		<description><![CDATA[The first beta of MooTools 1.3 has become available. The biggest feature is their new CSS selector engine. They aren&#8217;t using Sizzle like some of the other boys, but instead have become Slick: Slick is our new, shiny, super fast, exhaustively tested, pure-javascript selector engine. There will probably be a dedicated Slick post in the [...]]]></description>
			<content:encoded><![CDATA[<p>The first beta of <a href="http://mootools.net/blog/2010/04/27/mootools-1-3-beta-1/">MooTools 1.3</a> has become available. The biggest feature is their new CSS selector engine. They aren&#8217;t using Sizzle like some of the other boys, but instead have become Slick:</p>
<blockquote><p>
Slick is our new, shiny, super fast, exhaustively tested, pure-javascript selector engine. There will probably be a dedicated Slick post in the following days (or months, given our relaxed release cycles), but here’s a few Slick-facts for those who haven’t checked it out already:</p>
<ul>
<li><em>Slick</em> is a MooTools-family project by MooTools developers <a href="http://subtlegradient.com/">Thomas Aylott</a>, <a href="http://www.meiocodigo.com/">Fabio Costa</a> and <a href="http://mad4milk.net">yours truly</a>. It can be <a href="http://github.com/mootools/slick">forked from github</a>, free of charge!</li>
<li><em>Slick</em> is an incredibly advanced evolution of our previous selector engine.</li>
<li><em>Slick</em> is written using only pure-javascript, none of the MooTools apis are required. It can be used in any project or framework, and it does not require MooTools to function (though the MooTools DOM components do require <em>Slick</em>).</li>
<li><em>Slick</em> is speedy, blows away the 1.2 selector engine by 50%, at least. We will give you detailed data in the post dedicated to <em>Slick</em>.</li>
<li><em>Slick</em> supports every selector you can think of. Seriously, every one of them. I promise you.</li>
<li><em>Slick</em> is customizable, you can make your own pseudo-selectors, your own attribute-selectors, and many more your-own kinds of things.</li>
<li><em>Slick</em> supports reversed combinators. You might not know what they are, but they are pretty darn cool.</li>
<li><em>Slick</em> has a <a href="http://github.com/mootools/slick/blob/master/Slick.Parser.js">detached parser</a>. You can parse a css-style-selector string and get back a property-filled object.</li>
<li><em>Slick</em> perfectly supports XML documents.</li>
<li><em>Slick</em> is slick!</li>
</ul>
</blockquote>
<p>This bleeds into some new APIs too.</p>
<p>For example, what you may have done like this:</p>
<div><a href="showCodeTxt('javascript-3');">PLAIN TEXT</a></div>
<div><span>JAVASCRIPT:</span></p>
<div>
<div>
<ol>
<li>
<div>&nbsp;</div>
</li>
<li>
<div><span>new</span> Element<span>&#40;</span><span>&#8220;input&#8221;</span>, <span>&#123;</span><span>&#8220;id&#8221;</span>: <span>&#8220;someID&#8221;</span>, <span>&#8220;class&#8221;</span>: <span>&#8220;someClass1 someClass2&#8243;</span>, <span>&#8220;disabled&#8221;</span>: <span>true</span><span>&#125;</span><span>&#41;</span>;</div>
</li>
<li>
<div>&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>you can now do using selectors:</p>
<div><a href="showCodeTxt('javascript-4');">PLAIN TEXT</a></div>
<div><span>JAVASCRIPT:</span></p>
<div>
<div>
<ol>
<li>
<div>&nbsp;</div>
</li>
<li>
<div><span>new</span> Element<span>&#40;</span><span>&#8220;input#someID.someClass1.someClass2[disabled=true]&#8220;</span><span>&#41;</span>;</div>
</li>
<li>
<div>&nbsp;</div>
</li>
</ol>
</div>
</div>
</div>
<p>There are other features too:</p>
<blockquote><p>
<b>Globals</b></p>
<p>MooTools 1.3 moves away from the $name functions. Most of the useless ones, such as $chk (god knows why I thought it was a good idea to have $chk), were completely nixed. Some of them moved to the proper object’s namespace ($merge » Object.merge, $pick » Array.prototype.pick). Some others were renamed without the stupid $ in front ($type » typeOf, $defined » nil). In the end, there are a lot less global variables now. You can refer to the 1.3 documentation to have a proper list of what’s changed. Keep in mind that the old version of the methods will still work, by default. There will be a way in the future to “compile” MooTools without the compatibility stuff, but the feature is not ready yet.</p>
<p><b>From types with love</b></p>
<p>Every native type has now a from method that will try to convert every object passed to that type. Array.from, for instance, replaces both $A and $splat. Function.from will return a function that returns the passed in value, if it wasn’t a function itself. String.from… well you know that at this point, don’t you? We also changed how we internally handle Native types, but that should be none of your concerns, since they were handled with private apis anyways.</p>
<p><b>Generating your own MooTools, from your own computer</b></p>
<p>It is now possible, easy, and even perhaps recommended to generate MooTools (and its plugins) yourself. Last few months I’ve been working, on and off, on a pretty advanced projects-builder. It’s called Packager, it supports multiple project dependancies and has a very similar syntax of what’s used in the Forge right now. It’s written in php and you can use it from your php webpages to dynamically include JavaScripts for development, or you can build a single .js for production from the command line.
</p>
</blockquote>
<div>
</div>
<p><a href="http://feeds2.feedburner.com/ajaxian">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-1-3b1-a-%e2%80%9cslick%e2%80%9d-release/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Accomplishing Common Tasks Using MooTools, jQuery, and&#160;Dojo</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/accomplishing-common-tasks-using-mootools-jquery-anddojo/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/accomplishing-common-tasks-using-mootools-jquery-anddojo/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 18:20:03 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[div id]]></category>
		<category><![CDATA[document body]]></category>
		<category><![CDATA[document id]]></category>
		<category><![CDATA[jquery ajax]]></category>
		<category><![CDATA[lt]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/accomplishing-common-tasks-using-mootools-jquery-anddojo/</guid>
		<description><![CDATA[I&#8217;ve been dabbling with Dojo quite a bit lately. I feel great about my MooTools and jQuery skills but I&#8217;m a bit still raw when it comes to Dojo. What&#8217;s important that I keep in mind, however, is that the tasks I&#8217;m trying to accomplish are the same &#8212; the syntax is simply different. Here [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been dabbling with Dojo quite a bit lately.  I feel great about my MooTools and jQuery skills but I&#8217;m a bit still raw when it comes to Dojo.  What&#8217;s important that I keep in mind, however, is that the tasks I&#8217;m trying to accomplish are the same &#8212; the syntax is simply different.  Here are a few basic JavaScript tasks and the syntax to accomplish them within each awesome framework.</p>
<p>
<h2>Execute Code when the DOM is Ready</h2>
<h3>Dojo Toolkit</h3>
<pre>
dojo.ready(function() {
	//do stuff
});
</pre>
<h3>jQuery</h3>
<pre>
$(document).ready(function() {
	//do stuff
});
</pre>
<h3>MooTools</h3>
<pre>
window.addEvent('domready',function() {
	//do stuff
});
</pre>
<p>
<h2>Collect Elements</h2>
<h3>Dojo Toolkit</h3>
<pre>
var myElement = dojo.byId('myElement');
var divs = dojo.query('div');
</pre>
<h3>jQuery</h3>
<pre>
var myElement = jQuery('#myElement');
var divs = jQuery('div');
</pre>
<h3>MooTools</h3>
<pre>
var myElement = document.id('myElement');
var divs = $$('div');
</pre>
<p>
<h2>Create Event Listeners</h2>
<h3>Dojo Toolkit</h3>
<pre>
dojo.connect(dojo.byId('myElement'),'onclick',function() {
	alert('You clicked me!');
});
</pre>
<h3>jQuery</h3>
<pre>
jQuery('#myElement').click(function() {
	alert('You clicked me!');
});
</pre>
<h3>MooTools</h3>
<pre>
document.id('myElement').addEvent('click',function() {
	alert('You clicked me!');
});
</pre>
<p>
<h2>Create a New Element, Inject Into Document.Body</h2>
<h3>Dojo Toolkit</h3>
<pre>
dojo.create('div',{
	innerHTML: 'This is a new element',
	id: 'myElement'
},dojo.body());
</pre>
<h3>jQuery</h3>
<pre>
$('&lt;div id=&quot;myElement&quot;&gt;This is a new element&lt;/div&gt;').appendTo('body');
</pre>
<h3>MooTools</h3>
<pre>
new Element('div',{
	id: 'myElement',
	text: 'This is a new element'
}).inject(document.body);
</pre>
<p>
<h2>Execute AJAX Requests</h2>
<h3>Dojo Toolkit</h3>
<pre>
dojo.xhrPost({
	url: 'save.php',
	content: {
		id: dojo.byId('user-id').value
	}
	load: function(response) {
		alert('Received the following response:  ' + response);
	}
});
</pre>
<h3>jQuery</h3>
<pre>
jQuery.ajax({
	url: 'save.php',
	type: 'post',
	data: {
		id: jQuery('#user-id').val()
	},
	success: function(response) {
		alert('Received the following response:  ' + response);
	}
});
</pre>
<h3>MooTools</h3>
<pre>
new Request({
	url: 'save.php',
	method: 'post',
	data: {
		id: document.id('user-id').value
	},
	onSuccess: function(response) {
		alert('Received the following response:  ' + response);
	}
}).send();
</pre>
<p>
<h2>Animate the Opacity of an Element</h2>
<h3>Dojo Toolkit</h3>
<pre>
dojo.anim('myElement',{ opacity: 0.7 }, 250);
</pre>
<h3>jQuery</h3>
<pre>
jQuery('#myElement').fadeTo(250,0.7);
//duration first...ftl
</pre>
<h3>MooTools</h3>
<pre>
document.id('myElement').set('tween',{ duration: 250 }).fade(0.7);
</pre>
<p>See?  Dojo, jQuery, and MooTools aren&#8217;t that different.  Same problems, different solution syntax.  Like <a href="http://higginsforpresident.net" rel="nofollow">Pete Higgins</a> says:  It&#8217;s just JavaScript!</p>
<p>Don&#8217;t forget to <a href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a href="http://scriptandstyle.com">Script &amp; Style</a> for the best Javascript and CSS articles around!<a href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!</p>
<p><a href="http://davidwalsh.name/mootools-jquery-dojo">Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/dojo-mootools" rel="bookmark" title="Permanent Link: Quick Dojo Setup Snippet for MooTools Developers">Quick Dojo Setup Snippet for MooTools&nbsp;Developers</a></li>
<li><a href="http://davidwalsh.name/remove-images-dojo" rel="bookmark" title="Permanent Link: Remove Broken Images Using Dojo">Remove Broken Images Using&nbsp;Dojo</a></li>
<li><a href="http://davidwalsh.name/quickboxes-dojo" rel="bookmark" title="Permanent Link: QuickBoxes for Dojo">QuickBoxes for&nbsp;Dojo</a></li>
<li><a href="http://davidwalsh.name/jquery-add-event" rel="bookmark" title="Permanent Link: Implement MooTools’ Elements.addEvent in jQuery">Implement MooTools&#8217; Elements.addEvent in&nbsp;jQuery</a></li>
<li><a href="http://davidwalsh.name/link-nudging-dojo" rel="bookmark" title="Permanent Link: Link Nudging Using Dojo">Link Nudging Using&nbsp;Dojo</a></li>
</ol>
<p><a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/accomplishing-common-tasks-using-mootools-jquery-anddojo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mind42</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mind42/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mind42/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 04:46:46 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[collaborative nature]]></category>
		<category><![CDATA[guide to the galaxy]]></category>
		<category><![CDATA[java projects]]></category>
		<category><![CDATA[keyboard shortcuts]]></category>
		<category><![CDATA[mind mapping software]]></category>
		<category><![CDATA[mind mapping tool]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[science fiction novel]]></category>
		<category><![CDATA[software offerings]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mind42/</guid>
		<description><![CDATA[What can you use the application for? Mind42 is a collaborative browser-based mind mapping tool. The name refers to two concepts: 42 is the “answer to life” in the popular science fiction novel, The Hitchhiker’s Guide to the Galaxy; and it also stands for “For Two” – signifying the collaborative nature of the application. The [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://feedads.g.doubleclick.net/~a/am2j9r5ireqPIFPnKpRaep1nRwU/0/da"><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/1c49d_di" border="0"></img></a><br />
<a href="http://feedads.g.doubleclick.net/~a/am2j9r5ireqPIFPnKpRaep1nRwU/1/da"><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/1c49d_di" border="0"></img></a></p>
<p>        <img alt="Logo" src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/1c49d_logo.png" />
<p>
  <b><br />
    What can you use the application for?<br />
  </b><br />
  <br />
  Mind42 is a collaborative browser-based mind mapping tool. The name refers to two concepts: 42 is the “answer to life” in the popular science fiction novel, The Hitchhiker’s Guide to the Galaxy; and it also stands for “For Two” – signifying the collaborative nature of the application. The application is a very useful image based tool for brainstorming by arranging ideas in a tree diagram. The online component allows for collaboration that is not limited by geographic location.
</p>
<p>
  <b><br />
    What is the history and popularity of the application?<br />
  </b><br />
  <br />
  Mind42 is a product of Irian Solutions, a company that specializes in creating Java projects.
</p>
<p>
  <b><br />
    What are the differences to other applications?<br />
  </b><br />
  <br />
  The application is completely free, which is different than several other mind mapping software offerings. The spare, orderly workspace is conducive to brainstorming as there are few elements for distraction. The program also contains handy keyboard shortcuts for adding nodes and editing. Another great feature is the auto-saving element. As users work on their maps, the application automatically saves every five minutes to prevent data loss. Users can also go back and restore the map to an earlier saved period.
</p>
<p>
  <b><br />
    How does the application look and feel to use?<br />
  </b><br />
  <br />
  The workspace is very clean and uncluttered. Tools pop up with the addition of a new element rather than in the toolbar which contains just the basic gadgets. There is an instructional video that demonstrates the basics and users new to this type of program may need to refer to it while working with the software for the first time. In addition to the video, there is a completely indexed help section for each feature in Mind42. This may be accessed by clicking the question mark on the workspace. </p>
<p>One of the most convenient options is the ability to search for an online image from within the program for insertion into the map. Attachments, hyperlinks, and a variety of icons may be added to any node entry. A variety of font options allows for further customization.</p>
<p>Because the application is free, no files may be attached as there is no bandwidth/storage space for them, however there is no limit to the number of maps that a user can create. An unlimited number of collaborators are allowed to work on each project. </p>
<p>Files may be exported in Freemind, Mind42, Mindjet MindManager, RTF, PDF, JPG, or PNG formats. Mind maps may be published into a user’s blog or website easily. Mind maps may be imported from Mind42, Freemind, and Mindmanager.</p>
<p>Mind42 uses Google groups to host a forum for networking and questions as well as a FAQ section.
</p>
<p>
  <b><br />
    How does the registration process work?<br />
  </b><br />
  <br />
  Registration requires a username, password, and email address. A confirmation email with activation link is sent to the provided address.
</p>
<p>
  <b><br />
    What does it cost to use the application?<br />
  </b><br />
  <br />
  Mind42 is completely free to use.
</p>
<p>
  <b><br />
    Who would you recommend the application to?<br />
  </b><br />
  <br />
  Anyone who wishes to work through a problem alone or with any number of partners can benefit from Mind42. The ability to use a visual representative to assist with brainstorming and problem solving is useful in classrooms, corporations, or personal life.
</p>
<p>      <img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/1c49d_8a2yzOS2TQY" height="1" width="1" /><br />
<a href="http://feeds2.feedburner.com/appappealnewest">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mind42/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a Trailing Mouse Cursor Effect Using&#160;MooTools</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-a-trailing-mouse-cursor-effect-usingmootools/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-a-trailing-mouse-cursor-effect-usingmootools/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 19:30:06 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[absolute positioning]]></category>
		<category><![CDATA[container document]]></category>
		<category><![CDATA[david walsh]]></category>
		<category><![CDATA[javascript window]]></category>
		<category><![CDATA[mouse cursor]]></category>
		<category><![CDATA[mouse trailer]]></category>
		<category><![CDATA[mousemove event]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[page x]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-a-trailing-mouse-cursor-effect-usingmootools/</guid>
		<description><![CDATA[Remember the old days of DHTML and effects that were an achievement to create but had absolutely no value? Well, a trailing mouse cursor script is sorta like that. And I&#8217;m sorta the type of guy that creates effects just because I can. Here&#8217;s how you can create a trailing mouse cursor script for your [...]]]></description>
			<content:encoded><![CDATA[<p>Remember the old days of DHTML and effects that were an achievement to create but had absolutely no value?  Well, a trailing mouse cursor script is sorta like that.  And I&#8217;m sorta the type of guy that creates effects just because I can.  Here&#8217;s how you can create a trailing mouse cursor script for your website.</p>
<div><a href="http://davidwalsh.name/dw-content/mouse-trailer.php">View Demo</a>
<div></div>
</div>
<h2>The MooTools JavaScript</h2>
<pre>
window.addEvent('domready',function() {
	var container = $(document.body),
		speed = 1200;
	container.addEvent('mousemove',function(e) {
		var image = new Element('img',{
			src: 'pointer.png',
			styles: {
				position: 'absolute',
				top: e.page.y,
				left: e.page.x
			},
			tween: {
				duration: speed,
				onComplete: function() {
					image.dispose();
				}
			}
		}).inject(container,'top').fade('out');
	});
});
</pre>
<p>The first step is to pick the container for which you want the mouse trailer to work in and the speed at which you&#8217;d like the element to fade out.  Apply a mousemove event listen to the container and inject a new element into that container each time the event fires.  Use the Event.page.x/y coordinates as your absolute positioning coordinates.</p>
<div><a href="http://davidwalsh.name/dw-content/mouse-trailer.php">View Demo</a>
<div></div>
</div>
<p>Use this sparingly as using it on every page could be the most annoying thing in the world.  Yay!  Now we&#8217;re all DHTML superstars!</p>
<p>Don&#8217;t forget to <a href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a href="http://scriptandstyle.com">Script &amp; Style</a> for the best Javascript and CSS articles around!<a href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!</p>
<p><a href="http://davidwalsh.name/mouse-trailer-cursor">Create a Trailing Mouse Cursor Effect Using&nbsp;MooTools</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/mootools-typewriter-plugin-upgrade" rel="bookmark" title="Permanent Link: MooTools Typewriter Effect Plugin Upgrade">MooTools Typewriter Effect Plugin&nbsp;Upgrade</a></li>
<li><a href="http://davidwalsh.name/mootools-slideshow-ii" rel="bookmark" title="Permanent Link: Create a Simple Slideshow Using MooTools, Part II:  Controls and Events">Create a Simple Slideshow Using MooTools, Part II:  Controls and&nbsp;Events</a></li>
<li><a href="http://davidwalsh.name/mootools-typewriter" rel="bookmark" title="Permanent Link: MooTools Typewriter Effect Plugin">MooTools Typewriter Effect&nbsp;Plugin</a></li>
<li><a href="http://davidwalsh.name/mootools-slideshow" rel="bookmark" title="Permanent Link: Create a Simple Slideshow Using MooTools">Create a Simple Slideshow Using&nbsp;MooTools</a></li>
<li><a href="http://davidwalsh.name/slideshow-thumbnails-captions" rel="bookmark" title="Permanent Link: Create a Simple Slideshow Using MooTools, Part IV: Thumbnails and Captions">Create a Simple Slideshow Using MooTools, Part IV: Thumbnails and&nbsp;Captions</a></li>
</ol>
<p><a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-a-trailing-mouse-cursor-effect-usingmootools/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Prototype&#8217;s Element.on with&#160;MooTools</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/prototypes-element-on-withmootools/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/prototypes-element-on-withmootools/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 19:50:24 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[Alias]]></category>
		<category><![CDATA[david walsh]]></category>
		<category><![CDATA[Enhancements]]></category>
		<category><![CDATA[fn]]></category>
		<category><![CDATA[impending release]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[prototype team]]></category>
		<category><![CDATA[several thousand]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/prototypes-element-on-withmootools/</guid>
		<description><![CDATA[Prototype 1.7RC1 was released on Monday. While the big news with this release appears to be the implementation of John Resig&#8217;s Sizzle selector engine, what caught my eye was the new on method. This new Element.on method is very similar to Prototype&#8217;s Element.observe method but with a few enhancements (event relaying, event stop). While I [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="nofollow" href="http://prototypejs.org/2010/4/5/prototype-1-7-rc1-sizzle-layout-dimensions-api-event-delegation-and-more">Prototype 1.7RC1 was released</a> on Monday.  While the big news with this release appears to be the implementation of John Resig&#8217;s Sizzle selector engine, what caught my eye was the new <span>on</span> method.  This new <span>Element.on</span> method is very similar to Prototype&#8217;s <span>Element.observe</span> method but with a few enhancements (event relaying, event stop).  While I don&#8217;t necessarily care about the enhancements, I simply love that the event method is called &#8220;on.&#8221;  Using &#8220;on&#8221; as the method name makes it sound more like the event itself.  Here&#8217;s how easy it is to use &#8220;on&#8221; instead of &#8220;addEvent&#8221; for your events.</p>
<h2>The MooTools JavaScript</h2>
<pre>/* the directive */
Element.alias('addEvent','on');

/* the usage */
$('myElement').on('click',fn);
</pre>
<p>Using <span>on</span> instead of <span>addEvent</span> is as easy as a quick MooTools <span>Element.alias</span> directive.</p>
<p>It&#8217;s weird that I like &#8220;on&#8221; so much considering a generally don&#8217;t like jQuery&#8217;s <span>css</span> and <span>attr</span> methods.  Oh well.  Congrats to the Prototype team for their impending release.</p>
<p>Don&#8217;t forget to <a href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a href="http://scriptandstyle.com">Script &amp; Style</a> for the best Javascript and CSS articles around!<a href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!</p>
<p><a href="http://davidwalsh.name/element-on">Prototype&#8217;s Element.on with&nbsp;MooTools</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/count-mootools-events" rel="bookmark" title="Permanent Link: Count MooTools Events Per Element in MooTools 1.2">Count MooTools Events Per Element in MooTools&nbsp;1.2</a></li>
<li><a href="http://davidwalsh.name/jquery-add-event" rel="bookmark" title="Permanent Link: Implement MooTools’ Elements.addEvent in jQuery">Implement MooTools&#8217; Elements.addEvent in&nbsp;jQuery</a></li>
<li><a href="http://davidwalsh.name/mootools-alias" rel="bookmark" title="Permanent Link: Using MooTools’ Alias Functionality">Using MooTools&#8217; Alias&nbsp;Functionality</a></li>
<li><a href="http://davidwalsh.name/element-has-event" rel="bookmark" title="Permanent Link: Implementing Element.hasEvent in MooTools 1.2.3">Implementing Element.hasEvent in MooTools&nbsp;1.2.3</a></li>
<li><a href="http://davidwalsh.name/mootools-one-event" rel="bookmark" title="Permanent Link: Implementing jQuery’s “One” Functionality in MooTools">Implementing jQuery&#8217;s &#8220;One&#8221; Functionality in&nbsp;MooTools</a></li>
</ol>
<p><a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/prototypes-element-on-withmootools/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>20 Helpful jQuery Methods you Should be Using</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/20-helpful-jquery-methods-you-should-be-using/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/20-helpful-jquery-methods-you-should-be-using/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 18:23:45 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[event handlers]]></category>
		<category><![CDATA[input type text]]></category>
		<category><![CDATA[insertbefore]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[sibling]]></category>
		<category><![CDATA[target element]]></category>
		<category><![CDATA[text inputs]]></category>
		<category><![CDATA[validation code]]></category>
		<category><![CDATA[value input]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/20-helpful-jquery-methods-you-should-be-using/</guid>
		<description><![CDATA[So you&#8217;ve been playing with jQuery for a while now, you&#8217;re starting to get the hang of it, and you&#8217;re really liking it! Are you ready to take your jQuery knowledge to level two? Today, I&#8217;ll demonstrate twenty functions and features you probably haven&#8217;t seen before! 1 after() / before() Sometimes you want to insert [...]]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;ve been playing with jQuery for a while now, you&#8217;re starting to get the hang of it, and you&#8217;re really liking it! Are you ready to take your jQuery knowledge to level two? Today, I&#8217;ll demonstrate twenty functions and features you probably haven&#8217;t seen before!</p>
<p><span></span></p>
<hr />
<h2><span>1</span> after() / before()</h2>
<p>Sometimes you want to insert something into the DOM, but you don&#8217;t have any good hooks to do it with; <code>append()</code> or <code>prepend()</code> aren&#8217;t going to cut it and you don&#8217;t want to add an extra element or id. These two functions might be what you need. They allow you to insert elements into the DOM just before or after another element, so the new element is a sibling of the older one. </p>
<pre>
$('#child').after($('&lt;p /&gt;')).text('This becomes a sibling of #child'));
$('#child').before($('&lt;p /&gt;')).text('Same here, but this is go about #child'));
</pre>
<p>You can also do this if you&#8217;re working primarily with the element you want to insert; just use the <code>insertAfter()</code> or <code>insertBefore</code> functions.</p>
<pre>
$('&lt;p&gt;I\'ll be a sibling of #child&lt;/p&gt;').insertAfter($('#child'));
</pre>
<hr />
<h2><span>2</span> change()</h2>
<p>The <code>change()</code> method is an event handler, just like <code>click()</code> or <code>hover()</code>. The change event is for textareas, text inputs, and select boxes, and it will fire when the value of the target element is changed; note that this is different from the <code>focusOut()</code> or <code>blur()</code> event handlers, which fire when the element loses focus, whether its value has changed or not.</p>
<p>The <code>change()</code> event is perfect for client-side validation; it&#8217;s much better than <code>blur()</code>, because you won&#8217;t be re-validating fields if the user doesn&#8217;t change the value.</p>
<pre>
$('input[type=text]').change(function () {
    switch (this.id) {
        /* some validation code here */
    }
});​​​​​​​​​​
</pre>
<hr />
<h2><span>3</span> Context</h2>
<p>Context is both a parameter and a property in jQuery. When collecting elements, you can pass in a second parameter to the jQuery function. This parameter, the context, will usually be a DOM element, and it limits the elements returned to item matching your selector that are children of the context element. That might sound a bit confusing, so check out this example:</p>
<pre>
&lt;p class="hello"&gt;Hello World&lt;/p&gt;
&lt;div id="wrap"&gt;
    &lt;p class="hello"&gt;Hello World&lt;/p&gt;
&lt;/div&gt;
</pre>
<pre>
var hi1 = $('.hello'),
    hi2 = $('.hello', $('#wrap').get(0));

console.group('hi1');
console.log("Number of elements in collection:", hi1.length);
console.log("Context of the collection:", hi1.context);
console.groupEnd();
console.group('hi2');
console.log("Number of elements in collection:", hi2.length);
console.log("Context of the collection:", hi2.context);
console.groupEnd();
</pre>
<div><img src="http://s3.amazonaws.com/nettuts/615_jquery/context.jpg" alt="context example" /></div>
<p>So where would this be useful? One place might be inside an event handler function. If you&#8217;d like to get an element within the one the event was fired on, you could pass <code>this</code> as the context:</p>
<pre>
$('ul#options li').click(function () {
    $('a', this) . . .
});
</pre>
<hr />
<h2><span>4</span> data() / removeData()</h2>
<p>Have you ever wanted to store some bit of information about an element? You can do that easily with the <code>data()</code> method. To set a value, you can pass in two parameters (a key and a value) or just one (an object).</p>
<pre>
$('#wrap').data('myKey', 'myValue');
$('#container').data({ myOtherKey : 'myOtherValue', year : 2010 });
</pre>
<p>To get your data back, just call the method with the key of value you want.</p>
<pre>
$('#container').data('myOtherKey'); //returns 'myOtherValue'
$('#container').data('year'); //returns 2010
</pre>
<p>To get all the data that corresponds with an element, call data without any parameters; you&#8217;ll get an object with all the keys and values you&#8217;ve given to that item.<br />
If you want to delete a key/value pair after you&#8217;ve added it to an element, just call <code>removeData()</code>, passing in the correct key.</p>
<pre>
$('#container').removeData('myOtherKey');
</pre>
<hr />
<h2><span>5</span> queue() / dequeue()</h2>
<p>The <code>queue()</code> and <code>dequeue()</code> functions deal with animations. A queue is list of animations to be executed on an element; be default, an element&#8217;s queue is named &#8216;fx.&#8217; Let&#8217;s set up a scenario:</p>
<p><strong>HTML</strong></p>
<pre>
&lt;ul&gt;
  &lt;li id="start"&gt;Start Animating&lt;/li&gt;
  &lt;li id="reset"&gt;Stop Animating&lt;/li&gt;
  &lt;li id="add"&gt;Add to Queue&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="width:150px; height:150px; background:#ececec;"&gt;&lt;/div&gt;
</pre>
<p><strong>JavaScript</strong></p>
<pre>
$('#start').click(animateBox);

$('#reset').click(function() {
    $('div').queue('fx', []);
});

$('#add').click(function() {
    $('div').queue( function(){
        $(this).animate({ height : '-=25'}, 2000);
        $(this).dequeue();
    });
});

function animateBox() {
  $('div').slideUp(2000)
           .slideDown(2000)
           .hide(2000)
           .show(2000, animateBox);
}
</pre>
<p>So, here&#8217;s what&#8217;s going on: in the <code>animateBox</code> function, we&#8217;re setting up a queue of animations; notice that the last one calls back to the function, so this will continually repeat the queue. When we click <code>li#start</code>, the function is called and the queue begins. When we click <code>li#reset</code>, the current animation finishes, and then the <code>div</code> stops animating. What we&#8217;ve done with jQuery is set the queue named &#8216;fx&#8217; (remember, the default queue) to an empty array; essentially, we&#8217;ve emptied the queue. And what about when we click <code>li#add</code>? First, we&#8217;re calling the <code>queue</code> function on the <code>div</code>; this adds the function we pass into it to the end of the queue; since we didn&#8217;t specify a queue as the first parameter, &#8216;fx&#8217; is used. In that function, we animate the <code>div</code>, and then call <code>dequeue()</code> on the div, which removes this function from the queue and continues the queue; the queue will continue repeating, but this function will not be part of it.</p>
<hr />
<h2><span>6</span> delay()</h2>
<p>When you&#8217;re queuing up a chain of animations, you can use the <code>delay()</code> method to pause the animation for a length of time; pass that time as a parameter in milliseconds.</p>
<pre>
$('div').hide().delay(2000).show(); // div will stay hidden for 2 seconds before showing.
</pre>
<hr />
<h2><span>7</span> bind(), unbind(), live(), and die()</h2>
<p>Did you know that when you add a click event to an element like this . . . </p>
<pre>
$('#el').click(function () { /*******/ });
</pre>
<p>. . . you&#8217;re really just using a wrapper for the <code>bind()</code> method? To use the <code>bind()</code> method itself, you can pass the event type as the first parameter and then the function as the second.</p>
<p>
If you use a lot of events, you can categorize them with namespacing; just add a period after the event name and add your namespace.</p>
<pre>
$('#el').bind('click', function () { /*******/ });
$('#el').bind('click.toolbarEvents', function () { /*******/ }); // namespaced
</pre>
<p>You can also assign the same function to multiple events at the same time, by separating them with spaces. So if you wanted to make a hover effect, you could start this way:</p>
<pre>
$('#el').bind('mouseover mouseout', function () { /*******/ });
</pre>
<p>You can also pass data to the function if you&#8217;d like, by adding a third parameter (in the second position).</p>
<pre>
$('#el').bind('click', { status : 'user-ready' }, function () {
    switch(event.data.status) {
    /********/
    }
});
</pre>
<p>Sooner or later, you&#8217;ll find yourself inserting element into the DOM via an event handler; however, you&#8217;ll find that the event handlers you&#8217;ve made with bind (or its wrappers) don&#8217;t work for inserted elements. In cases like this, you&#8217;ll need to use the <code>live()</code> (or delegate) method; this will add the event handlers to the appropriate inserted elements.</p>
<pre>
$('.toggle').live(function () {
    /* code */
    $('&lt;span class="toggle"&gt;Enable Beta Features&lt;/span&gt;').appendTo($('#optionsPanel'));
    /* more code */
});
</pre>
<p>To remove event handlers created with <code>bind()</code>, use the <code>unbind()</code> method. If you don&#8217;t pass it any parameters, it will remove all the handlers; you can pass in the event type to only remove event handlers of that type; to remove events from a specific namespace, add the namespace, or use it alone. If you just want to remove a certain function, pass its name along as the second parameter.</p>
<pre>
$('button').unbind(); // removes all
$('button').unbind('click'); // removes all clicks
$('button').unbind('.toolbarEvents'); // removes all events from the toolbarEvents namespace
$('button').unbind('click.toolbarEvents'); // removes all clicks from the toolbarEvents namespace
$('button').unbind('click', myFunction); // removes that one handler
</pre>
<p>Note that you can bind/unbind functions you&#8217;ve passed in anonymously; this only works with the functions name.<br />
If you&#8217;re trying to unbind an event from inside the function called by the event, just pass <code>unbind()</code> the <code>event</code> object.</p>
<pre>
$('p').bind('click', function (event) {
    $('p').unbind(event);
} );
</pre>
<p>You can&#8217;t use <code>unbind()</code> for <code>live</code> events; instead, use the <code>die()</code>. Without parameters, it will remove all <code>live</code> events from the element collection; you can also pass it just the event type, of the event type and the function. </p>
<pre>
$('span').die(); // removes all
$('span').die('mouseover'); // removes all mouseovers
$('span').die('mouseover', fn); // remove that one handler
</pre>
<p>And now, you can wield jQuery events with deftness and power!</p>
<p><strong>You should also <a href="http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-the-difference-between-live-and-delegate/">review the delegate() method</a>, as there can be substantial performance benefits to using it over live(). </strong></p>
<hr />
<h2><span>8</span> eq()</h2>
<p>If you&#8217;re looking for a specific element within a set of elements, you can pass the index of the element to the <code>eq()</code> method and get a single jQuery element. Pass in a negative index to count back from the end of the set.</p>
<pre>
var ps = $('p');
console.log(ps.length); // logs 3;
ps.eq(1).addClass('emphasis'); // just adds the class to the second item (index in zero-based)
</pre>
<p>You can also use <code>:eq()</code> in your selectors; so the previous example could have been done like this:</p>
<pre>
$('p:eq(1)').addClass('emphasis');
</pre>
<hr />
<h2><span>9</span> get()</h2>
<p>When getting a collection of element, jQuery returns them as a jQuery object, so you have access to all the methods. If you just want the raw DOM elements, you can use the <code>get()</code> method. </p>
<p>You can specify an index to get only one element.</p>
<pre>
alert( $('p') ); // [object Object] - the jquery object
alert( $('p').get(1) ); // [object HTMLParagraphElement]
</pre>
<hr />
<h2><span>10</span> grep()</h2>
<p>If you&#8217;re not familiar with Unix/Linix shells, you might not have heard the term <code>grep</code>. In a terminal, it&#8217;s a text search utility; but here in jQuery, we use it to filter an array of elements. It&#8217;s not a method of a jQuery collection; you pass in the array as the first parameter and the filtering function as the second parameter. That filter function takes two parameters itself: an element from the array and its index. That filter function should perform its work and return a true or false value. Be default, all the items that return true will be kept. You can add a third parameter, a boolean, to invert the results and kept the items that return false.</p>
<p><strong>Jeffrey Way did <a href="http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-fully-understanding-grep/">a great quick tip</a> about the <code>$.grep</code> not long ago; check that out to see how to use it!</strong></p>
<pre>
var nums = '1,2,3,4,5,6,7,8,9,10'.split(',');

nums = $.grep(nums, function(num, index) {
  // num = the current value for the item in the array
  // index = the index of the item in the array
  return num &gt; 5; // returns a boolean
});

console.log(nums) // 6,7,8,9,10
</pre>
<hr />
<h2><span>11</span> Pseudo-Selectors</h2>
<p>Sizzle, the CSS Selector engine inside jQuery, offers quite a few pseudo-selectors to make the job of selecting the elements you want easy. Check out these interesting ones:</p>
<pre>
$(':animated'); // returns all elements currently animating
$(':contains(me)'); // returns all elements with the text 'me'
$(':empty'); // returns all elements with no child nodes or text
$(':parent'); // returns all elements with child nodes or text
$('li:even'); // returns all even-index elements (in this case, &lt;li&gt;s)
$('li:odd'); // can you guess?
$(':header'); // returns all h1 - h6s.
$('li:gt(4)'); // returns all elements with an (zero-based) index greater than the given number
$('li:lt(4)'); // returns all element with an index less than the given number
$(':only-child'); // returns all . . . well, it should be obvious
</pre>
<p>There are more, of course, but these are the unique ones.</p>
<hr />
<h2><span>12</span> isArray() / isEmptyObject() / isFunction() / isPlainObject()</h2>
<p>Sometimes you want to make sure the parameter that was passed to a function was the corrent type; these functions make it easy to do. The first three are pretty self explanatory:</p>
<pre>
$.isArray([1, 2, 3]); // returns true
$.isEmptyObject({}); // returns true
$.isFunction(function () { /****/ }); // returns true
</pre>
<p>The next one isn&#8217;t as obvious; <code>isPlainObject()</code> will return true if the parameter passed in was created as an object literal, or with <code>new Object()</code>.</p>
<pre>
function Person(name) {
	this.name = name
	return this;
}
$.isPlainObject({})); // returns true
$.isPlainObject(new Object()); // returns true
$.isPlainObject(new Person()); // returns false
</pre>
<hr />
<h2><span>13</span> makeArray()</h2>
<p>When you create a collection of DOM elements with jQuery, you&#8217;re returned a jQuery object; in some situations, you might prefer that this be an array or regular DOM elements; the <code>makeArray()</code> function can do just that.</p>
<pre>
var ps = $('p');
$.isArray(ps); //returns false;
ps = $.makeArray(ps);
$.isArray(ps); // returns true;
</pre>
<hr />
<h2><span>14</span> map()</h2>
<p>The <code>map()</code> method is remotely similar to <code>grep()</code>. As you might expect, it takes one parameter, a function. That function can have two parameters: the index of the current element and the element itself. Here&#8217;s what happens: the function that you pass in will be run once for each item in the collection; whatever value is returned from that function takes the place of the item it was run for in the collection. </p>
<pre>
$('ul#nav li a').map(function() {
  return $(this).attr('title');
});  // now the collection is the link titles
// this could be the beginning of a tooltip plugin.
</pre>
<hr />
<h2><span>15</span> parseJSON()</h2>
<p>If you&#8217;re using <code>$.post</code> or <code>$.get</code>&mdash;and in other situations that you work with JSON strings&mdash;you&#8217;ll find the <code>parseJSON</code> function useful. It&#8217;s nice that this function uses the browsers built-in JSON parser if it has one (which will obviously be faster).</p>
<pre>
$.post('somePage.php', function (data) {
    /*****/
data =  $.parseJSON(data);
    /*****/
});
</pre>
<hr />
<h2>16</span> proxy()</h2>
<p>If you have a function as a property of an object, and that function uses other properties of the object, you can&#8217;t call that function from within other functions and get the right results. I know that was confusing, so let&#8217;s look at a quick example:</p>
<pre>
var person = {
  name : "Andrew",
  meet : function () {
    alert('Hi! My name is ' + this.name);
  }
};
person.meet();
$('#test').click(person.meet);
</pre>
<p>By itself, <code>person.meet()</code> will alert correctly; but when it&#8217;s called by the event handler, it will alert &#8220;Hi! My name is undefined.&#8221; This is because the function is not being called in the right context. To fix this, we can use the <code>proxy()</code> function:</p>
<pre>
$('#test').click($.proxy(person.meet, person));
// we could also do $.proxy(person, "meet")
</pre>
<p>The first parameter of the proxy function is the method to run; the second is the context we should run it in. Alternatively, we can pass the context first, and the method name as a string second. Now you&#8217;ll find that the function alerts correctly.</p>
<p><strong><a href="http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-learning-jquery-1-4s-proxy/">Prefer a video quick tip on $.proxy?</a></strong></p>
<hr />
<h2><span>17</span> replaceAll() / replaceWith()</h2>
<p>If you&#8217;d like to replace DOM elements with other ones, here&#8217;s how to do it. We can call <code>replaceAll()</code> on elements we&#8217;ve collected or created, passing in a selector for the elements we&#8217;d like to replace. In this example, all elements with the <code>error</code> class will be replaced with the <code>span</code> we&#8217;ve created. </p>
<pre>
$('&lt;span class="fixed"&gt;The error has been corrected&lt;/span&gt;').replaceAll('.error');
</pre>
<p>The <code>replaceWith()</code> method just reverses the selectors; find the ones you want to replace first:</p>
<pre>
$('.error').replaceWith('&lt;span class="fixed"&gt;The error has been corrected&lt;/span&gt;');
</pre>
<p>You can also pass these two methods functions that will return elements or HTML strings.</p>
<hr />
<h2><span>18</span> serialize() / serializeArray()</h2>
<p>The <code>serialize()</code> method is what to use for encoding the values in a form into a string. </p>
<p><strong>HTML</strong></p>
<pre>
&lt;form&gt;
    &lt;input type="text" name="name" value="John Doe" /&gt;
    &lt;input type="text" name="url" value="http://www.example.com" /&gt;
&lt;/form&gt;
</pre>
<p><strong>JavaScript</strong></p>
<pre>
console.log($('form').serialize());​​​ // logs : name=John+Doe&amp;url=http%3A%2F%2Fwww.example.com
</pre>
<p>You can use <code>serializeArray()</code> to turn the form values into an array of objects instead of a string:</p>
<pre>
console.log($('form').serializeArray());​​​
// logs : [{ name : 'name', value : 'John Doe'} , { name : 'url', value : 'http://www.example.com' } ]
</pre>
<hr />
<h2><span>19</span> siblings()</h2>
<p>You can probably guess what the <code>siblings()</code> method does; it will return a collection of the siblings of the whatever items are in your original collections:</p>
<pre>
&lt;div&gt; . . . &lt;/div&gt;
&lt;p&gt; . . . &lt;/p&gt;
&lt;span&gt; . . . &lt;/span&gt;
</pre>
<pre>
$('p').siblings(); // returns &lt;div&gt;, &lt;span&gt;
</pre>
<hr />
<h2><span>20</span> wrap() / wrapAll() / wrapInner()</h2>
<p>These three functions make it easy to wrap elements in other elements. First off, I&#8217;ll mention that all three take one parameter: either an element (which is an HTML string, a CSS selctor, a jQuery object, or a DOM element) or a function that returns an element.<br />
The <code>wrap()</code> method wraps each item in the collection with the assigned element:</p>
<pre>
$('p').wrap('&lt;div class="warning" /&gt;'); // all paragraphs are now wrapped in a div.warning
</pre>
<p>The <code>wrapAll()</code> will wrap one element around all the elements in the collection; this means that the elements in the collection will be moved to a new spot in the DOM; they&#8217;ll line up at the place of the first element in the collection and be wrapped there:</p>
<p><strong>HTML, Before:</strong></p>
<pre>
&lt;p&gt;
    &lt;span&gt; . . . &lt;/span&gt;
    &lt;span class="moveMe"&gt; . . . &lt;/span&gt;
    &lt;span class="moveMe"&gt; . . . &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
    &lt;span&gt; . . . &lt;/span&gt;
    &lt;span class="moveMe"&gt; . . . &lt;/span&gt;
    &lt;span class="moveMe"&gt; . . . &lt;/span&gt;
&lt;/p&gt;
</pre>
<p><strong>JavaScript</strong></p>
<pre>
$('.moveMe').wrapAll(document.createElement('div'));
</pre>
<p><strong>HTML, After:</strong></p>
<pre>
&lt;p&gt;
    &lt;span&gt; . . . &lt;/span&gt;
    &lt;div&gt;
        &lt;span class="moveMe"&gt; . . . &lt;/span&gt;
        &lt;span class="moveMe"&gt; . . . &lt;/span&gt;
        &lt;span class="moveMe"&gt; . . . &lt;/span&gt;
        &lt;span class="moveMe"&gt; . . . &lt;/span&gt;
    &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
    &lt;span&gt; . . . &lt;/span&gt;
&lt;/p&gt;
</pre>
<p>Finally, the <code>wrapInner</code> function wraps everything inside each element in the collecting with the given element:</p>
<p><strong>HTML, Before:</strong></p>
<pre>
&lt;p&gt;
    &lt;span&gt; . . . &lt;/span&gt;
    &lt;span&gt; . . . &lt;/span&gt;
&lt;/p&gt;
</pre>
<p><strong>JavaScript:</strong></p>
<pre>
$('p').wrapInner($('&lt;div /&gt;'));
</pre>
<p><strong>HTML, After:</strong></p>
<pre>
&lt;p&gt;
    &lt;div&gt;
        &lt;span&gt; . . . &lt;/span&gt;
        &lt;span&gt; . . . &lt;/span&gt;
    &lt;/div&gt;
&lt;/p&gt;
</pre>
<hr />
<h2>Conclusion</h2>
<p>Well, now you&#8217;ve got more than twenty new jQuery features to play with on your next project; have fun with them!</p>
<p><a href="http://feedads.g.doubleclick.net/~a/106I4w7fNbaxKmhRgmXMme_VBDw/0/da"><img src="http://feedads.g.doubleclick.net/~a/106I4w7fNbaxKmhRgmXMme_VBDw/0/di" border="0"></img></a><br />
<a href="http://feedads.g.doubleclick.net/~a/106I4w7fNbaxKmhRgmXMme_VBDw/1/da"><img src="http://feedads.g.doubleclick.net/~a/106I4w7fNbaxKmhRgmXMme_VBDw/1/di" border="0"></img></a></p>
<div>
<a href="http://feeds.feedburner.com/~ff/nettuts?a=W4DMNq3AbnI:gKK4Y_-Fk5I:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/nettuts?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=W4DMNq3AbnI:gKK4Y_-Fk5I:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/nettuts?i=W4DMNq3AbnI:gKK4Y_-Fk5I:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=W4DMNq3AbnI:gKK4Y_-Fk5I:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/nettuts?i=W4DMNq3AbnI:gKK4Y_-Fk5I:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=W4DMNq3AbnI:gKK4Y_-Fk5I:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/nettuts?i=W4DMNq3AbnI:gKK4Y_-Fk5I:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=W4DMNq3AbnI:gKK4Y_-Fk5I:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/nettuts?d=TzevzKxY174" border="0"></img></a>
</div>
<p><img src="http://feeds.feedburner.com/~r/nettuts/~4/W4DMNq3AbnI" height="1" width="1" /><br />
<a href="http://feedproxy.google.com/nettuts">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/20-helpful-jquery-methods-you-should-be-using/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a Quick MooTools Slideshow with Preloading&#160;Images</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-a-quick-mootools-slideshow-with-preloadingimages/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-a-quick-mootools-slideshow-with-preloadingimages/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 08:47:43 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[background url]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[div id]]></category>
		<category><![CDATA[image x]]></category>
		<category><![CDATA[loading image]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[page images]]></category>
		<category><![CDATA[preload images]]></category>
		<category><![CDATA[relative progress]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-a-quick-mootools-slideshow-with-preloadingimages/</guid>
		<description><![CDATA[I&#8217;ve been creating a lot of slideshow posts lately. Why, you ask? Because they help me get chicks. A quick formula for you: var numChicks = $$('.slideshow').length; //simple! The following code snippet will show you how to create a simple slideshow with MooTools; the script will also preload the images and feature a progress message. [...]]]></description>
			<content:encoded><![CDATA[<p><img style="width: 450px;height: 300px" src="http://davidwalsh.name/dw-content/epics/1.jpg" alt="David Walsh Slideshow" />
<p>I&#8217;ve been creating a lot of slideshow posts lately.  Why, you ask?  Because they help me get chicks.  A quick formula for you:</p>
<pre>var numChicks = $$('.slideshow').length; //simple!
</pre>
<p>The following code snippet will show you how to create a simple slideshow with MooTools;  the script will also preload the images and feature a progress message.  Why preload images?  They make the slideshow more elegant and you can avoid an onLoad mess.  Oh, and chicks&#8230;loads and loads of chicks.</p>
<div><a href="http://davidwalsh.name/dw-content/preload-slideshow.php">View Demo</a>
<div></div>
</div>
<h2>The HTML</h2>
<pre>&lt;div id="slideshow-holder"&gt;
	&lt;div id="progress"&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>Basically just two DIVs which will hold content.</p>
<h2>The CSS</h2>
<pre>#slideshow-holder	{ width:600px; height:400px; background:url(spinner.gif) center center no-repeat #fff; position:relative; }
#progress			{ position:absolute; width:100%; text-align:center; color:#999; top:225px; }
</pre>
<p>The image holder is given set dimensions, starts with a background spinner, and its position set to relative;  the images will all be positioned absolutely.  The progress holder is set right below the spinner.</p>
<h2>The MooTools Javascript</h2>
<pre>window.addEvent('domready',function() {
	/* preloading */
	var imagesDir = 'epics/';
	var images = ['2.jpg','3.jpg','1.jpg','4.jpg','5.jpg'];
	var holder = $('slideshow-holder');
	images.each(function(img,i){ images[i] = imagesDir + '' + img; }); //add dir to images
	var progressTemplate = 'Loading image {x} of ' + images.length;
	var updateProgress = function(num) {
		progress.set('text',progressTemplate.replace('{x}',num));
	};
	var progress = $('progress');
	updateProgress('text','0');
	var loader = new Asset.images(images, {
		onProgress: function(c,index) {
			updateProgress('text',index + 1);
		},
		onComplete: function() {
			var slides = [];
			/* put images into page */
			images.each(function(im) {
				slides.push(new Element('img',{
					src:im,
					width: 600,
					height: 400,
					styles: {
						opacity:0,
						top:0,
						left:0,
						position:'absolute',
						'z-index': 10
					}
				}).inject(holder));
				holder.setStyle('background','url(logo.png) center 80px no-repeat');
			});
			var showInterval = 5000;
			var index = 0;
			progress.set('text','Images loaded.  MooTools FTW.');
			(function() {slides[index].tween('opacity',1); }).delay(1000);
			var start = function() {
				(function() {
					holder.setStyle('background','');
					slides[index].fade(0);
					++index;
					index = (slides[index] ? index : 0);
					slides[index].fade(1);
				}).periodical(showInterval);
			};

			/* start the show */
			start();
		}
	});
});
</pre>
<p>The first set of variable declarations represent basic settings for the preloader:  images, preload-message-updating, etc.  We pass our Asset.images instance an array of images.  When each image loads, we update the status message.  When every image has loaded, we remove the status message and start the slideshow.  That&#8217;s it!</p>
<div><a href="http://davidwalsh.name/dw-content/preload-slideshow.php">View Demo</a>
<div></div>
</div>
<p>Of course the above could be turned into the class&#8230;.I&#8217;m just slightly lazy&#8230;Feel free to turn it into a class and share with everyone!</p>
<p>Don&#8217;t forget to <a href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a href="http://scriptandstyle.com">Script &amp; Style</a> for the best Javascript and CSS articles around!<a href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!</p>
<p><a href="http://davidwalsh.name/slideshow-preload-images">Create a Quick MooTools Slideshow with Preloading&nbsp;Images</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/mootools-slideshow" rel="bookmark" title="Permanent Link: Create a Simple Slideshow Using MooTools">Create a Simple Slideshow Using&nbsp;MooTools</a></li>
<li><a href="http://davidwalsh.name/mootools-slideshow-ii" rel="bookmark" title="Permanent Link: Create a Simple Slideshow Using MooTools, Part II:  Controls and Events">Create a Simple Slideshow Using MooTools, Part II:  Controls and&nbsp;Events</a></li>
<li><a href="http://davidwalsh.name/mootools-image-preloading-progress-bar" rel="bookmark" title="Permanent Link: MooTools Image Preloading with Progress Bar">MooTools Image Preloading with Progress&nbsp;Bar</a></li>
<li><a href="http://davidwalsh.name/slideshow-thumbnails-captions" rel="bookmark" title="Permanent Link: Create a Simple Slideshow Using MooTools, Part IV: Thumbnails and Captions">Create a Simple Slideshow Using MooTools, Part IV: Thumbnails and&nbsp;Captions</a></li>
<li><a href="http://davidwalsh.name/create-a-simple-slideshow-iii" rel="bookmark" title="Permanent Link: Create a Simple Slideshow Using MooTools, Part III: Creating a Class">Create a Simple Slideshow Using MooTools, Part III: Creating a&nbsp;Class</a></li>
</ol>
<p><img src="http://feeds.feedburner.com/~r/Bludice/~4/x1MIqYjzvsw" height="1" width="1" /><br />
<a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-a-quick-mootools-slideshow-with-preloadingimages/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>MooTools Class Creation Tips&#160;II</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-class-creation-tipsii/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-class-creation-tipsii/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 14:15:08 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[class creation]]></category>
		<category><![CDATA[container]]></category>
		<category><![CDATA[creation tips]]></category>
		<category><![CDATA[currentIndex]]></category>
		<category><![CDATA[Don]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[functionalities]]></category>
		<category><![CDATA[lt images]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[var]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-class-creation-tipsii/</guid>
		<description><![CDATA[A while back I shared a few MooTools class creation tips that I live by. More experience in creating MooTools plugins has given me some new guidelines to share. Code &#8220;Inline&#8221; First, Then Class-ize; Don&#8217;t Force It The number one tip I give to MooTools Class rookies is this: create the desired class functionality before [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I shared a few MooTools class creation tips that I live by.  More experience in creating MooTools plugins has given me some new guidelines to share.</p>
<h2>Code &#8220;Inline&#8221; First, Then Class-ize; Don&#8217;t Force It<br />
</h2>
<p>The number one tip I give to MooTools Class rookies is this:  create the desired class functionality <strong>before</strong> turning it into a class.  Once you have the code working using &#8220;inline&#8221; MooTools javascript, evaluate what you have.  You may decide that your functionality is too specific to the task at hand that making a Class isn&#8217;t the right choice.</p>
<p>If you do think you should turn the code into a class, take a look at all of your initial &#8220;var {key} = {value}&#8221; declarations &#8212; those will likely be your arguments and options.  Take any repeated code and turn them into class methods.  Do the same for specific functionalities the Class should have.  Here&#8217;s a very basic example:</p>
<pre>
window.addEvent('domready',function() {
	/* settings */
	var showDuration = 3000;
	var container = $('slideshow-container');
	var images = container.getElements('img');
	var currentIndex = 0;
	var interval;
	var toc = [];
	var tocWidth = 20;
	var tocActive = 'toc-active';

	/* new: starts the show */
	var start = function() { interval = show.periodical(showDuration); };
	var stop = function() { $clear(interval); };
	/* worker */
	var show = function(to) {
		images[currentIndex].fade('out');
		toc[currentIndex].removeClass(tocActive);
		images[currentIndex = ($defined(to) ? to : (currentIndex &lt; images.length - 1 ? currentIndex+1 : 0))].fade('in');
		toc[currentIndex].addClass(tocActive);
	};

	/* new: control: table of contents */
	images.each(function(img,i){
		toc.push(new Element('a',{
			text: i+1,
			href: '#',
			'class': 'toc' + (i == 0 ? ' ' + tocActive : ''),
			events: {
				click: function(e) {
					if(e) e.stop();
					stop();
					show(i);
				}
			},
			styles: {
				left: ((i + 1) * (tocWidth + 10))
			}
		}).inject(container));
		if(i &gt; 0) { img.set('opacity',0); }
	});

	/* new: control: next and previous */
	var next = new Element('a',{
		href: '#',
		id: 'next',
		text: '&gt;&gt;',
		events: {
			click: function(e) {
				if(e) e.stop();
				stop(); show();
			}
		}
	}).inject(container);
	var previous = new Element('a',{
		href: '#',
		id: 'previous',
		text: '&lt;&lt;',
		events: {
			click: function(e) {
				if(e) e.stop();
				stop(); show(currentIndex != 0 ? currentIndex -1 : images.length-1);
			}
		}
	}).inject(container);

	/* new: control: start/stop on mouseover/mouseout */
	container.addEvents({
		mouseenter: function() { stop(); },
		mouseleave: function() { start(); }
	});

	/* start once the page is finished loading */
	window.addEvent('load',function(){
		start();
	});
});
</pre>
<p>And now the Class version:</p>
<pre>
var SimpleSlideshow = new Class({
	options: {
		showControls: true,
		showDuration: 3000,
		showTOC: true,
		tocWidth: 20,
		tocClass: 'toc',
		tocActiveClass: 'toc-active'
	},
	Implements: [Options,Events],
	initialize: function(container,elements,options) {
		//settings
		this.container = $(container);
		this.elements = $$(elements);
		this.currentIndex = 0;
		this.interval = '';
		if(this.options.showTOC) this.toc = [];

		//assign
		this.elements.each(function(el,i){
			if(this.options.showTOC) {
				this.toc.push(new Element('a',{
					text: i+1,
					href: '#',
					'class': this.options.tocClass + '' + (i == 0 ? ' ' + this.options.tocActiveClass : ''),
					events: {
						click: function(e) {
							if(e) e.stop();
							this.stop();
							this.show(i);
						}.bind(this)
					},
					styles: {
						left: ((i + 1) * (this.options.tocWidth + 10))
					}
				}).inject(this.container));
			}
			if(i &gt; 0) el.set('opacity',0);
		},this);

		//next,previous links
		if(this.options.showControls) {
			this.createControls();

		}
		//events
		this.container.addEvents({
			mouseenter: function() { this.stop(); }.bind(this),
			mouseleave: function() { this.start(); }.bind(this)
		});

	},
	show: function(to) {
		this.elements[this.currentIndex].fade('out');
		if(this.options.showTOC) this.toc[this.currentIndex].removeClass(this.options.tocActiveClass);
		this.elements[this.currentIndex = ($defined(to) ? to : (this.currentIndex &lt; this.elements.length - 1 ? this.currentIndex+1 : 0))].fade('in');
		if(this.options.showTOC) this.toc[this.currentIndex].addClass(this.options.tocActiveClass);
	},
	start: function() {
		this.interval = this.show.bind(this).periodical(this.options.showDuration);
	},
	stop: function() {
		$clear(this.interval);
	},
	//"private"
	createControls: function() {
		var next = new Element('a',{
			href: '#',
			id: 'next',
			text: '&gt;&gt;',
			events: {
				click: function(e) {
					if(e) e.stop();
					this.stop();
					this.show();
				}.bind(this)
			}
		}).inject(this.container);
		var previous = new Element('a',{
			href: '#',
			id: 'previous',
			text: '&lt;&lt;',
			events: {
				click: function(e) {
					if(e) e.stop();
					this.stop();
					this.show(this.currentIndex != 0 ? this.currentIndex -1 : this.elements.length-1);
				}.bind(this)
			}
		}).inject(this.container);
	}
});
</pre>
<p>See how easy the transition is when you have the inline code in front of you?  Simple!</p>
<h2>Add Events When Possible</h2>
<p>Adding events to your classes gives a completely new level of control over the class functionality.  Consider my <a href="http://davidwalsh.name/mootools-overlay">Overlay class</a>.  I spent 95% of the time creating the plugin functionality and 5% implementing events but I consider events essential to the Overlay.  Here&#8217;s a quick example of implementing events:</p>
<pre>
//.....
Implements: [Options,Events],
open: function() {
	this.fireEvent('open');
	//do stuff
},
//.....
</pre>
<p>Now my Overlay class allows you fire events at 4 different times.  More flexible and a perfect usage of events.</p>
<h2>Evaluate Options vs. Arguments</h2>
<p>Judge your list of options and your class&#8217; primary responsibilities to determine if all of the options should be kept as options and not as arguments, and visa versa.  When I come to a 50/50 decision I choose to make the parameter an option.  If the class cannot live without the given option/argument and there&#8217;s no suitable default, keep it as an argument.</p>
<h2>Chaining: return this;</h2>
<p>One of the great advantages of using a javascript frameworks and classes is the ability to chain method class to make your code shorter.  And implementing that type of functionality is so easy!</p>
<pre>
//.....
store: function(key,value) {
	this.data[key] = value;
	return this;
}
//.....
</pre>
<p>Don&#8217;t let your methods end with nothing &#8212; return this!</p>
<h2>Put it in the Forge!</h2>
<p>Share your awesome plugin by posting it in the <a href="http://mootools.net/plugins">MooTools Forge</a>.  Sharing your plugins in the Forge allows you to easily get feedback, improvements, and requests.</p>
<p>There you have it.  Feel free to share any of your tips!</p>
<div>
                                <a href="http://davidwalsh.name/wp-content/plugins/as-pdf/generate.php?post=4534"><br />
                                    <span>Download PDF</span><br />
                                </a>
                            </div>
<p>Don&#8217;t forget to <a href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a href="http://scriptandstyle.com">Script &amp; Style</a> for the best Javascript and CSS articles around!</p>
<p><a href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!</p>
<p><a href="http://davidwalsh.name/mootools-class-tips-ii">MooTools Class Creation Tips&nbsp;II</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/mootools-class-tips" rel="bookmark" title="Permanent Link: MooTools Class Creation Tips">MooTools Class Creation&nbsp;Tips</a></li>
<li><a href="http://davidwalsh.name/create-a-simple-slideshow-iii" rel="bookmark" title="Permanent Link: Create a Simple Slideshow Using MooTools, Part III: Creating a Class">Create a Simple Slideshow Using MooTools, Part III: Creating a&nbsp;Class</a></li>
<li><a href="http://davidwalsh.name/jquery-create-element" rel="bookmark" title="Permanent Link: MooTools-Like Element Creation in jQuery">MooTools-Like Element Creation in&nbsp;jQuery</a></li>
<li><a href="http://davidwalsh.name/function-class-exists-php" rel="bookmark" title="Permanent Link: Check for Function and Class Existence Using PHP">Check for Function and Class Existence Using&nbsp;PHP</a></li>
<li><a href="http://davidwalsh.name/mootools-12-tooltips-customize" rel="bookmark" title="Permanent Link: MooTools 1.2 Tooltips: Customize Your Tips">MooTools 1.2 Tooltips: Customize Your&nbsp;Tips</a></li>
</ol>
<p><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/89bc1_Mv35VwmD6r4" height="1" width="1" /><br />
<a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/mootools-class-creation-tipsii/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Create a Simple Slideshow Using MooTools, Part III: Creating a&#160;Class</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-a-simple-slideshow-using-mootools-part-iii-creating-aclass/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-a-simple-slideshow-using-mootools-part-iii-creating-aclass/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 02:26:02 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[container]]></category>
		<category><![CDATA[currentIndex]]></category>
		<category><![CDATA[Don]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[inline code]]></category>
		<category><![CDATA[interval]]></category>
		<category><![CDATA[lt events]]></category>
		<category><![CDATA[lt images]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[var]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-a-simple-slideshow-using-mootools-part-iii-creating-aclass/</guid>
		<description><![CDATA[In my previous two slideshow posts, Create a Simple Slideshow Using MooTools and Create a Simple Slideshow Using MooTools, Part II: Controls and Events, I showed you how to create a slideshow using &#8220;inline&#8221; MooTools javascript. Today we&#8217;ll take that code and transition it into a MooTools class. View Demo The Original Inline Code window.addEvent('domready',function() [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://davidwalsh.name/simple-slideshow-class.php"><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/de45a_cricci1.jpg" alt="Christina Ricci" width="512" height="384" /></a>
</p>
<p>In my previous two slideshow posts, <a title="Permanent Link: Create a Simple Slideshow Using MooTools" rel="bookmark" href="http://davidwalsh.name/mootools-slideshow">Create a Simple Slideshow Using MooTools</a> and <a href="http://davidwalsh.name/mootools-slideshow-ii">Create a Simple Slideshow Using MooTools, Part II:  Controls and Events</a>, I showed you how to create a slideshow using &#8220;inline&#8221; MooTools javascript.  Today we&#8217;ll take that code and transition it into a MooTools class.</p>
<div><a href="http://davidwalsh.name/dw-content/simple-slideshow-class.php">View Demo</a>
<div></div>
</div>
<h2>The Original Inline Code</h2>
<pre>
window.addEvent('domready',function() {
	/* settings */
	var showDuration = 3000;
	var container = $('slideshow-container');
	var images = container.getElements('img');
	var currentIndex = 0;
	var interval;
	var toc = [];
	var tocWidth = 20;
	var tocActive = 'toc-active';

	/* new: starts the show */
	var start = function() { interval = show.periodical(showDuration); };
	var stop = function() { $clear(interval); };
	/* worker */
	var show = function(to) {
		images[currentIndex].fade('out');
		toc[currentIndex].removeClass(tocActive);
		images[currentIndex = ($defined(to) ? to : (currentIndex &lt; images.length - 1 ? currentIndex+1 : 0))].fade('in');
		toc[currentIndex].addClass(tocActive);
	};

	/* new: control: table of contents */
	images.each(function(img,i){
		toc.push(new Element('a',{
			text: i+1,
			href: '#',
			'class': 'toc' + (i == 0 ? ' ' + tocActive : ''),
			events: {
				click: function(e) {
					if(e) e.stop();
					stop();
					show(i);
				}
			},
			styles: {
				left: ((i + 1) * (tocWidth + 10))
			}
		}).inject(container));
		if(i &gt; 0) { img.set('opacity',0); }
	});

	/* new: control: next and previous */
	var next = new Element('a',{
		href: '#',
		id: 'next',
		text: '&gt;&gt;',
		events: {
			click: function(e) {
				if(e) e.stop();
				stop(); show();
			}
		}
	}).inject(container);
	var previous = new Element('a',{
		href: '#',
		id: 'previous',
		text: '&lt;&lt;',
		events: {
			click: function(e) {
				if(e) e.stop();
				stop(); show(currentIndex != 0 ? currentIndex -1 : images.length-1);
			}
		}
	}).inject(container);

	/* new: control: start/stop on mouseover/mouseout */
	container.addEvents({
		mouseenter: function() { stop(); },
		mouseleave: function() { start(); }
	});

	/* start once the page is finished loading */
	window.addEvent('load',function(){
		start();
	});
});
</pre>
<p>We&#8217;ll be starting from the above code which was used in the second post.</p>
<h2>Step 1:  Create a Basic Class Outline</h2>
<p>The following MooTools Class template can be downloaded <a href="http://davidwalsh.name/mootools-12-class-template">here</a>.</p>
<pre>
var yourClass = new Class({

	//implements
	Implements: [Options],

	//options
	options: {
		yourOption: ''
	},

	//initialization
	initialize: function(options) {
		//set options
		this.setOptions(options);
	},

	//a method that does whatever you want
	yourMethod: function() {

	}

});
</pre>
<h2>Step 2:  Variables Become Options, Arguments<br />
</h2>
<p>Remember that our class needs to be flexible (duh, that&#8217;s the reason we create classes!).  For that reason, we&#8217;ll transition as many of the variables as we can into options for the class.  Since the container and elements of the slideshow are mandatory (we can&#8217;t create a slideshow without them!), we&#8217;ll make those arguments.</p>
<pre>
var SimpleSlideshow = new Class({
	options: {
		showControls: true,
		showDuration: 3000,
		showTOC: true,
		tocWidth: 20,
		tocClass: 'toc',
		tocActiveClass: 'toc-active'
	},
	Implements: [Options,Events],
	initialize: function(container,elements,options) {
		//settings
		this.container = $(container);
		this.elements = $$(elements);
		this.currentIndex = 0;
		this.interval = '';
		if(this.options.showTOC) this.toc = [];

		//assign
		this.elements.each(function(el,i){
			if(this.options.showTOC) {
				this.toc.push(new Element('a',{
					text: i+1,
					href: '#',
					'class': this.options.tocClass + '' + (i == 0 ? ' ' + this.options.tocActiveClass : ''),
					events: {
						click: function(e) {
							if(e) e.stop();
							this.stop();
							this.show(i);
						}.bind(this)
					},
					styles: {
						left: ((i + 1) * (this.options.tocWidth + 10))
					}
				}).inject(this.container));
			}
			if(i &gt; 0) el.set('opacity',0);
		},this);

		//next,previous links
		if(this.options.showControls) {
			this.createControls();

		}
		//events
		this.container.addEvents({
			mouseenter: function() { this.stop(); }.bind(this),
			mouseleave: function() { this.start(); }.bind(this)
		});

	},

//...
</pre>
<p>The usefulness of our class is largely dependent upon the options we bake into our plugin.  Don&#8217;t go overboard though &#8212; it&#8217;s easy to bloat your plugin by allowing for too many options.</p>
<h2>Step 3:  Functions Become Methods</h2>
<p>This step is really easy:  take the global functions we created (start, stop, etc.) and make them the methods within the class.  The only big change in doing this will be changing variables references to &#8220;this.{variable}&#8221; or &#8220;this.options.{variable}&#8221;.</p>
<pre>
//...
show: function(to) {
	this.elements[this.currentIndex].fade('out');
	if(this.options.showTOC) this.toc[this.currentIndex].removeClass(this.options.tocActiveClass);
	this.elements[this.currentIndex = ($defined(to) ? to : (this.currentIndex &lt; this.elements.length - 1 ? this.currentIndex+1 : 0))].fade('in');
	if(this.options.showTOC) this.toc[this.currentIndex].addClass(this.options.tocActiveClass);
},
start: function() {
	this.interval = this.show.bind(this).periodical(this.options.showDuration);
},
stop: function() {
	$clear(this.interval);
}
//...
</pre>
<h2>Step 4:  Controls</h2>
<p>We&#8217;ll use another custom, private method to generate the code for the controls (next,previous):</p>
<pre>
//...
,
//&quot;private&quot;
createControls: function() {
	var next = new Element('a',{
		href: '#',
		id: 'next',
		text: '&gt;&gt;',
		events: {
			click: function(e) {
				if(e) e.stop();
				this.stop();
				this.show();
			}.bind(this)
		}
	}).inject(this.container);
	var previous = new Element('a',{
		href: '#',
		id: 'previous',
		text: '&lt;&lt;',
		events: {
			click: function(e) {
				if(e) e.stop();
				this.stop();
				this.show(this.currentIndex != 0 ? this.currentIndex -1 : this.elements.length-1);
			}.bind(this)
		}
	}).inject(this.container);
}
//...
</pre>
<h2>Pulling It All Together</h2>
<p>The following is our completed class:</p>
<pre>
var SimpleSlideshow = new Class({
	options: {
		showControls: true,
		showDuration: 3000,
		showTOC: true,
		tocWidth: 20,
		tocClass: 'toc',
		tocActiveClass: 'toc-active'
	},
	Implements: [Options,Events],
	initialize: function(container,elements,options) {
		//settings
		this.container = $(container);
		this.elements = $$(elements);
		this.currentIndex = 0;
		this.interval = '';
		if(this.options.showTOC) this.toc = [];

		//assign
		this.elements.each(function(el,i){
			if(this.options.showTOC) {
				this.toc.push(new Element('a',{
					text: i+1,
					href: '#',
					'class': this.options.tocClass + '' + (i == 0 ? ' ' + this.options.tocActiveClass : ''),
					events: {
						click: function(e) {
							if(e) e.stop();
							this.stop();
							this.show(i);
						}.bind(this)
					},
					styles: {
						left: ((i + 1) * (this.options.tocWidth + 10))
					}
				}).inject(this.container));
			}
			if(i &gt; 0) el.set('opacity',0);
		},this);

		//next,previous links
		if(this.options.showControls) {
			this.createControls();

		}
		//events
		this.container.addEvents({
			mouseenter: function() { this.stop(); }.bind(this),
			mouseleave: function() { this.start(); }.bind(this)
		});

	},
	show: function(to) {
		this.elements[this.currentIndex].fade('out');
		if(this.options.showTOC) this.toc[this.currentIndex].removeClass(this.options.tocActiveClass);
		this.elements[this.currentIndex = ($defined(to) ? to : (this.currentIndex &lt; this.elements.length - 1 ? this.currentIndex+1 : 0))].fade('in');
		if(this.options.showTOC) this.toc[this.currentIndex].addClass(this.options.tocActiveClass);
	},
	start: function() {
		this.interval = this.show.bind(this).periodical(this.options.showDuration);
	},
	stop: function() {
		$clear(this.interval);
	},
	//&quot;private&quot;
	createControls: function() {
		var next = new Element('a',{
			href: '#',
			id: 'next',
			text: '&gt;&gt;',
			events: {
				click: function(e) {
					if(e) e.stop();
					this.stop();
					this.show();
				}.bind(this)
			}
		}).inject(this.container);
		var previous = new Element('a',{
			href: '#',
			id: 'previous',
			text: '&lt;&lt;',
			events: {
				click: function(e) {
					if(e) e.stop();
					this.stop();
					this.show(this.currentIndex != 0 ? this.currentIndex -1 : this.elements.length-1);
				}.bind(this)
			}
		}).inject(this.container);
	}
});
</pre>
<p>&#8230;and the usage:</p>
<pre>
/* usage */
window.addEvent('domready',function() {
	var slideshow = new SimpleSlideshow('slideshow-container','#slideshow-container img');
	slideshow.start();
});
</pre>
<div><a href="http://davidwalsh.name/dw-content/simple-slideshow-class.php">View Demo</a>
<div></div>
</div>
<h2>MooTools Classes FTW!</h2>
<p>Now we have a reusable, flexible MooTools class that you can use on any website you create.  Hell, you could even share it on the Forge for all to use!  How was it?  Any questions about creating MooTools classes?</p>
<div>
                                <a href="http://davidwalsh.name/wp-content/plugins/as-pdf/generate.php?post=4563"><br />
                                    <span>Download PDF</span><br />
                                </a>
                            </div>
<p>Don&#8217;t forget to <a href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a href="http://scriptandstyle.com">Script &amp; Style</a> for the best Javascript and CSS articles around!</p>
<p><a href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!</p>
<p><a href="http://davidwalsh.name/create-a-simple-slideshow-iii">Create a Simple Slideshow Using MooTools, Part III: Creating a&nbsp;Class</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/mootools-slideshow-ii" rel="bookmark" title="Permanent Link: Create a Simple Slideshow Using MooTools, Part II:  Controls and Events">Create a Simple Slideshow Using MooTools, Part II:  Controls and&nbsp;Events</a></li>
<li><a href="http://davidwalsh.name/mootools-slideshow" rel="bookmark" title="Permanent Link: Create a Simple Slideshow Using MooTools">Create a Simple Slideshow Using&nbsp;MooTools</a></li>
<li><a href="http://davidwalsh.name/simple-mootools-event-class-binding" rel="bookmark" title="Permanent Link: Simple MooTools Event / Class Binding">Simple MooTools Event / Class&nbsp;Binding</a></li>
<li><a href="http://davidwalsh.name/mootools-dotter" rel="bookmark" title="Permanent Link: Introducing MooTools Dotter">Introducing MooTools&nbsp;Dotter</a></li>
<li><a href="http://davidwalsh.name/mootools-periodical" rel="bookmark" title="Permanent Link: Using MooTools Periodicals">Using MooTools&nbsp;Periodicals</a></li>
</ol>
<p><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/de45a_R4KoJ_s8wyA" height="1" width="1" /><br />
<a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/create-a-simple-slideshow-using-mootools-part-iii-creating-aclass/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Better Pull Quotes with&#160;MooTools</title>
		<link>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/better-pull-quotes-withmootools/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/better-pull-quotes-withmootools/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 16:50:05 +0000</pubDate>
		<dc:creator>Facebook-Web-Design</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[background color]]></category>
		<category><![CDATA[Chris]]></category>
		<category><![CDATA[Chris Coyier]]></category>
		<category><![CDATA[David Walsh Blog]]></category>
		<category><![CDATA[Don]]></category>
		<category><![CDATA[element]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[padding]]></category>
		<category><![CDATA[quote]]></category>
		<category><![CDATA[span]]></category>
		<category><![CDATA[span class]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/better-pull-quotes-withmootools/</guid>
		<description><![CDATA[Chris Coyier authored a post titled Better Pull Quotes: Don&#8217;t Repeat Markup a while back. In his post he created great-looking pull quotes without repeating any content &#8212; instead he uses jQuery to dynamically create the pull quotes. The following is the MooTools method for doing so. View Demo The HTML &#60;p&#62;&#60;span class=&#34;pull-me&#34;&#62;As a MooTools [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://davidwalsh.name/dw-content/mootools-pull-quote.php"><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/fce5d_pullquotes.png" alt="Pull Quotes" /></a></p>
<p>Chris Coyier authored a post titled <a href="http://css-tricks.com/better-pull-quotes/">Better Pull Quotes: Don&#8217;t Repeat Markup</a> a while back.  In his post he created great-looking pull quotes without repeating any content &#8212; instead he uses jQuery to dynamically create the pull quotes.  The following is the MooTools method for doing so.</p>
<div><a href="http://davidwalsh.name/dw-content/mootools-pull-quote.php">View Demo</a>
<div></div>
</div>
<h2>The HTML</h2>
<pre>
&lt;p&gt;&lt;span class=&quot;pull-me&quot;&gt;As a MooTools &quot;insider&quot;, however, I'm excited for what the MooTools team will bring to the table during 2010.&lt;/span&gt; We'll be launching the Forge (our public plugin repository), releasing MooTools 2, continuing to grow MooTools More, featuring more community work, and much more. MooTools FTW!&lt;/p&gt;
</pre>
<p>The HTML above features a paragraph of content with a SPAN tag wrapping what I&#8217;d like to be the pull quote.</p>
<h2>The CSS</h2>
<pre>
.quote { padding:20px; margin:0 0 20px 20px; font-size:20px; font-style:italic; background:#eee; color:#999; display:block; width:200px; float:right; }
</pre>
<p>You may style the quote any way you&#8217;d like.  These elements are traditionally large in text with italicized text and a different background color.</p>
<h2>The MooTools Javascript</h2>
<pre>
window.addEvent('domready',function() {
	//grab all quotes
	$$('span.pull-me').each(function(span) {
		//inject styled quote into page
		new Element('span',{
			'class': 'quote',
			text: span.get('text')
		}).inject(span.getParent(),'top');
	});
});
</pre>
<p>We find each element with a &#8220;pull-me&#8221; CSS class and generate a new element with our &#8220;quote&#8221; class.  We then inject the new element into the original element&#8217;s parent.  That&#8217;s all!</p>
<div><a href="http://davidwalsh.name/dw-content/mootools-pull-quote.php">View Demo</a>
<div></div>
</div>
<p>Chris did a great job with the execution of his idea.  This is a technique that will likely be used well into the future.</p>
<div>
                                <a href="http://davidwalsh.name/wp-content/plugins/as-pdf/generate.php?post=4292"><br />
                                    <span>Download PDF</span><br />
                                </a>
                            </div>
<p>Don&#8217;t forget to <a href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a href="http://scriptandstyle.com">Script &amp; Style</a> for the best Javascript and CSS articles around!</p>
<p><a href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!</p>
<p><a href="http://davidwalsh.name/mootools-pull-quotes">Better Pull Quotes with&nbsp;MooTools</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/highlight-table-columns" rel="bookmark" title="Permanent Link: Highlight Table Rows, Columns, and Cells Using MooTools 1.2.3">Highlight Table Rows, Columns, and Cells Using MooTools&nbsp;1.2.3</a></li>
<li><a href="http://davidwalsh.name/predictions-2010" rel="bookmark" title="Permanent Link: Bold Web Predictions for 2010">Bold Web Predictions for&nbsp;2010</a></li>
<li><a href="http://davidwalsh.name/mootools-html-police-dwmarkupmarine" rel="bookmark" title="Permanent Link: MooTools HTML Police: dwMarkupMarine">MooTools HTML Police:&nbsp;dwMarkupMarine</a></li>
<li><a href="http://davidwalsh.name/method-chaining" rel="bookmark" title="Permanent Link: Method Chaining in MooTools and PHP">Method Chaining in MooTools and&nbsp;PHP</a></li>
<li><a href="http://davidwalsh.name/image-protector-plugin-for-jquery" rel="bookmark" title="Permanent Link: dwImageProtector Plugin for jQuery">dwImageProtector Plugin for&nbsp;jQuery</a></li>
</ol>
<p><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/fce5d_NCxy8TQwalw" height="1" width="1" /><br />
<a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/better-pull-quotes-withmootools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Event Delegation with&#160;MooTools</title>
		<link>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/event-delegation-withmootools/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/event-delegation-withmootools/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 18:14:19 +0000</pubDate>
		<dc:creator>BlogPoster</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[david walsh]]></category>
		<category><![CDATA[David Walsh Blog]]></category>
		<category><![CDATA[Delegation]]></category>
		<category><![CDATA[document id]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Don]]></category>
		<category><![CDATA[element]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[sample html]]></category>
		<category><![CDATA[syntax window]]></category>
		<category><![CDATA[Walsh Blog]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/event-delegation-withmootools/</guid>
		<description><![CDATA[Events play a huge role in javascript. I can&#8217;t name one website I&#8217;ve created in the past two years that hasn&#8217;t used javascript event handling on some level. Ask yourself: how often do I inject elements into the DOM and not add an event to them? For me it&#8217;s very rare. For this reason I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>Events play a huge role in javascript.  I can&#8217;t name one website I&#8217;ve created in the past two years that hasn&#8217;t used javascript event handling on some level.  Ask yourself:  how often do I inject elements into the DOM and not add an event to them?  For me it&#8217;s very rare.  For this reason I&#8217;m proud and excited for the release of <a href="http://mootools.net/docs/more/Element/Element.Delegation">MooTools 1.2.4&#8217;s Event.Delegation</a> code.</p>
<h2>WTF is Event Delegation?</h2>
<p>Event delegation is the process of assigning an event listener to a parent for all of its children instead of assigning the same event to every child.</p>
<div><a href="http://davidwalsh.name/dw-content/event-delegation.php">View Demo</a>
<div></div>
</div>
<h2>Some Sample HTML</h2>
<pre>
&lt;ul id=&quot;link-list&quot;&gt;
	&lt;li&gt;&lt;a href=&quot;http://davidwalsh.name&quot;&gt;David Walsh Blog Link 1&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://davidwalsh.name&quot;&gt;David Walsh Blog Link 2&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://davidwalsh.name&quot;&gt;David Walsh Blog Link 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>A list with 3 list item elements which contain a link.  For the sake of my example, this list will have list items added to it and we want an alert to pop up any time a link within the list is clicked.</p>
<h2>The MooTools Javascript Event Delegation Syntax</h2>
<pre>
window.addEvent('domready',function() {
	/* delegate */
	document.id('link-list').addEvent('click:relay(a)', function(e){
		e.stop();
		alert('you clicked a link!');
	});
	/*
		Add link to show event delegation works!
		Notice how we haven't assigned an event to this specific element.
		We already added the event to the list element itself
	*/
	document.id('add-link').addEvent('click',function() {
		var li = new Element('li').inject('link-list');
		var link = new Element('a',{ text:'David Walsh Blog', href:'http://davidwalsh.name'}).inject(li);
	});
});
</pre>
<p>All you need to do is add <span>:relay</span> to the parent selector and place the &#8220;children&#8221; match inside the relay pseudo selector.  You&#8217;ll probably question how <span>:relay</span> works because the &#8220;:&#8221; syntax is used for pseudo selectors.  The Element.Delegation javascript download overwrites the addEvent, removeEvent, and fireEvent methods to accommodate for the <span>:relay</span> syntax.</p>
<h2>Event Delegation Replaces&#8230;</h2>
<pre>
var links = document.id('link-list').getElements('li');
links.each(function(link) {
	link.addEvent('click',function() {
		//assign actions here
	});
})
</pre>
<p>Why collect and iterate through elements to add events when you can simply use event delegation?</p>
<div><a href="http://davidwalsh.name/dw-content/event-delegation.php">View Demo</a>
<div></div>
</div>
<p>Event delegation is a great way to avoid repeating the same event assignments for elements within a parent element, especially when you are adding elements into the page dynamically.  If you&#8217;ve not upgraded to MooTools 1.2.4 yet, I hope this is just the kick in the pants you need!</p>
<p>Don&#8217;t forget to <a href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a href="http://scriptandstyle.com">Script &amp; Style</a> for the best Javascript and CSS articles around!</p>
<p><a href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!</p>
<p><a href="http://davidwalsh.name/event-delegation">Event Delegation with&nbsp;MooTools</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/mootools-event-delegation" rel="bookmark" title="Permanent Link: MooTools Event Delegation">MooTools Event&nbsp;Delegation</a></li>
<li><a href="http://davidwalsh.name/prevent-default-event-actions-mootools-12" rel="bookmark" title="Permanent Link: Prevent Default Event Actions Using MooTools 1.2">Prevent Default Event Actions Using MooTools&nbsp;1.2</a></li>
<li><a href="http://davidwalsh.name/implement-jquery-mootools-event" rel="bookmark" title="Permanent Link: Implementing jQuery-Like Event Syntax in MooTools">Implementing jQuery-Like Event Syntax in&nbsp;MooTools</a></li>
<li><a href="http://davidwalsh.name/dwclickable-entire-block-clickable-mootools" rel="bookmark" title="Permanent Link: dwClickable:  Entire Block Clickable Using MooTools 1.2">dwClickable:  Entire Block Clickable Using MooTools&nbsp;1.2</a></li>
<li><a href="http://davidwalsh.name/animated-ajax-record-deletion-mootools" rel="bookmark" title="Permanent Link: Animated Ajax Record Deletion Using MooTools">Animated Ajax Record Deletion Using&nbsp;MooTools</a></li>
</ol>
<p><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/aa9be_k8uWzc8i7P0" height="1" width="1" /><br />
<a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/event-delegation-withmootools/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Event Delegation with MooTools</title>
		<link>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/event-delegation-with-mootools/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/event-delegation-with-mootools/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 17:09:03 +0000</pubDate>
		<dc:creator>BlogPoster</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[david walsh]]></category>
		<category><![CDATA[David Walsh Blog]]></category>
		<category><![CDATA[Delegation]]></category>
		<category><![CDATA[document id]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Don]]></category>
		<category><![CDATA[element]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[sample html]]></category>
		<category><![CDATA[syntax window]]></category>
		<category><![CDATA[Walsh Blog]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/event-delegation-with-mootools/</guid>
		<description><![CDATA[Events play a huge role in javascript. I can&#8217;t name one website I&#8217;ve created in the past two years that hasn&#8217;t used javascript event handling on some level. Ask yourself: how often do I inject elements into the DOM and not add an event to them? For me it&#8217;s very rare. For this reason I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>
<p>Events play a huge role in javascript.  I can&#8217;t name one website I&#8217;ve created in the past two years that hasn&#8217;t used javascript event handling on some level.  Ask yourself:  how often do I inject elements into the DOM and not add an event to them?  For me it&#8217;s very rare.  For this reason I&#8217;m proud and excited for the release of <a href="http://mootools.net/docs/more/Element/Element.Delegation">MooTools 1.2.4&#8217;s Event.Delegation</a> code.</p>
<h2>WTF is Event Delegation?</h2>
<p>Event delegation is the process of assigning an event listener to a parent for all of its children instead of assigning the same event to every child.</p>
<div><a href="http://davidwalsh.name/dw-content/event-delegation.php">View Demo</a>
<div></div>
</div>
<h2>Some Sample HTML</h2>
<pre>
&lt;ul id=&quot;link-list&quot;&gt;
	&lt;li&gt;&lt;a href=&quot;http://davidwalsh.name&quot;&gt;David Walsh Blog Link 1&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://davidwalsh.name&quot;&gt;David Walsh Blog Link 2&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://davidwalsh.name&quot;&gt;David Walsh Blog Link 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>A list with 3 list item elements which contain a link.  For the sake of my example, this list will have list items added to it and we want an alert to pop up any time a link within the list is clicked.</p>
<h2>The MooTools Javascript Event Delegation Syntax</h2>
<pre>
window.addEvent('domready',function() {
	/* delegate */
	document.id('link-list').addEvent('click:relay(a)', function(e){
		e.stop();
		alert('you clicked a link!');
	});
	/*
		Add link to show event delegation works!
		Notice how we haven't assigned an event to this specific element.
		We already added the event to the list element itself
	*/
	document.id('add-link').addEvent('click',function() {
		var li = new Element('li').inject('link-list');
		var link = new Element('a',{ text:'David Walsh Blog', href:'http://davidwalsh.name'}).inject(li);
	});
});
</pre>
<p>All you need to do is add <span>:relay</span> to the parent selector and place the &#8220;children&#8221; match inside the relay pseudo selector.  You&#8217;ll probably question how <span>:relay</span> works because the &#8220;:&#8221; syntax is used for pseudo selectors.  The Element.Delegation javascript download overwrites the addEvent, removeEvent, and fireEvent methods to accommodate for the <span>:relay</span> syntax.</p>
<h2>Event Delegation Replaces&#8230;</h2>
<pre>
var links = document.id('link-list').getElements('li');
links.each(function(link) {
	link.addEvent('click',function() {
		//assign actions here
	});
})
</pre>
<p>Why collect and iterate through elements to add events when you can simply use event delegation?</p>
<div><a href="http://davidwalsh.name/dw-content/event-delegation.php">View Demo</a>
<div></div>
</div>
<p>Event delegation is a great way to avoid repeating the same event assignments for elements within a parent element, especially when you are adding elements into the page dynamically.  If you&#8217;ve not upgraded to MooTools 1.2.4 yet, I hope this is just the kick in the pants you need!</p>
<div>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td align="left">Send article as PDF to:   </td>
<td align="right"><a href="http://en.pdf24.org" target="_blank" title="PDF Download"><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/858b3_sheep_16x16.gif" alt="PDF Download" border="0" /></a></td>
</tr>
</table>
</div>
<p>Don&#8217;t forget to <a href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a href="http://scriptandstyle.com">Script &amp; Style</a> for the best Javascript and CSS articles around!</p>
<p><a href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!</p>
<p><a href="http://davidwalsh.name/event-delegation">Event Delegation with MooTools</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/mootools-event-delegation" rel="bookmark" title="Permanent Link: MooTools Event Delegation">MooTools Event Delegation</a></li>
<li><a href="http://davidwalsh.name/prevent-default-event-actions-mootools-12" rel="bookmark" title="Permanent Link: Prevent Default Event Actions Using MooTools 1.2">Prevent Default Event Actions Using MooTools 1.2</a></li>
<li><a href="http://davidwalsh.name/implement-jquery-mootools-event" rel="bookmark" title="Permanent Link: Implementing jQuery-Like Event Syntax in MooTools">Implementing jQuery-Like Event Syntax in MooTools</a></li>
<li><a href="http://davidwalsh.name/flip-text" rel="bookmark" title="Permanent Link: MooTools Text Flipping">MooTools Text Flipping</a></li>
<li><a href="http://davidwalsh.name/simple-mootools-event-class-binding" rel="bookmark" title="Permanent Link: Simple MooTools Event / Class Binding">Simple MooTools Event / Class Binding</a></li>
</ol>
<p><a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/event-delegation-with-mootools/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Form Element AJAX Spinner Attachment Using MooTools</title>
		<link>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/form-element-ajax-spinner-attachment-using-mootools/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/form-element-ajax-spinner-attachment-using-mootools/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 16:15:03 +0000</pubDate>
		<dc:creator>BlogPoster</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[david walsh]]></category>
		<category><![CDATA[David Walsh Blog]]></category>
		<category><![CDATA[Don]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[input type text]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[option]]></category>
		<category><![CDATA[request object]]></category>
		<category><![CDATA[request url]]></category>
		<category><![CDATA[spinner]]></category>
		<category><![CDATA[value]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/form-element-ajax-spinner-attachment-using-mootools/</guid>
		<description><![CDATA[Many times you&#8217;ll see a form dynamically change available values based on the value of a form field. For example, a &#8220;State&#8221; field will change based on which Country a user selects. What annoys me about these forms is that they&#8217;ll often do an AJAX request to grab the states but wont show any indicator [...]]]></description>
			<content:encoded><![CDATA[<p>
<p>Many times you&#8217;ll see a form dynamically change available values based on the value of a form field.  For example, a &#8220;State&#8221; field will change based on which Country a user selects.  What annoys me about these forms is that they&#8217;ll often do an AJAX request to grab the states but wont show any indicator to the user that something is happening.  We&#8217;re going to use MooTools to add an AJAX spinner image next to form fields that perform such AJAX requests.</p>
<div><a href="http://davidwalsh.name/dw-content/ajax-request-spinner.php">View Demo</a>
<div></div>
</div>
<h2>The XHTML</h2>
<pre>
&lt;select class="ajax"&gt;
	&lt;option value=""&gt;-- Select a Site--&lt;/option&gt;
	&lt;option value="David Walsh Blog"&gt;David Walsh Blog&lt;/option&gt;
	&lt;option value="Script &amp; Style"&gt;Script &amp; Style&lt;/option&gt;
	&lt;option value="Band Website Template"&gt;Band Website Template&lt;/option&gt;
&lt;/select&gt;

&lt;br /&gt;&lt;br /&gt;

&lt;input type="text" id="my-text" class="ajax" /&gt;
</pre>
<p>Add the &#8220;ajax&#8221; class (or any class for that matter) to the elements you&#8217;d like the spinner to display by.</p>
<h2>The MooTools Javascript</h2>
<pre>
window.addEvent('domready',function() {
	//inject image
	var spinner = new Element('img',{
		src: 'move-spinner.gif',
		styles: {
			position:'absolute'
		},
		opacity: 0
	}).inject(document.body);
	//form element events
	$$('.ajax').each(function(el) {
		//get coordinates
		var coords = el.getCoordinates(document.body);
		//ajax request object
		var request = new Request({
			url: '',
			method: 'post',
			onRequest: function() {
				spinner.setStyles({
					left: coords.right + 10,
					top: coords.top + 5
				}).fade('in');
			},
			onComplete: function() {
				spinner.fade('out');
			}
		});
		//change event
		el.addEvent('change',function() {
			//ajax request
			request.send({
				data: {
					ajax: 1,
					value: el.get('value')
				}
			});
		});
	});
});
</pre>
<p>We first add the spinner image to the document but hide it right away.  When any of the form elements with the &#8220;ajax&#8221; class changes value, we move the spinner image to the right of the element.  Then we use Reqeust&#8217;s onRequest and onComplete methods to show and hide the spinner.  Simple!</p>
<div><a href="http://davidwalsh.name/dw-content/ajax-request-spinner.php">View Demo</a>
<div></div>
</div>
<p>Look forward to a jQuery version tomorrow.</p>
<div>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td align="left">Send article as PDF to:   </td>
<td align="right"><a href="http://en.pdf24.org" target="_blank" title="PDF Printer"><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/9a4f6_sheep_16x16.gif" alt="PDF Printer" border="0" /></a></td>
</tr>
</table>
</div>
<p>Don&#8217;t forget to <a href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a href="http://scriptandstyle.com">Script &amp; Style</a> for the best Javascript and CSS articles around!</p>
<p><a href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!</p>
<p><a href="http://davidwalsh.name/ajax-spinner">Form Element AJAX Spinner Attachment Using MooTools</a></p>
<p>Related posts:
<ol>
<li><a href="http://davidwalsh.name/ajax-username-availability-checker-mootools" rel="bookmark" title="Permanent Link: Ajax Username Availability Checker Using MooTools 1.2">Ajax Username Availability Checker Using MooTools 1.2</a></li>
<li><a href="http://davidwalsh.name/php-form-submission-recognize-image-input-buttons" rel="bookmark" title="Permanent Link: PHP Form Submission: Recognize Image Input Buttons">PHP Form Submission: Recognize Image Input Buttons</a></li>
<li><a href="http://davidwalsh.name/noscript-compatible-select-form-element-onchange-event" rel="bookmark" title="Permanent Link: Create a NoScript Compatible Select Form Element with an onChange Event">Create a NoScript Compatible Select Form Element with an onChange Event</a></li>
<li><a href="http://davidwalsh.name/cache-ajax" rel="bookmark" title="Permanent Link: Caching AJAX Results in Javascript">Caching AJAX Results in Javascript</a></li>
<li><a href="http://davidwalsh.name/submit-form-new-window" rel="bookmark" title="Permanent Link: Submit a Form to a New Window">Submit a Form to a New Window</a></li>
</ol>
<p><a href="http://davidwalsh.name/feed/atom">Go to Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/form-element-ajax-spinner-attachment-using-mootools/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MooTools Window Object Dumping</title>
		<link>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/mootools-window-object-dumping/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/mootools-window-object-dumping/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 11:54:44 +0000</pubDate>
		<dc:creator>BlogPoster</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[courier font]]></category>
		<category><![CDATA[div id]]></category>
		<category><![CDATA[font family]]></category>
		<category><![CDATA[javascript window]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[script style]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/mootools-window-object-dumping/</guid>
		<description><![CDATA[Ever want to see all of the information stored within the &#8220;window&#8221; property of your browser? Here&#8217;s your chance. View Demo The XHTML &#60;div id="console"&#62;&#60;/div&#62; We need a wrapper DIV that we&#8217;ll consider a console. The CSS #console pre { font-family:Courier; font-size:11px; background:#000; color:lightgreen; margin:0 0 20px 0; padding:10px; } #console h3 { color:navy; padding:3px [...]]]></description>
			<content:encoded><![CDATA[<p>Ever want to see all of the information stored within the &#8220;window&#8221; property of your browser?  Here&#8217;s your chance.</p>
<div>
<a href="http://davidwalsh.name/dw-content/window-dump.php">View Demo</a></p>
<div></div>
</div>
<h2>The XHTML</h2>
<pre>
&lt;div id="console"&gt;&lt;/div&gt;
</pre>
<p>We need a wrapper DIV that we&#8217;ll consider a console.</p>
<h2>The CSS</h2>
<pre>
#console pre	{ font-family:Courier; font-size:11px; background:#000; color:lightgreen; margin:0 0 20px 0; padding:10px; }
#console h3		{ color:navy; padding:3px 0; }
</pre>
<p>I like making this look like a command-line console.</p>
<h2>The MooTools Javascript</h2>
<pre>
window.addEvent('domready',function() {
	new Hash(window).each(function(value,property) {
		new Element('h3',{ text: property }).inject('console');
		new Element('pre',{ text: value }).inject('console');
	});
});
</pre>
<p>Depending on what you have loaded into the page as a javascript framework, the amount stored within the window object will vary.</p>
<div>
<a href="http://davidwalsh.name/dw-content/window-dump.php">View Demo</a></p>
<div></div>
</div>
<p>Fun!  You could opt to just log all of this to Firebug&#8217;s console but the above works in all browsers.</p>
<p>Don&#8217;t forget to <a href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a href="http://scriptandstyle.com">Script &amp; Style</a> for the best Javascript and CSS articles around!</p>
<p><img src="http://www.neurosoftware.ro/programming-blog/wp-content/plugins/wp-o-matic/cache/53207_RtCOTAgLcKU" height="1" width="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/mootools-window-object-dumping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MooTools FontChecker Plugin</title>
		<link>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/mootools-fontchecker-plugin/</link>
		<comments>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/mootools-fontchecker-plugin/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 14:40:53 +0000</pubDate>
		<dc:creator>BlogPoster</dc:creator>
				<category><![CDATA[web resources]]></category>
		<category><![CDATA[class implements]]></category>
		<category><![CDATA[document body]]></category>
		<category><![CDATA[garbage text]]></category>
		<category><![CDATA[hidden element]]></category>
		<category><![CDATA[inline element]]></category>
		<category><![CDATA[new element]]></category>
		<category><![CDATA[span styles]]></category>

		<guid isPermaLink="false">http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/mootools-fontchecker-plugin/</guid>
		<description><![CDATA[There&#8217;s a very interesting piece of code on Google Code called FontAvailable which does a jQuery-based javascript check on a string to check whether or not your system has a specific font based upon its output width. I&#8217;ve ported this functionality to MooTools. View Demo Download The MooTools Javascript var FontChecker = new Class({ /* [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a very interesting piece of code on Google Code called <a href="http://code.google.com/p/jquery-fontavailable/">FontAvailable</a> which does a jQuery-based javascript check on a string to check whether or not your system has a specific font based upon its output width.  I&#8217;ve ported this functionality to MooTools.</p>
<div>
<a href="http://davidwalsh.name/dw-content/moo-font-available.php">View Demo</a><br />
<a href="http://davidwalsh.name/js">Download</a></p>
<div></div>
</div>
<h2>The MooTools Javascript</h2>
<pre>
var FontChecker = new Class({
	/* implements */
	Implements: [Options],
	/* options */
	options: {
		fakeFont: '__RUBBUSH_FONT__',
		testString: 'abcdefghijklmnopqrstuvwxyz'
	},
	/* initialization */
	initialize: function(options) {
		//set options
		this.setOptions(options);
	},
	/* a method that does whatever you want */
	check: function(desiredFont) {
		/* create a hidden element */
		var element = new Element('span',{
			styles: {
				visibility: 'hidden',
				'font-family': this.options.fakeFont
			},
			html: this.options.testString
		}).inject(document.body);
		/* apply a fake font, get width */
		var width = element.getCoordinates().width;
		/* apply desired font */
		element.setStyle('font-family', desiredFont);
		var new_width = element.getCoordinates().width;
		/* take our temp element out of the DOM */
		element.dispose();
		/* compare widths to see check if font is available */
		return (width !== new_width);
	}
});
</pre>
<p>My code follows the same logic as FontAvailable:</p>
<ul>
<li>inject a hidden inline element with some garbage text and a fake font</li>
<li>record the calculated width of the element</li>
<li>set the element&#8217;s font to the desired font</li>
<li>compare the widths and return whether they are the same</li>
</ul>
<h2>The Usage</h2>
<pre>
/* when the dom is ready */
window.addEvent('domready',function() {
	var fc = new FontChecker();
	/* use it...or lose it? */
	$('start').addEvent('click',function() {
		$$('#font-list li').each(function(el) {
			el.setStyle('color', fc.check(el.get('text')) ? 'green' : 'red');
		});
	});
});
</pre>
<p>You may check as many fonts as you&#8217;d like using one instance by using the &#8220;check&#8221; method.</p>
<div>
<a href="http://davidwalsh.name/dw-content/moo-font-available.php">View Demo</a><br />
<a href="http://davidwalsh.name/js">Download</a></p>
<div></div>
</div>
<p>The accuracy of this type of check can never be 100% because two fonts could theoretically have the same calculated width.  This methods does, however, provide a fairly accurate result.</p>
<p>Don&#8217;t forget to <a href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a href="http://scriptandstyle.com">Script &amp; Style</a> for the best Javascript and CSS articles around!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neurosoftware.ro/programming-blog/blogposter/web-resources/mootools-fontchecker-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

