[FIX] web{site,_editor}: gallery upload image

* when getting the src of an uploaded attachment we have to use src which
  is by default url,

* in a MediaDialog the pager is shared between the document and image
  dialog, but when changing page, it was done for both (even if not
  displayed),

* select the image after uploading it in the ImageDialog.

closes #9284
opw-653061
opw-653167
This commit is contained in:
Nicolas Lempereur
2015-10-29 13:25:27 +01:00
parent a71caede2d
commit 1da79c54a1
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -285,6 +285,9 @@ var ImageDialog = Widget.extend({
o.id = +o.url.match(/\/web\/content\/([0-9]*)/, '')[1];
}
this.parent.$(".pager > li").click(function (e) {
if(!self.$el.is(':visible')) {
return;
}
e.preventDefault();
var $target = $(e.currentTarget);
if ($target.hasClass('disabled')) {
@@ -303,7 +306,6 @@ var ImageDialog = Widget.extend({
var img = _.select(this.images, function (v) { return v.id == attachment.id;});
if (img.length) {
this.images.splice(this.images.indexOf(img[0]),1);
return;
}
} else {
this.images = [];
@@ -421,11 +423,11 @@ var ImageDialog = Widget.extend({
var $button = this.$('button.filepicker');
if (!error) {
$button.addClass('btn-success');
this.set_image(attachment);
} else {
this.$('form').addClass('has-error')
.find('.help-block').text(error);
$button.addClass('btn-danger');
this.set_image(attachment, error);
}
if (!this.options.select_images) {
@@ -232,7 +232,7 @@ options.registry.gallery = options.Class.extend({
editor.on('saved', this, function (attachments) {
for (var i = 0 ; i < attachments.length; i++) {
var img = $('<img class="img img-responsive mb8 mt8"/>')
.attr("src", attachments[i].url)
.attr("src", attachments[i].src)
.attr('data-index', index+i)
.data('index', index+i)
.appendTo($container);