MCPcopy Index your code
hub / github.com/codecombat/codecombat / handleNormalUrls

Function handleNormalUrls

app/core/initialize.js:151–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

149module.exports.init = init
150
151var handleNormalUrls = () => // https://artsy.github.io/blog/2012/06/25/replacing-hashbang-routes-with-pushstate/
152 $(document).on('click', "a[href^='/']", function (event) {
153 const href = $(event.currentTarget).attr('href')
154 const target = $(event.currentTarget).attr('target')
155
156 // chain 'or's for other black list routes
157 const passThrough = href.indexOf('sign_out') >= 0
158
159 // Allow shift+click for new tabs, etc.
160 if (passThrough || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || (target === '_blank')) {
161 return
162 }
163
164 event.preventDefault()
165
166 // Remove leading slashes and hash bangs (backward compatablility)
167 const url = href.replace(/^\//, '').replace('\#\!\/', '')
168
169 // Instruct Backbone to trigger routing events
170 app.router.navigate(url, { trigger: true })
171
172 return false
173 })
174
175var setUpBackboneMediator = function (app) {
176 let schemas

Callers 1

initFunction · 0.85

Calls 1

navigateMethod · 0.80

Tested by

no test coverage detected