From 16cfc756ce0612a437fc81850283747eb7f4f94a Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Mon, 23 Nov 2009 16:21:49 -0600 Subject: [PATCH] fix 11185 Code editor broken in IE8 for SQLreport --- docs/changelog/7.x.x.txt | 1 + .../build/code-editor/code-editor.js | 55 +++++++++---------- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index d0e4a13ad..53a041cc6 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -9,6 +9,7 @@ - fixed #10932: code showing - fixed #11265: typo i18n - fixed #11263: CleanLoginHistory can cause workflow errors + - fixed #11185: Code editor broken in IE8 for SQLReport 7.8.5 - added the EMS submission subsystem diff --git a/www/extras/yui-webgui/build/code-editor/code-editor.js b/www/extras/yui-webgui/build/code-editor/code-editor.js index 865c569e9..972958632 100755 --- a/www/extras/yui-webgui/build/code-editor/code-editor.js +++ b/www/extras/yui-webgui/build/code-editor/code-editor.js @@ -42,38 +42,28 @@ link.href = this.get('css_url'); this._getDoc().getElementsByTagName('head')[0].appendChild(link); // Highlight the initial value - if ( !this.browser.ie ) { // IE puts "!!CURSOR HERE!!" in the main doc, not the iframe... - this.highlight(false); + if ( this.getEditorText() != this.old_text ) { + Lang.later(10, this, this.highlight); + if ( this.status ) { + Lang.later(100, this, this._writeStatus); + } + this.old_text = this.getEditorText(); } // Setup resize if ( this.status ) { - this._writeStatus(); this._setupResize(); } }, this, true); + this.on('editorKeyUp', function(ev) { - - // Don't highlight arrows or modifiers - if ( ( ev.ev.keyCode > 36 && ev.ev.keyCode < 41 ) - || ev.ev.keyCode == 16 || ev.ev.keyCode == 17 - || ev.ev.keyCode == 18 || ev.ev.keyCode == 91 // Safari "command" - || ev.ev.keyCode == 224 // Firefox "command" - ) { - return; + // Highlight only if content has changed + if ( this.getEditorText() != this.old_text ) { + Lang.later(10, this, this.highlight); + if ( this.status ) { + Lang.later(100, this, this._writeStatus); + } + this.old_text = this.getEditorText(); } - - // TODO: Don't re-highlight if there is a selection - // That is the problem we're trying to avoid with disabling - // highlighting for arrows and modifiers - - // Don't highlight Ctrl, Alt, or Meta key combinations - if ( ev.ev.ctrlKey || ev.ev.altKey || ev.ev.metaKey ) { - return; - } - - // Highlight every keypress - Lang.later(10, this, this.highlight); - Lang.later(100, this, this._writeStatus); }, this, true); //Borrowed this from CodePress: http://codepress.sourceforge.net @@ -107,10 +97,14 @@ str = str.replace(/{/gi, 'RIGHT_BRACKET'); str = str.replace(/}/gi, 'LEFT_BRACKET'); - //   before
for IE7 so lines show up correctly - if ( this.browser.ie && this.browser.ie <= 7 ) { + //   before
for IE8 so lines show up correctly + if ( this.browser.ie && this.browser.ie <= 8 ) { str = str.replace(/\r?\n/g, " 
"); } + + // Fix tabs into softtabs + str = str.replace(/\t/g, '    '); // TODO: Make softtabs configurable + return str; }; @@ -167,6 +161,7 @@ if (!html) { html = this.getEditorHTML(); } + html = html.replace(/( ){4}/g,"\t"); // TODO: make softtabs configurable html = html.replace(/ /g," "); html = html.replace(/ ?
/gi,'\n'); html = html.replace(/<[^>]+>/g,''); @@ -211,7 +206,7 @@ this._getSelection().getRangeAt(0).insertNode(this._getDoc().createTextNode(this.cc)); } else if (this.browser.webkit || this.browser.ie || this.browser.opera) { try { - this.execCommand('inserthtml', '!!CURSOR_HERE!!'); + this.execCommand('inserthtml', ''); } catch (e) {} } @@ -236,18 +231,18 @@ } YAHOO.log(html); //   before
for IE7 - html = html.replace(/( |!!CURSOR_HERE!!)?]*>/gi,'$1\n'); + html = html.replace(/( |<\/span>)?]*>/gi,'$1\n'); html = html.replace(/<[^>]*>/g,''); html = html.replace(/\r?\n/g,'
'); //   between
for IE6 - html = html.replace(/]*>(!!CURSOR_HERE!!)?]*>/gi, '
$1 
'); + html = html.replace(/]*>(<\/span>)?]*>/gi, '
$1 
'); YAHOO.log(html); } for (var i = 0; i < this.keywords.length; i++) { html = html.replace(this.keywords[i].code, this.keywords[i].tag); } YAHOO.log("AFTER HIGHLIGHT:" + html); - html = html.replace('!!CURSOR_HERE!!', '|'); + html = html.replace('', '|'); this._getDoc().body.innerHTML = html; if (!focus) {