|
@@ -19,9 +19,9 @@ define [], () ->
|
|
|
init: () ->
|
|
init: () ->
|
|
|
@emitCursorUpdateEvent()
|
|
@emitCursorUpdateEvent()
|
|
|
|
|
|
|
|
- onSessionChange: (e) =>
|
|
|
|
|
- if e.oldSession?
|
|
|
|
|
- @storeCursorPosition(e.oldSession)
|
|
|
|
|
|
|
+ onBeforeSessionChange: (hasPrevSession = false) =>
|
|
|
|
|
+ if hasPrevSession
|
|
|
|
|
+ @storeCursorPosition()
|
|
|
@storeFirstVisibleLine()
|
|
@storeFirstVisibleLine()
|
|
|
|
|
|
|
|
@doc_id = @$scope.sharejsDoc?.doc_id
|
|
@doc_id = @$scope.sharejsDoc?.doc_id
|
|
@@ -30,8 +30,8 @@ define [], () ->
|
|
|
@gotoStoredPosition()
|
|
@gotoStoredPosition()
|
|
|
, 0
|
|
, 0
|
|
|
|
|
|
|
|
- onUnload: (session) =>
|
|
|
|
|
- @storeCursorPosition(session)
|
|
|
|
|
|
|
+ onUnload: () =>
|
|
|
|
|
+ @storeCursorPosition()
|
|
|
@storeFirstVisibleLine()
|
|
@storeFirstVisibleLine()
|
|
|
|
|
|
|
|
onCursorChange: () =>
|
|
onCursorChange: () =>
|
|
@@ -43,10 +43,10 @@ define [], () ->
|
|
|
docPosition.firstVisibleLine = @adapter.getEditorScrollPosition()
|
|
docPosition.firstVisibleLine = @adapter.getEditorScrollPosition()
|
|
|
@localStorage("doc.position.#{@doc_id}", docPosition)
|
|
@localStorage("doc.position.#{@doc_id}", docPosition)
|
|
|
|
|
|
|
|
- storeCursorPosition: (session) ->
|
|
|
|
|
|
|
+ storeCursorPosition: () ->
|
|
|
if @doc_id?
|
|
if @doc_id?
|
|
|
docPosition = @localStorage("doc.position.#{@doc_id}") || {}
|
|
docPosition = @localStorage("doc.position.#{@doc_id}") || {}
|
|
|
- docPosition.cursorPosition = @adapter.getCursorForSession(session)
|
|
|
|
|
|
|
+ docPosition.cursorPosition = @adapter.getCursor()
|
|
|
@localStorage("doc.position.#{@doc_id}", docPosition)
|
|
@localStorage("doc.position.#{@doc_id}", docPosition)
|
|
|
|
|
|
|
|
emitCursorUpdateEvent: () ->
|
|
emitCursorUpdateEvent: () ->
|