diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_actions.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_actions.coffee index 6b60eb01e..df150405a 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_actions.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_actions.coffee @@ -391,6 +391,7 @@ class App.TicketZoomArticleActions extends App.Controller body = @el.closest('.ticketZoom').find('.article-add [data-name="body"]').html() || '' # check if quote need to be added + signaturePosition = 'bottom' selected = App.ClipBoard.getSelected('html') if selected selected = App.Utils.htmlCleanup(selected).html() @@ -399,6 +400,16 @@ class App.TicketZoomArticleActions extends App.Controller if selected selected = App.Utils.textCleanup(selected) selected = App.Utils.text2html(selected) + + # full quote, if needed + if !selected && article && App.Config.get('ui_ticket_zoom_article_email_full_quote') + signaturePosition = 'top' + if article.content_type.match('html') + selected = App.Utils.textCleanup(article.body) + if article.content_type.match('plain') + selected = App.Utils.textCleanup(selected) + selected = App.Utils.text2html(selected) + if selected selected = "


#{selected}

" @@ -409,7 +420,12 @@ class App.TicketZoomArticleActions extends App.Controller type = App.TicketArticleType.findByAttribute(name:'email') - App.Event.trigger('ui::ticket::setArticleType', { ticket: @ticket, type: type, article: articleNew } ) + App.Event.trigger('ui::ticket::setArticleType', { + ticket: @ticket + type: type + article: articleNew + signaturePosition: signaturePosition + }) telegramPersonalMessageReply: (e) => e.preventDefault() diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee index 60fd1b1bf..82ed57e1e 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee @@ -59,7 +59,7 @@ class App.TicketZoomArticleNew extends App.Controller @$('[name="' + key + '"]').val(value).trigger('change') # preselect article type - @setArticleType(data.type.name) + @setArticleType(data.type.name, data.signaturePosition) # set focus at end of field if data.position is 'end' @@ -483,7 +483,7 @@ class App.TicketZoomArticleNew extends App.Controller @$('[name=internal]').val('') - setArticleType: (type) => + setArticleType: (type, signaturePosition = 'bottom') => wasScrolledToBottom = @isScrolledToBottom() @type = type @$('[name=type]').val(type).trigger('change') @@ -532,7 +532,10 @@ class App.TicketZoomArticleNew extends App.Controller body.append('

') signature = $("
#{signatureFinished}
") App.Utils.htmlStrip(signature) - body.append(signature) + if signaturePosition is 'top' + body.prepend(signature) + else + body.append(signature) @$('[data-name=body]').replaceWith(body) # remove old signature @@ -566,6 +569,20 @@ class App.TicketZoomArticleNew extends App.Controller @delay(@updateLetterCount, 600) @$('.js-textSizeLimit').removeClass('hide') + # convert remote src images to data uri + @$('[data-name=body] img').each( (i,image) -> + $image = $(image) + src = $image.attr('src') + if !_.isEmpty(src) && !src.match(/^data:image/i) + canvas = document.createElement('canvas') + canvas.width = image.width + canvas.height = image.height + ctx = canvas.getContext('2d') + ctx.drawImage(image, 0, 0) + dataURL = canvas.toDataURL() + $image.attr('src', dataURL) + ) + @scrollToBottom() if wasScrolledToBottom isScrolledToBottom: -> diff --git a/db/migrate/20170630000001_ticket_zoom_setting.rb b/db/migrate/20170713000001_ticket_zoom_setting2.rb similarity index 74% rename from db/migrate/20170630000001_ticket_zoom_setting.rb rename to db/migrate/20170713000001_ticket_zoom_setting2.rb index 9966132fd..8147edc1f 100644 --- a/db/migrate/20170630000001_ticket_zoom_setting.rb +++ b/db/migrate/20170713000001_ticket_zoom_setting2.rb @@ -1,4 +1,4 @@ -class TicketZoomSetting < ActiveRecord::Migration +class TicketZoomSetting2 < ActiveRecord::Migration def up # return if it's a new setup @@ -67,6 +67,33 @@ class TicketZoomSetting < ActiveRecord::Migration }, frontend: true ) + Setting.create_if_not_exists( + title: 'Email - full quote', + name: 'ui_ticket_zoom_article_email_full_quote', + area: 'UI::TicketZoom', + description: 'Enable if you want to quote the full email in your answer. The quoted email will be put at the end of your answer. If you just want to quote a certain phrase, just mark the text and press reply (this feature is always available).', + options: { + form: [ + { + display: '', + null: true, + name: 'ui_ticket_zoom_article_email_full_quote', + tag: 'boolean', + translate: true, + options: { + true => 'yes', + false => 'no', + }, + }, + ], + }, + state: false, + preferences: { + prio: 220, + permission: ['admin.ui'], + }, + frontend: true + ) Setting.create_if_not_exists( title: 'Twitter - tweet initials', name: 'ui_ticket_zoom_article_twitter_initials', diff --git a/db/seeds/settings.rb b/db/seeds/settings.rb index 73b3b7797..e791637f6 100644 --- a/db/seeds/settings.rb +++ b/db/seeds/settings.rb @@ -600,6 +600,33 @@ Setting.create_if_not_exists( }, frontend: true ) +Setting.create_if_not_exists( + title: 'Email - full quote', + name: 'ui_ticket_zoom_article_email_full_quote', + area: 'UI::TicketZoom', + description: 'Enable if you want to quote the full email in your answer. The quoted email will be put at the end of your answer. If you just want to quote a certain phrase, just mark the text and press reply (this feature is always available).', + options: { + form: [ + { + display: '', + null: true, + name: 'ui_ticket_zoom_article_email_full_quote', + tag: 'boolean', + translate: true, + options: { + true => 'yes', + false => 'no', + }, + }, + ], + }, + state: false, + preferences: { + prio: 220, + permission: ['admin.ui'], + }, + frontend: true +) Setting.create_if_not_exists( title: 'Twitter - tweet initials', name: 'ui_ticket_zoom_article_twitter_initials',