mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Simplified edit form toggle in UploadField.js, prevent new <button> element trigger from submitting the form
This commit is contained in:
parent
8b6ef6599e
commit
ddf4791708
@ -192,32 +192,22 @@
|
|||||||
this.siblings().toggleClass('ui-state-disabled');
|
this.siblings().toggleClass('ui-state-disabled');
|
||||||
editform.toggleEditForm();
|
editform.toggleEditForm();
|
||||||
}
|
}
|
||||||
|
e.preventDefault(); // Avoid a form submit
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('div.ss-upload .ss-uploadfield-item-editform').entwine({
|
$('div.ss-upload .ss-uploadfield-item-editform').entwine({
|
||||||
EditFormVisible: false,
|
|
||||||
fitHeight: function() {
|
|
||||||
var iframe = this.find('iframe'),
|
|
||||||
h = iframe.contents().height() + 'px';
|
|
||||||
iframe.css('height', h);
|
|
||||||
return h;
|
|
||||||
},
|
|
||||||
showEditForm: function() {
|
|
||||||
return this.stop().animate({height: this.fitHeight()});
|
|
||||||
},
|
|
||||||
hideEditFormShow: function() {
|
|
||||||
return this.stop().animate({height: 0});
|
|
||||||
},
|
|
||||||
toggleEditForm: function() {
|
toggleEditForm: function() {
|
||||||
if (this.getEditFormVisible()) this.hideEditFormShow();
|
jQuery(this).toggle();
|
||||||
else this.showEditForm();
|
|
||||||
this.setEditFormVisible(!this.getEditFormVisible());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('div.ss-upload .ss-uploadfield-item-editform iframe').entwine({
|
$('div.ss-upload .ss-uploadfield-item-editform iframe').entwine({
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
this.load(function() {
|
this.load(function() {
|
||||||
$(this).parent().removeClass('loading');
|
var iframe = $(this), h = iframe.contents().height();
|
||||||
|
// Set iframe to match its contents height
|
||||||
|
iframe.height(h);
|
||||||
|
// set container to match the same height
|
||||||
|
iframe.parent().removeClass('loading').height(h);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user