Make Modal Box optionally deactivate on show

33 views
Skip to first unread message

Grecy

unread,
Oct 8, 2008, 3:28:58 PM10/8/08
to ModalBox
Hey everyone,

We would like to make a modal box optionally come up in the
'deactivate' state when launched.
This is so it can be used to show something like a progress bar, that
can't be escaped out of, or closed.
The reason I would like this to happen on launch, is that the modalBox
window in our example doesn't have any user interaction (ie no
buttons, etc.) so calling the deactivate() function manually is not
really an option.

I have made the modifications myself and they work really well, I'm
hoping to get them added in a future version.
Basically, I added a 'deactivateOnLaunch' to options (default false).
if it is set to true, then in show(), I call deactivate().

Here are the changes I have made.

Index: Shared/WebServerResources/js/modalbox.js
===================================================================
--- Shared/WebServerResources/js/modalbox.js (revision 10936)
+++ Shared/WebServerResources/js/modalbox.js (working copy)
@@ -35,7 +35,8 @@
params: {},
method: 'get', // Default Ajax request method
autoFocusing: true, // Toggles auto-focusing for form elements.
Disable for long text pages.
- aspnet: false // Should be use then using with ASP.NET costrols.
Then true Modalbox window will be injected into the first form
element.
+ aspnet: false, // Should be use then using with ASP.NET costrols.
Then true Modalbox window will be injected into the first form
element.
+ deactivateOnLaunch: false //If the ModalBox is 'deactive' when
launched.
},
_options: new Object,

@@ -106,6 +107,9 @@
this._update();
this.event("onUpdate"); // Passing onUpdate callback
}
+
+ if(this.options.deactivateOnLaunch)
+ this.deactivate(options);
},

hide: function(options) { // External hide method to use from
external HTML and JS

Thanks very much,
-Dan

Andrey Okonetchnikov

unread,
Oct 8, 2008, 7:24:01 PM10/8/08
to moda...@googlegroups.com
Why not to use the "afterLoad" or "onShow" callback? It's much easier
and doesn't require any source code changes.

Andrey

--
With best regards,
Andrey Okonetchnikov

Grecy

unread,
Oct 9, 2008, 12:13:10 PM10/9/08
to ModalBox
Andrey,

You're absolutely right. We figured that out after we played for a
long time.

I'm not sure if it's because of ModalBox, or how we are using it
inside of Ajax inside of Wonder inside of WebObjects <grin>, but we
need to use notation like:
beforeLoad = "function() { Modalbox.deactivate(); }";

instead of just
beforeLoad = "Modalbox.deactivate();";

I'm still trying to get my head around the JavaScript notation.

Thanks again!
-Dan

On Oct 8, 5:24 pm, "Andrey Okonetchnikov"

Andrey Okonetchnikov

unread,
Oct 9, 2008, 12:18:29 PM10/9/08
to moda...@googlegroups.com
That's because of how Ajax requests will be passed to browser. So
don't think about it, it's the right way to use it.

But you can do it just on Modalbox call. Ex: Modalbox.show(url,
{beforeLoad: function() { Modalbox.deactivate(); } });

Try it out.

Andrey

Reply all
Reply to author
Forward
0 new messages