www/assets/js/scripts.js
/**
 * Change a font-size of a DOM block by its ID.
 * @param string action The action to execute on font-size : '+' to increase it, '-' to decrease it and '0' for the original size
 * @param string id A dom block ID for selection
 * @param float range The range to use for increase/decrease font-size
 * @param string def The default original font-size to use if it's not set in CSS
 */
Change a font-size of a DOM block by its ID.
Change a font - size of a DOM block by its ID .
function font_size ( action, id, range, def )
{
console.debug('[text_size] for action ['+action+'] on dom ID ['+id+']');
    var unity_table = new Array(
        [ 'px', 5 ],
        [ 'pt', 3 ],
        [ 'em', 0.3 ],
        [ '%', 25 ]
    ), _unit;
    var domobj = document.getElementById( id );
    if (domobj)
    {
        var current_fs = domobj.style.fontSize,
            _newobj = domobj;
        while (_newobj!=undefined && (current_fs==null || current_fs==''))
        {
            _newobj = _newobj.parentNode;
            if (_newobj!=undefined && _newobj.style!=undefined)
            {
                if (_newobj.currentStyle)
                    current_fs = el.currentStyle['fontSize'];
                else if (document.defaultView && document.defaultView.getComputedStyle)
                    current_fs = document.defaultView.getComputedStyle(_newobj,null).getPropertyValue('font-size');
                else
                    current_fs = _newobj.style.fontSize; 
            }
        }
        if (current_fs==null || current_fs=='')
        {
            if (def!=undefined && def!=null) current_fs = def;
            else {
                console.error('No font-size defined for dom ID ['+id+']!');
                return;
            }
        }
        if (FONTSIZE_ORIGINALS[id]==undefined)
            FONTSIZE_ORIGINALS[id]=current_fs;
        var current_fs_val;
        for(i=0; i<unity_table.length; i++)
        {
            _str = current_fs.replace(unity_table[i][0], '');
            if (_str != current_fs)
            {
                _unit = unity_table[i][0];
                current_fs_val = parseFloat(_str);
                if (range==undefined || range==null) range = unity_table[i][1];
            }
        }
        if (action == '+') _new_size = (current_fs_val+range)+_unit;
        else if (action == '-') _new_size = (current_fs_val-range)+_unit;
        else _new_size = FONTSIZE_ORIGINALS[id];
        domobj.style.fontSize = _new_size;
    }
}
function font_size ( action , id , range , def ) { console . debug ( '[text_size] for action [' + action + '] on dom ID [' + id + ']' ) ; var unity_table = new Array ( [ 'px' , 5 ] , [ 'pt' , 3 ] , [ 'em' , 0.3 ] , [ '%' , 25 ] ) , _unit ; var domobj = document . getElementById ( id ) ; if ( domobj ) { var current_fs = domobj . style . fontSize , _newobj = domobj ; while ( _newobj != undefined && ( current_fs == null || current_fs == '' ) ) { _newobj = _newobj . parentNode ; if ( _newobj != undefined && _newobj . style != undefined ) { if ( _newobj . currentStyle ) current_fs = el . currentStyle [ 'fontSize' ] ; else if ( document . defaultView && document . defaultView . getComputedStyle ) current_fs = document . defaultView . getComputedStyle ( _newobj , null ) . getPropertyValue ( 'font-size' ) ; else current_fs = _newobj . style . fontSize ; } } if ( current_fs == null || current_fs == '' ) { if ( def != undefined && def != null ) current_fs = def ; else { console . error ( 'No font-size defined for dom ID [' + id + ']!' ) ; return ; } } if ( FONTSIZE_ORIGINALS [ id ] == undefined ) FONTSIZE_ORIGINALS [ id ] = current_fs ; var current_fs_val ; for ( i = 0 ; i < unity_table . length ; i ++ ) { _str = current_fs . replace ( unity_table [ i ] [ 0 ] , '' ) ; if ( _str != current_fs ) { _unit = unity_table [ i ] [ 0 ] ; current_fs_val = parseFloat ( _str ) ; if ( range == undefined || range == null ) range = unity_table [ i ] [ 1 ] ; } } if ( action == '+' ) _new_size = ( current_fs_val + range ) + _unit ; else if ( action == '-' ) _new_size = ( current_fs_val - range ) + _unit ; else _new_size = FONTSIZE_ORIGINALS [ id ] ; domobj . style . fontSize = _new_size ; } }
Change a font-size of a DOM block by its ID.
Change a font - size of a DOM block by its ID .