Interacting With YouTube Videos Inside A CFWindow

Posted By : todd sharp Posted At : January 19, 2009 9:25 PM Posted In: Ajax, ColdFusion

1

A friend wrote me today and asked:

I have a cfwindow that embeds YouTube content. The problem is that when you close the window the content keeps playing. Is there a way to unload the embedded content?

Progressively Enhanced Transcripts With jQuery

Posted By : todd sharp Posted At : January 15, 2009 10:08 AM Posted In: jQuery, Ajax, Usability, JavaScript, SlideSix

3

I quietly added a new feature to SlideSix earlier this week which now extracts the text contents of each slide and displays that text as a transcript on the view page of a presentation. The reason behind this enhancement is to dramatically increase the search engine visibility of your presentations since search engines will be basically indexing the content of each of your slides.

Removing The Shadow From A CFWindow (And Something To Watch For)

Posted By : todd sharp Posted At : December 3, 2008 10:42 PM Posted In: Ext, Ajax, ColdFusion

0

I received what seemed like a pretty simple question today given my background with ColdFusion 8 Ajax:

I've been looking for a way to simply eliminate the shadow on a cfwindow. The closest thing I could find so far is in your example of using ext to fade the window in/out, but is there a way I could do it with just css since I don't need the fade effect?

Preventing Double Form Submission With jQuery Revisited

Posted By : todd sharp Posted At : July 17, 2008 3:32 PM Posted In: jQuery, Ajax, ColdFusion

4

I had a request via IM for a more complete example of doing validation within a form submission. I threw together a quick example here to better explain my thought process. Please remember I'm new to jQuery so what I'm doing might not be an example of best practices. Feel free to suggest an alternative.

So essentially I need to capture the submit event of my form. In this case I'm assuming a single form so I simply refer to the tag name in my selector, but I'm sure you could just as easily refer to an id. Here is a simple wrapper to capture the form submission:

Quick jQuery Tip - Preventing Double Form Submission

Posted By : todd sharp Posted At : July 17, 2008 9:05 AM Posted In: jQuery, Ajax

18

Last night I wanted to implement a simple measure to prevent double form submissions so I of course turned to my newest best friend for a little help. My goal was simple - when the form was submitted just swap out the submit button for a little animated gif and a 'Saving' message. My first thought was to capture the click of the submit button like so:

HTML OnMissingImage - With Dynamic Content

Posted By : todd sharp Posted At : April 21, 2008 12:41 PM Posted In: Ajax

0

This morning Rob Gonda blogged about using the 'onerror' attribute of the <img> tag to display an alternate image if your image does not load. I tried this solution within a dynamic Spry region, and it didn't seem to work. I'm guessing that the onerror is fired once and only once, and since the image src is dynamic (within my Spry region) it is not firing the onerror again so the initial replacement image is loaded.

Thanks to some good discussion in the comments I devised a method to get this to work with my Spry region. It's pretty simple really, just register an observer on the region, and once the region is updated loop over the dataset, checking to see if the image is loaded. If not, replace it with your 'oops' image. Here's some code:

observer = function(type,notifier,data){
    if(type == 'onPostStateChange'){
        var ds = dsName.getData();
        
        for(var i = 0; i<ds.length; i++){
            //assumes you've named your image {ID}_img
            
            var id = ds[i].ID + '_img';
            
            //check to see if the image was loaded
            
            if(!document.images[id].complete){
                 document.getElementById(id).src = 'oops.jpg';
            }
        }
    }
}
Spry.Data.Region.addObserver('regionName', observer);

That's it!

Managing Sessions In CF Ajax Applications

Posted By : todd sharp Posted At : April 9, 2008 10:58 AM Posted In: Ajax

9

Everyone is likely familiar with standard application logic for managing authenticated sessions with ColdFusion. Typically you do some sort of check inside your Application.cfc file (usually in onRequestStart()) and if the current user is not authenticated (or there session has timed out) you redirect them to a login screen. Nothing new there, but when you think of the nature of an Ajax application you realize that there is a fundamental issue with that concept. What happens if a cfdiv were to be refreshed and the users session has timed out? Well, likely your cfdiv would then contain the results of the redirection (maybe a login.cfm template), but that may not be the 'prettiest' solution depending on your application.

So I put together a quick application to demo one possible solution. The basic concept this:

  • Log a timestamp of the last 'hit' by a given user in their session
  • Create a simple facade that looks at the time difference between the last hit and the current time
  • Create a ajax proxy to query that session facade
  • Make sure the proxy request does not update the 'last hit' - otherwise your session will never time out
  • Run a call to the session facade (via the ajax proxy) on a set interval
  • Evaluate the inactivity period, if in a 'warning' period (say between 15-19 minutes) display a modal window warning the user.
  • If the user chooses to extend the session, ping the session facade which will update the 'last hit' variable.
  • If the inactivity is beyond the session timeout (I usually go with >= 19 minutes display a modal (non-closable) window telling them the session has timed out

I have a demo online here. If you open the demo and wait longer then a minute you'll be warned. Longer then 2 minutes and you're logged out. Full source is attached to this entry. As always, feel free to post questions/comments.

CFGrid Date Picker Editor

Posted By : todd sharp Posted At : April 7, 2008 4:29 PM Posted In: Ext, Ajax, ColdFusion

28

A few weeks ago Dan Vega blogged about creating a comboxbox (drop down) cell editor for the editable <cfgrid> before he realized that cfgrid supports in cell drop downs. I commented that I'd like to see something like a date picker cell editor and after using Dan's orginal code as inspiration and some hints from this post by Scott Bennett I finally got the thing working. Yes, I do realize that sometimes it'd just be easier to roll your own Ajax widget from scratch, but sometimes hacking it is more fun.

I'll leave it to Dan and Scott's original posts to explain the details, but here is what you'll end up with:

And here's the code:

<cfsetting showdebugoutput="false">

<cfajaximport tags="cfinput-datefield" />

<html>
<head>
<title>Edit Artist Grid</title>
<link href="/CFIDE/scripts/ajax/ext/resources/css/ytheme-aero.css" rel="stylesheet" type="text/css">

<style>
.x-menu-list{
margin: 0px; padding: 0px;
}
</style>

<script type="text/javascript" src="/CFIDE/scripts/ajax/ext/ext-all.js"></script>

<script type="text/javascript">
function init(){
//grid object

grid = ColdFusion.Grid.getGridObject("ArtistGrid");

//column model

cm = grid.getColumnModel();

//we need to know the column id

stIndex = cm.findColumnIndex("LASTMODIFIED");

var df = new Ext.grid.GridEditor(
    new Ext.form.DateField(
        {
            format: 'm/d/Y',
            minValue: '04/01/08',
        }
    )
);


cm.setEditor(stIndex, df);
cm.setRenderer(stIndex, Ext.util.Format.dateRenderer('m/d/Y'));

grid.reconfigure(grid.getDataSource(),cm);
}
</script>
</head>

<body>



<cfquery name="getArtists" datasource="cfartgallery">
SELECT artistId, firstname, lastname, address, city, state,
postalcode, email, '04/01/2008' as lastModified
FROM Artists
</cfquery>

<cfset args = structNew()>
<cfset args.name = "ArtistGrid">

<cfset args.format = "html">
<cfset args.query = "getArtists">
<cfset args.stripeRows = true>
<cfset args.selectColor = "##D9E8FB">
<cfset args.selectmode = "edit">
<cfset args.onchange = "cfc:artists.editArtist({cfgridaction},{cfgridrow},{cfgridchanged})">

<cfform>
<cfgrid attributeCollection="#args#">
<cfgridcolumn name="artistid" display="false">
<cfgridcolumn name="firstname" header="First Name">
<cfgridcolumn name="lastname" header="Last Name">
<cfgridcolumn name="address" header="Address">
<cfgridcolumn name="city" header="City">
<cfgridcolumn name="state" header="State">
<cfgridcolumn name="postalcode" header="Zip">
<cfgridcolumn name="lastModified" header="Last Modified">
</cfgrid>
</cfform>

<cfset ajaxOnLoad("init")>
</body>
</html>

Progressive Enhancement With ColdFusion 8 Ajax

Posted By : todd sharp Posted At : March 17, 2008 1:00 PM Posted In: Ajax, JavaScript, ColdFusion

10

I've been heavy into some research lately, trying to become more familiar with some advanced concepts. Part of such research has been to learn more about Progressive Enhancement. I wouldn't exactly call myself an expert on the topic, but essentially it's a shift in mindsight from what I've gotten used to with Ajax development over the last year.

Speaking At April CFUG Meeting

Posted By : todd sharp Posted At : March 17, 2008 12:18 PM Posted In: Model-Glue, Ajax, ColdFusion

0

I will be presenting a preview of my cf.objective() presentation 'Integrating ColdFusion 8 Ajax with Model-Glue Applications' at the Cleveland ColdFusion User Group meeting on April 10.

I've been trying to attend more meetings in person but things often come up for me. Brian Meloche and Dan Vega do a great job with the group, so if you're in the area you should try to attend. I believe Brian is also presenting at the April meeting and I think Dan is presenting in May.