### Eclipse Workspace Patch 1.0 #P d7 Index: modules/menu/menu.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.admin.inc,v retrieving revision 1.51 diff -u -r1.51 menu.admin.inc --- modules/menu/menu.admin.inc 27 Jun 2009 23:49:19 -0000 1.51 +++ modules/menu/menu.admin.inc 28 Jun 2009 14:38:10 -0000 @@ -414,13 +414,16 @@ ); } 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', '#title' => t('Menu name'), '#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.'), + '#description' => t('This text will be used to construct the URL for this menu. This name must contain only lowercase letters, numbers and hyphens, and must be unique.'), '#required' => TRUE, + '#weight' => 1, ); $form['#insert'] = TRUE; } @@ -437,16 +440,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(' URL Path: ' + 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);