From 367e6ab8bedc414d06d5808f52f2c592f54fd7b4 Mon Sep 17 00:00:00 2001 From: Felix Niklas Date: Thu, 18 Sep 2014 11:29:25 +0200 Subject: [PATCH] recipientList add dynamic targets using data-organisation for reference --- .../controllers/agent_ticket_create.js.coffee | 29 +++++++------- .../app/views/agent_ticket_create.jst.eco | 38 +++++++++++++++++-- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee index 75bfd4392..e837ce821 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -43,15 +43,18 @@ class App.TicketCreate extends App.Controller showOrganisationMembers: (e) => e.stopPropagation() - list = @$('.recipientList') - organisationList = @$('.recipientList-organisationMembers') + listEntry = $(e.currentTarget) + organisationId = listEntry.data('organisation') + + @recipientList = @$('.recipientList') + @organisationList = @$("##{ organisationId }") # move organisation-list to the right and slide it in - $.Velocity.hook(organisationList, 'translateX', '100%') - organisationList.removeClass('hide') + $.Velocity.hook(@organisationList, 'translateX', '100%') + @organisationList.removeClass('hide') - organisationList.velocity + @organisationList.velocity properties: translateX: 0 options: @@ -59,21 +62,21 @@ class App.TicketCreate extends App.Controller # fade out list - list.velocity + @recipientList.velocity properties: translateX: '-100%' options: speed: 300 - complete: -> list.height(organisationList.height()) + complete: => @recipientList.height(@organisationList.height()) hideOrganisationMembers: (e) => e && e.stopPropagation() - list = @$('.recipientList') - organisationList = @$('.recipientList-organisationMembers') + + return if !@organisationList # fade list back in - list.velocity + @recipientList.velocity properties: translateX: 0 options: @@ -81,16 +84,16 @@ class App.TicketCreate extends App.Controller # reset list height - list.height('') + @recipientList.height('') # slide out organisation-list and hide it - organisationList.velocity + @organisationList.velocity properties: translateX: '100%' options: speed: 300 - complete: -> organisationList.addClass('hide') + complete: => @organisationList.addClass('hide') changeFormType: (e) => type = $(e.target).data('type') diff --git a/app/assets/javascripts/app/views/agent_ticket_create.jst.eco b/app/assets/javascripts/app/views/agent_ticket_create.jst.eco index d0ad3f11e..6cce00c13 100644 --- a/app/assets/javascripts/app/views/agent_ticket_create.jst.eco +++ b/app/assets/javascripts/app/views/agent_ticket_create.jst.eco @@ -33,8 +33,8 @@
-
  • +
  • @@ -130,7 +130,7 @@ -