diff options
Diffstat (limited to 'modules/node')
-rw-r--r-- | modules/node/content_types.inc | 23 | ||||
-rw-r--r-- | modules/node/content_types.js | 22 |
2 files changed, 15 insertions, 30 deletions
diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc index 005603c06..7d5351e06 100644 --- a/modules/node/content_types.inc +++ b/modules/node/content_types.inc @@ -58,7 +58,6 @@ function theme_node_admin_overview($name, $type) { * Generates the node type editing form. */ function node_type_form(&$form_state, $type = NULL) { - drupal_add_js(drupal_get_path('module', 'node') . '/content_types.js'); if (!isset($type->type)) { // This is a new type. Node module managed types are custom and unlocked. $type = node_type_set_defaults(array('custom' => 1, 'locked' => 0)); @@ -78,10 +77,23 @@ function node_type_form(&$form_state, $type = NULL) { '#description' => t('The human-readable name of this content type. This text will be displayed as part of the list on the <em>add new content</em> page. It is recommended that this name begin with a capital letter and contain only letters, numbers, and <strong>spaces</strong>. This name must be unique.'), '#required' => TRUE, '#size' => 30, - '#field_suffix' => ' <small id="node-type-name-suffix"> </small>', + '#field_suffix' => ' <small id="edit-name-suffix">' . ($type->locked ? t('Machine name: @name', array('@name' => $type->type)) : ' ') . '</small>', ); if (!$type->locked) { + $js_settings = array( + 'type' => 'setting', + 'data' => array( + 'machineReadableValue' => array( + 'name' => array( + 'text' => t('Machine name'), + 'target' => 'type', + 'searchPattern' => '[^a-z0-9]+', + 'replaceToken' => '_', + ), + ), + ), + ); $form['identity']['type'] = array( '#title' => t('Machine name'), '#type' => 'textfield', @@ -89,6 +101,7 @@ function node_type_form(&$form_state, $type = NULL) { '#maxlength' => 32, '#required' => TRUE, '#description' => t('The machine-readable name of this content type. This text will be used for constructing the URL of the <em>add new content</em> page for this content type. This name must contain only lowercase letters, numbers, and underscores. Underscores will be converted into hyphens when constructing the URL of the <em>add new content</em> page. This name must be unique.'), + '#attached_js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings), ); } else { @@ -96,12 +109,6 @@ function node_type_form(&$form_state, $type = NULL) { '#type' => 'value', '#value' => $type->type, ); - $form['identity']['type_display'] = array( - '#title' => t('Machine name'), - '#type' => 'item', - '#markup' => theme('placeholder', $type->type), - '#description' => t('The machine-readable name of this content type. This field cannot be modified for system-defined content types.'), - ); } $form['identity']['description'] = array( diff --git a/modules/node/content_types.js b/modules/node/content_types.js index 98a0baed1..8ff713ba9 100644 --- a/modules/node/content_types.js +++ b/modules/node/content_types.js @@ -30,28 +30,6 @@ Drupal.behaviors.contentTypes = { } return vals.join(', '); }); - - // Process the machine name. - if ($('#edit-type').val() == $('#edit-name').val().toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/_+/g, '_') || $('#edit-type').val() == '') { - $('.form-item.type-wrapper').hide(); - $('#edit-name').keyup(function () { - var machine = $(this).val().toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/_+/g, '_'); - if (machine != '_' && machine != '') { - $('#edit-type').val(machine); - $('#node-type-name-suffix').empty().append(' Machine name: ' + machine + ' [').append($('<a href="#">' + Drupal.t('Edit') + '</a>').click(function () { - $('.form-item-textfield.type-wrapper').show(); - $('#node-type-name-suffix').hide(); - $('#edit-name').unbind('keyup'); - return false; - })).append(']'); - } - else { - $('#edit-type').val(machine); - $('#node-type-name-suffix').text(''); - } - }); - $('#edit-name').keyup(); - } } }; |