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-75d572ba1dddmaster
parent
47001a9488
commit
0b7c8d489a
|
@ -69,20 +69,20 @@ var supportsPathInsertItemBefore_ = (function() {
|
|||
return false;
|
||||
})();
|
||||
|
||||
// text character positioning
|
||||
var supportsTextCharPos_ = (function() {
|
||||
// text character positioning (for IE9)
|
||||
var supportsGoodTextCharPos_ = (function() {
|
||||
var retValue = false;
|
||||
var svgroot = document.createElementNS(svgns, 'svg');
|
||||
var svgcontent = document.createElementNS(svgns, 'svg');
|
||||
document.documentElement.appendChild(svgcontent);
|
||||
try {
|
||||
var text = document.createElementNS(svgns,'text');
|
||||
text.textContent = 'a';
|
||||
svgcontent.appendChild(text);
|
||||
text.getStartPositionOfChar(0);
|
||||
retValue = true;
|
||||
} catch(err) {}
|
||||
document.documentElement.removeChild(svgcontent);
|
||||
return retValue;
|
||||
document.documentElement.appendChild(svgroot);
|
||||
svgcontent.setAttribute('x', 5);
|
||||
svgroot.appendChild(svgcontent);
|
||||
var text = document.createElementNS(svgns,'text');
|
||||
text.textContent = 'a';
|
||||
svgcontent.appendChild(text);
|
||||
var pos = text.getStartPositionOfChar(0).x;
|
||||
document.documentElement.removeChild(svgroot);
|
||||
return (pos === 0);
|
||||
})();
|
||||
|
||||
var supportsPathBBox_ = (function() {
|
||||
|
@ -161,7 +161,7 @@ svgedit.browser.supportsPathReplaceItem = function() { return supportsPathReplac
|
|||
svgedit.browser.supportsPathInsertItemBefore = function() { return supportsPathInsertItemBefore_; }
|
||||
svgedit.browser.supportsPathBBox = function() { return supportsPathBBox_; }
|
||||
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.supportsGoodDecimals = function() { return supportsGoodDecimals_; }
|
||||
svgedit.browser.supportsNonScalingStroke = function() { return supportsNonScalingStroke_; }
|
||||
|
|
|
@ -3862,8 +3862,8 @@ var textActions = canvas.textActions = function() {
|
|||
for(var i=0; i<len; i++) {
|
||||
var start = curtext.getStartPositionOfChar(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;
|
||||
start.x -= offset;
|
||||
end.x -= offset;
|
||||
|
@ -8783,32 +8783,4 @@ this.getPrivateMethods = function() {
|
|||
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();
|
||||
}
|
||||
})();
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue