Persistent dialog position and size

Persistent dialog position and size


Hi,
I have been using jQuery and jQuery UI for some time now. In a new
project I was writing an AJAX chat client using jQuery, I used the
dialog to display the users who sent new messages, clicking on each
user would open the chat window.
Anyway, the dialog was perfect except for a few minor issues. I did
not want it to display anything when there were no new messages, so it
had to be closed and opened again from time to time. But this caused
the box position to be reset again, each time. I thought it would be
annoying to the users so I modified this behavior externally, to use
the same position the user dragged it after it was closed and opened.
I have moved one step further, and decided to store the dialogs
position and size in a cookie, and use that the next time the user
opened the page.
I thought this was a good idea and decided to try extending the
current dialog (version 1.7.2) to have this option, which to my
surprise rather easy. The code really well written.
So I created a new option called "history", default is false. This can
be set whatever options you want to be used for cookies. It uses the
cookie plugin, and passes the history option as the options parameter
for the cookie plugin.
If the cookie plugin is included, and the history option is set, my
modification saves the position and size whenever they are changed by
dragging or resizing. And if there is already a cookie set, it uses
that to extract the position and size and overwrite these options. The
only drawback is that this modification uses the id property of the
dialog box to identify which dialog it is, since you can not store
reference to the element in the cookie. So if there is no id, or you
use the same id for different elements, there will be conflicts.
I know this is something fairly simple, but I thought some people
might like the idea and want to have something like this. I am
thinking of creating a more generic plugin which can be used to keep
attributes, position, size and content of any element in the cookies
and load them the next time page loads. This can come in handy for
some applications, like chat boxes. I am not sure if this would better
suit the jQuery plugin repository or the jQuery UI.
I tested this and it seems to work well. Let me know if anybody thinks
it is worth including in a release.