# HG changeset patch # User Franck Deroche # Date 1233053665 -3600 # Node ID 281e131cb6c3347633dfa35579b55c1440dc0512 # Parent e3f85c9247b7e248441b22d7e14be8756a3e6e00 Change location of the out-of-space warning and way to pick the wrapper Previously the warning was screwed when the user pressed the "Add more" button (the possibilites were: warning above the label which looked strange, warning below the the add more button but that would then expand to contain the whole field or warning between the textfields and the add more button but the warning would disaspear when the button was clicked). It's now conveniently placed under the "Search" link. A class is also added to the
wrapping the textfields, so we use that to find the wrapper instead of walking the DOM tree. diff -r e3f85c9247b7 -r 281e131cb6c3 noderef_view.js --- a/noderef_view.js Mon Jan 26 15:09:55 2009 +0100 +++ b/noderef_view.js Tue Jan 27 11:54:25 2009 +0100 @@ -7,13 +7,14 @@ $('.noderef_view_link', context).each(function(i, obj) { $(obj).addClass('noderef_view_link_processed').click(function() { // Get the wrapper - var wrapper = $(this).prev(); - while (!wrapper.is('div')) { - wrapper = wrapper.prev(); - } + var wrapper = $(this) + .parent() + .find('.noderef-view-items') + .filter(':first'); + var element = $(this); // Hide existing "No space left" message - $('div.noderef_nospace', wrapper).fadeOut(); + $('div.noderef_outofspace', element.parent()).fadeOut(); // Suppress behavior if it was previsously attached $(document).unbind('popups_form_success.noderef_view'); @@ -42,7 +43,11 @@ if (left.length) { message = Drupal.t('No space left for value(s): @titles', { '@titles': left.join(', ')}); - wrapper.append('
'+ message +'
'); + text = $('
'+ message + '
') + .css('display', 'inline') + .addClass('warning') + .addClass('noderef_outofspace'); + element.after(text); } }); });