From a1c2774a0de18be311c585da228fe560558956eb Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 31 May 2011 10:43:26 +0500 Subject: [PATCH] when unfocused make cursor transparent instead of removing it --- lib/ace/css/editor.css | 4 ++++ lib/ace/layer/cursor.js | 15 ++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index 45ca6d71..6312262c 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -117,6 +117,10 @@ position: absolute; } +.ace_cursor.ace_hidden { + opacity: 0.2; +} + .ace_line { white-space: nowrap; } diff --git a/lib/ace/layer/cursor.js b/lib/ace/layer/cursor.js index 2bde0115..8e7db23f 100644 --- a/lib/ace/layer/cursor.js +++ b/lib/ace/layer/cursor.js @@ -47,7 +47,8 @@ var Cursor = function(parentEl) { parentEl.appendChild(this.element); this.cursor = dom.createElement("div"); - this.cursor.className = "ace_cursor"; + this.cursor.className = "ace_cursor ace_hidden"; + this.element.appendChild(this.cursor); this.isVisible = false; }; @@ -60,18 +61,14 @@ var Cursor = function(parentEl) { this.hideCursor = function() { this.isVisible = false; - if (this.cursor.parentNode) { - this.cursor.parentNode.removeChild(this.cursor); - } + dom.addCssClass(this.cursor, "ace_hidden"); clearInterval(this.blinkId); }; this.showCursor = function() { - this.isVisible = true; - this.element.appendChild(this.cursor); - - var cursor = this.cursor; - cursor.style.visibility = "visible"; + this.isVisible = true; + dom.removeCssClass(this.cursor, "ace_hidden"); + this.cursor.style.visibility = "visible"; this.restartTimer(); };