Browse Source

follow JQuery convention + browser compatibility

pull/391/head
kutyel 8 years ago
parent
commit
cb6d2c66ad
  1. 10
      web_widget_image_download/static/src/js/web_widget_image_download.js

10
web_widget_image_download/static/src/js/web_widget_image_download.js

@ -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');
}

Loading…
Cancel
Save