ENHANCEMENT: Nice enabling and disabling of fields when linking a document

This commit is contained in:
Andrew O'Neil 2012-08-20 11:40:53 +12:00
parent 820f89bec0
commit 7dd6b2bb72

View File

@ -39,6 +39,9 @@
var document_id = ui.item.value; var document_id = ui.item.value;
$(this).closest('.document-add-existing').adddocument(document_id); $(this).closest('.document-add-existing').adddocument(document_id);
$(this).val('');
return false;
} }
} }
}); });
@ -52,23 +55,22 @@
} }
}); });
// TODO - This will become redundant if the above function works $('.document-add-existing .TreeDropdownField').entwine({
// When clicking on the search input this removes the disabled state onpanelshow: function() {
$('.document-add-existing .treedropdownfield-toggle-panel-link').entwine({
onclick: function() {
$(this).closest('.document-add-existing').find('input.document-autocomplete').prop('disabled', true); $(this).closest('.document-add-existing').find('input.document-autocomplete').prop('disabled', true);
},
onpanelhide: function() {
$(this).closest('.document-add-existing').find('input.document-autocomplete').prop('disabled', $(this).closest('.document-add-existing').find('.document-list:visible').length > 0);
} }
}); });
//TODO - When documents load in the document list. Toggle the visibilty of this. By default it should be hidden
$('.document-add-existing input[name=PageSelector]').entwine({ $('.document-add-existing input[name=PageSelector]').entwine({
onchange: function(event) { onchange: function(event) {
$(this).closest('.document-add-existing').find('.document-list').load( var doclist = $(this).closest('.document-add-existing').find('.document-list');
'admin/pages/adddocument/documentlist?pageID=' + $(this).val(), doclist.html('<span>Loading...</span>');
null, doclist.show();
function () { doclist.load(
$(this).show(); 'admin/pages/adddocument/documentlist?pageID=' + $(this).val()
}
); );
} }
@ -84,7 +86,14 @@
return false; return false;
} }
}) });
$('body').entwine({
onclick: function(event) {
$('.document-list:visible').hide()
.closest('.document-add-existing').find('input.document-autocomplete').prop('disabled', false);
}
});
}); });
}(jQuery)); }(jQuery));