     if History.enabled
       url = ("/view/#{page}" for page in state.pages).join('') # + "##{state.active}"
       History.pushState state, state.active, url
-      
+
   setActive = (page) ->
     if History.enabled
       state = History.getState().data
       state.active = page
       setState state
-        
+
   showState = (state) ->
     # show and refresh correct pages
     oldPages = pagesInDom()
     newPages = state.pages
     previousPage = newPages
-    
+
     return unless newPages
-    
+
     for name in newPages
       if name in oldPages
         delete oldPages[oldPages.indexOf(name)]

    target = el.position().left
    width = el.outerWidth(true)
    contentWidth = $(".page").outerWidth(true) * $(".page").size()
  
    if target < minX
      $("body").animate scrollLeft: target
    else if target + width > maxX
      $("body").animate scrollLeft: target - ($("body").width() - width)
    else if maxX > $(".pages").outerWidth()
      $("body").animate scrollLeft: Math.min(target, contentWidth - $("body").width())
      
      
# PLUGINS for each story item type

  window.plugins =

      $(e.target).parents('.page').nextAll().remove() unless e.shiftKey
      scrollTo createPage(name).appendTo('.main').each refresh
      # FIXME: can open page multiple times with shift key

      if History.enabled
        setState {pages: pagesInDom(), active: name}

