diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2012-08-21 18:15:17 +0200 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2012-08-21 18:15:17 +0200 |
| commit | a70222628b7749f20a6ce2db2f4b6ac47e71c577 (patch) | |
| tree | 4997e0d60133d953f922c2219a1ab690875c52c1 /addons/web/static/src | |
| parent | 47175ac608ff67d70a72a68bb817caf4e7326735 (diff) | |
[IMP] added preview_image and size in images
bzr revid: nicolas.vanhoren@openerp.com-20120821161517-umnu1465gq809orj
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/css/base.css | 4 | ||||
| -rw-r--r-- | addons/web/static/src/css/base.sass | 4 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 19 |
3 files changed, 20 insertions, 7 deletions
diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 269d224bc06..24828e89452 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -505,8 +505,8 @@ margin: 4px; } .openerp .oe_avatar > img { - height: 90px; - max-width: 100px; + max-height: 90px; + max-width: 90px; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index f195015ff1e..176a255a239 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -426,8 +426,8 @@ $sheet-max-width: 860px margin: 4px .oe_avatar > img - height: 90px - max-width: 100px + max-height: 90px + max-width: 90px @include radius(3px) @include box-shadow(0 1px 3px rgba(0, 0, 0, 0.3)) border: none diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 4f3f1c62f13..45adceacfb0 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4635,19 +4635,32 @@ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({ this.render_value(); }, render_value: function() { + var self = this; var url; if (this.get('value') && ! /^\d+(\.\d*)? \w+$/.test(this.get('value'))) { url = 'data:image/png;base64,' + this.get('value'); } else if (this.get('value')) { var id = escape(JSON.stringify(this.view.datarecord.id || null)); + var field = this.name; + if (this.options.preview_image) + field = this.options.preview_image; url = '/web/binary/image?session_id=' + this.session.session_id + '&model=' + - this.view.dataset.model +'&id=' + id + '&field=' + this.name + '&t=' + (new Date().getTime()); + this.view.dataset.model +'&id=' + id + '&field=' + field + '&t=' + (new Date().getTime()); } else { url = "/web/static/src/img/placeholder.png"; } - var img = QWeb.render("FieldBinaryImage-img", { widget: this, url: url }); + var $img = $(QWeb.render("FieldBinaryImage-img", { widget: this, url: url })); this.$element.find('> img').remove(); - this.$element.prepend(img); + this.$element.prepend($img); + $img.load(function() { + if (! self.options.size) + return; + debugger; + $img.css("max-width", "" + self.options.size[0] + "px"); + $img.css("max-height", "" + self.options.size[1] + "px"); + $img.css("margin-left", "" + (self.options.size[0] - $img.width()) / 2 + "px"); + $img.css("margin-top", "" + (self.options.size[1] - $img.height()) / 2 + "px"); + }); }, on_file_change: function() { this.render_value(); |
