Javawin (Prototype Windows) patch

We've been using Javawin for a few months now; its a great windowing toolkit in pure JavaScript. Its good enough that, while demoing it recently, somebody complained because the modal windows still let them click. On the desktop.

One of the library's great features is configurable open/close effects per window instance. You can choose any effect from the Script.aculo.us library for bringing your window into being and getting rid of it when you are done. The latter, though, has a problem.

If you call setDestoryOnClose() on a window, this means that the instance will be terminated whenever the window is closed (as opposed to left hanging around taking up memory). However, the way the code in the library is written, this means that your hide effect will never be invoked and the window simply disappears. Here is the fix.

Change setDestroyOnClose to this:

  setDestroyOnClose: function() {
        if(!this.hideEffectOptions) this.hideEffectOptions = {};
        Object.extend(this.hideEffectOptions, {afterFinish:  
  this.destroy.bind(this)});
        this.destroyOnClose = true;     
    },

Change Windows.close to:

  close: function(id) {
        win = this.getWindow(id);
        // Asks delegate if exists
        if (win.getDelegate() && ! win.getDelegate().canClose(win))
            return;

         if (win) {
                this.notify("onClose", win);
                win.hide();
        }
     },

(just take out the call to win.destroy).