This code creates inline buttons on the form which greatly enhance usually bland CRM UI.
Code is taken from Adi Katz' blog
http://mscrm4ever.blogspot.com/////Example
//function OnCrmPageLoad()
//{
// window.GeneralToolbar = new InlineToolbar("gi_toolbar");
// GeneralToolbar.AddButton("btnReset","Reset","15%",Reset_Click);
// GeneralToolbar.AddButton("btnLookup","Lookup","10%",Lookup_Click);
// //GeneralToolbar.RemoveButton("btnLookup");
// GeneralToolbar.AddButton("btnAddNote","Create Note","16px",AddNote_Click,"/_imgs/ico_16_5_d.gif");
//}
//
//function Reset_Click()
//{
// alert('Reseting Fields...');
//}
//
//function Lookup_Click()
//{
// alert('lookup records...');
//}
//
//function AddNote_Click()
//{
// alert('Add new note');
//}
function InlineToolbar(containerId)
{
var toolbar = this;
var container = document.all[containerId];
if (!container)
{
return alert("Toolbar Field: " + containerId + " is missing");
}
crmForm.all[containerId + "_c"].style.display = 'none';
container.style.display = "none";
container = container.parentElement;
toolbar.AddButton = function(id,text,width,callback,imgSrc)
{
var btn = document.createElement("button");
var btStyle = new StyleBuilder();
btStyle.Add( "font-family" , "Arial" );
btStyle.Add( "font-size" , "12px" );
btStyle.Add( "line-height" , "16px" );
btStyle.Add( "text-align" , "center" );
btStyle.Add( "cursor" , "hand" );
btStyle.Add( "border" , "1px solid #3366CC" );
btStyle.Add( "background-color" , "#CEE7FF" );
btStyle.Add( "background-image" , "url( '/_imgs/btn_rest.gif' )" );
btStyle.Add( "background-repeat" , "repeat-x" );
btStyle.Add( "padding-left" , "5px" );
btStyle.Add( "padding-right" , "5px" );
btStyle.Add( "overflow" , "visible" );
btStyle.Add( "width" , width );
btn.style.cssText = btStyle.ToString();
btn.attachEvent("onclick",callback);
btn.id = id;
if (imgSrc)
{
var img = document.createElement("img");
img.src = imgSrc;
img.style.verticalAlign = "middle";
btn.appendChild(img);
btn.appendChild(document.createTextNode(" "));
var spn = document.createElement("span");
spn.innerText = text;
btn.appendChild(spn);
}
else
{
btn.innerText = text;
}
container.appendChild(btn);
container.appendChild(document.createTextNode(" "));
return btn;
}
toolbar.RemoveButton = function(id)
{
var btn = toolbar.GetButton(id)
if (btn)
{
btn.parentNode.removeChild(btn);
}
}
toolbar.GetButton = function(id)
{
return document.getElementById(id);
}
function StyleBuilder()
{
var cssText = new StringBuilder();
this.Add = function( key , value ){cssText.Append( key ).Append( ":" ).Append( value ).Append( ";" );}
this.ToString = function(){return cssText.ToString();}
}
function StringBuilder()
{
var parts = [];
this.Append = function( text ){parts[ parts.length ] = text;return this;}
this.Reset = function(){parts = [];}
this.ToString = function(){return parts.join( "" );}
}
}