<?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>Web Development Blog &#187; js</title>
	<atom:link href="http://www.leigeber.com/tag/js/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leigeber.com</link>
	<description>This web development blog features fresh articles on JavaScript, AJAX, CSS, XHTML, PHP, Photoshop and more.</description>
	<lastBuildDate>Sat, 13 Feb 2010 02:05:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Custom JavaScript Dialog Boxes</title>
		<link>http://www.leigeber.com/2008/04/custom-javascript-dialog-boxes/</link>
		<comments>http://www.leigeber.com/2008/04/custom-javascript-dialog-boxes/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 02:20:33 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[dialog]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[popup]]></category>

		<guid isPermaLink="false">http://www.leigeber.com/?p=23</guid>
		<description><![CDATA[This lightweight JavaScript dialog box library can easily be incorporated in your website to display alerts, prompts, warnings and success messages.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.leigeber.com/wp-content/uploads/2008/04/error_dialog_screen.gif" alt="JavaScript dialog boxes" width="459" height="263" /></p>
<p>I have put together a lightweight (~4.5kb) JavaScript dialog box library. The script currently offers four dialog styles: alerts, warnings, prompts and success. There is nothing to add to your page except references to the JavaScript and CSS if you choose not to incorporate them in your existing files. The Divs are dynamically added to the DOM when the function is called. The function currently relies on a content wrapper to calculate the page height however you could use the body height but the background overlay would only cover the currently visible content. The variable for the wrapper ID as well as the speed and timer settings are available at the top of the JavaScript file. Dialog boxes are generated as follows.</p>
<pre class="brush: jscript;">showDialog('Error','You have encountered an error.','error',2);</pre>
<p>The first property is the title of the box, the second is the message, the third is the box style (alert, warning, prompt or success) and the fourth is an optional autohide timeout. Set the auto hide to the number of seconds you want to show the dialog before it fades out.  The message can take HTML, just be sure and escape when necessary. The &#8220;look and feel&#8221; can easily be changed through the CSS and additional styles can easily be added by adding 2 lines of CSS.</p>
<p>This script has been tested in all major browsers and is available free of charge for both personal or commercial projects under the <a href="http://creativecommons.org/licenses/by/3.0/us/" target="_blank">creative commons license</a>. Community support is <a href="http://forum.leigeber.com/">available here</a>. Paid support is also available, <a href="http://www.leigeber.com/contact/">contact me</a> for details.</p>
<p><strong>Update 4/23/2008</strong> &#8211; Added autohide feature, thanks for the suggestion Chris.<br />
<strong>Update 4/23/2008</strong> &#8211; Added dynamic vertical positioning, 1/3 way down the current viewable window.<br />
<strong>Update 4/25/2008</strong> &#8211; Resolved double click issue when closing.<br />
<strong>Update 5/21/2008</strong> &#8211; Resolved issue when clicking to close the dialog box before the fading animation completes.</p>
<p><strong><a href='http://sandbox.leigeber.com/dialog/dialog_box.html'>View the demo.</a></strong></p>
<p><strong><a href='http://www.leigeber.com/wp-content/uploads/2008/04/dialog.zip'>Download the source.</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.leigeber.com/2008/04/custom-javascript-dialog-boxes/feed/</wfw:commentRss>
		<slash:comments>242</slash:comments>
		</item>
		<item>
		<title>5 JavaScript Best Practices</title>
		<link>http://www.leigeber.com/2008/04/5-javascript-best-practices/</link>
		<comments>http://www.leigeber.com/2008/04/5-javascript-best-practices/#comments</comments>
		<pubDate>Sun, 20 Apr 2008 17:19:08 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[js]]></category>

		<guid isPermaLink="false">http://www.leigeber.com/?p=15</guid>
		<description><![CDATA[JavaScript is an extremely powerful and flexible scripting language. This article highlights 5 JavaScript best practices to keep in mind.]]></description>
			<content:encoded><![CDATA[<p>JavaScript is an extremely powerful and flexible scripting language. Unfortunately flexible, for many people, means fallible. I am going to highlight 5 best practices that you can use in any JavaScript project. These are very broad, I will follow up soon with more specific best practices.</p>
<p><strong>First and foremost, keep your code simple, clean and well documented</strong>. This is by no means unique to JavaScript but many people seem to think it is the exception to the rule. Your code should naturally comment itself but it is also important to at least introduce every function. I recommend two versions, a fully documented and formatted version and then a compressed version that you use in production. There are a number of free online utilities that can strip out comments and pack your script. There is no need to push out the extra size required for the documentation and formatting.</p>
<p><strong>Second, keep your JavaScript in an external file</strong>. The only exception to this rule is if you have some very lightweight script specific to a single page or are setting up variables that cannot be done in the external JS. An external file results in greater scalability, maintainability and degradability. The correct way to reference an external JS file is as follows:</p>
<p><code>&lt;script type="text/javascript" src="script.js">&lt;/script></code></p>
<p><strong>Third, separate your JavaScript from the presentation layer</strong>. We have all heard of unobtrusive JavaScript but we still see inline script all the time. Instead of cluttering your font-end code with dozens of event handlers add them dynamically. There are exceptions to this rule so please use common sense and separate the layers when it makes sense. An example of adding an onclick event handler from JavaScript:</p>
<p><code>var div = document.getElementById('div');<br />
div.onclick = new Function("processClick(this)");</code></p>
<p><strong>Fourth, properly define and scope variables</strong>. Many of the scripts I download hoping to use in a project I immediately throw out. The reason being that the programmer did not take the time to properly define and scope variables. Always reference the first instance of a variable by using var. Otherwise the only way someone can know if that is the first reference to that variable is by starting at the top and reading all the way down. It is also important to scope variables correctly. Don&#8217;t scope a variable on the global level unless you need it there. I also recommend differentiation of global and local variables though some kind of visual identifier such is all caps on global variables or some easily identifiable character.</p>
<p><strong>Fifth, don&#8217;t assume JavaScript support in the first place</strong>. Depending on your audience you may choose to disregard this suggestion but for mainstream websites I highly suggest coding with the minority in mind (an estimated 5-10% of web users do not have JavaScript enabled) and degrade your scripts gracefully. JavaScript should be considered as an added feature and not a dependency. An examples of this would be links, the most fundamental element of a web page.</p>
<p><code>&lt;a href="javascript:processClick()">link&lt;/a><br />
&lt;a href="#" onclick="javascript:processClick()">link&lt;/a><br />
</code></p>
<p>If the user clicks the either of the links above with JavaScript disabled nothing will happen. However, with the code below they could still navigate.</p>
<p><code>&lt;a href="link.html" onclick="processClick(); return false;">link&lt;/a></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.leigeber.com/2008/04/5-javascript-best-practices/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Lightweight JavaScript Accordion with CSS</title>
		<link>http://www.leigeber.com/2008/04/lightweight-javascript-and-css-accordion/</link>
		<comments>http://www.leigeber.com/2008/04/lightweight-javascript-and-css-accordion/#comments</comments>
		<pubDate>Sat, 19 Apr 2008 02:44:25 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[accordion]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://www.leigeber.com/?p=13</guid>
		<description><![CDATA[This simple JavaScript accordion is only 1.65 kilobytes when packed. If you have a small project that could use a JavaScript accordion and don’t want to include an entire JavaScript framework to do the job then give this script a try.]]></description>
			<content:encoded><![CDATA[<p><strong>The updated accordion script is <a href="http://www.leigeber.com/2009/03/accordion/">available here</a>.</strong></p>
<p>This JavaScript accordion is only 1.5kb. If you have a small project that could use an accordion and don&#8217;t want to include an entire JavaScript framework to do the job then give this script a try.</p>
<p>You will need to call the following function in your body onload where the first parameter is the div id of the accordion parent and the second tells the script which section to expand onload.</p>
<pre class="brush: jscript;">slider.init('slider',1)</pre>
<p>This script has been tested in all major browsers and is available free of charge for both personal or commercial projects under the <a href="http://creativecommons.org/licenses/by/3.0/us/" target="_blank">creative commons license</a>. Community support is <a href="http://forum.leigeber.com/">available here</a>. Paid support is also available, <a href="http://www.leigeber.com/contact/">contact me</a> for details.</p>
<p><strong><a href="http://www.leigeber.com/wp-content/uploads/2008/04/javascript_slider.zip">Click here</a> to download the source code.</strong></p>
<p><strong>Updated 5/27/2008</strong> &#8211; Slightly minified the code cutting off 1kb and added the script into a global namespace.<br />
<strong>Updated 6/19/2008</strong> &#8211; Shaved of a few bytes and added change the &#8220;c&#8221; variable to identify which section to be expanded onload.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leigeber.com/2008/04/lightweight-javascript-and-css-accordion/feed/</wfw:commentRss>
		<slash:comments>106</slash:comments>
		</item>
	</channel>
</rss>
