<?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>Totti&#039;s Blog &#187; Javascript</title>
	<atom:link href="http://iamtotti.com/blog/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://iamtotti.com/blog</link>
	<description>Javascript, and front-end stuff.</description>
	<lastBuildDate>Tue, 24 Aug 2010 17:21:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>ExtJS Vertical TabPanel example</title>
		<link>http://iamtotti.com/blog/2010/03/extjs-vertical-tabpanel-example/</link>
		<comments>http://iamtotti.com/blog/2010/03/extjs-vertical-tabpanel-example/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 02:16:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ext JS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[ExtJS]]></category>

		<guid isPermaLink="false">http://iamtotti.com/blog/?p=233</guid>
		<description><![CDATA[Currently, ExtJS 3.1.1 doesn&#8217;t support Vertical TabPanel. Here is my simple custom Vertical TabPanel ux class. Currently, it supports the same set of features as Ext.Tabpanel except advanced auto tab-scrolling feature. Default position is &#8220;left&#8221;. Tested working on FF3.6, IE7, IE8, Chrome 4, Safari 4, and Opera 10. You can put the source files in [...]]]></description>
			<content:encoded><![CDATA[<p>Currently, ExtJS 3.1.1 doesn&#8217;t support Vertical TabPanel. Here is my simple custom Vertical TabPanel ux class. Currently, it supports the same set of features as Ext.Tabpanel except advanced auto tab-scrolling feature. Default position is &#8220;left&#8221;.</p>
<p>Tested working on FF3.6, IE7, IE8, Chrome 4, Safari 4, and Opera 10.</p>
<p>You can put the source files in ExtJS Tabs folder to test: ext-3.1.1\examples\tabs\..</p>
<p>Check out the live example <a href="http://iamtotti.com/playground/js/ext-3.1.1/examples/tabs/tabs.html">here</a></p>
<p><a href="http://iamtotti.com/playground/js/ext-3.1.1/examples/tabs/Ext.ux.VrTabPanel.Examples.zip">Download </a>the whole example<br />
<a href="http://iamtotti.com/blog/wp-content/uploads/code/js/ext/Ext.ux.VrTabPanel.zip">Download </a>the extension code only</p>
<p><em><span style="color: #339966;">Extension updated to work with ExtJS 3.1.2</span></em></p>
<p>Cheers,</p>
<p>Totti</p>
]]></content:encoded>
			<wfw:commentRss>http://iamtotti.com/blog/2010/03/extjs-vertical-tabpanel-example/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>The interesting javascript window object</title>
		<link>http://iamtotti.com/blog/2010/02/the-interesting-javascript-window-object/</link>
		<comments>http://iamtotti.com/blog/2010/02/the-interesting-javascript-window-object/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 18:44:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://iamtotti.com/blog/?p=208</guid>
		<description><![CDATA[As we all know that in Javascript, the Window object is the global variable that contains attributes of the current opened window. An interesting part is this object also has a property called &#8216;window&#8216; which refers to itself. I&#8217;m not sure why this special object is implemented that way. alert(window); // object Window alert(window.window); // [...]]]></description>
			<content:encoded><![CDATA[<p>As we all know that in Javascript, the Window object is the global variable that contains attributes of the current opened window. An interesting part is this object also has a property called &#8216;<em>window</em>&#8216; which refers to itself. I&#8217;m not sure why this special object is implemented that way.<br />
<span id="more-208"></span></p>
<pre class="brush: jscript;">
alert(window);  // object Window
alert(window.window);   // object Window
alert(window.window.window);  // object Window
alert(window.window.window === window);   // true
</pre>
<p>A fun bit about this is the <strong>window </strong>object is read-only, while the <strong>self </strong>object, also referring to the current opened window, is not.</p>
<pre class="brush: jscript;">
// Try assigning window to null
window = null;
alert(window);  // object Window
window.window = null;
alert(window.window); // object Window

// Try assigning self to null
window.self = null;  // only on IE 6, 7 this will returns exception: 'Not Implemented'
alert(window.self)  // on other browsers, self now is null.
alert(window)  // object Window .
</pre>
<p>This proves that <strong>self </strong>object actually is just a reference of <strong>window</strong>. And <strong>self </strong>could be assigned to point to other objects while <strong>window </strong>remains intact.</p>
<p>Totti</p>
]]></content:encoded>
			<wfw:commentRss>http://iamtotti.com/blog/2010/02/the-interesting-javascript-window-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript: Function length vs arguments</title>
		<link>http://iamtotti.com/blog/2010/02/javascript-function-length-vs-arguments/</link>
		<comments>http://iamtotti.com/blog/2010/02/javascript-function-length-vs-arguments/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 18:59:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[arguments]]></category>
		<category><![CDATA[length]]></category>

		<guid isPermaLink="false">http://iamtotti.com/blog/?p=170</guid>
		<description><![CDATA[One of the reasons quite a number of programmers don&#8217;t like Javascript because it&#8217;s weird, behaving differently on different browsers.. and hard to debug.. However, it&#8217;s quite fun or even addictive to learn JS also for that reason. Below is a brief on two mysterious properties of Javascript functions : length, and arguments. arguments : [...]]]></description>
			<content:encoded><![CDATA[<p>One of the reasons quite a number of programmers don&#8217;t like Javascript because it&#8217;s weird, behaving differently on different browsers.. and hard to debug.. However, it&#8217;s quite fun or even addictive to learn JS also for that reason. Below is a brief on two mysterious properties of Javascript functions : <strong>length</strong>, and <strong>arguments</strong>.<br />
<span id="more-170"></span><br />
<strong>arguments</strong> :<br />
- available : only inside a function&#8217;s body<br />
- is : an array of parameters/arguments provided when the function is called.</p>
<p><strong>length</strong> :<br />
- available : both in/outside a function&#8217;s body. Could be called using : <em>functionName</em><strong>.</strong>length<br />
- is : the total number of arguments declared in the function&#8217;s signature</p>
<p>Below is the demo snippet showing how to use these properties:</p>
<pre class="brush: jscript;">
var myFunction = function(a, b, c, d, e) {
		// total number of params declared : TRUE
		alert(myFunction.length == 5);

		// real number of arguments provided : TRUE
		alert(arguments.length == 2);

		// you can also refer to the function using its name : TRUE
		alert(myFunction.arguments.length == 2);		

// how to refer to the arguments provided ?
		alert(a === 'x' &amp;&amp; arguments[0] === 'x');
		alert(b === 'y' &amp;&amp; arguments[1] === 'y');
};

// myFunction is called with two arguments only
myFunction( 'x', 'y' );

// total number of params declared : TRUE
alert(myFunction.length == 5);

// undefined : FALSE
alert(myFunction.arguments == 2);
</pre>
<p>Have fun,</p>
<p>Totti</p>
]]></content:encoded>
			<wfw:commentRss>http://iamtotti.com/blog/2010/02/javascript-function-length-vs-arguments/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JSMag for FREE</title>
		<link>http://iamtotti.com/blog/2010/01/jsmag-for-free/</link>
		<comments>http://iamtotti.com/blog/2010/01/jsmag-for-free/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 15:51:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ebooks]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jsmag]]></category>
		<category><![CDATA[magazine]]></category>

		<guid isPermaLink="false">http://iamtotti.com/blog/?p=148</guid>
		<description><![CDATA[JSMag is currently kinda the only Javascript magazine for enthusiastic front-end developers. I&#8217;m a subscriber of this magazine, finding it really fun, and interesting to read, especially if you love Javascript. This is a must-read for you and only costs $4.99. You can purchase at JsMag or ..I will periodically, and per request, upload old [...]]]></description>
			<content:encoded><![CDATA[<p>JSMag is currently kinda the only Javascript magazine for enthusiastic front-end developers. I&#8217;m a subscriber of this magazine, finding it really fun, and interesting to read, especially if you love Javascript. This is a must-read for you <img src='http://iamtotti.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  and only costs $4.99. You can purchase at <a href="http://www.jsmag.com/">JsMag</a> or ..I will periodically, and per request, upload old JSMag for the &#8220;hungry&#8221;-minded to download <img src='http://iamtotti.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . However, I can&#8217;t upload the latest ones as ..you know <img src='http://iamtotti.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
<span id="more-148"></span><br />
Below are several issues I found very informative.<br />
<a href="http://iamtotti.com/ebooks/javascript/jsmag/jsmag_js1.pdf">Issue 1</a><br />
<a href="http://iamtotti.com/ebooks/javascript/jsmag/jsmag_js2.pdf">Issue 2</a><br />
<a href="http://iamtotti.com/ebooks/javascript/jsmag/jsmag_js4.pdf">Issue 4</a><br />
<a href="http://iamtotti.com/ebooks/javascript/jsmag/jsmag_js7.pdf">Issue 7</a><br />
<a href="http://iamtotti.com/ebooks/javascript/jsmag/jsmag_js8.pdf">Issue 8</a><br />
<a href="http://iamtotti.com/ebooks/javascript/jsmag/jsmag_js11.pdf">Issue 11</a></p>
<p>Totti</p>
]]></content:encoded>
			<wfw:commentRss>http://iamtotti.com/blog/2010/01/jsmag-for-free/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Learning Javascript, JQuery w John Resig</title>
		<link>http://iamtotti.com/blog/2010/01/learning-javascript-jquery-w-john-resig/</link>
		<comments>http://iamtotti.com/blog/2010/01/learning-javascript-jquery-w-john-resig/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 15:35:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[John Resig]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Teaching]]></category>

		<guid isPermaLink="false">http://iamtotti.com/blog/?p=141</guid>
		<description><![CDATA[John Resig, one of my favorite Javascript experts, recently has just released a site teaching advanced Javascript for intermediate programmers. I myself find this resource very informative. Hope you guys love it too. http://ejohn.org/apps/learn/ and also the page teaching jQuery at http://ejohn.org/apps/learn-jquery/ You could also find more of his lectures in the upcoming book called [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ejohn.org/about/">John Resig</a>, one of my favorite Javascript experts, recently has just released a site teaching advanced Javascript for intermediate programmers. I myself find this resource very informative. Hope you guys love it too.</p>
<p><a href="http://ejohn.org/apps/learn/">http://ejohn.org/apps/learn/</a></p>
<p>and also the page teaching jQuery at <a href="http://ejohn.org/apps/learn-jquery/">http://ejohn.org/apps/learn-jquery/</a></p>
<p>You could also find more of his lectures in the upcoming book called <a href="http://ejohn.org/blog/50-off-secrets-of-the-javascript-ninja/">Secrets of Javascript Ninja</a>.</p>
<p>Totti</p>
]]></content:encoded>
			<wfw:commentRss>http://iamtotti.com/blog/2010/01/learning-javascript-jquery-w-john-resig/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A JavaScript Module Pattern</title>
		<link>http://iamtotti.com/blog/2009/12/a-javascript-module-pattern/</link>
		<comments>http://iamtotti.com/blog/2009/12/a-javascript-module-pattern/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 13:47:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Great Articles]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[pattern]]></category>

		<guid isPermaLink="false">http://iamtotti.com/blog/?p=114</guid>
		<description><![CDATA[This is the first episode in the collection of Great Javascript articles by world&#8217;s top-notched Javascript gurus. Our entry this week was written by Eric Miraglia originally posted on Y!UI Blog. Global variables are evil. Within YUI, we use only two globals: YAHOO and YAHOO_config. Everthing in YUI makes use of members within the YAHOO [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first episode in the collection of Great Javascript articles by world&#8217;s top-notched Javascript gurus.<br />
Our entry this week was written by <a href="http://ericmiraglia.com/">Eric Miraglia</a> originally posted on <a href="http://www.yuiblog.com/blog/2007/06/12/module-pattern/">Y!UI Blog.</a></p>
<p>Global variables are evil. Within YUI, we use only two globals: <em>YAHOO </em>and <em>YAHOO_config</em>. Everthing in YUI makes use of members within the YAHOO object hierarchy or variables that are scoped to such a member. We advise that you exercise similar discipline in your own applications, too.</p>
<p>Douglas Crockford has been teaching a useful singleton pattern for achieving this discipline, and I thought his pattern might be of interest to those of you building on top of YUI. Douglas calls this the “module pattern.” Here’s how it works:<br />
<span id="more-114"></span><br />
<strong>1. Create a namespace object</strong>: If you’re using YUI, you can use the YAHOO.namespace() method: </p>
<pre class="brush: jscript;">
YAHOO.namespace(&quot;myProject&quot;);
</pre>
<p>This assigns an empty object myProject as a member of YAHOO (but doesn’t overwrite myProject if it already exists). Now we can begin adding members to YAHOO.myProject.</p>
<p><strong>2. Assign the return value of an anonymous function</strong> to your namespace object:</p>
<pre class="brush: jscript;">
YAHOO.myProject.myModule = function () {
	return  {
		myPublicProperty: &quot;I'm accessible as YAHOO.myProject.myModule.myPublicProperty.&quot;,
		myPublicMethod: function () {
			YAHOO.log(&quot;I'm accessible as YAHOO.myProject.myModule.myPublicMethod.&quot;);
		}
	};

}(); // the parens here cause the anonymous function to execute and return
</pre>
<p>Note the very last line with the closing curly brace and then the parentheses () — this notation causes the anonymous function to execute immediately, returning the object containing <em>myPublicProperty </em>and <em>myPublicMethod</em>. As soon as the anonymous function returns, that returned object is addressable as <em>YAHOO.myProject.myModule</em>. </p>
<p><strong>3. Add “private” methods and variables</strong> in the anonymous function prior to the return statement. So far, the above code hasn’t bought us any more than we could have gotten by assigning <em>myPublicProperty </em>and <em>myPublicMethod </em>directly to <em>YAHOO.myProject.myModule</em>. But the pattern does provide added utility when we place code before the return statement:</p>
<pre class="brush: jscript;">
YAHOO.myProject.myModule = function () {

	//&quot;private&quot; variables:
	var myPrivateVar = &quot;I can be accessed only from within YAHOO.myProject.myModule.&quot;;

	//&quot;private&quot; method:
	var myPrivateMethod = function () {
		YAHOO.log(&quot;I can be accessed only from within YAHOO.myProject.myModule&quot;);
	}

	return  {
		myPublicProperty: &quot;I'm accessible as YAHOO.myProject.myModule.myPublicProperty.&quot;
		myPublicMethod: function () {
			YAHOO.log(&quot;I'm accessible as YAHOO.myProject.myModule.myPublicMethod.&quot;);

			//Within myProject, I can access &quot;private&quot; vars and methods:
			YAHOO.log(myPrivateVar);
			YAHOO.log(myPrivateMethod());

			//The native scope of myPublicMethod is myProject; we can
			//access public members using &quot;this&quot;:
			YAHOO.log(this.myPublicProperty);
		}
	};

}(); // the parens here cause the anonymous function to execute and return
</pre>
<p>In the codeblock above, we’re returning from an anonymous function an object with two members. These members are addressable from within <em>YAHOO.myProject.myModule</em> as this.myPublicProperty and this.myPublicMethod respectively. From outside of <em>YAHOO.myProject.myModule</em>, these public members are addressable as <em>YAHOO.myProject.myModule</em>.myPublicProperty and <em>YAHOO.myProject.myModule</em>.myPublicMethod.</p>
<p>The private variables myPrivateProperty and myPrivateMethod can only be accessed from within the anonymous function itself or from within a member of the returned object. They are preserved, despite the immediate execution and termination of the anonymous function, through the power of closure — the principle by which variables local to a function are retained after the function has returned. As long as YAHOO.myProject.myModule needs them, our two private variables will not be destroyed.</p>
<p><strong>4. Do something useful with the pattern.</strong> Let’s look at a common use case for the module pattern. Suppose you have a list, some of whose list items should be draggable. The draggable items have the CSS class draggable applied to them.</p>
<pre class="brush: xml;">
&lt;!--This script file includes all of the YUI utilities:--&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://yui.yahooapis.com/2.2.2/build/utilities/utilities.js&quot;&gt;&lt;/script&gt;

&lt;ul id=&quot;myList&quot;&gt;
	&lt;li class=&quot;draggable&quot;&gt;Item one.&lt;/li&gt;
	&lt;li&gt;Item two.&lt;/li&gt; &lt;!--item two won't be draggable--&gt;
	&lt;li class=&quot;draggable&quot;&gt;Item three.&lt;/li&gt;
&lt;/ul&gt;
</pre>
<pre class="brush: jscript;">
&lt;script&gt;
YAHOO.namespace(&quot;myProject&quot;);
YAHOO.myProject.myModule = function () {

	//private shorthand references to YUI utilities:
	var yue = YAHOO.util.Event,
		yud = YAHOO.util.Dom;

	//private method:
	var getListItems = function () {

		//note that we can use other private variables here, including
		//our &quot;yud&quot; shorthand to YAHOO.util.Dom:
		var elList = yud.get(&quot;myList&quot;);
		var aListItems = yud.getElementsByClassName(
			&quot;draggable&quot;, //get only items with css class &quot;draggable&quot;
			&quot;li&quot;, //only return list items
			elList //restrict search to children of this element
		);
		return aListItems;
	};

	//the returned object here will become YAHOO.myProject.myModule:
	return  {

		aDragObjects: [], //a publicly accessible place to store our DD objects

		init: function () {
			//we'll defer making list items draggable until the DOM is fully loaded:
			yue.onDOMReady(this.makeLIsDraggable, this, true);
		},

		makeLIsDraggable: function () {
			var aListItems = getListItems(); //these are the elements we'll make draggable
			for (var i=0, j=aListItems.length; i&lt;j; i++) {
				this.aDragObjects.push(new YAHOO.util.DD(aListItems[i]));
			}
		}

	};
}(); // the parens here cause the anonymous function to execute and return

//The above code has already executed, so we can access the init
//method immediately:
YAHOO.myProject.myModule.init();
&lt;/script&gt;
</pre>
<p>This example is a simple one, and it’s deliberately verbose — if this was all we were doing, we could doubtless write it in a more compact way. However, this pattern scales well as the project becomes more complex and as its API grows. It stays out of the global namespace, provides publicly addressable API methods, and supports protected or “private” data and methods along the way.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamtotti.com/blog/2009/12/a-javascript-module-pattern/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ExtJS : 2 secs with custom vType</title>
		<link>http://iamtotti.com/blog/2009/12/extjs-2-secs-with-vtype/</link>
		<comments>http://iamtotti.com/blog/2009/12/extjs-2-secs-with-vtype/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 17:54:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ext JS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[vType]]></category>

		<guid isPermaLink="false">http://iamtotti.com/blog/?p=95</guid>
		<description><![CDATA[Following another question on ExtJS forum, I&#8217;ve created a sample of how to use vType for ExtJS newbies. Basically, in form submission you need to validate user input and / or prevent user from entering invalid keys. Pure Javascript implementation could be quite a headache to some folks. ExtJS now provides a regex-based validation class [...]]]></description>
			<content:encoded><![CDATA[<p>Following another question on ExtJS forum, I&#8217;ve created a sample of how to use vType for ExtJS newbies.</p>
<p>Basically, in form submission you need to validate user input and / or prevent user from entering invalid keys. Pure Javascript implementation could be quite a headache to some folks. ExtJS now provides a regex-based validation class called, vType, which helps you to do both things mentioned above.</p>
<p>Demo:<a href="http://iamtotti.com/playground/js/ext-3.1.0/playground/vtype.html"> a simple Custom vType</a><br />
<span id="more-95"></span><br />
You can find more examples at <a href="http://www.extjs.com/deploy/dev/docs/?class=Ext.form.VTypes" target="_blank">ExtJS 3.1 API: vType<br />
</a></p>
<p>vType.js</p>
<pre class="brush: jscript;">
&lt;pre&gt;
Ext.onReady(function(){
	// QuickTips to display error messages next to form fields
	Ext.QuickTips.init();

	// Declare a custom VType
	Ext.apply(Ext.form.VTypes, {
                 // This function validates input text
		AlphaNum:  function(v) {
			return /^[a-z0-9]$/i.test(v);
		},
                // This is the tooltip message displayed when invalid input occurs
		AlphaNumText: 'Must be an alphanumeric word',
                // This mask filter invalid keystrokes
		AlphaNumMask: /[a-z0-9]/i
	});

	// Simple form with a text field for demo purpose
	var myForm = new Ext.FormPanel({
		width: 300,
		renderTo: Ext.getBody(),
		title: '2 secs with vType Demo',
		items: [
			{
				xtype: 'textfield',
				id: 'alphanum',
				fieldLabel: 'AlphaNum',
				vtype: 'AlphaNum'
			}
		],
		buttons: [
			{
				text: 'Submit',
				handler: function() {
					// myForm.getForm().submit();
					Ext.Msg.alert('Action', 'Form submitted');
				}
			}, {
				text: 'Reset',
				handler: function() {
					myForm.getForm().reset();
				}
			}
		]
	});
});
&lt;/pre&gt;
</pre>
<p>vType.html</p>
<pre class="brush: xml;">
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;ExtJS - VTypes&lt;/title&gt;
	&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;../resources/css/ext-all.css&quot; /&gt;
	&lt;script src=&quot;../adapter/ext/ext-base.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
	&lt;script src=&quot;../ext-all.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

	&lt;script src=&quot;js/vtype.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>You need to know a little bit of javascript regular expression in order to configure vType as you want.</p>
<p>Happy coding,</p>
<p>Totti</p>
]]></content:encoded>
			<wfw:commentRss>http://iamtotti.com/blog/2009/12/extjs-2-secs-with-vtype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to remove white spaces from a string</title>
		<link>http://iamtotti.com/blog/2009/12/how-to-remove-white-spaces-from-a-string/</link>
		<comments>http://iamtotti.com/blog/2009/12/how-to-remove-white-spaces-from-a-string/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 06:37:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Regex]]></category>

		<guid isPermaLink="false">http://iamtotti.com/blog/?p=92</guid>
		<description><![CDATA[Today at work, I happened to write a function that removes white spaces from a string. After trying different ways using: loops, array indexer, or regex, I came up with the shortest way using regular expression to share with you: var str = ” — This is %$# ‘\’ a test string ha hee hhhoo [...]]]></description>
			<content:encoded><![CDATA[<p>Today at work, I happened to write a function that removes white spaces from a string. After trying different ways using: loops, array indexer, or regex, I came up with the shortest way using regular expression to share with you:</p>
<p><span id="more-92"></span></p>
<pre class="brush: jscript;">
var str = ” — This is %$# ‘\’ a test string ha    hee hhhoo    1   22 33  “;
str = str.replace(/\s/g, ”);
// str is now –Thisis%$#”ateststringhaheehhhoo12233
</pre>
]]></content:encoded>
			<wfw:commentRss>http://iamtotti.com/blog/2009/12/how-to-remove-white-spaces-from-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ext JS Examples: Drag n&#8217; Drop buttons on a panel</title>
		<link>http://iamtotti.com/blog/2009/12/ext-js-drag-n-drop-buttons-on-a-panel/</link>
		<comments>http://iamtotti.com/blog/2009/12/ext-js-drag-n-drop-buttons-on-a-panel/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 20:17:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ext JS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Drag n' Drop]]></category>
		<category><![CDATA[examples]]></category>

		<guid isPermaLink="false">http://iamtotti.com/blog/?p=42</guid>
		<description><![CDATA[This blog entry was written following a question of an user in ExtJS forum: How to drag n&#8217; drop a button on a panel ? ExtJs people tend to just focus on the grid-to-grid, grid-to-listview.. sort of drag and drop, and forgot to include in their documentation a typical example of &#8216;drag and drop&#8217; of [...]]]></description>
			<content:encoded><![CDATA[<p>This blog entry was written following a question of an user in ExtJS forum: <em>How to drag n&#8217; drop a button on a panel ?</em></p>
<p>ExtJs people tend to just focus on the grid-to-grid, grid-to-listview.. sort of drag and drop, and forgot to include in their documentation a typical example of &#8216;drag and drop&#8217; of a simple element like <em>a button on a panel</em>. Below is my implementation:</p>
<p>ExtJS: 3.x</p>
<p>Demo:<a href="http://iamtotti.com/playground/js/ext-3.1.0/playground/dd_button.html" target="_blank"> Drag and Drop a button</a></p>
<p><span id="more-42"></span>index.html</p>
<pre class="brush:html">&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;ExtJS - Drag n' Drop Demo&lt;/title&gt;
	&lt;link rel="stylesheet" type="text/css" href="../resources/css/ext-all.css" /&gt;
	&lt;script src="js/ext-base.js" type="text/javascript"&gt;&lt;/script&gt;
	&lt;script src="js/ext-all.js" type="text/javascript"&gt;&lt;/script&gt;

	&lt;script src="js/dd_button.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;div id="canvas"&gt;
	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>dd_button.js</p>
<pre class="brush:js">Ext.onReady(function(){

	// Make the button Draggable inside  tag
	var initDragZone = function(v) {

		v.dragZone = new Ext.dd.DragZone(Ext.getBody(), {
			getDragData: function(e) {
				// .button-draggable == class of the button you want to drag around
				if(sourceEl = e.getTarget('.button-draggable')) {
					d = sourceEl.cloneNode(true);
					d.id = Ext.id();
					return v.dragData = {
						sourceEl: sourceEl,
						repairXY: Ext.fly(sourceEl).getXY(),
						ddel: d
					}
				}
			},

			onDrag: function(e) {
				// !Important: manually fix the default position of Ext-generated proxy element
				// Uncomment these line to see the Ext issue
				var proxy = Ext.DomQuery.select('*', this.getDragEl());
				proxy[2].style.position = '';
			},

			getRepairXY: function() {
				return this.dragData.repairXY;
			}
		});
	};		

        // Make the panel droppable to the button
	var initDropZone = function(g) {
		g.dropZone = new Ext.dd.DropZone(g.body, {

			getTargetFromEvent: function(e) {
				return e.getTarget('#canvas');
			},

			onNodeOver : function(target, dd, e, data){
				return Ext.dd.DropZone.prototype.dropAllowed;
			},

			onNodeDrop : function(target, dd, e, data) {
				// !Important: We assign the dragged element to be set to new drop position
				if(dragEl = Ext.get(data.sourceEl)) {
					dragEl.setXY([e.getPageX(),e.getPageY()]);
				}

				return true;
			}	

		});
	};

        // Make the Panel Droppable
	var myPanel = new Ext.Panel({
		width: 500,
		height: 300,
		renderTo: 'canvas',
		bodyStyle: { background: 'yellow' },
		html: 'Drop your button here',
		listeners: {
			render: initDropZone
		}
	});		

	var myButton = new Ext.Button({
		width: 30,
		height: 20,
		cls: 'button-draggable',
		text: "Drag me",
		renderTo: Ext.getBody(),
		listeners: {
			render: initDragZone
		}
	});
});</pre>
<p>The important point of this implementation is the onDrag method</p>
<pre class="brush:js">onDrag: function(e) {
				// !Important: manually fix the default position of Ext-generated proxy element
				// Uncomment these line to see the Ext issue
				var proxy = Ext.DomQuery.select('*', this.getDragEl());
				proxy[2].style.position = '';
			},</pre>
<p>Try removing the function onDrag above, you&#8217;ll see this positioning issue:</p>
<p><img src="http://iamtotti.com/blog/wp-content/uploads/2009/12/dd_button.jpg" alt="Positioning Issue" width="100%" /></p>
<p>Have fun,</p>
<p>Totti</p>
]]></content:encoded>
			<wfw:commentRss>http://iamtotti.com/blog/2009/12/ext-js-drag-n-drop-buttons-on-a-panel/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
