attachment preview resize
This commit is contained in:
@@ -186,6 +186,12 @@ Espo.define('views/fields/attachment-multiple', 'views/fields/base', function (D
|
||||
this.listenTo(this.model, 'change:' + this.nameHashName, function () {
|
||||
this.nameHash = _.clone(this.model.get(this.nameHashName)) || {};
|
||||
}.bind(this));
|
||||
|
||||
this.once('remove', function () {
|
||||
if (this.resizeIsBeingListened) {
|
||||
$(window).off('resize.' + this.cid);
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
setupSearch: function () {
|
||||
@@ -202,6 +208,11 @@ Espo.define('views/fields/attachment-multiple', 'views/fields/base', function (D
|
||||
this.$attachments.empty();
|
||||
},
|
||||
|
||||
handleResize: function () {
|
||||
var width = this.$el.width();
|
||||
this.$el.find('img.image-preview').css('maxWidth', width + 'px');
|
||||
},
|
||||
|
||||
deleteAttachment: function (id) {
|
||||
this.removeId(id);
|
||||
if (this.model.isNew()) {
|
||||
@@ -466,6 +477,16 @@ Espo.define('views/fields/attachment-multiple', 'views/fields/base', function (D
|
||||
var type = this.$el.find('select.search-type').val();
|
||||
this.handleSearchType(type);
|
||||
}
|
||||
|
||||
if (this.mode === 'detail') {
|
||||
if (this.previewSize === 'large') {
|
||||
this.handleResize();
|
||||
this.resizeIsBeingListened = true;
|
||||
$(window).on('resize.' + this.cid, function () {
|
||||
this.handleResize();
|
||||
}.bind(this));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
isTypeIsImage: function (type) {
|
||||
@@ -483,7 +504,7 @@ Espo.define('views/fields/attachment-multiple', 'views/fields/base', function (D
|
||||
|
||||
var preview = name;
|
||||
if (this.isTypeIsImage(type)) {
|
||||
preview = '<a data-action="showImagePreview" data-id="' + id + '" href="' + this.getImageUrl(id) + '"><img src="'+this.getImageUrl(id, this.previewSize)+'"></a>';
|
||||
preview = '<a data-action="showImagePreview" data-id="' + id + '" href="' + this.getImageUrl(id) + '"><img src="'+this.getImageUrl(id, this.previewSize)+'" class="image-preview"></a>';
|
||||
}
|
||||
return preview;
|
||||
},
|
||||
|
||||
@@ -183,6 +183,11 @@ Espo.define('views/fields/file', 'views/fields/link', function (Dep) {
|
||||
this.acceptAttribue = this.accept.join('|');
|
||||
}
|
||||
|
||||
this.once('remove', function () {
|
||||
if (this.resizeIsBeingListened) {
|
||||
$(window).off('resize.' + this.cid);
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
afterRender: function () {
|
||||
@@ -221,6 +226,21 @@ Espo.define('views/fields/file', 'views/fields/link', function (Dep) {
|
||||
var type = this.$el.find('select.search-type').val();
|
||||
this.handleSearchType(type);
|
||||
}
|
||||
|
||||
if (this.mode === 'detail') {
|
||||
if (this.previewSize === 'large') {
|
||||
this.handleResize();
|
||||
this.resizeIsBeingListened = true;
|
||||
$(window).on('resize.' + this.cid, function () {
|
||||
this.handleResize();
|
||||
}.bind(this));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
handleResize: function () {
|
||||
var width = this.$el.width();
|
||||
this.$el.find('img.image-preview').css('maxWidth', width + 'px');
|
||||
},
|
||||
|
||||
getDetailPreview: function (name, type, id) {
|
||||
@@ -231,7 +251,7 @@ Espo.define('views/fields/file', 'views/fields/link', function (Dep) {
|
||||
case 'image/png':
|
||||
case 'image/jpeg':
|
||||
case 'image/gif':
|
||||
preview = '<a data-action="showImagePreview" data-id="' + id + '" href="' + this.getImageUrl(id) + '"><img src="'+this.getBasePath()+'?entryPoint=image&size='+this.previewSize+'&id=' + id + '"></a>';
|
||||
preview = '<a data-action="showImagePreview" data-id="' + id + '" href="' + this.getImageUrl(id) + '"><img src="'+this.getBasePath()+'?entryPoint=image&size='+this.previewSize+'&id=' + id + '" class="image-preview"></a>';
|
||||
}
|
||||
return preview;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user