Always calculate dimensions with editor on DOM

Closes #206
This commit is contained in:
Corey Johnson & Kevin Sawicki
2013-01-31 10:31:13 -08:00
parent ef6e525674
commit 8f030cd97e
3 changed files with 27 additions and 0 deletions

View File

@@ -804,6 +804,10 @@ class Editor extends View
@overlayer.append(view)
calculateDimensions: ->
if not @isOnDom()
detachedEditorParent = _.last(@parents()) ? this
$(document.body).append(detachedEditorParent)
fragment = $('<pre class="line" style="position: absolute; visibility: hidden;"><span>x</span></div>')
@renderedLines.append(fragment)
@@ -815,6 +819,8 @@ class Editor extends View
@height(@lineHeight) if @mini
fragment.remove()
$(detachedEditorParent).detach()
updateLayerDimensions: ->
@gutter.calculateWidth()

View File

@@ -25,6 +25,9 @@ $.fn.pageUp = ->
$.fn.pageDown = ->
@scrollTop(@scrollTop() + @height())
$.fn.isOnDom = ->
@closest(document.body).length is 1
$.fn.containsElement = (element) ->
(element[0].compareDocumentPosition(this[0]) & 8) == 8