The plugin everyone has been waiting for: Impromtu 1.3!!! Sorry for dragging around for so long on this but its here a long with some awesome additions and bug fixes!! Whats different you ask?
- An option to focus a button by default
- An option for zIndex if you need to change it from the default
- If you click outside the prompt you will get a nice blinking effect on the prompt
- Escape key should now close the prompt without submitting the form
- $.prompt now returns a container with the fade and the prompt created
- Fixed a bug if the body was shorter than the window so was the fade
So all of these additions what did you take out? Just the container option. This option in my opinion was too buggy and not all that useful, so away it went. So there we have it, please give it a shot and remember, it doesn’t have any bugs, just undocumented “features”. Enjoy!
Related posts:


17 Responses
Diether
25|Feb|2008 1Nice work!
Fixed the fading problem in IE6 for me.
However, I found 2 undocumented “features” ;)
- The blinking doesn’t seem to work for me in IE6.
- We get a “This page contains secure and non-secure items” popup because our webapplication uses https. The cause of it is the iframe you use for the popup when using IE6 (with src=”").
As far as I know the iframe is just used for dropdown lists that always stay visible and on top of the popup?
So I’m just gonna see if I can hide all dropdowns when the popup is there (I believe that’s also how you did it prior to version 1.2).
But anyway, this is a great script and really fun to work with!
Keep up the good work!
Matt Wilson
25|Feb|2008 2Howdy Trent!
I love the plugin, and I love how simple the code is. Great job all around.
One question I have : Is there any way to pass a variable string as the button text? I have translated values for them being passed to me in the way of a function call and I’d like to pass those values in for the buttons. However my knowledge of JavaScript hashes are limited so I’m not sure how to go about doing this.
Thanks again for the great script!
Regards,
Matt
Oskar
25|Feb|2008 3Hello,
i use your script for my new website. It works very good.
I would like to have closing button at the top of popup that programatically close the popup.
I have managed to make button but i do not know how to close it programatically with JS. Can you provide the JS for that?
thanx very much and sorry for bothering you
trent
25|Feb|2008 4Diether, The iframe is mainly for the select box so yes hiding those should work just fine. Might could even snatch the old routine from the older version to do that. As far as the blinking in ie6 I will look into that.
Matt, Not sure if this helps or not but the quotes around the key in a hash is optional, so you might can say
{‘Ok’:true,’Cancel’:false}
Oskar, There are two ways to do this, which pretty much boil down to the same thing. Once you’ve added the button you need to add an event. $.prompt returns everything for the fade, so removing that will remove everything. Something like this might work:
var jqi = $.prompt(‘hello world’);
jqi.find(‘#jqi_close_button’).click(function(){
jqi.remove();
});
Or, you can go into the code of Impromptu and add the click event function “removePrompt” which is a built in Impromptu function which removes all events and elements.
I was debating adding a close button to Impromptu, but didn’t, I will add it to my todo list for the next version.
Diether
26|Feb|2008 5Indeed snatched the routine from the older version (0.3 to be exact), and it works fine :)
Harrison
26|Feb|2008 6I ran into the problem of the container being smaller than the window (with 1.2), so it was nice that you let out the new version the next day! =D One thing I noticed with the switch, though: After clicking a button, the fade doesn’t actually fade away anymore, but just cuts off. Was this intended? It worked fine when I just swapped out the two versions, but my code isn’t the simplest, most straightforward example, so that may be contributing.
trent
26|Feb|2008 7Diether, I guess I need completely drop the iframe solution since ie6 and an iframe will obviously not work on https.. My appologies on poor testing.
Harrison, I found the problem and I will release a fix tonight hopefully. The reason is I placed the fade and the prompt inside a container div, and that container div is removed before the fadeOut completes. So these two lines:
jqib.unbind(‘keypress’,escapeKeyClosePrompt);
jqib.remove();
need to be moved up one line into that callback function for jqif.fadeOut. Sorry!
Also during my testing I must have changed the return value. I noticed its returning jqi, my intentions with this release was to return jqib which is that div with the fade and the prompt
Matt Wilson
26|Feb|2008 8Thanks for the help Trent! I’ll look into sending in strings straight away.
Also, I’m not sure there’s a solution for hiding IE6 select elements correctly other than an iframe. Maybe if you let the user pass in a root domain there might be a way to properly set the source of the iframe to https://theirdomain.com. If you use createElement(‘iframe’) it inits immediately before you’re able to give it an attribute– I’m not sure what jQuery(”) would do, honestly.
Anyway thanks again for the great plugin, Trent. Simple, effective and reusable!
trent
26|Feb|2008 9What I may do is make iframe an option, if useiframe option is true then we will use it, otherwise I will do the old fashion hide select boxes routine. It is ugly but what else can you do?? Thanks for the the thoughts and for using the plugin!
Matt Wilson
28|Feb|2008 10Trent –
I’m still a little lost with the scenario that button text is passed in via variable, the hash always just takes in the variable name literally:
var ok = ‘not ok’;
$.prompt(‘lollerskates.’,
{ buttons: { ok : true, NO: false} }
);
});
The button will say ‘ok’ and not ‘not ok’. Do you know of a way to tell the hash to look at the variable value?
trent
28|Feb|2008 11You can use quotes around the keys of the hash:
$.prompt(‘Example 2′,
{ buttons: { Ok: true, ‘Not Ok’: false }
})
Stewart
04|Mar|2008 12Matt, for theâThis page contains secure and non-secure itemsâ popup in SSL mode, one of the workaround is to put’src=”javascript:false” for the ie6 iframe.
Stewart
04|Mar|2008 13*o*, the previous message should be to “trent”
Stewart
05|Mar|2008 14More info. If you put put src=”javascript:false”, the page will display the word “false” in the page. I amend this to src=”javascript:”” and it solves the problem.
trent
05|Mar|2008 15Thanks Stewart. I am about done with the next release (1.4). I have made it an option to use the iframe or just hide the selects. I will add this to the iframe.
Jesse
07|Mar|2008 16Hi there. I’m new to Impromptu and relatively new to JQuery as well. For whatever reason the only way I could get things workingin IE (6 and 7) was to change this:
var jqib = b.append(msgbox).children(‘#’+ o.prefix +’box’);
To this:
b.append(msgbox);
var jqib = $(‘#’+ o.prefix +’box’);
Otherwise jqib was returning a null object and so on down the line. I am using the latest JQuery (1.2.3). Have no idea why that was not working. It worked fine from the get-go in FF of course. Anyway, Impromptu’s great — I can see I’ll be using it a great deal in the future.
trent
07|Mar|2008 17Hey Jesse,
I think i fixed this in 1.4, I just put it out last night but didn’t change the download link. It has a couple fixes like the iframe, close “X” at the top, and the problem you found.
http://trentrichardson.com/Impromptu/scripts/jquery-impromptu.1.4.js
Hope that helps. Also just a note that might help you out, the .children will search for immediate decendants, but if you would have used .find instead it will search through all children and sub nodes. Ofcourse you could always use .find(), but .children is faster if you know the element you’re looking for is an immediate child.
Thanks for finding that!
Leave a reply