Sha256: 142fe38c070c5e2451b07aae41d3cbd3260380098be588324a790a8cc021b50a

Contents?: true

Size: 1.04 KB

Versions: 15

Compression:

Stored size: 1.04 KB

Contents

#= require ./snapshot
#= require ./snapshot_renderer
#= require ./error_renderer

class Turbolinks.View
  constructor: (@delegate) ->
    @htmlElement = document.documentElement

  getRootLocation: ->
    @getSnapshot().getRootLocation()

  getElementForAnchor: (anchor) ->
    @getSnapshot().getElementForAnchor(anchor)

  getSnapshot: ->
    Turbolinks.Snapshot.fromHTMLElement(@htmlElement)

  render: ({snapshot, error, isPreview}, callback) ->
    @markAsPreview(isPreview)
    if snapshot?
      @renderSnapshot(snapshot, isPreview, callback)
    else
      @renderError(error, callback)

  # Private

  markAsPreview: (isPreview) ->
    if isPreview
      @htmlElement.setAttribute("data-turbolinks-preview", "")
    else
      @htmlElement.removeAttribute("data-turbolinks-preview")

  renderSnapshot: (snapshot, isPreview, callback) ->
    Turbolinks.SnapshotRenderer.render(@delegate, callback, @getSnapshot(), Turbolinks.Snapshot.wrap(snapshot), isPreview)

  renderError: (error, callback) ->
    Turbolinks.ErrorRenderer.render(@delegate, callback, error)

Version data entries

15 entries across 14 versions & 6 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/turbolinks/src/turbolinks/view.coffee
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/turbolinks/src/turbolinks/view.coffee
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/turbolinks/src/turbolinks/view.coffee
ruby2js-4.0.4 lib/tasks/testrails/node_modules/turbolinks/src/turbolinks/view.coffee
ruby2js-4.0.3 lib/tasks/testrails/node_modules/turbolinks/src/turbolinks/view.coffee
jester-data-8.0.0 node_modules/turbolinks/src/turbolinks/view.coffee
ezii-os-5.2.1 node_modules/turbolinks/src/turbolinks/view.coffee
ezii-os-2.0.1 node_modules/turbolinks/src/turbolinks/view.coffee
ezii-os-1.1.0 node_modules/turbolinks/src/turbolinks/view.coffee
ezii-os-1.0.0 node_modules/turbolinks/src/turbolinks/view.coffee
ezii-os-0.0.0.1.0 node_modules/turbolinks/src/turbolinks/view.coffee
ezii-os-0.0.0.0.1 node_modules/turbolinks/src/turbolinks/view.coffee
rails_auth-1.0.6 test/dummy/node_modules/turbolinks/src/turbolinks/view.coffee
rails_auth-1.0.5 test/dummy/node_modules/turbolinks/src/turbolinks/view.coffee
rails_auth-1.0.4 test/dummy/node_modules/turbolinks/src/turbolinks/view.coffee