# HG changeset patch # User Franck Deroche # Date 1232969357 -3600 # Node ID b4c1e3d5d5ce60203ebbecd974684e085b7e4e79 # Parent 9372c64483117237d8fdcae0a9a7ed15f5c7797d Warn if value omitted due to lack of space diff -r 9372c6448311 -r b4c1e3d5d5ce noderef_view.js --- a/noderef_view.js Mon Jan 26 12:28:09 2009 +0100 +++ b/noderef_view.js Mon Jan 26 12:29:17 2009 +0100 @@ -1,4 +1,4 @@ -// vim: set ts=2 sw=2 expandtab syntax=php: +// vim: set ts=2 sw=2 expandtab: /** * Attach the noderef_view behavior. */ @@ -11,22 +11,37 @@ wrapper = wrapper.prev(); } + // Hide existing "No space left" message + $('div.noderef_nospace', wrapper).fadeOut(); + // Suppress behavior if it was previsously attached $(document).unbind('popups_form_success.noderef_view'); // And now bind it. This code will be executed after successful // completion of the popup select form $(document).bind('popups_form_success.noderef_view', function() { - selection = noderef_view_get_selection(); + var selection = noderef_view_get_selection(), left = []; for(nid in selection) { + count = 0; // Autocomplete field - $('input.form-autocomplete:not([value])', wrapper) + count += $('input.form-autocomplete:not([value])', wrapper) .filter(':first') - .val(selection[nid]); - // Select field - $('select', wrapper).val(nid); + .val(selection[nid]) + .length; + // Select field (exclude the weight of autocomplete fields) + count += $('select:not([id$="--weight"])', wrapper).val(nid).length; // Radio field - $('input:radio[value='+ nid + '], input:checkbox[value='+ nid +']', wrapper).attr('checked', 'checked'); + count += $('input:radio[value='+ nid + '], input:checkbox[value='+ nid +']', wrapper) + .attr('checked', 'checked') + .length; + if (count == 0) { + left.push(selection[nid]); + } + } + if (left.length) { + message = Drupal.t('No space left for value(s): @titles', + { '@titles': left.join(', ')}); + wrapper.append('
'+ message +'
'); } }); });