summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.editor.js
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2013-09-13 13:41:43 +0200
committerXavier Morel <xmo@openerp.com>2013-09-13 13:41:43 +0200
commitf16b61cbe61a77cf331a54ea11520322e7730739 (patch)
tree20f68a87fd4a3c8f437060e9717ded613243b661 /addons/website/static/src/js/website.editor.js
parente2676729b0e5b0a58e0d19b109deaf8e1983f791 (diff)
[ADD] separate attachment dialog selector
bzr revid: xmo@openerp.com-20130913114143-v799fvf08rpiox3r
Diffstat (limited to 'addons/website/static/src/js/website.editor.js')
-rw-r--r--addons/website/static/src/js/website.editor.js43
1 files changed, 37 insertions, 6 deletions
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js
index 5a8801bba38..77bed2f9215 100644
--- a/addons/website/static/src/js/website.editor.js
+++ b/addons/website/static/src/js/website.editor.js
@@ -589,7 +589,7 @@
},
'change input[type=file]': 'file_selection',
'change input.url': 'preview_image',
- 'click .existing-attachments a': 'select_existing',
+ 'click a[href=#existing]': 'browse_existing',
}),
start: function () {
var selection = this.editor.getSelection();
@@ -600,9 +600,7 @@
this.set_image(el.getAttribute('src'));
}
- return $.when(
- this._super(),
- this.fetch_existing().then(this.proxy('fetched_existing')));
+ return this._super();
},
save: function () {
var url = this.$('input.url').val();
@@ -660,6 +658,29 @@
this.$('img.image-preview').attr('src', image);
},
+ browse_existing: function (e) {
+ e.preventDefault();
+ new website.editor.ExistingImageDialog(this).appendTo(document.body);
+ },
+ });
+
+ website.editor.ExistingImageDialog = website.editor.Dialog.extend({
+ template: 'website.editor.dialog.image.existing',
+ events: _.extend({}, website.editor.Dialog.prototype.events, {
+ 'click .existing-attachments a': 'select_existing',
+ }),
+ init: function (parent) {
+ this.image = null;
+ this.parent = parent;
+ this._super(parent.editor);
+ },
+
+ start: function () {
+ return $.when(
+ this._super(),
+ this.fetch_existing().then(this.proxy('fetched_existing')));
+ },
+
fetch_existing: function () {
// FIXME: lazy load attachments?
return openerp.jsonRpc('/web/dataset/call_kw', 'call', {
@@ -681,11 +702,21 @@
.values()
.value();
this.$('.existing-attachments').replaceWith(
- openerp.qweb.render('website.editor.dialog.image.existing', {rows: rows}));
+ openerp.qweb.render(
+ 'website.editor.dialog.image.existing.content', {rows: rows}));
},
select_existing: function (e) {
e.preventDefault();
- this.set_image(e.currentTarget.getAttribute('href'));
+ this.$('a.thumbnail.selected').removeClass('selected');
+
+ $(e.currentTarget).addClass('selected');
+ },
+ save: function () {
+ var link = this.$('a.thumbnail.selected').attr('href');
+ if (link) {
+ this.parent.set_image(link);
+ }
+ this._super();
},
});