<?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>Extraordinary Thoughts</title>
	<atom:link href="http://extraordinarythoughts.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://extraordinarythoughts.com</link>
	<description>My World, My Blog!</description>
	<lastBuildDate>Tue, 14 Feb 2012 03:18:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>jQuery &amp; Multi-touch: Getting Started</title>
		<link>http://extraordinarythoughts.com/2012/02/13/jquery-multi-touch-getting-started/</link>
		<comments>http://extraordinarythoughts.com/2012/02/13/jquery-multi-touch-getting-started/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 03:18:26 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://extraordinarythoughts.com/?p=349</guid>
		<description><![CDATA[It&#8217;s been about a month since my last update, well I have some fun treats for everyone this time.  Let&#8217;s enter the world of mobile &#38; touch devices.  Over the past month I&#8217;ve been working on some touch devices and &#8230; <a href="http://extraordinarythoughts.com/2012/02/13/jquery-multi-touch-getting-started/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been about a month since my last update, well I have some fun treats for everyone this time.  Let&#8217;s enter the world of mobile &amp; touch devices.  Over the past month I&#8217;ve been working on some touch devices and have released a couple scripts to accelerate development on such devices.</p>
<p>There are a few things to keep in mind:</p>
<ul>
<li>Touch events are treated as the same event for each touch.</li>
<li>Touch events do not coincide with mouse events, except on mobile devices.</li>
<li>Currently, no stable release of a desktop browser supports touch events.</li>
<li>IE10 will not support touch events as standardized by W3C.  (<a href="http://blogs.msdn.com/b/ie/archive/2011/09/20/touch-input-for-ie10-and-metro-style-apps.aspx">read more</a>)</li>
</ul>
<p>Well, now that you know [some] of what you&#8217;d be dealing with, you may understand why multi-touch platforms could be potentially cumbersome.  Web pages have been designed with one &#8220;pointer&#8221;, the mouse, in mind.  With one pointer you don&#8217;t have to manage touch events around multiple pointer inputs &#8211; so what happens when you start porting drag &amp; drop code to multi-touch interfaces?  You get interference from other pointers.</p>
<h1>Solution #1: jqTouchEvents</h1>
<p>Well, I&#8217;ve got a simple solution for all of this called <a href="https://github.com/skhameneh/jqTouchEvents">jqTouchEvents</a>.  jqTouchEvents is a jQuery library designed to accelerate development of multitouch applications by allowing touch events to take exclusive control of an interacting element.  What does this mean?  You can prevent elements from responding to more than one touch event at a time.</p>
<p>Here&#8217;s a drag &amp; drop example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> startPoint<span style="color: #339933;">,</span> startPosition<span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> $dragElement <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.dragElement'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> processMove <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>touch<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>		
		$dragElement.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
			marginLeft<span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>touch.<span style="color: #660066;">pageX</span> <span style="color: #339933;">-</span> startPoint.<span style="color: #660066;">pageX</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> startPosition.<span style="color: #660066;">left</span><span style="color: #339933;">,</span>
			marginTop<span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>touch.<span style="color: #660066;">pageY</span> <span style="color: #339933;">-</span> startPoint.<span style="color: #660066;">pageY</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> startPosition.<span style="color: #660066;">top</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	$dragElement.<span style="color: #660066;">exclusiveTouch</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		anyEl<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// Invoke move and end for the touch holding the element exclusively regardless of the target</span>
		start<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>touch<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">// Grab starting touch point</span>
			startPoint <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>pageX<span style="color: #339933;">:</span> touch.<span style="color: #660066;">pageX</span><span style="color: #339933;">,</span> pageY<span style="color: #339933;">:</span> touch.<span style="color: #660066;">pageY</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// Grab current position of element</span>
			startPosition <span style="color: #339933;">=</span> $dragElement.<span style="color: #660066;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		move<span style="color: #339933;">:</span> processMove<span style="color: #339933;">,</span>
		end<span style="color: #339933;">:</span> processMove <span style="color: #006600; font-style: italic;">// Call again when touch ends, for precision</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>Solution #2: clickTouch.js</h1>
<p>This is an easy one, if you want the mouse to act like a touch input, I&#8217;ve create a script for that called <a href="https://github.com/skhameneh/clickTouch.js">clickTouch.js</a>.  It only needs to be included in your project and initialized.  You can also pass the boolean &#8220;true&#8221; if you wish to block all mouse events and only invoke touch events from the mouse.</p>
<p>Usage:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	clickTouch.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>&nbsp;</p>
<p><strong>Stay tuned, I&#8217;ll have more coming soon&#8230;</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://extraordinarythoughts.com/2012/02/13/jquery-multi-touch-getting-started/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Native Browser Wrapper with HTML5 &amp; CSS3</title>
		<link>http://extraordinarythoughts.com/2012/01/12/browser-wrapper-with-html5-css3/</link>
		<comments>http://extraordinarythoughts.com/2012/01/12/browser-wrapper-with-html5-css3/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 03:52:29 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Misc Development]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://extraordinarythoughts.com/?p=340</guid>
		<description><![CDATA[This blog is due for an update and I&#8217;ve got a good one finally.  There&#8217;s this open-source project called OpenWebKitSharp that&#8217;s so heavily underrated, it&#8217;s ridiculous.  Apparently it&#8217;s run by GT Web Software, which is surprising &#8212; I don&#8217;t mean to undercut &#8230; <a href="http://extraordinarythoughts.com/2012/01/12/browser-wrapper-with-html5-css3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This blog is due for an update and I&#8217;ve got a good one finally.  There&#8217;s this open-source project called <a href="http://code.google.com/p/open-webkit-sharp/">OpenWebKitSharp</a> that&#8217;s so heavily underrated, it&#8217;s ridiculous.  Apparently it&#8217;s run by GT Web Software, which is surprising &#8212; I don&#8217;t mean to undercut them, but their projects are great, they just don&#8217;t look like much at first glance.  They have something truly valuable to many developers on their hands and I don&#8217;t think they even realize it.</p>
<p>Now back to reality, OpenWebKitSharp is just a wrapper for WebKit to be used in [C#] .Net, it&#8217;s nothing unexpectedly original except for the fact there&#8217;s very little like it.  You have one commercial solution called <a href="http://awesomium.com/">Awesomium</a> (almost $3k for a license? that insane for new ventures for a medium sized company) and then another called <a href="http://berkelium.org/">Berkelium</a> (looks great, but interfaces directly with Chromium).</p>
<p>So why do I chose OpenWebKitSharp?</p>
<ul>
<li>No ridiculous licensing.  Though Awesomium may be great to look at for the future, but too costly for a new venture.</li>
<li>It interfaces directly with WebKit nighties, I know for a fact the browser itself can&#8217;t be easily hijacked.  I&#8217;m not saying Berkelium in insecure, but it definitely looks to add another layer rather than creating it&#8217;s own rendition of the browser document.</li>
<li>I can download the code and have an easily-understood example up and running in minutes.  There&#8217;s a solution in their sources prepackaged for Visual Studio.</li>
<li>HTML5 &amp; CSS3 Support!  You have all the latest features of the WebKit engine, essentially it&#8217;s the same as running Chrome or Safari!</li>
<li>It&#8217;s simple!</li>
</ul>
<div>Lastly, why would anyone want this?  It allows a controlled browser environment.  This can be used for a number of applications in which the developer desires to use web technologies to build applications that look and feel native to Windows.  It&#8217;s an easy alternative to Adobe Air and other related technologies.</div>
]]></content:encoded>
			<wfw:commentRss>http://extraordinarythoughts.com/2012/01/12/browser-wrapper-with-html5-css3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ExtJS 4 Loader Tips &amp; Tricks</title>
		<link>http://extraordinarythoughts.com/2011/11/09/extjs-4-loader-tips-tricks/</link>
		<comments>http://extraordinarythoughts.com/2011/11/09/extjs-4-loader-tips-tricks/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 03:32:45 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://extraordinarythoughts.com/?p=320</guid>
		<description><![CDATA[The Loader component in ExtJS 4 is great, but there&#8217;s a few quirks.  I thought I&#8217;d share for anyone else who may be running into issues similar to what I encountered. Tip #1: Fix &#8220;disappearing&#8221; breakpoints. Just because Ext disabled &#8230; <a href="http://extraordinarythoughts.com/2011/11/09/extjs-4-loader-tips-tricks/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The Loader component in ExtJS 4 is great, but there&#8217;s a few quirks.  I thought I&#8217;d share for anyone else who may be running into issues similar to what I encountered.</p>
<h1>Tip #1: Fix &#8220;disappearing&#8221; breakpoints.</h1>
<p>Just because Ext disabled sends and extra parameter (&#8220;disableCachingParam&#8221; or &#8220;_dc&#8221;) to prevent caching, just about every browser loses breakpoints on page refresh. You might also want to install some cache clearing tools for your browser too, I could not get my scripts to clear from cache with just a refresh. (even hard refresh wont do)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">Loader</span>.<span style="color: #660066;">setConfig</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	disableCaching<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>Tip #2: Don&#8217;t forget to define!</h1>
<p>Be sure to define a class for each script you load. I&#8217;ve found not doing so can cause Ext to lock up on occassion. It won&#8217;t throw an error and it won&#8217;t freeze the browser, it will just stop running certain parts of code. This is especially good to know if you wish to auto-load oddly named overrides.</p>
<h1>Tip #3: Test your code by auto-loading.</h1>
<p>Auto-loading will always create excess http requests over loading one condensed script, but you can still use it for testing code structure. If your code isn&#8217;t structured (namespaced) properly it can still work perfectly when included, but will fail to auto-load. Just by testing your code with auto-loading, you can verify all file names and class definitions are correct.</p>
<p>Note: This post was sitting in my drafts awaiting additions for some time, not sure of anything to add, so *post*. <img src='http://extraordinarythoughts.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://extraordinarythoughts.com/2011/11/09/extjs-4-loader-tips-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I Hate Dreamweaver</title>
		<link>http://extraordinarythoughts.com/2011/08/26/why-i-hate-dreamweaver/</link>
		<comments>http://extraordinarythoughts.com/2011/08/26/why-i-hate-dreamweaver/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 04:03:05 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[complaints]]></category>
		<category><![CDATA[Dreameaver]]></category>
		<category><![CDATA[IDE]]></category>

		<guid isPermaLink="false">http://extraordinarythoughts.com/?p=254</guid>
		<description><![CDATA[I hate Dreamweaver. It seems everyone and their dog can use Dreamweaver these days, and that&#8217;s great.  For me, this is all about the fight against Dreamweaver and most IDE&#8217;s.  Did I just say most?  I meant just about every &#8230; <a href="http://extraordinarythoughts.com/2011/08/26/why-i-hate-dreamweaver/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I hate Dreamweaver. It seems everyone and their dog can use Dreamweaver these days, and that&#8217;s great.  For me, this is all about the fight against Dreamweaver and most IDE&#8217;s.  Did I just say most?  I meant just about every IDE out there, especially most mainstream IDE&#8217;s like Dreamweaver.</p>
<p>To set things clear, this article is also about the general concept of most IDE&#8217;s in general.  Why did I pick Dreamweaver?  Well, apparently <a href="http://www.akawebdesign.com/2009/05/20/why-i-hate-dreamweaver/">Arthur Kay</a> doesn&#8217;t think I can possibly out-hate Dreamweaver more than him.  I&#8217;m here to prove him wrong and claim my delicious beer.  Yes, Art, I want that beer.  That, oh, so delicious Dreamweaver-free beer.</p>
<p>Now that you understand where I&#8217;m coming from, let&#8217;s begin. It&#8217;s clear, I hate Dreamweaver. Let&#8217;s start off with the word &#8220;hate&#8221;, as defined in the <a href="http://www.merriam-webster.com/dictionary/hate">Merrian-Webster</a> dictionary.</p>
<blockquote><p><strong>\ˈhāt\</strong> : intense hostility and aversion usually deriving from fear, anger, or sense of injury.</p></blockquote>
<p>That about sums up how I feel; intense hostility. I most definitely feel hostile towards Dreamweaver, I&#8217;ve gone through the trouble of expressing how much I hate it in the form of writing. That takes patience, but mostly anger.</p>
<p>So, I hate Dreamweaver, but why?</p>
<p><span id="more-254"></span></p>
<ul>
<li>
<h2>Embraces poor code.</h2>
<p>I hate how Dreamweaver does this, just about every WSIWYG editor does. I have yet to see such an editor create external stylesheets. I&#8217;ll hand it to recent versions of Dreamweaver for creating and managing styles for you, but I really don&#8217;t see much of an advantage over hand coding.  However good the style management may be, Dreamweaver is still encouraging bad practice.  I hate opening up sources and finding styles embedded in each and every page!</li>
<li>
<h2>Why use it</h2>
<p>I just don&#8217;t understand why anyone would use an IDE that does anything more than syntax completion, code hinting, and manage/deploy versions. It just doesn&#8217;t make sense, with the way Dreamweaver is designed, if I have to use it, I only use it as a text editor. Seriously, for the longest time my editor of choice was Notepad++.  Even Adobe removed portions of WYSIWYG from recent releases of Dreamweaver.  I&#8217;m convinced even Adobe employees hate old versions of Dreamweaver.</li>
<li>
<h2>W3C Incompatible</h2>
<p>Even if most of Dreamweaver (in recent versions) complies with W3C standards, the last time I looked some CSS properties list weren&#8217;t standard. If the IDE is going to suggest properties, at least alert me it&#8217;s not cross compatible.  It&#8217;s terrible to use non-standard CSS if you don&#8217;t know what you&#8217;re doing and Dreamweaver needs to stop encouraging it.</li>
<li>
<h2>The same DOCTYPE!?.</h2>
<p>For some weird reason, Dreamweaver doesn&#8217;t prompt you on the DOCTYPE. I hate how Dreamweaver just assumes you want xHTML, why? Maybe I want HTML 4.01 transitional or even HTML5. I think you can configure Dreamweaver to use a different DOCTYPE, but what&#8217;s the point of doing that every time you want to switch.  I can&#8217;t stand how Dreamweaver does that, I want to chose my own DOCTYPE!</li>
<li>
<h2>WYSIWYG + Dynamic Pages, Not Happening</h2>
<p>I hate that all WYSIWYG editors just don&#8217;t work with dynamic content. It&#8217;s just not possible. Even worse, the WYSIWYG doesn&#8217;t render the same as any browser. Try working with &#8220;fixed&#8221; positioning, not gonna happen. Yes, Dreamweaver, your WYSIWYG editor sucks just like every other and I hate it.</li>
<li>
<h2>It doesn&#8217;t always work</h2>
<p>Just like any other software, the more it does the more opportunity for issues. Take <a href="http://crappysw.blogspot.com/2007/08/i-love-dreamweaver-except-when-it-acts.html">Jeremy Butler</a>, for instance, he&#8217;s been complaining about how he hates when Dreamweaver just errors out seemingly without a reason. It seems it was caused by Javascript syntax parsing, but who knows. For me that&#8217;s another reason to hate large IDE&#8217;s.</li>
</ul>
<p>There you have it, just a few of many reasons I hate Dreamweaver just like every other IDE. All I really need is a nice text editor; I do like code completion, but I have yet to find one that works flawlessly with all libraries and languages I work with. You may be thinking &#8220;We know why you hate Dreamweaver, but you must be using some IDE&#8221;. Well, yes, I do use an IDE. My favorites to date are Aptana, Xcode, Coda, and Notepad++. I use Visual Studio just for ease of .Net development. Don&#8217;t even get me started on why I hate .Net. Do you hate Dreamweaver too? Feel free to join in the ranting below. I don&#8217;t mind discussing more reasons for why I hate Dreamweaver.</p>
<p>Care to keep reading?  Here&#8217;s some related links, see why Dreamweaver is driving other people mad too!</p>
<ul>
<li><a href="https://www.facebook.com/group.php?gid=29944723900">I Hate Dreamweaver Facebook Group</a></li>
<li><a href="http://codewords.wordpress.com/2007/02/28/sorry-ben-but-i-hate-dreamweaver/">List of [old] Dreamweaver alternatives and missing features</a></li>
<li><a href="http://www.osalt.com/dreamweaver">List of open-source alternatives to Dreamweaver</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://extraordinarythoughts.com/2011/08/26/why-i-hate-dreamweaver/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Injecting jQuery: Just for Fun</title>
		<link>http://extraordinarythoughts.com/2011/08/25/injecting-jquery-just-for-fun/</link>
		<comments>http://extraordinarythoughts.com/2011/08/25/injecting-jquery-just-for-fun/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 18:02:37 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://extraordinarythoughts.com/?p=249</guid>
		<description><![CDATA[I&#8217;ve put together a small snippet you can enter at the top of any page. Use it to inject the jQuery library into the page, and optionally run a small script of mine which will create a small debugging tool. &#8230; <a href="http://extraordinarythoughts.com/2011/08/25/injecting-jquery-just-for-fun/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve put together a small snippet you can enter at the top of any page. Use it to inject the jQuery library into the page, and optionally run a small script of mine which will create a small debugging tool. It&#8217;s like Firebug Lite, except much smaller and less useful.</p>
<p>Just type this into the address bar after you&#8217;ve loaded a page:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">,</span>s<span style="color: #339933;">,</span>ss<span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'http://extraordinarythoughts.com/toybox.js'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>for<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">!=</span>ss.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>s<span style="color: #339933;">=</span>document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>s.<span style="color: #660066;">src</span><span style="color: #339933;">=</span>ss<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>document.<span style="color: #660066;">body</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">void</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Want only jQuery? Use this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">,</span>s<span style="color: #339933;">,</span>ss<span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>for<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">!=</span>ss.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>s<span style="color: #339933;">=</span>document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>s.<span style="color: #660066;">src</span><span style="color: #339933;">=</span>ss<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>document.<span style="color: #660066;">body</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">void</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://extraordinarythoughts.com/2011/08/25/injecting-jquery-just-for-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ExtJS GridView autoFill &amp; forceFit</title>
		<link>http://extraordinarythoughts.com/2011/08/24/extjs-gridview-autofill-forcefit/</link>
		<comments>http://extraordinarythoughts.com/2011/08/24/extjs-gridview-autofill-forcefit/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 16:10:30 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[fixes]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://extraordinarythoughts.com/?p=239</guid>
		<description><![CDATA[It&#8217;s no surprise grid layouts can be tricky in ExtJS. After much struggle, I&#8217;d like to point out an obvious that isn&#8217;t well documented &#8211; ExtJS GridPanels scrollbars, and those scrollbars are always accounted for unless configured otherwise. If you &#8230; <a href="http://extraordinarythoughts.com/2011/08/24/extjs-gridview-autofill-forcefit/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s no surprise grid layouts can be tricky in ExtJS. After much struggle, I&#8217;d like to point out an obvious that isn&#8217;t well documented &#8211; ExtJS GridPanels scrollbars, and those scrollbars are always accounted for unless configured otherwise.</p>
<p>If you happen to be using autoFill &amp; forceFit with autoHeight, you&#8217;ll notice there&#8217;s still a gaping void of 10 pixels or so to the side of your columns, this is where scrollOffset comes in. scrollOffset is used to predict where a scrollbar would be, just set it to 0 and enjoy your new, nicely formatted, grid!  This also works with Ext.grid.EditorGridPanel, of course.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Perfect full-width columns!</span>
<span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">grid</span>.<span style="color: #660066;">GridPanel</span><span style="color: #009900;">&#123;</span>
	autoHeight<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
	viewConfig<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
		autoFill<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
		scrollOffset<span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://extraordinarythoughts.com/2011/08/24/extjs-gridview-autofill-forcefit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding jQuery Plugins</title>
		<link>http://extraordinarythoughts.com/2011/08/20/understanding-jquery-plugins/</link>
		<comments>http://extraordinarythoughts.com/2011/08/20/understanding-jquery-plugins/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 08:45:28 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://extraordinarythoughts.com/?p=182</guid>
		<description><![CDATA[If you&#8217;re here, I&#8217;m sure it&#8217;s no surprise jQuery is an easy library to use. jQuery may be easy, but it still has its quirks and can be difficult for some to grasp beyond basic functionality and concepts. No worries, &#8230; <a href="http://extraordinarythoughts.com/2011/08/20/understanding-jquery-plugins/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="size-medium wp-image-212" style="border: 0px;" title="jQuery Logo" src="http://extraordinarythoughts.com/wp-content/uploads/2011/08/jquery_logo_color_onwhite-300x73.png" alt="jQuery Logo" width="300" height="73" /></p>
<p>If you&#8217;re here, I&#8217;m sure it&#8217;s no surprise jQuery is an easy library to use. jQuery may be easy, but it still has its quirks and can be difficult for some to grasp beyond basic functionality and concepts. No worries, I&#8217;ve got a simple guide here to help break down code, that may seem like overly complex syntax, into simple thoughts and patterns that can be easily understood.</p>
<p>Here, we&#8217;ve got a basic plugin layout:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Shawn Khameneh</span>
<span style="color: #006600; font-style: italic;">// ExtraordinaryThoughts.com</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> privateFunction <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// code here</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> methods <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
		init<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> $this <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #003366; font-weight: bold;">var</span> settings <span style="color: #339933;">=</span> $this.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pluginName'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>settings<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
					<span style="color: #003366; font-weight: bold;">var</span> defaults <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
						propertyName<span style="color: #339933;">:</span> <span style="color: #3366CC;">'value'</span><span style="color: #339933;">,</span>
						onSomeEvent<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span>
&nbsp;
					settings <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> defaults<span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
					$this.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pluginName'</span><span style="color: #339933;">,</span> settings<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					settings <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> settings<span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #006600; font-style: italic;">// run code here</span>
&nbsp;
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		destroy<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">return</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> $this <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				$this.<span style="color: #660066;">removeData</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pluginName'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		val<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> someValue <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">return</span> someValue<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
	$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">pluginName</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> method <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>methods<span style="color: #009900;">&#91;</span>method<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			method <span style="color: #339933;">=</span> methods<span style="color: #009900;">&#91;</span>method<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			arguments <span style="color: #339933;">=</span> Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">slice</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>arguments<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>method<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'object'</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>method <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			method <span style="color: #339933;">=</span> methods.<span style="color: #660066;">init</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			$.<span style="color: #660066;">error</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'Method '</span> <span style="color: #339933;">+</span>  method <span style="color: #339933;">+</span> <span style="color: #3366CC;">' does not exist on jQuery.pluginName'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">return</span> method.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You may notice the structure I&#8217;ve provided is significantly different from others. Plugins can vary depending on usage and needs. Here, it is my goal to explain the concepts in code well enough for you to understand and author a plugin in such a way that suits you best.</p>
<p>So, let&#8217;s break it down!<br />
<span id="more-182"></span></p>
<h1>The Container: An Immediate Function</h1>
<p>Essentially every plugin is contained in an immediate function like so:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>arg1<span style="color: #339933;">,</span> arg2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #006600; font-style: italic;">// code</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>arg1<span style="color: #339933;">,</span> arg2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>An immediate function is, as its name insinuates, a function. What&#8217;s unique about it is it&#8217;s enclosure in parenthesis, this makes everything inside the function run within a local scope. This does not mean the DOM (global) is protected, but rather all public variables and object namespaces are inaccessible. This makes a perfect start for defining variables and objects to your hearts content without interfering with existing code.</p>
<p>Now since all public variables are inaccessible, that could be a problem seeing jQuery itself is, in fact, a public variable. Just like any function, immediate functions can be passed variables and objects are passed by reference. We can just pass jQuery into our immediate function like so:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #006600; font-style: italic;">// run some jQuery using $ symbol locally</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>So what I&#8217;m doing here is passing &#8220;jQuery&#8221; as a public variable into the immediate function where I can reference it locally (inside the container) as &#8220;$&#8221;. In other words I&#8217;m calling the container as a function and passing jQuery as an argument. This also allows for compatibility with Prototype, since the public variable I am referencing is &#8220;jQuery&#8221; rather than it&#8217;s shortcode &#8220;$&#8221;. If you don&#8217;t use Prototype or any other library using &#8220;$&#8221; as a shortcode it isn&#8217;t as relevant but still good to know.</p>
<h1>The Plugin: A Function</h1>
<p>Every jQuery plugin is essentially a large function we shove into the jQuery namespace, while we can easily assign our function using &#8220;jQuery.pluginName = function&#8221;, but if we do so our plugin&#8217;s code isn&#8217;t protected. &#8220;jQuery.fn&#8221; is a shortcode to &#8220;jQuery.prototype&#8221;, meaning it can only be read (and not modified) when using the jQuery namespace to access it. What purpose does this actually serve you? Not much other than writing your code properly and understanding protecting your code from unwanted runtime modification. Best said, it&#8217;s just good practice!</p>
<p>We&#8217;ve got a basic jQuery function via a plugin:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">pluginName</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// code here</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The above code function can be run just like any other jQuery function using &#8220;$(&#8216;#element&#8217;).pluginName()&#8221;. Notice how I include &#8220;return this;&#8221;; this small piece of code allows chainability by returning the original elements (contained in &#8220;this&#8221;) wrapped in a jQuery object. You should also note that &#8220;this&#8221; within this particular scope is a jQuery object, the equivalence of &#8220;$(&#8216;#element&#8217;)&#8221;.</p>
<p>This could be summarized by stating the object returned, in the code above, by &#8220;$(&#8216;#element&#8217;).pluginName()&#8221; is exactly the same as &#8220;$(&#8216;#element&#8217;)&#8221;, and within your function&#8217;s immediate scope there is no need to wrap &#8220;this&#8221; into a jQuery object such as &#8220;$(this)&#8221; as it has already been done.</p>
<h1>Multiple Elements: Understanding Sizzle</h1>
<p>jQuery uses a selector engine called Sizzle, which supports selecting multiple elements (such as entire classes) for use with functions. This is one of the great features of jQuery, but it&#8217;s also something to be considered when developing a plugin. Even if you don&#8217;t anticipate grabbing multiple elements with your plugin, it&#8217;s still good practice to plan for such in the event.</p>
<p>Here I&#8217;ve added in a few pieces of code to account for and run code on multiple elements, individually:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// Add the plugin to the jQuery (protected, &quot;fn&quot;) namespace under &quot;pluginName&quot; as the function name.</span>
	$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">pluginName</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Return &quot;this&quot; (result of &quot;each&quot; is also &quot;this&quot;) to allow for chaining the plugin</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// code here, reference each individual element by &quot;this&quot;</span>
			<span style="color: #006600; font-style: italic;">// e.g. $(this).show();</span>
			<span style="color: #003366; font-weight: bold;">var</span> $this <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In this example, I&#8217;m not using &#8220;each()&#8221; to run code over each element I have in the selector. Within the function called by &#8220;each()&#8221; the individual element being processed can be referenced in the local scope by &#8220;this&#8221; and used as a jQuery object by &#8220;$(this)&#8221;. It&#8217;s also good practice to store the jQuery object you with to manipulate rather than calling &#8220;$(this)&#8221; each time you wish to run a function. Doing such is, of course, optional and not always needed; I have included it for good measure. Also note that we will be moving the &#8220;each()&#8221; command into our individual functions, this way we can return values when calling methods.</p>
<p>One example of this would be a plugin that supports a &#8220;val&#8221; method for returning a value:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#element'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pluginName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'val'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// Would return a value instead of a jQuery object</span></pre></div></div>

<h1>Functionality: Public &amp; Private Methods</h1>
<p>A basic function may work for some cases, but more complex plugins will require a various supply of methods and private functions. You may be tempted to use various namespaces to provide various methods for you plugin, but it&#8217;s best not to clutter your sources with excess namespaces.</p>
<p>The code snippet below defines a JSON object to store public methods and demonstrates how you can use your plugin&#8217;s primary function to determine which method needs calling and call that method on each element in the selector.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// Create a private function by creating a public variable within our plugin's container.</span>
	<span style="color: #003366; font-weight: bold;">var</span> privateFunction <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// code here</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// Create an object literal for our methods</span>
	<span style="color: #003366; font-weight: bold;">var</span> methods <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// Define individual methods within the literal</span>
		init<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// Repeat over each element in selector</span>
			<span style="color: #006600; font-style: italic;">// Taken from our main function and moved into each method for flexibility</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">// Create a jQuery object to use with this individual element</span>
				<span style="color: #003366; font-weight: bold;">var</span> $this <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #006600; font-style: italic;">// run code here</span>
				<span style="color: #006600; font-style: italic;">// e.g. privateFunction();</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		destroy<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">// Repeat over each element in selector</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">// run code here</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
	$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">pluginName</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// Grab our method, sadly if we used function(method){}, it ruins it all</span>
		<span style="color: #003366; font-weight: bold;">var</span> method <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Check if the passed method exists</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>methods<span style="color: #009900;">&#91;</span>method<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// If the method exists, store it for use</span>
			<span style="color: #006600; font-style: italic;">// Note: I am only doing this for repetition when using &quot;each()&quot;, later.</span>
			method <span style="color: #339933;">=</span> methods<span style="color: #009900;">&#91;</span>method<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// If the method is not found, check if the method is an object (JSON Object) or one was not sent.</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>method<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'object'</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>method <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// If we passed parameters as the first object or no arguments, just use the &quot;init&quot; methods</span>
			method <span style="color: #339933;">=</span> methods.<span style="color: #660066;">init</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// Not a method and not parameters, so return an error.  Something wasn't called correctly.</span>
			$.<span style="color: #660066;">error</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'Method '</span> <span style="color: #339933;">+</span>  method <span style="color: #339933;">+</span> <span style="color: #3366CC;">' does not exist on jQuery.pluginName'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Call our selected method</span>
		<span style="color: #006600; font-style: italic;">// Once again, note how we move the &quot;each()&quot; from here to the individual methods</span>
		<span style="color: #000066; font-weight: bold;">return</span> method.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Notice how I have placed &#8220;privateFunction&#8221; as a global. This is more than acceptable considering all is within the plugin&#8217;s container, therefore it&#8217;s only accessible to the scope of the plugin. In the plugin&#8217;s main function, I am checking if a method to be passed exists. If a method does not exist or the argument passed is an object, the &#8220;init&#8221; method is run. Lastly, if the argument passed is not an object and a method doesn&#8217;t exist, we send out an error.</p>
<p>Also note how each method I am using &#8220;this.each()&#8221;. When I am calling &#8220;method.call(this)&#8221; in the main function, &#8220;this&#8221; is in fact a jQuery object and is being passed into each method as &#8220;this&#8221;. So within our methods&#8217; immediate scope it is already a jQuery object. Only in our function being called by &#8220;each()&#8221; do we need to contain &#8220;this&#8221; in a jQuery object.</p>
<p>Here are some usage examples:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/* Please note that these cases match the code posted earlier in this section.
Not all plugin layouts will use the same code structure. */</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Call method &quot;init&quot; on each element matching &quot;.className&quot;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.className'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pluginName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.className'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pluginName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'init'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.className'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pluginName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'init'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Pass object &quot;{}&quot; to &quot;init&quot; as arguments</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.className'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pluginName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Pass object &quot;{}&quot; to &quot;init&quot; as arguments</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Call method &quot;destroy&quot; on each element matching &quot;.className&quot;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.className'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pluginName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'destroy'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.className'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pluginName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'destroy'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Pass object &quot;{}&quot; to &quot;destroy&quot; as arguments</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Also works</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.className'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pluginName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'init'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'argument1'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'argument2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Pass &quot;argument 1&quot; and &quot;argument 2&quot; to &quot;init&quot;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Incorrect</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.className'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pluginName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'nonexistantMethod'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.className'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pluginName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'nonexistantMethod'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.className'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pluginName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'argument 1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Will attempt to call &quot;argument 1&quot; as method</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.className'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pluginName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'argument 1'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'argument 2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Will attempt to call &quot;argument 1&quot; as method</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.className'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">pluginName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'privateFunction'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 'privateFunction' is not a method</span></pre></div></div>

<p>The above examples do show &#8220;{}&#8221;, which would represent arguments. While it will still work with the code in this section, the arguments will not be passed. Proceed to the next section for passing arguments.</p>
<h1>Plugin Settings: Passing Arguments</h1>
<p>Many plugins support passing parameters such as configurations and callbacks. You can pass information either by function arguments or by a JS object using key-value pairs. If your plugin supports more than one or two parameters, it&#8217;s best practice to pass parameters in an object.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> methods <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
		init<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// Repeat over each element in selector</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> $this <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #006600; font-style: italic;">// Create a default settings variable</span>
				<span style="color: #003366; font-weight: bold;">var</span> defaults <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
					propertyName<span style="color: #339933;">:</span> <span style="color: #3366CC;">'value'</span><span style="color: #339933;">,</span>
					onSomeEvent<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #006600; font-style: italic;">// Use extend to create settings from passed options and the defaults</span>
				<span style="color: #003366; font-weight: bold;">var</span> settings <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> defaults<span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #006600; font-style: italic;">// run code here</span>
&nbsp;
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
	$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">pluginName</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> method <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>methods<span style="color: #009900;">&#91;</span>method<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			method <span style="color: #339933;">=</span> methods<span style="color: #009900;">&#91;</span>method<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// Our method was sent as an argument, remove it using slice because it's not an argument for our method</span>
			arguments <span style="color: #339933;">=</span> Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">slice</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>arguments<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>method<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'object'</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>method <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			method <span style="color: #339933;">=</span> methods.<span style="color: #660066;">init</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			$.<span style="color: #660066;">error</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'Method '</span> <span style="color: #339933;">+</span>  method <span style="color: #339933;">+</span> <span style="color: #3366CC;">' does not exist on jQuery.pluginName'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Use apply to sent arguments when calling our selected method</span>
		<span style="color: #000066; font-weight: bold;">return</span> method.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As seen above, an &#8220;options&#8221; argument has been added to the functions and arguments also added to the main function. If a method has been declared, that method is also removed from the arguments before passing them to the method. I have swapped &#8220;call()&#8221; for &#8220;apply()&#8221;; &#8220;apply()&#8221; essentially does the same as &#8220;call()&#8221;, with support for passing arguments. This structure also supports more than one argument, if you wish to use such instead, just modify the arguments for you methods. e.g. &#8220;init: function(arg1, arg2) {}&#8221;</p>
<p>If using a JS object for parameters, you may want to define a defaults variable. Once a defaults variable has been declared, you want to use &#8220;$.extend&#8221; to merge values into a final parameter object (in this case, &#8220;settings&#8221;) for use.</p>
<p>To demonstrate, here are a few examples of logic:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> options <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	customParameter<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Test 1'</span><span style="color: #339933;">,</span>
	propertyName<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Test 2'</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> defaults <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	propertyName<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Test 3'</span><span style="color: #339933;">,</span>
	onSomeEvent<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Test 4'</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> settings <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> defaults<span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">/*
settings == {
	propertyName: 'Test 2',
	onSomeEvent: 'Test 4',
	customParameter: 'Test 1'
}
*/</span></pre></div></div>

<h1>Retaining Settings: Adding Persistant Data</h1>
<p>Sometimes you&#8217;ll want to retain settings and information within your plugin, to do such the jQuery &#8220;data()&#8221; function can be used. It&#8217;s quite simple in practice, make an attempt to fetch data associated with the element and if such data doesn&#8217;t exist, create it and add it to the element. Once you add information using &#8220;data()&#8221;, make sure to keep in mind deallocating resources when no longer needed using &#8220;removeData()&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Shawn Khameneh</span>
<span style="color: #006600; font-style: italic;">// ExtraordinaryThoughts.com</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> privateFunction <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// code here</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> methods <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
		init<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// Repeat over each element in selector</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> $this <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #006600; font-style: italic;">// Attempt to grab saved settings, if they don't exist we'll get &quot;undefined&quot;.</span>
				<span style="color: #003366; font-weight: bold;">var</span> settings <span style="color: #339933;">=</span> $this.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pluginName'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #006600; font-style: italic;">// If we could't grab settings, create them from defaults and passed options</span>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>settings<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
					<span style="color: #003366; font-weight: bold;">var</span> defaults <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
						propertyName<span style="color: #339933;">:</span> <span style="color: #3366CC;">'value'</span><span style="color: #339933;">,</span>
						onSomeEvent<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span>
&nbsp;
					settings <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> defaults<span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #006600; font-style: italic;">// Save our newly created settings</span>
					$this.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pluginName'</span><span style="color: #339933;">,</span> settings<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #006600; font-style: italic;">// We got settings, merge our passed options in with them (optional)</span>
					settings <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> settings<span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #006600; font-style: italic;">// If you wish to save options passed each time, add:</span>
					<span style="color: #006600; font-style: italic;">// $this.data('pluginName', settings);</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #006600; font-style: italic;">// run code here</span>
&nbsp;
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		destroy<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">// Repeat over each element in selector</span>
			<span style="color: #000066; font-weight: bold;">return</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> $this <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #006600; font-style: italic;">// run code here</span>
&nbsp;
				<span style="color: #006600; font-style: italic;">// Remove settings data when deallocating our plugin</span>
				$this.<span style="color: #660066;">removeData</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pluginName'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		val<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">// code here, use .eq(0) to grab first element in selector</span>
			<span style="color: #006600; font-style: italic;">// we'll just grab the HTML of that element for our value</span>
			<span style="color: #003366; font-weight: bold;">var</span> someValue <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// return one value</span>
			<span style="color: #000066; font-weight: bold;">return</span> someValue<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
	$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">pluginName</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> method <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>methods<span style="color: #009900;">&#91;</span>method<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			method <span style="color: #339933;">=</span> methods<span style="color: #009900;">&#91;</span>method<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			arguments <span style="color: #339933;">=</span> Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">slice</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>arguments<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>method<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'object'</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>method <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			method <span style="color: #339933;">=</span> methods.<span style="color: #660066;">init</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			$.<span style="color: #660066;">error</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'Method '</span> <span style="color: #339933;">+</span>  method <span style="color: #339933;">+</span> <span style="color: #3366CC;">' does not exist on jQuery.pluginName'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">return</span> method.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In the code above, I am checking if data for the elements exists. If data for the element doesn&#8217;t exist, settings are created by merging the the passed &#8220;options&#8221; and &#8220;defaults&#8221;, then saved using the &#8220;data()&#8221; command.</p>
<h1>All Done: Continue Reading!</h1>
<div>Here are a couple links for reference:</div>
<ul>
<li><a href="http://docs.jquery.com/Plugins/Authoring">jQuery Documentation &#8211; Plugins/Authoring</a></li>
<li><a href="http://docs.jquery.com/Types#Context.2C_Call_and_Apply">jQuery Documentation &#8211; Context, Call, and Apply</a></li>
<li><a href="http://webcloud.se/log/Building-jQuery-plugins/">Alternative Method Using &#8220;$.fn.extend()&#8221;</a></li>
<li><a href="http://www.learningjquery.com/2007/10/a-plugin-development-pattern">Another Guide Demonstrating Secondary Functions</a></li>
</ul>
<p>Last but not least, I&#8217;d also highly recommend the book <a href="http://oreilly.com/catalog/9780596806767">Javascript Patterns</a>. Some of the best books I&#8217;ve found are code patterns, and this book can help give you a head start to developing cleaner code and plugins.</p>
]]></content:encoded>
			<wfw:commentRss>http://extraordinarythoughts.com/2011/08/20/understanding-jquery-plugins/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>ExtJS Snapping Windows</title>
		<link>http://extraordinarythoughts.com/2011/08/17/extjs-snapping-windows/</link>
		<comments>http://extraordinarythoughts.com/2011/08/17/extjs-snapping-windows/#comments</comments>
		<pubDate>Wed, 17 Aug 2011 17:31:18 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[extensions]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://extraordinarythoughts.com/?p=174</guid>
		<description><![CDATA[There&#8217;s a really useful feature in Windows 7 that allows windows to be resized just by dragging them to edges of the screen.  Well, I wanted that feature for an ExtJS desktop environment, so here&#8217;s my solution for Windows 7 &#8230; <a href="http://extraordinarythoughts.com/2011/08/17/extjs-snapping-windows/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a really useful feature in Windows 7 that allows windows to be resized just by dragging them to edges of the screen.  Well, I wanted that feature for an ExtJS desktop environment, so here&#8217;s my solution for Windows 7 style window dragging.</p>
<p>The following code overrides some functionality in ExtJS and allows windows to be resized in the same manner.</p>
<div>Features:</div>
<ul>
<li>Windows can be dragged when maximized and will resize when dragged.</li>
<li>Dragging a window (cursor within 20 pixels) to top of container will maximize it.</li>
<li>Dragging a window (cursor within 20 pixels) to left or right of container will resize it to that half of the container.</li>
<li>The window ghost will indicate its new size according to placement when dragging.</li>
<li>Windows will restore to their original size before being snapped. (Not working in ExtJS 4 version)</li>
<li>Adds snapLeft() and snapRight() functions to the Ext.Window component.</li>
<li>Unsnapping windows will position them relative to the original cursor position on the title bar. (v2 only)</li>
<li>Supports autoloading (v2 only)</li>
</ul>
<div>Bugs / Quirks:</div>
<div>
<ul>
<li>Windows that initialize maximized will restore to 800&#215;400</li>
<li>Windows that initialize with resizable = false cannot be dragged when maximized. (Only ExtJS 3.3.1 version)</li>
<li>Maximizing a window when snapped to half the screen will make it resize to half of the screen.  (only ExtJS 3.3.1 version when using resize button)</li>
</ul>
<div>Yeah, the quirks can be easily fixed, I just have no immediate need to fix them.</div>
<p><span id="more-174"></span></p>
<p><a href="http://extraordinarythoughts.com/wp-content/uploads/2011/08/SnapWindows.js">Ext.ux.SnapWindows.js v2 for ExtJS 4 (Nov 7, 2001)</a> - <a href="http://extraordinarythoughts.com/code/ext-4.0.7/examples/snapwindows/">Demo</a><br />
<a href="http://extraordinarythoughts.com/wp-content/uploads/2011/08/Ext.ux_.SnapWindows.js">Ext.ux.SnapWindows.js v1 for ExtJS 4 (Oct 6, 2011)</a><br />
<a href="http://extraordinarythoughts.com/wp-content/uploads/2011/08/Ext.ux_.SnapWindows1.js">Ext.ux.SnapWindows.js v1 for ExtJS 3.3.1</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://extraordinarythoughts.com/2011/08/17/extjs-snapping-windows/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>ExtJS Window Reference &amp; Focus</title>
		<link>http://extraordinarythoughts.com/2011/08/16/extjs-win-re/</link>
		<comments>http://extraordinarythoughts.com/2011/08/16/extjs-win-re/#comments</comments>
		<pubDate>Wed, 17 Aug 2011 00:03:19 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[enhancements]]></category>
		<category><![CDATA[fixes]]></category>

		<guid isPermaLink="false">http://extraordinarythoughts.com/?p=143</guid>
		<description><![CDATA[I&#8217;ve got a short &#38; sweet code snippet to provide provide more usable functionality in ExtJS 3.3.1. This code snippet solves two minor drawbacks in Ext that I felt the need to address:  To reference a [nested] component&#8217;s window in &#8230; <a href="http://extraordinarythoughts.com/2011/08/16/extjs-win-re/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got a short &amp; sweet code snippet to provide provide more usable functionality in ExtJS 3.3.1.</p>
<p>This code snippet solves two minor drawbacks in Ext that I felt the need to address:</p>
<ol>
<li> To reference a [nested] component&#8217;s window in ExtJS, you must explicitly pass a reference to the window or obtain the window component by means not recommended to be practiced in production-level code.</li>
<li>Selecting an item in a list grid does not always give the parent window focus.</li>
</ol>
<p>To solve this, I&#8217;ve created a snippet of code to give each component a property called &#8220;ownerWindow&#8221; and components containing a &#8220;dynamicGrid&#8221; will focus the parent window when clicked.</p>
<p>Components that aren&#8217;t rendered or have no containing window will default the &#8220;ownerWindow&#8221; property to false for convenience.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Shawn Khameneh</span>
<span style="color: #006600; font-style: italic;">// GFX International</span>
<span style="color: #006600; font-style: italic;">// www.gfxi.com</span>
&nbsp;
Ext.<span style="color: #660066;">Component</span>.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">initComponent</span> <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">Component</span>.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">initComponent</span>.<span style="color: #660066;">createSequence</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">ownerWindow</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">ownerWindow</span> <span style="color: #339933;">||</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Ext.<span style="color: #660066;">Component</span>.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">afterRender</span> <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">Component</span>.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">afterRender</span>.<span style="color: #660066;">createSequence</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">ownerWindow</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">ownerCt</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">ownerCt</span>.<span style="color: #660066;">ownerWindow</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">ownerWindow</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">ownerCt</span>.<span style="color: #660066;">ownerWindow</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">dynamicGrid</span> <span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">root</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">el</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">ownerWindow</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">ownerWindow</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://extraordinarythoughts.com/2011/08/16/extjs-win-re/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back Online</title>
		<link>http://extraordinarythoughts.com/2011/06/09/back-online/</link>
		<comments>http://extraordinarythoughts.com/2011/06/09/back-online/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 16:49:46 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://extraordinarythoughts.com/?p=115</guid>
		<description><![CDATA[So the site was down for a long time and almost all worthy posts are lost.  The ironic thing is, they are lost in the database but still in cache. I guess next step is to restore them&#8230;oh what fun &#8230; <a href="http://extraordinarythoughts.com/2011/06/09/back-online/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So the site was down for a long time and almost all worthy posts are lost.  The ironic thing is, they are lost in the database but still in cache.<br />
I guess next step is to restore them&#8230;oh what fun that will be.</p>
<p><strong>Update:</strong> Forget that, starting over fresh. <img src='http://extraordinarythoughts.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://extraordinarythoughts.com/2011/06/09/back-online/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

