Fix issue 934. Patch by adambender.
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2083 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
db95f77300
commit
36e0fbd2d5
|
@ -1908,7 +1908,7 @@
|
|||
$('.attr_changer').change(function() {
|
||||
var attr = this.getAttribute("data-attr");
|
||||
var val = this.value;
|
||||
var valid = svgedit.units.isValidUnit(attr, val);
|
||||
var valid = svgedit.units.isValidUnit(attr, val, selectedElement);
|
||||
|
||||
if(!valid) {
|
||||
$.alert(uiStrings.notification.invalidAttrValGiven);
|
||||
|
@ -1941,6 +1941,7 @@
|
|||
else {
|
||||
svgCanvas.changeSelectedAttribute(attr, val);
|
||||
}
|
||||
this.blur();
|
||||
});
|
||||
|
||||
// Prevent selection of elements when shift-clicking
|
||||
|
|
|
@ -241,7 +241,7 @@ svgedit.units.convertToNum = function(attr, val) {
|
|||
// 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) {
|
||||
svgedit.units.isValidUnit = function(attr, val, selectedElement) {
|
||||
var valid = false;
|
||||
if(unit_attrs.indexOf(attr) >= 0) {
|
||||
// True if it's just a number
|
||||
|
@ -267,7 +267,7 @@ svgedit.units.isValidUnit = function(attr, val) {
|
|||
// not already present
|
||||
try {
|
||||
var elem = elementContainer_.getElement(val);
|
||||
result = (elem == null);
|
||||
result = (elem == null || elem === selectedElement);
|
||||
} catch(e) {}
|
||||
return result;
|
||||
} else {
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
function setUp() {
|
||||
svgedit.units.init({
|
||||
getBaseUnit: function() { return "cm"; },
|
||||
getElement: function() { return null; },
|
||||
getHeight: function() { return 600; },
|
||||
getWidth: function() { return 800; },
|
||||
getRoundDigits: function() { return 4; }
|
||||
getRoundDigits: function() { return 4; },
|
||||
getElement:function(elementId){ return document.getElementById(elementId);}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
|||
});
|
||||
|
||||
test('Test svgedit.units.isValidUnit()', function() {
|
||||
expect(14);
|
||||
expect(18);
|
||||
|
||||
setUp();
|
||||
|
||||
|
@ -67,6 +67,12 @@
|
|||
ok(isValidUnit("-0.4em"));
|
||||
ok(isValidUnit("-0.ex"));
|
||||
ok(isValidUnit("40.123%"));
|
||||
|
||||
|
||||
equals(isValidUnit("id","uniqueId",document.getElementById("uniqueId")), true);
|
||||
equals(isValidUnit("id","newId",document.getElementById("uniqueId")), true);
|
||||
equals(isValidUnit("id","uniqueId"), false);
|
||||
equals(isValidUnit("id","uniqueId",document.getElementById("nonUniqueId")), false);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@ -78,6 +84,12 @@
|
|||
<ol id='qunit-tests'>
|
||||
</ol>
|
||||
<div id='anchor' style='visibility:hidden'>
|
||||
</div>
|
||||
<div id="elementsContainer">
|
||||
<div id='uniqueId' style='visibility:hidden'></div>
|
||||
<div id='nonUniqueId' style='visibility:hidden'></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue