This post was imported from my old blog at http://dylanmccall.blogspot.com/2010/07/harvest-gsoc-week-9.html

The past week, unfortunately, hasn’t been very productive for me. Still, I have a few things to show!

I did a bunch of cleanup (again) and I toyed with animations for a while. There is now an animation (and a loading indicator) when new results are retrieved for the filters. One philosophy I have found myself following is that this UI that never, ever blocks on a task. So, no matter what is happening, you should always be able to click the same buttons you could before.
(On a related note, I’ve been very excited about Blender lately).

Turns out non-modal design has an interesting impact as far as loading indicators are concerned. I wanted this indicator to be totally unobtrusive, but also obvious. So, as soon as someone starts adjusting filters, they can see that Harvest is waiting, then loading results.

It’s a little bubble that appears from the top of the results and is always visible at the top of the screen as the user scrolls. Conveniently enough, the existing results are all pushed away to make room for it. That was an accident at first, but really it makes the slide in a bit more pronounced and it means it doesn’t overlap anything you may have been looking at. (And even if it does, you can fix that by scrolling up).

Pretty simple :)

I made a quick video to show how this is all working:

The other thing I tried doing was to have the Javascript interface record its state in the location so it can be bookmarked and navigated through in the browser history (with the Back and Forward buttons).

I learned a lot of terrifying things, since I’ve never done that before.

Of course, the first terrifying thing is that you can’t change any part of the URL except the part after #, which never gets sent to the server. Well, you can change the other parts, but when you do it redirects to the given URL. That’s a good thing, but it does make life a little difficult for me :)

So, what we need to do is change location.hash to describe the current state, just like we do with the query strings sent to the server. There also needs to be an event handler watching for that change. With those two bits in place, that event handler is called whenever the user presses the Back button or loads the page from a bookmark, and it can apply the given state.

There are piles of jQuery plugins for this job. Two stood out above the pack: Asual’s impressively professional looking jQuery Address, and Ben Alman’s deliciously silly sounding jQuery BBQ. After some pondering and licking my lips, I went with jQuery BBQ.

BBQ is very clever in its simplicity. It uses the existing jQuery.param stuff to generate a query string the usual way, then it puts that in the hash part of the url instead of the ? part. It adds a “deparam” function to deserialize those query strings, a browser-agnostic hashchange event, a few helper functions, a bunch of documentation, and that’s it.

Unfortunately, even with jQuery BBQ, my work got really loopy here. In short, there are a lot of variables to deal with already and adding more almost exploded my brain.
(That was no doubt strengthened by a brief interlude at the family cottage, where I regressed to glorious redneckism and finally unlearned PHP)

So, unfortunately, I’m going to hold off on that for now. I could have planned the Javascript stuff much better, and getting BBQ working smoothly is likely a rewrite away. It may be a bad idea anyway. If someone shares a link that has #querystring instead of ?querystring, that link won’t work for anyone who has Javascript disabled. Instead, I’ll probably go the Google Maps approach, offering a “Permalink” button but never editing the URL in operation.

Next up: nicely formatted package details, and editing opportunities!

One Response

  1. Marius Gedminas

    But if you implement AJAXy navigation without #hash manipulation, then the users' Back button will not work. The explicit "permalink" link solves some problems, but not all of them.