Fixed setting of highlighter.

This commit is contained in:
Martin Edenhofer 2015-10-02 00:07:28 +02:00
parent e1594f07ba
commit 19a2e5f8de
3 changed files with 29 additions and 41 deletions

View file

@ -107,9 +107,6 @@ class App.TicketZoom extends App.Controller
if !@shown if !@shown
# inital load of highlights
@loadHighlighter()
# trigger shown to article # trigger shown to article
App.Event.trigger('ui::ticket::shown', { ticket_id: @ticket_id } ) App.Event.trigger('ui::ticket::shown', { ticket_id: @ticket_id } )
@ -271,12 +268,6 @@ class App.TicketZoom extends App.Controller
@scrollPageHeader.css('transform', "translateY(#{top}px)") @scrollPageHeader.css('transform', "translateY(#{top}px)")
loadHighlighter: =>
return if !@highligher
return if @highlighed
@highlighed = true
@highligher.loadHighlights()
render: => render: =>
# update taskbar with new meta data # update taskbar with new meta data
@ -320,17 +311,18 @@ class App.TicketZoom extends App.Controller
ui: @ ui: @
) )
@article_view = new App.TicketZoomArticleView(
ticket: @ticket
el: @el.find('.ticket-article')
ui: @
)
@highligher = new App.TicketZoomHighlighter( @highligher = new App.TicketZoomHighlighter(
el: @$('.highlighter') el: @$('.highlighter')
ticket_id: @ticket.id ticket_id: @ticket.id
) )
@article_view = new App.TicketZoomArticleView(
ticket: @ticket
el: @el.find('.ticket-article')
ui: @
highligher: @highligher
)
# rerender whole sidebar if customer or organization has changed # rerender whole sidebar if customer or organization has changed
if @ticketLastAttributes.customer_id isnt @ticket.customer_id || @ticketLastAttributes.organization_id isnt @ticket.organization_id if @ticketLastAttributes.customer_id isnt @ticket.customer_id || @ticketLastAttributes.organization_id isnt @ticket.organization_id
new App.WidgetAvatar( new App.WidgetAvatar(
@ -350,13 +342,6 @@ class App.TicketZoom extends App.Controller
) )
# show article # show article
if !@article_view
@article_view = new App.TicketZoomArticleView(
ticket: @ticket
el: @el.find('.ticket-article')
ui: @
)
@article_view.execute( @article_view.execute(
ticket_article_ids: @ticket_article_ids ticket_article_ids: @ticket_article_ids
) )
@ -374,9 +359,6 @@ class App.TicketZoom extends App.Controller
if @shown && !@initDone if @shown && !@initDone
@initDone = true @initDone = true
# inital load of highlights
@loadHighlighter()
# scroll to end of page # scroll to end of page
@scrollToBottom() @scrollToBottom()

View file

@ -14,12 +14,13 @@ class App.TicketZoomArticleView extends App.Controller
ticket_article_id: ticket_article_id ticket_article_id: ticket_article_id
el: el el: el
ui: @ui ui: @ui
highligher: @highligher
) )
all.push el all.push el
@el.append( all ) @el.append( all )
class ArticleViewItem extends App.Controller class ArticleViewItem extends App.Controller
hasChangedAttributes: ['from', 'to', 'cc', 'subject', 'body', 'internal'] hasChangedAttributes: ['from', 'to', 'cc', 'subject', 'body', 'internal', 'preferences']
elements: elements:
'.textBubble-content': 'textBubbleContent' '.textBubble-content': 'textBubbleContent'
@ -42,10 +43,17 @@ class ArticleViewItem extends App.Controller
@bind( @bind(
'ui::ticket::shown' 'ui::ticket::shown'
(data) => (data) =>
return if data.ticket_id.toString() isnt @ticket.id.toString()
# set highlighter
@highligher.loadHighlights(@ticket_article_id)
if !@shown if !@shown
if data.ticket_id.toString() is @ticket.id.toString()
@setSeeMore() # set see more
@shown = true @setSeeMore()
@shown = true
) )
# subscribe to changes # subscribe to changes
@ -117,6 +125,9 @@ class ArticleViewItem extends App.Controller
# set see more option # set see more option
@setSeeMore() @setSeeMore()
# set highlighter
@highligher.loadHighlights(@ticket_article_id)
# set see more options # set see more options
setSeeMore: => setSeeMore: =>
maxHeight = 560 maxHeight = 560

View file

@ -49,11 +49,6 @@ class App.TicketZoomHighlighter extends App.Controller
# store original highlight css data # store original highlight css data
@storeOriginalHighlight() @storeOriginalHighlight()
update = =>
@loadHighlights()
@refreshObserver()
App.Delay.set( update, 800 )
render: -> render: ->
@html App.view('ticket_zoom/highlighter') @html App.view('ticket_zoom/highlighter')
colors: @colors colors: @colors
@ -93,14 +88,14 @@ class App.TicketZoomHighlighter extends App.Controller
articles.on('mouseup', @onMouseUp) #future: touchend articles.on('mouseup', @onMouseUp) #future: touchend
# for testing purposes the highlights get stored in localStorage # for testing purposes the highlights get stored in localStorage
loadHighlights: -> loadHighlights: (ticket_article_id) ->
return if !@isRole('Agent') return if !@isRole('Agent')
@el.closest('.content').find('.textBubble-content').each( (index, element) => article = App.TicketArticle.find(ticket_article_id)
article_id = $(element).data('id') return if !article.preferences
article = App.TicketArticle.find(article_id) return if !article.preferences.highlight
if article.preferences && article.preferences['highlight'] return if _.isEmpty(article.preferences.highlight)
@highlighter.deserialize(article.preferences['highlight']) return if article.preferences.highlight is 'type:TextRange'
) @highlighter.deserialize(article.preferences['highlight'])
# the serialization creates one string for the entiery ticket # the serialization creates one string for the entiery ticket
# containing the offsets and the highlight classes # containing the offsets and the highlight classes