<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>&lt;!--- CFChris ---&gt; - JavaScript</title>
			<link>http://www.cfchris.com/cfchris/index.cfm</link>
			<description>The blog of Chris Phillips, a ColdFusion developer with a passion for improvement.</description>
			<language>en-us</language>
			<pubDate>Sun, 05 Sep 2010 08:06:54 -0700</pubDate>
			<lastBuildDate>Mon, 03 May 2010 16:34:00 -0700</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>me@cfchris.com</managingEditor>
			<webMaster>me@cfchris.com</webMaster>
			
			
			
			
			
			<item>
				<title>Textarea Auto Grow</title>
				<link>http://www.cfchris.com/cfchris/index.cfm/2010/5/3/Textarea-Auto-Grow</link>
				<description>
				
				I have seen instances where I&apos;m on a form on a website and there is some mechanism by which the textarea automatically grows to fit what I&apos;m typing. I&apos;ve also seen this not work too well, and eventually half the bottom line is cut off or the bottom of the textarea has expanded further than it needs to.

A while ago a super simple solution to this popped into my head. And today I happened to need just such a solution. So, I wrote up a vary small JavaScript function to add to our utility library.
				 [More]
				</description>
						
				
				<category>JavaScript</category>				
				
				<category>Web 2.0</category>				
				
				<pubDate>Mon, 03 May 2010 16:34:00 -0700</pubDate>
				<guid>http://www.cfchris.com/cfchris/index.cfm/2010/5/3/Textarea-Auto-Grow</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>PSA: Browser Back Button Differences</title>
				<link>http://www.cfchris.com/cfchris/index.cfm/2010/1/11/PSA-Browser-Back-Button-Differences</link>
				<description>
				
				At work, we had some old display code that was supposed to prevent users from submitting the same form twice. In the form&apos;s submit event, there was a window scoped boolean being set. If validation errors needed to be displayed, then the boolean was un-set. And at the very top of the submit action it would just &apos;return&apos; if it saw the boolean. Maybe it will make more sense if you look at the submit event handler.
				 [More]
				</description>
						
				
				<category>JavaScript</category>				
				
				<category>Web 2.0</category>				
				
				<pubDate>Mon, 11 Jan 2010 16:37:00 -0700</pubDate>
				<guid>http://www.cfchris.com/cfchris/index.cfm/2010/1/11/PSA-Browser-Back-Button-Differences</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>How To: Prototype Resize Handle</title>
				<link>http://www.cfchris.com/cfchris/index.cfm/2009/2/18/How-To-Prototype-Drag-Corner</link>
				<description>
				
				This is just a short post to share some JavaScript that I wrote to be able to add a drag corner to an html element to make it resizable.

I did this using prototype.js. As an example the two divs below have been made resizable. (Go ahead. Drag the bottom right corner around.)

&lt;div id=&quot;SomeDiv&quot; style=&quot;position: relative; width: 200px; height:100px; border: 2px solid black; padding: 3px;&quot;&gt;
	Div One
	&lt;div class=&quot;corner&quot; id=&quot;DragHandle&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;DivTwo&quot; style=&quot;position:relative; width:150px; height:75px; border:1px dashed red;&quot;&gt;
	Div Two
	&lt;div class=&quot;corner&quot; id=&quot;DragHandleTwo&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;

&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot;&gt;
	
	function DragCorner(container, handle) {
		var container = $(container);
		var handle = $(handle);
		
		/* Add property to container to store position variables */
		container.moveposition = {x:0, y:0};
		
		function moveListener(event) {
			/* Calculate how far the mouse moved */
			var moved = {
							x:(event.pointerX() - container.moveposition.x),
							y:(event.pointerY() - container.moveposition.y)
						};
			/* Reset container&apos;s x/y utility property */
			container.moveposition = {x:event.pointerX(), y:event.pointerY()};
			/* Border adds to dimensions */
			var borderStyle = container.getStyle(&apos;border-width&apos;);
			var borderSize = borderStyle.split(&apos; &apos;)[0].replace(/[^0-9]/g,&apos;&apos;);
			/* Padding adds to dimensions */
			var paddingStyle = container.getStyle(&apos;padding&apos;);
			var paddingSize = paddingStyle.split(&apos; &apos;)[0].replace(/[^0-9]/g,&apos;&apos;);
			/* Add things up that change dimensions */
			var sizeAdjust = (borderSize*2) + (paddingSize*2);
			/* Update container&apos;s size */
			var size = container.getDimensions();
			container.setStyle({
					height: size.height+moved.y-sizeAdjust+&apos;px&apos;,
					width:size.width+moved.x-sizeAdjust+&apos;px&apos;
				});
		}
		
		/* Listen for &apos;mouse down&apos; on handle to start the move listener */
		handle.observe(&apos;mousedown&apos;, function(event) {
			/* Set starting x/y */
			container.moveposition = {x:event.pointerX(),y:event.pointerY()};
			/* Start listening for mouse move on body */
			Event.observe(document.body,&apos;mousemove&apos;,moveListener);
		});
		
		/* Listen for &apos;mouse up&apos; to cancel &apos;move&apos; listener */
		Event.observe(document.body,&apos;mouseup&apos;, function(event) {
			Event.stopObserving(document.body,&apos;mousemove&apos;,moveListener);
		});
	}
	
	DragCorner(&apos;SomeDiv&apos;,&apos;DragHandle&apos;);
	
	DragCorner(&apos;DivTwo&apos;,&apos;DragHandleTwo&apos;);
	
&lt;/script&gt;

&lt;style type=&quot;text/css&quot;&gt;
	div.corner {
		background-color: silver;
		cursor: se-resize;
		height: 25px;
		width: 25px;
		position: absolute;
		bottom: 0px;
		right: 0px;
	}
&lt;/style&gt;

And below is the code that makes it possible. If you take a look at it and read the comments, You&apos;ll see that it&apos;s actually pretty simple. The thing that had me stuck for a while was asking Prototype how tall or wide something is isn&apos;t the whole story. Border and padding add to width and height. I have some code in there that will compensate for that. However, I only covered situations where the border/passing were uniform all the way around. Anyway, love to hear what you think about this.

&lt;code&gt;
&lt;div id=&quot;SomeDiv&quot; style=&quot;position: relative; width: 200px; height:100px; border: 2px solid black; padding: 3px;&quot;&gt;
	Div One
	&lt;div class=&quot;corner&quot; id=&quot;DragHandle&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;DivTwo&quot; style=&quot;position:relative; width:150px; height:75px; border:1px dashed red;&quot;&gt;
	Div Two
	&lt;div class=&quot;corner&quot; id=&quot;DragHandleTwo&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;

&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot;&gt;

	function DragCorner(container, handle) {
		var container = $(container);
		var handle = $(handle);
		
		/* Add property to container to store position variables */
		container.moveposition = {x:0, y:0};
		
		function moveListener(event) {
			/* Calculate how far the mouse moved */
			var moved = {
							x:(event.pointerX() - container.moveposition.x),
							y:(event.pointerY() - container.moveposition.y)
						};
			/* Reset container&apos;s x/y utility property */
			container.moveposition = {x:event.pointerX(), y:event.pointerY()};
			/* Border adds to dimensions */
			var borderStyle = container.getStyle(&apos;border-width&apos;);
			var borderSize = borderStyle.split(&apos; &apos;)[0].replace(/[^0-9]/g,&apos;&apos;);
			/* Padding adds to dimensions */
			var paddingStyle = container.getStyle(&apos;padding&apos;);
			var paddingSize = paddingStyle.split(&apos; &apos;)[0].replace(/[^0-9]/g,&apos;&apos;);
			/* Add things up that change dimensions */
			var sizeAdjust = (borderSize*2) + (paddingSize*2);
			/* Update container&apos;s size */
			var size = container.getDimensions();
			container.setStyle({
					height: size.height+moved.y-sizeAdjust+&apos;px&apos;,
					width:size.width+moved.x-sizeAdjust+&apos;px&apos;
				});
		}
		
		/* Listen for &apos;mouse down&apos; on handle to start the move listener */
		handle.observe(&apos;mousedown&apos;, function(event) {
			/* Set starting x/y */
			container.moveposition = {x:event.pointerX(),y:event.pointerY()};
			/* Start listening for mouse move on body */
			Event.observe(document.body,&apos;mousemove&apos;,moveListener);
		});
		
		/* Listen for &apos;mouse up&apos; to cancel &apos;move&apos; listener */
		Event.observe(document.body,&apos;mouseup&apos;, function(event) {
			Event.stopObserving(document.body,&apos;mousemove&apos;,moveListener);
		});
	}
	
	DragCorner(&apos;SomeDiv&apos;,&apos;DragHandle&apos;);
	
	DragCorner(&apos;DivTwo&apos;,&apos;DragHandleTwo&apos;);
	
&lt;/script&gt;
&lt;/code&gt;
				
				</description>
						
				
				<category>JavaScript</category>				
				
				<category>Web 2.0</category>				
				
				<pubDate>Wed, 18 Feb 2009 15:01:00 -0700</pubDate>
				<guid>http://www.cfchris.com/cfchris/index.cfm/2009/2/18/How-To-Prototype-Drag-Corner</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Real World AJAX Presentation Code</title>
				<link>http://www.cfchris.com/cfchris/index.cfm/2008/11/14/Real-World-AJAX-Presentation-Code</link>
				<description>
				
				Last night I presented my &quot;Real World AJAX&quot; talk to PDXRIA (our local Portland Adobe User Group). I said I would post the code. So, here it is! (Download link below)

I have included the PDF slide presentation too. There are not a lot of slides. This is a code heavy talk. It uses a very simple CRUD application to demonstrate adding AJAX to an existing application. There are three versions in the zip. One completely paged based. Another one with some &apos;partial page update&apos; style AJAX to improve the user experience. And a final one with some DHTML and DOM building. The code uses an in memory query object instead of a database. So, you should be able to drop it in a folder and run it with no setup.

When I give the presentation, I show how you can turn JavaScript off and the second version still works (it gracefully degrades). I really need to add about 10 more slides with some of the stuff that I ramble off while I&apos;m showing the code examples. If I get around to polishing it off, I&apos;ll re-post the updated slides and code.

Also, I built the slides in OpenOffice.org Impress. If you would like to give this talk to your user group, or somewhere else, let me know.
				
				</description>
						
				
				<category>JavaScript</category>				
				
				<category>Web 2.0</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Fri, 14 Nov 2008 19:52:00 -0700</pubDate>
				<guid>http://www.cfchris.com/cfchris/index.cfm/2008/11/14/Real-World-AJAX-Presentation-Code</guid>
				
				<enclosure url="http://www.cfchris.com/cfchris/enclosures/RealWorldAJAX.zip" length="230208" type="application/zip"/>
				
			</item>
			
		 	
			
			
			<item>
				<title>Get Firebug Now! (Because Debuggers Are Awesome)</title>
				<link>http://www.cfchris.com/cfchris/index.cfm/2008/4/6/Get-Firebug-Now-Because-Debuggers-Are-Awesome</link>
				<description>
				
				If you already know &lt;a href=&quot;http://www.getfirebug.com/&quot; target=&quot;_blank&quot;&gt;Firebug&lt;/a&gt; inside and out, feel free to move along. You already know how awesome it is.

OK, now that the know-it-alls are gone... I have to tell you that the other week I had another one of those &quot;giant step ahead&quot; moments in my development career. I used a step-through debugger for the first time (Firebug). I wouldn&apos;t admit this in public if it weren&apos;t for the fact that I think admitting it will help other people to take that step too.

I was having a hell-of-a time with a particular page. There was a lot of JavaScript going on on this page including validation and chained AJAX calls. Anyway, the page was, in some circumstances, throwing a JS slow-running script error across browsers. I actually tried for some time to put in alerts, comment out portions, etc. like I normally do. This was not working.

So, I said, &quot;I think now is the time to check out the Firebug break-point thing&quot;. I went over to &lt;a href=&quot;http://www.getfirebug.com/&quot; target=&quot;_blank&quot;&gt;http://www.getfirebug.com&lt;/a&gt; and scanned the portion about the debugger. I set a break-point in a method above where I knew the slowness was occurring. Firebug, having paused the JS execution at that point, also showed me what data was being passed into the method. With the ability to see the data and step through line-by-line, it wasn&apos;t long until I found what was wrong. (Some records in our db have a guid for their email. And the regex for our email validation choked on them).

Here&apos; my point: It is so much easier to debug JS with the proper tool that I am &lt;em&gt;looking forward&lt;/em&gt; to the next  tricky JS error!

&lt;a href=&quot;http://www.getfirebug.com/&quot; target=&quot;_blank&quot;&gt;Firebug&lt;/a&gt; is an amazing tool! I&apos;ve been using it for a while for testing and debugging AJAX calls. I also use it to help figure out CSS issues quickly. If you don&apos;t know that you can edit your html and CSS, debug JS, monitor network activity and much more with Firebug, then you owe it to yourself to go read about it. I know now that not having done this earlier was penny-wise and dollar foolish on my part.

You can come back and thank me for the kick in the pants later. :-)
				
				</description>
						
				
				<category>Firefox</category>				
				
				<category>JavaScript</category>				
				
				<pubDate>Sun, 06 Apr 2008 09:14:00 -0700</pubDate>
				<guid>http://www.cfchris.com/cfchris/index.cfm/2008/4/6/Get-Firebug-Now-Because-Debuggers-Are-Awesome</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>BlogCFC JS Twitter Pod (Bug Fixed)</title>
				<link>http://www.cfchris.com/cfchris/index.cfm/2008/2/3/BlogCFC-JS-Twitter-Pod-Bug-Fixed</link>
				<description>
				
				If you are using my BlogCFC JS Twitter Pod or you visit my blog, you may have noticed that the Twitter time-stamp started reading &quot;About 365 days ago&quot; when the year rolled over. I finally sat down and looked into this today. Turns out, it&apos;s all my fault. I had to do some string manipulation on the date that Twitter sends to get it to work in IE and FF. Apparently I hard-coded &apos;2007&apos; in there to get it working. Maybe, I thought the world would end last year... Well, it didn&apos;t. So that code has been updated with #year(now())#.

The Twitter Pod download is still available &lt;a href=&quot;http://www.cfchris.com/cfchris/DownLoads/twitterJS.zip&quot;&gt;here&lt;/a&gt;. And I&apos;d still love to hear if anyone uses it on their blog.
				
				</description>
						
				
				<category>JavaScript</category>				
				
				<category>Twitter</category>				
				
				<category>Blogging</category>				
				
				<pubDate>Sun, 03 Feb 2008 09:30:00 -0700</pubDate>
				<guid>http://www.cfchris.com/cfchris/index.cfm/2008/2/3/BlogCFC-JS-Twitter-Pod-Bug-Fixed</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>BlogCFC JS Twitter Pod (Updated)</title>
				<link>http://www.cfchris.com/cfchris/index.cfm/2007/6/5/BlogCFC-JS-Twitter-Pod-Updated</link>
				<description>
				
				In march I created a BlogCFC pod to show Twitter messages using the JS Twitter badge script. Recently, Twitter changed the location of the script.

So, my script
&lt;br/&gt;http://www.twitter.com/t/status/user_timeline/3026521?callback=twitterCallback&amp;count=10
&lt;br/&gt;changed to
&lt;br/&gt;http://www.twitter.com/statuses/user_timeline/3026521.json?callback=twitterCallback&amp;count=10

Also, Twitter&apos;s server seems to have load issues at times. This can pause pages to render slowly while they wait for the script file. So, if you move the script include to the bottom of tags/layout.cfm, then it won&apos;t interfere with the page rendering.

The download is still available &lt;a href=&quot;http://www.cfchris.com/cfchris/DownLoads/twitterJS.zip&quot;&gt;here&lt;/a&gt;. And I&apos;d still love to hear if anyone uses it on their blog.
				
				</description>
						
				
				<category>JavaScript</category>				
				
				<category>Twitter</category>				
				
				<category>Blogging</category>				
				
				<pubDate>Tue, 05 Jun 2007 23:20:00 -0700</pubDate>
				<guid>http://www.cfchris.com/cfchris/index.cfm/2007/6/5/BlogCFC-JS-Twitter-Pod-Updated</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Google Gears Could Help Make Your Apps Work Offline</title>
				<link>http://www.cfchris.com/cfchris/index.cfm/2007/5/30/Google-Gears-Could-Help-Make-Your-Apps-Work-Offline</link>
				<description>
				
				I saw this story about &lt;a href=&quot;http://code.google.com/apis/gears/index.html&quot; target=&quot;_blank&quot;&gt;Google Gears&lt;/a&gt; on Ryan&apos;s blog earlier. It is such cool news that I wanted to make sure it got spread. Having a consistent cross-browser, cross-platform way to implement an &quot;occasionally connected&quot; work-flow for web-applications seems like huge news to me. Plus, Google + Adobe + Mozilla = Happy if you ask me.

I&apos;ve already installed Gears and tried it with Google Reader under both WinXP and PCLinuxOS 2007.

Please go and check out the &lt;a href=&quot;http://code.google.com/apis/gears/api_database.html&quot; target=&quot;_blank&quot;&gt;JavaScript syntax for executing SQL&lt;/a&gt; against a &lt;i&gt;local&lt;/i&gt; SQLite database.

&lt;blockquote&gt;&quot;&lt;a href=&quot;http://blogs.zdnet.com/Stewart/?p=399&quot; rel=&quot;bookmark&quot; title=&quot;Permalink&quot;&gt; What Google Gears means for Rich Internet Applications and Apollo&lt;/a&gt; by &lt;a href=&quot;http://zdnet.com&quot;&gt;ZDNet&lt;/a&gt;&apos;s Ryan Stewart -- Some big news today that Google is announcing an open source project called &quot;Google Gears&quot; which is an open source collaboration between Google, Adobe, Mozilla, and Opera that enables offline web applications in the browser. It seems very similar to the announcement that Mozilla made about the offline features in Firefox 3 and will be [...]&quot;&lt;/blockquote&gt;
				
				</description>
						
				
				<category>Web 2.0</category>				
				
				<category>JavaScript</category>				
				
				<category>Google</category>				
				
				<pubDate>Wed, 30 May 2007 23:56:00 -0700</pubDate>
				<guid>http://www.cfchris.com/cfchris/index.cfm/2007/5/30/Google-Gears-Could-Help-Make-Your-Apps-Work-Offline</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>BlogCFC Print Using DOM Injection</title>
				<link>http://www.cfchris.com/cfchris/index.cfm/2007/4/12/BlogCFC-Print-Using-DOM-Injection</link>
				<description>
				
				For some reason I clicked the print button on my blog the other day. It opened up a PDF in the tab I was in. Well, I just didn&apos;t like that (sorry Ray).

I recently built a print feature for an AJAX heavy project at work. Since this project uses Spry, the detail you see doesn&apos;t exist until javascript renders it in the browser. So, I came up with a solution of opening another window and then pushing the rendered contents into it. The new window even has a print.css. So, although it&apos;s the same mark-up, it looks different. 

If you want to see the code I wrote for work you can check it out &lt;a href=&quot;http://demo1.dealerpeak.net/index.cfm?fuseaction=configure.default&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;. Just drill all the way into a vehicle and click the print button on the right.

Anyway, I used the same idea to change the print functionality on my blog. I&apos;ve posted the resulting code and instructions for download &lt;a href=&quot;http://www.cfchris.com/cfchris/DownLoads/printJS.zip&quot;&gt;here.&lt;/a&gt;

If anyone uses it I would love to hear about it.
				
				</description>
						
				
				<category>JavaScript</category>				
				
				<category>Blogging</category>				
				
				<pubDate>Thu, 12 Apr 2007 21:57:00 -0700</pubDate>
				<guid>http://www.cfchris.com/cfchris/index.cfm/2007/4/12/BlogCFC-Print-Using-DOM-Injection</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Spry 1.5 Preview</title>
				<link>http://www.cfchris.com/cfchris/index.cfm/2007/4/3/Spry-15-Preview</link>
				<description>
				
				This is a little late...

But, Adobe snuck out a preview of &lt;a href=&quot;http://labs.adobe.com/technologies/spry/&quot; target=&quot;_blank&quot;&gt;Spry&lt;/a&gt; 1.5 on March 15th.

You can go get it &lt;a href=&quot;http://labs.adobe.com/technologies/spry/preview/&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.

If you haven&apos;t heard, Spry is an AJAX and DHTML JavaScript library. 

I&apos;ve been using it on a project at work. It&apos;s pretty slick. It reminds me of Flex the way you bind DataSets to &quot;controls&quot; and use curly brackets to reference variables. 

The 1.5 preview seems to have fixed a couple of small issues that I had with it. It also promoted JSON DataSets to first-class citizenship. And I think that rocks!

So, if you haven&apos;t already, go &lt;a href=&quot;http://labs.adobe.com/technologies/spry/&quot; target=&quot;_blank&quot;&gt;check it out&lt;/a&gt;.
				
				</description>
						
				
				<category>JavaScript</category>				
				
				<pubDate>Tue, 03 Apr 2007 17:14:00 -0700</pubDate>
				<guid>http://www.cfchris.com/cfchris/index.cfm/2007/4/3/Spry-15-Preview</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>BlogCFC JS Twitter Pod</title>
				<link>http://www.cfchris.com/cfchris/index.cfm/2007/3/31/BlogCFC-JavaScript-Twitter-Pod</link>
				<description>
				
				I was looking at the Twitter Badges that you can add to your site. I noticed that there was a JS implementation. I thought that would be cool because I could style it to match the rest of the site.

So, I created a new empty BlogCFC pod and pasted in the code that Twitter offered. Well, I have to say I was very un-impressed. It basically is only set up to display the current message and the time it was added. Except there&apos;s even a typo. So, it wasn&apos;t even showing the date.

After a little investigation, I got it to show the date, which turns out to be the raw date, not the &quot;about x [min|hours|days]&quot; that I was expecting.

Well, I took that as a challenge and began to build out similar functionality to the Flash Twitter badge in my JS Twitter badge.
				 [More]
				</description>
						
				
				<category>JavaScript</category>				
				
				<category>Twitter</category>				
				
				<category>Blogging</category>				
				
				<pubDate>Sat, 31 Mar 2007 22:06:00 -0700</pubDate>
				<guid>http://www.cfchris.com/cfchris/index.cfm/2007/3/31/BlogCFC-JavaScript-Twitter-Pod</guid>
				
			</item>
			
		 	
			</channel></rss>