Blurt

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()

blurt('This is a simple alert');
blurt('A title','An alert with a title');
blurt(
    'Success title',
    'A success message',
    'success'
);
/*{
   'type' : 'success', 'error', 'info' or 'warning'
}*/

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()

brompt('Prompt title', onOkCallback);
/* Example */
brompt('Enter your name',function(val){
    blurt('Hi '+val);
});
brompt('Prompt title', onOkCallback, onCancelCallback);
/* Example */
brompt('Enter your name', function(val){
    blurt('Hi '+val);
},
function(){
    blurt('Error','You did not enter anything.', 'error');
});
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');
    }
});