mirror of
https://github.com/atom/atom.git
synced 2026-01-22 13:28:01 -05:00
Move onDrop global to WindowEventHandler
This commit is contained in:
@@ -114,7 +114,7 @@ describe "Window", ->
|
||||
it "opens it", ->
|
||||
spyOn(atom, "open")
|
||||
event = buildDragEvent("drop", [ {path: "/fake1"}, {path: "/fake2"} ])
|
||||
window.onDrop(event)
|
||||
$(document).trigger(event)
|
||||
expect(atom.open.callCount).toBe 1
|
||||
expect(atom.open.argsForCall[0][0]).toEqual pathsToOpen: ['/fake1', '/fake2']
|
||||
|
||||
@@ -122,7 +122,7 @@ describe "Window", ->
|
||||
it "does nothing", ->
|
||||
spyOn(atom, "open")
|
||||
event = buildDragEvent("drop", [])
|
||||
window.onDrop(event)
|
||||
$(document).trigger(event)
|
||||
expect(atom.open).not.toHaveBeenCalled()
|
||||
|
||||
describe "when a link is clicked", ->
|
||||
|
||||
@@ -20,29 +20,43 @@ class WindowEventHandler
|
||||
$(atom.contextMenu.activeElement).trigger(command, args...)
|
||||
|
||||
@subscribe $(window), 'focus', -> $("body").removeClass('is-blurred')
|
||||
|
||||
@subscribe $(window), 'blur', -> $("body").addClass('is-blurred')
|
||||
|
||||
@subscribe $(window), 'window:open-path', (event, {pathToOpen, initialLine}) ->
|
||||
atom.rootView?.open(pathToOpen, {initialLine}) unless fsUtils.isDirectorySync(pathToOpen)
|
||||
|
||||
@subscribe $(window), 'beforeunload', =>
|
||||
confirmed = atom.rootView?.confirmClose()
|
||||
atom.hide() if confirmed and not @reloadRequested and atom.getCurrentWindow().isWebViewFocused()
|
||||
@reloadRequested = false
|
||||
confirmed
|
||||
|
||||
@subscribe $(window), 'unload', ->
|
||||
atom.getWindowState().set('dimensions', atom.getDimensions())
|
||||
|
||||
@subscribeToCommand $(window), 'window:toggle-full-screen', => atom.toggleFullScreen()
|
||||
|
||||
@subscribeToCommand $(window), 'window:close', => atom.close()
|
||||
|
||||
@subscribeToCommand $(window), 'window:reload', =>
|
||||
@reloadRequested = true
|
||||
atom.reload()
|
||||
|
||||
@subscribeToCommand $(window), 'window:toggle-dev-tools', => atom.toggleDevTools()
|
||||
|
||||
@subscribeToCommand $(document), 'core:focus-next', @focusNext
|
||||
|
||||
@subscribeToCommand $(document), 'core:focus-previous', @focusPrevious
|
||||
|
||||
@subscribe $(document), 'keydown', atom.keymap.handleKeyEvent
|
||||
|
||||
@subscribe $(document), 'drop', onDrop
|
||||
@subscribe $(document), 'drop', (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
pathsToOpen = _.pluck(e.originalEvent.dataTransfer.files, 'path')
|
||||
atom.open({pathsToOpen}) if pathsToOpen.length > 0
|
||||
|
||||
@subscribe $(document), 'dragover', (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
@@ -86,12 +86,6 @@ installApmCommand = (callback) ->
|
||||
commandPath = path.join(window.resourcePath, 'node_modules', '.bin', 'apm')
|
||||
require('./command-installer').install(commandPath, callback)
|
||||
|
||||
window.onDrop = (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
pathsToOpen = _.pluck(e.originalEvent.dataTransfer.files, 'path')
|
||||
atom.open({pathsToOpen}) if pathsToOpen.length > 0
|
||||
|
||||
window.deserializeEditorWindow = ->
|
||||
atom.deserializePackageStates()
|
||||
atom.deserializeProject()
|
||||
|
||||
Reference in New Issue
Block a user