MINOR Removing special case handling for chosen.js from UploadField, using generic change listener (incl. some iframe scoping fixes)

This commit is contained in:
Ingo Schommer 2012-05-11 12:40:57 +02:00
parent 8e7d221ce2
commit 3f19f4cec0

View File

@ -287,27 +287,18 @@
var editform = this.closest('.ss-uploadfield-item').find('.ss-uploadfield-item-editform'); var editform = this.closest('.ss-uploadfield-item').find('.ss-uploadfield-item-editform');
var disabled; var disabled;
var iframe = editform.find('iframe'); var iframe = editform.find('iframe');
var inputs = iframe.contents().find('.ss-uploadfield-edit-iframe input');
var ulSelects =iframe.contents().find('.ss-uploadfield-edit-iframe .chzn-drop ul.chzn-results'); // Mark the row as changed if any of its form fields are edited
iframe.contents().ready(function() {
for(var i=0;i<inputs.length;i++){ // Need to use the iframe's own jQuery, as custom event triggers
$(inputs[i]).change(function(){ // (e.g. from TreeDropdownField) can't be captured by the parent jQuery object.
var iframe_jQuery = iframe.get(0).contentWindow.jQuery;
iframe_jQuery(iframe_jQuery.find(':input')).bind('change', function(e){
editform.removeClass('edited'); editform.removeClass('edited');
editform.addClass('edited'); editform.addClass('edited');
}); });
});
}
for(var i=0;i<ulSelects.length;i++){
var current= $(ulSelects[i]).find('li.result-selected');
$(ulSelects[i]).children('li').click(function(){
if(this !== current[0]){
editform.removeClass('edited');
editform.addClass('edited');
}
});
}
if (editform.hasClass('loading')) { if (editform.hasClass('loading')) {
// TODO Display loading indication, and register an event to toggle edit form // TODO Display loading indication, and register an event to toggle edit form
} else { } else {