Fixes #452.
Unified · Split
| @@ -8,6 +8,7 @@ class app.views.DocPicker extends app.View · 7 unmodified lines | |||
| 8 | 8 | ||
| 9 | @events: | 9 | @events: |
| 10 | click: 'onClick' | 10 | click: 'onClick' |
| 11 | mousedown: 'onMouseDown' | ||
| 11 | 12 | ||
| 12 | @shortcuts: | 13 | @shortcuts: |
| 13 | enter: 'onEnter' | 14 | enter: 'onEnter' |
| @@ -84,26 +85,24 @@ class app.views.DocPicker extends app.View · 70 unmodified lines | |||
| 84 | input.name | 85 | input.name |
| 85 | 86 | ||
| 86 | onClick: (event) => | 87 | onClick: (event) => |
| 87 | if @focusTimeout | ||
| 88 | clearTimeout @focusTimeout | ||
| 89 | @focusTimeout = null | ||
| 90 | return if event.which isnt 1 | 88 | return if event.which isnt 1 |
| 91 | if event.target is @saveLink | 89 | if event.target is @saveLink |
| 92 | $.stopEvent(event) | 90 | $.stopEvent(event) |
| 93 | @save() | 91 | @save() |
| 94 | return | 92 | return |
| 95 | 93 | ||
| 94 | onMouseDown: => | ||
| 95 | @mouseDown = Date.now() | ||
| 96 | |||
| 96 | onDOMFocus: (event) => | 97 | onDOMFocus: (event) => |
| 97 | target = event.target | 98 | target = event.target |
| 98 | if target.tagName is 'INPUT' | 99 | if target.tagName is 'INPUT' |
| 99 | $.scrollTo target.parentNode, null, 'continuous', bottomGap: 2 | 100 | $.scrollTo target.parentNode, null, 'continuous', bottomGap: 2 |
| 100 | else if target.classList.contains(app.views.ListFold.targetClass) | 101 | else if target.classList.contains(app.views.ListFold.targetClass) |
| 101 | target.blur() | 102 | target.blur() |
| 102 | @focusTimeout = setTimeout => | 103 | unless @mouseDown and @mouseDown > Date.now() - 100 |
| 103 | @listFold.open(target) unless target.classList.contains(app.views.ListFold.activeClass) | 104 | @listFold.open(target) unless target.classList.contains(app.views.ListFold.activeClass) |
| 104 | $('input', target.nextElementSibling).focus() | 105 | $('input', target.nextElementSibling).focus() |
| 105 | @focusTimeout = null | ||
| 106 | , 10 | ||
| 107 | return | 106 | return |
| 108 | 107 | ||
| 109 | onEnter: => | 108 | onEnter: => |