Skip to main content

Bug Tracker

Side navigation

#3562 closed bug (wontfix)

Opened November 01, 2008 10:29AM UTC

Closed March 18, 2009 03:08AM UTC

code to get pixel values for other measurement units is lacking

Reported by: koteskie Owned by:
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: Cc:
Blocked by: Blocking:
Description

pixel value for a border-width set to for example thin is incorrect.

the following code does the trick.

var toPixels = function ( element , value )
    {
        if ( /^(\\d+)|(small|medium|large|thin|thick)$/ . test ( value ) )
        {
            var tmp = document.createElement ( 'span' );
            tmp.style.position = 'absolute';
            tmp.style.visibility = 'hidden';
            tmp.style.borderStyle = 'solid';
            tmp.style.borderRightWidth = '0px';
            tmp.style.borderLeftWidth = value;
            element.parentNode.appendChild ( tmp );
            value = tmp.offsetWidth + 'px';
            element.parentNode.removeChild ( tmp );
        }
       
        return value;
    };
Attachments (0)
Change History (3)

Changed November 01, 2008 08:18PM UTC by flesler comment:1

component: unfilledcore
owner: flesler

Changed November 12, 2008 07:59AM UTC by davidserduke comment:2

description: pixel value for a border-width set to for example thin is incorrect. \ the following code does the trick. \ \ var toPixels = function ( element , value ) \ { \ if ( /^(\\d+)|(small|medium|large|thin|thick)$/ . test ( value ) ) \ { \ var tmp = document.createElement ( 'span' ); \ tmp.style.position = 'absolute'; \ tmp.style.visibility = 'hidden'; \ tmp.style.borderStyle = 'solid'; \ tmp.style.borderRightWidth = '0px'; \ tmp.style.borderLeftWidth = value; \ element.parentNode.appendChild ( tmp ); \ value = tmp.offsetWidth + 'px'; \ element.parentNode.removeChild ( tmp ); \ } \ \ return value; \ };pixel value for a border-width set to for example thin is incorrect. \ the following code does the trick. \ \ {{{ \ var toPixels = function ( element , value ) \ { \ if ( /^(\\d+)|(small|medium|large|thin|thick)$/ . test ( value ) ) \ { \ var tmp = document.createElement ( 'span' ); \ tmp.style.position = 'absolute'; \ tmp.style.visibility = 'hidden'; \ tmp.style.borderStyle = 'solid'; \ tmp.style.borderRightWidth = '0px'; \ tmp.style.borderLeftWidth = value; \ element.parentNode.appendChild ( tmp ); \ value = tmp.offsetWidth + 'px'; \ element.parentNode.removeChild ( tmp ); \ } \ \ return value; \ }; \ }}}

Changed March 18, 2009 03:08AM UTC by brandon comment:3

resolution: → wontfix
status: newclosed

This would be better as a plugin for those who need this functionality.