Improved handling of popovers.
This commit is contained in:
parent
5f401a7b04
commit
807b9e5838
2 changed files with 39 additions and 24 deletions
|
@ -62,6 +62,10 @@ class App.Controller extends Spine.Controller
|
||||||
if @ajaxCalls
|
if @ajaxCalls
|
||||||
for callId in @ajaxCalls
|
for callId in @ajaxCalls
|
||||||
App.Ajax.abort(callId)
|
App.Ajax.abort(callId)
|
||||||
|
@userTicketPopupsDestroy()
|
||||||
|
@ticketPopupsDestroy()
|
||||||
|
@userPopupsDestroy()
|
||||||
|
@organizationPopupsDestroy()
|
||||||
|
|
||||||
release: =>
|
release: =>
|
||||||
# release custom bindings after it got removed from dom
|
# release custom bindings after it got removed from dom
|
||||||
|
@ -281,16 +285,15 @@ class App.Controller extends Spine.Controller
|
||||||
|
|
||||||
ticketPopups: (position = 'right') ->
|
ticketPopups: (position = 'right') ->
|
||||||
|
|
||||||
# remove old popovers
|
@ticketPopupsDestroy()
|
||||||
$('.popover').remove()
|
|
||||||
|
|
||||||
# show ticket popup
|
# show ticket popup
|
||||||
ui = @
|
ui = @
|
||||||
@el.find('.ticket-popover').popover(
|
@ticketPopupsList = @el.find('.ticket-popover').popover(
|
||||||
trigger: 'hover'
|
trigger: 'hover'
|
||||||
container: 'body'
|
container: 'body'
|
||||||
html: true
|
html: true
|
||||||
delay: { show: 500, hide: 1200 }
|
delay: { show: 400, hide: 400 }
|
||||||
placement: position
|
placement: position
|
||||||
title: ->
|
title: ->
|
||||||
ticket_id = $(@).data('id')
|
ticket_id = $(@).data('id')
|
||||||
|
@ -306,25 +309,27 @@ class App.Controller extends Spine.Controller
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
userPopups: (position = 'right') ->
|
ticketPopupsDestroy: =>
|
||||||
|
if @ticketPopupsList
|
||||||
|
@ticketPopupsList.popover('destroy')
|
||||||
|
|
||||||
# remove old popovers
|
userPopups: (position = 'right') ->
|
||||||
$('.popover').remove()
|
|
||||||
|
|
||||||
# open user in new task if user isn't customer
|
# open user in new task if user isn't customer
|
||||||
if !@isRole('Customer')
|
if !@isRole('Customer')
|
||||||
@el.find('.user-popover').bind('click', (e) =>
|
@el.find('.user-popover').bind('click', (e) =>
|
||||||
user_id = $(e.target).data('id')
|
user_id = $(e.target).data('id')
|
||||||
@navigate "#user/zoom/#{user_id}"
|
@navigate "#user/zoom/#{user_id}"
|
||||||
$('.popover').remove()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@userPopupsDestroy()
|
||||||
|
|
||||||
# show user popup
|
# show user popup
|
||||||
@el.find('.user-popover').popover(
|
@userPopupsList = @el.find('.user-popover').popover(
|
||||||
trigger: 'hover'
|
trigger: 'hover'
|
||||||
container: 'body'
|
container: 'body'
|
||||||
html: true
|
html: true
|
||||||
delay: { show: 500, hide: 1200 }
|
delay: { show: 400, hide: 400 }
|
||||||
placement: position
|
placement: position
|
||||||
title: ->
|
title: ->
|
||||||
user_id = $(@).data('id')
|
user_id = $(@).data('id')
|
||||||
|
@ -360,17 +365,21 @@ class App.Controller extends Spine.Controller
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
userPopupsDestroy: =>
|
||||||
|
console.log('userPopupsDestroy', @userPopupsList)
|
||||||
|
if @userPopupsList
|
||||||
|
@userPopupsList.popover('destroy')
|
||||||
|
|
||||||
organizationPopups: (position = 'right') ->
|
organizationPopups: (position = 'right') ->
|
||||||
|
|
||||||
# remove old popovers
|
@organizationPopupsDestroy()
|
||||||
$('.popover').remove()
|
|
||||||
|
|
||||||
# show organization popup
|
# show organization popup
|
||||||
@el.find('.organization-popover').popover(
|
@organizationPopupsList = @el.find('.organization-popover').popover(
|
||||||
trigger: 'hover'
|
trigger: 'hover'
|
||||||
container: 'body'
|
container: 'body'
|
||||||
html: true
|
html: true
|
||||||
delay: { show: 500, hide: 1200 }
|
delay: { show: 400, hide: 400 }
|
||||||
placement: position
|
placement: position
|
||||||
title: ->
|
title: ->
|
||||||
organization_id = $(@).data('id')
|
organization_id = $(@).data('id')
|
||||||
|
@ -385,19 +394,22 @@ class App.Controller extends Spine.Controller
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
userTicketPopups: (params) ->
|
organizationPopupsDestroy: =>
|
||||||
|
if @organizationPopupsList
|
||||||
|
@organizationPopupsList.popover('destroy')
|
||||||
|
|
||||||
# remove old popovers
|
userTicketPopups: (params) ->
|
||||||
$('.popover').remove()
|
|
||||||
|
|
||||||
show = (data, tickets) =>
|
show = (data, tickets) =>
|
||||||
|
|
||||||
if !data.position
|
if !data.position
|
||||||
data.position = 'left'
|
data.position = 'left'
|
||||||
|
|
||||||
|
@userTicketPopupsDestroy()
|
||||||
|
|
||||||
# show user popup
|
# show user popup
|
||||||
controller = @
|
controller = @
|
||||||
@el.find(data.selector).popover(
|
@userTicketPopupsList = @el.find(data.selector).popover(
|
||||||
trigger: 'hover'
|
trigger: 'hover'
|
||||||
container: 'body'
|
container: 'body'
|
||||||
html: true
|
html: true
|
||||||
|
@ -446,6 +458,10 @@ class App.Controller extends Spine.Controller
|
||||||
else
|
else
|
||||||
fetch(params)
|
fetch(params)
|
||||||
|
|
||||||
|
userTicketPopupsDestroy: =>
|
||||||
|
if @userTicketPopupsList
|
||||||
|
@userTicketPopupsList.popover('destroy')
|
||||||
|
|
||||||
recentView: (object, o_id) =>
|
recentView: (object, o_id) =>
|
||||||
params =
|
params =
|
||||||
object: object
|
object: object
|
||||||
|
|
|
@ -89,13 +89,15 @@ class App.Navigation extends App.Controller
|
||||||
renderResult: (result = []) =>
|
renderResult: (result = []) =>
|
||||||
el = @el.find('#global-search-result')
|
el = @el.find('#global-search-result')
|
||||||
|
|
||||||
|
# destroy existing popovers
|
||||||
|
@ticketPopupsDestroy()
|
||||||
|
@userPopupsDestroy()
|
||||||
|
@organizationPopupsDestroy()
|
||||||
|
|
||||||
# remove result if not result exists
|
# remove result if not result exists
|
||||||
if _.isEmpty( result )
|
if _.isEmpty( result )
|
||||||
@el.find('#global-search').parents('li').removeClass('open')
|
@el.find('#global-search').parents('li').removeClass('open')
|
||||||
el.html( '' )
|
el.html( '' )
|
||||||
|
|
||||||
# remove old popovers
|
|
||||||
$('.popover').remove()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# show result list
|
# show result list
|
||||||
|
@ -118,9 +120,6 @@ class App.Navigation extends App.Controller
|
||||||
|
|
||||||
render: () ->
|
render: () ->
|
||||||
|
|
||||||
# remove old popovers
|
|
||||||
$('.popover').remove()
|
|
||||||
|
|
||||||
# remember old search query
|
# remember old search query
|
||||||
search = @el.find('#global-search').val()
|
search = @el.find('#global-search').val()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue