Skip to content

Instantly share code, notes, and snippets.

@cj

cj/pjax.rb Secret

Created March 23, 2016 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cj/583e18f219af6ec6a43e to your computer and use it in GitHub Desktop.
Save cj/583e18f219af6ec6a43e to your computer and use it in GitHub Desktop.
module Opal::Connect
module ConnectPlugins
module Pjax
def self.load_dependencies(connect)
connect.plugin :events
end
if RUBY_ENGINE == 'opal'
`require('expose?$!expose?Pjax!pjax')`
`require('expose?$!expose?NProgress!nprogress')`
`require('nprogress/nprogress.css')`
ConnectSetup = -> do
on(:document, 'pjax:send') { `NProgress.start(); NProgress.inc()` }
on(:document, 'pjax:complete') { `NProgress.done()` }
`new Pjax({elements: 'a', selectors: ['#k-menu', '.container']})`
end
end
end
register_plugin :pjax, Pjax
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment