From 2910f7798ac41330c1930e7d9b4a689114e9573a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 15 Feb 2013 09:15:45 -0800 Subject: [PATCH] Always use global rootView object This removes the last few places where rootView was looked up via jQuery selector and instead just uses the rootView property available on the window. --- src/app/editor.coffee | 11 ++++------- src/app/grammar-view.coffee | 2 +- src/app/pane.coffee | 6 +----- .../autocomplete/lib/autocomplete-view.coffee | 2 +- src/packages/symbols-view/lib/tag-reader.coffee | 2 +- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 2dc140b12..fddf1dc4a 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -57,7 +57,7 @@ class Editor extends View newSelections: null redrawOnReattach: false - @deserialize: (state, rootView) -> + @deserialize: (state) -> editor = new Editor(mini: state.mini, deserializing: true) editSessions = state.editSessions.map (state) -> EditSession.deserialize(state, rootView.project) editor.pushEditSession(editSession) for editSession in editSessions @@ -101,7 +101,7 @@ class Editor extends View isFocused: @isFocused copy: -> - Editor.deserialize(@serialize(), @rootView()) + Editor.deserialize(@serialize(), rootView) bindKeys: -> editorBindings = @@ -356,7 +356,7 @@ class Editor extends View false @hiddenInput.on 'focus', => - @rootView()?.editorFocused(this) + rootView?.editorFocused(this) @isFocused = true @addClass 'is-focused' @@ -483,7 +483,7 @@ class Editor extends View return unless @closedEditSessions.length > 0 {path, index} = @closedEditSessions.pop() - @rootView().open(path) + rootView.open(path) activeIndex = @getActiveEditSessionIndex() @moveEditSessionToIndex(activeIndex, index) if index < activeIndex @@ -782,9 +782,6 @@ class Editor extends View pane: -> @parent('.pane').view() - rootView: -> - @parents('#root-view').view() - promptToSaveDirtySession: (session, callback) -> path = session.getPath() filename = if path then fs.base(path) else "untitled buffer" diff --git a/src/app/grammar-view.coffee b/src/app/grammar-view.coffee index 1319f979a..388a6a66e 100644 --- a/src/app/grammar-view.coffee +++ b/src/app/grammar-view.coffee @@ -45,5 +45,5 @@ class GrammarView extends SelectList attach: -> super - @editor.rootView()?.append(this) + rootView.append(this) @miniEditor.focus() diff --git a/src/app/pane.coffee b/src/app/pane.coffee index 81881e74a..7d8349a4a 100644 --- a/src/app/pane.coffee +++ b/src/app/pane.coffee @@ -43,7 +43,7 @@ class Pane extends View pane = new Pane(view) this[side](pane) - @rootView().adjustPaneDimensions() + rootView.adjustPaneDimensions() view.focus?() pane @@ -51,7 +51,6 @@ class Pane extends View return super if keepData # find parent elements before removing from dom parentAxis = @parent('.row, .column') - rootView = @rootView() super if parentAxis.children().length == 1 sibling = parentAxis.children().detach() @@ -62,6 +61,3 @@ class Pane extends View switch axis when 'row' then new PaneRow when 'column' then new PaneColumn - - rootView: -> - @parents('#root-view').view() diff --git a/src/packages/autocomplete/lib/autocomplete-view.coffee b/src/packages/autocomplete/lib/autocomplete-view.coffee index a3b3cc93f..2123c442f 100644 --- a/src/packages/autocomplete/lib/autocomplete-view.coffee +++ b/src/packages/autocomplete/lib/autocomplete-view.coffee @@ -73,7 +73,7 @@ class AutocompleteView extends SelectList @editor.abort() @editor.setSelectedBufferRange(@originalSelectionBufferRange) - @editor.rootView()?.focus() if @miniEditor.isFocused + rootView.focus() if @miniEditor.isFocused attach: -> @editor.transact() diff --git a/src/packages/symbols-view/lib/tag-reader.coffee b/src/packages/symbols-view/lib/tag-reader.coffee index 520f0d415..a70892319 100644 --- a/src/packages/symbols-view/lib/tag-reader.coffee +++ b/src/packages/symbols-view/lib/tag-reader.coffee @@ -11,7 +11,7 @@ find: (editor) -> word = editor.getTextInRange(editor.getCursor().getCurrentWordBufferRange()) return [] unless word.length > 0 - tagsFile = @getTagsFile(editor.rootView().project) + tagsFile = @getTagsFile(rootView.project) return [] unless tagsFile $tags.find(tagsFile, word) or []