Commit 90b00a68 authored by Steven Wittens's avatar Steven Wittens
Browse files

#80085: Don't show user picture form on registration pages (chx / webchick)

parent f80f7a7d
// $Id$
/**
* Auto-attach for teaser behaviour.
*
* Note: depends on resizable textareas.
*/
Drupal.teaserAttach = function() {
$('textarea.teaser:not(.joined)').each(function() {
var teaser = $(this).addClass('joined');
// Move teaser textarea before body, and remove its form-item wrapper.
var body = $('#'+ Drupal.settings.teaser[this.id]);
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()));
}
// Hide and disable teaser
$(teaser).attr('disabled', 'disabled');
$(teaser).parent().slideUp('fast');
// Change label
$(this).val(Drupal.settings.teaserButton[1]);
}
// 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.settings.teaserButton[0]);
}
// Add split/join button.
var button = $('<input type="button" class="teaser-button" />')
.prependTo($(this).parent())
// Extract the teaser from the body, if set. Otherwise, stay in joined mode.
var text = body.val().split('<!--break-->', 2);
if (text.length == 2) {
teaser[0].value = trim(text[0]);
body[0].value = trim(text[1]);
$(teaser).attr('disabled', '');
$(button).val(Drupal.settings.teaserButton[0]).toggle(join_teaser, split_teaser);
}
else {
$(teaser).hide();
$(button).val(Drupal.settings.teaserButton[1]).toggle(split_teaser, join_teaser);
}
});
}
if (Drupal.jsEnabled) {
$(document).ready(Drupal.teaserAttach);
}
......@@ -138,6 +138,28 @@ function node_mark($nid, $timestamp) {
return MARK_READ;
}
/**
* 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<!--break-->\r\n". trim($form_values['body']);
}
else {
// Empty teaser, no spaces.
$body = '<!--break-->'. $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.
*/
......@@ -2199,7 +2221,7 @@ function node_preview($node) {
function theme_node_preview($node) {
$output = '<div class="preview">';
if ($node->teaser && $node->teaser != $node->body) {
drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication. You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.'));
drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication.<span class="no-js"> You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.</span>'));
$output .= '<h3>'. t('Preview trimmed version') .'</h3>';
$output .= node_view(drupal_clone($node), 1, FALSE, 0);
$output .= '<h3>'. t('Preview full version') .'</h3>';
......@@ -2931,13 +2953,23 @@ function node_content_form($node) {
}
if ($type->has_body) {
$form['body_filter']['body'] = array(
$form['body_field'] = array(
'#after_build' => array('node_teaser_js'));
$form['body_field']['teaser_js'] = array(
'#type' => 'textarea',
'#rows' => 10,
'#teaser' => 'edit-body',
'#disabled' => TRUE);
$form['body_field']['body'] = array(
'#type' => 'textarea',
'#title' => check_plain($type->body_label),
'#default_value' => $node->body,
'#rows' => 20,
'#required' => ($type->min_word_count > 0));
$form['body_filter']['format'] = filter_form($node->format);
$form['body_field']['format'] = filter_form($node->format);
}
return $form;
......
......@@ -1333,7 +1333,7 @@ function user_edit_form($uid, $edit, $register = FALSE) {
}
// Picture/avatar:
if (variable_get('user_pictures', 0)) {
if (variable_get('user_pictures', 0) && !$register) {
$form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1);
$picture = theme('user_picture', (object)$edit);
if ($picture) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment