     value
 
   rememberReferer = ->
-    referer = document.location.href
+    window.referer = document.location.href
 
   processResponse = (responseText, status, headers)->
     clientOrServerError = ->

  loadedAssets = null
  createDocument = null
  xhr_req = null
  referer = null

  triggerEvent = (name, data) ->
    event = document.createEvent 'Events'

    xhr_req = $q.defer()

    triggerEvent 'page:fetch', url: url
    $http({
      url: url,
      method: 'GET',
      headers: {
        'Accept' : 'text/html, application/xhtml+xml, application/xml',
        'X-XHR-Referer' : window.referer
      },
      timeout: xhr_req.promise
    }).success((data, status, headers)->
