public/assets/js/clientlib-commons.js
/**
     * Converts dimensions specified in options to pixel values.
     * Determines if specified value is a minimum, maximum or exact value.
     * The value can be a number or a string with px, pts, ems, in, cm, mm, or % units.
     * Number/Numeric string treated as pixel measurements
     *  - 30
     *  - '30'
     *  - '>30px'
     *  - '1.3em'
     *  - '20 pt'
     *  - '30%'
     * @param {string} dimText Option text (or number) containing possibly < or >, number, and a unit.
     * @param {object} $elem jQuery object (or node) to reference for % calculations.
     * @param {boolean} isHeight T/F to change from using width in % calculations.
     * @return {object} object containing pixels and -1/1/0 indicating min/max/exact.
     */
Converts dimensions specified in options to pixel values.
Determines if specified value is a minimum, maximum or exact value.
The value can be a number or a string with px, pts, ems, in, cm, mm, or % units.
Converts dimensions specified in options to pixel values . Determines if specified value is a minimum maximum or exact value . The value can be a number or a string with px pts ems in cm mm or % units .
function parse2px(dimText, $elem, isHeight) {
      if (typeof dimText !== 'string') {
         return {px: dimText, minimax: 0};
      }
      var parts = dimText.match(/([<>])?=?\s*([.\d]+)\s*([eimnptx%]*)s?/i);
      var minimax = parts[1];
      var value = parseFloat(parts[2]);
      var unit = parts[3].toLowerCase();
      var pixels = -1;
      switch (unit) {
         case 'pt':
         case 'in':
         case 'cm':
         case 'mm':
            pixels = {'pt': 4.0 / 3.0, 'in': 96.0, 'cm': 96.0 / 2.54, 'mm': 96.0 / 25.4}[unit] * value;
            break;
         case 'em':
            pixels = parseFloat(determineFontSize()) * value;
            break;
         case '%':
            if ( !!$elem ) {
               if (typeof $elem === 'string' || !$elem.jquery) {
                  $elem = $($elem);
               }
               pixels = ( !!isHeight ? $elem.parent().height() : $elem.parent().width() ) * (value / 100.0);
            } 
            break;
         default:
            pixels = value;
      }
      return {px: pixels, minimax: minimax == '>' ? -1 : ( minimax == '<' ? 1 : 0 )};
    }
function parse2px ( dimText , $elem , isHeight ) { if ( typeof dimText !== 'string' ) { return { px : dimText , minimax : 0 } ; } var parts = dimText . match ( / ([<>])?=?\s*([.\d]+)\s*([eimnptx%]*)s? / i ) ; var minimax = parts [ 1 ] ; var value = parseFloat ( parts [ 2 ] ) ; var unit = parts [ 3 ] . toLowerCase ( ) ; var pixels = - 1 ; switch ( unit ) { case 'pt' : case 'in' : case 'cm' : case 'mm' : pixels = { 'pt' : 4.0 / 3.0 , 'in' : 96.0 , 'cm' : 96.0 / 2.54 , 'mm' : 96.0 / 25.4 } [ unit ] * value ; break ; case 'em' : pixels = parseFloat ( determineFontSize ( ) ) * value ; break ; case '%' : if ( ! ! $elem ) { if ( typeof $elem === 'string' || ! $elem . jquery ) { $elem = $ ( $elem ) ; } pixels = ( ! ! isHeight ? $elem . parent ( ) . height ( ) : $elem . parent ( ) . width ( ) ) * ( value / 100.0 ) ; } break ; default : pixels = value ; } return { px : pixels , minimax : minimax == '>' ? - 1 : ( minimax == '<' ? 1 : 0 ) } ; }
Converts dimensions specified in options to pixel values.
Converts dimensions specified in options to pixel values .
// else returns -1 default value from above. // minimax:  -1 => minimum value, 1 => maximum value, 0 => exact value