Permalink
Browse files

MINOR Simplified edit form toggle in UploadField.js, prevent new <but…

…ton> element trigger from submitting the form
  • Loading branch information...
1 parent 8b6ef65 commit ddf479170880d3254e76f61e5c1141248974910a @chillu chillu committed Feb 23, 2012
Showing with 7 additions and 17 deletions.
  1. +7 −17 javascript/UploadField.js
View
@@ -192,32 +192,22 @@
this.siblings().toggleClass('ui-state-disabled');
editform.toggleEditForm();
}
+ e.preventDefault(); // Avoid a form submit
}
});
$('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() {
- if (this.getEditFormVisible()) this.hideEditFormShow();
- else this.showEditForm();
- this.setEditFormVisible(!this.getEditFormVisible());
+ jQuery(this).toggle();
}
});
$('div.ss-upload .ss-uploadfield-item-editform iframe').entwine({
onmatch: 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);
});
}
});

0 comments on commit ddf4791

Please sign in to comment.