class @Mercury.PageEditor
# options
# saveStyle: 'form', or 'json' (defaults to json)
# saveDataType: 'xml', 'json', 'jsonp', 'script', 'text', 'html' (defaults to json)
# saveMethod: 'POST', or 'PUT', create or update actions on save (defaults to PUT)
# visible: boolean, if the interface should start visible or not (defaults to true)
constructor: (@saveUrl = null, @options = {}) ->
throw Mercury.I18n('Mercury.PageEditor can only be instantiated once.') if window.mercuryInstance
@options.visible = true unless (@options.visible == false || @options.visible == 'false')
@visible = @options.visible
@options.saveDataType = 'json' unless (@options.saveDataType == false || @options.saveDataType)
window.mercuryInstance = @
@regions = []
@initializeInterface()
Mercury.csrfToken = token if token = jQuery(Mercury.config.csrfSelector).attr('content')
initializeInterface: ->
@focusableElement = jQuery('', {class: 'mercury-focusable', type: 'text'}).appendTo(@options.appendTo ? 'body')
@iframe = jQuery('