Skip to content

Instantly share code, notes, and snippets.

@tstone
Created November 20, 2009 23:30
Show Gist options
  • Save tstone/239877 to your computer and use it in GitHub Desktop.
Save tstone/239877 to your computer and use it in GitHub Desktop.
// When the toolbar button is clicked...
$('#newNickButton').click(function() {
getAndSetNewNickname(null);
}
function getAndSetNewNickname(nick) {
if (typeof(nick) === 'undefined') {
showNickDialog(function(value){
getAndSetNewNickname(value);
})
}
else {
setNewNickName(nick);
}
}
function getNewNickname(callback) {
// Build dialog markup
var win = $('<div><p>Enter your new nickname</p></div>');
var userInput = $('<input type="text" style="width:100%"></input>');
userInput.appendTo(win);
// Display dialog
$(win).dialog({
'modal': true,
'buttons': {
'Ok': function() {
$(this).dialog('close');
callback($(userInput).val());
},
'Cancel': function() {
$(this).dialog('close');
}
}
});
}
function setNewNickname(nick) {
// Do whatever...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment