diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2007-01-07 08:20:31 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2007-01-07 08:20:31 +0000 |
commit | 90b00a688fef440d364c3384f7453b29b152665b (patch) | |
tree | 16236f61d894329229b1195a4861c89333096834 /misc | |
parent | f80f7a7dbd78c68ca38bc6279c942db053f62a89 (diff) | |
download | brdo-90b00a688fef440d364c3384f7453b29b152665b.tar.gz brdo-90b00a688fef440d364c3384f7453b29b152665b.tar.bz2 |
#80085: Don't show user picture form on registration pages (chx / webchick)
Diffstat (limited to 'misc')
-rw-r--r-- | misc/teaser.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/misc/teaser.js b/misc/teaser.js new file mode 100644 index 000000000..0f4340d59 --- /dev/null +++ b/misc/teaser.js @@ -0,0 +1,73 @@ +// $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); +} |