This isn't any better.

This commit is contained in:
Corey Johnson
2011-11-11 14:14:23 -08:00
parent 2512b48293
commit a7f7ae2bbe
5 changed files with 27 additions and 26 deletions

View File

@@ -4,7 +4,10 @@ Document = require 'document'
module.exports =
class Browser extends Document
@register (path) -> /^https?:/.test path
Document.handlers.push this
@canOpen: (path) ->
/^https?:/.test path
path: null
html: $ "<div id='browser'></div>"
@@ -12,7 +15,7 @@ class Browser extends Document
$ "<iframe src='#{@path}' style='width:100%;height:100%'></iframe>"
open: ->
return false if not super
return false if not super path
@html.html @iframe().bind 'load', (e) =>
window.setTitle e.target.contentWindow.document.title

View File

@@ -5,30 +5,23 @@ Pane = require 'pane'
# constructor.
module.exports =
class Document extends Pane
@handlers: []
@canOpen: () ->
throw "#{@name}: Must implement a 'canOpen' class method."
@forURL: (url) ->
handler = _.find @handlers, (handler) -> handler.canOpen url
throw "I DON'T KNOW ABOUT #{window.url}" if not handler
new handler
position: "main"
path: null
@handlers: {}
@handler: (path) ->
for name, {test, handler} of Document.handlers
return handler if test path
null
@register: (test) ->
Document.handlers[@name] = {test, handler: this}
@forURL: ->
if handler = @handler window.url
new handler
else
throw "I DON'T KNOW ABOUT #{window.url}"
constructor: ->
open: (path) ->
(@constructor is Document.handler path) and not @path
not @path and @constructor.canOpen path
close: ->
window.close()

View File

@@ -9,13 +9,15 @@ ace = require 'ace/ace'
module.exports =
class Editor extends Document
@register (path) ->
not path or fs.isFile path
Document.handlers.push this
dirty: false
path: null
html: $ "<div id='ace-editor'></div>"
@canOpen: (path) ->
not path or fs.isFile path
constructor: ->
@show()
@@ -74,7 +76,7 @@ class Editor extends Document
if @path then _.last @path.split '/' else 'untitled'
open: (path) ->
return false if not super
return false if not super path
@path = path
@dirty = false

View File

@@ -5,12 +5,15 @@ Document = require 'document'
module.exports =
class Project extends Document
@register (path) -> fs.isDirectory path
Document.handlers.push this
@canOpen: (path) ->
fs.isDirectory path
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 super
return false if not super path
@path = path
@show()

View File

@@ -24,7 +24,7 @@ windowAdditions =
url = atom.native.openPanel() unless url
(atom.document.open url) or atom.app.open url
close: (url) ->
close: (path) ->
@shutdown()
$atomController.close