Improved re-execute of controller if already active on click.

This commit is contained in:
Martin Edenhofer 2015-12-08 13:41:32 +01:00
parent f06348e843
commit 3b47de0014
3 changed files with 21 additions and 14 deletions

View file

@ -550,21 +550,25 @@ class App.Controller extends Spine.Controller
'meta-task-update'
)
locationVerify: (e, callback) =>
locationVerify: (e) =>
newLocation = $(e.currentTarget).attr 'href'
@log 'debug', "new location #{newLocation}"
@log 'debug', "new location '#{newLocation}'"
return if !newLocation
currentLocation = Spine.Route.getPath()
@log 'debug', "current location #{currentLocation}"
return if newLocation.replace(/#/, '') isnt currentLocation
@locationExecute(newLocation, callback)
@locationExecuteOrNavigate(newLocation)
locationExecute: (location, callback) =>
if callback
callback()
location = location.replace(/#/, '')
@log 'debug', "execute controller again for '#{location}' because of same hash"
Spine.Route.matchRoutes(location)
locationExecuteOrNavigate: (newLocation) =>
currentLocation = Spine.Route.getPath()
@log 'debug', "current location '#{currentLocation}'"
if newLocation.replace(/#/, '') isnt currentLocation
@log 'debug', "navigate to location '#{newLocation}'"
@navigate(newLocation)
return
@locationExecute(newLocation)
locationExecute: (newLocation) =>
newLocation = newLocation.replace(/#/, '')
@log 'debug', "execute controller again for '#{newLocation}' because of same hash"
Spine.Route.matchRoutes(newLocation)
logoUrl: ->
"#{@Config.get('image_path')}/#{@Config.get('product_logo')}"

View file

@ -29,14 +29,16 @@ class App.Notify extends App.ControllerWidgetPermanent
counter = @desktopNotifyCounter
notification = new window.Notification(data.title, data)
@desktopNotify[counter] = notification
@log 'debug', 'notifyDesktop', data, counter
notification.onclose = (e) =>
delete @desktopNotify[counter]
notification.onclick = (e) =>
window.focus()
@log 'debug', 'notifyDesktop.click', data
if data.url
@locationExecute(data.url)
@locationExecuteOrNavigate(data.url)
if data.callback
data.callback()

View file

@ -150,7 +150,8 @@ class App.OnlineNotificationWidget extends App.Controller
# execute controller again of already open (because hash hasn't changed, we need to do it manually)
notificationsContainer.find('.js-locationVerify').on('click', (e) =>
@locationVerify(e, @hidePopover)
@locationVerify(e)
@hidePopover()
)
# close notification list on click