mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #1145 from silverstripe-rebelalliance/bug/image_reedit_attr
FIX Not calling updateFromNode on re-opening an image
This commit is contained in:
commit
0b44d8fbfb
@ -800,8 +800,8 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
|
||||
|
||||
// TODO Depends on managed mime type
|
||||
if(node.is('img')) {
|
||||
this.showFileView(node.data('url') || node.attr('src')).complete(function() {
|
||||
$(this).updateFromNode(node);
|
||||
this.showFileView(node.data('url') || node.attr('src')).done(function(filefield) {
|
||||
filefield.updateFromNode(node);
|
||||
self.toggleCloseButton();
|
||||
self.redraw();
|
||||
});
|
||||
@ -844,25 +844,29 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
|
||||
getFileView: function(idOrUrl) {
|
||||
return this.find('.ss-htmleditorfield-file[data-id=' + idOrUrl + ']');
|
||||
},
|
||||
showFileView: function(idOrUrl, successCallback) {
|
||||
var self = this, params = (Number(idOrUrl) == idOrUrl) ? {ID: idOrUrl} : {FileURL: idOrUrl},
|
||||
item = $('<div class="ss-htmleditorfield-file" />');
|
||||
showFileView: function(idOrUrl) {
|
||||
var self = this, params = (Number(idOrUrl) == idOrUrl) ? {ID: idOrUrl} : {FileURL: idOrUrl};
|
||||
|
||||
item.addClass('loading');
|
||||
var item = $('<div class="ss-htmleditorfield-file loading" />');
|
||||
this.find('.content-edit').append(item);
|
||||
return $.ajax({
|
||||
// url: this.data('urlViewfile') + '?ID=' + id,
|
||||
|
||||
var dfr = $.Deferred();
|
||||
|
||||
$.ajax({
|
||||
url: $.path.addSearchParams(this.attr('action').replace(/MediaForm/, 'viewfile'), params),
|
||||
success: function(html, status, xhr) {
|
||||
var newItem = $(html);
|
||||
var newItem = $(html).filter('.ss-htmleditorfield-file');
|
||||
item.replaceWith(newItem);
|
||||
self.redraw();
|
||||
if(successCallback) successCallback.call(newItem, html, status, xhr);
|
||||
dfr.resolve(newItem);
|
||||
},
|
||||
error: function() {
|
||||
item.remove();
|
||||
dfr.reject();
|
||||
}
|
||||
});
|
||||
|
||||
return dfr.promise();
|
||||
}
|
||||
});
|
||||
|
||||
@ -951,7 +955,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
|
||||
|
||||
if (urlField.validate()) {
|
||||
container.addClass('loading');
|
||||
form.showFileView('http://' + urlField.val()).complete(function() {
|
||||
form.showFileView('http://' + urlField.val()).done(function() {
|
||||
container.removeClass('loading');
|
||||
});
|
||||
form.redraw();
|
||||
|
Loading…
Reference in New Issue
Block a user