Improved preview detection for attachment.

This commit is contained in:
Martin Edenhofer 2018-02-22 14:51:59 +01:00
parent 8a2579139e
commit 8ed2bdd234
5 changed files with 51 additions and 1 deletions

View file

@ -12,7 +12,7 @@ class App.TicketZoomArticleImageView extends App.ControllerModal
'click .js-close': 'cancel'
content: ->
"<div class=\"centered\">#{@image}</div>"
"<div class=\"centered imagePreview\">#{@image}</div>"
onSubmit: =>
url = "#{$(@image).attr('src')}?disposition=attachment"

View file

@ -137,6 +137,7 @@ class App extends Spine.Controller
App.i18n.translateContent(string)
ContentTypeIcon: (contentType) ->
contentType = App.Utils.contentTypeCleanup(contentType)
icons =
# image
'image/jpeg': 'file-image'
@ -172,6 +173,7 @@ class App extends Spine.Controller
return icons[contentType]
canDownload: (contentType) ->
contentType = App.Utils.contentTypeCleanup(contentType)
contentType != 'text/html'
canPreview: (contentType) ->

View file

@ -913,6 +913,11 @@ class App.Utils
result.push localResult[0]
result
@contentTypeCleanup: (contentType) ->
return contentType if !contentType
contentType = contentType.replace(/^(.+?\/.+?)(\b|\s).+?$/, '$1')
contentType
@getRecipientArticle: (ticket, article, article_created_by, type, email_addresses = [], all) ->
# empty form

View file

@ -7206,6 +7206,11 @@ label + .wizard-buttonList {
opacity: 0;
}
.imagePreview img {
max-width: 100%;
max-height: 100%;
}
.imageCropper p {
margin: 0;
}

View file

@ -2606,3 +2606,41 @@ test('check getRecipientArticle format', function() {
});
}
test("contentTypeCleanup", function() {
var source = "image/png"
var should = "image/png"
var result = App.Utils.contentTypeCleanup(source)
equal(result, should, source)
source = "image/png; some.file"
should = "image/png"
result = App.Utils.contentTypeCleanup(source)
equal(result, should, source)
source = "image/png;some.file"
should = "image/png"
result = App.Utils.contentTypeCleanup(source)
equal(result, should, source)
source = "image/jpeg;some.file"
should = "image/jpeg"
result = App.Utils.contentTypeCleanup(source)
equal(result, should, source)
source = "image/jpg;some.file"
should = "image/jpg"
result = App.Utils.contentTypeCleanup(source)
equal(result, should, source)
source = "image/gif;some.file"
should = "image/gif"
result = App.Utils.contentTypeCleanup(source)
equal(result, should, source)
source = "image/gif\n;some.file"
should = "image/gif"
result = App.Utils.contentTypeCleanup(source)
equal(result, should, source)
});