We're in beta-test of a site that uses addresses as part of a content profile in a few places. We have received pretty consistent negative feedback that stems from the delayed 'pop-up' nature of the provinces select box, and so we made some changes as reflected in the attached patch to address this. In particular:

  1. always display a throbber when country is selected and the JSON call is made to retrieve provinces,
  2. optionally add a "-- Please Select --" to the top of the provices select list when the list is returned to the browser,
  3. optionally have the province list always show even if no country is selected yet by initially having a single option of "Choose a country first",
  4. properly passing back error and required flags to the _addresses_provice_ajax function so that the 'required' and 'error' classes can be correctly added to the controls sent back to the browser, and
  5. wrapping the country element div and the new throbber div in an overall div so that the trobber can appear behind the country selector via css and javascript.

The attached patch borrows some ideas from More robust JavaScript to allow form theming, and also includes the following fixes:

  1. customising field labels for parts of the address,
  2. removing the check_plain function call from function theme_addresses_aname, as that call was causing things like apostrophies to appear as hex codes,
  3. ensuring the proper label is passed to the js for province, and
  4. improving the formatting of single-line display.

Comments

sdsheridan’s picture

StatusFileSize
new12.72 KB

Oops! We made a couple of mistakes in the patch. Please use this one instead!

Shawn

AlexisWilke’s picture

Title: Options for better user experience with province selection » Options for better user experience with province selection, look into better cache solution too

That looks good. I have a few problems with a couple changes, but other than that, it looks good.

Now, I was just thinking that if the addresses was to create a JS file for each province array that it generates, then the Browser would have a chance to cache those and we could even use a mechanism a la Boost to get the .js when they already exist without having to hit the database at all. Since there is no top secret information in those files, whether a hacker gains access to them wouldn't matter!

Now I'm not too sure whether it's possible to load a JS with AJAX and have the browser cache it... Worth a try though.

Thank you.
Alexis

sdsheridan’s picture

Good question. Have to confess it's a bit beyond my .js expertise at the moment, but I'm all ears. :-)

Do let me know with which bits you have issues vis-a-vis the patch, and let's see if we can come to a consensus on a course of action.

Shawn

bwinett’s picture

sdsheridan - thanks! I just tested your patch, and it works perfectly. Can we get it merged into the module?