Welcome to Dovetail Software Blogs : Sign in | Join | Help
Using modern JavaScript libraries to create a better user experience in fcClient

Over the last couple of years, a number of very useful JavaScript libraries and frameworks have been introduced that make it tremendously easier to build rich web applications. A few of the more popular ones:

These frameworks allow developers to easily write very rich, cross-browser web applications.

I've heard about these libraries for some time, and have experienced many great web apps that use these libraries.

So I asked myself whether I could use these modern libraries with fcClient. The answer is a resounding Yes!

A simple example: Modify the Save/Discard/Cancel page in order to improve the user experience.

How it used to work

If a page was "dirty", meaning that data on that page had changed, and the user attempts to dismiss the page (such as by clicking the Done button), then a Save/Discard/Cancel window is posted, which is a new IE window.

Here's what it looks like before:

subcase_sdc

The plan

I wanted to eliminate the additional IE window, thus reducing window clutter, and removing the physical disconnect between the dialog and the main window.

The library

I did some research and chose the Prototype Window class. This Javascript class allows you to create windows or dialogs in a HTML page.This class is based on Prototype. The code is inspired by the powerful script.aculo.us library. You can even use all script.aculo.us effects to show and hide windows.

The execution

On the main page, I include the prototype and window libraries, as well as the stylesheets:

<script type="text/javascript" src="../javascripts/prototype.js"> </script> 
<script type="text/javascript" src="../javascripts/window.js"> </script> 
<link href="../stylesheets/themes/default.css" rel="stylesheet" type="text/css"/>
<link href="../stylesheets/themes/alphacube.css" rel="stylesheet" type="text/css"/>

The click action for the Done button simply calls on the the OpenSaveDiscardCancelDialog function, if the page is dirty:

<a id="done" name="done" href="BLOCKED SCRIPTif(PageIsDirty())
{OpenSaveDiscardCancelDialog('save');} else { window.close(); }">
Done</a>

I created a new page saveDiscardCancel.htm which contains the OpenSaveDiscardCancelDialog function and the HTML elements to be included in the dialog:

<html>

<script type="text/javascript">
function OpenSaveDiscardCancelDialog(saveElementId){
  Dialog.info($('sdcDialog').innerHTML, {className:"alphacube",destroyOnClose:true,width:300,height:120});
  Dialog.SaveElementId = saveElementId;
}


function sdcSaveButtonClick(){
  Dialog.closeInfo();
  $(Dialog.SaveElementId).click();
}
</script>


<body>
<div id="sdcDialog" style="display:none">
  <p>
  The information on this page has been changed.
  </p>
  <p>
  Please choose one of the following:
  </p>
  <p>
  <input type="button" id="sdc_save"    value="Save"    onclick="sdcSaveButtonClick();" >
  <input type="button" id="sdc_discard" value="Discard" onclick="window.close();">
  <input type="button" id="sdc_cancel"  value="Cancel"  onclick="Dialog.closeInfo();">
  </p>
</div>
</body>
</html>

The result

Notice that we've used a "lightbox" presentation, where the main page is dimmed, and the new content is front, center, and clear - just where we want it. And notice that the Save/Discard/Cancel is not a separate page.

 subcase_sdc_lightbox

 

 

A similar example : an elapsed time dialog

Before:

subcase_duration  

 

After: 

subcase_duration_lightbox

 

Summary

It doesn't matter whether your web application is ASP.NET, Java, Ruby on Rails, or Classic ASP - these powerful Javascript libraries can make your developers more productive and make your user experience much richer.

Posted: Wednesday, September 26, 2007 3:53 PM by gsherman

Comments

Gary Storey said:

Another great javascript library is jquery (http://jquery.com/) and i amy personal favorite.  It has a "plugin" archetecture and has literally hundreds of plugins including some for ajax, menus, windows, tabs, and datepickers.

# September 28, 2007 10:15 AM

gsherman said:

Gary - thanks for reminding us about jQuery.

I forgot about that one.

I've heard good things about that library, its becoming pretty popular as well.

Curious - are you using it within fcClient?

# October 1, 2007 3:35 PM

Gary Storey said:

I am working with jquery on a couple of my side projects and once I am familiar enough with it, I plan on implementing it into our fcclient.  The side projects I am working on use the Drupal CMS and jquery is now bundled with it out of the box.  So far, I think it is a fantastic library.  

# October 8, 2007 2:24 PM