Skip to content

Instantly share code, notes, and snippets.

@gregorynicholas
Created April 28, 2011 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregorynicholas/945925 to your computer and use it in GitHub Desktop.
Save gregorynicholas/945925 to your computer and use it in GitHub Desktop.
Apprise: Modal Dialogue Popup
.appriseOverlay
{
position:fixed;
top:0;
left:0;
background:rgba(0, 0, 0, 0.3);
display:none;
}
.appriseOuter
{
background:#eee;
border:1px solid #fff;
box-shadow:0px 3px 7px #333;
-moz-box-shadow:0px 3px 7px #333;
-webkit-box-shadow:0px 3px 7px #333;
-moz-border-radius:4px;
-webkit-border-radius:4px;
border-radius:4px;
-khtml-border-radius:4px;
position:absolute;
z-index:99999999;
min-width:200px;
min-height:50px;
max-width:75%;
position:fixed;
display:none;
}
.appriseInner
{
padding:20px;
color:#333;
text-shadow:0px 1px 0px #fff;
}
.appriseInner button
{
border:1px solid #bbb;
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
-khtml-border-radius:3px;
background: -moz-linear-gradient(100% 100% 90deg, #eee, #d5d5d5);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#eee), to(#d5d5d5));
background: -webkit-linear-gradient(#eee, #d5d5d5);
background: -o-linear-gradient(#eee, #d5d5d5);
color:#232d3d;
font-size:12px;
font-weight:bold;
padding:4px 10px;
margin:0 3px;
text-shadow:0px 1px 0px #fff;
cursor:pointer;
box-shadow:0px 1px 2px #ccc;
-moz-box-shadow:0px 1px 2px #ccc;
-webkit-box-shadow:0px 1px 2px #ccc;
}
.appriseInner button:hover
{
color:#d85054;
}
.aButtons, .aInput
{
margin:20px 10px 0px 10px;
text-align:center;
}
.aTextbox
{
border:1px solid #aaa;
-moz-border-radius:4px;
-webkit-border-radius:4px;
border-radius:4px;
-khtml-border-radius:4px;
box-shadow:0px 1px 0px #fff;
-moz-box-shadow:0px 1px 0px #fff;
-webkit-box-shadow:0px 1px 0px #fff;
width:180px;
font-size:12px;
font-weight:bold;
padding:5px 10px;
}
// Apprise 1.5 by Daniel Raftery
// http://thrivingkings.com/apprise
//
// Button text added by Adam Bezulski
//
function apprise(string, args, callback)
{
var default_args =
{
'confirm' : false, // Ok and Cancel buttons
'verify' : false, // Yes and No buttons
'input' : false, // Text input (can be true or string for default text)
'animate' : false, // Groovy animation (can true or number, default is 400)
'textOk' : 'Ok', // Ok button default text
'textCancel' : 'Cancel', // Cancel button default text
'textYes' : 'Yes', // Yes button default text
'textNo' : 'No' // No button default text
}
if(args)
{
for(var index in default_args)
{ if(typeof args[index] == "undefined") args[index] = default_args[index]; }
}
var aHeight = $(document).height();
var aWidth = $(document).width();
$('body').append('<div class="appriseOverlay" id="aOverlay"></div>');
$('.appriseOverlay').css('height', aHeight).css('width', aWidth).fadeIn(100);
$('body').append('<div class="appriseOuter"></div>');
$('.appriseOuter').append('<div class="appriseInner"></div>');
$('.appriseInner').append(string);
$('.appriseOuter').css("left", ( $(window).width() - $('.appriseOuter').width() ) / 2+$(window).scrollLeft() + "px");
if(args)
{
if(args['animate'])
{
var aniSpeed = args['animate'];
if(isNaN(aniSpeed)) { aniSpeed = 400; }
$('.appriseOuter').css('top', '-200px').show().animate({top:"100px"}, aniSpeed);
}
else
{ $('.appriseOuter').css('top', '100px').fadeIn(200); }
}
else
{ $('.appriseOuter').css('top', '100px').fadeIn(200); }
if(args)
{
if(args['input'])
{
if(typeof(args['input'])=='string')
{
$('.appriseInner').append('<div class="aInput"><input type="text" class="aTextbox" t="aTextbox" value="'+args['input']+'" /></div>');
}
else
{
$('.appriseInner').append('<div class="aInput"><input type="text" class="aTextbox" t="aTextbox" /></div>');
}
$('.aTextbox').focus();
}
}
$('.appriseInner').append('<div class="aButtons"></div>');
if(args)
{
if(args['confirm'] || args['input'])
{
$('.aButtons').append('<button value="ok">'+args['textOk']+'</button>');
$('.aButtons').append('<button value="cancel">'+args['textCancel']+'</button>');
}
else if(args['verify'])
{
$('.aButtons').append('<button value="ok">'+args['textYes']+'</button>');
$('.aButtons').append('<button value="cancel">'+args['textNo']+'</button>');
}
else
{ $('.aButtons').append('<button value="ok">'+args['textOk']+'</button>'); }
}
else
{ $('.aButtons').append('<button value="ok">Ok</button>'); }
$(document).keydown(function(e)
{
if($('.appriseOverlay').is(':visible'))
{
if(e.keyCode == 13)
{ $('.aButtons > button[value="ok"]').click(); }
if(e.keyCode == 27)
{ $('.aButtons > button[value="cancel"]').click(); }
}
});
var aText = $('.aTextbox').val();
if(!aText) { aText = false; }
$('.aTextbox').keyup(function()
{ aText = $(this).val(); });
$('.aButtons > button').click(function()
{
$('.appriseOverlay').remove();
$('.appriseOuter').remove();
if(callback)
{
var wButton = $(this).attr("value");
if(wButton=='ok')
{
if(args)
{
if(args['input'])
{ callback(aText); }
else
{ callback(true); }
}
else
{ callback(true); }
}
else if(wButton=='cancel')
{ callback(false); }
}
});
}
@kaji-bikash
Copy link

What are the licensing options for this library? http://thrivingkings.com/apprise is not working too. Please consider putting inline if that makes sense.

@gregorynicholas
Copy link
Author

gregorynicholas commented Sep 19, 2019

@kajisaap - here is where you can find the original source: https://github.com/ThrivingKings/Apprise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment