Pages

Friday, December 17, 2010

Javascript - ShowHints

/**
* This class will give you a hint in a user friendly 
* customizable box
*
* @param int id of the elements
* @param string text description to show what about the matter.
*
* @author irfanudin ridho
* @email irfan.ub@gmail.com
* @date december 19, 2010
* @version 1.0
*
**/


function ShowHints(id,text){
    this.id = id;
    this.text = text;

    this.elem = document.getElementById(this.id);
    this.elem.style.backgroundColor = '#ef0';
    this.elem.style.padding = '5px';
    this.elem.innerHTML = this.text;
    this.elem.style.position = 'relative';

    this.close = document.createElement('div');
    this.close.innerHTML = "x";
    this.close.style.border = '1px solid blue';
    this.close.style.width = '20px';
    this.close.style.textAlign = 'center';
    this.close.style.backgroundColor = 'white';
    this.close.style.cursor = 'pointer';
    this.close.style.position = 'absolute';
    this.close.style.right = '5px';
    this.close.style.top = '5px';
    this.elem.setAttribute("onClick","this.parentNode.setAttribute('style','display:none')");

    this.elem.appendChild(this.close);
}

No comments:

Post a Comment