     {content: page.content}
   componentDidMount: ->
     @focus()
-    document.body.addEventListener('click', @focus)
-  componentWillUnmount: ->
-    document.body.removeEventListener('click', @focus)
   focus: ->
     @refs.editable.getDOMNode().focus()
   render: ->

      .append $("<a></a>")
      .text(JSON.parse(recentPage).name)

  PageApp.titleRegion.attachView(new PageNameView(
    model: new Page()
  ))

App = React.createClass(
  handlePageSubmit: ->
    ce = $("<pre />").html(React.findDOMNode(@refs.content).innerHTML)
    if($.browser.webkit)

)

PageTitle = React.createClass(
  propTypes:
    onTitleChange: React.PropTypes.func.isRequired
    onTitleSubmit: React.PropTypes.func.isRequired
  getInitialState: ->
    {
      title: page.name
      focus: false
    }
  toggleFocus: (e) ->
    @setState({focus: !@state.focus}, -> @refs.input.getDOMNode().focus())
  changeTitle: (e) ->
    @setState({title: event.target.value}, -> @props.onTitleSubmit(@state.title))
  handleSubmit: (e) ->
    e.preventDefault()
    @props.onTitleSubmit(@state.title)
  render: ->
    pageTitleElem =
      if @state.focus
        <form id="pagenameform" className="pagename" onSubmit={@handleSubmit}>
          <input id="pagenameinput" className="border-dotted" type="text" placeholder="no title" value={@state.title} onChange={@changeTitle} onBlur={@toggleFocus} ref="input" />
        </form>
      else
        <h3 id="pagename" className="pageTitle border-dotted cursor-text" placeholder="no title" onClick={@toggleFocus}>
          {@state.title}
        </h3>
    return (
      <section id="pagetitle" className="pagetitle">
        {pageTitleElem}
      </section>
    )
)

