Fixed icons in Opera which were broken due to jQuery 1.4.3

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1832 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2010-10-28 16:04:35 +00:00
parent f97395ced4
commit a439a8fea5
2 changed files with 42 additions and 15 deletions

View File

@ -3198,7 +3198,7 @@
var buttonsNeedingStroke = [ '#tool_fhpath', '#tool_line' ];
var buttonsNeedingFillAndStroke = [ '#tools_rect .tool_button', '#tools_ellipse .tool_button', '#tool_text', '#tool_path'];
if (bNoStroke) {
for (index in buttonsNeedingStroke) {
for (var index in buttonsNeedingStroke) {
var button = buttonsNeedingStroke[index];
if ($(button).hasClass('tool_button_current')) {
clickSelect();
@ -3207,14 +3207,14 @@
}
}
else {
for (index in buttonsNeedingStroke) {
for (var index in buttonsNeedingStroke) {
var button = buttonsNeedingStroke[index];
$(button).removeClass('disabled');
}
}
if (bNoStroke && bNoFill) {
for (index in buttonsNeedingFillAndStroke) {
for (var index in buttonsNeedingFillAndStroke) {
var button = buttonsNeedingFillAndStroke[index];
if ($(button).hasClass('tool_button_current')) {
clickSelect();
@ -3223,7 +3223,7 @@
}
}
else {
for (index in buttonsNeedingFillAndStroke) {
for (var index in buttonsNeedingFillAndStroke) {
var button = buttonsNeedingFillAndStroke[index];
$(button).removeClass('disabled');
}

View File

@ -357,25 +357,52 @@ $(function() {
var defs = svg_el.find('defs');
if(!defs.length) return svg_el;
defs.find('[id]').each(function(i) {
if(isOpera) {
var id_elems = defs.find('*').filter(function() {
return !!this.id;
});
} else {
var id_elems = defs.find('[id]');
}
var all_elems = svg_el[0].getElementsByTagName('*'), len = all_elems.length;
id_elems.each(function(i) {
var id = this.id;
var no_dupes = ($(svgdoc).find('#' + id).length <= 1);
if(isOpera) no_dupes = false; // Opera didn't clone svg_el, so not reliable
// if(!force && no_dupes) return;
var new_id = 'x' + id + svg_num + i;
this.id = new_id;
var old_val = 'url(#' + id + ')';
var new_val = 'url(#' + new_id + ')';
// Selector method, possibly faster but fails in Opera / jQuery 1.4.3
// svg_el.find('[fill="url(#' + id + ')"]').each(function() {
// this.setAttribute('fill', 'url(#' + new_id + ')');
// }).end().find('[stroke="url(#' + id + ')"]').each(function() {
// this.setAttribute('stroke', 'url(#' + new_id + ')');
// }).end().find('use').each(function() {
// if(this.getAttribute('xlink:href') == '#' + id) {
// this.setAttributeNS(xlinkns,'href','#' + new_id);
// }
// }).end().find('[filter="url(#' + id + ')"]').each(function() {
// this.setAttribute('filter', 'url(#' + new_id + ')');
// });
svg_el.find('[fill="url(#' + id + ')"]').each(function() {
this.setAttribute('fill', 'url(#' + new_id + ')');
}).end().find('[stroke="url(#' + id + ')"]').each(function() {
this.setAttribute('stroke', 'url(#' + new_id + ')');
}).end().find('use').each(function() {
if(this.getAttribute('xlink:href') == '#' + id) {
this.setAttributeNS(xlinkns,'href','#' + new_id);
for(var i = 0; i < len; i++) {
var elem = all_elems[i];
if(elem.getAttribute('fill') === old_val) {
elem.setAttribute('fill', new_val);
}
}).end().find('[filter="url(#' + id + ')"]').each(function() {
this.setAttribute('filter', 'url(#' + new_id + ')');
});
if(elem.getAttribute('stroke') === old_val) {
elem.setAttribute('stroke', new_val);
}
if(elem.getAttribute('filter') === old_val) {
elem.setAttribute('filter', new_val);
}
}
});
return svg_el;
}