jQuery UI alert/confirm/prompt testcases

Here are some simple examples for each of the methods.

alert

Basic alert dialog:

jqUI.alert("I'm a jqUI alert dialog!");

Alert dialog with a title:

jqUI.alert({text:"I'm a jqUI alert dialog!",title:"This is a title"});

Basic alert dialog with a callback:

jqUI.alert("I'm a jqUI alert dialog!",function(){console.log("jqUI alert dialog closed")});

Alert dialog with a title and callback:

jqUI.alert({text:"I'm a jqUI alert dialog!",title:"This is a title"},function(){console.log("jqUI alert dialog closed")});

Alert dialog with a title, custom button label, and callback:

jqUI.alert({text:"I'm a jqUI alert dialog!",title:"I'm hungry",buttonLabel:"pizza"},function(){console.log("What kind of answer is pizza?")});

confirm

Basic confirm dialog with a callback:

jqUI.confirm("I'm a jqUI confirm dialog!",function(yes){console.log("You pressed "+yes?"OK":"Cancel")});

Confirm dialog with a title and callback:

jqUI.confirm({text:"I'm a jqUI confirm dialog!",title:"This is a title"},function(yes){console.log("You pressed "+yes?"OK":"Cancel")});

Confirm dialog with a title, custom button label, and callback:

jqUI.confirm({text:"True or false: jqUI is cool.",title:"This is a title",buttonLabel:["true","false"]},function(true_or_false){console.log("Your answer is "+true_or_false)});

prompt

Basic prompt dialog with a callback:

jqUI.prompt("Please type your name.",function(name){jqUI.alert("Hello "+name)});

Prompt dialog with a title and callback:

jqUI.prompt({text:"Please type your name.",title:"Have we met before?..."},function(name){jqUI.alert("Hello "+name)});

Prompt dialog with a title, custom button label, and callback:

jqUI.prompt({text:"Please type your name.",title:"Have we met before?...",buttonLabel:["Nice to meet you","I like to keep my personal information private"]},function(name){jqUI.alert("Hello "+name)});

Prompt dialog with a default value and callback:

jqUI.prompt("What's your favorite source-sharing site?","GitHub",function(site){ if (site=="GitHub") jqUI.alert("I like GitHub too.") else if (site=="SourceForge") jqUI.alert("I'm starting to move away from SourceForge...") else jqUI.alert("I've never heard of that one.") });

Prompt dialog with a title, default, and callback:

jqUI.prompt({text:"What's your favorite source-sharing site?",title:"Open source FTW!"},"GitHub",function(site){ if (site==null) jqUI.alert("What, you like proprietary?") else if (site=="GitHub") jqUI.alert("I like GitHub too.") else if (site=="SourceForge") jqUI.alert("I'm starting to move away from SourceForge...") else jqUI.alert("I've never heard of that one.") });

The same example above, but set using {value:"default"}:

jqUI.prompt({text:"What's your favorite source-sharing site?",title:"Open source FTW!",value:"GitHub"},function(site){ if (site==null) jqUI.alert("What, you like proprietary?") else if (site=="GitHub") jqUI.alert("I like GitHub too.") else if (site=="SourceForge") jqUI.alert("I'm starting to move away from SourceForge...") else jqUI.alert("I've never heard of that one.") });

Prompt dialog with a default value and no callback (useful for getting a user to copy something) (currently buggy):

jqUI.prompt("Copy this code:","0a6e846b954e345951e710cd6ce3440e"); // MD5 of jquery-2.0.3.min.js