Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
852848749c
|
@ -82,11 +82,11 @@ function setupSVGedit(path){
|
|||
f.insert({top: SVGeditButton});
|
||||
SVGeditButton.disabled = true;
|
||||
Event.observe(SVGeditButton, 'click', function(){
|
||||
var editor = window.open(path, 'Edit SVG graphic', 'status=1,resizable=1,scrollbars=1');
|
||||
if (selected) {
|
||||
var editor = window.open(path +'?source=data:image/svg+xml;base64,' + window.btoa(selected),
|
||||
'Editing Existing SVG Graphic', 'status=1,resizable=1,scrollbars=1');
|
||||
} else {
|
||||
var editor = window.open(path, 'Creating New SVG graphic', 'status=1,resizable=1,scrollbars=1');
|
||||
editor.addEventListener("load", function() {
|
||||
editor.svgCanvas.setSvgString(selected);
|
||||
}, true);
|
||||
}
|
||||
SVGeditButton.disabled = true;
|
||||
SVGeditButton.value = 'Create SVG graphic';
|
||||
|
|
|
@ -625,6 +625,7 @@ function svg_edit_setup() {
|
|||
// updates the toolbar (colors, opacity, etc) based on the selected element
|
||||
var updateToolbar = function() {
|
||||
if (selectedElement != null &&
|
||||
selectedElement.tagName != "foreignObject" &&
|
||||
selectedElement.tagName != "image" &&
|
||||
selectedElement.tagName != "g")
|
||||
{
|
||||
|
|
|
@ -976,7 +976,7 @@ function BatchCommand(text) {
|
|||
|
||||
if($.inArray(attr, w_attrs) !== -1) {
|
||||
return num * res.w;
|
||||
} else if($.inArray(attr, w_attrs) !== -1) {
|
||||
} else if($.inArray(attr, h_attrs) !== -1) {
|
||||
return num * res.h;
|
||||
} else {
|
||||
return num * Math.sqrt((res.w*res.w) + (res.h*res.h))/Math.sqrt(2);
|
||||
|
@ -1003,7 +1003,7 @@ function BatchCommand(text) {
|
|||
val *= 100;
|
||||
if($.inArray(attr, w_attrs) !== -1) {
|
||||
val = val / res.w;
|
||||
} else if($.inArray(attr, w_attrs) !== -1) {
|
||||
} else if($.inArray(attr, h_attrs) !== -1) {
|
||||
val = val / res.h;
|
||||
} else {
|
||||
return val / Math.sqrt((res.w*res.w) + (res.h*res.h))/Math.sqrt(2);
|
||||
|
@ -4720,11 +4720,18 @@ function BatchCommand(text) {
|
|||
}
|
||||
// else, create a new point, append to pts array, update path element
|
||||
else {
|
||||
// Checks if current target or parents are #svgcontent
|
||||
if(!$.contains(container, evt.target)) {
|
||||
// Clicked outside canvas, so don't make point
|
||||
return false;
|
||||
}
|
||||
|
||||
var lastx = current_path_pts[len-2], lasty = current_path_pts[len-1];
|
||||
// we store absolute values in our path points array for easy checking above
|
||||
current_path_pts.push(x);
|
||||
current_path_pts.push(y);
|
||||
d_attr += "L" + round(x) + "," + round(y) + " ";
|
||||
|
||||
path.setAttribute("d", d_attr);
|
||||
|
||||
// set stretchy line to latest point
|
||||
|
@ -7743,7 +7750,7 @@ function BatchCommand(text) {
|
|||
// Function: getVersion
|
||||
// Returns a string which describes the revision number of SvgCanvas.
|
||||
this.getVersion = function() {
|
||||
return "svgcanvas.js ($Rev: 1380 $)";
|
||||
return "svgcanvas.js ($Rev: 1382 $)";
|
||||
};
|
||||
|
||||
this.setUiStrings = function(strs) {
|
||||
|
|
|
@ -163,6 +163,31 @@
|
|||
equals(null, t.getAttribute("d"), "Imported a <text> with a d attribute");
|
||||
});
|
||||
|
||||
// This test makes sure import/export properly handles namespaced attributes
|
||||
test("Test importing/exporting namespaced attributes", function() {
|
||||
expect(5);
|
||||
var set = svgCanvas.setSvgString('<svg width="640" height="480" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:se="http://svg-edit.googlecode.com" xmlns:foo="http://example.com">'+
|
||||
'<image xlink:href="../editor/images/logo.png"/>' +
|
||||
'<polyline id="se_test_elem" se:foo="bar"/>' +
|
||||
'</svg>');
|
||||
var attrVal = document.getElementById('se_test_elem').getAttributeNS("http://svg-edit.googlecode.com", "foo");
|
||||
|
||||
equals(true, attrVal === "bar", "Preserved namespaced attribute on import");
|
||||
|
||||
var output = svgCanvas.getSvgString();
|
||||
var has_xlink = output.indexOf('xmlns:xlink="http://www.w3.org/1999/xlink"') !== -1;
|
||||
var has_se = output.indexOf('xmlns:se=') !== -1;
|
||||
var has_foo = output.indexOf('xmlns:foo=') === -1;
|
||||
var has_attr = output.indexOf('se:foo="bar"') !== -1;
|
||||
|
||||
equals(true, has_attr, "Preserved namespaced attribute on export");
|
||||
equals(true, has_xlink, "Included xlink: xmlns");
|
||||
equals(true, has_se, "Included se: xmlns");
|
||||
equals(true, has_foo, "Did not include foo: xmlns");
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
|
Loading…
Reference in a new issue