### Eclipse Workspace Patch 1.0 #P Drupal Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.591 diff -u -r1.591 system.module --- modules/system/system.module 18 Feb 2008 19:19:47 -0000 1.591 +++ modules/system/system.module 19 Feb 2008 22:33:15 -0000 @@ -169,7 +169,7 @@ $type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE, '#process' => array('form_expand_ahah')); $type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE, '#process' => array('form_expand_ahah')); $type['image_button'] = array('#input' => TRUE, '#button_type' => 'submit', '#executes_submit_callback' => TRUE, '#process' => array('form_expand_ahah'), '#return_value' => TRUE, '#has_garbage_value' => TRUE, '#src' => NULL); - $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE, '#process' => array('form_expand_ahah')); + $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE, '#process' => array('form_expand_ahah'), '#example' => ''); $type['password'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#process' => array('form_expand_ahah')); $type['password_confirm'] = array('#input' => TRUE, '#process' => array('expand_password_confirm')); $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5, '#resizable' => TRUE, '#process' => array('form_expand_ahah')); Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.63 diff -u -r1.63 system.admin.inc --- modules/system/system.admin.inc 4 Feb 2008 12:35:48 -0000 1.63 +++ modules/system/system.admin.inc 19 Feb 2008 22:33:14 -0000 @@ -1142,7 +1142,8 @@ '#type' => 'textfield', '#title' => t('Slogan'), '#default_value' => variable_get('site_slogan', ''), - '#description' => t("Your site's motto, tag line, or catchphrase (often displayed alongside the title of the site).") + '#description' => t("Your site's motto, tag line, or catchphrase (often displayed alongside the title of the site)."), + '#example' => t('The place to be!') ); $form['site_mission'] = array( '#type' => 'textarea', Index: modules/system/system.css =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.css,v retrieving revision 1.48 diff -u -r1.48 system.css --- modules/system/system.css 9 Jan 2008 09:56:39 -0000 1.48 +++ modules/system/system.css 19 Feb 2008 22:33:14 -0000 @@ -150,6 +150,9 @@ margin-top: 0.4em; margin-bottom: 0.4em; } +.form-item .example { + color: #999; +} .marker, .form-required { color: #f00; } Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.267 diff -u -r1.267 form.inc --- includes/form.inc 12 Feb 2008 13:52:32 -0000 1.267 +++ includes/form.inc 19 Feb 2008 22:33:13 -0000 @@ -2002,6 +2002,16 @@ if (isset($element['#field_suffix'])) { $output .= ' '. $element['#field_suffix'] .''; } + if (!empty($element['#example'])) { + $element['#description'] .= ' '. t('Example: ') . $element['#example']; + drupal_add_js('misc/jquery.example.js', 'module', 'footer'); + drupal_add_js("$(function() { + $('#{$element['#id']}').example('{$element['#example']}', { + class_name: 'example', + }); + $('#{$element['#id']}-wrapper .description .example').hide(); + });", 'inline', 'footer'); + } return theme('form_element', $element, $output) . $extra; } Index: misc/jquery.example.js =================================================================== RCS file: misc/jquery.example.js diff -N misc/jquery.example.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ misc/jquery.example.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,17 @@ +// $Id$ + +/* + * jQuery Example Plugin 1.1 + * Populate form inputs with example text that disappears on focus. + * + * e.g. + * $('input#name').example('Bob Smith'); + * $('textarea#message').example('Type your message here', { + * class_name: 'example_text', + * hide_label: true + * }); + * + * Copyright (c) Paul Mucur (http://mucur.name), 2007-2008. + * Licensed under the BSD License (LICENSE.txt). + */ +(function(A){A.fn.example=function(E,D){var C=A.extend({},A.fn.example.defaults,D);var B=A.data(document.body,"example")||[];if(A.inArray(C.class_name,B)==-1){A(window).unload(function(){A("."+C.class_name).val("");});A(this).parents("form:first").submit(function(){A("."+C.class_name).val("");});B.push(C.class_name);A.data(document.body,"example",B);}return this.each(function(){var F=A(this);if(F.val()==""){F.addClass(C.class_name);F.val(E);}if(C.hide_label){A("label[@for="+F.attr("id")+"]").next("br").andSelf().hide();}F.focus(function(){if(A(this).hasClass(C.class_name)){A(this).val("");A(this).removeClass(C.class_name);}});F.blur(function(){if(A(this).val()==""){A(this).addClass(C.class_name);A(this).val(E);}});});};A.fn.example.defaults={class_name:"example",hide_label:false};})(jQuery);