Cursor is colored / blinks on on focused editor pane

This commit is contained in:
Nathan Sobo
2012-03-19 09:31:03 -06:00
parent 1437858241
commit 509bac15b6
3 changed files with 16 additions and 5 deletions

View File

@@ -932,14 +932,16 @@ describe "Editor", ->
expect(editor.hiddenInput).toMatchSelector ':focus'
describe "when the hidden input is focused / unfocused", ->
it "assigns the isFocused flag on the editor", ->
it "assigns the isFocused flag on the editor and also adds/removes the .focused css class", ->
editor.attachToDom()
editor.isFocused = false
editor.hiddenInput.focus()
expect(editor.isFocused).toBeTruthy()
expect(editor).toHaveClass('focused')
editor.hiddenInput.focusout()
expect(editor.isFocused).toBeFalsy()
expect(editor).not.toHaveClass('focused')
describe "construction", ->
it "assigns an empty buffer and correctly handles text input (regression coverage)", ->

View File

@@ -108,8 +108,13 @@ class Editor extends View
@hiddenInput.focus()
false
@hiddenInput.on 'focus', => @isFocused = true
@hiddenInput.on 'focusout', => @isFocused = false
@hiddenInput.on 'focus', =>
@isFocused = true
@addClass 'focused'
@hiddenInput.on 'focusout', =>
@isFocused = false
@removeClass 'focused'
@on 'mousedown', '.fold-placeholder', (e) =>
@destroyFold($(e.currentTarget).attr('foldId'))

View File

@@ -67,11 +67,15 @@
.editor .cursor {
position: absolute;
border-left: 3px solid #9dff9d;
border-left: 3px solid rgba(255, 255, 255, .4);
opacity: 0.7;
}
.editor .cursor.idle {
.editor.focused .cursor {
border-color: #9dff9d;
}
.editor.focused .cursor.idle {
-webkit-animation: blink 0.6s;
-webkit-animation-iteration-count: infinite;
}