Made IE text bug be detected through supportsGoodTextCharPos rather than browser sniffing

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2002 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2011-02-23 19:45:02 +00:00
parent 47001a9488
commit 0b7c8d489a
2 changed files with 15 additions and 43 deletions

View File

@ -69,20 +69,20 @@ var supportsPathInsertItemBefore_ = (function() {
return false; return false;
})(); })();
// text character positioning // text character positioning (for IE9)
var supportsTextCharPos_ = (function() { var supportsGoodTextCharPos_ = (function() {
var retValue = false; var retValue = false;
var svgroot = document.createElementNS(svgns, 'svg');
var svgcontent = document.createElementNS(svgns, 'svg'); var svgcontent = document.createElementNS(svgns, 'svg');
document.documentElement.appendChild(svgcontent); document.documentElement.appendChild(svgroot);
try { svgcontent.setAttribute('x', 5);
svgroot.appendChild(svgcontent);
var text = document.createElementNS(svgns,'text'); var text = document.createElementNS(svgns,'text');
text.textContent = 'a'; text.textContent = 'a';
svgcontent.appendChild(text); svgcontent.appendChild(text);
text.getStartPositionOfChar(0); var pos = text.getStartPositionOfChar(0).x;
retValue = true; document.documentElement.removeChild(svgroot);
} catch(err) {} return (pos === 0);
document.documentElement.removeChild(svgcontent);
return retValue;
})(); })();
var supportsPathBBox_ = (function() { var supportsPathBBox_ = (function() {
@ -161,7 +161,7 @@ svgedit.browser.supportsPathReplaceItem = function() { return supportsPathReplac
svgedit.browser.supportsPathInsertItemBefore = function() { return supportsPathInsertItemBefore_; } svgedit.browser.supportsPathInsertItemBefore = function() { return supportsPathInsertItemBefore_; }
svgedit.browser.supportsPathBBox = function() { return supportsPathBBox_; } svgedit.browser.supportsPathBBox = function() { return supportsPathBBox_; }
svgedit.browser.supportsHVLineContainerBBox = function() { return supportsHVLineContainerBBox_; } svgedit.browser.supportsHVLineContainerBBox = function() { return supportsHVLineContainerBBox_; }
svgedit.browser.supportsTextCharPos = function() { return supportsTextCharPos_; } svgedit.browser.supportsGoodTextCharPos = function() { return supportsGoodTextCharPos_; }
svgedit.browser.supportsEditableText = function() { return supportsEditableText_; } svgedit.browser.supportsEditableText = function() { return supportsEditableText_; }
svgedit.browser.supportsGoodDecimals = function() { return supportsGoodDecimals_; } svgedit.browser.supportsGoodDecimals = function() { return supportsGoodDecimals_; }
svgedit.browser.supportsNonScalingStroke = function() { return supportsNonScalingStroke_; } svgedit.browser.supportsNonScalingStroke = function() { return supportsNonScalingStroke_; }

View File

@ -3862,8 +3862,8 @@ var textActions = canvas.textActions = function() {
for(var i=0; i<len; i++) { for(var i=0; i<len; i++) {
var start = curtext.getStartPositionOfChar(i); var start = curtext.getStartPositionOfChar(i);
var end = curtext.getEndPositionOfChar(i); var end = curtext.getEndPositionOfChar(i);
// TODO: Make support property for this
if(svgedit.browser.isIE()) { if(!svgedit.browser.supportsGoodTextCharPos()) {
var offset = canvas.contentW * current_zoom; var offset = canvas.contentW * current_zoom;
start.x -= offset; start.x -= offset;
end.x -= offset; end.x -= offset;
@ -8783,32 +8783,4 @@ this.getPrivateMethods = function() {
return obj; return obj;
}; };
(function() {
// Temporary fix until MS fixes:
// https://connect.microsoft.com/IE/feedback/details/599257/
var disableAdvancedTextEdit = function() {
var curtext;
var textInput = $('#text').css({
position: 'static'
});
$.each(['mouseDown','mouseUp','mouseMove', 'setCursor', 'init', 'select', 'toEditMode'], function() {
textActions[this] = $.noop;
});
textActions.init = function(elem) {
curtext = elem;
$(curtext).unbind('dblclick').bind('dblclick', function() {
textInput.focus();
});
}
canvas.textActions = textActions;
}
if (!svgedit.browser.supportsTextCharPos()) {
disableAdvancedTextEdit();
}
})();
} }