Created
December 18, 2010 06:57
-
-
Save ecounysis/746255 to your computer and use it in GitHub Desktop.
jQuery UI plugin for themed alerts and dialogs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* jalert jQuery JavaScript Plugin v0.0.1 | |
* | |
* Copyright 2010, Eric Christensen | |
* | |
* Permission to use, copy, modify, and distribute this software and its | |
* documentation for any purpose and without fee is hereby granted, provided | |
* that the above copyright notice appear in all copies and that both that | |
* copyright notice and this permission notice appear in supporting | |
* documentation, and that the name of the copyright holder not be used in | |
* advertising or publicity pertaining to distribution of the software | |
* without specific, written prior permission. The copyright holder makes | |
* no representations about the suitability of this software for any | |
* purpose. It is provided "as is" without express or implied | |
* warranty. | |
* | |
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS | |
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY | |
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER | |
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF | |
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
* | |
* Date: Mon Dec 20 2010 12:28:18 GMT-0700 | |
* | |
*/ | |
(function($) { | |
$.jalert = function(the_text, the_title, butts, close_butt) { | |
function Buttons(obj) { | |
for(var key in obj) { | |
this[key] = obj[key]; | |
} | |
} | |
var new_butts = undefined; | |
if (butts) { | |
new_butts = new Buttons(butts); | |
if (close_butt) { | |
new_butts[close_butt] = function() {$(this).remove()}; | |
} | |
} | |
var time = (new Date()).getTime() + ""; | |
var id = "_jalert" + time; | |
var sel = "#" + id; | |
$("body").append("<div id=\"" + id + "\" style=\"font-size: 80%\"></div>"); | |
$(sel).dialog( { | |
bgiframe: true, | |
modal: true, | |
width: 350, | |
height: 250 }); | |
$(sel).text(the_text); | |
$(sel).dialog("option", "title", the_title || "Notification"); | |
$(sel).dialog("option", "buttons", new_butts || { "Ok": function() { $(this).remove(); }}); | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment