Still in development
blurt is a javascript replacement for default alert(), prompt(), and confirm()
functions in javascript.
The equivalents in blurt are:
alert()
->blurt()
prompt()
->brompt()
To install:
- Download Blurt files
- Attach the js and css files to your webpage:
link rel="stylesheet" href="blurt.min.css"
script src="blurt.min.js"
Usage - blurt()
Simple alert
blurt('This is a simple alert');
An alert with a title and a text.
blurt('A title','An alert with a title');
An alert with a title, a text and a type.
blurt(
'Success title',
'A success message',
'success'
);
/*{
'type' : 'success', 'error', 'info' or 'warning'
}*/
Complete blurt()
configuration.
blurt({
/* alert title */
title: 'Success',
/* alert text */
text: 'File has been deleted',
/*
* alert type
* success, error, warning, info
* default is 'default'
*/
type: 'success',
/* custom text for OK button */
okButtonText: 'Done',
/*
* escapable, if true, then
* alert closes when escape key is pressesed
* or when clicked outside the alert box
* default is false
*/
escapable: true
});
Usage - brompt()
Simple prompt with just title and success callback.
brompt('Prompt title', onOkCallback);
/* Example */
brompt('Enter your name',function(val){
blurt('Hi '+val);
});
prompt with title, successCallback and errorCallback
brompt('Prompt title', onOkCallback, onCancelCallback);
/* Example */
brompt('Enter your name', function(val){
blurt('Hi '+val);
},
function(){
blurt('Error','You did not enter anything.', 'error');
});
complete brompt()
config
brompt({
/* prompt title */
title: 'Title',
/*
* prompt design type -
* success, info, error or warning
*/
type: 'info',
/* OK button custom done */
okButtonText: 'Done',
/* Cancel button custom text */
cancelButtonText: 'Back',
/* same function as that of blurt() */
escapable: false,
/*
* success callback function
* this callback is passed the value which the user has entered
*/
onConfirm: function(val){
blurt('You entered '+val);
},
/*
* method to be called
* when user presses cancel button
*/
onCancel: function(){
blurt('Error', 'You cancelled the operation.', 'error');
}
});