--- modules/poll.module.old 2005-11-13 18:53:28.000000000 -0800 +++ modules/poll.module 2005-11-13 19:35:27.000000000 -0800 @@ -133,9 +133,42 @@ function poll_form(&$node) { $node->choices *= 2; } - $output .= '
'; + $choice_element = form_textfield(t('Choice %n'), "choice][%m][chtext", NULL, 50, 127); + if ($admin) { + $choice_element .= form_textfield(t('Votes for choice %n'), "choice][%m][chvotes", 0, 7, 7); + } + // remove any newlines to avoid angering javascript + $choice_element = str_replace(array("\n", "\r"), "", $choice_element); + + $more_button = form_button(t('add choice'), NULL, 'button', array('onClick' => 'pollAddChoices();')); + $more_button = str_replace(array("\n", "\r"), "", $more_button); + + // create the necessary javascript + $output .= " + "; + $output .= '
'; + // Poll choices + $group1 .= '
'; $opts = drupal_map_assoc(range(2, $node->choices * 2 + 5)); for ($a = 0; $a < $node->choices; $a++) { $group1 .= form_textfield(t('Choice %n', array('%n' => ($a + 1))), "choice][$a][chtext", $node->choice[$a]['chtext'], 50, 127); @@ -144,7 +177,10 @@ function poll_form(&$node) { } } $group1 .= form_hidden('choices', $node->choices); + $group1 .= '
'; // end of poll choices div + $group1 .= '
'; $group1 .= form_checkbox(t('Need more choices'), 'morechoices', 1, 0, t("If the amount of boxes above isn't enough, check this box and click the Preview button below to add some more.")); + $group1 .= "
"; $output .= form_group(t('Choices'), $group1); @@ -163,6 +199,13 @@ function poll_form(&$node) { return $output; } +/* + * Implementation of hook_onload() + */ +function poll_onload() { + return array('pollOnload()'); +} + function poll_insert($node) { if (!user_access('administer nodes')) { // Make sure all votes are 0 initially