Removed chunks of code for IE9 compat, no longer necessary thanks to fixes in IE9 Beta
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1716 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
119bf24229
commit
fac8fbe1d1
|
@ -121,7 +121,7 @@ script type="text/javascript" src="locale/locale.min.js"></script-->
|
|||
|
||||
<li id="tool_docprops">
|
||||
<div></div>
|
||||
Document Properties [I]
|
||||
Document Properties [P]
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -3115,70 +3115,45 @@
|
|||
operaRepaint();
|
||||
};
|
||||
|
||||
if(window.DOMParser) {
|
||||
// set up gradients to be used for the buttons
|
||||
var svgdocbox = new DOMParser().parseFromString(
|
||||
'<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\
|
||||
fill="#' + curConfig.initFill.color + '" opacity="' + curConfig.initFill.opacity + '"/>\
|
||||
<linearGradient id="gradbox_">\
|
||||
<stop stop-color="#000" offset="0.0"/>\
|
||||
<stop stop-color="#FF0000" offset="1.0"/>\
|
||||
</linearGradient></svg>', 'text/xml');
|
||||
var docElem = svgdocbox.documentElement;
|
||||
// set up gradients to be used for the buttons
|
||||
var svgdocbox = new DOMParser().parseFromString(
|
||||
'<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\
|
||||
fill="#' + curConfig.initFill.color + '" opacity="' + curConfig.initFill.opacity + '"/>\
|
||||
<linearGradient id="gradbox_">\
|
||||
<stop stop-color="#000" offset="0.0"/>\
|
||||
<stop stop-color="#FF0000" offset="1.0"/>\
|
||||
</linearGradient></svg>', 'text/xml');
|
||||
var docElem = svgdocbox.documentElement;
|
||||
|
||||
|
||||
var boxgrad = svgdocbox.getElementById('gradbox_');
|
||||
boxgrad.id = 'gradbox_fill';
|
||||
docElem.setAttribute('width',16.5);
|
||||
$('#fill_color').append( document.importNode(docElem,true) );
|
||||
|
||||
boxgrad.id = 'gradbox_stroke';
|
||||
docElem.setAttribute('width',16.5);
|
||||
$('#stroke_color').append( document.importNode(docElem,true) );
|
||||
$('#stroke_color rect').attr({
|
||||
'fill': '#' + curConfig.initStroke.color,
|
||||
'opacity': curConfig.initStroke.opacity
|
||||
});
|
||||
|
||||
$('#stroke_width').val(curConfig.initStroke.width);
|
||||
$('#group_opacity').val(curConfig.initOpacity * 100);
|
||||
|
||||
// Use this SVG elem to test vectorEffect support
|
||||
var test_el = docElem.firstChild;
|
||||
test_el.setAttribute('style','vector-effect:non-scaling-stroke');
|
||||
var supportsNonSS = (test_el.style.vectorEffect == 'non-scaling-stroke');
|
||||
test_el.removeAttribute('style');
|
||||
|
||||
// Use this to test support for blur element. Seems to work to test support in Webkit
|
||||
var blur_test = svgdocbox.createElementNS('http://www.w3.org/2000/svg', 'feGaussianBlur');
|
||||
if(typeof blur_test.stdDeviationX === "undefined") {
|
||||
$('#tool_blur').hide();
|
||||
}
|
||||
$(blur_test).remove();
|
||||
} else {
|
||||
var svgns = "http://www.w3.org/2000/svg";
|
||||
var svgdocbox = document.createElementNS(svgns, 'svg');
|
||||
var rect = svgCanvas.addSvgElementFromJson({
|
||||
element: 'rect',
|
||||
attr: {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
fill: '#' + curConfig.initFill.color,
|
||||
opacity: curConfig.initFill.opacity
|
||||
}
|
||||
});
|
||||
svgdocbox.appendChild(rect);
|
||||
var linearGradient = svgCanvas.addSvgElementFromJson({
|
||||
element: 'linearGradient',
|
||||
attr: {
|
||||
id: 'gradbox_'
|
||||
}
|
||||
});
|
||||
svgdocbox.appendChild(linearGradient);
|
||||
var docElem = svgdocbox;
|
||||
var boxgrad = svgdocbox.getElementById('gradbox_');
|
||||
boxgrad.id = 'gradbox_fill';
|
||||
docElem.setAttribute('width',16.5);
|
||||
$('#fill_color').append( document.importNode(docElem,true) );
|
||||
|
||||
boxgrad.id = 'gradbox_stroke';
|
||||
docElem.setAttribute('width',16.5);
|
||||
$('#stroke_color').append( document.importNode(docElem,true) );
|
||||
$('#stroke_color rect').attr({
|
||||
'fill': '#' + curConfig.initStroke.color,
|
||||
'opacity': curConfig.initStroke.opacity
|
||||
});
|
||||
|
||||
$('#stroke_width').val(curConfig.initStroke.width);
|
||||
$('#group_opacity').val(curConfig.initOpacity * 100);
|
||||
|
||||
// Use this SVG elem to test vectorEffect support
|
||||
var test_el = docElem.firstChild;
|
||||
test_el.setAttribute('style','vector-effect:non-scaling-stroke');
|
||||
var supportsNonSS = (test_el.style.vectorEffect == 'non-scaling-stroke');
|
||||
test_el.removeAttribute('style');
|
||||
|
||||
// Use this to test support for blur element. Seems to work to test support in Webkit
|
||||
var blur_test = svgdocbox.createElementNS('http://www.w3.org/2000/svg', 'feGaussianBlur');
|
||||
if(typeof blur_test.stdDeviationX === "undefined") {
|
||||
$('#tool_blur').hide();
|
||||
}
|
||||
|
||||
|
||||
$(blur_test).remove();
|
||||
|
||||
// Test for embedImage support (use timeout to not interfere with page load)
|
||||
setTimeout(function() {
|
||||
|
|
|
@ -128,39 +128,6 @@ $(function() {
|
|||
|
||||
|
||||
(function($) {
|
||||
function makeSVG(el) {
|
||||
// manually create a copy of the element
|
||||
var new_el = document.createElementNS(el.namespaceURI, el.nodeName);
|
||||
$.each(el.attributes, function(i, attr) {
|
||||
var ns = attr.namespaceURI;
|
||||
if(ns) {
|
||||
new_el.setAttributeNS(ns, attr.nodeName, attr.nodeValue);
|
||||
} else {
|
||||
new_el.setAttribute(attr.nodeName, attr.nodeValue);
|
||||
}
|
||||
if(attr.nodeName == 'transform') {
|
||||
|
||||
console.log('val1:', attr.nodeValue);
|
||||
console.log('val2:', new_el.getAttribute('transform'));
|
||||
}
|
||||
});
|
||||
|
||||
// now create copies of all children
|
||||
$.each(el.childNodes, function(i, child) {
|
||||
switch(child.nodeType) {
|
||||
case 1: // element node
|
||||
new_el.appendChild(makeSVG(child));
|
||||
break;
|
||||
case 3: // text node
|
||||
new_el.textContent = child.nodeValue;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
return new_el;
|
||||
}
|
||||
|
||||
var svg_icons = {}, fixIDs;
|
||||
|
||||
$.svgIcons = function(file, opts) {
|
||||
|
@ -177,18 +144,21 @@ $(function() {
|
|||
var data_el = $('<object data="' + file + '" type=image/svg+xml>').appendTo('body').hide();
|
||||
try {
|
||||
svgdoc = data_el[0].contentDocument;
|
||||
// TODO: IE still loads this, shouldn't even bother.
|
||||
data_el.load(getIcons);
|
||||
getIcons(0, true); // Opera will not run "load" event if file is already cached
|
||||
} catch(err1) {
|
||||
useFallback();
|
||||
}
|
||||
} else {
|
||||
var parser = new DOMParser();
|
||||
$.ajax({
|
||||
url: file,
|
||||
dataType: 'xml',
|
||||
success: function(data) {
|
||||
svgdoc = data;
|
||||
if(!data) {
|
||||
$(useFallback);
|
||||
return;
|
||||
}
|
||||
svgdoc = parser.parseFromString(data, "text/xml");
|
||||
$(function() {
|
||||
getIcons('ajax');
|
||||
});
|
||||
|
@ -201,17 +171,9 @@ $(function() {
|
|||
});
|
||||
} else {
|
||||
if(err.responseXML) {
|
||||
// Is there a non-ActiveX solution in IE9?
|
||||
svgdoc = err.responseXML;
|
||||
svgdoc = parser.parseFromString(err.responseXML, "text/xml");
|
||||
|
||||
if(!svgdoc.childNodes.length) {
|
||||
if(window.ActiveXObject) {
|
||||
svgdoc = new ActiveXObject("Microsoft.XMLDOM");
|
||||
svgdoc.loadXML(err.responseText);
|
||||
} else {
|
||||
$(useFallback);
|
||||
}
|
||||
} else {
|
||||
$(useFallback);
|
||||
}
|
||||
$(function() {
|
||||
|
@ -346,9 +308,7 @@ $(function() {
|
|||
holder = $('#' + id);
|
||||
if(elem.getElementsByTagNameNS) {
|
||||
var svg = elem.getElementsByTagNameNS(svgns, 'svg')[0];
|
||||
} else {
|
||||
var svg = elem.getElementsByTagName('svg')[0];
|
||||
}
|
||||
}
|
||||
var svgroot = document.createElementNS(svgns, "svg");
|
||||
svgroot.setAttributeNS(svgns, 'viewBox', [0,0,icon_w,icon_h].join(' '));
|
||||
|
||||
|
@ -375,13 +335,7 @@ $(function() {
|
|||
// With cloning, causes issue in Opera/Win/Non-EN
|
||||
if(!isOpera) svg = svg.cloneNode(true);
|
||||
|
||||
// TODO: Figure out why makeSVG is necessary for IE9
|
||||
try {
|
||||
svgroot.appendChild(svg);
|
||||
} catch(e) {
|
||||
// For IE9
|
||||
svgroot.appendChild(makeSVG(svg));
|
||||
}
|
||||
svgroot.appendChild(svg);
|
||||
|
||||
if(toImage) {
|
||||
// Without cloning, Safari will crash
|
||||
|
@ -402,12 +356,7 @@ $(function() {
|
|||
$.each(opts.placement, function(sel, id) {
|
||||
if(!svg_icons[id]) return;
|
||||
$(sel).each(function(i) {
|
||||
// TODO: Figure out why makeSVG is necessary for IE9
|
||||
try {
|
||||
var copy = svg_icons[id].clone();
|
||||
} catch(e) {
|
||||
var copy = makeSVG(svg_icons[id][0]);
|
||||
}
|
||||
var copy = svg_icons[id].clone();
|
||||
setIcon($(this), copy, id);
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue