osx.coffee is dead.

Split Chrome into App and Window, in app.coffee and window.coffee
This commit is contained in:
Chris Wanstrath
2011-09-04 14:17:46 -07:00
parent de2ffdf25d
commit 804b67f8df
10 changed files with 138 additions and 125 deletions

62
src/window.coffee Normal file
View File

@@ -0,0 +1,62 @@
$ = require 'jquery'
module.exports =
class Window
controller: null
document: null
nswindow: null
panes: []
constructor: (options={}) ->
@controller = options.controller
@document = options.document
@nswindow = options.controller?.window
addPane: (position, html) ->
Editor = require 'editor'
verticalDiv = $('#app-vertical')
horizontalDiv = $('#app-horizontal')
el = document.createElement "div"
el.setAttribute 'class', "pane " + position
el.innerHTML = html
el.addEventListener 'DOMNodeInsertedIntoDocument', ->
Editor.resize()
, false
el.addEventListener 'DOMNodeRemovedFromDocument', ->
Editor.resize()
, false
switch position
when 'top', 'main'
verticalDiv.prepend el
when 'left'
horizontalDiv.prepend el
when 'bottom'
verticalDiv.append el
when 'right'
horizontalDiv.append el
else
throw "I DON'T KNOW HOW TO DEAL WITH #{position}"
close: ->
@controller.close()
isDirty: ->
@nswindow.isDocumentEdited()
# Set the active window's dirty status.
setDirty: (bool) ->
@nswindow.setDocumentEdited bool
inspector:->
@_inspector ?= WindowController.webView.inspector
title: ->
@nswindow.title
setTitle: (title) ->
@nswindow.title = title