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

View file

@ -29,14 +29,16 @@ class App.Notify extends App.ControllerWidgetPermanent
counter = @desktopNotifyCounter counter = @desktopNotifyCounter
notification = new window.Notification(data.title, data) notification = new window.Notification(data.title, data)
@desktopNotify[counter] = notification @desktopNotify[counter] = notification
@log 'debug', 'notifyDesktop', data, counter
notification.onclose = (e) => notification.onclose = (e) =>
delete @desktopNotify[counter] delete @desktopNotify[counter]
notification.onclick = (e) => notification.onclick = (e) =>
window.focus() window.focus()
@log 'debug', 'notifyDesktop.click', data
if data.url if data.url
@locationExecute(data.url) @locationExecuteOrNavigate(data.url)
if data.callback if data.callback
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) # execute controller again of already open (because hash hasn't changed, we need to do it manually)
notificationsContainer.find('.js-locationVerify').on('click', (e) => notificationsContainer.find('.js-locationVerify').on('click', (e) =>
@locationVerify(e, @hidePopover) @locationVerify(e)
@hidePopover()
) )
# close notification list on click # close notification list on click