From dea7b5c896bfdd280ed5020801491d09c07c296d Mon Sep 17 00:00:00 2001 From: Alexis Deveria Date: Thu, 16 Sep 2010 16:20:48 +0000 Subject: [PATCH] Disabled inbuilt advanced text editing for IE9 until a bug is fixed git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1722 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svg-editor.js | 5 ++++- editor/svgcanvas.js | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index b6dd66be..eeb7a261 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -1469,7 +1469,10 @@ $('#font_size').val(elem.getAttribute("font-size")); $('#text').val(elem.textContent); if (svgCanvas.addedNew) { - $('#text').focus().select(); + // Timeout needed for IE9 + setTimeout(function() { + $('#text').focus().select(); + },100); } } // text else if(el_name == 'image') { diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 5aeb1869..1aeeeb80 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -11095,7 +11095,28 @@ this.getPrivateMethods = function() { return obj; }; -// console.log('canvas.getPrivateMethods',canvas.getPrivateMethods); +// Temporary fix until MS fixes: +// https://connect.microsoft.com/IE/feedback/details/599257/ +function disableAdvancedTextEdit() { + 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; + +} // Test support for features/bugs (function() { @@ -11118,6 +11139,19 @@ this.getPrivateMethods = function() { support.pathInsertItemBefore = false; } + var text = document.createElementNS(svgns,'text'); + text.textContent = 'a'; + + // text character positioning + try { + text.getStartPositionOfChar(0); + support.textCharPos = true; + } catch(err) { + support.textCharPos = false; + + disableAdvancedTextEdit(); + } + // TODO: Find better way to check support for this support.editableText = isOpera;