<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Pure-Essence.Net &#187; non php code</title>
	<atom:link href="http://pure-essence.net/category/geeky/non-php-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://pure-essence.net</link>
	<description>You have to visit this geeky girl&#039;s blog.</description>
	<lastBuildDate>Fri, 10 Feb 2012 11:26:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='pure-essence.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Pure-Essence.Net &#187; non php code</title>
		<link>http://pure-essence.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://pure-essence.net/osd.xml" title="Pure-Essence.Net" />
	<atom:link rel='hub' href='http://pure-essence.net/?pushpress=hub'/>
		<item>
		<title>jQuery read only elements</title>
		<link>http://pure-essence.net/2011/09/22/jquery-read-only-elements/</link>
		<comments>http://pure-essence.net/2011/09/22/jquery-read-only-elements/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 00:47:40 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[non php code]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[readonly]]></category>

		<guid isPermaLink="false">http://pure-essence.net/?p=2171</guid>
		<description><![CDATA[There is a business requirement on a project I have at work to only allow a certain number of properties editable at a certain stage of the domain object&#8217;s life cycle. And like always, the properties defined to be editable could change in the future. I already have a page that allows the user to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=2171&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There is a business requirement on a project I have at work to only allow a certain number of properties editable at a certain stage of the domain object&#8217;s life cycle. <b>And like always, the properties defined to be editable could change in the future.<b></p>
<p>I already have a page that allows the user to edit all properties of the domain object, I really do not wish to duplicate that code. Please note that if you set an input element on a form as <b>disabled</b>, the value associated with the element will <b>NOT be submitted via form post</b>, that certainly is NOT what I&#8217;m looking for. I want the values of the *read only* fields still be submitted by the form but I just don&#8217;t want the user to edit the values. So I looked into using the readonly attribute in HTML. <a href="http://stackoverflow.com/questions/155291/can-html-checkboxes-be-set-to-readonly" target="_blank">It&#8217;s complete crap</a>. </p>
<p>For <a href="http://www.faqs.org/docs/htmltut/forms/_INPUT_DISABLED.html">faqs.org</a>:</p>
<blockquote><p>It&#8217;s important to understand that READONLY merely prevents the user from changing the value of the field, not from interacting with the field. In checkboxes, for example, you can check them on or off (thus setting the CHECKED state) but you don&#8217;t change the value of the field.</p></blockquote>
<p>Basically it works half-hearted and most browsers (IE, FF) do not indicate (by default) that a field is readonly. So the users will probably be left wondering why they cannot edit the field.</p>
<p>I searched around for an alternative and found <a href="http://plugins.jquery.com/project/readonly" target="_blank">this wonderful jQuery plugin readonly</a>. Even though I couldn&#8217;t get it to work right for my application, the idea behind it is genius. You basically put overlay layers on top of any input fields you wish to make read only. The plugin seems a bit outdated. Perhaps it doesn&#8217;t work well with the newer version of jQuery but the idea still works well. Therefore I implemented my own.</p>
<p>This implementation automatically makes all input fields read only unless the input field has the class <b>excludeMeFromReadOnly</b>. This is just my implementation for demonstration. I do not provide any support for this code. Use where you see fit.</p>
<p><b>CSS</b><br />
<pre class="brush: css; wrap-lines: false;">
.readOnlyOverlay {
	position: absolute;
	background-color: #666;
	opacity: 0.3;
	filter: alpha(opacity=30);
	padding: 0pt !IMPORTANT;
	margin: 0pt !IMPORTANT;
}
</pre></p>
<p><b>javascript function generateOverlay</b><br />
<pre class="brush: jscript; wrap-lines: false;">
function generateOverlay(element) {
	var dimension = getDimensions($(element));
	//console.log('top=' + dimension.top + ' left=' + dimension.left +' width='+ dimension.width + ' height=' + dimension.height);

	// disassociate corresponding label attributes so the value of the element cannot be changed by clicking on the labels
	var id = $(element).attr('id');
	var label = $('label[for=&quot;'+id+'&quot;]');
	$(label).removeAttr('for');
	
	// set my tabindex to -1 so tabs will ignore me
	$(element).attr('tabIndex', -1);
	$(label).attr('tabIndex', -1);

	// create a div overlay
	var overlay = $('&lt;div class=&quot;readOnlyOverlay&quot;&gt;&amp;nbsp;&lt;/div&gt;').appendTo('body');
	$(overlay).css('top', dimension.top).css('left', dimension.left).css('width', dimension.width).css('height', dimension.height);
}
</pre></p>
<p><b>javascript function getDimensions</b><br />
<pre class="brush: jscript; wrap-lines: false;">
function getDimensions(element){
	var ret = {};

	// The multiple acquisitions of the CSS styles are required to cover any border and padding the elements may have.
	// The Ternary (parseInt(...) || 0) statements fix a bug in IE6 where it returns NaN,
	//  which doesn't play nicely when adding to numbers...
	ret.width = $(element).width() 
	  + (parseInt($(element).css('borderLeftWidth')) || 0)
	  + (parseInt($(element).css('borderRightWidth')) || 0)
	  + (parseInt($(element).css('padding-left')) || 0)
	  + (parseInt($(element).css('padding-right')) || 0);
	ret.height = $(element).height() 
	  + (parseInt($(element).css('borderTopWidth')) || 0) 
	  + (parseInt($(element).css('borderBottomWidth')) || 0)
	  + (parseInt($(element).css('padding-bottom')) || 0)
	  + (parseInt($(element).css('padding-bottom')) || 0);
	var offsets = $(element).offset();
	ret.left = offsets.left;
	ret.top = offsets.top;

	return ret;
}
</pre></p>
<p><b>jQuery selector</b><br />
<pre class="brush: jscript; wrap-lines: false;">
// select all input,select elements. I'd wrap my form in a div.
$('div#formContent input, div#formContent select, div#formContent textarea').each(function(i, element) {
	// if the element doesn't have the class named excludeMeFromReadOnly, overlay it to make it look like it's read only
	if(!$(element).hasClass('excludeMeFromReadOnly')) {
		generateOverlay($(element));
	}
});
</pre></p>
<p>Please note, the plugin contains a lot more logic including IE hacks etc. Fortunately for me, I really don&#8217;t care about IE prior to version 8 in my particular scenario. Therefore I don&#8217;t need all of those hacks.</p>
<p><b>&#8212;&gt;<a href="http://regretless.com/stuff/jQuery/readOnlyOverlay.html" target="_blank">Example code</a> (<a href="http://jsfiddle.net/dodozhang21/dVGNV/" target="_blank">example at jsFiddle</a>)&lt;&#8212;</b></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/2171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/2171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/2171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/2171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/2171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/2171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/2171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/2171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/2171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/2171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/2171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/2171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/2171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/2171/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=2171&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2011/09/22/jquery-read-only-elements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>
	</item>
		<item>
		<title>QUnit &#8211; test your javascript</title>
		<link>http://pure-essence.net/2011/07/24/qunit-test-your-javascript/</link>
		<comments>http://pure-essence.net/2011/07/24/qunit-test-your-javascript/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 16:28:06 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[non php code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[qunit]]></category>
		<category><![CDATA[unit test]]></category>

		<guid isPermaLink="false">http://pure-essence.net/?p=2139</guid>
		<description><![CDATA[After over ten years of javascript programming, I&#8217;m finally seriously considering writing at least unit tests for my javascript. Since I&#8217;m such a big fan of jQuery, QUnit seems like the obvious choice. It&#8217;s sad but better late than never. The truth is, in my opinion, the fact that javascript test frameworks do not yet [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=2139&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After over ten years of javascript programming, I&#8217;m finally seriously considering writing at least unit tests for my javascript. Since I&#8217;m such a big fan of jQuery, <a href="http://docs.jquery.com/QUnit">QUnit</a> seems like the obvious choice.</p>
<p>It&#8217;s sad but better late than never.</p>
<p>The truth is, in my opinion, the fact that javascript test frameworks do not yet maturely work with many of the continuous integration software deters programmers from using them. What&#8217;s the point of unit testing if they don&#8217;t automatically get run? Based on my research, <a href="http://www.jsunit.net/" target="_blank">JSUnit</a> is the only one that integrates with ANT innately. But JSUnit is more of an abandomware now so people are looking for alternatives.</p>
<p><strong>QUnit + CI topics</strong></p>
<ul>
<li>
<a href="http://lostechies.com/joshuaflanagan/2008/09/18/running-jquery-qunit-tests-under-continuous-integration/" target="_blank">jQuery tests under CI</a>
</li>
<li>
<a href="http://jupiterjs.com/#news/syn-a-standalone-synthetic-event-library" target="_blank">Syn instead of Selenium?</a>
</li>
<li>
<a href="http://docs.jquery.com/Qunit#Integration_into_Browser_Automation_Tools" target="_blank">QUnit and automated browser tools</a>
</li>
</ul>
<p>&gt;&gt; <a href="http://regretless.com/stuff/qunit/testSuite.html" target="_blank">Run my test suite</a> &lt;&lt;</p>
<p><strong>QUnit simple example:</strong></p>
<p>HTML:<br />
<pre class="brush: xml; wrap-lines: false;">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;Test Suite&lt;/title&gt;
	&lt;script src=&quot;http://code.jquery.com/jquery-latest.js&quot;&gt;&lt;/script&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;http://code.jquery.com/qunit/git/qunit.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/qunit/git/qunit.js&quot;&gt;&lt;/script&gt;
	&lt;!-- Your source files go here --&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;functions.js&quot;&gt;&lt;/script&gt;

	&lt;!-- Your tests files go here --&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;isEvenTest.js&quot;&gt;&lt;/script&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;startsWithTest.js&quot;&gt;&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
	&lt;h1 id=&quot;qunit-header&quot;&gt;QUnit example&lt;/h1&gt;
	&lt;h2 id=&quot;qunit-banner&quot;&gt;&lt;/h2&gt;
	&lt;div id=&quot;qunit-testrunner-toolbar&quot;&gt;&lt;/div&gt;
	&lt;h2 id=&quot;qunit-userAgent&quot;&gt;&lt;/h2&gt;
	&lt;ol id=&quot;qunit-tests&quot;&gt;&lt;/ol&gt;

	&lt;!-- Any HTML you may require for your tests to work properly --&gt;
	&lt;div id=&quot;qunit-fixture&quot;&gt;test markup, will be hidden&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre></p>
<p>Source javascript file:<br />
<pre class="brush: jscript; wrap-lines: false;">
function isEven(val) {
	return val % 2 === 0;
}

function startsWith(data, startsWithStr) {
	data = jQuery.trim(data);
	startsWithStr = jQuery.trim(startsWithStr);
	if(data) {
		return data.toUpperCase().lastIndexOf(startsWithStr.toUpperCase(), 0) === 0;
	} else if(data === startsWithStr) {
		return true;
	} else {
		return false;
	}
}
</pre></p>
<p>Sample test file:<br />
<pre class="brush: jscript; wrap-lines: false;">
$(document).ready(function(){

	module(&quot;startsWithTest&quot;);

	test('startsWith', function() { 
		ok(startsWith(&quot;ll-925&quot;, &quot;ll-&quot;), 'Starts with ll-'); 
		ok(!startsWith(&quot;ll-925&quot;, &quot;xl-&quot;), 'Does not start with xl-'); 
		ok(!startsWith(&quot;&quot;, &quot;xx-&quot;), 'Does not start with xx-'); 
		ok(startsWith(&quot; xx-sdgj &quot;, &quot;xx-&quot;), 'Trimming test: starts with xx-'); 
		ok(startsWith(&quot; xx-sdgj&quot;, &quot; xx- &quot;), 'Trimming test 2: starts with xx-'); 
		ok(startsWith(&quot;&quot;, &quot; &quot;), 'Empty string starts with empty string'); 
		ok(startsWith(&quot;Mn-u59&quot;, &quot;mN-&quot;), 'Non case sensitive test'); 
//		raises(startsWith(foo, &quot; &quot;), 'Undefined test 1');  // undefined is obviously not considered a normal exception
	}) 

});
</pre></p>
<p>&gt;&gt; <a href="https://github.com/dodozhang21/QUnit-Example" target="_blank">git repo for the source</a> &lt;&lt;</p>
<p><strong>Additional resources:</strong></p>
<ul>
<li><a href="http://net.tutsplus.com/tutorials/javascript-ajax/how-to-test-your-javascript-code-with-qunit/" target="_blank">QUnit tutorials</a></li>
<li><a href="http://docs.jquery.com/QUnit#API_documentation" target="_blank">API documentation</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/2139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/2139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/2139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=2139&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2011/07/24/qunit-test-your-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>
	</item>
		<item>
		<title>Use modal windows for delete confirmations please</title>
		<link>http://pure-essence.net/2011/03/01/use-modal-windows-for-delete-confirmations-please/</link>
		<comments>http://pure-essence.net/2011/03/01/use-modal-windows-for-delete-confirmations-please/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 21:00:15 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[non php code]]></category>
		<category><![CDATA[delete confirmation]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQueryUI]]></category>
		<category><![CDATA[modal window]]></category>

		<guid isPermaLink="false">http://pe20110517.wordpress.com/?p=1778</guid>
		<description><![CDATA[While reviewing an existing project at work, I notice it has many delete confirmation pages. In my opinion, delete confirmation PAGES should really just retire from the face of the earth. Seriously, why do we need to create a http request &#38; html for the mere purpose of asking &#8220;Are you sure you wish to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1778&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While reviewing an existing project at work, I notice it has many delete confirmation pages. In my opinion, delete confirmation PAGES should really just retire from the face of the earth. Seriously, why do we need to create a http request &amp; html for the mere purpose of asking</p>
<p>&#8220;Are you sure you wish to delete blah?&#8221;</p>
<p>Yes, I&#8217;m sure | No, go back</p>
<p>Often the URLs for delete confirmation pages are consisted of</p>
<p>some.host/someApplication/deleteConfirmation?toDelete=<b>some+description</b>&amp;id=<b>some+id</b></p>
<p>Delete confirmation should be an UI client side behavior to prevent the user from accidentally clicking on a delete link/button and forcing a backend change to the data that was not intended.</p>
<p><img src="http://regretless.com/stuff/jQuery/jQueryDeleteConfirmation.png" /></p>
<p><b>Preconditions</b></p>
<p>The delete actions are hyperlinks. There are many examples with delete actions as form submissions. My example expects the delete actions to be links such as <b>delete.php?id=#</b>. I believe this is a more challenging situation than a form submission. I will share my solution. I think ideally it will be nice for <a href="http://jqueryui.com/demos/dialog/">the jQuery UI dialog</a> to return a boolean javascript variable but since it currently does not (and I&#8217;m not sure it ever will), I&#8217;m using window.location to load the delete action link. </p>
<p><a href="http://regretless.com/stuff/jQuery/deleteConfirmationNoJs.html"><span style="font-size:1.5em;">View the example of the page without any jQuery</span></a></p>
<p>Please have some general knowledge regarding <a href="http://api.jquery.com/category/selectors/">jQuery selectors</a>. I will not go into details how that works.</p>
<p>Assume you have a way of using jQuery selectors to uniquely bind an onclick event to each delete link. For simplicity purpose, in my example, all of my delete links will have the css class <b>deleteConfirmation</b>.</p>
<p><b>jQuery UI example of a delete confirmation modal window</b><br />
I will be using links from <a href="http://code.google.com/apis/libraries/devguide.html">Google CDN</a> in my example.</p>
<p><b>Step 1</b><br />
Create a div with an unique id in your html markup. It doesn&#8217;t matter where it exists in your markup, it just need to exist. We will create the jQuery UI dialog off it.<br />
<pre class="brush: xml; wrap-lines: false;">
&lt;div id=&quot;jQueryDeleteConfirmationModalWindow&quot;&gt;&lt;/div&gt;
</pre></p>
<p><b>Step 2</b><br />
When the DOM is loaded, create your jQuery UI dialog and have its autoOpen property set to false. This allows us to reuse this dialog for all delete confirmations.<br />
<pre class="brush: jscript; wrap-lines: false;">
// create the jQuery modal window and set autoOpen to false
$(&quot;#jQueryDeleteConfirmationModalWindow&quot;).dialog({
	title: &quot;Delete Confirmation&quot;,
	autoOpen: false,	// set this to false so we can manually open it
	dialogClass: &quot;jQueryDeleteConfirmationModalWindow&quot;,
	closeOnEscape: false,
	draggable: false,
	width: 460,
	height: 260,
	modal: true,
	buttons: {
			&quot;Yes, I'm sure&quot;: function() {
				$( this ).dialog( &quot;close&quot; );
			},
			Cancel: function() {
				$( this ).dialog( &quot;close&quot; );
			}
		},
	resizable: false,
	open: function() {
		// scrollbar fix for IE
		$('body').css('overflow','hidden');
	},
	close: function() {
		// reset overflow
		$('body').css('overflow','auto');
	}
}); // end of dialog
</pre></p>
<p><b>Step 3</b><br />
Bind the onclick events to the delete action links via the css class <b>deleteConfirmation</b>.<br />
<pre class="brush: jscript; wrap-lines: false;">
$('a.deleteConfirmation').click(function() {
	var name = $(this).parent().parent().children('td.name').html(); // a.delete -&gt; td -&gt; tr -&gt; td.name
	name = jQuery.trim(name);
	$(&quot;#jQueryDeleteConfirmationModalWindow&quot;).html('Are you sure you wish to delete ' + name + '?');
	$(&quot;#jQueryDeleteConfirmationModalWindow&quot;).dialog('open');
	return false;
});
</pre><br />
Notice I also made it so my confirmation message will contain an unique description via the inner html property of another table cell of the same table row?</p>
<p><b>Step 4</b><br />
If the user clicks on &#8220;Yes, I&#8217;m sure&#8221;, we want to execute the delete action. Therefore, my solution is to create a global variable that contains the value of the hyperlink the user clicked on and then set it to the window.location if the &#8220;Yes, I&#8217;m sure&#8221; is clicked on the modal window.</p>
<p>As the first line inside of the script tag, add<br />
<pre class="brush: jscript; wrap-lines: false;">
var deleteTheSelectedUrl = '';
</pre></p>
<p>In the button &#8220;Yes, I&#8217;m sure&#8221;, after dialog close, add</p>
<p><pre class="brush: jscript; wrap-lines: false;">
if('' != jQuery.trim(deleteTheSelectedUrl)) {
	window.location = deleteTheSelectedUrl;
}
</pre></p>
<p>In the onclick event binding, add as the first line</p>
<p><pre class="brush: jscript; wrap-lines: false;">
deleteTheSelectedUrl = $(this).attr('href');
</pre></p>
<p><a href="http://regretless.com/stuff/jQuery/deleteConfirmation.html"><span style="font-size:1.5em;">View the final example</span></a></p>
<p><a href="https://github.com/dodozhang21/jQuery-delete-confirmation">github repo</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/1778/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/1778/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/1778/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/1778/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/1778/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/1778/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/1778/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/1778/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/1778/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/1778/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/1778/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/1778/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/1778/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/1778/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1778&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2011/03/01/use-modal-windows-for-delete-confirmations-please/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>

		<media:content url="http://regretless.com/stuff/jQuery/jQueryDeleteConfirmation.png" medium="image" />
	</item>
		<item>
		<title>itext page number (page x of y)</title>
		<link>http://pure-essence.net/2010/11/14/itext-page-number-page-x-of-y/</link>
		<comments>http://pure-essence.net/2010/11/14/itext-page-number-page-x-of-y/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 16:08:06 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[non php code]]></category>
		<category><![CDATA[itext]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[page x of y]]></category>

		<guid isPermaLink="false">http://localhost/pureEssence/?p=1691</guid>
		<description><![CDATA[I was looking for a complete example of how to dynamically generate the page numbers when you create the pdf using iText and I couldn&#8217;t find one. This is based on the example in the iText in Action book but I added my &#8220;refactoring&#8221; if you will. I hope this helps someone. If not, it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1691&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was looking for a complete example of how to dynamically generate the page numbers when you create the pdf using <a href="http://itextpdf.com/">iText</a> and I couldn&#8217;t find one. This is based on the example in the <a href="http://www.manning.com/lowagie/">iText in Action</a> book but I added my &#8220;refactoring&#8221; if you will.</p>
<p>I hope this helps someone. If not, it will definitely help myself in the future <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><pre class="brush: java; wrap-lines: false;">
public abstract class BaseReportBuilder extends PdfPageEventHelper {
	protected BaseFont baseFont;
	private PdfTemplate totalPages;
	private float footerTextSize = 8f;
	private int pageNumberAlignment = Element.ALIGN_CENTER;

	public BaseReportBuilder() {
		super();
		baseFont = load(&quot;fonts&quot;, &quot;tahoma.ttf&quot;);
	}

	private BaseFont load(String location, String fontname) {
		try {
			InputStream is = getClass().getClassLoader().getResourceAsStream(location + System.getProperty(&quot;file.separator&quot;) + fontname);

			ByteArrayOutputStream out = new ByteArrayOutputStream();
			byte buf[] = new byte[1024];

			while (true) {
				int size = is.read(buf);
				if (size &lt; 0)
					break;
				out.write(buf, 0, size);
			}
			is.close();
			buf = out.toByteArray();
			return BaseFont.createFont(fontname, BaseFont.CP1252, true, true, buf, null);
		} catch (Exception ex) {
			return null;
		}
	}

	@Override
	public void onOpenDocument(PdfWriter writer, Document document) {
		totalPages = writer.getDirectContent().createTemplate(100, 100);
		totalPages.setBoundingBox(new Rectangle(-20, -20, 100, 100));
	}

	@Override
	public void onEndPage(PdfWriter writer, Document document) {
		PdfContentByte cb = writer.getDirectContent();
		cb.saveState();
		String text = String.format(&quot;Page %s of &quot;, writer.getPageNumber());

		float textBase = document.bottom() - 20;
		float textSize = baseFont.getWidthPoint(text, footerTextSize);
		
		cb.beginText();
		cb.setFontAndSize(baseFont, footerTextSize);
		if(Element.ALIGN_CENTER == pageNumberAlignment) {
			cb.setTextMatrix((document.right() / 2), textBase);
			cb.showText(text);
			cb.endText();
			cb.addTemplate(totalPages, (document.right() / 2) + textSize, textBase);
		} else if(Element.ALIGN_LEFT == pageNumberAlignment) {
			cb.setTextMatrix(document.left(), textBase);
			cb.showText(text);
			cb.endText();
			cb.addTemplate(totalPages, document.left() + textSize, textBase);
		} else {
			float adjust = baseFont.getWidthPoint(&quot;0&quot;, footerTextSize);
			cb.setTextMatrix(document.right() - textSize - adjust, textBase);
			cb.showText(text);
			cb.endText();
			cb.addTemplate(totalPages, document.right() - adjust, textBase);
		}
		cb.restoreState();
	}

	@Override
	public void onCloseDocument(PdfWriter writer, Document document) {
		totalPages.beginText();
		totalPages.setFontAndSize(baseFont, footerTextSize);
		totalPages.setTextMatrix(0, 0);
		totalPages.showText(String.valueOf(writer.getPageNumber() - 1));
		totalPages.endText();
	}

	public void setPageNumberAlignment(int pageNumberAlignment) {
		this.pageNumberAlignment = pageNumberAlignment;
	}
}

public class PageNumberReportBuilder extends BaseReportBuilder {
	public ByteArrayOutputStream buildPage() {
		ByteArrayOutputStream stream = new ByteArrayOutputStream();
		Document document = new Document(PageSize.LETTER);
		
		try {
			PdfWriter writer = PdfWriter.getInstance(document, stream);
			writer.setPageEvent(this);
			document.open();
			// add your document stuff
		} catch(DocumentException e) {
			throw new RuntimeException(e);
		}
		
		document.close();
		return stream;
	}
}
</pre></p>
<p><a href="http://regretless.com/work/ItextPageNumbers.rar"><b>Download</b></a> the complete code example (eclipse project) along with jUnit tests where you can actually generate the PDF file.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/1691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/1691/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/1691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/1691/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/1691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/1691/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/1691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/1691/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/1691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/1691/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/1691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/1691/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/1691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/1691/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1691&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2010/11/14/itext-page-number-page-x-of-y/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>
	</item>
		<item>
		<title>Java instaniate an abstract class&#8230; sort of&#8230;</title>
		<link>http://pure-essence.net/2010/08/27/java-instaniate-an-abstract-class-sort-of/</link>
		<comments>http://pure-essence.net/2010/08/27/java-instaniate-an-abstract-class-sort-of/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 16:55:35 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[non php code]]></category>
		<category><![CDATA[abstract class]]></category>
		<category><![CDATA[instantiate]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://regretless.com/?p=1683</guid>
		<description><![CDATA[At work I had to create some test data for a junit test. The function I&#8217;m testing expects a super abstract class to be passed in and I need to test the same function for bunch of child classes. I wish I could just pass in the parent class but since it&#8217;s abstract I cannot [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1683&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At work I had to create some test data for a junit test. The function I&#8217;m testing expects a super abstract class to be passed in and I need to test the same function for bunch of child classes. I wish I could just pass in the parent class but since it&#8217;s abstract I cannot instantiate it. I wonder if there is a way using reflection so I can instantiate the class?? Since I could not find a way, I used the following:</p>
<p><pre class="brush: java; wrap-lines: false;">
public void testSomeFunction() throws Exception {
	ParentData data1 = populate(ChildDataOne.class);
	//..test..

	ParentData data2 = populate(ChildDataTwo.class);
	//..test..
}

private static ParentData populate(Class clazz) throws Exception {
	ParentData data = clazz.newInstance();
	data.setProperty1(&quot;1&quot;);
	data.setProperty2(&quot;2&quot;);
	data.setProperty3(&quot;3&quot;);
	data.setProperty4(&quot;4&quot;);
	data.setProperty5(&quot;5&quot;);
	return data;
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/1683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/1683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/1683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/1683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/1683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/1683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/1683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/1683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/1683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/1683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/1683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/1683/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/1683/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/1683/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1683&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2010/08/27/java-instaniate-an-abstract-class-sort-of/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>
	</item>
		<item>
		<title>jQuery session timeout countdown with jQueryUI dialog</title>
		<link>http://pure-essence.net/2010/02/14/jquery-session-timeout-countdown/</link>
		<comments>http://pure-essence.net/2010/02/14/jquery-session-timeout-countdown/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 14:24:16 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[non php code]]></category>
		<category><![CDATA[countdown]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[timeout]]></category>

		<guid isPermaLink="false">http://regretless.com/?p=1604</guid>
		<description><![CDATA[Very nice jQuery session timeout countdown example with the use of the jQuery idleTimer plugin. Here&#8217;s my example with the jQueryUI dialog as the warning. Here&#8217;s my example with the jQueryUI dialog as the warning.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1604&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Very nice <a href="http://www.erichynds.com/jquery/creating-a-mint-com-style-idle-logout-timer-using-jquery/">jQuery session timeout countdown example</a> with the use of the <a href="http://paulirish.com/2009/jquery-idletimer-plugin/">jQuery idleTimer plugin</a>.</p>
<p><a href="http://regretless.com/stuff/jQuery/jQuerySessionTimeoutCountdownWithDialog.html">Here&#8217;s my example with the jQueryUI dialog as the warning</a>.</p>
<p><pre class="brush: jscript; wrap-lines: false;">
var idleTime = 2000; // number of miliseconds until the user is considered idle
var initialSessionTimeoutMessage = 'Your session will expire in &lt;span id=&quot;sessionTimeoutCountdown&quot;&gt;&lt;/span&gt; seconds.&lt;br /&gt;&lt;br /&gt;Click on &lt;b&gt;OK&lt;/b&gt; to continue your session.';
var sessionTimeoutCountdownId = 'sessionTimeoutCountdown';
var redirectAfter = 10; // number of seconds to wait before redirecting the user
var redirectTo = ' http://regretless.com/2010/02/14/jquery-session-timeout-countdown/'; // URL to relocate the user to once they have timed out
var keepAliveURL = 'keepAlive.php'; // URL to call to keep the session alive
var expiredMessage = 'Your session has expired.  You are being logged out for security reasons.'; // message to show user when the countdown reaches 0
var running = false; // var to check if the countdown is running
var timer; // reference to the setInterval timer so it can be stopped
$(document).ready(function() {
	// create the warning window and set autoOpen to false
	var sessionTimeoutWarningDialog = $(&quot;#sessionTimeoutWarning&quot;);
	$(sessionTimeoutWarningDialog).html(initialSessionTimeoutMessage);
	$(sessionTimeoutWarningDialog).dialog({
		title: 'Session Expiration Warning',
		autoOpen: false,	// set this to false so we can manually open it
		closeOnEscape: false,
		draggable: false,
		width: 460,
		minHeight: 50,
		modal: true,
		beforeclose: function() { // bind to beforeclose so if the user clicks on the &quot;X&quot; or escape to close the dialog, it will work too
			// stop the timer
			clearInterval(timer);

			// stop countdown
			running = false;

			// ajax call to keep the server-side session alive
			$.ajax({
			  url: keepAliveURL,
			  async: false
			});
		},
		buttons: {
			OK: function() {
				// close dialog
				$(this).dialog('close');
			}
		},
		resizable: false,
		open: function() {
			// scrollbar fix for IE
			$('body').css('overflow','hidden');
		},
		close: function() {
			// reset overflow
			$('body').css('overflow','auto');
		}
	}); // end of dialog


	// start the idle timer
	$.idleTimer(idleTime);

	// bind to idleTimer's idle.idleTimer event
	$(document).bind(&quot;idle.idleTimer&quot;, function(){
		// if the user is idle and a countdown isn't already running
		if($.data(document,'idleTimer') === 'idle' &amp;amp;&amp;amp; !running){
			var counter = redirectAfter;
			running = true;

			// intialisze timer
			$('#'+sessionTimeoutCountdownId).html(redirectAfter);
			// open dialog
			$(sessionTimeoutWarningDialog).dialog('open');

			// create a timer that runs every second
			timer = setInterval(function(){
				counter -= 1;

				// if the counter is 0, redirect the user
				if(counter === 0) {
					$(sessionTimeoutWarningDialog).html(expiredMessage);
					$(sessionTimeoutWarningDialog).dialog('disable');
					window.location = redirectTo;
				} else {
					$('#'+sessionTimeoutCountdownId).html(counter);
				};
			}, 1000);
		};
	});

});
</pre></p>
<p><a href="http://regretless.com/stuff/jQuery/jQuerySessionTimeoutCountdownWithDialog.html">Here&#8217;s my example with the jQueryUI dialog as the warning</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/1604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/1604/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/1604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/1604/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/1604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/1604/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/1604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/1604/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/1604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/1604/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/1604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/1604/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/1604/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/1604/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1604&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2010/02/14/jquery-session-timeout-countdown/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>
	</item>
		<item>
		<title>Stupid IE does it again</title>
		<link>http://pure-essence.net/2010/02/12/stupid-ie-does-it-again/</link>
		<comments>http://pure-essence.net/2010/02/12/stupid-ie-does-it-again/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 16:42:12 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[non php code]]></category>
		<category><![CDATA[event delegation]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[live]]></category>

		<guid isPermaLink="false">http://regretless.com/?p=1602</guid>
		<description><![CDATA[I just learned IE does not support jQuery&#8217;s new live (event delegation) binding on the change event. Very nice IE, you did it again.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1602&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just learned IE does not support jQuery&#8217;s new <a href="http://api.jquery.com/live/">live (event delegation) binding</a> on the <strong>change</strong> event.</p>
<p>Very nice IE, <a href="http://www.neeraj.name/blog/articles/882-how-live-method-works-in-jquery-why-it-does-not-work-in-some-cases-when-to-use-livequery">you did it again</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/1602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/1602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/1602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/1602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/1602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/1602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/1602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/1602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/1602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/1602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/1602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/1602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/1602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/1602/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1602&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2010/02/12/stupid-ie-does-it-again/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>
	</item>
		<item>
		<title>Creative overlay/popup with jQuery</title>
		<link>http://pure-essence.net/2010/01/15/creative-overlaypopup-with-jquery/</link>
		<comments>http://pure-essence.net/2010/01/15/creative-overlaypopup-with-jquery/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 02:11:10 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[non php code]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[overlay]]></category>
		<category><![CDATA[popup]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://regretless.com/?p=1566</guid>
		<description><![CDATA[While doing a presentation on jQuery at work today, I went over a particular example I put together earlier today. I thought I&#8217;d share it with you here. In the past, we have used popups for editing values inside of a input box. The most well known example I can think of is smilies on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1566&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While doing a presentation on jQuery at work today, I went over a particular example I put together earlier today. I thought I&#8217;d share it with you here.</p>
<p>In the past, we have used popups for editing values inside of a input box. The most well known example I can think of is smilies on a forum script.<br />
<a rel="lightbox" href="http://regretless.com/wp-content/uploads/2010/01/smileyPopup.png"><img title="smileyPopup" src="http://regretless.com/wp-content/uploads/2010/01/smileyPopup-300x124.png" alt="" width="300" height="124" /></a><br />
There are shortcuts to insert smilies on the right side of the your textarea. Then if you want more, you click on the more link. A popup window shows up, in the new window, you may click on any of the smiley to insert the shortcut into the textarea where your post is.</p>
<p>There is nothing wrong with the old way. It&#8217;s working fine but I believe there is a better way to handle this kind of scenario.</p>
<p><a href="http://regretless.com/stuff/jQuery/creativeOverlay.html">Take a look at this example</a>. (<a href="http://regretless.com/stuff/jQuery/timeEditor.html">More complete example</a>)</p>
<p>When you click on &#8220;Edit Input&#8221;, a layer slides out and then if you click on anywhere else on the page to indicate you are done with that input field, the layer goes away. On the layer that slides out, you may display more smiley shortcuts.</p>
<p>Benefits of the new way:</p>
<ol>
<li>You are not making another http request</li>
<li>You are not opening another window so you don&#8217;t have to worry about popup blockers</li>
<li>You don&#8217;t have to worry about the parent window child window crap in javascript</li>
<li>The layer is on the same page as your regular input, it&#8217;s a lot easier to access its content</li>
<li>Your code is probably is easier to understand.</li>
</ol>
<p><strong>HTML:</strong><br />
<pre class="brush: xml; wrap-lines: false;">
&lt;div class=&quot;editing&quot;&gt;&lt;span id=&quot;trigger&quot;&gt;Edit Input&lt;/span&gt;
&lt;div id=&quot;toolWrapper&quot;&gt;Some kind of editing tool&lt;/div&gt;
&lt;/div&gt;
</pre></p>
<p>Very simple. Just an input box with a layer next to it. Within the layer is a trigger link (you may use an nice image icon if you wish).</p>
<p><strong>CSS:</strong><br />
<pre class="brush: css; wrap-lines: false;">
#trigger {
	cursor: pointer;
}
#toolWrapper {
	position:absolute;
	z-index:100;
	top:20px;
	left:20px;
	background:#eee;
	border:1px solid #111;
	display:none;
	-moz-border-radius: 6px;
	-webkit-border-radius: 6px;
	width:250px;
	padding-right:20px;
	height:200px;
}
div.editing {
	position: relative;
	display: inline;
}
</pre></p>
<p>The CSS utilizes the positioning trick. The outer wrapper (div.editing) is relatively positioned so the insider layer (#toolWrapper) may be positioned absolute to the outer one.</p>
<p><strong>jQuery:</strong><br />
<pre class="brush: jscript; wrap-lines: false;">
$(function() {
	$(&quot;#trigger&quot;).click(function() {
		$('#toolWrapper').toggle(function() {
			$(document).click(function(event) {
				if (!($(event.target).is('#toolWrapper') || $(event.target).parents('#toolWrapper').length || $(event.target).is('#trigger'))) {
					$('#toolWrapper').hide(500);
				}
			});
		});
	});
});
</pre></p>
<p>Uses the new <a href="http://api.jquery.com/toggle/#toggle2">toggle(showOrHide)</a> method &#8211; the logic depends on where you click on the page. I will let you digest it yourself. Read <a href="http://api.jquery.com/">the jQuery api</a> if you need <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://regretless.com/stuff/jQuery/timeEditor.html">Now take a look the time editor I wrote for work</a>. It uses <a href="http://jqueryui.com/demos/slider/">the slider widget from jQuery UI</a>. I will not go over the javascript used. Feel free to view source if you are curious.</p>
<p>jQuery just got a <a href="http://forum.jquery.com">new forum</a>!! WOOHOO. I never liked discussion groups anyway. Forum is much more preference community format for me.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/1566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/1566/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/1566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/1566/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/1566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/1566/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/1566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/1566/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/1566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/1566/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/1566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/1566/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/1566/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/1566/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1566&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2010/01/15/creative-overlaypopup-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>

		<media:content url="http://regretless.com/wp-content/uploads/2010/01/smileyPopup-300x124.png" medium="image">
			<media:title type="html">smileyPopup</media:title>
		</media:content>
	</item>
		<item>
		<title>Java List/Array syntax</title>
		<link>http://pure-essence.net/2009/12/30/java-listarray-syntax/</link>
		<comments>http://pure-essence.net/2009/12/30/java-listarray-syntax/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 15:05:02 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[non php code]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://regretless.com/?p=1457</guid>
		<description><![CDATA[Something I always forget, a shortcut array syntax for Java:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1457&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Something I always forget, a shortcut array syntax for Java:</p>
<p><pre class="brush: java; wrap-lines: false;">
List&lt;T&gt; listOfAnything = Arrays.asList(t1, t2);
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/1457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/1457/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/1457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/1457/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/1457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/1457/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/1457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/1457/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/1457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/1457/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/1457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/1457/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/1457/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/1457/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1457&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2009/12/30/java-listarray-syntax/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>
	</item>
		<item>
		<title>SpringMVC generic errors</title>
		<link>http://pure-essence.net/2009/12/29/springmvc-generic-errors/</link>
		<comments>http://pure-essence.net/2009/12/29/springmvc-generic-errors/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 19:34:56 +0000</pubDate>
		<dc:creator>pureessence</dc:creator>
				<category><![CDATA[geeky]]></category>
		<category><![CDATA[non php code]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[generic]]></category>
		<category><![CDATA[spring mvc]]></category>

		<guid isPermaLink="false">http://regretless.com/?p=1452</guid>
		<description><![CDATA[I was looking around the net for this. Maybe I didn&#8217;t look hard enough but I wasn&#8217;t able to find it. Finally a coworker told me. If you use the SpringMVC framework and wish to show generic validation error messages at the top of the page, here&#8217;s how you do it: Obviously if you wish [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1452&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was looking around the net for this. Maybe I didn&#8217;t look hard enough but I wasn&#8217;t able to find it. Finally a coworker told me. If you use <a href="http://www.springsource.org/">the SpringMVC framework</a> and wish to show generic validation error messages at the top of the page, here&#8217;s how you do it:</p>
<p><pre class="brush: xml; wrap-lines: false;">
&lt;spring:hasBindErrors name=&quot;formName&quot;&gt;
  &lt;div class=&quot;genericErrors&quot;&gt;
  &lt;span class=&quot;errorRight&quot;&gt;
	&lt;c:choose&gt;
	      &lt;c:when test=&quot;${errors.errorCount &gt; 1}&quot;&gt;
		    There are ${errors.errorCount} errors. Please correct them.
	      &lt;/c:when&gt;
	      &lt;c:otherwise&gt;
		    There is ${errors.errorCount} error. Please correct it.
	      &lt;/c:otherwise&gt;
	&lt;/c:choose&gt;
	Scroll down if necessary to see all of the error messages in red.
  &lt;/span&gt;
&lt;/div&gt;
&lt;/spring:hasBindErrors&gt;
</pre></p>
<p>Obviously if you wish to display specific error for a field, you&#8217;d use<br />
<pre class="brush: xml; wrap-lines: false;">
&lt;form:errors path=&quot;yourInputName&quot; /&gt;
</pre></p>
<p>To read more about error handling in SpringMVC, <a href="http://static.springsource.org/spring/docs/2.0.x/reference/mvc.html">read the chapter 13</a> of its documentation.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pe20110517.wordpress.com/1452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pe20110517.wordpress.com/1452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pe20110517.wordpress.com/1452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pe20110517.wordpress.com/1452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pe20110517.wordpress.com/1452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pe20110517.wordpress.com/1452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pe20110517.wordpress.com/1452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pe20110517.wordpress.com/1452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pe20110517.wordpress.com/1452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pe20110517.wordpress.com/1452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pe20110517.wordpress.com/1452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pe20110517.wordpress.com/1452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pe20110517.wordpress.com/1452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pe20110517.wordpress.com/1452/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pure-essence.net&amp;blog=23194870&amp;post=1452&amp;subd=pe20110517&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pure-essence.net/2009/12/29/springmvc-generic-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fcfd5e14ca9c91790e95dfdb1d2ad756?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pureessence</media:title>
		</media:content>
	</item>
	</channel>
</rss>
