Change 'javascript:' links to use event listener

pull/417/head
Thibaut Courouble 9 years ago
parent fd6683f3b2
commit d9e64f9d06

@ -3,7 +3,7 @@ error = (title, text = '', links = '') ->
links = """<p class="_error-links">#{links}</p>""" if links
"""<div class="_error"><h1 class="_error-title">#{title}</h1>#{text}#{links}</div>"""
back = '<a href="javascript:history.back()" class="_error-link">Go back</a>'
back = '<a href="#" data-behavior="back" class="_error-link">Go back</a>'
app.templates.notFoundPage = ->
error """ Page not found. """,
@ -19,7 +19,7 @@ app.templates.pageLoadError = ->
app.templates.bootError = ->
error """ The app failed to load. """,
""" Check your Internet connection and try <a href="javascript:location.reload()">reloading</a>.<br>
""" Check your Internet connection and try <a href="#" data-behavior="reload">reloading</a>.<br>
If you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """
app.templates.offlineError = (reason) ->

@ -7,12 +7,12 @@ textNotif = (title, message) ->
app.templates.notifUpdateReady = ->
textNotif """ DevDocs has been updated. """,
""" <a href="javascript:location='/'">Reload the page</a> to use the new version. """
""" <a href="#" data-behavior="reboot">Reload the page</a> to use the new version. """
app.templates.notifError = ->
textNotif """ Oops, an error occured. """,
""" Try <a href="javascript:app.reload()">reloading</a>, and if the problem persists,
<a href="javascript:if(confirm('Are you sure you want to reset DevDocs?'))app.reset()">resetting the app</a>.<br>
""" Try <a href="#" data-behavior="hard-reload">reloading</a>, and if the problem persists,
<a href="#" data-behavior="reset">resetting the app</a>.<br>
You can also report this issue on <a href="https://github.com/Thibaut/devdocs/issues/new" target="_blank">GitHub</a>. """
app.templates.notifQuotaExceeded = ->

@ -33,7 +33,7 @@ app.templates.offlinePage = (docs) -> """
<dt>I found a bug, where do I report it?
<dd>In the <a href="https://github.com/Thibaut/devdocs/issues">issue tracker</a>. Thanks!
<dt>How do I uninstall/reset the app?
<dd>Click <a href="javascript:if(confirm('Are you sure you want to reset DevDocs?'))app.reset()">here</a>.
<dd>Click <a href="#" data-behavior="reset">here</a>.
<dt>Why aren't all documentations listed above?
<dd>You have to <a href="#" data-pick-docs>enable</a> them first.
</dl>

@ -24,6 +24,8 @@ class app.views.Document extends app.View
.on 'searching', @onSearching
.on 'clear', @onSearchClear
$.on document.body, 'click', @onClick
@activate()
return
@ -99,3 +101,14 @@ class app.views.Document extends app.View
onForward: ->
history.forward()
onClick: (event) ->
return unless event.target.hasAttribute('data-behavior')
$.stopEvent(event)
switch event.target.getAttribute('data-behavior')
when 'back' then history.back()
when 'reload' then window.location.reload()
when 'reboot' then window.location = '/'
when 'hard-reload' then app.reload()
when 'reset' then app.reset() if confirm('Are you sure you want to reset DevDocs?')
return

Loading…
Cancel
Save