With Webform Javascript Field you can use custom JavaScript or jQuery snippets for your Webform form elements.

Features

  • Use custom JavaScript code for all webform components.
  • Bundle your helper functions in a custom file and load them for the entire webform.


In addition, you can use a custom Javascript file which bundles all of your helper functions. All you have to do is entering the path to your file (e.g. sites/all/libraries/Calculation/js/formatter.js) on the node edit tab. Now you can simply call the desired function on the component edit page like described above.

Project page

https://drupal.org/sandbox/aprogs/2271743

Automated report by PAReview.sh

http://pareview.sh/pareview/httpgitdrupalorgsandboxaprogs2271743git

Command to clone git repository

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/aprogs/2271743.git webform_javascript_field

Comments

aprogs’s picture

Project: » Drupal.org security advisory coverage applications
Component: Code » module
abogomolov’s picture

Status: Needs review » Needs work
$description = t('You can access this field by referencing field name %field_name in jQuery.<br />
    For example, for textfield JavaScript snippet may look like this:<br />
    jQuery("input[name=\'%field_name\']").focusout(function() {<br />
    &nbsp;&nbsp;alert(jQuery(this).val());<br />
    });', array('%field_name' => 'submitted[' . $form['form_key']['#default_value'] . ']'));

Please move the example into a replacement so translation is clean.

aprogs’s picture

Status: Needs work » Needs review

Thank you @abogomolov for reviewing.
Example was moved into a replacement.

PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

dragonmantank’s picture

I'd probably argue the point that instead of using input[name=...] that you should inject the ID of the DOM element. This is a bit cleaner than using the name selector and easier to type. It's nothing major but something to consider.

I'd also change jQuery to $ in the examples, since that's how the code is wrapped in the final output. This will ensure that the correct version of jQuery is being referenced. Inexperienced developers will add multiple versions of jQuery and things get weird if you let that scope bubble out of your code. An example of the generated code is here:

<script type="text/javascript">
<!--//--><![CDATA[//><!--
(function($) {

      Drupal.behaviors.webform_javascript_field = {

        attach: function() {
jQuery("input[name='submitted[name]']").change(function() {

alert(jQuery(this).val());

});


        }
      }
    })(jQuery)
//--><!]]>
</script>
aprogs’s picture

Hi,

thanks for paying attentions to this application.

I'd probably argue the point that instead of using input[name=...] that you should inject the ID of the DOM element. This is a bit cleaner than using the name selector and easier to type. It's nothing major but something to consider.

I'm using element's name because id of the input element can be changed after the form was submitted (e. g. default id is edit-submitted-sphere but when the form was submitted and rendered with AJAX id will be something like this edit-submitted-sphere--2).

I'd also change jQuery to $ in the examples, since that's how the code is wrapped in the final output.

Thanks for the suggestion, I added jQuery alias to the example code.
Also I noticed that context variable is omitted in the behavior, so I added it for AJAX and to meet Drupal standards.

PA robot’s picture

Multiple Applications
It appears that there have been multiple project applications opened under your username:

Project 1: https://drupal.org/node/2211003

Project 2: https://drupal.org/node/2274889

As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).

If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.

I'm a robot and this is an automated message from Project Applications Scraper.

klausi’s picture

Status: Needs review » Closed (duplicate)

Whoops, the author change of the other application triggered this. Let's continue there!

PA robot’s picture

Multiple Applications
It appears that there have been multiple project applications opened under your username:

Project 1: https://www.drupal.org/node/2211003

Project 2: https://www.drupal.org/node/2274889

As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).

If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.

I'm a robot and this is an automated message from Project Applications Scraper.

avpaderno’s picture

Related issues: +#2211003: [D7] Semantic UI