lib/assets/javascripts/up/navigation.js.coffee in upjs-rails-0.2.1 vs lib/assets/javascripts/up/navigation.js.coffee in upjs-rails-0.2.2
- old
+ new
@@ -23,26 +23,35 @@
@class up.navigation
###
up.navigation = (->
+ u = up.util
+
CLASS_ACTIVE = 'up-active'
CLASS_CURRENT = 'up-current'
SELECTOR_SECTION = 'a[href], a[up-target], [up-follow], [up-modal], [up-popup]'
SELECTOR_ACTIVE = ".#{CLASS_ACTIVE}"
+
+ normalizeUrl = (url) ->
+ if u.isPresent(url)
+ u.normalizeUrl(url,
+ search: false
+ stripTrailingSlash: true
+ )
locationChanged = ->
- windowLocation = up.util.normalizeUrl(up.browser.url(), search: false)
- modalLocation = up.modal.source()
- popupLocation = up.popup.source()
+ windowLocation = normalizeUrl(up.browser.url())
+ modalLocation = normalizeUrl(up.modal.source())
+ popupLocation = normalizeUrl(up.popup.source())
- up.util.each $(SELECTOR_SECTION), (section) ->
+ u.each $(SELECTOR_SECTION), (section) ->
$section = $(section)
# if $section is marked up with up-follow,
# the actual link might be a child element.
url = up.link.resolveUrl($section)
- url = up.util.normalizeUrl(url, search: false)
+ url = normalizeUrl(url)
if url == windowLocation || url == modalLocation || url == popupLocation
$section.addClass(CLASS_CURRENT)
else
$section.removeClass(CLASS_CURRENT)
@@ -50,10 +59,10 @@
unmarkActive()
$section = enlargeClickArea($section)
$section.addClass(CLASS_ACTIVE)
enlargeClickArea = ($section) ->
- up.util.presence($section.parents(SELECTOR_SECTION)) || $section
+ u.presence($section.parents(SELECTOR_SECTION)) || $section
unmarkActive = ->
$(SELECTOR_ACTIVE).removeClass(CLASS_ACTIVE)
up.on 'click', SELECTOR_SECTION, (event, $section) ->