Archive for the ‘blog-post’ Category

How to close a jQuery dialog box by clicking outside of it

Monday, November 30th, 2009

JQuery gives you a very simple way to create dialog overlays with the dialog() event. So, by clicking an HTML element you can activate a “stay-on-the-page” overlay dialog box.

Traditionally one might use dialog boxes to ask the user a question to which she must respond (e.g. with an “Ok” or “Cancel”) but their use can extend beyond this. For instance I’ve used a dialog to show a mega drop-down menu; i.e. clicking a link opens a dialog box with a list of categorised links.

JQuery’s default behaviour for closing dialog boxes is not unreasonable: the user must click on the “Close” button (e.g. in the form of text or an “x”) or hit the escape key. However it’s possible you may want to provide more options for your users to close a box by simply clicking outside it.

I puzzled over this and didn’t get very far with Googling but came up with the following solution which seems to work.

When your dialog is created, a div with the class “ui-widget-overlay” is also created which “greys out” the background allowing the user to fully focus on the dialog. You can use this as a hook to add your dialog closing code, e.g.


$(".ui-widget-overlay").live("click", function() {  $("#quick-links-modal").dialog("close"); } );

In this case my dialog has the ID “quick-links-modal”. NB you need to use the “live” event (rather than “click” etc.)  in order to bind the event to your dialog before the dialog has been initiated.

Interesting stuff I’ve learned at the Plone Conference 2009 (days 1-2)

Thursday, October 29th, 2009

There’s been lots of interesting stuff going on at this year’s Plone conference, but what’s really excited me are the user interface and general front-end developments taking place, particularly the Dexterity / Deco editing user interfaces and a sensible approach to site theming that doesn’t make your brain melt.

It’s great that there have been so many sessions focusing on these things as it demonstrates how seriously this stuff is being taken in Plone. Designers and integrators certainly have no need to feel like the poor cousins of the hardcore Python programmers and sys admins.

Here are some of the highlights so far:

1. TinyMCE

This is going to be used as the replacement page editor for Kupu in Plone 4 and upwards, although it’s also available to install as an add-on product in Plone 3.

This is great news as we’ve started to identify some serious usability problems with Kupu and we’re keen to get away from using the third-party commercial editor we’ve been using, Editon-Pro.

Whilst Editon-Pro is a great tool, its reliance on running in a Java Applet makes it slow, especially on older computers and it has no simple integration into the main Plone setup. The main advantage Kupu offered was its ability to insert links and images by browsing Plone’s folder structure and to allow users to upload images directly.

Unfortunately, Kupu doesn’t do many of the things that Editon-Pro does quite well, for instance handling page anchors. Kupu’s implementation of this is frankly baffling but TinyMCE’s handling is far closer to Editon-Pro’s and doesn’t require users to adjust their mental model (in Editon-Pro and TinyMCE users can insert their anchors; in Kupu users can only link to anchors which have been automatically created for them).

Another nice feature in TinyMCE is the paste from Word option which is something that Kupu doesn’t seem able to handle at all — Editon-Pro allowed users to “paste as plain text” which may have removed all formatting but at least it worked.

2. collective.xdv and Deliverance

Plone 3 theming is horrible. Just horrible I tell you! Luckily, this is a view shared with everyone else who has ever done Plone theming so two very similar new approaches have been developed: collective.xdv and Deliverance.

These both use rules-based theming to map sections of a Plone page to a custom-built HTML/CSS theme. In essence this means you create your own design and just display the bits of Plone you want in it (i.e. the content). The mapping is done via a XML rules file which in collective.xdv’s case needs to be created manually. For Deliverance these rules can also be created manually but there is also an exciting new project called Banjo (see what they did there?) which is a GUI for generating the rules and which also provides real-time previews of the integrated theme.

So, what’s the difference? In essence it appears that Deliverance is not just Plone-specific — it can be used to theme any third-party system whereas collective.xdv is completely Plone-specific. Xdv is a little easier to get started with as it’s integrated fully into the Plone architecture (as an add-on product) and Deliverance runs as a proxy on a webserver so has a higher installation / configuration overhead.

The good news is that they basically use the same syntax (statements such as “drop”, “replace” etc.) so it should be able to move easily between the two. However, xdv uses XPath to write rules (it’s XSLT-based) whereas Deliverance uses a slightly more designer-friendly CSS-style syntax.

3. Deco

Slightly confusingly there seem to two elements to Plones 4 and 5 called Deco. One is the basic grid layout CSS used for the new default Plone theme which is similar to other CSS layout tools such as 960.gs. The other part of the Deco framework is a drag-and-drop UI which allows content editors to add different elements to their pages without having to do complex things in the page editor.

From a UI perspective it’s a great approach, although the pessimist in me sees it could also be a recipe for some pretty horrendous looking pages.

4. jQuery tools

More UI loveliness –jQuery tools is a lightweight jQuery plugin which provides a lot of the functionality supplied by jQuery UI at a fraction of the download overhead.

In Plone 4+ this is used to provide some great UI controls such as login boxes in stay-on-the-page overlays and dialogues, tabs and carousels.

5. Dexterity

Dexterity is a replacement for Archetypes (Plone’s framework for creating content types) which can be installed as an add-on product for Plone 3. Whilst statements like that might usually make me run in horror, this is great news for a simple reason: it provides through the web content type creation, just as it should be. Basically, another great UI improvement — no more fiddling around with lots of Python code to create your content types.

So, overall there’s some great stuff here — many of the annoyances faced by designers and integrators have been addressed and it’s great to see such an emphasis put on usability.

Posted via email from What’s this for?

Review of Plone 3 Theming by Veda Williams

Sunday, September 27th, 2009

Plone 3 theming

Veda Williams‘ Plone 3 Theming (Packt, 2009) [Amazon UK | Amazon US | Packt] is a useful reference for anyone involved in customising the look and feel of their Plone-based website. Used alongside the various online resources on the plone.org website, particularly the Plone Theme Reference,  it should ease  most of the pain that Plone themers experience. Unfortunately (and this is not a criticism of the author), the book is let down by some poor copy-editing. It also contains a number of errata, which the author is gathering on the plone.org website.

The book is broken down into fifteen chapters, the most useful of which I found were chapters seven to twelve which deal with the day-to-day business of Plone theming.  These chapters cover customising viewlets and portlets, an overview of the Zope templating language ( ZPT), the creation and installation of a Plone theme, template changes, custom page views and theming tips. Although I’ve done a fair amount of Plone theming, I still find it quite esoteric and complex so it’s certainly very useful to have these chapters to refer back to.

Chapter fifteen, written by Alex Limi, gives an overview of the future of Plone theming using products such as collective.xdv and Deliverance. These seem an ultimately saner way to proceed and should allow non-Plone specialists to theme a site without getting too bogged down in Plone specifics. This article is also freely available on the Plone website where it will be updated as the project develops.

I did wonder if the second chapter was really necessary — this provides an overview of the main graphic design, browser and text editing tools. I imagine that most web designers and developers already know about these and the complete beginner would be encouraged to to stay away from Plone until they are a little more experienced.

That aside, the only real complaint I have about the book is the quality of the copy-editing. I think the text would in places benefit from a little slimming down or rephrasing. I occasionally struggled with some of the explanations , although it must be borne in mind that Plone 3 theming is complex so is by its very nature difficult to explain in simple terms. Some other examples: it’s probably not necessary to have sentences like, “now what, you ask?” in a tutorial book and I’m not sure why there is a lengthy code sample from Plone 2 on pages 129-30 which is really only produced to show how things were done the “old way”.

Anyone who has been involved in Plone theming will know how hard Veda Williams has worked on it: in addition to this book, she coordinated the Out of the Box Plone Themes project. For her work I’m sure she has the gratitude of every Plone themer. Hopefully subsequent editions of the book will address the editorial issues and errata.