mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Remove more usages of getView, document getElement API
This commit is contained in:
@@ -290,7 +290,7 @@ class AtomEnvironment extends Model
|
||||
@workspace.openTextFile(@getUserInitScriptPath())
|
||||
|
||||
registerDefaultTargetForKeymaps: ->
|
||||
@keymaps.defaultTarget = @views.getView(@workspace)
|
||||
@keymaps.defaultTarget = @workspace.getElement()
|
||||
|
||||
observeAutoHideMenuBar: ->
|
||||
@disposables.add @config.onDidChange 'core.autoHideMenuBar', ({newValue}) =>
|
||||
@@ -655,8 +655,7 @@ class AtomEnvironment extends Model
|
||||
storeWindowBackground: ->
|
||||
return if @inSpecMode()
|
||||
|
||||
workspaceElement = @views.getView(@workspace)
|
||||
backgroundColor = @window.getComputedStyle(workspaceElement)['background-color']
|
||||
backgroundColor = @window.getComputedStyle(@workspace.getElement())['background-color']
|
||||
@window.localStorage.setItem('atom:window-background-color', backgroundColor)
|
||||
|
||||
# Call this method when establishing a real application window.
|
||||
@@ -700,7 +699,7 @@ class AtomEnvironment extends Model
|
||||
if process.platform is 'darwin' and @config.get('core.titleBar') is 'hidden'
|
||||
@document.body.classList.add('hidden-title-bar')
|
||||
|
||||
@document.body.appendChild(@views.getView(@workspace))
|
||||
@document.body.appendChild(@workspace.getElement())
|
||||
@backgroundStylesheet?.remove()
|
||||
|
||||
@watchProjectPaths()
|
||||
@@ -1018,8 +1017,8 @@ class AtomEnvironment extends Model
|
||||
dispatchApplicationMenuCommand: (command, arg) ->
|
||||
activeElement = @document.activeElement
|
||||
# Use the workspace element if body has focus
|
||||
if activeElement is @document.body and workspaceElement = @views.getView(@workspace)
|
||||
activeElement = workspaceElement
|
||||
if activeElement is @document.body
|
||||
activeElement = @workspace.getElement()
|
||||
@commands.dispatch(activeElement, command, arg)
|
||||
|
||||
dispatchContextMenuCommand: (command, args...) ->
|
||||
|
||||
@@ -63,7 +63,7 @@ class PaneContainerElement extends HTMLElement
|
||||
y = pointB.y - pointA.y
|
||||
Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))
|
||||
|
||||
paneView = @views.getView(@model.getActivePane())
|
||||
paneView = @model.getActivePane().getElement()
|
||||
box = @boundingBoxForPaneView(paneView)
|
||||
|
||||
paneViews = _.toArray(@querySelectorAll('atom-pane'))
|
||||
|
||||
@@ -23,28 +23,6 @@ AnyConstructor = Symbol('any-constructor')
|
||||
# an ideal tool for implementing views in Atom.
|
||||
#
|
||||
# You can access the `ViewRegistry` object via `atom.views`.
|
||||
#
|
||||
# ## Examples
|
||||
#
|
||||
# ### Getting the workspace element
|
||||
#
|
||||
# ```coffee
|
||||
# workspaceElement = atom.views.getView(atom.workspace)
|
||||
# ```
|
||||
#
|
||||
# ### Getting An Editor Element
|
||||
#
|
||||
# ```coffee
|
||||
# textEditor = atom.workspace.getActiveTextEditor()
|
||||
# textEditorElement = atom.views.getView(textEditor)
|
||||
# ```
|
||||
#
|
||||
# ### Getting A Pane Element
|
||||
#
|
||||
# ```coffee
|
||||
# pane = atom.workspace.getActivePane()
|
||||
# paneElement = pane.getElement()
|
||||
# ```
|
||||
module.exports =
|
||||
class ViewRegistry
|
||||
animationFrameRequest: null
|
||||
@@ -120,42 +98,19 @@ class ViewRegistry
|
||||
# layer, but view layer access may be necessary if you want to perform DOM
|
||||
# manipulation that isn't supported via the model API.
|
||||
#
|
||||
# ## Examples
|
||||
#
|
||||
# ### Getting An Editor Element
|
||||
#
|
||||
# ```coffee
|
||||
# textEditor = atom.workspace.getActiveTextEditor()
|
||||
# textEditorElement = atom.views.getView(textEditor)
|
||||
# ```
|
||||
#
|
||||
# ### Getting A Pane Element
|
||||
#
|
||||
# ```coffee
|
||||
# pane = atom.workspace.getActivePane()
|
||||
# paneElement = pane.getElement()
|
||||
# ```
|
||||
#
|
||||
# ### Getting The Workspace Element
|
||||
#
|
||||
# ```coffee
|
||||
# workspaceElement = atom.views.getView(atom.workspace)
|
||||
# ```
|
||||
#
|
||||
# * `object` The object for which you want to retrieve a view. This can be a
|
||||
# pane item, a pane, or the workspace itself.
|
||||
#
|
||||
# ## View Resolution Algorithm
|
||||
#
|
||||
# The view associated with the object is resolved using the following
|
||||
# sequence
|
||||
#
|
||||
# 1. Is the object an instance of `HTMLElement`? If true, return the object.
|
||||
# 2. Does the object have a property named `element` with a value which is
|
||||
# 2. Does the object have a method named `getElement` that returns an
|
||||
# instance of `HTMLElement`? If true, return that value.
|
||||
# 3. Does the object have a property named `element` with a value which is
|
||||
# an instance of `HTMLElement`? If true, return the property value.
|
||||
# 3. Is the object a jQuery object, indicated by the presence of a `jquery`
|
||||
# 4. Is the object a jQuery object, indicated by the presence of a `jquery`
|
||||
# property? If true, return the root DOM element (i.e. `object[0]`).
|
||||
# 4. Has a view provider been registered for the object? If true, use the
|
||||
# 5. Has a view provider been registered for the object? If true, use the
|
||||
# provider to create a view associated with the object, and return the
|
||||
# view.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user