Index: modules/book/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.module,v retrieving revision 1.415 diff -u -r1.415 book.module --- modules/book/book.module 6 Apr 2007 13:27:21 -0000 1.415 +++ modules/book/book.module 7 Apr 2007 18:55:04 -0000 @@ -232,13 +232,8 @@ '#default_value' => $node->title, '#weight' => -5, ); - $form['body_filter']['body'] = array('#type' => 'textarea', - '#title' => check_plain($type->body_label), - '#default_value' => $node->body, - '#rows' => 20, - '#required' => TRUE, - ); - $form['body_filter']['format'] = filter_form($node->format); + + $form['body_field'] = node_body_field($node, $type->body_label, 1); if (user_access('administer nodes')) { $form['weight'] = array('#type' => 'weight', Index: misc/drupal.js =================================================================== RCS file: /cvs/drupal/drupal/misc/drupal.js,v retrieving revision 1.29 diff -u -r1.29 drupal.js --- misc/drupal.js 14 Oct 2006 02:39:48 -0000 1.29 +++ misc/drupal.js 7 Apr 2007 18:55:03 -0000 @@ -200,6 +200,26 @@ return uri.indexOf('?q=') ? item : item.replace('%26', '%2526').replace('%23', '%2523'); }; +/** + * Get the text selection in a textarea. + */ +Drupal.getSelection = function (element) { + if (typeof(element.selectionStart) != 'number' && document.selection) { + // The current selection + var range1 = document.selection.createRange(); + var range2 = range1.duplicate(); + // Select all text. + range2.moveToElementText(element); + // Now move 'dummy' end point to end point of original range. + range2.setEndPoint('EndToEnd', range1); + // Now we can calculate start and end points. + var start = range2.text.length - range1.text.length; + var end = start + range1.text.length; + return { 'start': start, 'end': end }; + } + return { 'start': element.selectionStart, 'end': element.selectionEnd }; +} + // Global Killswitch on the element if (Drupal.jsEnabled) { document.documentElement.className = 'js'; Index: misc/textarea.js =================================================================== RCS file: /cvs/drupal/drupal/misc/textarea.js,v retrieving revision 1.12 diff -u -r1.12 textarea.js --- misc/textarea.js 15 Feb 2007 07:10:11 -0000 1.12 +++ misc/textarea.js 7 Apr 2007 18:55:03 -0000 @@ -7,6 +7,12 @@ $(this).wrap('
') .parent().append($('').mousedown(startDrag)); + // Inherit visibility + if ($(this).is(':hidden')) { + $(this).parent().hide(); + $(this).show(); + } + var grippie = $('div.grippie', $(this).parent())[0]; grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px'; Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.186 diff -u -r1.186 form.inc --- includes/form.inc 6 Apr 2007 13:27:20 -0000 1.186 +++ includes/form.inc 7 Apr 2007 18:55:03 -0000 @@ -1452,6 +1452,18 @@ */ function theme_textarea($element) { $class = array('form-textarea'); + + // Add teaser behaviour (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('teaserButton' => array(t('Join summary'), t('Split summary at cursor'))), 'setting'); + 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 behaviour if ($element['#resizable'] !== FALSE) { drupal_add_js('misc/textarea.js'); $class[] = 'resizable'; Index: modules/system/system.css =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.css,v retrieving revision 1.23 diff -u -r1.23 system.css --- modules/system/system.css 2 Mar 2007 09:40:13 -0000 1.23 +++ modules/system/system.css 7 Apr 2007 18:55:07 -0000 @@ -358,6 +358,31 @@ } /* +** Teaser splitter +*/ +.joined + .grippie { + height: 5px; + background-position: center 1px; + margin-bottom: -2px; +} +div.teaser-button-wrapper { + float: right; + padding-right: 5%; + margin: 0; +} +.teaser-checkbox div.form-item { + float: right; + margin: 0 5% 0 0; + padding: 0; +} +textarea.teaser { + display: none; +} +html.js .no-js { + display: none; +} + +/* ** Progressbar styles */ .progress { Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.797 diff -u -r1.797 node.module --- modules/node/node.module 6 Apr 2007 13:27:22 -0000 1.797 +++ modules/node/node.module 7 Apr 2007 18:55:06 -0000 @@ -171,6 +171,28 @@ } /** + * See if the user used JS to submit a teaser. + */ +function node_teaser_js(&$form, $form_values) { + // Glue the teaser to the body. + if (isset($form['#post']['teaser_js'])) { + if (trim($form_values['teaser_js'])) { + // Space the teaser from the body + $body = trim($form_values['teaser_js']) ."\r\n\r\n". trim($form_values['body']); + } + else { + // Empty teaser, no spaces. + $body = ''. $form_values['body']; + } + // Pass value onto preview/submit + form_set_value($form['body'], $body); + // Pass value back onto form + $form['body']['#value'] = $body; + } + return $form; +} + +/** * Automatically generate a teaser for a node body in a given format. */ function node_teaser($body, $format = NULL) { @@ -1876,7 +1898,16 @@ // Auto-generate the teaser, but only if it hasn't been set (e.g. by a // module-provided 'teaser' form item). if (!isset($node->teaser)) { - $node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : ''; + if (isset($node->body)) { + $node->teaser = node_teaser($node->body, isset($node->format) ? $node->format : NULL); + // Chop off the teaser from the body if needed. + if (!$node->teaser_include && $node->teaser == substr($node->body, 0, strlen($node->teaser))) { + $node->body = substr($node->body, strlen($node->teaser)); + } + } + else { + $node->teaser = ''; + } } if (user_access('administer nodes')) { @@ -2216,6 +2247,10 @@ // 'teaser' form item). if (!isset($node->teaser)) { $node->teaser = empty($node->body) ? '' : node_teaser($node->body, $node->format); + // Chop off the teaser from the body if needed. + if (!$node->teaser_include && $node->teaser == substr($node->body, 0, strlen($node->teaser))) { + $node->body = substr($node->body, strlen($node->teaser)); + } } // Display a preview of the node: @@ -2241,7 +2276,7 @@ function theme_node_preview($node) { $output = '