in bmi.module .

For starters, all strings in output should be enclosed in a t("") for translation.

That's not the case in lines 66 and 82.

    '#title' => 'Units', 

Should be

    '#title' => t("Units"), 

And in line 119, where it reads

    $output = "Your BMI value is <b>". $bmi ."</b>";
    $output .= "<br>". $bmi_text;

Should be

    $output = t("Your BMI value is");
    $output .= " <b>". $bmi ."</b><br>". $bmi_text;

And that's that for translation issues.

I guess that after the form button there should be some markup with style="clear:both"

You did it like this at line 102:

    '#suffix' => '</div>',

i've done

    '#suffix' => '</div><br style="clear:both">',

Next, if you input the data and hit enter while on the textfield, it goes awfully wrong, redirecting you to a non-related page and clearing out the input.

I've solved this by adding some js in line 58, so it reads like

    '#required' => TRUE,
    '#attributes' => array(
      'onkeypress' => ' var key;if(window.event) key = window.event.keyCode; else key = e.which; if(key == 13) return false; else return true; '
    ),
    '#prefix' => '<div style="float:left;">',

and at line 76

    '#required' => TRUE,
    '#attributes' => array(
      'onkeypress' => ' var key;if(window.event) key = window.event.keyCode; else key = e.which; if(key == 13) return false; else return true; '
    ),
    '#prefix' => '<div style="float:left;">',

It catches the enter key on textfield and blocks it, so the form don't get submitted.

And finally, added some js at line 93 to clear the message if 'Calculate' gets hit again.

    '#attributes' => array(
      'onmouseup' => ' document.getElementById("bmi_calculate_wrapper").firstChild.innerHTML = ""; '
    ),

I've included a file with the full module plus the modifications i've made.

Best wishes

CommentFileSizeAuthor
#4 bmi.patch954 bytesasifnoor
bmi.zip9.34 KBHLopes
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

HLopes’s picture

Also, there seems to be an issue with drupal's cache system. ( but hey, what doesn't have issues with that? )

The block should have cache disabled, i am currently testing it after i've changed value of block cache in 'blocks' table to -1, and seems to be ok.

pflame’s picture

committed code related to t() functions. Regarding javascript code, i could not reproduce the bug you mentioned in google chrome and firefox.

HLopes’s picture

Hi there,

to replicate just install the "Energetic" theme

http://drupal.org/project/energetic

and press enter while inserting your height.

It also happened with a theme developed by template-help.com.

asifnoor’s picture

FileSize
954 bytes

A patch with few more translation issues fixed.

asifnoor’s picture

Status: Active » Closed (fixed)