Index: modules/menu/menu.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.admin.inc,v retrieving revision 1.49 diff -u -r1.49 menu.admin.inc --- modules/menu/menu.admin.inc 7 Jun 2009 02:30:13 -0000 1.49 +++ modules/menu/menu.admin.inc 27 Jun 2009 13:40:29 -0000 @@ -413,6 +413,8 @@ ); } else { + drupal_add_js( 'misc/auto_machine_readable.js'); + drupal_add_js(array( 'autoMachineReadable' => array('title' => 'menu-name')), 'setting'); $menu = array('menu_name' => '', 'title' => '', 'description' => ''); $form['menu_name'] = array( '#type' => 'textfield', @@ -420,6 +422,7 @@ '#maxsize' => MENU_MAX_MENU_NAME_LENGTH_UI, '#description' => t('The machine-readable name of this menu. This text will be used for constructing the URL of the menu overview page for this menu. This name must contain only lowercase letters, numbers, and hyphens, and must be unique.'), '#required' => TRUE, + '#weight' => 1, ); $form['#insert'] = TRUE; } @@ -436,16 +439,20 @@ '#title' => t('Title'), '#default_value' => $menu['title'], '#required' => TRUE, + '#field_suffix' => '  ', + '#weight' => 0, ); } $form['description'] = array( '#type' => 'textarea', '#title' => t('Description'), '#default_value' => $menu['description'], + '#weight' => 2, ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), + '#weight' => 3, ); return $form; Index: misc/auto_machine_readable.js =================================================================== RCS file: misc/auto_machine_readable.js diff -N misc/auto_machine_readable.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ misc/auto_machine_readable.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,36 @@ +// $Id$ +(function ($) { + +Drupal.behaviors.autoMachineReadable = { + attach: function () { + var autoMRS = Drupal.settings.autoMachineReadable; + for(var autoMR in autoMRS) { + var source = '#edit-' + autoMR; + var suffix = '#edit-' + autoMR + '-suffix'; + var target = '#edit-' + autoMRS[autoMR]; + var wrapper = '#edit-' + autoMRS[autoMR] + '-wrapper'; + if ($(target).val() == $(source).val().toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/_+/g, '_') || $(target).val() == '') { + $(wrapper).hide(); + $(source).keyup(function () { + var machine = $(this).val().toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/_+/g, '_'); + if (machine != '_' && machine != '') { + $(target).val(machine); + $(suffix).empty().append(' Machine name: ' + machine + ' [').append($('' + Drupal.t('Edit') + '').click(function () { + $(wrapper).show(); + $(suffix).hide(); + $(source).unbind('keyup'); + return false; + })).append(']'); + } + else { + $(target).val(machine); + $(suffix).text(''); + } + }); + $(source).keyup(); + } + } + } +}; + +})(jQuery);