Method of the day

Another busy day. I do front-end and MVC related stuff, my workmate does DB and Web Services. Towards the of end the day there is a conversation between us:

I: I can't complete this view now. Can you give me a new method called GetPageByID?
Workmate: I have a method for you called GetLost.

Shocking! But still, laughing my ass off... 

jQuery Apprise

I contributed to the plugin. Well, sort of. While ago I was digging through my netvibes and found quite interesting jQuery plugin on WebAppers. It is a nice replacement for JavaScript alert/confirm pop-ups. It is lightweight, has its own CSS file, so the appearance can be adjusted. Plugin has been developed and published by Daniel Raftery.

I found that text for buttons was hard-coded and therefore L10n was not supported. This particular problem has been resolved by adding extra options to the configuration. After while, I realized that these options have to be passed each time when plugin needs to be used. This was another opportunity to play around with the code and transform it into proper jQuery plugin.

What gives the transformation? Options can have default values, which can be overwritten (without repetition) once are made public. That also changes the way how the plugin is called, but the core functionality done by Daniel remains the same.

Sample usage

$("#element").click(function () {

    $(this).apprise('Lorem ipsum', { 'verify': true }, function (r) {
        if (r) {
            //do something here when confirmed / verified

    return false;

Overwrite the defaults

$.apprise.defaults.confirm =  false;   // Shows OK and Cancel buttons
$.apprise.defaults.verify = false; // Shows Yes and No buttons
$.apprise.defaults.input = false; // Returns with user inputed text
$.apprise.defaults.animate = false; // Groovy animation (can true or number, default is 400)
$.apprise.defaults.txtOK = 'OK'; // Text for OK
$.apprise.defaults.txtCanel = 'Cancel';// Text for Cancel
$.apprise.defaults.txtYes = 'Yes'; // Text for Yes
$.apprise.defaults.txtNo = 'No'; // Text for No

The final result of my conversion can be found on the bitbucket repository. Original version is available on the plugin home page.

For the record - full credit for the plugin goes to Daniel.