From dd56429adca646165ad464c4597e0b90ff97750a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 3 Apr 2015 00:49:36 +0200 Subject: [PATCH] Reset "see more" on show/hide task. --- .../app/controllers/ticket_zoom.js.coffee | 45 +++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index db0a3b692..72824f5b7 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -90,6 +90,9 @@ class App.TicketZoom extends App.Controller return if @activeState @activeState = true + # set see more options + @setSeeMore() + App.OnlineNotification.seen( 'Ticket', @ticket_id ) @navupdate '#' @positionPageHeaderStart() @@ -484,20 +487,7 @@ class App.TicketZoom extends App.Controller ) # set see more options - maxHeight = 450 - @$('.textBubble-content').each( (index) -> - bubble = $( @ ) - offsetTop = bubble.find('.js-signatureMarker').position() - heigth = bubble.height() - if offsetTop - bubble.attr('data-height', heigth) - bubble.css('height', "#{offsetTop.top + 42}px") - else if heigth > maxHeight - bubble.attr('data-height', heigth) - bubble.css('height', "#{maxHeight}px") - else - bubble.parent().find('.textBubble-overflowContainer').addClass('hide') - ) + @setSeeMore() # scroll to article if given if @article_id && document.getElementById( 'article-' + @article_id ) @@ -515,6 +505,33 @@ class App.TicketZoom extends App.Controller @ticketLastAttributes = @ticket.attributes() + # set see more options + setSeeMore: => + maxHeight = 450 + @$('.textBubble-content').each( (index) -> + bubble = $( @ ) + + # reset bubble heigth and "see more" opacity + bubble.css('height', '') + bubble.parent().find('.textBubble-overflowContainer').css('opacity', '') + + # remember offset of "see more" + offsetTop = bubble.find('.js-signatureMarker').position() + + # remember bubble heigth + heigth = bubble.height() + if offsetTop + bubble.attr('data-height', heigth) + bubble.css('height', "#{offsetTop.top + 42}px") + bubble.parent().find('.textBubble-overflowContainer').removeClass('hide') + else if heigth > maxHeight + bubble.attr('data-height', heigth) + bubble.css('height', "#{maxHeight}px") + bubble.parent().find('.textBubble-overflowContainer').removeClass('hide') + else + bubble.parent().find('.textBubble-overflowContainer').addClass('hide') + ) + scrollToBottom: => @main.scrollTop( @main.prop('scrollHeight') )