follow JQuery convention + browser compatibility

This commit is contained in:
kutyel
2016-07-28 18:47:29 +02:00
parent 5d4308cfa2
commit cb6d2c66ad

View File

@@ -6,10 +6,10 @@ openerp.web_widget_image_download = function (instance) {
'use strict';
instance.web.form.web_widget_image_download = instance.web.form.FieldBinaryImage.include({
render_value() {
render_value: function () {
this._super();
const widget = this.$el.find('.oe_form_binary_file_download');
var $widget = this.$el.find('.oe_form_binary_file_download');
this.imgSrc = this.$el.find('img[name="image"]').attr('src');
@@ -18,7 +18,7 @@ openerp.web_widget_image_download = function (instance) {
url: this.imgSrc,
complete(xhr) {
// retrieve image type from server ("Content-Type" header)
widget.attr('download', xhr.getResponseHeader("Content-Type").replace('/', '.'));
$widget.attr('download', xhr.getResponseHeader("Content-Type").replace('/', '.'));
}
});
@@ -27,9 +27,9 @@ openerp.web_widget_image_download = function (instance) {
this.$el.find('.oe_form_binary_file_clear').removeClass('col-md-offset-5');
}
widget.attr('href', this.imgSrc);
$widget.attr('href', this.imgSrc);
},
has_custom_image() {
has_custom_image: function () {
// check if the image of the widget is different from the default placeholder
return this.imgSrc && !this.imgSrc.includes('/placeholder.png');
}