Skip to content

Commit

Permalink
MINOR Fixed UploadField edit forms falsely expanding by default
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Mar 1, 2012
1 parent f8201c4 commit 0b0e24b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions javascript/UploadField.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -196,18 +196,26 @@
} }
}); });
$('div.ss-upload .ss-uploadfield-item-editform').entwine({ $('div.ss-upload .ss-uploadfield-item-editform').entwine({
fitHeight: function() {
var iframe = this.find('iframe'), h = iframe.contents().height();
// Set iframe to match its contents height
iframe.height(h);
// set container to match the same height
iframe.parent().height(h);
},
toggleEditForm: function() { toggleEditForm: function() {
jQuery(this).toggle(); if(this.height() === 0) {
this.fitHeight();
} else {
this.height(0);
}
} }
}); });
$('div.ss-upload .ss-uploadfield-item-editform iframe').entwine({ $('div.ss-upload .ss-uploadfield-item-editform iframe').entwine({
onmatch: function() { onmatch: function() {
// TODO entwine event binding doesn't work for iframes
this.load(function() { this.load(function() {
var iframe = $(this), h = iframe.contents().height(); $(this).parent().removeClass('loading');
// Set iframe to match its contents height
iframe.height(h);
// set container to match the same height
iframe.parent().removeClass('loading').height(h);
}); });
} }
}); });
Expand Down

0 comments on commit 0b0e24b

Please sign in to comment.