Click here to Skip to main content
15,891,248 members
Articles / Web Development / HTML

Context Sensitive Help using Client Callbacks - AJAX Style

Rate me:
Please Sign up or sign in to vote.
3.62/5 (8 votes)
25 Sep 20068 min read 39.5K   35  
This article is all about providing Context Sensitive Help in a web page, asynchronously or AJAX style, using Client Callbacks in .NET 2.0.
 /* variables */
var objParentObject;
var objobjElement;
var blnDraggable = false;
var intOriginalXOffset;
var intOriginalYOffset;

/* SetHelpDraggable( objElement )
 * Allows the help box to be dragged across the
 * screen.
 */
function SetHelpDraggable( objElement ) { 
    /* get the container object */
 
    
    objParentObject = objElement.parentElement;
         
    while (objParentObject.id=="" && objParentObject != null)
        objParentObject = objParentObject.parentElement;        
    
    /* set the handle object */
    objobjElement = objElement;
    
       
    
    
	blnDraggable = true;	
	SetOpacity(objParentObject,50);
	
	intOriginalXOffset = window.event.offsetX;
	intOriginalYOffset = window.event.offsetY;	
}

/* SetHelpFixed()
 * Stops the help box from being draggable
 */
function SetHelpFixed() {
	SetOpacity(objParentObject,100);
	blnDraggable = false;	
}

/* SetHelpClosed()
 * Closes the help box and makes it invisible
 */
function SetHelpClosed(objElement) {
    /* get the container object */
    objParentObject = objElement.parentElement;        
    while (objParentObject.id=="" && objParentObject != null)
        objParentObject = objParentObject.parentElement;        
    
    if (objParentObject == null) return false;
    
    objParentObject.style.display="none";       
}

/* MoveHelp()
 * Moves the help box to the current mouse co-ordinates
 */
function MoveHelp() {    
	if (!(blnDraggable) || objParentObject == null) return;
	
	
	objParentObject.style.left = GetXCoordinate() - intOriginalXOffset;
	objParentObject.style.top = GetYCoordinate() - intOriginalYOffset;
	
}

/* GetXCoordinate()
 * Returns the current X coordinate of the mouse pointer.
 */
function GetXCoordinate() {
	return event.clientX + document.body.scrollLeft;			
}

/* GetYCoordinate()
 * Returns the current Y coordinate of the mouse pointer.
 */
function GetYCoordinate() {
	return event.clientY + document.body.scrollTop;			
}

/* ShowHelp()
 * Display the context sensitive help
 */
function ShowHelp( strPrefix, strTitle, strMessage ) {    
    var objContainer = document.getElementById(strPrefix + '_csh_container');
    var objTitle = document.getElementById(strPrefix + '_csh_Title');
    var objHelp = document.getElementById(strPrefix + '_csh_Description');
    
    objContainer.style.display = 'block';
    objTitle.innerHTML = strTitle;    
    objHelp.innerHTML = strMessage;    
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions