mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
eureka, less code, props rtomayko
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
Todo
|
||||
- Make handlers not suck
|
||||
Intent
|
||||
- open a folder
|
||||
|
||||
- child urls of folder open in same window
|
||||
|
||||
- open/save/close on project
|
||||
|
||||
Want
|
||||
- cmd-shift-t: reopen last closed tab
|
||||
|
||||
@@ -4,7 +4,7 @@ Document = require 'document'
|
||||
|
||||
module.exports =
|
||||
class Browser extends Document
|
||||
window.resourceTypes.push [this, (url) -> /^https?:/.test url]
|
||||
window.resourceTypes.push this
|
||||
|
||||
path: null
|
||||
html: $ "<div id='browser'></div>"
|
||||
@@ -12,6 +12,8 @@ class Browser extends Document
|
||||
$ "<iframe src='#{@path}' style='width:100%;height:100%'></iframe>"
|
||||
|
||||
open: (path) ->
|
||||
return false if not /^https?:/.test path
|
||||
|
||||
@path = path
|
||||
@html.html @iframe().bind 'load', (e) =>
|
||||
window.setTitle e.target.contentWindow.document.title
|
||||
|
||||
@@ -9,7 +9,7 @@ ace = require 'ace/ace'
|
||||
|
||||
module.exports =
|
||||
class Editor extends Document
|
||||
window.resourceTypes.push [this, (url) -> not url or fs.isFile url]
|
||||
window.resourceTypes.push this
|
||||
|
||||
dirty: false
|
||||
path: null
|
||||
@@ -73,7 +73,9 @@ class Editor extends Document
|
||||
if @path then _.last @path.split '/' else 'untitled'
|
||||
|
||||
open: (path) ->
|
||||
return false if @path
|
||||
if path
|
||||
return false if not fs.isFile path
|
||||
return false if @path
|
||||
|
||||
@path = path
|
||||
@dirty = false
|
||||
|
||||
@@ -5,11 +5,21 @@ Document = require 'document'
|
||||
|
||||
module.exports =
|
||||
class Project extends Document
|
||||
window.resourceTypes.push [this, (url) -> fs.isDirectory url]
|
||||
window.resourceTypes.push this
|
||||
|
||||
html:
|
||||
$ '<img src="http://fc01.deviantart.net/fs70/f/2010/184/4/9/Neru_Troll_Face_by_nerutrollfaceplz.jpg">'
|
||||
|
||||
open: (path) ->
|
||||
return false if not fs.isDirectory url
|
||||
|
||||
#if not @path
|
||||
|
||||
#parent = @path.replace(/([^\/])$/, "$1/")
|
||||
#child = path.replace(/([^\/])$/, "$1/")
|
||||
|
||||
# If the child is contained by the parent, it can be opened by this window
|
||||
#child.match "^" + parent
|
||||
|
||||
@path = path
|
||||
@show()
|
||||
|
||||
@@ -9,15 +9,12 @@ windowAdditions =
|
||||
url: $atomController.url?.toString()
|
||||
|
||||
startup: ->
|
||||
resourceType = @resourceTypeForURL(@url)
|
||||
@resource = new resourceType
|
||||
@resource.open @url
|
||||
success = false
|
||||
for resourceType in @resourceTypes
|
||||
@resource = new resourceType
|
||||
break if success = @resource.open @url
|
||||
|
||||
resourceTypeForURL: (url) ->
|
||||
window.x = this
|
||||
resourceType = type for [type, test] in @resourceTypes when test url
|
||||
throw "I DON'T KNOW ABOUT #{@url}" if not resourceType
|
||||
resourceType
|
||||
throw "I DON'T KNOW ABOUT #{@url}" if not success
|
||||
|
||||
shutdown: ->
|
||||
|
||||
@@ -33,10 +30,7 @@ windowAdditions =
|
||||
|
||||
open: (url) ->
|
||||
url = atom.native.openPanel() unless url
|
||||
if (@resourceTypeForURL url) == @resource.constructor and @resource.open url
|
||||
# Cool (ICK)
|
||||
else
|
||||
atom.app.open url
|
||||
(@resource.open url) or atom.app.open url
|
||||
|
||||
close: (path) ->
|
||||
@shutdown()
|
||||
|
||||
Reference in New Issue
Block a user