jinlin
2024-09-26 7ec9326ce00d08f9d957981f2edff6df26f24a28
web/public/SVGOrigin/Method-Draw-master/editor/src/units.js
@@ -99,7 +99,7 @@
// Function: svgedit.units.shortFloat
// Rounds a given value to a float with number of digits defined in save_options
//
// Parameters:
// Parameters:
// val - The value as a String, Number or Array of two numbers to be rounded
//
// Returns:
@@ -129,7 +129,7 @@
// Function: svgedit.units.setUnitAttr
// Sets an element's attribute based on the unit in its current value.
//
// Parameters:
// Parameters:
// elem - DOM element to be changed
// attr - String with the name of the attribute associated with the value
// val - String with the attribute value to convert
@@ -137,7 +137,7 @@
  if(!isNaN(val)) {
    // New value is a number, so check currently used unit
    var old_val = elem.getAttribute(attr);
    // Enable this for alternate mode
//    if(old_val !== null && (isNaN(old_val) || elementContainer_.getBaseUnit() !== 'px')) {
//      // Old value was a number, so get unit, then convert
@@ -161,7 +161,7 @@
//        }
//        val = val / typeMap_[unit];
//      }
//
//
//    val += unit;
//    }
  }
@@ -204,7 +204,7 @@
};
// Function: svgedit.units.convertToNum
// Converts given values to numbers. Attributes must be supplied in
// Converts given values to numbers. Attributes must be supplied in
// case a percentage is given
//
// Parameters:
@@ -213,13 +213,13 @@
svgedit.units.convertToNum = function(attr, val) {
  // Return a number if that's what it already is
  if(!isNaN(val)) return val-0;
  if(val.substr(-1) === '%') {
    // Deal with percentage, depends on attribute
    var num = val.substr(0, val.length-1)/100;
    var width = elementContainer_.getWidth();
    var height = elementContainer_.getHeight();
    if(w_attrs.indexOf(attr) >= 0) {
      return num * width;
    } else if(h_attrs.indexOf(attr) >= 0) {
@@ -238,7 +238,7 @@
// Function: svgedit.units.isValidUnit
// Check if an attribute's value is in a valid format
//
// Parameters:
// Parameters:
// attr - String with the name of the attribute associated with the value
// val - String with the attribute value to check
svgedit.units.isValidUnit = function(attr, val, selectedElement) {
@@ -273,9 +273,9 @@
  } else {
    valid = true;
  }
  return valid;
};
})();
})();