science-ation/sfiab.js

84 lines
1.8 KiB
JavaScript
Raw Normal View History

//useful function that we'll be using throughout
function confirmClick(msg)
{
var okay=confirm(msg);
if(okay)
return true;
else
return false;
}
function el(str,domain,name)
{
document.write('<a href="ma'+'il'+'to:' + str + '@' + domain + '">' + name + '</a>');
}
function em(str,domain)
{
document.write('<a href="ma'+'il'+'to:' + str + '@' + domain + '">' + str + '@' + domain + '</a>');
}
var anyFieldHasBeenChanged=false;
function fieldChanged()
{
anyFieldHasBeenChanged=true;
}
function confirmChanges()
{
if(anyFieldHasBeenChanged)
{
var okay=confirm('<?=i18n("You have unsaved changes. Click \"Cancel\" to return so you can save your changes, or press \"OK\" to discard your changes and continue")?>');
if(okay)
return true;
else
return false;
}
else
return true;
}
var _notice_id = 0;
var _notice_div_id = 'notice_div';
function notice_delete(id)
{
$("notice_"+_notice_id).remove();
}
function notice_create(type,str,timeout)
{
_notice_id++;
var style="padding: 0.1em 0; text-align: center;";
$("#"+_notice_div_id).append("<div id=\"notice_"+_notice_id+"\" class=\""+type+"\" style=\""+style+"\">"+str+"</div><br />");
$("#"+_notice_div_id).fadeTo('fast', 0.75);
setTimeout(function() {
$("#notice_"+_notice_id).slideUp('slow', function() { notice_delete(_notice_id); });
}, timeout);
}
function notice_div_id(id)
{
var par = $("#"+id).parent();
var o = par.offset();
var w = par.outerWidth();
// var h = par.outerHeight();
// $("#"+id).css( { "left": 0, "top": 0 } );
$("#"+id).css( { left: o.left+"px", top: o.top+"px" } );
$("#"+id).css( { width: w+"px"} );
$("#"+id).show();
if(id == '') _notice_div_id = 'notice_div';
else _notice_div_id = id;
}
/* Stuff to do after the document loads */
$(document).ready(function()
{
});