Fixed issues 529 and 530, started some work on better <a> element support
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1511 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -963,12 +963,7 @@
|
||||
// updates the toolbar (colors, opacity, etc) based on the selected element
|
||||
// This function also updates the opacity and id elements that are in the context panel
|
||||
var updateToolbar = function() {
|
||||
if (selectedElement != null &&
|
||||
selectedElement.tagName != "image" &&
|
||||
selectedElement.tagName != "text" &&
|
||||
selectedElement.tagName != "foreignObject" &&
|
||||
selectedElement.tagName != "g")
|
||||
{
|
||||
if (selectedElement != null && $.inArray(selectedElement.tagName, ['image', 'text', 'foreignObject', 'g', 'a']) === -1) {
|
||||
// get opacity values
|
||||
var fillOpacity = parseFloat(selectedElement.getAttribute("fill-opacity"));
|
||||
if (isNaN(fillOpacity)) {
|
||||
@@ -1062,6 +1057,15 @@
|
||||
#ellipse_panel, #line_panel, #text_panel, #image_panel').hide();
|
||||
if (elem != null) {
|
||||
var elname = elem.nodeName;
|
||||
|
||||
// If this is a link with no transform and one child, pretend
|
||||
// its child is selected
|
||||
// console.log('go', elem)
|
||||
// if(elname === 'a') { // && !$(elem).attr('transform')) {
|
||||
// elem = elem.firstChild;
|
||||
// }
|
||||
|
||||
|
||||
var angle = svgCanvas.getRotationAngle(elem);
|
||||
$('#angle').val(angle);
|
||||
|
||||
|
||||
@@ -1600,6 +1600,7 @@ function BatchCommand(text) {
|
||||
if(elem.id == 'svgcontent') {
|
||||
// Process root element separately
|
||||
var res = canvas.getResolution();
|
||||
console.log('res',res);
|
||||
out.push(' width="' + res.w + '" height="' + res.h + '" xmlns="'+svgns+'"');
|
||||
|
||||
var nsuris = {};
|
||||
@@ -1611,10 +1612,6 @@ function BatchCommand(text) {
|
||||
var uri = attr.namespaceURI;
|
||||
if(uri && !nsuris[uri] && nsMap[uri] !== 'xmlns') {
|
||||
nsuris[uri] = true;
|
||||
// console.log('add', nsMap[uri]);
|
||||
// if(nsMap[uri] == 'xmlns') {
|
||||
// console.log('hm',el, attr.nodeName);
|
||||
// }
|
||||
out.push(" xmlns:" + nsMap[uri] + '="' + uri +'"');
|
||||
}
|
||||
});
|
||||
@@ -1634,7 +1631,6 @@ function BatchCommand(text) {
|
||||
{
|
||||
|
||||
if(!attr.namespaceURI || nsMap[attr.namespaceURI]) {
|
||||
console.log(!attr.namespaceURI, nsMap[attr.namespaceURI]);
|
||||
out.push(' ');
|
||||
out.push(attr.nodeName); out.push("=\"");
|
||||
out.push(attrVal); out.push("\"");
|
||||
@@ -2615,6 +2611,11 @@ function BatchCommand(text) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(selectedElements[0] && selectedElements.length === 1 && selectedElements[0].tagName == 'a') {
|
||||
// Make "a" element's child be the selected element
|
||||
selectedElements[0] = selectedElements[0].firstChild;
|
||||
}
|
||||
|
||||
call("selected", selectedElements);
|
||||
|
||||
if (showGrips || selectedElements.length == 1) {
|
||||
@@ -5119,12 +5120,17 @@ function BatchCommand(text) {
|
||||
},
|
||||
|
||||
clear: function(remove) {
|
||||
if(remove && current_mode == "path") {
|
||||
if (current_mode == "path" && current_path_pts.length > 0) {
|
||||
var elem = getElem(getId());
|
||||
if(elem) elem.parentNode.removeChild(elem);
|
||||
$(getElem("path_stretch_line")).remove();
|
||||
$(elem).remove();
|
||||
$(getElem("pathpointgrip_container")).find('*').attr('display', 'none');
|
||||
current_path_pts = [];
|
||||
started = false;
|
||||
} else if (current_mode == "pathedit") {
|
||||
this.toSelectMode();
|
||||
}
|
||||
if(path) path.init().show(false);
|
||||
current_path = null;
|
||||
},
|
||||
resetOrientation: function(path) {
|
||||
if(path == null || path.nodeName != 'path') return false;
|
||||
@@ -5164,20 +5170,6 @@ function BatchCommand(text) {
|
||||
path.update();
|
||||
}
|
||||
},
|
||||
modeChange: function() {
|
||||
// toss out half-drawn path
|
||||
if (current_mode == "path" && current_path_pts.length > 0) {
|
||||
var elem = getElem(getId());
|
||||
elem.parentNode.removeChild(elem);
|
||||
this.clear();
|
||||
canvas.clearSelection();
|
||||
started = false;
|
||||
}
|
||||
else if (current_mode == "pathedit") {
|
||||
this.clear();
|
||||
this.toSelectMode();
|
||||
}
|
||||
},
|
||||
getNodePoint: function() {
|
||||
var sel_pt = path.selected_pts.length ? path.selected_pts[0] : 1;
|
||||
|
||||
@@ -6682,8 +6674,8 @@ function BatchCommand(text) {
|
||||
// return {'w':vb[2], 'h':vb[3], 'zoom': current_zoom};
|
||||
|
||||
return {
|
||||
'w':svgcontent.getAttribute("width"),
|
||||
'h':svgcontent.getAttribute("height"),
|
||||
'w':svgcontent.getAttribute("width")/current_zoom,
|
||||
'h':svgcontent.getAttribute("height")/current_zoom,
|
||||
'zoom': current_zoom
|
||||
};
|
||||
};
|
||||
@@ -6851,7 +6843,7 @@ function BatchCommand(text) {
|
||||
};
|
||||
|
||||
this.setMode = function(name) {
|
||||
pathActions.modeChange();
|
||||
pathActions.clear(true);
|
||||
|
||||
cur_properties = (selectedElements[0] && selectedElements[0].nodeName == 'text') ? cur_text : cur_shape;
|
||||
current_mode = name;
|
||||
|
||||
Reference in New Issue
Block a user