// -----------------------------------------------------------------------------------------------------------
// set up bonfire objects
// -----------------------------------------------------------------------------------------------------------
dojo.addOnLoad(
function(){
var menuidx = 0 ;
var noteidx = 0 ;
var pencilstats = { lastx:-100, lasty:-100, lastoffset : 0 };
dojo.query("div[bftype]").forEach(
function(obj)
{
switch(obj.getAttribute('bftype'))
{
case 'menu':
bfmenu(obj,menuidx++);
break;
}
}
);
dojo.query("div[bftype]").forEach(
function(obj)
{
switch(obj.getAttribute('bftype'))
{
case 'pencil':
bfpencil(obj,pencilstats);
break;
case 'edithtml':
bfedithtml(obj,pencilstats);
break;
case 'note':
bfnote(obj,noteidx++);
fillNoteTooltip(noteidx);
break;
case 'box':
bfbox(obj);
break;
}
}
);
}
);
// -----------------------------------------------------------------------------------------------------------
// set up widget menu
// -----------------------------------------------------------------------------------------------------------
function bfnote(div, idx)
{
dojo.require("dijit.dijit");
dojo.require("dojo.parser");
dojo.require("dijit.Dialog");
dojo.require("dijit.form.Button");
div.id = 'bfnote.' + idx;
var baseid = div.id;
var pnd = div.parentNode;
dojo.connect(div,"onclick", function(){ fillTooltip(); dijit.popup.open({popup: dijit.byId(baseid + '.Dlg'), orient:{'BR':'TR', 'TR':'BR'}, around: dojo.byId(baseid)}); });
var divDlg = document.createElement("DIV");
divDlg.id = baseid + '.Dlg';
divDlg.dojoType = 'dijit.TooltipDialog';
divDlg.style.display = 'none';
pnd.insertBefore( divDlg, div );
var DlgFrm = document.createElement("FORM");
DlgFrm.name = baseid + '.DlgForm';
DlgFrm.id = baseid + '.DlgForm';
divDlg.appendChild( DlgFrm );
var hiddenAction = document.createElement("INPUT");
hiddenAction.type = 'hidden';
hiddenAction.name = 'action';
hiddenAction.id = baseid + '.DlgForm.action';
DlgFrm.appendChild( hiddenAction );
var hiddenKey = document.createElement("INPUT");
hiddenKey.type = 'hidden';
hiddenKey.name = 'key';
hiddenKey.id = baseid + '.DlgForm.key';
hiddenKey.value = '';
DlgFrm.appendChild( hiddenKey );
var DlgFrmHdr = document.createElement("H2");
DlgFrmHdr.innerHTML = 'Notes';
DlgFrm.appendChild( DlgFrmHdr );
var DlgNotes = document.createElement("TEXTAREA");
DlgNotes.name = 'notes';
DlgNotes.id = baseid + '.DlgForm.notes';
DlgNotes.innerHTML = 'Notes';
DlgNotes.style.width = "560px";
DlgNotes.style.height = "300px";
DlgNotes.style.width = "560px";
//DlgNotes.style.background-color = "#ccffff";
DlgFrm.appendChild( DlgNotes );
DlgFrm.appendChild( document.createElement("BR") );
var DlgButtons = document.createElement("CENTER");
DlgFrm.appendChild( DlgButtons );
var DlgReportDiv = document.createElement("DIV");
DlgReportDiv.style.cssFloat = "left";
if (DlgReportDiv.style.styleFloat) DlgReportDiv.style.styleFloat = "left";
DlgButtons.appendChild( DlgReportDiv );
var DlgReport = document.createElement("BUTTON");
DlgReport.dojoType ="dijit.form.Button";
if(dojo.isIE)
{ dojo.connect(div,"onclick", function(){ window.location.href = 'profile_notes_list.asp'; }); }
else
{ div.setAttribute( "onclick","window.location.href = 'profile_notes_list.asp';", 0 ); }
DlgReport.innerHTML = 'Report';
DlgReportDiv.appendChild( DlgReport );
var DlgSave = document.createElement("BUTTON");
DlgSave.dojoType ="dijit.form.Button";
if(dojo.isIE)
{ dojo.connect(div,"onclick", function(){ saveTooltip(); }); }
else
{ div.setAttribute( "onclick","saveTooltip();", 0 ); }
DlgSave.innerHTML = 'Save';
DlgButtons.appendChild( DlgSave );
var DlgClose = document.createElement("BUTTON");
DlgClose.dojoType ="dijit.form.Button";
//if(dojo.isIE) {
dojo.connect(div,"onclick", function(){ dijit.popup.close(dijit.byId( baseid + '.Dlg')); });
//}
//else
// div.setAttribute( "onclick","dijit.popup.close(dijit.byId( baseid + '.Dlg'));", 0 );
DlgClose.innerHTML = 'Cancel';
DlgButtons.appendChild( DlgClose );
}
function saveNoteTooltip(baseid)
{
document.forms[baseid + '.DlgForm'].elements['action'].value = 'Save';
dojo.xhrPost(
{
url: '/profile_notes_ajax.asp',
handleAs: 'text',
form: baseid + '.DlgForm',
load: function(data)
{
data = data.replace(/\t/g, " ");
loadNoteTooltipData(baseid, data);
}
}
);
dijit.popup.close(dijit.byId('notestooltipDlg'));
return true;
}
function loadNoteTooltipData(baseid, data)
{
dojo.query(baseid)[0].innerHTML = ((data!="") ? '
' : '
');
a = dojo.query("#" + baseid + ".DlgForm.notes")[0]
a.innerHTML = data;
a.value = data;
}
function fillNoteTooltip(baseid)
{
var GetOut = dojo.xhrGet({ load: function(data){
data = data.replace(/\t/g, " ");
loadNoteTooltipData(baseid, data);
},
preventCache: true,
url: '/profile_notes_ajax.asp?key=', handleAs: 'text' });
}
function bfmenu(div,idx)
{
var menustyle = div.getAttribute('menustyle') ? div.getAttribute('menustyle') : 'default';
var orientation = div.getAttribute('orientation') ? div.getAttribute('orientation') : 'v';
div.id = 'bfmenu.' + idx++; //nlsmenu cannot tolerate underscores in ID's
var divname = div.id;
dojo.query('ul',div)[0].id = div.id + '.main';
// add auto generated separators
dojo.query('ul[menuseparators="Y"] > li',div).forEach(
function(li)
{
if (dojo.query('~ li',li)[0]) {
var sep = document.createElement("LI");
sep.innerHTML = '-';
li.parentNode.insertBefore( sep, li.nextSibling );
}
}
);
// If any top-level li's on a horizontal menu contain an image, they they must all have one
if (orientation=='h' && dojo.query('> ul > li img',div)[0] )
{
dojo.query('> ul > li > a',div).forEach(
function(a)
{
if (!dojo.query('img',a)[0]) {
var p = dojo.query('> span',a)[0] ? dojo.query('> span',a)[0] : a;
var img = document.createElement("IMG");
img.src = '/images/spacer.gif';
img.height = 18;
img.width = 1;
a.insertBefore( img, a.firstChild );
}
}
);
}
// make sure all images are surronded by spans
dojo.query('li > a > img',div).forEach(
function(img)
{
var a = img.parentNode;
var span = document.createElement('SPAN');
while( a.childNodes.length > 0 )
span.appendChild( a.removeChild(a.childNodes[0]) );
a.appendChild(span);
}
);
// apply image styles
dojo.query('li > a > span > img',div).style('verticalAlign','middle');
// put spans around separators
dojo.query('li',div).forEach(
function(li)
{
if (li.innerHTML.match(/^\s*-\s*$/)) //IE puts a space at the end of the innerHTML
li.innerHTML = '-';
}
);
// fix up hrefs
dojo.query('a',div).forEach(
function(a)
{
if (a.href!='javascript:;')
if (!a.href.match(/:\/\//))
a.href = '/' + a.href;
}
);
var subidx = 0;
dojo.query('ul ul',div).forEach(function(ul){ ul.id = divname + '.' + subidx++; });
var menustyle = menustyle;
var substyle = div.getAttribute('submenustyle') ? div.getAttribute('submenustyle') : menustyle;
var menuMgr = new NlsMenuManager("MyMenu."+div.id);
menuMgr.defaultEffect="fade";
menuMgr.loadMenuFromHTML(div.id, true, false);
var menuBar = menuMgr.menubar;
menuBar.orient = orientation.toUpperCase();
menuBar.stlprf = menustyle + '_1_'; // nlsmenu format header needs _
dojo.query('ul ul',div).forEach( function(ul){menuMgr.getMenu(ul.id).stlprf = substyle + '_2_';} ); // nlsmenu format header needs _
menuMgr.renderMenubar(div.id);
}
// -----------------------------------------------------------------------------------------------------------
// adjust pencil locations
// -----------------------------------------------------------------------------------------------------------
function bfpencil(div,stats)
{
var c = dojo.coords(div);
if ( Math.abs(c.x - stats.lastx) > 10 || Math.abs(c.y - stats.lasty) > 10 ) {
stats.lastoffset = 0;
}
else {
stats.lastoffset += 12;
div.style.left = stats.lastoffset + 'px';
}
stats.lastx = c.x;
stats.lasty = c.y;
}
// -----------------------------------------------------------------------------------------------------------
function bfedithtml(div, stats)
{
// if(dojo.isIE) {
dojo.connect(div,"onmouseover", function(){ this.style.borderColor='black'; });
dojo.connect(div,"onmouseout", function(){ this.style.borderColor='white'; });
// }
// else {
// div.setAttribute( "onmouseover","this.style.borderColor='black'; return false", 0 );
// div.setAttribute( "onmouseout","this.style.borderColor='white'; return false", 0 );
// }
//div.onmouseover = "this.style.borderColor='black';";
//div.onmouseout = "this.style.borderColor='white';";
div.style.display = 'block';
div.style.border = 'white 1px dashed';
div.style.padding = '0px';
div.style.margin = '0px';
var edithtmlid = div.getAttribute('edithtmlid') ? div.getAttribute('edithtmlid') : '';
var div2 = document.createElement("DIV");
div2.style.position = 'relative';
var contdiv = div.firstChild;
div.insertBefore( div2, contdiv );
var div3 = document.createElement("DIV");
div3.style.display = 'inline';
div3.style.position = 'absolute';
div2.insertBefore( div3, div2.firstChild );
bfpencil(div3, stats);
var nobr = document.createElement("NOBR");
div3.insertBefore( nobr, div3.firstChild );
var a = document.createElement("a");
a.href = 'javascript:;';
//a.onclick = 'window.open(\'/EditHTML/edithtml.asp?edithtmlid=' + edithtmlid + '\', \'_blank\', \'scrollbar=yes,resizable=yes\'); ';
nobr.insertBefore( a, nobr.firstChild );
// if(dojo.isIE)
dojo.connect(a,"onclick", function(){ window.open('/EditHTML/edithtml.asp?edithtmlid=' + edithtmlid , '_blank', 'scrollbar=yes,resizable=yes,height=600,width=800'); });
// else
// a.setAttribute( "onclick","window.open('/EditHTML/edithtml.asp?edithtmlid=" + edithtmlid + "', '_blank', 'scrollbar=yes,resizable=yes'); return false", 0 );
var img = document.createElement("img");
img.title = 'Edit the block below';
img.src = '/EditHTML/images/pencil.gif';
img.alt = 'edit';
img.border = '0';
a.insertBefore( img, a.firstChild );
//dojo.connect(div2,"onclick", showEditHtmlContextMenu );
}
function showEditHtmlContextMenu(evt)
{
alert( evt.currentTarget.parentNode.getAttribute('edithtmlid') );
/*
var div = evt.target;
while( div.parentNode && (!div.attributes || !div.getAttribute('edithtmlid')))
div = div.parentNode;
alert( div.getAttribute('edithtmlid') );
*/
}
// -----------------------------------------------------------------------------------------------------------
// draw boxes with rounded corners
// -----------------------------------------------------------------------------------------------------------
function bfbox(div)
{
var bname = div.className ? div.className : 'default';
dojo.query('div.' + bname + ' > h1').addClass( bname + '-header' );
dojo.query('div.' + bname + ' > div').addClass( bname + '-body' );
Nifty('h1.' + bname + '-header','top big');
}
// -----------------------------------------------------------------------------------------------------------
// "Please wait..." functions
// -----------------------------------------------------------------------------------------------------------
dojo.addOnLoad(function() {dojo.doc.createElement("img").src = '/images/loading.gif';});
//function bfDisableEverything() {dojo.query("input, button, textarea, select", dojo.query('body')[0] ).attr("disabled", true);}
function bfWait(msg)
{
var span = dojo.doc.createElement("div");
msg = msg ? (msg=='' ? '' : ' '+msg) : ' Please wait...';
span.innerHTML = '
' + msg + '';
dojo.body().appendChild(span);
var thisdialog = new dijit.Dialog({ title: "", content: span });
dojo.body().appendChild(thisdialog.domNode);
thisdialog.titleBar.style.display='none';
thisdialog.startup();
thisdialog.show();
}