### Eclipse Workspace Patch 1.0 #P drupal_test_7 Index: misc/teaser.js =================================================================== RCS file: misc/teaser.js diff -N misc/teaser.js --- misc/teaser.js 17 May 2009 08:26:42 -0000 1.20 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,96 +0,0 @@ -// $Id: teaser.js,v 1.20 2009/05/17 08:26:42 dries Exp $ -(function ($) { - -/** - * Auto-attach for teaser behavior. - * - * Note: depends on resizable textareas. - */ -Drupal.behaviors.teaser = { - attach: function (context, settings) { - $('textarea.teaser:not(.teaser-processed)', context).each(function () { - var teaser = $(this).addClass('teaser-processed'); - - // Move teaser textarea before body, and remove its form-item wrapper. - var body = $('#' + settings.teaser[this.id]); - var checkbox = $('#' + settings.teaserCheckbox[this.id]).parent(); - var checked = $(checkbox).children('input').attr('checked') ? true : false; - var parent = teaser[0].parentNode; - $(body).before(teaser); - $(parent).remove(); - - function trim(text) { - return text.replace(/^\s+/g, '').replace(/\s+$/g, ''); - } - - // Join the teaser back to the body. - function join_teaser() { - if (teaser.val()) { - body.val(trim(teaser.val()) + '\r\n\r\n' + trim(body.val())); - } - // Empty, hide and disable teaser. - teaser[0].value = ''; - $(teaser).attr('disabled', 'disabled'); - $(teaser).parent().slideUp('fast'); - // Change label. - $(this).val(Drupal.t('Split summary at cursor')); - // Hide separate teaser checkbox. - $(checkbox).hide(); - // Force a hidden checkbox to be checked (to ensure that the body is - // correctly processed on form submit when teaser/body are in joined - // state), and remember the current checked status. - checked = $(checkbox).children('input').attr('checked') ? true : false; - $(checkbox).children('input').attr('checked', true); - } - - // Split the teaser from the body. - function split_teaser() { - body[0].focus(); - var selection = Drupal.getSelection(body[0]); - var split = selection.start; - var text = body.val(); - - // Note: using val() fails sometimes. jQuery bug? - teaser[0].value = trim(text.slice(0, split)); - body[0].value = trim(text.slice(split)); - // Reveal and enable teaser. - $(teaser).attr('disabled', ''); - $(teaser).parent().slideDown('fast'); - // Change label. - $(this).val(Drupal.t('Join summary')); - // Show separate teaser checkbox, restore checked value. - $(checkbox).show().children('input').attr('checked', checked); - } - - // Add split/join button. - var button = $('
'); - var include = $('#' + this.id.substring(0, this.id.length - 2) + 'include'); - $(include).parent().parent().before(button); - - // Extract the teaser from the body, if set. Otherwise, stay in joined mode. - var text = body.val().split(''); - if (text.length >= 2) { - teaser[0].value = trim(text.shift()); - body[0].value = trim(text.join('')); - $(teaser).attr('disabled', ''); - $('input', button).val(Drupal.t('Join summary')).toggle(join_teaser, split_teaser); - } - else { - $('input', button).val(Drupal.t('Split summary at cursor')).toggle(split_teaser, join_teaser); - $(checkbox).hide().children('input').attr('checked', true); - } - - // Make sure that textarea.js has done its magic to ensure proper visibility state. - if (Drupal.behaviors.textarea && teaser.is(('.form-textarea:not(.textarea-processed)'))) { - Drupal.behaviors.textarea.attach(teaser.parentNode); - } - // Set initial visibility. - if (teaser[0].disabled) { - teaser.parent().hide(); - } - - }); - } -}; - -})(jQuery); Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.340 diff -u -r1.340 form.inc --- includes/form.inc 14 Jun 2009 08:04:25 -0000 1.340 +++ includes/form.inc 14 Jun 2009 21:53:33 -0000 @@ -2498,15 +2498,6 @@ function theme_textarea($element) { $class = array('form-textarea'); - // Add teaser behavior (must come before resizable) - if (!empty($element['#teaser'])) { - drupal_add_js('misc/teaser.js'); - // Note: arrays are merged in drupal_get_js(). - drupal_add_js(array('teaserCheckbox' => array($element['#id'] => $element['#teaser_checkbox'])), 'setting'); - drupal_add_js(array('teaser' => array($element['#id'] => $element['#teaser'])), 'setting'); - $class[] = 'teaser'; - } - // Add resizable behavior if ($element['#resizable'] !== FALSE) { drupal_add_js('misc/textarea.js');