Small bugfixes.
This commit is contained in:
parent
7258122455
commit
7d1a3dcb6b
1 changed files with 23 additions and 16 deletions
|
@ -89,7 +89,6 @@ class App.TicketZoomHighlighter extends App.Controller
|
||||||
|
|
||||||
refreshObserver: =>
|
refreshObserver: =>
|
||||||
articles = @el.closest('.content').find('.textBubble-content')
|
articles = @el.closest('.content').find('.textBubble-content')
|
||||||
console.log('refreshObserver', articles)
|
|
||||||
articles.off('mouseup', @onMouseUp)
|
articles.off('mouseup', @onMouseUp)
|
||||||
articles.on('mouseup', @onMouseUp) #future: touchend
|
articles.on('mouseup', @onMouseUp) #future: touchend
|
||||||
|
|
||||||
|
@ -99,21 +98,30 @@ class App.TicketZoomHighlighter extends App.Controller
|
||||||
article_id = $(element).data('id')
|
article_id = $(element).data('id')
|
||||||
article = App.TicketArticle.find(article_id)
|
article = App.TicketArticle.find(article_id)
|
||||||
if article.preferences && article.preferences['highlight']
|
if article.preferences && article.preferences['highlight']
|
||||||
console.log('highlight', article.preferences['highlight'])
|
|
||||||
@highlighter.deserialize(article.preferences['highlight'])
|
@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
|
||||||
#
|
#
|
||||||
# we have to check how it works with having open several tickets – it might break
|
# we have to check how it works with having open several tickets - it might break
|
||||||
#
|
#
|
||||||
# if classes can be changed in the admin interface
|
# if classes can be changed in the admin interface
|
||||||
# we have to watch out to not end up with empty highlight classes
|
# we have to watch out to not end up with empty highlight classes
|
||||||
storeHighlights: (article_id) ->
|
storeHighlights: (article_id) ->
|
||||||
article = App.TicketArticle.find(article_id)
|
|
||||||
|
# cleanup marker
|
||||||
data = @highlighter.serialize()
|
data = @highlighter.serialize()
|
||||||
console.log('HI', article_id, data)
|
marker = "$article-content-#{article_id}"
|
||||||
|
items = data.split('|')
|
||||||
|
newDataArray = [ items.shift() ]
|
||||||
|
for item in items
|
||||||
|
if item.substr(item.length-marker.length, item.length) is marker
|
||||||
|
newDataArray.push item
|
||||||
|
data = newDataArray.join('|')
|
||||||
|
|
||||||
|
# store
|
||||||
|
article = App.TicketArticle.find(article_id)
|
||||||
article.preferences['highlight'] = data
|
article.preferences['highlight'] = data
|
||||||
article.save()
|
article.save()
|
||||||
|
|
||||||
|
@ -132,7 +140,6 @@ class App.TicketZoomHighlighter extends App.Controller
|
||||||
articles.attr('data-highlightcolor', @colors[@activeColorIndex].name)
|
articles.attr('data-highlightcolor', @colors[@activeColorIndex].name)
|
||||||
|
|
||||||
toggleHighlight: (e) =>
|
toggleHighlight: (e) =>
|
||||||
console.log('toggleHighlight', @isActive)
|
|
||||||
|
|
||||||
if @isActive
|
if @isActive
|
||||||
$(e.currentTarget).removeClass('active')
|
$(e.currentTarget).removeClass('active')
|
||||||
|
@ -198,16 +205,16 @@ class App.TicketZoomHighlighter extends App.Controller
|
||||||
if @highlighter.selectionOverlapsHighlight selection
|
if @highlighter.selectionOverlapsHighlight selection
|
||||||
console.log('SELECTION EXISTS, REMOVED IT')
|
console.log('SELECTION EXISTS, REMOVED IT')
|
||||||
@highlighter.unhighlightSelection()
|
@highlighter.unhighlightSelection()
|
||||||
else
|
selection.removeAllRanges()
|
||||||
console.log('NEW SELECTION')
|
@highlightDisable()
|
||||||
|
@storeHighlights(article_id)
|
||||||
|
return
|
||||||
|
|
||||||
|
if selection && selection.rangeCount > 0
|
||||||
|
console.log('NEW SELECTION', selection)
|
||||||
@highlighter.highlightSelection @highlightClass,
|
@highlighter.highlightSelection @highlightClass,
|
||||||
selection: selection
|
selection: selection
|
||||||
containerElementId: article.get(0).id
|
containerElementId: article.get(0).id
|
||||||
|
|
||||||
# remove selection
|
|
||||||
selection.removeAllRanges()
|
selection.removeAllRanges()
|
||||||
|
|
||||||
@highlightDisable()
|
@highlightDisable()
|
||||||
|
|
||||||
# save new selections
|
|
||||||
@storeHighlights(article_id)
|
@storeHighlights(article_id)
|
Loading…
Reference in a new issue