lib/assets/javascripts/gretel.trails.hidden.js.coffee.erb in gretel-trails-0.0.1 vs lib/assets/javascripts/gretel.trails.hidden.js.coffee.erb in gretel-trails-0.0.2
- old
+ new
@@ -6,14 +6,14 @@
end
%>
# Remove trail from querystring
removeTrailFromUrl = ->
+ return if location.href.indexOf("<%= Gretel::Trails.trail_param %>=") is -1
if history.replaceState?
- return if location.href.indexOf("<%= Gretel.trail_param %>=") is -1
uri = new Gretel.Trails.Uri(location.href)
- history.replaceState history.state, document.title, uri.deleteQueryParam("<%= Gretel.trail_param %>")
+ history.replaceState history.state, document.title, uri.deleteQueryParam("<%= Gretel::Trails.trail_param %>")
# Remove trail on load
removeTrailFromUrl()
if Turbolinks?
@@ -24,9 +24,9 @@
$ ->
$("body").on "click", "[data-<%= Gretel::Trails::HiddenStrategy.data_attribute %>], <%= Gretel::Trails::HiddenStrategy.js_selector %>", ->
if trail = $(this).data("<%= Gretel::Trails::HiddenStrategy.data_attribute %>") || $("body").data("<%= Gretel::Trails::HiddenStrategy.data_attribute %>")
href = $(this).attr("href")
uri = new Gretel.Trails.Uri(href)
- href = uri.deleteQueryParam("<%= Gretel.trail_param %>").addQueryParam("<%= Gretel.trail_param %>", trail)
+ href = uri.deleteQueryParam("<%= Gretel::Trails.trail_param %>").addQueryParam("<%= Gretel::Trails.trail_param %>", trail)
$(this).attr("href", href)
else
console?.log "[Gretel] No `data-<%= Gretel::Trails::HiddenStrategy.data_attribute %>` was found on the <body> tag or the link you just clicked. Please set it using the `breadcrumb_trail` helper or see the Gretel::Trails readme for more info."
\ No newline at end of file