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
# inital load of highlights
@loadHighlighter()
# trigger shown to article
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)")
loadHighlighter: =>
return if !@highligher
return if @highlighed
@highlighed = true
@highligher.loadHighlights()
render: =>
# update taskbar with new meta data
@ -320,17 +311,18 @@ class App.TicketZoom extends App.Controller
ui: @
)
@article_view = new App.TicketZoomArticleView(
ticket: @ticket
el: @el.find('.ticket-article')
ui: @
)
@highligher = new App.TicketZoomHighlighter(
el: @$('.highlighter')
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
if @ticketLastAttributes.customer_id isnt @ticket.customer_id || @ticketLastAttributes.organization_id isnt @ticket.organization_id
new App.WidgetAvatar(
@ -350,13 +342,6 @@ class App.TicketZoom extends App.Controller
)
# show article
if !@article_view
@article_view = new App.TicketZoomArticleView(
ticket: @ticket
el: @el.find('.ticket-article')
ui: @
)
@article_view.execute(
ticket_article_ids: @ticket_article_ids
)
@ -374,9 +359,6 @@ class App.TicketZoom extends App.Controller
if @shown && !@initDone
@initDone = true
# inital load of highlights
@loadHighlighter()
# scroll to end of page
@scrollToBottom()

View file

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

View file

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