<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atomfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" version="0.3" xml:lang="English">
<title>Web Application Mania blog posts</title>
<link rel="alternate" type="text/html" href="http://www.webappmania.com/blog" />
<tagline>Web Application Mania posts - programming, web design, productivity, web standards</tagline>
<modified>2009-07-20 10:37:33</modified>
<generator url="http://www.webappmania.com" version="1.0">Web Application Mania</generator>
<copyright>Copyright 2007-2008 by Web Application Mania.</copyright>
<link rel="start" href="http://feeds.feedburner.com/webappmania_blog" type="application/atom+xml" /><entry>
<title>Java Script form handler class. Part 2:  implementing the locking feature.</title>
<link rel="alternate" type="text/html" href="http://www.webappmania.com/blog/java_script_form_handler_class_part_2_implementing_the_locking_feature" />
<id>tag:12</id>
<issued>2008-06-24T11:28:07+00:00</issued>
<modified>2008-06-24T11:28:07+00:00</modified>
<description>Java Script form handler class. Part 2:  implementing the locking feature.</description>
<created>2008-06-24T11:28:07+00:00</created>
<author><name>Web application mania</name></author>
<content type="text/html" mode="escaped" xml:lang="en-US"><![CDATA[<p>In <a href="http://www.webappmania.com/blog/java_script_form_handler_class_part_1_processing_hot_keys">part I</a> I've showed how I use my class FormHandler for processing hot keys in client-side forms. In this post I'm going to demonstrate the locking feature implemented in FormHandler. You may download an archive with all tutorial files here: <a href="http://www.webappmania.com/resources/blog/locks/locks.zip">locks.zip</a>.</p>

<p>Locking is necessary when you want to avoid executing some code while another code is being executed. Imagine, user clicks the Entery key on a product order form. You send an AJAX request to a server with order details. You don't want the user make another order by pressing the Enter key for the second time. What you want to do is to lock the form until the AJAX request is complete. In this case it's good to use the locking feature.</p>

<p>I have defined 3 methods in FormHandler class:</p>

<ul>
<li>setLock(Name) – add a lock with a specified name</li>
<li>getLock(Name) – check whether a lock with a specified name exists</li>
<li>removeLock(Name) – deletes a lock with a specified name</li>
</ul>

<p>These methods have very simple imlementation. They use MooTools <a href="http://docs.mootools.net/Native/Hash">Hash</a> class.</p>

<ol class="Code">
<li>this.locks = new Hash();</li>
<li>..</li>
<li>getLock: function( Name )</li>
<li>{</li>
<li class="Ind1">return this.locks.has(Name);</li>
<li>}</li>
<li>…
</ol>

<p>After that I can use these methods in my form classes extending FormHandler this way:</p>

<ol class="Code">
<li>var KeyTester = new Class({</li>
<li class="Ind1">Extends: FormHandler,</li>
<li class="Ind1">initialize: function()</li>
<li class="Ind1">{</li>
<li class="Ind2">this.parent({</li>
<li class="Ind3">keyMap: {</li>
<li class="Ind4">'LoginForm:enter': this.login.bind(this)</li>
<li class="Ind3">}</li>
<li class="Ind2">});</li>
<li class="Ind1">},</li>
<li class="Ind1">login: function()</li>
<li class="Ind1">{</li>
<li class="Ind2">if (this.getLock('login'))</li>
<li class="Ind2">{</li>
<li class="Ind3">alert('The form is locked. Processing request...');</li>
<li class="Ind3">return;</li>
<li class="Ind2">}</li>
<li class="Ind2">this.setLock('login')</li>
<li class="Ind2">alert('Login form submitted!');</li>
<li class="Ind1">}</li>
<li>});</li>
</ol>

<p>When user presses the Enter key for the first time, the handler class sets the lock «login», that will not allow the method code to be executed for the seocond time. You may look how it work <a href="http://www.webappmania.com/blog_post_files/locks/index.htm">here</a>.</p>


<p>I widely use this method in my applications. It is simple, useful and it really saves time. Sometimes I develop complex pages where user can edit many objects on a same page. In such cases I assign dynamic names to locks, matching object identifiers.</p>

<p>In a next post I will go into detail on how I implemented the simple loading indicators support.</p><p>Tags: <a href="http://www.webappmania.com/blog/tags/javascript">javascript</a>, <a href="http://www.webappmania.com/blog/tags/tutorials">tutorials</a></p>]]></content>
</entry>
<entry>
<title>Java Script form handler class. Part 1: processing hot keys.</title>
<link rel="alternate" type="text/html" href="http://www.webappmania.com/blog/java_script_form_handler_class_part_1_processing_hot_keys" />
<id>tag:11</id>
<issued>2008-06-22T09:17:14+00:00</issued>
<modified>2008-06-22T09:17:14+00:00</modified>
<description>Java Script form handler class. Part 1: processing hot keys.</description>
<created>2008-06-22T09:17:14+00:00</created>
<author><name>Web application mania</name></author>
<content type="text/html" mode="escaped" xml:lang="en-US"><![CDATA[<p>In all my recent projects I use FormHandler - the class that solves tasks of handling hot keys, displaying load indicators and locking. I use this class for building client-side form classes.  In the following 3 tutorials I will reveal the class code and demonstrate examples of its usage.</p>

<p>This class is based on <a href="http://www.mootools.net">MooTools 1.2</a>. You may download all files for this tutorial here: <a href="http://www.webappmania.com/resources/blog/hot_keys/hotkeys.zip">hotkeys.zip</a>.</p>

<h4>Handling hot keys</h4>

<p>I like MooTools for it simplicity and an elegance of code based on this library. When I started developing the hot keys processing I decided this feature should be designed in the MooTools manner. As a result I got a class that I inherit in all client-side form classes in my applications. It is very simple to setup the key map in a constructor of a child class:</p>

<ol class="Code">
<li>this.parent({</li>
<li class="Ind1">keyMap: {</li>
<li class="Ind2">'control+l, control+d': this.reloadTasks.bind(this),</li>
<li class="Ind2">'LoginForm:enter': this.login.bind(this)</li>
<li class="Ind1">}</li>
<li>});</li>
</ol>

<p>You may look how it work <a href="http://www.webappmania.com/blog_post_files/hot_keys/index.htm">here</a>.</p>

<p>Class FormHandler implements MooTools <a href="http://docs.mootools.net/Class/Class.Extras#Options">Options</a> class. FormHandler options have keyMap key that is used for defining a correspondence between hot keys and handlers. A value to be passed to keyMap should be an object (or hash) with hot key definition strings in keys and handlers in values. The key definition strings syntax follows.</p>

<ul>
<li><strong>Just a key</strong> e.g. a, c</li>
<li><strong>Modifier(s)+key</strong> e.g. control+t, or control+alt+t</li>
<li><strong>Target or parent element Id: key</strong> e.g. LoginForm:enter or TaskList:control+a</li>
<li><strong>Multiple hot key sets in a same declaration</strong> e.g. control+t, alt+m</li>
</ul>

<p>In the <a href="http://www.webappmania.com/blog_post_files/hot_keys/index.htm">example</a> I have defined the simple KeyTester class that implements the FormHandler class.</p> 

<ol class="Code">
<li>var KeyTester = new Class({</li>
<li class="Ind1">Extends: FormHandler,</li>
<li class="Ind1">initialize: function()</li>
<li class="Ind1">{</li>
<li class="Ind2">this.parent({</li>
<li class="Ind3">keyMap: {</li>
<li class="Ind4">'TaskForm:shift+control+t,shift+control+m': this.addTask.bind(this),</li>
<li class="Ind4">'LoginForm:enter': this.login.bind(this)</li>
<li class="Ind3">}</li>
<li class="Ind2">});</li>
<li class="Ind1">},</li>
<li class="Ind1">addTask: function()</li>
<li class="Ind1">{</li>
<li class="Ind2">alert('Task added!');</li>
<li class="Ind1">},</li>
<li class="Ind1">login: function()</li>
<li class="Ind1">{</li>
<li class="Ind2">alert('Login form submitted!');</li>
<li class="Ind1">}</li>
<li>});</li>
<li>window.addEvent('load', function(){</li>
<li class="Ind1">new KeyTester();</li>
<li>});</li>
</ol>

<p>Please note - if HTML element identifiers are used in hot key declarations (<strong>TaskForm</strong>:shift+control+t) the FormHandler class should be instanced only after the page elements are loaded. You may process the onLoad or onDomReady events of window object for creating the object.</p>

<p>The code of FormHandler that is responsible for hot key handling is not so interesting to analyse it here. It parses the hot key definitions and finds a suitable handler when KeyDown event occurs. In the constructor it assigns a handler for KeyDown event for the Window object for all browsers and for Document object for Internet Explorer.</p>

<h4>Known issues</h4>

<p>Unfortunately it is not possible to cancel default event actions in some browsers. As these browsers have commands assigned with specific hot keys (like ctrl+t in FireFox for New Tab) this is impossible to use some combinations of hot keys in web applications.</p>

<h4>To be continued</h4>

<p>In following tutorials I will demonstrate how the locks functionality is implemented. The locks are useful when you need to prevent a code execution until some previous call is complete. This is especially necessary with AJAX requests initiated by hot keys. </p><p>Tags: <a href="http://www.webappmania.com/blog/tags/javascript">javascript</a>, <a href="http://www.webappmania.com/blog/tags/tutorials">tutorials</a></p>]]></content>
</entry>
<entry>
<title>Subversion client for Mac OS</title>
<link rel="alternate" type="text/html" href="http://www.webappmania.com/blog/subversion_client_for_mac_os" />
<id>tag:10</id>
<issued>2008-06-17T07:16:45+00:00</issued>
<modified>2008-06-17T07:16:45+00:00</modified>
<description>Subversion client for Mac OS</description>
<created>2008-06-17T07:16:45+00:00</created>
<author><name>Web application mania</name></author>
<content type="text/html" mode="escaped" xml:lang="en-US"><![CDATA[<p>Since I moved from Windows to Mac several months ago I was looking for Subversion client for Mac OS X. There are different options available for Mac OS:  Text Mate bundle, command line tools, and some tools with graphical interface. The reason I switched to Mac was its magical and inspirational environment so I was looking for a Subversion tool what would correspond to Mac elegant concept. I am a designer and I like beautiful things. </p>

<a rel="lightbox" class="FloatLeft" href="http://www.webappmania.com/resources/blog/versions/ui_hires.gif"><img alt="Click to enlarge" src="http://www.webappmania.com/resources/blog/versions/ui.jpg"/></a>

<p>Last week I came across such application - <a href="http://www.versionsapp.com/">Versions</a>. It is beta at the moment. But even now it is obvious it has all features any developer needs. I like Versions due to following reasons:</p>

<ul>
<li> It has graphical interface.</li>
<li>The interface is beautifully designed and polished, in keeping with the best traditions of Mac OS applications design.</li>
<li>The directory tree displays a status of each file and directory in the repository in a way that you can quickly determine what files have been modified or added.</li>
<li>It has great Timeline feature that displays a history of repository updates grouped by date.</li>
<li>All necessary commands like Add, Commit and Revert are available for each file or directory through the context menu.</li>
</ul>

<p>The user interface of Versions is very simple and intuitive. I recommend for everyone who strive to create a perfect working environment to have a look on this tool. </p><p>Tags: <a href="http://www.webappmania.com/blog/tags/tools">tools</a></p>]]></content>
</entry>
</feed>
