<?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>djsipe.com &#187; JavaScript</title>
	<atom:link href="http://blog.djsipe.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.djsipe.com</link>
	<description>Web Development</description>
	<lastBuildDate>Sat, 31 Dec 2011 16:25:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Intro to jQuery &#8211; Web Dev Connect</title>
		<link>http://blog.djsipe.com/2011/12/12/intro-to-jquery-web-dev-connect/</link>
		<comments>http://blog.djsipe.com/2011/12/12/intro-to-jquery-web-dev-connect/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 01:15:37 +0000</pubDate>
		<dc:creator>DJ</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.djsipe.com/?p=89</guid>
		<description><![CDATA[It was my pleasure to speak at this month&#8217;s first-ever meeting of Web Dev Connect.  This month&#8217;s topic was an introduction to jQuery.  Next month we&#8217;ll be talking about the new jQuery Mobile framework.  Hope to see you there! Below are my slides.]]></description>
			<content:encoded><![CDATA[<p>It was my pleasure to speak at this month&#8217;s first-ever meeting of <em>Web Dev Connect</em>.  This month&#8217;s topic was an introduction to jQuery.  Next month we&#8217;ll be talking about the new <a title="jQuery Mobile" href="http://jquerymobile.com/" target="_blank">jQuery Mobile</a> framework.  Hope to see you <a href="http://www.meetup.com/WebDevConnect/events/43644842/" target="_blank">there</a>!</p>
<p>Below are my slides.</p>

<!-- Iframe plugin v.2.1 (wordpress.org/extend/plugins/iframe/) -->
<iframe src="http://app.sliderocket.com:80/app/fullplayer.aspx?id=0ad63f05-1e8f-409b-a5ad-8b0f758983e2" width="100%" height="480" scrolling="no" class="iframe-class" frameborder="0"></iframe>
]]></content:encoded>
			<wfw:commentRss>http://blog.djsipe.com/2011/12/12/intro-to-jquery-web-dev-connect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scoping ExtJS CSS</title>
		<link>http://blog.djsipe.com/2011/07/08/scoping-extjs-css/</link>
		<comments>http://blog.djsipe.com/2011/07/08/scoping-extjs-css/#comments</comments>
		<pubDate>Sat, 09 Jul 2011 01:38:14 +0000</pubDate>
		<dc:creator>DJ</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[ExtJS]]></category>

		<guid isPermaLink="false">http://www.djsipe.com/?p=82</guid>
		<description><![CDATA[This took me a while to figure out so I thought I would post it here just in case it may help someone else. One of the challenges of using any of those nifty widgets that ship with our favorite JavaScript frameworks is getting around CSS style conflicts.  A lot of times, widgets created by [...]]]></description>
			<content:encoded><![CDATA[<p><em>This took me a while to figure out so I thought I would post it here just in case it may help someone else.</em></p>
<p>One of the challenges of using any of those nifty widgets that ship with our favorite JavaScript frameworks is getting around CSS style conflicts.  A lot of times, widgets created by framework developers will rely on custom style sheets to style their UI elements.  Since I&#8217;m old fashioned and like to code my own style sheets, it can be very frustrating when a framework&#8217;s style sheet overrides some of my own styles elsewhere on the page.</p>
<p>To get around this in ExtJS, you have to use the &#8220;scoped&#8221; stylesheet that ships with ExtJS and do a little footwork with the JavaScript:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;head&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;js/libs/ext/4.0.2a/resources/css/ext-all-scoped.css&quot;&gt;
    ...
</pre>
<p>This style sheet will only apply ExtJS&#8217;s styling to elements that are inside an element with the class <code>x-reset</code>.  That&#8217;s great but what isn&#8217;t clear is that once you load <code>ext-all.js</code>, it will automatically apply that <code>x-reset</code> class to the <code>html</code> element. To get around this you&#8217;ll need to tell the <code>Ext</code> object not to apply this class by actually defining the <code>Ext</code> object before it&#8217;s created by the ExtJS code itself:</p>
<pre class="brush: xml; title: ; notranslate">
    ...
    &lt;script&gt;
        // Here we define Ext for the first time
        Ext = {
            buildSettings:{
                &quot;scopeResetCSS&quot;: true  // Thanks, but I'll do my own scoping please
            }
        };
    &lt;/script&gt;
    &lt;script src=&quot;js/libs/ext/4.0.2a/ext-all-debug.js&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
</pre>
<p>When <code>Ext</code> loads, it actually looks to see if an <code>Ext</code> object has already been defined and if so, treats its values like a config object.  So by setting the <code>buildSettings</code> value before <code>Ext</code> loads you are telling the future <code>Ext</code> object that you&#8217;re going to handle scoping the CSS yourself and it can just chill out&#8212;go have a Coke or something.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.djsipe.com/2011/07/08/scoping-extjs-css/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Why I Don&#8217;t Like ExtJS</title>
		<link>http://blog.djsipe.com/2011/07/07/why-i-dont-like-extjs/</link>
		<comments>http://blog.djsipe.com/2011/07/07/why-i-dont-like-extjs/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 00:14:22 +0000</pubDate>
		<dc:creator>DJ</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[progressive enhancement]]></category>

		<guid isPermaLink="false">http://www.djsipe.com/?p=59</guid>
		<description><![CDATA[From time to time at work, I feel like the only person in the world who doesn&#8217;t have a big soft spot in their heart for ExtJS.  Each time it&#8217;s vaunted as the Swiss Army Knife of UI development I can&#8217;t help but object.  I will say that ExtJS is a top-notch library with tons [...]]]></description>
			<content:encoded><![CDATA[<p>From time to time at work, I feel like the only person in the world who doesn&#8217;t have a big soft spot in their heart for <a title="Why would you need this?" href="http://dev.sencha.com/deploy/ext-4.0.2a/examples/desktop/desktop.html" target="_blank">ExtJS</a>.  Each time it&#8217;s vaunted as the Swiss Army Knife of UI development I can&#8217;t help but object.  I will say that ExtJS is a top-notch library with tons of amazing features, but what I take issue with is when it&#8217;s implemented as a replacement for traditional UI design and markup.</p>
<p>When you are writing your UI entirely in JavaScript, something is wrong.  Not only are you pushing the browser to generate a daunting amount of HTML through code, you&#8217;re also completely depending on JavaScript for anything to work on your site.  It&#8217;s <a href="http://www.alistapart.com/articles/understandingprogressiveenhancement" target="_blank">Progressive Enhancement</a> cryptonite.</p>
<p>To be fair, there are some reasons why you might use ExtJS for your UI:  You can get projects up and running much faster and in some groups where there isn&#8217;t a strong designer you can actually improve the consistency and look and feel of your applications.  Outside of these scenarios, I much prefer libraries like<a href="http://jquery.com/" target="_blank"> jQuery</a> that focus on building upon the existing markup of the page rather than writing the markup for the page.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.djsipe.com/2011/07/07/why-i-dont-like-extjs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Doing Pop-Ups the Right Way with jQuery</title>
		<link>http://blog.djsipe.com/2008/07/04/doing-pop-ups-the-right-way-with-jquery/</link>
		<comments>http://blog.djsipe.com/2008/07/04/doing-pop-ups-the-right-way-with-jquery/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 18:57:17 +0000</pubDate>
		<dc:creator>DJ</dc:creator>
				<category><![CDATA[Front End]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[popup]]></category>

		<guid isPermaLink="false">http://www.djsipe.com/2008/07/04/doing-pop-ups-the-right-way-with-jquery/</guid>
		<description><![CDATA[We&#8217;ve all seen them, links that look like they go somewhere but when you roll your mouse over them you see something like &#8220;javascript:popupWindow();&#8221; in the status bar instead of a URL. Putting JavaScript into the href of links is just a horrible idea as it severely degrades the accessibility of your site (and ticks [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all seen them, links that look like they go somewhere but when you roll your mouse over them you see something like &#8220;javascript:popupWindow();&#8221; in the status bar instead of a URL. Putting JavaScript into the href of links is just a horrible idea as it severely degrades the accessibility of your site (and ticks off people like me who want to see where they&#8217;re about to be taken before they click). But rather than just complain about it, I thought I&#8217;d put together some code to help us all avoid this situation all together.</p>
<p>The ideal solution is one that will work for the greatest number of users. Given that, we need a solution that will use <a href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript" target="_blank">unobtrusive JavaScript</a> to enhance a standard HTML page with customizable popup windows&#8212;rather than rely solely on JavaScript. Since straight-up HTML supports opening links in new windows by <a href="http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/target.html" target="_blank">adding a target attribute to the link</a>, we start off with a link that looks like this:</p>
<pre class="brush: xml; title: ; notranslate">&lt;a href=&quot;/popup.html&quot; target=&quot;popupWindow&quot; class=&quot;popup&quot;&gt;Open new window&lt;/a&gt;</pre>
<p>Using this as a starting point, the next step is to create a simple popup window function that wraps the standard DOM method: <a href="http://developer.mozilla.org/en/docs/DOM:window.open" target="_blank">window.open()</a>.  I use this function to do a few things:</p>
<ol>
<li>Enforce default parameters rather than depend on the browser&#8217;s defaults</li>
<li>Provide defaults that favor greater accessibility, ie: scrollbars and resize</li>
<li>Allow a <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Literals#Object_Literals" target="_blank">JavaScript object literal</a> to be used instead of the standard configuration string</li>
</ol>
<p>Here&#8217;s the function:</p>
<pre class="brush: jscript; title: ; notranslate">
// Create a namespace for our utilities
var UTIL = UTIL || {};
UTIL.popup = UTIL.popup || {};

/**
 * Open popup window
 *
 * Opens a popup window using as little as a URL. An optional params object can
 * be passed.
 *
 * @param {String} href
 * @param {Object} params
 * @return {WindowObjectReference}
 */
UTIL.popup.open = function (href, params) {
	// Defaults (don't leave it to the browser)
	var defaultParams = {
		&quot;width&quot;:       &quot;800&quot;,   // Window width
		&quot;height&quot;:      &quot;600&quot;,   // Window height
		&quot;top&quot;:         &quot;0&quot;,     // Y offset (in pixels) from top of screen
		&quot;left&quot;:        &quot;0&quot;,     // X offset (in pixels) from left side of screen
		&quot;directories&quot;: &quot;no&quot;,    // Show directories/Links bar?
		&quot;location&quot;:    &quot;no&quot;,    // Show location/address bar?
		&quot;resizeable&quot;:  &quot;yes&quot;,   // Make the window resizable?
		&quot;menubar&quot;:     &quot;no&quot;,    // Show the menu bar?
		&quot;toolbar&quot;:     &quot;no&quot;,    // Show the tool (Back button etc.) bar?
		&quot;scrollbars&quot;:  &quot;yes&quot;,   // Show scrollbars?
		&quot;status&quot;:      &quot;no&quot;     // Show the status bar?
	};

	var windowName = params[&quot;windowName&quot;] || &quot;new_window&quot;;

	var i, useParams = &quot;&quot;;

	// Override defaults with custom values while we construct the params string
	for (i in defaultParams) {
		useParams += (useParams === &quot;&quot;) ? &quot;&quot; : &quot;,&quot;;
		useParams += i + &quot;=&quot;;
		useParams += params[i] || defaultParams[i];
	}

	return window.open(href, windowName, useParams);
};
</pre>
<p>Admittedly, this part isn&#8217;t rocket science and could probably be done in a more elegant way, but it&#8217;s needed to really open things up for the next part.  Now we get to the fun stuff.  Using <a title="jQuery" href="http://jquery.com/" target="_blank">jQuery</a>, we search the document for all links that have a CSS class of &#8220;popup&#8221;.  For each one we find, we add an <a href="http://developer.mozilla.org/en/docs/onclick" target="_blank">onClick handler</a>that disables the browser&#8217;s default onClick behavior for links and then opens up a popup window using the links href attribute.  Here&#8217;s the code:</p>
<pre class="brush: jscript; title: ; notranslate">
$(function(){ // Run this code when the document's done loading

    // Apply this code to each link with class=&quot;popup&quot;
    $(&quot;a.popup&quot;).each(function (i){

        // Add an onClick behavior to this link
        $(this).click(function(event) {

            // Prevent the browser's default onClick handler
            event.preventDefault();

            // Grab parameters using jQuery's data() method
            var params = $(this).data(&quot;popup&quot;) || {};

            // Use the target attribute as the window name
            if ($(this).attr(&quot;target&quot;)) {
               params.windowName = $(this).attr(&quot;target&quot;);
            }

            // Pop up the window
            var windowObject = UTIL.popup.open(this.href, params);

            // Save the window object for other code to use
            $(this).data(&quot;windowObject&quot;, windowObject);
        });
    });
});
</pre>
<p>One of the great features of jQuery that we utilize here is the <a title="jQuery's data() method" href="http://docs.jquery.com/Core/data" target="_blank">data method</a>.  This allows us to attach data to DOM elements without corrupting the HTML with non-standard attributes or tags.  Using jQuery&#8217;s ability to locate DOM elements using CSS selectors, we can bind the custom configuration object (used in our new popup function) to the links themselves.  Then, when a link is clicked, it can read it&#8217;s popup configuration and pass it to the popup window function.  In this way, we can keep our HTML standards compliant <em>and </em>completely separate from our JavaScript code.</p>
<p>Putting it all together, we can create an HTML page like this:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
		&lt;title&gt;Popup Window Test&lt;/title&gt;
		&lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.2.6.pack.js&quot;&gt;&lt;/script&gt;
		&lt;script type=&quot;text/javascript&quot; src=&quot;utils.js&quot;&gt;&lt;/script&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;ul&gt;
			&lt;li&gt;
				This link uses defaults:
				&lt;a href=&quot;http://google.com&quot; target=&quot;google&quot; class=&quot;popup&quot;&gt;Google.com&lt;/a&gt;
			&lt;/li&gt;
			&lt;li&gt;
				This link uses custom parameters:
				&lt;a id=&quot;custom-popup&quot; href=&quot;http://yahoo.com&quot; target=&quot;yahoo&quot; class=&quot;popup&quot;&gt;Yahoo.com&lt;/a&gt;
			&lt;/li&gt;
		&lt;/ul&gt;
		&lt;script type=&quot;text/javascript&quot;&gt;

			// Add custom pop-up properties to the second link
			$(&quot;a#custom-popup&quot;).data(&quot;popup&quot;, {width:400,height:400, top:200, left:200});

		&lt;/script&gt;
	&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>If you would like to download this example, you can get it <a href="https://com.djsipe.s3.amazonaws.com/demos/popup-test.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.djsipe.com/2008/07/04/doing-pop-ups-the-right-way-with-jquery/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>My First Plugin</title>
		<link>http://blog.djsipe.com/2008/01/31/my-first-plugin/</link>
		<comments>http://blog.djsipe.com/2008/01/31/my-first-plugin/#comments</comments>
		<pubDate>Fri, 01 Feb 2008 03:07:32 +0000</pubDate>
		<dc:creator>DJ</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[code face]]></category>
		<category><![CDATA[progressive enhancement]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[yui]]></category>

		<guid isPermaLink="false">http://www.djsipe.com/2008/01/31/my-first-plugin/</guid>
		<description><![CDATA[After a few posts where I wanted to include code examples, I quickly became frustrated with the standard &#60;pre&#62; display that the folks at WordPress recommend. I looked for a plugin that worked well, but didn&#8217;t like what I was seeing. So at the prodding of my colleague, Pat Doran, I decided to roll my [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.djsipe.com/code-face-plugin"><img style="margin: 0pt 10px 10px 0pt;" src="http://wordpress.plugin.codeface.s3.amazonaws.com/code-face.gif" alt="Code Face" width="263" height="145" align="left" /></a>After a few posts where I wanted to include code examples, I quickly became frustrated with the standard &lt;pre&gt; display that the folks at WordPress <a href="http://codex.wordpress.org/Writing_Code_in_Your_Posts" target="_blank">recommend</a>. I looked for a plugin that worked well, but didn&#8217;t like what I was seeing. So at the prodding of my colleague, <a href="http://rockland-ave.com/blog/" target="_blank">Pat Doran</a>, I decided to roll my own plugin.</p>
<p>The result is my &#8220;<a href="http://www.djsipe.com/code-face-plugin">Code Face</a>&#8221; plugin. It uses the <a href="http://developer.yahoo.com/yui/" target="_blank">YUI</a> JavaScript framework to scan your posts and replace specially tagged &lt;pre&gt; blocks with rich code syntax highlighting via the <a href="http://code.google.com/p/syntaxhighlighter/" target="_blank">syntaxhighlighter</a> utility. Ninety-nine percent of the plugin is written in JavaScript using the concept of <a href="http://en.wikipedia.org/wiki/Progressive_enhancement" target="_blank">progressive enhancement</a>. That means that even if your readers have JavaScript turned off or are using a screen reader, the content of your post is still highly accessible.</p>
<p><a href="http://www.djsipe.com/code-face-plugin">Check it out</a> and let me know what you think. I&#8217;d love to hear your comments.</p>
<p><strong>Update: </strong>This version of Code Face is now on <a href="https://github.com/djsipe/Code-Face" target="_blank">Github</a>.  Hope to have an easier to use version update soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.djsipe.com/2008/01/31/my-first-plugin/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Click to Activate and Use This Control</title>
		<link>http://blog.djsipe.com/2008/01/20/click-to-activate-and-use-this-control/</link>
		<comments>http://blog.djsipe.com/2008/01/20/click-to-activate-and-use-this-control/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 01:33:00 +0000</pubDate>
		<dc:creator>DJ</dc:creator>
				<category><![CDATA[Front End]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[ie]]></category>

		<guid isPermaLink="false">http://www.djsipe.com/2008/01/20/click-to-activate-and-use-this-control/</guid>
		<description><![CDATA[Ever get that annoying &#8220;Click to activate and use this control&#8221; message in IE when you embed a Flash movie? I did and couldn&#8217;t find a solution that worked as well as I&#8217;d like. A quick browse of my Google results brought be here, but the solution there was kinda sloppy in my opinion. But [...]]]></description>
			<content:encoded><![CDATA[<p>Ever get that annoying &#8220;Click to activate and use this control&#8221; message in IE when you embed a Flash movie?  I did and couldn&#8217;t find a solution that worked as well as I&#8217;d like.  A quick browse of my Google results brought be <a href="http://www.mix-fx.com/flash-prompt.htm" target="_blank">here</a>, but the solution there was kinda sloppy in my opinion.  But with a few tweaks, I got things working&#8230;and with the added street cred&#8217; of not introducing a single global variable.</p>
<p>Here&#8217;s the code:</p>
<pre class="js-codeface">
(function()
{
    var clear = function(a)
    {
        for(var i=0; i &lt; a.length; i++)
        {
            a[i].outerHTML=a[i].outerHTML;
        }
    };

    clear(document.getElementsByTagName("object"));
    clear(document.getElementsByTagName("embed"));
})();</pre>
<p>The original code I found only applied the fix to <code>object</code> tags.  But since use of the <code>object</code> tag is becoming deprecated, we also need to touch the <code>embed</code> tags as well.  The code above does both and is wrapped in an anonymous function to keep all is private bits private.</p>
<p>Finally, since this is an IE-only fix, we should make use of IE&#8217;s <a href="http://www.quirksmode.org/css/condcom.html" target="_blank">conditional comments</a> so other browsers don&#8217;t have to be bothered by the script.  Assuming we placed (a <a href="http://javascript.crockford.com/jsmin.html" target="_blank">minified</a> version of) the code into a file named <code>controlFix.js</code>, we then add the following code at the end of the source code:</p>
<pre class="html-codeface">&lt;!--[if IE]&gt;
&lt;script type="text/javascript" src="controlFix.js"&gt;&lt;/script&gt;
&lt;![endif]--&gt;</pre>
<p>If you&#8217;d like to use this on your site, you can download the minified JavaScript <a href="https://djsipe.code.s3.amazonaws.com/controlFix.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.djsipe.com/2008/01/20/click-to-activate-and-use-this-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

